OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/codec/video_decoder_vpx.h" | 5 #include "remoting/codec/video_decoder_vpx.h" |
6 | 6 |
7 #include "media/base/video_frame.h" | 7 #include "media/base/video_frame.h" |
8 #include "remoting/codec/codec_test.h" | 8 #include "remoting/codec/codec_test.h" |
9 #include "remoting/codec/video_encoder_vpx.h" | 9 #include "remoting/codec/video_encoder_vpx.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 11 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
12 | 12 |
13 namespace remoting { | 13 namespace remoting { |
14 | 14 |
| 15 namespace { |
| 16 |
15 class VideoDecoderVpxTest : public testing::Test { | 17 class VideoDecoderVpxTest : public testing::Test { |
16 protected: | 18 protected: |
17 scoped_ptr<VideoEncoderVpx> encoder_; | 19 scoped_ptr<VideoEncoderVpx> encoder_; |
18 scoped_ptr<VideoDecoderVpx> decoder_; | 20 scoped_ptr<VideoDecoderVpx> decoder_; |
19 | 21 |
20 VideoDecoderVpxTest() : encoder_(VideoEncoderVpx::CreateForVP8()), | 22 VideoDecoderVpxTest() : encoder_(VideoEncoderVpx::CreateForVP8()), |
21 decoder_(VideoDecoderVpx::CreateForVP8()) { | 23 decoder_(VideoDecoderVpx::CreateForVP8()) { |
22 } | 24 } |
23 | 25 |
24 void TestGradient(int screen_width, int screen_height, | 26 void TestGradient(int screen_width, int screen_height, |
25 int view_width, int view_height, | 27 int view_width, int view_height, |
26 double max_error_limit, double mean_error_limit) { | 28 double max_error_limit, double mean_error_limit) { |
27 TestVideoEncoderDecoderGradient( | 29 TestVideoEncoderDecoderGradient( |
28 encoder_.get(), decoder_.get(), | 30 encoder_.get(), decoder_.get(), |
29 webrtc::DesktopSize(screen_width, screen_height), | 31 webrtc::DesktopSize(screen_width, screen_height), |
30 webrtc::DesktopSize(view_width, view_height), | 32 webrtc::DesktopSize(view_width, view_height), |
31 max_error_limit, mean_error_limit); | 33 max_error_limit, mean_error_limit); |
32 } | 34 } |
33 }; | 35 }; |
34 | 36 |
35 TEST_F(VideoDecoderVpxTest, VideoEncodeAndDecode) { | 37 class VideoDecoderVp8Test : public VideoDecoderVpxTest { |
| 38 protected: |
| 39 VideoDecoderVp8Test() { |
| 40 encoder_ = VideoEncoderVpx::CreateForVP8(); |
| 41 decoder_ = VideoDecoderVpx::CreateForVP8(); |
| 42 } |
| 43 }; |
| 44 |
| 45 class VideoDecoderVp9Test : public VideoDecoderVpxTest { |
| 46 protected: |
| 47 VideoDecoderVp9Test() { |
| 48 encoder_ = VideoEncoderVpx::CreateForVP9(); |
| 49 decoder_ = VideoDecoderVpx::CreateForVP9(); |
| 50 } |
| 51 }; |
| 52 |
| 53 } // namespace |
| 54 |
| 55 // |
| 56 // Test the VP8 codec. |
| 57 // |
| 58 |
| 59 TEST_F(VideoDecoderVp8Test, VideoEncodeAndDecode) { |
36 TestVideoEncoderDecoder(encoder_.get(), decoder_.get(), false); | 60 TestVideoEncoderDecoder(encoder_.get(), decoder_.get(), false); |
37 } | 61 } |
38 | 62 |
39 // Check that encoding and decoding a particular frame doesn't change the | 63 // Check that encoding and decoding a particular frame doesn't change the |
40 // frame too much. The frame used is a gradient, which does not contain sharp | 64 // frame too much. The frame used is a gradient, which does not contain sharp |
41 // transitions, so encoding lossiness should not be too high. | 65 // transitions, so encoding lossiness should not be too high. |
42 TEST_F(VideoDecoderVpxTest, Gradient) { | 66 TEST_F(VideoDecoderVp8Test, Gradient) { |
43 TestGradient(320, 240, 320, 240, 0.04, 0.02); | 67 TestGradient(320, 240, 320, 240, 0.04, 0.02); |
44 } | 68 } |
45 | 69 |
46 TEST_F(VideoDecoderVpxTest, GradientScaleUpEvenToEven) { | 70 TEST_F(VideoDecoderVp8Test, GradientScaleUpEvenToEven) { |
47 TestGradient(320, 240, 640, 480, 0.04, 0.02); | 71 TestGradient(320, 240, 640, 480, 0.04, 0.02); |
48 } | 72 } |
49 | 73 |
50 TEST_F(VideoDecoderVpxTest, GradientScaleUpEvenToOdd) { | 74 TEST_F(VideoDecoderVp8Test, GradientScaleUpEvenToOdd) { |
51 TestGradient(320, 240, 641, 481, 0.04, 0.02); | 75 TestGradient(320, 240, 641, 481, 0.04, 0.02); |
52 } | 76 } |
53 | 77 |
54 TEST_F(VideoDecoderVpxTest, GradientScaleUpOddToEven) { | 78 TEST_F(VideoDecoderVp8Test, GradientScaleUpOddToEven) { |
55 TestGradient(321, 241, 640, 480, 0.04, 0.02); | 79 TestGradient(321, 241, 640, 480, 0.04, 0.02); |
56 } | 80 } |
57 | 81 |
58 TEST_F(VideoDecoderVpxTest, GradientScaleUpOddToOdd) { | 82 TEST_F(VideoDecoderVp8Test, GradientScaleUpOddToOdd) { |
59 TestGradient(321, 241, 641, 481, 0.04, 0.02); | 83 TestGradient(321, 241, 641, 481, 0.04, 0.02); |
60 } | 84 } |
61 | 85 |
62 TEST_F(VideoDecoderVpxTest, GradientScaleDownEvenToEven) { | 86 TEST_F(VideoDecoderVp8Test, GradientScaleDownEvenToEven) { |
63 TestGradient(320, 240, 160, 120, 0.04, 0.02); | 87 TestGradient(320, 240, 160, 120, 0.04, 0.02); |
64 } | 88 } |
65 | 89 |
66 TEST_F(VideoDecoderVpxTest, GradientScaleDownEvenToOdd) { | 90 TEST_F(VideoDecoderVp8Test, GradientScaleDownEvenToOdd) { |
67 // The maximum error is non-deterministic. The mean error is not too high, | 91 // The maximum error is non-deterministic. The mean error is not too high, |
68 // which suggests that the problem is restricted to a small area of the output | 92 // which suggests that the problem is restricted to a small area of the output |
69 // image. See crbug.com/139437 and crbug.com/139633. | 93 // image. See crbug.com/139437 and crbug.com/139633. |
70 TestGradient(320, 240, 161, 121, 1.0, 0.02); | 94 TestGradient(320, 240, 161, 121, 1.0, 0.02); |
71 } | 95 } |
72 | 96 |
73 TEST_F(VideoDecoderVpxTest, GradientScaleDownOddToEven) { | 97 TEST_F(VideoDecoderVp8Test, GradientScaleDownOddToEven) { |
74 TestGradient(321, 241, 160, 120, 0.04, 0.02); | 98 TestGradient(321, 241, 160, 120, 0.04, 0.02); |
75 } | 99 } |
76 | 100 |
77 TEST_F(VideoDecoderVpxTest, GradientScaleDownOddToOdd) { | 101 TEST_F(VideoDecoderVp8Test, GradientScaleDownOddToOdd) { |
78 TestGradient(321, 241, 161, 121, 0.04, 0.02); | 102 TestGradient(321, 241, 161, 121, 0.04, 0.02); |
79 } | 103 } |
80 | 104 |
| 105 // |
| 106 // Test the VP9 codec. |
| 107 // |
| 108 |
| 109 TEST_F(VideoDecoderVp9Test, VideoEncodeAndDecode) { |
| 110 TestVideoEncoderDecoder(encoder_.get(), decoder_.get(), false); |
| 111 } |
| 112 |
| 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); |
| 118 } |
| 119 |
| 120 TEST_F(VideoDecoderVp9Test, GradientScaleUpEvenToEven) { |
| 121 TestGradient(320, 240, 640, 480, 0.04, 0.02); |
| 122 } |
| 123 |
| 124 TEST_F(VideoDecoderVp9Test, GradientScaleUpEvenToOdd) { |
| 125 TestGradient(320, 240, 641, 481, 0.04, 0.02); |
| 126 } |
| 127 |
| 128 TEST_F(VideoDecoderVp9Test, GradientScaleUpOddToEven) { |
| 129 TestGradient(321, 241, 640, 480, 0.04, 0.02); |
| 130 } |
| 131 |
| 132 TEST_F(VideoDecoderVp9Test, GradientScaleUpOddToOdd) { |
| 133 TestGradient(321, 241, 641, 481, 0.04, 0.02); |
| 134 } |
| 135 |
| 136 TEST_F(VideoDecoderVp9Test, GradientScaleDownEvenToEven) { |
| 137 TestGradient(320, 240, 160, 120, 0.04, 0.02); |
| 138 } |
| 139 |
| 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); |
| 145 } |
| 146 |
| 147 TEST_F(VideoDecoderVp9Test, GradientScaleDownOddToEven) { |
| 148 TestGradient(321, 241, 160, 120, 0.04, 0.02); |
| 149 } |
| 150 |
| 151 TEST_F(VideoDecoderVp9Test, GradientScaleDownOddToOdd) { |
| 152 TestGradient(321, 241, 161, 121, 0.04, 0.02); |
| 153 } |
| 154 |
81 } // namespace remoting | 155 } // namespace remoting |
OLD | NEW |