63 5, 6, 7, 8, 9, 10, 11, 12, 14, 16
84 3.162275, 2.818382, 2.511886, 2.238719, 1.995261, 1.778278, 1.584893,
85 1.412536, 1.258924, 1.122018, 1.000000, 0.891251, 0.794328, 0.707946,
86 0.630957, 0.562341, 0.501187, 0.446683, 0.398107, 0.354813, 0.316227,
87 0.281838, 0.251188, 0.223872, 0.199526, 0.177828, 0.158489, 0.141253,
88 0.125892, 0.112201, 0.100000, 0.089125
96 { { 2, 7 }, { 7, 2 }, },
98 { { 2, 7 }, { 7, 2 }, },
99 { { 2, 7 }, { 5, 5 }, { 7, 2 }, },
100 { { 2, 7 }, { 7, 2 }, { 6, 6 }, },
101 { { 2, 7 }, { 5, 5 }, { 7, 2 }, { 8, 8 }, },
102 { { 2, 7 }, { 7, 2 }, { 6, 7 }, { 7, 6 }, },
103 { { 2, 7 }, { 5, 5 }, { 7, 2 }, { 6, 7 }, { 7, 6 }, },
114 return ((code - (levels >> 1)) << 24) / levels;
126 for (i = 0; i < 128; i++) {
134 for (i = 0; i < 32; i++) {
140 for (i = 0; i < 128; i++) {
152 for (i = 0; i < 7; i++) {
156 for (i = 0; i < 15; i++) {
163 for (i = 0; i < 256; i++) {
164 int v = (i >> 5) - ((i >> 7) << 3) - 5;
202 #if FF_API_REQUEST_CHANNELS
339 }
else if (CONFIG_EAC3_DECODER) {
365 downmix_coeffs[1][0] = downmix_coeffs[1][1] = cmix;
369 downmix_coeffs[nf][0] = downmix_coeffs[nf][1] = smix *
LEVEL_MINUS_3DB;
373 downmix_coeffs[nf][0] = downmix_coeffs[nf+1][1] = smix;
379 norm0 += downmix_coeffs[i][0];
380 norm1 += downmix_coeffs[i][1];
382 norm0 = 1.0f / norm0;
383 norm1 = 1.0f / norm1;
385 downmix_coeffs[i][0] *= norm0;
386 downmix_coeffs[i][1] *= norm1;
391 downmix_coeffs[i][0] = (downmix_coeffs[i][0] +
407 int i, j, grp, group_size;
412 group_size = exp_strategy + (exp_strategy ==
EXP_D45);
413 for (grp = 0, i = 0; grp < ngrps; grp++) {
422 for (i = 0, j = 0; i < ngrps * 3; i++) {
423 prevexp += dexp[i] - 2;
426 switch (group_size) {
427 case 4: dexps[j++] = prevexp;
428 dexps[j++] = prevexp;
429 case 2: dexps[j++] = prevexp;
430 case 1: dexps[j++] = prevexp;
447 int band_start = bin;
452 for (bin = band_start; bin < band_end; bin++) {
457 for (bin = band_start; bin < band_end; bin++)
485 int end_freq = s->
end_freq[ch_index];
487 int8_t *exps = s->
dexps[ch_index];
493 for (freq = start_freq; freq < end_freq; freq++) {
494 int bap = baps[freq];
555 coeffs[freq] = mantissa >> exps[freq];
586 if (!blk && CONFIG_EAC3_DECODER)
588 for (bin = s->
start_freq[ch]; bin < s->end_freq[ch]; bin++) {
605 for (ch = 1; ch <= s->
channels; ch++) {
661 for (ch = 1; ch <= channels; ch++) {
665 for (i = 0; i < 128; i++)
669 s->
fdsp->vector_fmul_window_scaled(s->
outptr[ch - 1], s->
delay[ch - 1],
675 for (i = 0; i < 128; i++)
681 s->
fdsp->vector_fmul_window_scaled(s->
outptr[ch - 1], s->
delay[ch - 1],
697 int channel_data_size =
sizeof(s->
delay[0]);
702 memcpy(s->
delay[1], s->
delay[0], channel_data_size);
705 memset(s->
delay[3], 0, channel_data_size);
707 memset(s->
delay[2], 0, channel_data_size);
710 memset(s->
delay[4], 0, channel_data_size);
712 memset(s->
delay[3], 0, channel_data_size);
714 memcpy(s->
delay[2], s->
delay[1], channel_data_size);
715 memset(s->
delay[1], 0, channel_data_size);
737 int ecpl,
int start_subband,
int end_subband,
738 const uint8_t *default_band_struct,
739 int *num_bands,
uint8_t *band_sizes)
741 int subbnd, bnd, n_subbands, n_bands=0;
746 n_subbands = end_subband - start_subband;
750 for (subbnd = 0; subbnd < n_subbands - 1; subbnd++) {
751 coded_band_struct[subbnd] =
get_bits1(gbc);
753 band_struct = coded_band_struct;
755 band_struct = &default_band_struct[start_subband+1];
764 if (num_bands || band_sizes ) {
765 n_bands = n_subbands;
766 bnd_sz[0] = ecpl ? 6 : 12;
767 for (bnd = 0, subbnd = 1; subbnd < n_subbands; subbnd++) {
768 int subbnd_size = (ecpl && subbnd < 4) ? 6 : 12;
769 if (band_struct[subbnd - 1]) {
771 bnd_sz[bnd] += subbnd_size;
773 bnd_sz[++bnd] = subbnd_size;
780 *num_bands = n_bands;
782 memcpy(band_sizes, bnd_sz, n_bands);
793 int different_transforms;
800 different_transforms = 0;
802 for (ch = 1; ch <= fbw_channels; ch++) {
805 different_transforms = 1;
811 for (ch = 1; ch <= fbw_channels; ch++) {
827 }
else if (blk == 0) {
836 int dst_start_freq, dst_end_freq, src_start_freq,
837 start_subband, end_subband;
843 for (ch = 1; ch <= fbw_channels; ch++)
850 start_subband =
get_bits(gbc, 3) + 2;
851 if (start_subband > 7)
852 start_subband += start_subband - 7;
858 end_subband += end_subband - 7;
859 dst_start_freq = dst_start_freq * 12 + 25;
860 src_start_freq = start_subband * 12 + 25;
861 dst_end_freq = end_subband * 12 + 25;
864 if (start_subband >= end_subband) {
866 "range (%d >= %d)\n", start_subband, end_subband);
869 if (dst_start_freq >= src_start_freq) {
871 "copy start bin (%d >= %d)\n", dst_start_freq, src_start_freq);
881 start_subband, end_subband,
886 for (ch = 1; ch <= fbw_channels; ch++) {
895 for (ch = 1; ch <= fbw_channels; ch++) {
899 int bin, master_spx_coord;
903 master_spx_coord =
get_bits(gbc, 2) * 3;
908 int spx_coord_exp, spx_coord_mant;
915 nratio = (int)(accu >> 32);
916 nratio -= spx_blend << 18;
921 }
else if (nratio > 0x7fffff) {
926 accu = (int64_t)nblend * 1859775393;
927 nblend = (int)((accu + (1<<29)) >> 30);
935 nratio = ((float)((bin + (bandsize >> 1))) / s->
spx_dst_end_freq) - spx_blend;
936 nratio = av_clipf(nratio, 0.0f, 1.0f);
937 nblend = sqrtf(3.0f * nratio);
939 sblend = sqrtf(1.0f - nratio);
946 if (spx_coord_exp == 15) spx_coord_mant <<= 1;
947 else spx_coord_mant += 4;
948 spx_coord_mant <<= (25 - spx_coord_exp - master_spx_coord);
952 accu = (int64_t)nblend * spx_coord_mant;
954 accu = (int64_t)sblend * spx_coord_mant;
957 spx_coord = spx_coord_mant * (1.0f / (1 << 23));
976 int cpl_start_subband, cpl_end_subband;
995 for (ch = 1; ch <= fbw_channels; ch++)
1004 cpl_start_subband =
get_bits(gbc, 4);
1007 if (cpl_start_subband >= cpl_end_subband) {
1009 cpl_start_subband, cpl_end_subband);
1021 for (ch = 1; ch <= fbw_channels; ch++) {
1028 }
else if (!s->
eac3) {
1031 "be present in block 0\n");
1041 int cpl_coords_exist = 0;
1043 for (ch = 1; ch <= fbw_channels; ch++) {
1046 int master_cpl_coord, cpl_coord_exp, cpl_coord_mant;
1048 cpl_coords_exist = 1;
1049 master_cpl_coord = 3 *
get_bits(gbc, 2);
1053 if (cpl_coord_exp == 15)
1054 s->
cpl_coords[ch][bnd] = cpl_coord_mant << 22;
1056 s->
cpl_coords[ch][bnd] = (cpl_coord_mant + 16) << 21;
1057 s->
cpl_coords[ch][bnd] >>= (cpl_coord_exp + master_cpl_coord);
1061 "be present in block 0\n");
1090 "new rematrixing strategy not present in block 0\n");
1096 for (ch = !cpl_in_use; ch <= s->
channels; ch++) {
1100 bit_alloc_stages[ch] = 3;
1104 for (ch = 1; ch <= fbw_channels; ch++) {
1114 int bandwidth_code =
get_bits(gbc, 6);
1115 if (bandwidth_code > 60) {
1119 s->
end_freq[ch] = bandwidth_code * 3 + 73;
1123 if (blk > 0 && s->
end_freq[ch] != prev)
1133 for (ch = !cpl_in_use; ch <= s->
channels; ch++) {
1155 for (ch = !cpl_in_use; ch <= s->
channels; ch++)
1156 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 2);
1159 "be present in block 0\n");
1165 if (!s->
eac3 || !blk) {
1169 csnr = (
get_bits(gbc, 6) - 15) << 4;
1170 for (i = ch = !cpl_in_use; ch <= s->
channels; ch++) {
1173 snr = (csnr +
get_bits(gbc, 4)) << 2;
1176 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 1);
1186 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 2);
1189 }
else if (!s->
eac3 && !blk) {
1197 for (ch = !cpl_in_use; ch <= s->
channels; ch++) {
1202 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 2);
1204 }
else if (s->
eac3 && !blk) {
1205 for (ch = !cpl_in_use; ch <= s->
channels; ch++)
1227 }
else if (!s->
eac3 && !blk) {
1229 "be present in block 0\n");
1238 for (ch = !cpl_in_use; ch <= fbw_channels; ch++) {
1244 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 2);
1247 for (ch = !cpl_in_use; ch <= fbw_channels; ch++) {
1250 for (seg = 0; seg < s->
dba_nsegs[ch]; seg++) {
1256 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 2);
1259 }
else if (blk == 0) {
1260 for (ch = 0; ch <= s->
channels; ch++) {
1266 for (ch = !cpl_in_use; ch <= s->
channels; ch++) {
1267 if (bit_alloc_stages[ch] > 2) {
1273 if (bit_alloc_stages[ch] > 1) {
1286 if (bit_alloc_stages[ch] > 0) {
1294 bap_tab, s->
bap[ch]);
1316 for (ch = 1; ch <= s->
channels; ch++) {
1326 gain *= 1.0 / 4194304.0f;
1343 if (different_transforms) {
1353 if (downmix_output) {
1363 if (downmix_output) {
1384 int *got_frame_ptr,
AVPacket *avpkt)
1388 int buf_size = avpkt->
size;
1398 if (buf_size >= 2 &&
AV_RB16(buf) == 0x770B) {
1402 (
const uint16_t *) buf, cnt);
1431 "skipping frame\n");
1515 output[ch] = s->
output[ch];
1518 for (ch = 0; ch < s->
channels; ch++) {
1519 if (ch < s->out_channels)
1531 output[ch] = s->
outptr[channel_map[ch]];
1533 if (!ch || channel_map[ch])
1620 #define OFFSET(x) offsetof(AC3DecodeContext, x)
1621 #define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM)