Go to the documentation of this file.
51 int *tab_offset,
VLC *out_vlc)
57 for (
int b = 1;
b <= 12;
b++) {
58 for (
i = *
cb++;
i > 0;
i--) {
72 *tab_offset += 1 << max_len;
78 int i, tab_offset = 0;
82 for (
int i = 0;
i < 4;
i++) {
90 for (
int i = 0;
i < 8;
i++)
96 for (
i = 0;
i < 112;
i++) {
106 for (
i = 0;
i < 11;
i++)
112 for (
i = 0;
i < 7;
i++)
136 "Invalid number of transmitted units!\n");
161 const int8_t *weights_tab =
164 for (
i = 0;
i <
ctx->num_quant_units;
i++) {
168 "WL index out of range: pos=%d, val=%d!\n",
193 for (
i = 0;
i <
ctx->used_quant_units;
i++) {
197 "SF index out of range: pos=%d, val=%d!\n",
215 int *
dst,
int num_values)
221 for (
i = 3;
i < num_values;
i++)
226 #define UNPACK_SF_VQ_SHAPE(gb, dst, num_vals) \
227 start_val = get_bits((gb), 6); \
228 unpack_vq_shape(start_val, &atrac3p_sf_shapes[get_bits((gb), 6)][0], \
253 for (
i = 0;
i <
ctx->num_quant_units;
i++)
278 "WL mode 1: invalid position!\n");
326 vlc_tab->
bits, 1)) & 7;
329 vlc_tab->
bits, 1)) & 7;
335 vlc_tab->
bits, 1)) & 7;
390 int i, weight_idx = 0,
delta,
diff, num_long_vals,
391 delta_bits, min_val, vlc_sel, start_val;
398 for (
i = 0;
i <
ctx->used_quant_units;
i++)
405 for (
i = 0;
i <
ctx->used_quant_units;
i++) {
411 if (weight_idx == 3) {
418 for (
i = 0;
i < num_long_vals;
i++)
423 for (
i = num_long_vals;
i <
ctx->used_quant_units;
i++)
430 if (num_long_vals >
ctx->used_quant_units || delta_bits == 7) {
432 "SF mode 1: invalid parameters!\n");
437 for (
i = 0;
i < num_long_vals;
i++)
441 for (
i = num_long_vals;
i <
ctx->used_quant_units;
i++)
454 for (
i = 1;
i <
ctx->used_quant_units;
i++) {
464 for (
i = 0;
i <
ctx->used_quant_units;
i++) {
474 for (
i = 0;
i <
ctx->used_quant_units;
i++)
481 if (weight_idx == 3) {
489 for (
i = 1;
i <
ctx->used_quant_units;
i++) {
498 for (
i = 1;
i <
ctx->used_quant_units;
i++) {
507 if (weight_idx && weight_idx < 3)
527 for (ch_num = 0; ch_num < num_channels; ch_num++) {
528 memset(
ctx->channels[ch_num].qu_wordlen, 0,
529 sizeof(
ctx->channels[ch_num].qu_wordlen));
537 for (
i =
ctx->num_quant_units - 1;
i >= 0;
i--)
538 if (
ctx->channels[0].qu_wordlen[
i] ||
539 (num_channels == 2 &&
ctx->channels[1].qu_wordlen[
i]))
541 ctx->used_quant_units =
i + 1;
560 if (!
ctx->used_quant_units)
563 for (ch_num = 0; ch_num < num_channels; ch_num++) {
564 memset(
ctx->channels[ch_num].qu_sf_idx, 0,
565 sizeof(
ctx->channels[ch_num].qu_sf_idx));
589 if (num_coded_vals >
ctx->used_quant_units) {
591 "Invalid number of code table indexes: %d!\n", num_coded_vals);
594 return num_coded_vals;
596 return ctx->used_quant_units;
599 #define DEC_CT_IDX_COMMON(OP) \
600 num_vals = get_num_ct_values(gb, ctx, avctx); \
604 for (i = 0; i < num_vals; i++) { \
605 if (chan->qu_wordlen[i]) { \
606 chan->qu_tab_idx[i] = OP; \
607 } else if (ch_num && ref_chan->qu_wordlen[i]) \
609 chan->qu_tab_idx[i] = get_bits1(gb); \
612 #define CODING_DIRECT get_bits(gb, num_bits)
614 #define CODING_VLC get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1)
616 #define CODING_VLC_DELTA \
618 : (pred + get_vlc2(gb, delta_vlc->table, \
619 delta_vlc->bits, 1)) & mask; \
620 pred = chan->qu_tab_idx[i]
622 #define CODING_VLC_DIFF \
623 (ref_chan->qu_tab_idx[i] + \
624 get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1)) & mask
638 int i, num_vals, num_bits,
pred;
639 int mask =
ctx->use_full_table ? 7 : 3;
640 VLC *vlc_tab, *delta_vlc;
648 num_bits =
ctx->use_full_table + 2;
657 if (
ctx->use_full_table) {
693 if (!
ctx->used_quant_units)
698 for (ch_num = 0; ch_num < num_channels; ch_num++) {
699 memset(
ctx->channels[ch_num].qu_tab_idx, 0,
700 sizeof(
ctx->channels[ch_num].qu_tab_idx));
722 VLC *vlc_tab, int16_t *
out,
const int num_specs)
725 int group_size =
tab->group_size;
726 int num_coeffs =
tab->num_coeffs;
728 int is_signed =
tab->is_signed;
731 for (
pos = 0;
pos < num_specs;) {
733 for (j = 0; j < group_size; j++) {
736 for (
i = 0;
i < num_coeffs;
i++) {
748 pos += group_size * num_coeffs;
763 int i, ch_num,
qu, wordlen, codetab, tab_index, num_specs;
767 for (ch_num = 0; ch_num < num_channels; ch_num++) {
768 chan = &
ctx->channels[ch_num];
775 for (
qu = 0;
qu <
ctx->used_quant_units;
qu++) {
782 if (!
ctx->use_full_table)
785 tab_index = (chan->
table_type * 8 + codetab) * 7 + wordlen - 1;
791 }
else if (ch_num &&
ctx->channels[0].qu_wordlen[
qu] && !codetab) {
805 if (
ctx->used_quant_units > 2) {
807 for (
i = 0;
i < num_specs;
i++)
830 memset(
out, 0, num_flags);
835 for (
i = 0;
i < num_flags;
i++)
838 memset(
out, 1, num_flags);
856 for (ch_num = 0; ch_num < num_channels; ch_num++)
871 int ch_num,
int coded_subbands)
873 int i,
delta, delta_bits, min_val;
879 for (
i = 0;
i < coded_subbands;
i++)
883 for (
i = 0;
i < coded_subbands;
i++)
890 for (
i = 0;
i < coded_subbands;
i++) {
901 for (
i = 1;
i < coded_subbands;
i++) {
911 for (
i = 0;
i < coded_subbands;
i++)
918 for (
i = 0;
i < coded_subbands;
i++) {
939 for (
i = 0;
i <
dst->num_points;
i++)
940 dst->lev_code[
i] = (
i >=
ref->num_points) ? 7 :
ref->lev_code[
i];
956 if (
dst->num_points > 0)
960 for (
i = 1;
i <
dst->num_points;
i++) {
977 int ch_num,
int coded_subbands)
985 for (sb = 0; sb < coded_subbands; sb++)
991 for (sb = 0; sb < coded_subbands; sb++)
1000 for (sb = 0; sb < coded_subbands; sb++)
1006 for (sb = 0; sb < coded_subbands; sb++)
1018 for (sb = 1; sb < coded_subbands; sb++)
1030 for (sb = 0; sb < coded_subbands; sb++)
1037 for (sb = 0; sb < coded_subbands; sb++)
1063 if (!
pos ||
dst->loc_code[
pos - 1] < 15)
1065 else if (
dst->loc_code[
pos - 1] >= 30)
1087 if (
dst->num_points > 0) {
1091 for (
i = 1;
i <
dst->num_points;
i++) {
1097 dst->loc_code[
i] =
dst->loc_code[
i - 1] +
1114 int ch_num,
int coded_subbands,
1117 int sb,
i,
delta, delta_bits, min_val,
pred, more_than_ref;
1125 for (sb = 0; sb < coded_subbands; sb++)
1131 for (sb = 0; sb < coded_subbands; sb++) {
1140 pred =
ref->num_points > 0 ?
ref->loc_code[0] : 0;
1143 for (
i = 1;
i <
dst->num_points;
i++) {
1144 more_than_ref =
i >=
ref->num_points;
1145 if (
dst->lev_code[
i] >
dst->lev_code[
i - 1]) {
1147 if (more_than_ref) {
1156 dst->loc_code[
i] =
ref->loc_code[
i];
1170 for (sb = 0; sb < coded_subbands; sb++)
1175 for (sb = 0; sb < coded_subbands; sb++) {
1184 dst->loc_code[
i] =
ref->loc_code[
i];
1191 for (sb = 1; sb < coded_subbands; sb++) {
1201 ?
dst[-1].loc_code[0] : 0;
1204 for (
i = 1;
i <
dst->num_points;
i++) {
1205 more_than_ref =
i >=
dst[-1].num_points;
1209 2 + more_than_ref + 6];
1221 for (sb = 0; sb < coded_subbands; sb++)
1233 for (sb = 0; sb < coded_subbands; sb++)
1242 for (sb = 0; sb < coded_subbands; sb++) {
1245 if (
dst->loc_code[
i] < 0 ||
dst->loc_code[
i] > 31 ||
1246 (
i &&
dst->loc_code[
i] <=
dst->loc_code[
i - 1])) {
1248 "Invalid gain location: ch=%d, sb=%d, pos=%d, val=%d\n",
1249 ch_num, sb,
i,
dst->loc_code[
i]);
1270 int ch_num, coded_subbands, sb,
ret;
1272 for (ch_num = 0; ch_num < num_channels; ch_num++) {
1273 memset(
ctx->channels[ch_num].gain_data, 0,
1277 coded_subbands =
get_bits(gb, 4) + 1;
1279 ctx->channels[ch_num].num_gain_subbands =
get_bits(gb, 4) + 1;
1281 ctx->channels[ch_num].num_gain_subbands = coded_subbands;
1288 if (coded_subbands > 0) {
1289 for (sb = coded_subbands; sb <
ctx->channels[ch_num].num_gain_subbands; sb++)
1290 ctx->channels[ch_num].gain_data[sb] =
1291 ctx->channels[ch_num].gain_data[sb - 1];
1294 ctx->channels[ch_num].num_gain_subbands = 0;
1311 int ch_num,
int band_has_tones[])
1318 for (sb = 0; sb <
ctx->waves_info->num_tone_bands; sb++) {
1319 if (!band_has_tones[sb])
1322 dst[sb].pend_env.start_pos =
dst[sb].pend_env.has_start_point
1325 dst[sb].pend_env.stop_pos =
dst[sb].pend_env.has_stop_point
1329 for (sb = 0; sb <
ctx->waves_info->num_tone_bands; sb++) {
1330 if (!band_has_tones[sb])
1332 dst[sb].pend_env.has_start_point =
ref[sb].pend_env.has_start_point;
1333 dst[sb].pend_env.has_stop_point =
ref[sb].pend_env.has_stop_point;
1334 dst[sb].pend_env.start_pos =
ref[sb].pend_env.start_pos;
1335 dst[sb].pend_env.stop_pos =
ref[sb].pend_env.stop_pos;
1352 int ch_num,
int band_has_tones[],
1362 for (sb = 0; sb <
ctx->waves_info->num_tone_bands; sb++)
1363 if (band_has_tones[sb])
1367 for (sb = 0; sb <
ctx->waves_info->num_tone_bands; sb++)
1368 if (band_has_tones[sb])
1374 for (sb = 0; sb <
ctx->waves_info->num_tone_bands; sb++)
1375 if (band_has_tones[sb]) {
1379 dst[sb].num_wavs = (
ref[sb].num_wavs +
delta) & 0xF;
1383 for (sb = 0; sb <
ctx->waves_info->num_tone_bands; sb++)
1384 if (band_has_tones[sb])
1385 dst[sb].num_wavs =
ref[sb].num_wavs;
1390 for (sb = 0; sb <
ctx->waves_info->num_tone_bands; sb++)
1391 if (band_has_tones[sb]) {
1392 if (
ctx->waves_info->tones_index +
dst[sb].num_wavs > 48) {
1394 "Too many tones: %d (max. 48), frame: %"PRId64
"!\n",
1395 ctx->waves_info->tones_index +
dst[sb].num_wavs,
1399 dst[sb].start_index =
ctx->waves_info->tones_index;
1400 ctx->waves_info->tones_index +=
dst[sb].num_wavs;
1416 int ch_num,
int band_has_tones[])
1424 for (sb = 0; sb <
ctx->waves_info->num_tone_bands; sb++) {
1425 if (!band_has_tones[sb] || !
dst[sb].num_wavs)
1427 iwav = &
ctx->waves_info->waves[
dst[sb].start_index];
1428 direction = (
dst[sb].num_wavs > 1) ?
get_bits1(gb) : 0;
1430 if (
dst[sb].num_wavs)
1432 for (
i =
dst[sb].num_wavs - 2;
i >= 0 ;
i--) {
1433 nbits =
av_log2(iwav[
i+1].freq_index) + 1;
1437 for (
i = 0;
i <
dst[sb].num_wavs;
i++) {
1438 if (!
i || iwav[
i - 1].freq_index < 512)
1441 nbits =
av_log2(1023 - iwav[
i - 1].freq_index) + 1;
1443 1024 - (1 << nbits);
1449 for (sb = 0; sb <
ctx->waves_info->num_tone_bands; sb++) {
1450 if (!band_has_tones[sb] || !
dst[sb].num_wavs)
1452 iwav = &
ctx->waves_info->waves[
ref[sb].start_index];
1453 owav = &
ctx->waves_info->waves[
dst[sb].start_index];
1454 for (
i = 0;
i <
dst[sb].num_wavs;
i++) {
1458 pred = (
i <
ref[sb].num_wavs) ? iwav[
i].freq_index :
1459 (
ref[sb].num_wavs ? iwav[
ref[sb].num_wavs - 1].freq_index : 0);
1476 int ch_num,
int band_has_tones[])
1480 int refwaves[48] = { 0 };
1485 for (sb = 0; sb <
ctx->waves_info->num_tone_bands; sb++) {
1486 if (!band_has_tones[sb] || !
dst[sb].num_wavs)
1488 wsrc = &
ctx->waves_info->waves[
dst[sb].start_index];
1489 wref = &
ctx->waves_info->waves[
ref[sb].start_index];
1490 for (j = 0; j <
dst[sb].num_wavs; j++) {
1491 for (
i = 0, fi = 0, maxdiff = 1024;
i <
ref[sb].num_wavs;
i++) {
1492 diff =
FFABS(wsrc[j].freq_index - wref[
i].freq_index);
1493 if (
diff < maxdiff) {
1500 refwaves[
dst[sb].start_index + j] = fi +
ref[sb].start_index;
1501 else if (j <
ref[sb].num_wavs)
1502 refwaves[
dst[sb].start_index + j] = j +
ref[sb].start_index;
1504 refwaves[
dst[sb].start_index + j] = -1;
1513 for (sb = 0; sb <
ctx->waves_info->num_tone_bands; sb++) {
1514 if (!band_has_tones[sb] || !
dst[sb].num_wavs)
1516 if (
ctx->waves_info->amplitude_mode)
1517 for (
i = 0;
i <
dst[sb].num_wavs;
i++)
1518 ctx->waves_info->waves[
dst[sb].start_index +
i].amp_sf =
get_bits(gb, 6);
1520 ctx->waves_info->waves[
dst[sb].start_index].amp_sf =
get_bits(gb, 6);
1524 for (sb = 0; sb <
ctx->waves_info->num_tone_bands; sb++) {
1525 if (!band_has_tones[sb] || !
dst[sb].num_wavs)
1527 if (
ctx->waves_info->amplitude_mode)
1528 for (
i = 0;
i <
dst[sb].num_wavs;
i++)
1529 ctx->waves_info->waves[
dst[sb].start_index +
i].amp_sf =
1533 ctx->waves_info->waves[
dst[sb].start_index].amp_sf =
1539 for (sb = 0; sb <
ctx->waves_info->num_tone_bands; sb++) {
1540 if (!band_has_tones[sb] || !
dst[sb].num_wavs)
1542 for (
i = 0;
i <
dst[sb].num_wavs;
i++) {
1546 pred = refwaves[
dst[sb].start_index +
i] >= 0 ?
1547 ctx->waves_info->waves[refwaves[
dst[sb].start_index +
i]].amp_sf : 34;
1548 ctx->waves_info->waves[
dst[sb].start_index +
i].amp_sf = (
pred +
delta) & 0x3F;
1553 for (sb = 0; sb <
ctx->waves_info->num_tone_bands; sb++) {
1554 if (!band_has_tones[sb])
1556 for (
i = 0;
i <
dst[sb].num_wavs;
i++)
1557 ctx->waves_info->waves[
dst[sb].start_index +
i].amp_sf =
1558 refwaves[
dst[sb].start_index +
i] >= 0
1559 ?
ctx->waves_info->waves[refwaves[
dst[sb].start_index +
i]].amp_sf
1576 int ch_num,
int band_has_tones[])
1582 for (sb = 0; sb <
ctx->waves_info->num_tone_bands; sb++) {
1583 if (!band_has_tones[sb])
1585 wparam = &
ctx->waves_info->waves[
dst[sb].start_index];
1586 for (
i = 0;
i <
dst[sb].num_wavs;
i++)
1587 wparam[
i].phase_index =
get_bits(gb, 5);
1604 int band_has_tones[16];
1606 for (ch_num = 0; ch_num < num_channels; ch_num++)
1607 memset(
ctx->channels[ch_num].tones_info, 0,
1611 if (!
ctx->waves_info->tones_present)
1614 memset(
ctx->waves_info->waves, 0,
sizeof(
ctx->waves_info->waves));
1617 if (!
ctx->waves_info->amplitude_mode) {
1622 ctx->waves_info->num_tone_bands =
1626 if (num_channels == 2) {
1632 ctx->waves_info->tones_index = 0;
1634 for (ch_num = 0; ch_num < num_channels; ch_num++) {
1635 for (
i = 0;
i <
ctx->waves_info->num_tone_bands;
i++)
1636 band_has_tones[
i] = !ch_num ? 1 : !
ctx->waves_info->tone_sharing[
i];
1648 if (num_channels == 2) {
1649 for (
i = 0;
i <
ctx->waves_info->num_tone_bands;
i++) {
1650 if (
ctx->waves_info->tone_sharing[
i])
1651 ctx->channels[1].tones_info[
i] =
ctx->channels[0].tones_info[
i];
1653 if (
ctx->waves_info->tone_master[
i])
1655 ctx->channels[1].tones_info[
i]);
1669 if (
ctx->num_quant_units > 28 &&
ctx->num_quant_units < 32) {
1671 "Invalid number of quantization units: %d!\n",
1672 ctx->num_quant_units);
1683 ctx->num_coded_subbands =
ctx->used_quant_units
1695 if (num_channels == 2) {
1710 if (
ctx->noise_present) {
static const Atrac3pSpecCodeTab atrac3p_spectra_tabs[112]
static const uint8_t atrac3p_tone_xlats[]
static int get_num_ct_values(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, AVCodecContext *avctx)
Decode number of code table values.
static int get_subband_flags(GetBitContext *gb, uint8_t *out, int num_flags)
Retrieve specified amount of flag bits from the input bitstream.
int ff_vlc_init_from_lengths(VLC *vlc, int nb_bits, int nb_codes, const int8_t *lens, int lens_wrap, const void *symbols, int symbols_wrap, int symbols_size, int offset, int flags, void *logctx)
Build VLC decoding tables suitable for use with get_vlc2()
static VLC wl_vlc_tabs[4]
static int decode_band_numwavs(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int band_has_tones[], AVCodecContext *avctx)
Decode number of tones for each subband of a channel.
static double cb(void *priv, double x, double y)
int qu_tab_idx[32]
array of code table indexes for each quant unit
static const uint8_t atrac3p_qu_num_to_seg[32]
Ungroup table for word length segments.
static int decode_quant_wordlen(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx)
Decode word length information for each channel.
static int decode_tones_info(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx)
Decode tones info for all channels.
static const uint16_t table[]
static VLC ct_vlc_tabs[4]
static int decode_gainc_data(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx)
Decode gain control data for all channels.
#define DEC_CT_IDX_COMMON(OP)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static const uint8_t atrac3p_sf_cbs[][12]
VLC tables for scale factor indexes.
static int subtract_sf_weights(Atrac3pChanUnitCtx *ctx, Atrac3pChanParams *chan, int wtab_idx, AVCodecContext *avctx)
Subtract weighting coefficients from decoded scalefactors.
static const struct twinvq_data tab
static double val(void *priv, double ch)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
static int num_coded_units(GetBitContext *gb, Atrac3pChanParams *chan, Atrac3pChanUnitCtx *ctx, AVCodecContext *avctx)
Decode number of coded quantization units.
static void decode_tones_frequency(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int band_has_tones[])
Decode frequency information for each subband of a channel.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int num_points
number of gain control points
const uint16_t ff_atrac3p_qu_to_spec_pos[33]
Map quant unit number to its position in the spectrum.
static int decode_channel_code_tab(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, AVCodecContext *avctx)
Decode code table indexes for each quant unit of a channel.
static const int8_t atrac3p_spectra_cbs[][12]
Tables for spectrum coding.
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static VLC sf_vlc_tabs[8]
static const uint8_t atrac3p_tone_cbs[][12]
and forward the result(frame or status change) to the corresponding input. If nothing is possible
static const uint8_t atrac3p_spectra_xlats[]
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static int decode_gainc_loc_codes(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int coded_subbands, AVCodecContext *avctx)
Decode location code for each gain control point.
static unsigned int get_bits1(GetBitContext *s)
static const uint8_t atrac3p_gain_cbs[][12]
int16_t spectrum[2048]
decoded IMDCT spectrum
int num_coded_vals
number of transmitted quant unit values
static VLC spec_vlc_tabs[112]
Gain control parameters for one subband.
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
static void gainc_loc_mode1(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, AtracGainInfo *dst)
Implements coding mode 1 for gain compensation locations.
static void decode_tones_envelope(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int band_has_tones[])
Decode envelope for all tones of a channel.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
av_cold void ff_atrac3p_init_vlcs(void)
Initialize VLC tables for bitstream parsing.
static int decode_gainc_levels(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int coded_subbands)
Decode level code for each gain control point.
#define UNPACK_SF_VQ_SHAPE(gb, dst, num_vals)
int loc_code[7]
location of gain control points
int qu_sf_idx[32]
array of scale factor indexes for each quant unit
static int decode_gainc_npoints(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int coded_subbands)
Decode number of gain control points.
static const uint8_t atrac3p_wl_ct_xlats[]
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static const int atrac3p_subband_to_num_powgrps[16]
Map subband number to number of power compensation groups.
static av_cold void build_canonical_huff(const uint8_t *cb, const uint8_t **xlat, int *tab_offset, VLC *out_vlc)
Generate canonical VLC table from given descriptor.
static const uint8_t atrac3p_ct_cbs[][12]
VLC tables for code table indexes.
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
Sound channel parameters.
int ff_atrac3p_decode_channel_unit(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx)
Decode bitstream data of a channel unit.
static void gainc_level_mode1m(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, AtracGainInfo *dst)
Implements coding mode 1 (master) for gain compensation levels.
static int add_wordlen_weights(Atrac3pChanUnitCtx *ctx, Atrac3pChanParams *chan, int wtab_idx, AVCodecContext *avctx)
Add weighting coefficients to the decoded word-length information.
static void decode_tones_phase(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int band_has_tones[])
Decode phase information for each subband of a channel.
static const uint8_t atrac3p_sf_xlats[]
#define i(width, name, range_min, range_max)
static int decode_scale_factors(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx)
Decode scale factor indexes for each channel.
Parameters of a single sine wave.
static VLCElem tables_data[154276]
static const int8_t atrac3p_wl_weights[6][32]
static VLC tone_vlc_tabs[7]
static const int8_t atrac3p_wl_shapes[8][16][9]
3D base shape tables.
static const uint8_t atrac3p_gain_xlats[]
int64_t frame_num
Frame counter, set by libavcodec.
static const float pred[4]
#define FFSWAP(type, a, b)
int lev_code[7]
level at corresponding control point
uint8_t power_levs[5]
power compensation levels
static void decode_tones_amplitude(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int band_has_tones[])
Decode amplitude information for each subband of a channel.
int freq_index
wave frequency index
main external API structure.
Parameters of a group of sine waves.
Tables for spectrum coding.
static av_const int sign_extend(int val, unsigned bits)
static const uint8_t atrac3p_wl_cbs[][12]
VLC tables for wordlen.
static int ref[MAX_W *MAX_W]
static VLC gain_vlc_tabs[11]
int table_type
table type: 0 - tone?, 1- noise?
static void gainc_level_mode3s(AtracGainInfo *dst, AtracGainInfo *ref)
Implements coding mode 3 (slave) for gain compensation levels.
static int decode_channel_wordlen(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, AVCodecContext *avctx)
Decode word length for each quantization unit of a channel.
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
static const int8_t atrac3p_sf_weights[2][32]
#define ATRAC3P_SUBBANDS
Global unit sizes.
static void decode_qu_spectra(GetBitContext *gb, const Atrac3pSpecCodeTab *tab, VLC *vlc_tab, int16_t *out, const int num_specs)
Decode huffman-coded spectral lines for a given quant unit.
static int decode_channel_sf_idx(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, AVCodecContext *avctx)
Decode scale factor indexes for each quant unit of a channel.
static const uint8_t atrac3p_ct_restricted_to_full[2][7][4]
static void decode_spectrum(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx)
Decode huffman-coded IMDCT spectrum for all channels.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define VLC_INIT_USE_STATIC
int qu_wordlen[32]
array of word lengths for each quant unit
static int decode_code_table_indexes(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx)
Decode code table indexes for each channel.
AtracGainInfo * gain_data
gain control data for next frame
#define ATRAC3P_POWER_COMP_OFF
Global constants.
static void decode_window_shape(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels)
Decode mdct window shape flags for all channels.
static const uint8_t atrac3p_qu_to_subband[32]
Map quant unit number to subband number.
static void gainc_loc_mode0(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, AtracGainInfo *dst, int pos)
Implements coding mode 0 for gain compensation locations.
static void unpack_vq_shape(int start_val, const int8_t *shape_vec, int *dst, int num_values)
Unpack vector quantization tables.