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

Unified Diff: webrtc/modules/video_coding/codecs/vp9/test/vp9_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/vp9/test/vp9_impl_unittest.cc
diff --git a/webrtc/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc b/webrtc/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc
index fd4cbfd3bc787e0bf48c3c08c8e081d3541642db..823543d325b365e4560c19592ab795e1878596db 100644
--- a/webrtc/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc
+++ b/webrtc/modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc
@@ -8,161 +8,25 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "webrtc/base/criticalsection.h"
-#include "webrtc/base/event.h"
-#include "webrtc/base/thread_annotations.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
-#include "webrtc/test/frame_utils.h"
-#include "webrtc/test/gtest.h"
-#include "webrtc/test/testsupport/fileutils.h"
+#include "webrtc/modules/video_coding/codecs/test/video_codec_test.h"
namespace webrtc {
-static const int kEncodeTimeoutMs = 100;
-static const int kDecodeTimeoutMs = 25;
-// Set a start bitrate to get higher quality.
-static const int kStartBitrate = 300;
-static const int kWidth = 172; // Width of the input image.
-static const int kHeight = 144; // Height of the input image.
-static const int kMaxFramerate = 30; // Arbitrary value.
-
-class TestVp9Impl : public ::testing::Test {
- public:
- TestVp9Impl()
- : encode_complete_callback_(this),
- decode_complete_callback_(this),
- encoded_frame_event_(false /* manual reset */,
- false /* initially signaled */),
- decoded_frame_event_(false /* manual reset */,
- false /* initially signaled */) {}
-
+class TestVp9Impl : public VideoCodecTest {
protected:
- class FakeEncodeCompleteCallback : public webrtc::EncodedImageCallback {
- public:
- explicit FakeEncodeCompleteCallback(TestVp9Impl* test) : test_(test) {}
-
- Result OnEncodedImage(const EncodedImage& frame,
- const CodecSpecificInfo* codec_specific_info,
- const RTPFragmentationHeader* fragmentation) {
- rtc::CritScope lock(&test_->encoded_frame_section_);
- test_->encoded_frame_ = rtc::Optional<EncodedImage>(frame);
- test_->encoded_frame_event_.Set();
- return Result(Result::OK);
- }
-
- private:
- TestVp9Impl* const test_;
- };
-
- class FakeDecodeCompleteCallback : public webrtc::DecodedImageCallback {
- public:
- explicit FakeDecodeCompleteCallback(TestVp9Impl* test) : test_(test) {}
+ VideoEncoder* CreateEncoder() override { return VP9Encoder::Create(); }
- int32_t Decoded(VideoFrame& frame) override {
- RTC_NOTREACHED();
- return -1;
- }
- int32_t Decoded(VideoFrame& frame, int64_t decode_time_ms) override {
- RTC_NOTREACHED();
- return -1;
- }
- void Decoded(VideoFrame& frame,
- rtc::Optional<int32_t> decode_time_ms,
- rtc::Optional<uint8_t> qp) override {
- rtc::CritScope lock(&test_->decoded_frame_section_);
- test_->decoded_frame_ = rtc::Optional<VideoFrame>(frame);
- test_->decoded_qp_ = qp;
- test_->decoded_frame_event_.Set();
- }
-
- private:
- TestVp9Impl* const test_;
- };
-
- void SetUp() override {
- // Using a QCIF image. Processing only one frame.
- FILE* source_file_ =
- fopen(test::ResourcePath("paris_qcif", "yuv").c_str(), "rb");
- ASSERT_TRUE(source_file_ != NULL);
- rtc::scoped_refptr<VideoFrameBuffer> video_frame_buffer(
- test::ReadI420Buffer(kWidth, kHeight, source_file_));
- input_frame_.reset(new VideoFrame(video_frame_buffer, kVideoRotation_0, 0));
- fclose(source_file_);
-
- encoder_.reset(VP9Encoder::Create());
- decoder_.reset(VP9Decoder::Create());
- encoder_->RegisterEncodeCompleteCallback(&encode_complete_callback_);
- decoder_->RegisterDecodeCompleteCallback(&decode_complete_callback_);
-
- InitCodecs();
- }
+ VideoDecoder* CreateDecoder() override { return VP9Decoder::Create(); }
- void InitCodecs() {
- VideoCodec codec_inst_;
- codec_inst_.startBitrate = kStartBitrate;
- codec_inst_.codecType = webrtc::kVideoCodecVP9;
- codec_inst_.maxFramerate = kMaxFramerate;
- codec_inst_.width = kWidth;
- codec_inst_.height = kHeight;
- codec_inst_.VP9()->numberOfTemporalLayers = 1;
- codec_inst_.VP9()->numberOfSpatialLayers = 1;
- EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
- encoder_->InitEncode(&codec_inst_, 1 /* number of cores */,
- 0 /* max payload size (unused) */));
- EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
- decoder_->InitDecode(&codec_inst_, 1 /* number of cores */));
+ VideoCodec codec_settings() override {
+ VideoCodec codec_inst;
+ codec_inst.codecType = webrtc::kVideoCodecVP9;
+ codec_inst.VP9()->numberOfTemporalLayers = 1;
+ codec_inst.VP9()->numberOfSpatialLayers = 1;
+ return codec_inst;
}
-
- bool WaitForEncodedFrame(EncodedImage* frame) {
- bool ret = encoded_frame_event_.Wait(kEncodeTimeoutMs);
- EXPECT_TRUE(ret) << "Timed out while waiting for an encoded frame.";
- // This becomes unsafe if there are multiple threads waiting for frames.
- rtc::CritScope lock(&encoded_frame_section_);
- EXPECT_TRUE(encoded_frame_);
- if (encoded_frame_) {
- *frame = std::move(*encoded_frame_);
- encoded_frame_.reset();
- return true;
- } else {
- return false;
- }
- }
-
- bool WaitForDecodedFrame(std::unique_ptr<VideoFrame>* frame,
- rtc::Optional<uint8_t>* qp) {
- bool ret = decoded_frame_event_.Wait(kDecodeTimeoutMs);
- EXPECT_TRUE(ret) << "Timed out while waiting for a decoded frame.";
- // This becomes unsafe if there are multiple threads waiting for frames.
- rtc::CritScope lock(&decoded_frame_section_);
- EXPECT_TRUE(decoded_frame_);
- if (decoded_frame_) {
- frame->reset(new VideoFrame(std::move(*decoded_frame_)));
- *qp = decoded_qp_;
- decoded_frame_.reset();
- return true;
- } else {
- return false;
- }
- }
-
- std::unique_ptr<VideoFrame> input_frame_;
-
- std::unique_ptr<VideoEncoder> encoder_;
- std::unique_ptr<VideoDecoder> decoder_;
-
- private:
- FakeEncodeCompleteCallback encode_complete_callback_;
- FakeDecodeCompleteCallback decode_complete_callback_;
-
- rtc::Event encoded_frame_event_;
- rtc::CriticalSection encoded_frame_section_;
- rtc::Optional<EncodedImage> encoded_frame_ GUARDED_BY(encoded_frame_section_);
-
- rtc::Event decoded_frame_event_;
- rtc::CriticalSection decoded_frame_section_;
- rtc::Optional<VideoFrame> decoded_frame_ GUARDED_BY(decoded_frame_section_);
- rtc::Optional<uint8_t> decoded_qp_ GUARDED_BY(decoded_frame_section_);
};
TEST_F(TestVp9Impl, EncodeDecode) {

Powered by Google App Engine
This is Rietveld 408576698