From 2f862791242be7ab6f48e8f082df3e3df6d31e7c Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Tue, 15 Apr 2014 14:43:45 -0700 Subject: [PATCH] Adding scale_if_required() function. Change-Id: I87819fed5aebb6ffe2f4d4655df226235a3d21cb --- vp9/encoder/vp9_onyx_if.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index 1d70538c6..a7527c63d 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -2364,6 +2364,17 @@ static void set_ext_overrides(VP9_COMP *cpi) { } } +static YV12_BUFFER_CONFIG *scale_if_required(VP9_COMMON *cm, + YV12_BUFFER_CONFIG *unscaled, YV12_BUFFER_CONFIG *scaled) { + if (cm->mi_cols * MI_SIZE != unscaled->y_width || + cm->mi_rows * MI_SIZE != unscaled->y_height) { + scale_and_extend_frame_nonnormative(unscaled, scaled); + return scaled; + } else { + return unscaled; + } +} + static void encode_frame_to_data_rate(VP9_COMP *cpi, size_t *size, uint8_t *dest, @@ -2377,30 +2388,14 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, const SPEED_FEATURES *const sf = &cpi->sf; const unsigned int max_mv_def = MIN(cm->width, cm->height); struct segmentation *const seg = &cm->seg; - set_ext_overrides(cpi); - /* Scale the source buffer, if required. */ - if (cm->mi_cols * MI_SIZE != cpi->un_scaled_source->y_width || - cm->mi_rows * MI_SIZE != cpi->un_scaled_source->y_height) { - scale_and_extend_frame_nonnormative(cpi->un_scaled_source, - &cpi->scaled_source); - cpi->Source = &cpi->scaled_source; - } else { - cpi->Source = cpi->un_scaled_source; - } + cpi->Source = scale_if_required(cm, cpi->un_scaled_source, + &cpi->scaled_source); - // Scale the last source buffer, if required. - if (cpi->unscaled_last_source != NULL) { - if (cm->mi_cols * MI_SIZE != cpi->unscaled_last_source->y_width || - cm->mi_rows * MI_SIZE != cpi->unscaled_last_source->y_height) { - scale_and_extend_frame_nonnormative(cpi->unscaled_last_source, - &cpi->scaled_last_source); - cpi->Last_Source = &cpi->scaled_last_source; - } else { - cpi->Last_Source = cpi->unscaled_last_source; - } - } + if (cpi->unscaled_last_source != NULL) + cpi->Last_Source = scale_if_required(cm, cpi->unscaled_last_source, + &cpi->scaled_last_source); vp9_scale_references(cpi);