summaryrefslogtreecommitdiff
path: root/libavcodec/aacenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-10-07 11:23:29 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-10-07 11:28:38 +0200
commit79d30321a29dc648d5a475ce5086b2760d5d8c12 (patch)
treec712b09b56a0937ca08a1c89365addd8e4e33d4b /libavcodec/aacenc.c
parent537ef8bebf8a35aab448db6ec876e275a10f0f15 (diff)
parent31b2262dca9cc77709d20c45610ec8030e7f9257 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: wmaenc: use float planar sample format (e)ac3enc: use planar sample format aacenc: use planar sample format adpcmenc: use planar sample format for adpcm_ima_wav and adpcm_ima_qt adpcmenc: move 'ch' variable to higher scope adpcmenc: fix 3 instances of variable shadowing adpcm_ima_wav: simplify encoding libvorbis: use planar sample format libmp3lame: use planar sample formats vorbisenc: use float planar sample format ffm: do not write or read the audio sample format parseutils: fix parsing of invalid alpha values doc/RELEASE_NOTES: update for the 9 release. smoothstreamingenc: Add a more verbose error message smoothstreamingenc: Ignore the return value from mkdir smoothstreamingenc: Try writing a manifest when opening the muxer smoothstreamingenc: Move the output_chunk_list and write_manifest functions up smoothstreamingenc: Properly return errors from ism_flush to the caller smoothstreamingenc: Check the output UrlContext before accessing it Conflicts: doc/RELEASE_NOTES libavcodec/aacenc.c libavcodec/ac3enc_template.c libavcodec/wmaenc.c tests/ref/lavf/ffm Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/aacenc.c')
-rw-r--r--libavcodec/aacenc.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 383cb5a7c1..9178babda6 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -479,31 +479,28 @@ static void put_bitstream_info(AVCodecContext *avctx, AACEncContext *s,
}
/*
- * Deinterleave input samples.
+ * Copy input samples.
* Channels are reordered from libavcodec's default order to AAC order.
*/
-static void deinterleave_input_samples(AACEncContext *s, const AVFrame *frame)
+static void copy_input_samples(AACEncContext *s, const AVFrame *frame)
{
- int ch, i;
- const int sinc = s->channels;
- const uint8_t *channel_map = aac_chan_maps[sinc - 1];
+ int ch;
+ int end = 2048 + (frame ? frame->nb_samples : 0);
+ const uint8_t *channel_map = aac_chan_maps[s->channels - 1];
- /* deinterleave and remap input samples */
- for (ch = 0; ch < sinc; ch++) {
+ /* copy and remap input samples */
+ for (ch = 0; ch < s->channels; ch++) {
/* copy last 1024 samples of previous frame to the start of the current frame */
memcpy(&s->planar_samples[ch][1024], &s->planar_samples[ch][2048], 1024 * sizeof(s->planar_samples[0][0]));
- /* deinterleave */
- i = 2048;
+ /* copy new samples and zero any remaining samples */
if (frame) {
- const float *sptr = ((const float *)frame->data[0]) + channel_map[ch];
- for (; i < 2048 + frame->nb_samples; i++) {
- s->planar_samples[ch][i] = *sptr;
- sptr += sinc;
- }
+ memcpy(&s->planar_samples[ch][2048],
+ frame->extended_data[channel_map[ch]],
+ frame->nb_samples * sizeof(s->planar_samples[0][0]));
}
- memset(&s->planar_samples[ch][i], 0,
- (3072 - i) * sizeof(s->planar_samples[0][0]));
+ memset(&s->planar_samples[ch][end], 0,
+ (3072 - end) * sizeof(s->planar_samples[0][0]));
}
}
@@ -526,7 +523,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
return ret;
}
- deinterleave_input_samples(s, frame);
+ copy_input_samples(s, frame);
if (s->psypp)
ff_psy_preprocess(s->psypp, s->planar_samples, s->channels);
@@ -827,7 +824,7 @@ AVCodec ff_aac_encoder = {
.supported_samplerates = avpriv_mpeg4audio_sample_rates,
.capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY |
CODEC_CAP_EXPERIMENTAL,
- .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLT,
+ .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
.long_name = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"),
.priv_class = &aacenc_class,