42 #define GET_DELTA(gb, delta_bits) \
43 ((delta_bits) ? get_bits((gb), (delta_bits)) : 0)
54 int *tab_offset,
VLC *out_vlc)
64 for (b = min_len; b <= max_len; b++) {
65 for (i = *cb++; i > 0; i--) {
68 codes[
index] = code++;
80 *tab_offset += 1 << max_len;
85 int i, wl_vlc_offs, ct_vlc_offs, sf_vlc_offs, tab_offset;
87 static const int wl_nb_bits[4] = { 2, 3, 5, 5 };
88 static const int wl_nb_codes[4] = { 3, 5, 8, 8 };
89 static const uint8_t *
const wl_bits[4] = {
93 static const uint8_t *
const wl_codes[4] = {
97 static const uint8_t *
const wl_xlats[4] = {
101 static const int ct_nb_bits[4] = { 3, 4, 4, 4 };
102 static const int ct_nb_codes[4] = { 4, 8, 8, 8 };
103 static const uint8_t *
const ct_bits[4] = {
107 static const uint8_t *
const ct_codes[4] = {
111 static const uint8_t *
const ct_xlats[4] = {
115 static const int sf_nb_bits[8] = { 9, 9, 9, 9, 6, 6, 7, 7 };
116 static const int sf_nb_codes[8] = { 64, 64, 64, 64, 16, 16, 16, 16 };
117 static const uint8_t *
const sf_bits[8] = {
122 static const uint16_t *
const sf_codes[8] = {
127 static const uint8_t *
const sf_xlats[8] = {
132 static const uint8_t *
const gain_cbs[11] = {
140 static const uint8_t *
const gain_xlats[11] = {
148 static const uint8_t *
const tone_cbs[7] = {
154 static const uint8_t *
const tone_xlats[7] = {
160 for (i = 0, wl_vlc_offs = 0, ct_vlc_offs = 2508; i < 4; i++) {
182 for (i = 0, sf_vlc_offs = 76; i < 8; i++) {
197 for (i = 0; i < 112; i++) {
201 &tab_offset, &spec_vlc_tabs[i]);
203 spec_vlc_tabs[i].
table = 0;
207 for (i = 0; i < 11; i++)
211 for (i = 0; i < 7; i++)
234 "Invalid number of transmitted units!\n");
259 const int8_t *weights_tab =
266 "WL index out of range: pos=%d, val=%d!\n",
295 "SF index out of range: pos=%d, val=%d!\n",
313 int *dst,
int num_values)
318 dst[0] = dst[1] = dst[2] = start_val;
319 for (i = 3; i < num_values; i++)
324 #define UNPACK_SF_VQ_SHAPE(gb, dst, num_vals) \
325 start_val = get_bits((gb), 6); \
326 unpack_vq_shape(start_val, &atrac3p_sf_shapes[get_bits((gb), 6)][0], \
341 int i, weight_idx = 0,
delta,
diff, pos, delta_bits, min_val, flag,
360 vlc_tab = &wl_vlc_tabs[
get_bits(gb, 2)];
376 "WL mode 1: invalid position!\n");
383 for (i = 0; i < pos; i++)
396 vlc_tab = &wl_vlc_tabs[
get_bits(gb, 2)];
407 vlc_tab = &wl_vlc_tabs[
get_bits(gb, 1)];
424 vlc_tab->
bits, 1)) & 7;
427 vlc_tab->
bits, 1)) & 7;
433 vlc_tab->
bits, 1)) & 7;
443 vlc_tab = &wl_vlc_tabs[
get_bits(gb, 2)];
484 int i, weight_idx = 0,
delta,
diff, num_long_vals,
485 delta_bits, min_val, vlc_sel, start_val;
497 vlc_tab = &sf_vlc_tabs[
get_bits(gb, 2)];
505 if (weight_idx == 3) {
512 for (i = 0; i < num_long_vals; i++)
526 "SF mode 1: invalid parameters!\n");
531 for (i = 0; i < num_long_vals; i++)
543 vlc_tab = &sf_vlc_tabs[
get_bits(gb, 2)];
554 vlc_tab = &sf_vlc_tabs[
get_bits(gb, 2) + 4];
573 vlc_tab = &sf_vlc_tabs[vlc_sel];
575 if (weight_idx == 3) {
576 vlc_tab = &sf_vlc_tabs[vlc_sel + 4];
580 diff = (
get_bits(gb, 4) + 56) & 0x3F;
601 if (weight_idx && weight_idx < 3)
621 for (ch_num = 0; ch_num < num_channels; ch_num++) {
657 for (ch_num = 0; ch_num < num_channels; ch_num++) {
685 "Invalid number of code table indexes: %d!\n", num_coded_vals);
688 return num_coded_vals;
693 #define DEC_CT_IDX_COMMON(OP) \
694 num_vals = get_num_ct_values(gb, ctx, avctx); \
698 for (i = 0; i < num_vals; i++) { \
699 if (chan->qu_wordlen[i]) { \
700 chan->qu_tab_idx[i] = OP; \
701 } else if (ch_num && ref_chan->qu_wordlen[i]) \
703 chan->qu_tab_idx[i] = get_bits1(gb); \
706 #define CODING_DIRECT get_bits(gb, num_bits)
708 #define CODING_VLC get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1)
710 #define CODING_VLC_DELTA \
712 : (pred + get_vlc2(gb, delta_vlc->table, \
713 delta_vlc->bits, 1)) & mask; \
714 pred = chan->qu_tab_idx[i]
716 #define CODING_VLC_DIFF \
717 (ref_chan->qu_tab_idx[i] + \
718 get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1)) & mask
732 int i, num_vals, num_bits,
pred;
734 VLC *vlc_tab, *delta_vlc;
752 vlc_tab = &ct_vlc_tabs[1];
753 delta_vlc = &ct_vlc_tabs[2];
792 for (ch_num = 0; ch_num < num_channels; ch_num++) {
816 VLC *vlc_tab, int16_t *
out,
const int num_specs)
825 for (pos = 0; pos < num_specs;) {
827 for (j = 0; j < group_size; j++) {
830 for (i = 0; i < num_coeffs; i++) {
831 cf = av_mod_uintp2(val, bits);
842 pos += group_size * num_coeffs;
857 int i, ch_num,
qu, wordlen, codetab, tab_index, num_specs;
861 for (ch_num = 0; ch_num < num_channels; ch_num++) {
879 tab_index = (chan->
table_type * 8 + codetab) * 7 + wordlen - 1;
887 &chan->
spectrum[ff_atrac3p_qu_to_spec_pos[qu]],
891 memcpy(&chan->
spectrum[ff_atrac3p_qu_to_spec_pos[qu]],
894 sizeof(chan->
spectrum[ff_atrac3p_qu_to_spec_pos[qu]]));
905 for (i = 0; i < num_specs; i++)
928 memset(out, 0, num_flags);
933 for (i = 0; i < num_flags; i++)
936 memset(out, 1, num_flags);
954 for (ch_num = 0; ch_num < num_channels; ch_num++)
969 int ch_num,
int coded_subbands)
971 int i,
delta, delta_bits, min_val;
977 for (i = 0; i < coded_subbands; i++)
981 for (i = 0; i < coded_subbands; i++)
984 gain_vlc_tabs[0].
bits, 1);
988 for (i = 0; i < coded_subbands; i++) {
989 delta =
get_vlc2(gb, gain_vlc_tabs[1].table,
990 gain_vlc_tabs[1].bits, 1);
996 get_vlc2(gb, gain_vlc_tabs[0].table,
997 gain_vlc_tabs[0].bits, 1);
999 for (i = 1; i < coded_subbands; i++) {
1000 delta =
get_vlc2(gb, gain_vlc_tabs[1].table,
1001 gain_vlc_tabs[1].bits, 1);
1009 for (i = 0; i < coded_subbands; i++)
1016 for (i = 0; i < coded_subbands; i++) {
1056 gain_vlc_tabs[2].
bits, 1);
1059 delta =
get_vlc2(gb, gain_vlc_tabs[3].table,
1060 gain_vlc_tabs[3].bits, 1);
1075 int ch_num,
int coded_subbands)
1077 int sb, i,
delta, delta_bits, min_val,
pred;
1083 for (sb = 0; sb < coded_subbands; sb++)
1089 for (sb = 0; sb < coded_subbands; sb++)
1092 gain_vlc_tabs[5].
bits, 1);
1098 for (sb = 0; sb < coded_subbands; sb++)
1104 for (sb = 0; sb < coded_subbands; sb++)
1116 for (sb = 1; sb < coded_subbands; sb++)
1119 gain_vlc_tabs[4].
bits, 1);
1128 for (sb = 0; sb < coded_subbands; sb++)
1135 for (sb = 0; sb < coded_subbands; sb++)
1161 if (!pos || dst->
loc_code[pos - 1] < 15)
1163 else if (dst->
loc_code[pos - 1] >= 30)
1194 : &gain_vlc_tabs[9];
1212 int ch_num,
int coded_subbands,
1215 int sb, i,
delta, delta_bits, min_val,
pred, more_than_ref;
1223 for (sb = 0; sb < coded_subbands; sb++)
1229 for (sb = 0; sb < coded_subbands; sb++) {
1237 gain_vlc_tabs[10].
bits, 1);
1245 if (more_than_ref) {
1247 get_vlc2(gb, gain_vlc_tabs[9].table,
1248 gain_vlc_tabs[9].bits, 1);
1257 tab = more_than_ref ? &gain_vlc_tabs[7]
1258 : &gain_vlc_tabs[10];
1268 for (sb = 0; sb < coded_subbands; sb++)
1273 for (sb = 0; sb < coded_subbands; sb++) {
1289 for (sb = 1; sb < coded_subbands; sb++) {
1297 gain_vlc_tabs[6].
bits, 1);
1307 2 + more_than_ref + 6];
1319 for (sb = 0; sb < coded_subbands; sb++)
1331 for (sb = 0; sb < coded_subbands; sb++)
1340 for (sb = 0; sb < coded_subbands; sb++) {
1346 "Invalid gain location: ch=%d, sb=%d, pos=%d, val=%d\n",
1368 int ch_num, coded_subbands, sb,
ret;
1370 for (ch_num = 0; ch_num < num_channels; ch_num++) {
1375 coded_subbands =
get_bits(gb, 4) + 1;
1386 if (coded_subbands > 0) {
1409 int ch_num,
int band_has_tones[])
1417 if (!band_has_tones[sb])
1428 if (!band_has_tones[sb])
1450 int ch_num,
int band_has_tones[],
1461 if (band_has_tones[sb])
1466 if (band_has_tones[sb])
1469 tone_vlc_tabs[1].
bits, 1);
1473 if (band_has_tones[sb]) {
1474 delta =
get_vlc2(gb, tone_vlc_tabs[2].table,
1475 tone_vlc_tabs[2].bits, 1);
1482 if (band_has_tones[sb])
1489 if (band_has_tones[sb]) {
1492 "Too many tones: %d (max. 48), frame: %d!\n",
1514 int ch_num,
int band_has_tones[])
1516 int sb, i, direction, nbits,
pred,
delta;
1523 if (!band_has_tones[sb] || !dst[sb].num_wavs)
1528 if (dst[sb].num_wavs)
1530 for (i = dst[sb].num_wavs - 2; i >= 0 ; i--) {
1531 nbits =
av_log2(iwav[i+1].freq_index) + 1;
1535 for (i = 0; i < dst[sb].
num_wavs; i++) {
1536 if (!i || iwav[i - 1].freq_index < 512)
1539 nbits =
av_log2(1023 - iwav[i - 1].freq_index) + 1;
1541 1024 - (1 << nbits);
1548 if (!band_has_tones[sb] || !dst[sb].num_wavs)
1552 for (i = 0; i < dst[sb].
num_wavs; i++) {
1554 tone_vlc_tabs[6].
bits, 1);
1556 pred = (i < ref[sb].
num_wavs) ? iwav[i].freq_index :
1557 (ref[sb].num_wavs ? iwav[ref[sb].num_wavs - 1].freq_index : 0);
1574 int ch_num,
int band_has_tones[])
1578 int refwaves[48] = { 0 };
1584 if (!band_has_tones[sb] || !dst[sb].num_wavs)
1588 for (j = 0; j < dst[sb].
num_wavs; j++) {
1589 for (i = 0, fi = 0, maxdiff = 1024; i < ref[sb].
num_wavs; i++) {
1590 diff =
FFABS(wsrc[j].freq_index - wref[i].freq_index);
1591 if (diff < maxdiff) {
1599 else if (j < ref[sb].num_wavs)
1600 refwaves[dst[sb].start_index + j] = j + ref[sb].
start_index;
1602 refwaves[dst[sb].start_index + j] = -1;
1612 if (!band_has_tones[sb] || !dst[sb].num_wavs)
1615 for (i = 0; i < dst[sb].
num_wavs; i++)
1623 if (!band_has_tones[sb] || !dst[sb].num_wavs)
1626 for (i = 0; i < dst[sb].
num_wavs; i++)
1629 tone_vlc_tabs[3].
bits, 1) + 20;
1632 get_vlc2(gb, tone_vlc_tabs[4].table,
1633 tone_vlc_tabs[4].bits, 1) + 24;
1638 if (!band_has_tones[sb] || !dst[sb].num_wavs)
1640 for (i = 0; i < dst[sb].
num_wavs; i++) {
1642 tone_vlc_tabs[5].
bits, 1);
1652 if (!band_has_tones[sb])
1654 for (i = 0; i < dst[sb].
num_wavs; i++)
1674 int ch_num,
int band_has_tones[])
1681 if (!band_has_tones[sb])
1684 for (i = 0; i < dst[sb].
num_wavs; i++)
1685 wparam[i].phase_index =
get_bits(gb, 5);
1702 int band_has_tones[16];
1704 for (ch_num = 0; ch_num < num_channels; ch_num++)
1722 tone_vlc_tabs[0].
bits, 1) + 1;
1724 if (num_channels == 2) {
1732 for (ch_num = 0; ch_num < num_channels; ch_num++) {
1746 if (num_channels == 2) {
1769 "Invalid number of quantization units: %d!\n",
1793 if (num_channels == 2) {
static void unpack_vq_shape(int start_val, const int8_t *shape_vec, int *dst, int num_values)
Unpack vector quantization tables.
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 int get_num_ct_values(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, AVCodecContext *avctx)
Decode number of code table values.
static const uint8_t atrac3p_ct_huff_bits2[8]
const char const char void * val
#define GET_DELTA(gb, delta_bits)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
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.
uint8_t bits
number of bits a single coefficient occupy
Atrac3pWaveParam waves[48]
static const uint8_t atrac3p_huff_gain_loc2_xlat[31]
static const uint8_t atrac3p_huff_freq_cb[13]
const uint16_t ff_atrac3p_qu_to_spec_pos[33]
Map quant unit number to its position in the spectrum.
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.
uint8_t is_signed
1 - values in that table are signed ones, otherwise - absolute ones
static const uint8_t atrac3p_huff_wav_ampsf2_cb[7]
static const uint8_t atrac3p_ct_huff_code2[8]
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static const Atrac3pSpecCodeTab atrac3p_spectra_tabs[112]
static const uint8_t atrac3p_sf_huff_bits2[64]
static int decode_code_table_indexes(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx)
Decode code table indexes for each channel.
int num_tone_bands
number of PQF bands with tones
int ff_init_vlc_sparse(VLC *vlc_arg, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags)
static const uint8_t atrac3p_ct_huff_bits3[8]
int num_coded_subbands
number of subbands with coded spectrum
int table_type
table type: 0 - tone?, 1- noise?
static const uint8_t atrac3p_huff_gain_loc2_cb[8]
int num_wavs
number of sine waves in the group
static const uint8_t atrac3p_huff_gain_loc1_xlat[31]
int used_quant_units
number of quant units with coded spectrum
static const uint8_t atrac3p_huff_gain_npoints2_xlat[8]
static const uint8_t atrac3p_huff_gain_lev4_cb[11]
int lev_code[7]
level at corresponding control point
uint8_t negate_coeffs[ATRAC3P_SUBBANDS]
1 - subband-wise IMDCT coefficients negation
static const uint8_t atrac3p_ct_huff_xlat1[8]
#define ATRAC3P_SUBBANDS
Global unit sizes.
static const uint8_t atrac3p_wl_huff_code4[8]
static const uint16_t atrac3p_sf_huff_code2[64]
static VLC_TYPE tables_data[154276][2]
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static const uint8_t atrac3p_sf_huff_xlat2[64]
static double cb(void *priv, double x, double y)
static const uint8_t atrac3p_huff_gain_loc4_xlat[32]
static const uint8_t atrac3p_wl_huff_xlat2[5]
static const uint8_t atrac3p_huff_wav_ampsf2_xlat[32]
static const uint8_t atrac3p_huff_gain_loc4_cb[5]
static void gainc_level_mode3s(AtracGainInfo *dst, AtracGainInfo *ref)
Implements coding mode 3 (slave) for gain compensation levels.
int16_t spectrum[2048]
decoded IMDCT spectrum
static const uint8_t atrac3p_wl_huff_bits1[3]
static const uint8_t atrac3p_huff_gain_lev1_cb[9]
int stop_pos
stop position expressed in n*4 samples
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_wl_huff_bits3[8]
static int decode_gainc_levels(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int coded_subbands)
Decode level code for each gain control point.
int ff_atrac3p_decode_channel_unit(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx)
Decode bitstream data of a channel unit.
uint8_t num_coeffs
1 - map index to a single value, > 1 - map index to a vector of values
Parameters of a single sine wave.
Atrac3pWaveEnvelope pend_env
pending envelope from the previous frame
static const int atrac3p_subband_to_num_powgrps[16]
Map subband number to number of power compensation groups.
int qu_sf_idx[32]
array of scale factor indexes for each quant unit
bitstream reader API header.
static void decode_spectrum(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx)
Decode huffman-coded IMDCT spectrum for all channels.
int tones_index
total sum of tones in this unit
static const uint8_t atrac3p_huff_gain_lev3_cb[11]
int loc_code[7]
location of gain control points
static const uint8_t atrac3p_sf_huff_bits6[16]
uint8_t invert_phase[ATRAC3P_SUBBANDS]
1 - subband-wise phase inversion
static const uint16_t atrac3p_sf_huff_code1[64]
VLC tables for scale factor indexes.
uint8_t * wnd_shape
IMDCT window shape for current frame.
int noise_level_index
global noise level index
static const uint8_t atrac3p_qu_to_subband[32]
Map quant unit number to subband number.
static const uint8_t atrac3p_huff_freq_xlat[256]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint16_t mask[17]
static const int8_t atrac3p_sf_weights[2][32]
static void decode_tones_envelope(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int band_has_tones[])
Decode envelope for all tones of a channel.
static const uint8_t atrac3p_ct_huff_code1[4]
VLC tables for code table indexes.
static const uint8_t atrac3p_huff_gain_loc1_cb[9]
static const uint16_t atrac3p_sf_huff_code4[16]
static const struct endianess table[]
static const uint8_t atrac3p_huff_wav_ampsf3_cb[9]
Tables for spectrum coding.
Parameters of a group of sine waves.
static const uint8_t atrac3p_huff_gain_loc3_cb[7]
int noise_table_index
global noise RNG table index
static VLC wl_vlc_tabs[4]
simple assert() macros that are a bit more flexible than ISO C assert().
static VLC tone_vlc_tabs[7]
Libavcodec external API header.
int qu_wordlen[32]
array of word lengths for each quant unit
static void gainc_level_mode1m(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, AtracGainInfo *dst)
Implements coding mode 1 (master) for gain compensation levels.
int amplitude_mode
1 - low range, 0 - high range
static const uint8_t atrac3p_sf_huff_xlat1[64]
#define ATRAC3P_POWER_COMP_OFF
Global constants.
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 int get_subband_flags(GetBitContext *gb, uint8_t *out, int num_flags)
Retrieve specified amount of flag bits from the input bitstream.
static const uint8_t atrac3p_huff_gain_npoints1_cb[9]
static int decode_quant_wordlen(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx)
Decode word length information for each channel.
uint8_t group_size
number of coefficients grouped together
static const uint8_t atrac3p_sf_huff_xlat5[16]
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 const uint8_t atrac3p_qu_num_to_seg[32]
Ungroup table for word length segments.
static const uint8_t atrac3p_huff_gain_lev3_xlat[16]
static VLC ct_vlc_tabs[4]
static const uint8_t atrac3p_wl_huff_xlat1[3]
Atrac3pWavesData * tones_info
#define DEC_CT_IDX_COMMON(OP)
int use_full_table
1 - full table list, 0 - restricted one
static const uint8_t atrac3p_wl_huff_code1[3]
VLC tables for wordlen.
static const uint8_t atrac3p_ct_restricted_to_full[2][7][4]
static const uint8_t atrac3p_huff_numwavs1_cb[9]
int num_gain_subbands
number of subbands with gain control data
uint8_t swap_channels[ATRAC3P_SUBBANDS]
1 - perform subband-wise channel swapping
uint8_t tone_sharing[ATRAC3P_SUBBANDS]
1 - subband-wise tone sharing flags
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
int num_coded_vals
number of transmitted quant unit values
static const uint8_t atrac3p_sf_huff_bits1[64]
static const uint8_t atrac3p_huff_gain_loc5_xlat[32]
static const uint8_t atrac3p_huff_wav_ampsf1_xlat[32]
av_cold void ff_atrac3p_init_vlcs(void)
Initialize VLC tables for bitstream parsing.
static const uint8_t atrac3p_huff_gain_lev2_xlat[15]
#define INIT_VLC_USE_NEW_STATIC
static VLC sf_vlc_tabs[8]
static int decode_gainc_data(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx)
Decode gain control data for all channels.
static const float pred[4]
static const uint8_t atrac3p_huff_gain_loc5_cb[9]
static const uint8_t atrac3p_huff_gain_lev2_cb[11]
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static const uint8_t atrac3p_sf_huff_bits5[16]
int start_index
start index into global tones table for that subband
int freq_index
wave frequency index
Gain control parameters for one subband.
static void gainc_loc_mode1(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, AtracGainInfo *dst)
Implements coding mode 1 for gain compensation locations.
static const uint8_t atrac3p_huff_wav_ampsf3_xlat[32]
main external API structure.
static const uint8_t atrac3p_sf_huff_xlat4[16]
static const int8_t atrac3p_wl_weights[6][32]
static const uint8_t atrac3p_ct_huff_code3[8]
int amp_sf
quantized amplitude scale factor
Sound channel parameters.
static unsigned int get_bits1(GetBitContext *s)
static const uint16_t atrac3p_sf_huff_code6[16]
static const uint8_t atrac3p_huff_gain_lev4_xlat[16]
#define UNPACK_SF_VQ_SHAPE(gb, dst, num_vals)
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 int subtract_sf_weights(Atrac3pChanUnitCtx *ctx, Atrac3pChanParams *chan, int wtab_idx, AVCodecContext *avctx)
Subtract weighting coefficients from decoded scalefactors.
static av_const int sign_extend(int val, unsigned bits)
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
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 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.
int num_points
number of gain control points
static int num_coded_units(GetBitContext *gb, Atrac3pChanParams *chan, Atrac3pChanUnitCtx *ctx, AVCodecContext *avctx)
Decode number of coded quantization units.
static const uint8_t atrac3p_huff_tonebands_cb[8]
static const uint8_t atrac3p_huff_numwavs2_cb[8]
int redirect
if >= 0: tells which huffman table must be reused
int has_start_point
indicates start point within the GHA window
static const uint8_t atrac3p_huff_gain_loc3_xlat[32]
AtracGainInfo * gain_data
gain control data for next frame
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.
int has_stop_point
indicates stop point within the GHA window
static VLC spec_vlc_tabs[112]
Atrac3pWaveSynthParams * waves_info
int qu_tab_idx[32]
array of code table indexes for each quant unit
int noise_present
1 - global noise info present
static const uint8_t atrac3p_wl_huff_bits2[5]
static av_always_inline int diff(const uint32_t a, const uint32_t b)
static const uint8_t atrac3p_huff_numwavs2_xlat[8]
static const int8_t atrac3p_wl_shapes[8][16][9]
3D base shape tables.
VLC_TYPE(* table)[2]
code, bits
Atrac3pChanParams channels[2]
static int decode_scale_factors(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx)
Decode scale factor indexes for each channel.
static const uint8_t atrac3p_sf_huff_bits4[16]
static const uint8_t atrac3p_sf_huff_bits3[64]
int start_pos
start position expressed in n*4 samples
static const struct twinvq_data tab
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
static const uint8_t atrac3p_huff_wav_ampsf1_cb[7]
static const uint16_t atrac3p_sf_huff_code5[16]
static int decode_tones_info(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int num_channels, AVCodecContext *avctx)
Decode tones info for all channels.
int frame_number
Frame counter, set by libavcodec.
static const uint8_t atrac3p_ct_huff_bits1[4]
static const uint8_t atrac3p_huff_gain_lev1_xlat[16]
static void gainc_loc_mode0(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, AtracGainInfo *dst, int pos)
Implements coding mode 0 for gain compensation locations.
#define FFSWAP(type, a, b)
static const uint8_t atrac3p_wl_huff_code2[5]
int tones_present
1 - tones info present
static int decode_gainc_npoints(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int coded_subbands)
Decode number of gain control points.
uint8_t tone_master[ATRAC3P_SUBBANDS]
1 - subband-wise tone channel swapping
static const uint8_t atrac3p_wl_huff_code3[8]
Global structures, constants and data for ATRAC3+ decoder.
static VLC gain_vlc_tabs[11]
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_amplitude(GetBitContext *gb, Atrac3pChanUnitCtx *ctx, int ch_num, int band_has_tones[])
Decode amplitude information for each subband of a channel.
static const uint16_t atrac3p_sf_huff_code3[64]
uint8_t power_levs[5]
power compensation levels
static const uint8_t atrac3p_wl_huff_bits4[8]