 Chromium Code Reviews
 Chromium Code Reviews Issue 1679323002:
  Cleanup of webrtc::VideoFrame.  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master
    
  
    Issue 1679323002:
  Cleanup of webrtc::VideoFrame.  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master| OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 <string.h> | 11 #include <string.h> | 
| 12 | 12 | 
| 13 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 13 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 
| 14 #include "webrtc/modules/video_processing/include/video_processing.h" | 14 #include "webrtc/modules/video_processing/include/video_processing.h" | 
| 15 #include "webrtc/modules/video_processing/test/video_processing_unittest.h" | 15 #include "webrtc/modules/video_processing/test/video_processing_unittest.h" | 
| 16 #include "webrtc/modules/video_processing/video_denoiser.h" | 16 #include "webrtc/modules/video_processing/video_denoiser.h" | 
| 17 | 17 | 
| 18 namespace { | |
| 19 // Duplicated in i420_video_frame_unittest.cc | |
| 
pbos-webrtc
2016/02/09 15:18:14
Put this somewhere common, even if it's only test
 
nisse-webrtc
2016/02/09 15:31:33
I see no obvious place. Any suggestion for file (a
 
pbos-webrtc
2016/02/09 15:36:10
I'll come over and sync with you.
 | |
| 20 bool EqualPlane(const uint8_t* data1, | |
| 21 const uint8_t* data2, | |
| 22 int stride, | |
| 23 int width, | |
| 24 int height) { | |
| 25 for (int y = 0; y < height; ++y) { | |
| 26 if (memcmp(data1, data2, width) != 0) | |
| 27 return false; | |
| 28 data1 += stride; | |
| 29 data2 += stride; | |
| 30 } | |
| 31 return true; | |
| 32 } | |
| 33 bool FramesEqual(const webrtc::VideoFrame& f1, const webrtc::VideoFrame& f2) { | |
| 34 if (f1.width() != f2.width() || f1.height() != f2.height() || | |
| 35 f1.stride(webrtc::kYPlane) != f2.stride(webrtc::kYPlane) || | |
| 36 f1.stride(webrtc::kUPlane) != f2.stride(webrtc::kUPlane) || | |
| 37 f1.stride(webrtc::kVPlane) != f2.stride(webrtc::kVPlane) || | |
| 38 f1.timestamp() != f2.timestamp() || | |
| 39 f1.ntp_time_ms() != f2.ntp_time_ms() || | |
| 40 f1.render_time_ms() != f2.render_time_ms()) { | |
| 41 return false; | |
| 42 } | |
| 43 const int half_width = (f1.width() + 1) / 2; | |
| 44 const int half_height = (f1.height() + 1) / 2; | |
| 45 return EqualPlane(f1.buffer(webrtc::kYPlane), f2.buffer(webrtc::kYPlane), | |
| 46 f1.stride(webrtc::kYPlane), f1.width(), f1.height()) && | |
| 47 EqualPlane(f1.buffer(webrtc::kUPlane), f2.buffer(webrtc::kUPlane), | |
| 48 f1.stride(webrtc::kUPlane), half_width, half_height) && | |
| 49 EqualPlane(f1.buffer(webrtc::kVPlane), f2.buffer(webrtc::kVPlane), | |
| 50 f1.stride(webrtc::kVPlane), half_width, half_height); | |
| 51 } | |
| 52 | |
| 53 } | |
| 54 | |
| 18 namespace webrtc { | 55 namespace webrtc { | 
| 19 | 56 | 
| 20 TEST_F(VideoProcessingTest, CopyMem) { | 57 TEST_F(VideoProcessingTest, CopyMem) { | 
| 21 rtc::scoped_ptr<DenoiserFilter> df_c(DenoiserFilter::Create(false)); | 58 rtc::scoped_ptr<DenoiserFilter> df_c(DenoiserFilter::Create(false)); | 
| 22 rtc::scoped_ptr<DenoiserFilter> df_sse_neon(DenoiserFilter::Create(true)); | 59 rtc::scoped_ptr<DenoiserFilter> df_sse_neon(DenoiserFilter::Create(true)); | 
| 23 uint8_t src[16 * 16], dst[16 * 16]; | 60 uint8_t src[16 * 16], dst[16 * 16]; | 
| 24 for (int i = 0; i < 16; ++i) { | 61 for (int i = 0; i < 16; ++i) { | 
| 25 for (int j = 0; j < 16; ++j) { | 62 for (int j = 0; j < 16; ++j) { | 
| 26 src[i * 16 + j] = i * 16 + j; | 63 src[i * 16 + j] = i * 16 + j; | 
| 27 } | 64 } | 
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 while (fread(video_buffer.get(), 1, frame_length_, source_file_) == | 178 while (fread(video_buffer.get(), 1, frame_length_, source_file_) == | 
| 142 frame_length_) { | 179 frame_length_) { | 
| 143 // Using ConvertToI420 to add stride to the image. | 180 // Using ConvertToI420 to add stride to the image. | 
| 144 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, | 181 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, | 
| 145 0, kVideoRotation_0, &video_frame_)); | 182 0, kVideoRotation_0, &video_frame_)); | 
| 146 | 183 | 
| 147 denoiser_c.DenoiseFrame(video_frame_, &denoised_frame_c); | 184 denoiser_c.DenoiseFrame(video_frame_, &denoised_frame_c); | 
| 148 denoiser_sse_neon.DenoiseFrame(video_frame_, &denoised_frame_sse_neon); | 185 denoiser_sse_neon.DenoiseFrame(video_frame_, &denoised_frame_sse_neon); | 
| 149 | 186 | 
| 150 // Denoising results should be the same for C and SSE/NEON denoiser. | 187 // Denoising results should be the same for C and SSE/NEON denoiser. | 
| 151 ASSERT_EQ(true, denoised_frame_c.EqualsFrame(denoised_frame_sse_neon)); | 188 ASSERT_EQ(true, FramesEqual(denoised_frame_c, denoised_frame_sse_neon)); | 
| 152 } | 189 } | 
| 153 ASSERT_NE(0, feof(source_file_)) << "Error reading source file"; | 190 ASSERT_NE(0, feof(source_file_)) << "Error reading source file"; | 
| 154 } | 191 } | 
| 155 | 192 | 
| 156 } // namespace webrtc | 193 } // namespace webrtc | 
| OLD | NEW |