Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / remoting / codec / video_decoder_vpx_unittest.cc
blob63cf870ba409f2cba51028691230ee5f2664d250
1 // Copyright 2013 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.
5 #include "remoting/codec/video_decoder_vpx.h"
7 #include "media/base/video_frame.h"
8 #include "remoting/codec/codec_test.h"
9 #include "remoting/codec/video_encoder_vpx.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
13 namespace remoting {
15 namespace {
17 class VideoDecoderVpxTest : public testing::Test {
18 protected:
19 scoped_ptr<VideoEncoderVpx> encoder_;
20 scoped_ptr<VideoDecoderVpx> decoder_;
22 VideoDecoderVpxTest() : encoder_(VideoEncoderVpx::CreateForVP8()),
23 decoder_(VideoDecoderVpx::CreateForVP8()) {
26 void TestGradient(int screen_width, int screen_height,
27 int view_width, int view_height,
28 double max_error_limit, double mean_error_limit) {
29 TestVideoEncoderDecoderGradient(
30 encoder_.get(), decoder_.get(),
31 webrtc::DesktopSize(screen_width, screen_height),
32 webrtc::DesktopSize(view_width, view_height),
33 max_error_limit, mean_error_limit);
37 class VideoDecoderVp8Test : public VideoDecoderVpxTest {
38 protected:
39 VideoDecoderVp8Test() {
40 encoder_ = VideoEncoderVpx::CreateForVP8();
41 decoder_ = VideoDecoderVpx::CreateForVP8();
45 class VideoDecoderVp9Test : public VideoDecoderVpxTest {
46 protected:
47 VideoDecoderVp9Test() {
48 encoder_ = VideoEncoderVpx::CreateForVP9();
49 decoder_ = VideoDecoderVpx::CreateForVP9();
53 } // namespace
56 // Test the VP8 codec.
59 TEST_F(VideoDecoderVp8Test, VideoEncodeAndDecode) {
60 TestVideoEncoderDecoder(encoder_.get(), decoder_.get(), false);
63 // Check that encoding and decoding a particular frame doesn't change the
64 // frame too much. The frame used is a gradient, which does not contain sharp
65 // transitions, so encoding lossiness should not be too high.
66 TEST_F(VideoDecoderVp8Test, Gradient) {
67 TestGradient(320, 240, 320, 240, 0.04, 0.02);
70 TEST_F(VideoDecoderVp8Test, GradientScaleUpEvenToEven) {
71 TestGradient(320, 240, 640, 480, 0.04, 0.02);
74 TEST_F(VideoDecoderVp8Test, GradientScaleUpEvenToOdd) {
75 TestGradient(320, 240, 641, 481, 0.04, 0.02);
78 TEST_F(VideoDecoderVp8Test, GradientScaleUpOddToEven) {
79 TestGradient(321, 241, 640, 480, 0.04, 0.02);
82 TEST_F(VideoDecoderVp8Test, GradientScaleUpOddToOdd) {
83 TestGradient(321, 241, 641, 481, 0.04, 0.02);
86 TEST_F(VideoDecoderVp8Test, GradientScaleDownEvenToEven) {
87 TestGradient(320, 240, 160, 120, 0.04, 0.02);
90 TEST_F(VideoDecoderVp8Test, GradientScaleDownEvenToOdd) {
91 // The maximum error is non-deterministic. The mean error is not too high,
92 // which suggests that the problem is restricted to a small area of the output
93 // image. See crbug.com/139437 and crbug.com/139633.
94 TestGradient(320, 240, 161, 121, 1.0, 0.02);
97 TEST_F(VideoDecoderVp8Test, GradientScaleDownOddToEven) {
98 TestGradient(321, 241, 160, 120, 0.04, 0.02);
101 TEST_F(VideoDecoderVp8Test, GradientScaleDownOddToOdd) {
102 TestGradient(321, 241, 161, 121, 0.04, 0.02);
106 // Test the VP9 codec.
109 TEST_F(VideoDecoderVp9Test, VideoEncodeAndDecode) {
110 TestVideoEncoderDecoder(encoder_.get(), decoder_.get(), false);
113 // Check that encoding and decoding a particular frame doesn't change the
114 // frame too much. The frame used is a gradient, which does not contain sharp
115 // transitions, so encoding lossiness should not be too high.
116 TEST_F(VideoDecoderVp9Test, Gradient) {
117 TestGradient(320, 240, 320, 240, 0.04, 0.02);
120 TEST_F(VideoDecoderVp9Test, GradientScaleUpEvenToEven) {
121 TestGradient(320, 240, 640, 480, 0.04, 0.02);
124 TEST_F(VideoDecoderVp9Test, GradientScaleUpEvenToOdd) {
125 TestGradient(320, 240, 641, 481, 0.04, 0.02);
128 TEST_F(VideoDecoderVp9Test, GradientScaleUpOddToEven) {
129 TestGradient(321, 241, 640, 480, 0.04, 0.02);
132 TEST_F(VideoDecoderVp9Test, GradientScaleUpOddToOdd) {
133 TestGradient(321, 241, 641, 481, 0.04, 0.02);
136 TEST_F(VideoDecoderVp9Test, GradientScaleDownEvenToEven) {
137 TestGradient(320, 240, 160, 120, 0.04, 0.02);
140 TEST_F(VideoDecoderVp9Test, GradientScaleDownEvenToOdd) {
141 // The maximum error is non-deterministic. The mean error is not too high,
142 // which suggests that the problem is restricted to a small area of the output
143 // image. See crbug.com/139437 and crbug.com/139633.
144 TestGradient(320, 240, 161, 121, 1.0, 0.02);
147 TEST_F(VideoDecoderVp9Test, GradientScaleDownOddToEven) {
148 TestGradient(321, 241, 160, 120, 0.04, 0.02);
151 TEST_F(VideoDecoderVp9Test, GradientScaleDownOddToOdd) {
152 TestGradient(321, 241, 161, 121, 0.04, 0.02);
155 } // namespace remoting