Commit 146a060a authored by Rupert Swarbrick's avatar Rupert Swarbrick Committed by Sebastien Alaiwan

Remove partial_frame support from loop restoration

This flag comes from the loop filter's speed features and (I think)
tells the encoder to make decisions about the filter by looking at a
narrow strip in the middle of the frame.

That's reasonable enough, but doesn't make any sense for loop
restoration, where we were calling av1_loop_restoration_frame from
pickrst.c in order to calculate what restoration parameters to use for
a given restoration unit (which might not be in the narrow strip in
the middle!)

As it turns out, the LPF_PICK_FROM_SUBIMAGE method is never actually
signalled in the reference encoder, which is presumably why we haven't
spotted this before.

Change-Id: I745e2eab873c0b33920caca40e338af9d078d25e
parent f88bc049
......@@ -1551,12 +1551,9 @@ static void loop_switchable_filter_highbd(uint8_t *data8, int width, int height,
}
#endif // CONFIG_HIGHBITDEPTH
static void loop_restoration_rows(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
int start_mi_row, int end_mi_row,
int components_pattern, RestorationInfo *rsi,
YV12_BUFFER_CONFIG *dst) {
const int ywidth = frame->y_crop_width;
const int yheight = frame->y_crop_height;
void av1_loop_restoration_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
RestorationInfo *rsi, int components_pattern,
YV12_BUFFER_CONFIG *dst) {
restore_func_type restore_funcs[RESTORE_TYPES] = {
NULL, loop_wiener_filter, loop_sgrproj_filter, loop_switchable_filter
};
......@@ -1594,12 +1591,13 @@ static void loop_restoration_rows(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
if (!dst) {
dst = &dst_;
memset(dst, 0, sizeof(YV12_BUFFER_CONFIG));
if (aom_realloc_frame_buffer(
dst, ywidth, yheight, cm->subsampling_x, cm->subsampling_y,
if (aom_realloc_frame_buffer(dst, frame->y_crop_width, frame->y_crop_height,
cm->subsampling_x, cm->subsampling_y,
#if CONFIG_HIGHBITDEPTH
cm->use_highbitdepth,
cm->use_highbitdepth,
#endif
AOM_BORDER_IN_PIXELS, cm->byte_alignment, NULL, NULL, NULL) < 0)
AOM_BORDER_IN_PIXELS, cm->byte_alignment, NULL,
NULL, NULL) < 0)
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate restoration dst buffer");
}
......@@ -1619,8 +1617,6 @@ static void loop_restoration_rows(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
const int plane_width = frame->crop_widths[is_uv];
const int plane_height = frame->crop_heights[is_uv];
const int row0 = (start_mi_row << MI_SIZE_LOG2) >> ss_y;
const int row1 = AOMMIN((end_mi_row << MI_SIZE_LOG2) >> ss_y, plane_height);
rst.rsi = &rsi[plane];
rst.keyframe = cm->frame_type == KEY_FRAME;
......@@ -1634,16 +1630,13 @@ static void loop_restoration_rows(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
#if CONFIG_HIGHBITDEPTH
restore_func_highbd_type restore_func_highbd = restore_funcs_highbd[rtype];
if (cm->use_highbitdepth)
restore_func_highbd(frame->buffers[plane] + row0 * frame->strides[is_uv],
plane_width, row1 - row0, frame->strides[is_uv], &rst,
cm->bit_depth,
dst->buffers[plane] + row0 * dst->strides[is_uv],
dst->strides[is_uv]);
restore_func_highbd(frame->buffers[plane], plane_width, plane_height,
frame->strides[is_uv], &rst, cm->bit_depth,
dst->buffers[plane], dst->strides[is_uv]);
else
#endif // CONFIG_HIGHBITDEPTH
restore_func(frame->buffers[plane] + row0 * frame->strides[is_uv],
plane_width, row1 - row0, frame->strides[is_uv], &rst,
dst->buffers[plane] + row0 * dst->strides[is_uv],
restore_func(frame->buffers[plane], plane_width, plane_height,
frame->strides[is_uv], &rst, dst->buffers[plane],
dst->strides[is_uv]);
}
......@@ -1657,27 +1650,6 @@ static void loop_restoration_rows(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
}
}
void av1_loop_restoration_frame(YV12_BUFFER_CONFIG *frame, AV1_COMMON *cm,
RestorationInfo *rsi, int components_pattern,
int partial_frame, YV12_BUFFER_CONFIG *dst) {
int start_mi_row, end_mi_row, mi_rows_to_filter;
start_mi_row = 0;
#if CONFIG_FRAME_SUPERRES
mi_rows_to_filter =
ALIGN_POWER_OF_TWO(cm->superres_upscaled_height, 3) >> MI_SIZE_LOG2;
#else
mi_rows_to_filter = cm->mi_rows;
#endif // CONFIG_FRAME_SUPERRES
if (partial_frame && mi_rows_to_filter > 8) {
start_mi_row = mi_rows_to_filter >> 1;
start_mi_row &= 0xfffffff8;
mi_rows_to_filter = AOMMAX(mi_rows_to_filter / 8, 8);
}
end_mi_row = start_mi_row + mi_rows_to_filter;
loop_restoration_rows(frame, cm, start_mi_row, end_mi_row, components_pattern,
rsi, dst);
}
int av1_loop_restoration_corners_in_sb(const struct AV1Common *cm, int plane,
int mi_row, int mi_col, BLOCK_SIZE bsize,
int *rcol0, int *rcol1, int *rrow0,
......
......@@ -297,7 +297,7 @@ void extend_frame_highbd(uint16_t *data, int width, int height, int stride,
void decode_xq(int *xqd, int *xq);
void av1_loop_restoration_frame(YV12_BUFFER_CONFIG *frame, struct AV1Common *cm,
RestorationInfo *rsi, int components_pattern,
int partial_frame, YV12_BUFFER_CONFIG *dst);
YV12_BUFFER_CONFIG *dst);
void av1_loop_restoration_precal();
// Return 1 iff the block at mi_row, mi_col with size bsize is a
......
......@@ -4661,7 +4661,7 @@ void av1_decode_tg_tiles_and_wrapup(AV1Decoder *pbi, const uint8_t *data,
cm->rst_info[2].frame_restoration_type != RESTORE_NONE) {
aom_extend_frame_borders((YV12_BUFFER_CONFIG *)xd->cur_buf);
av1_loop_restoration_frame((YV12_BUFFER_CONFIG *)xd->cur_buf, cm,
cm->rst_info, 7, 0, NULL);
cm->rst_info, 7, NULL);
}
#endif // CONFIG_LOOP_RESTORATION
......
......@@ -4693,11 +4693,11 @@ static void loopfilter_frame(AV1_COMP *cpi, AV1_COMMON *cm) {
#if CONFIG_LOOP_RESTORATION
aom_extend_frame_borders(cm->frame_to_show);
av1_pick_filter_restoration(cpi->source, cpi, cpi->sf.lpf_pick);
av1_pick_filter_restoration(cpi->source, cpi);
if (cm->rst_info[0].frame_restoration_type != RESTORE_NONE ||
cm->rst_info[1].frame_restoration_type != RESTORE_NONE ||
cm->rst_info[2].frame_restoration_type != RESTORE_NONE) {
av1_loop_restoration_frame(cm->frame_to_show, cm, cm->rst_info, 7, 0, NULL);
av1_loop_restoration_frame(cm->frame_to_show, cm, cm->rst_info, 7, NULL);
}
#endif // CONFIG_LOOP_RESTORATION
// TODO(debargha): Fix mv search range on encoder side
......
This diff is collapsed.
......@@ -20,8 +20,7 @@ extern "C" {
struct yv12_buffer_config;
struct AV1_COMP;
void av1_pick_filter_restoration(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi,
LPF_PICK_METHOD method);
void av1_pick_filter_restoration(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi);
#ifdef __cplusplus
} // extern "C"
......
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