Adjust timestamp scale
BufferQueue item timestamps are in nanoseconds, MediaCodec buffer
timestamps are in microseconds.
Bug 8988357
Change-Id: I940aa706af85b568642148e3495f22611f1ef9b8
diff --git a/tests/tests/media/src/android/media/cts/DecodeEditEncodeTest.java b/tests/tests/media/src/android/media/cts/DecodeEditEncodeTest.java
index 93b78a2..c0c21d1 100644
--- a/tests/tests/media/src/android/media/cts/DecodeEditEncodeTest.java
+++ b/tests/tests/media/src/android/media/cts/DecodeEditEncodeTest.java
@@ -116,6 +116,7 @@
mTest = test;
}
+ @Override
public void run() {
try {
mTest.videoEditTest();
@@ -293,7 +294,7 @@
inputDone = true;
} else {
generateSurfaceFrame(generateIndex);
- inputSurface.setPresentationTime(computePresentationTime(generateIndex));
+ inputSurface.setPresentationTime(computePresentationTime(generateIndex) * 1000);
if (VERBOSE) Log.d(TAG, "inputSurface swapBuffers");
inputSurface.swapBuffers();
}
@@ -586,7 +587,7 @@
outputSurface.drawImage();
// Send it to the encoder.
- inputSurface.setPresentationTime(info.presentationTimeUs);
+ inputSurface.setPresentationTime(info.presentationTimeUs * 1000);
if (VERBOSE) Log.d(TAG, "swapBuffers");
inputSurface.swapBuffers();
}
@@ -810,7 +811,7 @@
}
/**
- * Generates the presentation time for frame N.
+ * Generates the presentation time for frame N, in microseconds.
*/
private static long computePresentationTime(int frameIndex) {
return 123 + frameIndex * 1000000 / FRAME_RATE;
diff --git a/tests/tests/media/src/android/media/cts/EncodeDecodeTest.java b/tests/tests/media/src/android/media/cts/EncodeDecodeTest.java
index 849877a..b7ec961 100644
--- a/tests/tests/media/src/android/media/cts/EncodeDecodeTest.java
+++ b/tests/tests/media/src/android/media/cts/EncodeDecodeTest.java
@@ -130,6 +130,7 @@
mTest = test;
}
+ @Override
public void run() {
try {
mTest.encodeDecodeVideoFromBuffer(true);
@@ -178,6 +179,7 @@
mTest = test;
}
+ @Override
public void run() {
try {
mTest.encodeDecodeVideoFromSurfaceToSurface();
@@ -745,7 +747,7 @@
} else {
inputSurface.makeCurrent();
generateSurfaceFrame(generateIndex);
- inputSurface.setPresentationTime(computePresentationTime(generateIndex));
+ inputSurface.setPresentationTime(computePresentationTime(generateIndex) * 1000);
if (VERBOSE) Log.d(TAG, "inputSurface swapBuffers");
inputSurface.swapBuffers();
}
@@ -959,7 +961,7 @@
/**
* Performs a simple check to see if the frame is more or less right.
* <p>
- * See {@link generateFrame} for a description of the layout. The idea is to sample
+ * See {@link #generateFrame} for a description of the layout. The idea is to sample
* one pixel from the middle of the 8 regions, and verify that the correct one has
* the non-background color. We can't know exactly what the video encoder has done
* with our frames, so we just check to see if it looks like more or less the right thing.
@@ -1053,7 +1055,7 @@
}
/**
- * Checks the frame for correctness. Similar to {@link checkFrame}, but uses GL to
+ * Checks the frame for correctness. Similar to {@link #checkFrame}, but uses GL to
* read pixels from the current surface.
*
* @return true if the frame looks good
@@ -1118,7 +1120,7 @@
}
/**
- * Generates the presentation time for frame N.
+ * Generates the presentation time for frame N, in microseconds.
*/
private static long computePresentationTime(int frameIndex) {
return 132 + frameIndex * 1000000 / FRAME_RATE;
diff --git a/tests/tests/media/src/android/media/cts/ExtractDecodeEditEncodeMuxTest.java b/tests/tests/media/src/android/media/cts/ExtractDecodeEditEncodeMuxTest.java
index db6ce30..81296e4 100644
--- a/tests/tests/media/src/android/media/cts/ExtractDecodeEditEncodeMuxTest.java
+++ b/tests/tests/media/src/android/media/cts/ExtractDecodeEditEncodeMuxTest.java
@@ -797,7 +797,7 @@
if (VERBOSE) Log.d(TAG, "output surface: draw image");
outputSurface.drawImage();
inputSurface.setPresentationTime(
- videoDecoderOutputBufferInfo.presentationTimeUs);
+ videoDecoderOutputBufferInfo.presentationTimeUs * 1000);
if (VERBOSE) Log.d(TAG, "input surface: swap buffers");
inputSurface.swapBuffers();
if (VERBOSE) Log.d(TAG, "video encoder: notified of new frame");
diff --git a/tests/tests/media/src/android/media/cts/InputSurface.java b/tests/tests/media/src/android/media/cts/InputSurface.java
index 36ec2c7..a916b8f 100644
--- a/tests/tests/media/src/android/media/cts/InputSurface.java
+++ b/tests/tests/media/src/android/media/cts/InputSurface.java
@@ -22,15 +22,9 @@
import android.opengl.EGLContext;
import android.opengl.EGLDisplay;
import android.opengl.EGLSurface;
-import android.opengl.GLES10;
-import android.opengl.GLES11Ext;
-import android.opengl.GLES20;
-import android.opengl.Matrix;
import android.util.Log;
import android.view.Surface;
-import java.nio.ByteBuffer;
-
/**
* Holds state associated with a Surface used for MediaCodec encoder input.
@@ -167,10 +161,10 @@
}
/**
- * Sends the presentation time stamp to EGL.
+ * Sends the presentation time stamp to EGL. Time is expressed in nanoseconds.
*/
- public void setPresentationTime(long when) {
- EGLExt.eglPresentationTimeANDROID(mEGLDisplay, mEGLSurface, when);
+ public void setPresentationTime(long nsecs) {
+ EGLExt.eglPresentationTimeANDROID(mEGLDisplay, mEGLSurface, nsecs);
}
/**