summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Nagy <attilanagy@google.com>2011-02-02 13:10:27 +0200
committerAttila Nagy <attilanagy@google.com>2011-02-02 13:54:40 +0200
commite5904f2d5ec70ea5497aaab494b8bcee5dbea47f (patch)
tree16091283683c1db50a2d90afda4d2e7eb9b7a02f
parenta5ecaca6a79798008975ce84fd53303721642248 (diff)
downloadlibvpx-e5904f2d5ec70ea5497aaab494b8bcee5dbea47f.tar
libvpx-e5904f2d5ec70ea5497aaab494b8bcee5dbea47f.tar.gz
libvpx-e5904f2d5ec70ea5497aaab494b8bcee5dbea47f.tar.bz2
libvpx-e5904f2d5ec70ea5497aaab494b8bcee5dbea47f.zip
Delay auto key frame insertion in realtime configuration
Whe auto keyframe insertion is enabled and conditions are right (scene change) the encoder can decide to insert a key frame and does a re-encoding. This can introduce extra latency. In RT mode we do not do the re-encoding of the current frame but force the next frame to key frame. Change-Id: I15c175fa845ac4c1a1f18bea3676e154669522a7
-rw-r--r--vp8/encoder/onyx_if.c20
-rw-r--r--vp8/encoder/onyx_int.h3
2 files changed, 23 insertions, 0 deletions
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index 92b2f6fc5..d96703146 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -3603,6 +3603,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)
@@ -4113,6 +4124,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);
@@ -4151,6 +4170,7 @@ static void encode_frame_to_data_rate
resize_key_frame(cpi);
continue;
}
+#endif
}
vp8_clear_system_state();
diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h
index 7618a0a3d..50f81589e 100644
--- a/vp8/encoder/onyx_int.h
+++ b/vp8/encoder/onyx_int.h
@@ -679,6 +679,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);