diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-11-06 01:50:29 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-11-06 01:50:29 +0100 |
commit | 603a282f8ff1a84677fc0279b6d83e4a23729675 (patch) | |
tree | 08060d5f3901ac2b7373f0d97854d457519956ee /libavcodec | |
parent | 39c8434bced9a860388628e624170665ddff0e44 (diff) | |
parent | 973d752dfbfb3286c6494f99744f386b98fda4d7 (diff) | |
download | ffmpeg-603a282f8ff1a84677fc0279b6d83e4a23729675.tar.gz |
Merge remote-tracking branch 'qatar/release/0.6' into release/0.6
* qatar/release/0.6:
update version
Release notes and changelog for 0.6.3
Fix memory (re)allocation in matroskadec.c, related to MSVR-11-0080.
cavs: fix some crashes with invalid bitstreams
libvo-aacenc: Sync up with 0.7.2
Fix MMX rgb24 to yuv conversion with gcc 4.6
oggdec: prevent heap corruption.
Fix ff_imdct_calc_sse() on gcc-4.6
backport libvo-aacenc wrapper for aac encoding
Conflicts:
Changelog
VERSION
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/Makefile | 1 | ||||
-rw-r--r-- | libavcodec/allcodecs.c | 1 | ||||
-rw-r--r-- | libavcodec/cavsdec.c | 11 | ||||
-rw-r--r-- | libavcodec/libvo-aacenc.c | 130 | ||||
-rw-r--r-- | libavcodec/x86/fft_sse.c | 7 |
5 files changed, 143 insertions, 7 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 3dd24e7e12..4afce9a243 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -527,6 +527,7 @@ OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER) += libschroedingerenc.o \ OBJS-$(CONFIG_LIBSPEEX_DECODER) += libspeexdec.o OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o +OBJS-$(CONFIG_LIBVO_AACENC_ENCODER) += libvo-aacenc.o mpeg4audio.o OBJS-$(CONFIG_LIBVPX_DECODER) += libvpxdec.o OBJS-$(CONFIG_LIBVPX_ENCODER) += libvpxenc.o OBJS-$(CONFIG_LIBX264_ENCODER) += libx264.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index aa3001c546..245a77be78 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -343,6 +343,7 @@ void avcodec_register_all(void) REGISTER_ENCDEC (LIBSCHROEDINGER, libschroedinger); REGISTER_DECODER (LIBSPEEX, libspeex); REGISTER_ENCODER (LIBTHEORA, libtheora); + REGISTER_ENCODER (LIBVO_AACENC, libvo_aacenc); REGISTER_ENCODER (LIBVORBIS, libvorbis); REGISTER_ENCDEC (LIBVPX, libvpx); REGISTER_ENCODER (LIBX264, libx264); diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index 9d6307c217..626f33a4a2 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -130,12 +130,14 @@ static int decode_residual_block(AVSContext *h, GetBitContext *gb, r++; mask = -(level_code & 1); level = (level^mask) - mask; - } else { + } else if (level_code >= 0) { level = r->rltab[level_code][0]; if(!level) //end of block signal break; run = r->rltab[level_code][1]; r += r->rltab[level_code][2]; + } else { + break; } level_buf[i] = level; run_buf[i] = run; @@ -189,7 +191,8 @@ static inline int decode_residual_inter(AVSContext *h) { static int decode_mb_i(AVSContext *h, int cbp_code) { GetBitContext *gb = &h->s.gb; - int block, pred_mode_uv; + unsigned pred_mode_uv; + int block; uint8_t top[18]; uint8_t *left = NULL; uint8_t *d; @@ -445,6 +448,8 @@ static inline int check_for_slice(AVSContext *h) { if((show_bits_long(gb,24+align) & 0xFFFFFF) == 0x000001) { skip_bits_long(gb,24+align); h->stc = get_bits(gb,8); + if (h->stc >= h->mb_height) + return 0; decode_slice_header(h,gb); return 1; } @@ -659,7 +664,7 @@ static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size, buf_end = buf + buf_size; for(;;) { buf_ptr = ff_find_start_code(buf_ptr,buf_end, &stc); - if(stc & 0xFFFFFE00) + if((stc & 0xFFFFFE00) || buf_ptr == buf_end) return FFMAX(0, buf_ptr - buf - s->parse_context.last_index); input_size = (buf_end - buf_ptr)*8; switch(stc) { diff --git a/libavcodec/libvo-aacenc.c b/libavcodec/libvo-aacenc.c new file mode 100644 index 0000000000..da4a7bf07d --- /dev/null +++ b/libavcodec/libvo-aacenc.c @@ -0,0 +1,130 @@ +/* + * AAC encoder wrapper + * Copyright (c) 2010 Martin Storsjo + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <vo-aacenc/voAAC.h> +#include <vo-aacenc/cmnMemory.h> + +#include "avcodec.h" +#include "mpeg4audio.h" + +typedef struct AACContext { + VO_AUDIO_CODECAPI codec_api; + VO_HANDLE handle; + VO_MEM_OPERATOR mem_operator; + VO_CODEC_INIT_USERDATA user_data; +} AACContext; + +static av_cold int aac_encode_init(AVCodecContext *avctx) +{ + AACContext *s = avctx->priv_data; + AACENC_PARAM params = { 0 }; + int index; + + avctx->coded_frame = avcodec_alloc_frame(); + avctx->frame_size = 1024; + + voGetAACEncAPI(&s->codec_api); + + s->mem_operator.Alloc = cmnMemAlloc; + s->mem_operator.Copy = cmnMemCopy; + s->mem_operator.Free = cmnMemFree; + s->mem_operator.Set = cmnMemSet; + s->mem_operator.Check = cmnMemCheck; + s->user_data.memflag = VO_IMF_USERMEMOPERATOR; + s->user_data.memData = &s->mem_operator; + s->codec_api.Init(&s->handle, VO_AUDIO_CodingAAC, &s->user_data); + + params.sampleRate = avctx->sample_rate; + params.bitRate = avctx->bit_rate; + params.nChannels = avctx->channels; + params.adtsUsed = !(avctx->flags & CODEC_FLAG_GLOBAL_HEADER); + if (s->codec_api.SetParam(s->handle, VO_PID_AAC_ENCPARAM, ¶ms) + != VO_ERR_NONE) { + av_log(avctx, AV_LOG_ERROR, "Unable to set encoding parameters\n"); + return AVERROR(EINVAL); + } + + for (index = 0; index < 16; index++) + if (avctx->sample_rate == ff_mpeg4audio_sample_rates[index]) + break; + if (index == 16) { + av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate %d\n", + avctx->sample_rate); + return AVERROR(ENOSYS); + } + if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { + avctx->extradata_size = 2; + avctx->extradata = av_mallocz(avctx->extradata_size + + FF_INPUT_BUFFER_PADDING_SIZE); + if (!avctx->extradata) + return AVERROR(ENOMEM); + + avctx->extradata[0] = 0x02 << 3 | index >> 1; + avctx->extradata[1] = (index & 0x01) << 7 | avctx->channels << 3; + } + return 0; +} + +static int aac_encode_close(AVCodecContext *avctx) +{ + AACContext *s = avctx->priv_data; + + s->codec_api.Uninit(s->handle); + av_freep(&avctx->coded_frame); + + return 0; +} + +static int aac_encode_frame(AVCodecContext *avctx, + unsigned char *frame/*out*/, + int buf_size, void *data/*in*/) +{ + AACContext *s = avctx->priv_data; + VO_CODECBUFFER input = { 0 }, output = { 0 }; + VO_AUDIO_OUTPUTINFO output_info = { { 0 } }; + + input.Buffer = data; + input.Length = 2 * avctx->channels * avctx->frame_size; + output.Buffer = frame; + output.Length = buf_size; + + s->codec_api.SetInputData(s->handle, &input); + if (s->codec_api.GetOutputData(s->handle, &output, &output_info) + != VO_ERR_NONE) { + av_log(avctx, AV_LOG_ERROR, "Unable to encode frame\n"); + return AVERROR(EINVAL); + } + return output.Length; +} + +AVCodec libvo_aacenc_encoder = { + "libvo_aacenc", + CODEC_TYPE_AUDIO, + CODEC_ID_AAC, + sizeof(AACContext), + aac_encode_init, + aac_encode_frame, + aac_encode_close, + NULL, + .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, + .long_name = NULL_IF_CONFIG_SMALL("Android VisualOn AAC"), +}; + diff --git a/libavcodec/x86/fft_sse.c b/libavcodec/x86/fft_sse.c index a4cce69db1..eaca44a34f 100644 --- a/libavcodec/x86/fft_sse.c +++ b/libavcodec/x86/fft_sse.c @@ -23,7 +23,7 @@ #include "libavcodec/dsputil.h" #include "fft.h" -DECLARE_ALIGNED(16, static const int, m1m1m1m1)[4] = +DECLARE_ASM_CONST(16, int, ff_m1m1m1m1)[4] = { 1 << 31, 1 << 31, 1 << 31, 1 << 31 }; void ff_fft_dispatch_sse(FFTComplex *z, int nbits); @@ -183,7 +183,7 @@ void ff_imdct_calc_sse(FFTContext *s, FFTSample *output, const FFTSample *input) j = -n; k = n-16; __asm__ volatile( - "movaps %4, %%xmm7 \n" + "movaps "MANGLE(ff_m1m1m1m1)", %%xmm7 \n" "1: \n" "movaps (%2,%1), %%xmm0 \n" "movaps (%3,%0), %%xmm1 \n" @@ -196,8 +196,7 @@ void ff_imdct_calc_sse(FFTContext *s, FFTSample *output, const FFTSample *input) "add $16, %0 \n" "jl 1b \n" :"+r"(j), "+r"(k) - :"r"(output+n4), "r"(output+n4*3), - "m"(*m1m1m1m1) + :"r"(output+n4), "r"(output+n4*3) ); } |