52 if ((*length >> 24) || *length < 16)
68 static const uint8_t startcode[] = {0, 0, 0, 0, 1, 0xbc};
69 static const uint8_t endcode[] = {0, 0, 0, 0, 0xe1, 0xe2};
70 if (!memcmp(p->
buf, startcode,
sizeof(startcode)) &&
71 !memcmp(&p->
buf[16 -
sizeof(endcode)], endcode,
sizeof(endcode)))
207 if (fps < 1 || fps > 9) fps = 9;
208 return frame_rate_tab[fps - 1];
217 static const AVRational map[] = {{50, 1}, {60000, 1001}, {24, 1},
218 {25, 1}, {30000, 1001}};
219 int idx =
av_log2((flags & 0x7c0) >> 6);
242 else if (tag ==
TRACK_FPF && (value == 1 || value == 2))
263 if (map_cnt > 1000) {
265 "too many index entries %"PRIu32
" (%"PRIx32
")\n",
269 if (pkt_len < 4 * map_cnt) {
274 pkt_len -= 4 * map_cnt;
276 for (i = 0; i < map_cnt; i++)
278 i * (uint64_t)fields_per_map + 1, 0, 0, 0);
316 int track_type, track_id, track_len;
326 if (!(track_type & 0x80)) {
331 if ((track_id & 0xc0) != 0xc0) {
337 if (idx < 0)
continue;
339 if (!main_timebase.
num || !main_timebase.
den) {
369 if (!main_timebase.
num || !main_timebase.
den) {
371 main_timebase.
num = fps.
den;
372 main_timebase.
den = fps.
num * 2;
381 if (!main_timebase.
num || !main_timebase.
den)
392 if (!max_interval-- || pb->eof_reached) \
394 tmp = tmp << 8 | avio_r8(pb); \
407 uint64_t last_found_pos = 0;
424 if (
avio_seek(pb, last_pos, SEEK_SET) < 0)
432 if ((track >= 0 && track != cur_track) || (timestamp >= 0 && timestamp > cur_timestamp)) {
433 if (
avio_seek(pb, last_pos, SEEK_SET) >= 0)
439 return cur_timestamp;
450 int track_type, track_id, ret;
451 int field_nr, field_info, skip = 0;
473 stream_index =
get_sindex(s, track_id, track_type);
474 if (stream_index < 0)
484 int first = field_info >> 16;
485 int last = field_info & 0xffff;
487 if (first <= last && last*bps <= pkt_len) {
489 skip = pkt_len - last*
bps;
490 pkt_len = (last-first)*bps;
512 uint64_t maxlen = 100 * 1024 * 1024;
517 if (timestamp < start_time) timestamp =
start_time;
523 if (idx < st->nb_index_entries - 2)
525 maxlen =
FFMAX(maxlen, 200 * 1024);
530 if (
FFABS(found - timestamp) > 4)
536 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.
#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...
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.
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
static int64_t start_time
#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.
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,...)
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
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.
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.
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.
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_dlog(ac->avr,"%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
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_CH_LAYOUT_MONO
This structure stores compressed data.
#define AV_NOPTS_VALUE
Undefined timestamp value.