gxf.c File Reference
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "avformat.h"
#include "internal.h"
#include "gxf.h"
#include "libavcodec/mpeg12data.h"
Include dependency graph for gxf.c:

Go to the source code of this file.

Data Structures

struct  gxf_stream_info
 

Macros

#define READ_ONE()
 

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 More...
 
static int parse_packet_header (AVIOContext *pb, GXFPktType *type, int *length)
 parses a packet header, extracting type and length More...
 
static int gxf_probe (AVProbeData *p)
 check if file starts with a PKT_MAP header More...
 
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 More...
 
static void gxf_material_tags (AVIOContext *pb, int *len, struct gxf_stream_info *si)
 filters out interesting tags from material information. More...
 
static AVRational fps_tag2avr (int32_t fps)
 convert fps tag value to AVRational fps More...
 
static AVRational fps_umf2avr (uint32_t flags)
 convert UMF attributes flags to AVRational fps More...
 
static void gxf_track_tags (AVIOContext *pb, int *len, struct gxf_stream_info *si)
 filters out interesting tags from track information. More...
 
static void gxf_read_index (AVFormatContext *s, int pkt_len)
 read index from FLT packet into stream 0 av_index More...
 
static int gxf_header (AVFormatContext *s)
 
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 More...
 
static int gxf_packet (AVFormatContext *s, AVPacket *pkt)
 
static int gxf_seek (AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
 
static int64_t gxf_read_timestamp (AVFormatContext *s, int stream_index, int64_t *pos, int64_t pos_limit)
 

Variables

static const AVRational frame_rate_tab []
 
AVInputFormat ff_gxf_demuxer
 

Macro Definition Documentation

#define READ_ONE ( )
Value:
{ \
if (!max_interval-- || url_feof(pb)) \
goto out; \
tmp = tmp << 8 | avio_r8(pb); \
}
initialize output if(nPeaks >3)%at least 3 peaks in spectrum for trying to find f0 nf0peaks
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:469
int url_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
Definition: aviobuf.c:280
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31))))#define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac){}void ff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map){AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;}return ac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;}int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){int use_generic=1;int len=in->nb_samples;int p;if(ac->dc){av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> out

Definition at line 431 of file gxf.c.

Referenced by gxf_resync_media().

Function Documentation

static int add_timecode_metadata ( AVDictionary **  pm,
const char *  key,
uint32_t  timecode,
int  fields_per_frame 
)
static

parse gxf timecode and add it to metadata

Definition at line 40 of file gxf.c.

Referenced by gxf_header().

static AVRational fps_tag2avr ( int32_t  fps)
static

convert fps tag value to AVRational fps

Parameters
fpsfps value from tag
Returns
fps as AVRational, or 0 / 0 if unknown

Definition at line 226 of file gxf.c.

Referenced by gxf_track_tags().

static AVRational fps_umf2avr ( uint32_t  flags)
static

convert UMF attributes flags to AVRational fps

Parameters
flagsUMF flags to convert
Returns
fps as AVRational, or 0 / 0 if unknown

Definition at line 236 of file gxf.c.

Referenced by gxf_header().

static int get_sindex ( AVFormatContext s,
int  id,
int  format 
)
static

gets the stream index for the track with the specified id, creates new stream if not found

Parameters
idid of stream to find / add
formatstream format identifier

Definition at line 102 of file gxf.c.

Referenced by gxf_header(), and gxf_packet().

static int gxf_header ( AVFormatContext s)
static

Definition at line 304 of file gxf.c.

static void gxf_material_tags ( AVIOContext pb,
int *  len,
struct gxf_stream_info si 
)
static

filters out interesting tags from material information.

Parameters
lenlength of tag section, will be adjusted to contain remaining bytes
sistruct to store collected information into

Definition at line 188 of file gxf.c.

Referenced by gxf_header().

static int gxf_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 483 of file gxf.c.

static int gxf_probe ( AVProbeData p)
static

check if file starts with a PKT_MAP header

Definition at line 87 of file gxf.c.

static void gxf_read_index ( AVFormatContext s,
int  pkt_len 
)
static

read index from FLT packet into stream 0 av_index

Definition at line 275 of file gxf.c.

Referenced by gxf_header(), and gxf_packet().

static int64_t gxf_read_timestamp ( AVFormatContext s,
int  stream_index,
int64_t *  pos,
int64_t  pos_limit 
)
static

Definition at line 576 of file gxf.c.

static int64_t gxf_resync_media ( AVFormatContext s,
uint64_t  max_interval,
int  track,
int  timestamp 
)
static

resync the stream on the next media packet with specified properties

Parameters
max_intervalhow many bytes to search for matching packet at most
tracktrack id the media packet must belong to, -1 for any
timestampminimum timestamp (== field number) the packet must have, -1 for any
Returns
timestamp of packet found

Definition at line 445 of file gxf.c.

Referenced by gxf_read_timestamp(), and gxf_seek().

static int gxf_seek ( AVFormatContext s,
int  stream_index,
int64_t  timestamp,
int  flags 
)
static

Definition at line 550 of file gxf.c.

static void gxf_track_tags ( AVIOContext pb,
int *  len,
struct gxf_stream_info si 
)
static

filters out interesting tags from track information.

Parameters
lenlength of tag section, will be adjusted to contain remaining bytes
sistruct to store collected information into

Definition at line 248 of file gxf.c.

Referenced by gxf_header().

static int parse_packet_header ( AVIOContext pb,
GXFPktType type,
int *  length 
)
static

parses a packet header, extracting type and length

Parameters
pbAVIOContext to read header from
typedetected packet type is stored here
lengthdetected packet length, excluding header is stored here
Returns
0 if header not found or contains invalid data, 1 otherwise

Definition at line 65 of file gxf.c.

Referenced by gxf_header(), gxf_packet(), and gxf_resync_media().

Variable Documentation

AVInputFormat ff_gxf_demuxer
Initial value:
= {
.name = "gxf",
.long_name = NULL_IF_CONFIG_SMALL("GXF (General eXchange Format)"),
.priv_data_size = sizeof(struct gxf_stream_info),
.read_header = gxf_header,
.read_packet = gxf_packet,
.read_seek = gxf_seek,
.read_timestamp = gxf_read_timestamp,
}
static int gxf_packet(AVFormatContext *s, AVPacket *pkt)
Definition: gxf.c:483
static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition: gxf.c:550
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int read_probe(AVProbeData *pd)
static int gxf_header(AVFormatContext *s)
Definition: gxf.c:304
static int64_t gxf_read_timestamp(AVFormatContext *s, int stream_index, int64_t *pos, int64_t pos_limit)
Definition: gxf.c:576
static int gxf_probe(AVProbeData *p)
check if file starts with a PKT_MAP header
Definition: gxf.c:87

Definition at line 587 of file gxf.c.

const AVRational frame_rate_tab[]
static
Initial value:
= {
{ 60, 1},
{60000, 1001},
{ 50, 1},
{ 30, 1},
{30000, 1001},
{ 25, 1},
{ 24, 1},
{24000, 1001},
{ 0, 0},
}

Definition at line 209 of file gxf.c.