| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 #include "webrtc/modules/video_coding/utility/quality_scaler.h" | 10 #include "webrtc/modules/video_coding/utility/quality_scaler.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 const VideoFrame& QualityScaler::GetScaledFrame(const VideoFrame& frame) { | 137 const VideoFrame& QualityScaler::GetScaledFrame(const VideoFrame& frame) { |
| 138 Resolution res = GetScaledResolution(); | 138 Resolution res = GetScaledResolution(); |
| 139 if (res.width == frame.width()) | 139 if (res.width == frame.width()) |
| 140 return frame; | 140 return frame; |
| 141 | 141 |
| 142 scaler_.Set(frame.width(), frame.height(), res.width, res.height, kI420, | 142 scaler_.Set(frame.width(), frame.height(), res.width, res.height, kI420, |
| 143 kI420, kScaleBox); | 143 kI420, kScaleBox); |
| 144 if (scaler_.Scale(frame, &scaled_frame_) != 0) | 144 if (scaler_.Scale(frame, &scaled_frame_) != 0) |
| 145 return frame; | 145 return frame; |
| 146 | 146 |
| 147 // TODO(perkj): Refactor the scaler to not own |scaled_frame|. VideoFrame are |
| 148 // just thin wrappers so instead the scaler should return a |
| 149 // rtc::scoped_refptr<VideoFrameBuffer> and a new VideoFrame be created with |
| 150 // the meta data from |frame|. That way we would not have to set all these |
| 151 // meta data. |
| 147 scaled_frame_.set_ntp_time_ms(frame.ntp_time_ms()); | 152 scaled_frame_.set_ntp_time_ms(frame.ntp_time_ms()); |
| 148 scaled_frame_.set_timestamp(frame.timestamp()); | 153 scaled_frame_.set_timestamp(frame.timestamp()); |
| 149 scaled_frame_.set_render_time_ms(frame.render_time_ms()); | 154 scaled_frame_.set_render_time_ms(frame.render_time_ms()); |
| 155 scaled_frame_.set_rotation(frame.rotation()); |
| 150 | 156 |
| 151 return scaled_frame_; | 157 return scaled_frame_; |
| 152 } | 158 } |
| 153 | 159 |
| 154 void QualityScaler::UpdateTargetResolution(int frame_width, int frame_height) { | 160 void QualityScaler::UpdateTargetResolution(int frame_width, int frame_height) { |
| 155 assert(downscale_shift_ >= 0); | 161 assert(downscale_shift_ >= 0); |
| 156 res_.width = frame_width; | 162 res_.width = frame_width; |
| 157 res_.height = frame_height; | 163 res_.height = frame_height; |
| 158 for (int shift = downscale_shift_; | 164 for (int shift = downscale_shift_; |
| 159 shift > 0 && (res_.width / 2 >= kMinDownscaleDimension) && | 165 shift > 0 && (res_.width / 2 >= kMinDownscaleDimension) && |
| (...skipping 23 matching lines...) Expand all Loading... |
| 183 downscale_shift_ = 0; | 189 downscale_shift_ = 0; |
| 184 if (!up) { | 190 if (!up) { |
| 185 // Hit first downscale, start using a slower threshold for going up. | 191 // Hit first downscale, start using a slower threshold for going up. |
| 186 measure_seconds_upscale_ = kMeasureSecondsUpscale; | 192 measure_seconds_upscale_ = kMeasureSecondsUpscale; |
| 187 UpdateSampleCounts(); | 193 UpdateSampleCounts(); |
| 188 } | 194 } |
| 189 ClearSamples(); | 195 ClearSamples(); |
| 190 } | 196 } |
| 191 | 197 |
| 192 } // namespace webrtc | 198 } // namespace webrtc |
| OLD | NEW |