Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Unified Diff: webrtc/modules/video_processing/test/denoiser_test.cc

Issue 1492053003: Add unit test for stand-alone denoiser and fixed some bugs. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix asan test failure. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_processing/test/denoiser_test.cc
diff --git a/webrtc/modules/video_processing/test/denoiser_test.cc b/webrtc/modules/video_processing/test/denoiser_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..76bb86e23557364d81ed1115121badc7e5dd5930
--- /dev/null
+++ b/webrtc/modules/video_processing/test/denoiser_test.cc
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include <string.h>
+
+#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
+#include "webrtc/modules/video_processing/include/video_processing.h"
+#include "webrtc/modules/video_processing/test/video_processing_unittest.h"
+#include "webrtc/modules/video_processing/video_denoiser.h"
+#include "webrtc/test/testsupport/gtest_disable.h"
+
+namespace webrtc {
+
+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.
+ const VideoFrame *const img2) {
+ int match = 1;
stefan-webrtc 2015/12/10 08:53:25 bool
jackychen 2015/12/11 19:57:56 Done.
+ match &= (img1->width() == img2->width());
+ match &= (img1->height() == img2->height());
+ // Y plane should match.
+ for (int i = 0; i < img1->height(); ++i)
+ match &= (memcmp(img1->buffer(kYPlane) + i * img1->stride(kYPlane),
+ img2->buffer(kYPlane) + i * img2->stride(kYPlane),
+ img1->width()) == 0);
+ // U plane should match.
+ for (int i = 0; i < img1->height() >> 1; ++i)
+ match &= (memcmp(img1->buffer(kUPlane) + i * img1->stride(kUPlane),
+ img2->buffer(kUPlane) + i * img2->stride(kUPlane),
+ img1->width() >> 1) == 0);
+ // V plane should match.
+ for (int i = 0; i < img1->height() >> 1; ++i)
+ match &= (memcmp(img1->buffer(kVPlane) + i * img1->stride(kVPlane),
+ img2->buffer(kVPlane) + i * img2->stride(kVPlane),
+ img1->width() >> 1) == 0);
+ return match;
+}
+
+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.
+ rtc::scoped_ptr<VideoDenoiser> denoiser_c;
+ rtc::scoped_ptr<VideoDenoiser> denoiser_sse_neon;
+ VideoFrame denoised_frame_c;
+ VideoFrame denoised_frame_sse_neon;
+
+ // Create pure C denoiser.
+ 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.
+ // Create SSE or NEON denoiser.
+ denoiser_sse_neon.reset(new VideoDenoiser(true));
+
+ rtc::scoped_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]);
+ while (fread(video_buffer.get(), 1, frame_length_, source_file_) ==
+ frame_length_) {
+ // Using ConvertToI420 to add stride to the image.
+ EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_,
+ 0, kVideoRotation_0, &video_frame_));
+
+ denoiser_c->DenoiseFrame(video_frame_, &denoised_frame_c);
+ denoiser_sse_neon->DenoiseFrame(video_frame_, &denoised_frame_sse_neon);
+
+ // Denoising results should be the same for C and SSE/NEON denoiser.
+ ASSERT_EQ(1, CompareImage(&denoised_frame_c, &denoised_frame_sse_neon));
+ }
+ ASSERT_NE(0, feof(source_file_)) << "Error reading source file";
+}
+
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698