OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #include "common_video/libyuv/include/webrtc_libyuv.h" |
| 12 #include "modules/video_coding/codecs/stereo/include/stereo_decoder_adapter.h" |
| 13 #include "modules/video_coding/codecs/stereo/include/stereo_encoder_adapter.h" |
| 14 #include "modules/video_coding/codecs/test/video_codec_test.h" |
| 15 #include "modules/video_coding/codecs/vp9/include/vp9.h" |
| 16 |
| 17 namespace webrtc { |
| 18 |
| 19 class TestStereoEncoderFactory : public VideoEncoderFactory { |
| 20 public: |
| 21 VideoEncoder* Create() override { return VP9Encoder::Create(); } |
| 22 void Destroy(VideoEncoder* encoder) override { delete encoder; } |
| 23 }; |
| 24 |
| 25 class TestStereoDecoderFactory : public VideoDecoderFactory { |
| 26 public: |
| 27 VideoDecoder* Create() override { return VP9Decoder::Create(); } |
| 28 void Destroy(VideoDecoder* encoder) override { delete encoder; } |
| 29 }; |
| 30 |
| 31 class TestStereoAdapter : public VideoCodecTest { |
| 32 protected: |
| 33 VideoEncoder* CreateEncoder() override { |
| 34 return new StereoEncoderAdapter(new TestStereoEncoderFactory()); |
| 35 } |
| 36 VideoDecoder* CreateDecoder() override { |
| 37 return new StereoDecoderAdapter(new TestStereoDecoderFactory()); |
| 38 } |
| 39 VideoCodec codec_settings() override { |
| 40 VideoCodec codec_settings; |
| 41 codec_settings.codecType = webrtc::kVideoCodecVP9; |
| 42 codec_settings.VP9()->numberOfTemporalLayers = 1; |
| 43 codec_settings.VP9()->numberOfSpatialLayers = 1; |
| 44 return codec_settings; |
| 45 } |
| 46 }; |
| 47 |
| 48 TEST_F(TestStereoAdapter, ConstructAndDestructEncoder) { |
| 49 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release()); |
| 50 } |
| 51 |
| 52 TEST_F(TestStereoAdapter, ConstructAndDestructDecoder) { |
| 53 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release()); |
| 54 } |
| 55 |
| 56 TEST_F(TestStereoAdapter, EncodeDecodeI420Frame) { |
| 57 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
| 58 encoder_->Encode(*input_frame_, nullptr, nullptr)); |
| 59 EncodedImage encoded_frame; |
| 60 CodecSpecificInfo codec_specific_info; |
| 61 ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame, &codec_specific_info)); |
| 62 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
| 63 decoder_->Decode(encoded_frame, false, nullptr)); |
| 64 std::unique_ptr<VideoFrame> decoded_frame; |
| 65 rtc::Optional<uint8_t> decoded_qp; |
| 66 ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp)); |
| 67 ASSERT_TRUE(decoded_frame); |
| 68 EXPECT_GT(I420PSNR(input_frame_.get(), decoded_frame.get()), 36); |
| 69 } |
| 70 |
| 71 } // namespace webrtc |
OLD | NEW |