diff options
Diffstat (limited to 'libavcodec/aacdec.c')
-rw-r--r-- | libavcodec/aacdec.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 77ee59f0ab..4e591222fc 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -189,10 +189,10 @@ static int count_channels(enum ChannelPosition che_pos[4][MAX_ELEM_ID]) * @return Returns error status. 0 - OK, !0 - error */ static av_cold int che_configure(AACContext *ac, - enum ChannelPosition che_pos[4][MAX_ELEM_ID], + enum ChannelPosition che_pos, int type, int id, int *channels) { - if (che_pos[type][id]) { + if (che_pos) { if (!ac->che[type][id]) { if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement)))) return AVERROR(ENOMEM); @@ -222,22 +222,21 @@ static av_cold int che_configure(AACContext *ac, * @return Returns error status. 0 - OK, !0 - error */ static av_cold int output_configure(AACContext *ac, - enum ChannelPosition che_pos[4][MAX_ELEM_ID], enum ChannelPosition new_che_pos[4][MAX_ELEM_ID], int channel_config, enum OCStatus oc_type) { AVCodecContext *avctx = ac->avctx; int i, type, channels = 0, ret; - if (new_che_pos != che_pos) - memcpy(che_pos, new_che_pos, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); + if (new_che_pos) + memcpy(ac->che_pos, new_che_pos, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); if (channel_config) { for (i = 0; i < tags_per_config[channel_config]; i++) { - if ((ret = che_configure(ac, che_pos, - aac_channel_layout_map[channel_config - 1][i][0], - aac_channel_layout_map[channel_config - 1][i][1], - &channels))) + int id = aac_channel_layout_map[channel_config - 1][i][1]; + type = aac_channel_layout_map[channel_config - 1][i][0]; + if ((ret = che_configure(ac, ac->che_pos[type][id], + type, id, &channels))) return ret; } @@ -249,14 +248,12 @@ static av_cold int output_configure(AACContext *ac, * current program configuration. * * Set up default 1:1 output mapping. - * - * For a 5.1 stream the output order will be: - * [ Center ] [ Front Left ] [ Front Right ] [ LFE ] [ Surround Left ] [ Surround Right ] */ for (i = 0; i < MAX_ELEM_ID; i++) { for (type = 0; type < 4; type++) { - if ((ret = che_configure(ac, che_pos, type, i, &channels))) + if ((ret = che_configure(ac, ac->che_pos[type][i], + type, i, &channels))) return ret; } } @@ -456,7 +453,7 @@ static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx, } else if (m4ac->sbr == 1 && m4ac->ps == -1) m4ac->ps = 1; - if (ac && (ret = output_configure(ac, ac->che_pos, new_che_pos, channel_config, OC_GLOBAL_HDR))) + if (ac && (ret = output_configure(ac, new_che_pos, channel_config, OC_GLOBAL_HDR))) return ret; if (extension_flag) { @@ -629,7 +626,7 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) if (ac->m4ac.chan_config) { int ret = set_default_channel_config(avctx, new_che_pos, ac->m4ac.chan_config); if (!ret) - output_configure(ac, ac->che_pos, new_che_pos, ac->m4ac.chan_config, OC_GLOBAL_HDR); + output_configure(ac, new_che_pos, ac->m4ac.chan_config, OC_GLOBAL_HDR); else if (avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; } @@ -1733,7 +1730,7 @@ static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt, } else if (ac->m4ac.ps == -1 && ac->output_configured < OC_LOCKED && ac->avctx->channels == 1) { ac->m4ac.sbr = 1; ac->m4ac.ps = 1; - output_configure(ac, ac->che_pos, ac->che_pos, ac->m4ac.chan_config, ac->output_configured); + output_configure(ac, NULL, ac->m4ac.chan_config, ac->output_configured); } else { ac->m4ac.sbr = 1; } @@ -2116,7 +2113,7 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb) ac->m4ac.chan_config = hdr_info.chan_config; if (set_default_channel_config(ac->avctx, new_che_pos, hdr_info.chan_config)) return -7; - if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_config, + if (output_configure(ac, new_che_pos, hdr_info.chan_config, FFMAX(ac->output_configured, OC_TRIAL_FRAME))) return -7; } else if (ac->output_configured != OC_LOCKED) { @@ -2176,7 +2173,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data, if (set_default_channel_config(ac->avctx, new_che_pos, 2)<0) return -1; - if (output_configure(ac, ac->che_pos, new_che_pos, 2, OC_TRIAL_FRAME)<0) + if (output_configure(ac, new_che_pos, 2, OC_TRIAL_FRAME)<0) return -1; } if (!(che=get_che(ac, elem_type, elem_id))) { @@ -2220,7 +2217,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data, if (ac->output_configured > OC_TRIAL_PCE) av_log(avctx, AV_LOG_INFO, "Evaluating a further program_config_element.\n"); - err = output_configure(ac, ac->che_pos, new_che_pos, 0, OC_TRIAL_PCE); + err = output_configure(ac, new_che_pos, 0, OC_TRIAL_PCE); if (!err) ac->m4ac.chan_config = 0; break; |