Chromium Code Reviews| OLD | NEW |
|---|---|
| (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" | |
|
Dirk Pranke
2015/11/19 02:46:56
does this actually have anything to do w/ content?
phoglund_chromium
2015/11/19 12:39:24
Most of the WebRTC code is in content/ and execute
hbos_chromium
2015/11/19 13:00:43
content_unittests has several WebRTC unittests (so
| |
| 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 double shade = 0.0; | |
| 24 for (size_t i = 0; i < kNumSampleFrames; ++i) { | |
| 25 CreateRgbFrame(&sample_frames_[i], kVideoWidth, kVideoHeight, | |
| 26 shade, shade, shade); | |
| 27 if (kNumSampleFrames > 1) | |
| 28 shade += 255.0 / (kNumSampleFrames - 1); | |
| 29 } | |
| 30 } | |
| 31 ~OpenH264Tests() override {} | |
| 32 | |
| 33 VideoFrame sample_frames_[kNumSampleFrames]; | |
| 34 H264CodecTester codec_tester_; | |
| 35 }; | |
| 36 | |
| 37 TEST_F(OpenH264Tests, EncodeDecodeCompareFrames) { | |
| 38 const int kNumFrames = 30; | |
| 39 | |
| 40 ASSERT_TRUE(codec_tester_.Init(kVideoWidth, kVideoHeight)); | |
| 41 double avg_ssim = 0.0; | |
| 42 for (size_t i = 0; i < kNumFrames; ++i) { | |
| 43 VideoFrame* original_frame = &sample_frames_[i % kNumSampleFrames]; | |
| 44 ASSERT_TRUE(codec_tester_.Encode(*original_frame)); | |
| 45 VideoFrame* decoded_frame = codec_tester_.Decode(); | |
| 46 ASSERT_TRUE(decoded_frame != nullptr); | |
| 47 | |
| 48 avg_ssim += webrtc::I420SSIM(original_frame, decoded_frame); | |
| 49 } | |
| 50 avg_ssim /= kNumFrames; | |
| 51 | |
| 52 ASSERT_GE(avg_ssim, 0.9) << "Expected decoded frames to be more similar (on " | |
| 53 << "average) to the original frames (SSIM too low)"; | |
| 54 } | |
| 55 | |
| 56 } // namespace openh264 | |
| OLD | NEW |