summaryrefslogtreecommitdiff
path: root/libavcodec/aacenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-01-31 01:14:58 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-01-31 02:46:26 +0100
commit151ecc2aecd81718e2520936dd3c537d7e6fe2fc (patch)
treed30c9048773a1138a4567fead3fd2c440db745bc /libavcodec/aacenc.c
parentb8c16558828e73e933ae73b5888345d50e897dfc (diff)
parentd7edd359ec28142120eb7fde77b775309b6038d8 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: (26 commits) avconv: deprecate the -deinterlace option doc: Fix the name of the new function aacenc: make sure to encode enough frames to cover all input samples. aacenc: only use the number of input samples provided by the user. wmadec: Verify bitstream size makes sense before calling init_get_bits. kmvc: Log into a context at a log level constant. mpeg12: Pad framerate tab to 16 entries. kgv1dec: Increase offsets array size so it is large enough. kmvc: Check palsize. nsvdec: Propagate errors nsvdec: Be more careful with av_malloc(). nsvdec: Fix use of uninitialized streams. movenc: cosmetics: Get rid of camelCase identifiers swscale: more generic check for planar destination formats with alpha doc: Document mov/mp4 fragmentation options build: Use order-only prerequisites for creating FATE reference file dirs. x86 dsputil: provide SSE2/SSSE3 versions of bswap_buf rtsp: Remove some unused variables from ff_rtsp_connect(). avutil: make intfloat api public avformat_write_header(): detail error message ... Conflicts: doc/APIchanges doc/ffmpeg.texi doc/muxers.texi ffmpeg.c libavcodec/kmvc.c libavcodec/x86/Makefile libavcodec/x86/dsputil_yasm.asm libavcodec/x86/pngdsp-init.c libavformat/movenc.c libavformat/movenc.h libavformat/mpegtsenc.c libavformat/nsvdec.c libavformat/utils.c libavutil/avutil.h libswscale/swscale.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/aacenc.c')
-rw-r--r--libavcodec/aacenc.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 2ff6f9cc04..51c2fa8662 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -223,8 +223,9 @@ WINDOW_FUNC(eight_short)
const float *pwindow = sce->ics.use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128;
const float *in = audio + 448;
float *out = sce->ret;
+ int w;
- for (int w = 0; w < 8; w++) {
+ for (w = 0; w < 8; w++) {
dsp->vector_fmul (out, in, w ? pwindow : swindow, 128);
out += 128;
in += 128;
@@ -476,7 +477,7 @@ static void put_bitstream_info(AVCodecContext *avctx, AACEncContext *s,
* Channels are reordered from Libav's default order to AAC order.
*/
static void deinterleave_input_samples(AACEncContext *s,
- const float *samples)
+ const float *samples, int nb_samples)
{
int ch, i;
const int sinc = s->channels;
@@ -490,10 +491,12 @@ static void deinterleave_input_samples(AACEncContext *s,
memcpy(&s->planar_samples[ch][1024], &s->planar_samples[ch][2048], 1024 * sizeof(s->planar_samples[0][0]));
/* deinterleave */
- for (i = 2048; i < 3072; i++) {
+ for (i = 2048; i < 2048 + nb_samples; i++) {
s->planar_samples[ch][i] = *sptr;
sptr += sinc;
}
+ memset(&s->planar_samples[ch][i], 0,
+ (3072 - i) * sizeof(s->planar_samples[0][0]));
}
}
@@ -507,14 +510,12 @@ static int aac_encode_frame(AVCodecContext *avctx,
int chan_el_counter[4];
FFPsyWindowInfo windows[AAC_MAX_CHANNELS];
- if (s->last_frame)
+ if (s->last_frame == 2)
return 0;
- if (data) {
- deinterleave_input_samples(s, data);
- if (s->psypp)
- ff_psy_preprocess(s->psypp, s->planar_samples, s->channels);
- }
+ deinterleave_input_samples(s, data, data ? avctx->frame_size : 0);
+ if (s->psypp)
+ ff_psy_preprocess(s->psypp, s->planar_samples, s->channels);
if (!avctx->frame_number)
return 0;
@@ -645,7 +646,7 @@ static int aac_encode_frame(AVCodecContext *avctx,
}
if (!data)
- s->last_frame = 1;
+ s->last_frame++;
return put_bits_count(&s->pb)>>3;
}
@@ -686,11 +687,12 @@ static av_cold int dsp_init(AVCodecContext *avctx, AACEncContext *s)
static av_cold int alloc_buffers(AVCodecContext *avctx, AACEncContext *s)
{
+ int ch;
FF_ALLOCZ_OR_GOTO(avctx, s->buffer.samples, 3 * 1024 * s->channels * sizeof(s->buffer.samples[0]), alloc_fail);
FF_ALLOCZ_OR_GOTO(avctx, s->cpe, sizeof(ChannelElement) * s->chan_map[0], alloc_fail);
FF_ALLOCZ_OR_GOTO(avctx, avctx->extradata, 5 + FF_INPUT_BUFFER_PADDING_SIZE, alloc_fail);
- for(int ch = 0; ch < s->channels; ch++)
+ for(ch = 0; ch < s->channels; ch++)
s->planar_samples[ch] = s->buffer.samples + 3 * 1024 * ch;
return 0;