Commit e58b564d authored by Urvang Joshi's avatar Urvang Joshi

Add a macro SCALE_HORIZONTAL_ONLY.

When enabled, scaling through resize and superres will occur only in the
frame's width; the height will not be scaled.

Macro is off by default.

Change-Id: I501b2b0b2766aa4a86da5937b57c4d5aee4e34c4
parent b2752174
......@@ -1171,10 +1171,13 @@ YV12_BUFFER_CONFIG *av1_scale_if_required(AV1_COMMON *cm,
void av1_calculate_scaled_size(int *width, int *height, int denom) {
if (denom != SCALE_NUMERATOR) {
*width = *width * SCALE_NUMERATOR / denom;
*width += *width & 1; // Make it even.
#if SCALE_HORIZONTAL_ONLY
(void)height;
#else
*height = *height * SCALE_NUMERATOR / denom;
// Make width and height even
*width += *width & 1;
*height += *height & 1;
*height += *height & 1; // Make it even.
#endif // !SCALE_HORIZONTAL_ONLY
}
}
......@@ -1183,7 +1186,11 @@ void av1_calculate_unscaled_size(int *width, int *height, int denom) {
// Note: av1_calculate_scaled_size() rounds *up* after division when the
// resulting dimensions are odd. So here, we round *down*.
*width = *width * denom / SCALE_NUMERATOR;
#if SCALE_HORIZONTAL_ONLY
(void)height;
#else
*height = *height * denom / SCALE_NUMERATOR;
#endif // !SCALE_HORIZONTAL_ONLY
}
}
......
......@@ -85,6 +85,10 @@ YV12_BUFFER_CONFIG *av1_scale_if_required(AV1_COMMON *cm,
YV12_BUFFER_CONFIG *unscaled,
YV12_BUFFER_CONFIG *scaled);
// If 0: resize and superres scaling happens for both width and height.
// If 1: resize and superres scaling happens ONLY for width.
#define SCALE_HORIZONTAL_ONLY 0
// Calculates the scaled size from the given original dimensions and the scale
// denominator.
void av1_calculate_scaled_size(int *width, int *height, int denom);
......
......@@ -4447,6 +4447,7 @@ static uint8_t calculate_next_resize_scale(const AV1_COMP *cpi) {
}
#if CONFIG_FRAME_SUPERRES
static uint8_t calculate_next_superres_scale(AV1_COMP *cpi) {
// Choose an arbitrary random number
static unsigned int seed = 34567;
......@@ -4490,7 +4491,8 @@ static int dimension_is_ok(int orig_dim, int resized_dim, int denom) {
static int dimensions_are_ok(int owidth, int oheight, size_params_type *rsz) {
return dimension_is_ok(owidth, rsz->resize_width, rsz->superres_denom) &&
dimension_is_ok(oheight, rsz->resize_height, rsz->superres_denom);
(SCALE_HORIZONTAL_ONLY ||
dimension_is_ok(oheight, rsz->resize_height, rsz->superres_denom));
}
#define DIVIDE_AND_ROUND(x, y) (((x) + ((y) >> 1)) / (y))
......@@ -4502,10 +4504,15 @@ static int validate_size_scales(RESIZE_MODE resize_mode,
return 1;
}
// Calculate current resize scale.
// Calculate current resize scale.
#if SCALE_HORIZONTAL_ONLY
int resize_denom =
DIVIDE_AND_ROUND(owidth * SCALE_NUMERATOR, rsz->resize_width);
#else
int resize_denom =
AOMMAX(DIVIDE_AND_ROUND(owidth * SCALE_NUMERATOR, rsz->resize_width),
DIVIDE_AND_ROUND(oheight * SCALE_NUMERATOR, rsz->resize_height));
#endif // SCALE_HORIZONTAL_ONLY
if (resize_mode != RESIZE_RANDOM && superres_mode == SUPERRES_RANDOM) {
// Alter superres scale as needed to enforce conformity.
......
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