Tests: Move codec configure() out of VideoDecodingWrapper constructor.
This allows us to release both codecs used in SSIM when one fails to configure() or start(). Tested and confirmed that on Samsung Galaxy Z Flip 4, running all TransformationTest.java tests, tests after transform8k24() fails to start the 2nd codec: * Before this CL, all fail. * After this CL, all pass. PiperOrigin-RevId: 490461560
This commit is contained in:
parent
03f0b53cf8
commit
0a176d1f05
@ -167,6 +167,7 @@ public final class SsimHelper {
|
||||
private static final String ASSET_FILE_SCHEME = "asset:///";
|
||||
private static final int MAX_IMAGES_ALLOWED = 1;
|
||||
|
||||
private final MediaFormat mediaFormat;
|
||||
private final MediaCodec mediaCodec;
|
||||
private final MediaExtractor mediaExtractor;
|
||||
private final MediaCodec.BufferInfo bufferInfo;
|
||||
@ -178,6 +179,7 @@ public final class SsimHelper {
|
||||
private boolean hasReadEndOfInputStream;
|
||||
private boolean queuedEndOfStreamToDecoder;
|
||||
private boolean dequeuedAllDecodedFrames;
|
||||
private boolean isCodecStarted;
|
||||
private int dequeuedFramesCount;
|
||||
|
||||
/**
|
||||
@ -230,10 +232,8 @@ public final class SsimHelper {
|
||||
|
||||
String sampleMimeType = checkNotNull(mediaFormat.getString(MediaFormat.KEY_MIME));
|
||||
mediaFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, MEDIA_CODEC_COLOR_SPACE);
|
||||
this.mediaFormat = mediaFormat;
|
||||
mediaCodec = MediaCodec.createDecoderByType(sampleMimeType);
|
||||
mediaCodec.configure(
|
||||
mediaFormat, imageReader.getSurface(), /* crypto= */ null, /* flags= */ 0);
|
||||
mediaCodec.start();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -243,6 +243,12 @@ public final class SsimHelper {
|
||||
*/
|
||||
@Nullable
|
||||
public Image runUntilComparisonFrameOrEnded() throws InterruptedException {
|
||||
if (!isCodecStarted) {
|
||||
mediaCodec.configure(
|
||||
mediaFormat, imageReader.getSurface(), /* crypto= */ null, /* flags= */ 0);
|
||||
mediaCodec.start();
|
||||
isCodecStarted = true;
|
||||
}
|
||||
while (!hasEnded() && !isCurrentFrameComparisonFrame) {
|
||||
while (dequeueOneFrameFromDecoder()) {}
|
||||
while (queueOneFrameToDecoder()) {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user