Lines Matching refs:ac
97 static int output_configure(AACContext *ac,
127 static av_cold int che_configure(AACContext *ac, in che_configure() argument
134 if (!ac->che[type][id]) { in che_configure()
135 if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement)))) in che_configure()
137 AAC_RENAME(ff_aac_sbr_ctx_init)(ac, &ac->che[type][id]->sbr, type); in che_configure()
140 …if (*channels >= MAX_CHANNELS - (type == TYPE_CPE || (type == TYPE_SCE && ac->oc[1].m4ac.ps == 1))… in che_configure()
141 av_log(ac->avctx, AV_LOG_ERROR, "Too many channels\n"); in che_configure()
144 ac->output_element[(*channels)++] = &ac->che[type][id]->ch[0]; in che_configure()
146 (type == TYPE_SCE && ac->oc[1].m4ac.ps == 1)) { in che_configure()
147 ac->output_element[(*channels)++] = &ac->che[type][id]->ch[1]; in che_configure()
151 if (ac->che[type][id]) in che_configure()
152 AAC_RENAME(ff_aac_sbr_ctx_close)(&ac->che[type][id]->sbr); in che_configure()
153 av_freep(&ac->che[type][id]); in che_configure()
160 AACContext *ac = avctx->priv_data; in frame_configure_elements() local
166 ChannelElement *che = ac->che[type][id]; in frame_configure_elements()
175 av_frame_unref(ac->frame); in frame_configure_elements()
179 ac->frame->nb_samples = 2048; in frame_configure_elements()
180 if ((ret = ff_get_buffer(avctx, ac->frame, 0)) < 0) in frame_configure_elements()
185 if (ac->output_element[ch]) in frame_configure_elements()
186 ac->output_element[ch]->ret = (INTFLOAT *)ac->frame->extended_data[ch]; in frame_configure_elements()
501 static int push_output_configuration(AACContext *ac) { in push_output_configuration() argument
504 if (ac->oc[1].status == OC_LOCKED || ac->oc[0].status == OC_NONE) { in push_output_configuration()
505 ac->oc[0] = ac->oc[1]; in push_output_configuration()
508 ac->oc[1].status = OC_NONE; in push_output_configuration()
516 static void pop_output_configuration(AACContext *ac) { in pop_output_configuration() argument
517 if (ac->oc[1].status != OC_LOCKED && ac->oc[0].status != OC_NONE) { in pop_output_configuration()
518 ac->oc[1] = ac->oc[0]; in pop_output_configuration()
519 ac->avctx->channels = ac->oc[1].channels; in pop_output_configuration()
520 ac->avctx->channel_layout = ac->oc[1].channel_layout; in pop_output_configuration()
521 output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, in pop_output_configuration()
522 ac->oc[1].status, 0); in pop_output_configuration()
532 static int output_configure(AACContext *ac, in output_configure() argument
536 AVCodecContext *avctx = ac->avctx; in output_configure()
542 if (ac->oc[1].layout_map != layout_map) { in output_configure()
543 memcpy(ac->oc[1].layout_map, layout_map, tags * sizeof(layout_map[0])); in output_configure()
544 ac->oc[1].layout_map_tags = tags; in output_configure()
551 avpriv_request_sample(ac->avctx, "Too large remapped id"); in output_configure()
566 ret = che_configure(ac, position, type, iid, &channels); in output_configure()
569 ac->tag_che_map[type][id] = ac->che[type][iid]; in output_configure()
571 if (ac->oc[1].m4ac.ps == 1 && channels == 2) { in output_configure()
580 ac->oc[1].channel_layout = layout; in output_configure()
581 avctx->channels = ac->oc[1].channels = channels; in output_configure()
582 ac->oc[1].status = oc_type; in output_configure()
585 if ((ret = frame_configure_elements(ac->avctx)) < 0) in output_configure()
594 AACContext *ac= avctx->priv_data; in flush() local
599 ChannelElement *che = ac->che[type][i]; in flush()
615 static int set_default_channel_config(AACContext *ac, AVCodecContext *avctx, in set_default_channel_config() argument
645 if (!ac || !ac->warned_71_wide++) { in set_default_channel_config()
655 static ChannelElement *get_che(AACContext *ac, int type, int elem_id) in get_che() argument
659 if (!ac->oc[1].m4ac.chan_config) { in get_che()
660 return ac->tag_che_map[type][elem_id]; in get_che()
663 if (!ac->tags_mapped && type == TYPE_CPE && in get_che()
664 ac->oc[1].m4ac.chan_config == 1) { in get_che()
667 push_output_configuration(ac); in get_che()
669 av_log(ac->avctx, AV_LOG_DEBUG, "mono with CPE\n"); in get_che()
671 if (set_default_channel_config(ac, ac->avctx, layout_map, in get_che()
674 if (output_configure(ac, layout_map, layout_map_tags, in get_che()
678 ac->oc[1].m4ac.chan_config = 2; in get_che()
679 ac->oc[1].m4ac.ps = 0; in get_che()
682 if (!ac->tags_mapped && type == TYPE_SCE && in get_che()
683 ac->oc[1].m4ac.chan_config == 2) { in get_che()
686 push_output_configuration(ac); in get_che()
688 av_log(ac->avctx, AV_LOG_DEBUG, "stereo with SCE\n"); in get_che()
690 if (set_default_channel_config(ac, ac->avctx, layout_map, in get_che()
693 if (output_configure(ac, layout_map, layout_map_tags, in get_che()
697 ac->oc[1].m4ac.chan_config = 1; in get_che()
698 if (ac->oc[1].m4ac.sbr) in get_che()
699 ac->oc[1].m4ac.ps = -1; in get_che()
703 switch (ac->oc[1].m4ac.chan_config) { in get_che()
705 if (ac->tags_mapped > 3 && ((type == TYPE_CPE && elem_id < 8) || in get_che()
708 ac->tags_mapped++; in get_che()
709 return ac->tag_che_map[type][elem_id] = ac->che[type][elem_id]; in get_che()
713 if (ac->tags_mapped == 3 && type == TYPE_CPE) { in get_che()
714 ac->tags_mapped++; in get_che()
715 return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2]; in get_che()
718 if (ac->tags_mapped == 2 && in get_che()
719 ac->oc[1].m4ac.chan_config == 11 && in get_che()
721 ac->tags_mapped++; in get_che()
722 return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1]; in get_che()
731 …if (ac->tags_mapped == tags_per_config[ac->oc[1].m4ac.chan_config] - 1 && (type == TYPE_LFE || typ… in get_che()
732 if (!ac->warned_remapping_once && (type != TYPE_LFE || elem_id != 0)) { in get_che()
733 av_log(ac->avctx, AV_LOG_WARNING, in get_che()
736 ac->warned_remapping_once++; in get_che()
738 ac->tags_mapped++; in get_che()
739 return ac->tag_che_map[type][elem_id] = ac->che[TYPE_LFE][0]; in get_che()
742 if (ac->tags_mapped == 2 && type == TYPE_CPE) { in get_che()
743 ac->tags_mapped++; in get_che()
744 return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][1]; in get_che()
753 …if (ac->tags_mapped == tags_per_config[ac->oc[1].m4ac.chan_config] - 1 && (type == TYPE_LFE || typ… in get_che()
754 if (!ac->warned_remapping_once && (type != TYPE_SCE || elem_id != 1)) { in get_che()
755 av_log(ac->avctx, AV_LOG_WARNING, in get_che()
758 ac->warned_remapping_once++; in get_che()
760 ac->tags_mapped++; in get_che()
761 return ac->tag_che_map[type][elem_id] = ac->che[TYPE_SCE][1]; in get_che()
763 if (ac->tags_mapped == 2 && in get_che()
764 ac->oc[1].m4ac.chan_config == 4 && in get_che()
766 ac->tags_mapped++; in get_che()
767 return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1]; in get_che()
771 if (ac->tags_mapped == (ac->oc[1].m4ac.chan_config != 2) && in get_che()
773 ac->tags_mapped++; in get_che()
774 return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][0]; in get_che()
775 } else if (ac->oc[1].m4ac.chan_config == 2) { in get_che()
779 if (!ac->tags_mapped && type == TYPE_SCE) { in get_che()
780 ac->tags_mapped++; in get_che()
781 return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][0]; in get_che()
906 static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx, in decode_ga_specific_config() argument
926 if (ac) ac->warned_960_sbr = 1; in decode_ga_specific_config()
946 if ((ret = set_default_channel_config(ac, avctx, layout_map, in decode_ga_specific_config()
956 if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) in decode_ga_specific_config()
995 static int decode_eld_specific_config(AACContext *ac, AVCodecContext *avctx, in decode_eld_specific_config() argument
1042 if ((ret = set_default_channel_config(ac, avctx, layout_map, in decode_eld_specific_config()
1046 if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) in decode_eld_specific_config()
1070 static int decode_audio_specific_config_gb(AACContext *ac, in decode_audio_specific_config_gb() argument
1111 if ((ret = decode_ga_specific_config(ac, avctx, gb, get_bit_alignment, in decode_audio_specific_config_gb()
1116 if ((ret = decode_eld_specific_config(ac, avctx, gb, in decode_audio_specific_config_gb()
1137 static int decode_audio_specific_config(AACContext *ac, in decode_audio_specific_config() argument
1159 return decode_audio_specific_config_gb(ac, avctx, m4ac, &gb, 0, in decode_audio_specific_config()
1206 static void aacdec_init(AACContext *ac);
1261 AACContext *ac = avctx->priv_data; in aac_decode_init() local
1271 ac->avctx = avctx; in aac_decode_init()
1272 ac->oc[1].m4ac.sample_rate = avctx->sample_rate; in aac_decode_init()
1274 aacdec_init(ac); in aac_decode_init()
1282 if ((ret = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac, in aac_decode_init()
1293 ac->oc[1].m4ac.sampling_index = sr; in aac_decode_init()
1294 ac->oc[1].m4ac.channels = avctx->channels; in aac_decode_init()
1295 ac->oc[1].m4ac.sbr = -1; in aac_decode_init()
1296 ac->oc[1].m4ac.ps = -1; in aac_decode_init()
1304 ac->oc[1].m4ac.chan_config = i; in aac_decode_init()
1306 if (ac->oc[1].m4ac.chan_config) { in aac_decode_init()
1307 int ret = set_default_channel_config(ac, avctx, layout_map, in aac_decode_init()
1308 &layout_map_tags, ac->oc[1].m4ac.chan_config); in aac_decode_init()
1310 output_configure(ac, layout_map, layout_map_tags, in aac_decode_init()
1323 ac->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT); in aac_decode_init()
1325 ac->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); in aac_decode_init()
1327 if (!ac->fdsp) { in aac_decode_init()
1331 ac->random_state = 0x1f2e3d4c; in aac_decode_init()
1333 AAC_RENAME_32(ff_mdct_init)(&ac->mdct, 11, 1, 1.0 / RANGE15(1024.0)); in aac_decode_init()
1334 AAC_RENAME_32(ff_mdct_init)(&ac->mdct_ld, 10, 1, 1.0 / RANGE15(512.0)); in aac_decode_init()
1335 AAC_RENAME_32(ff_mdct_init)(&ac->mdct_small, 8, 1, 1.0 / RANGE15(128.0)); in aac_decode_init()
1336 AAC_RENAME_32(ff_mdct_init)(&ac->mdct_ltp, 11, 0, RANGE15(-2.0)); in aac_decode_init()
1338 ret = ff_mdct15_init(&ac->mdct120, 1, 3, 1.0f/(16*1024*120*2)); in aac_decode_init()
1341 ret = ff_mdct15_init(&ac->mdct480, 1, 5, 1.0f/(16*1024*960)); in aac_decode_init()
1344 ret = ff_mdct15_init(&ac->mdct960, 1, 6, 1.0f/(16*1024*960*2)); in aac_decode_init()
1355 static int skip_data_stream_element(AACContext *ac, GetBitContext *gb) in skip_data_stream_element() argument
1365 av_log(ac->avctx, AV_LOG_ERROR, "skip_data_stream_element: "overread_err); in skip_data_stream_element()
1372 static int decode_prediction(AACContext *ac, IndividualChannelStream *ics, in decode_prediction() argument
1380 av_log(ac->avctx, AV_LOG_ERROR, in decode_prediction()
1385 …for (sfb = 0; sfb < FFMIN(ics->max_sfb, ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index]); sfb++… in decode_prediction()
1408 static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, in decode_ics_info() argument
1411 const MPEG4AudioConfig *const m4ac = &ac->oc[1].m4ac; in decode_ics_info()
1418 av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n"); in decode_ics_info()
1419 if (ac->avctx->err_recognition & AV_EF_BITSTREAM) in decode_ics_info()
1426 av_log(ac->avctx, AV_LOG_ERROR, in decode_ics_info()
1491 if (decode_prediction(ac, ics, gb)) { in decode_ics_info()
1496 av_log(ac->avctx, AV_LOG_ERROR, in decode_ics_info()
1501 av_log(ac->avctx, AV_LOG_ERROR, in decode_ics_info()
1513 av_log(ac->avctx, AV_LOG_ERROR, in decode_ics_info()
1534 static int decode_band_types(AACContext *ac, enum BandType band_type[120], in decode_band_types() argument
1547 av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n"); in decode_band_types()
1554 av_log(ac->avctx, AV_LOG_ERROR, "decode_band_types: "overread_err); in decode_band_types()
1558 av_log(ac->avctx, AV_LOG_ERROR, in decode_band_types()
1583 static int decode_scalefactors(AACContext *ac, INTFLOAT sf[120], GetBitContext *gb, in decode_scalefactors() argument
1605 avpriv_request_sample(ac->avctx, in decode_scalefactors()
1624 avpriv_request_sample(ac->avctx, in decode_scalefactors()
1639 av_log(ac->avctx, AV_LOG_ERROR, in decode_scalefactors()
1685 static int decode_tns(AACContext *ac, TemporalNoiseShaping *tns, in decode_tns() argument
1690 const int tns_max_order = is8 ? 7 : ac->oc[1].m4ac.object_type == AOT_AAC_MAIN ? 20 : 12; in decode_tns()
1700 av_log(ac->avctx, AV_LOG_ERROR, in decode_tns()
1753 static int decode_spectrum_and_dequant(AACContext *ac, INTFLOAT coef[1024], in decode_spectrum_and_dequant() argument
1786 ac->random_state = lcg_random(ac->random_state); in decode_spectrum_and_dequant()
1787 cfo[k] = ac->random_state >> 3; in decode_spectrum_and_dequant()
1790 band_energy = ac->fdsp->scalarproduct_fixed(cfo, cfo, off_len); in decode_spectrum_and_dequant()
1797 ac->random_state = lcg_random(ac->random_state); in decode_spectrum_and_dequant()
1798 cfo[k] = ac->random_state; in decode_spectrum_and_dequant()
1801 band_energy = ac->fdsp->scalarproduct_float(cfo, cfo, off_len); in decode_spectrum_and_dequant()
1803 ac->fdsp->vector_fmul_scalar(cfo, cfo, scale, off_len); in decode_spectrum_and_dequant()
1953 … av_log(ac->avctx, AV_LOG_ERROR, "error in spectral data, ESC overflow\n"); in decode_spectrum_and_dequant()
1986 ac->fdsp->vector_fmul_scalar(cfo, cfo, sf[idx], off_len); in decode_spectrum_and_dequant()
2034 ac->vector_pow43(cfo, off_len); in decode_spectrum_and_dequant()
2035 ac->subband_scale(cfo, cfo, sf[idx], 34, off_len, ac->avctx); in decode_spectrum_and_dequant()
2048 static void apply_prediction(AACContext *ac, SingleChannelElement *sce) in apply_prediction() argument
2059 sfb < ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index]; in apply_prediction()
2111 static int decode_ics(AACContext *ac, SingleChannelElement *sce, in decode_ics() argument
2121 eld_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD; in decode_ics()
2122 er_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_LC || in decode_ics()
2123 ac->oc[1].m4ac.object_type == AOT_ER_AAC_LTP || in decode_ics()
2124 ac->oc[1].m4ac.object_type == AOT_ER_AAC_LD || in decode_ics()
2125 ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD; in decode_ics()
2135 ret = decode_ics_info(ac, ics, gb); in decode_ics()
2140 if ((ret = decode_band_types(ac, sce->band_type, in decode_ics()
2143 if ((ret = decode_scalefactors(ac, sce->sf, gb, global_gain, ics, in decode_ics()
2151 av_log(ac->avctx, AV_LOG_ERROR, in decode_ics()
2157 av_log(ac->avctx, AV_LOG_ERROR, in decode_ics()
2165 ret = decode_tns(ac, tns, gb, ics); in decode_ics()
2171 if (!ac->warned_gain_control) { in decode_ics()
2172 avpriv_report_missing_feature(ac->avctx, "Gain control"); in decode_ics()
2173 ac->warned_gain_control = 1; in decode_ics()
2179 ret = decode_tns(ac, tns, gb, ics); in decode_ics()
2185 ret = decode_spectrum_and_dequant(ac, out, gb, sce->sf, pulse_present, in decode_ics()
2190 if (ac->oc[1].m4ac.object_type == AOT_AAC_MAIN && !common_window) in decode_ics()
2191 apply_prediction(ac, sce); in decode_ics()
2202 static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe) argument
2216 ac->fdsp->butterflies_fixed(ch0 + group * 128 + offsets[i],
2221 ac->fdsp->butterflies_float(ch0 + group * 128 + offsets[i],
2240 static void apply_intensity_stereo(AACContext *ac, argument
2262 ac->subband_scale(coef1 + group * 128 + offsets[i],
2266 offsets[i + 1] - offsets[i] ,ac->avctx);
2268 ac->fdsp->vector_fmul_scalar(coef1 + group * 128 + offsets[i],
2290 static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe) argument
2293 int eld_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD;
2297 if (decode_ics_info(ac, &cpe->ch[0].ics, gb))
2303 (ac->oc[1].m4ac.object_type != AOT_AAC_MAIN))
2308 av_log(ac->avctx, AV_LOG_ERROR, "ms_present = 3 is reserved.\n");
2313 if ((ret = decode_ics(ac, &cpe->ch[0], gb, common_window, 0)))
2315 if ((ret = decode_ics(ac, &cpe->ch[1], gb, common_window, 0)))
2320 apply_mid_side_stereo(ac, cpe);
2321 if (ac->oc[1].m4ac.object_type == AOT_AAC_MAIN) {
2322 apply_prediction(ac, &cpe->ch[0]);
2323 apply_prediction(ac, &cpe->ch[1]);
2327 apply_intensity_stereo(ac, cpe, ms_present);
2343 static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che) argument
2374 if ((ret = decode_ics(ac, sce, gb, 0, 0)))
2493 static int decode_fill(AACContext *ac, GetBitContext *gb, int len) { argument
2506 if (ac->avctx->debug & FF_DEBUG_PICT_INFO)
2507 av_log(ac->avctx, AV_LOG_DEBUG, "FILL:%s\n", buf);
2510 ac->avctx->internal->skip_samples = 1024;
2526 static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt, argument
2533 if (ac->avctx->debug & FF_DEBUG_STARTCODE)
2534 av_log(ac->avctx, AV_LOG_DEBUG, "extension type: %d len:%d\n", type, cnt);
2541 av_log(ac->avctx, AV_LOG_ERROR, "SBR was found before the first channel element.\n");
2543 } else if (ac->oc[1].m4ac.frame_length_short) {
2544 if (!ac->warned_960_sbr)
2545 avpriv_report_missing_feature(ac->avctx,
2547 ac->warned_960_sbr = 1;
2550 } else if (!ac->oc[1].m4ac.sbr) {
2551 …av_log(ac->avctx, AV_LOG_ERROR, "SBR signaled to be not-present but was found in the bitstream.\n"…
2554 } else if (ac->oc[1].m4ac.sbr == -1 && ac->oc[1].status == OC_LOCKED) {
2555 …av_log(ac->avctx, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first fr…
2558 … } else if (ac->oc[1].m4ac.ps == -1 && ac->oc[1].status < OC_LOCKED && ac->avctx->channels == 1) {
2559 ac->oc[1].m4ac.sbr = 1;
2560 ac->oc[1].m4ac.ps = 1;
2561 ac->avctx->profile = FF_PROFILE_AAC_HE_V2;
2562 output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags,
2563 ac->oc[1].status, 1);
2565 ac->oc[1].m4ac.sbr = 1;
2566 ac->avctx->profile = FF_PROFILE_AAC_HE;
2568 res = AAC_RENAME(ff_decode_sbr_extension)(ac, &che->sbr, gb, crc_flag, cnt, elem_type);
2571 res = decode_dynamic_range(&ac->che_drc, gb);
2574 decode_fill(ac, gb, 8 * cnt - 4);
2651 static void windowing_and_mdct_ltp(AACContext *ac, INTFLOAT *out, argument
2660 ac->fdsp->vector_fmul(in, in, lwindow_prev, 1024);
2663 ac->fdsp->vector_fmul(in + 448, in + 448, swindow_prev, 128);
2666 ac->fdsp->vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024);
2668 ac->fdsp->vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128);
2671 ac->mdct_ltp.mdct_calc(&ac->mdct_ltp, out, in);
2677 static void apply_ltp(AACContext *ac, SingleChannelElement *sce) argument
2685 INTFLOAT *predFreq = ac->buf_mdct;
2694 ac->windowing_and_mdct_ltp(ac, predFreq, predTime, &sce->ics);
2697 ac->apply_tns(predFreq, &sce->tns, &sce->ics, 0);
2709 static void update_ltp(AACContext *ac, SingleChannelElement *sce) argument
2721 … ac->fdsp->vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64);
2724 saved_ltp[i + 512] = AAC_MUL31(ac->buf_mdct[1023 - i], swindow[63 - i]);
2726 memcpy(saved_ltp, ac->buf_mdct + 512, 448 * sizeof(*saved_ltp));
2728 … ac->fdsp->vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64);
2731 saved_ltp[i + 512] = AAC_MUL31(ac->buf_mdct[1023 - i], swindow[63 - i]);
2733 … ac->fdsp->vector_fmul_reverse(saved_ltp, ac->buf_mdct + 512, &lwindow[512], 512);
2736 saved_ltp[i + 512] = AAC_MUL31(ac->buf_mdct[1023 - i], lwindow[511 - i]);
2747 static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce) argument
2756 INTFLOAT *buf = ac->buf_mdct;
2757 INTFLOAT *temp = ac->temp;
2763 ac->mdct_small.imdct_half(&ac->mdct_small, buf + i, in + i);
2765 ac->mdct.imdct_half(&ac->mdct, buf, in);
2780 …ac->fdsp->vector_fmul_window( out, saved, buf, lwindow_prev, 5…
2785 … ac->fdsp->vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, 64);
2786 … ac->fdsp->vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, 64);
2787 … ac->fdsp->vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, 64);
2788 … ac->fdsp->vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, 64);
2789 … ac->fdsp->vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, 64);
2792 … ac->fdsp->vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, 64);
2800 ac->fdsp->vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 64);
2801 ac->fdsp->vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 64);
2802 ac->fdsp->vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 64);
2815 static void imdct_and_windowing_960(AACContext *ac, SingleChannelElement *sce) argument
2825 INTFLOAT *buf = ac->buf_mdct;
2826 INTFLOAT *temp = ac->temp;
2832 ac->mdct120->imdct_half(ac->mdct120, buf + i * 120, in + i * 128, 1);
2834 ac->mdct960->imdct_half(ac->mdct960, buf, in, 1);
2846 …ac->fdsp->vector_fmul_window( out, saved, buf, lwindow_prev, 4…
2851 … ac->fdsp->vector_fmul_window(out + 420 + 0*120, saved + 420, buf + 0*120, swindow_prev, 60);
2852 … ac->fdsp->vector_fmul_window(out + 420 + 1*120, buf + 0*120 + 60, buf + 1*120, swindow, 60);
2853 … ac->fdsp->vector_fmul_window(out + 420 + 2*120, buf + 1*120 + 60, buf + 2*120, swindow, 60);
2854 … ac->fdsp->vector_fmul_window(out + 420 + 3*120, buf + 2*120 + 60, buf + 3*120, swindow, 60);
2855 … ac->fdsp->vector_fmul_window(temp, buf + 3*120 + 60, buf + 4*120, swindow, 60);
2858 … ac->fdsp->vector_fmul_window(out + 420, saved + 420, buf, swindow_prev, 60);
2866 ac->fdsp->vector_fmul_window(saved + 60, buf + 4*120 + 60, buf + 5*120, swindow, 60);
2867 ac->fdsp->vector_fmul_window(saved + 180, buf + 5*120 + 60, buf + 6*120, swindow, 60);
2868 ac->fdsp->vector_fmul_window(saved + 300, buf + 6*120 + 60, buf + 7*120, swindow, 60);
2878 static void imdct_and_windowing_ld(AACContext *ac, SingleChannelElement *sce) argument
2884 INTFLOAT *buf = ac->buf_mdct;
2890 ac->mdct.imdct_half(&ac->mdct_ld, buf, in);
2901 ac->fdsp->vector_fmul_window(out + 192, saved + 192, buf, AAC_RENAME2(sine_128), 64);
2904 ac->fdsp->vector_fmul_window(out, saved, buf, AAC_RENAME2(sine_512), 256);
2911 static void imdct_and_windowing_eld(AACContext *ac, SingleChannelElement *sce) argument
2916 INTFLOAT *buf = ac->buf_mdct;
2918 const int n = ac->oc[1].m4ac.frame_length_short ? 480 : 512;
2936 ac->mdct480->imdct_half(ac->mdct480, buf, in, 1);
2939 ac->mdct.imdct_half(&ac->mdct_ld, buf, in);
2984 static void apply_channel_coupling(AACContext *ac, ChannelElement *cc, argument
2987 …void (*apply_coupling_method)(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, i… argument
2992 ChannelElement *cce = ac->che[TYPE_CCE][i];
3001 apply_coupling_method(ac, &cc->ch[0], cce, index);
3006 apply_coupling_method(ac, &cc->ch[1], cce, index++);
3017 static void spectral_to_sample(AACContext *ac, int samples) argument
3020 void (*imdct_and_window)(AACContext *ac, SingleChannelElement *sce);
3021 switch (ac->oc[1].m4ac.object_type) {
3029 if (ac->oc[1].m4ac.frame_length_short)
3032 imdct_and_window = ac->imdct_and_windowing;
3036 ChannelElement *che = ac->che[type][i];
3039 … apply_channel_coupling(ac, che, type, i, BEFORE_TNS, AAC_RENAME(apply_dependent_coupling));
3040 if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) {
3043 ac->apply_ltp(ac, &che->ch[0]);
3045 ac->apply_ltp(ac, &che->ch[1]);
3049 ac->apply_tns(che->ch[0].coeffs, &che->ch[0].tns, &che->ch[0].ics, 1);
3051 ac->apply_tns(che->ch[1].coeffs, &che->ch[1].tns, &che->ch[1].ics, 1);
3053 …apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, AAC_RENAME(apply_dependent_couplin…
3055 imdct_and_window(ac, &che->ch[0]);
3056 if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP)
3057 ac->update_ltp(ac, &che->ch[0]);
3059 imdct_and_window(ac, &che->ch[1]);
3060 if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP)
3061 ac->update_ltp(ac, &che->ch[1]);
3063 if (ac->oc[1].m4ac.sbr > 0) {
3064 … AAC_RENAME(ff_sbr_apply)(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret);
3068 … apply_channel_coupling(ac, che, type, i, AFTER_IMDCT, AAC_RENAME(apply_independent_coupling));
3083 av_log(ac->avctx, AV_LOG_VERBOSE, "ChannelElement %d.%d missing \n", type, i);
3089 static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb) argument
3098 if (!ac->warned_num_aac_frames && hdr_info.num_aac_frames != 1) {
3101 avpriv_report_missing_feature(ac->avctx,
3103 ac->warned_num_aac_frames = 1;
3105 push_output_configuration(ac);
3107 ac->oc[1].m4ac.chan_config = hdr_info.chan_config;
3108 if ((ret = set_default_channel_config(ac, ac->avctx,
3113 if ((ret = output_configure(ac, layout_map, layout_map_tags,
3114 FFMAX(ac->oc[1].status,
3118 ac->oc[1].m4ac.chan_config = 0;
3124 if (ac->dmono_mode && ac->oc[0].status == OC_NONE) {
3130 if (output_configure(ac, layout_map, layout_map_tags,
3135 ac->oc[1].m4ac.sample_rate = hdr_info.sample_rate;
3136 ac->oc[1].m4ac.sampling_index = hdr_info.sampling_index;
3137 ac->oc[1].m4ac.object_type = hdr_info.object_type;
3138 ac->oc[1].m4ac.frame_length_short = 0;
3139 if (ac->oc[0].status != OC_LOCKED ||
3140 ac->oc[0].m4ac.chan_config != hdr_info.chan_config ||
3141 ac->oc[0].m4ac.sample_rate != hdr_info.sample_rate) {
3142 ac->oc[1].m4ac.sbr = -1;
3143 ac->oc[1].m4ac.ps = -1;
3154 AACContext *ac = avctx->priv_data; local
3155 const MPEG4AudioConfig *const m4ac = &ac->oc[1].m4ac;
3165 ac->frame = data;
3172 ac->avctx->profile = aot - 1;
3174 ac->tags_mapped = 0;
3184 if (!(che=get_che(ac, elem_type, elem_id))) {
3185 av_log(ac->avctx, AV_LOG_ERROR,
3195 err = decode_ics(ac, &che->ch[0], gb, 0, 0);
3198 err = decode_cpe(ac, gb, che);
3201 err = decode_ics(ac, &che->ch[0], gb, 0, 0);
3208 spectral_to_sample(ac, samples);
3210 if (!ac->frame->data[0] && samples) {
3215 ac->frame->nb_samples = samples;
3216 ac->frame->sample_rate = avctx->sample_rate;
3227 AACContext *ac = avctx->priv_data; local
3236 ac->frame = data;
3239 if ((err = parse_adts_frame_header(ac, gb)) < 0) {
3243 if (ac->oc[1].m4ac.sampling_index > 12) {
3244 …av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->oc[1].m4ac.sampling_index);
3255 ac->avctx->profile = ac->oc[1].m4ac.object_type - 1;
3258 ac->tags_mapped = 0;
3274 … av_log(ac->avctx, error ? AV_LOG_ERROR : AV_LOG_DEBUG, "channel element %d.%d duplicate\n",
3283 if (!(che=get_che(ac, elem_type, elem_id))) {
3284 av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n",
3289 samples = ac->oc[1].m4ac.frame_length_short ? 960 : 1024;
3296 err = decode_ics(ac, &che->ch[0], gb, 0, 0);
3302 err = decode_cpe(ac, gb, che);
3307 err = decode_cce(ac, gb, che);
3311 err = decode_ics(ac, &che->ch[0], gb, 0, 0);
3316 err = skip_data_stream_element(ac, gb);
3323 int pushed = push_output_configuration(ac);
3329 tags = decode_pce(avctx, &ac->oc[1].m4ac, layout_map, gb,
3338 pop_output_configuration(ac);
3340 err = output_configure(ac, layout_map, tags, OC_TRIAL_PCE, 1);
3342 ac->oc[1].m4ac.chan_config = 0;
3358 int ret = decode_extension_payload(ac, gb, elem_id, che_prev, che_prev_type);
3392 …multiplier = (ac->oc[1].m4ac.sbr == 1) ? ac->oc[1].m4ac.ext_sample_rate > ac->oc[1].m4ac.sample_ra…
3395 spectral_to_sample(ac, samples);
3397 if (ac->oc[1].status && audio_found) {
3398 avctx->sample_rate = ac->oc[1].m4ac.sample_rate << multiplier;
3400 ac->oc[1].status = OC_LOCKED;
3406 if (!ac->frame->data[0] && samples) {
3413 ac->frame->nb_samples = samples;
3414 ac->frame->sample_rate = avctx->sample_rate;
3416 av_frame_unref(ac->frame);
3420 is_dmono = ac->dmono_mode && sce_count == 2 &&
3421 ac->oc[1].channel_layout == (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT);
3423 if (ac->dmono_mode == 1)
3425 else if (ac->dmono_mode == 2)
3431 pop_output_configuration(ac);
3438 AACContext *ac = avctx->priv_data; local
3456 ac->oc[1].status = OC_NONE;
3457 err = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac,
3465 ac->dmono_mode = 0;
3467 ac->dmono_mode = 1 + *jp_dualmono;
3468 if (ac->force_dmono_mode >= 0)
3469 ac->dmono_mode = ac->force_dmono_mode;
3477 switch (ac->oc[1].m4ac.object_type) {
3500 AACContext *ac = avctx->priv_data; local
3505 if (ac->che[type][i])
3506 AAC_RENAME(ff_aac_sbr_ctx_close)(&ac->che[type][i]->sbr);
3507 av_freep(&ac->che[type][i]);
3511 ff_mdct_end(&ac->mdct);
3512 ff_mdct_end(&ac->mdct_small);
3513 ff_mdct_end(&ac->mdct_ld);
3514 ff_mdct_end(&ac->mdct_ltp);
3516 ff_mdct15_uninit(&ac->mdct120);
3517 ff_mdct15_uninit(&ac->mdct480);
3518 ff_mdct15_uninit(&ac->mdct960);
3520 av_freep(&ac->fdsp);