diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2009-04-17 08:39:11 +0000 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2009-04-17 08:39:11 +0000 |
commit | a7c6e1171b1984b949464c4d9070f10a1fd43d6d (patch) | |
tree | bdd1daca2bfc7ecfc91d1550f39ab3940b74b1e2 /libavcodec/ac3enc.c | |
parent | 35e2e681b820a878903c35b939bf130acdbb5c63 (diff) | |
download | ffmpeg-a7c6e1171b1984b949464c4d9070f10a1fd43d6d.tar.gz |
ac3enc: reorder input channels to AC-3 channel order
Originally committed as revision 18540 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/ac3enc.c')
-rw-r--r-- | libavcodec/ac3enc.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index e851cdbc5c..4d51c2e187 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -36,6 +36,7 @@ typedef struct AC3EncodeContext { int nb_channels; int nb_all_channels; int lfe_channel; + const uint8_t *channel_map; int bit_rate; unsigned int sample_rate; unsigned int bitstream_id; @@ -638,6 +639,7 @@ static av_cold int AC3_encode_init(AVCodecContext *avctx) s->nb_all_channels = channels; s->nb_channels = channels > 5 ? 5 : channels; s->lfe_channel = s->lfe ? 5 : -1; + s->channel_map = ff_ac3_enc_channel_map[s->channel_mode][s->lfe]; /* frequency */ for(i=0;i<3;i++) { @@ -1158,19 +1160,20 @@ static int AC3_encode_frame(AVCodecContext *avctx, frame_bits = 0; for(ch=0;ch<s->nb_all_channels;ch++) { + int ich = s->channel_map[ch]; /* fixed mdct to the six sub blocks & exponent computation */ for(i=0;i<NB_BLOCKS;i++) { int16_t *sptr; int sinc; /* compute input samples */ - memcpy(input_samples, s->last_samples[ch], N/2 * sizeof(int16_t)); + memcpy(input_samples, s->last_samples[ich], N/2 * sizeof(int16_t)); sinc = s->nb_all_channels; - sptr = samples + (sinc * (N/2) * i) + ch; + sptr = samples + (sinc * (N/2) * i) + ich; for(j=0;j<N/2;j++) { v = *sptr; input_samples[j + N/2] = v; - s->last_samples[ch][j] = v; + s->last_samples[ich][j] = v; sptr += sinc; } |