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..6fe1c66490d3c2cbc6a358408d484c1d18606489 100644 |
--- a/webrtc/modules/video_coding/utility/quality_scaler.cc |
+++ b/webrtc/modules/video_coding/utility/quality_scaler.cc |
@@ -7,6 +7,10 @@ |
* in the file PATENTS. All contributing project authors may |
* be found in the AUTHORS file in the root of the source tree. |
*/ |
+ |
+// TODO(nisse): Switch to RTC_CHECK (or RTC_DCHECK) ? |
pbos-webrtc
2016/05/31 14:14:02
Do that now, please. Pref DCHECK. :)
nisse-webrtc
2016/06/01 09:15:18
Done.
|
+#include <assert.h> |
+ |
#include "webrtc/modules/video_coding/utility/quality_scaler.h" |
namespace webrtc { |
@@ -94,7 +98,7 @@ 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); |
@@ -113,34 +117,27 @@ 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::GetScaledFrame( |
+ 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 = |
+ pool_.CreateBuffer(res.width, res.height); |
+ |
+ I420Buffer::CenterCropAndScale(scaled, 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; |
} |
void QualityScaler::UpdateTargetResolution(int frame_width, int frame_height) { |