Mercurial > libavcodec.hg
comparison aac.c @ 10306:c97a6cabee62 libavcodec
AAC: Add channel layout support for channel configuration as defined in the
specification
author | superdump |
---|---|
date | Mon, 28 Sep 2009 15:35:13 +0000 |
parents | 10df50768c02 |
children | 4e1d3e37bba0 |
comparison
equal
deleted
inserted
replaced
10305:86fadefa1143 | 10306:c97a6cabee62 |
---|---|
102 static VLC vlc_spectral[11]; | 102 static VLC vlc_spectral[11]; |
103 | 103 |
104 | 104 |
105 static ChannelElement *get_che(AACContext *ac, int type, int elem_id) | 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 if (ac->tag_che_map[type][elem_id]) { | 107 if (ac->tag_che_map[type][elem_id]) { |
109 return ac->tag_che_map[type][elem_id]; | 108 return ac->tag_che_map[type][elem_id]; |
110 } | 109 } |
111 if (ac->tags_mapped >= tags_per_config[ac->m4ac.chan_config]) { | 110 if (ac->tags_mapped >= tags_per_config[ac->m4ac.chan_config]) { |
112 return NULL; | 111 return NULL; |
169 AVCodecContext *avctx = ac->avccontext; | 168 AVCodecContext *avctx = ac->avccontext; |
170 int i, type, channels = 0; | 169 int i, type, channels = 0; |
171 | 170 |
172 memcpy(che_pos, new_che_pos, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); | 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 /* Allocate or free elements depending on if they are in the | 193 /* Allocate or free elements depending on if they are in the |
175 * current program configuration. | 194 * current program configuration. |
176 * | 195 * |
177 * Set up default 1:1 output mapping. | 196 * Set up default 1:1 output mapping. |
178 * | 197 * |
194 } else | 213 } else |
195 av_freep(&ac->che[type][i]); | 214 av_freep(&ac->che[type][i]); |
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 memcpy(ac->tag_che_map, ac->che, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0])); | 218 memcpy(ac->tag_che_map, ac->che, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0])); |
204 ac->tags_mapped = 4 * MAX_ELEM_ID; | 219 ac->tags_mapped = 4 * MAX_ELEM_ID; |
220 | |
221 avctx->channel_layout = 0; | |
205 } | 222 } |
206 | 223 |
207 avctx->channels = channels; | 224 avctx->channels = channels; |
208 | 225 |
209 ac->output_configured = 1; | 226 ac->output_configured = 1; |
1800 aac_decode_frame, | 1817 aac_decode_frame, |
1801 .long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"), | 1818 .long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"), |
1802 .sample_fmts = (const enum SampleFormat[]) { | 1819 .sample_fmts = (const enum SampleFormat[]) { |
1803 SAMPLE_FMT_S16,SAMPLE_FMT_NONE | 1820 SAMPLE_FMT_S16,SAMPLE_FMT_NONE |
1804 }, | 1821 }, |
1822 .channel_layouts = aac_channel_layout, | |
1805 }; | 1823 }; |