48 if ((*length >> 24) || *length < 16)
64 static const uint8_t startcode[] = {0, 0, 0, 0, 1, 0xbc};
65 static const uint8_t endcode[] = {0, 0, 0, 0, 0xe1, 0xe2};
66 if (!memcmp(p->
buf, startcode,
sizeof(startcode)) &&
67 !memcmp(&p->
buf[16 -
sizeof(endcode)], endcode,
sizeof(endcode)))
189 if (fps < 1 || fps > 9) fps = 9;
190 return avpriv_frame_rate_tab[9 - fps];
199 static const AVRational map[] = {{50, 1}, {60000, 1001}, {24, 1},
200 {25, 1}, {30000, 1001}};
201 int idx = av_log2((flags & 0x7c0) >> 6);
224 else if (tag ==
TRACK_FPF && (value == 1 || value == 2))
245 if (map_cnt > 1000) {
249 if (pkt_len < 4 * map_cnt) {
254 pkt_len -= 4 * map_cnt;
256 for (i = 0; i < map_cnt; i++)
258 i * (uint64_t)fields_per_map + 1, 0, 0, 0);
296 int track_type, track_id, track_len;
306 if (!(track_type & 0x80)) {
311 if ((track_id & 0xc0) != 0xc0) {
317 if (idx < 0)
continue;
319 if (!main_timebase.
num || !main_timebase.
den) {
349 if (!main_timebase.
num || !main_timebase.
den) {
351 main_timebase.
num = fps.
den;
352 main_timebase.
den = fps.
num * 2;
361 if (!main_timebase.
num || !main_timebase.
den)
372 if (!max_interval-- || pb->eof_reached) \
374 tmp = tmp << 8 | avio_r8(pb); \
387 uint64_t last_found_pos = 0;
404 if (
avio_seek(pb, last_pos, SEEK_SET) < 0)
412 if ((track >= 0 && track != cur_track) || (timestamp >= 0 && timestamp > cur_timestamp)) {
413 if (
avio_seek(pb, last_pos, SEEK_SET) >= 0)
419 return cur_timestamp;
430 int track_type, track_id, ret;
431 int field_nr, field_info, skip = 0;
453 stream_index =
get_sindex(s, track_id, track_type);
454 if (stream_index < 0)
464 int first = field_info >> 16;
465 int last = field_info & 0xffff;
467 if (first <= last && last*bps <= pkt_len) {
469 skip = pkt_len - last*
bps;
470 pkt_len = (last-first)*bps;
492 uint64_t maxlen = 100 * 1024 * 1024;
497 if (timestamp < start_time) timestamp =
start_time;
503 if (idx < st->nb_index_entries - 2)
505 maxlen =
FFMAX(maxlen, 200 * 1024);
510 if (
FFABS(found - timestamp) > 4)
516 int64_t *pos, int64_t pos_limit) {
static int gxf_packet(AVFormatContext *s, AVPacket *pkt)
static void gxf_track_tags(AVIOContext *pb, int *len, struct gxf_stream_info *si)
filters out interesting tags from track information.
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
static void gxf_material_tags(AVIOContext *pb, int *len, struct gxf_stream_info *si)
filters out interesting tags from material information.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
const AVRational avpriv_frame_rate_tab[16]
static void gxf_read_index(AVFormatContext *s, int pkt_len)
read index from FLT packet into stream 0 av_index
unsigned int avio_rb16(AVIOContext *s)
static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
Opaque data information usually continuous.
unsigned int avio_rb32(AVIOContext *s)
enum AVStreamParseType need_parsing
int id
format-specific stream ID
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
int av_get_bits_per_sample(enum CodecID codec_id)
Return codec bits per sample.
static int gxf_header(AVFormatContext *s, AVFormatParameters *ap)
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static int parse_packet_header(AVIOContext *pb, GXFPktType *type, int *length)
parses a packet header, extracting type and length
preferred ID for MPEG-1/2 video decoding
static AVRational fps_umf2avr(uint32_t flags)
convert UMF attributes flags to AVRational fps
static int64_t start_time
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
unsigned int avio_rl32(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
AVInputFormat ff_gxf_demuxer
void av_log(void *avcl, int level, const char *fmt,...)
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
int avio_r8(AVIOContext *s)
AVCodecContext * codec
codec context
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
unsigned int nb_streams
A list of all streams in the file.
struct AVRational AVRational
rational number numerator/denominator
int bit_rate
the average bitrate
static AVRational fps_tag2avr(int32_t fps)
convert fps tag value to AVRational fps
static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static int get_sindex(AVFormatContext *s, int id, int format)
gets the stream index for the track with the specified id, creates new stream if not found ...
Usually treated as AVMEDIA_TYPE_DATA.
enum AVMediaType codec_type
int sample_rate
samples per second
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
rational number numerator/denominator
This structure contains the data a format has to probe a file.
int64_t duration
Decoding: duration of the stream, in stream time base.
AVRational frames_per_second
common internal and external API header
static int64_t gxf_resync_media(AVFormatContext *s, uint64_t max_interval, int track, int timestamp)
resync the stream on the next media packet with specified properties
int64_t start_time
Decoding: pts of the first frame of the stream, in stream time base.
static int64_t gxf_read_timestamp(AVFormatContext *s, int stream_index, int64_t *pos, int64_t pos_limit)
static int gxf_probe(AVProbeData *p)
check if file starts with a PKT_MAP header
int eof_reached
true if eof reached
int channels
number of audio channels
void * priv_data
Format private data.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
#define AV_NOPTS_VALUE
Undefined timestamp value.