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)))
189 return s->nb_streams - 1;
236 if (fps < 1 || fps > 9) fps = 9;
246 static const AVRational map[] = {{50, 1}, {60000, 1001}, {24, 1},
247 {25, 1}, {30000, 1001}};
287 uint32_t fields_per_map, map_cnt;
299 if (map_cnt > 1000) {
301 "too many index entries %"PRIu32
" (%"PRIx32
")\n",
305 if (pkt_len < 4 * map_cnt) {
310 pkt_len -= 4 * map_cnt;
312 for (
i = 0;
i < map_cnt;
i++)
314 i * (uint64_t)fields_per_map + 1, 0, 0, 0);
352 int track_type, track_id, track_len;
360 if (!(track_type & 0x80)) {
365 if ((track_id & 0xc0) != 0xc0) {
372 if (track_type == 7 || track_type == 8 || track_type == 24) {
381 if (idx < 0)
continue;
382 st =
s->streams[idx];
383 if (!main_timebase.
num || !main_timebase.
den) {
413 if (!main_timebase.
num || !main_timebase.
den) {
415 " This might give wrong results.\n");
417 main_timebase.
num = fps.
den;
418 main_timebase.
den = fps.
num * 2;
436 if (!main_timebase.
num || !main_timebase.
den)
438 for (
i = 0;
i <
s->nb_streams;
i++) {
447 if (!max_interval-- || avio_feof(pb)) \
449 tmp = tmp << 8 | avio_r8(pb); \
462 uint64_t last_found_pos = 0;
479 if (
avio_seek(pb, last_pos, SEEK_SET) < 0)
487 if ((track >= 0 && track != cur_track) || (timestamp >= 0 && timestamp > cur_timestamp)) {
488 if (
avio_seek(pb, last_pos, SEEK_SET) >= 0)
494 return cur_timestamp;
505 int track_type, track_id, ret;
506 int field_nr, field_info,
skip = 0;
528 stream_index =
get_sindex(
s, track_id, track_type);
529 if (stream_index < 0)
531 st =
s->streams[stream_index];
539 int first = field_info >> 16;
540 int last = field_info & 0xffff;
542 if (first <= last && last*
bps <= pkt_len) {
545 pkt_len = (last-first)*
bps;
552 pkt->stream_index = stream_index;
567 uint64_t maxlen = 100 * 1024 * 1024;
579 if (idx < sti->nb_index_entries - 2)
581 maxlen =
FFMAX(maxlen, 200 * 1024);
586 if (
FFABS(found - timestamp) > 4)
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)
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
Public libavutil channel layout APIs header.
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 ...
int ff_find_stream_index(const AVFormatContext *s, int id)
Find stream index based on format-specific stream ID.
static int64_t start_time
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
AVStream * avformat_new_stream(AVFormatContext *s, const struct 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.
#define AV_CHANNEL_LAYOUT_STEREO
#define AV_CHANNEL_LAYOUT_MONO
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_INVALIDDATA
Invalid data found when processing input.
#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
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
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
An AVChannelLayout holds information about the channel layout of audio data.
int bits_per_coded_sample
The number of bits per sample in the codedwords.
AVChannelLayout ch_layout
The channel layout and number of channels.
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
The number of bytes per coded audio frame, required by some formats.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
int eof_reached
true if was unable to read due to error or eof
This structure stores compressed data.
This structure contains the data a format has to probe a file.
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