Revision e22da6b6

View differences:

libavcodec/aac.c
104 104

  
105 105
static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
106 106
{
107
    static const int8_t tags_per_config[16] = { 0, 1, 1, 2, 3, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0 };
108 107
    if (ac->tag_che_map[type][elem_id]) {
109 108
        return ac->tag_che_map[type][elem_id];
110 109
    }
......
171 170

  
172 171
    memcpy(che_pos, new_che_pos, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0]));
173 172

  
173
    if (channel_config) {
174
        for (i = 0; i < tags_per_config[channel_config]; i++) {
175
            const int id = aac_channel_layout_map[channel_config - 1][i][1];
176
            type         = aac_channel_layout_map[channel_config - 1][i][0];
177

  
178
            if (!ac->che[type][id] && !(ac->che[type][id] = av_mallocz(sizeof(ChannelElement))))
179
                return AVERROR(ENOMEM);
180

  
181
            if (type != TYPE_CCE) {
182
                ac->output_data[channels++] = ac->che[type][id]->ch[0].ret;
183
                if (type == TYPE_CPE)
184
                    ac->output_data[channels++] = ac->che[type][id]->ch[1].ret;
185
            }
186
        }
187

  
188
        memset(ac->tag_che_map, 0,       4 * MAX_ELEM_ID * sizeof(ac->che[0][0]));
189
        ac->tags_mapped = 0;
190

  
191
        avctx->channel_layout = aac_channel_layout[channel_config - 1];
192
    } else {
174 193
    /* Allocate or free elements depending on if they are in the
175 194
     * current program configuration.
176 195
     *
......
196 215
        }
197 216
    }
198 217

  
199
    if (channel_config) {
200
        memset(ac->tag_che_map, 0,       4 * MAX_ELEM_ID * sizeof(ac->che[0][0]));
201
        ac->tags_mapped = 0;
202
    } else {
203 218
        memcpy(ac->tag_che_map, ac->che, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0]));
204 219
        ac->tags_mapped = 4 * MAX_ELEM_ID;
220

  
221
        avctx->channel_layout = 0;
205 222
    }
206 223

  
207 224
    avctx->channels = channels;
......
1802 1819
    .sample_fmts = (const enum SampleFormat[]) {
1803 1820
        SAMPLE_FMT_S16,SAMPLE_FMT_NONE
1804 1821
    },
1822
    .channel_layouts = aac_channel_layout,
1805 1823
};
libavcodec/aacdectab.h
69 69
};
70 70
// @}
71 71

  
72
static const int8_t tags_per_config[16] = { 0, 1, 1, 2, 3, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0 };
73

  
74
static const uint8_t aac_channel_layout_map[7][5][2] = {
75
    { { TYPE_SCE, 0 }, },
76
    { { TYPE_CPE, 0 }, },
77
    { { TYPE_CPE, 0 }, { TYPE_SCE, 0 }, },
78
    { { TYPE_CPE, 0 }, { TYPE_SCE, 0 }, { TYPE_SCE, 1 }, },
79
    { { TYPE_CPE, 0 }, { TYPE_SCE, 0 }, { TYPE_CPE, 1 }, },
80
    { { TYPE_CPE, 0 }, { TYPE_SCE, 0 }, { TYPE_LFE, 0 }, { TYPE_CPE, 1 }, },
81
    { { TYPE_CPE, 0 }, { TYPE_SCE, 0 }, { TYPE_LFE, 0 }, { TYPE_CPE, 2 }, { TYPE_CPE, 1 }, },
82
};
83

  
84
static const int64_t aac_channel_layout[8] = {
85
    CH_LAYOUT_MONO,
86
    CH_LAYOUT_STEREO,
87
    CH_LAYOUT_SURROUND,
88
    CH_LAYOUT_4POINT0,
89
    CH_LAYOUT_5POINT0_BACK,
90
    CH_LAYOUT_5POINT1_BACK,
91
    CH_LAYOUT_7POINT1_WIDE,
92
    0,
93
};
94

  
72 95
#endif /* AVCODEC_AACDECTAB_H */

Also available in: Unified diff