You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
aacdec: Simplify output configuration.
This commit is contained in:
@@ -189,10 +189,10 @@ static int count_channels(enum ChannelPosition che_pos[4][MAX_ELEM_ID])
|
|||||||
* @return Returns error status. 0 - OK, !0 - error
|
* @return Returns error status. 0 - OK, !0 - error
|
||||||
*/
|
*/
|
||||||
static av_cold int che_configure(AACContext *ac,
|
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)
|
int type, int id, int *channels)
|
||||||
{
|
{
|
||||||
if (che_pos[type][id]) {
|
if (che_pos) {
|
||||||
if (!ac->che[type][id]) {
|
if (!ac->che[type][id]) {
|
||||||
if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement))))
|
if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement))))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
@@ -222,22 +222,21 @@ static av_cold int che_configure(AACContext *ac,
|
|||||||
* @return Returns error status. 0 - OK, !0 - error
|
* @return Returns error status. 0 - OK, !0 - error
|
||||||
*/
|
*/
|
||||||
static av_cold int output_configure(AACContext *ac,
|
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],
|
enum ChannelPosition new_che_pos[4][MAX_ELEM_ID],
|
||||||
int channel_config, enum OCStatus oc_type)
|
int channel_config, enum OCStatus oc_type)
|
||||||
{
|
{
|
||||||
AVCodecContext *avctx = ac->avctx;
|
AVCodecContext *avctx = ac->avctx;
|
||||||
int i, type, channels = 0, ret;
|
int i, type, channels = 0, ret;
|
||||||
|
|
||||||
if (new_che_pos != che_pos)
|
if (new_che_pos)
|
||||||
memcpy(che_pos, new_che_pos, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
|
memcpy(ac->che_pos, new_che_pos, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
|
||||||
|
|
||||||
if (channel_config) {
|
if (channel_config) {
|
||||||
for (i = 0; i < tags_per_config[channel_config]; i++) {
|
for (i = 0; i < tags_per_config[channel_config]; i++) {
|
||||||
if ((ret = che_configure(ac, che_pos,
|
int id = aac_channel_layout_map[channel_config - 1][i][1];
|
||||||
aac_channel_layout_map[channel_config - 1][i][0],
|
type = aac_channel_layout_map[channel_config - 1][i][0];
|
||||||
aac_channel_layout_map[channel_config - 1][i][1],
|
if ((ret = che_configure(ac, ac->che_pos[type][id],
|
||||||
&channels)))
|
type, id, &channels)))
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,7 +255,8 @@ static av_cold int output_configure(AACContext *ac,
|
|||||||
|
|
||||||
for (i = 0; i < MAX_ELEM_ID; i++) {
|
for (i = 0; i < MAX_ELEM_ID; i++) {
|
||||||
for (type = 0; type < 4; type++) {
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -437,7 +437,7 @@ static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx,
|
|||||||
} else if (m4ac->sbr == 1 && m4ac->ps == -1)
|
} else if (m4ac->sbr == 1 && m4ac->ps == -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;
|
return ret;
|
||||||
|
|
||||||
if (extension_flag) {
|
if (extension_flag) {
|
||||||
@@ -610,7 +610,7 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
|
|||||||
if (ac->m4ac.chan_config) {
|
if (ac->m4ac.chan_config) {
|
||||||
int ret = set_default_channel_config(avctx, new_che_pos, ac->m4ac.chan_config);
|
int ret = set_default_channel_config(avctx, new_che_pos, ac->m4ac.chan_config);
|
||||||
if (!ret)
|
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)
|
else if (avctx->err_recognition & AV_EF_EXPLODE)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
@@ -1714,7 +1714,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) {
|
} else if (ac->m4ac.ps == -1 && ac->output_configured < OC_LOCKED && ac->avctx->channels == 1) {
|
||||||
ac->m4ac.sbr = 1;
|
ac->m4ac.sbr = 1;
|
||||||
ac->m4ac.ps = 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 {
|
} else {
|
||||||
ac->m4ac.sbr = 1;
|
ac->m4ac.sbr = 1;
|
||||||
}
|
}
|
||||||
@@ -2097,7 +2097,7 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb)
|
|||||||
ac->m4ac.chan_config = hdr_info.chan_config;
|
ac->m4ac.chan_config = hdr_info.chan_config;
|
||||||
if (set_default_channel_config(ac->avctx, new_che_pos, hdr_info.chan_config))
|
if (set_default_channel_config(ac->avctx, new_che_pos, hdr_info.chan_config))
|
||||||
return -7;
|
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)))
|
FFMAX(ac->output_configured, OC_TRIAL_FRAME)))
|
||||||
return -7;
|
return -7;
|
||||||
} else if (ac->output_configured != OC_LOCKED) {
|
} else if (ac->output_configured != OC_LOCKED) {
|
||||||
@@ -2192,7 +2192,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
|
|||||||
av_log(avctx, AV_LOG_ERROR,
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
"Not evaluating a further program_config_element as this construct is dubious at best.\n");
|
"Not evaluating a further program_config_element as this construct is dubious at best.\n");
|
||||||
else
|
else
|
||||||
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);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user