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

Side by Side 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 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;
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.
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 }
54
55 } // namespace openh264
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698