Commit 5d2e729e authored by Rupert Swarbrick's avatar Rupert Swarbrick
Browse files

Simplify av1_get_rest_tile_limits

The subtile and clamping features are no longer used. This patch
removes the dead code that implemented them and the parameters to
support them.

It also changes the return format. Instead of having return type void
and passing data out through 4 output pointers, the function now just
returns a RestorationTileLimits structure. Since the function is
defined inline in a header, I suspect that most callsites will
actually compile to identical code.

There should be no functional change from this patch.

Change-Id: I6ebc4da66a00676bd988f939a4b4957f743e8004
parent 87fe5b96
......@@ -123,20 +123,17 @@ void extend_frame(uint8_t *data, int width, int height, int stride,
}
}
static void loop_copy_tile(uint8_t *data, int tile_idx, int subtile_idx,
int subtile_bits, int width, int height, int stride,
RestorationInternal *rst, uint8_t *dst,
static void loop_copy_tile(uint8_t *data, int tile_idx, int width, int height,
int stride, RestorationInternal *rst, uint8_t *dst,
int dst_stride) {
const int tile_width = rst->tile_width;
const int tile_height = rst->tile_height;
int i;
int h_start, h_end, v_start, v_end;
av1_get_rest_tile_limits(tile_idx, subtile_idx, subtile_bits, rst->nhtiles,
rst->nvtiles, tile_width, tile_height, width, height,
0, 0, &h_start, &h_end, &v_start, &v_end);
for (i = v_start; i < v_end; ++i)
memcpy(dst + i * dst_stride + h_start, data + i * stride + h_start,
h_end - h_start);
RestorationTileLimits limits =
av1_get_rest_tile_limits(tile_idx, rst->nhtiles, rst->nvtiles, tile_width,
tile_height, width, height);
for (int i = limits.v_start; i < limits.v_end; ++i)
memcpy(dst + i * dst_stride + limits.h_start,
data + i * stride + limits.h_start, limits.h_end - limits.h_start);
}
static void stepdown_wiener_kernel(const InterpKernel orig, InterpKernel vert,
......@@ -179,23 +176,20 @@ static void loop_wiener_filter_tile(uint8_t *data, int tile_idx, int width,
const int procunit_height = rst->rsi->procunit_height;
const int tile_width = rst->tile_width;
const int tile_height = rst->tile_height;
int i, j;
int h_start, h_end, v_start, v_end;
if (rst->rsi->restoration_type[tile_idx] == RESTORE_NONE) {
loop_copy_tile(data, tile_idx, 0, 0, width, height, stride, rst, dst,
dst_stride);
loop_copy_tile(data, tile_idx, width, height, stride, rst, dst, dst_stride);
return;
}
InterpKernel vertical_topbot;
av1_get_rest_tile_limits(tile_idx, 0, 0, rst->nhtiles, rst->nvtiles,
tile_width, tile_height, width, height, 0, 0,
&h_start, &h_end, &v_start, &v_end);
RestorationTileLimits limits =
av1_get_rest_tile_limits(tile_idx, rst->nhtiles, rst->nvtiles, tile_width,
tile_height, width, height);
// Convolve the whole tile (done in blocks here to match the requirements
// of the vectorized convolve functions, but the result is equivalent)
for (i = v_start; i < v_end; i += procunit_height)
for (j = h_start; j < h_end; j += procunit_width) {
int w = AOMMIN(procunit_width, (h_end - j + 15) & ~15);
int h = AOMMIN(procunit_height, (v_end - i + 15) & ~15);
for (int i = limits.v_start; i < limits.v_end; i += procunit_height)
for (int j = limits.h_start; j < limits.h_end; j += procunit_width) {
int w = AOMMIN(procunit_width, (limits.h_end - j + 15) & ~15);
int h = AOMMIN(procunit_height, (limits.v_end - i + 15) & ~15);
const uint8_t *data_p = data + i * stride + j;
uint8_t *dst_p = dst + i * dst_stride + j;
// Note h is at least 16
......@@ -987,21 +981,17 @@ static void loop_sgrproj_filter_tile(uint8_t *data, int tile_idx, int width,
const int procunit_height = rst->rsi->procunit_height;
const int tile_width = rst->tile_width;
const int tile_height = rst->tile_height;
int i, j;
int h_start, h_end, v_start, v_end;
if (rst->rsi->restoration_type[tile_idx] == RESTORE_NONE) {
loop_copy_tile(data, tile_idx, 0, 0, width, height, stride, rst, dst,
dst_stride);
loop_copy_tile(data, tile_idx, width, height, stride, rst, dst, dst_stride);
return;
}
av1_get_rest_tile_limits(tile_idx, 0, 0, rst->nhtiles, rst->nvtiles,
tile_width, tile_height, width, height, 0, 0,
&h_start, &h_end, &v_start, &v_end);
for (i = v_start; i < v_end; i += procunit_height)
for (j = h_start; j < h_end; j += procunit_width) {
int w = AOMMIN(procunit_width, h_end - j);
int h = AOMMIN(procunit_height, v_end - i);
RestorationTileLimits limits =
av1_get_rest_tile_limits(tile_idx, rst->nhtiles, rst->nvtiles, tile_width,
tile_height, width, height);
for (int i = limits.v_start; i < limits.v_end; i += procunit_height)
for (int j = limits.h_start; j < limits.h_end; j += procunit_width) {
int w = AOMMIN(procunit_width, limits.h_end - j);
int h = AOMMIN(procunit_height, limits.v_end - i);
uint8_t *data_p = data + i * stride + j;
uint8_t *dst_p = dst + i * dst_stride + j;
apply_selfguided_restoration(
......@@ -1030,7 +1020,7 @@ static void loop_switchable_filter(uint8_t *data, int width, int height,
RESTORATION_BORDER_VERT);
for (tile_idx = 0; tile_idx < rst->ntiles; ++tile_idx) {
if (rst->rsi->restoration_type[tile_idx] == RESTORE_NONE) {
loop_copy_tile(data, tile_idx, 0, 0, width, height, stride, rst, dst,
loop_copy_tile(data, tile_idx, width, height, stride, rst, dst,
dst_stride);
} else if (rst->rsi->restoration_type[tile_idx] == RESTORE_WIENER) {
loop_wiener_filter_tile(data, tile_idx, width, height, stride, rst, dst,
......@@ -1063,20 +1053,19 @@ void extend_frame_highbd(uint16_t *data, int width, int height, int stride,
}
}
static void loop_copy_tile_highbd(uint16_t *data, int tile_idx, int subtile_idx,
int subtile_bits, int width, int height,
int stride, RestorationInternal *rst,
uint16_t *dst, int dst_stride) {
static void loop_copy_tile_highbd(uint16_t *data, int tile_idx, int width,
int height, int stride,
RestorationInternal *rst, uint16_t *dst,
int dst_stride) {
const int tile_width = rst->tile_width;
const int tile_height = rst->tile_height;
int i;
int h_start, h_end, v_start, v_end;
av1_get_rest_tile_limits(tile_idx, subtile_idx, subtile_bits, rst->nhtiles,
rst->nvtiles, tile_width, tile_height, width, height,
0, 0, &h_start, &h_end, &v_start, &v_end);
for (i = v_start; i < v_end; ++i)
memcpy(dst + i * dst_stride + h_start, data + i * stride + h_start,
(h_end - h_start) * sizeof(*dst));
RestorationTileLimits limits =
av1_get_rest_tile_limits(tile_idx, rst->nhtiles, rst->nvtiles, tile_width,
tile_height, width, height);
for (int i = limits.v_start; i < limits.v_end; ++i)
memcpy(dst + i * dst_stride + limits.h_start,
data + i * stride + limits.h_start,
(limits.h_end - limits.h_start) * sizeof(*dst));
}
static void loop_wiener_filter_tile_highbd(uint16_t *data, int tile_idx,
......@@ -1088,24 +1077,22 @@ static void loop_wiener_filter_tile_highbd(uint16_t *data, int tile_idx,
const int procunit_height = rst->rsi->procunit_height;
const int tile_width = rst->tile_width;
const int tile_height = rst->tile_height;
int h_start, h_end, v_start, v_end;
int i, j;
if (rst->rsi->restoration_type[tile_idx] == RESTORE_NONE) {
loop_copy_tile_highbd(data, tile_idx, 0, 0, width, height, stride, rst, dst,
loop_copy_tile_highbd(data, tile_idx, width, height, stride, rst, dst,
dst_stride);
return;
}
av1_get_rest_tile_limits(tile_idx, 0, 0, rst->nhtiles, rst->nvtiles,
tile_width, tile_height, width, height, 0, 0,
&h_start, &h_end, &v_start, &v_end);
RestorationTileLimits limits =
av1_get_rest_tile_limits(tile_idx, rst->nhtiles, rst->nvtiles, tile_width,
tile_height, width, height);
InterpKernel vertical_topbot;
// Convolve the whole tile (done in blocks here to match the requirements
// of the vectorized convolve functions, but the result is equivalent)
for (i = v_start; i < v_end; i += procunit_height)
for (j = h_start; j < h_end; j += procunit_width) {
int w = AOMMIN(procunit_width, (h_end - j + 15) & ~15);
int h = AOMMIN(procunit_height, (v_end - i + 15) & ~15);
for (int i = limits.v_start; i < limits.v_end; i += procunit_height)
for (int j = limits.h_start; j < limits.h_end; j += procunit_width) {
int w = AOMMIN(procunit_width, (limits.h_end - j + 15) & ~15);
int h = AOMMIN(procunit_height, (limits.v_end - i + 15) & ~15);
const uint16_t *data_p = data + i * stride + j;
uint16_t *dst_p = dst + i * dst_stride + j;
// Note h is at least 16
......@@ -1331,21 +1318,19 @@ static void loop_sgrproj_filter_tile_highbd(uint16_t *data, int tile_idx,
const int procunit_height = rst->rsi->procunit_height;
const int tile_width = rst->tile_width;
const int tile_height = rst->tile_height;
int i, j;
int h_start, h_end, v_start, v_end;
if (rst->rsi->restoration_type[tile_idx] == RESTORE_NONE) {
loop_copy_tile_highbd(data, tile_idx, 0, 0, width, height, stride, rst, dst,
loop_copy_tile_highbd(data, tile_idx, width, height, stride, rst, dst,
dst_stride);
return;
}
av1_get_rest_tile_limits(tile_idx, 0, 0, rst->nhtiles, rst->nvtiles,
tile_width, tile_height, width, height, 0, 0,
&h_start, &h_end, &v_start, &v_end);
for (i = v_start; i < v_end; i += procunit_height)
for (j = h_start; j < h_end; j += procunit_width) {
int w = AOMMIN(procunit_width, h_end - j);
int h = AOMMIN(procunit_height, v_end - i);
RestorationTileLimits limits =
av1_get_rest_tile_limits(tile_idx, rst->nhtiles, rst->nvtiles, tile_width,
tile_height, width, height);
for (int i = limits.v_start; i < limits.v_end; i += procunit_height)
for (int j = limits.h_start; j < limits.h_end; j += procunit_width) {
int w = AOMMIN(procunit_width, limits.h_end - j);
int h = AOMMIN(procunit_height, limits.v_end - i);
uint16_t *data_p = data + i * stride + j;
uint16_t *dst_p = dst + i * dst_stride + j;
apply_selfguided_restoration_highbd(
......@@ -1380,8 +1365,8 @@ static void loop_switchable_filter_highbd(uint8_t *data8, int width, int height,
RESTORATION_BORDER_VERT);
for (tile_idx = 0; tile_idx < rst->ntiles; ++tile_idx) {
if (rst->rsi->restoration_type[tile_idx] == RESTORE_NONE) {
loop_copy_tile_highbd(data, tile_idx, 0, 0, width, height, stride, rst,
dst, dst_stride);
loop_copy_tile_highbd(data, tile_idx, width, height, stride, rst, dst,
dst_stride);
} else if (rst->rsi->restoration_type[tile_idx] == RESTORE_WIENER) {
loop_wiener_filter_tile_highbd(data, tile_idx, width, height, stride, rst,
bit_depth, dst, dst_stride);
......
......@@ -232,37 +232,21 @@ static INLINE int av1_get_rest_ntiles(int width, int height, int tilesize,
return (nhtiles_ * nvtiles_);
}
static INLINE void av1_get_rest_tile_limits(
int tile_idx, int subtile_idx, int subtile_bits, int nhtiles, int nvtiles,
int tile_width, int tile_height, int im_width, int im_height, int clamp_h,
int clamp_v, int *h_start, int *h_end, int *v_start, int *v_end) {
typedef struct { int h_start, h_end, v_start, v_end; } RestorationTileLimits;
static INLINE RestorationTileLimits
av1_get_rest_tile_limits(int tile_idx, int nhtiles, int nvtiles, int tile_width,
int tile_height, int im_width, int im_height) {
const int htile_idx = tile_idx % nhtiles;
const int vtile_idx = tile_idx / nhtiles;
*h_start = htile_idx * tile_width;
*v_start = vtile_idx * tile_height;
*h_end = (htile_idx < nhtiles - 1) ? *h_start + tile_width : im_width;
*v_end = (vtile_idx < nvtiles - 1) ? *v_start + tile_height : im_height;
if (subtile_bits) {
const int num_subtiles_1d = (1 << subtile_bits);
const int subtile_width = (*h_end - *h_start) >> subtile_bits;
const int subtile_height = (*v_end - *v_start) >> subtile_bits;
const int subtile_idx_h = subtile_idx & (num_subtiles_1d - 1);
const int subtile_idx_v = subtile_idx >> subtile_bits;
*h_start += subtile_idx_h * subtile_width;
*v_start += subtile_idx_v * subtile_height;
*h_end = subtile_idx_h == num_subtiles_1d - 1 ? *h_end
: *h_start + subtile_width;
*v_end = subtile_idx_v == num_subtiles_1d - 1 ? *v_end
: *v_start + subtile_height;
}
if (clamp_h) {
*h_start = AOMMAX(*h_start, clamp_h);
*h_end = AOMMIN(*h_end, im_width - clamp_h);
}
if (clamp_v) {
*v_start = AOMMAX(*v_start, clamp_v);
*v_end = AOMMIN(*v_end, im_height - clamp_v);
}
RestorationTileLimits limits;
limits.h_start = htile_idx * tile_width;
limits.v_start = vtile_idx * tile_height;
limits.h_end =
(htile_idx < nhtiles - 1) ? limits.h_start + tile_width : im_width;
limits.v_end =
(vtile_idx < nvtiles - 1) ? limits.v_start + tile_height : im_height;
return limits;
}
extern const sgr_params_type sgr_params[SGRPROJ_PARAMS];
......
......@@ -124,13 +124,11 @@ static int64_t sse_restoration_frame(AV1_COMMON *const cm,
static int64_t try_restoration_tile(const YV12_BUFFER_CONFIG *src,
AV1_COMP *const cpi, RestorationInfo *rsi,
int components_pattern, int partial_frame,
int tile_idx, int subtile_idx,
int subtile_bits,
int tile_idx,
YV12_BUFFER_CONFIG *dst_frame) {
AV1_COMMON *const cm = &cpi->common;
int64_t filt_err;
int tile_width, tile_height, nhtiles, nvtiles;
int h_start, h_end, v_start, v_end;
int ntiles, width, height;
// Y and UV components cannot be mixed
......@@ -151,11 +149,11 @@ static int64_t try_restoration_tile(const YV12_BUFFER_CONFIG *src,
av1_loop_restoration_frame(cm->frame_to_show, cm, rsi, components_pattern,
partial_frame, dst_frame);
av1_get_rest_tile_limits(tile_idx, subtile_idx, subtile_bits, nhtiles,
nvtiles, tile_width, tile_height, width, height, 0,
0, &h_start, &h_end, &v_start, &v_end);
filt_err = sse_restoration_tile(src, dst_frame, cm, h_start, h_end - h_start,
v_start, v_end - v_start, components_pattern);
RestorationTileLimits limits = av1_get_rest_tile_limits(
tile_idx, nhtiles, nvtiles, tile_width, tile_height, width, height);
filt_err = sse_restoration_tile(
src, dst_frame, cm, limits.h_start, limits.h_end - limits.h_start,
limits.v_start, limits.v_end - limits.v_start, components_pattern);
return filt_err;
}
......@@ -513,8 +511,8 @@ static INLINE int init_rest_search_ctxt(
}
typedef void (*rtile_visitor_t)(const struct rest_search_ctxt *search_ctxt,
int rtile_idx, int h_start, int h_end,
int v_start, int v_end, void *arg);
int rtile_idx,
const RestorationTileLimits *limits, void *arg);
static void foreach_rtile_in_tile(const struct rest_search_ctxt *ctxt,
int tile_row, int tile_col,
......@@ -550,20 +548,18 @@ static void foreach_rtile_in_tile(const struct rest_search_ctxt *ctxt,
for (int rtile_row = rtile_row0; rtile_row < rtile_row1; ++rtile_row) {
for (int rtile_col = rtile_col0; rtile_col < rtile_col1; ++rtile_col) {
const int rtile_idx = rtile_row * ctxt->nrtiles_x + rtile_col;
int h_start, h_end, v_start, v_end;
av1_get_rest_tile_limits(rtile_idx, 0, 0, ctxt->nrtiles_x,
ctxt->nrtiles_y, rtile_width, rtile_height,
ctxt->plane_width, ctxt->plane_height, 0, 0,
&h_start, &h_end, &v_start, &v_end);
fun(ctxt, rtile_idx, h_start, h_end, v_start, v_end, arg);
RestorationTileLimits limits = av1_get_rest_tile_limits(
rtile_idx, ctxt->nrtiles_x, ctxt->nrtiles_y, rtile_width,
rtile_height, ctxt->plane_width, ctxt->plane_height);
fun(ctxt, rtile_idx, &limits, arg);
}
}
}
static void search_sgrproj_for_rtile(const struct rest_search_ctxt *ctxt,
int rtile_idx, int h_start, int h_end,
int v_start, int v_end, void *arg) {
int rtile_idx,
const RestorationTileLimits *limits,
void *arg) {
const MACROBLOCK *const x = &ctxt->cpi->td.mb;
const AV1_COMMON *const cm = &ctxt->cpi->common;
RestorationInfo *rsi = ctxt->cpi->rst_search;
......@@ -571,9 +567,10 @@ static void search_sgrproj_for_rtile(const struct rest_search_ctxt *ctxt,
SgrprojInfo *ref_sgrproj_info = (SgrprojInfo *)arg;
int64_t err = sse_restoration_tile(ctxt->src, cm->frame_to_show, cm, h_start,
h_end - h_start, v_start, v_end - v_start,
(1 << ctxt->plane));
int64_t err =
sse_restoration_tile(ctxt->src, cm->frame_to_show, cm, limits->h_start,
limits->h_end - limits->h_start, limits->v_start,
limits->v_end - limits->v_start, (1 << ctxt->plane));
// #bits when a tile is not restored
int bits = av1_cost_bit(RESTORE_NONE_SGRPROJ_PROB, 0);
double cost_norestore = RDCOST_DBL(x->rdmult, (bits >> 4), err);
......@@ -581,12 +578,14 @@ static void search_sgrproj_for_rtile(const struct rest_search_ctxt *ctxt,
RestorationInfo *plane_rsi = &rsi[ctxt->plane];
SgrprojInfo *rtile_sgrproj_info = &plane_rsi->sgrproj_info[rtile_idx];
uint8_t *dgd_start = ctxt->dgd_buffer + v_start * ctxt->dgd_stride + h_start;
uint8_t *dgd_start =
ctxt->dgd_buffer + limits->v_start * ctxt->dgd_stride + limits->h_start;
const uint8_t *src_start =
ctxt->src_buffer + v_start * ctxt->src_stride + h_start;
ctxt->src_buffer + limits->v_start * ctxt->src_stride + limits->h_start;
search_selfguided_restoration(
dgd_start, h_end - h_start, v_end - v_start, ctxt->dgd_stride, src_start,
dgd_start, limits->h_end - limits->h_start,
limits->v_end - limits->v_start, ctxt->dgd_stride, src_start,
ctxt->src_stride,
#if CONFIG_HIGHBITDEPTH
cm->use_highbitdepth, cm->bit_depth,
......@@ -598,8 +597,7 @@ static void search_sgrproj_for_rtile(const struct rest_search_ctxt *ctxt,
cm->rst_internal.tmpbuf);
plane_rsi->restoration_type[rtile_idx] = RESTORE_SGRPROJ;
err = try_restoration_tile(ctxt->src, ctxt->cpi, rsi, (1 << ctxt->plane),
ctxt->partial_frame, rtile_idx, 0, 0,
ctxt->dst_frame);
ctxt->partial_frame, rtile_idx, ctxt->dst_frame);
bits =
count_sgrproj_bits(&plane_rsi->sgrproj_info[rtile_idx], ref_sgrproj_info)
<< AV1_PROB_COST_SHIFT;
......@@ -1040,7 +1038,7 @@ static int64_t finer_tile_search_wiener(const YV12_BUFFER_CONFIG *src,
YV12_BUFFER_CONFIG *dst_frame) {
const int plane_off = (WIENER_WIN - wiener_win) >> 1;
int64_t err = try_restoration_tile(src, cpi, rsi, 1 << plane, partial_frame,
tile_idx, 0, 0, dst_frame);
tile_idx, dst_frame);
(void)start_step;
#if USE_WIENER_REFINEMENT_SEARCH
int64_t err2;
......@@ -1058,7 +1056,7 @@ static int64_t finer_tile_search_wiener(const YV12_BUFFER_CONFIG *src,
rsi[plane].wiener_info[tile_idx].hfilter[WIENER_WIN - p - 1] -= s;
rsi[plane].wiener_info[tile_idx].hfilter[WIENER_HALFWIN] += 2 * s;
err2 = try_restoration_tile(src, cpi, rsi, 1 << plane, partial_frame,
tile_idx, 0, 0, dst_frame);
tile_idx, dst_frame);
if (err2 > err) {
rsi[plane].wiener_info[tile_idx].hfilter[p] += s;
rsi[plane].wiener_info[tile_idx].hfilter[WIENER_WIN - p - 1] += s;
......@@ -1079,7 +1077,7 @@ static int64_t finer_tile_search_wiener(const YV12_BUFFER_CONFIG *src,
rsi[plane].wiener_info[tile_idx].hfilter[WIENER_WIN - p - 1] += s;
rsi[plane].wiener_info[tile_idx].hfilter[WIENER_HALFWIN] -= 2 * s;
err2 = try_restoration_tile(src, cpi, rsi, 1 << plane, partial_frame,
tile_idx, 0, 0, dst_frame);
tile_idx, dst_frame);
if (err2 > err) {
rsi[plane].wiener_info[tile_idx].hfilter[p] -= s;
rsi[plane].wiener_info[tile_idx].hfilter[WIENER_WIN - p - 1] -= s;
......@@ -1101,7 +1099,7 @@ static int64_t finer_tile_search_wiener(const YV12_BUFFER_CONFIG *src,
rsi[plane].wiener_info[tile_idx].vfilter[WIENER_WIN - p - 1] -= s;
rsi[plane].wiener_info[tile_idx].vfilter[WIENER_HALFWIN] += 2 * s;
err2 = try_restoration_tile(src, cpi, rsi, 1 << plane, partial_frame,
tile_idx, 0, 0, dst_frame);
tile_idx, dst_frame);
if (err2 > err) {
rsi[plane].wiener_info[tile_idx].vfilter[p] += s;
rsi[plane].wiener_info[tile_idx].vfilter[WIENER_WIN - p - 1] += s;
......@@ -1122,7 +1120,7 @@ static int64_t finer_tile_search_wiener(const YV12_BUFFER_CONFIG *src,
rsi[plane].wiener_info[tile_idx].vfilter[WIENER_WIN - p - 1] += s;
rsi[plane].wiener_info[tile_idx].vfilter[WIENER_HALFWIN] -= 2 * s;
err2 = try_restoration_tile(src, cpi, rsi, 1 << plane, partial_frame,
tile_idx, 0, 0, dst_frame);
tile_idx, dst_frame);
if (err2 > err) {
rsi[plane].wiener_info[tile_idx].vfilter[p] -= s;
rsi[plane].wiener_info[tile_idx].vfilter[WIENER_WIN - p - 1] -= s;
......@@ -1143,8 +1141,9 @@ static int64_t finer_tile_search_wiener(const YV12_BUFFER_CONFIG *src,
}
static void search_wiener_for_rtile(const struct rest_search_ctxt *ctxt,
int rtile_idx, int h_start, int h_end,
int v_start, int v_end, void *arg) {
int rtile_idx,
const RestorationTileLimits *limits,
void *arg) {
const MACROBLOCK *const x = &ctxt->cpi->td.mb;
const AV1_COMMON *const cm = &ctxt->cpi->common;
RestorationInfo *rsi = ctxt->cpi->rst_search;
......@@ -1158,9 +1157,10 @@ static void search_wiener_for_rtile(const struct rest_search_ctxt *ctxt,
WienerInfo *ref_wiener_info = (WienerInfo *)arg;
int64_t err = sse_restoration_tile(ctxt->src, cm->frame_to_show, cm, h_start,
h_end - h_start, v_start, v_end - v_start,
(1 << ctxt->plane));
int64_t err =
sse_restoration_tile(ctxt->src, cm->frame_to_show, cm, limits->h_start,
limits->h_end - limits->h_start, limits->v_start,
limits->v_end - limits->v_start, (1 << ctxt->plane));
// #bits when a tile is not restored
int bits = av1_cost_bit(RESTORE_NONE_WIENER_PROB, 0);
double cost_norestore = RDCOST_DBL(x->rdmult, (bits >> 4), err);
......@@ -1169,13 +1169,14 @@ static void search_wiener_for_rtile(const struct rest_search_ctxt *ctxt,
#if CONFIG_HIGHBITDEPTH
if (cm->use_highbitdepth)
compute_stats_highbd(wiener_win, ctxt->dgd_buffer, ctxt->src_buffer,
h_start, h_end, v_start, v_end, ctxt->dgd_stride,
ctxt->src_stride, M, H);
limits->h_start, limits->h_end, limits->v_start,
limits->v_end, ctxt->dgd_stride, ctxt->src_stride, M,
H);
else
#endif // CONFIG_HIGHBITDEPTH
compute_stats(wiener_win, ctxt->dgd_buffer, ctxt->src_buffer, h_start,
h_end, v_start, v_end, ctxt->dgd_stride, ctxt->src_stride, M,
H);
compute_stats(wiener_win, ctxt->dgd_buffer, ctxt->src_buffer,
limits->h_start, limits->h_end, limits->v_start,
limits->v_end, ctxt->dgd_stride, ctxt->src_stride, M, H);
ctxt->type[rtile_idx] = RESTORE_WIENER;
......@@ -1305,7 +1306,6 @@ static double search_norestore(const YV12_BUFFER_CONFIG *src, AV1_COMP *cpi,
MACROBLOCK *x = &cpi->td.mb;
AV1_COMMON *const cm = &cpi->common;
int tile_idx, tile_width, tile_height, nhtiles, nvtiles;
int h_start, h_end, v_start, v_end;
int width, height;
if (plane == AOM_PLANE_Y) {
width = src->y_crop_width;
......@@ -1323,12 +1323,11 @@ static double search_norestore(const YV12_BUFFER_CONFIG *src, AV1_COMP *cpi,
info->frame_restoration_type = RESTORE_NONE;
for (tile_idx = 0; tile_idx < ntiles; ++tile_idx) {
av1_get_rest_tile_limits(tile_idx, 0, 0, nhtiles, nvtiles, tile_width,
tile_height, width, height, 0, 0, &h_start, &h_end,
&v_start, &v_end);
err = sse_restoration_tile(src, cm->frame_to_show, cm, h_start,
h_end - h_start, v_start, v_end - v_start,
1 << plane);
RestorationTileLimits limits = av1_get_rest_tile_limits(
tile_idx, nhtiles, nvtiles, tile_width, tile_height, width, height);
err = sse_restoration_tile(src, cm->frame_to_show, cm, limits.h_start,
limits.h_end - limits.h_start, limits.v_start,
limits.v_end - limits.v_start, 1 << plane);
type[tile_idx] = RESTORE_NONE;
best_tile_cost[tile_idx] = err;
}
......@@ -1348,17 +1347,15 @@ struct switchable_rest_search_ctxt {
};
static void search_switchable_for_rtile(const struct rest_search_ctxt *ctxt,
int rtile_idx, int h_start, int h_end,
int v_start, int v_end, void *arg) {
int rtile_idx,
const RestorationTileLimits *limits,
void *arg) {
const MACROBLOCK *x = &ctxt->cpi->td.mb;
RestorationInfo *rsi = &ctxt->cpi->common.rst_info[ctxt->plane];
struct switchable_rest_search_ctxt *swctxt =
(struct switchable_rest_search_ctxt *)arg;
(void)h_start;
(void)h_end;
(void)v_start;
(void)v_end;
(void)limits;
double best_cost =
RDCOST_DBL(x->rdmult, (x->switchable_restore_cost[RESTORE_NONE] >> 4),
......
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