]> granicus.if.org Git - libvpx/commitdiff
fixed a bug of context overwritten by key frame recoding
authorYaowu Xu <yaowu@google.com>
Thu, 15 Mar 2012 00:29:39 +0000 (17:29 -0700)
committerYaowu Xu <yaowu@google.com>
Thu, 15 Mar 2012 00:29:39 +0000 (17:29 -0700)
The recoding loop save and restore frame coding context for recodes.
However in recoding of key frames, some of the coding context saved
was stale from last encoded inter frame. The save/restore sometimes
overwrites the re-inintialized coding context with saved context
from last frame, resulting in encoder/decoder mismatch

Change-Id: I354ae2f71074d142602d51d06544c05a2462caaf

vp8/encoder/ratectrl.c

index bf06f32e16bf852e6dbb137fc348791db2dffd7e..0a9f12a310c6ebec4cbce2435b700b802428c52d 100644 (file)
@@ -222,9 +222,9 @@ void vp8_restore_coding_context(VP8_COMP *cpi)
 void vp8_setup_key_frame(VP8_COMP *cpi)
 {
     // Setup for Key frame:
-
     vp8_default_coef_probs(& cpi->common);
     vp8_kf_default_bmode_probs(cpi->common.kf_bmode_prob);
+    vp8_init_mbmode_probs(& cpi->common);
 
     vpx_memcpy(cpi->common.fc.mvc, vp8_default_mv_context, sizeof(vp8_default_mv_context));
     {
@@ -263,6 +263,18 @@ void vp8_setup_key_frame(VP8_COMP *cpi)
     vpx_memcpy( cpi->common.vp8_mode_contexts,
                 default_vp8_mode_contexts,
                 sizeof(default_vp8_mode_contexts));
+
+    /* make sure coding_context is correct in key frame recode */
+    {
+        CODING_CONTEXT *const cc = & cpi->coding_context;
+
+        vp8_copy(cc->mvc,      cpi->common.fc.mvc);
+#if CONFIG_HIGH_PRECISION_MV
+        vp8_copy(cc->mvc_hp,      cpi->common.fc.mvc_hp);
+#endif
+        vp8_copy(cc->ymode_prob,   cpi->common.fc.ymode_prob);
+        vp8_copy(cc->uv_mode_prob,  cpi->common.fc.uv_mode_prob);
+    }
 }
 void vp8_setup_inter_frame(VP8_COMP *cpi)
 {