62 5, 6, 7, 8, 9, 10, 11, 12, 14, 16
83 3.162275, 2.818382, 2.511886, 2.238719, 1.995261, 1.778278, 1.584893,
84 1.412536, 1.258924, 1.122018, 1.000000, 0.891251, 0.794328, 0.707946,
85 0.630957, 0.562341, 0.501187, 0.446683, 0.398107, 0.354813, 0.316227,
86 0.281838, 0.251188, 0.223872, 0.199526, 0.177828, 0.158489, 0.141253,
87 0.125892, 0.112201, 0.100000, 0.089125
95 { { 2, 7 }, { 7, 2 }, },
97 { { 2, 7 }, { 7, 2 }, },
98 { { 2, 7 }, { 5, 5 }, { 7, 2 }, },
99 { { 2, 7 }, { 7, 2 }, { 6, 6 }, },
100 { { 2, 7 }, { 5, 5 }, { 7, 2 }, { 8, 8 }, },
101 { { 2, 7 }, { 7, 2 }, { 6, 7 }, { 7, 6 }, },
102 { { 2, 7 }, { 5, 5 }, { 7, 2 }, { 6, 7 }, { 7, 6 }, },
113 return ((code - (levels >> 1)) << 24) / levels;
125 for (i = 0; i < 128; i++) {
133 for (i = 0; i < 32; i++) {
139 for (i = 0; i < 128; i++) {
151 for (i = 0; i < 7; i++) {
155 for (i = 0; i < 15; i++) {
162 for (i = 0; i < 256; i++) {
163 int v = (i >> 5) - ((i >> 7) << 3) - 5;
192 #if FF_API_REQUEST_CHANNELS
371 norm0 = 1.0f / norm0;
372 norm1 = 1.0f / norm1;
392 int i, j, grp, group_size;
397 group_size = exp_strategy + (exp_strategy ==
EXP_D45);
398 for (grp = 0, i = 0; grp < ngrps; grp++) {
407 for (i = 0, j = 0; i < ngrps * 3; i++) {
408 prevexp += dexp[i] - 2;
411 switch (group_size) {
412 case 4: dexps[j++] = prevexp;
413 dexps[j++] = prevexp;
414 case 2: dexps[j++] = prevexp;
415 case 1: dexps[j++] = prevexp;
432 int band_start = bin;
437 for (bin = band_start; bin < band_end; bin++) {
442 for (bin = band_start; bin < band_end; bin++)
470 int end_freq = s->
end_freq[ch_index];
472 int8_t *exps = s->
dexps[ch_index];
478 for (freq = start_freq; freq < end_freq; freq++) {
479 int bap = baps[freq];
536 coeffs[freq] = mantissa >> exps[freq];
569 for (bin = s->
start_freq[ch]; bin < s->end_freq[ch]; bin++) {
586 for (ch = 1; ch <= s->
channels; ch++) {
642 for (ch = 1; ch <= channels; ch++) {
646 for (i = 0; i < 128; i++)
651 for (i = 0; i < 128; i++)
668 int channel_data_size =
sizeof(s->
delay[0]);
673 memcpy(s->
delay[1], s->
delay[0], channel_data_size);
676 memset(s->
delay[3], 0, channel_data_size);
678 memset(s->
delay[2], 0, channel_data_size);
681 memset(s->
delay[4], 0, channel_data_size);
683 memset(s->
delay[3], 0, channel_data_size);
685 memcpy(s->
delay[2], s->
delay[1], channel_data_size);
686 memset(s->
delay[1], 0, channel_data_size);
708 int ecpl,
int start_subband,
int end_subband,
709 const uint8_t *default_band_struct,
710 int *num_bands,
uint8_t *band_sizes)
712 int subbnd, bnd, n_subbands, n_bands=0;
717 n_subbands = end_subband - start_subband;
721 for (subbnd = 0; subbnd < n_subbands - 1; subbnd++) {
722 coded_band_struct[subbnd] =
get_bits1(gbc);
724 band_struct = coded_band_struct;
726 band_struct = &default_band_struct[start_subband+1];
735 if (num_bands || band_sizes ) {
736 n_bands = n_subbands;
737 bnd_sz[0] = ecpl ? 6 : 12;
738 for (bnd = 0, subbnd = 1; subbnd < n_subbands; subbnd++) {
739 int subbnd_size = (ecpl && subbnd < 4) ? 6 : 12;
740 if (band_struct[subbnd - 1]) {
742 bnd_sz[bnd] += subbnd_size;
744 bnd_sz[++bnd] = subbnd_size;
751 *num_bands = n_bands;
753 memcpy(band_sizes, bnd_sz, n_bands);
764 int different_transforms;
771 different_transforms = 0;
773 for (ch = 1; ch <= fbw_channels; ch++) {
776 different_transforms = 1;
782 for (ch = 1; ch <= fbw_channels; ch++) {
798 }
else if (blk == 0) {
807 int dst_start_freq, dst_end_freq, src_start_freq,
808 start_subband, end_subband;
814 for (ch = 1; ch <= fbw_channels; ch++)
821 start_subband =
get_bits(gbc, 3) + 2;
822 if (start_subband > 7)
823 start_subband += start_subband - 7;
826 end_subband += end_subband - 7;
827 dst_start_freq = dst_start_freq * 12 + 25;
828 src_start_freq = start_subband * 12 + 25;
829 dst_end_freq = end_subband * 12 + 25;
832 if (start_subband >= end_subband) {
834 "range (%d >= %d)\n", start_subband, end_subband);
837 if (dst_start_freq >= src_start_freq) {
839 "copy start bin (%d >= %d)\n", dst_start_freq, src_start_freq);
848 start_subband, end_subband,
853 for (ch = 1; ch <= fbw_channels; ch++) {
862 for (ch = 1; ch <= fbw_channels; ch++) {
866 int bin, master_spx_coord;
869 spx_blend =
get_bits(gbc, 5) * (1.0f/32);
870 master_spx_coord =
get_bits(gbc, 2) * 3;
875 int spx_coord_exp, spx_coord_mant;
876 float nratio, sblend, nblend, spx_coord;
880 nratio = ((float)((bin + (bandsize >> 1))) / s->
spx_dst_end_freq) - spx_blend;
881 nratio = av_clipf(nratio, 0.0f, 1.0f);
882 nblend = sqrtf(3.0f * nratio);
884 sblend = sqrtf(1.0f - nratio);
890 if (spx_coord_exp == 15) spx_coord_mant <<= 1;
891 else spx_coord_mant += 4;
892 spx_coord_mant <<= (25 - spx_coord_exp - master_spx_coord);
893 spx_coord = spx_coord_mant * (1.0f / (1 << 23));
913 int cpl_start_subband, cpl_end_subband;
932 for (ch = 1; ch <= fbw_channels; ch++)
941 cpl_start_subband =
get_bits(gbc, 4);
944 if (cpl_start_subband >= cpl_end_subband) {
946 cpl_start_subband, cpl_end_subband);
958 for (ch = 1; ch <= fbw_channels; ch++) {
965 }
else if (!s->
eac3) {
968 "be present in block 0\n");
978 int cpl_coords_exist = 0;
980 for (ch = 1; ch <= fbw_channels; ch++) {
983 int master_cpl_coord, cpl_coord_exp, cpl_coord_mant;
985 cpl_coords_exist = 1;
986 master_cpl_coord = 3 *
get_bits(gbc, 2);
990 if (cpl_coord_exp == 15)
991 s->
cpl_coords[ch][bnd] = cpl_coord_mant << 22;
993 s->
cpl_coords[ch][bnd] = (cpl_coord_mant + 16) << 21;
994 s->
cpl_coords[ch][bnd] >>= (cpl_coord_exp + master_cpl_coord);
998 "be present in block 0\n");
1027 "new rematrixing strategy not present in block 0\n");
1033 for (ch = !cpl_in_use; ch <= s->
channels; ch++) {
1037 bit_alloc_stages[ch] = 3;
1041 for (ch = 1; ch <= fbw_channels; ch++) {
1051 int bandwidth_code =
get_bits(gbc, 6);
1052 if (bandwidth_code > 60) {
1056 s->
end_freq[ch] = bandwidth_code * 3 + 73;
1060 if (blk > 0 && s->
end_freq[ch] != prev)
1070 for (ch = !cpl_in_use; ch <= s->
channels; ch++) {
1092 for (ch = !cpl_in_use; ch <= s->
channels; ch++)
1093 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 2);
1096 "be present in block 0\n");
1102 if (!s->
eac3 || !blk) {
1106 csnr = (
get_bits(gbc, 6) - 15) << 4;
1107 for (i = ch = !cpl_in_use; ch <= s->
channels; ch++) {
1110 snr = (csnr +
get_bits(gbc, 4)) << 2;
1113 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 1);
1123 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 2);
1126 }
else if (!s->
eac3 && !blk) {
1134 for (ch = !cpl_in_use; ch <= s->
channels; ch++) {
1139 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 2);
1141 }
else if (s->
eac3 && !blk) {
1142 for (ch = !cpl_in_use; ch <= s->
channels; ch++)
1164 }
else if (!s->
eac3 && !blk) {
1166 "be present in block 0\n");
1175 for (ch = !cpl_in_use; ch <= fbw_channels; ch++) {
1181 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 2);
1184 for (ch = !cpl_in_use; ch <= fbw_channels; ch++) {
1187 for (seg = 0; seg < s->
dba_nsegs[ch]; seg++) {
1193 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 2);
1196 }
else if (blk == 0) {
1197 for (ch = 0; ch <= s->
channels; ch++) {
1203 for (ch = !cpl_in_use; ch <= s->
channels; ch++) {
1204 if (bit_alloc_stages[ch] > 2) {
1210 if (bit_alloc_stages[ch] > 1) {
1223 if (bit_alloc_stages[ch] > 0) {
1231 bap_tab, s->
bap[ch]);
1253 for (ch = 1; ch <= s->
channels; ch++) {
1254 float gain = 1.0 / 4194304.0f;
1275 if (different_transforms) {
1285 if (downmix_output) {
1290 if (downmix_output) {
1311 int *got_frame_ptr,
AVPacket *avpkt)
1315 int buf_size = avpkt->
size;
1317 int blk, ch, err, ret;
1325 if (buf_size >= 2 &&
AV_RB16(buf) == 0x770B) {
1357 "skipping frame\n");
1438 for (ch = 0; ch < s->
channels; ch++) {
1439 if (ch < s->out_channels)
1440 s->
outptr[channel_map[ch]] = (
float *)frame->
data[ch];
1443 output[ch] = s->
output[ch];
1454 output[ch] = s->
outptr[channel_map[ch]];
1456 s->
outptr[ch] += AC3_BLOCK_SIZE;
1536 #define OFFSET(x) offsetof(AC3DecodeContext, x)
1537 #define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM)
1539 {
"drc_scale",
"percentage of dynamic range compression to apply",
OFFSET(drc_scale),
AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 6.0,
PAR },
1565 #if CONFIG_EAC3_DECODER
1566 static const AVClass eac3_decoder_class = {
1585 .priv_class = &eac3_decoder_class,