• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/iserver/libav-0.8.8/libavcodec/

Lines Matching defs:ac

117 static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
120 if (!ac->m4ac.chan_config) {
121 return ac->tag_che_map[type][elem_id];
124 switch (ac->m4ac.chan_config) {
126 if (ac->tags_mapped == 3 && type == TYPE_CPE) {
127 ac->tags_mapped++;
128 return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2];
134 if (ac->tags_mapped == tags_per_config[ac->m4ac.chan_config] - 1 && (type == TYPE_LFE || type == TYPE_SCE)) {
135 ac->tags_mapped++;
136 return ac->tag_che_map[type][elem_id] = ac->che[TYPE_LFE][0];
139 if (ac->tags_mapped == 2 && type == TYPE_CPE) {
140 ac->tags_mapped++;
141 return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][1];
144 if (ac->tags_mapped == 2 && ac->m4ac.chan_config == 4 && type == TYPE_SCE) {
145 ac->tags_mapped++;
146 return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1];
150 if (ac->tags_mapped == (ac->m4ac.chan_config != 2) && type == TYPE_CPE) {
151 ac->tags_mapped++;
152 return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][0];
153 } else if (ac->m4ac.chan_config == 2) {
157 if (!ac->tags_mapped && type == TYPE_SCE) {
158 ac->tags_mapped++;
159 return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][0];
191 static av_cold int che_configure(AACContext *ac,
198 if (!ac->che[type][id]) {
199 if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement))))
201 ff_aac_sbr_ctx_init(ac, &ac->che[type][id]->sbr);
204 ac->output_data[(*channels)++] = ac->che[type][id]->ch[0].ret;
206 (type == TYPE_SCE && ac->m4ac.ps == 1)) {
207 ac->output_data[(*channels)++] = ac->che[type][id]->ch[1].ret;
211 if (ac->che[type][id])
212 ff_aac_sbr_ctx_close(&ac->che[type][id]->sbr);
213 av_freep(&ac->che[type][id]);
226 static av_cold int output_configure(AACContext *ac,
231 AVCodecContext *avctx = ac->avctx;
239 if ((ret = che_configure(ac, che_pos,
246 memset(ac->tag_che_map, 0, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0]));
261 if ((ret = che_configure(ac, che_pos, type, i, &channels)))
266 memcpy(ac->tag_che_map, ac->che, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0]));
273 ac->output_configured = oc_type;
401 * @param ac pointer to AACContext, may be null
406 static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx,
442 if (ac && (ret = output_configure(ac, ac->che_pos, new_che_pos, channel_config, OC_GLOBAL_HDR)))
469 * @param ac pointer to AACContext, may be null
478 static int decode_audio_specific_config(AACContext *ac,
507 if (decode_ga_specific_config(ac, avctx, &gb, m4ac, m4ac->chan_config))
583 AACContext *ac = avctx->priv_data;
586 ac->avctx = avctx;
587 ac->m4ac.sample_rate = avctx->sample_rate;
590 if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac,
599 ac->m4ac.sampling_index = sr;
600 ac->m4ac.channels = avctx->channels;
601 ac->m4ac.sbr = -1;
602 ac->m4ac.ps = -1;
610 ac->m4ac.chan_config = i;
612 if (ac->m4ac.chan_config) {
613 int ret = set_default_channel_config(avctx, new_che_pos, ac->m4ac.chan_config);
615 output_configure(ac, ac->che_pos, new_che_pos, ac->m4ac.chan_config, OC_GLOBAL_HDR);
643 dsputil_init(&ac->dsp, avctx);
644 ff_fmt_convert_init(&ac->fmt_conv, avctx);
646 ac->random_state = 0x1f2e3d4c;
655 ff_mdct_init(&ac->mdct, 11, 1, output_scale_factor/1024.0);
656 ff_mdct_init(&ac->mdct_small, 8, 1, output_scale_factor/128.0);
657 ff_mdct_init(&ac->mdct_ltp, 11, 0, -2.0/output_scale_factor);
666 avcodec_get_frame_defaults(&ac->frame);
667 avctx->coded_frame = &ac->frame;
675 static int skip_data_stream_element(AACContext *ac, GetBitContext *gb)
685 av_log(ac->avctx, AV_LOG_ERROR, overread_err);
692 static int decode_prediction(AACContext *ac, IndividualChannelStream *ics,
699 av_log(ac->avctx, AV_LOG_ERROR, "Invalid Predictor Reset Group.\n");
703 for (sfb = 0; sfb < FFMIN(ics->max_sfb, ff_aac_pred_sfb_max[ac->m4ac.sampling_index]); sfb++) {
712 static void decode_ltp(AACContext *ac, LongTermPrediction *ltp,
726 static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics,
730 av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n");
751 ics->swb_offset = ff_swb_offset_128[ac->m4ac.sampling_index];
752 ics->num_swb = ff_aac_num_swb_128[ac->m4ac.sampling_index];
753 ics->tns_max_bands = ff_tns_max_bands_128[ac->m4ac.sampling_index];
758 ics->swb_offset = ff_swb_offset_1024[ac->m4ac.sampling_index];
759 ics->num_swb = ff_aac_num_swb_1024[ac->m4ac.sampling_index];
760 ics->tns_max_bands = ff_tns_max_bands_1024[ac->m4ac.sampling_index];
764 if (ac->m4ac.object_type == AOT_AAC_MAIN) {
765 if (decode_prediction(ac, ics, gb)) {
768 } else if (ac->m4ac.object_type == AOT_AAC_LC) {
769 av_log(ac->avctx, AV_LOG_ERROR, "Prediction is not allowed in AAC-LC.\n");
773 decode_ltp(ac, &ics->ltp, gb, ics->max_sfb);
779 av_log(ac->avctx, AV_LOG_ERROR,
796 static int decode_band_types(AACContext *ac, enum BandType band_type[120],
809 av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n");
816 av_log(ac->avctx, AV_LOG_ERROR, overread_err);
820 av_log(ac->avctx, AV_LOG_ERROR,
845 static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb,
867 av_log_ask_for_sample(ac->avctx, "Intensity stereo "
882 av_log_ask_for_sample(ac->avctx, "Noise gain clipped "
893 av_log(ac->avctx, AV_LOG_ERROR,
935 static int decode_tns(AACContext *ac, TemporalNoiseShaping *tns,
940 const int tns_max_order = is8 ? 7 : ac->m4ac.object_type == AOT_AAC_MAIN ? 20 : 12;
950 av_log(ac->avctx, AV_LOG_ERROR, "TNS filter order %d is greater than maximum %d.\n",
1069 static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024],
1102 ac->random_state = lcg_random(ac->random_state);
1103 cfo[k] = ac->random_state;
1106 band_energy = ac->dsp.scalarproduct_float(cfo, cfo, off_len);
1108 ac->dsp.vector_fmul_scalar(cfo, cfo, scale, off_len);
1235 av_log(ac->avctx, AV_LOG_ERROR, "error in spectral data, ESC overflow\n");
1254 ac->dsp.vector_fmul_scalar(cfo, cfo, sf[idx], off_len);
1341 static void apply_prediction(AACContext *ac, SingleChannelElement *sce)
1351 for (sfb = 0; sfb < ff_aac_pred_sfb_max[ac->m4ac.sampling_index]; sfb++) {
1371 static int decode_ics(AACContext *ac, SingleChannelElement *sce,
1388 if (decode_ics_info(ac, ics, gb) < 0)
1392 if (decode_band_types(ac, sce->band_type, sce->band_type_run_end, gb, ics) < 0)
1394 if (decode_scalefactors(ac, sce->sf, gb, global_gain, ics, sce->band_type, sce->band_type_run_end) < 0)
1401 av_log(ac->avctx, AV_LOG_ERROR, "Pulse tool not allowed in eight short sequence.\n");
1405 av_log(ac->avctx, AV_LOG_ERROR, "Pulse data corrupt or invalid.\n");
1409 if ((tns->present = get_bits1(gb)) && decode_tns(ac, tns, gb, ics))
1412 av_log_missing_feature(ac->avctx, "SSR", 1);
1417 if (decode_spectrum_and_dequant(ac, out, gb, sce->sf, pulse_present, &pulse, ics, sce->band_type) < 0)
1420 if (ac->m4ac.object_type == AOT_AAC_MAIN && !common_window)
1421 apply_prediction(ac, sce);
1429 static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe)
1441 ac->dsp.butterflies_float(ch0 + group * 128 + offsets[i],
1459 static void apply_intensity_stereo(AACContext *ac, ChannelElement *cpe, int ms_present)
1478 ac->dsp.vector_fmul_scalar(coef1 + group * 128 + offsets[i],
1499 static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe)
1505 if (decode_ics_info(ac, &cpe->ch[0].ics, gb))
1510 if (cpe->ch[1].ics.predictor_present && (ac->m4ac.object_type != AOT_AAC_MAIN))
1512 decode_ltp(ac, &cpe->ch[1].ics.ltp, gb, cpe->ch[1].ics.max_sfb);
1515 av_log(ac->avctx, AV_LOG_ERROR, "ms_present = 3 is reserved.\n");
1520 if ((ret = decode_ics(ac, &cpe->ch[0], gb, common_window, 0)))
1522 if ((ret = decode_ics(ac, &cpe->ch[1], gb, common_window, 0)))
1527 apply_mid_side_stereo(ac, cpe);
1528 if (ac->m4ac.object_type == AOT_AAC_MAIN) {
1529 apply_prediction(ac, &cpe->ch[0]);
1530 apply_prediction(ac, &cpe->ch[1]);
1534 apply_intensity_stereo(ac, cpe, ms_present);
1550 static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che)
1577 if ((ret = decode_ics(ac, sce, gb, 0, 0)))
1697 static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt,
1707 av_log(ac->avctx, AV_LOG_ERROR, "SBR was found before the first channel element.\n");
1709 } else if (!ac->m4ac.sbr) {
1710 av_log(ac->avctx, AV_LOG_ERROR, "SBR signaled to be not-present but was found in the bitstream.\n");
1713 } else if (ac->m4ac.sbr == -1 && ac->output_configured == OC_LOCKED) {
1714 av_log(ac->avctx, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n");
1717 } else if (ac->m4ac.ps == -1 && ac->output_configured < OC_LOCKED && ac->avctx->channels == 1) {
1718 ac->m4ac.sbr = 1;
1719 ac->m4ac.ps = 1;
1720 output_configure(ac, ac->che_pos, ac->che_pos, ac->m4ac.chan_config, ac->output_configured);
1722 ac->m4ac.sbr = 1;
1724 res = ff_decode_sbr_extension(ac, &che->sbr, gb, crc_flag, cnt, elem_type);
1727 res = decode_dynamic_range(&ac->che_drc, gb, cnt);
1801 static void windowing_and_mdct_ltp(AACContext *ac, float *out,
1810 ac->dsp.vector_fmul(in, in, lwindow_prev, 1024);
1813 ac->dsp.vector_fmul(in + 448, in + 448, swindow_prev, 128);
1816 ac->dsp.vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024);
1818 ac->dsp.vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128);
1821 ac->mdct_ltp.mdct_calc(&ac->mdct_ltp, out, in);
1827 static void apply_ltp(AACContext *ac, SingleChannelElement *sce)
1835 float *predFreq = ac->buf_mdct;
1844 windowing_and_mdct_ltp(ac, predFreq, predTime, &sce->ics);
1859 static void update_ltp(AACContext *ac, SingleChannelElement *sce)
1871 ac->dsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64);
1873 saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i];
1875 memcpy(saved_ltp, ac->buf_mdct + 512, 448 * sizeof(float));
1877 ac->dsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64);
1879 saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i];
1881 ac->dsp.vector_fmul_reverse(saved_ltp, ac->buf_mdct + 512, &lwindow[512], 512);
1883 saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * lwindow[511 - i];
1894 static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce)
1903 float *buf = ac->buf_mdct;
1904 float *temp = ac->temp;
1910 ac->mdct_small.imdct_half(&ac->mdct_small, buf + i, in + i);
1912 ac->mdct.imdct_half(&ac->mdct, buf, in);
1922 ac->dsp.vector_fmul_window( out, saved, buf, lwindow_prev, 512);
1927 ac->dsp.vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, 64);
1928 ac->dsp.vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, 64);
1929 ac->dsp.vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, 64);
1930 ac->dsp.vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, 64);
1931 ac->dsp.vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, 64);
1934 ac->dsp.vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, 64);
1942 ac->dsp.vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 64);
1943 ac->dsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 64);
1944 ac->dsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 64);
1959 static void apply_dependent_coupling(AACContext *ac,
1968 if (ac->m4ac.object_type == AOT_AAC_LTP) {
1969 av_log(ac->avctx, AV_LOG_ERROR,
1995 static void apply_independent_coupling(AACContext *ac,
2003 const int len = 1024 << (ac->m4ac.sbr == 1);
2014 static void apply_channel_coupling(AACContext *ac, ChannelElement *cc,
2017 void (*apply_coupling_method)(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index))
2022 ChannelElement *cce = ac->che[TYPE_CCE][i];
2031 apply_coupling_method(ac, &cc->ch[0], cce, index);
2036 apply_coupling_method(ac, &cc->ch[1], cce, index++);
2047 static void spectral_to_sample(AACContext *ac)
2052 ChannelElement *che = ac->che[type][i];
2055 apply_channel_coupling(ac, che, type, i, BEFORE_TNS, apply_dependent_coupling);
2056 if (ac->m4ac.object_type == AOT_AAC_LTP) {
2059 apply_ltp(ac, &che->ch[0]);
2061 apply_ltp(ac, &che->ch[1]);
2069 apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, apply_dependent_coupling);
2071 imdct_and_windowing(ac, &che->ch[0]);
2072 if (ac->m4ac.object_type == AOT_AAC_LTP)
2073 update_ltp(ac, &che->ch[0]);
2075 imdct_and_windowing(ac, &che->ch[1]);
2076 if (ac->m4ac.object_type == AOT_AAC_LTP)
2077 update_ltp(ac, &che->ch[1]);
2079 if (ac->m4ac.sbr > 0) {
2080 ff_sbr_apply(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret);
2084 apply_channel_coupling(ac, che, type, i, AFTER_IMDCT, apply_independent_coupling);
2090 static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb)
2100 ac->m4ac.chan_config = hdr_info.chan_config;
2101 if (set_default_channel_config(ac->avctx, new_che_pos, hdr_info.chan_config))
2103 if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_config,
2104 FFMAX(ac->output_configured, OC_TRIAL_FRAME)))
2106 } else if (ac->output_configured != OC_LOCKED) {
2107 ac->m4ac.chan_config = 0;
2108 ac->output_configured = OC_NONE;
2110 if (ac->output_configured != OC_LOCKED) {
2111 ac->m4ac.sbr = -1;
2112 ac->m4ac.ps = -1;
2113 ac->m4ac.sample_rate = hdr_info.sample_rate;
2114 ac->m4ac.sampling_index = hdr_info.sampling_index;
2115 ac->m4ac.object_type = hdr_info.object_type;
2117 if (!ac->avctx->sample_rate)
2118 ac->avctx->sample_rate = hdr_info.sample_rate;
2123 av_log_missing_feature(ac->avctx, "More than one AAC RDB per ADTS frame is", 0);
2133 AACContext *ac = avctx->priv_data;
2140 if (parse_adts_frame_header(ac, gb) < 0) {
2144 if (ac->m4ac.sampling_index > 12) {
2145 av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->m4ac.sampling_index);
2150 ac->tags_mapped = 0;
2156 if (!(che=get_che(ac, elem_type, elem_id))) {
2157 av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n",
2167 err = decode_ics(ac, &che->ch[0], gb, 0, 0);
2172 err = decode_cpe(ac, gb, che);
2177 err = decode_cce(ac, gb, che);
2181 err = decode_ics(ac, &che->ch[0], gb, 0, 0);
2186 err = skip_data_stream_element(ac, gb);
2192 if ((err = decode_pce(avctx, &ac->m4ac, new_che_pos, gb)))
2194 if (ac->output_configured > OC_TRIAL_PCE)
2198 err = output_configure(ac, ac->che_pos, new_che_pos, 0, OC_TRIAL_PCE);
2210 elem_id -= decode_extension_payload(ac, gb, elem_id, che_prev, elem_type_prev);
2231 spectral_to_sample(ac);
2233 multiplier = (ac->m4ac.sbr == 1) ? ac->m4ac.ext_sample_rate > ac->m4ac.sample_rate : 0;
2235 if (ac->output_configured < OC_LOCKED) {
2236 avctx->sample_rate = ac->m4ac.sample_rate << multiplier;
2242 ac->frame.nb_samples = samples;
2243 if ((err = avctx->get_buffer(avctx, &ac->frame)) < 0) {
2249 ac->fmt_conv.float_interleave((float *)ac->frame.data[0],
2250 (const float **)ac->output_data,
2253 ac->fmt_conv.float_to_int16_interleave((int16_t *)ac->frame.data[0],
2254 (const float **)ac->output_data,
2257 *(AVFrame *)data = ac->frame;
2261 if (ac->output_configured && audio_found)
2262 ac->output_configured = OC_LOCKED;
2270 AACContext *ac = avctx->priv_data;
2290 if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac,
2311 AACContext *ac = avctx->priv_data;
2316 if (ac->che[type][i])
2317 ff_aac_sbr_ctx_close(&ac->che[type][i]->sbr);
2318 av_freep(&ac->che[type][i]);
2322 ff_mdct_end(&ac->mdct);
2323 ff_mdct_end(&ac->mdct_small);
2324 ff_mdct_end(&ac->mdct_ltp);
2351 AACContext *ac = &latmctx->aac_ctx;
2352 AVCodecContext *avctx = ac->avctx;
2378 if (ac->m4ac.sample_rate != m4ac.sample_rate ||
2379 ac->m4ac.chan_config != m4ac.chan_config) {