Commit f88bc049 authored by Rupert Swarbrick's avatar Rupert Swarbrick Committed by Sebastien Alaiwan

Remove RestorationInternal from AV1_COMMON

The bits needed by striped loop restoration are now in
RestorationInfo (which also gets rid of a rather ugly extra
index).

The scratch buffer that's used for self-guided restoration has been
moved up to its own variable (rst_tmpbuf).

All the rest of the fields are now safely hidden inside restoration.c

This patch also does a big cleanup of the initialisation code in
loop_restoration_rows: it doesn't need to be as repetitive now that
the fields of YV12_BUFFER_CONFIG can be accessed by plane index.

Change-Id: Iba7edc0f94041fa053cdeb3d6cf35d84a05dbfaf
parent 64b8bbdf
......@@ -157,8 +157,8 @@ void av1_alloc_restoration_buffers(AV1_COMMON *cm) {
av1_alloc_restoration_struct(cm, &cm->rst_info[p],
ROUND_POWER_OF_TWO(width, cm->subsampling_x),
ROUND_POWER_OF_TWO(height, cm->subsampling_y));
aom_free(cm->rst_internal.tmpbuf);
CHECK_MEM_ERROR(cm, cm->rst_internal.tmpbuf,
aom_free(cm->rst_tmpbuf);
CHECK_MEM_ERROR(cm, cm->rst_tmpbuf,
(int32_t *)aom_memalign(16, RESTORATION_TMPBUF_SIZE));
#if CONFIG_STRIPED_LOOP_RESTORATION
......@@ -172,8 +172,8 @@ void av1_alloc_restoration_buffers(AV1_COMMON *cm) {
int buf_size = num_stripes * 2 * stride;
uint8_t *above_buf, *below_buf;
aom_free(cm->rst_internal.stripe_boundary_above[p]);
aom_free(cm->rst_internal.stripe_boundary_below[p]);
aom_free(cm->rst_info[p].stripe_boundary_above);
aom_free(cm->rst_info[p].stripe_boundary_below);
#if CONFIG_HIGHBITDEPTH
if (cm->use_highbitdepth) buf_size = buf_size * 2;
......@@ -182,9 +182,9 @@ void av1_alloc_restoration_buffers(AV1_COMMON *cm) {
(uint8_t *)aom_memalign(1 << align_bits, buf_size));
CHECK_MEM_ERROR(cm, below_buf,
(uint8_t *)aom_memalign(1 << align_bits, buf_size));
cm->rst_internal.stripe_boundary_above[p] = above_buf;
cm->rst_internal.stripe_boundary_below[p] = below_buf;
cm->rst_internal.stripe_boundary_stride[p] = stride;
cm->rst_info[p].stripe_boundary_above = above_buf;
cm->rst_info[p].stripe_boundary_below = below_buf;
cm->rst_info[p].stripe_boundary_stride = stride;
}
#endif // CONFIG_STRIPED_LOOP_RESTORATION
}
......@@ -193,8 +193,8 @@ void av1_free_restoration_buffers(AV1_COMMON *cm) {
int p;
for (p = 0; p < MAX_MB_PLANE; ++p)
av1_free_restoration_struct(&cm->rst_info[p]);
aom_free(cm->rst_internal.tmpbuf);
cm->rst_internal.tmpbuf = NULL;
aom_free(cm->rst_tmpbuf);
cm->rst_tmpbuf = NULL;
}
#endif // CONFIG_LOOP_RESTORATION
......
......@@ -367,7 +367,7 @@ typedef struct AV1Common {
#endif // CONFIG_FRAME_SUPERRES
#if CONFIG_LOOP_RESTORATION
RestorationInfo rst_info[MAX_MB_PLANE];
RestorationInternal rst_internal;
int32_t *rst_tmpbuf;
#endif // CONFIG_LOOP_RESTORATION
// Flag signaling how frame contexts should be updated at the end of
......
This diff is collapsed.
......@@ -215,29 +215,12 @@ typedef struct {
WienerInfo *wiener_info;
// Selfguided proj filter
SgrprojInfo *sgrproj_info;
} RestorationInfo;
typedef struct {
RestorationInfo *rsi;
int keyframe;
int ntiles;
int nhtiles, nvtiles;
int32_t *tmpbuf;
int subsampling_y;
#if CONFIG_STRIPED_LOOP_RESTORATION
int component;
uint8_t *stripe_boundary_above[MAX_MB_PLANE];
uint8_t *stripe_boundary_below[MAX_MB_PLANE];
int stripe_boundary_stride[MAX_MB_PLANE];
// Temporary buffers to save/restore 2 lines above/below the restoration
// stripe
// Allow for filter margin to left and right
uint16_t
tmp_save_above[2][RESTORATION_TILESIZE_MAX + 2 * RESTORATION_EXTRA_HORZ];
uint16_t
tmp_save_below[2][RESTORATION_TILESIZE_MAX + 2 * RESTORATION_EXTRA_HORZ];
uint8_t *stripe_boundary_above;
uint8_t *stripe_boundary_below;
int stripe_boundary_stride;
#endif
} RestorationInternal;
} RestorationInfo;
static INLINE void set_default_sgrproj(SgrprojInfo *sgrproj_info) {
sgrproj_info->xqd[0] = (SGRPROJ_PRJ_MIN0 + SGRPROJ_PRJ_MAX0) / 2;
......
......@@ -4294,19 +4294,34 @@ static void set_frame_size(AV1_COMP *cpi, int width, int height) {
cm->subsampling_x, cm->subsampling_y, cm->rst_info);
for (int i = 0; i < MAX_MB_PLANE; ++i)
cm->rst_info[i].frame_restoration_type = RESTORE_NONE;
av1_alloc_restoration_buffers(cm);
for (int i = 0; i < MAX_MB_PLANE; ++i) {
cpi->rst_search[i].restoration_tilesize =
cm->rst_info[i].restoration_tilesize;
cpi->rst_search[i].procunit_width = cm->rst_info[i].procunit_width;
cpi->rst_search[i].procunit_height = cm->rst_info[i].procunit_height;
av1_alloc_restoration_struct(cm, &cpi->rst_search[i],
#if CONFIG_FRAME_SUPERRES
cm->superres_upscaled_width,
cm->superres_upscaled_height);
const int frame_width = cm->superres_upscaled_width;
const int frame_height = cm->superres_upscaled_height;
#else
cm->width, cm->height);
#endif // CONFIG_FRAME_SUPERRES
const int frame_width = cm->width;
const int frame_height = cm->height;
#endif
av1_alloc_restoration_buffers(cm);
// Set up the rst_search RestorationInfo structures. These are the same as
// the rst_info ones except need their own arrays of types and coefficients,
// allocated in av1_alloc_restoration_struct.
for (int i = 0; i < MAX_MB_PLANE; ++i) {
RestorationInfo *search = &cpi->rst_search[i];
RestorationInfo *rsi = &cm->rst_info[i];
search->restoration_tilesize = rsi->restoration_tilesize;
search->procunit_width = rsi->procunit_width;
search->procunit_height = rsi->procunit_height;
av1_alloc_restoration_struct(cm, search, frame_width, frame_height);
#if CONFIG_STRIPED_LOOP_RESTORATION
// We can share boundary buffers between the search info and the main one
search->stripe_boundary_above = rsi->stripe_boundary_above;
search->stripe_boundary_below = rsi->stripe_boundary_below;
search->stripe_boundary_stride = rsi->stripe_boundary_stride;
#endif
}
#endif // CONFIG_LOOP_RESTORATION
alloc_util_frame_buffers(cpi); // TODO(afergs): Remove? Gets called anyways.
......
......@@ -590,8 +590,7 @@ static void search_sgrproj_for_rtile(const struct rest_search_ctxt *ctxt,
0, 8,
#endif // CONFIG_HIGHBITDEPTH
rsi[ctxt->plane].procunit_width, rsi[ctxt->plane].procunit_height,
&rtile_sgrproj_info->ep, rtile_sgrproj_info->xqd,
cm->rst_internal.tmpbuf);
&rtile_sgrproj_info->ep, rtile_sgrproj_info->xqd, cm->rst_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, ctxt->dst_frame);
......
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