Commit 7d45b9d8 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 d74eb750
......@@ -21,6 +21,7 @@ import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.common.util.Assertions.checkState;
import android.content.Context;
import android.media.MediaFormat;
import android.os.Build;
import androidx.annotation.Nullable;
import androidx.media3.common.C;
......@@ -43,6 +44,13 @@ import org.json.JSONObject;
public final class 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.
public static final String MP4_ASSET_URI_STRING = "asset:///media/mp4/sample.mp4";
......
......@@ -19,6 +19,7 @@ package androidx.media3.transformer;
import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.common.util.Assertions.checkState;
import static androidx.media3.common.util.Assertions.checkStateNotNull;
import static androidx.media3.transformer.AndroidTestUtil.MEDIA_CODEC_PRIORITY_NON_REALTIME;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
......@@ -232,6 +233,7 @@ public final class SsimHelper {
String sampleMimeType = checkNotNull(mediaFormat.getString(MediaFormat.KEY_MIME));
mediaFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, MEDIA_CODEC_COLOR_SPACE);
mediaFormat.setInteger(MediaFormat.KEY_PRIORITY, MEDIA_CODEC_PRIORITY_NON_REALTIME);
this.mediaFormat = mediaFormat;
mediaCodec = MediaCodec.createDecoderByType(sampleMimeType);
}
......
......@@ -17,10 +17,11 @@
package androidx.media3.transformer.mh.analysis;
import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.transformer.AndroidTestUtil.MEDIA_CODEC_PRIORITY_NON_REALTIME;
import static androidx.media3.transformer.AndroidTestUtil.MEDIA_CODEC_PRIORITY_REALTIME;
import static androidx.media3.transformer.AndroidTestUtil.recordTestSkipped;
import android.content.Context;
import android.media.MediaFormat;
import android.net.Uri;
import androidx.media3.common.MediaItem;
import androidx.media3.common.util.Util;
......@@ -44,13 +45,6 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
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 =
ImmutableList.of(
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