From b49ac78c71d3dfa24a8a3877ca800c9593a484ee Mon Sep 17 00:00:00 2001 From: pbos Date: Wed, 4 May 2016 07:17:53 -0700 Subject: [PATCH] Revert of Use RC_TIMESTAMP_MODE for OpenH264. (patchset #1 id:1 of https://codereview.webrtc.org/1945763002/ ) Reason for revert: Previous mode aligns with other encoders, and RC_TIMESTAMP_MODE might have issues with no frames for several seconds. Original issue's description: > Use RC_TIMESTAMP_MODE for OpenH264. > > Performs rate control based on timestamp deltas instead of announced > frame rate. > > BUG=webrtc:5855 > R=hbos@webrtc.org > > Committed: https://crrev.com/c4deee49a3ec42b7fe83c82f750539b36aae1d3f > Cr-Commit-Position: refs/heads/master@{#12611} TBR=hbos@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:5855 Review-Url: https://codereview.webrtc.org/1950973002 Cr-Commit-Position: refs/heads/master@{#12629} --- .../codecs/h264/h264_encoder_impl.cc | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc b/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc index a6325a9070..18eccb25a5 100644 --- a/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc +++ b/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc @@ -224,7 +224,7 @@ int32_t H264EncoderImpl::InitEncode(const VideoCodec* codec_settings, init_params.iTargetBitrate = codec_settings_.targetBitrate * 1000; init_params.iMaxBitrate = codec_settings_.maxBitrate * 1000; // Rate Control mode - init_params.iRCMode = RC_TIMESTAMP_MODE; + init_params.iRCMode = RC_BITRATE_MODE; init_params.fMaxFrameRate = static_cast(codec_settings_.maxFramerate); // The following parameters are extension parameters (they're in SEncParamExt, @@ -343,13 +343,21 @@ int32_t H264EncoderImpl::Encode( return WEBRTC_VIDEO_CODEC_ERR_SIZE; } - RTC_DCHECK(frame_types != nullptr); - // We only support a single stream. - RTC_DCHECK_EQ(1u, frame_types->size()); - // Force key frame? - if ((*frame_types)[0] == kVideoFrameKey) { + bool force_key_frame = false; + if (frame_types != nullptr) { + // We only support a single stream. + RTC_DCHECK_EQ(frame_types->size(), static_cast(1)); + // Skip frame? + if ((*frame_types)[0] == kEmptyFrame) { + return WEBRTC_VIDEO_CODEC_OK; + } + // Force key frame? + force_key_frame = (*frame_types)[0] == kVideoFrameKey; + } + if (force_key_frame) { // API doc says ForceIntraFrame(false) does nothing, but calling this // function forces a key frame regardless of the |bIDR| argument's value. + // (If every frame is a key frame we get lag/delays.) openh264_encoder_->ForceIntraFrame(true); }