Commit c371907f authored by Ronald S. Bultje's avatar Ronald S. Bultje

Make frame_hdr a pointer

parent e071d257
......@@ -88,7 +88,7 @@ void bytefn(dav1d_cdef_brow)(Dav1dFrameContext *const f,
pixel *ptrs[3] = { p[0], p[1], p[2] };
const int sbsz = 16;
const int sb64w = f->sb128w << 1;
const int damping = f->frame_hdr.cdef.damping + BITDEPTH - 8;
const int damping = f->frame_hdr->cdef.damping + BITDEPTH - 8;
const enum Dav1dPixelLayout layout = f->cur.p.layout;
const int uv_idx = DAV1D_PIXEL_LAYOUT_I444 - layout;
const int has_chroma = layout != DAV1D_PIXEL_LAYOUT_I400;
......@@ -119,15 +119,15 @@ void bytefn(dav1d_cdef_brow)(Dav1dFrameContext *const f,
const int sb64_idx = ((by & sbsz) >> 3) + (sbx & 1);
const int cdef_idx = lflvl[sb128x].cdef_idx[sb64_idx];
if (cdef_idx == -1 ||
(!f->frame_hdr.cdef.y_strength[cdef_idx] &&
!f->frame_hdr.cdef.uv_strength[cdef_idx]))
(!f->frame_hdr->cdef.y_strength[cdef_idx] &&
!f->frame_hdr->cdef.uv_strength[cdef_idx]))
{
last_skip = 1;
goto next_sb;
}
const int y_lvl = f->frame_hdr.cdef.y_strength[cdef_idx];
const int uv_lvl = f->frame_hdr.cdef.uv_strength[cdef_idx];
const int y_lvl = f->frame_hdr->cdef.y_strength[cdef_idx];
const int uv_lvl = f->frame_hdr->cdef.uv_strength[cdef_idx];
pixel *bptrs[3] = { iptrs[0], iptrs[1], iptrs[2] };
for (int bx = sbx * sbsz; bx < imin((sbx + 1) * sbsz, f->bw);
bx += 2, edges |= HAVE_LEFT)
......
......@@ -77,7 +77,7 @@ static int read_mv_component_diff(Dav1dTileContext *const t,
{
Dav1dTileState *const ts = t->ts;
const Dav1dFrameContext *const f = t->f;
const int have_hp = f->frame_hdr.hp;
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);
int up, fp, hp;
......@@ -613,26 +613,26 @@ static void read_vartx_tree(Dav1dTileContext *const t,
// var-tx tree coding
b->tx_split[0] = b->tx_split[1] = 0;
b->max_ytx = dav1d_max_txfm_size_for_bs[bs][0];
if (f->frame_hdr.segmentation.lossless[b->seg_id] ||
if (f->frame_hdr->segmentation.lossless[b->seg_id] ||
b->max_ytx == TX_4X4)
{
b->max_ytx = b->uvtx = TX_4X4;
if (f->frame_hdr.txfm_mode == TX_SWITCHABLE) {
if (f->frame_hdr->txfm_mode == TX_SWITCHABLE) {
#define set_ctx(type, dir, diridx, off, mul, rep_macro) \
rep_macro(type, t->dir tx, off, TX_4X4)
case_set(bh4, l., 1, by4);
case_set(bw4, a->, 0, bx4);
#undef set_ctx
}
} else if (f->frame_hdr.txfm_mode != TX_SWITCHABLE || b->skip) {
if (f->frame_hdr.txfm_mode == TX_SWITCHABLE) {
} else if (f->frame_hdr->txfm_mode != TX_SWITCHABLE || b->skip) {
if (f->frame_hdr->txfm_mode == TX_SWITCHABLE) {
#define set_ctx(type, dir, diridx, off, mul, rep_macro) \
rep_macro(type, t->dir tx, off, mul * b_dim[2 + diridx])
case_set(bh4, l., 1, by4);
case_set(bw4, a->, 0, bx4);
#undef set_ctx
} else {
assert(f->frame_hdr.txfm_mode == TX_LARGEST);
assert(f->frame_hdr->txfm_mode == TX_LARGEST);
}
b->uvtx = dav1d_max_txfm_size_for_bs[bs][f->cur.p.layout];
} else {
......@@ -664,8 +664,8 @@ static inline unsigned get_prev_frame_segid(const Dav1dFrameContext *const f,
{
unsigned seg_id = 8;
assert(f->frame_hdr.primary_ref_frame != PRIMARY_REF_NONE);
if (dav1d_thread_picture_wait(&f->refp[f->frame_hdr.primary_ref_frame],
assert(f->frame_hdr->primary_ref_frame != PRIMARY_REF_NONE);
if (dav1d_thread_picture_wait(&f->refp[f->frame_hdr->primary_ref_frame],
(by + h4) * 4, PLANE_TYPE_BLOCK))
{
return 8;
......@@ -727,7 +727,7 @@ static int decode_b(Dav1dTileContext *const t,
#undef set_ctx
}
} else {
if (f->frame_hdr.frame_type & 1 /* not intrabc */ &&
if (f->frame_hdr->frame_type & 1 /* not intrabc */ &&
b->comp_type == COMP_INTER_NONE && b->motion_mode == MM_WARP)
{
uint64_t mask[2] = { 0, 0 };
......@@ -767,8 +767,8 @@ static int decode_b(Dav1dTileContext *const t,
// segment_id (if seg_feature for skip/ref/gmv is enabled)
int seg_pred = 0;
if (f->frame_hdr.segmentation.enabled) {
if (!f->frame_hdr.segmentation.update_map) {
if (f->frame_hdr->segmentation.enabled) {
if (!f->frame_hdr->segmentation.update_map) {
if (f->prev_segmap) {
unsigned seg_id = get_prev_frame_segid(f, t->by, t->bx, w4, h4,
f->prev_segmap,
......@@ -778,9 +778,9 @@ static int decode_b(Dav1dTileContext *const t,
} else {
b->seg_id = 0;
}
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 = &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]])))
......@@ -805,7 +805,7 @@ static int decode_b(Dav1dTileContext *const t,
ts->cdf.m.seg_id[seg_ctx],
NUM_SEGMENTS);
const unsigned last_active_seg_id =
f->frame_hdr.segmentation.seg_data.last_active_segid;
f->frame_hdr->segmentation.seg_data.last_active_segid;
b->seg_id = neg_deinterleave(diff, pred_seg_id,
last_active_seg_id + 1);
if (b->seg_id > last_active_seg_id) b->seg_id = 0; // error?
......@@ -816,7 +816,7 @@ static int decode_b(Dav1dTileContext *const t,
printf("Post-segid[preskip;%d]: r=%d\n",
b->seg_id, ts->msac.rng);
seg = &f->frame_hdr.segmentation.seg_data.d[b->seg_id];
seg = &f->frame_hdr->segmentation.seg_data.d[b->seg_id];
}
} else {
b->seg_id = 0;
......@@ -824,7 +824,7 @@ static int decode_b(Dav1dTileContext *const t,
// skip_mode
if ((!seg || (!seg->globalmv && seg->ref == -1 && !seg->skip)) &&
f->frame_hdr.skip_mode_enabled && imin(bw4, bh4) > 1)
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,
......@@ -846,11 +846,11 @@ static int decode_b(Dav1dTileContext *const t,
}
// segment_id
if (f->frame_hdr.segmentation.enabled &&
f->frame_hdr.segmentation.update_map &&
!f->frame_hdr.segmentation.seg_data.preskip)
if (f->frame_hdr->segmentation.enabled &&
f->frame_hdr->segmentation.update_map &&
!f->frame_hdr->segmentation.seg_data.preskip)
{
if (!b->skip && f->frame_hdr.segmentation.temporal &&
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]])))
......@@ -877,7 +877,7 @@ static int decode_b(Dav1dTileContext *const t,
ts->cdf.m.seg_id[seg_ctx],
NUM_SEGMENTS);
const unsigned last_active_seg_id =
f->frame_hdr.segmentation.seg_data.last_active_segid;
f->frame_hdr->segmentation.seg_data.last_active_segid;
b->seg_id = neg_deinterleave(diff, pred_seg_id,
last_active_seg_id + 1);
if (b->seg_id > last_active_seg_id) b->seg_id = 0; // error?
......@@ -885,7 +885,7 @@ static int decode_b(Dav1dTileContext *const t,
if (b->seg_id >= NUM_SEGMENTS) b->seg_id = 0; // error?
}
seg = &f->frame_hdr.segmentation.seg_data.d[b->seg_id];
seg = &f->frame_hdr->segmentation.seg_data.d[b->seg_id];
if (DEBUG_BLOCK_INFO)
printf("Post-segid[postskip;%d]: r=%d\n",
......@@ -897,7 +897,7 @@ static int decode_b(Dav1dTileContext *const t,
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 = 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;
......@@ -914,7 +914,7 @@ static int decode_b(Dav1dTileContext *const t,
!(t->by & (31 >> !f->seq_hdr->sb128)))
{
const int prev_qidx = ts->last_qidx;
const int have_delta_q = f->frame_hdr.delta.q.present &&
const int have_delta_q = f->frame_hdr->delta.q.present &&
(bs != (f->seq_hdr->sb128 ? BS_128x128 : BS_64x64) || !b->skip);
int8_t prev_delta_lf[4];
......@@ -928,21 +928,21 @@ static int decode_b(Dav1dTileContext *const t,
}
if (delta_q) {
if (msac_decode_bool(&ts->msac, EC_BOOL_EPROB)) delta_q = -delta_q;
delta_q *= 1 << f->frame_hdr.delta.q.res_log2;
delta_q *= 1 << f->frame_hdr->delta.q.res_log2;
}
ts->last_qidx = iclip(ts->last_qidx + delta_q, 1, 255);
if (have_delta_q && DEBUG_BLOCK_INFO)
printf("Post-delta_q[%d->%d]: r=%d\n",
delta_q, ts->last_qidx, ts->msac.rng);
if (f->frame_hdr.delta.lf.present) {
const int n_lfs = f->frame_hdr.delta.lf.multi ?
if (f->frame_hdr->delta.lf.present) {
const int n_lfs = f->frame_hdr->delta.lf.multi ?
f->seq_hdr->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,
ts->cdf.m.delta_lf[i + f->frame_hdr.delta.lf.multi], 4);
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) +
......@@ -951,7 +951,7 @@ static int decode_b(Dav1dTileContext *const t,
if (delta_lf) {
if (msac_decode_bool(&ts->msac, EC_BOOL_EPROB))
delta_lf = -delta_lf;
delta_lf *= 1 << f->frame_hdr.delta.lf.res_log2;
delta_lf *= 1 << f->frame_hdr->delta.lf.res_log2;
}
ts->last_delta_lf[i] =
iclip(ts->last_delta_lf[i] + delta_lf, -63, 63);
......@@ -961,12 +961,12 @@ static int decode_b(Dav1dTileContext *const t,
}
}
}
if (ts->last_qidx == f->frame_hdr.quant.yac) {
if (ts->last_qidx == f->frame_hdr->quant.yac) {
// assign frame-wide q values to this sb
ts->dq = f->dq;
} else if (ts->last_qidx != prev_qidx) {
// find sb-specific quant parameters
init_quant_tables(f->seq_hdr, &f->frame_hdr, ts->last_qidx, ts->dqmem);
init_quant_tables(f->seq_hdr, f->frame_hdr, ts->last_qidx, ts->dqmem);
ts->dq = ts->dqmem;
}
if (!memcmp(ts->last_delta_lf, (int8_t[4]) { 0, 0, 0, 0 }, 4)) {
......@@ -974,14 +974,14 @@ static int decode_b(Dav1dTileContext *const t,
ts->lflvl = f->lf.lvl;
} else if (memcmp(ts->last_delta_lf, prev_delta_lf, 4)) {
// find sb-specific lf lvl parameters
dav1d_calc_lf_values(ts->lflvlmem, &f->frame_hdr, ts->last_delta_lf);
dav1d_calc_lf_values(ts->lflvlmem, f->frame_hdr, ts->last_delta_lf);
ts->lflvl = ts->lflvlmem;
}
}
if (b->skip_mode) {
b->intra = 0;
} else if (f->frame_hdr.frame_type & 1) {
} else if (f->frame_hdr->frame_type & 1) {
if (seg && (seg->ref >= 0 || seg->globalmv)) {
b->intra = !seg->ref;
} else {
......@@ -991,7 +991,7 @@ static int decode_b(Dav1dTileContext *const t,
if (DEBUG_BLOCK_INFO)
printf("Post-intra[%d]: r=%d\n", b->intra, ts->msac.rng);
}
} else if (f->frame_hdr.allow_intrabc) {
} else if (f->frame_hdr->allow_intrabc) {
b->intra = !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);
......@@ -1001,7 +1001,7 @@ static int decode_b(Dav1dTileContext *const t,
// intra/inter-specific stuff
if (b->intra) {
uint16_t *const ymode_cdf = f->frame_hdr.frame_type & 1 ?
uint16_t *const ymode_cdf = f->frame_hdr->frame_type & 1 ?
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]]];
......@@ -1022,7 +1022,7 @@ static int decode_b(Dav1dTileContext *const t,
}
if (has_chroma) {
const int cfl_allowed = f->frame_hdr.segmentation.lossless[b->seg_id] ?
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,
......@@ -1068,7 +1068,7 @@ static int decode_b(Dav1dTileContext *const t,
}
b->pal_sz[0] = b->pal_sz[1] = 0;
if (f->frame_hdr.allow_screen_content_tools &&
if (f->frame_hdr->allow_screen_content_tools &&
imax(bw4, bh4) <= 16 && bw4 + bh4 >= 4)
{
const int sz_ctx = b_dim[2] + b_dim[3] - 2;
......@@ -1133,14 +1133,14 @@ static int decode_b(Dav1dTileContext *const t,
}
const TxfmInfo *t_dim;
if (f->frame_hdr.segmentation.lossless[b->seg_id]) {
if (f->frame_hdr->segmentation.lossless[b->seg_id]) {
b->tx = b->uvtx = (int) TX_4X4;
t_dim = &dav1d_txfm_dimensions[TX_4X4];
} else {
b->tx = dav1d_max_txfm_size_for_bs[bs][0];
b->uvtx = dav1d_max_txfm_size_for_bs[bs][f->cur.p.layout];
t_dim = &dav1d_txfm_dimensions[b->tx];
if (f->frame_hdr.txfm_mode == TX_SWITCHABLE && t_dim->max > TX_4X4) {
if (f->frame_hdr->txfm_mode == 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,
......@@ -1163,7 +1163,7 @@ static int decode_b(Dav1dTileContext *const t,
}
dav1d_create_lf_mask_intra(t->lf_mask, f->lf.level, f->b4_stride,
&f->frame_hdr, (const uint8_t (*)[8][2])
f->frame_hdr, (const uint8_t (*)[8][2])
&ts->lflvl[b->seg_id][0][0][0],
t->bx, t->by, f->w4, f->h4, bs,
b->tx, b->uvtx, f->cur.p.layout,
......@@ -1183,7 +1183,7 @@ static int decode_b(Dav1dTileContext *const t,
rep_macro(type, t->dir skip, off, mul * b->skip); \
/* see aomedia bug 2183 for why we use luma coordinates here */ \
rep_macro(type, t->pal_sz_uv[diridx], off, mul * (has_chroma ? b->pal_sz[1] : 0)); \
if (f->frame_hdr.frame_type & 1) { \
if (f->frame_hdr->frame_type & 1) { \
rep_macro(type, t->dir comp_type, off, mul * COMP_INTER_NONE); \
rep_macro(type, t->dir ref[0], off, mul * ((uint8_t) -1)); \
rep_macro(type, t->dir ref[1], off, mul * ((uint8_t) -1)); \
......@@ -1221,11 +1221,11 @@ static int decode_b(Dav1dTileContext *const t,
memcpy(t->al_pal[1][by4 + y][pl], pal, 16);
}
}
if ((f->frame_hdr.frame_type & 1) || f->frame_hdr.allow_intrabc) {
if ((f->frame_hdr->frame_type & 1) || f->frame_hdr->allow_intrabc) {
splat_intraref(f->mvs, f->b4_stride, t->by, t->bx, bs,
y_mode_nofilt);
}
} else if (!(f->frame_hdr.frame_type & 1)) {
} else if (!(f->frame_hdr->frame_type & 1)) {
// intra block copy
candidate_mv mvstack[8];
int n_mvs;
......@@ -1351,7 +1351,7 @@ static int decode_b(Dav1dTileContext *const t,
if (b->skip_mode) {
is_comp = 1;
} else if ((!seg || (seg->ref == -1 && !seg->globalmv && !seg->skip)) &&
f->frame_hdr.switchable_comp_refs && imin(bw4, bh4) > 1)
f->frame_hdr->switchable_comp_refs && imin(bw4, bh4) > 1)
{
const int ctx = get_comp_ctx(t->a, &t->l, by4, bx4,
have_top, have_left);
......@@ -1363,8 +1363,8 @@ static int decode_b(Dav1dTileContext *const t,
}
if (b->skip_mode) {
b->ref[0] = f->frame_hdr.skip_mode_refs[0];
b->ref[1] = f->frame_hdr.skip_mode_refs[1];
b->ref[0] = f->frame_hdr->skip_mode_refs[0];
b->ref[1] = f->frame_hdr->skip_mode_refs[1];
b->comp_type = COMP_INTER_AVG;
b->inter_mode = NEARESTMV_NEARESTMV;
b->drl_idx = 0;
......@@ -1381,8 +1381,8 @@ static int decode_b(Dav1dTileContext *const t,
b->mv[0] = mvstack[0].this_mv;
b->mv[1] = mvstack[0].comp_mv;
fix_mv_precision(&f->frame_hdr, &b->mv[0]);
fix_mv_precision(&f->frame_hdr, &b->mv[1]);
fix_mv_precision(f->frame_hdr, &b->mv[0]);
fix_mv_precision(f->frame_hdr, &b->mv[1]);
if (DEBUG_BLOCK_INFO)
printf("Post-skipmodeblock[mv=1:y=%d,x=%d,2:y=%d,x=%d,refs=%d+%d\n",
b->mv[0].y, b->mv[0].x, b->mv[1].y, b->mv[1].x,
......@@ -1502,19 +1502,19 @@ static int decode_b(Dav1dTileContext *const t,
case NEARMV: \
case NEARESTMV: \
b->mv[idx] = mvstack[b->drl_idx].pfx##_mv; \
fix_mv_precision(&f->frame_hdr, &b->mv[idx]); \
fix_mv_precision(f->frame_hdr, &b->mv[idx]); \
break; \
case GLOBALMV: \
has_subpel_filter |= \
f->frame_hdr.gmv[b->ref[idx]].type == WM_TYPE_TRANSLATION; \
b->mv[idx] = get_gmv_2d(&f->frame_hdr.gmv[b->ref[idx]], \
t->bx, t->by, bw4, bh4, &f->frame_hdr); \
fix_mv_precision(&f->frame_hdr, &b->mv[idx]); \
f->frame_hdr->gmv[b->ref[idx]].type == WM_TYPE_TRANSLATION; \
b->mv[idx] = get_gmv_2d(&f->frame_hdr->gmv[b->ref[idx]], \
t->bx, t->by, bw4, bh4, f->frame_hdr); \
fix_mv_precision(f->frame_hdr, &b->mv[idx]); \
break; \
case NEWMV: \
b->mv[idx] = mvstack[b->drl_idx].pfx##_mv; \
read_mv_residual(t, &b->mv[idx], &ts->cdf.mv, \
!f->frame_hdr.force_integer_mv); \
!f->frame_hdr->force_integer_mv); \
break; \
}
has_subpel_filter = imin(bw4, bh4) == 1 ||
......@@ -1636,11 +1636,11 @@ static int decode_b(Dav1dTileContext *const t,
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]],
t->bx, t->by, bw4, bh4, &f->frame_hdr);
fix_mv_precision(&f->frame_hdr, &b->mv[0]);
b->mv[0] = get_gmv_2d(&f->frame_hdr->gmv[b->ref[0]],
t->bx, t->by, bw4, bh4, f->frame_hdr);
fix_mv_precision(f->frame_hdr, &b->mv[0]);
has_subpel_filter = imin(bw4, bh4) == 1 ||
f->frame_hdr.gmv[b->ref[0]].type == WM_TYPE_TRANSLATION;
f->frame_hdr->gmv[b->ref[0]].type == WM_TYPE_TRANSLATION;
} else {
has_subpel_filter = 1;
if (msac_decode_bool_adapt(&ts->msac,
......@@ -1667,7 +1667,7 @@ static int decode_b(Dav1dTileContext *const t,
b->mv[0] = mvstack[b->drl_idx].this_mv;
} else {
b->mv[0] = mvlist[0][b->drl_idx];
fix_mv_precision(&f->frame_hdr, &b->mv[0]);
fix_mv_precision(f->frame_hdr, &b->mv[0]);
}
}
......@@ -1693,13 +1693,13 @@ static int decode_b(Dav1dTileContext *const t,
b->mv[0] = mvstack[b->drl_idx].this_mv;
} else {
b->mv[0] = mvlist[0][0];
fix_mv_precision(&f->frame_hdr, &b->mv[0]);
fix_mv_precision(f->frame_hdr, &b->mv[0]);
}
if (DEBUG_BLOCK_INFO)
printf("Post-intermode[%d,drl=%d]: r=%d\n",
b->inter_mode, b->drl_idx, ts->msac.rng);
read_mv_residual(t, &b->mv[0], &ts->cdf.mv,
!f->frame_hdr.force_integer_mv);
!f->frame_hdr->force_integer_mv);
if (DEBUG_BLOCK_INFO)
printf("Post-residualmv[mv=y:%d,x:%d]: r=%d\n",
b->mv[0].y, b->mv[0].x, ts->msac.rng);
......@@ -1733,11 +1733,11 @@ static int decode_b(Dav1dTileContext *const t,
}
// motion variation
if (f->frame_hdr.switchable_motion_mode &&
if (f->frame_hdr->switchable_motion_mode &&
b->interintra_type == INTER_INTRA_NONE && imin(bw4, bh4) >= 2 &&
// is not warped global motion
!(!f->frame_hdr.force_integer_mv && b->inter_mode == GLOBALMV &&
f->frame_hdr.gmv[b->ref[0]].type > WM_TYPE_TRANSLATION) &&
!(!f->frame_hdr->force_integer_mv && b->inter_mode == GLOBALMV &&
f->frame_hdr->gmv[b->ref[0]].type > WM_TYPE_TRANSLATION) &&
// has overlappable neighbours
((have_left && findoddzero(&t->l.intra[by4 + 1], h4 >> 1)) ||
(have_top && findoddzero(&t->a->intra[bx4 + 1], w4 >> 1))))
......@@ -1748,8 +1748,8 @@ static int decode_b(Dav1dTileContext *const t,
find_matching_ref(t, intra_edge_flags, bw4, bh4, w4, h4,
have_left, have_top, b->ref[0], mask);
const int allow_warp = !f->svc[b->ref[0]][0].scale &&
!f->frame_hdr.force_integer_mv &&
f->frame_hdr.warp_motion && (mask[0] | mask[1]);
!f->frame_hdr->force_integer_mv &&
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) :
......@@ -1785,7 +1785,7 @@ static int decode_b(Dav1dTileContext *const t,
// subpel filter
enum FilterMode filter[2];
if (f->frame_hdr.subpel_filter_mode == FILTER_SWITCHABLE) {
if (f->frame_hdr->subpel_filter_mode == FILTER_SWITCHABLE) {
if (has_subpel_filter) {
const int comp = b->comp_type != COMP_INTER_NONE;
const int ctx1 = get_filter_ctx(t->a, &t->l, comp, 0, b->ref[0],
......@@ -1813,7 +1813,7 @@ static int decode_b(Dav1dTileContext *const t,
filter[0] = filter[1] = FILTER_8TAP_REGULAR;
}
} else {
filter[0] = filter[1] = f->frame_hdr.subpel_filter_mode;
filter[0] = filter[1] = f->frame_hdr->subpel_filter_mode;
}
b->filter2d = dav1d_filter_2d[filter[1]][filter[0]];
......@@ -1831,7 +1831,7 @@ static int decode_b(Dav1dTileContext *const t,
const uint8_t (*const lf_lvls)[8][2] = (const uint8_t (*)[8][2])
&ts->lflvl[b->seg_id][0][b->ref[0] + 1][!is_globalmv];
dav1d_create_lf_mask_inter(t->lf_mask, f->lf.level, f->b4_stride,
&f->frame_hdr, lf_lvls, t->bx, t->by,
f->frame_hdr, lf_lvls, t->bx, t->by,
f->w4, f->h4, b->skip, bs, b->tx_split,
b->uvtx, f->cur.p.layout,
&t->a->tx_lpf_y[bx4], &t->l.tx_lpf_y[by4],
......@@ -1878,8 +1878,8 @@ static int decode_b(Dav1dTileContext *const t,
}
// update contexts
if (f->frame_hdr.segmentation.enabled &&
f->frame_hdr.segmentation.update_map)
if (f->frame_hdr->segmentation.enabled &&
f->frame_hdr->segmentation.update_map)
{
uint8_t *seg_ptr = &f->cur_segmap[t->by * f->b4_stride + t->bx];
#define set_ctx(type, dir, diridx, off, mul, rep_macro) \
......@@ -1923,7 +1923,7 @@ static int decode_sb(Dav1dTileContext *const t, const enum BlockLevel bl,
if (f->frame_thread.pass != 2) {
if (0 && bl == BL_64X64)
printf("poc=%d,y=%d,x=%d,bl=%d,r=%d\n",
f->frame_hdr.frame_offset, t->by, t->bx, bl, t->ts->msac.rng);
f->frame_hdr->frame_offset, t->by, t->bx, bl, t->ts->msac.rng);
bx8 = (t->bx & 31) >> 1;
by8 = (t->by & 31) >> 1;
ctx = get_partition_ctx(t->a, &t->l, bl, by8, bx8);
......@@ -1946,7 +1946,7 @@ static int decode_sb(Dav1dTileContext *const t, const enum BlockLevel 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, bp,
f->frame_hdr->frame_offset, t->by, t->bx, bl, ctx, bp,
t->ts->msac.rng);
}
const uint8_t *const b = dav1d_block_sizes[bl][bp];
......@@ -2111,7 +2111,7 @@ static int decode_sb(Dav1dTileContext *const t, const enum BlockLevel bl,
is_split = msac_decode_bool(&t->ts->msac, gather_top_partition_prob(pc, bl) >> EC_PROB_SHIFT);
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,
f->frame_hdr->frame_offset, t->by, t->bx, bl, ctx,
is_split ? PARTITION_SPLIT : PARTITION_H, t->ts->msac.rng);
}
......@@ -2141,7 +2141,7 @@ static int decode_sb(Dav1dTileContext *const t, const enum BlockLevel bl,
return 1;
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,
f->frame_hdr->frame_offset, t->by, t->bx, bl, ctx,
is_split ? PARTITION_SPLIT : PARTITION_V, t->ts->msac.rng);
}
......@@ -2205,20 +2205,20 @@ static void setup_tile(Dav1dTileState *const ts,
const int tile_row, const int tile_col,
const int tile_start_off)
{
const int col_sb_start = f->frame_hdr.tiling.col_start_sb[tile_col];
const int col_sb_start = f->frame_hdr->tiling.col_start_sb[tile_col];
const int col_sb128_start = col_sb_start >> !f->seq_hdr->sb128;
const int col_sb_end = f->frame_hdr.tiling.col_start_sb[tile_col + 1];
const int row_sb_start = f->frame_hdr.tiling.row_start_sb[tile_row];
const int row_sb_end = f->frame_hdr.tiling.row_start_sb[tile_row + 1];
const int col_sb_end = f->frame_hdr->tiling.col_start_sb[tile_col + 1];
const int row_sb_start = f->frame_hdr->tiling.row_start_sb[tile_row];
const int row_sb_end = f->frame_hdr->tiling.row_start_sb[tile_row + 1];
const int sb_shift = f->sb_shift;
ts->frame_thread.pal_idx = &f->frame_thread.pal_idx[tile_start_off * 2];
ts->frame_thread.cf = &((int32_t *) f->frame_thread.cf)[tile_start_off * 3];
ts->cdf = *f->in_cdf.cdf;
ts->last_qidx = f->frame_hdr.quant.yac;
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);
msac_init(&ts->msac, data, sz, f->frame_hdr->disable_cdf_update);
ts->tiling.row = tile_row;
ts->tiling.col = tile_col;
......@@ -2229,7 +2229,7 @@ static void setup_tile(Dav1dTileState *const ts,
// Reference Restoration Unit (used for exp coding)
int sb_idx, unit_idx;
if (f->frame_hdr.super_res.enabled) {
if (f->frame_hdr->super_res.enabled) {
// vertical components only
sb_idx = (ts->tiling.row_start >> 5) * f->sr_sb128w;
unit_idx = (ts->tiling.row_start & 16) >> 3;
......@@ -2239,13 +2239,13 @@ static void setup_tile(Dav1dTileState *const ts,
((ts->tiling.col_start & 16) >> 4);
}
for (int p = 0; p < 3; p++) {
if (f->frame_hdr.restoration.type[p] == RESTORATION_NONE)
if (f->frame_hdr->restoration.type[p] == RESTORATION_NONE)
continue;
if (f->frame_hdr.super_res.enabled) {
if (f->frame_hdr->super_res.enabled) {
const int ss_hor = p && f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444;
const int d = f->frame_hdr.super_res.width_scale_denominator;
const int unit_size_log2 = f->frame_hdr.restoration.unit_size[!!p];
const int d = f->frame_hdr->super_res.width_scale_denominator;
const int unit_size_log2 = f->frame_hdr->restoration.unit_size[!!p];
const int rnd = (8 << unit_size_log2) - 1, shift = unit_size_log2 + 3;
const int x = ((4 * ts->tiling.col_start * d >> ss_hor) + rnd) >> shift;
const int px_x = x << (unit_size_log2 + ss_hor);
......@@ -2359,10 +2359,10 @@ int dav1d_decode_tile_sbrow(Dav1dTileContext *const t) {
const Dav1dContext *const c = f->c;
const int sb_step = f->sb_step;
const int tile_row = ts->tiling.row, tile_col = ts->tiling.col;
const int col_sb_start = f->frame_hdr.tiling.col_start_sb[tile_col];
const int col_sb_start = f->frame_hdr->tiling.col_start_sb[tile_col];
const int col_sb128_start = col_sb_start >> !f->seq_hdr->sb128;
reset_context(&t->l, !(f->frame_hdr.frame_type & 1), f->frame_thread.pass);
reset_context(&t->l, !(f->frame_hdr->frame_type & 1), f->frame_thread.pass);
if (f->frame_thread.pass == 2) {
for (t->bx = ts->tiling.col_start,
t->a = f->a + col_sb128_start + tile_row * f->sb128w;
......@@ -2382,7 +2382,7 @@ int dav1d_decode_tile_sbrow(Dav1dTileContext *const t) {
// error out on symbol decoder overread
if (ts->msac.cnt < -15) return 1;
if (c->n_fc > 1 && f->frame_hdr.use_ref_frame_mvs) {
if (c->n_fc > 1 && f->frame_hdr->use_ref_frame_mvs) {
for (int n = 0; n < 7; n++)
if (dav1d_thread_picture_wait(&f->refp[n], 4 * (t->by + sb_step),
PLANE_TYPE_BLOCK))
......@@ -2415,12 +2415,12 @@ int dav1d_decode_tile_sbrow(Dav1dTileContext *const t) {
}
// Restoration filter
for (int p = 0; p < 3; p++) {
if (f->frame_hdr.restoration.type[p] == RESTORATION_NONE)
if (f->frame_hdr->restoration.type[p] == RESTORATION_NONE)
continue;
const int ss_ver = p && f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420;
const int ss_hor = p && f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444;
const int unit_size_log2 = f->frame_hdr.restoration.unit_size[!!p];
const int unit_size_log2 = f->frame_hdr->restoration.unit_size[!!p];
const int y = t->by * 4 >> ss_ver;
const int h = (f->cur.p.h + ss_ver) >> ss_ver;
......@@ -2432,13 +2432,13 @@ int dav1d_decode_tile_sbrow(Dav1dTileContext *const t) {
// restoration unit
if (y && y + half_unit > h) continue;
const enum RestorationType frame_type = f->frame_hdr.restoration.type[p];
const enum RestorationType frame_type = f->frame_hdr->restoration.type[p];
if (f->frame_hdr.super_res.enabled) {
if (f->frame_hdr->super_res.enabled) {
const int w = (f->sr_cur.p.p.w + ss_hor) >> ss_hor;
const int n_units = imax(1, (w + half_unit) >> unit_size_log2);
const int d = f->frame_hdr.super_res.width_scale_denominator;
const int d = f->frame_hdr->super_res.width_scale_denominator;
const int rnd = unit_size * 8 - 1, shift = unit_size_log2 + 3;
const int x0 = ((4 * t->bx * d >> ss_hor) + rnd) >> shift;
const int x1 = ((4 * (t->bx + sb_step) * d >> ss_hor) + rnd) >> shift;
......@@ -2495,43 +2495,43 @@ int dav1d_decode_frame(Dav1dFrameContext *const f) {
int retval = -EINVAL;
if (f->n_tc > 1) {
if (f->frame_hdr.tiling.cols * f->sbh > f->tile_thread.titsati_sz) {
if (f->frame_hdr->tiling.cols * f->sbh > f->tile_thread.titsati_sz) {
freep(&f->tile_thread.task_idx_to_sby_and_tile_idx);
f->tile_thread.task_idx_to_sby_and_tile_idx =
malloc(sizeof(*f->tile_thread.task_idx_to_sby_and_tile_idx) *
f->frame_hdr.tiling.cols * f->sbh);
f->frame_hdr->tiling.cols * f->sbh);
if (!f->tile_thread.task_idx_to_sby_and_tile_idx) return -ENOMEM;
f->tile_thread.titsati_sz = f->frame_hdr.tiling.cols * f->sbh;
f->tile_thread.titsati_sz = f->frame_hdr->tiling.cols * f->sbh;
}
if (f->tile_thread.titsati_init[0] != f->frame_hdr.tiling.cols ||
if (f->tile_thread.titsati_init[0] != f->frame_hdr->tiling.cols ||
f->tile_thread.titsati_init[1] != f->sbh)
{
for (int tile_row = 0, tile_idx = 0;
tile_row < f->frame_hdr.tiling.rows; tile_row++)
tile_row < f->frame_hdr->tiling.rows; tile_row++)
{
for (int sby = f->frame_hdr.tiling.row_start_sb[tile_row];
sby < f->frame_hdr.tiling.row_start_sb[tile_row + 1]; sby++)
for (int sby = f->frame_hdr->tiling.row_start_sb[tile_row];
sby < f->frame_hdr->tiling.row_start_sb[tile_row + 1]; sby++)
{
for (int tile_col = 0; tile_col < f->frame_hdr.tiling.cols;
for (int tile_col = 0; tile_col < f->frame_hdr->tiling.cols;
tile_col++, tile_idx++)
{
f->tile_thread.task_idx_to_sby_and_tile_idx[tile_idx][0] = sby;
f->tile_thread.task_idx_to_sby_and_tile_idx[tile_idx][1] =
tile_row * f->frame_hdr.tiling.cols + tile_col;
tile_row * f->frame_hdr->tiling.cols + tile_col;
}
}
}
f->tile_thread.titsati_init[0] = f->frame_hdr.tiling.cols;
f->tile_thread.titsati_init[0] = f->frame_hdr->tiling.cols;
f->tile_thread.titsati_init[1] = f->sbh;
}
}
if (f->frame_hdr.tiling.cols * f->frame_hdr.tiling.rows > f->n_ts) {
f->ts = realloc(f->ts, f->frame_hdr.tiling.cols *
f->frame_hdr.tiling.rows * sizeof(*f->ts));
if (f->frame_hdr->tiling.cols * f->frame_hdr->tiling.rows > f->n_ts) {
f->ts = realloc(f->ts, f->frame_hdr->tiling.cols *
f->frame_hdr->tiling.rows * sizeof(*f->ts));
if (!f->ts) return -ENOMEM;
for (int n = f->n_ts;
n < f->frame_hdr.tiling.cols * f->frame_hdr.tiling.rows; n++)
n < f->frame_hdr->tiling.cols * f->frame_hdr->tiling.rows; n++)
{
Dav1dTileState *const ts = &f->ts[n];