diff --git a/mythtv/external/FFmpeg/libavcodec/aac.h b/mythtv/external/FFmpeg/libavcodec/aac.h
index a2bf70b..837f612 100644
|
a
|
b
|
typedef struct {
|
| 130 | 130 | #define SCALE_MAX_POS 255 ///< scalefactor index maximum value |
| 131 | 131 | #define SCALE_MAX_DIFF 60 ///< maximum scalefactor difference allowed by standard |
| 132 | 132 | #define SCALE_DIFF_ZERO 60 ///< codebook index corresponding to zero scalefactor indices difference |
| | 133 | #define POW_SF2_ZERO 200 ///< ff_aac_pow2sf_tab index corresponding to pow(2, 0); |
| 133 | 134 | |
| 134 | 135 | /** |
| 135 | 136 | * Long Term Prediction |
diff --git a/mythtv/external/FFmpeg/libavcodec/aacdec.c b/mythtv/external/FFmpeg/libavcodec/aacdec.c
index a362d6a..214812d 100644
|
a
|
b
|
static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
|
| 178 | 178 | * @return Returns error status. 0 - OK, !0 - error |
| 179 | 179 | */ |
| 180 | 180 | static av_cold int che_configure(AACContext *ac, |
| 181 | | enum ChannelPosition che_pos[4][MAX_ELEM_ID], |
| 182 | | int type, int id, |
| 183 | | int *channels) |
| | 181 | enum ChannelPosition che_pos[4][MAX_ELEM_ID], |
| | 182 | int type, int id, int *channels) |
| 184 | 183 | { |
| 185 | 184 | if (che_pos[type][id]) { |
| 186 | 185 | if (!ac->che[type][id] && !(ac->che[type][id] = av_mallocz(sizeof(ChannelElement)))) |
| … |
… |
static av_cold int che_configure(AACContext *ac,
|
| 210 | 209 | * @return Returns error status. 0 - OK, !0 - error |
| 211 | 210 | */ |
| 212 | 211 | static av_cold int output_configure(AACContext *ac, |
| 213 | | enum ChannelPosition che_pos[4][MAX_ELEM_ID], |
| 214 | | enum ChannelPosition new_che_pos[4][MAX_ELEM_ID], |
| 215 | | int channel_config, enum OCStatus oc_type) |
| | 212 | enum ChannelPosition che_pos[4][MAX_ELEM_ID], |
| | 213 | enum ChannelPosition new_che_pos[4][MAX_ELEM_ID], |
| | 214 | int channel_config, enum OCStatus oc_type) |
| 216 | 215 | { |
| 217 | 216 | AVCodecContext *avctx = ac->avctx; |
| 218 | 217 | int i, type, channels = 0, ret; |
| … |
… |
static av_cold int output_configure(AACContext *ac,
|
| 229 | 228 | return ret; |
| 230 | 229 | } |
| 231 | 230 | |
| 232 | | memset(ac->tag_che_map, 0, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0])); |
| | 231 | memset(ac->tag_che_map, 0, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0])); |
| 233 | 232 | |
| 234 | 233 | avctx->channel_layout = aac_channel_layout[channel_config - 1]; |
| 235 | 234 | } else { |
| … |
… |
static av_cold int output_configure(AACContext *ac,
|
| 250 | 249 | } |
| 251 | 250 | |
| 252 | 251 | memcpy(ac->tag_che_map, ac->che, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0])); |
| 253 | | |
| 254 | | avctx->channel_layout = 0; |
| 255 | 252 | } |
| 256 | 253 | |
| 257 | 254 | avctx->channels = channels; |
| … |
… |
static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac,
|
| 314 | 311 | if (get_bits1(gb)) |
| 315 | 312 | skip_bits(gb, 3); // mixdown_coeff_index and pseudo_surround |
| 316 | 313 | |
| | 314 | if (get_bits_left(gb) < 4 * (num_front + num_side + num_back + num_lfe + num_assoc_data + num_cc)) { |
| | 315 | av_log(avctx, AV_LOG_ERROR, overread_err); |
| | 316 | return -1; |
| | 317 | } |
| 317 | 318 | decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_FRONT, gb, num_front); |
| 318 | 319 | decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_SIDE, gb, num_side ); |
| 319 | 320 | decode_channel_map(new_che_pos[TYPE_CPE], new_che_pos[TYPE_SCE], AAC_CHANNEL_BACK, gb, num_back ); |
| … |
… |
static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac,
|
| 344 | 345 | * @return Returns error status. 0 - OK, !0 - error |
| 345 | 346 | */ |
| 346 | 347 | static av_cold int set_default_channel_config(AVCodecContext *avctx, |
| 347 | | enum ChannelPosition new_che_pos[4][MAX_ELEM_ID], |
| 348 | | int channel_config) |
| | 348 | enum ChannelPosition new_che_pos[4][MAX_ELEM_ID], |
| | 349 | int channel_config) |
| 349 | 350 | { |
| 350 | 351 | if (channel_config < 1 || channel_config > 7) { |
| 351 | 352 | av_log(avctx, AV_LOG_ERROR, "invalid default channel configuration (%d)\n", |
| … |
… |
static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx,
|
| 457 | 458 | static int decode_audio_specific_config(AACContext *ac, |
| 458 | 459 | AVCodecContext *avctx, |
| 459 | 460 | MPEG4AudioConfig *m4ac, |
| 460 | | const uint8_t *data, int data_size) |
| | 461 | const uint8_t *data, int data_size, int asclen) |
| 461 | 462 | { |
| 462 | 463 | GetBitContext gb; |
| 463 | 464 | int i; |
| 464 | 465 | |
| | 466 | av_dlog(avctx, "extradata size %d\n", avctx->extradata_size); |
| | 467 | for (i = 0; i < avctx->extradata_size; i++) |
| | 468 | av_dlog(avctx, "%02x ", avctx->extradata[i]); |
| | 469 | av_dlog(avctx, "\n"); |
| | 470 | |
| 465 | 471 | init_get_bits(&gb, data, data_size * 8); |
| 466 | 472 | |
| 467 | | if ((i = ff_mpeg4audio_get_config(m4ac, data, data_size)) < 0) |
| | 473 | if ((i = ff_mpeg4audio_get_config(m4ac, data, asclen/8)) < 0) |
| 468 | 474 | return -1; |
| 469 | 475 | if (m4ac->sampling_index > 12) { |
| 470 | 476 | av_log(avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", m4ac->sampling_index); |
| … |
… |
static int decode_audio_specific_config(AACContext *ac,
|
| 488 | 494 | return -1; |
| 489 | 495 | } |
| 490 | 496 | |
| | 497 | av_dlog(avctx, "AOT %d chan config %d sampling index %d (%d) SBR %d PS %d\n", |
| | 498 | m4ac->object_type, m4ac->chan_config, m4ac->sampling_index, |
| | 499 | m4ac->sample_rate, m4ac->sbr, m4ac->ps); |
| | 500 | |
| 491 | 501 | return get_bits_count(&gb); |
| 492 | 502 | } |
| 493 | 503 | |
| … |
… |
static void reset_all_predictors(PredictorState *ps)
|
| 520 | 530 | reset_predict_state(&ps[i]); |
| 521 | 531 | } |
| 522 | 532 | |
| | 533 | static int sample_rate_idx (int rate) |
| | 534 | { |
| | 535 | if (92017 <= rate) return 0; |
| | 536 | else if (75132 <= rate) return 1; |
| | 537 | else if (55426 <= rate) return 2; |
| | 538 | else if (46009 <= rate) return 3; |
| | 539 | else if (37566 <= rate) return 4; |
| | 540 | else if (27713 <= rate) return 5; |
| | 541 | else if (23004 <= rate) return 6; |
| | 542 | else if (18783 <= rate) return 7; |
| | 543 | else if (13856 <= rate) return 8; |
| | 544 | else if (11502 <= rate) return 9; |
| | 545 | else if (9391 <= rate) return 10; |
| | 546 | else return 11; |
| | 547 | } |
| | 548 | |
| 523 | 549 | static void reset_predictor_group(PredictorState *ps, int group_num) |
| 524 | 550 | { |
| 525 | 551 | int i; |
| … |
… |
static av_cold int aac_decode_init(AVCodecContext *avctx)
|
| 543 | 569 | if (avctx->extradata_size > 0) { |
| 544 | 570 | if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac, |
| 545 | 571 | avctx->extradata, |
| 546 | | avctx->extradata_size) < 0) |
| | 572 | avctx->extradata_size, 8*avctx->extradata_size) < 0) |
| 547 | 573 | return -1; |
| | 574 | } else { |
| | 575 | int sr, i; |
| | 576 | enum ChannelPosition new_che_pos[4][MAX_ELEM_ID]; |
| | 577 | |
| | 578 | sr = sample_rate_idx(avctx->sample_rate); |
| | 579 | ac->m4ac.sampling_index = sr; |
| | 580 | ac->m4ac.channels = avctx->channels; |
| | 581 | ac->m4ac.sbr = -1; |
| | 582 | ac->m4ac.ps = -1; |
| | 583 | |
| | 584 | for (i = 0; i < FF_ARRAY_ELEMS(ff_mpeg4audio_channels); i++) |
| | 585 | if (ff_mpeg4audio_channels[i] == avctx->channels) |
| | 586 | break; |
| | 587 | if (i == FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) { |
| | 588 | i = 0; |
| | 589 | } |
| | 590 | ac->m4ac.chan_config = i; |
| | 591 | |
| | 592 | if (ac->m4ac.chan_config) { |
| | 593 | set_default_channel_config(avctx, new_che_pos, ac->m4ac.chan_config); |
| | 594 | } |
| 548 | 595 | } |
| 549 | 596 | |
| 550 | 597 | avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
| … |
… |
static av_cold int aac_decode_init(AVCodecContext *avctx)
|
| 568 | 615 | |
| 569 | 616 | ac->random_state = 0x1f2e3d4c; |
| 570 | 617 | |
| 571 | | // -1024 - Compensate wrong IMDCT method. |
| 572 | | // 60 - Required to scale values to the correct range [-32768,32767] |
| 573 | | // for float to int16 conversion. (1 << (60 / 4)) == 32768 |
| 574 | | ac->sf_scale = 1. / -1024.; |
| 575 | | ac->sf_offset = 60; |
| 576 | | |
| 577 | 618 | ff_aac_tableinit(); |
| 578 | 619 | |
| 579 | 620 | INIT_VLC_STATIC(&vlc_scalefactors,7,FF_ARRAY_ELEMS(ff_aac_scalefactor_code), |
| … |
… |
static av_cold int aac_decode_init(AVCodecContext *avctx)
|
| 581 | 622 | ff_aac_scalefactor_code, sizeof(ff_aac_scalefactor_code[0]), sizeof(ff_aac_scalefactor_code[0]), |
| 582 | 623 | 352); |
| 583 | 624 | |
| 584 | | ff_mdct_init(&ac->mdct, 11, 1, 1.0); |
| 585 | | ff_mdct_init(&ac->mdct_small, 8, 1, 1.0); |
| 586 | | ff_mdct_init(&ac->mdct_ltp, 11, 0, 1.0); |
| | 625 | ff_mdct_init(&ac->mdct, 11, 1, 1.0/1024.0); |
| | 626 | ff_mdct_init(&ac->mdct_small, 8, 1, 1.0/128.0); |
| | 627 | ff_mdct_init(&ac->mdct_ltp, 11, 0, -2.0); |
| 587 | 628 | // window initialization |
| 588 | 629 | ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024); |
| 589 | 630 | ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128); |
| … |
… |
static void decode_ltp(AACContext *ac, LongTermPrediction *ltp,
|
| 641 | 682 | int sfb; |
| 642 | 683 | |
| 643 | 684 | ltp->lag = get_bits(gb, 11); |
| 644 | | ltp->coef = ltp_coef[get_bits(gb, 3)] * ac->sf_scale; |
| | 685 | ltp->coef = ltp_coef[get_bits(gb, 3)]; |
| 645 | 686 | for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++) |
| 646 | 687 | ltp->used[sfb] = get_bits1(gb); |
| 647 | 688 | } |
| … |
… |
static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb,
|
| 779 | 820 | enum BandType band_type[120], |
| 780 | 821 | int band_type_run_end[120]) |
| 781 | 822 | { |
| 782 | | const int sf_offset = ac->sf_offset + (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE ? 12 : 0); |
| 783 | 823 | int g, i, idx = 0; |
| 784 | | int offset[3] = { global_gain, global_gain - 90, 100 }; |
| | 824 | int offset[3] = { global_gain, global_gain - 90, 0 }; |
| | 825 | int clipped_offset; |
| 785 | 826 | int noise_flag = 1; |
| 786 | 827 | static const char *sf_str[3] = { "Global gain", "Noise gain", "Intensity stereo position" }; |
| 787 | 828 | for (g = 0; g < ics->num_window_groups; g++) { |
| … |
… |
static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb,
|
| 793 | 834 | } else if ((band_type[idx] == INTENSITY_BT) || (band_type[idx] == INTENSITY_BT2)) { |
| 794 | 835 | for (; i < run_end; i++, idx++) { |
| 795 | 836 | offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; |
| 796 | | if (offset[2] > 255U) { |
| 797 | | av_log(ac->avctx, AV_LOG_ERROR, |
| 798 | | "%s (%d) out of range.\n", sf_str[2], offset[2]); |
| 799 | | return -1; |
| | 837 | clipped_offset = av_clip(offset[2], -155, 100); |
| | 838 | if (offset[2] != clipped_offset) { |
| | 839 | /* av_log_ask_for_sample(ac->avctx, "Intensity stereo " |
| | 840 | "position clipped (%d -> %d).\nIf you heard an " |
| | 841 | "audible artifact, there may be a bug in the " |
| | 842 | "decoder. ", offset[2], clipped_offset); |
| | 843 | */ |
| 800 | 844 | } |
| 801 | | sf[idx] = ff_aac_pow2sf_tab[-offset[2] + 300]; |
| | 845 | sf[idx] = ff_aac_pow2sf_tab[-clipped_offset + POW_SF2_ZERO]; |
| 802 | 846 | } |
| 803 | 847 | } else if (band_type[idx] == NOISE_BT) { |
| 804 | 848 | for (; i < run_end; i++, idx++) { |
| … |
… |
static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb,
|
| 806 | 850 | offset[1] += get_bits(gb, 9) - 256; |
| 807 | 851 | else |
| 808 | 852 | offset[1] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; |
| 809 | | if (offset[1] > 255U) { |
| 810 | | av_log(ac->avctx, AV_LOG_ERROR, |
| 811 | | "%s (%d) out of range.\n", sf_str[1], offset[1]); |
| 812 | | return -1; |
| | 853 | clipped_offset = av_clip(offset[1], -100, 155); |
| | 854 | if (offset[1] != clipped_offset) { |
| | 855 | /* av_log_ask_for_sample(ac->avctx, "Noise gain clipped " |
| | 856 | "(%d -> %d).\nIf you heard an audible " |
| | 857 | "artifact, there may be a bug in the decoder. ", |
| | 858 | offset[1], clipped_offset); |
| | 859 | */ |
| 813 | 860 | } |
| 814 | | sf[idx] = -ff_aac_pow2sf_tab[offset[1] + sf_offset + 100]; |
| | 861 | sf[idx] = -ff_aac_pow2sf_tab[clipped_offset + POW_SF2_ZERO]; |
| 815 | 862 | } |
| 816 | 863 | } else { |
| 817 | 864 | for (; i < run_end; i++, idx++) { |
| … |
… |
static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb,
|
| 821 | 868 | "%s (%d) out of range.\n", sf_str[0], offset[0]); |
| 822 | 869 | return -1; |
| 823 | 870 | } |
| 824 | | sf[idx] = -ff_aac_pow2sf_tab[ offset[0] + sf_offset]; |
| | 871 | sf[idx] = -ff_aac_pow2sf_tab[offset[0] - 100 + POW_SF2_ZERO]; |
| 825 | 872 | } |
| 826 | 873 | } |
| 827 | 874 | } |
| … |
… |
static inline float *VMUL4S(float *dst, const float *v, unsigned idx,
|
| 962 | 1009 | union float754 s = { .f = *scale }; |
| 963 | 1010 | union float754 t; |
| 964 | 1011 | |
| 965 | | t.i = s.i ^ (sign & 1<<31); |
| | 1012 | t.i = s.i ^ (sign & 1U<<31); |
| 966 | 1013 | *dst++ = v[idx & 3] * t.f; |
| 967 | 1014 | |
| 968 | 1015 | sign <<= nz & 1; nz >>= 1; |
| 969 | | t.i = s.i ^ (sign & 1<<31); |
| | 1016 | t.i = s.i ^ (sign & 1U<<31); |
| 970 | 1017 | *dst++ = v[idx>>2 & 3] * t.f; |
| 971 | 1018 | |
| 972 | 1019 | sign <<= nz & 1; nz >>= 1; |
| 973 | | t.i = s.i ^ (sign & 1<<31); |
| | 1020 | t.i = s.i ^ (sign & 1U<<31); |
| 974 | 1021 | *dst++ = v[idx>>4 & 3] * t.f; |
| 975 | 1022 | |
| 976 | 1023 | sign <<= nz & 1; nz >>= 1; |
| 977 | | t.i = s.i ^ (sign & 1<<31); |
| | 1024 | t.i = s.i ^ (sign & 1U<<31); |
| 978 | 1025 | *dst++ = v[idx>>6 & 3] * t.f; |
| 979 | 1026 | |
| 980 | 1027 | return dst; |
| … |
… |
static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024],
|
| 1167 | 1214 | b += 4; |
| 1168 | 1215 | n = (1 << b) + SHOW_UBITS(re, gb, b); |
| 1169 | 1216 | LAST_SKIP_BITS(re, gb, b); |
| 1170 | | *icf++ = cbrt_tab[n] | (bits & 1<<31); |
| | 1217 | *icf++ = cbrt_tab[n] | (bits & 1U<<31); |
| 1171 | 1218 | bits <<= 1; |
| 1172 | 1219 | } else { |
| 1173 | 1220 | unsigned v = ((const uint32_t*)vq)[cb_idx & 15]; |
| 1174 | | *icf++ = (bits & 1<<31) | v; |
| | 1221 | *icf++ = (bits & 1U<<31) | v; |
| 1175 | 1222 | bits <<= !!v; |
| 1176 | 1223 | } |
| 1177 | 1224 | cb_idx >>= 4; |
| … |
… |
static av_always_inline float flt16_trunc(float pf)
|
| 1232 | 1279 | } |
| 1233 | 1280 | |
| 1234 | 1281 | static av_always_inline void predict(PredictorState *ps, float *coef, |
| 1235 | | float sf_scale, float inv_sf_scale, |
| 1236 | | int output_enable) |
| | 1282 | int output_enable) |
| 1237 | 1283 | { |
| 1238 | 1284 | const float a = 0.953125; // 61.0 / 64 |
| 1239 | 1285 | const float alpha = 0.90625; // 29.0 / 32 |
| … |
… |
static av_always_inline void predict(PredictorState *ps, float *coef,
|
| 1249 | 1295 | |
| 1250 | 1296 | pv = flt16_round(k1 * r0 + k2 * r1); |
| 1251 | 1297 | if (output_enable) |
| 1252 | | *coef += pv * sf_scale; |
| | 1298 | *coef += pv; |
| 1253 | 1299 | |
| 1254 | | e0 = *coef * inv_sf_scale; |
| | 1300 | e0 = *coef; |
| 1255 | 1301 | e1 = e0 - k1 * r0; |
| 1256 | 1302 | |
| 1257 | 1303 | ps->cor1 = flt16_trunc(alpha * cor1 + r1 * e1); |
| … |
… |
static av_always_inline void predict(PredictorState *ps, float *coef,
|
| 1269 | 1315 | static void apply_prediction(AACContext *ac, SingleChannelElement *sce) |
| 1270 | 1316 | { |
| 1271 | 1317 | int sfb, k; |
| 1272 | | float sf_scale = ac->sf_scale, inv_sf_scale = 1 / ac->sf_scale; |
| 1273 | 1318 | |
| 1274 | 1319 | if (!sce->ics.predictor_initialized) { |
| 1275 | 1320 | reset_all_predictors(sce->predictor_state); |
| … |
… |
static void apply_prediction(AACContext *ac, SingleChannelElement *sce)
|
| 1280 | 1325 | for (sfb = 0; sfb < ff_aac_pred_sfb_max[ac->m4ac.sampling_index]; sfb++) { |
| 1281 | 1326 | for (k = sce->ics.swb_offset[sfb]; k < sce->ics.swb_offset[sfb + 1]; k++) { |
| 1282 | 1327 | predict(&sce->predictor_state[k], &sce->coeffs[k], |
| 1283 | | sf_scale, inv_sf_scale, |
| 1284 | 1328 | sce->ics.predictor_present && sce->ics.prediction_used[sfb]); |
| 1285 | 1329 | } |
| 1286 | 1330 | } |
| … |
… |
static void windowing_and_mdct_ltp(AACContext *ac, float *out,
|
| 1741 | 1785 | } else { |
| 1742 | 1786 | memset(in, 0, 448 * sizeof(float)); |
| 1743 | 1787 | ac->dsp.vector_fmul(in + 448, in + 448, swindow_prev, 128); |
| 1744 | | memcpy(in + 576, in + 576, 448 * sizeof(float)); |
| 1745 | 1788 | } |
| 1746 | 1789 | if (ics->window_sequence[0] != LONG_START_SEQUENCE) { |
| 1747 | 1790 | ac->dsp.vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024); |
| 1748 | 1791 | } else { |
| 1749 | | memcpy(in + 1024, in + 1024, 448 * sizeof(float)); |
| 1750 | 1792 | ac->dsp.vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128); |
| 1751 | 1793 | memset(in + 1024 + 576, 0, 448 * sizeof(float)); |
| 1752 | 1794 | } |
| 1753 | | ff_mdct_calc(&ac->mdct_ltp, out, in); |
| | 1795 | ac->mdct_ltp.mdct_calc(&ac->mdct_ltp, out, in); |
| 1754 | 1796 | } |
| 1755 | 1797 | |
| 1756 | 1798 | /** |
| … |
… |
static void apply_ltp(AACContext *ac, SingleChannelElement *sce)
|
| 1763 | 1805 | int i, sfb; |
| 1764 | 1806 | |
| 1765 | 1807 | if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) { |
| 1766 | | float *predTime = ac->buf_mdct; |
| 1767 | | float *predFreq = sce->ret; |
| | 1808 | float *predTime = sce->ret; |
| | 1809 | float *predFreq = ac->buf_mdct; |
| 1768 | 1810 | int16_t num_samples = 2048; |
| 1769 | 1811 | |
| 1770 | 1812 | if (ltp->lag < 1024) |
| … |
… |
static void update_ltp(AACContext *ac, SingleChannelElement *sce)
|
| 1797 | 1839 | const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; |
| 1798 | 1840 | int i; |
| 1799 | 1841 | |
| 1800 | | for (i = 0; i < 512; i++) |
| 1801 | | ac->buf_mdct[1535 - i] = ac->buf_mdct[512 + i]; |
| 1802 | | |
| 1803 | 1842 | if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { |
| 1804 | 1843 | memcpy(saved_ltp, saved, 512 * sizeof(float)); |
| 1805 | 1844 | memset(saved_ltp + 576, 0, 448 * sizeof(float)); |
| 1806 | | ac->dsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, swindow, 128); |
| | 1845 | ac->dsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); |
| | 1846 | for (i = 0; i < 64; i++) |
| | 1847 | saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i]; |
| 1807 | 1848 | } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) { |
| 1808 | 1849 | memcpy(saved_ltp, ac->buf_mdct + 512, 448 * sizeof(float)); |
| 1809 | 1850 | memset(saved_ltp + 576, 0, 448 * sizeof(float)); |
| 1810 | | ac->dsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, swindow, 128); |
| | 1851 | ac->dsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64); |
| | 1852 | for (i = 0; i < 64; i++) |
| | 1853 | saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i]; |
| 1811 | 1854 | } else { // LONG_STOP or ONLY_LONG |
| 1812 | | ac->dsp.vector_fmul_reverse(saved_ltp, ac->buf_mdct + 512, lwindow, 1024); |
| | 1855 | ac->dsp.vector_fmul_reverse(saved_ltp, ac->buf_mdct + 512, &lwindow[512], 512); |
| | 1856 | for (i = 0; i < 512; i++) |
| | 1857 | saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * lwindow[511 - i]; |
| 1813 | 1858 | } |
| 1814 | 1859 | |
| 1815 | | memcpy(sce->ltp_state, &sce->ltp_state[1024], 1024 * sizeof(int16_t)); |
| 1816 | | ac->fmt_conv.float_to_int16(&(sce->ltp_state[1024]), sce->ret, 1024); |
| 1817 | | ac->fmt_conv.float_to_int16(&(sce->ltp_state[2048]), saved_ltp, 1024); |
| | 1860 | memcpy(sce->ltp_state, sce->ltp_state+1024, 1024 * sizeof(*sce->ltp_state)); |
| | 1861 | memcpy(sce->ltp_state+1024, sce->ret, 1024 * sizeof(*sce->ltp_state)); |
| | 1862 | memcpy(sce->ltp_state+2048, saved_ltp, 1024 * sizeof(*sce->ltp_state)); |
| 1818 | 1863 | } |
| 1819 | 1864 | |
| 1820 | 1865 | /** |
| … |
… |
static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce)
|
| 1836 | 1881 | // imdct |
| 1837 | 1882 | if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { |
| 1838 | 1883 | for (i = 0; i < 1024; i += 128) |
| 1839 | | ff_imdct_half(&ac->mdct_small, buf + i, in + i); |
| | 1884 | ac->mdct_small.imdct_half(&ac->mdct_small, buf + i, in + i); |
| 1840 | 1885 | } else |
| 1841 | | ff_imdct_half(&ac->mdct, buf, in); |
| | 1886 | ac->mdct.imdct_half(&ac->mdct, buf, in); |
| 1842 | 1887 | |
| 1843 | 1888 | /* window overlapping |
| 1844 | 1889 | * NOTE: To simplify the overlapping code, all 'meaningless' short to long |
| … |
… |
static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb)
|
| 2023 | 2068 | |
| 2024 | 2069 | size = ff_aac_parse_header(gb, &hdr_info); |
| 2025 | 2070 | if (size > 0) { |
| 2026 | | if (ac->output_configured != OC_LOCKED && hdr_info.chan_config) { |
| | 2071 | if (hdr_info.chan_config) { |
| 2027 | 2072 | enum ChannelPosition new_che_pos[4][MAX_ELEM_ID]; |
| 2028 | 2073 | memset(new_che_pos, 0, 4 * MAX_ELEM_ID * sizeof(new_che_pos[0][0])); |
| 2029 | 2074 | ac->m4ac.chan_config = hdr_info.chan_config; |
| … |
… |
static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb)
|
| 2032 | 2077 | if (output_configure(ac, ac->che_pos, new_che_pos, hdr_info.chan_config, OC_TRIAL_FRAME)) |
| 2033 | 2078 | return -7; |
| 2034 | 2079 | } else if (ac->output_configured != OC_LOCKED) { |
| | 2080 | ac->m4ac.chan_config = 0; |
| 2035 | 2081 | ac->output_configured = OC_NONE; |
| 2036 | 2082 | } |
| 2037 | 2083 | if (ac->output_configured != OC_LOCKED) { |
| 2038 | 2084 | ac->m4ac.sbr = -1; |
| 2039 | 2085 | ac->m4ac.ps = -1; |
| | 2086 | ac->m4ac.sample_rate = hdr_info.sample_rate; |
| | 2087 | ac->m4ac.sampling_index = hdr_info.sampling_index; |
| | 2088 | ac->m4ac.object_type = hdr_info.object_type; |
| 2040 | 2089 | } |
| 2041 | | ac->m4ac.sample_rate = hdr_info.sample_rate; |
| 2042 | | ac->m4ac.sampling_index = hdr_info.sampling_index; |
| 2043 | | ac->m4ac.object_type = hdr_info.object_type; |
| 2044 | 2090 | if (!ac->avctx->sample_rate) |
| 2045 | 2091 | ac->avctx->sample_rate = hdr_info.sample_rate; |
| 2046 | 2092 | if (hdr_info.num_aac_frames == 1) { |
| … |
… |
static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
|
| 2061 | 2107 | ChannelElement *che = NULL, *che_prev = NULL; |
| 2062 | 2108 | enum RawDataBlockType elem_type, elem_type_prev = TYPE_END; |
| 2063 | 2109 | int err, elem_id, data_size_tmp; |
| 2064 | | int samples = 0, multiplier; |
| | 2110 | int samples = 0, multiplier, audio_found = 0; |
| 2065 | 2111 | |
| 2066 | 2112 | if (show_bits(gb, 12) == 0xfff) { |
| 2067 | 2113 | if (parse_adts_frame_header(ac, gb) < 0) { |
| … |
… |
static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
|
| 2092 | 2138 | |
| 2093 | 2139 | case TYPE_SCE: |
| 2094 | 2140 | err = decode_ics(ac, &che->ch[0], gb, 0, 0); |
| | 2141 | audio_found = 1; |
| 2095 | 2142 | break; |
| 2096 | 2143 | |
| 2097 | 2144 | case TYPE_CPE: |
| 2098 | 2145 | err = decode_cpe(ac, gb, che); |
| | 2146 | audio_found = 1; |
| 2099 | 2147 | break; |
| 2100 | 2148 | |
| 2101 | 2149 | case TYPE_CCE: |
| … |
… |
static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
|
| 2104 | 2152 | |
| 2105 | 2153 | case TYPE_LFE: |
| 2106 | 2154 | err = decode_ics(ac, &che->ch[0], gb, 0, 0); |
| | 2155 | audio_found = 1; |
| 2107 | 2156 | break; |
| 2108 | 2157 | |
| 2109 | 2158 | case TYPE_DSE: |
| … |
… |
static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
|
| 2173 | 2222 | if (samples) |
| 2174 | 2223 | ac->fmt_conv.float_to_int16_interleave(data, (const float **)ac->output_data, samples, avctx->channels); |
| 2175 | 2224 | |
| 2176 | | if (ac->output_configured) |
| | 2225 | if (ac->output_configured && audio_found) |
| 2177 | 2226 | ac->output_configured = OC_LOCKED; |
| 2178 | 2227 | |
| 2179 | 2228 | return 0; |
| … |
… |
static inline uint32_t latm_get_value(GetBitContext *b)
|
| 2242 | 2291 | } |
| 2243 | 2292 | |
| 2244 | 2293 | static int latm_decode_audio_specific_config(struct LATMContext *latmctx, |
| 2245 | | GetBitContext *gb) |
| | 2294 | GetBitContext *gb, int asclen) |
| 2246 | 2295 | { |
| 2247 | 2296 | AVCodecContext *avctx = latmctx->aac_ctx.avctx; |
| 2248 | 2297 | MPEG4AudioConfig m4ac; |
| | 2298 | AACContext *ac= &latmctx->aac_ctx; |
| 2249 | 2299 | int config_start_bit = get_bits_count(gb); |
| 2250 | 2300 | int bits_consumed, esize; |
| 2251 | 2301 | |
| … |
… |
static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
|
| 2255 | 2305 | return AVERROR_INVALIDDATA; |
| 2256 | 2306 | } else { |
| 2257 | 2307 | bits_consumed = |
| 2258 | | decode_audio_specific_config(NULL, avctx, &m4ac, |
| | 2308 | decode_audio_specific_config(ac, avctx, &m4ac, |
| 2259 | 2309 | gb->buffer + (config_start_bit / 8), |
| 2260 | | get_bits_left(gb) / 8); |
| | 2310 | get_bits_left(gb) / 8, asclen); |
| 2261 | 2311 | |
| 2262 | 2312 | if (bits_consumed < 0) |
| 2263 | 2313 | return AVERROR_INVALIDDATA; |
| | 2314 | ac->m4ac= m4ac; |
| 2264 | 2315 | |
| 2265 | 2316 | esize = (bits_consumed+7) / 8; |
| 2266 | 2317 | |
| … |
… |
static int read_stream_mux_config(struct LATMContext *latmctx,
|
| 2315 | 2366 | |
| 2316 | 2367 | // for all but first stream: use_same_config = get_bits(gb, 1); |
| 2317 | 2368 | if (!audio_mux_version) { |
| 2318 | | if ((ret = latm_decode_audio_specific_config(latmctx, gb)) < 0) |
| | 2369 | if ((ret = latm_decode_audio_specific_config(latmctx, gb, 0)) < 0) |
| 2319 | 2370 | return ret; |
| 2320 | 2371 | } else { |
| 2321 | 2372 | int ascLen = latm_get_value(gb); |
| 2322 | | if ((ret = latm_decode_audio_specific_config(latmctx, gb)) < 0) |
| | 2373 | if ((ret = latm_decode_audio_specific_config(latmctx, gb, ascLen)) < 0) |
| 2323 | 2374 | return ret; |
| 2324 | 2375 | ascLen -= ret; |
| 2325 | 2376 | skip_bits_long(gb, ascLen); |
| … |
… |
static int latm_decode_frame(AVCodecContext *avctx, void *out, int *out_size,
|
| 2442 | 2493 | *out_size = 0; |
| 2443 | 2494 | return avpkt->size; |
| 2444 | 2495 | } else { |
| | 2496 | aac_decode_close(avctx); |
| 2445 | 2497 | if ((err = aac_decode_init(avctx)) < 0) |
| 2446 | 2498 | return err; |
| 2447 | 2499 | latmctx->initialized = 1; |
diff --git a/mythtv/external/FFmpeg/libavcodec/aacsbr.c b/mythtv/external/FFmpeg/libavcodec/aacsbr.c
index 237d51a..e2b37df 100644
|
a
|
b
|
|
| 32 | 32 | #include "aacsbrdata.h" |
| 33 | 33 | #include "fft.h" |
| 34 | 34 | #include "aacps.h" |
| | 35 | #include "libavutil/libm.h" |
| | 36 | #include "libavutil/avassert.h" |
| 35 | 37 | |
| 36 | 38 | #include <stdint.h> |
| 37 | 39 | #include <float.h> |
| | 40 | #include <math.h> |
| 38 | 41 | |
| 39 | 42 | #define ENVELOPE_ADJUSTMENT_OFFSET 2 |
| 40 | 43 | #define NOISE_FLOOR_OFFSET 6.0f |
| … |
… |
av_cold void ff_aac_sbr_init(void)
|
| 127 | 130 | |
| 128 | 131 | av_cold void ff_aac_sbr_ctx_init(SpectralBandReplication *sbr) |
| 129 | 132 | { |
| | 133 | if(sbr->mdct.mdct_bits) |
| | 134 | return; |
| 130 | 135 | sbr->kx[0] = sbr->kx[1] = 32; //Typo in spec, kx' inits to 32 |
| 131 | 136 | sbr->data[0].e_a[1] = sbr->data[1].e_a[1] = -1; |
| 132 | 137 | sbr->data[0].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); |
| 133 | 138 | sbr->data[1].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128); |
| 134 | | ff_mdct_init(&sbr->mdct, 7, 1, 1.0/64); |
| | 139 | ff_mdct_init(&sbr->mdct, 7, 1, 1.0 / 64.0); |
| 135 | 140 | ff_mdct_init(&sbr->mdct_ana, 7, 1, -2.0); |
| 136 | 141 | ff_ps_ctx_init(&sbr->ps); |
| 137 | 142 | } |
| … |
… |
static void sbr_qmf_analysis(DSPContext *dsp, FFTContext *mdct, const float *in,
|
| 1155 | 1160 | } |
| 1156 | 1161 | z[64+63] = z[32]; |
| 1157 | 1162 | |
| 1158 | | ff_imdct_half(mdct, z, z+64); |
| | 1163 | mdct->imdct_half(mdct, z, z+64); |
| 1159 | 1164 | for (k = 0; k < 32; k++) { |
| 1160 | 1165 | W[1][i][k][0] = -z[63-k]; |
| 1161 | 1166 | W[1][i][k][1] = z[k]; |
| … |
… |
static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct,
|
| 1190 | 1195 | X[0][i][ n] = -X[0][i][n]; |
| 1191 | 1196 | X[0][i][32+n] = X[1][i][31-n]; |
| 1192 | 1197 | } |
| 1193 | | ff_imdct_half(mdct, mdct_buf[0], X[0][i]); |
| | 1198 | mdct->imdct_half(mdct, mdct_buf[0], X[0][i]); |
| 1194 | 1199 | for (n = 0; n < 32; n++) { |
| 1195 | 1200 | v[ n] = mdct_buf[0][63 - 2*n]; |
| 1196 | 1201 | v[63 - n] = -mdct_buf[0][62 - 2*n]; |
| … |
… |
static void sbr_qmf_synthesis(DSPContext *dsp, FFTContext *mdct,
|
| 1199 | 1204 | for (n = 1; n < 64; n+=2) { |
| 1200 | 1205 | X[1][i][n] = -X[1][i][n]; |
| 1201 | 1206 | } |
| 1202 | | ff_imdct_half(mdct, mdct_buf[0], X[0][i]); |
| 1203 | | ff_imdct_half(mdct, mdct_buf[1], X[1][i]); |
| | 1207 | mdct->imdct_half(mdct, mdct_buf[0], X[0][i]); |
| | 1208 | mdct->imdct_half(mdct, mdct_buf[1], X[1][i]); |
| 1204 | 1209 | for (n = 0; n < 64; n++) { |
| 1205 | 1210 | v[ n] = -mdct_buf[0][63 - n] + mdct_buf[1][ n ]; |
| 1206 | 1211 | v[127 - n] = mdct_buf[0][63 - n] + mdct_buf[1][ n ]; |
| … |
… |
static void sbr_mapping(AACContext *ac, SpectralBandReplication *sbr,
|
| 1450 | 1455 | uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow; |
| 1451 | 1456 | int k; |
| 1452 | 1457 | |
| | 1458 | av_assert0(sbr->kx[1] <= table[0]); |
| 1453 | 1459 | for (i = 0; i < ilim; i++) |
| 1454 | 1460 | for (m = table[i]; m < table[i + 1]; m++) |
| 1455 | 1461 | sbr->e_origmapped[e][m - sbr->kx[1]] = ch_data->env_facs[e+1][i]; |