56 const int16_t (*hcod_first_band)[2];
57 const int16_t (*hcod1D)[2];
81 for (
int off = diff_freq; off < data_bands; off++) {
98 data[0] = -sum + (2*lav + 1);
130 int16_t
offset,
int nb_pcm_data_bands,
131 int nb_quant_steps,
int nb_levels)
135 case 3: max_group_len = 5;
break;
136 case 7: max_group_len = 6;
break;
137 case 11: max_group_len = 2;
break;
138 case 13: max_group_len = 4;
break;
139 case 19: max_group_len = 4;
break;
140 case 25: max_group_len = 3;
break;
141 case 51: max_group_len = 4;
break;
142 case 4:
case 8:
case 15:
case 16:
case 26:
case 31:
151 int pcm_chunk_size[7] = { 0 };
154 for (
int i = 1;
i <= max_group_len;
i++) {
159 for (
int i = 0;
i < nb_pcm_data_bands;
i+= max_group_len) {
160 int group_len =
FFMIN(max_group_len, nb_pcm_data_bands -
i);
162 int pcm =
get_bits(gb, pcm_chunk_size[group_len]);
163 for (
int j = 0; j < group_len; j++) {
164 int idx =
i + (group_len - 1) - j;
165 int val = pcm % nb_levels;
166 if (data0 && data1) {
176 pcm = (pcm -
val) / nb_levels;
183 int diff_freq,
int freq_pair)
188 const int16_t (*hcod1D)[2];
189 const int16_t (*hcod2D)[2];
229 int16_t esc_data[2][28];
231 for (;
i < data_bands;
i +=
stride) {
233 esc_idx[esc_cnt++] =
i;
240 0, 2*esc_cnt, 0, (2*lav + 1));
241 for (
i = 0;
i < esc_cnt;
i++) {
242 data[esc_idx[
i]][0] = esc_data[0][
i] - lav;
243 data[esc_idx[
i]][1] = esc_data[1][
i] - lav;
250 int num_val,
int *time_pair)
252 int16_t pair_vec[28][2];
253 int num_val_ch[2] = { num_val, num_val };
254 int16_t *p0_data[2][2] = { 0 };
255 int df_rest_flag[2] = { 0, 0 };
265 if (diff_freq[0] || diff_freq[1]) {
266 p0_data[0][0] =
data[0];
267 p0_data[0][1] =
data[1];
276 if (!diff_freq[0] || !diff_freq[1])
279 huff_data_2d(gb, p0_data[0], pair_vec, num_val_ch[0], 1, data_type,
282 for (
int i = 0;
i < num_val_ch[0];
i++) {
283 data[0][
i] = pair_vec[
i][0];
284 data[1][
i] = pair_vec[
i][1];
289 p0_data[0][0] =
data[0];
290 p0_data[0][1] =
NULL;
295 df_rest_flag[0] = num_val_ch[0] % 2;
298 if (num_val_ch[0] < 0)
304 p0_data[1][0] =
NULL;
305 p0_data[1][1] =
data[1];
310 df_rest_flag[1] = num_val_ch[1] % 2;
313 if (num_val_ch[1] < 0)
318 huff_data_2d(gb, p0_data[0], pair_vec, num_val_ch[0], 2, data_type,
322 data_type, !diff_freq[0], 0);
325 huff_data_2d(gb, p0_data[1], pair_vec + 1, num_val_ch[1], 2, data_type,
329 data_type, !diff_freq[1], 0);
346 for (
i = 1;
i < nb_val;
i++)
351 int16_t *
out,
const int mixed_diff_type,
356 for (
int i = mixed_diff_type;
i < nb_val;
i++)
361 int16_t *
out,
const int mixed_diff_type,
366 for (
int i = mixed_diff_type;
i < nb_val;
i++)
371 int offset,
int nb_lsb,
int nb_val,
374 for (
int i = 0;
i < nb_val;
i++) {
375 int msb = data_msb[
i];
377 uint32_t lsb =
get_bits(gb, nb_lsb);
389 int pair,
int coarse,
392 int attach_lsb_flag = 0;
393 int quant_levels = 0;
394 int quant_offset = 0;
432 int16_t last_msb[28] = { 0 };
433 int16_t data_pair[2][28] = { 0 };
434 int16_t data_diff[2][28] = { 0 };
441 p_data[0] = data_pair[0];
442 p_data[1] = data_pair[1];
443 nb_pcm_vals = 2 * nb_bands;
445 p_data[0] = data_pair[0];
447 nb_pcm_vals = nb_bands;
452 case MPS_CLD: nb_quant_steps = coarse ? 15 : 31;
break;
453 case MPS_ICC: nb_quant_steps = coarse ? 4 : 8;
break;
454 case MPS_IPD: nb_quant_steps = coarse ? 8 : 16;
break;
456 pcm_decode(gb, p_data[0], p_data[1], quant_offset, nb_pcm_vals,
457 nb_quant_steps, quant_levels);
459 memcpy(&set1[start_band], data_pair[0], 2*nb_bands);
461 memcpy(&set2[start_band], data_pair[1], 2*nb_bands);
467 p_data[0] = data_diff[0];
468 p_data[1] = data_diff[1];
470 p_data[0] = data_diff[0];
474 int diff_freq[2] = { 1, 1 };
477 if (pair || diff_time_back)
480 if (pair && (diff_freq[0] || diff_time_back))
485 nb_bands, &time_pair);
488 if (!diff_freq[0] || !diff_freq[1]) {
493 if (!diff_freq[0] && !diff_time_back)
495 else if (!diff_freq[1])
505 int mixed_time_pair = (diff_freq[0] != diff_freq[1]) && time_pair;
511 for (
int i = 0;
i < nb_bands;
i++) {
512 last_msb[
i] = last[
i + start_band] + quant_offset;
513 if (attach_lsb_flag) {
518 mixed_time_pair, nb_bands);
525 data_pair[1], mixed_time_pair, nb_bands);
533 mixed_time_pair, nb_bands);
537 attach_lsb(gb, data_pair[0], quant_offset, attach_lsb_flag,
538 nb_bands, data_pair[0]);
540 attach_lsb(gb, data_pair[1], quant_offset, attach_lsb_flag,
541 nb_bands, data_pair[1]);
543 memcpy(&set1[start_band], data_pair[0], 2*nb_bands);
545 memcpy(&set2[start_band], data_pair[1], 2*nb_bands);
551 int start_band,
int end_band)
553 for (
int i = start_band;
i < end_band;
i++)
556 for (
int i = start_band;
i < end_band;
i++) {
559 else if (
data[
i] == 14)
566 int start_band,
int end_band)
568 for (
int i = start_band;
i < end_band;
i++) {
577 int start_band,
int end_band)
579 int data_bands = (end_band - start_band - 1) / band_stride + 1;
581 freq_strides[0] = start_band;
582 for (
int i = 1;
i <= data_bands;
i++)
583 freq_strides[
i] = freq_strides[
i - 1] + band_stride;
586 while (freq_strides[data_bands] > end_band) {
587 if (offs < data_bands)
589 for (
int i = offs;
i <= data_bands;
i++) {
602 int start_band,
int end_band,
int frame_indep_flag,
603 int indep_flag,
int nb_param_sets)
605 for (
int i = 0;
i < nb_param_sets;
i++) {
609 ((
i == (nb_param_sets - 1) && (ld->
data_mode[
i] == 2)))) {
618 for (
int i = 0;
i < nb_param_sets;
i++) {
620 for (
int j = start_band; j < end_band; j++)
627 }
else if (data_pair) {
646 start_band, end_band);
651 for (
int j = 0; j < data_bands; j++)
655 ld->
data[set_idx + 0], ld->
data[set_idx + 1],
656 ld->
last_data, data_type, start_band, end_band - start_band,
658 !(indep_flag && (
i == 0)) || (set_idx > 0));
664 for (
int j = 0; j < data_bands; j++)
665 for (
int k = freq_stride_map[j + 0]; k < freq_stride_map[j + 1]; k++)
668 for (
int j = 0; j < data_bands; j++)
669 for (
int k = freq_stride_map[j + 0]; k < freq_stride_map[j + 1]; k++)
670 ld->
last_data[k] = ld->
data[set_idx + data_pair][start_band + j];
678 set_idx += data_pair + 1;
690 int val_received = 0;
691 int16_t rl_data[2] = { 0 };
693 while (val_received < nb_val) {
696 len = rl_data[1] + 1;
697 if (val_received +
len > nb_val)
699 for (
int i = val_received;
i < val_received +
len;
i++)
708 int start_band,
int stop_band,
int stride)
711 int src_bands = stop_band - start_band;
712 int dst_bands = (src_bands - 1) /
stride + 1;
717 int bands_achived = dst_bands *
stride;
718 int bands_diff = src_bands - bands_achived;
719 for (
int i = 0;
i < dst_bands;
i++)
723 if (bands_diff > 0) {
731 while (bands_diff != 0) {
734 bands_diff = bands_diff + incr;
735 if (k >= dst_bands) {
736 if (bands_diff > 0) {
738 }
else if (bands_diff < 0) {
745 for (
int i = 0;
i < dst_bands;
i++)
750 int *
map,
int nb_bands)
752 for (
int i = 0;
i < nb_bands;
i++) {
754 int start_band =
map[
i];
755 int stop_band =
map[
i + 1];
756 for (
int j = start_band; j < stop_band; j++) {
768 if (((
value + 15) >= 0) && ((
value + 15) < 31))
789 int default_value,
int start_band,
int stop_band,
790 int nb_param_sets,
const int *param_set_idx,
797 int nb_data_mode_3 = 0;
798 for (
int i = 0;
i < nb_param_sets;
i++) {
800 data_mode_3_idx[nb_data_mode_3] =
i;
810 for (
int i = 0;
i < nb_param_sets;
i++) {
813 for (
int band = start_band; band < stop_band; band++)
814 tmp_idx_data[
i][band] = default_value;
815 for (
int band = start_band; band < stop_band; band++)
821 for (
int band = start_band; band < stop_band; band++)
827 for (
int band = start_band; band < stop_band; band++)
838 int parmSlot = data_mode_3_idx[set_idx];
840 int dataBands = (stop_band - start_band - 1) /
stride + 1;
847 for (
int band = start_band; band < stop_band; band++)
848 ld->
last_data[band] = tmp_idx_data[parmSlot][band];
858 for (
int i = 0;
i < nb_param_sets;
i++) {
868 for (
int i = 0;
i < nb_param_sets;
i++) {
874 for (i2 =
i; i2 < nb_param_sets; i2++)
877 if (i2 >= nb_param_sets)
880 x1 = param_set_idx[i1];
881 xi = param_set_idx[
i];
882 x2 = param_set_idx[i2];
884 for (
int band = start_band; band < stop_band; band++) {
886 y1 = tmp_idx_data[i1][band];
887 y2 = tmp_idx_data[i2][band];
889 yi = y1 + (
xi - x1) * (y2 - y1) / (x2 - x1);
893 tmp_idx_data[
i][band] = yi;
899 for (
int ps = 0; ps < nb_param_sets; ps++) {
901 for (
int band = start_band; band < stop_band; band++) {
902 dst_idx[ps][band] =
deq_idx(tmp_idx_data[ps][band],
904 if (dst_idx[ps][band] == -1)
905 dst_idx[ps][band] = default_value;
912 for (
int band = start_band; band < stop_band; band++)
913 dst_idx[nb_param_sets][band] = dst_idx[nb_param_sets - 1][band];
#define MPS_MAX_PARAM_SETS
#define MPS_MAX_PARAM_BANDS
const int16_t ff_aac_hcod_firstband_ICC[7][2]
const int16_t ff_aac_hcod2D_IPD_03[2][2][15][2]
const int16_t ff_aac_hcod2D_ICC_05[2][2][35][2]
const int16_t ff_aac_hcod_firstband_IPD[7][2]
const int16_t ff_aac_hcod2D_IPD_05[2][2][35][2]
const int16_t ff_aac_hcod2D_ICC_07[2][2][63][2]
const uint8_t ff_aac_lav_tab_XXX[3][4]
const int16_t ff_aac_hcod2D_IPD_01[2][2][3][2]
const int16_t ff_aac_hcod_firstband_CLD[30][2]
const int16_t ff_aac_hcod2D_ICC_01[2][2][3][2]
const int16_t ff_aac_hcod2D_ICC_03[2][2][15][2]
const int16_t ff_aac_hcod1D_IPD[2][7][2]
const int16_t ff_aac_hcod1D_ICC[7][2]
const int16_t ff_aac_hcod_lav_idx[3][2]
const int16_t ff_aac_hcod2D_CLD_05[2][2][35][2]
const int16_t ff_aac_hcod1D_CLD[2][30][2]
const int16_t ff_aac_hcod2D_CLD_03[2][2][15][2]
const int16_t ff_aac_hcod2D_reshape[39][2]
const int16_t ff_aac_hcod2D_CLD_07[2][2][63][2]
const int16_t ff_aac_hcod2D_CLD_09[2][2][99][2]
const int16_t ff_aac_hcod2D_IPD_07[2][2][63][2]
static void pcm_decode(GetBitContext *gb, int16_t *data0, int16_t *data1, int16_t offset, int nb_pcm_data_bands, int nb_quant_steps, int nb_levels)
static void diff_time_decode_backwards(const int16_t *prev, const int16_t *diff, int16_t *out, const int mixed_diff_type, const int nb_val)
static const int stride_table[4]
static void diff_time_decode_forwards(const int16_t *prev, const int16_t *diff, int16_t *out, const int mixed_diff_type, const int nb_val)
static void diff_freq_decode(const int16_t *diff, int16_t *out, int nb_val)
static void symmetry_data(GetBitContext *gb, int16_t data[2], uint8_t lav, enum AACMPSDataType data_type)
static void create_mapping(int map[MPS_MAX_PARAM_BANDS+1], int start_band, int stop_band, int stride)
int ff_aac_ec_data_dec(GetBitContext *gb, AACMPSLosslessData *ld, enum AACMPSDataType data_type, int default_val, int start_band, int end_band, int frame_indep_flag, int indep_flag, int nb_param_sets)
static int huff_dec_1D(GetBitContext *gb, const int16_t(*tab)[2])
static void coarse_to_fine(int16_t *data, enum AACMPSDataType data_type, int start_band, int end_band)
static void huff_data_2d(GetBitContext *gb, int16_t *part0_data[2], int16_t(*data)[2], int data_bands, int stride, enum AACMPSDataType data_type, int diff_freq, int freq_pair)
static void fine_to_coarse(int16_t *data, enum AACMPSDataType data_type, int start_band, int end_band)
static int mps_log2(int s)
static int ec_pair_dec(GetBitContext *gb, int16_t set1[MPS_MAX_PARAM_BANDS], int16_t set2[MPS_MAX_PARAM_BANDS], int16_t *last, enum AACMPSDataType data_type, int start_band, int nb_bands, int pair, int coarse, int diff_time_back)
static int huff_decode(GetBitContext *gb, int16_t *data[2], enum AACMPSDataType data_type, int diff_freq[2], int num_val, int *time_pair)
int ff_aac_huff_dec_reshape(GetBitContext *gb, int16_t *out_data, int nb_val)
int ff_aac_map_index_data(AACMPSLosslessData *ld, enum AACMPSDataType data_type, int dst_idx[MPS_MAX_PARAM_SETS][MPS_MAX_PARAM_BANDS], int default_value, int start_band, int stop_band, int nb_param_sets, const int *param_set_idx, int extend_frame)
static int huff_data_1d(GetBitContext *gb, int16_t *data, int data_bands, enum AACMPSDataType data_type, int diff_freq, int p0_flag)
static void attach_lsb(GetBitContext *gb, int16_t *data_msb, int offset, int nb_lsb, int nb_val, int16_t *data)
static void map_freq(int16_t *dst, const int16_t *src, int *map, int nb_bands)
static int get_freq_strides(int16_t *freq_strides, int band_stride, int start_band, int end_band)
static int huff_dec_2D(GetBitContext *gb, const int16_t(*tab)[2], int16_t ret[2])
static int deq_idx(int value, enum AACMPSDataType data_type)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static double val(void *priv, double ch)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
#define i(width, name, range_min, range_max)
#define xi(width, name, var, range_min, range_max, subs,...)
bitstream reader API header.
static unsigned int get_bits1(GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
const VDPAUPixFmtMap * map
static const uint16_t mask[17]
Utility Preprocessor macros.
#define FFSWAP(type, a, b)
int16_t data[MPS_MAX_PARAM_SETS][MPS_MAX_PARAM_BANDS]
int16_t freq_res[MPS_MAX_PARAM_SETS]
int16_t data_mode[MPS_MAX_PARAM_SETS]
int16_t last_data[MPS_MAX_PARAM_BANDS]
int16_t coarse_quant_no[MPS_MAX_PARAM_SETS]
bool coarse_quant[MPS_MAX_PARAM_SETS]
static void interpolate(float *out, float v1, float v2, int size)
static const struct twinvq_data tab
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)