OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 | 10 |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 static_cast<int>(total_runtime)); | 187 static_cast<int>(total_runtime)); |
188 printf("Min run time = %d us / frame\n\n", static_cast<int>(min_runtime)); | 188 printf("Min run time = %d us / frame\n\n", static_cast<int>(min_runtime)); |
189 } | 189 } |
190 | 190 |
191 void PreprocessFrameAndVerify(const VideoFrame& source, | 191 void PreprocessFrameAndVerify(const VideoFrame& source, |
192 int target_width, | 192 int target_width, |
193 int target_height, | 193 int target_height, |
194 VideoProcessing* vpm, | 194 VideoProcessing* vpm, |
195 const VideoFrame* out_frame) { | 195 const VideoFrame* out_frame) { |
196 ASSERT_EQ(VPM_OK, vpm->SetTargetResolution(target_width, target_height, 30)); | 196 ASSERT_EQ(VPM_OK, vpm->SetTargetResolution(target_width, target_height, 30)); |
197 out_frame = vpm->PreprocessFrame(source); | 197 out_frame = vpm->PreprocessFrame(source); |
magjed_webrtc
2016/10/25 07:32:11
We are completely ignoring the input value of |out
nisse-webrtc
2016/10/25 08:01:34
I agree. It was changed in cl https://codereview.w
| |
198 EXPECT_TRUE(out_frame != nullptr); | 198 EXPECT_TRUE(out_frame != nullptr); |
199 | 199 |
200 // If no resizing is needed, expect the original frame. | 200 // If no resizing is needed, expect the original frame. |
201 if (target_width == source.width() && target_height == source.height()) { | 201 if (target_width == source.width() && target_height == source.height()) { |
202 EXPECT_EQ(&source, out_frame); | 202 EXPECT_EQ(&source, out_frame); |
203 return; | 203 return; |
204 } | 204 } |
205 | 205 |
206 // Verify the resampled frame. | 206 // Verify the resampled frame. |
207 EXPECT_TRUE(out_frame != NULL); | 207 EXPECT_TRUE(out_frame != NULL); |
(...skipping 29 matching lines...) Expand all Loading... | |
237 const VideoFrameBuffer& cropped_source, | 237 const VideoFrameBuffer& cropped_source, |
238 int target_width, | 238 int target_width, |
239 int target_height, | 239 int target_height, |
240 double expected_psnr, | 240 double expected_psnr, |
241 VideoProcessing* vpm) { | 241 VideoProcessing* vpm) { |
242 // Resample source_frame to out_frame. | 242 // Resample source_frame to out_frame. |
243 VideoFrame* out_frame = NULL; | 243 VideoFrame* out_frame = NULL; |
244 vpm->SetInputFrameResampleMode(kBox); | 244 vpm->SetInputFrameResampleMode(kBox); |
245 PreprocessFrameAndVerify(source_frame, target_width, target_height, vpm, | 245 PreprocessFrameAndVerify(source_frame, target_width, target_height, vpm, |
246 out_frame); | 246 out_frame); |
247 if (out_frame == NULL) | 247 if (out_frame == NULL) |
magjed_webrtc
2016/10/25 07:32:11
Something is wrong. |out_frame| will always be nul
nisse-webrtc
2016/10/25 08:01:34
Same here, change from the earlier refactoring.
| |
248 return; | 248 return; |
249 WriteProcessedFrameForVisualInspection(source_frame, *out_frame); | 249 WriteProcessedFrameForVisualInspection(source_frame, *out_frame); |
250 | 250 |
251 // Scale |resampled_source_frame| back to the source scale. | 251 // Scale |resampled_source_frame| back to the source scale. |
252 VideoFrame resampled_source_frame; | 252 VideoFrame resampled_source_frame(*out_frame); |
253 resampled_source_frame.ShallowCopy(*out_frame); | |
254 // Compute PSNR against the cropped source frame and check expectation. | 253 // Compute PSNR against the cropped source frame and check expectation. |
255 PreprocessFrameAndVerify(resampled_source_frame, | 254 PreprocessFrameAndVerify(resampled_source_frame, |
256 cropped_source.width(), | 255 cropped_source.width(), |
257 cropped_source.height(), vpm, out_frame); | 256 cropped_source.height(), vpm, out_frame); |
258 WriteProcessedFrameForVisualInspection(resampled_source_frame, *out_frame); | 257 WriteProcessedFrameForVisualInspection(resampled_source_frame, *out_frame); |
259 | 258 |
260 // Compute PSNR against the cropped source frame and check expectation. | 259 // Compute PSNR against the cropped source frame and check expectation. |
261 double psnr = | 260 double psnr = |
262 I420PSNR(cropped_source, *out_frame->video_frame_buffer()); | 261 I420PSNR(cropped_source, *out_frame->video_frame_buffer()); |
263 EXPECT_GT(psnr, expected_psnr); | 262 EXPECT_GT(psnr, expected_psnr); |
(...skipping 17 matching lines...) Expand all Loading... | |
281 std::cout << "Watch " << filename.str() << " and verify that it is okay." | 280 std::cout << "Watch " << filename.str() << " and verify that it is okay." |
282 << std::endl; | 281 << std::endl; |
283 FILE* stand_alone_file = fopen(filename.str().c_str(), "wb"); | 282 FILE* stand_alone_file = fopen(filename.str().c_str(), "wb"); |
284 if (PrintVideoFrame(processed, stand_alone_file) < 0) | 283 if (PrintVideoFrame(processed, stand_alone_file) < 0) |
285 std::cerr << "Failed to write: " << filename.str() << std::endl; | 284 std::cerr << "Failed to write: " << filename.str() << std::endl; |
286 if (stand_alone_file) | 285 if (stand_alone_file) |
287 fclose(stand_alone_file); | 286 fclose(stand_alone_file); |
288 } | 287 } |
289 | 288 |
290 } // namespace webrtc | 289 } // namespace webrtc |
OLD | NEW |