Lines Matching refs:gb

120  * @param[in]     gb            the GetBit context
126 static int num_coded_units(GetBitContext *gb, Atrac3pChanParams *chan,
129 chan->fill_mode = get_bits(gb, 2);
133 chan->num_coded_vals = get_bits(gb, 5);
141 chan->split_point = get_bits(gb, 2) + (chan->ch_num << 1) + 1;
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], \
234 * @param[in] gb the GetBit context
240 static int decode_channel_wordlen(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
251 switch (get_bits(gb, 2)) { /* switch according to coding mode */
254 chan->qu_wordlen[i] = get_bits(gb, 3);
258 if ((ret = num_coded_units(gb, chan, ctx, avctx)) < 0)
262 vlc_tab = &wl_vlc_tabs[get_bits(gb, 2)];
265 delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
270 weight_idx = get_bits(gb, 2);
271 if ((ret = num_coded_units(gb, chan, ctx, avctx)) < 0)
275 pos = get_bits(gb, 5);
282 delta_bits = get_bits(gb, 2);
283 min_val = get_bits(gb, 3);
286 chan->qu_wordlen[i] = get_bits(gb, 3);
289 chan->qu_wordlen[i] = (min_val + get_bitsz(gb, delta_bits)) & 7;
294 if ((ret = num_coded_units(gb, chan, ctx, avctx)) < 0)
298 vlc_tab = &wl_vlc_tabs[get_bits(gb, 2)];
299 delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
304 delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
308 flag = get_bits(gb, 1);
309 vlc_tab = &wl_vlc_tabs[get_bits(gb, 1)];
311 start_val = get_bits(gb, 3);
313 &atrac3p_wl_shapes[start_val][get_bits(gb, 4)][0],
318 delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
323 if (!get_bits1(gb)) {
325 get_vlc2(gb, vlc_tab->table,
328 get_vlc2(gb, vlc_tab->table,
334 get_vlc2(gb, vlc_tab->table,
340 weight_idx = get_bits(gb, 2);
341 if ((ret = num_coded_units(gb, chan, ctx, avctx)) < 0)
345 vlc_tab = &wl_vlc_tabs[get_bits(gb, 2)];
348 chan->qu_wordlen[0] = get_bits(gb, 3);
351 delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
360 chan->qu_wordlen[i] = ch_num ? get_bits1(gb) : 1;
381 * @param[in] gb the GetBit context
387 static int decode_channel_sf_idx(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
396 switch (get_bits(gb, 2)) { /* switch according to coding mode */
399 chan->qu_sf_idx[i] = get_bits(gb, 6);
403 vlc_tab = &sf_vlc_tabs[get_bits(gb, 2)];
406 delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
410 weight_idx = get_bits(gb, 2);
412 UNPACK_SF_VQ_SHAPE(gb, chan->qu_sf_idx, ctx->used_quant_units);
414 num_long_vals = get_bits(gb, 5);
415 delta_bits = get_bits(gb, 2);
416 min_val = get_bits(gb, 4) - 7;
420 get_bits(gb, 4) - 7) & 0x3F;
425 get_bitsz(gb, delta_bits)) & 0x3F;
427 num_long_vals = get_bits(gb, 5);
428 delta_bits = get_bits(gb, 3);
429 min_val = get_bits(gb, 6);
438 chan->qu_sf_idx[i] = get_bits(gb, 6);
443 get_bitsz(gb, delta_bits)) & 0x3F;
449 vlc_tab = &sf_vlc_tabs[get_bits(gb, 2)];
451 delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
456 delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
460 vlc_tab = &sf_vlc_tabs[get_bits(gb, 2) + 4];
462 UNPACK_SF_VQ_SHAPE(gb, chan->qu_sf_idx, ctx->used_quant_units);
465 delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
477 weight_idx = get_bits(gb, 2);
478 vlc_sel = get_bits(gb, 2);
484 UNPACK_SF_VQ_SHAPE(gb, chan->qu_sf_idx, ctx->used_quant_units);
486 diff = (get_bits(gb, 4) + 56) & 0x3F;
490 delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
496 chan->qu_sf_idx[0] = get_bits(gb, 6);
499 delta = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
516 * @param[in] gb the GetBit context
522 static int decode_quant_wordlen(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
531 if ((ret = decode_channel_wordlen(gb, ctx, ch_num, avctx)) < 0)
549 * @param[in] gb the GetBit context
555 static int decode_scale_factors(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
567 if ((ret = decode_channel_sf_idx(gb, ctx, ch_num, avctx)) < 0)
577 * @param[in] gb the GetBit context
582 static int get_num_ct_values(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
587 if (get_bits1(gb)) {
588 num_coded_vals = get_bits(gb, 5);
600 num_vals = get_num_ct_values(gb, ctx, avctx); \
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)
618 : (pred + get_vlc2(gb, delta_vlc->table, \
624 get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1)) & mask
629 * @param[in] gb the GetBit context
635 static int decode_channel_code_tab(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
644 chan->table_type = get_bits1(gb);
646 switch (get_bits(gb, 2)) { /* switch according to coding mode */
682 * @param[in] gb the GetBit context
688 static int decode_code_table_indexes(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
696 ctx->use_full_table = get_bits1(gb);
702 if ((ret = decode_channel_code_tab(gb, ctx, ch_num, avctx)) < 0)
715 * @param[in] gb the GetBit context
721 static void decode_qu_spectra(GetBitContext *gb, const Atrac3pSpecCodeTab *tab,
732 if (group_size == 1 || get_bits1(gb)) {
734 val = get_vlc2(gb, vlc_tab->table, vlc_tab->bits, 1);
740 else if (cf && get_bits1(gb))
755 * @param[in] gb the GetBit context
760 static void decode_spectrum(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
788 decode_qu_spectra(gb, tab, &spec_vlc_tabs[tab_index],
808 chan->power_levs[i] = get_bits(gb, 4);
821 * @param[in] gb ptr to the GetBitContext
826 static int get_subband_flags(GetBitContext *gb, uint8_t *out, int num_flags)
832 result = get_bits1(gb);
834 if (get_bits1(gb))
836 out[i] = get_bits1(gb);
847 * @param[in] gb the GetBit context
851 static void decode_window_shape(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
857 get_subband_flags(gb, ctx->channels[ch_num].wnd_shape,
864 * @param[in] gb the GetBit context
870 static int decode_gainc_npoints(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
877 switch (get_bits(gb, 2)) { /* switch according to coding mode */
880 chan->gain_data[i].num_points = get_bits(gb, 3);
885 get_vlc2(gb, gain_vlc_tabs[0].table,
891 delta = get_vlc2(gb, gain_vlc_tabs[1].table,
898 get_vlc2(gb, gain_vlc_tabs[0].table,
902 delta = get_vlc2(gb, gain_vlc_tabs[1].table,
915 delta_bits = get_bits(gb, 2);
916 min_val = get_bits(gb, 3);
919 chan->gain_data[i].num_points = min_val + get_bitsz(gb, delta_bits);
946 * @param[in] gb the GetBit context
950 static inline void gainc_level_mode1m(GetBitContext *gb,
957 dst->lev_code[0] = get_vlc2(gb, gain_vlc_tabs[2].table,
961 delta = get_vlc2(gb, gain_vlc_tabs[3].table,
970 * @param[in] gb the GetBit context
976 static int decode_gainc_levels(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
983 switch (get_bits(gb, 2)) { /* switch according to coding mode */
987 chan->gain_data[sb].lev_code[i] = get_bits(gb, 4);
993 delta = get_vlc2(gb, gain_vlc_tabs[5].table,
1001 gainc_level_mode1m(gb, ctx, &chan->gain_data[sb]);
1008 if (get_bits1(gb))
1009 gainc_level_mode1m(gb, ctx, &chan->gain_data[sb]);
1016 gainc_level_mode1m(gb, ctx, &chan->gain_data[0]);
1020 delta = get_vlc2(gb, gain_vlc_tabs[4].table,
1034 delta_bits = get_bits(gb, 2);
1035 min_val = get_bits(gb, 4);
1039 chan->gain_data[sb].lev_code[i] = min_val + get_bitsz(gb, delta_bits);
1053 * @param[in] gb the GetBit context
1058 static inline void gainc_loc_mode0(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
1064 dst->loc_code[pos] = get_bits(gb, 5);
1070 get_bits(gb, delta_bits) + 1;
1077 * @param[in] gb the GetBit context
1081 static inline void gainc_loc_mode1(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
1089 dst->loc_code[0] = get_bits(gb, 5);
1098 get_vlc2(gb, tab->table, tab->bits, 1);
1106 * @param[in] gb the GetBit context
1113 static int decode_gainc_loc_codes(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
1123 switch (get_bits(gb, 2)) { /* switch according to coding mode */
1127 gainc_loc_mode0(gb, ctx, &chan->gain_data[sb], i);
1138 delta = get_vlc2(gb, gain_vlc_tabs[10].table,
1149 get_vlc2(gb, gain_vlc_tabs[9].table,
1153 if (get_bits1(gb))
1154 gainc_loc_mode0(gb, ctx, dst, i); // direct coding
1161 delta = get_vlc2(gb, tab->table, tab->bits, 1);
1171 gainc_loc_mode1(gb, ctx, &chan->gain_data[sb]);
1180 if (dst->num_points > ref->num_points || get_bits1(gb))
1181 gainc_loc_mode1(gb, ctx, dst);
1189 gainc_loc_mode0(gb, ctx, &chan->gain_data[0], i);
1198 delta = get_vlc2(gb, gain_vlc_tabs[6].table,
1210 delta = get_vlc2(gb, tab->table, tab->bits, 1);
1224 gainc_loc_mode0(gb, ctx, &chan->gain_data[sb], i);
1230 delta_bits = get_bits(gb, 2) + 1;
1231 min_val = get_bits(gb, 5);
1236 get_bits(gb, delta_bits);
1261 * @param[in] gb the GetBit context
1267 static int decode_gainc_data(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
1276 if (get_bits1(gb)) { /* gain control data present? */
1277 coded_subbands = get_bits(gb, 4) + 1;
1278 if (get_bits1(gb)) /* is high band gain data replication on? */
1279 ctx->channels[ch_num].num_gain_subbands = get_bits(gb, 4) + 1;
1283 if ((ret = decode_gainc_npoints(gb, ctx, ch_num, coded_subbands)) < 0 ||
1284 (ret = decode_gainc_levels(gb, ctx, ch_num, coded_subbands)) < 0 ||
1285 (ret = decode_gainc_loc_codes(gb, ctx, ch_num, coded_subbands, avctx)) < 0)
1304 * @param[in] gb the GetBit context
1310 static void decode_tones_envelope(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
1317 if (!ch_num || !get_bits1(gb)) { /* mode 0: fixed-length coding */
1321 dst[sb].pend_env.has_start_point = get_bits1(gb);
1323 ? get_bits(gb, 5) : -1;
1324 dst[sb].pend_env.has_stop_point = get_bits1(gb);
1326 ? get_bits(gb, 5) : 32;
1343 * @param[in] gb the GetBit context
1351 static int decode_band_numwavs(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
1359 mode = get_bits(gb, ch_num + 1);
1364 dst[sb].num_wavs = get_bits(gb, 4);
1370 get_vlc2(gb, tone_vlc_tabs[1].table,
1376 delta = get_vlc2(gb, tone_vlc_tabs[2].table,
1409 * @param[in] gb the GetBit context
1415 static void decode_tones_frequency(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
1423 if (!ch_num || !get_bits1(gb)) { /* mode 0: fixed-length coding */
1428 direction = (dst[sb].num_wavs > 1) ? get_bits1(gb) : 0;
1431 iwav[dst[sb].num_wavs - 1].freq_index = get_bits(gb, 10);
1434 iwav[i].freq_index = get_bits(gb, nbits);
1439 iwav[i].freq_index = get_bits(gb, 10);
1442 iwav[i].freq_index = get_bits(gb, nbits) +
1455 delta = get_vlc2(gb, tone_vlc_tabs[6].table,
1469 * @param[in] gb the GetBit context
1475 static void decode_tones_amplitude(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
1509 mode = get_bits(gb, ch_num + 1);
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);
1530 get_vlc2(gb, tone_vlc_tabs[3].table,
1534 get_vlc2(gb, tone_vlc_tabs[4].table,
1543 delta = get_vlc2(gb, tone_vlc_tabs[5].table,
1569 * @param[in] gb the GetBit context
1575 static void decode_tones_phase(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
1587 wparam[i].phase_index = get_bits(gb, 5);
1594 * @param[in] gb the GetBit context
1600 static int decode_tones_info(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
1610 ctx->waves_info->tones_present = get_bits1(gb);
1616 ctx->waves_info->amplitude_mode = get_bits1(gb);
1623 get_vlc2(gb, tone_vlc_tabs[0].table,
1627 get_subband_flags(gb, ctx->waves_info->tone_sharing, ctx->waves_info->num_tone_bands);
1628 get_subband_flags(gb, ctx->waves_info->tone_master, ctx->waves_info->num_tone_bands);
1629 get_subband_flags(gb, ctx->waves_info->invert_phase, ctx->waves_info->num_tone_bands);
1638 decode_tones_envelope(gb, ctx, ch_num, band_has_tones);
1639 if ((ret = decode_band_numwavs(gb, ctx, ch_num, band_has_tones,
1643 decode_tones_frequency(gb, ctx, ch_num, band_has_tones);
1644 decode_tones_amplitude(gb, ctx, ch_num, band_has_tones);
1645 decode_tones_phase(gb, ctx, ch_num, band_has_tones);
1662 int ff_atrac3p_decode_channel_unit(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
1668 ctx->num_quant_units = get_bits(gb, 5) + 1;
1676 ctx->mute_flag = get_bits1(gb);
1679 if ((ret = decode_quant_wordlen(gb, ctx, num_channels, avctx)) < 0)
1687 if ((ret = decode_scale_factors(gb, ctx, num_channels, avctx)) < 0)
1690 if ((ret = decode_code_table_indexes(gb, ctx, num_channels, avctx)) < 0)
1693 decode_spectrum(gb, ctx, num_channels, avctx);
1696 get_subband_flags(gb, ctx->swap_channels, ctx->num_coded_subbands);
1697 get_subband_flags(gb, ctx->negate_coeffs, ctx->num_coded_subbands);
1700 decode_window_shape(gb, ctx, num_channels);
1702 if ((ret = decode_gainc_data(gb, ctx, num_channels, avctx)) < 0)
1705 if ((ret = decode_tones_info(gb, ctx, num_channels, avctx)) < 0)
1709 ctx->noise_present = get_bits1(gb);
1711 ctx->noise_level_index = get_bits(gb, 4);
1712 ctx->noise_table_index = get_bits(gb, 4);