Commit b66894ac authored by Rupert Swarbrick's avatar Rupert Swarbrick Committed by Urvang Joshi

Upscale frame correctly in foreach_rtile_in_tile

The restoration tiles (rtiles) divide the upscaled frame, not the
encoded one.

Change-Id: I2d08fe926d694fee7064461685289d3fd1c1de0c
parent 9245d89d
......@@ -1178,6 +1178,17 @@ void av1_calculate_scaled_size(int *width, int *height, int num) {
}
}
// Inverse of av1_calculate_scaled_size() above: calculates the original size
// from the given scaled dimensions and the scale numerator.
void av1_calculate_unscaled_size(int *width, int *height, int num) {
if (num != SCALE_DENOMINATOR) {
// Note: av1_calculate_scaled_size() rounds *up* after division when the
// resulting dimensions are odd. So here, we round *down*.
*width = *width * SCALE_DENOMINATOR / num;
*height = *height * SCALE_DENOMINATOR / num;
}
}
#if CONFIG_FRAME_SUPERRES
// TODO(afergs): Look for in-place upscaling
// TODO(afergs): aom_ vs av1_ functions? Which can I use?
......
......@@ -85,8 +85,14 @@ YV12_BUFFER_CONFIG *av1_scale_if_required(AV1_COMMON *cm,
YV12_BUFFER_CONFIG *unscaled,
YV12_BUFFER_CONFIG *scaled);
// Calculates the scaled size from the given original dimensions and the scale
// numerator.
void av1_calculate_scaled_size(int *width, int *height, int num);
// Inverse of av1_calculate_scaled_size() above: calculates the original size
// from the given scaled dimensions and the scale numerator.
void av1_calculate_unscaled_size(int *width, int *height, int num);
#if CONFIG_FRAME_SUPERRES
void av1_superres_upscale(AV1_COMMON *cm, BufferPool *const pool);
......
......@@ -540,6 +540,21 @@ static void foreach_rtile_in_tile(const struct rest_search_ctxt *ctxt,
tile_row_end = ROUND_POWER_OF_TWO(tile_row_end, cm->subsampling_y);
}
#if CONFIG_FRAME_SUPERRES
// If upscaling is enabled, the tile limits need scaling to match the
// upscaled frame where the restoration tiles live. To do this, scale up the
// top-left and bottom-right of the tile.
if (!av1_superres_unscaled(cm)) {
av1_calculate_unscaled_size(&tile_col_start, &tile_row_start,
cm->superres_scale_numerator);
av1_calculate_unscaled_size(&tile_col_end, &tile_row_end,
cm->superres_scale_numerator);
// Make sure we don't fall off the bottom-right of the frame.
tile_col_end = AOMMIN(tile_col_end, ctxt->plane_width);
tile_row_end = AOMMIN(tile_row_end, ctxt->plane_height);
}
#endif // CONFIG_FRAME_SUPERRES
const int rtile_size = rsi->restoration_tilesize;
const int rtile_col0 = (tile_col_start + rtile_size - 1) / rtile_size;
const int rtile_col1 =
......
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