45 int field = timecode & 0xff;
46 int frame = fields_per_frame ? field / fields_per_frame : field;
47 int second = (timecode >> 8) & 0xff;
48 int minute = (timecode >> 16) & 0xff;
49 int hour = (timecode >> 24) & 0x1f;
50 int drop = (timecode >> 29) & 1;
56 hour, minute, second, drop ?
';' :
':',
frame);
74 if ((*length >> 24) || *length < 16)
90 static const uint8_t startcode[] = {0, 0, 0, 0, 1, 0xbc};
91 static const uint8_t endcode[] = {0, 0, 0, 0, 0xe1, 0xe2};
92 if (!memcmp(p->
buf, startcode,
sizeof(startcode)) &&
93 !memcmp(&p->
buf[16 -
sizeof(endcode)], endcode,
sizeof(endcode)))
190 return s->nb_streams - 1;
237 if (fps < 1 || fps > 9) fps = 9;
247 static const AVRational map[] = {{50, 1}, {60000, 1001}, {24, 1},
248 {25, 1}, {30000, 1001}};
288 uint32_t fields_per_map, map_cnt;
300 if (map_cnt > 1000) {
302 "too many index entries %"PRIu32
" (%"PRIx32
")\n",
306 if (pkt_len < 4 * map_cnt) {
311 pkt_len -= 4 * map_cnt;
313 for (
i = 0;
i < map_cnt;
i++)
315 i * (uint64_t)fields_per_map + 1, 0, 0, 0);
353 int track_type, track_id, track_len;
361 if (!(track_type & 0x80)) {
366 if ((track_id & 0xc0) != 0xc0) {
373 if (track_type == 7 || track_type == 8 || track_type == 24) {
382 if (idx < 0)
continue;
383 st =
s->streams[idx];
384 if (!main_timebase.
num || !main_timebase.
den) {
414 if (!main_timebase.
num || !main_timebase.
den) {
416 " This might give wrong results.\n");
418 main_timebase.
num = fps.
den;
419 main_timebase.
den = fps.
num * 2;
437 if (!main_timebase.
num || !main_timebase.
den)
439 for (
i = 0;
i <
s->nb_streams;
i++) {
448 if (!max_interval-- || avio_feof(pb)) \
450 tmp = tmp << 8 | avio_r8(pb); \
463 uint64_t last_found_pos = 0;
480 if (
avio_seek(pb, last_pos, SEEK_SET) < 0)
488 if ((track >= 0 && track != cur_track) || (timestamp >= 0 && timestamp > cur_timestamp)) {
489 if (
avio_seek(pb, last_pos, SEEK_SET) >= 0)
495 return cur_timestamp;
506 int track_type, track_id, ret;
507 int field_nr, field_info, skip = 0;
529 stream_index =
get_sindex(
s, track_id, track_type);
530 if (stream_index < 0)
532 st =
s->streams[stream_index];
540 int first = field_info >> 16;
541 int last = field_info & 0xffff;
543 if (first <= last && last*
bps <= pkt_len) {
545 skip = pkt_len - last*
bps;
546 pkt_len = (last-first)*
bps;
568 uint64_t maxlen = 100 * 1024 * 1024;
570 int64_t
start_time =
s->streams[stream_index]->start_time;
579 if (idx < st->nb_index_entries - 2)
581 maxlen =
FFMAX(maxlen, 200 * 1024);
586 if (
FFABS(found - timestamp) > 4)
592 int64_t *
pos, int64_t pos_limit) {
static const char *const format[]
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
unsigned int avio_rb16(AVIOContext *s)
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
unsigned int avio_rl32(AVIOContext *s)
unsigned int avio_rb32(AVIOContext *s)
int avio_r8(AVIOContext *s)
uint64_t avio_rl64(AVIOContext *s)
#define flags(name, subs,...)
audio channel layout utility functions
common internal and external API header
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static int64_t start_time
#define AV_CH_LAYOUT_MONO
#define AV_CH_LAYOUT_STEREO
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
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.
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AVERROR_EOF
End of file.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
#define AV_NOPTS_VALUE
Undefined timestamp value.
static const AVRational frame_rate_tab[]
static int gxf_probe(const AVProbeData *p)
check if file starts with a PKT_MAP header
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
static AVRational fps_umf2avr(uint32_t flags)
convert UMF attributes flags to AVRational fps
static void gxf_material_tags(AVIOContext *pb, int *len, struct gxf_stream_info *si)
filters out interesting tags from material information.
static int add_timecode_metadata(AVDictionary **pm, const char *key, uint32_t timecode, int fields_per_frame)
parse gxf timecode and add it to metadata
static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
static int parse_packet_header(AVIOContext *pb, GXFPktType *type, int *length)
parses a packet header, extracting type and length
static int gxf_packet(AVFormatContext *s, AVPacket *pkt)
static int gxf_header(AVFormatContext *s)
static AVRational fps_tag2avr(int32_t fps)
convert fps tag value to AVRational fps
AVInputFormat ff_gxf_demuxer
static int64_t gxf_read_timestamp(AVFormatContext *s, int stream_index, int64_t *pos, int64_t pos_limit)
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
static void gxf_read_index(AVFormatContext *s, int pkt_len)
read index from FLT packet into stream 0 av_index
static void gxf_track_tags(AVIOContext *pb, int *len, struct gxf_stream_info *si)
filters out interesting tags from track information.
const VDPAUPixFmtMap * map
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
uint64_t channel_layout
Audio only.
int bits_per_coded_sample
The number of bits per sample in the codedwords.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
enum AVMediaType codec_type
General type of the encoded data.
int block_align
Audio only.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
Audio only.
int eof_reached
true if was unable to read due to error or eof
This structure stores compressed data.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
This structure contains the data a format has to probe a file.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Rational number (pair of numerator and denominator).
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int64_t duration
Decoding: duration of the stream, in stream time base.
int id
Format-specific stream ID.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
enum AVStreamParseType need_parsing
AVRational frames_per_second