Commit 6ca67af4 by huangdarwin Committed by Ian Baker

Tests: Set SSIM decoder KEY_PRIORITY to 1.

This reduces the priority to best effort (from the default that seems to be best effort), and allows us to run SSIM even on 8k24fps video. Without this CL,
start()'ing a second codec may result in a MediaCodec.CodecException.

Tested to confirm that transformation8k24():
* fails deterministically without this CL, or with KEY_PRIORITY set to 0.
* succeeds deterministically after this CL (~18s on Samsung Z Fold 4)

PiperOrigin-RevId: 490570416
parent 87e98b48
...@@ -21,6 +21,7 @@ import static com.google.android.exoplayer2.util.MimeTypes.VIDEO_H264; ...@@ -21,6 +21,7 @@ import static com.google.android.exoplayer2.util.MimeTypes.VIDEO_H264;
import static com.google.android.exoplayer2.util.MimeTypes.VIDEO_H265; import static com.google.android.exoplayer2.util.MimeTypes.VIDEO_H265;
import android.content.Context; import android.content.Context;
import android.media.MediaFormat;
import android.os.Build; import android.os.Build;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
...@@ -43,6 +44,13 @@ import org.json.JSONObject; ...@@ -43,6 +44,13 @@ import org.json.JSONObject;
public final class AndroidTestUtil { public final class AndroidTestUtil {
private static final String TAG = "AndroidTestUtil"; private static final String TAG = "AndroidTestUtil";
/** A realtime {@linkplain MediaFormat#KEY_PRIORITY encoder priority}. */
public static final int MEDIA_CODEC_PRIORITY_REALTIME = 0;
/**
* A non-realtime (as fast as possible) {@linkplain MediaFormat#KEY_PRIORITY encoder priority}.
*/
public static final int MEDIA_CODEC_PRIORITY_NON_REALTIME = 1;
// Format values are sourced from `mediainfo` command. // Format values are sourced from `mediainfo` command.
public static final String MP4_ASSET_URI_STRING = "asset:///media/mp4/sample.mp4"; public static final String MP4_ASSET_URI_STRING = "asset:///media/mp4/sample.mp4";
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.transformer; package com.google.android.exoplayer2.transformer;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MEDIA_CODEC_PRIORITY_NON_REALTIME;
import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import static com.google.android.exoplayer2.util.Assertions.checkState; import static com.google.android.exoplayer2.util.Assertions.checkState;
import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull; import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
...@@ -232,6 +233,7 @@ public final class SsimHelper { ...@@ -232,6 +233,7 @@ public final class SsimHelper {
String sampleMimeType = checkNotNull(mediaFormat.getString(MediaFormat.KEY_MIME)); String sampleMimeType = checkNotNull(mediaFormat.getString(MediaFormat.KEY_MIME));
mediaFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, MEDIA_CODEC_COLOR_SPACE); mediaFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, MEDIA_CODEC_COLOR_SPACE);
mediaFormat.setInteger(MediaFormat.KEY_PRIORITY, MEDIA_CODEC_PRIORITY_NON_REALTIME);
this.mediaFormat = mediaFormat; this.mediaFormat = mediaFormat;
mediaCodec = MediaCodec.createDecoderByType(sampleMimeType); mediaCodec = MediaCodec.createDecoderByType(sampleMimeType);
} }
......
...@@ -16,11 +16,12 @@ ...@@ -16,11 +16,12 @@
package com.google.android.exoplayer2.transformer.mh.analysis; package com.google.android.exoplayer2.transformer.mh.analysis;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MEDIA_CODEC_PRIORITY_NON_REALTIME;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MEDIA_CODEC_PRIORITY_REALTIME;
import static com.google.android.exoplayer2.transformer.AndroidTestUtil.recordTestSkipped; import static com.google.android.exoplayer2.transformer.AndroidTestUtil.recordTestSkipped;
import static com.google.android.exoplayer2.util.Assertions.checkNotNull; import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import android.content.Context; import android.content.Context;
import android.media.MediaFormat;
import android.net.Uri; import android.net.Uri;
import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider;
import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.MediaItem;
...@@ -44,13 +45,6 @@ import org.junit.runners.Parameterized.Parameters; ...@@ -44,13 +45,6 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class EncoderPerformanceAnalysisTest { public class EncoderPerformanceAnalysisTest {
/** A realtime {@linkplain MediaFormat#KEY_PRIORITY encoder priority}. */
private static final int MEDIA_CODEC_PRIORITY_REALTIME = 0;
/**
* A non-realtime (as fast as possible) {@linkplain MediaFormat#KEY_PRIORITY encoder priority}.
*/
private static final int MEDIA_CODEC_PRIORITY_NON_REALTIME = 1;
private static final ImmutableList<String> INPUT_FILES = private static final ImmutableList<String> INPUT_FILES =
ImmutableList.of( ImmutableList.of(
AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_320W_240H_15S_URI_STRING, AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_320W_240H_15S_URI_STRING,
......
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 sign in to comment