| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 | |
| 17 class VideoDecoderVpxTest : public testing::Test { | 15 class VideoDecoderVpxTest : public testing::Test { |
| 18 protected: | 16 protected: |
| 19 scoped_ptr<VideoEncoderVpx> encoder_; | 17 scoped_ptr<VideoEncoderVpx> encoder_; |
| 20 scoped_ptr<VideoDecoderVpx> decoder_; | 18 scoped_ptr<VideoDecoderVpx> decoder_; |
| 21 | 19 |
| 22 VideoDecoderVpxTest() : encoder_(VideoEncoderVpx::CreateForVP8()), | 20 VideoDecoderVpxTest() : encoder_(VideoEncoderVpx::CreateForVP8()), |
| 23 decoder_(VideoDecoderVpx::CreateForVP8()) { | 21 decoder_(VideoDecoderVpx::CreateForVP8()) { |
| 24 } | 22 } |
| 25 | 23 |
| 26 void TestGradient(int screen_width, int screen_height, | 24 void TestGradient(int screen_width, int screen_height, |
| 27 int view_width, int view_height, | 25 int view_width, int view_height, |
| 28 double max_error_limit, double mean_error_limit) { | 26 double max_error_limit, double mean_error_limit) { |
| 29 TestVideoEncoderDecoderGradient( | 27 TestVideoEncoderDecoderGradient( |
| 30 encoder_.get(), decoder_.get(), | 28 encoder_.get(), decoder_.get(), |
| 31 webrtc::DesktopSize(screen_width, screen_height), | 29 webrtc::DesktopSize(screen_width, screen_height), |
| 32 webrtc::DesktopSize(view_width, view_height), | 30 webrtc::DesktopSize(view_width, view_height), |
| 33 max_error_limit, mean_error_limit); | 31 max_error_limit, mean_error_limit); |
| 34 } | 32 } |
| 35 }; | 33 }; |
| 36 | 34 |
| 37 class VideoDecoderVp8Test : public VideoDecoderVpxTest { | 35 TEST_F(VideoDecoderVpxTest, VideoEncodeAndDecode) { |
| 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) { | |
| 60 TestVideoEncoderDecoder(encoder_.get(), decoder_.get(), false); | 36 TestVideoEncoderDecoder(encoder_.get(), decoder_.get(), false); |
| 61 } | 37 } |
| 62 | 38 |
| 63 // Check that encoding and decoding a particular frame doesn't change the | 39 // 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 | 40 // frame too much. The frame used is a gradient, which does not contain sharp |
| 65 // transitions, so encoding lossiness should not be too high. | 41 // transitions, so encoding lossiness should not be too high. |
| 66 TEST_F(VideoDecoderVp8Test, Gradient) { | 42 TEST_F(VideoDecoderVpxTest, Gradient) { |
| 67 TestGradient(320, 240, 320, 240, 0.04, 0.02); | 43 TestGradient(320, 240, 320, 240, 0.04, 0.02); |
| 68 } | 44 } |
| 69 | 45 |
| 70 TEST_F(VideoDecoderVp8Test, GradientScaleUpEvenToEven) { | 46 TEST_F(VideoDecoderVpxTest, GradientScaleUpEvenToEven) { |
| 71 TestGradient(320, 240, 640, 480, 0.04, 0.02); | 47 TestGradient(320, 240, 640, 480, 0.04, 0.02); |
| 72 } | 48 } |
| 73 | 49 |
| 74 TEST_F(VideoDecoderVp8Test, GradientScaleUpEvenToOdd) { | 50 TEST_F(VideoDecoderVpxTest, GradientScaleUpEvenToOdd) { |
| 75 TestGradient(320, 240, 641, 481, 0.04, 0.02); | 51 TestGradient(320, 240, 641, 481, 0.04, 0.02); |
| 76 } | 52 } |
| 77 | 53 |
| 78 TEST_F(VideoDecoderVp8Test, GradientScaleUpOddToEven) { | 54 TEST_F(VideoDecoderVpxTest, GradientScaleUpOddToEven) { |
| 79 TestGradient(321, 241, 640, 480, 0.04, 0.02); | 55 TestGradient(321, 241, 640, 480, 0.04, 0.02); |
| 80 } | 56 } |
| 81 | 57 |
| 82 TEST_F(VideoDecoderVp8Test, GradientScaleUpOddToOdd) { | 58 TEST_F(VideoDecoderVpxTest, GradientScaleUpOddToOdd) { |
| 83 TestGradient(321, 241, 641, 481, 0.04, 0.02); | 59 TestGradient(321, 241, 641, 481, 0.04, 0.02); |
| 84 } | 60 } |
| 85 | 61 |
| 86 TEST_F(VideoDecoderVp8Test, GradientScaleDownEvenToEven) { | 62 TEST_F(VideoDecoderVpxTest, GradientScaleDownEvenToEven) { |
| 87 TestGradient(320, 240, 160, 120, 0.04, 0.02); | 63 TestGradient(320, 240, 160, 120, 0.04, 0.02); |
| 88 } | 64 } |
| 89 | 65 |
| 90 TEST_F(VideoDecoderVp8Test, GradientScaleDownEvenToOdd) { | 66 TEST_F(VideoDecoderVpxTest, GradientScaleDownEvenToOdd) { |
| 91 // The maximum error is non-deterministic. The mean error is not too high, | 67 // 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 | 68 // which suggests that the problem is restricted to a small area of the output |
| 93 // image. See crbug.com/139437 and crbug.com/139633. | 69 // image. See crbug.com/139437 and crbug.com/139633. |
| 94 TestGradient(320, 240, 161, 121, 1.0, 0.02); | 70 TestGradient(320, 240, 161, 121, 1.0, 0.02); |
| 95 } | 71 } |
| 96 | 72 |
| 97 TEST_F(VideoDecoderVp8Test, GradientScaleDownOddToEven) { | 73 TEST_F(VideoDecoderVpxTest, GradientScaleDownOddToEven) { |
| 98 TestGradient(321, 241, 160, 120, 0.04, 0.02); | 74 TestGradient(321, 241, 160, 120, 0.04, 0.02); |
| 99 } | 75 } |
| 100 | 76 |
| 101 TEST_F(VideoDecoderVp8Test, GradientScaleDownOddToOdd) { | 77 TEST_F(VideoDecoderVpxTest, GradientScaleDownOddToOdd) { |
| 102 TestGradient(321, 241, 161, 121, 0.04, 0.02); | |
| 103 } | |
| 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); | 78 TestGradient(321, 241, 161, 121, 0.04, 0.02); |
| 153 } | 79 } |
| 154 | 80 |
| 155 } // namespace remoting | 81 } // namespace remoting |
| OLD | NEW |