Lines Matching refs:bd
594 static int read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
600 if (bd->block_length <= 0)
603 *bd->raw_samples = 0;
604 *bd->const_block = get_bits1(gb); // 1 = constant value, 0 = zero block (silence)
605 bd->js_blocks = get_bits1(gb);
610 if (*bd->const_block) {
612 *bd->raw_samples = get_sbits_long(gb, const_val_bits);
616 *bd->const_block = 1;
624 static void decode_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
626 int smp = bd->block_length - 1;
627 int32_t val = *bd->raw_samples;
628 int32_t *dst = bd->raw_samples + 1;
638 static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
650 int32_t *quant_cof = bd->quant_cof;
655 *bd->const_block = 0;
657 *bd->opt_order = 1;
658 bd->js_blocks = get_bits1(gb);
660 opt_order = *bd->opt_order;
676 if (bd->block_length & (sub_blocks - 1) || bd->block_length <= 0) {
682 sb_length = bd->block_length >> log2_sub_blocks;
705 *bd->shift_lsbs = get_bits(gb, 4) + 1;
707 *bd->store_prev_samples = (bd->js_blocks && bd->raw_other) || *bd->shift_lsbs;
712 int opt_order_length = av_ceil_log2(av_clip((bd->block_length >> 3) - 1,
714 *bd->opt_order = get_bits(gb, opt_order_length);
715 if (*bd->opt_order > sconf->max_order) {
716 *bd->opt_order = sconf->max_order;
721 *bd->opt_order = sconf->max_order;
723 opt_order = *bd->opt_order;
781 *bd->use_ltp = get_bits1(gb);
783 if (*bd->use_ltp) {
786 bd->ltp_gain[0] = decode_rice(gb, 1) * 8;
787 bd->ltp_gain[1] = decode_rice(gb, 2) * 8;
796 bd->ltp_gain[2] = ltp_gain_values[r][c];
798 bd->ltp_gain[3] = decode_rice(gb, 2) * 8;
799 bd->ltp_gain[4] = decode_rice(gb, 1) * 8;
801 *bd->ltp_lag = get_bits(gb, ctx->ltp_lag_length);
802 *bd->ltp_lag += FFMAX(4, opt_order + 1);
807 if (bd->ra_block) {
817 bd->raw_samples[0] = decode_rice(gb, avctx->bits_per_raw_sample - 4);
819 bd->raw_samples[1] = decode_rice(gb, FFMIN(s[0] + 3, ctx->s_max));
821 bd->raw_samples[2] = decode_rice(gb, FFMIN(s[0] + 1, ctx->s_max));
828 unsigned int b = av_clip((av_ceil_log2(bd->block_length) - 3) >> 1, 0, 5);
839 current_res = bd->raw_samples + start;
860 current_res = bd->raw_samples + start;
900 current_res = bd->raw_samples + start;
913 static int decode_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
916 unsigned int block_length = bd->block_length;
919 int opt_order = *bd->opt_order;
922 int32_t *quant_cof = bd->quant_cof;
923 int32_t *lpc_cof = bd->lpc_cof;
924 int32_t *raw_samples = bd->raw_samples;
925 int32_t *raw_samples_end = bd->raw_samples + bd->block_length;
929 if (*bd->use_ltp) {
932 for (ltp_smp = FFMAX(*bd->ltp_lag - 2, 0); ltp_smp < block_length; ltp_smp++) {
933 int center = ltp_smp - *bd->ltp_lag;
942 y += (uint64_t)MUL64(bd->ltp_gain[tab], raw_samples[base]);
949 if (bd->ra_block) {
964 if (*bd->store_prev_samples)
965 memcpy(bd->prev_raw_samples, raw_samples - sconf->max_order,
966 sizeof(*bd->prev_raw_samples) * sconf->max_order);
969 if (bd->js_blocks && bd->raw_other) {
972 if (bd->raw_other > raw_samples) { // D = R - L
974 right = bd->raw_other;
976 left = bd->raw_other;
985 if (*bd->shift_lsbs)
987 raw_samples[sb] >>= *bd->shift_lsbs;
997 raw_samples = bd->raw_samples + smp;
1009 raw_samples = bd->raw_samples;
1012 if (*bd->store_prev_samples)
1013 memcpy(raw_samples - sconf->max_order, bd->prev_raw_samples,
1022 static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
1028 *bd->shift_lsbs = 0;
1035 ret = read_var_block_data(ctx, bd);
1037 ret = read_const_block_data(ctx, bd);
1049 static int decode_block(ALSDecContext *ctx, ALSBlockData *bd)
1055 if (*bd->const_block)
1056 decode_const_block_data(ctx, bd);
1058 ret = decode_var_block_data(ctx, bd); // always return 0
1065 if (*bd->shift_lsbs)
1066 for (smp = 0; smp < bd->block_length; smp++)
1067 bd->raw_samples[smp] = (unsigned)bd->raw_samples[smp] << *bd->shift_lsbs;
1075 static int read_decode_block(ALSDecContext *ctx, ALSBlockData *bd)
1079 if ((ret = read_block(ctx, bd)) < 0)
1082 return decode_block(ctx, bd);
1110 ALSBlockData bd = { 0 };
1112 bd.ra_block = ra_frame;
1113 bd.const_block = ctx->const_block;
1114 bd.shift_lsbs = ctx->shift_lsbs;
1115 bd.opt_order = ctx->opt_order;
1116 bd.store_prev_samples = ctx->store_prev_samples;
1117 bd.use_ltp = ctx->use_ltp;
1118 bd.ltp_lag = ctx->ltp_lag;
1119 bd.ltp_gain = ctx->ltp_gain[0];
1120 bd.quant_cof = ctx->quant_cof[0];
1121 bd.lpc_cof = ctx->lpc_cof[0];
1122 bd.prev_raw_samples = ctx->prev_raw_samples;
1123 bd.raw_samples = ctx->raw_samples[c];
1127 bd.block_length = div_blocks[b];
1129 if ((ret = read_decode_block(ctx, &bd)) < 0) {
1131 zero_remaining(b, ctx->num_blocks, div_blocks, bd.raw_samples);
1134 bd.raw_samples += div_blocks[b];
1135 bd.ra_block = 0;
1152 ALSBlockData bd[2] = { { 0 } };
1154 bd[0].ra_block = ra_frame;
1155 bd[0].const_block = ctx->const_block;
1156 bd[0].shift_lsbs = ctx->shift_lsbs;
1157 bd[0].opt_order = ctx->opt_order;
1158 bd[0].store_prev_samples = ctx->store_prev_samples;
1159 bd[0].use_ltp = ctx->use_ltp;
1160 bd[0].ltp_lag = ctx->ltp_lag;
1161 bd[0].ltp_gain = ctx->ltp_gain[0];
1162 bd[0].quant_cof = ctx->quant_cof[0];
1163 bd[0].lpc_cof = ctx->lpc_cof[0];
1164 bd[0].prev_raw_samples = ctx->prev_raw_samples;
1165 bd[0].js_blocks = *js_blocks;
1167 bd[1].ra_block = ra_frame;
1168 bd[1].const_block = ctx->const_block;
1169 bd[1].shift_lsbs = ctx->shift_lsbs;
1170 bd[1].opt_order = ctx->opt_order;
1171 bd[1].store_prev_samples = ctx->store_prev_samples;
1172 bd[1].use_ltp = ctx->use_ltp;
1173 bd[1].ltp_lag = ctx->ltp_lag;
1174 bd[1].ltp_gain = ctx->ltp_gain[0];
1175 bd[1].quant_cof = ctx->quant_cof[0];
1176 bd[1].lpc_cof = ctx->lpc_cof[0];
1177 bd[1].prev_raw_samples = ctx->prev_raw_samples;
1178 bd[1].js_blocks = *(js_blocks + 1);
1184 bd[0].block_length = div_blocks[b];
1185 bd[1].block_length = div_blocks[b];
1187 bd[0].raw_samples = ctx->raw_samples[c ] + offset;
1188 bd[1].raw_samples = ctx->raw_samples[c + 1] + offset;
1190 bd[0].raw_other = bd[1].raw_samples;
1191 bd[1].raw_other = bd[0].raw_samples;
1193 if ((ret = read_decode_block(ctx, &bd[0])) < 0 ||
1194 (ret = read_decode_block(ctx, &bd[1])) < 0)
1198 if (bd[0].js_blocks) {
1199 if (bd[1].js_blocks)
1203 bd[0].raw_samples[s] = bd[1].raw_samples[s] - (unsigned)bd[0].raw_samples[s];
1204 } else if (bd[1].js_blocks) {
1206 bd[1].raw_samples[s] = bd[1].raw_samples[s] + (unsigned)bd[0].raw_samples[s];
1210 bd[0].ra_block = 0;
1211 bd[1].ra_block = 0;
1223 zero_remaining(b, ctx->num_blocks, div_blocks, bd[0].raw_samples);
1224 zero_remaining(b, ctx->num_blocks, div_blocks, bd[1].raw_samples);
1284 static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
1299 revert_channel_correlation(ctx, bd, cd, reverted, offset,
1310 bd->const_block = ctx->const_block + c;
1311 bd->shift_lsbs = ctx->shift_lsbs + c;
1312 bd->opt_order = ctx->opt_order + c;
1313 bd->store_prev_samples = ctx->store_prev_samples + c;
1314 bd->use_ltp = ctx->use_ltp + c;
1315 bd->ltp_lag = ctx->ltp_lag + c;
1316 bd->ltp_gain = ctx->ltp_gain[c];
1317 bd->lpc_cof = ctx->lpc_cof[c];
1318 bd->quant_cof = ctx->quant_cof[c];
1319 bd->raw_samples = ctx->raw_samples[c] + offset;
1324 ptrdiff_t end = bd->block_length - 1;
1367 bd->raw_samples[smp] += y >> 7;
1386 bd->raw_samples[smp] += y >> 7;
1701 ALSBlockData bd = { 0 };
1714 bd.ra_block = ra_frame;
1715 bd.prev_raw_samples = ctx->prev_raw_samples;
1720 bd.block_length = div_blocks[b];
1721 if (bd.block_length <= 0) {
1724 bd.block_length);
1729 bd.const_block = ctx->const_block + c;
1730 bd.shift_lsbs = ctx->shift_lsbs + c;
1731 bd.opt_order = ctx->opt_order + c;
1732 bd.store_prev_samples = ctx->store_prev_samples + c;
1733 bd.use_ltp = ctx->use_ltp + c;
1734 bd.ltp_lag = ctx->ltp_lag + c;
1735 bd.ltp_gain = ctx->ltp_gain[c];
1736 bd.lpc_cof = ctx->lpc_cof[c];
1737 bd.quant_cof = ctx->quant_cof[c];
1738 bd.raw_samples = ctx->raw_samples[c] + offset;
1739 bd.raw_other = NULL;
1741 if ((ret = read_block(ctx, &bd)) < 0)
1748 ret = revert_channel_correlation(ctx, &bd, ctx->chan_data,
1754 bd.const_block = ctx->const_block + c;
1755 bd.shift_lsbs = ctx->shift_lsbs + c;
1756 bd.opt_order = ctx->opt_order + c;
1757 bd.store_prev_samples = ctx->store_prev_samples + c;
1758 bd.use_ltp = ctx->use_ltp + c;
1759 bd.ltp_lag = ctx->ltp_lag + c;
1760 bd.ltp_gain = ctx->ltp_gain[c];
1761 bd.lpc_cof = ctx->lpc_cof[c];
1762 bd.quant_cof = ctx->quant_cof[c];
1763 bd.raw_samples = ctx->raw_samples[c] + offset;
1765 if ((ret = decode_block(ctx, &bd)) < 0)
1773 bd.ra_block = 0;