From: Marco Paniconi Date: Wed, 6 Jun 2012 18:38:48 +0000 (-0700) Subject: Reset Q for key frame when spatial resizing occurs. X-Git-Tag: v1.2.0~178^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=baedcedcbe3abbf018ff8147e71f4faa3e4bba6f;p=libvpx Reset Q for key frame when spatial resizing occurs. The logic for spatial resizing is done after the Q is selected for the frame. This causes a problem that the Q we select for the (resized) key frame may be based on a different resolution than the frame we will encode. This fix is to ensure that, when resize is on, the selected Q is still based on the resolution of the frame to be encoded. Change-Id: Ia49a9eac5f64e48d1c00dfc7ed4ce26fe84d3fa1 --- diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index 878cad48b..5b4d08b27 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -2612,7 +2612,7 @@ static void scale_and_extend_source(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi) } -static void resize_key_frame(VP8_COMP *cpi) +static int resize_key_frame(VP8_COMP *cpi) { #if CONFIG_SPATIAL_RESAMPLING VP8_COMMON *cm = &cpi->common; @@ -2653,10 +2653,12 @@ static void resize_key_frame(VP8_COMP *cpi) cm->Height = new_height; vp8_alloc_compressor_data(cpi); scale_and_extend_source(cpi->un_scaled_source, cpi); + return 1; } } #endif + return 0; } @@ -3801,7 +3803,17 @@ static void encode_frame_to_data_rate if (cm->frame_type == KEY_FRAME) { - resize_key_frame(cpi); + if(resize_key_frame(cpi)) + { + /* If the frame size has changed, need to reset Q, quantizer, + * and background refresh. + */ + Q = vp8_regulate_q(cpi, cpi->this_frame_target); + if (cpi->cyclic_refresh_mode_enabled && (cpi->current_layer==0)) + cyclic_background_refresh(cpi, Q, 0); + vp8_set_quantizer(cpi, Q); + } + vp8_setup_key_frame(cpi); }