Merge "Delay auto key frame insertion in realtime configuration"
authorJohn Koleszar <jkoleszar@google.com>
Fri, 4 Feb 2011 13:16:15 +0000 (05:16 -0800)
committerCode Review <code-review@webmproject.org>
Fri, 4 Feb 2011 13:16:15 +0000 (05:16 -0800)
vp8/encoder/onyx_if.c
vp8/encoder/onyx_int.h

index 6a3f7f6..df1a6f5 100644 (file)
@@ -3614,6 +3614,17 @@ static void encode_frame_to_data_rate
     // Test code for segmentation of gf/arf (0,0)
     //segmentation_test_function((VP8_PTR) cpi);
 
+#if CONFIG_REALTIME_ONLY
+    if(cpi->oxcf.auto_key && cm->frame_type != KEY_FRAME)
+    {
+        if(cpi->force_next_frame_intra)
+        {
+            cm->frame_type = KEY_FRAME;  /* delayed intra frame */
+        }
+    }
+    cpi->force_next_frame_intra = 0;
+#endif
+
     // For an alt ref frame in 2 pass we skip the call to the second pass function that sets the target bandwidth
 #if !(CONFIG_REALTIME_ONLY)
 
@@ -4124,6 +4135,14 @@ static void encode_frame_to_data_rate
         // (assuming that we didn't)!
         if (cpi->pass != 2 && cpi->oxcf.auto_key && cm->frame_type != KEY_FRAME)
         {
+
+#if CONFIG_REALTIME_ONLY
+            {
+                /* we don't do re-encoding in realtime mode
+                 * if key frame is decided than we force it on next frame */
+                cpi->force_next_frame_intra = decide_key_frame(cpi);
+            }
+#else
             if (decide_key_frame(cpi))
             {
                 vp8_calc_auto_iframe_target_size(cpi);
@@ -4162,6 +4181,7 @@ static void encode_frame_to_data_rate
                 resize_key_frame(cpi);
                 continue;
             }
+#endif
         }
 
         vp8_clear_system_state();
index 4d8f3ec..e8a452d 100644 (file)
@@ -677,6 +677,9 @@ typedef struct
     int *lf_ref_frame_sign_bias;
     int *lf_ref_frame;
 
+#if CONFIG_REALTIME_ONLY
+    int force_next_frame_intra; /* force next frame to intra when kf_auto says so */
+#endif
 } VP8_COMP;
 
 void control_data_rate(VP8_COMP *cpi);