Mercurial > libavcodec.hg
comparison aacdec.c @ 11886:2d81202be6e2 libavcodec
Add HE-AAC v2 support to the AAC decoder.
author | alexc |
---|---|
date | Sat, 19 Jun 2010 14:14:51 +0000 |
parents | 758c052eb8a9 |
children | c883aa4aa616 |
comparison
equal
deleted
inserted
replaced
11885:0e777af9160a | 11886:2d81202be6e2 |
---|---|
65 * Y Spectral Band Replication | 65 * Y Spectral Band Replication |
66 * Y (not in this code) Layer-1 | 66 * Y (not in this code) Layer-1 |
67 * Y (not in this code) Layer-2 | 67 * Y (not in this code) Layer-2 |
68 * Y (not in this code) Layer-3 | 68 * Y (not in this code) Layer-3 |
69 * N SinuSoidal Coding (Transient, Sinusoid, Noise) | 69 * N SinuSoidal Coding (Transient, Sinusoid, Noise) |
70 * N (planned) Parametric Stereo | 70 * Y Parametric Stereo |
71 * N Direct Stream Transfer | 71 * N Direct Stream Transfer |
72 * | 72 * |
73 * Note: - HE AAC v1 comprises LC AAC with Spectral Band Replication. | 73 * Note: - HE AAC v1 comprises LC AAC with Spectral Band Replication. |
74 * - HE AAC v2 comprises LC AAC with Spectral Band Replication and | 74 * - HE AAC v2 comprises LC AAC with Spectral Band Replication and |
75 Parametric Stereo. | 75 Parametric Stereo. |
198 if (!ac->che[type][id] && !(ac->che[type][id] = av_mallocz(sizeof(ChannelElement)))) | 198 if (!ac->che[type][id] && !(ac->che[type][id] = av_mallocz(sizeof(ChannelElement)))) |
199 return AVERROR(ENOMEM); | 199 return AVERROR(ENOMEM); |
200 ff_aac_sbr_ctx_init(&ac->che[type][id]->sbr); | 200 ff_aac_sbr_ctx_init(&ac->che[type][id]->sbr); |
201 if (type != TYPE_CCE) { | 201 if (type != TYPE_CCE) { |
202 ac->output_data[(*channels)++] = ac->che[type][id]->ch[0].ret; | 202 ac->output_data[(*channels)++] = ac->che[type][id]->ch[0].ret; |
203 if (type == TYPE_CPE) { | 203 if (type == TYPE_CPE || |
204 (type == TYPE_SCE && ac->m4ac.ps == 1)) { | |
204 ac->output_data[(*channels)++] = ac->che[type][id]->ch[1].ret; | 205 ac->output_data[(*channels)++] = ac->che[type][id]->ch[1].ret; |
205 } | 206 } |
206 } | 207 } |
207 } else { | 208 } else { |
208 if (ac->che[type][id]) | 209 if (ac->che[type][id]) |
226 int channel_config, enum OCStatus oc_type) | 227 int channel_config, enum OCStatus oc_type) |
227 { | 228 { |
228 AVCodecContext *avctx = ac->avctx; | 229 AVCodecContext *avctx = ac->avctx; |
229 int i, type, channels = 0, ret; | 230 int i, type, channels = 0, ret; |
230 | 231 |
232 if (new_che_pos != che_pos) | |
231 memcpy(che_pos, new_che_pos, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); | 233 memcpy(che_pos, new_che_pos, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); |
232 | 234 |
233 if (channel_config) { | 235 if (channel_config) { |
234 for (i = 0; i < tags_per_config[channel_config]; i++) { | 236 for (i = 0; i < tags_per_config[channel_config]; i++) { |
235 if ((ret = che_configure(ac, che_pos, | 237 if ((ret = che_configure(ac, che_pos, |
469 return -1; | 471 return -1; |
470 if (ac->m4ac.sampling_index > 12) { | 472 if (ac->m4ac.sampling_index > 12) { |
471 av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index); | 473 av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index); |
472 return -1; | 474 return -1; |
473 } | 475 } |
476 if (ac->m4ac.sbr == 1 && ac->m4ac.ps == -1) | |
477 ac->m4ac.ps = 1; | |
474 | 478 |
475 skip_bits_long(&gb, i); | 479 skip_bits_long(&gb, i); |
476 | 480 |
477 switch (ac->m4ac.object_type) { | 481 switch (ac->m4ac.object_type) { |
478 case AOT_AAC_MAIN: | 482 case AOT_AAC_MAIN: |
1665 return res; | 1669 return res; |
1666 } else if (ac->m4ac.sbr == -1 && ac->output_configured == OC_LOCKED) { | 1670 } else if (ac->m4ac.sbr == -1 && ac->output_configured == OC_LOCKED) { |
1667 av_log(ac->avctx, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n"); | 1671 av_log(ac->avctx, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n"); |
1668 skip_bits_long(gb, 8 * cnt - 4); | 1672 skip_bits_long(gb, 8 * cnt - 4); |
1669 return res; | 1673 return res; |
1674 } else if (ac->m4ac.ps == -1 && ac->output_configured < OC_LOCKED && ac->avctx->channels == 1) { | |
1675 ac->m4ac.sbr = 1; | |
1676 ac->m4ac.ps = 1; | |
1677 output_configure(ac, ac->che_pos, ac->che_pos, ac->m4ac.chan_config, ac->output_configured); | |
1670 } else { | 1678 } else { |
1671 ac->m4ac.sbr = 1; | 1679 ac->m4ac.sbr = 1; |
1672 } | 1680 } |
1673 res = ff_decode_sbr_extension(ac, &che->sbr, gb, crc_flag, cnt, elem_type); | 1681 res = ff_decode_sbr_extension(ac, &che->sbr, gb, crc_flag, cnt, elem_type); |
1674 break; | 1682 break; |
1944 if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_config, OC_TRIAL_FRAME)) | 1952 if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_config, OC_TRIAL_FRAME)) |
1945 return -7; | 1953 return -7; |
1946 } else if (ac->output_configured != OC_LOCKED) { | 1954 } else if (ac->output_configured != OC_LOCKED) { |
1947 ac->output_configured = OC_NONE; | 1955 ac->output_configured = OC_NONE; |
1948 } | 1956 } |
1949 if (ac->output_configured != OC_LOCKED) | 1957 if (ac->output_configured != OC_LOCKED) { |
1950 ac->m4ac.sbr = -1; | 1958 ac->m4ac.sbr = -1; |
1959 ac->m4ac.ps = -1; | |
1960 } | |
1951 ac->m4ac.sample_rate = hdr_info.sample_rate; | 1961 ac->m4ac.sample_rate = hdr_info.sample_rate; |
1952 ac->m4ac.sampling_index = hdr_info.sampling_index; | 1962 ac->m4ac.sampling_index = hdr_info.sampling_index; |
1953 ac->m4ac.object_type = hdr_info.object_type; | 1963 ac->m4ac.object_type = hdr_info.object_type; |
1954 if (!ac->avctx->sample_rate) | 1964 if (!ac->avctx->sample_rate) |
1955 ac->avctx->sample_rate = hdr_info.sample_rate; | 1965 ac->avctx->sample_rate = hdr_info.sample_rate; |