Work around adaptation issue for Tab 4

The decoder doesn't claim to be adaptive, but if we're staying
in the same resolution we'll try and re-use the decoder anyway.
The H264 decoder can't handle this case on the Tab 4 can't deal
with this case.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=213478378
This commit is contained in:
olly 2018-09-18 10:59:20 -07:00 committed by Oliver Woodman
parent 7fe5230a7e
commit 918a43e48d

View File

@ -290,6 +290,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
private @Nullable DecoderInitializationException preferredDecoderInitializationException; private @Nullable DecoderInitializationException preferredDecoderInitializationException;
private @Nullable MediaCodecInfo codecInfo; private @Nullable MediaCodecInfo codecInfo;
private @AdaptationWorkaroundMode int codecAdaptationWorkaroundMode; private @AdaptationWorkaroundMode int codecAdaptationWorkaroundMode;
private boolean codecNeedsReconfigureWorkaround;
private boolean codecNeedsDiscardToSpsWorkaround; private boolean codecNeedsDiscardToSpsWorkaround;
private boolean codecNeedsFlushWorkaround; private boolean codecNeedsFlushWorkaround;
private boolean codecNeedsEosFlushWorkaround; private boolean codecNeedsEosFlushWorkaround;
@ -466,6 +467,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
String codecName = codecInfo.name; String codecName = codecInfo.name;
codecAdaptationWorkaroundMode = codecAdaptationWorkaroundMode(codecName); codecAdaptationWorkaroundMode = codecAdaptationWorkaroundMode(codecName);
codecNeedsReconfigureWorkaround = codecNeedsReconfigureWorkaround(codecName);
codecNeedsDiscardToSpsWorkaround = codecNeedsDiscardToSpsWorkaround(codecName, format); codecNeedsDiscardToSpsWorkaround = codecNeedsDiscardToSpsWorkaround(codecName, format);
codecNeedsFlushWorkaround = codecNeedsFlushWorkaround(codecName); codecNeedsFlushWorkaround = codecNeedsFlushWorkaround(codecName);
codecNeedsEosFlushWorkaround = codecNeedsEosFlushWorkaround(codecName); codecNeedsEosFlushWorkaround = codecNeedsEosFlushWorkaround(codecName);
@ -562,6 +564,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
codecNeedsDiscardToSpsWorkaround = false; codecNeedsDiscardToSpsWorkaround = false;
codecNeedsFlushWorkaround = false; codecNeedsFlushWorkaround = false;
codecAdaptationWorkaroundMode = ADAPTATION_WORKAROUND_MODE_NEVER; codecAdaptationWorkaroundMode = ADAPTATION_WORKAROUND_MODE_NEVER;
codecNeedsReconfigureWorkaround = false;
codecNeedsEosFlushWorkaround = false; codecNeedsEosFlushWorkaround = false;
codecNeedsMonoChannelCountWorkaround = false; codecNeedsMonoChannelCountWorkaround = false;
codecNeedsAdaptationWorkaroundBuffer = false; codecNeedsAdaptationWorkaroundBuffer = false;
@ -1060,6 +1063,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
keepingCodec = true; keepingCodec = true;
break; break;
case KEEP_CODEC_RESULT_YES_WITH_RECONFIGURATION: case KEEP_CODEC_RESULT_YES_WITH_RECONFIGURATION:
if (!codecNeedsReconfigureWorkaround) {
keepingCodec = true; keepingCodec = true;
codecReconfigured = true; codecReconfigured = true;
codecReconfigurationState = RECONFIGURATION_STATE_WRITE_PENDING; codecReconfigurationState = RECONFIGURATION_STATE_WRITE_PENDING;
@ -1068,6 +1072,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|| (codecAdaptationWorkaroundMode == ADAPTATION_WORKAROUND_MODE_SAME_RESOLUTION || (codecAdaptationWorkaroundMode == ADAPTATION_WORKAROUND_MODE_SAME_RESOLUTION
&& format.width == oldFormat.width && format.width == oldFormat.width
&& format.height == oldFormat.height); && format.height == oldFormat.height);
}
break; break;
default: default:
throw new IllegalStateException(); // Never happens. throw new IllegalStateException(); // Never happens.
@ -1501,13 +1506,13 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
/** /**
* Returns a mode that specifies when the adaptation workaround should be enabled. * Returns a mode that specifies when the adaptation workaround should be enabled.
* <p> *
* When enabled, the workaround queues and discards a blank frame with a resolution whose width * <p>When enabled, the workaround queues and discards a blank frame with a resolution whose width
* and height both equal {@link #ADAPTATION_WORKAROUND_SLICE_WIDTH_HEIGHT}, to reset the codec's * and height both equal {@link #ADAPTATION_WORKAROUND_SLICE_WIDTH_HEIGHT}, to reset the decoder's
* internal state when a format change occurs. * internal state when a format change occurs.
* <p> *
* See [Internal: b/27807182]. * <p>See [Internal: b/27807182]. See <a
* See <a href="https://github.com/google/ExoPlayer/issues/3257">GitHub issue #3257</a>. * href="https://github.com/google/ExoPlayer/issues/3257">GitHub issue #3257</a>.
* *
* @param name The name of the decoder. * @param name The name of the decoder.
* @return The mode specifying when the adaptation workaround should be enabled. * @return The mode specifying when the adaptation workaround should be enabled.
@ -1527,6 +1532,21 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
} }
} }
/**
* Returns whether the decoder is known to fail when an attempt is made to reconfigure it with a
* new format's configuration data.
*
* <p>When enabled, the workaround will always release and recreate the decoder, rather than
* attempting to reconfigure the existing instance.
*
* @param name The name of the decoder.
* @return True if the decoder is known to fail when an attempt is made to reconfigure it with a
* new format's configuration data.
*/
private static boolean codecNeedsReconfigureWorkaround(String name) {
return Util.MODEL.startsWith("SM-T230") && "OMX.MARVELL.VIDEO.HW.CODA7542DECODER".equals(name);
}
/** /**
* Returns whether the decoder is an H.264/AVC decoder known to fail if NAL units are queued * Returns whether the decoder is an H.264/AVC decoder known to fail if NAL units are queued
* before the codec specific data. * before the codec specific data.