From 2ee9415a8c949d6c7a87114cbdf99d204c349c12 Mon Sep 17 00:00:00 2001 From: Raman Budny Date: Wed, 24 Feb 2021 12:12:13 +0300 Subject: [PATCH] AndroidVideoDecoder: Ignore format updates with zero dimensions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sometimes c2.qti.vp8.decoder reports format updates with zero frame width / height right after initialization, that leads to the precondition check failure made by SurfaceTextureHelper.setTextureSize. This patch makes AndroidVideoDecoder.reformat to ignore such format updates so as to continue to use this HW decoder. It seems to be safe because this decoder singals one more format update with valid dimensions soon and continue to operate in normal mode. Bug: webrtc:12492 Change-Id: I5155166637bd2d4247d31e608d714e687e0ad1df Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/208222 Reviewed-by: Sami Kalliomäki Commit-Queue: Sami Kalliomäki Cr-Commit-Position: refs/heads/master@{#33332} --- .../java/org/webrtc/AndroidVideoDecoder.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sdk/android/src/java/org/webrtc/AndroidVideoDecoder.java b/sdk/android/src/java/org/webrtc/AndroidVideoDecoder.java index 35a0f0e011..aa68e9d832 100644 --- a/sdk/android/src/java/org/webrtc/AndroidVideoDecoder.java +++ b/sdk/android/src/java/org/webrtc/AndroidVideoDecoder.java @@ -585,13 +585,21 @@ class AndroidVideoDecoder implements VideoDecoder, VideoSink { } // Compare to existing width, height, and save values under the dimension lock. synchronized (dimensionLock) { - if (hasDecodedFirstFrame && (width != newWidth || height != newHeight)) { - stopOnOutputThread(new RuntimeException("Unexpected size change. Configured " + width + "*" - + height + ". New " + newWidth + "*" + newHeight)); - return; + if (newWidth != width || newHeight != height) { + if (hasDecodedFirstFrame) { + stopOnOutputThread(new RuntimeException("Unexpected size change. " + + "Configured " + width + "*" + height + ". " + + "New " + newWidth + "*" + newHeight)); + return; + } else if (newWidth <= 0 || newHeight <= 0) { + Logging.w(TAG, + "Unexpected format dimensions. Configured " + width + "*" + height + ". " + + "New " + newWidth + "*" + newHeight + ". Skip it"); + return; + } + width = newWidth; + height = newHeight; } - width = newWidth; - height = newHeight; } // Note: texture mode ignores colorFormat. Hence, if the texture helper is non-null, skip