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)
......
This diff is collapsed.
......@@ -79,7 +79,7 @@ struct Dav1dContext {
int n_tiles;
Dav1dRef *seq_hdr_ref;
Av1SequenceHeader *seq_hdr;
Av1FrameHeader frame_hdr; // FIXME make ref?
Av1FrameHeader *frame_hdr, frame_hdr_mem; // FIXME make ref?
// decoded output picture queue
Dav1dData in;
......@@ -125,7 +125,7 @@ struct Dav1dContext {
struct Dav1dFrameContext {
Dav1dRef *seq_hdr_ref;
Av1SequenceHeader *seq_hdr;
Av1FrameHeader frame_hdr;
Av1FrameHeader *frame_hdr, frame_hdr_mem;
Dav1dThreadPicture refp[7];
Dav1dPicture cur; // during block coding / reconstruction
Dav1dThreadPicture sr_cur; // after super-resolution upscaling
......
......@@ -194,7 +194,7 @@ void bytefn(dav1d_loopfilter_sbrow)(const Dav1dFrameContext *const f,
const uint8_t *lpf_y = &f->lf.tx_lpf_right_edge[0][sby << sbl2];
const uint8_t *lpf_uv = &f->lf.tx_lpf_right_edge[1][sby << (sbl2 - ss_ver)];
for (int tile_col = 1;; tile_col++) {
x = f->frame_hdr.tiling.col_start_sb[tile_col];
x = f->frame_hdr->tiling.col_start_sb[tile_col];
if ((x << sbl2) >= f->bw) break;
const int bx4 = x & is_sb64 ? 16 : 0, cbx4 = bx4 >> ss_hor;
x >>= is_sb64;
......@@ -279,7 +279,7 @@ void bytefn(dav1d_loopfilter_sbrow)(const Dav1dFrameContext *const f,
imin(32, f->w4 - x * 32), starty4, endy4);
}
if (!f->frame_hdr.loopfilter.level_u && !f->frame_hdr.loopfilter.level_v)
if (!f->frame_hdr->loopfilter.level_u && !f->frame_hdr->loopfilter.level_v)
return;
ptrdiff_t uv_off;
......
......@@ -89,6 +89,7 @@ int dav1d_open(Dav1dContext **const c_out,
if (!c) goto error;
memset(c, 0, sizeof(*c));
c->frame_hdr = &c->frame_hdr_mem;
c->allocator = s->allocator;
c->apply_grain = s->apply_grain;
c->operating_point = s->operating_point;
......@@ -107,6 +108,7 @@ int dav1d_open(Dav1dContext **const c_out,
for (int n = 0; n < s->n_frame_threads; n++) {
Dav1dFrameContext *const f = &c->fc[n];
f->c = c;
f->frame_hdr = &f->frame_hdr_mem;
f->lf.last_sharpness = -1;
f->n_tc = s->n_tile_threads;
f->tc = dav1d_alloc_aligned(sizeof(*f->tc) * s->n_tile_threads, 32);
......
......@@ -49,8 +49,8 @@ static void backup_lpf(const Dav1dFrameContext *const f,
const int ss_ver, const int sb128,
int row, const int row_h, const int src_w, const int ss_hor)
{
const int dst_w = f->frame_hdr.super_res.enabled ?
(f->frame_hdr.width[1] + ss_hor) >> ss_hor : src_w;
const int dst_w = f->frame_hdr->super_res.enabled ?
(f->frame_hdr->width[1] + ss_hor) >> ss_hor : src_w;
// The first stripe of the frame is shorter by 8 luma pixel rows.
int stripe_h = (64 - 8 * !row) >> ss_ver;
......@@ -72,7 +72,7 @@ static void backup_lpf(const Dav1dFrameContext *const f,
dst += 4 * PXSTRIDE(dst_stride);
src += (stripe_h - 2) * PXSTRIDE(src_stride);
if (f->frame_hdr.super_res.enabled) {
if (f->frame_hdr->super_res.enabled) {
for (; row + stripe_h <= row_h; row += stripe_h) {
f->dsp->mc.resize(dst, dst_stride, src, src_stride,
dst_w, src_w, 4, f->resize_step[ss_hor],
......@@ -103,9 +103,9 @@ void bytefn(dav1d_lr_copy_lpf)(Dav1dFrameContext *const f,
// TODO Also check block level restore type to reduce copying.
const int restore_planes =
((f->frame_hdr.restoration.type[0] != RESTORATION_NONE) << 0) +
((f->frame_hdr.restoration.type[1] != RESTORATION_NONE) << 1) +
((f->frame_hdr.restoration.type[2] != RESTORATION_NONE) << 2);
((f->frame_hdr->restoration.type[0] != RESTORATION_NONE) << 0) +
((f->frame_hdr->restoration.type[1] != RESTORATION_NONE) << 1) +
((f->frame_hdr->restoration.type[2] != RESTORATION_NONE) << 2);
if (restore_planes & LR_RESTORE_Y) {
const int h = f->bh << 2;
......@@ -211,7 +211,7 @@ static void lr_sbrow(const Dav1dFrameContext *const f, pixel *p, const int y,
const int ss_hor = chroma & (f->sr_cur.p.p.layout != DAV1D_PIXEL_LAYOUT_I444);
const ptrdiff_t p_stride = f->sr_cur.p.stride[chroma];
const int unit_size_log2 = f->frame_hdr.restoration.unit_size[!!plane];
const int unit_size_log2 = f->frame_hdr->restoration.unit_size[!!plane];
const int unit_size = 1 << unit_size_log2;
const int half_unit_size = unit_size >> 1;
const int max_unit_size = unit_size + half_unit_size;
......@@ -271,9 +271,9 @@ void bytefn(dav1d_lr_sbrow)(Dav1dFrameContext *const f, pixel *const dst[3],
const ptrdiff_t *const dst_stride = f->sr_cur.p.stride;
const int restore_planes =
((f->frame_hdr.restoration.type[0] != RESTORATION_NONE) << 0) +
((f->frame_hdr.restoration.type[1] != RESTORATION_NONE) << 1) +
((f->frame_hdr.restoration.type[2] != RESTORATION_NONE) << 2);
((f->frame_hdr->restoration.type[0] != RESTORATION_NONE) << 0) +
((f->frame_hdr->restoration.type[1] != RESTORATION_NONE) << 1) +
((f->frame_hdr->restoration.type[2] != RESTORATION_NONE) << 2);
if (restore_planes & LR_RESTORE_Y) {
const int h = f->sr_cur.p.p.h;
......
......@@ -275,13 +275,13 @@ static int read_frame_size(Dav1dContext *const c, GetBits *const gb,
const int use_ref)
{
const Av1SequenceHeader *const seqhdr = c->seq_hdr;
Av1FrameHeader *const hdr = &c->frame_hdr;
Av1FrameHeader *const hdr = c->frame_hdr;
if (use_ref) {
for (int i = 0; i < 7; i++) {
if (dav1d_get_bits(gb, 1)) {
Dav1dThreadPicture *const ref =
&c->refs[c->frame_hdr.refidx[i]].p;
&c->refs[c->frame_hdr->refidx[i]].p;
if (!ref->p.data[0]) return -1;
// FIXME render_* may be wrong
hdr->render_width = hdr->width[1] = ref->p.p.w;
......@@ -345,7 +345,7 @@ static int parse_frame_hdr(Dav1dContext *const c, GetBits *const gb) {
const uint8_t *const init_ptr = gb->ptr;
#endif
const Av1SequenceHeader *const seqhdr = c->seq_hdr;
Av1FrameHeader *const hdr = &c->frame_hdr;
Av1FrameHeader *const hdr = c->frame_hdr;
int res;
hdr->show_existing_frame =
......@@ -1097,13 +1097,13 @@ error:
static void parse_tile_hdr(Dav1dContext *const c, GetBits *const gb) {
int have_tile_pos = 0;
const int n_tiles = c->frame_hdr.tiling.cols * c->frame_hdr.tiling.rows;
const int n_tiles = c->frame_hdr->tiling.cols * c->frame_hdr->tiling.rows;
if (n_tiles > 1)
have_tile_pos = dav1d_get_bits(gb, 1);
if (have_tile_pos) {
const int n_bits = c->frame_hdr.tiling.log2_cols +
c->frame_hdr.tiling.log2_rows;
const int n_bits = c->frame_hdr->tiling.log2_cols +
c->frame_hdr->tiling.log2_rows;
c->tile[c->n_tile_data].start = dav1d_get_bits(gb, n_bits);
c->tile[c->n_tile_data].end = dav1d_get_bits(gb, n_bits);
} else {
......@@ -1241,8 +1241,8 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in) {
case OBU_FRAME_HDR:
c->have_frame_hdr = 0;
if (!c->seq_hdr) goto error;
c->frame_hdr.temporal_id = temporal_id;
c->frame_hdr.spatial_id = spatial_id;
c->frame_hdr->temporal_id = temporal_id;
c->frame_hdr->spatial_id = spatial_id;
if ((res = parse_frame_hdr(c, &gb)) < 0)
return res;
for (int n = 0; n < c->n_tile_data; n++)
......@@ -1260,7 +1260,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in) {
break;
}
// OBU_FRAMEs shouldn't be signalled with show_existing_frame
if (c->frame_hdr.show_existing_frame) goto error;
if (c->frame_hdr->show_existing_frame) goto error;
c->have_frame_hdr = 1;
......@@ -1314,7 +1314,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in) {
}
if (c->seq_hdr && c->have_frame_hdr &&
c->n_tiles == c->frame_hdr.tiling.cols * c->frame_hdr.tiling.rows)
c->n_tiles == c->frame_hdr->tiling.cols * c->frame_hdr->tiling.rows)
{
if (!c->n_tile_data)
return -EINVAL;
......@@ -1324,11 +1324,11 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in) {
c->have_frame_hdr = 0;
c->n_tiles = 0;
} else if (c->seq_hdr && c->have_frame_hdr &&
c->frame_hdr.show_existing_frame)
c->frame_hdr->show_existing_frame)
{
if (c->n_fc == 1) {
dav1d_picture_ref(&c->out,
&c->refs[c->frame_hdr.existing_frame_idx].p.p);
&c->refs[c->frame_hdr->existing_frame_idx].p.p);
c->out.m = in->m;
} else {
// need to append this to the frame output queue
......@@ -1351,16 +1351,16 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in) {
dav1d_thread_picture_unref(out_delayed);
}
dav1d_thread_picture_ref(out_delayed,
&c->refs[c->frame_hdr.existing_frame_idx].p);
&c->refs[c->frame_hdr->existing_frame_idx].p);
out_delayed->visible = 1;
out_delayed->p.m = in->m;
pthread_mutex_unlock(&f->frame_thread.td.lock);
}
c->have_frame_hdr = 0;
if (c->refs[c->frame_hdr.existing_frame_idx].p.p.p.type == DAV1D_FRAME_TYPE_KEY) {
const int r = c->frame_hdr.existing_frame_idx;
if (c->refs[c->frame_hdr->existing_frame_idx].p.p.p.type == DAV1D_FRAME_TYPE_KEY) {
const int r = c->frame_hdr->existing_frame_idx;
for (int i = 0; i < 8; i++) {
if (i == c->frame_hdr.existing_frame_idx) continue;
if (i == c->frame_hdr->existing_frame_idx) continue;
if (c->refs[i].p.p.data[0])
dav1d_thread_picture_unref(&c->refs[i].p);
......
......@@ -32,7 +32,7 @@
#include "src/levels.h"
#define DEBUG_BLOCK_INFO 0 && \
f->frame_hdr.frame_offset == 2 && t->by >= 0 && t->by < 4 && \
f->frame_hdr->frame_offset == 2 && t->by >= 0 && t->by < 4 && \
t->bx >= 8 && t->bx < 12
#define DEBUG_B_PIXELS 0
......
......@@ -80,7 +80,7 @@ static int decode_coefs(Dav1dTileContext *const t,
t_dim->ctx, sctx, all_skip, ts->msac.rng);
if (all_skip) {
*res_ctx = 0x40;
*txtp = f->frame_hdr.segmentation.lossless[b->seg_id] ? WHT_WHT :
*txtp = f->frame_hdr->segmentation.lossless[b->seg_id] ? WHT_WHT :
DCT_DCT;
return -1;
}
......@@ -88,14 +88,14 @@ static int decode_coefs(Dav1dTileContext *const t,
// transform type (chroma: derived, luma: explicitly coded)
if (chroma) {
if (intra) {
*txtp = get_uv_intra_txtp(b->uv_mode, tx, &f->frame_hdr, b->seg_id);
*txtp = get_uv_intra_txtp(b->uv_mode, tx, f->frame_hdr, b->seg_id);
} else {
const enum TxfmType y_txtp = *txtp;
*txtp = get_uv_inter_txtp(t_dim, y_txtp, &f->frame_hdr, b->seg_id);
*txtp = get_uv_inter_txtp(t_dim, y_txtp, f->frame_hdr, b->seg_id);
}
} else {
const enum TxfmTypeSet set = get_ext_txtp_set(tx, !intra,
&f->frame_hdr, b->seg_id);
f->frame_hdr, b->seg_id);
const unsigned set_cnt = dav1d_tx_type_count[set];
unsigned idx;
if (set_cnt == 1) {
......@@ -1152,9 +1152,9 @@ int bytefn(dav1d_recon_b_inter)(Dav1dTileContext *const t, const enum BlockSize
4 * (t->by * PXSTRIDE(f->cur.stride[0]) + t->bx);
const ptrdiff_t uvdstoff =
4 * ((t->bx >> ss_hor) + (t->by >> ss_ver) * PXSTRIDE(f->cur.stride[1]));
if (!(f->frame_hdr.frame_type & 1)) {
if (!(f->frame_hdr->frame_type & 1)) {
// intrabc
assert(!f->frame_hdr.super_res.enabled);
assert(!f->frame_hdr->super_res.enabled);
res = mc(t, dst, NULL, f->cur.stride[0], bw4, bh4, t->bx, t->by, 0,
b->mv[0], &f->sr_cur, 0 /* unused */, FILTER_2D_BILINEAR);
if (res) return res;
......@@ -1175,7 +1175,7 @@ int bytefn(dav1d_recon_b_inter)(Dav1dTileContext *const t, const enum BlockSize
{
res = warp_affine(t, dst, NULL, f->cur.stride[0], b_dim, 0, refp,
b->motion_mode == MM_WARP ? &t->warpmv :
&f->frame_hdr.gmv[b->ref[0]]);
&f->frame_hdr->gmv[b->ref[0]]);
if (res) return res;
} else {
res = mc(t, dst, NULL, f->cur.stride[0],
......@@ -1291,7 +1291,7 @@ int bytefn(dav1d_recon_b_inter)(Dav1dTileContext *const t, const enum BlockSize
res = warp_affine(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff, NULL,
f->cur.stride[1], b_dim, 1 + pl, refp,
b->motion_mode == MM_WARP ? &t->warpmv :
&f->frame_hdr.gmv[b->ref[0]]);
&f->frame_hdr->gmv[b->ref[0]]);
if (res) return res;
}
} else {
......@@ -1367,7 +1367,7 @@ int bytefn(dav1d_recon_b_inter)(Dav1dTileContext *const t, const enum BlockSize
if (b->inter_mode == GLOBALMV_GLOBALMV && f->gmv_warp_allowed[b->ref[i]]) {
res = warp_affine(t, NULL, tmp[i], bw4 * 4, b_dim, 0, refp,
&f->frame_hdr.gmv[b->ref[i]]);
&f->frame_hdr->gmv[b->ref[i]]);
if (res) return res;
} else {
res = mc(t, NULL, tmp[i], 0, bw4, bh4, t->bx, t->by, 0,
......@@ -1411,7 +1411,7 @@ int bytefn(dav1d_recon_b_inter)(Dav1dTileContext *const t, const enum BlockSize
imin(cbw4, cbh4) > 1 && f->gmv_warp_allowed[b->ref[i]])
{
res = warp_affine(t, NULL, tmp[i], bw4 * 2, b_dim, 1 + pl,
refp, &f->frame_hdr.gmv[b->ref[i]]);
refp, &f->frame_hdr->gmv[b->ref[i]]);
if (res) return res;
} else {
res = mc(t, NULL, tmp[i], 0, bw4, bh4, t->bx, t->by,
......@@ -1569,11 +1569,11 @@ int bytefn(dav1d_recon_b_inter)(Dav1dTileContext *const t, const enum BlockSize
void bytefn(dav1d_filter_sbrow)(Dav1dFrameContext *const f, const int sby) {
const int sbsz = f->sb_step, sbh = f->sbh;
if (f->frame_hdr.loopfilter.level_y[0] ||
f->frame_hdr.loopfilter.level_y[1])
if (f->frame_hdr->loopfilter.level_y[0] ||
f->frame_hdr->loopfilter.level_y[1])
{
int start_of_tile_row = 0;
if (f->frame_hdr.tiling.row_start_sb[f->lf.tile_row] == sby)
if (f->frame_hdr->tiling.row_start_sb[f->lf.tile_row] == sby)
start_of_tile_row = f->lf.tile_row++;
bytefn(dav1d_loopfilter_sbrow)(f, f->lf.p, f->lf.mask_ptr, sby,
start_of_tile_row);
......@@ -1598,7 +1598,7 @@ void bytefn(dav1d_filter_sbrow)(Dav1dFrameContext *const f, const int sby) {
bytefn(dav1d_cdef_brow)(f, f->lf.p, f->lf.mask_ptr, sby * sbsz,
imin(sby * sbsz + n_blks, f->bh));
}
if (f->frame_hdr.super_res.enabled) {
if (f->frame_hdr->super_res.enabled) {
const int has_chroma = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400;
for (int pl = 0; pl < 1 + 2 * has_chroma; pl++) {
const int ss_ver = pl && f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420;
......
......@@ -79,7 +79,7 @@ void *dav1d_tile_task(void *const data) {
const int task_idx = fttd->num_tasks - fttd->tasks_left--;
pthread_mutex_unlock(&fttd->lock);
if (f->frame_thread.pass == 1 || f->n_tc >= f->frame_hdr.tiling.cols) {
if (f->frame_thread.pass == 1 || f->n_tc >= f->frame_hdr->tiling.cols) {
// we can (or in fact, if >, we need to) do full tile decoding.
// loopfilter happens in the main thread
Dav1dTileState *const ts = t->ts = &f->ts[task_idx];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment