video_decoder_vpx_unittest.cc 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.
  4. #include "remoting/codec/video_decoder_vpx.h"
  5. #include "remoting/codec/codec_test.h"
  6. #include "remoting/codec/video_encoder_vpx.h"
  7. #include "testing/gtest/include/gtest/gtest.h"
  8. #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
  9. namespace remoting {
  10. namespace {
  11. class VideoDecoderVpxTest : public testing::Test {
  12. protected:
  13. std::unique_ptr<VideoEncoderVpx> encoder_;
  14. std::unique_ptr<VideoDecoderVpx> decoder_;
  15. VideoDecoderVpxTest() : encoder_(VideoEncoderVpx::CreateForVP8()),
  16. decoder_(VideoDecoderVpx::CreateForVP8()) {
  17. }
  18. void TestGradient(int screen_width, int screen_height,
  19. double max_error_limit, double mean_error_limit) {
  20. TestVideoEncoderDecoderGradient(
  21. encoder_.get(), decoder_.get(),
  22. webrtc::DesktopSize(screen_width, screen_height),
  23. max_error_limit, mean_error_limit);
  24. }
  25. };
  26. class VideoDecoderVp8Test : public VideoDecoderVpxTest {
  27. protected:
  28. VideoDecoderVp8Test() {
  29. encoder_ = VideoEncoderVpx::CreateForVP8();
  30. decoder_ = VideoDecoderVpx::CreateForVP8();
  31. }
  32. };
  33. class VideoDecoderVp9Test : public VideoDecoderVpxTest {
  34. protected:
  35. VideoDecoderVp9Test() {
  36. encoder_ = VideoEncoderVpx::CreateForVP9();
  37. decoder_ = VideoDecoderVpx::CreateForVP9();
  38. }
  39. };
  40. } // namespace
  41. //
  42. // Test the VP8 codec.
  43. //
  44. TEST_F(VideoDecoderVp8Test, VideoEncodeAndDecode) {
  45. TestVideoEncoderDecoder(encoder_.get(), decoder_.get(), false);
  46. }
  47. // Check that encoding and decoding a particular frame doesn't change the
  48. // frame too much. The frame used is a gradient, which does not contain sharp
  49. // transitions, so encoding lossiness should not be too high.
  50. TEST_F(VideoDecoderVp8Test, Gradient) {
  51. TestGradient(320, 240, 0.04, 0.02);
  52. }
  53. //
  54. // Test the VP9 codec.
  55. //
  56. TEST_F(VideoDecoderVp9Test, VideoEncodeAndDecode) {
  57. TestVideoEncoderDecoder(encoder_.get(), decoder_.get(), false);
  58. }
  59. // Check that encoding and decoding a particular frame doesn't change the
  60. // frame too much. The frame used is a gradient, which does not contain sharp
  61. // transitions, so encoding lossiness should not be too high.
  62. TEST_F(VideoDecoderVp9Test, Gradient) {
  63. TestGradient(320, 240, 0.04, 0.02);
  64. }
  65. } // namespace remoting