VP8: Making key frame interval a tunnable parameter

Review URL: https://webrtc-codereview.appspot.com/1070006

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3444 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mikhal@webrtc.org 2013-01-31 16:37:13 +00:00
parent 6e3968f62a
commit e07c661a29
6 changed files with 43 additions and 35 deletions

View File

@ -530,6 +530,7 @@ struct VideoCodecVP8
bool errorConcealmentOn; bool errorConcealmentOn;
bool automaticResizeOn; bool automaticResizeOn;
bool frameDroppingOn; bool frameDroppingOn;
int keyFrameInterval;
}; };
// Unknown specific // Unknown specific

View File

@ -8,22 +8,22 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "gtest/gtest.h"
#include <math.h> #include <math.h>
#include "modules/video_coding/codecs/interface/video_codec_interface.h" #include "gtest/gtest.h"
#include "modules/video_coding/codecs/test/packet_manipulator.h"
#include "modules/video_coding/codecs/test/videoprocessor.h" #include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h"
#include "modules/video_coding/codecs/vp8/include/vp8.h" #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h"
#include "modules/video_coding/codecs/vp8/include/vp8_common_types.h" #include "webrtc/modules/video_coding/codecs/test/videoprocessor.h"
#include "modules/video_coding/main/interface/video_coding.h" #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
#include "testsupport/fileutils.h" #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h"
#include "testsupport/frame_reader.h" #include "webrtc/modules/video_coding/main/interface/video_coding.h"
#include "testsupport/frame_writer.h" #include "webrtc/test/testsupport/fileutils.h"
#include "testsupport/metrics/video_metrics.h" #include "webrtc/test/testsupport/frame_reader.h"
#include "testsupport/packet_reader.h" #include "webrtc/test/testsupport/frame_writer.h"
#include "typedefs.h" #include "webrtc/test/testsupport/metrics/video_metrics.h"
#include "webrtc/test/testsupport/packet_reader.h"
#include "webrtc/typedefs.h"
namespace webrtc { namespace webrtc {
@ -32,6 +32,7 @@ namespace webrtc {
const int kMaxNumRateUpdates = 3; const int kMaxNumRateUpdates = 3;
const int kPercTargetvsActualMismatch = 20; const int kPercTargetvsActualMismatch = 20;
const int kBaseKeyFrameInterval = 3000;
// Codec and network settings. // Codec and network settings.
struct CodecConfigPars { struct CodecConfigPars {
@ -182,6 +183,8 @@ class VideoProcessorIntegrationTest: public testing::Test {
frame_dropper_on_; frame_dropper_on_;
config_.codec_settings->codecSpecific.VP8.automaticResizeOn = config_.codec_settings->codecSpecific.VP8.automaticResizeOn =
spatial_resize_on_; spatial_resize_on_;
config_.codec_settings->codecSpecific.VP8.keyFrameInterval =
kBaseKeyFrameInterval;
frame_reader_ = frame_reader_ =
new webrtc::test::FrameReaderImpl(config_.input_filename, new webrtc::test::FrameReaderImpl(config_.input_filename,

View File

@ -11,23 +11,24 @@
* *
*/ */
#include "modules/video_coding/codecs/vp8/vp8_impl.h" #include "webrtc/modules/video_coding/codecs/vp8/vp8_impl.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <vector>
#include "vpx/vpx_encoder.h" #include "vpx/vpx_encoder.h"
#include "vpx/vpx_decoder.h" #include "vpx/vpx_decoder.h"
#include "vpx/vp8cx.h" #include "vpx/vp8cx.h"
#include "vpx/vp8dx.h" #include "vpx/vp8dx.h"
#include "common_video/libyuv/include/webrtc_libyuv.h" #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "module_common_types.h" #include "webrtc/modules/interface/module_common_types.h"
#include "modules/video_coding/codecs/vp8/reference_picture_selection.h" #include "webrtc/modules/video_coding/codecs/vp8/reference_picture_selection.h"
#include "modules/video_coding/codecs/vp8/temporal_layers.h" #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
#include "system_wrappers/interface/tick_util.h" #include "webrtc/system_wrappers/interface/tick_util.h"
#include "system_wrappers/interface/trace_event.h" #include "webrtc/system_wrappers/interface/trace_event.h"
enum { kVp8ErrorPropagationTh = 30 }; enum { kVp8ErrorPropagationTh = 30 };
@ -251,9 +252,11 @@ int VP8EncoderImpl::InitEncode(const VideoCodec* inst,
// Disable periodic key frames if we get feedback from the decoder // Disable periodic key frames if we get feedback from the decoder
// through SLI and RPSI. // through SLI and RPSI.
config_->kf_mode = VPX_KF_DISABLED; config_->kf_mode = VPX_KF_DISABLED;
} else { } else if (inst->codecSpecific.VP8.keyFrameInterval > 0) {
config_->kf_mode = VPX_KF_AUTO; config_->kf_mode = VPX_KF_AUTO;
config_->kf_max_dist = 3000; config_->kf_max_dist = inst->codecSpecific.VP8.keyFrameInterval;
} else {
config_->kf_mode = VPX_KF_DISABLED;
} }
switch (inst->codecSpecific.VP8.complexity) { switch (inst->codecSpecific.VP8.complexity) {
case kComplexityHigh: case kComplexityHigh:

View File

@ -8,19 +8,19 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "modules/video_coding/main/source/codec_database.h" #include "webrtc/modules/video_coding/main/source/codec_database.h"
#include <assert.h> #include <assert.h>
#include "engine_configurations.h" #include "webrtc/engine_configurations.h"
#ifdef VIDEOCODEC_I420 #ifdef VIDEOCODEC_I420
#include "modules/video_coding/codecs/i420/main/interface/i420.h" #include "webrtc/modules/video_coding/codecs/i420/main/interface/i420.h"
#endif #endif
#ifdef VIDEOCODEC_VP8 #ifdef VIDEOCODEC_VP8
#include "modules/video_coding/codecs/vp8/include/vp8.h" #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
#endif #endif
#include "modules/video_coding/main/source/internal_defines.h" #include "webrtc/modules/video_coding/main/source/internal_defines.h"
#include "system_wrappers/interface/trace.h" #include "webrtc/system_wrappers/interface/trace.h"
namespace webrtc { namespace webrtc {
@ -98,6 +98,7 @@ bool VCMCodecDataBase::Codec(int list_id,
settings->codecSpecific.VP8.errorConcealmentOn = false; settings->codecSpecific.VP8.errorConcealmentOn = false;
settings->codecSpecific.VP8.automaticResizeOn = false; settings->codecSpecific.VP8.automaticResizeOn = false;
settings->codecSpecific.VP8.frameDroppingOn = true; settings->codecSpecific.VP8.frameDroppingOn = true;
settings->codecSpecific.VP8.keyFrameInterval = 3000;
return true; return true;
} }
#endif #endif

View File

@ -453,6 +453,7 @@ void ViEAutoTest::ViECodecAPITest() {
if (video_codec.codecType == webrtc::kVideoCodecVP8) { if (video_codec.codecType == webrtc::kVideoCodecVP8) {
video_codec.codecSpecific.VP8.automaticResizeOn = true; video_codec.codecSpecific.VP8.automaticResizeOn = true;
video_codec.codecSpecific.VP8.frameDroppingOn = true; video_codec.codecSpecific.VP8.frameDroppingOn = true;
video_codec.codecSpecific.VP8.keyFrameInterval = 300;
EXPECT_EQ(0, codec->SetSendCodec(video_channel, video_codec)); EXPECT_EQ(0, codec->SetSendCodec(video_channel, video_codec));
break; break;
} }
@ -462,12 +463,11 @@ void ViEAutoTest::ViECodecAPITest() {
EXPECT_EQ(webrtc::kVideoCodecVP8, video_codec.codecType); EXPECT_EQ(webrtc::kVideoCodecVP8, video_codec.codecType);
EXPECT_TRUE(video_codec.codecSpecific.VP8.automaticResizeOn); EXPECT_TRUE(video_codec.codecSpecific.VP8.automaticResizeOn);
EXPECT_TRUE(video_codec.codecSpecific.VP8.frameDroppingOn); EXPECT_TRUE(video_codec.codecSpecific.VP8.frameDroppingOn);
EXPECT_EQ(300, video_codec.codecSpecific.VP8.keyFrameInterval);
for (int i = 0; i < number_of_codecs; i++) { for (int i = 0; i < number_of_codecs; i++) {
EXPECT_EQ(0, codec->GetCodec(i, video_codec)); EXPECT_EQ(0, codec->GetCodec(i, video_codec));
if (video_codec.codecType == webrtc::kVideoCodecI420) { if (video_codec.codecType == webrtc::kVideoCodecI420) {
video_codec.codecSpecific.VP8.automaticResizeOn = false;
video_codec.codecSpecific.VP8.frameDroppingOn = false;
EXPECT_EQ(0, codec->SetSendCodec(video_channel, video_codec)); EXPECT_EQ(0, codec->SetSendCodec(video_channel, video_codec));
break; break;
} }
@ -475,8 +475,6 @@ void ViEAutoTest::ViECodecAPITest() {
memset(&video_codec, 0, sizeof(video_codec)); memset(&video_codec, 0, sizeof(video_codec));
EXPECT_EQ(0, codec->GetSendCodec(video_channel, video_codec)); EXPECT_EQ(0, codec->GetSendCodec(video_channel, video_codec));
EXPECT_EQ(webrtc::kVideoCodecI420, video_codec.codecType); EXPECT_EQ(webrtc::kVideoCodecI420, video_codec.codecType);
EXPECT_FALSE(video_codec.codecSpecific.VP8.automaticResizeOn);
EXPECT_FALSE(video_codec.codecSpecific.VP8.frameDroppingOn);
EXPECT_EQ(0, base->DeleteChannel(video_channel)); EXPECT_EQ(0, base->DeleteChannel(video_channel));

View File

@ -124,12 +124,14 @@ int ViECodecImpl::SetSendCodec(const int video_channel,
WEBRTC_TRACE(kTraceInfo, kTraceVideo, WEBRTC_TRACE(kTraceInfo, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel), ViEId(shared_data_->instance_id(), video_channel),
"pictureLossIndicationOn: %d, feedbackModeOn: %d, " "pictureLossIndicationOn: %d, feedbackModeOn: %d, "
"complexity: %d, resilience: %d, numberOfTemporalLayers: %u", "complexity: %d, resilience: %d, numberOfTemporalLayers: %u"
"keyFrameInterval %d",
video_codec.codecSpecific.VP8.pictureLossIndicationOn, video_codec.codecSpecific.VP8.pictureLossIndicationOn,
video_codec.codecSpecific.VP8.feedbackModeOn, video_codec.codecSpecific.VP8.feedbackModeOn,
video_codec.codecSpecific.VP8.complexity, video_codec.codecSpecific.VP8.complexity,
video_codec.codecSpecific.VP8.resilience, video_codec.codecSpecific.VP8.resilience,
video_codec.codecSpecific.VP8.numberOfTemporalLayers); video_codec.codecSpecific.VP8.numberOfTemporalLayers,
video_codec.codecSpecific.VP8.keyFrameInterval);
} }
if (!CodecValid(video_codec)) { if (!CodecValid(video_codec)) {
// Error logged. // Error logged.