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

Unified Diff: content/browser/media/openh264_unittests.cc

Issue 1446453004: Adding third_party/openh264 build files for encoding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase with master Created 5 years, 1 month 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: content/browser/media/openh264_unittests.cc
diff --git a/content/browser/media/openh264_unittests.cc b/content/browser/media/openh264_unittests.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9fb43031e1b16f62709c96d2bd05d32f8253d451
--- /dev/null
+++ b/content/browser/media/openh264_unittests.cc
@@ -0,0 +1,55 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+#include "third_party/openh264/testing/h264_codec_tester.h"
+#include "third_party/openh264/testing/h264_decoder_impl.h"
+#include "third_party/openh264/testing/h264_encoder_impl.h"
+#include "third_party/openh264/testing/i420_utils.h"
+#include "third_party/webrtc/common_video/libyuv/include/webrtc_libyuv.h"
+
+namespace openh264 {
+
+static const unsigned short kVideoWidth = 320;
+static const unsigned short kVideoHeight = 240;
+
+static const size_t kNumSampleFrames = 10;
+
+class OpenH264Tests : public testing::Test {
+ protected:
+ OpenH264Tests() {
+ int shade = 0;
torbjorng 2015/11/18 14:41:09 Note that shade here will go from 0 to 225, since
hbos_chromium 2015/11/18 15:55:04 Done.
+ for (size_t i = 0; i < kNumSampleFrames; ++i) {
+ CreateRgbFrame(&sample_frames_[i], kVideoWidth, kVideoHeight,
+ shade, shade, shade);
+ shade += 255 / kNumSampleFrames;
+ }
+ }
+ ~OpenH264Tests() override {}
+
+ VideoFrame sample_frames_[kNumSampleFrames];
+ H264CodecTester codec_tester_;
+};
+
+TEST_F(OpenH264Tests, EncodeDecodeCompareFrames) {
+ const int kNumFrames = 30;
+
+ ASSERT_TRUE(codec_tester_.Init(kVideoWidth, kVideoHeight));
+ double avg_ssim = 0.0;
+ for (size_t i = 0; i < kNumFrames; ++i) {
+ VideoFrame* original_frame = &sample_frames_[i % kNumSampleFrames];
+ ASSERT_TRUE(codec_tester_.Encode(*original_frame));
+ VideoFrame* decoded_frame = codec_tester_.Decode();
+ ASSERT_TRUE(decoded_frame != nullptr);
+
+ avg_ssim += webrtc::I420SSIM(original_frame, decoded_frame);
+ }
+ avg_ssim /= kNumFrames;
+
+ ASSERT_GE(avg_ssim, 0.9) << "Expected decoded frames to be more similar (on "
+ << "average) to the original frames (SSIM too low)";
+}
+
+} // namespace openh264

Powered by Google App Engine
This is Rietveld 408576698