History

dca: Support for XLL (lossless extension)

Cleanup and integration by Diego Biurrun.

Niels Möller committed 12 years ago

Commit 217e4ff1 parent 4da5aac10 files · +1718 −32Browse files

Unified · Split

10 files
  1. Changelog +1 −0
  2. doc/general.texi +1 −0
  3. libavcodec/Makefile +1 −1
  4. libavcodec/dca.h +99 −2
  5. libavcodec/dca_exss.c +52 −5
  6. libavcodec/dca_xll.c +747 −0
  7. libavcodec/dcadata.c +629 −1
  8. libavcodec/dcadata.h +9 −1
  9. libavcodec/dcadec.c +178 −21
  10. libavcodec/version.h +1 −1
Changelog+1−0
@@ -23,6 +23,7 @@ version <next>: · 22 unmodified lines
2323 - RTP depacketization of T.140 text (RFC 4103)
2424 - VP9 RTP payload format (draft 0) experimental depacketizer
2525 - TDSC decoder
26+- DTS lossless extension (XLL) decoding (not lossless, disabled by default)
2627
2728
2829 version 11:
doc/general.texi+1−0
@@ -828,6 +828,7 @@ following image formats are supported: · 827 unmodified lines
828828 @item COOK @tab @tab X
829829 @tab All versions except 5.1 are supported.
830830 @item DCA (DTS Coherent Acoustics) @tab @tab X
831+ @tab supported extensions: XCh, XLL (partially)
831832 @item DPCM id RoQ @tab X @tab X
832833 @tab Used in Quake III, Jedi Knight 2, other computer games.
833834 @item DPCM Interplay @tab @tab X
libavcodec/Makefile+1−1
@@ -161,7 +161,7 @@ OBJS-$(CONFIG_CSCD_DECODER) += cscd.o · 160 unmodified lines
161161 OBJS-$(CONFIG_CYUV_DECODER) += cyuv.o
162162 OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadsp.o \
163163 dcadata.o dca_exss.o \
164− synth_filter.o
164+ dca_xll.o synth_filter.o
165165 OBJS-$(CONFIG_DFA_DECODER) += dfa.o
166166 OBJS-$(CONFIG_DNXHD_DECODER) += dnxhddec.o dnxhddata.o
167167 OBJS-$(CONFIG_DNXHD_ENCODER) += dnxhdenc.o dnxhddata.o
libavcodec/dca.h+99−2
@@ -42,6 +42,21 @@ · 41 unmodified lines
4242 #define DCA_BLOCKS_MAX (16)
4343 #define DCA_LFE_MAX (3)
4444
45+#define DCA_PRIM_CHANNELS_MAX (7)
46+#define DCA_ABITS_MAX (32) /* Should be 28 */
47+#define DCA_SUBSUBFRAMES_MAX (4)
48+#define DCA_SUBFRAMES_MAX (16)
49+#define DCA_BLOCKS_MAX (16)
50+#define DCA_LFE_MAX (3)
51+#define DCA_XLL_FBANDS_MAX (4)
52+#define DCA_XLL_SEGMENTS_MAX (16)
53+#define DCA_XLL_CHSETS_MAX (16)
54+#define DCA_XLL_CHANNELS_MAX (16)
55+#define DCA_XLL_AORDER_MAX (15)
56+
57+/* Arbitrary limit; not sure what the maximum really is, but much larger. */
58+#define DCA_XLL_DMIX_NCOEFFS_MAX (18)
59+
4560 #define DCA_MAX_FRAME_SIZE 16384
4661 #define DCA_MAX_EXSS_HEADER_SIZE 4096
4762
@@ -60,6 +75,61 @@ enum DCAExtensionMask { · 12 unmodified lines
6075 DCA_EXT_EXSS_XLL = 0x200, ///< lossless extension in ExSS
6176 };
6277
78+typedef struct XllChSetSubHeader {
79+ int channels; ///< number of channels in channel set, at most 16
80+ int residual_encode; ///< residual channel encoding
81+ int bit_resolution; ///< input sample bit-width
82+ int bit_width; ///< original input sample bit-width
83+ int sampling_frequency; ///< sampling frequency
84+ int samp_freq_interp; ///< sampling frequency interpolation multiplier
85+ int replacement_set; ///< replacement channel set group
86+ int active_replace_set; ///< current channel set is active channel set
87+ int primary_ch_set;
88+ int downmix_coeff_code_embedded;
89+ int downmix_embedded;
90+ int downmix_type;
91+ int hier_chset; ///< hierarchical channel set
92+ int downmix_ncoeffs;
93+ int downmix_coeffs[DCA_XLL_DMIX_NCOEFFS_MAX];
94+ int ch_mask_enabled;
95+ int ch_mask;
96+ int mapping_coeffs_present;
97+ int num_freq_bands;
98+
99+ /* m_nOrigChanOrder */
100+ uint8_t orig_chan_order[DCA_XLL_FBANDS_MAX][DCA_XLL_CHANNELS_MAX];
101+ uint8_t orig_chan_order_inv[DCA_XLL_FBANDS_MAX][DCA_XLL_CHANNELS_MAX];
102+ /* Coefficients for channel pairs (at most 8), m_anPWChPairsCoeffs */
103+ int8_t pw_ch_pairs_coeffs[DCA_XLL_FBANDS_MAX][DCA_XLL_CHANNELS_MAX/2];
104+ /* m_nCurrHighestLPCOrder */
105+ uint8_t adapt_order_max[DCA_XLL_FBANDS_MAX];
106+ /* m_pnAdaptPredOrder */
107+ uint8_t adapt_order[DCA_XLL_FBANDS_MAX][DCA_XLL_CHANNELS_MAX];
108+ /* m_pnFixedPredOrder */
109+ uint8_t fixed_order[DCA_XLL_FBANDS_MAX][DCA_XLL_CHANNELS_MAX];
110+ /* m_pnLPCReflCoeffsQInd, unsigned version */
111+ uint8_t lpc_refl_coeffs_q_ind[DCA_XLL_FBANDS_MAX]
112+ [DCA_XLL_CHANNELS_MAX][DCA_XLL_AORDER_MAX];
113+
114+ int lsb_fsize[DCA_XLL_FBANDS_MAX];
115+ int8_t scalable_lsbs[DCA_XLL_FBANDS_MAX][DCA_XLL_CHANNELS_MAX];
116+ int8_t bit_width_adj_per_ch[DCA_XLL_FBANDS_MAX][DCA_XLL_CHANNELS_MAX];
117+} XllChSetSubHeader;
118+
119+typedef struct XllNavi {
120+ GetBitContext gb; // Context for parsing the data segments
121+ unsigned band_size[DCA_XLL_FBANDS_MAX];
122+ unsigned segment_size[DCA_XLL_FBANDS_MAX][DCA_XLL_SEGMENTS_MAX];
123+ unsigned chset_size[DCA_XLL_FBANDS_MAX][DCA_XLL_SEGMENTS_MAX][DCA_XLL_CHSETS_MAX];
124+} XllNavi;
125+
126+typedef struct QMF64_table {
127+ float dct4_coeff[32][32];
128+ float dct2_coeff[32][32];
129+ float rcos[32];
130+ float rsin[32];
131+} QMF64_table;
132+
63133 typedef struct DCAContext {
64134 AVClass *class; ///< class for AVOptions
65135 AVCodecContext *avctx;
@@ -132,8 +202,10 @@ typedef struct DCAContext { · 66 unmodified lines
132202
133203 /* Subband samples history (for ADPCM) */
134204 DECLARE_ALIGNED(16, float, subband_samples_hist)[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][4];
135− DECLARE_ALIGNED(32, float, subband_fir_hist)[DCA_PRIM_CHANNELS_MAX][512];
136− DECLARE_ALIGNED(32, float, subband_fir_noidea)[DCA_PRIM_CHANNELS_MAX][32];
205+ /* Half size is sufficient for core decoding, but for 96 kHz data
206+ * we need QMF with 64 subbands and 1024 samples. */
207+ DECLARE_ALIGNED(32, float, subband_fir_hist)[DCA_PRIM_CHANNELS_MAX][1024];
208+ DECLARE_ALIGNED(32, float, subband_fir_noidea)[DCA_PRIM_CHANNELS_MAX][64];
137209 int hist_index[DCA_PRIM_CHANNELS_MAX];
138210 DECLARE_ALIGNED(32, float, raXin)[32];
139211
@@ -155,12 +227,31 @@ typedef struct DCAContext { · 15 unmodified lines
155227 int current_subsubframe;
156228
157229 int core_ext_mask; ///< present extensions in the core substream
230+ int exss_ext_mask; ///< Non-core extensions
158231
159232 /* XCh extension information */
160233 int xch_present; ///< XCh extension present and valid
161234 int xch_base_channel; ///< index of first (only) channel containing XCH data
162235 int xch_disable; ///< whether the XCh extension should be decoded or not
163236
237+ /* XLL extension information */
238+ int xll_disable;
239+ int xll_nch_sets; ///< number of channel sets per frame
240+ int xll_channels; ///< total number of channels (in all channel sets)
241+ int xll_residual_channels; ///< number of residual channels
242+ int xll_segments; ///< number of segments per frame
243+ int xll_log_smpl_in_seg; ///< supposedly this is "nBits4SamplLoci"
244+ int xll_smpl_in_seg; ///< samples in segment per one frequency band for the first channel set
245+ int xll_bits4seg_size; ///< number of bits used to read segment size
246+ int xll_banddata_crc; ///< presence of CRC16 within each frequency band
247+ int xll_scalable_lsb;
248+ int xll_bits4ch_mask; ///< channel position mask
249+ int xll_fixed_lsb_width;
250+ XllChSetSubHeader xll_chsets[DCA_XLL_CHSETS_MAX];
251+ XllNavi xll_navi;
252+ int *xll_sample_buf;
253+ unsigned int xll_sample_buf_size;
254+
164255 /* ExSS header parser */
165256 int static_fields; ///< static fields present
166257 int mix_metadata; ///< mixing metadata present
@@ -168,12 +259,14 @@ typedef struct DCAContext { · 1 unmodified line
168259 int mix_config_num_ch[4]; ///< number of channels in each mix out configuration
169260
170261 int profile;
262+ int one2one_map_chtospkr;
171263
172264 int debug_flag; ///< used for suppressing repeated error messages output
173265 AVFloatDSPContext fdsp;
174266 FFTContext imdct;
175267 SynthFilterContext synth;
176268 DCADSPContext dcadsp;
269+ QMF64_table *qmf64_table;
177270 FmtConvertContext fmt_conv;
178271 } DCAContext;
179272
@@ -187,4 +280,8 @@ int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, · 7 unmodified lines
187280
188281 void ff_dca_exss_parse_header(DCAContext *s);
189282
283+int ff_dca_xll_decode_header(DCAContext *s);
284+int ff_dca_xll_decode_navi(DCAContext *s, int asset_end);
285+int ff_dca_xll_decode_audio(DCAContext *s, AVFrame *frame);
286+
190287 #endif /* AVCODEC_DCA_H */
libavcodec/dca_exss.c+52−5
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 #include "libavutil/log.h"
2323
2424 #include "dca.h"
25+#include "dca_syncwords.h"
2526 #include "get_bits.h"
2627
2728 /* extensions that reside in core substream */
@@ -121,7 +122,8 @@ static int dca_exss_parse_asset_header(DCAContext *s) · 93 unmodified lines
121122 skip_bits(&s->gb, 4); // max sample rate code
122123 channels = get_bits(&s->gb, 8) + 1;
123124
124− if (get_bits1(&s->gb)) { // 1-to-1 channels to speakers
125+ s->one2one_map_chtospkr = get_bits1(&s->gb);
126+ if (s->one2one_map_chtospkr) {
125127 int spkr_remap_sets;
126128 int spkr_mask_size = 16;
127129 int num_spkrs[7];
@@ -242,21 +244,27 @@ static int dca_exss_parse_asset_header(DCAContext *s) · 114 unmodified lines
242244 */
243245 void ff_dca_exss_parse_header(DCAContext *s)
244246 {
247+ int asset_size[8];
245248 int ss_index;
246249 int blownup;
247250 int num_audiop = 1;
248251 int num_assets = 1;
249252 int active_ss_mask[8];
250253 int i, j;
254+ int start_pos;
255+ int hdrsize;
256+ uint32_t mkr;
251257
252258 if (get_bits_left(&s->gb) < 52)
253259 return;
254260
261+ start_pos = get_bits_count(&s->gb) - 32;
262+
255263 skip_bits(&s->gb, 8); // user data
256264 ss_index = get_bits(&s->gb, 2);
257265
258266 blownup = get_bits1(&s->gb);
259− skip_bits(&s->gb, 8 + 4 * blownup); // header_size
267+ hdrsize = get_bits(&s->gb, 8 + 4 * blownup) + 1; // header_size
260268 skip_bits(&s->gb, 16 + 4 * blownup); // hd_size
261269
262270 s->static_fields = get_bits1(&s->gb);
@@ -309,13 +317,52 @@ void ff_dca_exss_parse_header(DCAContext *s) · 46 unmodified lines
309317 }
310318
311319 for (i = 0; i < num_assets; i++)
312− skip_bits_long(&s->gb, 16 + 4 * blownup); // asset size
320+ asset_size[i] = get_bits_long(&s->gb, 16 + 4 * blownup) + 1;
313321
314322 for (i = 0; i < num_assets; i++) {
315323 if (dca_exss_parse_asset_header(s))
316324 return;
317325 }
318326
319− /* not parsed further, we were only interested in the extensions mask
320− * from the asset header */
327+ if (num_assets > 0) {
328+ j = get_bits_count(&s->gb);
329+ if (start_pos + hdrsize * 8 > j)
330+ skip_bits_long(&s->gb, start_pos + hdrsize * 8 - j);
331+
332+ for (i = 0; i < num_assets; i++) {
333+ int end_pos;
334+ start_pos = get_bits_count(&s->gb);
335+ end_pos = start_pos + asset_size[i] * 8;
336+ mkr = get_bits_long(&s->gb, 32);
337+
338+ /* parse extensions that we know about */
339+ switch (mkr) {
340+ case DCA_SYNCWORD_XLL:
341+ if (s->xll_disable) {
342+ av_log(s->avctx, AV_LOG_DEBUG,
343+ "DTS-XLL: ignoring XLL extension\n");
344+ break;
345+ }
346+ av_log(s->avctx, AV_LOG_DEBUG,
347+ "DTS-XLL: decoding XLL extension\n");
348+ if (ff_dca_xll_decode_header(s) == 0 &&
349+ ff_dca_xll_decode_navi(s, end_pos) == 0)
350+ s->exss_ext_mask |= DCA_EXT_EXSS_XLL;
351+ break;
352+ case DCA_SYNCWORD_XBR:
353+ case DCA_SYNCWORD_XXCH:
354+ default:
355+ av_log(s->avctx, AV_LOG_VERBOSE,
356+ "DTS-ExSS: unknown marker = 0x%08"PRIx32"\n", mkr);
357+ }
358+
359+ /* skip to end of block */
360+ j = get_bits_count(&s->gb);
361+ if (j > end_pos)
362+ av_log(s->avctx, AV_LOG_ERROR,
363+ "DTS-ExSS: Processed asset too long.\n");
364+ if (j < end_pos)
365+ skip_bits_long(&s->gb, end_pos - j);
366+ }
367+ }
321368 }
libavcodec/dca_xll.c+747−0
@@ -0,0 +1,747 @@
1+/*
2+ * DCA XLL extension
3+ *
4+ * Copyright (C) 2012 Paul B Mahol
5+ * Copyright (C) 2014 Niels Möller
6+ *
7+ * This file is part of Libav.
8+ *
9+ * Libav is free software; you can redistribute it and/or
10+ * modify it under the terms of the GNU Lesser General Public
11+ * License as published by the Free Software Foundation; either
12+ * version 2.1 of the License, or (at your option) any later version.
13+ *
14+ * Libav is distributed in the hope that it will be useful,
15+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+ * Lesser General Public License for more details.
18+ *
19+ * You should have received a copy of the GNU Lesser General Public
20+ * License along with Libav; if not, write to the Free Software
21+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22+ */
23+
24+#include "libavutil/attributes.h"
25+#include "libavutil/common.h"
26+#include "libavutil/internal.h"
27+
28+#include "avcodec.h"
29+#include "dca.h"
30+#include "dcadata.h"
31+#include "get_bits.h"
32+#include "unary.h"
33+
34+/* Sign as bit 0 */
35+static inline int get_bits_sm(GetBitContext *s, unsigned n)
36+{
37+ int x = get_bits(s, n);
38+ if (x & 1)
39+ return -(x >> 1) - 1;
40+ else
41+ return x >> 1;
42+}
43+
44+/* Return -1 on error. */
45+static int32_t get_dmix_coeff(DCAContext *s, int inverse)
46+{
47+ unsigned code = get_bits(&s->gb, 9);
48+ int32_t sign = (int32_t) (code >> 8) - 1;
49+ unsigned idx = code & 0xff;
50+ int inv_offset = FF_DCA_DMIXTABLE_SIZE -FF_DCA_INV_DMIXTABLE_SIZE;
51+ if (idx >= FF_DCA_DMIXTABLE_SIZE) {
52+ av_log(s->avctx, AV_LOG_ERROR,
53+ "XLL: Invalid channel set downmix code %x\n", code);
54+ return -1;
55+ } else if (!inverse) {
56+ return (ff_dca_dmixtable[idx] ^ sign) - sign;
57+ } else if (idx < inv_offset) {
58+ av_log(s->avctx, AV_LOG_ERROR,
59+ "XLL: Invalid channel set inverse downmix code %x\n", code);
60+ return -1;
61+ } else {
62+ return (ff_dca_inv_dmixtable[idx - inv_offset] ^ sign) - sign;
63+ }
64+}
65+
66+static int32_t dca_get_dmix_coeff(DCAContext *s)
67+{
68+ return get_dmix_coeff(s, 0);
69+}
70+
71+static int32_t dca_get_inv_dmix_coeff(DCAContext *s)
72+{
73+ return get_dmix_coeff(s, 1);
74+}
75+
76+/* parse XLL header */
77+int ff_dca_xll_decode_header(DCAContext *s)
78+{
79+ int hdr_pos, hdr_size;
80+ av_unused int version, frame_size;
81+ int i, chset_index;
82+
83+ /* get bit position of sync header */
84+ hdr_pos = get_bits_count(&s->gb) - 32;
85+
86+ version = get_bits(&s->gb, 4) + 1;
87+ hdr_size = get_bits(&s->gb, 8) + 1;
88+
89+ frame_size = get_bits_long(&s->gb, get_bits(&s->gb, 5) + 1) + 1;
90+
91+ s->xll_channels =
92+ s->xll_residual_channels = 0;
93+ s->xll_nch_sets = get_bits(&s->gb, 4) + 1;
94+ s->xll_segments = 1 << get_bits(&s->gb, 4);
95+ s->xll_log_smpl_in_seg = get_bits(&s->gb, 4);
96+ s->xll_smpl_in_seg = 1 << s->xll_log_smpl_in_seg;
97+ s->xll_bits4seg_size = get_bits(&s->gb, 5) + 1;
98+ s->xll_banddata_crc = get_bits(&s->gb, 2);
99+ s->xll_scalable_lsb = get_bits1(&s->gb);
100+ s->xll_bits4ch_mask = get_bits(&s->gb, 5) + 1;
101+
102+ if (s->xll_scalable_lsb) {
103+ s->xll_fixed_lsb_width = get_bits(&s->gb, 4);
104+ if (s->xll_fixed_lsb_width)
105+ av_log(s->avctx, AV_LOG_WARNING,
106+ "XLL: fixed lsb width = %d, non-zero not supported.\n",
107+ s->xll_fixed_lsb_width);
108+ }
109+ /* skip to the end of the common header */
110+ i = get_bits_count(&s->gb);
111+ if (hdr_pos + hdr_size * 8 > i)
112+ skip_bits_long(&s->gb, hdr_pos + hdr_size * 8 - i);
113+
114+ for (chset_index = 0; chset_index < s->xll_nch_sets; chset_index++) {
115+ XllChSetSubHeader *chset = &s->xll_chsets[chset_index];
116+ hdr_pos = get_bits_count(&s->gb);
117+ hdr_size = get_bits(&s->gb, 10) + 1;
118+
119+ chset->channels = get_bits(&s->gb, 4) + 1;
120+ chset->residual_encode = get_bits(&s->gb, chset->channels);
121+ chset->bit_resolution = get_bits(&s->gb, 5) + 1;
122+ chset->bit_width = get_bits(&s->gb, 5) + 1;
123+ chset->sampling_frequency = ff_dca_sampling_freqs[get_bits(&s->gb, 4)];
124+ chset->samp_freq_interp = get_bits(&s->gb, 2);
125+ chset->replacement_set = get_bits(&s->gb, 2);
126+ if (chset->replacement_set)
127+ chset->active_replace_set = get_bits(&s->gb, 1);
128+
129+ if (s->one2one_map_chtospkr) {
130+ chset->primary_ch_set = get_bits(&s->gb, 1);
131+ chset->downmix_coeff_code_embedded = get_bits(&s->gb, 1);
132+ if (chset->downmix_coeff_code_embedded) {
133+ chset->downmix_embedded = get_bits(&s->gb, 1);
134+ if (chset->primary_ch_set) {
135+ chset->downmix_type = get_bits(&s->gb, 3);
136+ if (chset->downmix_type > 6) {
137+ av_log(s->avctx, AV_LOG_ERROR,
138+ "XLL: Invalid channel set downmix type\n");
139+ return AVERROR_INVALIDDATA;
140+ }
141+ }
142+ }
143+ chset->hier_chset = get_bits(&s->gb, 1);
144+
145+ if (chset->downmix_coeff_code_embedded) {
146+ /* nDownmixCoeffs is specified as N * M. For a primary
147+ * channel set, it appears that N = number of
148+ * channels, and M is the number of downmix channels.
149+ *
150+ * For a non-primary channel set, N is specified as
151+ * number of channels + 1, and M is derived from the
152+ * channel set hierarchy, and at least in simple cases
153+ * M is the number of channels in preceding channel
154+ * sets. */
155+ if (chset->primary_ch_set) {
156+ static const char dmix_table[7] = { 1, 2, 2, 3, 3, 4, 4 };
157+ chset->downmix_ncoeffs = chset->channels * dmix_table[chset->downmix_type];
158+ } else
159+ chset->downmix_ncoeffs = (chset->channels + 1) * s->xll_channels;
160+
161+ if (chset->downmix_ncoeffs > DCA_XLL_DMIX_NCOEFFS_MAX) {
162+ avpriv_request_sample(s->avctx,
163+ "XLL: More than %d downmix coefficients",
164+ DCA_XLL_DMIX_NCOEFFS_MAX);
165+ return AVERROR_PATCHWELCOME;
166+ } else if (chset->primary_ch_set) {
167+ for (i = 0; i < chset->downmix_ncoeffs; i++)
168+ if ((chset->downmix_coeffs[i] = dca_get_dmix_coeff(s)) == -1)
169+ return AVERROR_INVALIDDATA;
170+ } else {
171+ unsigned c, r;
172+ for (c = 0, i = 0; c < s->xll_channels; c++, i += chset->channels + 1) {
173+ if ((chset->downmix_coeffs[i] = dca_get_inv_dmix_coeff(s)) == -1)
174+ return AVERROR_INVALIDDATA;
175+ for (r = 1; r <= chset->channels; r++) {
176+ int32_t coeff = dca_get_dmix_coeff(s);
177+ if (coeff == -1)
178+ return AVERROR_INVALIDDATA;
179+ chset->downmix_coeffs[i + r] =
180+ (chset->downmix_coeffs[i] * (int64_t) coeff + (1 << 15)) >> 16;
181+ }
182+ }
183+ }
184+ }
185+ chset->ch_mask_enabled = get_bits(&s->gb, 1);
186+ if (chset->ch_mask_enabled)
187+ chset->ch_mask = get_bits(&s->gb, s->xll_bits4ch_mask);
188+ else
189+ /* Skip speaker configuration bits */
190+ skip_bits_long(&s->gb, 25 * chset->channels);
191+ } else {
192+ chset->primary_ch_set = 1;
193+ chset->downmix_coeff_code_embedded = 0;
194+ /* Spec: NumChHierChSet = 0, NumDwnMixCodeCoeffs = 0, whatever that means. */
195+ chset->mapping_coeffs_present = get_bits(&s->gb, 1);
196+ if (chset->mapping_coeffs_present) {
197+ avpriv_report_missing_feature(s->avctx, "XLL: mapping coefficients");
198+ return AVERROR_PATCHWELCOME;
199+ }
200+ }
201+ if (chset->sampling_frequency > 96000)
202+ chset->num_freq_bands = 2 * (1 + get_bits(&s->gb, 1));
203+ else
204+ chset->num_freq_bands = 1;
205+
206+ if (chset->num_freq_bands > 1) {
207+ avpriv_report_missing_feature(s->avctx, "XLL: num_freq_bands > 1");
208+ return AVERROR_PATCHWELCOME;
209+ }
210+
211+ if (get_bits(&s->gb, 1)) { /* pw_ch_decor_enabled */
212+ int bits = av_ceil_log2(chset->channels);
213+ for (i = 0; i < chset->channels; i++) {
214+ unsigned j = get_bits(&s->gb, bits);
215+ if (j >= chset->channels) {
216+ av_log(s->avctx, AV_LOG_ERROR,
217+ "Original channel order value %u too large, only %d channels.\n",
218+ j, chset->channels);
219+ return AVERROR_INVALIDDATA;
220+ }
221+ chset->orig_chan_order[0][i] = j;
222+ chset->orig_chan_order_inv[0][j] = i;
223+ }
224+ for (i = 0; i < chset->channels / 2; i++) {
225+ if (get_bits(&s->gb, 1)) /* bChPFlag */
226+ chset->pw_ch_pairs_coeffs[0][i] = get_bits_sm(&s->gb, 7);
227+ else
228+ chset->pw_ch_pairs_coeffs[0][i] = 0;
229+ }
230+ } else {
231+ for (i = 0; i < chset->channels; i++)
232+ chset->orig_chan_order[0][i] =
233+ chset->orig_chan_order_inv[0][i] = i;
234+ for (i = 0; i < chset->channels / 2; i++)
235+ chset->pw_ch_pairs_coeffs[0][i] = 0;
236+ }
237+ /* Adaptive prediction order */
238+ chset->adapt_order_max[0] = 0;
239+ for (i = 0; i < chset->channels; i++) {
240+ chset->adapt_order[0][i] = get_bits(&s->gb, 4);
241+ if (chset->adapt_order_max[0] < chset->adapt_order[0][i])
242+ chset->adapt_order_max[0] = chset->adapt_order[0][i];
243+ }
244+ /* Fixed prediction order, used in case the adaptive order
245+ * above is zero */
246+ for (i = 0; i < chset->channels; i++)
247+ chset->fixed_order[0][i] =
248+ chset->adapt_order[0][i] ? 0 : get_bits(&s->gb, 2);
249+
250+ for (i = 0; i < chset->channels; i++) {
251+ unsigned j;
252+ for (j = 0; j < chset->adapt_order[0][i]; j++)
253+ chset->lpc_refl_coeffs_q_ind[0][i][j] = get_bits(&s->gb, 8);
254+ }
255+
256+ if (s->xll_scalable_lsb) {
257+ chset->lsb_fsize[0] = get_bits(&s->gb, s->xll_bits4seg_size);
258+
259+ for (i = 0; i < chset->channels; i++)
260+ chset->scalable_lsbs[0][i] = get_bits(&s->gb, 4);
261+ for (i = 0; i < chset->channels; i++)
262+ chset->bit_width_adj_per_ch[0][i] = get_bits(&s->gb, 4);
263+ } else {
264+ memset(chset->scalable_lsbs[0], 0,
265+ chset->channels * sizeof(chset->scalable_lsbs[0][0]));
266+ memset(chset->bit_width_adj_per_ch[0], 0,
267+ chset->channels * sizeof(chset->bit_width_adj_per_ch[0][0]));
268+ }
269+
270+ s->xll_channels += chset->channels;
271+ s->xll_residual_channels += chset->channels -
272+ av_popcount(chset->residual_encode);
273+
274+ /* FIXME: Parse header data for extra frequency bands. */
275+
276+ /* Skip to end of channel set sub header. */
277+ i = get_bits_count(&s->gb);
278+ if (hdr_pos + 8 * hdr_size < i) {
279+ av_log(s->avctx, AV_LOG_ERROR,
280+ "chset header too large, %d bits, should be <= %d bits\n",
281+ i - hdr_pos, 8 * hdr_size);
282+ return AVERROR_INVALIDDATA;
283+ }
284+ if (hdr_pos + 8 * hdr_size > i)
285+ skip_bits_long(&s->gb, hdr_pos + 8 * hdr_size - i);
286+ }
287+ return 0;
288+}
289+
290+/* parse XLL navigation table */
291+int ff_dca_xll_decode_navi(DCAContext *s, int asset_end)
292+{
293+ int nbands, band, chset, seg, data_start;
294+
295+ /* FIXME: Supports only a single frequency band */
296+ nbands = 1;
297+
298+ for (band = 0; band < nbands; band++) {
299+ s->xll_navi.band_size[band] = 0;
300+ for (seg = 0; seg < s->xll_segments; seg++) {
301+ /* Note: The spec, ETSI TS 102 114 V1.4.1 (2012-09), says
302+ * we should read a base value for segment_size from the
303+ * stream, before reading the sizes of the channel sets.
304+ * But that's apparently incorrect. */
305+ s->xll_navi.segment_size[band][seg] = 0;
306+
307+ for (chset = 0; chset < s->xll_nch_sets; chset++)
308+ if (band < s->xll_chsets[chset].num_freq_bands) {
309+ s->xll_navi.chset_size[band][seg][chset] =
310+ get_bits(&s->gb, s->xll_bits4seg_size) + 1;
311+ s->xll_navi.segment_size[band][seg] +=
312+ s->xll_navi.chset_size[band][seg][chset];
313+ }
314+ s->xll_navi.band_size[band] += s->xll_navi.segment_size[band][seg];
315+ }
316+ }
317+ /* Align to 8 bits and skip 16-bit CRC. */
318+ skip_bits_long(&s->gb, 16 + ((-get_bits_count(&s->gb)) & 7));
319+
320+ data_start = get_bits_count(&s->gb);
321+ if (data_start + 8 * s->xll_navi.band_size[0] > asset_end) {
322+ av_log(s->avctx, AV_LOG_ERROR,
323+ "XLL: Data in NAVI table exceeds containing asset\n"
324+ "start: %d (bit), size %u (bytes), end %d (bit), error %u\n",
325+ data_start, s->xll_navi.band_size[0], asset_end,
326+ data_start + 8 * s->xll_navi.band_size[0] - asset_end);
327+ return AVERROR_INVALIDDATA;
328+ }
329+ init_get_bits(&s->xll_navi.gb, s->gb.buffer + data_start / 8,
330+ 8 * s->xll_navi.band_size[0]);
331+ return 0;
332+}
333+
334+static void dca_xll_inv_adapt_pred(int *samples, int nsamples, unsigned order,
335+ const int *prev, const uint8_t *q_ind)
336+{
337+ static const uint16_t table[0x81] = {
338+ 0, 3070, 5110, 7140, 9156, 11154, 13132, 15085,
339+ 17010, 18904, 20764, 22588, 24373, 26117, 27818, 29474,
340+ 31085, 32648, 34164, 35631, 37049, 38418, 39738, 41008,
341+ 42230, 43404, 44530, 45609, 46642, 47630, 48575, 49477,
342+ 50337, 51157, 51937, 52681, 53387, 54059, 54697, 55302,
343+ 55876, 56421, 56937, 57426, 57888, 58326, 58741, 59132,
344+ 59502, 59852, 60182, 60494, 60789, 61066, 61328, 61576,
345+ 61809, 62029, 62236, 62431, 62615, 62788, 62951, 63105,
346+ 63250, 63386, 63514, 63635, 63749, 63855, 63956, 64051,
347+ 64140, 64224, 64302, 64376, 64446, 64512, 64573, 64631,
348+ 64686, 64737, 64785, 64830, 64873, 64913, 64950, 64986,
349+ 65019, 65050, 65079, 65107, 65133, 65157, 65180, 65202,
350+ 65222, 65241, 65259, 65275, 65291, 65306, 65320, 65333,
351+ 65345, 65357, 65368, 65378, 65387, 65396, 65405, 65413,
352+ 65420, 65427, 65434, 65440, 65446, 65451, 65456, 65461,
353+ 65466, 65470, 65474, 65478, 65481, 65485, 65488, 65491,
354+ 65535, /* Final value is for the -128 corner case, see below. */
355+ };
356+ int c[DCA_XLL_AORDER_MAX];
357+ int64_t s;
358+ unsigned i, j;
359+
360+ for (i = 0; i < order; i++) {
361+ if (q_ind[i] & 1)
362+ /* The index value 0xff corresponds to a lookup of entry 0x80 in
363+ * the table, and no value is provided in the specification. */
364+ c[i] = -table[(q_ind[i] >> 1) + 1];
365+ else
366+ c[i] = table[q_ind[i] >> 1];
367+ }
368+ /* The description in the spec is a bit convoluted. We can convert
369+ * the reflected values to direct values in place, using a
370+ * sequence of reflections operating on two values. */
371+ for (i = 1; i < order; i++) {
372+ /* i = 1: scale c[0]
373+ * i = 2: reflect c[0] <-> c[1]
374+ * i = 3: scale c[1], reflect c[0] <-> c[2]
375+ * i = 4: reflect c[0] <-> c[3] reflect c[1] <-> c[2]
376+ * ... */
377+ if (i & 1)
378+ c[i / 2] += ((int64_t) c[i] * c[i / 2] + 0x8000) >> 16;
379+ for (j = 0; j < i / 2; j++) {
380+ int r0 = c[j];
381+ int r1 = c[i - j - 1];
382+ c[j] += ((int64_t) c[i] * r1 + 0x8000) >> 16;
383+ c[i - j - 1] += ((int64_t) c[i] * r0 + 0x8000) >> 16;
384+ }
385+ }
386+ /* Apply predictor. */
387+ /* NOTE: Processing samples in this order means that the
388+ * predictor is applied to the newly reconstructed samples. */
389+ if (prev) {
390+ for (i = 0; i < order; i++) {
391+ for (j = s = 0; j < i; j++)
392+ s += (int64_t) c[j] * samples[i - 1 - j];
393+ for (; j < order; j++)
394+ s += (int64_t) c[j] * prev[DCA_XLL_AORDER_MAX + i - 1 - j];
395+
396+ samples[i] -= av_clip((s + 0x8000) >> 16, -0x1000000, 0xffffff);
397+ }
398+ }
399+ for (i = order; i < nsamples; i++) {
400+ for (j = s = 0; j < order; j++)
401+ s += (int64_t) c[j] * samples[i - 1 - j];
402+
403+ /* NOTE: Equations seem to imply addition, while the
404+ * pseudocode seems to use subtraction.*/
405+ samples[i] -= av_clip((s + 0x8000) >> 16, -0x1000000, 0xffffff);
406+ }
407+}
408+
409+int ff_dca_xll_decode_audio(DCAContext *s, AVFrame *frame)
410+{
411+ /* FIXME: Decodes only the first frequency band. */
412+ int seg, chset_i;
413+
414+ /* Coding parameters for each channel set. */
415+ struct coding_params {
416+ int seg_type;
417+ int rice_code_flag[16];
418+ int pancAuxABIT[16];
419+ int pancABIT0[16]; /* Not sure what this is */
420+ int pancABIT[16]; /* Not sure what this is */
421+ int nSamplPart0[16];
422+ } param_state[16];
423+
424+ GetBitContext *gb = &s->xll_navi.gb;
425+ int *history;
426+
427+ /* Layout: First the sample buffer for one segment per channel,
428+ * followed by history buffers of DCA_XLL_AORDER_MAX samples for
429+ * each channel. */
430+ av_fast_malloc(&s->xll_sample_buf, &s->xll_sample_buf_size,
431+ (s->xll_smpl_in_seg + DCA_XLL_AORDER_MAX) *
432+ s->xll_channels * sizeof(*s->xll_sample_buf));
433+ if (!s->xll_sample_buf)
434+ return AVERROR(ENOMEM);
435+
436+ history = s->xll_sample_buf + s->xll_smpl_in_seg * s->xll_channels;
437+
438+ for (seg = 0; seg < s->xll_segments; seg++) {
439+ unsigned in_channel;
440+
441+ for (chset_i = in_channel = 0; chset_i < s->xll_nch_sets; chset_i++) {
442+ /* The spec isn't very explicit, but I think the NAVI sizes are in bytes. */
443+ int end_pos = get_bits_count(gb) +
444+ 8 * s->xll_navi.chset_size[0][seg][chset_i];
445+ int i, j;
446+ struct coding_params *params = &param_state[chset_i];
447+ /* I think this flag means that we should keep seg_type and
448+ * other parameters from the previous segment. */
449+ int use_seg_state_code_param;
450+ XllChSetSubHeader *chset = &s->xll_chsets[chset_i];
451+ if (in_channel >= s->avctx->channels)
452+ /* FIXME: Could go directly to next segment */
453+ goto next_chset;
454+
455+ if (s->avctx->sample_rate != chset->sampling_frequency) {
456+ av_log(s->avctx, AV_LOG_WARNING,
457+ "XLL: unexpected chset sample rate %d, expected %d\n",
458+ chset->sampling_frequency, s->avctx->sample_rate);
459+ goto next_chset;
460+ }
461+ if (seg != 0)
462+ use_seg_state_code_param = get_bits(gb, 1);
463+ else
464+ use_seg_state_code_param = 0;
465+
466+ if (!use_seg_state_code_param) {
467+ int num_param_sets, i;
468+ unsigned bits4ABIT;
469+
470+ params->seg_type = get_bits(gb, 1);
471+ num_param_sets = params->seg_type ? 1 : chset->channels;
472+
473+ if (chset->bit_width > 16) {
474+ bits4ABIT = 5;
475+ } else {
476+ if (chset->bit_width > 8)
477+ bits4ABIT = 4;
478+ else
479+ bits4ABIT = 3;
480+ if (s->xll_nch_sets > 1)
481+ bits4ABIT++;
482+ }
483+
484+ for (i = 0; i < num_param_sets; i++) {
485+ params->rice_code_flag[i] = get_bits(gb, 1);
486+ if (!params->seg_type && params->rice_code_flag[i] && get_bits(gb, 1))
487+ params->pancAuxABIT[i] = get_bits(gb, bits4ABIT) + 1;
488+ else
489+ params->pancAuxABIT[i] = 0;
490+ }
491+
492+ for (i = 0; i < num_param_sets; i++) {
493+ if (!seg) {
494+ /* Parameters for part 1 */
495+ params->pancABIT0[i] = get_bits(gb, bits4ABIT);
496+ if (params->rice_code_flag[i] == 0 && params->pancABIT0[i] > 0)
497+ /* For linear code */
498+ params->pancABIT0[i]++;
499+
500+ /* NOTE: In the spec, not indexed by band??? */
501+ if (params->seg_type == 0)
502+ params->nSamplPart0[i] = chset->adapt_order[0][i];
503+ else
504+ params->nSamplPart0[i] = chset->adapt_order_max[0];
505+ } else
506+ params->nSamplPart0[i] = 0;
507+
508+ /* Parameters for part 2 */
509+ params->pancABIT[i] = get_bits(gb, bits4ABIT);
510+ if (params->rice_code_flag[i] == 0 && params->pancABIT[i] > 0)
511+ /* For linear code */
512+ params->pancABIT[i]++;
513+ }
514+ }
515+ for (i = 0; i < chset->channels; i++) {
516+ int param_index = params->seg_type ? 0 : i;
517+ int bits = params->pancABIT0[param_index];
518+ int part0 = params->nSamplPart0[param_index];
519+ int *sample_buf = s->xll_sample_buf +
520+ (in_channel + i) * s->xll_smpl_in_seg;
521+
522+ if (!params->rice_code_flag[param_index]) {
523+ /* Linear code */
524+ if (bits)
525+ for (j = 0; j < part0; j++)
526+ sample_buf[j] = get_bits_sm(gb, bits);
527+ else
528+ memset(sample_buf, 0, part0 * sizeof(sample_buf[0]));
529+
530+ /* Second part */
531+ bits = params->pancABIT[param_index];
532+ if (bits)
533+ for (j = part0; j < s->xll_smpl_in_seg; j++)
534+ sample_buf[j] = get_bits_sm(gb, bits);
535+ else
536+ memset(sample_buf + part0, 0,
537+ (s->xll_smpl_in_seg - part0) * sizeof(sample_buf[0]));
538+ } else {
539+ int aux_bits = params->pancAuxABIT[param_index];
540+
541+ for (j = 0; j < part0; j++) {
542+ /* FIXME: Is this identical to Golomb code? */
543+ int t = get_unary(gb, 1, 33) << bits;
544+ /* FIXME: Could move this test outside of the loop, for efficiency. */
545+ if (bits)
546+ t |= get_bits(gb, bits);
547+ sample_buf[j] = (t & 1) ? -(t >> 1) - 1 : (t >> 1);
548+ }
549+
550+ /* Second part */
551+ bits = params->pancABIT[param_index];
552+
553+ /* Follow the spec's suggestion of using the
554+ * buffer also to store the hybrid-rice flags. */
555+ memset(sample_buf + part0, 0,
556+ (s->xll_smpl_in_seg - part0) * sizeof(sample_buf[0]));
557+
558+ if (aux_bits > 0) {
559+ /* For hybrid rice encoding, some samples are linearly
560+ * coded. According to the spec, "nBits4SamplLoci" bits
561+ * are used for each index, but this value is not
562+ * defined. I guess we should use log2(xll_smpl_in_seg)
563+ * bits. */
564+ int count = get_bits(gb, s->xll_log_smpl_in_seg);
565+ av_log(s->avctx, AV_LOG_DEBUG, "aux count %d (bits %d)\n",
566+ count, s->xll_log_smpl_in_seg);
567+
568+ for (j = 0; j < count; j++)
569+ sample_buf[get_bits(gb, s->xll_log_smpl_in_seg)] = 1;
570+ }
571+ for (j = part0; j < s->xll_smpl_in_seg; j++) {
572+ if (!sample_buf[j]) {
573+ int t = get_unary(gb, 1, 33);
574+ if (bits)
575+ t = (t << bits) | get_bits(gb, bits);
576+ sample_buf[j] = (t & 1) ? -(t >> 1) - 1 : (t >> 1);
577+ } else
578+ sample_buf[j] = get_bits_sm(gb, aux_bits);
579+ }
580+ }
581+ }
582+
583+ for (i = 0; i < chset->channels; i++) {
584+ unsigned adapt_order = chset->adapt_order[0][i];
585+ int *sample_buf = s->xll_sample_buf +
586+ (in_channel + i) * s->xll_smpl_in_seg;
587+ int *prev = history + (in_channel + i) * DCA_XLL_AORDER_MAX;
588+
589+ if (!adapt_order) {
590+ unsigned order;
591+ for (order = chset->fixed_order[0][i]; order > 0; order--) {
592+ unsigned j;
593+ for (j = 1; j < s->xll_smpl_in_seg; j++)
594+ sample_buf[j] += sample_buf[j - 1];
595+ }
596+ } else
597+ /* Inverse adaptive prediction, in place. */
598+ dca_xll_inv_adapt_pred(sample_buf, s->xll_smpl_in_seg,
599+ adapt_order, seg ? prev : NULL,
600+ chset->lpc_refl_coeffs_q_ind[0][i]);
601+ memcpy(prev, sample_buf + s->xll_smpl_in_seg - DCA_XLL_AORDER_MAX,
602+ DCA_XLL_AORDER_MAX * sizeof(*prev));
603+ }
604+ for (i = 1; i < chset->channels; i += 2) {
605+ int coeff = chset->pw_ch_pairs_coeffs[0][i / 2];
606+ if (coeff != 0) {
607+ int *sample_buf = s->xll_sample_buf +
608+ (in_channel + i) * s->xll_smpl_in_seg;
609+ int *prev = sample_buf - s->xll_smpl_in_seg;
610+ unsigned j;
611+ for (j = 0; j < s->xll_smpl_in_seg; j++)
612+ /* Shift is unspecified, but should apparently be 3. */
613+ sample_buf[j] += ((int64_t) coeff * prev[j] + 4) >> 3;
614+ }
615+ }
616+
617+ if (s->xll_scalable_lsb) {
618+ int lsb_start = end_pos - 8 * chset->lsb_fsize[0] -
619+ 8 * (s->xll_banddata_crc & 2);
620+ int done;
621+ i = get_bits_count(gb);
622+ if (i > lsb_start) {
623+ av_log(s->avctx, AV_LOG_ERROR,
624+ "chset data lsb exceeds NAVI size, end_pos %d, lsb_start %d, pos %d\n",
625+ end_pos, lsb_start, i);
626+ return AVERROR_INVALIDDATA;
627+ }
628+ if (i < lsb_start)
629+ skip_bits_long(gb, lsb_start - i);
630+
631+ for (i = done = 0; i < chset->channels; i++) {
632+ int bits = chset->scalable_lsbs[0][i];
633+ if (bits > 0) {
634+ /* The channel reordering is conceptually done
635+ * before adding the lsb:s, so we need to do
636+ * the inverse permutation here. */
637+ unsigned pi = chset->orig_chan_order_inv[0][i];
638+ int *sample_buf = s->xll_sample_buf +
639+ (in_channel + pi) * s->xll_smpl_in_seg;
640+ int adj = chset->bit_width_adj_per_ch[0][i];
641+ int msb_shift = bits;
642+ unsigned j;
643+
644+ if (adj > 0)
645+ msb_shift += adj - 1;
646+
647+ for (j = 0; j < s->xll_smpl_in_seg; j++)
648+ sample_buf[j] = (sample_buf[j] << msb_shift) +
649+ (get_bits(gb, bits) << adj);
650+
651+ done += bits * s->xll_smpl_in_seg;
652+ }
653+ }
654+ if (done > 8 * chset->lsb_fsize[0]) {
655+ av_log(s->avctx, AV_LOG_ERROR,
656+ "chset lsb exceeds lsb_size\n");
657+ return AVERROR_INVALIDDATA;
658+ }
659+ }
660+
661+ /* Store output. */
662+ for (i = 0; i < chset->channels; i++) {
663+ int *sample_buf = s->xll_sample_buf +
664+ (in_channel + i) * s->xll_smpl_in_seg;
665+ int shift = 1 - chset->bit_resolution;
666+ int out_channel = chset->orig_chan_order[0][i];
667+ float *out;
668+
669+ /* XLL uses the channel order C, L, R, and we want L,
670+ * R, C. FIXME: Generalize. */
671+ if (chset->ch_mask_enabled &&
672+ (chset->ch_mask & 7) == 7 && out_channel < 3)
673+ out_channel = out_channel ? out_channel - 1 : 2;
674+
675+ out_channel += in_channel;
676+ if (out_channel >= s->avctx->channels)
677+ continue;
678+
679+ out = (float *) frame->extended_data[out_channel];
680+ out += seg * s->xll_smpl_in_seg;
681+
682+ /* NOTE: A one bit means residual encoding is *not* used. */
683+ if ((chset->residual_encode >> i) & 1) {
684+ /* Replace channel samples.
685+ * FIXME: Most likely not the right thing to do. */
686+ for (j = 0; j < s->xll_smpl_in_seg; j++)
687+ out[j] = ldexpf(sample_buf[j], shift);
688+ } else {
689+ /* Add residual signal to core channel */
690+ for (j = 0; j < s->xll_smpl_in_seg; j++)
691+ out[j] += ldexpf(sample_buf[j], shift);
692+ }
693+ }
694+
695+ if (chset->downmix_coeff_code_embedded &&
696+ !chset->primary_ch_set && chset->hier_chset) {
697+ /* Undo hierarchical downmix of earlier channels. */
698+ unsigned mix_channel;
699+ for (mix_channel = 0; mix_channel < in_channel; mix_channel++) {
700+ float *mix_buf;
701+ const int *col;
702+ float coeff;
703+ unsigned row;
704+ /* Similar channel reorder C, L, R vs L, R, C reorder. */
705+ if (chset->ch_mask_enabled &&
706+ (chset->ch_mask & 7) == 7 && mix_channel < 3)
707+ mix_buf = (float *) frame->extended_data[mix_channel ? mix_channel - 1 : 2];
708+ else
709+ mix_buf = (float *) frame->extended_data[mix_channel];
710+
711+ mix_buf += seg * s->xll_smpl_in_seg;
712+ col = &chset->downmix_coeffs[mix_channel * (chset->channels + 1)];
713+
714+ /* Scale */
715+ coeff = ldexpf(col[0], -16);
716+ for (j = 0; j < s->xll_smpl_in_seg; j++)
717+ mix_buf[j] *= coeff;
718+
719+ for (row = 0;
720+ row < chset->channels && in_channel + row < s->avctx->channels;
721+ row++)
722+ if (col[row + 1]) {
723+ const float *new_channel =
724+ (const float *) frame->extended_data[in_channel + row];
725+ new_channel += seg * s->xll_smpl_in_seg;
726+ coeff = ldexpf(col[row + 1], -15);
727+ for (j = 0; j < s->xll_smpl_in_seg; j++)
728+ mix_buf[j] -= coeff * new_channel[j];
729+ }
730+ }
731+ }
732+
733+next_chset:
734+ in_channel += chset->channels;
735+ /* Skip to next channel set using the NAVI info. */
736+ i = get_bits_count(gb);
737+ if (i > end_pos) {
738+ av_log(s->avctx, AV_LOG_ERROR,
739+ "chset data exceeds NAVI size\n");
740+ return AVERROR_INVALIDDATA;
741+ }
742+ if (i < end_pos)
743+ skip_bits_long(gb, end_pos - i);
744+ }
745+ }
746+ return 0;
747+}
libavcodec/dcadata.c+629−1
@@ -7522,6 +7522,600 @@ DECLARE_ALIGNED(16, const float, ff_dca_lfe_fir_128)[256] = { · 7521 unmodified lines
75227522 };
75237523 #undef SCALE
75247524
7525+
7526+#define SCALE(c) ((float)(c) / (256.0f * 32768.0f * 8388608.0f))
7527+DECLARE_ALIGNED(16, const float, ff_dca_lfe_xll_fir_64)[256] = {
7528+ SCALE( 6103), SCALE( 52170), SCALE(-558064), SCALE(1592440),
7529+ SCALE(6290049), SCALE(1502534), SCALE(-546669), SCALE( 53047),
7530+ SCALE( 1930), SCALE( 51089), SCALE(-568920), SCALE(1683709),
7531+ SCALE(6286575), SCALE(1414057), SCALE(-534782), SCALE( 53729),
7532+ SCALE( 2228), SCALE( 49794), SCALE(-579194), SCALE(1776276),
7533+ SCALE(6279634), SCALE(1327070), SCALE(-522445), SCALE( 54228),
7534+ SCALE( 2552), SCALE( 48275), SCALE(-588839), SCALE(1870070),
7535+ SCALE(6269231), SCALE(1241632), SCALE(-509702), SCALE( 54550),
7536+ SCALE( 2904), SCALE( 46523), SCALE(-597808), SCALE(1965017),
7537+ SCALE(6255380), SCALE(1157798), SCALE(-496595), SCALE( 54708),
7538+ SCALE( 3287), SCALE( 44529), SCALE(-606054), SCALE(2061044),
7539+ SCALE(6238099), SCALE(1075621), SCALE(-483164), SCALE( 54710),
7540+ SCALE( 3704), SCALE( 42282), SCALE(-613529), SCALE(2158071),
7541+ SCALE(6217408), SCALE( 995149), SCALE(-469451), SCALE( 54566),
7542+ SCALE( 4152), SCALE( 39774), SCALE(-620186), SCALE(2256019),
7543+ SCALE(6193332), SCALE( 916430), SCALE(-455494), SCALE( 54285),
7544+ SCALE( 4631), SCALE( 36995), SCALE(-625976), SCALE(2354805),
7545+ SCALE(6165900), SCALE( 839507), SCALE(-441330), SCALE( 53876),
7546+ SCALE( 5139), SCALE( 33937), SCALE(-630850), SCALE(2454343),
7547+ SCALE(6135146), SCALE( 764419), SCALE(-426998), SCALE( 53348),
7548+ SCALE( 5682), SCALE( 30591), SCALE(-634759), SCALE(2554547),
7549+ SCALE(6101107), SCALE( 691203), SCALE(-412531), SCALE( 52711),
7550+ SCALE( 6264), SCALE( 26948), SCALE(-637655), SCALE(2655326),
7551+ SCALE(6063824), SCALE( 619894), SCALE(-397966), SCALE( 51972),
7552+ SCALE( 6886), SCALE( 23001), SCALE(-639488), SCALE(2756591),
7553+ SCALE(6023343), SCALE( 550521), SCALE(-383335), SCALE( 51140),
7554+ SCALE( 7531), SCALE( 18741), SCALE(-640210), SCALE(2858248),
7555+ SCALE(5979711), SCALE( 483113), SCALE(-368671), SCALE( 50224),
7556+ SCALE( 8230), SCALE( 14162), SCALE(-639772), SCALE(2960201),
7557+ SCALE(5932981), SCALE( 417692), SCALE(-354003), SCALE( 49231),
7558+ SCALE( 8959), SCALE( 9257), SCALE(-638125), SCALE(3062355),
7559+ SCALE(5883210), SCALE( 354281), SCALE(-339362), SCALE( 48168),
7560+ SCALE( 9727), SCALE( 4018), SCALE(-635222), SCALE(3164612),
7561+ SCALE(5830457), SCALE( 292897), SCALE(-324777), SCALE( 47044),
7562+ SCALE( 10535), SCALE( -1558), SCALE(-631014), SCALE(3266872),
7563+ SCALE(5774785), SCALE( 233555), SCALE(-310273), SCALE( 45866),
7564+ SCALE( 11381), SCALE( -7480), SCALE(-625455), SCALE(3369035),
7565+ SCALE(5716260), SCALE( 176267), SCALE(-295877), SCALE( 44640),
7566+ SCALE( 12267), SCALE( -13750), SCALE(-618499), SCALE(3471000),
7567+ SCALE(5654952), SCALE( 121042), SCALE(-281613), SCALE( 43373),
7568+ SCALE( 13190), SCALE( -20372), SCALE(-610098), SCALE(3572664),
7569+ SCALE(5590933), SCALE( 67886), SCALE(-267505), SCALE( 42072),
7570+ SCALE( 14152), SCALE( -27352), SCALE(-600209), SCALE(3673924),
7571+ SCALE(5524280), SCALE( 16800), SCALE(-253574), SCALE( 40743),
7572+ SCALE( 15153), SCALE( -34691), SCALE(-588788), SCALE(3774676),
7573+ SCALE(5455069), SCALE( -32214), SCALE(-239840), SCALE( 39391),
7574+ SCALE( 16192), SCALE( -42390), SCALE(-575791), SCALE(3874816),
7575+ SCALE(5383383), SCALE( -79159), SCALE(-226323), SCALE( 38022),
7576+ SCALE( 17267), SCALE( -50453), SCALE(-561178), SCALE(3974239),
7577+ SCALE(5309305), SCALE(-124041), SCALE(-213041), SCALE( 36642),
7578+ SCALE( 18377), SCALE( -58879), SCALE(-544906), SCALE(4072841),
7579+ SCALE(5232922), SCALE(-166869), SCALE(-200010), SCALE( 35256),
7580+ SCALE( 19525), SCALE( -67667), SCALE(-526937), SCALE(4170517),
7581+ SCALE(5154321), SCALE(-207653), SCALE(-187246), SCALE( 33866),
7582+ SCALE( 20704), SCALE( -76817), SCALE(-507233), SCALE(4267162),
7583+ SCALE(5073593), SCALE(-246406), SCALE(-174764), SCALE( 32480),
7584+ SCALE( 21915), SCALE( -86327), SCALE(-485757), SCALE(4362672),
7585+ SCALE(4990831), SCALE(-283146), SCALE(-162575), SCALE( 31101),
7586+ SCALE( 23157), SCALE( -96193), SCALE(-462476), SCALE(4456942),
7587+ SCALE(4906129), SCALE(-317890), SCALE(-150692), SCALE( 29732),
7588+ SCALE( 24426), SCALE(-106412), SCALE(-437356), SCALE(4549871),
7589+ SCALE(4819584), SCALE(-350658), SCALE(-139125), SCALE( 28376),
7590+ SCALE( 25721), SCALE(-116977), SCALE(-410365), SCALE(4641355),
7591+ SCALE(4731293), SCALE(-381475), SCALE(-127884), SCALE( 27038),
7592+};
7593+#undef SCALE
7594+
7595+DECLARE_ALIGNED(16, const float, ff_dca_fir_64bands)[1024] = {
7596+ /* Bank 0 */
7597+ -7.1279389866041690e-8, -7.0950903150874990e-8,
7598+ -7.9525034321375090e-8, -8.9326871281374790e-8,
7599+ -9.7483190494874640e-8, -1.0586659510721950e-7,
7600+ -1.1527363411865760e-7, -1.2523109645615350e-7,
7601+ -1.3555636137971380e-7, -1.4640931821191640e-7,
7602+ -1.5787424998123710e-7, -1.6994592926571220e-7,
7603+ -1.8264184311018150e-7, -1.9600594587757850e-7,
7604+ -2.1007899706006800e-7, -2.2489759047553620e-7,
7605+ -2.4050245877923400e-7, -2.5693874615777660e-7,
7606+ -2.7425370308549580e-7, -2.9249662541757600e-7,
7607+ -3.1171981968268900e-7, -3.3197864040473180e-7,
7608+ -3.5333134588843600e-7, -3.7583910465412180e-7,
7609+ -3.9956628121669190e-7, -4.2458045296159330e-7,
7610+ -4.5095249563698380e-7, -4.7875659112606760e-7,
7611+ -5.0807031294631050e-7, -5.3897464223335550e-7,
7612+ -5.7155423388793000e-7, -6.0589741192019800e-7,
7613+ -6.4209580087853050e-7, -6.8024432849991400e-7,
7614+ -7.2044165259013450e-7, -7.6279018172077200e-7,
7615+ -8.0739610368280600e-7, -8.5436937020293650e-7,
7616+ -9.0382333224895500e-7, -9.5587472540498280e-7,
7617+ -1.0106437128213760e-6, -1.0682538906146330e-6,
7618+ -1.1288323637155430e-6, -1.1925097184646100e-6,
7619+ -1.2594193438633260e-6, -1.3296974052300520e-6,
7620+ -1.4034829433780260e-6, -1.4809178634979940e-6,
7621+ -1.5621465913980060e-6, -1.6473160377545360e-6,
7622+ -1.7365751553971340e-6, -1.8300749104526120e-6,
7623+ -1.9279680902322050e-6, -2.0304092660990760e-6,
7624+ -2.1375541686662320e-6, -2.2495596253776460e-6,
7625+ -2.3665828120950560e-6, -2.4887811970856540e-6,
7626+ -2.6163120571644820e-6, -2.7493324266391140e-6,
7627+ -2.8879984579501380e-6, -3.0324653639203880e-6,
7628+ -3.1828867865974640e-6, -3.3394147240855820e-6,
7629+ -3.5021985520037540e-6, -3.6713849262294680e-6,
7630+ -3.8471166218015830e-6, -4.0295324657699800e-6,
7631+ -4.2187670209852250e-6, -4.4149505043312320e-6,
7632+ -4.6182073040543900e-6, -4.8286558658894680e-6,
7633+ -5.0464076705003400e-6, -5.2715671455405850e-6,
7634+ -5.5042307535458100e-6, -5.7444868785028750e-6,
7635+ -5.9924142424804800e-6, -6.2480817863072800e-6,
7636+ -6.5115476278604000e-6, -6.7828589565804950e-6,
7637+ -7.0620507545154100e-6, -7.3491456697144900e-6,
7638+ -7.6441525098592000e-6, -7.9470661364365490e-6,
7639+ -8.2578666429227760e-6, -8.5765192154768100e-6,
7640+ -8.9029718900122000e-6, -9.2371554195468400e-6,
7641+ -9.5789825988253100e-6, -9.9283481667264540e-6,
7642+ -1.0285127334608450e-5, -1.0649175634328590e-5,
7643+ -1.1020327046334650e-5, -1.1398393880881060e-5,
7644+ -1.1783166036693560e-5, -1.2174410889256530e-5,
7645+ -1.2571871574469220e-5, -1.2975266858030310e-5,
7646+ -1.3384289978242060e-5, -1.3798608540965960e-5,
7647+ -1.4217863365843780e-5, -1.4641668383496450e-5,
7648+ -1.5069609527679710e-5, -1.5501244597782600e-5,
7649+ -1.5936101341640500e-5, -1.6373677426466900e-5,
7650+ -1.6813441716539560e-5, -1.7254834143068570e-5,
7651+ -1.7697261563607500e-5, -1.8140097714618200e-5,
7652+ -1.8582686308483550e-5, -1.9024340970099240e-5,
7653+ -1.9464340744880170e-5, -1.9901930030141080e-5,
7654+ -2.0336321557464510e-5, -2.0766696417773940e-5,
7655+ -2.1192201630574280e-5, -2.1611950084231910e-5,
7656+ -2.2025021652894630e-5, -2.2430463239517170e-5,
7657+ -2.2827288605503470e-5, -2.3214478371918170e-5,
7658+ -2.3590980216497750e-5, -2.3955708939763280e-5,
7659+ -2.4307547722489910e-5, -2.4645348200903720e-5,
7660+ -2.4967930863542620e-5, -2.5274085082324960e-5,
7661+ /* Bank 1 */
7662+ 2.5562569399199020e-5, 2.5832111724562040e-5,
7663+ 2.6081413415833200e-5, 2.6309149390520640e-5,
7664+ 2.6513966535124460e-5, 2.6694483850464800e-5,
7665+ 2.6849297239997120e-5, 2.6976979753245170e-5,
7666+ 2.7076082153012070e-5, 2.7145133103663890e-5,
7667+ 2.7182642746157720e-5, 2.7187102980536760e-5,
7668+ 2.7156990105794550e-5, 2.7090765064735940e-5,
7669+ 2.6986876191054700e-5, 2.6843759539035120e-5,
7670+ 2.6659843389908530e-5, 2.6433548592482960e-5,
7671+ 2.6163291550639320e-5, 2.5847484577439320e-5,
7672+ 2.5484540698002960e-5, 2.5072874052447260e-5,
7673+ 2.4610903957661350e-5, 2.4097055300584120e-5,
7674+ 2.3529763128539150e-5, 2.2907473117403740e-5,
7675+ 2.2228647280994560e-5, 2.1491764461832140e-5,
7676+ 2.0695325418576370e-5, 1.9837853265502040e-5,
7677+ /* NOTE: The spec has a duplicated row "160 | 1.7934037335534700e-5" ! */
7678+ 1.8917898053528080e-5, 1.7934037335534700e-5,
7679+ 1.6884884022311310e-5, 1.5769086921577900e-5,
7680+ 1.4585334740507920e-5, 1.3332356590263080e-5,
7681+ 1.2008929083235120e-5, 1.0613876973541650e-5,
7682+ 9.1460801506922300e-6, 7.6044740757265500e-6,
7683+ 5.9880523825897000e-6, 4.2958677847708840e-6,
7684+ 2.5270494199802070e-6, 6.8080315386959900e-7,
7685+ -1.2435990827839660e-6, -3.2468187066945930e-6,
7686+ -5.3294268968052800e-6, -7.4919036559427900e-6,
7687+ -9.7346407524871100e-6, -1.2057941408635810e-5,
7688+ -1.4462010500550970e-5, -1.6946953848107710e-5,
7689+ -1.9512772389215240e-5, -2.2159361597292710e-5,
7690+ -2.4886504491416160e-5, -2.7693871041862060e-5,
7691+ -3.0581012081916960e-5, -3.3547358765259040e-5,
7692+ -3.6592216716540970e-5, -3.9714765485539260e-5,
7693+ -4.2914052387856640e-5, -4.6188991961724560e-5,
7694+ -4.9538360176954340e-5, -5.2960794000140600e-5,
7695+ -5.6454787620185350e-5, -6.0018691972791050e-5,
7696+ -6.3650708053788550e-5, -6.7348886525882700e-5,
7697+ -7.1111125753722860e-5, -7.4935171411178040e-5,
7698+ -7.8818609806320000e-5, -8.2758867628623800e-5,
7699+ -8.6753213062403400e-5, -9.0798755482139240e-5,
7700+ -9.4892437636254000e-5, -9.9031035415475500e-5,
7701+ -1.0321116057304920e-4, -1.0742926070674010e-4,
7702+ -1.1168161614264270e-4, -1.1596433966772030e-4,
7703+ -1.2027337376184880e-4, -1.2460449089034750e-4,
7704+ -1.2895330270761850e-4, -1.3331525983885840e-4,
7705+ -1.3768563787408340e-4, -1.4205953760578120e-4,
7706+ -1.4643190426323540e-4, -1.5079752791692290e-4,
7707+ -1.5515103314094370e-4, -1.5948687909058970e-4,
7708+ -1.6379937154642740e-4, -1.6808266356446820e-4,
7709+ -1.7233075773584680e-4, -1.7653750646560020e-4,
7710+ -1.8069661584612290e-4, -1.8480164638953740e-4,
7711+ -1.8884602526638050e-4, -1.9282304696531290e-4,
7712+ -1.9672587556804270e-4, -2.0054754547108610e-4,
7713+ -2.0428097498957360e-4, -2.0791896735659270e-4,
7714+ -2.1145421910491280e-4, -2.1487932080488700e-4,
7715+ -2.1818676491655660e-4, -2.2136894706917190e-4,
7716+ -2.2441818635854840e-4, -2.2732672676686290e-4,
7717+ -2.3008674810081220e-4, -2.3269036653525150e-4,
7718+ -2.3512963563507800e-4, -2.3739654799291240e-4,
7719+ -2.3948307023621970e-4, -2.4138114593372380e-4,
7720+ -2.4308272452941820e-4, -2.4457975717687980e-4,
7721+ -2.4586407616017000e-4, -2.4692741569938220e-4,
7722+ -2.4776199025177680e-4, -2.4836046092637280e-4,
7723+ -2.4871461830381660e-4, -2.4881540457247040e-4,
7724+ -2.4865471770248810e-4, -2.4822543333608940e-4,
7725+ -2.4752008219951220e-4, -2.4653081794176570e-4,
7726+ -2.4525003217524440e-4, -2.4367037437341020e-4,
7727+ /* Bank 2 */
7728+ 2.4178457457919800e-4, 2.3958543985834340e-4,
7729+ 2.3706595356421380e-4, 2.3421928008696620e-4,
7730+ 2.3103877007019660e-4, 2.2751796132972940e-4,
7731+ 2.2365059385031200e-4, 2.1943061159567880e-4,
7732+ 2.1485218733324290e-4, 2.0990972538755550e-4,
7733+ 2.0459789739171640e-4, 1.9891164424316180e-4,
7734+ 1.9284618337957900e-4, 1.8639701070854740e-4,
7735+ 1.7955993578371750e-4, 1.7233108395155490e-4,
7736+ 1.6470690840351980e-4, 1.5668419239382670e-4,
7737+ 1.4826008597798460e-4, 1.3943210818407590e-4,
7738+ 1.3019815804235450e-4, 1.2055651618705740e-4,
7739+ 1.1050586906665980e-4, 1.0004531116378850e-4,
7740+ 8.9174369623037550e-5, 7.7893006105444910e-5,
7741+ 6.6201632959158800e-5, 5.4101115008963200e-5,
7742+ 4.1592792755171040e-5, 2.8678484003389880e-5,
7743+ 1.5360496520469550e-5, 1.6416297019304470e-6,
7744+ -1.2474801400564880e-5, -2.6984964757674160e-5,
7745+ -4.1884506316022560e-5, -5.7168548169515050e-5,
7746+ -7.2831653374563650e-5, -8.8867825335203200e-5,
7747+ -1.0527052946041040e-4, -1.2203269185287530e-4,
7748+ -1.3914664880465400e-4, -1.5660414556657680e-4,
7749+ -1.7439635977956720e-4, -1.9251390142613000e-4,
7750+ -2.1094678833176480e-4, -2.2968444457655940e-4,
7751+ -2.4871569004884240e-4, -2.6802874127778880e-4,
7752+ -2.8761124019708440e-4, -3.0745025297166030e-4,
7753+ -3.2753221542219500e-4, -3.4784293347385130e-4,
7754+ -3.6836764760397900e-4, -3.8909103335715320e-4,
7755+ -4.0999714822829530e-4, -4.3106943097409840e-4,
7756+ -4.5229073958127750e-4, -4.7364335350426610e-4,
7757+ -4.9510898492628230e-4, -5.1666877822680600e-4,
7758+ -5.3830328700499900e-4, -5.5999247625413450e-4,
7759+ -5.8171579317559550e-4, -6.0345216810040500e-4,
7760+ -6.2517996394886800e-4, -6.4687697763330650e-4,
7761+ -6.6852052145861900e-4, -6.9008742526480550e-4,
7762+ -7.1155400216196750e-4, -7.3289605035434600e-4,
7763+ -7.5408892753413600e-4, -7.7510755325530950e-4,
7764+ -7.9592638676398950e-4, -8.1651942936660300e-4,
7765+ -8.3686029869896850e-4, -8.5692223230171550e-4,
7766+ -8.7667809201044900e-4, -8.9610036547340950e-4,
7767+ -9.1516119514986000e-4, -9.3383238324995840e-4,
7768+ -9.5208547141354700e-4, -9.6989174214394400e-4,
7769+ -9.8722217067251400e-4, -1.0040474297445790e-3,
7770+ -1.0203380430448350e-3, -1.0360643900964910e-3,
7771+ -1.0511966606168980e-3, -1.0657048556038330e-3,
7772+ -1.0795588568782010e-3, -1.0927284332850520e-3,
7773+ -1.1051833075734240e-3, -1.1168931605293980e-3,
7774+ -1.1278276550234160e-3, -1.1379564405661050e-3,
7775+ -1.1472492294891640e-3, -1.1556758000499310e-3,
7776+ -1.1632059885511800e-3, -1.1698096960154200e-3,
7777+ -1.1754570428998680e-3, -1.1801183720212010e-3,
7778+ -1.1837641581852870e-3, -1.1863650153060240e-3,
7779+ -1.1878919433902330e-3, -1.1883163316843900e-3,
7780+ -1.1876097809178440e-3, -1.1857441072376680e-3,
7781+ -1.1826916065321440e-3, -1.1784250628415020e-3,
7782+ -1.1729176690707690e-3, -1.1661430294353880e-3,
7783+ -1.1580752925519680e-3, -1.1486891568700730e-3,
7784+ -1.1379598570807350e-3, -1.1258631690530700e-3,
7785+ -1.1123755320313420e-3, -1.0974740543942100e-3,
7786+ -1.0811365181610850e-3, -1.0633413819325920e-3,
7787+ -1.0440678410743190e-3, -1.0232958338441730e-3,
7788+ -1.0010061160103870e-3, -9.7718026613602800e-4,
7789+ -9.5180072722007060e-4, -9.2485080945546600e-4,
7790+ -8.9631470926558100e-4, -8.6617751390929650e-4,
7791+ -8.3442528375666700e-4, -8.0104505655578600e-4,
7792+ /* Bank 3 */
7793+ 7.6602485902806300e-4, 7.2935371157849700e-4,
7794+ 6.9102172032639350e-4, 6.5102007948960100e-4,
7795+ 6.0934103180698750e-4, 5.6597787244591100e-4,
7796+ 5.2092507454409450e-4, 4.7417829303612970e-4,
7797+ 4.2573432329476060e-4, 3.7559110239316400e-4,
7798+ 3.2374777823389440e-4, 2.7020471361387040e-4,
7799+ 2.1496350652513040e-4, 1.5802699163104190e-4,
7800+ 9.9399252442146460e-5, 3.9085623279149610e-5,
7801+ -2.2907279717153710e-5, -8.6571556658577800e-5,
7802+ -1.5189801251884410e-4, -2.1887615668780720e-4,
7803+ -2.8749420455512610e-4, -3.5773907519488100e-4,
7804+ -4.2959633884346400e-4, -5.0305021853266900e-4,
7805+ -5.7808367853976800e-4, -6.5467842279709950e-4,
7806+ -7.3281477145293300e-4, -8.1247166091487090e-4,
7807+ -8.9362676824381250e-4, -9.7625651350435400e-4,
7808+ -1.0603359870796300e-3, -1.1458389497708370e-3,
7809+ -1.2327379076720450e-3, -1.3210041125919850e-3,
7810+ -1.4106074964587530e-3, -1.5015166759080980e-3,
7811+ -1.5936991188210680e-3, -1.6871211446584360e-3,
7812+ -1.7817477652804130e-3, -1.8775426862784720e-3,
7813+ -1.9744684954557180e-3, -2.0724866717198650e-3,
7814+ -2.1715575922482770e-3, -2.2716405301701940e-3,
7815+ -2.3726935964105480e-3, -2.4746737418493600e-3,
7816+ -2.5775368629845300e-3, -2.6812378156433060e-3,
7817+ -2.7857306109716460e-3, -2.8909684129992950e-3,
7818+ -2.9969032890820140e-3, -3.1034862132032660e-3,
7819+ -3.2106673881690480e-3, -3.3183962566563890e-3,
7820+ -3.4266214220855450e-3, -3.5352906520539890e-3,
7821+ -3.6443510330122110e-3, -3.7537489709635930e-3,
7822+ -3.8634300521859240e-3, -3.9733390588103910e-3,
7823+ -4.0834204508378470e-3, -4.1936183686073460e-3,
7824+ -4.3038762050876900e-3, -4.4141366059086620e-3,
7825+ -4.5243418977567100e-3, -4.6344341075783170e-3,
7826+ -4.7443549566589130e-3, -4.8540458565358850e-3,
7827+ -4.9634478250060780e-3, -5.0725014978718950e-3,
7828+ -5.1811474713480250e-3, -5.2893263173827950e-3,
7829+ -5.3969785783205650e-3, -5.5040447592375600e-3,
7830+ -5.6104651646665850e-3, -5.7161799140263450e-3,
7831+ -5.8211294443412250e-3, -5.9252545216101900e-3,
7832+ -6.0284959882028950e-3, -6.1307947602360250e-3,
7833+ -6.2320920224565700e-3, -6.3323292492425800e-3,
7834+ -6.4314484717364400e-3, -6.5293922762311450e-3,
7835+ -6.6261035015351700e-3, -6.7215252466922100e-3,
7836+ -6.8156013434509950e-3, -6.9082763630156450e-3,
7837+ -6.9994952920827200e-3, -7.0892035490577050e-3,
7838+ -7.1773476647806300e-3, -7.2638752839566550e-3,
7839+ -7.3487345159041400e-3, -7.4318739341000500e-3,
7840+ -7.5132432154309250e-3, -7.5927931627681400e-3,
7841+ -7.6704755623721500e-3, -7.7462431738117650e-3,
7842+ -7.8200496507836000e-3, -7.8918495587816850e-3,
7843+ -7.9615988430090790e-3, -8.0292548409052500e-3,
7844+ -8.0947760898363200e-3, -8.1581223027535600e-3,
7845+ -8.2192540249893810e-3, -8.2781326752680240e-3,
7846+ -8.3347217911436610e-3, -8.3889870206274740e-3,
7847+ -8.4408946925453690e-3, -8.4904118087845760e-3,
7848+ -8.5375073033623590e-3, -8.5821520672029750e-3,
7849+ -8.6243182341614300e-3, -8.6639791627160300e-3,
7850+ -8.7011097471794110e-3, -8.7356864659172800e-3,
7851+ -8.7676881309490440e-3, -8.7970958152554810e-3,
7852+ -8.8238905039462850e-3, -8.8480531477483150e-3,
7853+ -8.8695681885783190e-3, -8.8884235927356400e-3,
7854+ -8.9046080555685600e-3, -8.9181109318560050e-3,
7855+ -8.9289234995380550e-3, -8.9370390010903460e-3,
7856+ -8.9424522900292110e-3, -8.9451598223763610e-3,
7857+ /* Bank 4 */
7858+ 8.9451598223763610e-3, 8.9424522900292110e-3,
7859+ 8.9370390010903460e-3, 8.9289234995380550e-3,
7860+ 8.9181109318560050e-3, 8.9046080555685600e-3,
7861+ 8.8884235927356400e-3, 8.8695681885783190e-3,
7862+ 8.8480531477483150e-3, 8.8238905039462850e-3,
7863+ 8.7970958152554810e-3, 8.7676881309490440e-3,
7864+ 8.7356864659172800e-3, 8.7011097471794110e-3,
7865+ 8.6639791627160300e-3, 8.6243182341614300e-3,
7866+ 8.5821520672029750e-3, 8.5375073033623590e-3,
7867+ 8.4904118087845760e-3, 8.4408946925453690e-3,
7868+ 8.3889870206274740e-3, 8.3347217911436610e-3,
7869+ 8.2781326752680240e-3, 8.2192540249893810e-3,
7870+ 8.1581223027535600e-3, 8.0947760898363200e-3,
7871+ 8.0292548409052500e-3, 7.9615988430090790e-3,
7872+ 7.8918495587816850e-3, 7.8200496507836000e-3,
7873+ 7.7462431738117650e-3, 7.6704755623721500e-3,
7874+ 7.5927931627681400e-3, 7.5132432154309250e-3,
7875+ 7.4318739341000500e-3, 7.3487345159041400e-3,
7876+ 7.2638752839566550e-3, 7.1773476647806300e-3,
7877+ 7.0892035490577050e-3, 6.9994952920827200e-3,
7878+ 6.9082763630156450e-3, 6.8156013434509950e-3,
7879+ 6.7215252466922100e-3, 6.6261035015351700e-3,
7880+ 6.5293922762311450e-3, 6.4314484717364400e-3,
7881+ 6.3323292492425800e-3, 6.2320920224565700e-3,
7882+ 6.1307947602360250e-3, 6.0284959882028950e-3,
7883+ 5.9252545216101900e-3, 5.8211294443412250e-3,
7884+ 5.7161799140263450e-3, 5.6104651646665850e-3,
7885+ 5.5040447592375600e-3, 5.3969785783205650e-3,
7886+ 5.2893263173827950e-3, 5.1811474713480250e-3,
7887+ 5.0725014978718950e-3, 4.9634478250060780e-3,
7888+ 4.8540458565358850e-3, 4.7443549566589130e-3,
7889+ 4.6344341075783170e-3, 4.5243418977567100e-3,
7890+ 4.4141366059086620e-3, 4.3038762050876900e-3,
7891+ 4.1936183686073460e-3, 4.0834204508378470e-3,
7892+ 3.9733390588103910e-3, 3.8634300521859240e-3,
7893+ 3.7537489709635930e-3, 3.6443510330122110e-3,
7894+ 3.5352906520539890e-3, 3.4266214220855450e-3,
7895+ 3.3183962566563890e-3, 3.2106673881690480e-3,
7896+ 3.1034862132032660e-3, 2.9969032890820140e-3,
7897+ 2.8909684129992950e-3, 2.7857306109716460e-3,
7898+ 2.6812378156433060e-3, 2.5775368629845300e-3,
7899+ 2.4746737418493600e-3, 2.3726935964105480e-3,
7900+ 2.2716405301701940e-3, 2.1715575922482770e-3,
7901+ 2.0724866717198650e-3, 1.9744684954557180e-3,
7902+ 1.8775426862784720e-3, 1.7817477652804130e-3,
7903+ 1.6871211446584360e-3, 1.5936991188210680e-3,
7904+ 1.5015166759080980e-3, 1.4106074964587530e-3,
7905+ 1.3210041125919850e-3, 1.2327379076720450e-3,
7906+ 1.1458389497708370e-3, 1.0603359870796300e-3,
7907+ 9.7625651350435400e-4, 8.9362676824381250e-4,
7908+ 8.1247166091487090e-4, 7.3281477145293300e-4,
7909+ 6.5467842279709950e-4, 5.7808367853976800e-4,
7910+ 5.0305021853266900e-4, 4.2959633884346400e-4,
7911+ 3.5773907519488100e-4, 2.8749420455512610e-4,
7912+ 2.1887615668780720e-4, 1.5189801251884410e-4,
7913+ 8.6571556658577800e-5, 2.2907279717153710e-5,
7914+ -3.9085623279149610e-5, -9.9399252442146460e-5,
7915+ -1.5802699163104190e-4, -2.1496350652513040e-4,
7916+ -2.7020471361387040e-4, -3.2374777823389440e-4,
7917+ -3.7559110239316400e-4, -4.2573432329476060e-4,
7918+ -4.7417829303612970e-4, -5.2092507454409450e-4,
7919+ -5.6597787244591100e-4, -6.0934103180698750e-4,
7920+ -6.5102007948960100e-4, -6.9102172032639350e-4,
7921+ -7.2935371157849700e-4, -7.6602485902806300e-4,
7922+ /* Bank 5 */
7923+ 8.0104505655578600e-4, 8.3442528375666700e-4,
7924+ 8.6617751390929650e-4, 8.9631470926558100e-4,
7925+ 9.2485080945546600e-4, 9.5180072722007060e-4,
7926+ 9.7718026613602800e-4, 1.0010061160103870e-3,
7927+ 1.0232958338441730e-3, 1.0440678410743190e-3,
7928+ 1.0633413819325920e-3, 1.0811365181610850e-3,
7929+ 1.0974740543942100e-3, 1.1123755320313420e-3,
7930+ 1.1258631690530700e-3, 1.1379598570807350e-3,
7931+ 1.1486891568700730e-3, 1.1580752925519680e-3,
7932+ 1.1661430294353880e-3, 1.1729176690707690e-3,
7933+ 1.1784250628415020e-3, 1.1826916065321440e-3,
7934+ 1.1857441072376680e-3, 1.1876097809178440e-3,
7935+ 1.1883163316843900e-3, 1.1878919433902330e-3,
7936+ 1.1863650153060240e-3, 1.1837641581852870e-3,
7937+ 1.1801183720212010e-3, 1.1754570428998680e-3,
7938+ 1.1698096960154200e-3, 1.1632059885511800e-3,
7939+ 1.1556758000499310e-3, 1.1472492294891640e-3,
7940+ 1.1379564405661050e-3, 1.1278276550234160e-3,
7941+ 1.1168931605293980e-3, 1.1051833075734240e-3,
7942+ 1.0927284332850520e-3, 1.0795588568782010e-3,
7943+ 1.0657048556038330e-3, 1.0511966606168980e-3,
7944+ 1.0360643900964910e-3, 1.0203380430448350e-3,
7945+ 1.0040474297445790e-3, 9.8722217067251400e-4,
7946+ 9.6989174214394400e-4, 9.5208547141354700e-4,
7947+ 9.3383238324995840e-4, 9.1516119514986000e-4,
7948+ 8.9610036547340950e-4, 8.7667809201044900e-4,
7949+ 8.5692223230171550e-4, 8.3686029869896850e-4,
7950+ 8.1651942936660300e-4, 7.9592638676398950e-4,
7951+ 7.7510755325530950e-4, 7.5408892753413600e-4,
7952+ 7.3289605035434600e-4, 7.1155400216196750e-4,
7953+ 6.9008742526480550e-4, 6.6852052145861900e-4,
7954+ 6.4687697763330650e-4, 6.2517996394886800e-4,
7955+ 6.0345216810040500e-4, 5.8171579317559550e-4,
7956+ 5.5999247625413450e-4, 5.3830328700499900e-4,
7957+ 5.1666877822680600e-4, 4.9510898492628230e-4,
7958+ 4.7364335350426610e-4, 4.5229073958127750e-4,
7959+ 4.3106943097409840e-4, 4.0999714822829530e-4,
7960+ 3.8909103335715320e-4, 3.6836764760397900e-4,
7961+ 3.4784293347385130e-4, 3.2753221542219500e-4,
7962+ 3.0745025297166030e-4, 2.8761124019708440e-4,
7963+ 2.6802874127778880e-4, 2.4871569004884240e-4,
7964+ 2.2968444457655940e-4, 2.1094678833176480e-4,
7965+ 1.9251390142613000e-4, 1.7439635977956720e-4,
7966+ 1.5660414556657680e-4, 1.3914664880465400e-4,
7967+ 1.2203269185287530e-4, 1.0527052946041040e-4,
7968+ 8.8867825335203200e-5, 7.2831653374563650e-5,
7969+ 5.7168548169515050e-5, 4.1884506316022560e-5,
7970+ 2.6984964757674160e-5, 1.2474801400564880e-5,
7971+ -1.6416297019304470e-6, -1.5360496520469550e-5,
7972+ -2.8678484003389880e-5, -4.1592792755171040e-5,
7973+ -5.4101115008963200e-5, -6.6201632959158800e-5,
7974+ -7.7893006105444910e-5, -8.9174369623037550e-5,
7975+ -1.0004531116378850e-4, -1.1050586906665980e-4,
7976+ -1.2055651618705740e-4, -1.3019815804235450e-4,
7977+ -1.3943210818407590e-4, -1.4826008597798460e-4,
7978+ -1.5668419239382670e-4, -1.6470690840351980e-4,
7979+ -1.7233108395155490e-4, -1.7955993578371750e-4,
7980+ -1.8639701070854740e-4, -1.9284618337957900e-4,
7981+ -1.9891164424316180e-4, -2.0459789739171640e-4,
7982+ -2.0990972538755550e-4, -2.1485218733324290e-4,
7983+ -2.1943061159567880e-4, -2.2365059385031200e-4,
7984+ -2.2751796132972940e-4, -2.3103877007019660e-4,
7985+ -2.3421928008696620e-4, -2.3706595356421380e-4,
7986+ -2.3958543985834340e-4, -2.4178457457919800e-4,
7987+ /* Bank 6 */
7988+ 2.4367037437341020e-4, 2.4525003217524440e-4,
7989+ 2.4653081794176570e-4, 2.4752008219951220e-4,
7990+ 2.4822543333608940e-4, 2.4865471770248810e-4,
7991+ 2.4881540457247040e-4, 2.4871461830381660e-4,
7992+ 2.4836046092637280e-4, 2.4776199025177680e-4,
7993+ 2.4692741569938220e-4, 2.4586407616017000e-4,
7994+ 2.4457975717687980e-4, 2.4308272452941820e-4,
7995+ 2.4138114593372380e-4, 2.3948307023621970e-4,
7996+ 2.3739654799291240e-4, 2.3512963563507800e-4,
7997+ 2.3269036653525150e-4, 2.3008674810081220e-4,
7998+ 2.2732672676686290e-4, 2.2441818635854840e-4,
7999+ 2.2136894706917190e-4, 2.1818676491655660e-4,
8000+ 2.1487932080488700e-4, 2.1145421910491280e-4,
8001+ 2.0791896735659270e-4, 2.0428097498957360e-4,
8002+ 2.0054754547108610e-4, 1.9672587556804270e-4,
8003+ 1.9282304696531290e-4, 1.8884602526638050e-4,
8004+ 1.8480164638953740e-4, 1.8069661584612290e-4,
8005+ 1.7653750646560020e-4, 1.7233075773584680e-4,
8006+ 1.6808266356446820e-4, 1.6379937154642740e-4,
8007+ 1.5948687909058970e-4, 1.5515103314094370e-4,
8008+ 1.5079752791692290e-4, 1.4643190426323540e-4,
8009+ 1.4205953760578120e-4, 1.3768563787408340e-4,
8010+ 1.3331525983885840e-4, 1.2895330270761850e-4,
8011+ 1.2460449089034750e-4, 1.2027337376184880e-4,
8012+ 1.1596433966772030e-4, 1.1168161614264270e-4,
8013+ 1.0742926070674010e-4, 1.0321116057304920e-4,
8014+ 9.9031035415475500e-5, 9.4892437636254000e-5,
8015+ 9.0798755482139240e-5, 8.6753213062403400e-5,
8016+ 8.2758867628623800e-5, 7.8818609806320000e-5,
8017+ 7.4935171411178040e-5, 7.1111125753722860e-5,
8018+ 6.7348886525882700e-5, 6.3650708053788550e-5,
8019+ 6.0018691972791050e-5, 5.6454787620185350e-5,
8020+ 5.2960794000140600e-5, 4.9538360176954340e-5,
8021+ 4.6188991961724560e-5, 4.2914052387856640e-5,
8022+ 3.9714765485539260e-5, 3.6592216716540970e-5,
8023+ 3.3547358765259040e-5, 3.0581012081916960e-5,
8024+ 2.7693871041862060e-5, 2.4886504491416160e-5,
8025+ 2.2159361597292710e-5, 1.9512772389215240e-5,
8026+ 1.6946953848107710e-5, 1.4462010500550970e-5,
8027+ 1.2057941408635810e-5, 9.7346407524871100e-6,
8028+ 7.4919036559427900e-6, 5.3294268968052800e-6,
8029+ 3.2468187066945930e-6, 1.2435990827839660e-6,
8030+ -6.8080315386959900e-7, -2.5270494199802070e-6,
8031+ -4.2958677847708840e-6, -5.9880523825897000e-6,
8032+ -7.6044740757265500e-6, -9.1460801506922300e-6,
8033+ -1.0613876973541650e-5, -1.2008929083235120e-5,
8034+ -1.3332356590263080e-5, -1.4585334740507920e-5,
8035+ -1.5769086921577900e-5, -1.6884884022311310e-5,
8036+ -1.7934037335534700e-5, -1.8917898053528080e-5,
8037+ -1.9837853265502040e-5, -2.0695325418576370e-5,
8038+ -2.1491764461832140e-5, -2.2228647280994560e-5,
8039+ -2.2907473117403740e-5, -2.3529763128539150e-5,
8040+ -2.4097055300584120e-5, -2.4610903957661350e-5,
8041+ -2.5072874052447260e-5, -2.5484540698002960e-5,
8042+ -2.5847484577439320e-5, -2.6163291550639320e-5,
8043+ -2.6433548592482960e-5, -2.6659843389908530e-5,
8044+ -2.6843759539035120e-5, -2.6986876191054700e-5,
8045+ -2.7090765064735940e-5, -2.7156990105794550e-5,
8046+ -2.7187102980536760e-5, -2.7182642746157720e-5,
8047+ -2.7145133103663890e-5, -2.7076082153012070e-5,
8048+ -2.6976979753245170e-5, -2.6849297239997120e-5,
8049+ -2.6694483850464800e-5, -2.6513966535124460e-5,
8050+ -2.6309149390520640e-5, -2.6081413415833200e-5,
8051+ -2.5832111724562040e-5, -2.5562569399199020e-5,
8052+ /* Bank 7 */
8053+ 2.5274085082324960e-5, 2.4967930863542620e-5,
8054+ 2.4645348200903720e-5, 2.4307547722489910e-5,
8055+ 2.3955708939763280e-5, 2.3590980216497750e-5,
8056+ 2.3214478371918170e-5, 2.2827288605503470e-5,
8057+ 2.2430463239517170e-5, 2.2025021652894630e-5,
8058+ 2.1611950084231910e-5, 2.1192201630574280e-5,
8059+ 2.0766696417773940e-5, 2.0336321557464510e-5,
8060+ 1.9901930030141080e-5, 1.9464340744880170e-5,
8061+ 1.9024340970099240e-5, 1.8582686308483550e-5,
8062+ 1.8140097714618200e-5, 1.7697261563607500e-5,
8063+ 1.7254834143068570e-5, 1.6813441716539560e-5,
8064+ 1.6373677426466900e-5, 1.5936101341640500e-5,
8065+ 1.5501244597782600e-5, 1.5069609527679710e-5,
8066+ 1.4641668383496450e-5, 1.4217863365843780e-5,
8067+ 1.3798608540965960e-5, 1.3384289978242060e-5,
8068+ 1.2975266858030310e-5, 1.2571871574469220e-5,
8069+ 1.2174410889256530e-5, 1.1783166036693560e-5,
8070+ 1.1398393880881060e-5, 1.1020327046334650e-5,
8071+ 1.0649175634328590e-5, 1.0285127334608450e-5,
8072+ 9.9283481667264540e-6, 9.5789825988253100e-6,
8073+ 9.2371554195468400e-6, 8.9029718900122000e-6,
8074+ 8.5765192154768100e-6, 8.2578666429227760e-6,
8075+ 7.9470661364365490e-6, 7.6441525098592000e-6,
8076+ 7.3491456697144900e-6, 7.0620507545154100e-6,
8077+ 6.7828589565804950e-6, 6.5115476278604000e-6,
8078+ 6.2480817863072800e-6, 5.9924142424804800e-6,
8079+ 5.7444868785028750e-6, 5.5042307535458100e-6,
8080+ 5.2715671455405850e-6, 5.0464076705003400e-6,
8081+ 4.8286558658894680e-6, 4.6182073040543900e-6,
8082+ 4.4149505043312320e-6, 4.2187670209852250e-6,
8083+ 4.0295324657699800e-6, 3.8471166218015830e-6,
8084+ 3.6713849262294680e-6, 3.5021985520037540e-6,
8085+ 3.3394147240855820e-6, 3.1828867865974640e-6,
8086+ 3.0324653639203880e-6, 2.8879984579501380e-6,
8087+ 2.7493324266391140e-6, 2.6163120571644820e-6,
8088+ 2.4887811970856540e-6, 2.3665828120950560e-6,
8089+ 2.2495596253776460e-6, 2.1375541686662320e-6,
8090+ 2.0304092660990760e-6, 1.9279680902322050e-6,
8091+ 1.8300749104526120e-6, 1.7365751553971340e-6,
8092+ 1.6473160377545360e-6, 1.5621465913980060e-6,
8093+ 1.4809178634979940e-6, 1.4034829433780260e-6,
8094+ 1.3296974052300520e-6, 1.2594193438633260e-6,
8095+ 1.1925097184646100e-6, 1.1288323637155430e-6,
8096+ 1.0682538906146330e-6, 1.0106437128213760e-6,
8097+ 9.5587472540498280e-7, 9.0382333224895500e-7,
8098+ 8.5436937020293650e-7, 8.0739610368280600e-7,
8099+ 7.6279018172077200e-7, 7.2044165259013450e-7,
8100+ 6.8024432849991400e-7, 6.4209580087853050e-7,
8101+ 6.0589741192019800e-7, 5.7155423388793000e-7,
8102+ 5.3897464223335550e-7, 5.0807031294631050e-7,
8103+ 4.7875659112606760e-7, 4.5095249563698380e-7,
8104+ 4.2458045296159330e-7, 3.9956628121669190e-7,
8105+ 3.7583910465412180e-7, 3.5333134588843600e-7,
8106+ 3.3197864040473180e-7, 3.1171981968268900e-7,
8107+ 2.9249662541757600e-7, 2.7425370308549580e-7,
8108+ 2.5693874615777660e-7, 2.4050245877923400e-7,
8109+ 2.2489759047553620e-7, 2.1007899706006800e-7,
8110+ 1.9600594587757850e-7, 1.8264184311018150e-7,
8111+ 1.6994592926571220e-7, 1.5787424998123710e-7,
8112+ 1.4640931821191640e-7, 1.3555636137971380e-7,
8113+ 1.2523109645615350e-7, 1.1527363411865760e-7,
8114+ 1.0586659510721950e-7, 9.7483190494874640e-8,
8115+ 8.9326871281374790e-8, 7.9525034321375090e-8,
8116+ 7.0950903150874990e-8, 7.1279389866041690e-8,
8117+};
8118+
75258119 /*
75268120 * D.11 Look-up Table for Downmix Scale Factors
75278121 *
@@ -7534,7 +8128,7 @@ DECLARE_ALIGNED(16, const float, ff_dca_lfe_fir_128)[256] = { · 6 unmodified lines
75348128 * 2) [-29.750 to -15] with resolution of 0.250 dB
75358129 * 3) [-14.875 to 0] with resolution of 0.125 dB
75368130 */
7537−const uint16_t ff_dca_dmixtable[242] = {
8131+const uint16_t ff_dca_dmixtable[FF_DCA_DMIXTABLE_SIZE] = {
75388132 0, 33, 35, 37, 39, 41, 44, 46,
75398133 49, 52, 55, 58, 62, 65, 69, 73,
75408134 78, 82, 87, 92, 98, 104, 110, 116,
@@ -7568,6 +8162,35 @@ const uint16_t ff_dca_dmixtable[242] = { · 27 unmodified lines
75688162 32300, 32768,
75698163 };
75708164
8165+const uint32_t ff_dca_inv_dmixtable[FF_DCA_INV_DMIXTABLE_SIZE] = {
8166+ 6553600, 6186997, 5840902, 5514167, 5205710, 4914507, 4639593, 4380059,
8167+ 4135042, 3903731, 3685360, 3479204, 3284581, 3100844, 2927386, 2763630,
8168+ 2609035, 2463088, 2325305, 2195230, 2072430, 2013631, 1956500, 1900990,
8169+ 1847055, 1794651, 1743733, 1694260, 1646190, 1599484, 1554103, 1510010,
8170+ 1467168, 1425542, 1385096, 1345798, 1307615, 1270515, 1234468, 1199444,
8171+ 1165413, 1132348, 1100221, 1069005, 1038676, 1009206, 980573, 952752,
8172+ 925721, 899456, 873937, 849141, 825049, 801641, 778897, 756798,
8173+ 735326, 714463, 694193, 674497, 655360, 636766, 618700, 601146,
8174+ 584090, 567518, 551417, 535772, 520571, 505801, 491451, 477507,
8175+ 463959, 450796, 438006, 425579, 413504, 401772, 390373, 379297,
8176+ 368536, 363270, 358080, 352964, 347920, 342949, 338049, 333219,
8177+ 328458, 323765, 319139, 314579, 310084, 305654, 301287, 296982,
8178+ 292739, 288556, 284433, 280369, 276363, 272414, 268522, 264685,
8179+ 260904, 257176, 253501, 249879, 246309, 242790, 239321, 235901,
8180+ 232531, 229208, 225933, 222705, 219523, 216386, 213295, 210247,
8181+ 207243, 204282, 201363, 198486, 195650, 192855, 190099, 187383,
8182+ 184706, 182066, 179465, 176901, 174373, 171882, 169426, 167005,
8183+ 164619, 162267, 159948, 157663, 155410, 153190, 151001, 148844,
8184+ 146717, 144621, 142554, 140517, 138510, 136531, 134580, 132657,
8185+ 130762, 128893, 127052, 125236, 123447, 121683, 119944, 118231,
8186+ 116541, 114876, 113235, 111617, 110022, 108450, 106901, 105373,
8187+ 103868, 102383, 100921, 99479, 98057, 96656, 95275, 93914,
8188+ 92682, 91249, 89946, 88660, 87394, 86145, 84914, 83701,
8189+ 82505, 81326, 80164, 79019, 77890, 76777, 75680, 74598,
8190+ 73533, 72482, 71446, 70425, 69419, 68427, 67450, 66486,
8191+ 65536,
8192+};
8193+
75718194 const float ff_dca_default_coeffs[10][6][2] = {
75728195 { { 0.707107, 0.707107 }, { 0.000000, 0.000000 }, }, // A [LFE]
75738196 { { 1.000000, 0.000000 }, { 0.000000, 1.000000 }, { 0.000000, 0.000000 }, }, // A + B (dual mono) [LFE]
@@ -7581,6 +8204,11 @@ const float ff_dca_default_coeffs[10][6][2] = { · 7 unmodified lines
75818204 { { 0.501187, 0.501187 }, { 0.707107, 0.000000 }, { 0.000000, 0.707107 }, { 0.501187, 0.000000 }, { 0.000000, 0.501187 }, { 0.000000, 0.000000 }, }, // C + L + R + SL + SR [LFE]
75828205 };
75838206
8207+const int32_t ff_dca_sampling_freqs[16] = {
8208+ 8000, 16000, 32000, 64000, 128000, 22050, 44100, 88200,
8209+ 176400, 352800, 12000, 24000, 48000, 96000, 192000, 384000,
8210+};
8211+
75848212 /* downmix coeffs
75858213 *
75868214 * TABLE 9
libavcodec/dcadata.h+9−1
@@ -47,11 +47,19 @@ extern const float ff_dca_fir_32bands_nonperfect[512]; · 46 unmodified lines
4747
4848 extern const float ff_dca_lfe_fir_64[256];
4949 extern const float ff_dca_lfe_fir_128[256];
50+extern const float ff_dca_lfe_xll_fir_64[256];
51+extern const float ff_dca_fir_64bands[1024];
5052
51−extern const uint16_t ff_dca_dmixtable[242];
53+#define FF_DCA_DMIXTABLE_SIZE 242
54+#define FF_DCA_INV_DMIXTABLE_SIZE 201
55+
56+extern const uint16_t ff_dca_dmixtable[FF_DCA_DMIXTABLE_SIZE];
57+extern const uint32_t ff_dca_inv_dmixtable[FF_DCA_INV_DMIXTABLE_SIZE];
5258
5359 extern const float ff_dca_default_coeffs[10][6][2];
5460
61+extern const int32_t ff_dca_sampling_freqs[16];
62+
5563 extern const int8_t ff_dca_lfe_index[16];
5664
5765 extern const int8_t ff_dca_channel_reorder_lfe[16][9];
libavcodec/dcadec.c+178−21
@@ -4,6 +4,8 @@ · 3 unmodified lines
44 * Copyright (C) 2004 Benjamin Zores
55 * Copyright (C) 2006 Benjamin Larsson
66 * Copyright (C) 2007 Konstantin Shishkov
7+ * Copyright (C) 2012 Paul B Mahol
8+ * Copyright (C) 2014 Niels Möller
79 *
810 * This file is part of Libav.
911 *
@@ -26,6 +28,7 @@ · 16 unmodified lines
2628 #include <stddef.h>
2729 #include <stdio.h>
2830
31+#include "libavutil/attributes.h"
2932 #include "libavutil/channel_layout.h"
3033 #include "libavutil/common.h"
3134 #include "libavutil/float_dsp.h"
@@ -555,8 +558,83 @@ static void qmf_32_subbands(DCAContext *s, int chans, · 523 unmodified lines
555558 samples_out, s->raXin, scale);
556559 }
557560
558−static void lfe_interpolation_fir(DCAContext *s, int decimation_select,
559− int num_deci_sample, float *samples_in,
561+static QMF64_table *qmf64_precompute(void)
562+{
563+ unsigned i, j;
564+ QMF64_table *table = av_malloc(sizeof(*table));
565+ if (!table)
566+ return NULL;
567+
568+ for (i = 0; i < 32; i++)
569+ for (j = 0; j < 32; j++)
570+ table->dct4_coeff[i][j] = cos((2 * i + 1) * (2 * j + 1) * M_PI / 128);
571+ for (i = 0; i < 32; i++)
572+ for (j = 0; j < 32; j++)
573+ table->dct2_coeff[i][j] = cos((2 * i + 1) * j * M_PI / 64);
574+
575+ /* FIXME: Is the factor 0.125 = 1/8 right? */
576+ for (i = 0; i < 32; i++)
577+ table->rcos[i] = 0.125 / cos((2 * i + 1) * M_PI / 256);
578+ for (i = 0; i < 32; i++)
579+ table->rsin[i] = -0.125 / sin((2 * i + 1) * M_PI / 256);
580+
581+ return table;
582+}
583+
584+/* FIXME: Totally unoptimized. Based on the reference code and
585+ * http://multimedia.cx/mirror/dca-transform.pdf, with guessed tweaks
586+ * for doubling the size. */
587+static void qmf_64_subbands(DCAContext *s, int chans, float samples_in[64][8],
588+ float *samples_out, float scale)
589+{
590+ float raXin[64];
591+ float A[32], B[32];
592+ float *raX = s->subband_fir_hist[chans];
593+ float *raZ = s->subband_fir_noidea[chans];
594+ unsigned i, j, k, subindex;
595+
596+ for (i = s->subband_activity[chans]; i < 64; i++)
597+ raXin[i] = 0.0;
598+ for (subindex = 0; subindex < 8; subindex++) {
599+ for (i = 0; i < s->subband_activity[chans]; i++)
600+ raXin[i] = samples_in[i][subindex];
601+
602+ for (k = 0; k < 32; k++) {
603+ A[k] = 0.0;
604+ for (i = 0; i < 32; i++)
605+ A[k] += (raXin[2 * i] + raXin[2 * i + 1]) * s->qmf64_table->dct4_coeff[k][i];
606+ }
607+ for (k = 0; k < 32; k++) {
608+ B[k] = raXin[0] * s->qmf64_table->dct2_coeff[k][0];
609+ for (i = 1; i < 32; i++)
610+ B[k] += (raXin[2 * i] + raXin[2 * i - 1]) * s->qmf64_table->dct2_coeff[k][i];
611+ }
612+ for (k = 0; k < 32; k++) {
613+ raX[k] = s->qmf64_table->rcos[k] * (A[k] + B[k]);
614+ raX[63 - k] = s->qmf64_table->rsin[k] * (A[k] - B[k]);
615+ }
616+
617+ for (i = 0; i < 64; i++) {
618+ float out = raZ[i];
619+ for (j = 0; j < 1024; j += 128)
620+ out += ff_dca_fir_64bands[j + i] * (raX[j + i] - raX[j + 63 - i]);
621+ *samples_out++ = out * scale;
622+ }
623+
624+ for (i = 0; i < 64; i++) {
625+ float hist = 0.0;
626+ for (j = 0; j < 1024; j += 128)
627+ hist += ff_dca_fir_64bands[64 + j + i] * (-raX[i + j] - raX[j + 63 - i]);
628+
629+ raZ[i] = hist;
630+ }
631+
632+ /* FIXME: Make buffer circular, to avoid this move. */
633+ memmove(raX + 64, raX, (1024 - 64) * sizeof(*raX));
634+ }
635+}
636+
637+static void lfe_interpolation_fir(DCAContext *s, const float *samples_in,
560638 float *samples_out)
561639 {
562640 /* samples_in: An array holding decimated samples.
@@ -572,15 +650,18 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select, · 9 unmodified lines
572650 int deciindex;
573651
574652 /* Select decimation filter */
575− if (decimation_select == 1) {
653+ if (s->lfe == 1) {
576654 idx = 1;
577655 prCoeff = ff_dca_lfe_fir_128;
578656 } else {
579− idx = 0;
580− prCoeff = ff_dca_lfe_fir_64;
657+ idx = 0;
658+ if (s->exss_ext_mask & DCA_EXT_EXSS_XLL)
659+ prCoeff = ff_dca_lfe_xll_fir_64;
660+ else
661+ prCoeff = ff_dca_lfe_fir_64;
581662 }
582663 /* Interpolation */
583− for (deciindex = 0; deciindex < num_deci_sample; deciindex++) {
664+ for (deciindex = 0; deciindex < 2 * s->lfe; deciindex++) {
584665 s->dcadsp.lfe_fir[idx](samples_out, samples_in, prCoeff);
585666 samples_in++;
586667 samples_out += 2 * 32 * (1 + idx);
@@ -849,27 +930,56 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index) · 262 unmodified lines
849930 return 0;
850931 }
851932
852−static int dca_filter_channels(DCAContext *s, int block_index)
933+static int dca_filter_channels(DCAContext *s, int block_index, int upsample)
853934 {
854935 float (*subband_samples)[DCA_SUBBANDS][8] = s->subband_samples[block_index];
855936 int k;
856937
857− /* 32 subbands QMF */
858− for (k = 0; k < s->prim_channels; k++) {
859− if (s->channel_order_tab[k] >= 0)
860− qmf_32_subbands(s, k, subband_samples[k],
861− s->samples_chanptr[s->channel_order_tab[k]],
862− M_SQRT1_2 / 32768.0);
938+ if (upsample) {
939+ if (!s->qmf64_table) {
940+ s->qmf64_table = qmf64_precompute();
941+ if (!s->qmf64_table)
942+ return AVERROR(ENOMEM);
943+ }
944+
945+ /* 64 subbands QMF */
946+ for (k = 0; k < s->prim_channels; k++) {
947+ if (s->channel_order_tab[k] >= 0)
948+ qmf_64_subbands(s, k, subband_samples[k],
949+ s->samples_chanptr[s->channel_order_tab[k]],
950+ /* Upsampling needs a factor 2 here. */
951+ M_SQRT2 / 32768.0);
952+ }
953+ } else {
954+ /* 32 subbands QMF */
955+ for (k = 0; k < s->prim_channels; k++) {
956+ if (s->channel_order_tab[k] >= 0)
957+ qmf_32_subbands(s, k, subband_samples[k],
958+ s->samples_chanptr[s->channel_order_tab[k]],
959+ M_SQRT1_2 / 32768.0);
960+ }
863961 }
864962
865963 /* Generate LFE samples for this subsubframe FIXME!!! */
866964 if (s->lfe) {
867− lfe_interpolation_fir(s, s->lfe, 2 * s->lfe,
965+ float *samples = s->samples_chanptr[ff_dca_lfe_index[s->amode]];
966+ lfe_interpolation_fir(s,
868967 s->lfe_data + 2 * s->lfe * (block_index + 4),
869− s->samples_chanptr[ff_dca_lfe_index[s->amode]]);
870− /* Outputs 20bits pcm samples */
968+ samples);
969+ if (upsample) {
970+ unsigned i;
971+ /* Should apply the filter in Table 6-11 when upsampling. For
972+ * now, just duplicate. */
973+ for (i = 511; i > 0; i--) {
974+ samples[2 * i] =
975+ samples[2 * i + 1] = samples[i];
976+ }
977+ samples[1] = samples[0];
978+ }
871979 }
872980
981+ /* FIXME: This downmixing is probably broken with upsample.
982+ * Probably totally broken also with XLL in general. */
873983 /* Downmixing to Stereo */
874984 if (s->prim_channels + !!s->lfe > 2 &&
875985 s->avctx->request_channel_layout == AV_CH_LAYOUT_STEREO) {
@@ -1050,8 +1160,10 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, · 174 unmodified lines
10501160 DCAContext *s = avctx->priv_data;
10511161 int channels, full_channels;
10521162 int core_ss_end;
1163+ int upsample = 0;
10531164
1054− s->xch_present = 0;
1165+ s->exss_ext_mask = 0;
1166+ s->xch_present = 0;
10551167
10561168 s->dca_buffer_size = ff_dca_convert_bitstream(buf, buf_size, s->dca_buffer,
10571169 DCA_MAX_FRAME_SIZE + DCA_MAX_EXSS_HEADER_SIZE);
@@ -1279,6 +1391,43 @@ FF_ENABLE_DEPRECATION_WARNINGS · 221 unmodified lines
12791391
12801392 /* get output buffer */
12811393 frame->nb_samples = 256 * (s->sample_blocks / 8);
1394+ if (s->exss_ext_mask & DCA_EXT_EXSS_XLL) {
1395+ int xll_nb_samples = s->xll_segments * s->xll_smpl_in_seg;
1396+ /* Check for invalid/unsupported conditions first */
1397+ if (s->xll_residual_channels > channels) {
1398+ av_log(s->avctx, AV_LOG_WARNING,
1399+ "DCA: too many residual channels (%d, core channels %d). Disabling XLL\n",
1400+ s->xll_residual_channels, channels);
1401+ s->exss_ext_mask &= ~DCA_EXT_EXSS_XLL;
1402+ } else if (xll_nb_samples != frame->nb_samples &&
1403+ 2 * frame->nb_samples != xll_nb_samples) {
1404+ av_log(s->avctx, AV_LOG_WARNING,
1405+ "DCA: unsupported upsampling (%d XLL samples, %d core samples). Disabling XLL\n",
1406+ xll_nb_samples, frame->nb_samples);
1407+ s->exss_ext_mask &= ~DCA_EXT_EXSS_XLL;
1408+ } else {
1409+ if (2 * frame->nb_samples == xll_nb_samples) {
1410+ av_log(s->avctx, AV_LOG_INFO,
1411+ "XLL: upsampling core channels by a factor of 2\n");
1412+ upsample = 1;
1413+
1414+ frame->nb_samples = xll_nb_samples;
1415+ // FIXME: Is it good enough to copy from the first channel set?
1416+ avctx->sample_rate = s->xll_chsets[0].sampling_frequency;
1417+ }
1418+ /* If downmixing to stereo, don't decode additional channels.
1419+ * FIXME: Using the xch_disable flag for this doesn't seem right. */
1420+ if (!s->xch_disable)
1421+ avctx->channels += s->xll_channels - s->xll_residual_channels;
1422+ }
1423+ }
1424+
1425+ /* FIXME: This is an ugly hack, to just revert to the default
1426+ * layout if we have additional channels. Need to convert the XLL
1427+ * channel masks to libav channel_layout mask. */
1428+ if (av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels)
1429+ avctx->channel_layout = 0;
1430+
12821431 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
12831432 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
12841433 return ret;
@@ -1309,13 +1458,13 @@ FF_ENABLE_DEPRECATION_WARNINGS · 24 unmodified lines
13091458 /* filter to get final output */
13101459 for (i = 0; i < (s->sample_blocks / 8); i++) {
13111460 int ch;
1312−
1461+ unsigned block = upsample ? 512 : 256;
13131462 for (ch = 0; ch < channels; ch++)
1314− s->samples_chanptr[ch] = samples_flt[ch] + i * 256;
1463+ s->samples_chanptr[ch] = samples_flt[ch] + i * block;
13151464 for (; ch < full_channels; ch++)
1316− s->samples_chanptr[ch] = s->extra_channels[ch - channels] + i * 256;
1465+ s->samples_chanptr[ch] = s->extra_channels[ch - channels] + i * block;
13171466
1318− dca_filter_channels(s, i);
1467+ dca_filter_channels(s, i, upsample);
13191468
13201469 /* If this was marked as a DTS-ES stream we need to subtract back- */
13211470 /* channel from SL & SR to remove matrixed back-channel signal */
@@ -1333,6 +1482,11 @@ FF_ENABLE_DEPRECATION_WARNINGS · 11 unmodified lines
13331482 for (i = 0; i < 2 * s->lfe * 4; i++)
13341483 s->lfe_data[i] = s->lfe_data[i + lfe_samples];
13351484
1485+ if (s->exss_ext_mask & DCA_EXT_EXSS_XLL) {
1486+ ret = ff_dca_xll_decode_audio(s, frame);
1487+ if (ret < 0)
1488+ return ret;
1489+ }
13361490 /* AVMatrixEncoding
13371491 *
13381492 * DCA_STEREO_TOTAL (Lt/Rt) is equivalent to Dolby Surround */
@@ -1387,6 +1541,8 @@ static av_cold int dca_decode_end(AVCodecContext *avctx) · 48 unmodified lines
13871541 DCAContext *s = avctx->priv_data;
13881542 ff_mdct_end(&s->imdct);
13891543 av_freep(&s->extra_channels_buffer);
1544+ av_freep(&s->xll_sample_buf);
1545+ av_freep(&s->qmf64_table);
13901546 return 0;
13911547 }
13921548
@@ -1401,6 +1557,7 @@ static const AVProfile profiles[] = { · 8 unmodified lines
14011557
14021558 static const AVOption options[] = {
14031559 { "disable_xch", "disable decoding of the XCh extension", offsetof(DCAContext, xch_disable), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM },
1560+ { "disable_xll", "disable decoding of the XLL extension", offsetof(DCAContext, xll_disable), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM },
14041561 { NULL },
14051562 };
14061563
libavcodec/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929 #include "libavutil/version.h"
3030
3131 #define LIBAVCODEC_VERSION_MAJOR 56
32−#define LIBAVCODEC_VERSION_MINOR 18
32+#define LIBAVCODEC_VERSION_MINOR 19
3333 #define LIBAVCODEC_VERSION_MICRO 0
3434
3535 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t