• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/ffmpeg/libavcodec/

Lines Matching refs:ac

114 static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
116 if (ac->tag_che_map[type][elem_id]) {
117 return ac->tag_che_map[type][elem_id];
119 if (ac->tags_mapped >= tags_per_config[ac->m4ac.chan_config]) {
122 switch (ac->m4ac.chan_config) {
124 if (ac->tags_mapped == 3 && type == TYPE_CPE) {
125 ac->tags_mapped++;
126 return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2];
132 if (ac->tags_mapped == tags_per_config[ac->m4ac.chan_config] - 1 && (type == TYPE_LFE || type == TYPE_SCE)) {
133 ac->tags_mapped++;
134 return ac->tag_che_map[type][elem_id] = ac->che[TYPE_LFE][0];
137 if (ac->tags_mapped == 2 && type == TYPE_CPE) {
138 ac->tags_mapped++;
139 return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][1];
142 if (ac->tags_mapped == 2 && ac->m4ac.chan_config == 4 && type == TYPE_SCE) {
143 ac->tags_mapped++;
144 return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1];
148 if (ac->tags_mapped == (ac->m4ac.chan_config != 2) && type == TYPE_CPE) {
149 ac->tags_mapped++;
150 return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][0];
151 } else if (ac->m4ac.chan_config == 2) {
155 if (!ac->tags_mapped && type == TYPE_SCE) {
156 ac->tags_mapped++;
157 return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][0];
176 static av_cold int che_configure(AACContext *ac,
182 if (!ac->che[type][id] && !(ac->che[type][id] = av_mallocz(sizeof(ChannelElement))))
184 ff_aac_sbr_ctx_init(&ac->che[type][id]->sbr);
186 ac->output_data[(*channels)++] = ac->che[type][id]->ch[0].ret;
188 ac->output_data[(*channels)++] = ac->che[type][id]->ch[1].ret;
192 if (ac->che[type][id])
193 ff_aac_sbr_ctx_close(&ac->che[type][id]->sbr);
194 av_freep(&ac->che[type][id]);
207 static av_cold int output_configure(AACContext *ac,
212 AVCodecContext *avctx = ac->avccontext;
219 if ((ret = che_configure(ac, che_pos,
226 memset(ac->tag_che_map, 0, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0]));
227 ac->tags_mapped = 0;
242 if ((ret = che_configure(ac, che_pos, type, i, &channels)))
247 memcpy(ac->tag_che_map, ac->che, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0]));
248 ac->tags_mapped = 4 * MAX_ELEM_ID;
255 ac->output_configured = oc_type;
285 static int decode_pce(AACContext *ac, enum ChannelPosition new_che_pos[4][MAX_ELEM_ID],
294 if (ac->m4ac.sampling_index != sampling_index)
295 av_log(ac->avccontext, AV_LOG_WARNING, "Sample rate index in program config element does not match the sample rate index configured by the container.\n");
326 av_log(ac->avccontext, AV_LOG_ERROR, overread_err);
341 static av_cold int set_default_channel_config(AACContext *ac,
346 av_log(ac->avccontext, AV_LOG_ERROR, "invalid default channel configuration (%d)\n",
384 static int decode_ga_specific_config(AACContext *ac, GetBitContext *gb,
391 av_log_missing_feature(ac->avccontext, "960/120 MDCT window is", 1);
399 if (ac->m4ac.object_type == AOT_AAC_SCALABLE ||
400 ac->m4ac.object_type == AOT_ER_AAC_SCALABLE)
406 if ((ret = decode_pce(ac, new_che_pos, gb)))
409 if ((ret = set_default_channel_config(ac, new_che_pos, channel_config)))
412 if ((ret = output_configure(ac, ac->che_pos, new_che_pos, channel_config, OC_GLOBAL_HDR)))
416 switch (ac->m4ac.object_type) {
444 static int decode_audio_specific_config(AACContext *ac, void *data,
452 if ((i = ff_mpeg4audio_get_config(&ac->m4ac, data, data_size)) < 0)
454 if (ac->m4ac.sampling_index > 12) {
455 av_log(ac->avccontext, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index);
461 switch (ac->m4ac.object_type) {
464 if (decode_ga_specific_config(ac, &gb, ac->m4ac.chan_config))
468 av_log(ac->avccontext, AV_LOG_ERROR, "Audio object type %s%d is not supported.\n",
469 ac->m4ac.sbr == 1? "SBR+" : "", ac->m4ac.object_type);
513 AACContext *ac = avccontext->priv_data;
516 ac->avccontext = avccontext;
517 ac->m4ac.sample_rate = avccontext->sample_rate;
520 if (decode_audio_specific_config(ac, avccontext->extradata, avccontext->extradata_size))
540 dsputil_init(&ac->dsp, avccontext);
542 ac->random_state = 0x1f2e3d4c;
548 if (ac->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) {
549 ac->add_bias = 385.0f;
550 ac->sf_scale = 1. / (-1024. * 32768.);
551 ac->sf_offset = 0;
553 ac->add_bias = 0.0f;
554 ac->sf_scale = 1. / -1024.;
555 ac->sf_offset = 60;
568 ff_mdct_init(&ac->mdct, 11, 1, 1.0);
569 ff_mdct_init(&ac->mdct_small, 8, 1, 1.0);
584 static int skip_data_stream_element(AACContext *ac, GetBitContext *gb)
594 av_log(ac->avccontext, AV_LOG_ERROR, overread_err);
601 static int decode_prediction(AACContext *ac, IndividualChannelStream *ics,
608 av_log(ac->avccontext, AV_LOG_ERROR, "Invalid Predictor Reset Group.\n");
612 for (sfb = 0; sfb < FFMIN(ics->max_sfb, ff_aac_pred_sfb_max[ac->m4ac.sampling_index]); sfb++) {
623 static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics,
627 av_log(ac->avccontext, AV_LOG_ERROR, "Reserved bit set.\n");
649 ics->swb_offset = ff_swb_offset_128[ac->m4ac.sampling_index];
650 ics->num_swb = ff_aac_num_swb_128[ac->m4ac.sampling_index];
651 ics->tns_max_bands = ff_tns_max_bands_128[ac->m4ac.sampling_index];
656 ics->swb_offset = ff_swb_offset_1024[ac->m4ac.sampling_index];
657 ics->num_swb = ff_aac_num_swb_1024[ac->m4ac.sampling_index];
658 ics->tns_max_bands = ff_tns_max_bands_1024[ac->m4ac.sampling_index];
662 if (ac->m4ac.object_type == AOT_AAC_MAIN) {
663 if (decode_prediction(ac, ics, gb)) {
667 } else if (ac->m4ac.object_type == AOT_AAC_LC) {
668 av_log(ac->avccontext, AV_LOG_ERROR, "Prediction is not allowed in AAC-LC.\n");
672 av_log_missing_feature(ac->avccontext, "Predictor bit set but LTP is", 1);
680 av_log(ac->avccontext, AV_LOG_ERROR,
698 static int decode_band_types(AACContext *ac, enum BandType band_type[120],
711 av_log(ac->avccontext, AV_LOG_ERROR, "invalid band type\n");
718 av_log(ac->avccontext, AV_LOG_ERROR, overread_err);
722 av_log(ac->avccontext, AV_LOG_ERROR,
746 static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb,
752 const int sf_offset = ac->sf_offset + (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE ? 12 : 0);
767 av_log(ac->avccontext, AV_LOG_ERROR,
780 av_log(ac->avccontext, AV_LOG_ERROR,
790 av_log(ac->avccontext, AV_LOG_ERROR,
832 static int decode_tns(AACContext *ac, TemporalNoiseShaping *tns,
837 const int tns_max_order = is8 ? 7 : ac->m4ac.object_type == AOT_AAC_MAIN ? 20 : 12;
847 av_log(ac->avccontext, AV_LOG_ERROR, "TNS filter order %d is greater than maximum %d.\n",
966 static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024],
1000 ac->random_state = lcg_random(ac->random_state);
1001 cfo[k] = ac->random_state;
1004 band_energy = ac->dsp.scalarproduct_float(cfo, cfo, off_len);
1006 ac->dsp.vector_fmul_scalar(cfo, cfo, scale, off_len);
1166 av_log(ac->avccontext, AV_LOG_ERROR, "error in spectral data, ESC overflow\n");
1190 ac->dsp.vector_fmul_scalar(cfo, cfo, sf[idx], off_len);
1219 av_log(ac->avccontext, AV_LOG_ERROR,
1249 static av_always_inline void predict(AACContext *ac, PredictorState *ps, float *coef,
1263 *coef += pv * ac->sf_scale;
1265 e0 = *coef / ac->sf_scale;
1280 static void apply_prediction(AACContext *ac, SingleChannelElement *sce)
1290 for (sfb = 0; sfb < ff_aac_pred_sfb_max[ac->m4ac.sampling_index]; sfb++) {
1292 predict(ac, &sce->predictor_state[k], &sce->coeffs[k],
1310 static int decode_ics(AACContext *ac, SingleChannelElement *sce,
1327 if (decode_ics_info(ac, ics, gb, 0) < 0)
1331 if (decode_band_types(ac, sce->band_type, sce->band_type_run_end, gb, ics) < 0)
1333 if (decode_scalefactors(ac, sce->sf, gb, global_gain, ics, sce->band_type, sce->band_type_run_end) < 0)
1340 av_log(ac->avccontext, AV_LOG_ERROR, "Pulse tool not allowed in eight short sequence.\n");
1344 av_log(ac->avccontext, AV_LOG_ERROR, "Pulse data corrupt or invalid.\n");
1348 if ((tns->present = get_bits1(gb)) && decode_tns(ac, tns, gb, ics))
1351 av_log_missing_feature(ac->avccontext, "SSR", 1);
1356 if (decode_spectrum_and_dequant(ac, out, gb, sce->sf, pulse_present, &pulse, ics, sce->band_type) < 0)
1359 if (ac->m4ac.object_type == AOT_AAC_MAIN && !common_window)
1360 apply_prediction(ac, sce);
1368 static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe)
1380 ac->dsp.butterflies_float(ch0 + group * 128 + offsets[i],
1438 static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe)
1444 if (decode_ics_info(ac, &cpe->ch[0].ics, gb, 1))
1451 av_log(ac->avccontext, AV_LOG_ERROR, "ms_present = 3 is reserved.\n");
1456 if ((ret = decode_ics(ac, &cpe->ch[0], gb, common_window, 0)))
1458 if ((ret = decode_ics(ac, &cpe->ch[1], gb, common_window, 0)))
1463 apply_mid_side_stereo(ac, cpe);
1464 if (ac->m4ac.object_type == AOT_AAC_MAIN) {
1465 apply_prediction(ac, &cpe->ch[0]);
1466 apply_prediction(ac, &cpe->ch[1]);
1481 static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che)
1508 if ((ret = decode_ics(ac, sce, gb, 0, 0)))
1628 static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt,
1638 av_log(ac->avccontext, AV_LOG_ERROR, "SBR was found before the first channel element.\n");
1640 } else if (!ac->m4ac.sbr) {
1641 av_log(ac->avccontext, AV_LOG_ERROR, "SBR signaled to be not-present but was found in the bitstream.\n");
1644 } else if (ac->m4ac.sbr == -1 && ac->output_configured == OC_LOCKED) {
1645 av_log(ac->avccontext, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n");
1649 ac->m4ac.sbr = 1;
1651 res = ff_decode_sbr_extension(ac, &che->sbr, gb, crc_flag, cnt, elem_type);
1654 res = decode_dynamic_range(&ac->che_drc, gb, cnt);
1715 static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce, float bias)
1724 float *buf = ac->buf_mdct;
1725 float *temp = ac->temp;
1731 av_log(ac->avccontext, AV_LOG_WARNING,
1735 ff_imdct_half(&ac->mdct_small, buf + i, in + i);
1737 ff_imdct_half(&ac->mdct, buf, in);
1747 ac->dsp.vector_fmul_window( out, saved, buf, lwindow_prev, bias, 512);
1753 ac->dsp.vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, bias, 64);
1754 ac->dsp.vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, bias, 64);
1755 ac->dsp.vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, bias, 64);
1756 ac->dsp.vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, bias, 64);
1757 ac->dsp.vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, bias, 64);
1760 ac->dsp.vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, bias, 64);
1770 ac->dsp.vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 0, 64);
1771 ac->dsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 0, 64);
1772 ac->dsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 0, 64);
1787 static void apply_dependent_coupling(AACContext *ac,
1796 if (ac->m4ac.object_type == AOT_AAC_LTP) {
1797 av_log(ac->avccontext, AV_LOG_ERROR,
1823 static void apply_independent_coupling(AACContext *ac,
1829 const float bias = ac->add_bias;
1832 const int len = 1024 << (ac->m4ac.sbr == 1);
1844 static void apply_channel_coupling(AACContext *ac, ChannelElement *cc,
1847 void (*apply_coupling_method)(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index))
1852 ChannelElement *cce = ac->che[TYPE_CCE][i];
1861 apply_coupling_method(ac, &cc->ch[0], cce, index);
1866 apply_coupling_method(ac, &cc->ch[1], cce, index++);
1877 static void spectral_to_sample(AACContext *ac)
1880 float imdct_bias = (ac->m4ac.sbr <= 0) ? ac->add_bias : 0.0f;
1883 ChannelElement *che = ac->che[type][i];
1886 apply_channel_coupling(ac, che, type, i, BEFORE_TNS, apply_dependent_coupling);
1892 apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, apply_dependent_coupling);
1894 imdct_and_windowing(ac, &che->ch[0], imdct_bias);
1896 imdct_and_windowing(ac, &che->ch[1], imdct_bias);
1898 if (ac->m4ac.sbr > 0) {
1899 ff_sbr_apply(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret);
1903 apply_channel_coupling(ac, che, type, i, AFTER_IMDCT, apply_independent_coupling);
1909 static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb)
1916 if (ac->output_configured != OC_LOCKED && hdr_info.chan_config) {
1919 ac->m4ac.chan_config = hdr_info.chan_config;
1920 if (set_default_channel_config(ac, new_che_pos, hdr_info.chan_config))
1922 if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_config, OC_TRIAL_FRAME))
1924 } else if (ac->output_configured != OC_LOCKED) {
1925 ac->output_configured = OC_NONE;
1927 if (ac->output_configured != OC_LOCKED)
1928 ac->m4ac.sbr = -1;
1929 ac->m4ac.sample_rate = hdr_info.sample_rate;
1930 ac->m4ac.sampling_index = hdr_info.sampling_index;
1931 ac->m4ac.object_type = hdr_info.object_type;
1932 if (!ac->avccontext->sample_rate)
1933 ac->avccontext->sample_rate = hdr_info.sample_rate;
1938 av_log_missing_feature(ac->avccontext, "More than one AAC RDB per ADTS frame is", 0);
1950 AACContext *ac = avccontext->priv_data;
1962 if (parse_adts_frame_header(ac, &gb) < 0) {
1966 if (ac->m4ac.sampling_index > 12) {
1967 av_log(ac->avccontext, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index);
1976 if (elem_type < TYPE_DSE && !(che=get_che(ac, elem_type, elem_id))) {
1977 av_log(ac->avccontext, AV_LOG_ERROR, "channel element %d.%d is not allocated\n", elem_type, elem_id);
1984 err = decode_ics(ac, &che->ch[0], &gb, 0, 0);
1988 err = decode_cpe(ac, &gb, che);
1992 err = decode_cce(ac, &gb, che);
1996 err = decode_ics(ac, &che->ch[0], &gb, 0, 0);
2000 err = skip_data_stream_element(ac, &gb);
2006 if ((err = decode_pce(ac, new_che_pos, &gb)))
2008 if (ac->output_configured > OC_TRIAL_PCE)
2012 err = output_configure(ac, ac->che_pos, new_che_pos, 0, OC_TRIAL_PCE);
2024 elem_id -= decode_extension_payload(ac, &gb, elem_id, che_prev, elem_type_prev);
2045 spectral_to_sample(ac);
2047 multiplier = (ac->m4ac.sbr == 1) ? ac->m4ac.ext_sample_rate > ac->m4ac.sample_rate : 0;
2049 if (ac->output_configured < OC_LOCKED) {
2050 avccontext->sample_rate = ac->m4ac.sample_rate << multiplier;
2063 ac->dsp.float_to_int16_interleave(data, (const float **)ac->output_data, samples, avccontext->channels);
2065 if (ac->output_configured)
2066 ac->output_configured = OC_LOCKED;
2078 AACContext *ac = avccontext->priv_data;
2083 if (ac->che[type][i])
2084 ff_aac_sbr_ctx_close(&ac->che[type][i]->sbr);
2085 av_freep(&ac->che[type][i]);
2089 ff_mdct_end(&ac->mdct);
2090 ff_mdct_end(&ac->mdct_small);