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

Side by Side Diff: content/browser/media/openh264_unittests.cc

Issue 1403893007: Adding third_party/openh264/src, build files and unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Misc 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "testing/gtest/include/gtest/gtest.h"
6
7 #include "third_party/openh264/testing/h264_codec_tester.h"
8 #include "third_party/openh264/testing/h264_decoder_impl.h"
9 #include "third_party/openh264/testing/h264_encoder_impl.h"
10 #include "third_party/openh264/testing/i420_utils.h"
11 #include "third_party/webrtc/common_video/libyuv/include/webrtc_libyuv.h"
12
13 namespace openh264 {
14
15 static const unsigned short kVideoWidth = 320;
16 static const unsigned short kVideoHeight = 240;
17
18 static const size_t kNumSampleFrames = 10;
19
20 class OpenH264Tests : public testing::Test {
21 protected:
22 OpenH264Tests() {
23 int shade = 0;
24 for (size_t i = 0; i < kNumSampleFrames; ++i) {
25 CreateRgbFrame(&sample_frames_[i], kVideoWidth, kVideoHeight,
26 shade, shade, shade);
27 shade += 255 / kNumSampleFrames;
28 }
29 }
30 ~OpenH264Tests() override {}
31
32 VideoFrame sample_frames_[kNumSampleFrames];
33 H264CodecTester codec_tester_;
34 };
35
36 TEST_F(OpenH264Tests, EncodeDecodeCompareFrames) {
37 const int kNumFrames = 30;
38
39 ASSERT_TRUE(codec_tester_.Init(kVideoWidth, kVideoHeight));
40 double avg_ssim = 0.0;
41 for (size_t i = 0; i < kNumFrames; ++i) {
42 VideoFrame* original_frame = &sample_frames_[i % kNumSampleFrames];
43 ASSERT_TRUE(codec_tester_.Encode(*original_frame));
44 VideoFrame* decoded_frame = codec_tester_.Decode();
45 ASSERT_TRUE(decoded_frame != nullptr);
46
47 avg_ssim += webrtc::I420SSIM(original_frame, decoded_frame);
48 }
49 avg_ssim /= kNumFrames;
50
51 ASSERT_GE(avg_ssim, 0.9) << "Expected decoded frames to be more similar (on "
52 << "average) to the original frames (SSIM too low)";
53 }
hbos_chromium 2015/10/29 14:28:26 Note: I want to have another test that measures th
54
55 #if defined(OS_CHROMEOS)
hbos_chromium 2015/10/29 14:28:26 Note: This #if is to make only a small number of t
56 TEST_F(OpenH264Tests, BuildingWithOpenH264ShouldFail) {
57 FAIL() << "Building with 'build_openh264==1' / defined(BUILD_OPENH264) makes "
58 "this test fail. This is to ensure you do not accidentally land a "
59 "CL that changes the default behavior. The default should be not "
60 "to build it in Chromium due to licensing issues! However, you may "
61 "have to temporarily change the default behavior in order for the "
62 "trybots to run the OpenH264Tests test code.";
63 }
64 #endif
65
66 } // namespace openh264
OLDNEW
« no previous file with comments | « content/browser/DEPS ('k') | content/content_tests.gypi » ('j') | content/content_tests.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698