Skip to content

Commit

Permalink
Expose VP8/H264 defaults through video_encoder.h.
Browse files Browse the repository at this point in the history
Reduces code duplication quite a bit, these identical defaults were set
in quite a few different places.

R=mflodman@webrtc.org, stefan@webrtc.org
BUG=3070

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7220 4adac7df-926f-26a2-2b94-8c16560cd09d
  • Loading branch information
pbos@webrtc.org committed Sep 18, 2014
1 parent c7134f8 commit 6cd6ba8
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 44 deletions.
9 changes: 2 additions & 7 deletions talk/media/webrtc/webrtcvideoengine2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,9 @@ void* WebRtcVideoEncoderFactory2::CreateVideoEncoderSettings(
const VideoOptions& options) {
assert(SupportsCodec(codec));
if (_stricmp(codec.name.c_str(), kVp8CodecName) == 0) {
webrtc::VideoCodecVP8* settings = new webrtc::VideoCodecVP8();
settings->resilience = webrtc::kResilientStream;
settings->numberOfTemporalLayers = 1;
webrtc::VideoCodecVP8* settings = new webrtc::VideoCodecVP8(
webrtc::VideoEncoder::GetDefaultVp8Settings());
options.video_noise_reduction.Get(&settings->denoisingOn);
settings->errorConcealmentOn = false;
settings->automaticResizeOn = false;
settings->frameDroppingOn = true;
settings->keyFrameInterval = 3000;
return settings;
}
return NULL;
Expand Down
46 changes: 32 additions & 14 deletions webrtc/modules/video_coding/main/source/codec_database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,36 @@

namespace webrtc {

VideoCodecVP8 VideoEncoder::GetDefaultVp8Settings() {
VideoCodecVP8 vp8_settings;
memset(&vp8_settings, 0, sizeof(vp8_settings));

vp8_settings.resilience = kResilientStream;
vp8_settings.numberOfTemporalLayers = 1;
vp8_settings.denoisingOn = true;
vp8_settings.errorConcealmentOn = false;
vp8_settings.automaticResizeOn = false;
vp8_settings.frameDroppingOn = true;
vp8_settings.keyFrameInterval = 3000;

return vp8_settings;
}

VideoCodecH264 VideoEncoder::GetDefaultH264Settings() {
VideoCodecH264 h264_settings;
memset(&h264_settings, 0, sizeof(h264_settings));

h264_settings.profile = kProfileBase;
h264_settings.frameDroppingOn = true;
h264_settings.keyFrameInterval = 3000;
h264_settings.spsData = NULL;
h264_settings.spsLen = 0;
h264_settings.ppsData = NULL;
h264_settings.ppsLen = 0;

return h264_settings;
}

VCMDecoderMapItem::VCMDecoderMapItem(VideoCodec* settings,
int number_of_cores,
bool require_key_frame)
Expand Down Expand Up @@ -92,13 +122,7 @@ bool VCMCodecDataBase::Codec(int list_id,
settings->height = VCM_DEFAULT_CODEC_HEIGHT;
settings->numberOfSimulcastStreams = 0;
settings->qpMax = 56;
settings->codecSpecific.VP8.resilience = kResilientStream;
settings->codecSpecific.VP8.numberOfTemporalLayers = 1;
settings->codecSpecific.VP8.denoisingOn = true;
settings->codecSpecific.VP8.errorConcealmentOn = false;
settings->codecSpecific.VP8.automaticResizeOn = false;
settings->codecSpecific.VP8.frameDroppingOn = true;
settings->codecSpecific.VP8.keyFrameInterval = 3000;
settings->codecSpecific.VP8 = VideoEncoder::GetDefaultVp8Settings();
return true;
}
#endif
Expand All @@ -116,13 +140,7 @@ bool VCMCodecDataBase::Codec(int list_id,
settings->height = VCM_DEFAULT_CODEC_HEIGHT;
settings->numberOfSimulcastStreams = 0;
settings->qpMax = 56;
settings->codecSpecific.H264.profile = kProfileBase;
settings->codecSpecific.H264.frameDroppingOn = true;
settings->codecSpecific.H264.keyFrameInterval = 3000;
settings->codecSpecific.H264.spsData = NULL;
settings->codecSpecific.H264.spsLen = 0;
settings->codecSpecific.H264.ppsData = NULL;
settings->codecSpecific.H264.ppsLen = 0;
settings->codecSpecific.H264 = VideoEncoder::GetDefaultH264Settings();
return true;
}
#endif
Expand Down
17 changes: 4 additions & 13 deletions webrtc/test/encoder_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <assert.h>
#include <string.h>

#include "webrtc/video_encoder.h"
#include "webrtc/video_engine/vie_defines.h"

namespace webrtc {
Expand Down Expand Up @@ -68,19 +69,9 @@ VideoCodec CreateDecoderVideoCodec(
}

if (codec.codecType == kVideoCodecVP8) {
codec.codecSpecific.VP8.resilience = kResilientStream;
codec.codecSpecific.VP8.numberOfTemporalLayers = 1;
codec.codecSpecific.VP8.denoisingOn = true;
codec.codecSpecific.VP8.errorConcealmentOn = false;
codec.codecSpecific.VP8.automaticResizeOn = false;
codec.codecSpecific.VP8.frameDroppingOn = true;
codec.codecSpecific.VP8.keyFrameInterval = 3000;
}

if (codec.codecType == kVideoCodecH264) {
codec.codecSpecific.H264.profile = kProfileBase;
codec.codecSpecific.H264.frameDroppingOn = true;
codec.codecSpecific.H264.keyFrameInterval = 3000;
codec.codecSpecific.VP8 = VideoEncoder::GetDefaultVp8Settings();
} else if (codec.codecType == kVideoCodecH264) {
codec.codecSpecific.H264 = VideoEncoder::GetDefaultH264Settings();
}

codec.width = 320;
Expand Down
12 changes: 2 additions & 10 deletions webrtc/video/video_send_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,17 +313,9 @@ bool VideoSendStream::ReconfigureVideoEncoder(
}

if (video_codec.codecType == kVideoCodecVP8) {
video_codec.codecSpecific.VP8.resilience = kResilientStream;
video_codec.codecSpecific.VP8.numberOfTemporalLayers = 1;
video_codec.codecSpecific.VP8.denoisingOn = true;
video_codec.codecSpecific.VP8.errorConcealmentOn = false;
video_codec.codecSpecific.VP8.automaticResizeOn = false;
video_codec.codecSpecific.VP8.frameDroppingOn = true;
video_codec.codecSpecific.VP8.keyFrameInterval = 3000;
video_codec.codecSpecific.VP8 = VideoEncoder::GetDefaultVp8Settings();
} else if (video_codec.codecType == kVideoCodecH264) {
video_codec.codecSpecific.H264.profile = kProfileBase;
video_codec.codecSpecific.H264.frameDroppingOn = true;
video_codec.codecSpecific.H264.keyFrameInterval = 3000;
video_codec.codecSpecific.H264 = VideoEncoder::GetDefaultH264Settings();
}

if (video_codec.codecType == kVideoCodecVP8) {
Expand Down
4 changes: 4 additions & 0 deletions webrtc/video_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <vector>

#include "webrtc/common_types.h"
#include "webrtc/typedefs.h"
#include "webrtc/video_frame.h"

Expand Down Expand Up @@ -43,6 +44,9 @@ class VideoEncoder {

static VideoEncoder* Create(EncoderType codec_type);

static VideoCodecVP8 GetDefaultVp8Settings();
static VideoCodecH264 GetDefaultH264Settings();

virtual ~VideoEncoder() {}

virtual int32_t InitEncode(const VideoCodec* codec_settings,
Expand Down

0 comments on commit 6cd6ba8

Please sign in to comment.