Revert "Delete CodecSpecificInfo argument from VideoDecoder::Decode"

This reverts commit 39d3a7de02d63894d12e7332322e1d80cd7c0d40.

Reason for revert: This change broke an internal project

Original change's description:
> 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}

TBR=brandtr@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org,kthelgason@webrtc.org,sprang@webrtc.org

Change-Id: I2c730cc1834a3b23203fae3d7881f0890802c37b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10379
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/126320
Reviewed-by: Jeroen de Borst <jeroendb@webrtc.org>
Commit-Queue: Jeroen de Borst <jeroendb@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27026}
This commit is contained in:
Jeroen de Borst
2019-03-07 19:40:07 +00:00
committed by Commit Bot
parent 7e70291bb7
commit 2c7b9825bc
35 changed files with 105 additions and 72 deletions

View File

@ -41,9 +41,10 @@ class MockVideoDecoder : public VideoDecoder {
MOCK_METHOD2(InitDecode,
int32_t(const VideoCodec* codecSettings, int32_t numberOfCores));
MOCK_METHOD3(Decode,
MOCK_METHOD4(Decode,
int32_t(const EncodedImage& inputImage,
bool missingFrames,
const CodecSpecificInfo* codecSpecificInfo,
int64_t renderTimeMs));
MOCK_METHOD1(RegisterDecodeCompleteCallback,
int32_t(DecodedImageCallback* callback));

View File

@ -49,6 +49,7 @@ 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_;
@ -88,7 +89,7 @@ TEST_F(VideoDecoderSoftwareFallbackWrapperTest, InitializesDecoder) {
EncodedImage encoded_image;
encoded_image._frameType = kVideoFrameKey;
fallback_wrapper_->Decode(encoded_image, false, -1);
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
EXPECT_EQ(1, fake_decoder_->init_decode_count_)
<< "Initialized decoder should not be reinitialized.";
EXPECT_EQ(1, fake_decoder_->decode_count_);
@ -103,7 +104,7 @@ TEST_F(VideoDecoderSoftwareFallbackWrapperTest,
EncodedImage encoded_image;
encoded_image._frameType = kVideoFrameKey;
fallback_wrapper_->Decode(encoded_image, false, -1);
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
EXPECT_EQ(1, fake_decoder_->init_decode_count_)
<< "Should not have attempted reinitializing the fallback decoder on "
"keyframe.";
@ -119,12 +120,12 @@ TEST_F(VideoDecoderSoftwareFallbackWrapperTest, IsSoftwareFallbackSticky) {
fake_decoder_->decode_return_code_ = WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
EncodedImage encoded_image;
fallback_wrapper_->Decode(encoded_image, false, -1);
fallback_wrapper_->Decode(encoded_image, false, nullptr, -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, -1);
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
EXPECT_EQ(1, fake_decoder_->decode_count_)
<< "Decoder shouldn't be used after failure.";
@ -138,10 +139,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, -1));
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1));
EXPECT_EQ(1, fake_decoder_->decode_count_);
fallback_wrapper_->Decode(encoded_image, false, -1);
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
EXPECT_EQ(2, fake_decoder_->decode_count_)
<< "Decoder should be active even though previous decode failed.";
}
@ -152,14 +153,14 @@ TEST_F(VideoDecoderSoftwareFallbackWrapperTest, UsesHwDecoderAfterReinit) {
fake_decoder_->decode_return_code_ = WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
EncodedImage encoded_image;
fallback_wrapper_->Decode(encoded_image, false, -1);
fallback_wrapper_->Decode(encoded_image, false, nullptr, -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, -1);
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
EXPECT_EQ(2, fake_decoder_->decode_count_)
<< "Should not be using fallback after reinit.";
}
@ -173,7 +174,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, -1);
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
EXPECT_EQ(2, fake_decoder_->release_count_)
<< "Decoder should be released during fallback.";
fallback_wrapper_->Release();
@ -211,7 +212,7 @@ TEST_F(VideoDecoderSoftwareFallbackWrapperTest,
fake_decoder_->decode_return_code_ = WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
EncodedImage encoded_image;
fallback_wrapper_->Decode(encoded_image, false, -1);
fallback_wrapper_->Decode(encoded_image, false, nullptr, -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)",
@ -242,7 +243,7 @@ TEST_F(ForcedSoftwareDecoderFallbackTest, UsesForcedFallback) {
EncodedImage encoded_image;
encoded_image._frameType = kVideoFrameKey;
fallback_wrapper_->Decode(encoded_image, false, -1);
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
EXPECT_EQ(1, sw_fallback_decoder_->init_decode_count_);
EXPECT_EQ(1, sw_fallback_decoder_->decode_count_);

View File

@ -33,19 +33,6 @@ 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;
}

View File

@ -55,16 +55,10 @@ 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);
int64_t render_time_ms) = 0;
virtual int32_t RegisterDecodeCompleteCallback(
DecodedImageCallback* callback) = 0;

View File

@ -40,6 +40,7 @@ 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(
@ -146,6 +147,7 @@ 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_) {
@ -153,7 +155,8 @@ 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, render_time_ms);
ret = hw_decoder_->Decode(input_image, missing_frames,
codec_specific_info, render_time_ms);
if (ret != WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE) {
return ret;
}
@ -169,7 +172,7 @@ int32_t VideoDecoderSoftwareFallbackWrapper::Decode(
}
case DecoderType::kFallback:
return fallback_decoder_->Decode(input_image, missing_frames,
render_time_ms);
codec_specific_info, render_time_ms);
default:
RTC_NOTREACHED();
return WEBRTC_VIDEO_CODEC_ERROR;

View File

@ -57,6 +57,7 @@ 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;

View File

@ -46,6 +46,7 @@ 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;

View File

@ -228,6 +228,7 @@ 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();
@ -244,6 +245,11 @@ 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.

View File

@ -49,6 +49,7 @@ 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;

View File

@ -71,7 +71,8 @@ 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, 0));
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->Decode(encoded_frame, false, nullptr, 0));
std::unique_ptr<VideoFrame> decoded_frame;
absl::optional<uint8_t> decoded_qp;
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
@ -97,7 +98,8 @@ 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, 0));
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->Decode(encoded_frame, false, nullptr, 0));
std::unique_ptr<VideoFrame> decoded_frame;
absl::optional<uint8_t> decoded_qp;
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
@ -138,7 +140,8 @@ 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, 0));
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->Decode(encoded_frame, false, nullptr, 0));
std::unique_ptr<VideoFrame> decoded_frame;
absl::optional<uint8_t> decoded_qp;
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));

View File

@ -35,6 +35,7 @@ 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;

View File

@ -130,6 +130,7 @@ 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);
@ -153,7 +154,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,
image.image_components[i].encoded_image, missing_frames, nullptr,
render_time_ms);
if (rv != WEBRTC_VIDEO_CODEC_OK)
return rv;

View File

@ -225,7 +225,8 @@ 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, -1));
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->Decode(encoded_frame, false, &codec_specific_info, -1));
std::unique_ptr<VideoFrame> decoded_frame;
absl::optional<uint8_t> decoded_qp;
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
@ -242,7 +243,8 @@ 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, 0));
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->Decode(encoded_frame, false, nullptr, 0));
std::unique_ptr<VideoFrame> decoded_frame;
absl::optional<uint8_t> decoded_qp;
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));

View File

@ -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, 0);
decoders_->at(spatial_idx)->Decode(encoded_image, false, nullptr, 0);
}
const webrtc::EncodedImage* VideoProcessor::BuildAndStoreSuperframe(

View File

@ -153,6 +153,7 @@ 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;

View File

@ -34,6 +34,7 @@ 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;

View File

@ -210,7 +210,8 @@ 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, -1));
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->Decode(encoded_frame, false, nullptr, -1));
std::unique_ptr<VideoFrame> decoded_frame;
absl::optional<uint8_t> decoded_qp;
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
@ -229,7 +230,8 @@ 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, -1));
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->Decode(encoded_frame, false, nullptr, -1));
std::unique_ptr<VideoFrame> decoded_frame;
absl::optional<uint8_t> decoded_qp;
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
@ -323,7 +325,8 @@ 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, -1));
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->Decode(encoded_frame, false, nullptr, -1));
std::unique_ptr<VideoFrame> decoded_frame;
absl::optional<uint8_t> decoded_qp;
@ -349,15 +352,16 @@ 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, -1));
decoder_->Decode(encoded_frame, false, nullptr, -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, -1));
decoder_->Decode(encoded_frame, false, nullptr, -1));
// Now setting a key frame.
encoded_frame._frameType = kVideoFrameKey;
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encoded_frame, false, -1));
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->Decode(encoded_frame, false, nullptr, -1));
std::unique_ptr<VideoFrame> decoded_frame;
absl::optional<uint8_t> decoded_qp;
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));

View File

@ -128,7 +128,8 @@ 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, 0));
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->Decode(encoded_frame, false, nullptr, 0));
std::unique_ptr<VideoFrame> decoded_frame;
absl::optional<uint8_t> decoded_qp;
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
@ -197,7 +198,8 @@ 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, 0));
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->Decode(encoded_frame, false, nullptr, 0));
std::unique_ptr<VideoFrame> decoded_frame;
absl::optional<uint8_t> decoded_qp;
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
@ -210,7 +212,8 @@ 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, 0));
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->Decode(encoded_frame, false, nullptr, 0));
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
ASSERT_TRUE(decoded_frame);
ASSERT_TRUE(decoded_frame->color_space());
@ -225,7 +228,8 @@ 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, 0));
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->Decode(encoded_frame, false, nullptr, 0));
std::unique_ptr<VideoFrame> decoded_frame;
absl::optional<uint8_t> decoded_qp;
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));
@ -1427,7 +1431,8 @@ 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, 0));
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->Decode(encoded_frame, false, nullptr, 0));
std::unique_ptr<VideoFrame> decoded_frame;
absl::optional<uint8_t> decoded_qp;
ASSERT_TRUE(WaitForDecodedFrame(&decoded_frame, &decoded_qp));

View File

@ -1507,6 +1507,7 @@ 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;

View File

@ -184,6 +184,7 @@ 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;

View File

@ -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.RenderTimeMs());
frame.CodecSpecific(), frame.RenderTimeMs());
_callback->OnDecoderImplementationName(decoder_->ImplementationName());
if (ret < WEBRTC_VIDEO_CODEC_OK) {

View File

@ -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, 0));
EXPECT_EQ(0, decoder_->Decode(encoded_frame, false, NULL, 0));
encoder_callback.GetLastEncodedFrame(&encoded_frame);
decoder_->Decode(encoded_frame, false, 0);
decoder_->Decode(encoded_frame, false, NULL, 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, 0));
EXPECT_EQ(0, decoder_->Decode(encoded_frame[0], false, NULL, 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, 0));
EXPECT_EQ(0, decoder_->Decode(encoded_frame[1], false, NULL, 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, 0));
EXPECT_EQ(0, decoder_->Decode(encoded_frame[2], false, NULL, 0));
}
} // namespace test

View File

@ -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));
}

View File

@ -71,16 +71,20 @@ 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, 0), WEBRTC_VIDEO_CODEC_OK);
EXPECT_EQ(decoder->Decode(encoded_image, false, &info, 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, 0), WEBRTC_VIDEO_CODEC_ERROR);
EXPECT_EQ(decoder->Decode(encoded_image, false, &info, 0), WEBRTC_VIDEO_CODEC_ERROR);
}
TEST(ObjCVideoDecoderFactoryTest, ReleaseDecodeReturnsOKOnSuccess) {

View File

@ -39,6 +39,7 @@ 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;
@ -76,6 +77,7 @@ 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) {
@ -91,7 +93,8 @@ int32_t FakeH264Decoder::Decode(const EncodedImage& input,
}
++value;
}
return FakeDecoder::Decode(input, missing_frames, render_time_ms);
return FakeDecoder::Decode(input, missing_frames, codec_specific_info,
render_time_ms);
}
} // namespace test

View File

@ -31,6 +31,7 @@ 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(
@ -54,6 +55,7 @@ class FakeH264Decoder : public FakeDecoder {
int32_t Decode(const EncodedImage& input,
bool missing_frames,
const CodecSpecificInfo* codec_specific_info,
int64_t render_time_ms) override;
};

View File

@ -46,6 +46,7 @@ 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) {

View File

@ -31,6 +31,7 @@ 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(

View File

@ -53,6 +53,7 @@ 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
@ -94,8 +95,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, render_time_ms);
int32_t result = delegate_->Decode(*origin_image, missing_frames,
codec_specific_info, render_time_ms);
if (result != WEBRTC_VIDEO_CODEC_OK) {
// If delegate decoder failed, then cleanup data for this image.
{

View File

@ -63,6 +63,7 @@ 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;

View File

@ -50,8 +50,10 @@ 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, render_time_ms);
return decoder_->Decode(input_image, missing_frames, codec_specific_info,
render_time_ms);
}
int32_t InitDecode(const VideoCodec* config,
int32_t number_of_cores) override {

View File

@ -26,16 +26,17 @@ 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, render_time_ms);
writer_->WriteFrame(input_image, codec_type_);
int32_t ret = decoder_->Decode(input_image, missing_frames,
codec_specific_info, render_time_ms);
writer_->WriteFrame(input_image, codec_specific_info->codecType);
return ret;
}

View File

@ -32,6 +32,7 @@ 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;
@ -41,7 +42,6 @@ class FrameDumpingDecoder : public VideoDecoder {
private:
std::unique_ptr<VideoDecoder> decoder_;
VideoCodecType codec_type_ = VideoCodecType::kVideoCodecGeneric;
std::unique_ptr<IvfFileWriter> writer_;
};

View File

@ -102,6 +102,7 @@ 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;

View File

@ -50,9 +50,10 @@ class MockVideoDecoder : public VideoDecoder {
public:
MOCK_METHOD2(InitDecode,
int32_t(const VideoCodec* config, int32_t number_of_cores));
MOCK_METHOD3(Decode,
MOCK_METHOD4(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));
@ -140,7 +141,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);