From 9fba8ebe0acdc28193d37b5e1f4c0d73c589ede2 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Fri, 23 Sep 2011 16:28:23 -0700 Subject: [PATCH 01/11] mpegps: Handle buffer exhaustion when reading packets. --- libavformat/mpeg.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index bc450495ae..f797da7e27 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -418,7 +418,7 @@ static int mpegps_read_packet(AVFormatContext *s, { MpegDemuxContext *m = s->priv_data; AVStream *st; - int len, startcode, i, es_type; + int len, startcode, i, es_type, ret; enum CodecID codec_id = CODEC_ID_NONE; enum AVMediaType type; int64_t pts, dts, dummy_pos; //dummy_pos is needed for the index building to work @@ -562,7 +562,13 @@ static int mpegps_read_packet(AVFormatContext *s, return AVERROR(EINVAL); } av_new_packet(pkt, len); - avio_read(s->pb, pkt->data, pkt->size); + ret = avio_read(s->pb, pkt->data, pkt->size); + if (ret < 0) { + pkt->size = 0; + } else if (ret < pkt->size) { + pkt->size = ret; + memset(pkt->data + ret, 0, FF_INPUT_BUFFER_PADDING_SIZE); + } pkt->pts = pts; pkt->dts = dts; pkt->pos = dummy_pos; @@ -571,7 +577,7 @@ static int mpegps_read_packet(AVFormatContext *s, pkt->stream_index, pkt->pts / 90000.0, pkt->dts / 90000.0, pkt->size); - return 0; + return (ret < 0) ? ret : 0; } static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, From c2d3f561072132044114588a5f56b8e1974a2af7 Mon Sep 17 00:00:00 2001 From: Sean McGovern Date: Mon, 19 Sep 2011 21:32:09 -0400 Subject: [PATCH 02/11] fft: avoid a signed overflow As a signed integer, 1<<31 overflows, so force it to unsigned. Signed-off-by: Alex Converse --- libavcodec/x86/fft_3dn2.c | 4 ++-- libavcodec/x86/fft_sse.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/x86/fft_3dn2.c b/libavcodec/x86/fft_3dn2.c index 05c0467f08..a724398aff 100644 --- a/libavcodec/x86/fft_3dn2.c +++ b/libavcodec/x86/fft_3dn2.c @@ -23,7 +23,7 @@ #include "libavcodec/dsputil.h" #include "fft.h" -DECLARE_ALIGNED(8, static const int, m1m1)[2] = { 1<<31, 1<<31 }; +DECLARE_ALIGNED(8, static const unsigned int, m1m1)[2] = { 1U<<31, 1U<<31 }; #ifdef EMULATE_3DNOWEXT #define PSWAPD(s,d)\ @@ -70,7 +70,7 @@ void ff_imdct_half_3dn2(FFTContext *s, FFTSample *output, const FFTSample *input in1 = input; in2 = input + n2 - 1; #ifdef EMULATE_3DNOWEXT - __asm__ volatile("movd %0, %%mm7" ::"r"(1<<31)); + __asm__ volatile("movd %0, %%mm7" ::"r"(1U<<31)); #endif for(k = 0; k < n4; k++) { // FIXME a single block is faster, but gcc 2.95 and 3.4.x on 32bit can't compile it diff --git a/libavcodec/x86/fft_sse.c b/libavcodec/x86/fft_sse.c index add20dd5b2..6be5be9611 100644 --- a/libavcodec/x86/fft_sse.c +++ b/libavcodec/x86/fft_sse.c @@ -24,8 +24,8 @@ #include "fft.h" #include "config.h" -DECLARE_ASM_CONST(16, int, ff_m1m1m1m1)[4] = - { 1 << 31, 1 << 31, 1 << 31, 1 << 31 }; +DECLARE_ASM_CONST(16, unsigned int, ff_m1m1m1m1)[4] = + { 1U << 31, 1U << 31, 1U << 31, 1U << 31 }; void ff_fft_dispatch_sse(FFTComplex *z, int nbits); void ff_fft_dispatch_interleave_sse(FFTComplex *z, int nbits); From ffe92ff9f0c7f390d895de12c8ffef959ced3cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Wed, 7 Sep 2011 22:14:07 -0400 Subject: [PATCH 03/11] Fix input buffer size check in adpcm_ea decoder. Unfortunately the output buffer size check assumes that the input buffer is never over-consumed, thus this actually also allowed to write outside the output buffer if "lucky". Based on: git.videolan.org/ffmpeg.git commit 701d0eb185192542c4a17f296e39e37cedf7abc6 --- libavcodec/adpcm.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index c9ec0c3798..8ded663964 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -633,11 +633,17 @@ static int adpcm_decode_frame(AVCodecContext *avctx, } break; case CODEC_ID_ADPCM_EA: - if (buf_size < 4 || AV_RL32(src) >= ((buf_size - 12) * 2)) { - src += buf_size; - break; + /* Each EA ADPCM frame has a 12-byte header followed by 30-byte pieces, + each coding 28 stereo samples. */ + if (buf_size < 12) { + av_log(avctx, AV_LOG_ERROR, "frame too small\n"); + return AVERROR(EINVAL); } samples_in_chunk = AV_RL32(src); + if (samples_in_chunk / 28 > (buf_size - 12) / 30) { + av_log(avctx, AV_LOG_ERROR, "invalid frame\n"); + return AVERROR(EINVAL); + } src += 4; current_left_sample = (int16_t)bytestream_get_le16(&src); previous_left_sample = (int16_t)bytestream_get_le16(&src); From 3a549eb82be709d633a0ba964b037ee2f700e0c9 Mon Sep 17 00:00:00 2001 From: Peter Ross Date: Sat, 23 Apr 2011 22:08:48 +1000 Subject: [PATCH 04/11] permit decoding of multichannel ADPCM_EA_XAS Signed-off-by: Michael Niedermayer --- libavcodec/adpcm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 8ded663964..de4fe9b11f 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -92,6 +92,7 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx) case CODEC_ID_ADPCM_EA_R1: case CODEC_ID_ADPCM_EA_R2: case CODEC_ID_ADPCM_EA_R3: + case CODEC_ID_ADPCM_EA_XAS: max_channels = 6; break; } From bf334535b4d41e7278bd5361492cfe357b8b9821 Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier Date: Sun, 8 May 2011 13:13:17 +0200 Subject: [PATCH 05/11] adpcmdec: Fix QT IMA ADPCM decoder Signed-off-by: Michael Niedermayer --- libavcodec/adpcm.c | 58 +++++++++++++++++++++++++++-------- tests/ref/acodec/adpcm_ima_qt | 6 ++-- tests/ref/fate/qt-ima4-mono | 2 +- tests/ref/fate/qt-ima4-stereo | 2 +- 4 files changed, 50 insertions(+), 18 deletions(-) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index de4fe9b11f..3baa07b982 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -150,6 +150,32 @@ static inline short adpcm_ima_expand_nibble(ADPCMChannelStatus *c, char nibble, return (short)c->predictor; } +static inline int adpcm_ima_qt_expand_nibble(ADPCMChannelStatus *c, int nibble, int shift) +{ + int step_index; + int predictor; + int diff, step; + + step = ff_adpcm_step_table[c->step_index]; + step_index = c->step_index + ff_adpcm_index_table[nibble]; + step_index = av_clip(step_index, 0, 88); + + diff = step >> 3; + if (nibble & 4) diff += step; + if (nibble & 2) diff += step >> 1; + if (nibble & 1) diff += step >> 2; + + if (nibble & 8) + predictor = c->predictor - diff; + else + predictor = c->predictor + diff; + + c->predictor = av_clip_int16(predictor); + c->step_index = step_index; + + return c->predictor; +} + static inline short adpcm_ms_expand_nibble(ADPCMChannelStatus *c, char nibble) { int predictor; @@ -352,35 +378,41 @@ static int adpcm_decode_frame(AVCodecContext *avctx, case CODEC_ID_ADPCM_IMA_QT: n = buf_size - 2*avctx->channels; for (channel = 0; channel < avctx->channels; channel++) { + int16_t predictor; + int step_index; cs = &(c->status[channel]); /* (pppppp) (piiiiiii) */ /* Bits 15-7 are the _top_ 9 bits of the 16-bit initial predictor value */ - cs->predictor = (*src++) << 8; - cs->predictor |= (*src & 0x80); - cs->predictor &= 0xFF80; + predictor = AV_RB16(src); + step_index = predictor & 0x7F; + predictor &= 0xFF80; - /* sign extension */ - if(cs->predictor & 0x8000) - cs->predictor -= 0x10000; + src += 2; - cs->predictor = av_clip_int16(cs->predictor); - - cs->step_index = (*src++) & 0x7F; + if (cs->step_index == step_index) { + int diff = (int)predictor - cs->predictor; + if (diff < 0) + diff = - diff; + if (diff > 0x7f) + goto update; + } else { + update: + cs->step_index = step_index; + cs->predictor = predictor; + } if (cs->step_index > 88){ av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index); cs->step_index = 88; } - cs->step = ff_adpcm_step_table[cs->step_index]; - samples = (short*)data + channel; for(m=32; n>0 && m>0; n--, m--) { /* in QuickTime, IMA is encoded by chuncks of 34 bytes (=64 samples) */ - *samples = adpcm_ima_expand_nibble(cs, src[0] & 0x0F, 3); + *samples = adpcm_ima_qt_expand_nibble(cs, src[0] & 0x0F, 3); samples += avctx->channels; - *samples = adpcm_ima_expand_nibble(cs, src[0] >> 4 , 3); + *samples = adpcm_ima_qt_expand_nibble(cs, src[0] >> 4 , 3); samples += avctx->channels; src ++; } diff --git a/tests/ref/acodec/adpcm_ima_qt b/tests/ref/acodec/adpcm_ima_qt index 6e4415660e..a91cd2da3d 100644 --- a/tests/ref/acodec/adpcm_ima_qt +++ b/tests/ref/acodec/adpcm_ima_qt @@ -1,4 +1,4 @@ -3c06fd2f7831e3e8735b936e23ca220c *./tests/data/acodec/adpcm_qt.aiff +019564da45949d0b5278bd75ee9a4ac2 *./tests/data/acodec/adpcm_qt.aiff 281252 ./tests/data/acodec/adpcm_qt.aiff -9580492803ba1c1a3746367b24b751c8 *./tests/data/adpcm_ima_qt.acodec.out.wav -stddev: 914.65 PSNR: 37.10 MAXDIFF:34026 bytes: 1058560/ 1058400 +a7fb054f7bd82270c8fd476eb9f5677c *./tests/data/adpcm_ima_qt.acodec.out.wav +stddev: 920.19 PSNR: 37.05 MAXDIFF:34029 bytes: 1058560/ 1058400 diff --git a/tests/ref/fate/qt-ima4-mono b/tests/ref/fate/qt-ima4-mono index 66767d5d30..b8fc5f99de 100644 --- a/tests/ref/fate/qt-ima4-mono +++ b/tests/ref/fate/qt-ima4-mono @@ -1 +1 @@ -721b51fd66c3bb3dc49dd88d404188eb +e178ed520edf2f46492ae740d88f5815 diff --git a/tests/ref/fate/qt-ima4-stereo b/tests/ref/fate/qt-ima4-stereo index 5e6b1237d5..84c9f46d02 100644 --- a/tests/ref/fate/qt-ima4-stereo +++ b/tests/ref/fate/qt-ima4-stereo @@ -1 +1 @@ -c9e4c21fb62eca34a533f3a9ad2e394a +d22be0e193dcbba1068a1ca6ab04cf77 From b304244b54611e9a84e22ab40e94be4a7a474c21 Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier Date: Wed, 7 Sep 2011 22:27:03 -0400 Subject: [PATCH 06/11] adpcmenc: fix QT IMA ADPCM encoder Signed-off-by: Michael Niedermayer --- libavcodec/adpcmenc.c | 39 +++++++++++++++++++++++++++++++---- tests/ref/acodec/adpcm_ima_qt | 6 +++--- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c index ec062849bd..6295eedc55 100644 --- a/libavcodec/adpcmenc.c +++ b/libavcodec/adpcmenc.c @@ -164,6 +164,39 @@ static inline unsigned char adpcm_ima_compress_sample(ADPCMChannelStatus *c, sho return nibble; } +static inline unsigned char adpcm_ima_qt_compress_sample(ADPCMChannelStatus *c, short sample) +{ + int delta = sample - c->prev_sample; + int mask, step = ff_adpcm_step_table[c->step_index]; + int diff = step >> 3; + int nibble = 0; + + if (delta < 0) { + nibble = 8; + delta = -delta; + } + + for (mask = 4; mask;) { + if (delta >= step) { + nibble |= mask; + delta -= step; + diff += step; + } + step >>= 1; + mask >>= 1; + } + + if (nibble & 8) + c->prev_sample -= diff; + else + c->prev_sample += diff; + + c->prev_sample = av_clip_int16(c->prev_sample); + c->step_index = av_clip(c->step_index + ff_adpcm_index_table[nibble], 0, 88); + + return nibble; +} + static inline unsigned char adpcm_ms_compress_sample(ADPCMChannelStatus *c, short sample) { int predictor, nibble, bias; @@ -497,16 +530,14 @@ static int adpcm_encode_frame(AVCodecContext *avctx, adpcm_compress_trellis(avctx, samples+ch, buf, &c->status[ch], 64); for(i=0; i<64; i++) put_bits(&pb, 4, buf[i^1]); - c->status[ch].prev_sample = c->status[ch].predictor & ~0x7F; } else { for (i=0; i<64; i+=2){ int t1, t2; - t1 = adpcm_ima_compress_sample(&c->status[ch], samples[avctx->channels*(i+0)+ch]); - t2 = adpcm_ima_compress_sample(&c->status[ch], samples[avctx->channels*(i+1)+ch]); + t1 = adpcm_ima_qt_compress_sample(&c->status[ch], samples[avctx->channels*(i+0)+ch]); + t2 = adpcm_ima_qt_compress_sample(&c->status[ch], samples[avctx->channels*(i+1)+ch]); put_bits(&pb, 4, t2); put_bits(&pb, 4, t1); } - c->status[ch].prev_sample &= ~0x7F; } } diff --git a/tests/ref/acodec/adpcm_ima_qt b/tests/ref/acodec/adpcm_ima_qt index a91cd2da3d..cdd60e06b9 100644 --- a/tests/ref/acodec/adpcm_ima_qt +++ b/tests/ref/acodec/adpcm_ima_qt @@ -1,4 +1,4 @@ -019564da45949d0b5278bd75ee9a4ac2 *./tests/data/acodec/adpcm_qt.aiff +057d27978b35888776512e4e9669a63b *./tests/data/acodec/adpcm_qt.aiff 281252 ./tests/data/acodec/adpcm_qt.aiff -a7fb054f7bd82270c8fd476eb9f5677c *./tests/data/adpcm_ima_qt.acodec.out.wav -stddev: 920.19 PSNR: 37.05 MAXDIFF:34029 bytes: 1058560/ 1058400 +3890343c0c20934e014d7ac93f5d65bd *./tests/data/adpcm_ima_qt.acodec.out.wav +stddev: 918.61 PSNR: 37.07 MAXDIFF:34029 bytes: 1058560/ 1058400 From 9ff6d0791b220d80844b45c9217113306a50a6cc Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Wed, 7 Sep 2011 22:52:06 -0400 Subject: [PATCH 07/11] adpcmenc: Set bits_per_coded_sample --- libavcodec/adpcmenc.c | 2 ++ libavcodec/utils.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c index 6295eedc55..2a117f4aae 100644 --- a/libavcodec/adpcmenc.c +++ b/libavcodec/adpcmenc.c @@ -86,6 +86,8 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx) FF_ALLOC_OR_GOTO(avctx, s->trellis_hash, 65536 * sizeof(*s->trellis_hash), error); } + avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id); + switch(avctx->codec->id) { case CODEC_ID_ADPCM_IMA_WAV: avctx->frame_size = (BLKSIZE - 4 * avctx->channels) * 8 / (4 * avctx->channels) + 1; /* each 16 bits sample gives one nibble */ diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 9f198cb32a..8459e5f870 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -1121,6 +1121,8 @@ int av_get_bits_per_sample(enum CodecID codec_id){ case CODEC_ID_ADPCM_SBPRO_4: case CODEC_ID_ADPCM_CT: case CODEC_ID_ADPCM_IMA_WAV: + case CODEC_ID_ADPCM_IMA_QT: + case CODEC_ID_ADPCM_SWF: case CODEC_ID_ADPCM_MS: case CODEC_ID_ADPCM_YAMAHA: return 4; From 30b4ee7901ec5dbe24f1c75c0c0b43ba551c858b Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 23 Sep 2011 20:50:11 +0200 Subject: [PATCH 08/11] Use explicit struct initializers for AVOutputFormat/AVInputFormat declarations. --- libavdevice/alsa-audio-dec.c | 17 ++++++++-------- libavdevice/alsa-audio-enc.c | 20 +++++++++---------- libavdevice/bktr.c | 17 ++++++++-------- libavdevice/jack_audio.c | 17 ++++++++-------- libavdevice/oss_audio.c | 37 ++++++++++++++++------------------- libavdevice/v4l.c | 17 ++++++++-------- libavdevice/v4l2.c | 17 ++++++++-------- libavdevice/vfwcap.c | 17 ++++++++-------- libavdevice/x11grab.c | 20 +++++++++---------- libavformat/daud.c | 21 +++++++++----------- libavformat/idroqenc.c | 19 ++++++++---------- libavformat/pcmdec.c | 38 +++++++++++++++++------------------- libavformat/pcmenc.c | 21 +++++++++----------- libavformat/txd.c | 14 ++++++------- 14 files changed, 133 insertions(+), 159 deletions(-) diff --git a/libavdevice/alsa-audio-dec.c b/libavdevice/alsa-audio-dec.c index 05f68d3cdc..8eae021213 100644 --- a/libavdevice/alsa-audio-dec.c +++ b/libavdevice/alsa-audio-dec.c @@ -164,13 +164,12 @@ static const AVClass alsa_demuxer_class = { }; AVInputFormat ff_alsa_demuxer = { - "alsa", - NULL_IF_CONFIG_SMALL("ALSA audio input"), - sizeof(AlsaData), - NULL, - audio_read_header, - audio_read_packet, - ff_alsa_close, - .flags = AVFMT_NOFILE, - .priv_class = &alsa_demuxer_class, + .name = "alsa", + .long_name = NULL_IF_CONFIG_SMALL("ALSA audio input"), + .priv_data_size = sizeof(AlsaData), + .read_header = audio_read_header, + .read_packet = audio_read_packet, + .read_close = ff_alsa_close, + .flags = AVFMT_NOFILE, + .priv_class = &alsa_demuxer_class, }; diff --git a/libavdevice/alsa-audio-enc.c b/libavdevice/alsa-audio-enc.c index f3782c5ab6..95887c19ed 100644 --- a/libavdevice/alsa-audio-enc.c +++ b/libavdevice/alsa-audio-enc.c @@ -102,15 +102,13 @@ static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt) } AVOutputFormat ff_alsa_muxer = { - "alsa", - NULL_IF_CONFIG_SMALL("ALSA audio output"), - "", - "", - sizeof(AlsaData), - DEFAULT_CODEC_ID, - CODEC_ID_NONE, - audio_write_header, - audio_write_packet, - ff_alsa_close, - .flags = AVFMT_NOFILE, + .name = "alsa", + .long_name = NULL_IF_CONFIG_SMALL("ALSA audio output"), + .priv_data_size = sizeof(AlsaData), + .audio_codec = DEFAULT_CODEC_ID, + .video_codec = CODEC_ID_NONE, + .write_header = audio_write_header, + .write_packet = audio_write_packet, + .write_trailer = ff_alsa_close, + .flags = AVFMT_NOFILE, }; diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c index 7ff46cf8a3..f03cf2f192 100644 --- a/libavdevice/bktr.c +++ b/libavdevice/bktr.c @@ -345,13 +345,12 @@ static const AVClass bktr_class = { }; AVInputFormat ff_bktr_demuxer = { - "bktr", - NULL_IF_CONFIG_SMALL("video grab"), - sizeof(VideoData), - NULL, - grab_read_header, - grab_read_packet, - grab_read_close, - .flags = AVFMT_NOFILE, - .priv_class = &bktr_class, + .name = "bktr", + .long_name = NULL_IF_CONFIG_SMALL("video grab"), + .priv_data_size = sizeof(VideoData), + .read_header = grab_read_header, + .read_packet = grab_read_packet, + .read_close = grab_read_close, + .flags = AVFMT_NOFILE, + .priv_class = &bktr_class, }; diff --git a/libavdevice/jack_audio.c b/libavdevice/jack_audio.c index 029ace6dc0..c59a22d113 100644 --- a/libavdevice/jack_audio.c +++ b/libavdevice/jack_audio.c @@ -326,13 +326,12 @@ static const AVClass jack_indev_class = { }; AVInputFormat ff_jack_demuxer = { - "jack", - NULL_IF_CONFIG_SMALL("JACK Audio Connection Kit"), - sizeof(JackData), - NULL, - audio_read_header, - audio_read_packet, - audio_read_close, - .flags = AVFMT_NOFILE, - .priv_class = &jack_indev_class, + .name = "jack", + .long_name = NULL_IF_CONFIG_SMALL("JACK Audio Connection Kit"), + .priv_data_size = sizeof(JackData), + .read_header = audio_read_header, + .read_packet = audio_read_packet, + .read_close = audio_read_close, + .flags = AVFMT_NOFILE, + .priv_class = &jack_indev_class, }; diff --git a/libavdevice/oss_audio.c b/libavdevice/oss_audio.c index 6df7f34d7e..c19c67784d 100644 --- a/libavdevice/oss_audio.c +++ b/libavdevice/oss_audio.c @@ -295,33 +295,30 @@ static const AVClass oss_demuxer_class = { }; AVInputFormat ff_oss_demuxer = { - "oss", - NULL_IF_CONFIG_SMALL("Open Sound System capture"), - sizeof(AudioData), - NULL, - audio_read_header, - audio_read_packet, - audio_read_close, - .flags = AVFMT_NOFILE, - .priv_class = &oss_demuxer_class, + .name = "oss", + .long_name = NULL_IF_CONFIG_SMALL("Open Sound System capture"), + .priv_data_size = sizeof(AudioData), + .read_header = audio_read_header, + .read_packet = audio_read_packet, + .read_close = audio_read_close, + .flags = AVFMT_NOFILE, + .priv_class = &oss_demuxer_class, }; #endif #if CONFIG_OSS_OUTDEV AVOutputFormat ff_oss_muxer = { - "oss", - NULL_IF_CONFIG_SMALL("Open Sound System playback"), - "", - "", - sizeof(AudioData), + .name = "oss", + .long_name = NULL_IF_CONFIG_SMALL("Open Sound System playback"), + .priv_data_size = sizeof(AudioData), /* XXX: we make the assumption that the soundcard accepts this format */ /* XXX: find better solution with "preinit" method, needed also in other formats */ - AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE), - CODEC_ID_NONE, - audio_write_header, - audio_write_packet, - audio_write_trailer, - .flags = AVFMT_NOFILE, + .audio_codec = AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE), + .video_codec = CODEC_ID_NONE, + .write_header = audio_write_header, + .write_packet = audio_write_packet, + .write_trailer = audio_write_trailer, + .flags = AVFMT_NOFILE, }; #endif diff --git a/libavdevice/v4l.c b/libavdevice/v4l.c index b0f0452d8e..5c1caf858a 100644 --- a/libavdevice/v4l.c +++ b/libavdevice/v4l.c @@ -354,14 +354,13 @@ static const AVClass v4l_class = { }; AVInputFormat ff_v4l_demuxer = { - "video4linux", - NULL_IF_CONFIG_SMALL("Video4Linux device grab"), - sizeof(VideoData), - NULL, - grab_read_header, - grab_read_packet, - grab_read_close, - .flags = AVFMT_NOFILE, - .priv_class = &v4l_class, + .name = "video4linux", + .long_name = NULL_IF_CONFIG_SMALL("Video4Linux device grab"), + .priv_data_size = sizeof(VideoData), + .read_header = grab_read_header, + .read_packet = grab_read_packet, + .read_close = grab_read_close, + .flags = AVFMT_NOFILE, + .priv_class = &v4l_class, }; #endif /* FF_API_V4L */ diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index 7a501a901c..2ae5a3fe17 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -725,13 +725,12 @@ static const AVClass v4l2_class = { }; AVInputFormat ff_v4l2_demuxer = { - "video4linux2", - NULL_IF_CONFIG_SMALL("Video4Linux2 device grab"), - sizeof(struct video_data), - NULL, - v4l2_read_header, - v4l2_read_packet, - v4l2_read_close, - .flags = AVFMT_NOFILE, - .priv_class = &v4l2_class, + .name = "video4linux2", + .long_name = NULL_IF_CONFIG_SMALL("Video4Linux2 device grab"), + .priv_data_size = sizeof(struct video_data), + .read_header = v4l2_read_header, + .read_packet = v4l2_read_packet, + .read_close = v4l2_read_close, + .flags = AVFMT_NOFILE, + .priv_class = &v4l2_class, }; diff --git a/libavdevice/vfwcap.c b/libavdevice/vfwcap.c index 47a9ebeb9c..4faf2d937d 100644 --- a/libavdevice/vfwcap.c +++ b/libavdevice/vfwcap.c @@ -470,13 +470,12 @@ static const AVClass vfw_class = { }; AVInputFormat ff_vfwcap_demuxer = { - "vfwcap", - NULL_IF_CONFIG_SMALL("VFW video capture"), - sizeof(struct vfw_ctx), - NULL, - vfw_read_header, - vfw_read_packet, - vfw_read_close, - .flags = AVFMT_NOFILE, - .priv_class = &vfw_class, + .name = "vfwcap", + .long_name = NULL_IF_CONFIG_SMALL("VfW video capture"), + .priv_data_size = sizeof(struct vfw_ctx), + .read_header = vfw_read_header, + .read_packet = vfw_read_packet, + .read_close = vfw_read_close, + .flags = AVFMT_NOFILE, + .priv_class = &vfw_class, }; diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c index 5cc32dc20d..1a8a9963ed 100644 --- a/libavdevice/x11grab.c +++ b/libavdevice/x11grab.c @@ -598,15 +598,13 @@ static const AVClass x11_class = { }; /** x11 grabber device demuxer declaration */ -AVInputFormat ff_x11_grab_device_demuxer = -{ - "x11grab", - NULL_IF_CONFIG_SMALL("X11grab"), - sizeof(struct x11_grab), - NULL, - x11grab_read_header, - x11grab_read_packet, - x11grab_read_close, - .flags = AVFMT_NOFILE, - .priv_class = &x11_class, +AVInputFormat ff_x11_grab_device_demuxer = { + .name = "x11grab", + .long_name = NULL_IF_CONFIG_SMALL("X11grab"), + .priv_data_size = sizeof(struct x11_grab), + .read_header = x11grab_read_header, + .read_packet = x11grab_read_packet, + .read_close = x11grab_read_close, + .flags = AVFMT_NOFILE, + .priv_class = &x11_class, }; diff --git a/libavformat/daud.c b/libavformat/daud.c index 9421d18a3b..6a48818c84 100644 --- a/libavformat/daud.c +++ b/libavformat/daud.c @@ -80,17 +80,14 @@ AVInputFormat ff_daud_demuxer = { #endif #if CONFIG_DAUD_MUXER -AVOutputFormat ff_daud_muxer = -{ - "daud", - NULL_IF_CONFIG_SMALL("D-Cinema audio format"), - NULL, - "302", - 0, - CODEC_ID_PCM_S24DAUD, - CODEC_ID_NONE, - daud_write_header, - daud_write_packet, - .flags= AVFMT_NOTIMESTAMPS, +AVOutputFormat ff_daud_muxer = { + .name = "daud", + .long_name = NULL_IF_CONFIG_SMALL("D-Cinema audio format"), + .extensions = "302", + .audio_codec = CODEC_ID_PCM_S24DAUD, + .video_codec = CODEC_ID_NONE, + .write_header = daud_write_header, + .write_packet = daud_write_packet, + .flags = AVFMT_NOTIMESTAMPS, }; #endif diff --git a/libavformat/idroqenc.c b/libavformat/idroqenc.c index 688d58d1ab..266a731cc3 100644 --- a/libavformat/idroqenc.c +++ b/libavformat/idroqenc.c @@ -35,15 +35,12 @@ static int roq_write_header(struct AVFormatContext *s) return 0; } -AVOutputFormat ff_roq_muxer = -{ - "RoQ", - NULL_IF_CONFIG_SMALL("raw id RoQ format"), - NULL, - "roq", - 0, - CODEC_ID_ROQ_DPCM, - CODEC_ID_ROQ, - roq_write_header, - ff_raw_write_packet, +AVOutputFormat ff_roq_muxer = { + .name = "RoQ", + .long_name = NULL_IF_CONFIG_SMALL("raw id RoQ format"), + .extensions = "roq", + .audio_codec = CODEC_ID_ROQ_DPCM, + .video_codec = CODEC_ID_ROQ, + .write_header = roq_write_header, + .write_packet = ff_raw_write_packet, }; diff --git a/libavformat/pcmdec.c b/libavformat/pcmdec.c index 90799dd664..22023320b8 100644 --- a/libavformat/pcmdec.c +++ b/libavformat/pcmdec.c @@ -54,26 +54,24 @@ static const AVOption pcm_options[] = { { NULL }, }; -#define PCMDEF(name, long_name, ext, codec) \ -static const AVClass name ## _demuxer_class = {\ - .class_name = #name " demuxer",\ - .item_name = av_default_item_name,\ - .option = pcm_options,\ - .version = LIBAVUTIL_VERSION_INT,\ -};\ -AVInputFormat ff_pcm_ ## name ## _demuxer = {\ - #name,\ - NULL_IF_CONFIG_SMALL(long_name),\ - sizeof(RawAudioDemuxerContext),\ - NULL,\ - ff_raw_read_header,\ - raw_read_packet,\ - NULL,\ - pcm_read_seek,\ - .flags= AVFMT_GENERIC_INDEX,\ - .extensions = ext,\ - .value = codec,\ - .priv_class = &name ## _demuxer_class,\ +#define PCMDEF(name_, long_name_, ext, codec) \ +static const AVClass name_ ## _demuxer_class = { \ + .class_name = #name_ " demuxer", \ + .item_name = av_default_item_name, \ + .option = pcm_options, \ + .version = LIBAVUTIL_VERSION_INT, \ +}; \ +AVInputFormat ff_pcm_ ## name_ ## _demuxer = { \ + .name = #name_, \ + .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ + .priv_data_size = sizeof(RawAudioDemuxerContext), \ + .read_header = ff_raw_read_header, \ + .read_packet = raw_read_packet, \ + .read_seek = pcm_read_seek, \ + .flags = AVFMT_GENERIC_INDEX, \ + .extensions = ext, \ + .value = codec, \ + .priv_class = &name_ ## _demuxer_class, \ }; PCMDEF(f64be, "PCM 64 bit floating-point big-endian format", diff --git a/libavformat/pcmenc.c b/libavformat/pcmenc.c index 928124e9b0..553df1f877 100644 --- a/libavformat/pcmenc.c +++ b/libavformat/pcmenc.c @@ -22,18 +22,15 @@ #include "avformat.h" #include "rawenc.h" -#define PCMDEF(name, long_name, ext, codec) \ -AVOutputFormat ff_pcm_ ## name ## _muxer = {\ - #name,\ - NULL_IF_CONFIG_SMALL(long_name),\ - NULL,\ - ext,\ - 0,\ - codec,\ - CODEC_ID_NONE,\ - NULL,\ - ff_raw_write_packet,\ - .flags= AVFMT_NOTIMESTAMPS,\ +#define PCMDEF(name_, long_name_, ext, codec) \ +AVOutputFormat ff_pcm_ ## name_ ## _muxer = { \ + .name = #name_, \ + .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ + .extensions = ext, \ + .audio_codec = codec, \ + .video_codec = CODEC_ID_NONE, \ + .write_packet = ff_raw_write_packet, \ + .flags = AVFMT_NOTIMESTAMPS, \ }; PCMDEF(f64be, "PCM 64 bit floating-point big-endian format", diff --git a/libavformat/txd.c b/libavformat/txd.c index 0a93b7c760..e6fae08aa0 100644 --- a/libavformat/txd.c +++ b/libavformat/txd.c @@ -90,12 +90,10 @@ next_chunk: return 0; } -AVInputFormat ff_txd_demuxer = -{ - "txd", - NULL_IF_CONFIG_SMALL("Renderware TeXture Dictionary"), - 0, - txd_probe, - txd_read_header, - txd_read_packet, +AVInputFormat ff_txd_demuxer = { + .name = "txd", + .long_name = NULL_IF_CONFIG_SMALL("Renderware TeXture Dictionary"), + .read_probe = txd_probe, + .read_header = txd_read_header, + .read_packet = txd_read_packet, }; From 8671488799e7f03d7bc985099b73e18ea519ab39 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 23 Sep 2011 21:11:15 +0200 Subject: [PATCH 09/11] Use explicit struct initializers for AVCodec declarations. --- libavcodec/adpcm.c | 20 +++--- libavcodec/adpcmenc.c | 23 +++---- libavcodec/dpcm.c | 20 +++--- libavcodec/jpeglsenc.c | 17 +++-- libavcodec/libopenjpeg.c | 23 +++---- libavcodec/libvorbis.c | 24 +++---- libavcodec/ljpegenc.c | 16 ++--- libavcodec/mpegaudiodec.c | 114 ++++++++++++++------------------ libavcodec/mpegaudiodec_float.c | 114 ++++++++++++++------------------ libavcodec/ra144dec.c | 19 +++--- libavcodec/ra144enc.c | 19 +++--- libavcodec/ra288.c | 19 +++--- libavcodec/roqvideoenc.c | 21 +++--- libavcodec/twinvq.c | 20 +++--- libavcodec/wmadec.c | 44 ++++++------ libavcodec/wmaenc.c | 42 ++++++------ 16 files changed, 252 insertions(+), 303 deletions(-) diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 3baa07b982..5e83e4b37a 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -1086,17 +1086,15 @@ static int adpcm_decode_frame(AVCodecContext *avctx, } -#define ADPCM_DECODER(id,name,long_name_) \ -AVCodec ff_ ## name ## _decoder = { \ - #name, \ - AVMEDIA_TYPE_AUDIO, \ - id, \ - sizeof(ADPCMDecodeContext), \ - adpcm_decode_init, \ - NULL, \ - NULL, \ - adpcm_decode_frame, \ - .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ +#define ADPCM_DECODER(id_, name_, long_name_) \ +AVCodec ff_ ## name_ ## _decoder = { \ + .name = #name_, \ + .type = AVMEDIA_TYPE_AUDIO, \ + .id = id_, \ + .priv_data_size = sizeof(ADPCMDecodeContext), \ + .init = adpcm_decode_init, \ + .decode = adpcm_decode_frame, \ + .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ } /* Note: Do not forget to add new entries to the Makefile as well. */ diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c index 2a117f4aae..d46a8c98b6 100644 --- a/libavcodec/adpcmenc.c +++ b/libavcodec/adpcmenc.c @@ -667,18 +667,17 @@ static int adpcm_encode_frame(AVCodecContext *avctx, } -#define ADPCM_ENCODER(id,name,long_name_) \ -AVCodec ff_ ## name ## _encoder = { \ - #name, \ - AVMEDIA_TYPE_AUDIO, \ - id, \ - sizeof(ADPCMEncodeContext), \ - adpcm_encode_init, \ - adpcm_encode_frame, \ - adpcm_encode_close, \ - NULL, \ - .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, \ - .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ +#define ADPCM_ENCODER(id_, name_, long_name_) \ +AVCodec ff_ ## name_ ## _encoder = { \ + .name = #name_, \ + .type = AVMEDIA_TYPE_AUDIO, \ + .id = id_, \ + .priv_data_size = sizeof(ADPCMEncodeContext), \ + .init = adpcm_encode_init, \ + .encode = adpcm_encode_frame, \ + .close = adpcm_encode_close, \ + .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, \ + .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ } ADPCM_ENCODER(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt, "ADPCM IMA QuickTime"); diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c index af5bf8abea..34c739a790 100644 --- a/libavcodec/dpcm.c +++ b/libavcodec/dpcm.c @@ -298,17 +298,15 @@ static int dpcm_decode_frame(AVCodecContext *avctx, return buf_size; } -#define DPCM_DECODER(id, name, long_name_) \ -AVCodec ff_ ## name ## _decoder = { \ - #name, \ - AVMEDIA_TYPE_AUDIO, \ - id, \ - sizeof(DPCMContext), \ - dpcm_decode_init, \ - NULL, \ - NULL, \ - dpcm_decode_frame, \ - .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ +#define DPCM_DECODER(id_, name_, long_name_) \ +AVCodec ff_ ## name_ ## _decoder = { \ + .name = #name_, \ + .type = AVMEDIA_TYPE_AUDIO, \ + .id = id_, \ + .priv_data_size = sizeof(DPCMContext), \ + .init = dpcm_decode_init, \ + .decode = dpcm_decode_frame, \ + .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ } DPCM_DECODER(CODEC_ID_INTERPLAY_DPCM, interplay_dpcm, "DPCM Interplay"); diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c index a825cf9d6b..d15269e91d 100644 --- a/libavcodec/jpeglsenc.c +++ b/libavcodec/jpeglsenc.c @@ -383,13 +383,12 @@ static av_cold int encode_init_ls(AVCodecContext *ctx) { } AVCodec ff_jpegls_encoder = { //FIXME avoid MPV_* lossless JPEG should not need them - "jpegls", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_JPEGLS, - sizeof(JpeglsContext), - encode_init_ls, - encode_picture_ls, - NULL, - .pix_fmts= (const enum PixelFormat[]){PIX_FMT_BGR24, PIX_FMT_RGB24, PIX_FMT_GRAY8, PIX_FMT_GRAY16, PIX_FMT_NONE}, - .long_name= NULL_IF_CONFIG_SMALL("JPEG-LS"), + .name = "jpegls", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_JPEGLS, + .priv_data_size = sizeof(JpeglsContext), + .init = encode_init_ls, + .encode = encode_picture_ls, + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_BGR24, PIX_FMT_RGB24, PIX_FMT_GRAY8, PIX_FMT_GRAY16, PIX_FMT_NONE}, + .long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"), }; diff --git a/libavcodec/libopenjpeg.c b/libavcodec/libopenjpeg.c index 6e9e8fc68d..42809b992f 100644 --- a/libavcodec/libopenjpeg.c +++ b/libavcodec/libopenjpeg.c @@ -185,15 +185,14 @@ static av_cold int libopenjpeg_decode_close(AVCodecContext *avctx) AVCodec ff_libopenjpeg_decoder = { - "libopenjpeg", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_JPEG2000, - sizeof(LibOpenJPEGContext), - libopenjpeg_decode_init, - NULL, - libopenjpeg_decode_close, - libopenjpeg_decode_frame, - CODEC_CAP_DR1, - .max_lowres = 5, - .long_name = NULL_IF_CONFIG_SMALL("OpenJPEG based JPEG 2000 decoder"), -} ; + .name = "libopenjpeg", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_JPEG2000, + .priv_data_size = sizeof(LibOpenJPEGContext), + .init = libopenjpeg_decode_init, + .close = libopenjpeg_decode_close, + .decode = libopenjpeg_decode_frame, + .capabilities = CODEC_CAP_DR1, + .max_lowres = 5, + .long_name = NULL_IF_CONFIG_SMALL("OpenJPEG based JPEG 2000 decoder"), +}; diff --git a/libavcodec/libvorbis.c b/libavcodec/libvorbis.c index 85cb9c5989..703f3d55ff 100644 --- a/libavcodec/libvorbis.c +++ b/libavcodec/libvorbis.c @@ -245,15 +245,15 @@ static av_cold int oggvorbis_encode_close(AVCodecContext *avccontext) { AVCodec ff_libvorbis_encoder = { - "libvorbis", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_VORBIS, - sizeof(OggVorbisContext), - oggvorbis_encode_init, - oggvorbis_encode_frame, - oggvorbis_encode_close, - .capabilities= CODEC_CAP_DELAY, - .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, - .long_name= NULL_IF_CONFIG_SMALL("libvorbis Vorbis"), - .priv_class= &class, -} ; + .name = "libvorbis", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_VORBIS, + .priv_data_size = sizeof(OggVorbisContext), + .init = oggvorbis_encode_init, + .encode = oggvorbis_encode_frame, + .close = oggvorbis_encode_close, + .capabilities = CODEC_CAP_DELAY, + .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, + .long_name = NULL_IF_CONFIG_SMALL("libvorbis Vorbis"), + .priv_class = &class, +}; diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c index 56a60c913e..6a90338eb9 100644 --- a/libavcodec/ljpegenc.c +++ b/libavcodec/ljpegenc.c @@ -187,12 +187,12 @@ static int encode_picture_lossless(AVCodecContext *avctx, unsigned char *buf, in AVCodec ff_ljpeg_encoder = { //FIXME avoid MPV_* lossless JPEG should not need them - "ljpeg", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_LJPEG, - sizeof(MpegEncContext), - MPV_encode_init, - encode_picture_lossless, - MPV_encode_end, - .long_name = NULL_IF_CONFIG_SMALL("Lossless JPEG"), + .name = "ljpeg", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_LJPEG, + .priv_data_size = sizeof(MpegEncContext), + .init = MPV_encode_init, + .encode = encode_picture_lossless, + .close = MPV_encode_end, + .long_name = NULL_IF_CONFIG_SMALL("Lossless JPEG"), }; diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index 033d76e049..6f841e87b1 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -2051,82 +2051,68 @@ static int decode_frame_mp3on4(AVCodecContext * avctx, #if !CONFIG_FLOAT #if CONFIG_MP1_DECODER -AVCodec ff_mp1_decoder = -{ - "mp1", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MP1, - sizeof(MPADecodeContext), - decode_init, - NULL, - NULL, - decode_frame, - CODEC_CAP_PARSE_ONLY, - .flush= flush, - .long_name= NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"), +AVCodec ff_mp1_decoder = { + .name = "mp1", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MP1, + .priv_data_size = sizeof(MPADecodeContext), + .init = decode_init, + .decode = decode_frame, + .capabilities = CODEC_CAP_PARSE_ONLY, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"), }; #endif #if CONFIG_MP2_DECODER -AVCodec ff_mp2_decoder = -{ - "mp2", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MP2, - sizeof(MPADecodeContext), - decode_init, - NULL, - NULL, - decode_frame, - CODEC_CAP_PARSE_ONLY, - .flush= flush, - .long_name= NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"), +AVCodec ff_mp2_decoder = { + .name = "mp2", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MP2, + .priv_data_size = sizeof(MPADecodeContext), + .init = decode_init, + .decode = decode_frame, + .capabilities = CODEC_CAP_PARSE_ONLY, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"), }; #endif #if CONFIG_MP3_DECODER -AVCodec ff_mp3_decoder = -{ - "mp3", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MP3, - sizeof(MPADecodeContext), - decode_init, - NULL, - NULL, - decode_frame, - CODEC_CAP_PARSE_ONLY, - .flush= flush, - .long_name= NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"), +AVCodec ff_mp3_decoder = { + .name = "mp3", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MP3, + .priv_data_size = sizeof(MPADecodeContext), + .init = decode_init, + .decode = decode_frame, + .capabilities = CODEC_CAP_PARSE_ONLY, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"), }; #endif #if CONFIG_MP3ADU_DECODER -AVCodec ff_mp3adu_decoder = -{ - "mp3adu", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MP3ADU, - sizeof(MPADecodeContext), - decode_init, - NULL, - NULL, - decode_frame_adu, - CODEC_CAP_PARSE_ONLY, - .flush= flush, - .long_name= NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"), +AVCodec ff_mp3adu_decoder = { + .name = "mp3adu", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MP3ADU, + .priv_data_size = sizeof(MPADecodeContext), + .init = decode_init, + .decode = decode_frame_adu, + .capabilities = CODEC_CAP_PARSE_ONLY, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"), }; #endif #if CONFIG_MP3ON4_DECODER -AVCodec ff_mp3on4_decoder = -{ - "mp3on4", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MP3ON4, - sizeof(MP3On4DecodeContext), - decode_init_mp3on4, - NULL, - decode_close_mp3on4, - decode_frame_mp3on4, - .flush= flush, - .long_name= NULL_IF_CONFIG_SMALL("MP3onMP4"), +AVCodec ff_mp3on4_decoder = { + .name = "mp3on4", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MP3ON4, + .priv_data_size = sizeof(MP3On4DecodeContext), + .init = decode_init_mp3on4, + .close = decode_close_mp3on4, + .decode = decode_frame_mp3on4, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"), }; #endif #endif diff --git a/libavcodec/mpegaudiodec_float.c b/libavcodec/mpegaudiodec_float.c index 0ff866af31..929d72738b 100644 --- a/libavcodec/mpegaudiodec_float.c +++ b/libavcodec/mpegaudiodec_float.c @@ -23,81 +23,67 @@ #include "mpegaudiodec.c" #if CONFIG_MP1FLOAT_DECODER -AVCodec ff_mp1float_decoder = -{ - "mp1float", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MP1, - sizeof(MPADecodeContext), - decode_init, - NULL, - .close = NULL, - decode_frame, - CODEC_CAP_PARSE_ONLY, - .flush= flush, - .long_name= NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"), +AVCodec ff_mp1float_decoder = { + .name = "mp1float", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MP1, + .priv_data_size = sizeof(MPADecodeContext), + .init = decode_init, + .decode = decode_frame, + .capabilities = CODEC_CAP_PARSE_ONLY, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"), }; #endif #if CONFIG_MP2FLOAT_DECODER -AVCodec ff_mp2float_decoder = -{ - "mp2float", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MP2, - sizeof(MPADecodeContext), - decode_init, - NULL, - .close = NULL, - decode_frame, - CODEC_CAP_PARSE_ONLY, - .flush= flush, - .long_name= NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"), +AVCodec ff_mp2float_decoder = { + .name = "mp2float", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MP2, + .priv_data_size = sizeof(MPADecodeContext), + .init = decode_init, + .decode = decode_frame, + .capabilities = CODEC_CAP_PARSE_ONLY, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"), }; #endif #if CONFIG_MP3FLOAT_DECODER -AVCodec ff_mp3float_decoder = -{ - "mp3float", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MP3, - sizeof(MPADecodeContext), - decode_init, - NULL, - .close = NULL, - decode_frame, - CODEC_CAP_PARSE_ONLY, - .flush= flush, - .long_name= NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"), +AVCodec ff_mp3float_decoder = { + .name = "mp3float", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MP3, + .priv_data_size = sizeof(MPADecodeContext), + .init = decode_init, + .decode = decode_frame, + .capabilities = CODEC_CAP_PARSE_ONLY, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"), }; #endif #if CONFIG_MP3ADUFLOAT_DECODER -AVCodec ff_mp3adufloat_decoder = -{ - "mp3adufloat", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MP3ADU, - sizeof(MPADecodeContext), - decode_init, - NULL, - .close = NULL, - decode_frame_adu, - CODEC_CAP_PARSE_ONLY, - .flush= flush, - .long_name= NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"), +AVCodec ff_mp3adufloat_decoder = { + .name = "mp3adufloat", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MP3ADU, + .priv_data_size = sizeof(MPADecodeContext), + .init = decode_init, + .decode = decode_frame_adu, + .capabilities = CODEC_CAP_PARSE_ONLY, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"), }; #endif #if CONFIG_MP3ON4FLOAT_DECODER -AVCodec ff_mp3on4float_decoder = -{ - "mp3on4float", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_MP3ON4, - sizeof(MP3On4DecodeContext), - decode_init_mp3on4, - NULL, - decode_close_mp3on4, - decode_frame_mp3on4, - .flush= flush, - .long_name= NULL_IF_CONFIG_SMALL("MP3onMP4"), +AVCodec ff_mp3on4float_decoder = { + .name = "mp3on4float", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_MP3ON4, + .priv_data_size = sizeof(MP3On4DecodeContext), + .init = decode_init_mp3on4, + .close = decode_close_mp3on4, + .decode = decode_frame_mp3on4, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"), }; #endif diff --git a/libavcodec/ra144dec.c b/libavcodec/ra144dec.c index e64b6c20b4..10c85b72e2 100644 --- a/libavcodec/ra144dec.c +++ b/libavcodec/ra144dec.c @@ -114,15 +114,12 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, return 20; } -AVCodec ff_ra_144_decoder = -{ - "real_144", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_RA_144, - sizeof(RA144Context), - ra144_decode_init, - NULL, - NULL, - ra144_decode_frame, - .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"), +AVCodec ff_ra_144_decoder = { + .name = "real_144", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_RA_144, + .priv_data_size = sizeof(RA144Context), + .init = ra144_decode_init, + .decode = ra144_decode_frame, + .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"), }; diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c index 6eab6c300f..c475cbc933 100644 --- a/libavcodec/ra144enc.c +++ b/libavcodec/ra144enc.c @@ -508,14 +508,13 @@ static int ra144_encode_frame(AVCodecContext *avctx, uint8_t *frame, } -AVCodec ff_ra_144_encoder = -{ - "real_144", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_RA_144, - sizeof(RA144Context), - ra144_encode_init, - ra144_encode_frame, - ra144_encode_close, - .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K) encoder"), +AVCodec ff_ra_144_encoder = { + .name = "real_144", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_RA_144, + .priv_data_size = sizeof(RA144Context), + .init = ra144_encode_init, + .encode = ra144_encode_frame, + .close = ra144_encode_close, + .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K) encoder"), }; diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c index 64d765cecd..a0b86a2bf0 100644 --- a/libavcodec/ra288.c +++ b/libavcodec/ra288.c @@ -203,15 +203,12 @@ static int ra288_decode_frame(AVCodecContext * avctx, void *data, return avctx->block_align; } -AVCodec ff_ra_288_decoder = -{ - "real_288", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_RA_288, - sizeof(RA288Context), - ra288_decode_init, - NULL, - NULL, - ra288_decode_frame, - .long_name = NULL_IF_CONFIG_SMALL("RealAudio 2.0 (28.8K)"), +AVCodec ff_ra_288_decoder = { + .name = "real_288", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_RA_288, + .priv_data_size = sizeof(RA288Context), + .init = ra288_decode_init, + .decode = ra288_decode_frame, + .long_name = NULL_IF_CONFIG_SMALL("RealAudio 2.0 (28.8K)"), }; diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c index 052dcef3de..2a62d5509d 100644 --- a/libavcodec/roqvideoenc.c +++ b/libavcodec/roqvideoenc.c @@ -1065,16 +1065,15 @@ static int roq_encode_end(AVCodecContext *avctx) return 0; } -AVCodec ff_roq_encoder = -{ - "roqvideo", - AVMEDIA_TYPE_VIDEO, - CODEC_ID_ROQ, - sizeof(RoqContext), - roq_encode_init, - roq_encode_frame, - roq_encode_end, +AVCodec ff_roq_encoder = { + .name = "roqvideo", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_ROQ, + .priv_data_size = sizeof(RoqContext), + .init = roq_encode_init, + .encode = roq_encode_frame, + .close = roq_encode_end, .supported_framerates = (const AVRational[]){{30,1}, {0,0}}, - .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV444P, PIX_FMT_NONE}, - .long_name = NULL_IF_CONFIG_SMALL("id RoQ video"), + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV444P, PIX_FMT_NONE}, + .long_name = NULL_IF_CONFIG_SMALL("id RoQ video"), }; diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c index 86c81a1b0f..1326d22ea7 100644 --- a/libavcodec/twinvq.c +++ b/libavcodec/twinvq.c @@ -1120,15 +1120,13 @@ static av_cold int twin_decode_close(AVCodecContext *avctx) return 0; } -AVCodec ff_twinvq_decoder = -{ - "twinvq", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_TWINVQ, - sizeof(TwinContext), - twin_decode_init, - NULL, - twin_decode_close, - twin_decode_frame, - .long_name = NULL_IF_CONFIG_SMALL("VQF TwinVQ"), +AVCodec ff_twinvq_decoder = { + .name = "twinvq", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_TWINVQ, + .priv_data_size = sizeof(TwinContext), + .init = twin_decode_init, + .close = twin_decode_close, + .decode = twin_decode_frame, + .long_name = NULL_IF_CONFIG_SMALL("VQF TwinVQ"), }; diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c index 479b34c3e0..389bf02931 100644 --- a/libavcodec/wmadec.c +++ b/libavcodec/wmadec.c @@ -916,30 +916,26 @@ static av_cold void flush(AVCodecContext *avctx) s->last_superframe_len= 0; } -AVCodec ff_wmav1_decoder = -{ - "wmav1", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_WMAV1, - sizeof(WMACodecContext), - wma_decode_init, - NULL, - ff_wma_end, - wma_decode_superframe, - .flush=flush, - .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"), +AVCodec ff_wmav1_decoder = { + .name = "wmav1", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_WMAV1, + .priv_data_size = sizeof(WMACodecContext), + .init = wma_decode_init, + .close = ff_wma_end, + .decode = wma_decode_superframe, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"), }; -AVCodec ff_wmav2_decoder = -{ - "wmav2", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_WMAV2, - sizeof(WMACodecContext), - wma_decode_init, - NULL, - ff_wma_end, - wma_decode_superframe, - .flush=flush, - .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"), +AVCodec ff_wmav2_decoder = { + .name = "wmav2", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_WMAV2, + .priv_data_size = sizeof(WMACodecContext), + .init = wma_decode_init, + .close = ff_wma_end, + .decode = wma_decode_superframe, + .flush = flush, + .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"), }; diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c index 3cdb4a0b9b..2abc97a082 100644 --- a/libavcodec/wmaenc.c +++ b/libavcodec/wmaenc.c @@ -390,28 +390,26 @@ static int encode_superframe(AVCodecContext *avctx, return put_bits_ptr(&s->pb) - s->pb.buf; } -AVCodec ff_wmav1_encoder = -{ - "wmav1", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_WMAV1, - sizeof(WMACodecContext), - encode_init, - encode_superframe, - ff_wma_end, - .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, - .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"), +AVCodec ff_wmav1_encoder = { + .name = "wmav1", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_WMAV1, + .priv_data_size = sizeof(WMACodecContext), + .init = encode_init, + .encode = encode_superframe, + .close = ff_wma_end, + .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, + .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"), }; -AVCodec ff_wmav2_encoder = -{ - "wmav2", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_WMAV2, - sizeof(WMACodecContext), - encode_init, - encode_superframe, - ff_wma_end, - .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, - .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"), +AVCodec ff_wmav2_encoder = { + .name = "wmav2", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_WMAV2, + .priv_data_size = sizeof(WMACodecContext), + .init = encode_init, + .encode = encode_superframe, + .close = ff_wma_end, + .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, + .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"), }; From 87a74f478f1c9ff21c2c0101a498506ce6b1d631 Mon Sep 17 00:00:00 2001 From: Sean McGovern Date: Sat, 17 Sep 2011 00:36:37 -0400 Subject: [PATCH 10/11] configure: disable hardware capabilities ELF section with suncc on Solaris x86 When using suncc to build, the Solaris linker will mark an executable with each instruction set encountered by the Solaris assembler. As our libraries contain their own guards for processor-specific code, instead suppress generation of the HWCAPS ELF section on Solaris x86 only. Signed-off-by: Janne Grunau --- configure | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/configure b/configure index e01d9fda86..8440cab5d0 100755 --- a/configure +++ b/configure @@ -2370,6 +2370,12 @@ case $target_os in enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS" network_extralibs="-lsocket -lnsl" add_cppflags -D__EXTENSIONS__ + # When using suncc to build, the Solaris linker will mark + # an executable with each instruction set encountered by + # the Solaris assembler. As our libraries contain their own + # guards for processor-specific code, instead suppress + # generation of the HWCAPS ELF section on Solaris x86 only. + enabled_all suncc x86 && echo "hwcap_1 = OVERRIDE;" > mapfile && add_ldflags -Wl,-M,mapfile nm_opts='-P -g' ;; netbsd) From 2b4e49d4281690db67073ba644ad2ffc17767cdf Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Sat, 24 Sep 2011 16:16:38 +0200 Subject: [PATCH 11/11] flvdec: Fix invalid pointer deferences when parsing index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Storsjö --- libavformat/flvdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 569d7343c3..474c4d8658 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -196,8 +196,8 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, AVStream } } - if (timeslen == fileposlen) - for(i = 0; i < arraylen; i++) + if (!ret && timeslen == fileposlen) + for (i = 0; i < fileposlen; i++) av_add_index_entry(vstream, filepositions[i], times[i]*1000, 0, 0, AVINDEX_KEYFRAME); else av_log(s, AV_LOG_WARNING, "Invalid keyframes object, skipping.\n");