From 6f35b1958e0a767240ee20f8e2cece59b1dc1e12 Mon Sep 17 00:00:00 2001 From: Jim Bankoski Date: Mon, 1 Oct 2012 14:17:43 -0700 Subject: [PATCH] Disable keyframe in real time that's placed one frame after a cut. The codec as it stood placed a keyframe one frame after a real cut scene - and ignored datarate and other considerations. TODO: Its possible that we should detect a keyframe and recode the frame ( in certain circumstances) to improve quality. Change-Id: Ia1fd6d90103f4da4d21ca5ab62897d22e0b888a8 --- test/keyframe_test.cc | 10 ++++++++-- vp8/encoder/onyx_if.c | 14 ++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/keyframe_test.cc b/test/keyframe_test.cc index 19c7152..9925dae 100644 --- a/test/keyframe_test.cc +++ b/test/keyframe_test.cc @@ -62,7 +62,10 @@ TEST_P(KeyframeTest, TestRandomVideoSource) { ::libvpx_test::RandomVideoSource video; ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); - EXPECT_GT(kf_count_, 1); + // In realtime mode - auto placed keyframes are exceedingly rare, don't + // bother with this check if(GetParam() > 0) + if(GetParam() > 0) + EXPECT_GT(kf_count_, 1); } TEST_P(KeyframeTest, TestDisableKeyframes) { @@ -121,7 +124,10 @@ TEST_P(KeyframeTest, TestAutoKeyframe) { ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); - EXPECT_EQ(2u, kf_pts_list_.size()) << " Not the right number of keyframes "; + // In realtime mode - auto placed keyframes are exceedingly rare, don't + // bother with this check + if(GetParam() > 0) + EXPECT_EQ(2u, kf_pts_list_.size()) << " Not the right number of keyframes "; // Verify that keyframes match the file keyframes in the file. for (std::vector::const_iterator iter = kf_pts_list_.begin(); diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index b4e02e2..3ed36d3 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -3970,18 +3970,12 @@ static void encode_frame_to_data_rate /* Test to see if the stats generated for this frame indicate that * we should have coded a key frame (assuming that we didn't)! */ - if (cpi->pass != 2 && cpi->oxcf.auto_key && cm->frame_type != KEY_FRAME) - { - int key_frame_decision = decide_key_frame(cpi); - if (cpi->compressor_speed == 2) - { - /* we don't do re-encoding in realtime mode - * if key frame is decided then we force it on next frame */ - cpi->force_next_frame_intra = key_frame_decision; - } + if (cpi->pass != 2 && cpi->oxcf.auto_key && cm->frame_type != KEY_FRAME + && cpi->compressor_speed != 2) + { #if !(CONFIG_REALTIME_ONLY) - else if (key_frame_decision) + if (decide_key_frame(cpi)) { /* Reset all our sizing numbers and recode */ cm->frame_type = KEY_FRAME; -- 2.7.4