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

Unified Diff: webrtc/modules/video_coding/utility/quality_scaler.cc

Issue 2020593002: Refactor scaling. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Trivial rebase. Created 4 years, 6 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
Index: webrtc/modules/video_coding/utility/quality_scaler.cc
diff --git a/webrtc/modules/video_coding/utility/quality_scaler.cc b/webrtc/modules/video_coding/utility/quality_scaler.cc
index bb60ee036e381dc9762e3b9a030acd257582eed5..541d0d431fb413944ca42ffdc03f3a2b2b7f4766 100644
--- a/webrtc/modules/video_coding/utility/quality_scaler.cc
+++ b/webrtc/modules/video_coding/utility/quality_scaler.cc
@@ -7,6 +7,7 @@
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
+
#include "webrtc/modules/video_coding/utility/quality_scaler.h"
namespace webrtc {
@@ -94,11 +95,11 @@ void QualityScaler::ReportDroppedFrame() {
framedrop_percent_.AddSample(100);
}
-void QualityScaler::OnEncodeFrame(const VideoFrame& frame) {
+void QualityScaler::OnEncodeFrame(int width, int height) {
// Should be set through InitEncode -> Should be set by now.
- assert(low_qp_threshold_ >= 0);
- assert(num_samples_upscale_ > 0);
- assert(num_samples_downscale_ > 0);
+ RTC_DCHECK_GE(low_qp_threshold_, 0);
+ RTC_DCHECK_GT(num_samples_upscale_, 0u);
+ RTC_DCHECK_GT(num_samples_downscale_, 0u);
// Update scale factor.
int avg_drop = 0;
@@ -113,38 +114,31 @@ void QualityScaler::OnEncodeFrame(const VideoFrame& frame) {
avg_qp <= low_qp_threshold_) {
AdjustScale(true);
}
- UpdateTargetResolution(frame.width(), frame.height());
+ UpdateTargetResolution(width, height);
}
QualityScaler::Resolution QualityScaler::GetScaledResolution() const {
return res_;
}
-const VideoFrame& QualityScaler::GetScaledFrame(const VideoFrame& frame) {
+rtc::scoped_refptr<VideoFrameBuffer> QualityScaler::GetScaledBuffer(
+ const rtc::scoped_refptr<VideoFrameBuffer>& frame) {
Resolution res = GetScaledResolution();
- if (res.width == frame.width())
- return frame;
+ int src_width = frame->width();
+ int src_height = frame->height();
- scaler_.Set(frame.width(), frame.height(), res.width, res.height, kI420,
- kI420, kScaleBox);
- if (scaler_.Scale(frame, &scaled_frame_) != 0)
+ if (res.width == src_width && res.height == src_height)
return frame;
+ rtc::scoped_refptr<I420Buffer> scaled_buffer =
+ pool_.CreateBuffer(res.width, res.height);
+
+ scaled_buffer->ScaleFrom(frame);
- // TODO(perkj): Refactor the scaler to not own |scaled_frame|. VideoFrame are
- // just thin wrappers so instead the scaler should return a
- // rtc::scoped_refptr<VideoFrameBuffer> and a new VideoFrame be created with
- // the meta data from |frame|. That way we would not have to set all these
- // meta data.
- scaled_frame_.set_ntp_time_ms(frame.ntp_time_ms());
- scaled_frame_.set_timestamp(frame.timestamp());
- scaled_frame_.set_render_time_ms(frame.render_time_ms());
- scaled_frame_.set_rotation(frame.rotation());
-
- return scaled_frame_;
+ return scaled_buffer;
}
void QualityScaler::UpdateTargetResolution(int frame_width, int frame_height) {
- assert(downscale_shift_ >= 0);
+ RTC_DCHECK_GE(downscale_shift_, 0);
int shifts_performed = 0;
for (int shift = downscale_shift_;
shift > 0 && (frame_width / 2 >= kMinDownscaleDimension) &&
« no previous file with comments | « webrtc/modules/video_coding/utility/quality_scaler.h ('k') | webrtc/modules/video_coding/utility/quality_scaler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698