ref: 7b098ae8c62f5910a748d57530b3ce4568ed5eb5
parent: d28e6a3a2e81d09df3ab7d078e9b77d1b8cbee46
author: Henrik Gramner <gramner@twoorioles.com>
date: Fri Feb 15 08:51:12 EST 2019
Add a dav1d prefix to global msac symbols
--- a/src/decode.c
+++ b/src/decode.c
@@ -79,15 +79,18 @@
Dav1dTileState *const ts = t->ts;
const Dav1dFrameContext *const f = t->f;
const int have_hp = f->frame_hdr->hp;
- const int sign = msac_decode_bool_adapt(&ts->msac, mv_comp->sign);
- const int cl = msac_decode_symbol_adapt(&ts->msac, mv_comp->classes, 11);
+ const int sign = dav1d_msac_decode_bool_adapt(&ts->msac, mv_comp->sign);
+ const int cl = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ mv_comp->classes, 11);
int up, fp, hp;
if (!cl) {
- up = msac_decode_bool_adapt(&ts->msac, mv_comp->class0);
+ up = dav1d_msac_decode_bool_adapt(&ts->msac, mv_comp->class0);
if (have_fp) {
- fp = msac_decode_symbol_adapt(&ts->msac, mv_comp->class0_fp[up], 4);
- hp = have_hp ? msac_decode_bool_adapt(&ts->msac, mv_comp->class0_hp) : 1;
+ fp = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ mv_comp->class0_fp[up], 4);
+ hp = have_hp ? dav1d_msac_decode_bool_adapt(&ts->msac,
+ mv_comp->class0_hp) : 1;
} else {
fp = 3;
hp = 1;
@@ -95,10 +98,13 @@
} else {
up = 1 << cl;
for (int n = 0; n < cl; n++)
- up |= msac_decode_bool_adapt(&ts->msac, mv_comp->classN[n]) << n;
+ up |= dav1d_msac_decode_bool_adapt(&ts->msac,
+ mv_comp->classN[n]) << n;
if (have_fp) {
- fp = msac_decode_symbol_adapt(&ts->msac, mv_comp->classN_fp, 4);
- hp = have_hp ? msac_decode_bool_adapt(&ts->msac, mv_comp->classN_hp) : 1;
+ fp = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ mv_comp->classN_fp, 4);
+ hp = have_hp ? dav1d_msac_decode_bool_adapt(&ts->msac,
+ mv_comp->classN_hp) : 1;
} else {
fp = 3;
hp = 1;
@@ -113,7 +119,9 @@
static void read_mv_residual(Dav1dTileContext *const t, mv *const ref_mv,
CdfMvContext *const mv_cdf, const int have_fp)
{
- switch (msac_decode_symbol_adapt(&t->ts->msac, t->ts->cdf.mv.joint, N_MV_JOINTS)) {
+ switch (dav1d_msac_decode_symbol_adapt(&t->ts->msac, t->ts->cdf.mv.joint,
+ N_MV_JOINTS))
+ {
case MV_JOINT_HV:
ref_mv->y += read_mv_component_diff(t, &mv_cdf->comp[0], have_fp);
ref_mv->x += read_mv_component_diff(t, &mv_cdf->comp[1], have_fp);
@@ -145,7 +153,8 @@
const int a = t->a->tx[bx4] < txw;
const int l = t->l.tx[by4] < txh;
- is_split = msac_decode_bool_adapt(&t->ts->msac, t->ts->cdf.m.txpart[cat][a + l]);
+ is_split = dav1d_msac_decode_bool_adapt(&t->ts->msac,
+ t->ts->cdf.m.txpart[cat][a + l]);
if (is_split)
masks[depth] |= 1 << (y_off * 4 + x_off);
} else {
@@ -370,8 +379,8 @@
{
Dav1dTileState *const ts = t->ts;
const Dav1dFrameContext *const f = t->f;
- const int pal_sz = b->pal_sz[pl] = 2 + msac_decode_symbol_adapt(&ts->msac,
- ts->cdf.m.pal_sz[pl][sz_ctx], 7);
+ const int pal_sz = b->pal_sz[pl] = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ ts->cdf.m.pal_sz[pl][sz_ctx], 7) + 2;
uint16_t cache[16], used_cache[8];
int l_cache = pl ? t->pal_sz_uv[1][by4] : t->l.pal_sz[by4];
int n_cache = 0;
@@ -414,7 +423,7 @@
// find reused cache entries
int i = 0;
for (int n = 0; n < n_cache && i < pal_sz; n++)
- if (msac_decode_bool_equi(&ts->msac))
+ if (dav1d_msac_decode_bool_equi(&ts->msac))
used_cache[i++] = cache[n];
const int n_used_cache = i;
@@ -423,14 +432,14 @@
f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) +
((t->bx >> 1) + (t->by & 1))][pl] : t->pal[pl];
if (i < pal_sz) {
- int prev = pal[i++] = msac_decode_bools(&ts->msac, f->cur.p.bpc);
+ int prev = pal[i++] = dav1d_msac_decode_bools(&ts->msac, f->cur.p.bpc);
if (i < pal_sz) {
- int bits = f->cur.p.bpc - 3 + msac_decode_bools(&ts->msac, 2);
+ int bits = f->cur.p.bpc - 3 + dav1d_msac_decode_bools(&ts->msac, 2);
const int max = (1 << f->cur.p.bpc) - 1;
do {
- const int delta = msac_decode_bools(&ts->msac, bits);
+ const int delta = dav1d_msac_decode_bools(&ts->msac, bits);
prev = pal[i++] = imin(prev + delta + !pl, max);
if (prev + !pl >= max) {
for (; i < pal_sz; i++)
@@ -478,18 +487,19 @@
uint16_t *const pal = f->frame_thread.pass ?
f->frame_thread.pal[((t->by >> 1) + (t->bx & 1)) * (f->b4_stride >> 1) +
((t->bx >> 1) + (t->by & 1))][2] : t->pal[2];
- if (msac_decode_bool_equi(&ts->msac)) {
- const int bits = f->cur.p.bpc - 4 + msac_decode_bools(&ts->msac, 2);
- int prev = pal[0] = msac_decode_bools(&ts->msac, f->cur.p.bpc);
+ if (dav1d_msac_decode_bool_equi(&ts->msac)) {
+ const int bits = f->cur.p.bpc - 4 +
+ dav1d_msac_decode_bools(&ts->msac, 2);
+ int prev = pal[0] = dav1d_msac_decode_bools(&ts->msac, f->cur.p.bpc);
const int max = (1 << f->cur.p.bpc) - 1;
for (int i = 1; i < b->pal_sz[1]; i++) {
- int delta = msac_decode_bools(&ts->msac, bits);
- if (delta && msac_decode_bool_equi(&ts->msac)) delta = -delta;
+ int delta = dav1d_msac_decode_bools(&ts->msac, bits);
+ if (delta && dav1d_msac_decode_bool_equi(&ts->msac)) delta = -delta;
prev = pal[i] = (prev + delta) & max;
}
} else {
for (int i = 0; i < b->pal_sz[1]; i++)
- pal[i] = msac_decode_bools(&ts->msac, f->cur.p.bpc);
+ pal[i] = dav1d_msac_decode_bools(&ts->msac, f->cur.p.bpc);
}
if (DEBUG_BLOCK_INFO) {
printf("Post-pal[pl=2]: r=%d ", ts->msac.rng);
@@ -575,7 +585,7 @@
{
Dav1dTileState *const ts = t->ts;
const ptrdiff_t stride = bw4 * 4;
- pal_idx[0] = msac_decode_uniform(&ts->msac, b->pal_sz[pl]);
+ pal_idx[0] = dav1d_msac_decode_uniform(&ts->msac, b->pal_sz[pl]);
uint16_t (*const color_map_cdf)[8 + 1] =
ts->cdf.m.color_map[pl][b->pal_sz[pl] - 2];
for (int i = 1; i < 4 * (w4 + h4) - 1; i++) {
@@ -585,9 +595,8 @@
const int last = imax(0, i - h4 * 4 + 1);
order_palette(pal_idx, stride, i, first, last, order, ctx);
for (int j = first, m = 0; j >= last; j--, m++) {
- const int color_idx =
- msac_decode_symbol_adapt(&ts->msac, color_map_cdf[ctx[m]],
- b->pal_sz[pl]);
+ const int color_idx = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ color_map_cdf[ctx[m]], b->pal_sz[pl]);
pal_idx[(i - j) * stride + j] = order[m][color_idx];
}
}
@@ -782,9 +791,9 @@
seg = &f->frame_hdr->segmentation.seg_data.d[b->seg_id];
} else if (f->frame_hdr->segmentation.seg_data.preskip) {
if (f->frame_hdr->segmentation.temporal &&
- (seg_pred = msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.seg_pred[t->a->seg_pred[bx4] +
- t->l.seg_pred[by4]])))
+ (seg_pred = dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.seg_pred[t->a->seg_pred[bx4] +
+ t->l.seg_pred[by4]])))
{
// temporal predicted seg_id
if (f->prev_segmap) {
@@ -802,9 +811,9 @@
const unsigned pred_seg_id =
get_cur_frame_segid(t->by, t->bx, have_top, have_left,
&seg_ctx, f->cur_segmap, f->b4_stride);
- const unsigned diff = msac_decode_symbol_adapt(&ts->msac,
- ts->cdf.m.seg_id[seg_ctx],
- DAV1D_MAX_SEGMENTS);
+ const unsigned diff = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ ts->cdf.m.seg_id[seg_ctx],
+ DAV1D_MAX_SEGMENTS);
const unsigned last_active_seg_id =
f->frame_hdr->segmentation.seg_data.last_active_segid;
b->seg_id = neg_deinterleave(diff, pred_seg_id,
@@ -828,8 +837,8 @@
f->frame_hdr->skip_mode_enabled && imin(bw4, bh4) > 1)
{
const int smctx = t->a->skip_mode[bx4] + t->l.skip_mode[by4];
- b->skip_mode = msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.skip_mode[smctx]);
+ b->skip_mode = dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.skip_mode[smctx]);
if (DEBUG_BLOCK_INFO)
printf("Post-skipmode[%d]: r=%d\n", b->skip_mode, ts->msac.rng);
} else {
@@ -841,7 +850,7 @@
b->skip = 1;
} else {
const int sctx = t->a->skip[bx4] + t->l.skip[by4];
- b->skip = msac_decode_bool_adapt(&ts->msac, ts->cdf.m.skip[sctx]);
+ b->skip = dav1d_msac_decode_bool_adapt(&ts->msac, ts->cdf.m.skip[sctx]);
if (DEBUG_BLOCK_INFO)
printf("Post-skip[%d]: r=%d\n", b->skip, ts->msac.rng);
}
@@ -852,9 +861,9 @@
!f->frame_hdr->segmentation.seg_data.preskip)
{
if (!b->skip && f->frame_hdr->segmentation.temporal &&
- (seg_pred = msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.seg_pred[t->a->seg_pred[bx4] +
- t->l.seg_pred[by4]])))
+ (seg_pred = dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.seg_pred[t->a->seg_pred[bx4] +
+ t->l.seg_pred[by4]])))
{
// temporal predicted seg_id
if (f->prev_segmap) {
@@ -874,9 +883,9 @@
if (b->skip) {
b->seg_id = pred_seg_id;
} else {
- const unsigned diff = msac_decode_symbol_adapt(&ts->msac,
- ts->cdf.m.seg_id[seg_ctx],
- DAV1D_MAX_SEGMENTS);
+ const unsigned diff = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ ts->cdf.m.seg_id[seg_ctx],
+ DAV1D_MAX_SEGMENTS);
const unsigned last_active_seg_id =
f->frame_hdr->segmentation.seg_data.last_active_segid;
b->seg_id = neg_deinterleave(diff, pred_seg_id,
@@ -898,7 +907,8 @@
const int idx = f->seq_hdr->sb128 ? ((t->bx & 16) >> 4) +
((t->by & 16) >> 3) : 0;
if (t->cur_sb_cdef_idx_ptr[idx] == -1) {
- const int v = msac_decode_bools(&ts->msac, f->frame_hdr->cdef.n_bits);
+ const int v = dav1d_msac_decode_bools(&ts->msac,
+ f->frame_hdr->cdef.n_bits);
t->cur_sb_cdef_idx_ptr[idx] = v;
if (bw4 > 16) t->cur_sb_cdef_idx_ptr[idx + 1] = v;
if (bh4 > 16) t->cur_sb_cdef_idx_ptr[idx + 2] = v;
@@ -922,13 +932,15 @@
memcpy(prev_delta_lf, ts->last_delta_lf, 4);
if (have_delta_q) {
- int delta_q = msac_decode_symbol_adapt(&ts->msac, ts->cdf.m.delta_q, 4);
+ int delta_q = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ ts->cdf.m.delta_q, 4);
if (delta_q == 3) {
- const int n_bits = 1 + msac_decode_bools(&ts->msac, 3);
- delta_q = msac_decode_bools(&ts->msac, n_bits) + 1 + (1 << n_bits);
+ const int n_bits = 1 + dav1d_msac_decode_bools(&ts->msac, 3);
+ delta_q = dav1d_msac_decode_bools(&ts->msac, n_bits) +
+ 1 + (1 << n_bits);
}
if (delta_q) {
- if (msac_decode_bool_equi(&ts->msac)) delta_q = -delta_q;
+ if (dav1d_msac_decode_bool_equi(&ts->msac)) delta_q = -delta_q;
delta_q *= 1 << f->frame_hdr->delta.q.res_log2;
}
ts->last_qidx = iclip(ts->last_qidx + delta_q, 1, 255);
@@ -941,16 +953,15 @@
f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400 ? 4 : 2 : 1;
for (int i = 0; i < n_lfs; i++) {
- int delta_lf =
- msac_decode_symbol_adapt(&ts->msac,
+ int delta_lf = dav1d_msac_decode_symbol_adapt(&ts->msac,
ts->cdf.m.delta_lf[i + f->frame_hdr->delta.lf.multi], 4);
if (delta_lf == 3) {
- const int n_bits = 1 + msac_decode_bools(&ts->msac, 3);
- delta_lf = msac_decode_bools(&ts->msac, n_bits) +
+ const int n_bits = 1 + dav1d_msac_decode_bools(&ts->msac, 3);
+ delta_lf = dav1d_msac_decode_bools(&ts->msac, n_bits) +
1 + (1 << n_bits);
}
if (delta_lf) {
- if (msac_decode_bool_equi(&ts->msac))
+ if (dav1d_msac_decode_bool_equi(&ts->msac))
delta_lf = -delta_lf;
delta_lf *= 1 << f->frame_hdr->delta.lf.res_log2;
}
@@ -988,12 +999,13 @@
} else {
const int ictx = get_intra_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
- b->intra = !msac_decode_bool_adapt(&ts->msac, ts->cdf.m.intra[ictx]);
+ b->intra = !dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.intra[ictx]);
if (DEBUG_BLOCK_INFO)
printf("Post-intra[%d]: r=%d\n", b->intra, ts->msac.rng);
}
} else if (f->frame_hdr->allow_intrabc) {
- b->intra = !msac_decode_bool_adapt(&ts->msac, ts->cdf.m.intrabc);
+ b->intra = !dav1d_msac_decode_bool_adapt(&ts->msac, ts->cdf.m.intrabc);
if (DEBUG_BLOCK_INFO)
printf("Post-intrabcflag[%d]: r=%d\n", b->intra, ts->msac.rng);
} else {
@@ -1006,8 +1018,8 @@
ts->cdf.m.y_mode[dav1d_ymode_size_context[bs]] :
ts->cdf.kfym[dav1d_intra_mode_context[t->a->mode[bx4]]]
[dav1d_intra_mode_context[t->l.mode[by4]]];
- b->y_mode = msac_decode_symbol_adapt(&ts->msac, ymode_cdf,
- N_INTRA_PRED_MODES);
+ b->y_mode = dav1d_msac_decode_symbol_adapt(&ts->msac, ymode_cdf,
+ N_INTRA_PRED_MODES);
if (DEBUG_BLOCK_INFO)
printf("Post-ymode[%d]: r=%d\n", b->y_mode, ts->msac.rng);
@@ -1016,7 +1028,7 @@
b->y_mode <= VERT_LEFT_PRED)
{
uint16_t *const acdf = ts->cdf.m.angle_delta[b->y_mode - VERT_PRED];
- const int angle = msac_decode_symbol_adapt(&ts->msac, acdf, 7);
+ const int angle = dav1d_msac_decode_symbol_adapt(&ts->msac, acdf, 7);
b->y_angle = angle - 3;
} else {
b->y_angle = 0;
@@ -1026,21 +1038,21 @@
const int cfl_allowed = f->frame_hdr->segmentation.lossless[b->seg_id] ?
cbw4 == 1 && cbh4 == 1 : !!(cfl_allowed_mask & (1 << bs));
uint16_t *const uvmode_cdf = ts->cdf.m.uv_mode[cfl_allowed][b->y_mode];
- b->uv_mode = msac_decode_symbol_adapt(&ts->msac, uvmode_cdf,
- N_UV_INTRA_PRED_MODES - !cfl_allowed);
+ b->uv_mode = dav1d_msac_decode_symbol_adapt(&ts->msac, uvmode_cdf,
+ N_UV_INTRA_PRED_MODES - !cfl_allowed);
if (DEBUG_BLOCK_INFO)
printf("Post-uvmode[%d]: r=%d\n", b->uv_mode, ts->msac.rng);
if (b->uv_mode == CFL_PRED) {
#define SIGN(a) (!!(a) + ((a) > 0))
- const int sign =
- msac_decode_symbol_adapt(&ts->msac, ts->cdf.m.cfl_sign, 8) + 1;
+ const int sign = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ ts->cdf.m.cfl_sign, 8) + 1;
const int sign_u = sign * 0x56 >> 8, sign_v = sign - sign_u * 3;
assert(sign_u == sign / 3);
if (sign_u) {
const int ctx = (sign_u == 2) * 3 + sign_v;
- b->cfl_alpha[0] = msac_decode_symbol_adapt(&ts->msac,
- ts->cdf.m.cfl_alpha[ctx], 16) + 1;
+ b->cfl_alpha[0] = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ ts->cdf.m.cfl_alpha[ctx], 16) + 1;
if (sign_u == 1) b->cfl_alpha[0] = -b->cfl_alpha[0];
} else {
b->cfl_alpha[0] = 0;
@@ -1047,8 +1059,8 @@
}
if (sign_v) {
const int ctx = (sign_v == 2) * 3 + sign_u;
- b->cfl_alpha[1] = msac_decode_symbol_adapt(&ts->msac,
- ts->cdf.m.cfl_alpha[ctx], 16) + 1;
+ b->cfl_alpha[1] = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ ts->cdf.m.cfl_alpha[ctx], 16) + 1;
if (sign_v == 1) b->cfl_alpha[1] = -b->cfl_alpha[1];
} else {
b->cfl_alpha[1] = 0;
@@ -1061,7 +1073,7 @@
b->uv_mode <= VERT_LEFT_PRED)
{
uint16_t *const acdf = ts->cdf.m.angle_delta[b->uv_mode - VERT_PRED];
- const int angle = msac_decode_symbol_adapt(&ts->msac, acdf, 7);
+ const int angle = dav1d_msac_decode_symbol_adapt(&ts->msac, acdf, 7);
b->uv_angle = angle - 3;
} else {
b->uv_angle = 0;
@@ -1075,8 +1087,8 @@
const int sz_ctx = b_dim[2] + b_dim[3] - 2;
if (b->y_mode == DC_PRED) {
const int pal_ctx = (t->a->pal_sz[bx4] > 0) + (t->l.pal_sz[by4] > 0);
- const int use_y_pal =
- msac_decode_bool_adapt(&ts->msac, ts->cdf.m.pal_y[sz_ctx][pal_ctx]);
+ const int use_y_pal = dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.pal_y[sz_ctx][pal_ctx]);
if (DEBUG_BLOCK_INFO)
printf("Post-y_pal[%d]: r=%d\n", use_y_pal, ts->msac.rng);
if (use_y_pal)
@@ -1085,8 +1097,8 @@
if (has_chroma && b->uv_mode == DC_PRED) {
const int pal_ctx = b->pal_sz[0] > 0;
- const int use_uv_pal =
- msac_decode_bool_adapt(&ts->msac, ts->cdf.m.pal_uv[pal_ctx]);
+ const int use_uv_pal = dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.pal_uv[pal_ctx]);
if (DEBUG_BLOCK_INFO)
printf("Post-uv_pal[%d]: r=%d\n", use_uv_pal, ts->msac.rng);
if (use_uv_pal) // see aomedia bug 2183 for why we use luma coordinates
@@ -1097,12 +1109,12 @@
if (b->y_mode == DC_PRED && !b->pal_sz[0] &&
imax(b_dim[2], b_dim[3]) <= 3 && f->seq_hdr->filter_intra)
{
- const int is_filter = msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.use_filter_intra[bs]);
+ const int is_filter = dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.use_filter_intra[bs]);
if (is_filter) {
b->y_mode = FILTER_PRED;
- b->y_angle = msac_decode_symbol_adapt(&ts->msac,
- ts->cdf.m.filter_intra, 5);
+ b->y_angle = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ ts->cdf.m.filter_intra, 5);
}
if (DEBUG_BLOCK_INFO)
printf("Post-filterintramode[%d/%d]: r=%d\n",
@@ -1144,8 +1156,8 @@
if (f->frame_hdr->txfm_mode == DAV1D_TX_SWITCHABLE && t_dim->max > TX_4X4) {
const int tctx = get_tx_ctx(t->a, &t->l, t_dim, by4, bx4);
uint16_t *const tx_cdf = ts->cdf.m.txsz[t_dim->max - 1][tctx];
- int depth = msac_decode_symbol_adapt(&ts->msac, tx_cdf,
- imin(t_dim->max + 1, 3));
+ int depth = dav1d_msac_decode_symbol_adapt(&ts->msac, tx_cdf,
+ imin(t_dim->max + 1, 3));
while (depth--) {
b->tx = t_dim->sub;
@@ -1357,7 +1369,8 @@
{
const int ctx = get_comp_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
- is_comp = msac_decode_bool_adapt(&ts->msac, ts->cdf.m.comp[ctx]);
+ is_comp = dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.comp[ctx]);
if (DEBUG_BLOCK_INFO)
printf("Post-compflag[%d]: r=%d\n", is_comp, ts->msac.rng);
} else {
@@ -1392,43 +1405,45 @@
} else if (is_comp) {
const int dir_ctx = get_comp_dir_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
- if (msac_decode_bool_adapt(&ts->msac, ts->cdf.m.comp_dir[dir_ctx])) {
+ if (dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.comp_dir[dir_ctx]))
+ {
// bidir - first reference (fw)
const int ctx1 = av1_get_fwd_ref_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
- if (msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.comp_fwd_ref[0][ctx1]))
+ if (dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.comp_fwd_ref[0][ctx1]))
{
const int ctx2 = av1_get_fwd_ref_2_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
- b->ref[0] = 2 + msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.comp_fwd_ref[2][ctx2]);
+ b->ref[0] = 2 + dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.comp_fwd_ref[2][ctx2]);
} else {
const int ctx2 = av1_get_fwd_ref_1_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
- b->ref[0] = msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.comp_fwd_ref[1][ctx2]);
+ b->ref[0] = dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.comp_fwd_ref[1][ctx2]);
}
// second reference (bw)
const int ctx3 = av1_get_bwd_ref_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
- if (msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.comp_bwd_ref[0][ctx3]))
+ if (dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.comp_bwd_ref[0][ctx3]))
{
b->ref[1] = 6;
} else {
const int ctx4 = av1_get_bwd_ref_1_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
- b->ref[1] = 4 + msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.comp_bwd_ref[1][ctx4]);
+ b->ref[1] = 4 + dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.comp_bwd_ref[1][ctx4]);
}
} else {
// unidir
const int uctx_p = av1_get_uni_p_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
- if (msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.comp_uni_ref[0][uctx_p]))
+ if (dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.comp_uni_ref[0][uctx_p]))
{
b->ref[0] = 4;
b->ref[1] = 6;
@@ -1436,13 +1451,13 @@
const int uctx_p1 = av1_get_uni_p1_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
b->ref[0] = 0;
- b->ref[1] = 1 + msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.comp_uni_ref[1][uctx_p1]);
+ b->ref[1] = 1 + dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.comp_uni_ref[1][uctx_p1]);
if (b->ref[1] == 2) {
const int uctx_p2 = av1_get_uni_p2_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
- b->ref[1] += msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.comp_uni_ref[2][uctx_p2]);
+ b->ref[1] += dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.comp_uni_ref[2][uctx_p2]);
}
}
}
@@ -1459,9 +1474,9 @@
ts->tiling.col_end, ts->tiling.row_start,
ts->tiling.row_end, f->libaom_cm);
- b->inter_mode = msac_decode_symbol_adapt(&ts->msac,
- ts->cdf.m.comp_inter_mode[ctx],
- N_COMP_INTER_PRED_MODES);
+ b->inter_mode = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ ts->cdf.m.comp_inter_mode[ctx],
+ N_COMP_INTER_PRED_MODES);
if (DEBUG_BLOCK_INFO)
printf("Post-compintermode[%d,ctx=%d,n_mvs=%d]: r=%d\n",
b->inter_mode, ctx, n_mvs, ts->msac.rng);
@@ -1471,12 +1486,12 @@
if (b->inter_mode == NEWMV_NEWMV) {
if (n_mvs > 1) {
const int drl_ctx_v1 = get_drl_context(mvstack, 0);
- b->drl_idx += msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.drl_bit[drl_ctx_v1]);
+ b->drl_idx += dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.drl_bit[drl_ctx_v1]);
if (b->drl_idx == 1 && n_mvs > 2) {
const int drl_ctx_v2 = get_drl_context(mvstack, 1);
- b->drl_idx += msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.drl_bit[drl_ctx_v2]);
+ b->drl_idx += dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.drl_bit[drl_ctx_v2]);
}
if (DEBUG_BLOCK_INFO)
printf("Post-drlidx[%d,n_mvs=%d]: r=%d\n",
@@ -1486,12 +1501,12 @@
b->drl_idx = 1;
if (n_mvs > 2) {
const int drl_ctx_v2 = get_drl_context(mvstack, 1);
- b->drl_idx += msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.drl_bit[drl_ctx_v2]);
+ b->drl_idx += dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.drl_bit[drl_ctx_v2]);
if (b->drl_idx == 2 && n_mvs > 3) {
const int drl_ctx_v3 = get_drl_context(mvstack, 2);
- b->drl_idx += msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.drl_bit[drl_ctx_v3]);
+ b->drl_idx += dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.drl_bit[drl_ctx_v3]);
}
if (DEBUG_BLOCK_INFO)
printf("Post-drlidx[%d,n_mvs=%d]: r=%d\n",
@@ -1534,8 +1549,8 @@
if (f->seq_hdr->masked_compound) {
const int mask_ctx = get_mask_comp_ctx(t->a, &t->l, by4, bx4);
- is_segwedge = msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.mask_comp[mask_ctx]);
+ is_segwedge = dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.mask_comp[mask_ctx]);
if (DEBUG_BLOCK_INFO)
printf("Post-segwedge_vs_jntavg[%d,ctx=%d]: r=%d\n",
is_segwedge, mask_ctx, ts->msac.rng);
@@ -1550,8 +1565,8 @@
f->refp[b->ref[1]].p.frame_hdr->frame_offset,
t->a, &t->l, by4, bx4);
b->comp_type = COMP_INTER_WEIGHTED_AVG +
- msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.jnt_comp[jnt_ctx]);
+ dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.jnt_comp[jnt_ctx]);
if (DEBUG_BLOCK_INFO)
printf("Post-jnt_comp[%d,ctx=%d[ac:%d,ar:%d,lc:%d,lr:%d]]: r=%d\n",
b->comp_type == COMP_INTER_AVG,
@@ -1565,15 +1580,15 @@
if (wedge_allowed_mask & (1 << bs)) {
const int ctx = dav1d_wedge_ctx_lut[bs];
b->comp_type = COMP_INTER_WEDGE -
- msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.wedge_comp[ctx]);
+ dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.wedge_comp[ctx]);
if (b->comp_type == COMP_INTER_WEDGE)
- b->wedge_idx = msac_decode_symbol_adapt(&ts->msac,
- ts->cdf.m.wedge_idx[ctx], 16);
+ b->wedge_idx = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ ts->cdf.m.wedge_idx[ctx], 16);
} else {
b->comp_type = COMP_INTER_SEG;
}
- b->mask_sign = msac_decode_bool_equi(&ts->msac);
+ b->mask_sign = dav1d_msac_decode_bool_equi(&ts->msac);
if (DEBUG_BLOCK_INFO)
printf("Post-seg/wedge[%d,wedge_idx=%d,sign=%d]: r=%d\n",
b->comp_type == COMP_INTER_WEDGE,
@@ -1590,30 +1605,36 @@
} else {
const int ctx1 = av1_get_ref_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
- if (msac_decode_bool_adapt(&ts->msac, ts->cdf.m.ref[0][ctx1])) {
+ if (dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.ref[0][ctx1]))
+ {
const int ctx2 = av1_get_ref_2_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
- if (msac_decode_bool_adapt(&ts->msac, ts->cdf.m.ref[1][ctx2])) {
+ if (dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.ref[1][ctx2]))
+ {
b->ref[0] = 6;
} else {
const int ctx3 = av1_get_ref_6_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
- b->ref[0] = 4 + msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.ref[5][ctx3]);
+ b->ref[0] = 4 + dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.ref[5][ctx3]);
}
} else {
const int ctx2 = av1_get_ref_3_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
- if (msac_decode_bool_adapt(&ts->msac, ts->cdf.m.ref[2][ctx2])) {
+ if (dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.ref[2][ctx2]))
+ {
const int ctx3 = av1_get_ref_5_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
- b->ref[0] = 2 + msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.ref[4][ctx3]);
+ b->ref[0] = 2 + dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.ref[4][ctx3]);
} else {
const int ctx3 = av1_get_ref_4_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
- b->ref[0] = msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.ref[3][ctx3]);
+ b->ref[0] = dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.ref[3][ctx3]);
}
}
if (DEBUG_BLOCK_INFO)
@@ -1632,11 +1653,12 @@
// mode parsing and mv derivation from ref_mvs
if ((seg && (seg->skip || seg->globalmv)) ||
- msac_decode_bool_adapt(&ts->msac, ts->cdf.m.newmv_mode[ctx & 7]))
+ dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.newmv_mode[ctx & 7]))
{
if ((seg && (seg->skip || seg->globalmv)) ||
- !msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.globalmv_mode[(ctx >> 3) & 1]))
+ !dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.globalmv_mode[(ctx >> 3) & 1]))
{
b->inter_mode = GLOBALMV;
b->mv[0] = get_gmv_2d(&f->frame_hdr->gmv[b->ref[0]],
@@ -1646,20 +1668,20 @@
f->frame_hdr->gmv[b->ref[0]].type == DAV1D_WM_TYPE_TRANSLATION;
} else {
has_subpel_filter = 1;
- if (msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.refmv_mode[(ctx >> 4) & 15]))
+ if (dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.refmv_mode[(ctx >> 4) & 15]))
{
b->inter_mode = NEARMV;
b->drl_idx = 1;
if (n_mvs > 2) {
const int drl_ctx_v2 = get_drl_context(mvstack, 1);
- b->drl_idx += msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.drl_bit[drl_ctx_v2]);
+ b->drl_idx += dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.drl_bit[drl_ctx_v2]);
if (b->drl_idx == 2 && n_mvs > 3) {
const int drl_ctx_v3 =
get_drl_context(mvstack, 2);
- b->drl_idx += msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.drl_bit[drl_ctx_v3]);
+ b->drl_idx += dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.drl_bit[drl_ctx_v3]);
}
}
} else {
@@ -1684,12 +1706,12 @@
b->drl_idx = 0;
if (n_mvs > 1) {
const int drl_ctx_v1 = get_drl_context(mvstack, 0);
- b->drl_idx += msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.drl_bit[drl_ctx_v1]);
+ b->drl_idx += dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.drl_bit[drl_ctx_v1]);
if (b->drl_idx == 1 && n_mvs > 2) {
const int drl_ctx_v2 = get_drl_context(mvstack, 1);
- b->drl_idx += msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.drl_bit[drl_ctx_v2]);
+ b->drl_idx += dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.drl_bit[drl_ctx_v2]);
}
}
if (n_mvs > 1) {
@@ -1712,18 +1734,19 @@
const int ii_sz_grp = dav1d_ymode_size_context[bs];
if (f->seq_hdr->inter_intra &&
interintra_allowed_mask & (1 << bs) &&
- msac_decode_bool_adapt(&ts->msac, ts->cdf.m.interintra[ii_sz_grp]))
+ dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.interintra[ii_sz_grp]))
{
- b->interintra_mode = msac_decode_symbol_adapt(&ts->msac,
- ts->cdf.m.interintra_mode[ii_sz_grp],
- N_INTER_INTRA_PRED_MODES);
+ b->interintra_mode = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ ts->cdf.m.interintra_mode[ii_sz_grp],
+ N_INTER_INTRA_PRED_MODES);
const int wedge_ctx = dav1d_wedge_ctx_lut[bs];
b->interintra_type = INTER_INTRA_BLEND +
- msac_decode_bool_adapt(&ts->msac,
- ts->cdf.m.interintra_wedge[wedge_ctx]);
+ dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.m.interintra_wedge[wedge_ctx]);
if (b->interintra_type == INTER_INTRA_WEDGE)
- b->wedge_idx = msac_decode_symbol_adapt(&ts->msac,
- ts->cdf.m.wedge_idx[wedge_ctx], 16);
+ b->wedge_idx = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ ts->cdf.m.wedge_idx[wedge_ctx], 16);
} else {
b->interintra_type = INTER_INTRA_NONE;
}
@@ -1755,8 +1778,9 @@
f->frame_hdr->warp_motion && (mask[0] | mask[1]);
b->motion_mode = allow_warp ?
- msac_decode_symbol_adapt(&ts->msac, ts->cdf.m.motion_mode[bs], 3) :
- msac_decode_bool_adapt(&ts->msac, ts->cdf.m.obmc[bs]);
+ dav1d_msac_decode_symbol_adapt(&ts->msac,
+ ts->cdf.m.motion_mode[bs], 3) :
+ dav1d_msac_decode_bool_adapt(&ts->msac, ts->cdf.m.obmc[bs]);
if (b->motion_mode == MM_WARP) {
has_subpel_filter = 0;
derive_warpmv(t, bw4, bh4, mask, b->mv[0], &t->warpmv);
@@ -1793,8 +1817,9 @@
const int comp = b->comp_type != COMP_INTER_NONE;
const int ctx1 = get_filter_ctx(t->a, &t->l, comp, 0, b->ref[0],
by4, bx4);
- filter[0] = msac_decode_symbol_adapt(&ts->msac,
- ts->cdf.m.filter[0][ctx1], DAV1D_N_SWITCHABLE_FILTERS);
+ filter[0] = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ ts->cdf.m.filter[0][ctx1],
+ DAV1D_N_SWITCHABLE_FILTERS);
if (f->seq_hdr->dual_filter) {
const int ctx2 = get_filter_ctx(t->a, &t->l, comp, 1,
b->ref[0], by4, bx4);
@@ -1801,8 +1826,9 @@
if (DEBUG_BLOCK_INFO)
printf("Post-subpel_filter1[%d,ctx=%d]: r=%d\n",
filter[0], ctx1, ts->msac.rng);
- filter[1] = msac_decode_symbol_adapt(&ts->msac,
- ts->cdf.m.filter[1][ctx2], DAV1D_N_SWITCHABLE_FILTERS);
+ filter[1] = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ ts->cdf.m.filter[1][ctx2],
+ DAV1D_N_SWITCHABLE_FILTERS);
if (DEBUG_BLOCK_INFO)
printf("Post-subpel_filter2[%d,ctx=%d]: r=%d\n",
filter[1], ctx2, ts->msac.rng);
@@ -1995,7 +2021,7 @@
} else {
const unsigned n_part = bl == BL_8X8 ? N_SUB8X8_PARTITIONS :
bl == BL_128X128 ? N_PARTITIONS - 2 : N_PARTITIONS;
- bp = msac_decode_symbol_adapt(&t->ts->msac, pc, n_part);
+ bp = dav1d_msac_decode_symbol_adapt(&t->ts->msac, pc, n_part);
if (f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I422 &&
(bp == PARTITION_V || bp == PARTITION_V4 ||
bp == PARTITION_T_LEFT_SPLIT || bp == PARTITION_T_RIGHT_SPLIT))
@@ -2166,7 +2192,8 @@
const Av1Block *const b = &f->frame_thread.b[t->by * f->b4_stride + t->bx];
is_split = b->bl != bl;
} else {
- is_split = msac_decode_bool(&t->ts->msac, gather_top_partition_prob(pc, bl));
+ is_split = dav1d_msac_decode_bool(&t->ts->msac,
+ gather_top_partition_prob(pc, bl));
if (DEBUG_BLOCK_INFO)
printf("poc=%d,y=%d,x=%d,bl=%d,ctx=%d,bp=%d: r=%d\n",
f->frame_hdr->frame_offset, t->by, t->bx, bl, ctx,
@@ -2194,7 +2221,8 @@
const Av1Block *const b = &f->frame_thread.b[t->by * f->b4_stride + t->bx];
is_split = b->bl != bl;
} else {
- is_split = msac_decode_bool(&t->ts->msac, gather_left_partition_prob(pc, bl));
+ is_split = dav1d_msac_decode_bool(&t->ts->msac,
+ gather_left_partition_prob(pc, bl));
if (f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I422 && !is_split)
return 1;
if (DEBUG_BLOCK_INFO)
@@ -2276,7 +2304,7 @@
ts->last_qidx = f->frame_hdr->quant.yac;
memset(ts->last_delta_lf, 0, sizeof(ts->last_delta_lf));
- msac_init(&ts->msac, data, sz, f->frame_hdr->disable_cdf_update);
+ dav1d_msac_init(&ts->msac, data, sz, f->frame_hdr->disable_cdf_update);
ts->tiling.row = tile_row;
ts->tiling.col = tile_col;
@@ -2337,49 +2365,39 @@
Dav1dTileState *const ts = t->ts;
if (frame_type == DAV1D_RESTORATION_SWITCHABLE) {
- const int filter =
- msac_decode_symbol_adapt(&ts->msac,
- ts->cdf.m.restore_switchable, 3);
+ const int filter = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ ts->cdf.m.restore_switchable, 3);
lr->type = filter ? filter == 2 ? DAV1D_RESTORATION_SGRPROJ :
DAV1D_RESTORATION_WIENER :
- DAV1D_RESTORATION_NONE;
+ DAV1D_RESTORATION_NONE;
} else {
const unsigned type =
- msac_decode_bool_adapt(&ts->msac,
- frame_type == DAV1D_RESTORATION_WIENER ?
- ts->cdf.m.restore_wiener :
- ts->cdf.m.restore_sgrproj);
+ dav1d_msac_decode_bool_adapt(&ts->msac,
+ frame_type == DAV1D_RESTORATION_WIENER ?
+ ts->cdf.m.restore_wiener : ts->cdf.m.restore_sgrproj);
lr->type = type ? frame_type : DAV1D_RESTORATION_NONE;
}
if (lr->type == DAV1D_RESTORATION_WIENER) {
- lr->filter_v[0] =
- !p ? msac_decode_subexp(&ts->msac,
- ts->lr_ref[p]->filter_v[0] + 5, 16,
- 1) - 5:
- 0;
+ lr->filter_v[0] = p ? 0 :
+ dav1d_msac_decode_subexp(&ts->msac,
+ ts->lr_ref[p]->filter_v[0] + 5, 16, 1) - 5;
lr->filter_v[1] =
- msac_decode_subexp(&ts->msac,
- ts->lr_ref[p]->filter_v[1] + 23, 32,
- 2) - 23;
+ dav1d_msac_decode_subexp(&ts->msac,
+ ts->lr_ref[p]->filter_v[1] + 23, 32, 2) - 23;
lr->filter_v[2] =
- msac_decode_subexp(&ts->msac,
- ts->lr_ref[p]->filter_v[2] + 17, 64,
- 3) - 17;
+ dav1d_msac_decode_subexp(&ts->msac,
+ ts->lr_ref[p]->filter_v[2] + 17, 64, 3) - 17;
- lr->filter_h[0] =
- !p ? msac_decode_subexp(&ts->msac,
- ts->lr_ref[p]->filter_h[0] + 5, 16,
- 1) - 5:
- 0;
+ lr->filter_h[0] = p ? 0 :
+ dav1d_msac_decode_subexp(&ts->msac,
+ ts->lr_ref[p]->filter_h[0] + 5, 16, 1) - 5;
lr->filter_h[1] =
- msac_decode_subexp(&ts->msac,
- ts->lr_ref[p]->filter_h[1] + 23, 32,
- 2) - 23;
+ dav1d_msac_decode_subexp(&ts->msac,
+ ts->lr_ref[p]->filter_h[1] + 23, 32, 2) - 23;
lr->filter_h[2] =
- msac_decode_subexp(&ts->msac,
- ts->lr_ref[p]->filter_h[2] + 17, 64,
- 3) - 17;
+ dav1d_msac_decode_subexp(&ts->msac,
+ ts->lr_ref[p]->filter_h[2] + 17, 64, 3) - 17;
memcpy(lr->sgr_weights, ts->lr_ref[p]->sgr_weights, sizeof(lr->sgr_weights));
ts->lr_ref[p] = lr;
if (DEBUG_BLOCK_INFO)
@@ -2388,17 +2406,15 @@
lr->filter_v[2], lr->filter_h[0],
lr->filter_h[1], lr->filter_h[2], ts->msac.rng);
} else if (lr->type == DAV1D_RESTORATION_SGRPROJ) {
- const unsigned idx = msac_decode_bools(&ts->msac, 4);
+ const unsigned idx = dav1d_msac_decode_bools(&ts->msac, 4);
lr->sgr_idx = idx;
lr->sgr_weights[0] = dav1d_sgr_params[idx][0] ?
- msac_decode_subexp(&ts->msac,
- ts->lr_ref[p]->sgr_weights[0] + 96, 128,
- 4) - 96 :
+ dav1d_msac_decode_subexp(&ts->msac,
+ ts->lr_ref[p]->sgr_weights[0] + 96, 128, 4) - 96 :
0;
lr->sgr_weights[1] = dav1d_sgr_params[idx][1] ?
- msac_decode_subexp(&ts->msac,
- ts->lr_ref[p]->sgr_weights[1] + 32, 128,
- 4) - 32 :
+ dav1d_msac_decode_subexp(&ts->msac,
+ ts->lr_ref[p]->sgr_weights[1] + 32, 128, 4) - 32 :
iclip(128 - lr->sgr_weights[0], -32, 95);
memcpy(lr->filter_v, ts->lr_ref[p]->filter_v, sizeof(lr->filter_v));
memcpy(lr->filter_h, ts->lr_ref[p]->filter_h, sizeof(lr->filter_h));
--- a/src/msac.c
+++ b/src/msac.c
@@ -68,7 +68,7 @@
ctx_refill(s);
}
-unsigned msac_decode_bool_equi(MsacContext *const s) {
+unsigned dav1d_msac_decode_bool_equi(MsacContext *const s) {
ec_win v, vw, dif = s->dif;
uint16_t r = s->rng;
unsigned ret;
@@ -87,7 +87,7 @@
/* Decode a single binary value.
* f: The probability that the bit is one
* Return: The value decoded (0 or 1). */
-unsigned msac_decode_bool(MsacContext *const s, const unsigned f) {
+unsigned dav1d_msac_decode_bool(MsacContext *const s, const unsigned f) {
ec_win v, vw, dif = s->dif;
uint16_t r = s->rng;
unsigned ret;
@@ -101,36 +101,36 @@
return !ret;
}
-unsigned msac_decode_bools(MsacContext *const c, const unsigned l) {
+unsigned dav1d_msac_decode_bools(MsacContext *const c, const unsigned l) {
int v = 0;
for (int n = (int) l - 1; n >= 0; n--)
- v = (v << 1) | msac_decode_bool_equi(c);
+ v = (v << 1) | dav1d_msac_decode_bool_equi(c);
return v;
}
-int msac_decode_subexp(MsacContext *const c, const int ref,
- const int n, const unsigned k)
+int dav1d_msac_decode_subexp(MsacContext *const c, const int ref,
+ const int n, const unsigned k)
{
int i = 0;
int a = 0;
int b = k;
while ((2 << b) < n) {
- if (!msac_decode_bool_equi(c)) break;
+ if (!dav1d_msac_decode_bool_equi(c)) break;
b = k + i++;
a = (1 << b);
}
- const unsigned v = msac_decode_bools(c, b) + a;
+ const unsigned v = dav1d_msac_decode_bools(c, b) + a;
return ref * 2 <= n ? inv_recenter(ref, v) :
n - 1 - inv_recenter(n - 1 - ref, v);
}
-int msac_decode_uniform(MsacContext *const c, const unsigned n) {
+int dav1d_msac_decode_uniform(MsacContext *const c, const unsigned n) {
assert(n > 0);
const int l = ulog2(n) + 1;
assert(l > 1);
const unsigned m = (1 << l) - n;
- const unsigned v = msac_decode_bools(c, l - 1);
- return v < m ? v : (v << 1) - m + msac_decode_bool_equi(c);
+ const unsigned v = dav1d_msac_decode_bools(c, l - 1);
+ return v < m ? v : (v << 1) - m + dav1d_msac_decode_bool_equi(c);
}
/* Decodes a symbol given an inverse cumulative distribution function (CDF)
@@ -170,8 +170,9 @@
cdf[n_symbols] = count + (count < 32);
}
-unsigned msac_decode_symbol_adapt(MsacContext *const c,
- uint16_t *const cdf, const unsigned n_symbols)
+unsigned dav1d_msac_decode_symbol_adapt(MsacContext *const c,
+ uint16_t *const cdf,
+ const unsigned n_symbols)
{
const unsigned val = decode_symbol(c, cdf, n_symbols);
if(c->allow_update_cdf)
@@ -179,8 +180,10 @@
return val;
}
-unsigned msac_decode_bool_adapt(MsacContext *const c, uint16_t *const cdf) {
- const unsigned bit = msac_decode_bool(c, *cdf);
+unsigned dav1d_msac_decode_bool_adapt(MsacContext *const c,
+ uint16_t *const cdf)
+{
+ const unsigned bit = dav1d_msac_decode_bool(c, *cdf);
if(c->allow_update_cdf){
// update_cdf() specialized for boolean CDFs
@@ -197,8 +200,8 @@
return bit;
}
-void msac_init(MsacContext *const s, const uint8_t *const data,
- const size_t sz, const int disable_cdf_update_flag)
+void dav1d_msac_init(MsacContext *const s, const uint8_t *const data,
+ const size_t sz, const int disable_cdf_update_flag)
{
s->buf_pos = data;
s->buf_end = data + sz;
--- a/src/msac.h
+++ b/src/msac.h
@@ -43,14 +43,15 @@
int allow_update_cdf;
} MsacContext;
-void msac_init(MsacContext *c, const uint8_t *data, size_t sz, int disable_cdf_update_flag);
-unsigned msac_decode_symbol_adapt(MsacContext *s, uint16_t *cdf,
- const unsigned n_symbols);
-unsigned msac_decode_bool_equi(MsacContext *const s);
-unsigned msac_decode_bool(MsacContext *s, unsigned f);
-unsigned msac_decode_bool_adapt(MsacContext *s, uint16_t *cdf);
-unsigned msac_decode_bools(MsacContext *c, unsigned l);
-int msac_decode_subexp(MsacContext *c, int ref, int n, unsigned k);
-int msac_decode_uniform(MsacContext *c, unsigned n);
+void dav1d_msac_init(MsacContext *c, const uint8_t *data, size_t sz,
+ int disable_cdf_update_flag);
+unsigned dav1d_msac_decode_symbol_adapt(MsacContext *s, uint16_t *cdf,
+ const unsigned n_symbols);
+unsigned dav1d_msac_decode_bool_equi(MsacContext *const s);
+unsigned dav1d_msac_decode_bool(MsacContext *s, unsigned f);
+unsigned dav1d_msac_decode_bool_adapt(MsacContext *s, uint16_t *cdf);
+unsigned dav1d_msac_decode_bools(MsacContext *c, unsigned l);
+int dav1d_msac_decode_subexp(MsacContext *c, int ref, int n, unsigned k);
+int dav1d_msac_decode_uniform(MsacContext *c, unsigned n);
#endif /* DAV1D_SRC_MSAC_H */
--- a/src/recon_tmpl.c
+++ b/src/recon_tmpl.c
@@ -50,8 +50,8 @@
int len = 0;
unsigned val = 1;
- while (!msac_decode_bool_equi(msac) && len < 32) len++;
- while (len--) val = (val << 1) | msac_decode_bool_equi(msac);
+ while (!dav1d_msac_decode_bool_equi(msac) && len < 32) len++;
+ while (len--) val = (val << 1) | dav1d_msac_decode_bool_equi(msac);
return val - 1;
}
@@ -73,8 +73,8 @@
// does this block have any non-zero coefficients
const int sctx = get_coef_skip_ctx(t_dim, bs, a, l, chroma, f->cur.p.layout);
- const int all_skip =
- msac_decode_bool_adapt(&ts->msac, ts->cdf.coef.skip[t_dim->ctx][sctx]);
+ const int all_skip = dav1d_msac_decode_bool_adapt(&ts->msac,
+ ts->cdf.coef.skip[t_dim->ctx][sctx]);
if (dbg)
printf("Post-non-zero[%d][%d][%d]: r=%d\n",
t_dim->ctx, sctx, all_skip, ts->msac.rng);
@@ -107,7 +107,7 @@
uint16_t *const txtp_cdf = intra ?
ts->cdf.m.txtp_intra[set_idx][t_dim->min][y_mode_nofilt] :
ts->cdf.m.txtp_inter[set_idx][t_dim->min];
- idx = msac_decode_symbol_adapt(&ts->msac, txtp_cdf, set_cnt);
+ idx = dav1d_msac_decode_symbol_adapt(&ts->msac, txtp_cdf, set_cnt);
if (dbg)
printf("Post-txtp[%d->%d][%d->%d][%d][%d->%d]: r=%d\n",
set, set_idx, tx, t_dim->min, intra ? (int)y_mode_nofilt : -1,
@@ -125,7 +125,7 @@
#define case_sz(sz, bin) \
case sz: { \
uint16_t *const eob_bin_cdf = ts->cdf.coef.eob_bin_##bin[chroma][is_1d]; \
- eob_bin = msac_decode_symbol_adapt(&ts->msac, eob_bin_cdf, 5 + sz); \
+ eob_bin = dav1d_msac_decode_symbol_adapt(&ts->msac, eob_bin_cdf, 5 + sz); \
break; \
}
case_sz(0, 16);
@@ -145,7 +145,8 @@
eob = 1 << (eob_bin - 1);
uint16_t *const eob_hi_bit_cdf =
ts->cdf.coef.eob_hi_bit[t_dim->ctx][chroma][eob_bin];
- const int eob_hi_bit = msac_decode_bool_adapt(&ts->msac, eob_hi_bit_cdf);
+ const int eob_hi_bit = dav1d_msac_decode_bool_adapt(&ts->msac,
+ eob_hi_bit_cdf);
if (dbg)
printf("Post-eob_hi_bit[%d][%d][%d][%d]: r=%d\n",
t_dim->ctx, chroma, eob_bin, eob_hi_bit, ts->msac.rng);
@@ -152,7 +153,7 @@
unsigned mask = eob >> 1;
if (eob_hi_bit) eob |= mask;
for (mask >>= 1; mask; mask >>= 1) {
- const int eob_bit = msac_decode_bool_equi(&ts->msac);
+ const int eob_bit = dav1d_msac_decode_bool_equi(&ts->msac);
if (eob_bit) eob |= mask;
}
if (dbg)
@@ -178,8 +179,8 @@
uint16_t *const lo_cdf = is_last ?
ts->cdf.coef.eob_base_tok[t_dim->ctx][chroma][ctx] :
ts->cdf.coef.base_tok[t_dim->ctx][chroma][ctx];
- int tok = msac_decode_symbol_adapt(&ts->msac, lo_cdf,
- 4 - is_last) + is_last;
+ int tok = dav1d_msac_decode_symbol_adapt(&ts->msac, lo_cdf,
+ 4 - is_last) + is_last;
if (dbg)
printf("Post-lo_tok[%d][%d][%d][%d=%d=%d]: r=%d\n",
t_dim->ctx, chroma, ctx, i, rc, tok, ts->msac.rng);
@@ -189,8 +190,8 @@
if (tok == 3) {
const int br_ctx = get_br_ctx(levels, rc, tx, tx_class);
do {
- const int tok_br =
- msac_decode_symbol_adapt(&ts->msac, br_cdf[br_ctx], 4);
+ const int tok_br = dav1d_msac_decode_symbol_adapt(&ts->msac,
+ br_cdf[br_ctx], 4);
if (dbg)
printf("Post-hi_tok[%d][%d][%d][%d=%d=%d->%d]: r=%d\n",
imin(t_dim->ctx, 3), chroma, br_ctx,
@@ -225,7 +226,7 @@
const int dc_sign_ctx = get_dc_sign_ctx(t_dim, a, l);
uint16_t *const dc_sign_cdf =
ts->cdf.coef.dc_sign[chroma][dc_sign_ctx];
- sign = msac_decode_bool_adapt(&ts->msac, dc_sign_cdf);
+ sign = dav1d_msac_decode_bool_adapt(&ts->msac, dc_sign_cdf);
if (dbg)
printf("Post-dc_sign[%d][%d][%d]: r=%d\n",
chroma, dc_sign_ctx, sign, ts->msac.rng);
@@ -232,7 +233,7 @@
dc_sign = sign ? 0 : 2;
dq = (dq_tbl[0] * qm_tbl[0] + 16) >> 5;
} else {
- sign = msac_decode_bool_equi(&ts->msac);
+ sign = dav1d_msac_decode_bool_equi(&ts->msac);
if (dbg)
printf("Post-sign[%d=%d=%d]: r=%d\n", i, rc, sign, ts->msac.rng);
dq = (dq_tbl[1] * qm_tbl[rc] + 16) >> 5;