22 #include "libavutil/intfloat.h"
23 #include "libavutil/mathematics.h"
29 #define GXF_AUDIO_PACKET_SIZE 65536
101 #define SERVER_PATH "EXT:/PDR/default/"
102 #define ES_NAME_PATTERN "EXT:/PDR/default/ES."
109 for (i = 0; i < 6; ++i) {
120 for (; to_pad > 0; to_pad--) {
168 int size, starting_line;
191 size = snprintf(buffer, 1024,
"Ver 1\nBr %.6f\nIpg 1\nPpi %d\nBpiop %d\n"
192 "Pix 0\nCf %d\nCg %d\nSl %d\nnl16 %d\nVi 1\nf1 1\n",
275 const char *filename = strrchr(s->
filename,
'/');
285 len = strlen(filename);
374 int fields_per_flt = (gxf->
nb_fields+1) / 1000 + 1;
375 int flt_entries = gxf->
nb_fields / fields_per_flt;
384 for (i = 0; i < flt_entries; i++)
388 for (; i < 1000; i++)
398 int timecode_base = gxf->
time_base.
den == 60000 ? 60 : 50;
399 int64_t timestamp = 0;
408 gxf->
nb_fields / (timecode_base * 3600) % 24 << 24 |
409 gxf->
nb_fields / (timecode_base * 60) % 60 << 16 |
410 gxf->
nb_fields / timecode_base % 60 << 8 |
511 for (i = 0; i < 8; i++) {
539 int64_t startpos, curpos;
634 int i, media_info = 0;
641 gxf->
flags |= 0x00080000;
671 gxf->
flags |= 0x04000000;
682 gxf->
flags |= 0x00000080;
688 gxf->
flags |= 0x00000040;
692 "gxf muxer only accepts PAL or NTSC resolutions currently\n");
706 gxf->
flags |= 0x00004000;
718 gxf->
flags |= 0x00008000;
725 gxf->
flags |= 0x00002000;
729 gxf->
flags |= 0x00001000;
739 sc->
media_info = media_info<<8 | (
'0'+tracks[media_info]++);
747 gxf->
flags |= 0x200000;
803 for(i=0; i<size-4 && c!=0x100; i++){
808 return (buf[i+1]>>3)&7;
865 int packet_start_offset =
avio_tell(pb) / 1024;
869 padding = 4 - pkt->
size % 4;
909 for (i = 0; i < 2; i++) {
917 field_nb[i] = pkt[i]->
dts;
920 return field_nb[1] > field_nb[0] ||
921 (field_nb[1] == field_nb[0] && sc[1]->
order > sc[0]->
order);
static int gxf_write_header(AVFormatContext *s)
static int gxf_write_umf_media_dv(AVIOContext *pb, GXFStreamContext *sc)
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const
Rescale a 64-bit integer with specified rounding.
static int64_t updatePacketSize(AVIOContext *pb, int64_t pos)
AVCodecContext * codec
Codec context associated with this stream.
static int gxf_write_umf_media_mpeg(AVIOContext *pb, AVStream *st)
static const int GXF_samples_per_frame[]
int index
stream index in AVFormatContext
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
static const AVCodecTag gxf_media_types[]
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int b_per_i_or_p
number of B frames per I frame or P frame
GXFStreamContext timecode_track
uint32_t umf_start_offset
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
AVOutputFormat ff_gxf_muxer
uint32_t umf_track_offset
int ff_audio_interleave_init(AVFormatContext *s, const int *samples_per_frame, AVRational time_base)
AudioInterleaveContext aic
static void gxf_init_timecode_track(GXFStreamContext *sc, GXFStreamContext *vsc)
static int gxf_write_timecode_auxiliary(AVIOContext *pb, GXFStreamContext *sc)
static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, int flush)
Interleave an AVPacket correctly so it can be muxed.
static int gxf_find_lines_index(AVStream *st)
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static int gxf_compare_field_nb(AVFormatContext *s, AVPacket *next, AVPacket *cur)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int64_t updateSize(AVIOContext *pb, int64_t pos)
void * priv_data
Format private data.
char filename[1024]
input or output filename
int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush, int(*get_packet)(AVFormatContext *, AVPacket *, AVPacket *, int), int(*compare_ts)(AVFormatContext *, AVPacket *, AVPacket *))
Rechunk audio PCM packets per AudioInterleaveContext->samples_per_frame and interleave them correctly...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static void gxf_write_padding(AVIOContext *pb, int64_t to_pad)
uint32_t umf_media_offset
static int gxf_write_umf_media_audio(AVIOContext *pb, GXFStreamContext *sc)
static int gxf_write_umf_payload(AVFormatContext *s)
static int gxf_write_umf_material_description(AVFormatContext *s)
static int gxf_write_umf_media_timecode(AVIOContext *pb, GXFStreamContext *sc)
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static int gxf_write_media_preamble(AVFormatContext *s, AVPacket *pkt, int size)
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int bit_rate
the average bitrate
static int gxf_parse_mpeg_frame(GXFStreamContext *sc, const uint8_t *buf, int size)
static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
AVStream ** streams
A list of all streams in the file.
#define GXF_AUDIO_PACKET_SIZE
static int gxf_write_map_packet(AVFormatContext *s, int rewrite)
preferred ID for MPEG-1/2 video decoding
unsigned order
interleaving order
static int gxf_write_material_data_section(AVFormatContext *s)
unsigned * flt_entries
offsets of packets /1024, starts after 2nd video field
enum AVMediaType codec_type
int sample_rate
samples per second
static int gxf_write_track_description_section(AVFormatContext *s)
AVIOContext * pb
I/O context.
static int gxf_write_eos_packet(AVIOContext *pb)
rational number numerator/denominator
AVDictionary * metadata
Metadata that applies to the whole file.
static int gxf_write_trailer(AVFormatContext *s)
static const struct @109 gxf_lines_tab[]
static int gxf_write_track_description(AVFormatContext *s, GXFStreamContext *sc, int index)
static void gxf_write_packet_header(AVIOContext *pb, GXFPktType type)
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
static int gxf_write_flt_packet(AVFormatContext *s)
void ff_audio_interleave_close(AVFormatContext *s)
uint64_t * map_offsets
offset of map packets
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static int gxf_write_umf_track_description(AVFormatContext *s)
int channels
number of audio channels
static void write_header(FFV1Context *f)
static av_always_inline uint64_t av_double2int(double f)
Reinterpret a double as a 64-bit integer.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
static int gxf_write_umf_packet(AVFormatContext *s)
This structure stores compressed data.
static int gxf_write_umf_media_description(AVFormatContext *s)
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int gxf_write_mpeg_auxiliary(AVIOContext *pb, AVStream *st)
static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt)