Delete CodecSpecificInfo argument from VideoDecoder::Decode
Bug: webrtc:10379 Change-Id: I079b419604bf4e9c1994fe203d7db131a0ccddb6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/125920 Commit-Queue: Niels Moller <nisse@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27022}
This commit is contained in:
@ -41,10 +41,9 @@ class MockVideoDecoder : public VideoDecoder {
|
||||
|
||||
MOCK_METHOD2(InitDecode,
|
||||
int32_t(const VideoCodec* codecSettings, int32_t numberOfCores));
|
||||
MOCK_METHOD4(Decode,
|
||||
MOCK_METHOD3(Decode,
|
||||
int32_t(const EncodedImage& inputImage,
|
||||
bool missingFrames,
|
||||
const CodecSpecificInfo* codecSpecificInfo,
|
||||
int64_t renderTimeMs));
|
||||
MOCK_METHOD1(RegisterDecodeCompleteCallback,
|
||||
int32_t(DecodedImageCallback* callback));
|
||||
|
@ -49,7 +49,6 @@ class VideoDecoderSoftwareFallbackWrapperTest : public ::testing::Test {
|
||||
|
||||
int32_t Decode(const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) override {
|
||||
++decode_count_;
|
||||
return decode_return_code_;
|
||||
@ -89,7 +88,7 @@ TEST_F(VideoDecoderSoftwareFallbackWrapperTest, InitializesDecoder) {
|
||||
|
||||
EncodedImage encoded_image;
|
||||
encoded_image._frameType = kVideoFrameKey;
|
||||
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
|
||||
fallback_wrapper_->Decode(encoded_image, false, -1);
|
||||
EXPECT_EQ(1, fake_decoder_->init_decode_count_)
|
||||
<< "Initialized decoder should not be reinitialized.";
|
||||
EXPECT_EQ(1, fake_decoder_->decode_count_);
|
||||
@ -104,7 +103,7 @@ TEST_F(VideoDecoderSoftwareFallbackWrapperTest,
|
||||
|
||||
EncodedImage encoded_image;
|
||||
encoded_image._frameType = kVideoFrameKey;
|
||||
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
|
||||
fallback_wrapper_->Decode(encoded_image, false, -1);
|
||||
EXPECT_EQ(1, fake_decoder_->init_decode_count_)
|
||||
<< "Should not have attempted reinitializing the fallback decoder on "
|
||||
"keyframe.";
|
||||
@ -120,12 +119,12 @@ TEST_F(VideoDecoderSoftwareFallbackWrapperTest, IsSoftwareFallbackSticky) {
|
||||
|
||||
fake_decoder_->decode_return_code_ = WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
|
||||
EncodedImage encoded_image;
|
||||
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
|
||||
fallback_wrapper_->Decode(encoded_image, false, -1);
|
||||
EXPECT_EQ(1, fake_decoder_->decode_count_);
|
||||
|
||||
// Software fallback should be sticky, fake_decoder_ shouldn't be used.
|
||||
encoded_image._frameType = kVideoFrameKey;
|
||||
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
|
||||
fallback_wrapper_->Decode(encoded_image, false, -1);
|
||||
EXPECT_EQ(1, fake_decoder_->decode_count_)
|
||||
<< "Decoder shouldn't be used after failure.";
|
||||
|
||||
@ -139,10 +138,10 @@ TEST_F(VideoDecoderSoftwareFallbackWrapperTest, DoesNotFallbackOnEveryError) {
|
||||
fake_decoder_->decode_return_code_ = WEBRTC_VIDEO_CODEC_ERROR;
|
||||
EncodedImage encoded_image;
|
||||
EXPECT_EQ(fake_decoder_->decode_return_code_,
|
||||
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1));
|
||||
fallback_wrapper_->Decode(encoded_image, false, -1));
|
||||
EXPECT_EQ(1, fake_decoder_->decode_count_);
|
||||
|
||||
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
|
||||
fallback_wrapper_->Decode(encoded_image, false, -1);
|
||||
EXPECT_EQ(2, fake_decoder_->decode_count_)
|
||||
<< "Decoder should be active even though previous decode failed.";
|
||||
}
|
||||
@ -153,14 +152,14 @@ TEST_F(VideoDecoderSoftwareFallbackWrapperTest, UsesHwDecoderAfterReinit) {
|
||||
|
||||
fake_decoder_->decode_return_code_ = WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
|
||||
EncodedImage encoded_image;
|
||||
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
|
||||
fallback_wrapper_->Decode(encoded_image, false, -1);
|
||||
EXPECT_EQ(1, fake_decoder_->decode_count_);
|
||||
|
||||
fallback_wrapper_->Release();
|
||||
fallback_wrapper_->InitDecode(&codec, 2);
|
||||
|
||||
fake_decoder_->decode_return_code_ = WEBRTC_VIDEO_CODEC_OK;
|
||||
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
|
||||
fallback_wrapper_->Decode(encoded_image, false, -1);
|
||||
EXPECT_EQ(2, fake_decoder_->decode_count_)
|
||||
<< "Should not be using fallback after reinit.";
|
||||
}
|
||||
@ -174,7 +173,7 @@ TEST_F(VideoDecoderSoftwareFallbackWrapperTest, ForwardsReleaseCall) {
|
||||
fallback_wrapper_->InitDecode(&codec, 2);
|
||||
fake_decoder_->decode_return_code_ = WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
|
||||
EncodedImage encoded_image;
|
||||
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
|
||||
fallback_wrapper_->Decode(encoded_image, false, -1);
|
||||
EXPECT_EQ(2, fake_decoder_->release_count_)
|
||||
<< "Decoder should be released during fallback.";
|
||||
fallback_wrapper_->Release();
|
||||
@ -212,7 +211,7 @@ TEST_F(VideoDecoderSoftwareFallbackWrapperTest,
|
||||
|
||||
fake_decoder_->decode_return_code_ = WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
|
||||
EncodedImage encoded_image;
|
||||
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
|
||||
fallback_wrapper_->Decode(encoded_image, false, -1);
|
||||
// Hard coded expected value since libvpx is the software implementation name
|
||||
// for VP8. Change accordingly if the underlying implementation does.
|
||||
EXPECT_STREQ("libvpx (fallback from: fake-decoder)",
|
||||
@ -243,7 +242,7 @@ TEST_F(ForcedSoftwareDecoderFallbackTest, UsesForcedFallback) {
|
||||
|
||||
EncodedImage encoded_image;
|
||||
encoded_image._frameType = kVideoFrameKey;
|
||||
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
|
||||
fallback_wrapper_->Decode(encoded_image, false, -1);
|
||||
EXPECT_EQ(1, sw_fallback_decoder_->init_decode_count_);
|
||||
EXPECT_EQ(1, sw_fallback_decoder_->decode_count_);
|
||||
|
||||
|
@ -33,6 +33,19 @@ int32_t DecodedImageCallback::ReceivedDecodedFrame(const uint64_t pictureId) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t VideoDecoder::Decode(const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
int64_t render_time_ms) {
|
||||
return Decode(input_image, missing_frames, nullptr, render_time_ms);
|
||||
}
|
||||
|
||||
int32_t VideoDecoder::Decode(const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) {
|
||||
return Decode(input_image, missing_frames, render_time_ms);
|
||||
}
|
||||
|
||||
bool VideoDecoder::PrefersLateDecoding() const {
|
||||
return true;
|
||||
}
|
||||
|
@ -55,10 +55,16 @@ class RTC_EXPORT VideoDecoder {
|
||||
virtual int32_t InitDecode(const VideoCodec* codec_settings,
|
||||
int32_t number_of_cores) = 0;
|
||||
|
||||
virtual int32_t Decode(const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
int64_t render_time_ms);
|
||||
|
||||
// TODO(bugs.webrtc.org/10379): Deprecated. Delete, and make above method pure
|
||||
// virtual, as soon as downstream applications are updated.
|
||||
virtual int32_t Decode(const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) = 0;
|
||||
int64_t render_time_ms);
|
||||
|
||||
virtual int32_t RegisterDecodeCompleteCallback(
|
||||
DecodedImageCallback* callback) = 0;
|
||||
|
@ -40,7 +40,6 @@ class VideoDecoderSoftwareFallbackWrapper final : public VideoDecoder {
|
||||
|
||||
int32_t Decode(const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) override;
|
||||
|
||||
int32_t RegisterDecodeCompleteCallback(
|
||||
@ -147,7 +146,6 @@ bool VideoDecoderSoftwareFallbackWrapper::InitFallbackDecoder() {
|
||||
int32_t VideoDecoderSoftwareFallbackWrapper::Decode(
|
||||
const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) {
|
||||
TRACE_EVENT0("webrtc", "VideoDecoderSoftwareFallbackWrapper::Decode");
|
||||
switch (decoder_type_) {
|
||||
@ -155,8 +153,7 @@ int32_t VideoDecoderSoftwareFallbackWrapper::Decode(
|
||||
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
|
||||
case DecoderType::kHardware: {
|
||||
int32_t ret = WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
|
||||
ret = hw_decoder_->Decode(input_image, missing_frames,
|
||||
codec_specific_info, render_time_ms);
|
||||
ret = hw_decoder_->Decode(input_image, missing_frames, render_time_ms);
|
||||
if (ret != WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE) {
|
||||
return ret;
|
||||
}
|
||||
@ -172,7 +169,7 @@ int32_t VideoDecoderSoftwareFallbackWrapper::Decode(
|
||||
}
|
||||
case DecoderType::kFallback:
|
||||
return fallback_decoder_->Decode(input_image, missing_frames,
|
||||
codec_specific_info, render_time_ms);
|
||||
render_time_ms);
|
||||
default:
|
||||
RTC_NOTREACHED();
|
||||
return WEBRTC_VIDEO_CODEC_ERROR;
|
||||
|
@ -57,7 +57,6 @@ int32_t FakeWebRtcVideoDecoder::InitDecode(const webrtc::VideoCodec*, int32_t) {
|
||||
|
||||
int32_t FakeWebRtcVideoDecoder::Decode(const webrtc::EncodedImage&,
|
||||
bool,
|
||||
const webrtc::CodecSpecificInfo*,
|
||||
int64_t) {
|
||||
num_frames_received_++;
|
||||
return WEBRTC_VIDEO_CODEC_OK;
|
||||
|
@ -46,7 +46,6 @@ class FakeWebRtcVideoDecoder : public webrtc::VideoDecoder {
|
||||
int32_t InitDecode(const webrtc::VideoCodec*, int32_t) override;
|
||||
int32_t Decode(const webrtc::EncodedImage&,
|
||||
bool,
|
||||
const webrtc::CodecSpecificInfo*,
|
||||
int64_t) override;
|
||||
int32_t RegisterDecodeCompleteCallback(
|
||||
webrtc::DecodedImageCallback*) override;
|
||||
|
@ -228,7 +228,6 @@ int32_t H264DecoderImpl::RegisterDecodeCompleteCallback(
|
||||
|
||||
int32_t H264DecoderImpl::Decode(const EncodedImage& input_image,
|
||||
bool /*missing_frames*/,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t /*render_time_ms*/) {
|
||||
if (!IsInitialized()) {
|
||||
ReportError();
|
||||
@ -245,11 +244,6 @@ int32_t H264DecoderImpl::Decode(const EncodedImage& input_image,
|
||||
ReportError();
|
||||
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
|
||||
}
|
||||
if (codec_specific_info &&
|
||||
codec_specific_info->codecType != kVideoCodecH264) {
|
||||
ReportError();
|
||||
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
|
||||
}
|
||||
|
||||
// FFmpeg requires padding due to some optimized bitstream readers reading 32
|
||||
// or 64 bits at once and could read over the end. See avcodec_decode_video2.
|
||||
|
@ -49,7 +49,6 @@ class H264DecoderImpl : public H264Decoder {
|
||||
// |missing_frames|, |fragmentation| and |render_time_ms| are ignored.
|
||||
int32_t Decode(const EncodedImage& input_image,
|
||||
bool /*missing_frames*/,
|
||||
const CodecSpecificInfo* codec_specific_info = nullptr,
|
||||
int64_t render_time_ms = -1) override;
|
||||
|
||||
const char* ImplementationName() const override;
|
||||
|
@ -71,8 +71,7 @@ TEST_F(TestH264Impl, MAYBE_EncodeDecode) {
|
||||
ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame, &codec_specific_info));
|
||||
// First frame should be a key frame.
|
||||
encoded_frame._frameType = kVideoFrameKey;
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||
decoder_->Decode(encoded_frame, false, nullptr, 0));
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, false, 0));
|
||||
std::unique_ptr<VideoFrame> decoded_frame;
|
||||
absl::optional<uint8_t> decoded_qp;
|
||||
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
|
||||
@ -98,8 +97,7 @@ TEST_F(TestH264Impl, MAYBE_DecodedQpEqualsEncodedQp) {
|
||||
ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame, &codec_specific_info));
|
||||
// First frame should be a key frame.
|
||||
encoded_frame._frameType = kVideoFrameKey;
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||
decoder_->Decode(encoded_frame, false, nullptr, 0));
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, false, 0));
|
||||
std::unique_ptr<VideoFrame> decoded_frame;
|
||||
absl::optional<uint8_t> decoded_qp;
|
||||
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
|
||||
@ -140,8 +138,7 @@ TEST_F(TestH264Impl, MAYBE_DecodedColorSpaceEqualsEncodedColorSpace) {
|
||||
// Add color space to encoded frame.
|
||||
ColorSpace color_space = CreateTestColorSpace(/*with_hdr_metadata=*/false);
|
||||
encoded_frame.SetColorSpace(color_space);
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||
decoder_->Decode(encoded_frame, false, nullptr, 0));
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, false, 0));
|
||||
std::unique_ptr<VideoFrame> decoded_frame;
|
||||
absl::optional<uint8_t> decoded_qp;
|
||||
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
|
||||
|
@ -35,7 +35,6 @@ class MultiplexDecoderAdapter : public VideoDecoder {
|
||||
int32_t number_of_cores) override;
|
||||
int32_t Decode(const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) override;
|
||||
int32_t RegisterDecodeCompleteCallback(
|
||||
DecodedImageCallback* callback) override;
|
||||
|
@ -130,7 +130,6 @@ int32_t MultiplexDecoderAdapter::InitDecode(const VideoCodec* codec_settings,
|
||||
int32_t MultiplexDecoderAdapter::Decode(
|
||||
const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) {
|
||||
MultiplexImage image = MultiplexEncodedImagePacker::Unpack(input_image);
|
||||
|
||||
@ -154,7 +153,7 @@ int32_t MultiplexDecoderAdapter::Decode(
|
||||
int32_t rv = 0;
|
||||
for (size_t i = 0; i < image.image_components.size(); i++) {
|
||||
rv = decoders_[image.image_components[i].component_index]->Decode(
|
||||
image.image_components[i].encoded_image, missing_frames, nullptr,
|
||||
image.image_components[i].encoded_image, missing_frames,
|
||||
render_time_ms);
|
||||
if (rv != WEBRTC_VIDEO_CODEC_OK)
|
||||
return rv;
|
||||
|
@ -225,8 +225,7 @@ TEST_P(TestMultiplexAdapter, EncodeDecodeI420Frame) {
|
||||
ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame, &codec_specific_info));
|
||||
EXPECT_EQ(kVideoCodecMultiplex, codec_specific_info.codecType);
|
||||
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||
decoder_->Decode(encoded_frame, false, &codec_specific_info, -1));
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, false, -1));
|
||||
std::unique_ptr<VideoFrame> decoded_frame;
|
||||
absl::optional<uint8_t> decoded_qp;
|
||||
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
|
||||
@ -243,8 +242,7 @@ TEST_P(TestMultiplexAdapter, EncodeDecodeI420AFrame) {
|
||||
ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame, &codec_specific_info));
|
||||
EXPECT_EQ(kVideoCodecMultiplex, codec_specific_info.codecType);
|
||||
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||
decoder_->Decode(encoded_frame, false, nullptr, 0));
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, false, 0));
|
||||
std::unique_ptr<VideoFrame> decoded_frame;
|
||||
absl::optional<uint8_t> decoded_qp;
|
||||
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
|
||||
|
@ -529,7 +529,7 @@ void VideoProcessor::DecodeFrame(const EncodedImage& encoded_image,
|
||||
|
||||
frame_stat->decode_start_ns = rtc::TimeNanos();
|
||||
frame_stat->decode_return_code =
|
||||
decoders_->at(spatial_idx)->Decode(encoded_image, false, nullptr, 0);
|
||||
decoders_->at(spatial_idx)->Decode(encoded_image, false, 0);
|
||||
}
|
||||
|
||||
const webrtc::EncodedImage* VideoProcessor::BuildAndStoreSuperframe(
|
||||
|
@ -153,7 +153,6 @@ int LibvpxVp8Decoder::InitDecode(const VideoCodec* inst, int number_of_cores) {
|
||||
|
||||
int LibvpxVp8Decoder::Decode(const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t /*render_time_ms*/) {
|
||||
if (!inited_) {
|
||||
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
|
||||
|
@ -34,7 +34,6 @@ class LibvpxVp8Decoder : public VideoDecoder {
|
||||
|
||||
int Decode(const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t /*render_time_ms*/) override;
|
||||
|
||||
int RegisterDecodeCompleteCallback(DecodedImageCallback* callback) override;
|
||||
|
@ -210,8 +210,7 @@ TEST_F(TestVp8Impl, DecodedQpEqualsEncodedQp) {
|
||||
|
||||
// First frame should be a key frame.
|
||||
encoded_frame._frameType = kVideoFrameKey;
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||
decoder_->Decode(encoded_frame, false, nullptr, -1));
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, false, -1));
|
||||
std::unique_ptr<VideoFrame> decoded_frame;
|
||||
absl::optional<uint8_t> decoded_qp;
|
||||
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
|
||||
@ -230,8 +229,7 @@ TEST_F(TestVp8Impl, DecodedColorSpaceEqualsEncodedColorSpace) {
|
||||
// Encoded frame with explicit color space information.
|
||||
ColorSpace color_space = CreateTestColorSpace(/*with_hdr_metadata=*/false);
|
||||
encoded_frame.SetColorSpace(color_space);
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||
decoder_->Decode(encoded_frame, false, nullptr, -1));
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, false, -1));
|
||||
std::unique_ptr<VideoFrame> decoded_frame;
|
||||
absl::optional<uint8_t> decoded_qp;
|
||||
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
|
||||
@ -325,8 +323,7 @@ TEST_F(TestVp8Impl, MAYBE_AlignedStrideEncodeDecode) {
|
||||
// First frame should be a key frame.
|
||||
encoded_frame._frameType = kVideoFrameKey;
|
||||
encoded_frame.ntp_time_ms_ = kTestNtpTimeMs;
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||
decoder_->Decode(encoded_frame, false, nullptr, -1));
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, false, -1));
|
||||
|
||||
std::unique_ptr<VideoFrame> decoded_frame;
|
||||
absl::optional<uint8_t> decoded_qp;
|
||||
@ -352,16 +349,15 @@ TEST_F(TestVp8Impl, MAYBE_DecodeWithACompleteKeyFrame) {
|
||||
// Setting complete to false -> should return an error.
|
||||
encoded_frame._completeFrame = false;
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR,
|
||||
decoder_->Decode(encoded_frame, false, nullptr, -1));
|
||||
decoder_->Decode(encoded_frame, false, -1));
|
||||
// Setting complete back to true. Forcing a delta frame.
|
||||
encoded_frame._frameType = kVideoFrameDelta;
|
||||
encoded_frame._completeFrame = true;
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR,
|
||||
decoder_->Decode(encoded_frame, false, nullptr, -1));
|
||||
decoder_->Decode(encoded_frame, false, -1));
|
||||
// Now setting a key frame.
|
||||
encoded_frame._frameType = kVideoFrameKey;
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||
decoder_->Decode(encoded_frame, false, nullptr, -1));
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, false, -1));
|
||||
std::unique_ptr<VideoFrame> decoded_frame;
|
||||
absl::optional<uint8_t> decoded_qp;
|
||||
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
|
||||
|
@ -128,8 +128,7 @@ TEST_F(TestVp9Impl, EncodeDecode) {
|
||||
ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame, &codec_specific_info));
|
||||
// First frame should be a key frame.
|
||||
encoded_frame._frameType = kVideoFrameKey;
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||
decoder_->Decode(encoded_frame, false, nullptr, 0));
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, false, 0));
|
||||
std::unique_ptr<VideoFrame> decoded_frame;
|
||||
absl::optional<uint8_t> decoded_qp;
|
||||
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
|
||||
@ -198,8 +197,7 @@ TEST_F(TestVp9Impl, DecodedColorSpaceEqualsEncodedColorSpace) {
|
||||
ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame, &codec_specific_info));
|
||||
|
||||
// Encoded frame without explicit color space information.
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||
decoder_->Decode(encoded_frame, false, nullptr, 0));
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, false, 0));
|
||||
std::unique_ptr<VideoFrame> decoded_frame;
|
||||
absl::optional<uint8_t> decoded_qp;
|
||||
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
|
||||
@ -212,8 +210,7 @@ TEST_F(TestVp9Impl, DecodedColorSpaceEqualsEncodedColorSpace) {
|
||||
// Encoded frame with explicit color space information.
|
||||
ColorSpace color_space = CreateTestColorSpace(/*with_hdr_metadata=*/true);
|
||||
encoded_frame.SetColorSpace(color_space);
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||
decoder_->Decode(encoded_frame, false, nullptr, 0));
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, false, 0));
|
||||
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
|
||||
ASSERT_TRUE(decoded_frame);
|
||||
ASSERT_TRUE(decoded_frame->color_space());
|
||||
@ -228,8 +225,7 @@ TEST_F(TestVp9Impl, DecodedQpEqualsEncodedQp) {
|
||||
ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame, &codec_specific_info));
|
||||
// First frame should be a key frame.
|
||||
encoded_frame._frameType = kVideoFrameKey;
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||
decoder_->Decode(encoded_frame, false, nullptr, 0));
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, false, 0));
|
||||
std::unique_ptr<VideoFrame> decoded_frame;
|
||||
absl::optional<uint8_t> decoded_qp;
|
||||
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
|
||||
@ -1431,8 +1427,7 @@ TEST_F(TestVp9ImplProfile2, EncodeDecode) {
|
||||
ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame, &codec_specific_info));
|
||||
// First frame should be a key frame.
|
||||
encoded_frame._frameType = kVideoFrameKey;
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
||||
decoder_->Decode(encoded_frame, false, nullptr, 0));
|
||||
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, false, 0));
|
||||
std::unique_ptr<VideoFrame> decoded_frame;
|
||||
absl::optional<uint8_t> decoded_qp;
|
||||
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
|
||||
|
@ -1507,7 +1507,6 @@ int VP9DecoderImpl::InitDecode(const VideoCodec* inst, int number_of_cores) {
|
||||
|
||||
int VP9DecoderImpl::Decode(const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t /*render_time_ms*/) {
|
||||
if (!inited_) {
|
||||
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
|
||||
|
@ -184,7 +184,6 @@ class VP9DecoderImpl : public VP9Decoder {
|
||||
|
||||
int Decode(const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t /*render_time_ms*/) override;
|
||||
|
||||
int RegisterDecodeCompleteCallback(DecodedImageCallback* callback) override;
|
||||
|
@ -230,7 +230,7 @@ int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, int64_t nowMs) {
|
||||
|
||||
_nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength;
|
||||
int32_t ret = decoder_->Decode(frame.EncodedImage(), frame.MissingFrame(),
|
||||
frame.CodecSpecific(), frame.RenderTimeMs());
|
||||
frame.RenderTimeMs());
|
||||
|
||||
_callback->OnDecoderImplementationName(decoder_->ImplementationName());
|
||||
if (ret < WEBRTC_VIDEO_CODEC_OK) {
|
||||
|
@ -832,9 +832,9 @@ void SimulcastTestFixtureImpl::TestStrideEncodeDecode() {
|
||||
EncodedImage encoded_frame;
|
||||
// Only encoding one frame - so will be a key frame.
|
||||
encoder_callback.GetLastEncodedKeyFrame(&encoded_frame);
|
||||
EXPECT_EQ(0, decoder_->Decode(encoded_frame, false, NULL, 0));
|
||||
EXPECT_EQ(0, decoder_->Decode(encoded_frame, false, 0));
|
||||
encoder_callback.GetLastEncodedFrame(&encoded_frame);
|
||||
decoder_->Decode(encoded_frame, false, NULL, 0);
|
||||
decoder_->Decode(encoded_frame, false, 0);
|
||||
EXPECT_EQ(2, decoder_callback.DecodedFrames());
|
||||
}
|
||||
|
||||
@ -875,7 +875,7 @@ void SimulcastTestFixtureImpl::TestDecodeWidthHeightSet() {
|
||||
EXPECT_EQ(decodedImage.width(), kDefaultWidth / 4);
|
||||
EXPECT_EQ(decodedImage.height(), kDefaultHeight / 4);
|
||||
}));
|
||||
EXPECT_EQ(0, decoder_->Decode(encoded_frame[0], false, NULL, 0));
|
||||
EXPECT_EQ(0, decoder_->Decode(encoded_frame[0], false, 0));
|
||||
|
||||
EXPECT_CALL(decoder_callback, Decoded(_, _, _))
|
||||
.WillOnce(testing::Invoke([](VideoFrame& decodedImage,
|
||||
@ -884,7 +884,7 @@ void SimulcastTestFixtureImpl::TestDecodeWidthHeightSet() {
|
||||
EXPECT_EQ(decodedImage.width(), kDefaultWidth / 2);
|
||||
EXPECT_EQ(decodedImage.height(), kDefaultHeight / 2);
|
||||
}));
|
||||
EXPECT_EQ(0, decoder_->Decode(encoded_frame[1], false, NULL, 0));
|
||||
EXPECT_EQ(0, decoder_->Decode(encoded_frame[1], false, 0));
|
||||
|
||||
EXPECT_CALL(decoder_callback, Decoded(_, _, _))
|
||||
.WillOnce(testing::Invoke([](VideoFrame& decodedImage,
|
||||
@ -893,7 +893,7 @@ void SimulcastTestFixtureImpl::TestDecodeWidthHeightSet() {
|
||||
EXPECT_EQ(decodedImage.width(), kDefaultWidth);
|
||||
EXPECT_EQ(decodedImage.height(), kDefaultHeight);
|
||||
}));
|
||||
EXPECT_EQ(0, decoder_->Decode(encoded_frame[2], false, NULL, 0));
|
||||
EXPECT_EQ(0, decoder_->Decode(encoded_frame[2], false, 0));
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
@ -75,7 +75,7 @@ class TestVideoReceiver : public ::testing::Test {
|
||||
++header->header.sequenceNumber;
|
||||
}
|
||||
receiver_.Process();
|
||||
EXPECT_CALL(decoder_, Decode(_, _, _, _)).Times(0);
|
||||
EXPECT_CALL(decoder_, Decode(_, _, _)).Times(0);
|
||||
EXPECT_EQ(VCM_FRAME_NOT_READY, receiver_.Decode(kMaxWaitTimeMs));
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ class TestVideoReceiver : public ::testing::Test {
|
||||
EXPECT_CALL(packet_request_callback_, ResendPackets(_, _)).Times(0);
|
||||
|
||||
receiver_.Process();
|
||||
EXPECT_CALL(decoder_, Decode(_, _, _, _)).Times(1);
|
||||
EXPECT_CALL(decoder_, Decode(_, _, _)).Times(1);
|
||||
EXPECT_EQ(0, receiver_.Decode(kMaxWaitTimeMs));
|
||||
}
|
||||
|
||||
|
@ -71,20 +71,16 @@ TEST(ObjCVideoDecoderFactoryTest, DecodeReturnsOKOnSuccess) {
|
||||
std::unique_ptr<webrtc::VideoDecoder> decoder = GetObjCDecoder(CreateOKDecoderFactory());
|
||||
|
||||
webrtc::EncodedImage encoded_image;
|
||||
webrtc::CodecSpecificInfo info;
|
||||
info.codecType = webrtc::kVideoCodecH264;
|
||||
|
||||
EXPECT_EQ(decoder->Decode(encoded_image, false, &info, 0), WEBRTC_VIDEO_CODEC_OK);
|
||||
EXPECT_EQ(decoder->Decode(encoded_image, false, 0), WEBRTC_VIDEO_CODEC_OK);
|
||||
}
|
||||
|
||||
TEST(ObjCVideoDecoderFactoryTest, DecodeReturnsErrorOnFail) {
|
||||
std::unique_ptr<webrtc::VideoDecoder> decoder = GetObjCDecoder(CreateErrorDecoderFactory());
|
||||
|
||||
webrtc::EncodedImage encoded_image;
|
||||
webrtc::CodecSpecificInfo info;
|
||||
info.codecType = webrtc::kVideoCodecH264;
|
||||
|
||||
EXPECT_EQ(decoder->Decode(encoded_image, false, &info, 0), WEBRTC_VIDEO_CODEC_ERROR);
|
||||
EXPECT_EQ(decoder->Decode(encoded_image, false, 0), WEBRTC_VIDEO_CODEC_ERROR);
|
||||
}
|
||||
|
||||
TEST(ObjCVideoDecoderFactoryTest, ReleaseDecodeReturnsOKOnSuccess) {
|
||||
|
@ -39,7 +39,6 @@ int32_t FakeDecoder::InitDecode(const VideoCodec* config,
|
||||
|
||||
int32_t FakeDecoder::Decode(const EncodedImage& input,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) {
|
||||
if (input._encodedWidth > 0 && input._encodedHeight > 0) {
|
||||
width_ = input._encodedWidth;
|
||||
@ -77,7 +76,6 @@ const char* FakeDecoder::ImplementationName() const {
|
||||
|
||||
int32_t FakeH264Decoder::Decode(const EncodedImage& input,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) {
|
||||
uint8_t value = 0;
|
||||
for (size_t i = 0; i < input.size(); ++i) {
|
||||
@ -93,8 +91,7 @@ int32_t FakeH264Decoder::Decode(const EncodedImage& input,
|
||||
}
|
||||
++value;
|
||||
}
|
||||
return FakeDecoder::Decode(input, missing_frames, codec_specific_info,
|
||||
render_time_ms);
|
||||
return FakeDecoder::Decode(input, missing_frames, render_time_ms);
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
@ -31,7 +31,6 @@ class FakeDecoder : public VideoDecoder {
|
||||
|
||||
int32_t Decode(const EncodedImage& input,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) override;
|
||||
|
||||
int32_t RegisterDecodeCompleteCallback(
|
||||
@ -55,7 +54,6 @@ class FakeH264Decoder : public FakeDecoder {
|
||||
|
||||
int32_t Decode(const EncodedImage& input,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) override;
|
||||
};
|
||||
|
||||
|
@ -46,7 +46,6 @@ int32_t FakeVp8Decoder::InitDecode(const VideoCodec* config,
|
||||
|
||||
int32_t FakeVp8Decoder::Decode(const EncodedImage& input,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) {
|
||||
constexpr size_t kMinPayLoadHeaderLength = 10;
|
||||
if (input.size() < kMinPayLoadHeaderLength) {
|
||||
|
@ -31,7 +31,6 @@ class FakeVp8Decoder : public VideoDecoder {
|
||||
|
||||
int32_t Decode(const EncodedImage& input,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) override;
|
||||
|
||||
int32_t RegisterDecodeCompleteCallback(
|
||||
|
@ -53,7 +53,6 @@ int32_t QualityAnalyzingVideoDecoder::InitDecode(
|
||||
int32_t QualityAnalyzingVideoDecoder::Decode(
|
||||
const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) {
|
||||
// Image extractor extracts id from provided EncodedImage and also returns
|
||||
// the image with the original buffer. Buffer can be modified in place, so
|
||||
@ -95,8 +94,8 @@ int32_t QualityAnalyzingVideoDecoder::Decode(
|
||||
// the map only after |delegate_| Decode method will be invoked. Image will be
|
||||
// removed inside DecodedImageCallback, which can be done on separate thread.
|
||||
analyzer_->OnFrameReceived(out.id, *origin_image);
|
||||
int32_t result = delegate_->Decode(*origin_image, missing_frames,
|
||||
codec_specific_info, render_time_ms);
|
||||
int32_t result =
|
||||
delegate_->Decode(*origin_image, missing_frames, render_time_ms);
|
||||
if (result != WEBRTC_VIDEO_CODEC_OK) {
|
||||
// If delegate decoder failed, then cleanup data for this image.
|
||||
{
|
||||
|
@ -63,7 +63,6 @@ class QualityAnalyzingVideoDecoder : public VideoDecoder {
|
||||
int32_t number_of_cores) override;
|
||||
int32_t Decode(const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) override;
|
||||
int32_t RegisterDecodeCompleteCallback(
|
||||
DecodedImageCallback* callback) override;
|
||||
|
@ -50,10 +50,8 @@ class VideoDecoderProxyFactory final : public VideoDecoderFactory {
|
||||
private:
|
||||
int32_t Decode(const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) override {
|
||||
return decoder_->Decode(input_image, missing_frames, codec_specific_info,
|
||||
render_time_ms);
|
||||
return decoder_->Decode(input_image, missing_frames, render_time_ms);
|
||||
}
|
||||
int32_t InitDecode(const VideoCodec* config,
|
||||
int32_t number_of_cores) override {
|
||||
|
@ -26,17 +26,16 @@ FrameDumpingDecoder::~FrameDumpingDecoder() = default;
|
||||
|
||||
int32_t FrameDumpingDecoder::InitDecode(const VideoCodec* codec_settings,
|
||||
int32_t number_of_cores) {
|
||||
codec_type_ = codec_settings->codecType;
|
||||
return decoder_->InitDecode(codec_settings, number_of_cores);
|
||||
}
|
||||
|
||||
int32_t FrameDumpingDecoder::Decode(
|
||||
const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) {
|
||||
int32_t ret = decoder_->Decode(input_image, missing_frames,
|
||||
codec_specific_info, render_time_ms);
|
||||
writer_->WriteFrame(input_image, codec_specific_info->codecType);
|
||||
int32_t ret = decoder_->Decode(input_image, missing_frames, render_time_ms);
|
||||
writer_->WriteFrame(input_image, codec_type_);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ class FrameDumpingDecoder : public VideoDecoder {
|
||||
int32_t number_of_cores) override;
|
||||
int32_t Decode(const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) override;
|
||||
int32_t RegisterDecodeCompleteCallback(
|
||||
DecodedImageCallback* callback) override;
|
||||
@ -42,6 +41,7 @@ class FrameDumpingDecoder : public VideoDecoder {
|
||||
|
||||
private:
|
||||
std::unique_ptr<VideoDecoder> decoder_;
|
||||
VideoCodecType codec_type_ = VideoCodecType::kVideoCodecGeneric;
|
||||
std::unique_ptr<IvfFileWriter> writer_;
|
||||
};
|
||||
|
||||
|
@ -102,7 +102,6 @@ class NullVideoDecoder : public webrtc::VideoDecoder {
|
||||
|
||||
int32_t Decode(const webrtc::EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
const webrtc::CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms) override {
|
||||
RTC_LOG(LS_ERROR) << "The NullVideoDecoder doesn't support decoding.";
|
||||
return WEBRTC_VIDEO_CODEC_OK;
|
||||
|
@ -50,10 +50,9 @@ class MockVideoDecoder : public VideoDecoder {
|
||||
public:
|
||||
MOCK_METHOD2(InitDecode,
|
||||
int32_t(const VideoCodec* config, int32_t number_of_cores));
|
||||
MOCK_METHOD4(Decode,
|
||||
MOCK_METHOD3(Decode,
|
||||
int32_t(const EncodedImage& input,
|
||||
bool missing_frames,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
int64_t render_time_ms));
|
||||
MOCK_METHOD1(RegisterDecodeCompleteCallback,
|
||||
int32_t(DecodedImageCallback* callback));
|
||||
@ -141,7 +140,7 @@ TEST_F(VideoReceiveStreamTest, CreateFrameFromH264FmtpSpropAndIdr) {
|
||||
}));
|
||||
EXPECT_CALL(mock_h264_video_decoder_, RegisterDecodeCompleteCallback(_));
|
||||
video_receive_stream_->Start();
|
||||
EXPECT_CALL(mock_h264_video_decoder_, Decode(_, false, _, _));
|
||||
EXPECT_CALL(mock_h264_video_decoder_, Decode(_, false, _));
|
||||
RtpPacketReceived parsed_packet;
|
||||
ASSERT_TRUE(parsed_packet.Parse(rtppacket.data(), rtppacket.size()));
|
||||
rtp_stream_receiver_controller_.OnRtpPacket(parsed_packet);
|
||||
|
Reference in New Issue
Block a user