shithub: libvpx

Download patch

ref: 1ec44505c9f37b35f3f4e630b7bc564eca7980d6
parent: 400973c3610e9cd423a475b3a8ad5b4fd110a942
author: Minghai Shang <minghai@google.com>
date: Fri Apr 18 06:59:15 EDT 2014

Bug fix for svc first pass rate control.

1. We didn't scale source image in lower layers so that
the stats are incorrect.
2. We didn't extend borders for re-constructed image.

Change-Id: Ia8d7bafbdb695ffa7f504e171f9449812e7bb0a3

--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -532,6 +532,9 @@
     // Disable golden frame for svc first pass for now.
     gld_yv12 = NULL;
     set_ref_ptrs(cm, xd, ref_frame, NONE);
+
+    cpi->Source = vp9_scale_if_required(cm, cpi->un_scaled_source,
+                                        &cpi->scaled_source);
   }
 
   vp9_setup_src_planes(x, cpi->Source, 0, 0);
@@ -848,6 +851,8 @@
     ++twopass->sr_update_lag;
   }
 
+  vp9_extend_frame_borders(new_yv12);
+
   if (cpi->use_svc && cpi->svc.number_temporal_layers == 1) {
     vp9_update_reference_frames(cpi);
   } else {
@@ -854,8 +859,6 @@
     // Swap frame pointers so last frame refers to the frame we just compressed.
     swap_yv12(lst_yv12, new_yv12);
   }
-
-  vp9_extend_frame_borders(lst_yv12);
 
   // Special case for the first frame. Copy into the GF buffer as a second
   // reference.
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -2209,8 +2209,9 @@
   }
 }
 
-static YV12_BUFFER_CONFIG *scale_if_required(VP9_COMMON *cm,
-  YV12_BUFFER_CONFIG *unscaled, YV12_BUFFER_CONFIG *scaled) {
+YV12_BUFFER_CONFIG *vp9_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);
@@ -2235,12 +2236,12 @@
   struct segmentation *const seg = &cm->seg;
   set_ext_overrides(cpi);
 
-  cpi->Source = scale_if_required(cm, cpi->un_scaled_source,
-                                  &cpi->scaled_source);
+  cpi->Source = vp9_scale_if_required(cm, cpi->un_scaled_source,
+                                      &cpi->scaled_source);
 
   if (cpi->unscaled_last_source != NULL)
-    cpi->Last_Source = scale_if_required(cm, cpi->unscaled_last_source,
-                                         &cpi->scaled_last_source);
+    cpi->Last_Source = vp9_scale_if_required(cm, cpi->unscaled_last_source,
+                                             &cpi->scaled_last_source);
 
   vp9_scale_references(cpi);
 
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -618,6 +618,10 @@
 
 int64_t vp9_rescale(int64_t val, int64_t num, int denom);
 
+YV12_BUFFER_CONFIG *vp9_scale_if_required(VP9_COMMON *cm,
+                                          YV12_BUFFER_CONFIG *unscaled,
+                                          YV12_BUFFER_CONFIG *scaled);
+
 static INLINE void set_ref_ptrs(VP9_COMMON *cm, MACROBLOCKD *xd,
                                 MV_REFERENCE_FRAME ref0,
                                 MV_REFERENCE_FRAME ref1) {