webrtc_m130/modules/video_coding/codecs/test/video_codec_unittest.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

129 lines
4.2 KiB
C
Raw Normal View History

/*
* 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>
Reland "Add stereo codec header and pass it through RTP" This is a reland of 20f2133d5dbd1591b89425b24db3b1e09fbcf0b1 Original change's description: > Add stereo codec header and pass it through RTP > > - Defines CodecSpecificInfoStereo that carries stereo specific header info from > encoded image. > - Defines RTPVideoHeaderStereo that carries the above info to packetizer, > see module_common_types.h. > - Adds an RTPPacketizer and RTPDepacketizer that supports passing specific stereo > header. > - Uses new data containers in StereoAdapter classes. > > This CL is the step 3 for adding alpha channel support over the wire in webrtc. > See https://webrtc-review.googlesource.com/c/src/+/7800 for the experimental > CL that gives an idea about how it will come together. > Design Doc: https://goo.gl/sFeSUT > > Bug: webrtc:7671 > Change-Id: Ia932568fdd7065ba104afd2bc0ecf25a765748ab > Reviewed-on: https://webrtc-review.googlesource.com/22900 > Reviewed-by: Emircan Uysaler <emircan@webrtc.org> > Reviewed-by: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org> > Commit-Queue: Emircan Uysaler <emircan@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20920} TBR=danilchap@webrtc.org, sprang@webrtc.org, niklas.enbom@webrtc.org Bug: webrtc:7671 Change-Id: If8f0c7e6e3a2a704f19161f0e8bf1880906e7fe0 Reviewed-on: https://webrtc-review.googlesource.com/27160 Reviewed-by: Emircan Uysaler <emircan@webrtc.org> Commit-Queue: Emircan Uysaler <emircan@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20946}
2017-11-28 09:45:25 -08:00
#include <vector>
#include "api/test/frame_generator_interface.h"
#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/event.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
#include "test/gtest.h"
namespace webrtc {
class VideoCodecUnitTest : public ::testing::Test {
public:
VideoCodecUnitTest()
: encode_complete_callback_(this),
decode_complete_callback_(this),
Reland "Add stereo codec header and pass it through RTP" This is a reland of 20f2133d5dbd1591b89425b24db3b1e09fbcf0b1 Original change's description: > Add stereo codec header and pass it through RTP > > - Defines CodecSpecificInfoStereo that carries stereo specific header info from > encoded image. > - Defines RTPVideoHeaderStereo that carries the above info to packetizer, > see module_common_types.h. > - Adds an RTPPacketizer and RTPDepacketizer that supports passing specific stereo > header. > - Uses new data containers in StereoAdapter classes. > > This CL is the step 3 for adding alpha channel support over the wire in webrtc. > See https://webrtc-review.googlesource.com/c/src/+/7800 for the experimental > CL that gives an idea about how it will come together. > Design Doc: https://goo.gl/sFeSUT > > Bug: webrtc:7671 > Change-Id: Ia932568fdd7065ba104afd2bc0ecf25a765748ab > Reviewed-on: https://webrtc-review.googlesource.com/22900 > Reviewed-by: Emircan Uysaler <emircan@webrtc.org> > Reviewed-by: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org> > Commit-Queue: Emircan Uysaler <emircan@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20920} TBR=danilchap@webrtc.org, sprang@webrtc.org, niklas.enbom@webrtc.org Bug: webrtc:7671 Change-Id: If8f0c7e6e3a2a704f19161f0e8bf1880906e7fe0 Reviewed-on: https://webrtc-review.googlesource.com/27160 Reviewed-by: Emircan Uysaler <emircan@webrtc.org> Commit-Queue: Emircan Uysaler <emircan@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20946}
2017-11-28 09:45:25 -08:00
wait_for_encoded_frames_threshold_(1),
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);
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_;
};
Reland "Update internal SW codecs to return unique_ptrs" This reverts commit 34c8e6bce8af0c31f2b0b31d691a6a931fa3cb7b. Reason for revert: Fix Android compilation Original change's description: > Revert "Update internal SW codecs to return unique_ptrs" > > This reverts commit 4fe6adc06a8524ac25f85260bfe392eb31dae6b4. > > Reason for revert: Breaks android compile. > > Original change's description: > > Update internal SW codecs to return unique_ptrs > > > > TBR=stefan@webrtc.org > > > > Bug: webrtc:7925 > > Change-Id: I84239b071a2608d928f09b06809090eec5eafb14 > > Reviewed-on: https://webrtc-review.googlesource.com/21165 > > Commit-Queue: Magnus Jedvert <magjed@webrtc.org> > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#20650} > > TBR=magjed@webrtc.org,sprang@webrtc.org,stefan@webrtc.org > > Change-Id: If33c3a0ee0dfce63d105558a2897a472f0633306 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:7925 > Reviewed-on: https://webrtc-review.googlesource.com/22540 > Reviewed-by: Magnus Jedvert <magjed@webrtc.org> > Commit-Queue: Magnus Jedvert <magjed@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20652} TBR=magjed@webrtc.org,sprang@webrtc.org,stefan@webrtc.org Change-Id: Ic8551af4687e927c9b605060155abdd5bc6208b2 Bug: webrtc:7925 Reviewed-on: https://webrtc-review.googlesource.com/22541 Commit-Queue: Magnus Jedvert <magjed@webrtc.org> Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20655}
2017-11-13 14:10:02 +01:00
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();
Reland "Add stereo codec header and pass it through RTP" This is a reland of 20f2133d5dbd1591b89425b24db3b1e09fbcf0b1 Original change's description: > Add stereo codec header and pass it through RTP > > - Defines CodecSpecificInfoStereo that carries stereo specific header info from > encoded image. > - Defines RTPVideoHeaderStereo that carries the above info to packetizer, > see module_common_types.h. > - Adds an RTPPacketizer and RTPDepacketizer that supports passing specific stereo > header. > - Uses new data containers in StereoAdapter classes. > > This CL is the step 3 for adding alpha channel support over the wire in webrtc. > See https://webrtc-review.googlesource.com/c/src/+/7800 for the experimental > CL that gives an idea about how it will come together. > Design Doc: https://goo.gl/sFeSUT > > Bug: webrtc:7671 > Change-Id: Ia932568fdd7065ba104afd2bc0ecf25a765748ab > Reviewed-on: https://webrtc-review.googlesource.com/22900 > Reviewed-by: Emircan Uysaler <emircan@webrtc.org> > Reviewed-by: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org> > Commit-Queue: Emircan Uysaler <emircan@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20920} TBR=danilchap@webrtc.org, sprang@webrtc.org, niklas.enbom@webrtc.org Bug: webrtc:7671 Change-Id: If8f0c7e6e3a2a704f19161f0e8bf1880906e7fe0 Reviewed-on: https://webrtc-review.googlesource.com/27160 Reviewed-by: Emircan Uysaler <emircan@webrtc.org> Commit-Queue: Emircan Uysaler <emircan@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20946}
2017-11-28 09:45:25 -08:00
// Helper method for waiting a single encoded frame.
bool WaitForEncodedFrame(EncodedImage* frame,
CodecSpecificInfo* codec_specific_info);
Reland "Add stereo codec header and pass it through RTP" This is a reland of 20f2133d5dbd1591b89425b24db3b1e09fbcf0b1 Original change's description: > Add stereo codec header and pass it through RTP > > - Defines CodecSpecificInfoStereo that carries stereo specific header info from > encoded image. > - Defines RTPVideoHeaderStereo that carries the above info to packetizer, > see module_common_types.h. > - Adds an RTPPacketizer and RTPDepacketizer that supports passing specific stereo > header. > - Uses new data containers in StereoAdapter classes. > > This CL is the step 3 for adding alpha channel support over the wire in webrtc. > See https://webrtc-review.googlesource.com/c/src/+/7800 for the experimental > CL that gives an idea about how it will come together. > Design Doc: https://goo.gl/sFeSUT > > Bug: webrtc:7671 > Change-Id: Ia932568fdd7065ba104afd2bc0ecf25a765748ab > Reviewed-on: https://webrtc-review.googlesource.com/22900 > Reviewed-by: Emircan Uysaler <emircan@webrtc.org> > Reviewed-by: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org> > Commit-Queue: Emircan Uysaler <emircan@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20920} TBR=danilchap@webrtc.org, sprang@webrtc.org, niklas.enbom@webrtc.org Bug: webrtc:7671 Change-Id: If8f0c7e6e3a2a704f19161f0e8bf1880906e7fe0 Reviewed-on: https://webrtc-review.googlesource.com/27160 Reviewed-by: Emircan Uysaler <emircan@webrtc.org> Commit-Queue: Emircan Uysaler <emircan@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20946}
2017-11-28 09:45:25 -08:00
// Helper methods for waiting for multiple encoded frames. Caller must
// define how many frames are to be waited for via `num_frames` before calling
Reland "Add stereo codec header and pass it through RTP" This is a reland of 20f2133d5dbd1591b89425b24db3b1e09fbcf0b1 Original change's description: > Add stereo codec header and pass it through RTP > > - Defines CodecSpecificInfoStereo that carries stereo specific header info from > encoded image. > - Defines RTPVideoHeaderStereo that carries the above info to packetizer, > see module_common_types.h. > - Adds an RTPPacketizer and RTPDepacketizer that supports passing specific stereo > header. > - Uses new data containers in StereoAdapter classes. > > This CL is the step 3 for adding alpha channel support over the wire in webrtc. > See https://webrtc-review.googlesource.com/c/src/+/7800 for the experimental > CL that gives an idea about how it will come together. > Design Doc: https://goo.gl/sFeSUT > > Bug: webrtc:7671 > Change-Id: Ia932568fdd7065ba104afd2bc0ecf25a765748ab > Reviewed-on: https://webrtc-review.googlesource.com/22900 > Reviewed-by: Emircan Uysaler <emircan@webrtc.org> > Reviewed-by: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org> > Commit-Queue: Emircan Uysaler <emircan@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20920} TBR=danilchap@webrtc.org, sprang@webrtc.org, niklas.enbom@webrtc.org Bug: webrtc:7671 Change-Id: If8f0c7e6e3a2a704f19161f0e8bf1880906e7fe0 Reviewed-on: https://webrtc-review.googlesource.com/27160 Reviewed-by: Emircan Uysaler <emircan@webrtc.org> Commit-Queue: Emircan Uysaler <emircan@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20946}
2017-11-28 09:45:25 -08:00
// 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_;
std::unique_ptr<test::FrameGeneratorInterface> input_frame_generator_;
private:
FakeEncodeCompleteCallback encode_complete_callback_;
FakeDecodeCompleteCallback decode_complete_callback_;
rtc::Event encoded_frame_event_;
Mutex encoded_frame_section_;
Reland "Add stereo codec header and pass it through RTP" This is a reland of 20f2133d5dbd1591b89425b24db3b1e09fbcf0b1 Original change's description: > Add stereo codec header and pass it through RTP > > - Defines CodecSpecificInfoStereo that carries stereo specific header info from > encoded image. > - Defines RTPVideoHeaderStereo that carries the above info to packetizer, > see module_common_types.h. > - Adds an RTPPacketizer and RTPDepacketizer that supports passing specific stereo > header. > - Uses new data containers in StereoAdapter classes. > > This CL is the step 3 for adding alpha channel support over the wire in webrtc. > See https://webrtc-review.googlesource.com/c/src/+/7800 for the experimental > CL that gives an idea about how it will come together. > Design Doc: https://goo.gl/sFeSUT > > Bug: webrtc:7671 > Change-Id: Ia932568fdd7065ba104afd2bc0ecf25a765748ab > Reviewed-on: https://webrtc-review.googlesource.com/22900 > Reviewed-by: Emircan Uysaler <emircan@webrtc.org> > Reviewed-by: Erik Språng <sprang@webrtc.org> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> > Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org> > Commit-Queue: Emircan Uysaler <emircan@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20920} TBR=danilchap@webrtc.org, sprang@webrtc.org, niklas.enbom@webrtc.org Bug: webrtc:7671 Change-Id: If8f0c7e6e3a2a704f19161f0e8bf1880906e7fe0 Reviewed-on: https://webrtc-review.googlesource.com/27160 Reviewed-by: Emircan Uysaler <emircan@webrtc.org> Commit-Queue: Emircan Uysaler <emircan@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20946}
2017-11-28 09:45:25 -08:00
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_;
Mutex 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_);
uint32_t last_input_frame_timestamp_;
};
} // namespace webrtc
#endif // MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_UNITTEST_H_