Commit 1db057d3 authored by Emircan Uysaler's avatar Emircan Uysaler Committed by Commit Bot

Fallback to SW decoder after receiving frames without size set

Bug: 900718
Change-Id: Iade6c516120ced7c64991cecc5c1bfef7740d036
Reviewed-on: https://chromium-review.googlesource.com/c/1311694Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Commit-Queue: Emircan Uysaler <emircan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604956}
parent b2457b26
...@@ -233,9 +233,15 @@ int32_t RTCVideoDecoder::Decode( ...@@ -233,9 +233,15 @@ int32_t RTCVideoDecoder::Decode(
// TODO(wuchengli): VDA should handle it. Remove this when // TODO(wuchengli): VDA should handle it. Remove this when
// http://crosbug.com/p/21913 is fixed. // http://crosbug.com/p/21913 is fixed.
// If we're are in an error condition, increase the counter. DCHECK(new_frame_size.IsEmpty());
vda_error_counter_ += vda_error_counter_ ? 1 : 0; // Increase the error counter, if we are already in an error state. Also,
// increase the counter if we keep receiving keyframes without size set.
vda_error_counter_ +=
vda_error_counter_ || input_image._frameType == webrtc::kVideoFrameKey
? 1
: 0;
if (ShouldFallbackToSoftwareDecode())
return WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
DVLOG(1) << "The first frame should have resolution. Drop this."; DVLOG(1) << "The first frame should have resolution. Drop this.";
return WEBRTC_VIDEO_CODEC_ERROR; return WEBRTC_VIDEO_CODEC_ERROR;
} }
......
...@@ -114,6 +114,8 @@ class CONTENT_EXPORT RTCVideoDecoder ...@@ -114,6 +114,8 @@ class CONTENT_EXPORT RTCVideoDecoder
GetVDAErrorCounterForNotifyError); GetVDAErrorCounterForNotifyError);
FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest,
GetVDAErrorCounterForRunningOutOfPendingBuffers); GetVDAErrorCounterForRunningOutOfPendingBuffers);
FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest,
GetVDAErrorCounterForSendingFramesWithoutSize);
RTCVideoDecoder(webrtc::VideoCodecType type, RTCVideoDecoder(webrtc::VideoCodecType type,
media::GpuVideoAcceleratorFactories* factories); media::GpuVideoAcceleratorFactories* factories);
......
...@@ -416,6 +416,30 @@ TEST_P(RTCVideoDecoderTest, GetVDAErrorCounterForRunningOutOfPendingBuffers) { ...@@ -416,6 +416,30 @@ TEST_P(RTCVideoDecoderTest, GetVDAErrorCounterForRunningOutOfPendingBuffers) {
ASSERT_TRUE(false); ASSERT_TRUE(false);
} }
// Tests/Verifies that |rtc_decoder_| increases its error counter when it keeps
// getting frames with no size set.
TEST_P(RTCVideoDecoderTest, GetVDAErrorCounterForSendingFramesWithoutSize) {
const webrtc::VideoCodecType codec_type = GetParam();
CreateDecoder(codec_type);
Initialize();
webrtc::EncodedImage input_image;
uint8_t buffer[1];
input_image._buffer = buffer;
input_image._completeFrame = true;
input_image._encodedWidth = 0;
input_image._encodedHeight = 0;
input_image._frameType = webrtc::kVideoFrameKey;
input_image._length = sizeof(buffer);
const int kNumDecodeRequests = 3;
for (int i = 0; i < kNumDecodeRequests; i++) {
const int32_t result = rtc_decoder_->Decode(input_image, false, nullptr, 0);
RunUntilIdle();
EXPECT_EQ(WEBRTC_VIDEO_CODEC_ERROR, result);
EXPECT_EQ(i + 1, rtc_decoder_->GetVDAErrorCounterForTesting());
}
}
TEST_P(RTCVideoDecoderTest, Reinitialize) { TEST_P(RTCVideoDecoderTest, Reinitialize) {
const webrtc::VideoCodecType codec_type = GetParam(); const webrtc::VideoCodecType codec_type = GetParam();
CreateDecoder(codec_type); CreateDecoder(codec_type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment