Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Unified Diff: webrtc/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc

Issue 2649133007: Add QP for FFmpeg H264 decoder. (Closed)
Patch Set: Rebase. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc
diff --git a/webrtc/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc b/webrtc/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..82992058c9a4b578a29fa912f501d0981eee162c
--- /dev/null
+++ b/webrtc/modules/video_coding/codecs/h264/test/h264_impl_unittest.cc
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
+#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
+#include "webrtc/modules/video_coding/codecs/test/video_codec_test.h"
+
+namespace webrtc {
+
+class TestH264Impl : public VideoCodecTest {
+ protected:
+ VideoEncoder* CreateEncoder() override {
+ return H264Encoder::Create(cricket::VideoCodec(cricket::kH264CodecName));
+ }
+
+ VideoDecoder* CreateDecoder() override { return H264Decoder::Create(); }
+
+ VideoCodec codec_settings() override {
+ VideoCodec codec_inst;
+ codec_inst.codecType = webrtc::kVideoCodecH264;
+ // If frame dropping is false, we get a warning that bitrate can't
+ // be controlled for RC_QUALITY_MODE; RC_BITRATE_MODE and RC_TIMESTAMP_MODE
+ codec_inst.H264()->frameDroppingOn = true;
+ return codec_inst;
+ }
+};
+
+#ifdef WEBRTC_VIDEOPROCESSOR_H264_TESTS
+#define MAYBE_EncodeDecode EncodeDecode
+#define MAYBE_DecodedQpEqualsEncodedQp DecodedQpEqualsEncodedQp
+#else
+#define MAYBE_EncodeDecode DISABLED_EncodeDecode
+#define MAYBE_DecodedQpEqualsEncodedQp DISABLED_DecodedQpEqualsEncodedQp
+#endif
+
+TEST_F(TestH264Impl, MAYBE_EncodeDecode) {
+ EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
+ encoder_->Encode(*input_frame_, nullptr, nullptr));
+ EncodedImage encoded_frame;
+ ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame));
+ // First frame should be a key frame.
+ encoded_frame._frameType = kVideoFrameKey;
+ EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
+ decoder_->Decode(encoded_frame, false, nullptr));
+ std::unique_ptr<VideoFrame> decoded_frame;
+ rtc::Optional<uint8_t> decoded_qp;
+ ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
+ ASSERT_TRUE(decoded_frame);
+ EXPECT_GT(I420PSNR(input_frame_.get(), decoded_frame.get()), 36);
+}
+
+TEST_F(TestH264Impl, MAYBE_DecodedQpEqualsEncodedQp) {
+ EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
+ encoder_->Encode(*input_frame_, nullptr, nullptr));
+ EncodedImage encoded_frame;
+ ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame));
+ // First frame should be a key frame.
+ encoded_frame._frameType = kVideoFrameKey;
+ EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
+ decoder_->Decode(encoded_frame, false, nullptr));
+ std::unique_ptr<VideoFrame> decoded_frame;
+ rtc::Optional<uint8_t> decoded_qp;
+ ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
+ ASSERT_TRUE(decoded_frame);
+ ASSERT_TRUE(decoded_qp);
+ EXPECT_EQ(encoded_frame.qp_, *decoded_qp);
+}
+
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698