| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 const VideoFrame& QualityScaler::GetScaledFrame(const VideoFrame& frame) { | 139 const VideoFrame& QualityScaler::GetScaledFrame(const VideoFrame& frame) { |
| 140 Resolution res = GetScaledResolution(); | 140 Resolution res = GetScaledResolution(); |
| 141 if (res.width == frame.width()) | 141 if (res.width == frame.width()) |
| 142 return frame; | 142 return frame; |
| 143 | 143 |
| 144 scaler_.Set(frame.width(), frame.height(), res.width, res.height, kI420, | 144 scaler_.Set(frame.width(), frame.height(), res.width, res.height, kI420, |
| 145 kI420, kScaleBox); | 145 kI420, kScaleBox); |
| 146 if (scaler_.Scale(frame, &scaled_frame_) != 0) | 146 if (scaler_.Scale(frame, &scaled_frame_) != 0) |
| 147 return frame; | 147 return frame; |
| 148 | 148 |
| 149 // TODO(perkj): Refactor the scaler to not own |scaled_frame|. VideoFrame are |
| 150 // just thin wrappers so instead the scaler should return a |
| 151 // rtc::scoped_refptr<VideoFrameBuffer> and a new VideoFrame be created with |
| 152 // the meta data from |frame|. That way we would not have to set all these |
| 153 // meta data. |
| 149 scaled_frame_.set_ntp_time_ms(frame.ntp_time_ms()); | 154 scaled_frame_.set_ntp_time_ms(frame.ntp_time_ms()); |
| 150 scaled_frame_.set_timestamp(frame.timestamp()); | 155 scaled_frame_.set_timestamp(frame.timestamp()); |
| 151 scaled_frame_.set_render_time_ms(frame.render_time_ms()); | 156 scaled_frame_.set_render_time_ms(frame.render_time_ms()); |
| 157 scaled_frame_.set_rotation(frame.rotation()); |
| 152 | 158 |
| 153 return scaled_frame_; | 159 return scaled_frame_; |
| 154 } | 160 } |
| 155 | 161 |
| 156 void QualityScaler::UpdateTargetResolution(int frame_width, int frame_height) { | 162 void QualityScaler::UpdateTargetResolution(int frame_width, int frame_height) { |
| 157 assert(downscale_shift_ >= 0); | 163 assert(downscale_shift_ >= 0); |
| 158 res_.width = frame_width; | 164 res_.width = frame_width; |
| 159 res_.height = frame_height; | 165 res_.height = frame_height; |
| 160 for (int shift = downscale_shift_; | 166 for (int shift = downscale_shift_; |
| 161 shift > 0 && (res_.width / 2 >= min_width_) && | 167 shift > 0 && (res_.width / 2 >= min_width_) && |
| (...skipping 23 matching lines...) Expand all Loading... |
| 185 downscale_shift_ = 0; | 191 downscale_shift_ = 0; |
| 186 if (!up) { | 192 if (!up) { |
| 187 // Hit first downscale, start using a slower threshold for going up. | 193 // Hit first downscale, start using a slower threshold for going up. |
| 188 measure_seconds_upscale_ = kMeasureSecondsUpscale; | 194 measure_seconds_upscale_ = kMeasureSecondsUpscale; |
| 189 UpdateSampleCounts(); | 195 UpdateSampleCounts(); |
| 190 } | 196 } |
| 191 ClearSamples(); | 197 ClearSamples(); |
| 192 } | 198 } |
| 193 | 199 |
| 194 } // namespace webrtc | 200 } // namespace webrtc |
| OLD | NEW |