Commit 7a7fffef authored by Rupert Swarbrick's avatar Rupert Swarbrick Committed by Debargha Mukherjee

Save right # of lines in save_deblock_boundary_lines

The "src_height" computed in save_deblock_boundary_lines didn't match
the one in save_tile_row_boundary_lines, which meant that the wrapper
function assumed the deblock code was saving some lines and that code
thought that save_cdef_boundary_lines would do it.

This patch fixes up the logic to match, and also completely gets rid
of the lines_to_save variable (after all, bad things would happen if
lines_to_save was 1 because we'll still read both boundary lines
later)

The tile height gets rounded up to a multiple of 8 luma pixels in
save_tile_row_boundary_lines to avoid nasty corner cases. This will
only have any effect for rows at the bottom of the frame (where
av1_get_tile_rect clips to the frame boundary).

BUG=aomedia:1020

Change-Id: I55adb53fa8ba9c7f97fb2fd5b328a3f2f5065464
parent e72a2091
......@@ -1806,7 +1806,6 @@ static void save_deblock_boundary_lines(
RestorationStripeBoundaries *boundaries) {
const int is_uv = plane > 0;
const int src_width = frame->crop_widths[is_uv];
const int src_height = frame->crop_heights[is_uv];
const uint8_t *src_buf = REAL_PTR(use_highbd, frame->buffers[plane]);
const int src_stride = frame->strides[is_uv] << use_highbd;
const uint8_t *src_rows = src_buf + row * src_stride;
......@@ -1817,7 +1816,15 @@ static void save_deblock_boundary_lines(
const int bdry_stride = boundaries->stripe_boundary_stride << use_highbd;
uint8_t *bdry_rows = bdry_start + RESTORATION_CTX_VERT * stripe * bdry_stride;
const int lines_to_save = AOMMIN(RESTORATION_CTX_VERT, src_height - row);
// Because we're rounding to multiple of 8 luma pixels and this is
// only called when row < src_height, there must be at least 2 luma
// or chroma pixels available.
#ifndef NDEBUG
const int ss_y = is_uv && cm->subsampling_y;
const int src_height = cm->mi_rows << (MI_SIZE_LOG2 - ss_y);
assert(row + RESTORATION_CTX_VERT <= src_height);
#endif // NDEBUG
#if CONFIG_FRAME_SUPERRES
const int ss_x = is_uv && cm->subsampling_x;
const int upscaled_width = (cm->superres_upscaled_width + ss_x) >> ss_x;
......@@ -1826,24 +1833,24 @@ static void save_deblock_boundary_lines(
if (use_highbd)
av1_highbd_convolve_horiz_rs(
(uint16_t *)src_rows, src_stride >> 1, (uint16_t *)bdry_rows,
bdry_stride >> 1, upscaled_width, lines_to_save,
bdry_stride >> 1, upscaled_width, RESTORATION_CTX_VERT,
&av1_resize_filter_normative[0][0], UPSCALE_NORMATIVE_TAPS, 0, step,
cm->bit_depth);
else
#endif // CONFIG_HIGHBITDEPTH
av1_convolve_horiz_rs(src_rows, src_stride, bdry_rows, bdry_stride,
upscaled_width, lines_to_save,
upscaled_width, RESTORATION_CTX_VERT,
&av1_resize_filter_normative[0][0],
UPSCALE_NORMATIVE_TAPS, 0, step);
#else
(void)cm;
const int upscaled_width = src_width;
const int line_bytes = src_width << use_highbd;
for (int i = 0; i < lines_to_save; i++) {
for (int i = 0; i < RESTORATION_CTX_VERT; i++) {
memcpy(bdry_rows + i * bdry_stride, src_rows + i * src_stride, line_bytes);
}
#endif // CONFIG_FRAME_SUPERRES
extend_lines(bdry_rows, upscaled_width, lines_to_save, bdry_stride,
extend_lines(bdry_rows, upscaled_width, RESTORATION_CTX_VERT, bdry_stride,
RESTORATION_EXTRA_HORZ, use_highbd);
}
......@@ -1894,7 +1901,11 @@ static void save_tile_row_boundary_lines(const YV12_BUFFER_CONFIG *frame,
const int ss_y = is_uv && cm->subsampling_y;
const int stripe_height = RESTORATION_PROC_UNIT_SIZE >> ss_y;
const int stripe_off = RESTORATION_TILE_OFFSET >> ss_y;
const AV1PixelRect tile_rect = av1_get_tile_rect(tile_info, cm, plane > 0);
// Get the tile rectangle, with height rounded up to the next multiple of 8
// luma pixels (only relevant for the bottom tile of the frame)
AV1PixelRect tile_rect = av1_get_tile_rect(tile_info, cm, plane > 0);
tile_rect.bottom = ALIGN_POWER_OF_TWO(tile_rect.bottom, 3 - ss_y);
RestorationStripeBoundaries *boundaries = &cm->rst_info[plane].boundaries;
......
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