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;
55 snprintf(tmp,
sizeof(tmp),
"%02d:%02d:%02d%c%02d",
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)))
237 if (fps < 1 || fps > 9) fps = 9;
238 return frame_rate_tab[fps - 1];
247 static const AVRational map[] = {{50, 1}, {60000, 1001}, {24, 1},
248 {25, 1}, {30000, 1001}};
249 int idx =
av_log2((flags & 0x7c0) >> 6);
273 else if (tag ==
TRACK_FPF && (value == 1 || value == 2))
275 }
else if (tlen == 8 && tag ==
TRACK_AUX)
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;
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)
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)
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;
573 if (timestamp < start_time) timestamp =
start_time;
579 if (idx < st->internal->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 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.
#define AV_LOG_WARNING
Something somehow does not look correct.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
#define AV_CH_LAYOUT_STEREO
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)
static int64_t start_time
Opaque data information usually continuous.
unsigned int avio_rb32(AVIOContext *s)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
enum AVStreamParseType need_parsing
int id
Format-specific stream ID.
GLsizei GLboolean const GLfloat * value
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But first
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
int flags
Flags modifying the (de)muxer behaviour.
#define AVERROR_EOF
End of file.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
uint64_t channel_layout
Audio only.
static int parse_packet_header(AVIOContext *pb, GXFPktType *type, int *length)
parses a packet header, extracting type and length
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
static AVRational fps_umf2avr(uint32_t flags)
convert UMF attributes flags to AVRational fps
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
AVDictionary * metadata
Metadata that applies to the whole file.
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)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this field
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
AVInputFormat ff_gxf_demuxer
enum AVMediaType codec_type
General type of the encoded data.
int avio_r8(AVIOContext *s)
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int block_align
Audio only.
audio channel layout utility functions
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 AVRational fps_tag2avr(int32_t fps)
convert fps tag value to AVRational fps
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 ...
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Usually treated as AVMEDIA_TYPE_DATA.
preferred ID for MPEG-1/2 video decoding
#define AV_LOG_INFO
Standard information.
AVStreamInternal * internal
An opaque field for libavformat internal usage.
AVIOContext * pb
I/O context.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
static int gxf_probe(const AVProbeData *p)
check if file starts with a PKT_MAP header
Rational number (pair of numerator and denominator).
const VDPAUPixFmtMap * map
This structure contains the data a format has to probe a file.
#define flags(name, subs,...)
static int gxf_header(AVFormatContext *s)
static const AVRational frame_rate_tab[]
int64_t duration
Decoding: duration of the stream, in stream time base.
int sample_rate
Audio only.
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 presentation order, in stream time base...
static int64_t gxf_read_timestamp(AVFormatContext *s, int stream_index, int64_t *pos, int64_t pos_limit)
int eof_reached
true if was unable to read due to error or eof
void * priv_data
Format private data.
int bits_per_coded_sample
The number of bits per sample in the codedwords.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
#define AV_CH_LAYOUT_MONO
This structure stores compressed data.
uint64_t avio_rl64(AVIOContext *s)
#define AV_NOPTS_VALUE
Undefined timestamp value.