Skip to content

Instantly share code, notes, and snippets.

@nu774
Created June 2, 2015 15:01
Show Gist options
  • Save nu774/e268b2cde8fb73355e58 to your computer and use it in GitHub Desktop.
Save nu774/e268b2cde8fb73355e58 to your computer and use it in GitHub Desktop.
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 7b306c9..e3d6e99 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -443,6 +443,7 @@ static int output_configure(AACContext *ac,
AVCodecContext *avctx = ac->avctx;
int i, channels = 0, ret;
uint64_t layout = 0;
+ int type_counts[TYPE_END] = { 0 };
if (ac->oc[1].layout_map != layout_map) {
memcpy(ac->oc[1].layout_map, layout_map, tags * sizeof(layout_map[0]));
@@ -456,12 +457,14 @@ static int output_configure(AACContext *ac,
for (i = 0; i < tags; i++) {
int type = layout_map[i][0];
int id = layout_map[i][1];
+ int iid = type_counts[type]++;
int position = layout_map[i][2];
// Allocate or free elements depending on if they are in the
// current program configuration.
- ret = che_configure(ac, position, type, id, &channels);
+ ret = che_configure(ac, position, type, iid, &channels);
if (ret < 0)
return ret;
+ ac->tag_che_map[type][id] = ac->che[type][iid];
}
if (ac->oc[1].m4ac.ps == 1 && channels == 2) {
if (layout == AV_CH_FRONT_CENTER) {
@@ -471,7 +474,6 @@ static int output_configure(AACContext *ac,
}
}
- memcpy(ac->tag_che_map, ac->che, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0]));
avctx->channel_layout = ac->oc[1].channel_layout = layout;
avctx->channels = ac->oc[1].channels = channels;
ac->oc[1].status = oc_type;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment