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
329 }
else if (CONFIG_EAC3_DECODER) {
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];
540 coeffs[freq] = mantissa >> exps[freq];
571 if (!blk && CONFIG_EAC3_DECODER)
573 for (bin = s->
start_freq[ch]; bin < s->end_freq[ch]; bin++) {
590 for (ch = 1; ch <= s->
channels; ch++) {
646 for (ch = 1; ch <= channels; ch++) {
650 for (i = 0; i < 128; i++)
655 for (i = 0; i < 128; i++)
672 int channel_data_size =
sizeof(s->
delay[0]);
677 memcpy(s->
delay[1], s->
delay[0], channel_data_size);
680 memset(s->
delay[3], 0, channel_data_size);
682 memset(s->
delay[2], 0, channel_data_size);
685 memset(s->
delay[4], 0, channel_data_size);
687 memset(s->
delay[3], 0, channel_data_size);
689 memcpy(s->
delay[2], s->
delay[1], channel_data_size);
690 memset(s->
delay[1], 0, channel_data_size);
712 int ecpl,
int start_subband,
int end_subband,
713 const uint8_t *default_band_struct,
714 int *num_bands,
uint8_t *band_sizes)
716 int subbnd, bnd, n_subbands, n_bands=0;
721 n_subbands = end_subband - start_subband;
725 for (subbnd = 0; subbnd < n_subbands - 1; subbnd++) {
726 coded_band_struct[subbnd] =
get_bits1(gbc);
728 band_struct = coded_band_struct;
730 band_struct = &default_band_struct[start_subband+1];
739 if (num_bands || band_sizes ) {
740 n_bands = n_subbands;
741 bnd_sz[0] = ecpl ? 6 : 12;
742 for (bnd = 0, subbnd = 1; subbnd < n_subbands; subbnd++) {
743 int subbnd_size = (ecpl && subbnd < 4) ? 6 : 12;
744 if (band_struct[subbnd - 1]) {
746 bnd_sz[bnd] += subbnd_size;
748 bnd_sz[++bnd] = subbnd_size;
755 *num_bands = n_bands;
757 memcpy(band_sizes, bnd_sz, n_bands);
768 int different_transforms;
775 different_transforms = 0;
777 for (ch = 1; ch <= fbw_channels; ch++) {
780 different_transforms = 1;
786 for (ch = 1; ch <= fbw_channels; ch++) {
802 }
else if (blk == 0) {
811 int dst_start_freq, dst_end_freq, src_start_freq,
812 start_subband, end_subband;
818 for (ch = 1; ch <= fbw_channels; ch++)
825 start_subband =
get_bits(gbc, 3) + 2;
826 if (start_subband > 7)
827 start_subband += start_subband - 7;
830 end_subband += end_subband - 7;
831 dst_start_freq = dst_start_freq * 12 + 25;
832 src_start_freq = start_subband * 12 + 25;
833 dst_end_freq = end_subband * 12 + 25;
836 if (start_subband >= end_subband) {
838 "range (%d >= %d)\n", start_subband, end_subband);
841 if (dst_start_freq >= src_start_freq) {
843 "copy start bin (%d >= %d)\n", dst_start_freq, src_start_freq);
852 start_subband, end_subband,
857 for (ch = 1; ch <= fbw_channels; ch++) {
866 for (ch = 1; ch <= fbw_channels; ch++) {
870 int bin, master_spx_coord;
873 spx_blend =
get_bits(gbc, 5) * (1.0f/32);
874 master_spx_coord =
get_bits(gbc, 2) * 3;
879 int spx_coord_exp, spx_coord_mant;
880 float nratio, sblend, nblend, spx_coord;
884 nratio = ((float)((bin + (bandsize >> 1))) / s->
spx_dst_end_freq) - spx_blend;
885 nratio = av_clipf(nratio, 0.0f, 1.0f);
886 nblend = sqrtf(3.0f * nratio);
888 sblend = sqrtf(1.0f - nratio);
894 if (spx_coord_exp == 15) spx_coord_mant <<= 1;
895 else spx_coord_mant += 4;
896 spx_coord_mant <<= (25 - spx_coord_exp - master_spx_coord);
897 spx_coord = spx_coord_mant * (1.0f / (1 << 23));
917 int cpl_start_subband, cpl_end_subband;
936 for (ch = 1; ch <= fbw_channels; ch++)
945 cpl_start_subband =
get_bits(gbc, 4);
948 if (cpl_start_subband >= cpl_end_subband) {
950 cpl_start_subband, cpl_end_subband);
962 for (ch = 1; ch <= fbw_channels; ch++) {
969 }
else if (!s->
eac3) {
972 "be present in block 0\n");
982 int cpl_coords_exist = 0;
984 for (ch = 1; ch <= fbw_channels; ch++) {
987 int master_cpl_coord, cpl_coord_exp, cpl_coord_mant;
989 cpl_coords_exist = 1;
990 master_cpl_coord = 3 *
get_bits(gbc, 2);
994 if (cpl_coord_exp == 15)
995 s->
cpl_coords[ch][bnd] = cpl_coord_mant << 22;
997 s->
cpl_coords[ch][bnd] = (cpl_coord_mant + 16) << 21;
998 s->
cpl_coords[ch][bnd] >>= (cpl_coord_exp + master_cpl_coord);
1002 "be present in block 0\n");
1031 "new rematrixing strategy not present in block 0\n");
1037 for (ch = !cpl_in_use; ch <= s->
channels; ch++) {
1041 bit_alloc_stages[ch] = 3;
1045 for (ch = 1; ch <= fbw_channels; ch++) {
1055 int bandwidth_code =
get_bits(gbc, 6);
1056 if (bandwidth_code > 60) {
1060 s->
end_freq[ch] = bandwidth_code * 3 + 73;
1064 if (blk > 0 && s->
end_freq[ch] != prev)
1074 for (ch = !cpl_in_use; ch <= s->
channels; ch++) {
1096 for (ch = !cpl_in_use; ch <= s->
channels; ch++)
1097 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 2);
1100 "be present in block 0\n");
1106 if (!s->
eac3 || !blk) {
1110 csnr = (
get_bits(gbc, 6) - 15) << 4;
1111 for (i = ch = !cpl_in_use; ch <= s->
channels; ch++) {
1114 snr = (csnr +
get_bits(gbc, 4)) << 2;
1117 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 1);
1127 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 2);
1130 }
else if (!s->
eac3 && !blk) {
1138 for (ch = !cpl_in_use; ch <= s->
channels; ch++) {
1143 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 2);
1145 }
else if (s->
eac3 && !blk) {
1146 for (ch = !cpl_in_use; ch <= s->
channels; ch++)
1168 }
else if (!s->
eac3 && !blk) {
1170 "be present in block 0\n");
1179 for (ch = !cpl_in_use; ch <= fbw_channels; ch++) {
1185 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 2);
1188 for (ch = !cpl_in_use; ch <= fbw_channels; ch++) {
1191 for (seg = 0; seg < s->
dba_nsegs[ch]; seg++) {
1197 bit_alloc_stages[ch] =
FFMAX(bit_alloc_stages[ch], 2);
1200 }
else if (blk == 0) {
1201 for (ch = 0; ch <= s->
channels; ch++) {
1207 for (ch = !cpl_in_use; ch <= s->
channels; ch++) {
1208 if (bit_alloc_stages[ch] > 2) {
1214 if (bit_alloc_stages[ch] > 1) {
1227 if (bit_alloc_stages[ch] > 0) {
1235 bap_tab, s->
bap[ch]);
1257 for (ch = 1; ch <= s->
channels; ch++) {
1258 float gain = 1.0 / 4194304.0f;
1279 if (different_transforms) {
1289 if (downmix_output) {
1294 if (downmix_output) {
1315 int *got_frame_ptr,
AVPacket *avpkt)
1319 int buf_size = avpkt->
size;
1329 if (buf_size >= 2 &&
AV_RB16(buf) == 0x770B) {
1361 "skipping frame\n");
1445 output[ch] = s->
output[ch];
1448 for (ch = 0; ch < s->
channels; ch++) {
1449 if (ch < s->out_channels)
1450 s->
outptr[channel_map[ch]] = (
float *)frame->
data[ch];
1461 output[ch] = s->
outptr[channel_map[ch]];
1463 if (!ch || channel_map[ch])
1547 #define OFFSET(x) offsetof(AC3DecodeContext, x)
1548 #define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM)
1550 {
"drc_scale",
"percentage of dynamic range compression to apply",
OFFSET(drc_scale),
AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 6.0,
PAR },
1552 {
"dmix_mode",
"Preferred Stereo Downmix Mode",
OFFSET(preferred_stereo_downmix),
AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 2, 0,
"dmix_mode"},
1553 {
"ltrt_cmixlev",
"Lt/Rt Center Mix Level",
OFFSET(ltrt_center_mix_level),
AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
1554 {
"ltrt_surmixlev",
"Lt/Rt Surround Mix Level",
OFFSET(ltrt_surround_mix_level),
AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
1555 {
"loro_cmixlev",
"Lo/Ro Center Mix Level",
OFFSET(loro_center_mix_level),
AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
1556 {
"loro_surmixlev",
"Lo/Ro Surround Mix Level",
OFFSET(loro_surround_mix_level),
AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0},
1583 #if CONFIG_EAC3_DECODER
1584 static const AVClass eac3_decoder_class = {
1603 .priv_class = &eac3_decoder_class,