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