| 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 "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | |
| 12 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" | |
| 13 #include "webrtc/modules/video_coding/codecs/test/video_codec_test.h" | |
| 14 | |
| 15 namespace webrtc { | |
| 16 | |
| 17 class TestH264Impl : public VideoCodecTest { | |
| 18 protected: | |
| 19 VideoEncoder* CreateEncoder() override { | |
| 20 return H264Encoder::Create(cricket::VideoCodec(cricket::kH264CodecName)); | |
| 21 } | |
| 22 | |
| 23 VideoDecoder* CreateDecoder() override { return H264Decoder::Create(); } | |
| 24 | |
| 25 VideoCodec codec_settings() override { | |
| 26 VideoCodec codec_inst; | |
| 27 codec_inst.codecType = webrtc::kVideoCodecH264; | |
| 28 // If frame dropping is false, we get a warning that bitrate can't | |
| 29 // be controlled for RC_QUALITY_MODE; RC_BITRATE_MODE and RC_TIMESTAMP_MODE | |
| 30 codec_inst.H264()->frameDroppingOn = true; | |
| 31 return codec_inst; | |
| 32 } | |
| 33 }; | |
| 34 | |
| 35 #ifdef WEBRTC_VIDEOPROCESSOR_H264_TESTS | |
| 36 #define MAYBE_EncodeDecode EncodeDecode | |
| 37 #define MAYBE_DecodedQpEqualsEncodedQp DecodedQpEqualsEncodedQp | |
| 38 #else | |
| 39 #define MAYBE_EncodeDecode DISABLED_EncodeDecode | |
| 40 #define MAYBE_DecodedQpEqualsEncodedQp DISABLED_DecodedQpEqualsEncodedQp | |
| 41 #endif | |
| 42 | |
| 43 TEST_F(TestH264Impl, MAYBE_EncodeDecode) { | |
| 44 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | |
| 45 encoder_->Encode(*input_frame_, nullptr, nullptr)); | |
| 46 EncodedImage encoded_frame; | |
| 47 ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame)); | |
| 48 // First frame should be a key frame. | |
| 49 encoded_frame._frameType = kVideoFrameKey; | |
| 50 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | |
| 51 decoder_->Decode(encoded_frame, false, nullptr)); | |
| 52 std::unique_ptr<VideoFrame> decoded_frame; | |
| 53 rtc::Optional<uint8_t> decoded_qp; | |
| 54 ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp)); | |
| 55 ASSERT_TRUE(decoded_frame); | |
| 56 EXPECT_GT(I420PSNR(input_frame_.get(), decoded_frame.get()), 36); | |
| 57 } | |
| 58 | |
| 59 TEST_F(TestH264Impl, MAYBE_DecodedQpEqualsEncodedQp) { | |
| 60 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | |
| 61 encoder_->Encode(*input_frame_, nullptr, nullptr)); | |
| 62 EncodedImage encoded_frame; | |
| 63 ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame)); | |
| 64 // First frame should be a key frame. | |
| 65 encoded_frame._frameType = kVideoFrameKey; | |
| 66 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | |
| 67 decoder_->Decode(encoded_frame, false, nullptr)); | |
| 68 std::unique_ptr<VideoFrame> decoded_frame; | |
| 69 rtc::Optional<uint8_t> decoded_qp; | |
| 70 ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp)); | |
| 71 ASSERT_TRUE(decoded_frame); | |
| 72 ASSERT_TRUE(decoded_qp); | |
| 73 EXPECT_EQ(encoded_frame.qp_, *decoded_qp); | |
| 74 } | |
| 75 | |
| 76 } // namespace webrtc | |
| OLD | NEW |