mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-14 06:10:40 +01:00

This reverts commitcb853c8f90
. Reason for revert: Broke Linux tester on FYI bots, https://ci.chromium.org/buildbot/chromium.webrtc.fyi/Linux%20Tester/46636 . Original change's description: > Reland "Add Profile 2 configuration to VP9 Encoder and Decoder" > > This is a reland offc9c4e88b5
> > Original change's description: > > Add Profile 2 configuration to VP9 Encoder and Decoder > > > > Bug: webrtc:9376 > > Change-Id: I4f627fb2b6c146a90cfcaa815da459b09dc00003 > > Reviewed-on: https://webrtc-review.googlesource.com/81980 > > Commit-Queue: Emircan Uysaler <emircan@webrtc.org> > > Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org> > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Reviewed-by: Jerome Jiang <jianj@google.com> > > Cr-Commit-Position: refs/heads/master@{#23917} > > Bug: webrtc:9376 > Change-Id: I21fc44865af4e381f99dbc5ae2baf4a53ce834ca > TBR: niklas.enbom@webrtc.org > Reviewed-on: https://webrtc-review.googlesource.com/88341 > Commit-Queue: Emircan Uysaler <emircan@webrtc.org> > Reviewed-by: Emircan Uysaler <emircan@webrtc.org> > Reviewed-by: Erik Språng <sprang@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#23974} TBR=niklase@google.com,jianj@google.com,sprang@webrtc.org,marpan@google.com,niklas.enbom@webrtc.org,emircan@webrtc.org Change-Id: I23062a0a2e5feafa29fd36e6b1c4a6e2734c4d68 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:9376 Reviewed-on: https://webrtc-review.googlesource.com/88600 Reviewed-by: Emircan Uysaler <emircan@webrtc.org> Commit-Queue: Emircan Uysaler <emircan@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23976}
133 lines
4.5 KiB
C++
133 lines
4.5 KiB
C++
/*
|
|
* 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.
|
|
*/
|
|
|
|
#ifndef MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_UNITTEST_H_
|
|
#define MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_UNITTEST_H_
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "api/video_codecs/video_decoder.h"
|
|
#include "api/video_codecs/video_encoder.h"
|
|
#include "modules/video_coding/include/video_codec_interface.h"
|
|
#include "modules/video_coding/utility/vp8_header_parser.h"
|
|
#include "modules/video_coding/utility/vp9_uncompressed_header_parser.h"
|
|
#include "rtc_base/criticalsection.h"
|
|
#include "rtc_base/event.h"
|
|
#include "rtc_base/thread_annotations.h"
|
|
#include "test/frame_generator.h"
|
|
#include "test/gtest.h"
|
|
|
|
namespace webrtc {
|
|
|
|
class VideoCodecUnitTest : public ::testing::Test {
|
|
public:
|
|
VideoCodecUnitTest()
|
|
: encode_complete_callback_(this),
|
|
decode_complete_callback_(this),
|
|
encoded_frame_event_(false /* manual reset */,
|
|
false /* initially signaled */),
|
|
wait_for_encoded_frames_threshold_(1),
|
|
decoded_frame_event_(false /* manual reset */,
|
|
false /* initially signaled */),
|
|
last_input_frame_timestamp_(0) {}
|
|
|
|
protected:
|
|
class FakeEncodeCompleteCallback : public webrtc::EncodedImageCallback {
|
|
public:
|
|
explicit FakeEncodeCompleteCallback(VideoCodecUnitTest* test)
|
|
: test_(test) {}
|
|
|
|
Result OnEncodedImage(const EncodedImage& frame,
|
|
const CodecSpecificInfo* codec_specific_info,
|
|
const RTPFragmentationHeader* fragmentation);
|
|
|
|
private:
|
|
VideoCodecUnitTest* const test_;
|
|
};
|
|
|
|
class FakeDecodeCompleteCallback : public webrtc::DecodedImageCallback {
|
|
public:
|
|
explicit FakeDecodeCompleteCallback(VideoCodecUnitTest* test)
|
|
: test_(test) {}
|
|
|
|
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,
|
|
absl::optional<int32_t> decode_time_ms,
|
|
absl::optional<uint8_t> qp) override;
|
|
|
|
private:
|
|
VideoCodecUnitTest* const test_;
|
|
};
|
|
|
|
virtual std::unique_ptr<VideoEncoder> CreateEncoder() = 0;
|
|
virtual std::unique_ptr<VideoDecoder> CreateDecoder() = 0;
|
|
|
|
void SetUp() override;
|
|
|
|
virtual void ModifyCodecSettings(VideoCodec* codec_settings);
|
|
|
|
VideoFrame* NextInputFrame();
|
|
|
|
// Helper method for waiting a single encoded frame.
|
|
bool WaitForEncodedFrame(EncodedImage* frame,
|
|
CodecSpecificInfo* codec_specific_info);
|
|
|
|
// Helper methods for waiting for multiple encoded frames. Caller must
|
|
// define how many frames are to be waited for via |num_frames| before calling
|
|
// Encode(). Then, they can expect to retrive them via WaitForEncodedFrames().
|
|
void SetWaitForEncodedFramesThreshold(size_t num_frames);
|
|
bool WaitForEncodedFrames(
|
|
std::vector<EncodedImage>* frames,
|
|
std::vector<CodecSpecificInfo>* codec_specific_info);
|
|
|
|
// Helper method for waiting a single decoded frame.
|
|
bool WaitForDecodedFrame(std::unique_ptr<VideoFrame>* frame,
|
|
absl::optional<uint8_t>* qp);
|
|
|
|
size_t GetNumEncodedFrames();
|
|
|
|
VideoCodec codec_settings_;
|
|
|
|
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_;
|
|
size_t wait_for_encoded_frames_threshold_;
|
|
std::vector<EncodedImage> encoded_frames_
|
|
RTC_GUARDED_BY(encoded_frame_section_);
|
|
std::vector<CodecSpecificInfo> codec_specific_infos_
|
|
RTC_GUARDED_BY(encoded_frame_section_);
|
|
|
|
rtc::Event decoded_frame_event_;
|
|
rtc::CriticalSection decoded_frame_section_;
|
|
absl::optional<VideoFrame> decoded_frame_
|
|
RTC_GUARDED_BY(decoded_frame_section_);
|
|
absl::optional<uint8_t> decoded_qp_ RTC_GUARDED_BY(decoded_frame_section_);
|
|
|
|
std::unique_ptr<test::FrameGenerator> input_frame_generator_;
|
|
uint32_t last_input_frame_timestamp_;
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_UNITTEST_H_
|