| ... | ... |
@@ -199,8 +199,9 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) |
| 199 | 199 |
ff_init_ff_sine_windows(10); |
| 200 | 200 |
ff_init_ff_sine_windows(7); |
| 201 | 201 |
|
| 202 |
+ s->chan_map = aac_chan_configs[avctx->channels-1]; |
|
| 202 | 203 |
s->samples = av_malloc(2 * 1024 * avctx->channels * sizeof(s->samples[0])); |
| 203 |
- s->cpe = av_mallocz(sizeof(ChannelElement) * aac_chan_configs[avctx->channels-1][0]); |
|
| 204 |
+ s->cpe = av_mallocz(sizeof(ChannelElement) * s->chan_map[0]); |
|
| 204 | 205 |
avctx->extradata = av_mallocz(5 + FF_INPUT_BUFFER_PADDING_SIZE); |
| 205 | 206 |
avctx->extradata_size = 5; |
| 206 | 207 |
put_audio_specific_config(avctx); |
| ... | ... |
@@ -491,7 +492,6 @@ static int aac_encode_frame(AVCodecContext *avctx, |
| 491 | 491 |
int16_t *samples = s->samples, *samples2, *la; |
| 492 | 492 |
ChannelElement *cpe; |
| 493 | 493 |
int i, ch, w, g, chans, tag, start_ch; |
| 494 |
- const uint8_t *chan_map = aac_chan_configs[avctx->channels-1]; |
|
| 495 | 494 |
int chan_el_counter[4]; |
| 496 | 495 |
FFPsyWindowInfo windows[AAC_MAX_CHANNELS]; |
| 497 | 496 |
|
| ... | ... |
@@ -504,8 +504,8 @@ static int aac_encode_frame(AVCodecContext *avctx, |
| 504 | 504 |
} else {
|
| 505 | 505 |
start_ch = 0; |
| 506 | 506 |
samples2 = s->samples + 1024 * avctx->channels; |
| 507 |
- for (i = 0; i < chan_map[0]; i++) {
|
|
| 508 |
- tag = chan_map[i+1]; |
|
| 507 |
+ for (i = 0; i < s->chan_map[0]; i++) {
|
|
| 508 |
+ tag = s->chan_map[i+1]; |
|
| 509 | 509 |
chans = tag == TYPE_CPE ? 2 : 1; |
| 510 | 510 |
ff_psy_preprocess(s->psypp, (uint16_t*)data + start_ch, |
| 511 | 511 |
samples2 + start_ch, start_ch, chans); |
| ... | ... |
@@ -520,9 +520,9 @@ static int aac_encode_frame(AVCodecContext *avctx, |
| 520 | 520 |
} |
| 521 | 521 |
|
| 522 | 522 |
start_ch = 0; |
| 523 |
- for (i = 0; i < chan_map[0]; i++) {
|
|
| 523 |
+ for (i = 0; i < s->chan_map[0]; i++) {
|
|
| 524 | 524 |
FFPsyWindowInfo* wi = windows + start_ch; |
| 525 |
- tag = chan_map[i+1]; |
|
| 525 |
+ tag = s->chan_map[i+1]; |
|
| 526 | 526 |
chans = tag == TYPE_CPE ? 2 : 1; |
| 527 | 527 |
cpe = &s->cpe[i]; |
| 528 | 528 |
for (ch = 0; ch < chans; ch++) {
|
| ... | ... |
@@ -562,9 +562,9 @@ static int aac_encode_frame(AVCodecContext *avctx, |
| 562 | 562 |
put_bitstream_info(avctx, s, LIBAVCODEC_IDENT); |
| 563 | 563 |
start_ch = 0; |
| 564 | 564 |
memset(chan_el_counter, 0, sizeof(chan_el_counter)); |
| 565 |
- for (i = 0; i < chan_map[0]; i++) {
|
|
| 565 |
+ for (i = 0; i < s->chan_map[0]; i++) {
|
|
| 566 | 566 |
FFPsyWindowInfo* wi = windows + start_ch; |
| 567 |
- tag = chan_map[i+1]; |
|
| 567 |
+ tag = s->chan_map[i+1]; |
|
| 568 | 568 |
chans = tag == TYPE_CPE ? 2 : 1; |
| 569 | 569 |
cpe = &s->cpe[i]; |
| 570 | 570 |
put_bits(&s->pb, 3, tag); |
| ... | ... |
@@ -61,6 +61,7 @@ typedef struct AACEncContext {
|
| 61 | 61 |
int16_t *samples; ///< saved preprocessed input |
| 62 | 62 |
|
| 63 | 63 |
int samplerate_index; ///< MPEG-4 samplerate index |
| 64 |
+ uint8_t *chan_map; ///< channel configuration map |
|
| 64 | 65 |
|
| 65 | 66 |
ChannelElement *cpe; ///< channel elements |
| 66 | 67 |
FFPsyContext psy; |