| 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 |
| 11 #include "webrtc/modules/video_processing/test/video_processing_unittest.h" | 11 #include "webrtc/modules/video_processing/test/video_processing_unittest.h" |
| 12 | 12 |
| 13 #include <gflags/gflags.h> | 13 #include <gflags/gflags.h> |
| 14 | 14 |
| 15 #include <memory> | 15 #include <memory> |
| 16 #include <string> | 16 #include <string> |
| 17 | 17 |
| 18 #include "webrtc/base/keep_ref_until_done.h" | |
| 19 #include "webrtc/base/timeutils.h" | 18 #include "webrtc/base/timeutils.h" |
| 20 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 19 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
| 21 #include "webrtc/test/testsupport/fileutils.h" | 20 #include "webrtc/test/testsupport/fileutils.h" |
| 22 | 21 |
| 23 namespace webrtc { | 22 namespace webrtc { |
| 24 | 23 |
| 25 namespace { | 24 namespace { |
| 26 | 25 |
| 27 // Define command line flag 'gen_files' (default value: false). | 26 // Define command line flag 'gen_files' (default value: false). |
| 28 DEFINE_bool(gen_files, false, "Output files for visual inspection."); | 27 DEFINE_bool(gen_files, false, "Output files for visual inspection."); |
| 29 | 28 |
| 30 } // namespace | 29 } // namespace |
| 31 | 30 |
| 32 static void PreprocessFrameAndVerify(const VideoFrame& source, | 31 static void PreprocessFrameAndVerify(const VideoFrame& source, |
| 33 int target_width, | 32 int target_width, |
| 34 int target_height, | 33 int target_height, |
| 35 VideoProcessing* vpm, | 34 VideoProcessing* vpm, |
| 36 const VideoFrame* out_frame); | 35 const VideoFrame* out_frame); |
| 37 rtc::scoped_refptr<VideoFrameBuffer> CropBuffer( | 36 static void CropFrame(const uint8_t* source_data, |
| 38 const rtc::scoped_refptr<VideoFrameBuffer>& source_buffer, | 37 int source_width, |
| 39 int source_width, | 38 int source_height, |
| 40 int source_height, | 39 int offset_x, |
| 41 int offset_x, | 40 int offset_y, |
| 42 int offset_y, | 41 int cropped_width, |
| 43 int cropped_width, | 42 int cropped_height, |
| 44 int cropped_height); | 43 VideoFrame* cropped_frame); |
| 45 // The |source_data| is cropped and scaled to |target_width| x |target_height|, | 44 // The |source_data| is cropped and scaled to |target_width| x |target_height|, |
| 46 // and then scaled back to the expected cropped size. |expected_psnr| is used to | 45 // and then scaled back to the expected cropped size. |expected_psnr| is used to |
| 47 // verify basic quality, and is set to be ~0.1/0.05dB lower than actual PSNR | 46 // verify basic quality, and is set to be ~0.1/0.05dB lower than actual PSNR |
| 48 // verified under the same conditions. | 47 // verified under the same conditions. |
| 49 static void TestSize( | 48 static void TestSize(const VideoFrame& source_frame, |
| 50 const VideoFrame& source_frame, | 49 const VideoFrame& cropped_source_frame, |
| 51 const rtc::scoped_refptr<VideoFrameBuffer>& cropped_source_buffer, | 50 int target_width, |
| 52 int target_width, | 51 int target_height, |
| 53 int target_height, | 52 double expected_psnr, |
| 54 double expected_psnr, | 53 VideoProcessing* vpm); |
| 55 VideoProcessing* vpm); | |
| 56 static void WriteProcessedFrameForVisualInspection(const VideoFrame& source, | 54 static void WriteProcessedFrameForVisualInspection(const VideoFrame& source, |
| 57 const VideoFrame& processed); | 55 const VideoFrame& processed); |
| 58 | 56 |
| 59 VideoProcessingTest::VideoProcessingTest() | 57 VideoProcessingTest::VideoProcessingTest() |
| 60 : vp_(NULL), | 58 : vp_(NULL), |
| 61 source_file_(NULL), | 59 source_file_(NULL), |
| 62 width_(352), | 60 width_(352), |
| 63 half_width_((width_ + 1) / 2), | 61 half_width_((width_ + 1) / 2), |
| 64 height_(288), | 62 height_(288), |
| 65 size_y_(width_ * height_), | 63 size_y_(width_ * height_), |
| 66 size_uv_(half_width_ * ((height_ + 1) / 2)), | 64 size_uv_(half_width_ * ((height_ + 1) / 2)), |
| 67 frame_length_(CalcBufferSize(kI420, width_, height_)) {} | 65 frame_length_(CalcBufferSize(kI420, width_, height_)) {} |
| 68 | 66 |
| 69 void VideoProcessingTest::SetUp() { | 67 void VideoProcessingTest::SetUp() { |
| 70 vp_ = VideoProcessing::Create(); | 68 vp_ = VideoProcessing::Create(); |
| 71 ASSERT_TRUE(vp_ != NULL); | 69 ASSERT_TRUE(vp_ != NULL); |
| 72 | 70 |
| 71 video_frame_.CreateEmptyFrame(width_, height_, width_, |
| 72 half_width_, half_width_); |
| 73 // Clear video frame so DrMemory/Valgrind will allow reads of the buffer. |
| 74 memset(video_frame_.video_frame_buffer()->MutableDataY(), 0, |
| 75 video_frame_.allocated_size(kYPlane)); |
| 76 memset(video_frame_.video_frame_buffer()->MutableDataU(), 0, |
| 77 video_frame_.allocated_size(kUPlane)); |
| 78 memset(video_frame_.video_frame_buffer()->MutableDataV(), 0, |
| 79 video_frame_.allocated_size(kVPlane)); |
| 73 const std::string video_file = | 80 const std::string video_file = |
| 74 webrtc::test::ResourcePath("foreman_cif", "yuv"); | 81 webrtc::test::ResourcePath("foreman_cif", "yuv"); |
| 75 source_file_ = fopen(video_file.c_str(), "rb"); | 82 source_file_ = fopen(video_file.c_str(), "rb"); |
| 76 ASSERT_TRUE(source_file_ != NULL) | 83 ASSERT_TRUE(source_file_ != NULL) |
| 77 << "Cannot read source file: " + video_file + "\n"; | 84 << "Cannot read source file: " + video_file + "\n"; |
| 78 } | 85 } |
| 79 | 86 |
| 80 void VideoProcessingTest::TearDown() { | 87 void VideoProcessingTest::TearDown() { |
| 81 if (source_file_ != NULL) { | 88 if (source_file_ != NULL) { |
| 82 ASSERT_EQ(0, fclose(source_file_)); | 89 ASSERT_EQ(0, fclose(source_file_)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 95 vp_->EnableTemporalDecimation(false); | 102 vp_->EnableTemporalDecimation(false); |
| 96 int resolution = 100; | 103 int resolution = 100; |
| 97 EXPECT_EQ(VPM_OK, vp_->SetTargetResolution(resolution, resolution, 15)); | 104 EXPECT_EQ(VPM_OK, vp_->SetTargetResolution(resolution, resolution, 15)); |
| 98 EXPECT_EQ(VPM_OK, vp_->SetTargetResolution(resolution, resolution, 30)); | 105 EXPECT_EQ(VPM_OK, vp_->SetTargetResolution(resolution, resolution, 30)); |
| 99 // Disable spatial sampling. | 106 // Disable spatial sampling. |
| 100 vp_->SetInputFrameResampleMode(kNoRescaling); | 107 vp_->SetInputFrameResampleMode(kNoRescaling); |
| 101 EXPECT_EQ(VPM_OK, vp_->SetTargetResolution(resolution, resolution, 30)); | 108 EXPECT_EQ(VPM_OK, vp_->SetTargetResolution(resolution, resolution, 30)); |
| 102 VideoFrame* out_frame = NULL; | 109 VideoFrame* out_frame = NULL; |
| 103 // Set rescaling => output frame != NULL. | 110 // Set rescaling => output frame != NULL. |
| 104 vp_->SetInputFrameResampleMode(kFastRescaling); | 111 vp_->SetInputFrameResampleMode(kFastRescaling); |
| 105 | 112 PreprocessFrameAndVerify(video_frame_, resolution, resolution, vp_, |
| 106 rtc::scoped_refptr<webrtc::I420Buffer> buffer = | 113 out_frame); |
| 107 I420Buffer::Create(width_, height_, width_, half_width_, half_width_); | |
| 108 | |
| 109 // Clear video frame so DrMemory/Valgrind will allow reads of the buffer. | |
| 110 buffer->InitializeData(); | |
| 111 VideoFrame video_frame(buffer, 0, 0, webrtc::kVideoRotation_0); | |
| 112 | |
| 113 PreprocessFrameAndVerify(video_frame, resolution, resolution, vp_, out_frame); | |
| 114 // No rescaling=> output frame = NULL. | 114 // No rescaling=> output frame = NULL. |
| 115 vp_->SetInputFrameResampleMode(kNoRescaling); | 115 vp_->SetInputFrameResampleMode(kNoRescaling); |
| 116 EXPECT_TRUE(vp_->PreprocessFrame(video_frame) != nullptr); | 116 EXPECT_TRUE(vp_->PreprocessFrame(video_frame_) != nullptr); |
| 117 } | 117 } |
| 118 | 118 |
| 119 #if defined(WEBRTC_IOS) | 119 #if defined(WEBRTC_IOS) |
| 120 TEST_F(VideoProcessingTest, DISABLED_Resampler) { | 120 TEST_F(VideoProcessingTest, DISABLED_Resampler) { |
| 121 #else | 121 #else |
| 122 TEST_F(VideoProcessingTest, Resampler) { | 122 TEST_F(VideoProcessingTest, Resampler) { |
| 123 #endif | 123 #endif |
| 124 enum { NumRuns = 1 }; | 124 enum { NumRuns = 1 }; |
| 125 | 125 |
| 126 int64_t min_runtime = 0; | 126 int64_t min_runtime = 0; |
| 127 int64_t total_runtime = 0; | 127 int64_t total_runtime = 0; |
| 128 | 128 |
| 129 rewind(source_file_); | 129 rewind(source_file_); |
| 130 ASSERT_TRUE(source_file_ != NULL) << "Cannot read input file \n"; | 130 ASSERT_TRUE(source_file_ != NULL) << "Cannot read input file \n"; |
| 131 | 131 |
| 132 // no temporal decimation | 132 // no temporal decimation |
| 133 vp_->EnableTemporalDecimation(false); | 133 vp_->EnableTemporalDecimation(false); |
| 134 | 134 |
| 135 // Reading test frame | 135 // Reading test frame |
| 136 rtc::scoped_refptr<webrtc::I420Buffer> buffer = | 136 std::unique_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]); |
| 137 I420Buffer::Create(width_, height_, width_, half_width_, half_width_); | 137 ASSERT_EQ(frame_length_, |
| 138 | 138 fread(video_buffer.get(), 1, frame_length_, source_file_)); |
| 139 ASSERT_EQ(static_cast<size_t>(size_y_), | 139 // Using ConvertToI420 to add stride to the image. |
| 140 fread(buffer->MutableDataY(), 1, size_y_, source_file_)); | 140 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, |
| 141 ASSERT_EQ(static_cast<size_t>(size_uv_), | 141 0, kVideoRotation_0, &video_frame_)); |
| 142 fread(buffer->MutableDataU(), 1, size_uv_, source_file_)); | 142 // Cropped source frame that will contain the expected visible region. |
| 143 ASSERT_EQ(static_cast<size_t>(size_uv_), | 143 VideoFrame cropped_source_frame; |
| 144 fread(buffer->MutableDataV(), 1, size_uv_, source_file_)); | 144 cropped_source_frame.CopyFrame(video_frame_); |
| 145 | 145 |
| 146 for (uint32_t run_idx = 0; run_idx < NumRuns; run_idx++) { | 146 for (uint32_t run_idx = 0; run_idx < NumRuns; run_idx++) { |
| 147 // Initiate test timer. | 147 // Initiate test timer. |
| 148 const int64_t time_start = rtc::TimeNanos(); | 148 const int64_t time_start = rtc::TimeNanos(); |
| 149 | 149 |
| 150 // Init the sourceFrame with a timestamp. | 150 // Init the sourceFrame with a timestamp. |
| 151 int64_t time_start_ms = time_start / rtc::kNumNanosecsPerMillisec; | 151 int64_t time_start_ms = time_start / rtc::kNumNanosecsPerMillisec; |
| 152 VideoFrame video_frame(buffer, time_start_ms * 90, time_start_ms, | 152 video_frame_.set_render_time_ms(time_start_ms); |
| 153 webrtc::kVideoRotation_0); | 153 video_frame_.set_timestamp(time_start_ms * 90); |
| 154 | 154 |
| 155 // Test scaling to different sizes: source is of |width|/|height| = 352/288. | 155 // Test scaling to different sizes: source is of |width|/|height| = 352/288. |
| 156 // Pure scaling: | 156 // Pure scaling: |
| 157 TestSize(video_frame, buffer, width_ / 4, height_ / 4, 25.2, vp_); | 157 TestSize(video_frame_, video_frame_, width_ / 4, height_ / 4, 25.2, vp_); |
| 158 TestSize(video_frame, buffer, width_ / 2, height_ / 2, 28.1, vp_); | 158 TestSize(video_frame_, video_frame_, width_ / 2, height_ / 2, 28.1, vp_); |
| 159 // No resampling: | 159 // No resampling: |
| 160 TestSize(video_frame, buffer, width_, height_, -1, vp_); | 160 TestSize(video_frame_, video_frame_, width_, height_, -1, vp_); |
| 161 TestSize(video_frame, buffer, 2 * width_, 2 * height_, 32.2, vp_); | 161 TestSize(video_frame_, video_frame_, 2 * width_, 2 * height_, 32.2, vp_); |
| 162 | 162 |
| 163 // Scaling and cropping. The cropped source frame is the largest center | 163 // Scaling and cropping. The cropped source frame is the largest center |
| 164 // aligned region that can be used from the source while preserving aspect | 164 // aligned region that can be used from the source while preserving aspect |
| 165 // ratio. | 165 // ratio. |
| 166 TestSize(video_frame, CropBuffer(buffer, width_, height_, 0, 56, 352, 176), | 166 CropFrame(video_buffer.get(), width_, height_, 0, 56, 352, 176, |
| 167 100, 50, 24.0, vp_); | 167 &cropped_source_frame); |
| 168 TestSize(video_frame, CropBuffer(buffer, width_, height_, 0, 30, 352, 225), | 168 TestSize(video_frame_, cropped_source_frame, 100, 50, 24.0, vp_); |
| 169 400, 256, 31.3, vp_); | 169 |
| 170 TestSize(video_frame, CropBuffer(buffer, width_, height_, 68, 0, 216, 288), | 170 CropFrame(video_buffer.get(), width_, height_, 0, 30, 352, 225, |
| 171 480, 640, 32.15, vp_); | 171 &cropped_source_frame); |
| 172 TestSize(video_frame, CropBuffer(buffer, width_, height_, 0, 12, 352, 264), | 172 TestSize(video_frame_, cropped_source_frame, 400, 256, 31.3, vp_); |
| 173 960, 720, 32.2, vp_); | 173 |
| 174 TestSize(video_frame, CropBuffer(buffer, width_, height_, 0, 44, 352, 198), | 174 CropFrame(video_buffer.get(), width_, height_, 68, 0, 216, 288, |
| 175 1280, 720, 32.15, vp_); | 175 &cropped_source_frame); |
| 176 TestSize(video_frame_, cropped_source_frame, 480, 640, 32.15, vp_); |
| 177 |
| 178 CropFrame(video_buffer.get(), width_, height_, 0, 12, 352, 264, |
| 179 &cropped_source_frame); |
| 180 TestSize(video_frame_, cropped_source_frame, 960, 720, 32.2, vp_); |
| 181 |
| 182 CropFrame(video_buffer.get(), width_, height_, 0, 44, 352, 198, |
| 183 &cropped_source_frame); |
| 184 TestSize(video_frame_, cropped_source_frame, 1280, 720, 32.15, vp_); |
| 176 | 185 |
| 177 // Upsampling to odd size. | 186 // Upsampling to odd size. |
| 178 TestSize(video_frame, CropBuffer(buffer, width_, height_, 0, 26, 352, 233), | 187 CropFrame(video_buffer.get(), width_, height_, 0, 26, 352, 233, |
| 179 501, 333, 32.05, vp_); | 188 &cropped_source_frame); |
| 189 TestSize(video_frame_, cropped_source_frame, 501, 333, 32.05, vp_); |
| 180 // Downsample to odd size. | 190 // Downsample to odd size. |
| 181 TestSize(video_frame, CropBuffer(buffer, width_, height_, 0, 34, 352, 219), | 191 CropFrame(video_buffer.get(), width_, height_, 0, 34, 352, 219, |
| 182 281, 175, 29.3, vp_); | 192 &cropped_source_frame); |
| 193 TestSize(video_frame_, cropped_source_frame, 281, 175, 29.3, vp_); |
| 183 | 194 |
| 184 // Stop timer. | 195 // Stop timer. |
| 185 const int64_t runtime = | 196 const int64_t runtime = |
| 186 (rtc::TimeNanos() - time_start) / rtc::kNumNanosecsPerMicrosec; | 197 (rtc::TimeNanos() - time_start) / rtc::kNumNanosecsPerMicrosec; |
| 187 if (runtime < min_runtime || run_idx == 0) { | 198 if (runtime < min_runtime || run_idx == 0) { |
| 188 min_runtime = runtime; | 199 min_runtime = runtime; |
| 189 } | 200 } |
| 190 total_runtime += runtime; | 201 total_runtime += runtime; |
| 191 } | 202 } |
| 192 | 203 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 211 } | 222 } |
| 212 | 223 |
| 213 // Verify the resampled frame. | 224 // Verify the resampled frame. |
| 214 EXPECT_TRUE(out_frame != NULL); | 225 EXPECT_TRUE(out_frame != NULL); |
| 215 EXPECT_EQ(source.render_time_ms(), (out_frame)->render_time_ms()); | 226 EXPECT_EQ(source.render_time_ms(), (out_frame)->render_time_ms()); |
| 216 EXPECT_EQ(source.timestamp(), (out_frame)->timestamp()); | 227 EXPECT_EQ(source.timestamp(), (out_frame)->timestamp()); |
| 217 EXPECT_EQ(target_width, (out_frame)->width()); | 228 EXPECT_EQ(target_width, (out_frame)->width()); |
| 218 EXPECT_EQ(target_height, (out_frame)->height()); | 229 EXPECT_EQ(target_height, (out_frame)->height()); |
| 219 } | 230 } |
| 220 | 231 |
| 221 rtc::scoped_refptr<VideoFrameBuffer> CropBuffer( | 232 void CropFrame(const uint8_t* source_data, |
| 222 const rtc::scoped_refptr<VideoFrameBuffer>& source_buffer, | 233 int source_width, |
| 223 int source_width, | 234 int source_height, |
| 224 int source_height, | 235 int offset_x, |
| 225 int offset_x, | 236 int offset_y, |
| 226 int offset_y, | 237 int cropped_width, |
| 227 int cropped_width, | 238 int cropped_height, |
| 228 int cropped_height) { | 239 VideoFrame* cropped_frame) { |
| 229 // Force even. | 240 cropped_frame->CreateEmptyFrame(cropped_width, cropped_height, cropped_width, |
| 230 offset_x &= 1; | 241 (cropped_width + 1) / 2, |
| 231 offset_y &= 1; | 242 (cropped_width + 1) / 2); |
| 232 | 243 EXPECT_EQ(0, |
| 233 size_t y_start = offset_x + offset_y * source_buffer->StrideY(); | 244 ConvertToI420(kI420, source_data, offset_x, offset_y, source_width, |
| 234 size_t u_start = (offset_x / 2) + (offset_y / 2) * source_buffer->StrideU(); | 245 source_height, 0, kVideoRotation_0, cropped_frame)); |
| 235 size_t v_start = (offset_x / 2) + (offset_y / 2) * source_buffer->StrideU(); | |
| 236 | |
| 237 return rtc::scoped_refptr<VideoFrameBuffer>( | |
| 238 new rtc::RefCountedObject<WrappedI420Buffer>( | |
| 239 cropped_width, cropped_height, source_buffer->DataY() + y_start, | |
| 240 source_buffer->StrideY(), source_buffer->DataU() + u_start, | |
| 241 source_buffer->StrideU(), source_buffer->DataV() + v_start, | |
| 242 source_buffer->StrideV(), rtc::KeepRefUntilDone(source_buffer))); | |
| 243 } | 246 } |
| 244 | 247 |
| 245 void TestSize(const VideoFrame& source_frame, | 248 void TestSize(const VideoFrame& source_frame, |
| 246 const rtc::scoped_refptr<VideoFrameBuffer>& cropped_source_buffer, | 249 const VideoFrame& cropped_source_frame, |
| 247 int target_width, | 250 int target_width, |
| 248 int target_height, | 251 int target_height, |
| 249 double expected_psnr, | 252 double expected_psnr, |
| 250 VideoProcessing* vpm) { | 253 VideoProcessing* vpm) { |
| 251 // Resample source_frame to out_frame. | 254 // Resample source_frame to out_frame. |
| 252 VideoFrame* out_frame = NULL; | 255 VideoFrame* out_frame = NULL; |
| 253 vpm->SetInputFrameResampleMode(kBox); | 256 vpm->SetInputFrameResampleMode(kBox); |
| 254 PreprocessFrameAndVerify(source_frame, target_width, target_height, vpm, | 257 PreprocessFrameAndVerify(source_frame, target_width, target_height, vpm, |
| 255 out_frame); | 258 out_frame); |
| 256 if (out_frame == NULL) | 259 if (out_frame == NULL) |
| 257 return; | 260 return; |
| 258 WriteProcessedFrameForVisualInspection(source_frame, *out_frame); | 261 WriteProcessedFrameForVisualInspection(source_frame, *out_frame); |
| 259 | 262 |
| 260 // Scale |resampled_source_frame| back to the source scale. | 263 // Scale |resampled_source_frame| back to the source scale. |
| 261 VideoFrame resampled_source_frame; | 264 VideoFrame resampled_source_frame; |
| 262 resampled_source_frame.CopyFrame(*out_frame); | 265 resampled_source_frame.CopyFrame(*out_frame); |
| 263 PreprocessFrameAndVerify(resampled_source_frame, | 266 PreprocessFrameAndVerify(resampled_source_frame, cropped_source_frame.width(), |
| 264 cropped_source_buffer->width(), | 267 cropped_source_frame.height(), vpm, out_frame); |
| 265 cropped_source_buffer->height(), vpm, out_frame); | |
| 266 WriteProcessedFrameForVisualInspection(resampled_source_frame, *out_frame); | 268 WriteProcessedFrameForVisualInspection(resampled_source_frame, *out_frame); |
| 267 | 269 |
| 268 // Compute PSNR against the cropped source frame and check expectation. | 270 // Compute PSNR against the cropped source frame and check expectation. |
| 269 double psnr = | 271 double psnr = I420PSNR(&cropped_source_frame, out_frame); |
| 270 I420PSNR(*cropped_source_buffer, *out_frame->video_frame_buffer()); | |
| 271 EXPECT_GT(psnr, expected_psnr); | 272 EXPECT_GT(psnr, expected_psnr); |
| 272 printf( | 273 printf( |
| 273 "PSNR: %f. PSNR is between source of size %d %d, and a modified " | 274 "PSNR: %f. PSNR is between source of size %d %d, and a modified " |
| 274 "source which is scaled down/up to: %d %d, and back to source size \n", | 275 "source which is scaled down/up to: %d %d, and back to source size \n", |
| 275 psnr, source_frame.width(), source_frame.height(), target_width, | 276 psnr, source_frame.width(), source_frame.height(), target_width, |
| 276 target_height); | 277 target_height); |
| 277 } | 278 } |
| 278 | 279 |
| 279 void WriteProcessedFrameForVisualInspection(const VideoFrame& source, | 280 void WriteProcessedFrameForVisualInspection(const VideoFrame& source, |
| 280 const VideoFrame& processed) { | 281 const VideoFrame& processed) { |
| 281 // Skip if writing to files is not enabled. | 282 // Skip if writing to files is not enabled. |
| 282 if (!FLAGS_gen_files) | 283 if (!FLAGS_gen_files) |
| 283 return; | 284 return; |
| 284 // Write the processed frame to file for visual inspection. | 285 // Write the processed frame to file for visual inspection. |
| 285 std::ostringstream filename; | 286 std::ostringstream filename; |
| 286 filename << webrtc::test::OutputPath() << "Resampler_from_" << source.width() | 287 filename << webrtc::test::OutputPath() << "Resampler_from_" << source.width() |
| 287 << "x" << source.height() << "_to_" << processed.width() << "x" | 288 << "x" << source.height() << "_to_" << processed.width() << "x" |
| 288 << processed.height() << "_30Hz_P420.yuv"; | 289 << processed.height() << "_30Hz_P420.yuv"; |
| 289 std::cout << "Watch " << filename.str() << " and verify that it is okay." | 290 std::cout << "Watch " << filename.str() << " and verify that it is okay." |
| 290 << std::endl; | 291 << std::endl; |
| 291 FILE* stand_alone_file = fopen(filename.str().c_str(), "wb"); | 292 FILE* stand_alone_file = fopen(filename.str().c_str(), "wb"); |
| 292 if (PrintVideoFrame(processed, stand_alone_file) < 0) | 293 if (PrintVideoFrame(processed, stand_alone_file) < 0) |
| 293 std::cerr << "Failed to write: " << filename.str() << std::endl; | 294 std::cerr << "Failed to write: " << filename.str() << std::endl; |
| 294 if (stand_alone_file) | 295 if (stand_alone_file) |
| 295 fclose(stand_alone_file); | 296 fclose(stand_alone_file); |
| 296 } | 297 } |
| 297 | 298 |
| 298 } // namespace webrtc | 299 } // namespace webrtc |
| OLD | NEW |