OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include <string.h> | |
12 | |
13 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | |
14 #include "webrtc/modules/video_processing/include/video_processing.h" | |
15 #include "webrtc/modules/video_processing/test/video_processing_unittest.h" | |
16 #include "webrtc/modules/video_processing/video_denoiser.h" | |
17 #include "webrtc/test/testsupport/gtest_disable.h" | |
18 | |
19 namespace webrtc { | |
20 | |
21 static int CompareImage(const VideoFrame *const img1, | |
stefan-webrtc
2015/12/10 08:53:25
bool
Or maybe we can break out EqualFrames() in i
jackychen
2015/12/11 19:57:56
I broke out EqualFrames() and put it in video_fram
stefan-webrtc
2015/12/15 21:00:30
Maybe you could make it a method of the VideoFrame
jackychen
2015/12/16 22:41:56
Done.
| |
22 const VideoFrame *const img2) { | |
23 int match = 1; | |
stefan-webrtc
2015/12/10 08:53:25
bool
jackychen
2015/12/11 19:57:56
Done.
| |
24 match &= (img1->width() == img2->width()); | |
25 match &= (img1->height() == img2->height()); | |
26 // Y plane should match. | |
27 for (int i = 0; i < img1->height(); ++i) | |
28 match &= (memcmp(img1->buffer(kYPlane) + i * img1->stride(kYPlane), | |
29 img2->buffer(kYPlane) + i * img2->stride(kYPlane), | |
30 img1->width()) == 0); | |
31 // U plane should match. | |
32 for (int i = 0; i < img1->height() >> 1; ++i) | |
33 match &= (memcmp(img1->buffer(kUPlane) + i * img1->stride(kUPlane), | |
34 img2->buffer(kUPlane) + i * img2->stride(kUPlane), | |
35 img1->width() >> 1) == 0); | |
36 // V plane should match. | |
37 for (int i = 0; i < img1->height() >> 1; ++i) | |
38 match &= (memcmp(img1->buffer(kVPlane) + i * img1->stride(kVPlane), | |
39 img2->buffer(kVPlane) + i * img2->stride(kVPlane), | |
40 img1->width() >> 1) == 0); | |
41 return match; | |
42 } | |
43 | |
44 TEST_F(VideoProcessingModuleTest, DISABLED_ON_IOS(Denoiser)) { | |
stefan-webrtc
2015/12/10 08:53:25
Comment on why we disable on iOS
jackychen
2015/12/11 19:57:56
I don't know why, but in modules.gyp line 107, I s
stefan-webrtc
2015/12/15 21:00:30
Hm, ok. Could you try to do a tryjob without it? I
jackychen
2015/12/16 22:41:56
Seems OK to run on iOS. Done.
| |
45 rtc::scoped_ptr<VideoDenoiser> denoiser_c; | |
46 rtc::scoped_ptr<VideoDenoiser> denoiser_sse_neon; | |
47 VideoFrame denoised_frame_c; | |
48 VideoFrame denoised_frame_sse_neon; | |
49 | |
50 // Create pure C denoiser. | |
51 denoiser_c.reset(new VideoDenoiser(false)); | |
stefan-webrtc
2015/12/10 08:53:25
You may be able to just create these denoisers on
jackychen
2015/12/11 19:57:56
Done.
| |
52 // Create SSE or NEON denoiser. | |
53 denoiser_sse_neon.reset(new VideoDenoiser(true)); | |
54 | |
55 rtc::scoped_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]); | |
56 while (fread(video_buffer.get(), 1, frame_length_, source_file_) == | |
57 frame_length_) { | |
58 // Using ConvertToI420 to add stride to the image. | |
59 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, | |
60 0, kVideoRotation_0, &video_frame_)); | |
61 | |
62 denoiser_c->DenoiseFrame(video_frame_, &denoised_frame_c); | |
63 denoiser_sse_neon->DenoiseFrame(video_frame_, &denoised_frame_sse_neon); | |
64 | |
65 // Denoising results should be the same for C and SSE/NEON denoiser. | |
66 ASSERT_EQ(1, CompareImage(&denoised_frame_c, &denoised_frame_sse_neon)); | |
67 } | |
68 ASSERT_NE(0, feof(source_file_)) << "Error reading source file"; | |
69 } | |
70 | |
71 } // namespace webrtc | |
OLD | NEW |