Commit cb493d82 authored by Rupert Swarbrick's avatar Rupert Swarbrick

Get rid of RestorationInfo::procunit_height and width

These are just RESTORATION_PROC_UNIT_SIZE shifted right by the
vertical or horizontal subsampling for this plane and it's easier not
to have to pass them around.

Change-Id: I86441d6cd86bb146f3e5dcdf2c89e34dd9fed0e1
parent 238a6d63
......@@ -254,18 +254,19 @@ static void copy_tile(int width, int height, const uint8_t *src, int src_stride,
//
// limits gives the rectangular limits of the remaining stripes for the current
// restoration unit. rsb is the stored stripe boundaries (the saved output from
// the deblocker). stripe_height is the height of each stripe. ss_y is true if
// we're on a chroma plane with vertical subsampling. use_highbd is true if the
// data has 2 bytes per pixel. rlbs contain scratch buffers to hold the CDEF
// data (written back to the frame by restore_processing_stripe_boundary)
// the deblocker). ss_y is true if we're on a chroma plane with vertical
// subsampling. use_highbd is true if the data has 2 bytes per pixel. rlbs
// contain scratch buffers to hold the CDEF data (written back to the frame by
// restore_processing_stripe_boundary)
static int setup_processing_stripe_boundary(
const RestorationTileLimits *limits, const RestorationStripeBoundaries *rsb,
int stripe_height, int ss_y, int use_highbd, uint8_t *data8, int stride,
int ss_y, int use_highbd, uint8_t *data8, int stride,
RestorationLineBuffers *rlbs) {
// Which stripe is this? limits->v_start is the top of the stripe in pixel
// units, but we add tile_offset to get the number of pixels from the top of
// the first stripe, which lies off the image.
const int tile_offset = RESTORATION_TILE_OFFSET >> ss_y;
const int stripe_height = RESTORATION_PROC_UNIT_SIZE >> ss_y;
const int stripe_index = (limits->v_start + tile_offset) / stripe_height;
// Horizontal offsets within the line buffers. The buffer logically starts at
......@@ -335,8 +336,9 @@ static int setup_processing_stripe_boundary(
// setup_processing_stripe_boundary.
static void restore_processing_stripe_boundary(
const RestorationTileLimits *limits, const RestorationLineBuffers *rlbs,
int stripe_height, int ss_y, int use_highbd, uint8_t *data8, int stride) {
int ss_y, int use_highbd, uint8_t *data8, int stride) {
const int tile_offset = RESTORATION_TILE_OFFSET >> ss_y;
const int stripe_height = RESTORATION_PROC_UNIT_SIZE >> ss_y;
const int stripe_index = (limits->v_start + tile_offset) / stripe_height;
const int line_width =
......@@ -1344,16 +1346,13 @@ static const stripe_filter_fun stripe_filters[NUM_STRIPE_FILTERS] = {
#endif // CONFIG_HIGHBITDEPTH
};
void av1_loop_restoration_filter_unit(const RestorationTileLimits *limits,
const RestorationUnitInfo *rui,
void av1_loop_restoration_filter_unit(
const RestorationTileLimits *limits, const RestorationUnitInfo *rui,
#if CONFIG_STRIPED_LOOP_RESTORATION
const RestorationStripeBoundaries *rsb,
RestorationLineBuffers *rlbs, int ss_y,
const RestorationStripeBoundaries *rsb, RestorationLineBuffers *rlbs,
#endif
int procunit_width, int procunit_height,
int highbd, int bit_depth, uint8_t *data8,
int stride, uint8_t *dst8, int dst_stride,
int32_t *tmpbuf) {
int ss_x, int ss_y, int highbd, int bit_depth, uint8_t *data8, int stride,
uint8_t *dst8, int dst_stride, int32_t *tmpbuf) {
RestorationType unit_rtype = rui->restoration_type;
int unit_h = limits->v_end - limits->v_start;
......@@ -1370,6 +1369,8 @@ void av1_loop_restoration_filter_unit(const RestorationTileLimits *limits,
assert(filter_idx < NUM_STRIPE_FILTERS);
const stripe_filter_fun stripe_filter = stripe_filters[filter_idx];
const int procunit_width = RESTORATION_PROC_UNIT_SIZE >> ss_x;
// Convolve the whole tile one stripe at a time
#if CONFIG_STRIPED_LOOP_RESTORATION
RestorationTileLimits remaining_stripes = *limits;
......@@ -1378,19 +1379,19 @@ void av1_loop_restoration_filter_unit(const RestorationTileLimits *limits,
while (i < unit_h) {
#if CONFIG_STRIPED_LOOP_RESTORATION
remaining_stripes.v_start = limits->v_start + i;
int h = setup_processing_stripe_boundary(&remaining_stripes, rsb,
procunit_height, ss_y, highbd,
data8, stride, rlbs);
int h = setup_processing_stripe_boundary(&remaining_stripes, rsb, ss_y,
highbd, data8, stride, rlbs);
#else
const int h = AOMMIN(procunit_height, (unit_h - i + 15) & ~15);
const int h =
AOMMIN(RESTORATION_PROC_UNIT_SIZE >> ss_y, (unit_h - i + 15) & ~15);
#endif
stripe_filter(rui, unit_w, h, procunit_width, data8_tl + i * stride, stride,
dst8_tl + i * dst_stride, dst_stride, tmpbuf, bit_depth);
#if CONFIG_STRIPED_LOOP_RESTORATION
restore_processing_stripe_boundary(
&remaining_stripes, rlbs, procunit_height, ss_y, highbd, data8, stride);
restore_processing_stripe_boundary(&remaining_stripes, rlbs, ss_y, highbd,
data8, stride);
#endif
i += h;
......@@ -1401,8 +1402,8 @@ typedef struct {
const RestorationInfo *rsi;
#if CONFIG_STRIPED_LOOP_RESTORATION
RestorationLineBuffers *rlbs;
int ss_y;
#endif
int ss_x, ss_y;
int highbd, bit_depth;
uint8_t *data8, *dst8;
int data_stride, dst_stride;
......@@ -1414,14 +1415,13 @@ static void filter_frame_on_unit(const RestorationTileLimits *limits,
FilterFrameCtxt *ctxt = (FilterFrameCtxt *)priv;
const RestorationInfo *rsi = ctxt->rsi;
av1_loop_restoration_filter_unit(limits, &rsi->unit_info[rest_unit_idx],
av1_loop_restoration_filter_unit(
limits, &rsi->unit_info[rest_unit_idx],
#if CONFIG_STRIPED_LOOP_RESTORATION
&rsi->boundaries, ctxt->rlbs, ctxt->ss_y,
&rsi->boundaries, ctxt->rlbs,
#endif
rsi->procunit_width, rsi->procunit_height,
ctxt->highbd, ctxt->bit_depth, ctxt->data8,
ctxt->data_stride, ctxt->dst8,
ctxt->dst_stride, ctxt->tmpbuf);
ctxt->ss_x, ctxt->ss_y, ctxt->highbd, ctxt->bit_depth, ctxt->data8,
ctxt->data_stride, ctxt->dst8, ctxt->dst_stride, ctxt->tmpbuf);
}
void av1_loop_restoration_filter_frame(YV12_BUFFER_CONFIG *frame,
......@@ -1498,10 +1498,10 @@ void av1_loop_restoration_filter_frame(YV12_BUFFER_CONFIG *frame,
FilterFrameCtxt ctxt;
ctxt.rsi = prsi;
#if CONFIG_STRIPED_LOOP_RESTORATION
const int ss_y = is_uv && cm->subsampling_y;
ctxt.rlbs = &rlbs;
ctxt.ss_y = ss_y;
#endif
ctxt.ss_x = is_uv && cm->subsampling_x;
ctxt.ss_y = is_uv && cm->subsampling_y;
ctxt.highbd = highbd;
ctxt.bit_depth = bit_depth;
ctxt.data8 = frame->buffers[plane];
......
......@@ -242,7 +242,6 @@ typedef struct {
typedef struct {
RestorationType frame_restoration_type;
int restoration_unit_size;
int procunit_width, procunit_height;
// Fields below here are allocated and initialised by
// av1_alloc_restoration_struct. (horz_)units_per_tile give the number of
......@@ -297,12 +296,11 @@ void decode_xq(const int *xqd, int *xq);
// limits is the limits of the unit. rui gives the mode to use for this unit
// and its coefficients. If striped loop restoration is enabled, rsb contains
// deblocked pixels to use for stripe boundaries; rlbs is just some space to
// use as a scratch buffer. ss_y is a flag which should be 1 if this is a plane
// with vertical subsampling.
// use as a scratch buffer.
//
// procunit_width and procunit_height are the width and height in which to
// process the data. highbd is a flag which should be 1 in high bit depth mode,
// in which case bit_depth is the bit depth.
// ss_x and ss_y are flags which should be 1 if this is a plane with
// horizontal/vertical subsampling, respectively. highbd is a flag which should
// be 1 in high bit depth mode, in which case bit_depth is the bit depth.
//
// data8 is the frame data (pointing at the top-left corner of the frame, not
// the restoration unit) and stride is its stride. dst8 is the buffer where the
......@@ -311,16 +309,13 @@ void decode_xq(const int *xqd, int *xq);
//
// Finally tmpbuf is a scratch buffer used by the sgrproj filter which should
// be at least SGRPROJ_TMPBUF_SIZE big.
void av1_loop_restoration_filter_unit(const RestorationTileLimits *limits,
const RestorationUnitInfo *rui,
void av1_loop_restoration_filter_unit(
const RestorationTileLimits *limits, const RestorationUnitInfo *rui,
#if CONFIG_STRIPED_LOOP_RESTORATION
const RestorationStripeBoundaries *rsb,
RestorationLineBuffers *rlbs, int ss_y,
const RestorationStripeBoundaries *rsb, RestorationLineBuffers *rlbs,
#endif
int procunit_height, int procunit_width,
int highbd, int bit_depth, uint8_t *data8,
int stride, uint8_t *dst8, int dst_stride,
int32_t *tmpbuf);
int ss_x, int ss_y, int highbd, int bit_depth, uint8_t *data8, int stride,
uint8_t *dst8, int dst_stride, int32_t *tmpbuf);
void av1_loop_restoration_filter_frame(YV12_BUFFER_CONFIG *frame,
struct AV1Common *cm,
......
......@@ -1246,13 +1246,6 @@ static void decode_restoration_mode(AV1_COMMON *cm,
cm->rst_info[0].restoration_unit_size;
}
cm->rst_info[2].restoration_unit_size = cm->rst_info[1].restoration_unit_size;
cm->rst_info[0].procunit_width = cm->rst_info[0].procunit_height =
RESTORATION_PROC_UNIT_SIZE;
cm->rst_info[1].procunit_width = cm->rst_info[2].procunit_width =
RESTORATION_PROC_UNIT_SIZE >> cm->subsampling_x;
cm->rst_info[1].procunit_height = cm->rst_info[2].procunit_height =
RESTORATION_PROC_UNIT_SIZE >> cm->subsampling_y;
}
static void read_wiener_filter(int wiener_win, WienerInfo *wiener_info,
......
......@@ -4171,12 +4171,6 @@ static void set_restoration_unit_size(int width, int height, int sx, int sy,
rst[0].restoration_unit_size = (RESTORATION_TILESIZE_MAX >> 1);
rst[1].restoration_unit_size = rst[0].restoration_unit_size >> s;
rst[2].restoration_unit_size = rst[1].restoration_unit_size;
rst[0].procunit_width = rst[0].procunit_height = RESTORATION_PROC_UNIT_SIZE;
rst[1].procunit_width = rst[2].procunit_width =
RESTORATION_PROC_UNIT_SIZE >> sx;
rst[1].procunit_height = rst[2].procunit_height =
RESTORATION_PROC_UNIT_SIZE >> sy;
}
#endif // CONFIG_LOOP_RESTORATION
......
......@@ -75,11 +75,10 @@ static int64_t try_restoration_tile(const AV1_COMMON *cm,
const RestorationTileLimits *limits,
const RestorationUnitInfo *rui,
YV12_BUFFER_CONFIG *dst, int plane) {
const RestorationInfo *rsi = &cm->rst_info[plane];
const int is_uv = plane > 0;
#if CONFIG_STRIPED_LOOP_RESTORATION
const RestorationInfo *rsi = &cm->rst_info[plane];
RestorationLineBuffers rlbs;
const int ss_y = is_uv && cm->subsampling_y;
#endif
#if CONFIG_HIGHBITDEPTH
const int bit_depth = cm->bit_depth;
......@@ -91,14 +90,14 @@ static int64_t try_restoration_tile(const AV1_COMMON *cm,
const YV12_BUFFER_CONFIG *fts = cm->frame_to_show;
av1_loop_restoration_filter_unit(limits, rui,
av1_loop_restoration_filter_unit(
limits, rui,
#if CONFIG_STRIPED_LOOP_RESTORATION
&rsi->boundaries, &rlbs, ss_y,
&rsi->boundaries, &rlbs,
#endif
rsi->procunit_width, rsi->procunit_height,
highbd, bit_depth, fts->buffers[plane],
fts->strides[is_uv], dst->buffers[plane],
dst->strides[is_uv], cm->rst_tmpbuf);
is_uv && cm->subsampling_x, is_uv && cm->subsampling_y, highbd, bit_depth,
fts->buffers[plane], fts->strides[is_uv], dst->buffers[plane],
dst->strides[is_uv], cm->rst_tmpbuf);
return sse_restoration_tile(limits, src, dst, plane, highbd);
}
......@@ -472,8 +471,6 @@ static void search_sgrproj(const RestorationTileLimits *limits,
const MACROBLOCK *const x = rsc->x;
const AV1_COMMON *const cm = rsc->cm;
const RestorationInfo *rsi = &cm->rst_info[rsc->plane];
#if CONFIG_HIGHBITDEPTH
const int highbd = cm->use_highbitdepth;
const int bit_depth = cm->bit_depth;
......@@ -487,11 +484,17 @@ static void search_sgrproj(const RestorationTileLimits *limits,
const uint8_t *src_start =
rsc->src_buffer + limits->v_start * rsc->src_stride + limits->h_start;
const int is_uv = rsc->plane > 0;
const int ss_x = is_uv && cm->subsampling_x;
const int ss_y = is_uv && cm->subsampling_y;
const int procunit_width = RESTORATION_PROC_UNIT_SIZE >> ss_x;
const int procunit_height = RESTORATION_PROC_UNIT_SIZE >> ss_y;
rusi->sgrproj = search_selfguided_restoration(
dgd_start, limits->h_end - limits->h_start,
limits->v_end - limits->v_start, rsc->dgd_stride, src_start,
rsc->src_stride, highbd, bit_depth, rsi->procunit_width,
rsi->procunit_height, cm->rst_tmpbuf);
rsc->src_stride, highbd, bit_depth, procunit_width, procunit_height,
cm->rst_tmpbuf);
RestorationUnitInfo rui;
rui.restoration_type = RESTORE_SGRPROJ;
......
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