Merge "VideoDecoderPerfTest: Stopped using resources in apk" am: 53884bf0f7
Original change: https://android-review.googlesource.com/c/platform/cts/+/1426834
Change-Id: Ia6c8701bdc018c10ddbc3d98f144a1ebaf36f26f
diff --git a/tests/tests/media/src/android/media/cts/VideoDecoderPerfTest.java b/tests/tests/media/src/android/media/cts/VideoDecoderPerfTest.java
index a545b09..ca0181f 100644
--- a/tests/tests/media/src/android/media/cts/VideoDecoderPerfTest.java
+++ b/tests/tests/media/src/android/media/cts/VideoDecoderPerfTest.java
@@ -16,11 +16,7 @@
package android.media.cts;
-import android.media.cts.R;
-
import android.content.Context;
-import android.content.res.AssetFileDescriptor;
-import android.content.res.Resources;
import android.media.MediaCodec;
import android.media.MediaCodecInfo.VideoCapabilities;
import android.media.MediaExtractor;
@@ -76,13 +72,12 @@
private MediaFormat mDecOutputFormat;
private int mBitrate;
- private Resources mResources;
private boolean mSkipRateChecking = false;
+ static final String mInpPrefix = WorkDir.getMediaDirString();
@Override
protected void setUp() throws Exception {
super.setUp();
- mResources = mContext.getResources();
Bundle bundle = InstrumentationRegistry.getArguments();
mSkipRateChecking = TextUtils.equals("true", bundle.getString("mts-media"));
}
@@ -123,7 +118,7 @@
return line;
}
- private void decode(String name, int resourceId, MediaFormat format) throws Exception {
+ private void decode(String name, final String resource, MediaFormat format) throws Exception {
int width = format.getInteger(MediaFormat.KEY_WIDTH);
int height = format.getInteger(MediaFormat.KEY_HEIGHT);
String mime = format.getString(MediaFormat.KEY_MIME);
@@ -142,7 +137,7 @@
Log.d(TAG, "round #" + i + ": " + name + " for " + maxTimeMs + " msecs to surface");
Surface s = getActivity().getSurfaceHolder().getSurface();
// only verify the result for decode to surface case.
- measuredFps[i] = doDecode(name, resourceId, width, height, s, i, maxTimeMs);
+ measuredFps[i] = doDecode(name, resource, width, height, s, i, maxTimeMs);
// We don't test decoding to buffer.
// Log.d(TAG, "round #" + i + " decode to buffer");
@@ -160,13 +155,11 @@
mSamplesInMemory.clear();
}
- private double doDecode(
- String name, int video, int w, int h, Surface surface, int round, long maxTimeMs)
- throws Exception {
- AssetFileDescriptor testFd = mResources.openRawResourceFd(video);
+ private double doDecode(String name, final String filename, int w, int h, Surface surface,
+ int round, long maxTimeMs) throws Exception {
+ final String video = mInpPrefix + filename;
MediaExtractor extractor = new MediaExtractor();
- extractor.setDataSource(testFd.getFileDescriptor(), testFd.getStartOffset(),
- testFd.getLength());
+ extractor.setDataSource(video);
extractor.selectTrack(0);
int trackIndex = extractor.getSampleTrackIndex();
MediaFormat format = extractor.getTrackFormat(trackIndex);
@@ -220,7 +213,6 @@
int sampleIndex = 0;
extractor.release();
- testFd.close();
MediaCodec codec = MediaCodec.createByCodecName(name);
VideoCapabilities cap = codec.getCodecInfo().getCapabilitiesForType(mime).getVideoCapabilities();
@@ -335,21 +327,21 @@
return fps;
}
- private MediaFormat[] getVideoTrackFormats(int... resources) throws Exception {
+ private MediaFormat[] getVideoTrackFormats(String... resources) throws Exception {
MediaFormat[] formats = new MediaFormat[resources.length];
for (int i = 0; i < resources.length; ++i) {
- formats[i] = MediaUtils.getTrackFormatForResource(mContext, resources[i], "video/");
+ formats[i] = MediaUtils.getTrackFormatForResource(mInpPrefix + resources[i], "video/");
}
return formats;
}
- private void count(int[] resources, int numGoog, int numOther) throws Exception {
+ private void count(final String[] resources, int numGoog, int numOther) throws Exception {
MediaFormat[] formats = getVideoTrackFormats(resources);
MediaUtils.verifyNumCodecs(numGoog, false /* isEncoder */, true /* isGoog */, formats);
MediaUtils.verifyNumCodecs(numOther, false /* isEncoder */, false /* isGoog */, formats);
}
- private void perf(int[] resources, boolean isGoog, int ix) throws Exception {
+ private void perf(final String[] resources, boolean isGoog, int ix) throws Exception {
MediaFormat[] formats = getVideoTrackFormats(resources);
String[] decoders = MediaUtils.getDecoderNames(isGoog, formats);
String kind = isGoog ? "Google" : "non-Google";
@@ -379,8 +371,8 @@
// AVC tests
- private static final int[] sAvcMedia0320x0240 = {
- R.raw.bbb_s1_320x240_mp4_h264_mp2_800kbps_30fps_aac_lc_5ch_240kbps_44100hz,
+ private static final String[] sAvcMedia0320x0240 = {
+ "bbb_s1_320x240_mp4_h264_mp2_800kbps_30fps_aac_lc_5ch_240kbps_44100hz.mp4",
};
public void testAvcCount0320x0240() throws Exception { count(sAvcMedia0320x0240, 2, 4); }
@@ -391,8 +383,8 @@
public void testAvcOther2Perf0320x0240() throws Exception { perf(sAvcMedia0320x0240, OTHER, 2); }
public void testAvcOther3Perf0320x0240() throws Exception { perf(sAvcMedia0320x0240, OTHER, 3); }
- private static final int[] sAvcMedia0720x0480 = {
- R.raw.bbb_s1_720x480_mp4_h264_mp3_2mbps_30fps_aac_lc_5ch_320kbps_48000hz,
+ private static final String[] sAvcMedia0720x0480 = {
+ "bbb_s1_720x480_mp4_h264_mp3_2mbps_30fps_aac_lc_5ch_320kbps_48000hz.mp4",
};
public void testAvcCount0720x0480() throws Exception { count(sAvcMedia0720x0480, 2, 4); }
@@ -404,10 +396,10 @@
public void testAvcOther3Perf0720x0480() throws Exception { perf(sAvcMedia0720x0480, OTHER, 3); }
// prefer highest effective bitrate, then high profile
- private static final int[] sAvcMedia1280x0720 = {
- R.raw.bbb_s4_1280x720_mp4_h264_mp31_8mbps_30fps_aac_he_mono_40kbps_44100hz,
- R.raw.bbb_s3_1280x720_mp4_h264_hp32_8mbps_60fps_aac_he_v2_stereo_48kbps_48000hz,
- R.raw.bbb_s3_1280x720_mp4_h264_mp32_8mbps_60fps_aac_he_v2_6ch_144kbps_44100hz,
+ private static final String[] sAvcMedia1280x0720 = {
+ "bbb_s4_1280x720_mp4_h264_mp31_8mbps_30fps_aac_he_mono_40kbps_44100hz.mp4",
+ "bbb_s3_1280x720_mp4_h264_hp32_8mbps_60fps_aac_he_v2_stereo_48kbps_48000hz.mp4",
+ "bbb_s3_1280x720_mp4_h264_mp32_8mbps_60fps_aac_he_v2_6ch_144kbps_44100hz.mp4",
};
public void testAvcCount1280x0720() throws Exception { count(sAvcMedia1280x0720, 2, 4); }
@@ -419,11 +411,11 @@
public void testAvcOther3Perf1280x0720() throws Exception { perf(sAvcMedia1280x0720, OTHER, 3); }
// prefer highest effective bitrate, then high profile
- private static final int[] sAvcMedia1920x1080 = {
- R.raw.bbb_s4_1920x1080_wide_mp4_h264_hp4_20mbps_30fps_aac_lc_6ch_384kbps_44100hz,
- R.raw.bbb_s4_1920x1080_wide_mp4_h264_mp4_20mbps_30fps_aac_he_5ch_200kbps_44100hz,
- R.raw.bbb_s2_1920x1080_mp4_h264_hp42_20mbps_60fps_aac_lc_6ch_384kbps_48000hz,
- R.raw.bbb_s2_1920x1080_mp4_h264_mp42_20mbps_60fps_aac_he_v2_5ch_160kbps_48000hz,
+ private static final String[] sAvcMedia1920x1080 = {
+ "bbb_s4_1920x1080_wide_mp4_h264_hp4_20mbps_30fps_aac_lc_6ch_384kbps_44100hz.mp4",
+ "bbb_s4_1920x1080_wide_mp4_h264_mp4_20mbps_30fps_aac_he_5ch_200kbps_44100hz.mp4",
+ "bbb_s2_1920x1080_mp4_h264_hp42_20mbps_60fps_aac_lc_6ch_384kbps_48000hz.mp4",
+ "bbb_s2_1920x1080_mp4_h264_mp42_20mbps_60fps_aac_he_v2_5ch_160kbps_48000hz.mp4",
};
public void testAvcCount1920x1080() throws Exception { count(sAvcMedia1920x1080, 2, 4); }
@@ -436,8 +428,8 @@
// H263 tests
- private static final int[] sH263Media0176x0144 = {
- R.raw.video_176x144_3gp_h263_300kbps_12fps_aac_stereo_128kbps_22050hz,
+ private static final String[] sH263Media0176x0144 = {
+ "video_176x144_3gp_h263_300kbps_12fps_aac_stereo_128kbps_22050hz.3gp",
};
public void testH263Count0176x0144() throws Exception { count(sH263Media0176x0144, 2, 2); }
@@ -446,8 +438,8 @@
public void testH263Other0Perf0176x0144() throws Exception { perf(sH263Media0176x0144, OTHER, 0); }
public void testH263Other1Perf0176x0144() throws Exception { perf(sH263Media0176x0144, OTHER, 1); }
- private static final int[] sH263Media0352x0288 = {
- R.raw.video_352x288_3gp_h263_300kbps_12fps_aac_stereo_128kbps_22050hz,
+ private static final String[] sH263Media0352x0288 = {
+ "video_352x288_3gp_h263_300kbps_12fps_aac_stereo_128kbps_22050hz.3gp",
};
public void testH263Count0352x0288() throws Exception { count(sH263Media0352x0288, 2, 2); }
@@ -462,8 +454,8 @@
// HEVC tests
- private static final int[] sHevcMedia0352x0288 = {
- R.raw.bbb_s1_352x288_mp4_hevc_mp2_600kbps_30fps_aac_he_stereo_96kbps_48000hz,
+ private static final String[] sHevcMedia0352x0288 = {
+ "bbb_s1_352x288_mp4_hevc_mp2_600kbps_30fps_aac_he_stereo_96kbps_48000hz.mp4",
};
public void testHevcCount0352x0288() throws Exception { count(sHevcMedia0352x0288, 2, 4); }
@@ -474,8 +466,8 @@
public void testHevcOther2Perf0352x0288() throws Exception { perf(sHevcMedia0352x0288, OTHER, 2); }
public void testHevcOther3Perf0352x0288() throws Exception { perf(sHevcMedia0352x0288, OTHER, 3); }
- private static final int[] sHevcMedia0640x0360 = {
- R.raw.bbb_s1_640x360_mp4_hevc_mp21_1600kbps_30fps_aac_he_6ch_288kbps_44100hz,
+ private static final String[] sHevcMedia0640x0360 = {
+ "bbb_s1_640x360_mp4_hevc_mp21_1600kbps_30fps_aac_he_6ch_288kbps_44100hz.mp4",
};
public void testHevcCount0640x0360() throws Exception { count(sHevcMedia0640x0360, 2, 4); }
@@ -486,8 +478,8 @@
public void testHevcOther2Perf0640x0360() throws Exception { perf(sHevcMedia0640x0360, OTHER, 2); }
public void testHevcOther3Perf0640x0360() throws Exception { perf(sHevcMedia0640x0360, OTHER, 3); }
- private static final int[] sHevcMedia0720x0480 = {
- R.raw.bbb_s1_720x480_mp4_hevc_mp3_1600kbps_30fps_aac_he_6ch_240kbps_48000hz,
+ private static final String[] sHevcMedia0720x0480 = {
+ "bbb_s1_720x480_mp4_hevc_mp3_1600kbps_30fps_aac_he_6ch_240kbps_48000hz.mp4",
};
public void testHevcCount0720x0480() throws Exception { count(sHevcMedia0720x0480, 2, 4); }
@@ -498,8 +490,8 @@
public void testHevcOther2Perf0720x0480() throws Exception { perf(sHevcMedia0720x0480, OTHER, 2); }
public void testHevcOther3Perf0720x0480() throws Exception { perf(sHevcMedia0720x0480, OTHER, 3); }
- private static final int[] sHevcMedia1280x0720 = {
- R.raw.bbb_s4_1280x720_mp4_hevc_mp31_4mbps_30fps_aac_he_stereo_80kbps_32000hz,
+ private static final String[] sHevcMedia1280x0720 = {
+ "bbb_s4_1280x720_mp4_hevc_mp31_4mbps_30fps_aac_he_stereo_80kbps_32000hz.mp4",
};
public void testHevcCount1280x0720() throws Exception { count(sHevcMedia1280x0720, 2, 4); }
@@ -510,8 +502,8 @@
public void testHevcOther2Perf1280x0720() throws Exception { perf(sHevcMedia1280x0720, OTHER, 2); }
public void testHevcOther3Perf1280x0720() throws Exception { perf(sHevcMedia1280x0720, OTHER, 3); }
- private static final int[] sHevcMedia1920x1080 = {
- R.raw.bbb_s2_1920x1080_mp4_hevc_mp41_10mbps_60fps_aac_lc_6ch_384kbps_22050hz,
+ private static final String[] sHevcMedia1920x1080 = {
+ "bbb_s2_1920x1080_mp4_hevc_mp41_10mbps_60fps_aac_lc_6ch_384kbps_22050hz.mp4",
};
public void testHevcCount1920x1080() throws Exception { count(sHevcMedia1920x1080, 2, 4); }
@@ -523,9 +515,9 @@
public void testHevcOther3Perf1920x1080() throws Exception { perf(sHevcMedia1920x1080, OTHER, 3); }
// prefer highest effective bitrate
- private static final int[] sHevcMedia3840x2160 = {
- R.raw.bbb_s4_3840x2160_mp4_hevc_mp5_20mbps_30fps_aac_lc_6ch_384kbps_24000hz,
- R.raw.bbb_s2_3840x2160_mp4_hevc_mp51_20mbps_60fps_aac_lc_6ch_384kbps_32000hz,
+ private static final String[] sHevcMedia3840x2160 = {
+ "bbb_s4_3840x2160_mp4_hevc_mp5_20mbps_30fps_aac_lc_6ch_384kbps_24000hz.mp4",
+ "bbb_s2_3840x2160_mp4_hevc_mp51_20mbps_60fps_aac_lc_6ch_384kbps_32000hz.mp4",
};
public void testHevcCount3840x2160() throws Exception { count(sHevcMedia3840x2160, 2, 4); }
@@ -550,8 +542,8 @@
// MPEG4 tests
- private static final int[] sMpeg4Media0176x0144 = {
- R.raw.video_176x144_mp4_mpeg4_300kbps_25fps_aac_stereo_128kbps_44100hz,
+ private static final String[] sMpeg4Media0176x0144 = {
+ "video_176x144_mp4_mpeg4_300kbps_25fps_aac_stereo_128kbps_44100hz.mp4",
};
public void testMpeg4Count0176x0144() throws Exception { count(sMpeg4Media0176x0144, 2, 4); }
@@ -562,8 +554,8 @@
public void testMpeg4Other2Perf0176x0144() throws Exception { perf(sMpeg4Media0176x0144, OTHER, 2); }
public void testMpeg4Other3Perf0176x0144() throws Exception { perf(sMpeg4Media0176x0144, OTHER, 3); }
- private static final int[] sMpeg4Media0480x0360 = {
- R.raw.video_480x360_mp4_mpeg4_860kbps_25fps_aac_stereo_128kbps_44100hz,
+ private static final String[] sMpeg4Media0480x0360 = {
+ "video_480x360_mp4_mpeg4_860kbps_25fps_aac_stereo_128kbps_44100hz.mp4",
};
public void testMpeg4Count0480x0360() throws Exception { count(sMpeg4Media0480x0360, 2, 4); }
@@ -576,8 +568,8 @@
// No media for MPEG4 640x480
- private static final int[] sMpeg4Media1280x0720 = {
- R.raw.video_1280x720_mp4_mpeg4_1000kbps_25fps_aac_stereo_128kbps_44100hz,
+ private static final String[] sMpeg4Media1280x0720 = {
+ "video_1280x720_mp4_mpeg4_1000kbps_25fps_aac_stereo_128kbps_44100hz.mp4",
};
public void testMpeg4Count1280x0720() throws Exception { count(sMpeg4Media1280x0720, 2, 4); }
@@ -590,8 +582,8 @@
// VP8 tests
- private static final int[] sVp8Media0320x0180 = {
- R.raw.bbb_s1_320x180_webm_vp8_800kbps_30fps_opus_5ch_320kbps_48000hz,
+ private static final String[] sVp8Media0320x0180 = {
+ "bbb_s1_320x180_webm_vp8_800kbps_30fps_opus_5ch_320kbps_48000hz.webm",
};
public void testVp8Count0320x0180() throws Exception { count(sVp8Media0320x0180, 2, 2); }
@@ -600,8 +592,8 @@
public void testVp8Other0Perf0320x0180() throws Exception { perf(sVp8Media0320x0180, OTHER, 0); }
public void testVp8Other1Perf0320x0180() throws Exception { perf(sVp8Media0320x0180, OTHER, 1); }
- private static final int[] sVp8Media0640x0360 = {
- R.raw.bbb_s1_640x360_webm_vp8_2mbps_30fps_vorbis_5ch_320kbps_48000hz,
+ private static final String[] sVp8Media0640x0360 = {
+ "bbb_s1_640x360_webm_vp8_2mbps_30fps_vorbis_5ch_320kbps_48000hz.webm",
};
public void testVp8Count0640x0360() throws Exception { count(sVp8Media0640x0360, 2, 2); }
@@ -611,9 +603,9 @@
public void testVp8Other1Perf0640x0360() throws Exception { perf(sVp8Media0640x0360, OTHER, 1); }
// prefer highest effective bitrate
- private static final int[] sVp8Media1280x0720 = {
- R.raw.bbb_s4_1280x720_webm_vp8_8mbps_30fps_opus_mono_64kbps_48000hz,
- R.raw.bbb_s3_1280x720_webm_vp8_8mbps_60fps_opus_6ch_384kbps_48000hz,
+ private static final String[] sVp8Media1280x0720 = {
+ "bbb_s4_1280x720_webm_vp8_8mbps_30fps_opus_mono_64kbps_48000hz.webm",
+ "bbb_s3_1280x720_webm_vp8_8mbps_60fps_opus_6ch_384kbps_48000hz.webm",
};
public void testVp8Count1280x0720() throws Exception { count(sVp8Media1280x0720, 2, 2); }
@@ -623,9 +615,9 @@
public void testVp8Other1Perf1280x0720() throws Exception { perf(sVp8Media1280x0720, OTHER, 1); }
// prefer highest effective bitrate
- private static final int[] sVp8Media1920x1080 = {
- R.raw.bbb_s4_1920x1080_wide_webm_vp8_20mbps_30fps_vorbis_6ch_384kbps_44100hz,
- R.raw.bbb_s2_1920x1080_webm_vp8_20mbps_60fps_vorbis_6ch_384kbps_48000hz,
+ private static final String[] sVp8Media1920x1080 = {
+ "bbb_s4_1920x1080_wide_webm_vp8_20mbps_30fps_vorbis_6ch_384kbps_44100hz.webm",
+ "bbb_s2_1920x1080_webm_vp8_20mbps_60fps_vorbis_6ch_384kbps_48000hz.webm",
};
public void testVp8Count1920x1080() throws Exception { count(sVp8Media1920x1080, 2, 2); }
@@ -636,8 +628,8 @@
// VP9 tests
- private static final int[] sVp9Media0320x0180 = {
- R.raw.bbb_s1_320x180_webm_vp9_0p11_600kbps_30fps_vorbis_mono_64kbps_48000hz,
+ private static final String[] sVp9Media0320x0180 = {
+ "bbb_s1_320x180_webm_vp9_0p11_600kbps_30fps_vorbis_mono_64kbps_48000hz.webm",
};
public void testVp9Count0320x0180() throws Exception { count(sVp9Media0320x0180, 2, 4); }
@@ -648,8 +640,8 @@
public void testVp9Other2Perf0320x0180() throws Exception { perf(sVp9Media0320x0180, OTHER, 2); }
public void testVp9Other3Perf0320x0180() throws Exception { perf(sVp9Media0320x0180, OTHER, 3); }
- private static final int[] sVp9Media0640x0360 = {
- R.raw.bbb_s1_640x360_webm_vp9_0p21_1600kbps_30fps_vorbis_stereo_128kbps_48000hz,
+ private static final String[] sVp9Media0640x0360 = {
+ "bbb_s1_640x360_webm_vp9_0p21_1600kbps_30fps_vorbis_stereo_128kbps_48000hz.webm",
};
public void testVp9Count0640x0360() throws Exception { count(sVp9Media0640x0360, 2, 4); }
@@ -660,8 +652,8 @@
public void testVp9Other2Perf0640x0360() throws Exception { perf(sVp9Media0640x0360, OTHER, 2); }
public void testVp9Other3Perf0640x0360() throws Exception { perf(sVp9Media0640x0360, OTHER, 3); }
- private static final int[] sVp9Media1280x0720 = {
- R.raw.bbb_s4_1280x720_webm_vp9_0p31_4mbps_30fps_opus_stereo_128kbps_48000hz,
+ private static final String[] sVp9Media1280x0720 = {
+ "bbb_s4_1280x720_webm_vp9_0p31_4mbps_30fps_opus_stereo_128kbps_48000hz.webm",
};
public void testVp9Count1280x0720() throws Exception { count(sVp9Media1280x0720, 2, 4); }
@@ -672,8 +664,8 @@
public void testVp9Other2Perf1280x0720() throws Exception { perf(sVp9Media1280x0720, OTHER, 2); }
public void testVp9Other3Perf1280x0720() throws Exception { perf(sVp9Media1280x0720, OTHER, 3); }
- private static final int[] sVp9Media1920x1080 = {
- R.raw.bbb_s2_1920x1080_webm_vp9_0p41_10mbps_60fps_vorbis_6ch_384kbps_22050hz,
+ private static final String[] sVp9Media1920x1080 = {
+ "bbb_s2_1920x1080_webm_vp9_0p41_10mbps_60fps_vorbis_6ch_384kbps_22050hz.webm",
};
public void testVp9Count1920x1080() throws Exception { count(sVp9Media1920x1080, 2, 4); }
@@ -685,9 +677,9 @@
public void testVp9Other3Perf1920x1080() throws Exception { perf(sVp9Media1920x1080, OTHER, 3); }
// prefer highest effective bitrate
- private static final int[] sVp9Media3840x2160 = {
- R.raw.bbb_s4_3840x2160_webm_vp9_0p5_20mbps_30fps_vorbis_6ch_384kbps_24000hz,
- R.raw.bbb_s2_3840x2160_webm_vp9_0p51_20mbps_60fps_vorbis_6ch_384kbps_32000hz,
+ private static final String[] sVp9Media3840x2160 = {
+ "bbb_s4_3840x2160_webm_vp9_0p5_20mbps_30fps_vorbis_6ch_384kbps_24000hz.webm",
+ "bbb_s2_3840x2160_webm_vp9_0p51_20mbps_60fps_vorbis_6ch_384kbps_32000hz.webm",
};
public void testVp9Count3840x2160() throws Exception { count(sVp9Media3840x2160, 2, 4); }