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)
297 if (map_cnt > 1000) {
299 "too many index entries %"PRIu32
" (%"PRIx32
")\n",
303 if (pkt_len < 4 * map_cnt) {
308 pkt_len -= 4 * map_cnt;
310 for (i = 0; i < map_cnt; i++)
312 i * (uint64_t)fields_per_map + 1, 0, 0, 0);
350 int track_type, track_id, track_len;
358 if (!(track_type & 0x80)) {
363 if ((track_id & 0xc0) != 0xc0) {
370 if (track_type == 7 || track_type == 8 || track_type == 24) {
379 if (idx < 0)
continue;
381 if (!main_timebase.
num || !main_timebase.
den) {
411 if (!main_timebase.
num || !main_timebase.
den) {
413 " This might give wrong results.\n");
415 main_timebase.
num = fps.
den;
416 main_timebase.
den = fps.
num * 2;
434 if (!main_timebase.
num || !main_timebase.
den)
445 if (!max_interval-- || avio_feof(pb)) \
447 tmp = tmp << 8 | avio_r8(pb); \
460 uint64_t last_found_pos = 0;
477 if (
avio_seek(pb, last_pos, SEEK_SET) < 0)
485 if ((track >= 0 && track != cur_track) || (timestamp >= 0 && timestamp > cur_timestamp)) {
486 if (
avio_seek(pb, last_pos, SEEK_SET) >= 0)
492 return cur_timestamp;
503 int track_type, track_id, ret;
504 int field_nr, field_info, skip = 0;
526 stream_index =
get_sindex(s, track_id, track_type);
527 if (stream_index < 0)
537 int first = field_info >> 16;
538 int last = field_info & 0xffff;
540 if (first <= last && last*bps <= pkt_len) {
542 skip = pkt_len - last*
bps;
543 pkt_len = (last-first)*bps;
565 uint64_t maxlen = 100 * 1024 * 1024;
570 if (timestamp < start_time) timestamp =
start_time;
576 if (idx < st->nb_index_entries - 2)
578 maxlen =
FFMAX(maxlen, 200 * 1024);
583 if (
FFABS(found - timestamp) > 4)
589 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.
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.
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)
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
static int64_t start_time
Opaque data information usually continuous.
unsigned int avio_rb32(AVIOContext *s)
enum AVStreamParseType need_parsing
int id
Format-specific stream ID.
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.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
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
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)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
AVInputFormat ff_gxf_demuxer
uint64_t channel_layout
Audio channel layout.
int avio_r8(AVIOContext *s)
AVCodecContext * codec
Codec context associated with this stream.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int bit_rate
the average bitrate
audio channel layout utility functions
GLsizei GLboolean const GLfloat * value
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 ...
#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.
enum AVMediaType codec_type
int sample_rate
samples per second
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.
rational number numerator/denominator
This structure contains the data a format has to probe a file.
static int gxf_header(AVFormatContext *s)
static const AVRational frame_rate_tab[]
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 presentation order, 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.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
#define AV_CH_LAYOUT_MONO
This structure stores compressed data.
uint64_t avio_rl64(AVIOContext *s)
#define AV_NOPTS_VALUE
Undefined timestamp value.