21 #define BITSTREAM_READER_LE
91 { 0, -1, -1, -1, -1 },
101 { 0, -1, -1, -1, -1 },
102 { 0, 1, -1, -1, -1 },
104 { 1, 2, -1, -1, -1 },
133 static int initialized;
139 for (i = 0; i < 256; i++)
142 for (i = 0; i < 16; i++)
143 lpc_tab[i] = sin((i - 8) * (
M_PI / ((i < 8) ? 17 : 15)));
151 int i, ps, si, code, step_i;
157 value = (((ps & 0x7fffff) ^ -si) + si) * (1.0f / 0x7fffff);
160 if (step_i > step_max) {
167 for (i = 0; i < 64; i++) {
170 delta = step * 0.03125f;
174 delta += step * 0.5f;
176 delta += step * 0.25f;
178 delta += step * 0.125f;
180 delta += step * 0.0625f;
193 step_i = av_clip(step_i, 0, step_max);
205 int i, ps, si, code, step_i;
211 value = (((ps & 0x7fff) ^ -si) + si) * (1.0f / 0x7fff);
214 if (step_i > step_max) {
221 for (i = 0; i < 64; i++) {
224 delta = step * 0.125f;
228 delta += step * 0.5f;
230 delta += step * 0.25f;
243 step_i = av_clip(step_i, 0, step_max);
264 if (chunk->
len >= 52)
266 if (chunk->
len >= 35)
287 int sf, sf_idx, ch, main_ch, freq;
291 for (sf = 0; sf < 1 << group; sf += diff ? 8 : 1) {
292 sf_idx = ((s->
framenum << group) + sf) & 31;
296 for (freq = 1;; freq++) {
313 if (freq >> (5 - group) > s->
nsubbands * 4 - 5) {
323 amp[main_ch] = main_amp <
AMP_MAX ? main_amp : 0;
344 t->
x_freq = freq >> (5 - group);
345 t->
f_delt = (freq & ((1 << (5 - group)) - 1)) << group;
353 t->
phs[ch] = 128 - phs[ch] * 32 +
shift;
380 for (sb = 0; sb < 6; sb++)
386 for (group = 0; group < 5; group++)
422 int i, sf, prev, next, dist;
431 for (sf = 0; sf < 7; sf += dist) {
451 next = prev + ((next + 1) >> 1);
453 next = prev - ( next >> 1);
459 scf[sf + 1] = prev + ((next - prev) >> 1);
461 scf[sf + 1] = prev - ((prev - next) >> 1);
466 scf[sf + 1] = prev + ( (next - prev) >> 2);
467 scf[sf + 2] = prev + ( (next - prev) >> 1);
468 scf[sf + 3] = prev + (((next - prev) * 3) >> 2);
470 scf[sf + 1] = prev - ( (prev - next) >> 2);
471 scf[sf + 2] = prev - ( (prev - next) >> 1);
472 scf[sf + 3] = prev - (((prev - next) * 3) >> 2);
477 for (i = 1; i < dist; i++)
478 scf[sf + i] = prev + (next - prev) * i / dist;
506 int ch, sb, sf, nsubbands;
516 for (sb = 2; sb < nsubbands; sb++) {
528 for (sb = 0; sb < s->
nsubbands - 4; sb++) {
554 for (sb = 0; sb < nsubbands; sb++)
555 for (ch = ch1; ch <= ch2; ch++)
556 for (sf = 1; sf <= 4; sf++)
574 for (sb = 2; sb < nsubbands; sb++) {
581 for (sb = 0; sb < s->
nsubbands - 4; sb++) {
596 for (ch = ch1; ch <= ch2; ch++) {
603 for (i = 0; i < 8; i++) {
626 int i, j, code, nblocks, coding_method;
633 switch (quant_level) {
636 for (i = 0; i < nblocks; i++, samples += 8) {
638 for (j = 0; j < 8; j++)
654 for (i = 0; i < nblocks; i++, samples += 5) {
656 for (j = 0; j < 5; j++)
665 for (i = 0; i < nblocks; i++, samples += 3) {
667 for (j = 0; j < 3; j++)
680 for (i = 0; i < nblocks; i++)
698 int start_sb,
int end_sb,
int flag)
700 int sb, sb_g3, sb_reorder, quant_level;
702 for (sb = start_sb; sb < end_sb; sb++) {
706 }
else if (flag && sb < s->max_mono_subband) {
723 }
else if (sb < 12 && sb_reorder >= 4) {
744 parse_ch(s, ch1, sb_reorder, quant_level, 0);
746 parse_ch(s, ch2, sb_reorder, quant_level, 1);
748 parse_ch(s, ch1, sb_reorder, quant_level, 0);
750 parse_ch(s, ch2, sb_reorder, quant_level, 0);
764 for (i = 0; i < 8; i++) {
766 for (j = 0; j < (i + 1) / 2; j++) {
767 float tmp1 = coeff[ j ];
768 float tmp2 = coeff[i - j - 1];
769 coeff[ j ] = tmp1 + rc * tmp2;
770 coeff[i - j - 1] = tmp2 + rc * tmp1;
779 int i, sb, ch, codes[16];
782 for (sb = start_sb; sb < end_sb; sb++) {
783 int ncodes = 8 * (1 + (sb < 2));
784 for (ch = ch1; ch <= ch2; ch++) {
787 for (i = 0; i < ncodes; i++)
789 for (i = 0; i < ncodes / 8; i++)
800 int sb, ch, ol, st, max_sb,
profile;
811 ol = (profile >> 3) & 7;
815 max_sb = profile & 7;
820 int a = 18000 / (12 * f / 1000 + 100 + 40 * st) + 20 * ol;
822 quant_levels[sb] = 1;
824 quant_levels[sb] = 2;
826 quant_levels[sb] = 3;
828 quant_levels[sb] = 4;
830 quant_levels[sb] = 5;
834 for (sb = 0; sb < 8; sb++)
844 if (
parse_ts(s, ch1, ch2, 0, 2, 0) < 0)
848 for (sb = 0; sb < 2; sb++)
849 for (ch = ch1; ch <= ch2; ch++)
857 int start_sb,
int end_sb,
int flag)
859 int i, j, sb, ch, nsubbands;
862 if (end_sb > nsubbands)
865 for (sb = start_sb; sb < end_sb; sb++) {
866 for (ch = ch1; ch <= ch2; ch++) {
876 for (i = 0; i < 8; i++, g2_scf += 8) {
878 memset(g2_scf, 0, 64 - i * 8);
883 for (j = 0; j < 8; j++) {
889 memset(g2_scf, 0, 8);
906 if (
parse_ts(s, ch1, ch2, 2, 4, 0) < 0)
910 if (
parse_ts(s, ch1, ch2, 4, 6, 0) < 0)
938 double scale = (-1.0 / (1 << 17)) * sqrt(1 << (2 - s->
limited_range));
949 if (br_per_ch < 14000)
951 else if (br_per_ch < 32000)
952 scale = (br_per_ch - 14000) * (1.0 / 120000) + 0.85;
956 scale *= 1.0 / INT_MAX;
962 s->
sb_scf[i] = (i - 1) * 0.25 * 0.785 * scale;
964 s->
sb_scf[i] = 0.785 * scale;
1002 unsigned int sr_code;
1005 sr_code = bytestream2_get_byte(gb);
1017 s->
ch_mask = bytestream2_get_le16(gb);
1028 version = bytestream2_get_le16(gb);
1029 if ((version & 0xff00) != 0x0800) {
1035 s->
flags = bytestream2_get_byte(gb);
1049 bit_rate_hi = bytestream2_get_byte(gb);
1052 s->
bit_rate_orig = bytestream2_get_le16(gb) | ((bit_rate_hi & 0x0F) << 16);
1055 s->
bit_rate_scaled = bytestream2_get_le16(gb) | ((bit_rate_hi & 0xF0) << 12);
1162 int i, ch, sb, sf, ret, group, chunk_id, chunk_len;
1173 switch (bytestream2_get_byte(&gb)) {
1192 chunk_id = bytestream2_get_byte(&gb);
1193 chunk_len = (chunk_id & 0x80) ? bytestream2_get_be16(&gb) : bytestream2_get_byte(&gb);
1204 switch (chunk_id & 0x7f) {
1207 int checksum = bytestream2_get_be16(&gb);
1208 uint16_t res = chunk_id;
1209 res += (chunk_len >> 8) & 0xff;
1210 res += chunk_len & 0xff;
1211 for (i = 0; i < chunk_len - 2; i++)
1213 if (checksum != res) {
1246 for (sb = 0; sb < s->
nsubbands / 4; sb++) {
1254 for (group = 0; group < 5; group++) {
1255 for (sf = 0; sf < 1 << group; sf++) {
1256 int sf_idx = ((s->
framenum << group) + sf) & 31;
1264 chunk_id = bytestream2_get_byte(&gb);
1265 chunk_len = (chunk_id & 0x80) ? bytestream2_get_be16(&gb) : bytestream2_get_byte(&gb);
1277 chunk.lfe.len = chunk_len;
1278 chunk.lfe.data = gb.
buffer;
1284 chunk.tonal.id = chunk_id;
1285 chunk.tonal.len = chunk_len;
1286 chunk.tonal.data = gb.
buffer;
1295 chunk.tonal_grp[i].id = i;
1296 chunk.tonal_grp[i].len = chunk_len;
1297 chunk.tonal_grp[i].data = gb.
buffer;
1306 chunk.tonal_grp[i].id = i;
1307 chunk.tonal_grp[i].len = chunk_len;
1308 chunk.tonal_grp[i].data = gb.
buffer;
1315 chunk.grid1[i].len = chunk_len;
1316 chunk.grid1[i].data = gb.
buffer;
1323 chunk.hr_grid[i].len = chunk_len;
1324 chunk.hr_grid[i].data = gb.
buffer;
1331 chunk.ts1[i].len = chunk_len;
1332 chunk.ts1[i].data = gb.
buffer;
1339 chunk.ts2[i].len = chunk_len;
1340 chunk.ts2[i].data = gb.
buffer;
1352 for (i = 0; i < 5; i++)
1355 for (i = 0; i < (s->
nchannels + 1) / 2; i++) {
1366 if (!chunk.grid1[i].len || !chunk.hr_grid[i].len || !chunk.ts1[i].len)
1389 for (ch = ch1; ch <= ch2; ch++) {
1402 for (i = 0; i < 8; i++) {
1403 int scf = w1 * g1_scf_a[i] + w2 * g1_scf_b[i];
1404 hr_scf[i] = scf >> 7;
1410 for (i = 0; i < 8; i++) {
1411 int scf = w1 * g1_scf_a[i] + w2 * g1_scf_b[i];
1412 hr_scf[i] = (scf >> 7) - g3_avg - g3_scf[i];
1424 int i, j, k, ch, sb;
1426 for (ch = ch1; ch <= ch2; ch++) {
1436 }
else if (sb < 10) {
1441 float accum[8] = { 0 };
1444 for (k = 2; k < 6; k++) {
1446 for (j = 0; j < 8; j++)
1447 accum[j] += fabs(other[j]);
1450 for (j = 0; j < 8; j++)
1451 samples[j] = (accum[j] * 0.25f + 0.5f) *
lbr_rand(s, sb);
1462 for (i = 0; i < nsamples; i++) {
1464 for (j = 0; j < 8; j++)
1465 res += coeff[j] * samples[i - j - 1];
1475 for (ch = ch1; ch <= ch2; ch++) {
1478 if (!(s->
ch_pres[ch] & (1
U << sb)))
1498 for (ch = ch1; ch <= ch2; ch++) {
1503 unsigned int scf = hr_scf[i];
1506 for (j = 0; j < 16; j++)
1512 unsigned int scf = hr_scf[i / 8] - g2_scf[i];
1525 int ch2_pres = s->
ch_pres[ch2] & (1
U << sb);
1528 int sbms = (s->
sec_ch_sbms[ch1 / 2][sb] >> i) & 1;
1529 int lrms = (s->
sec_ch_lrms[ch1 / 2][sb] >> i) & 1;
1532 if (lrms && ch2_pres) {
1534 for (j = 0; j < 16; j++) {
1535 float tmp = samples_l[j];
1536 samples_l[j] = samples_r[j];
1537 samples_r[j] = -
tmp;
1540 for (j = 0; j < 16; j++) {
1541 float tmp = samples_l[j];
1542 samples_l[j] = samples_r[j];
1546 }
else if (!ch2_pres) {
1548 for (j = 0; j < 16; j++)
1549 samples_r[j] = -samples_l[j];
1551 for (j = 0; j < 16; j++)
1552 samples_r[j] = samples_l[j];
1555 }
else if (sbms && ch2_pres) {
1556 for (j = 0; j < 16; j++) {
1557 float tmp = samples_l[j];
1558 samples_l[j] = (tmp + samples_r[j]) * 0.5f;
1559 samples_r[j] = (tmp - samples_r[j]) * 0.5f;
1581 for (ch = ch1; ch <= ch2; ch++) {
1589 for (sf = 1; sf <= 4; sf++, samples += 32) {
1593 for (i = 0; i < 32; i++)
1594 samples[i] *= (32 - i) * prev + i * next;
1604 int group,
int group_sf,
int synth_idx)
1614 for (i = 0; i <
count; i++) {
1620 float s = amp *
cos_tab[(t->
phs[ch] + 64) & 255];
1628 values[3] += cf[0] * -
s;
1629 values[2] += cf[1] *
c;
1630 values[1] += cf[2] *
s;
1631 values[0] += cf[3] * -
c;
1634 values[2] += cf[0] * -
s;
1635 values[1] += cf[1] *
c;
1636 values[0] += cf[2] *
s;
1639 values[1] += cf[0] * -
s;
1640 values[0] += cf[1] *
c;
1643 values[0] += cf[0] * -
s;
1647 values[x_freq - 5] += cf[ 0] * -
s;
1648 p4: values[x_freq - 4] += cf[ 1] *
c;
1649 p3: values[x_freq - 3] += cf[ 2] *
s;
1650 p2: values[x_freq - 2] += cf[ 3] * -
c;
1651 p1: values[x_freq - 1] += cf[ 4] * -
s;
1652 p0: values[x_freq ] += cf[ 5] *
c;
1653 values[x_freq + 1] += cf[ 6] *
s;
1654 values[x_freq + 2] += cf[ 7] * -
c;
1655 values[x_freq + 3] += cf[ 8] * -
s;
1656 values[x_freq + 4] += cf[ 9] *
c;
1657 values[x_freq + 5] += cf[10] *
s;
1672 for (group = 0; group < 5; group++) {
1673 int group_sf = (s->
framenum << group) + ((sf - 22) >> (5 - group));
1674 int synth_idx = ((((sf - 22) & 31) << group) & 31) + (1 << group) - 1;
1676 synth_tones(s, ch, values, group, (group_sf - 1) & 31, 30 - synth_idx);
1677 synth_tones(s, ch, values, group, (group_sf ) & 31, synth_idx);
1688 if (nsubbands < noutsubbands)
1689 memset(values[nsubbands], 0, (noutsubbands - nsubbands) *
sizeof(values[0]));
1702 s->
history[ch], noutsubbands * 4);
1704 s->
window, noutsubbands * 4);
1705 output += noutsubbands * 4;
1709 for (sb = 0; sb < nsubbands; sb++) {
1718 int i, ret, nchannels, ch_conf = (s->
ch_mask & 0x7) - 1;
1719 const int8_t *reorder;
1742 for (i = 0; i < (s->
nchannels + 1) / 2; i++) {
1755 if (ch1 < nchannels)
1758 if (ch1 != ch2 && ch2 < nchannels)
static void parse_grid_3(DCALbrDecoder *s, int ch1, int ch2, int sb, int flag)
int ntones
Circular buffer head position.
static int parse_grid_1_sec_ch(DCALbrDecoder *s, int ch2)
const float ff_dca_rsd_level_2b[2]
static int parse_tonal_chunk(DCALbrDecoder *s, LBRChunk *chunk)
float window[DCA_LBR_SUBBANDS *4]
Long window for IMDCT.
static void synth_lpc(DCALbrDecoder *s, int ch1, int ch2, int sb)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int shift(int a, int b)
This structure describes decoded (raw) audio or video data.
const float ff_dca_st_coeff[34]
int bit_rate_scaled
Scaled bit rate.
ptrdiff_t const GLvoid * data
int ff_dca_lbr_parse(DCALbrDecoder *s, uint8_t *data, DCAExssAsset *asset)
uint8_t grid_2_scf[DCA_LBR_CHANNELS][3][64]
Grid 2 scale factors.
uint32_t ch_pres[DCA_LBR_CHANNELS]
Subband allocation flags.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t bit_rate
the average bitrate
const int8_t ff_dca_ph0_shift[8]
#define AV_CH_LAYOUT_SURROUND
#define DCA_LBR_CHANNELS_TOTAL
int max_mono_subband
Subband index where mono encoding ends.
static void skip_bits_long(GetBitContext *s, int n)
unsigned int ts_size
Time sample buffer size.
const uint8_t ff_dca_scf_to_grid_1[32]
static float cos_tab[256]
static int parse_st_code(GetBitContext *s, int min_v)
int nchannels_total
Total number of fullband channels.
int freq_range
Frequency range of LBR audio.
const float ff_dca_lfe_step_size_24[144]
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define FF_PROFILE_DTS_EXPRESS
uint8_t x_freq
Spectral line offset.
const uint16_t ff_dca_rsd_pack_5_in_8[256]
void(* vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len)
Calculate the entry wise product of two vectors of floats, and store the result in a vector of floats...
static int parse_lfe_16(DCALbrDecoder *s)
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
#define AV_CH_LAYOUT_STEREO
int bit_rate_orig
Original bit rate.
static int init_sample_rate(DCALbrDecoder *s)
const float ff_dca_quant_amp[57]
#define AV_CH_LAYOUT_5POINT0
static int parse_grid_1_chunk(DCALbrDecoder *s, LBRChunk *chunk, int ch1, int ch2)
float * ts_buffer
Time sample buffer base.
const uint8_t ff_dca_freq_ranges[16]
float sb_scf[DCA_LBR_SUBBANDS]
Subband randomization scale factors.
float lfe_scale
Scale factor of LFE samples before IIR filter.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int ensure_bits(GetBitContext *s, int n)
Check point to ensure that enough bits are left.
enum AVSampleFormat sample_fmt
audio sample format
static void filter_ts(DCALbrDecoder *s, int ch1, int ch2)
int ch_mask
LBR speaker mask.
uint8_t part_stereo_pres
Partial stereo coefficients presence flags.
static void random_ts(DCALbrDecoder *s, int ch1, int ch2)
Fill unallocated subbands with randomness.
void av_fast_mallocz(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
#define AV_CH_LOW_FREQUENCY
static void parse_ch(DCALbrDecoder *s, int ch, int sb, int quant_level, int flag)
Parse time samples for one subband, filling truncated samples with randomness.
uint8_t phs[DCA_LBR_CHANNELS]
Per-channel phase.
static int parse_lfe_chunk(DCALbrDecoder *s, LBRChunk *chunk)
static void transform_channel(DCALbrDecoder *s, int ch, float *output)
int nchannels
Number of fullband channels to decode.
int sample_rate
Sample rate of LBR audio.
static int get_bits_left(GetBitContext *gb)
static float lbr_rand(DCALbrDecoder *s, int sb)
const int8_t ff_dca_lfe_delta_index_16[8]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
DCALbrTone tones[DCA_LBR_TONES]
Circular buffer of tones.
uint8_t tonal_scf[6]
Tonal scale factors.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
void(* lfe_iir)(float *output, const float *input, const float iir[5][4], float hist[5][2], ptrdiff_t factor)
uint8_t ph_rot
Phase rotation.
int warned
Flags for warning suppression.
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
const float ff_dca_rsd_level_5[5]
static av_cold void init_tables(void)
float lfe_history[5][2]
LFE IIR filter history.
const uint32_t ff_dca_sampling_freqs[16]
uint8_t part_stereo[DCA_LBR_CHANNELS][DCA_LBR_SUBBANDS/4][5]
Partial stereo coefficients.
int lbr_offset
Offset to LBR component from start of substream.
uint8_t amp[DCA_LBR_CHANNELS]
Per-channel amplitude.
#define DCA_SPEAKER_LAYOUT_STEREO
static int parse_tonal_group(DCALbrDecoder *s, LBRChunk *chunk)
uint64_t channel_layout
Audio channel layout.
void(* imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
uint16_t tonal_bounds[5][32][2]
Per-group per-subframe start/end positions of tones.
static int alloc_sample_buffer(DCALbrDecoder *s)
const float ff_dca_synth_env[32]
static void base_func_synth(DCALbrDecoder *s, int ch, float *values, int sf)
Synthesise all tones in all groups for the given residual subframe.
audio channel layout utility functions
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
const float ff_dca_rsd_level_8[8]
const uint8_t ff_dca_scf_to_grid_2[32]
const uint16_t ff_dca_avg_g3_freqs[3]
GLsizei GLboolean const GLfloat * value
int lbr_rand
Seed for subband randomization.
const float ff_dca_rsd_level_16[16]
uint8_t sec_ch_sbms[DCA_LBR_CHANNELS/2][DCA_LBR_SUBBANDS]
Right channel inversion or mid/side decoding flags.
int8_t grid_3_avg[DCA_LBR_CHANNELS][DCA_LBR_SUBBANDS-4]
Grid 3 average values.
int nsubbands
Number of encoded subbands.
av_cold void ff_dca_lbr_flush(DCALbrDecoder *s)
av_cold void ff_dca_lbr_close(DCALbrDecoder *s)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
#define AV_EF_EXPLODE
abort decoding on minor error detection
static int parse_lpc(DCALbrDecoder *s, int ch1, int ch2, int start_sb, int end_sb)
static int parse_ts(DCALbrDecoder *s, int ch1, int ch2, int start_sb, int end_sb, int flag)
#define AV_CH_FRONT_CENTER
uint8_t grid_1_scf[DCA_LBR_CHANNELS][12][8]
Grid 1 scale factors.
static volatile int checksum
const float ff_dca_bank_coeff[10]
VLC ff_dca_vlc_tnl_grp[5]
static const uint8_t channel_counts[7]
int ff_dca_lbr_filter_frame(DCALbrDecoder *s, AVFrame *frame)
static void predict(float *samples, const float *coeff, int nsamples)
#define FF_ARRAY_ELEMS(a)
static int parse_high_res_grid(DCALbrDecoder *s, LBRChunk *chunk, int ch1, int ch2)
void(* lbr_bank)(float output[32][4], float **input, const float *coeff, ptrdiff_t ofs, ptrdiff_t len)
int ff_side_data_update_matrix_encoding(AVFrame *frame, enum AVMatrixEncoding matrix_encoding)
Add or update AV_FRAME_DATA_MATRIXENCODING side data.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static int parse_ts2_chunk(DCALbrDecoder *s, LBRChunk *chunk, int ch1, int ch2)
float lpc_coeff[2][DCA_LBR_CHANNELS][3][2][8]
Predictor coefficients.
static const int8_t channel_reorder_lfe[7][5]
const float ff_dca_corr_cf[32][11]
float history[DCA_LBR_CHANNELS][DCA_LBR_SUBBANDS *4]
IMDCT history.
const float ff_dca_lfe_iir[5][4]
int8_t grid_3_scf[DCA_LBR_CHANNELS][DCA_LBR_SUBBANDS-4][8]
Grid 3 scale factors.
int sample_rate
samples per second
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
int band_limit
Band limit factor.
main external API structure.
static int parse_ts1_chunk(DCALbrDecoder *s, LBRChunk *chunk, int ch1, int ch2)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int lbr_size
Size of LBR component in extension substream.
const uint8_t ff_dca_freq_to_sb[32]
#define AV_EF_CAREFUL
consider things that violate the spec, are fast to calculate and have not been seen in the wild as er...
void(* vector_fmul_add)(float *dst, const float *src0, const float *src1, const float *src2, int len)
Calculate the entry wise product of two vectors of floats, add a third vector of floats and store the...
static int parse_tonal(DCALbrDecoder *s, int group)
static unsigned int get_bits1(GetBitContext *s)
static const uint16_t channel_layouts[7]
int res_profile
Resolution profile.
const float ff_dca_long_window[128]
static void convert_lpc(float *coeff, const int *codes)
Convert from reflection coefficients to direct form coefficients.
uint8_t sb_indices[DCA_LBR_SUBBANDS]
Subband reordering indices.
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data...
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
const uint8_t ff_dca_rsd_pack_3_in_7[128][3]
int limited_range
Band limited frequency range.
static int parse_lfe_24(DCALbrDecoder *s)
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
const float ff_dca_rsd_level_3[3]
static int ff_dca_count_chs_for_mask(unsigned int mask)
Return number of individual channels in DCASpeakerPair mask.
uint8_t f_delt
Difference between original and center frequency.
#define DCA_LBR_TIME_HISTORY
#define LOCAL_ALIGNED_32(t, v,...)
int framenum
Lower 5 bits of current frame number.
int limited_rate
Band limited sample rate.
uint8_t sec_ch_lrms[DCA_LBR_CHANNELS/2][DCA_LBR_SUBBANDS]
Flags indicating if left/right channel are swapped.
const uint8_t ff_dca_grid_1_to_scf[11]
float lfe_data[64]
Decimated LFE samples.
#define DCA_LBR_TIME_SAMPLES
uint32_t grid_3_pres[DCA_LBR_CHANNELS]
Grid 3 scale factors presence flags.
const float ff_dca_rsd_level_2a[2]
const uint16_t ff_dca_fst_amp[44]
const float ff_dca_lfe_step_size_16[101]
int request_channel_layout
Converted from avctx.request_channel_layout.
static int parse_grid_2(DCALbrDecoder *s, int ch1, int ch2, int start_sb, int end_sb, int flag)
static int parse_vlc(GetBitContext *s, VLC *vlc, int max_depth)
float * time_samples[DCA_LBR_CHANNELS][DCA_LBR_SUBBANDS]
Time samples.
VLC ff_dca_vlc_fst_rsd_amp
static av_always_inline int diff(const uint32_t a, const uint32_t b)
int channels
number of audio channels
VLC_TYPE(* table)[2]
code, bits
static int parse_scale_factors(DCALbrDecoder *s, uint8_t *scf)
static const double coeff[2][5]
const uint8_t ff_dca_sb_reorder[8][8]
static const int8_t channel_reorder_nolfe[7][5]
static void decode_part_stereo(DCALbrDecoder *s, int ch1, int ch2)
Modulate by interpolated partial stereo coefficients.
int flags
Flags for LBR decoder initialization.
static void synth_tones(DCALbrDecoder *s, int ch, float *values, int group, int group_sf, int synth_idx)
Synthesise tones in the given group for the given tonal subframe.
av_cold int ff_dca_lbr_init(DCALbrDecoder *s)
uint8_t quant_levels[DCA_LBR_CHANNELS/2][DCA_LBR_SUBBANDS]
Quantization levels.
const int8_t ff_dca_lfe_delta_index_24[32]
static const uint8_t lfe_index[7]
int min_mono_subband
Subband index where mono encoding starts.
const uint8_t ff_dca_grid_2_to_scf[3]
uint8_t ** extended_data
pointers to the data planes/channels.
#define AV_CH_LAYOUT_MONO
int nb_samples
number of audio samples (per channel) described by this frame
int g3_avg_only_start_sb
Subband index where grid 3 scale factors end.
static int parse_decoder_init(DCALbrDecoder *s, GetByteContext *gb)
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
uint8_t high_res_scf[DCA_LBR_CHANNELS][DCA_LBR_SUBBANDS][8]
High-frequency resolution scale factors.
static void decode_grid(DCALbrDecoder *s, int ch1, int ch2)
Reconstruct high-frequency resolution grid from first and third grids.
const uint8_t ff_dca_grid_1_weights[12][32]