shithub: libvpx

Download patch

ref: baedcedcbe3abbf018ff8147e71f4faa3e4bba6f
parent: cab6ac16e0cc5fd149720165d351c8c8c9997dea
author: Marco Paniconi <marpan@google.com>
date: Wed Jun 6 07:38:48 EDT 2012

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

--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -2612,7 +2612,7 @@
 }
 
 
-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 @@
             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 @@
 
         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);
         }