Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Unified Diff: webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc

Issue 3011213002: Move reencode logic for screenshare bitrate overshoot from generic (Closed)
Patch Set: Implement sprang@ comments Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/modules/video_coding/generic_encoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc
diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc
index c84049f034609e7df4b08449da0d617f994bb151..8d10594da9c4c18f24463ee8755ff9802936ad6f 100644
--- a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc
+++ b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc
@@ -827,20 +827,31 @@ int VP8EncoderImpl::Encode(const VideoFrame& frame,
assert(codec_.maxFramerate > 0);
uint32_t duration = 90000 / codec_.maxFramerate;
- // Note we must pass 0 for |flags| field in encode call below since they are
- // set above in |vpx_codec_control| function for each encoder/spatial layer.
- int error = vpx_codec_encode(&encoders_[0], &raw_images_[0], timestamp_,
- duration, 0, VPX_DL_REALTIME);
- // Reset specific intra frame thresholds, following the key frame.
- if (send_key_frame) {
- vpx_codec_control(&(encoders_[0]), VP8E_SET_MAX_INTRA_BITRATE_PCT,
- rc_max_intra_target_);
+ int error = WEBRTC_VIDEO_CODEC_OK;
+ int num_tries = 0;
+ // If the first try returns WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT
+ // the frame must be reencoded with the same parameters again because
+ // target bitrate is exceeded and encoder state has been reset.
+ while (num_tries == 0 ||
+ (num_tries == 1 &&
+ error == WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT)) {
+ ++num_tries;
+ // Note we must pass 0 for |flags| field in encode call below since they are
+ // set above in |vpx_codec_control| function for each encoder/spatial layer.
+ error = vpx_codec_encode(&encoders_[0], &raw_images_[0], timestamp_,
+ duration, 0, VPX_DL_REALTIME);
+ // Reset specific intra frame thresholds, following the key frame.
+ if (send_key_frame) {
+ vpx_codec_control(&(encoders_[0]), VP8E_SET_MAX_INTRA_BITRATE_PCT,
+ rc_max_intra_target_);
+ }
+ if (error)
+ return WEBRTC_VIDEO_CODEC_ERROR;
+ timestamp_ += duration;
+ // Examines frame timestamps only.
+ error = GetEncodedPartitions(tl_configs, frame);
}
- if (error)
- return WEBRTC_VIDEO_CODEC_ERROR;
- timestamp_ += duration;
- // Examines frame timestamps only.
- return GetEncodedPartitions(tl_configs, frame);
+ return error;
}
void VP8EncoderImpl::PopulateCodecSpecific(
« no previous file with comments | « no previous file | webrtc/modules/video_coding/generic_encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698