Commit e570088d authored by Luc Trudeau's avatar Luc Trudeau Committed by Jean-Baptiste Kempf
Browse files

Check for RESTORATION_NONE once per frame

Prior checks were done at the sbrow level. This now allows to call
dav1d_lr_sbrow and dav1d_lr_copy_lpf only when there's something
for them to do.
parent a4ceff6f
......@@ -2339,7 +2339,7 @@ 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] == DAV1D_RESTORATION_NONE)
if (!((f->lf.restore_planes >> p) & 1U))
continue;
if (f->frame_hdr->super_res.enabled) {
......@@ -2503,7 +2503,7 @@ int dav1d_decode_tile_sbrow(Dav1dTileContext *const t) {
}
// Restoration filter
for (int p = 0; p < 3; p++) {
if (f->frame_hdr->restoration.type[p] == DAV1D_RESTORATION_NONE)
if (!((f->lf.restore_planes >> p) & 1U))
continue;
const int ss_ver = p && f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420;
......@@ -2817,6 +2817,10 @@ int dav1d_decode_frame(Dav1dFrameContext *const f) {
}
f->lf.lr_mask_sz = lr_mask_sz;
}
f->lf.restore_planes =
((f->frame_hdr->restoration.type[0] != DAV1D_RESTORATION_NONE) << 0) +
((f->frame_hdr->restoration.type[1] != DAV1D_RESTORATION_NONE) << 1) +
((f->frame_hdr->restoration.type[2] != DAV1D_RESTORATION_NONE) << 2);
if (f->frame_hdr->loopfilter.sharpness != f->lf.last_sharpness) {
dav1d_calc_eih(&f->lf.lim_lut, f->frame_hdr->loopfilter.sharpness);
f->lf.last_sharpness = f->frame_hdr->loopfilter.sharpness;
......
......@@ -228,6 +228,7 @@ struct Dav1dFrameContext {
int tile_row; // for carry-over at tile row edges
pixel *p[3], *sr_p[3];
Av1Filter *mask_ptr, *prev_mask_ptr;
int restore_planes; // enum LrRestorePlanes
} lf;
// threading (refer to tc[] for per-thread things)
......
......@@ -112,10 +112,7 @@ void bytefn(dav1d_lr_copy_lpf)(Dav1dFrameContext *const f,
const ptrdiff_t lr_stride = ((f->sr_cur.p.p.w + 31) & ~31) * sizeof(pixel);
// TODO Also check block level restore type to reduce copying.
const int restore_planes =
((f->frame_hdr->restoration.type[0] != DAV1D_RESTORATION_NONE) << 0) +
((f->frame_hdr->restoration.type[1] != DAV1D_RESTORATION_NONE) << 1) +
((f->frame_hdr->restoration.type[2] != DAV1D_RESTORATION_NONE) << 2);
const int restore_planes = f->lf.restore_planes;
if (restore_planes & LR_RESTORE_Y) {
const int h = f->cur.p.h;
......@@ -279,11 +276,7 @@ void bytefn(dav1d_lr_sbrow)(Dav1dFrameContext *const f, pixel *const dst[3],
{
const int offset_y = 8 * !!sby;
const ptrdiff_t *const dst_stride = f->sr_cur.p.stride;
const int restore_planes =
((f->frame_hdr->restoration.type[0] != DAV1D_RESTORATION_NONE) << 0) +
((f->frame_hdr->restoration.type[1] != DAV1D_RESTORATION_NONE) << 1) +
((f->frame_hdr->restoration.type[2] != DAV1D_RESTORATION_NONE) << 2);
const int restore_planes = f->lf.restore_planes;
if (restore_planes & LR_RESTORE_Y) {
const int h = f->sr_cur.p.p.h;
......
......@@ -1971,7 +1971,7 @@ void bytefn(dav1d_filter_sbrow)(Dav1dFrameContext *const f, const int sby) {
start_of_tile_row);
}
if (f->seq_hdr->restoration) {
if (f->lf.restore_planes) {
// Store loop filtered pixels required by loop restoration
bytefn(dav1d_lr_copy_lpf)(f, f->lf.p, sby);
}
......@@ -2010,7 +2010,7 @@ void bytefn(dav1d_filter_sbrow)(Dav1dFrameContext *const f, const int sby) {
f->resize_start[!!pl] HIGHBD_CALL_SUFFIX);
}
}
if (f->seq_hdr->restoration) {
if (f->lf.restore_planes) {
bytefn(dav1d_lr_sbrow)(f, f->lf.sr_p, sby);
}
......
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