DecoderTest: add VP8 and MPEG-4 tests
Created tests for VP8 and MPEG-4 akin to existing H264 tests.
Change-Id: I090e41aba3b781d4714e2e5da3c877e287b8f2e5
Signed-off-by: Lajos Molnar <lajos@google.com>
diff --git a/tests/tests/media/res/raw/video_480x360_mp4_mpeg4_860kbps_25fps_aac_stereo_128kbps_44100hz.mp4 b/tests/tests/media/res/raw/video_480x360_mp4_mpeg4_860kbps_25fps_aac_stereo_128kbps_44100hz.mp4
new file mode 100644
index 0000000..5dbb6db
--- /dev/null
+++ b/tests/tests/media/res/raw/video_480x360_mp4_mpeg4_860kbps_25fps_aac_stereo_128kbps_44100hz.mp4
Binary files differ
diff --git a/tests/tests/media/res/raw/video_480x360_mp4_vp8_333kbps_25fps_aac_stereo_128kbps_44100hz.webm b/tests/tests/media/res/raw/video_480x360_mp4_vp8_333kbps_25fps_aac_stereo_128kbps_44100hz.webm
new file mode 100644
index 0000000..f64aec3
--- /dev/null
+++ b/tests/tests/media/res/raw/video_480x360_mp4_vp8_333kbps_25fps_aac_stereo_128kbps_44100hz.webm
Binary files differ
diff --git a/tests/tests/media/src/android/media/cts/DecoderTest.java b/tests/tests/media/src/android/media/cts/DecoderTest.java
index 231bd83..091c6b0 100644
--- a/tests/tests/media/src/android/media/cts/DecoderTest.java
+++ b/tests/tests/media/src/android/media/cts/DecoderTest.java
@@ -273,6 +273,32 @@
assertEquals("different number of frames when using Surface", frames1, frames2);
}
+ public void testCodecBasicMpeg4() throws Exception {
+ Surface s = getActivity().getSurfaceHolder().getSurface();
+ int frames1 = countFrames(
+ R.raw.video_480x360_mp4_mpeg4_860kbps_25fps_aac_stereo_128kbps_44100hz,
+ false, -1, s);
+ assertEquals("wrong number of frames decoded", 249, frames1);
+
+ int frames2 = countFrames(
+ R.raw.video_480x360_mp4_mpeg4_860kbps_25fps_aac_stereo_128kbps_44100hz,
+ false, -1, null);
+ assertEquals("different number of frames when using Surface", frames1, frames2);
+ }
+
+ public void testCodecBasicVP8() throws Exception {
+ Surface s = getActivity().getSurfaceHolder().getSurface();
+ int frames1 = countFrames(
+ R.raw.video_480x360_mp4_vp8_333kbps_25fps_aac_stereo_128kbps_44100hz,
+ false, -1, s);
+ assertEquals("wrong number of frames decoded", 240, frames1);
+
+ int frames2 = countFrames(
+ R.raw.video_480x360_mp4_vp8_333kbps_25fps_aac_stereo_128kbps_44100hz,
+ false, -1, null);
+ assertEquals("different number of frames when using Surface", frames1, frames2);
+ }
+
public void testCodecEarlyEOSH263() throws Exception {
Surface s = getActivity().getSurfaceHolder().getSurface();
int frames1 = countFrames(
@@ -289,6 +315,22 @@
assertEquals("wrong number of frames decoded", 120, frames1);
}
+ public void testCodecEarlyEOSMpeg4() throws Exception {
+ Surface s = getActivity().getSurfaceHolder().getSurface();
+ int frames1 = countFrames(
+ R.raw.video_480x360_mp4_mpeg4_860kbps_25fps_aac_stereo_128kbps_44100hz,
+ false, 120, s);
+ assertEquals("wrong number of frames decoded", 120, frames1);
+ }
+
+ public void testCodecEarlyEOSVP8() throws Exception {
+ Surface s = getActivity().getSurfaceHolder().getSurface();
+ int frames1 = countFrames(
+ R.raw.video_480x360_mp4_vp8_333kbps_25fps_aac_stereo_128kbps_44100hz,
+ false, 120, s);
+ assertEquals("wrong number of frames decoded", 120, frames1);
+ }
+
public void testCodecReconfigH264WithoutSurface() throws Exception {
testCodecReconfig(
R.raw.video_480x360_mp4_h264_1000kbps_25fps_aac_stereo_128kbps_44100hz, null);
@@ -311,6 +353,28 @@
R.raw.video_176x144_3gp_h263_300kbps_12fps_aac_stereo_128kbps_22050hz, s);
}
+ public void testCodecReconfigMpeg4WithoutSurface() throws Exception {
+ testCodecReconfig(
+ R.raw.video_480x360_mp4_mpeg4_860kbps_25fps_aac_stereo_128kbps_44100hz, null);
+ }
+
+ public void testCodecReconfigMpeg4WithSurface() throws Exception {
+ Surface s = getActivity().getSurfaceHolder().getSurface();
+ testCodecReconfig(
+ R.raw.video_480x360_mp4_mpeg4_860kbps_25fps_aac_stereo_128kbps_44100hz, s);
+ }
+
+ public void testCodecReconfigVP8WithoutSurface() throws Exception {
+ testCodecReconfig(
+ R.raw.video_480x360_mp4_vp8_333kbps_25fps_aac_stereo_128kbps_44100hz, null);
+ }
+
+ public void testCodecReconfigVP8WithSurface() throws Exception {
+ Surface s = getActivity().getSurfaceHolder().getSurface();
+ testCodecReconfig(
+ R.raw.video_480x360_mp4_vp8_333kbps_25fps_aac_stereo_128kbps_44100hz, s);
+ }
+
// public void testCodecReconfigOgg() throws Exception {
// testCodecReconfig(R.raw.sinesweepogg, null);
// }
@@ -329,6 +393,22 @@
assertEquals("different number of frames when reusing codec", frames1, frames2);
}
+ private MediaCodec createDecoder(String mime) {
+ if (false) {
+ // change to force testing software codecs
+ if (mime.contains("avc")) {
+ return MediaCodec.createByCodecName("OMX.google.h264.decoder");
+ } else if (mime.contains("3gpp")) {
+ return MediaCodec.createByCodecName("OMX.google.h263.decoder");
+ } else if (mime.contains("mp4v")) {
+ return MediaCodec.createByCodecName("OMX.google.mpeg4.decoder");
+ } else if (mime.contains("vp8")) {
+ return MediaCodec.createByCodecName("OMX.google.vpx.decoder");
+ }
+ }
+ return MediaCodec.createDecoderByType(mime);
+ }
+
private int countFrames(int video, boolean reconfigure, int eosframe, Surface s) throws Exception {
int numframes = 0;
@@ -347,12 +427,8 @@
String mime = format.getString(MediaFormat.KEY_MIME);
boolean isAudio = mime.startsWith("audio/");
- codec = MediaCodec.createDecoderByType(mime);
-// if (mime.contains("avc")) {
-// codec = MediaCodec.createByCodecName("OMX.google.h264.decoder");
-// } else if (mime.contains("3gpp")) {
-// codec = MediaCodec.createByCodecName("OMX.google.h263.decoder");
-// }
+ codec = createDecoder(mime);
+
assertNotNull("couldn't find codec", codec);
Log.i("@@@@", "using codec: " + codec.getName());
codec.configure(format, s /* surface */, null /* crypto */, 0 /* flags */);
@@ -495,6 +571,23 @@
testEOSBehavior(R.raw.video_176x144_3gp_h263_300kbps_12fps_aac_stereo_128kbps_22050hz, 50);
}
+ public void testEOSBehaviorMpeg4() throws Exception {
+ // this video has an I frame every 12 frames
+ testEOSBehavior(R.raw.video_480x360_mp4_mpeg4_860kbps_25fps_aac_stereo_128kbps_44100hz, 24);
+ testEOSBehavior(R.raw.video_480x360_mp4_mpeg4_860kbps_25fps_aac_stereo_128kbps_44100hz, 25);
+ testEOSBehavior(R.raw.video_480x360_mp4_mpeg4_860kbps_25fps_aac_stereo_128kbps_44100hz, 48);
+ testEOSBehavior(R.raw.video_480x360_mp4_mpeg4_860kbps_25fps_aac_stereo_128kbps_44100hz, 50);
+ testEOSBehavior(R.raw.video_480x360_mp4_mpeg4_860kbps_25fps_aac_stereo_128kbps_44100hz, 2);
+ }
+
+ public void testEOSBehaviorVP8() throws Exception {
+ // this video has an I frame at 46
+ testEOSBehavior(R.raw.video_480x360_mp4_vp8_333kbps_25fps_aac_stereo_128kbps_44100hz, 46);
+ testEOSBehavior(R.raw.video_480x360_mp4_vp8_333kbps_25fps_aac_stereo_128kbps_44100hz, 47);
+ testEOSBehavior(R.raw.video_480x360_mp4_vp8_333kbps_25fps_aac_stereo_128kbps_44100hz, 57);
+ testEOSBehavior(R.raw.video_480x360_mp4_vp8_333kbps_25fps_aac_stereo_128kbps_44100hz, 45);
+ }
+
private void testEOSBehavior(int movie, int stopatsample) throws Exception {
int numframes = 0;
@@ -516,12 +609,8 @@
String mime = format.getString(MediaFormat.KEY_MIME);
boolean isAudio = mime.startsWith("audio/");
- codec = MediaCodec.createDecoderByType(mime);
-// if (mime.contains("avc")) {
-// codec = MediaCodec.createByCodecName("OMX.google.h264.decoder");
-// } else if (mime.contains("3gpp")) {
-// codec = MediaCodec.createByCodecName("OMX.google.h263.decoder");
-// }
+ codec = createDecoder(mime);
+
assertNotNull("couldn't find codec", codec);
Log.i("@@@@", "using codec: " + codec.getName());
codec.configure(format, null /* surface */, null /* crypto */, 0 /* flags */);
@@ -634,12 +723,7 @@
extractor.setDataSource(testFd.getFileDescriptor(), testFd.getStartOffset(),
testFd.getLength());
- codec = MediaCodec.createDecoderByType(mime);
-// if (mime.contains("avc")) {
-// codec = MediaCodec.createByCodecName("OMX.google.h264.decoder");
-// } else if (mime.contains("3gpp")) {
-// codec = MediaCodec.createByCodecName("OMX.google.h263.decoder");
-// }
+ codec = createDecoder(mime);
codec.configure(format, null /* surface */, null /* crypto */, 0 /* flags */);
codec.start();
codecInputBuffers = codec.getInputBuffers();