Loading media/java/android/media/Image.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -192,6 +192,13 @@ public abstract class Image implements AutoCloseable { */ */ public abstract int getTransform(); public abstract int getTransform(); /** * Get the scaling mode associated with this frame. * @return The scaling mode that needs to be applied for this frame. * @hide */ public abstract int getScalingMode(); /** /** * Get the {@link android.hardware.HardwareBuffer HardwareBuffer} handle of the input image * Get the {@link android.hardware.HardwareBuffer HardwareBuffer} handle of the input image * intended for GPU and/or hardware access. * intended for GPU and/or hardware access. Loading media/java/android/media/ImageReader.java +8 −5 Original line number Original line Diff line number Diff line Loading @@ -870,6 +870,12 @@ public class ImageReader implements AutoCloseable { return mTransform; return mTransform; } } @Override public int getScalingMode() { throwISEIfImageIsInvalid(); return mScalingMode; } @Override @Override public HardwareBuffer getHardwareBuffer() { public HardwareBuffer getHardwareBuffer() { throwISEIfImageIsInvalid(); throwISEIfImageIsInvalid(); Loading Loading @@ -1004,14 +1010,11 @@ public class ImageReader implements AutoCloseable { private long mNativeBuffer; private long mNativeBuffer; /** /** * This field is set by native code during nativeImageSetup(). * These fields are set by native code during nativeImageSetup(). */ */ private long mTimestamp; private long mTimestamp; /** * This field is set by native code during nativeImageSetup(). */ private int mTransform; private int mTransform; private int mScalingMode; private SurfacePlane[] mPlanes; private SurfacePlane[] mPlanes; private int mFormat = ImageFormat.UNKNOWN; private int mFormat = ImageFormat.UNKNOWN; Loading media/java/android/media/ImageWriter.java +13 −4 Original line number Original line Diff line number Diff line Loading @@ -371,7 +371,7 @@ public class ImageWriter implements AutoCloseable { Rect crop = image.getCropRect(); Rect crop = image.getCropRect(); nativeQueueInputImage(mNativeContext, image, image.getTimestamp(), crop.left, crop.top, nativeQueueInputImage(mNativeContext, image, image.getTimestamp(), crop.left, crop.top, crop.right, crop.bottom, image.getTransform()); crop.right, crop.bottom, image.getTransform(), image.getScalingMode()); /** /** * Only remove and cleanup the Images that are owned by this * Only remove and cleanup the Images that are owned by this Loading Loading @@ -558,7 +558,7 @@ public class ImageWriter implements AutoCloseable { Rect crop = image.getCropRect(); Rect crop = image.getCropRect(); nativeAttachAndQueueImage(mNativeContext, image.getNativeContext(), image.getFormat(), nativeAttachAndQueueImage(mNativeContext, image.getNativeContext(), image.getFormat(), image.getTimestamp(), crop.left, crop.top, crop.right, crop.bottom, image.getTimestamp(), crop.left, crop.top, crop.right, crop.bottom, image.getTransform()); image.getTransform(), image.getScalingMode()); } } /** /** Loading Loading @@ -676,6 +676,7 @@ public class ImageWriter implements AutoCloseable { private long mTimestamp = DEFAULT_TIMESTAMP; private long mTimestamp = DEFAULT_TIMESTAMP; private int mTransform = 0; //Default no transform private int mTransform = 0; //Default no transform private int mScalingMode = 0; //Default frozen scaling mode public WriterSurfaceImage(ImageWriter writer) { public WriterSurfaceImage(ImageWriter writer) { mOwner = writer; mOwner = writer; Loading Loading @@ -720,6 +721,13 @@ public class ImageWriter implements AutoCloseable { return mTransform; return mTransform; } } @Override public int getScalingMode() { throwISEIfImageIsInvalid(); return mScalingMode; } @Override @Override public long getTimestamp() { public long getTimestamp() { throwISEIfImageIsInvalid(); throwISEIfImageIsInvalid(); Loading Loading @@ -866,11 +874,12 @@ public class ImageWriter implements AutoCloseable { private synchronized native void nativeDequeueInputImage(long nativeCtx, Image wi); private synchronized native void nativeDequeueInputImage(long nativeCtx, Image wi); private synchronized native void nativeQueueInputImage(long nativeCtx, Image image, private synchronized native void nativeQueueInputImage(long nativeCtx, Image image, long timestampNs, int left, int top, int right, int bottom, int transform); long timestampNs, int left, int top, int right, int bottom, int transform, int scalingMode); private synchronized native int nativeAttachAndQueueImage(long nativeCtx, private synchronized native int nativeAttachAndQueueImage(long nativeCtx, long imageNativeBuffer, int imageFormat, long timestampNs, int left, long imageNativeBuffer, int imageFormat, long timestampNs, int left, int top, int right, int bottom, int transform); int top, int right, int bottom, int transform, int scalingMode); private synchronized native void cancelImage(long nativeCtx, Image image); private synchronized native void cancelImage(long nativeCtx, Image image); Loading media/java/android/media/MediaCodec.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -3574,6 +3574,7 @@ final public class MediaCodec { private final static int TYPE_YUV = 1; private final static int TYPE_YUV = 1; private final int mTransform = 0; //Default no transform private final int mTransform = 0; //Default no transform private final int mScalingMode = 0; //Default frozen scaling mode @Override @Override public int getFormat() { public int getFormat() { Loading @@ -3599,6 +3600,12 @@ final public class MediaCodec { return mTransform; return mTransform; } } @Override public int getScalingMode() { throwISEIfImageIsInvalid(); return mScalingMode; } @Override @Override public long getTimestamp() { public long getTimestamp() { throwISEIfImageIsInvalid(); throwISEIfImageIsInvalid(); Loading media/jni/android_media_ImageReader.cpp +10 −0 Original line number Original line Diff line number Diff line Loading @@ -46,6 +46,7 @@ #define ANDROID_MEDIA_SURFACEIMAGE_BUFFER_JNI_ID "mNativeBuffer" #define ANDROID_MEDIA_SURFACEIMAGE_BUFFER_JNI_ID "mNativeBuffer" #define ANDROID_MEDIA_SURFACEIMAGE_TS_JNI_ID "mTimestamp" #define ANDROID_MEDIA_SURFACEIMAGE_TS_JNI_ID "mTimestamp" #define ANDROID_MEDIA_SURFACEIMAGE_TF_JNI_ID "mTransform" #define ANDROID_MEDIA_SURFACEIMAGE_TF_JNI_ID "mTransform" #define ANDROID_MEDIA_SURFACEIMAGE_SM_JNI_ID "mScalingMode" #define CONSUMER_BUFFER_USAGE_UNKNOWN 0; #define CONSUMER_BUFFER_USAGE_UNKNOWN 0; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- Loading @@ -68,6 +69,7 @@ static struct { jfieldID mNativeBuffer; jfieldID mNativeBuffer; jfieldID mTimestamp; jfieldID mTimestamp; jfieldID mTransform; jfieldID mTransform; jfieldID mScalingMode; jfieldID mPlanes; jfieldID mPlanes; } gSurfaceImageClassInfo; } gSurfaceImageClassInfo; Loading Loading @@ -315,6 +317,12 @@ static void ImageReader_classInit(JNIEnv* env, jclass clazz) "can't find android/graphics/ImageReader.%s", "can't find android/graphics/ImageReader.%s", ANDROID_MEDIA_SURFACEIMAGE_TF_JNI_ID); ANDROID_MEDIA_SURFACEIMAGE_TF_JNI_ID); gSurfaceImageClassInfo.mScalingMode = env->GetFieldID( imageClazz, ANDROID_MEDIA_SURFACEIMAGE_SM_JNI_ID, "I"); LOG_ALWAYS_FATAL_IF(gSurfaceImageClassInfo.mScalingMode == NULL, "can't find android/graphics/ImageReader.%s", ANDROID_MEDIA_SURFACEIMAGE_SM_JNI_ID); gSurfaceImageClassInfo.mPlanes = env->GetFieldID( gSurfaceImageClassInfo.mPlanes = env->GetFieldID( imageClazz, "mPlanes", "[Landroid/media/ImageReader$SurfaceImage$SurfacePlane;"); imageClazz, "mPlanes", "[Landroid/media/ImageReader$SurfaceImage$SurfacePlane;"); LOG_ALWAYS_FATAL_IF(gSurfaceImageClassInfo.mPlanes == NULL, LOG_ALWAYS_FATAL_IF(gSurfaceImageClassInfo.mPlanes == NULL, Loading Loading @@ -606,6 +614,8 @@ static jint ImageReader_imageSetup(JNIEnv* env, jobject thiz, jobject image) { static_cast<jlong>(buffer->mTimestamp)); static_cast<jlong>(buffer->mTimestamp)); env->SetIntField(image, gSurfaceImageClassInfo.mTransform, env->SetIntField(image, gSurfaceImageClassInfo.mTransform, static_cast<jint>(buffer->mTransform)); static_cast<jint>(buffer->mTransform)); env->SetIntField(image, gSurfaceImageClassInfo.mScalingMode, static_cast<jint>(buffer->mScalingMode)); return ACQUIRE_SUCCESS; return ACQUIRE_SUCCESS; } } Loading Loading
media/java/android/media/Image.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -192,6 +192,13 @@ public abstract class Image implements AutoCloseable { */ */ public abstract int getTransform(); public abstract int getTransform(); /** * Get the scaling mode associated with this frame. * @return The scaling mode that needs to be applied for this frame. * @hide */ public abstract int getScalingMode(); /** /** * Get the {@link android.hardware.HardwareBuffer HardwareBuffer} handle of the input image * Get the {@link android.hardware.HardwareBuffer HardwareBuffer} handle of the input image * intended for GPU and/or hardware access. * intended for GPU and/or hardware access. Loading
media/java/android/media/ImageReader.java +8 −5 Original line number Original line Diff line number Diff line Loading @@ -870,6 +870,12 @@ public class ImageReader implements AutoCloseable { return mTransform; return mTransform; } } @Override public int getScalingMode() { throwISEIfImageIsInvalid(); return mScalingMode; } @Override @Override public HardwareBuffer getHardwareBuffer() { public HardwareBuffer getHardwareBuffer() { throwISEIfImageIsInvalid(); throwISEIfImageIsInvalid(); Loading Loading @@ -1004,14 +1010,11 @@ public class ImageReader implements AutoCloseable { private long mNativeBuffer; private long mNativeBuffer; /** /** * This field is set by native code during nativeImageSetup(). * These fields are set by native code during nativeImageSetup(). */ */ private long mTimestamp; private long mTimestamp; /** * This field is set by native code during nativeImageSetup(). */ private int mTransform; private int mTransform; private int mScalingMode; private SurfacePlane[] mPlanes; private SurfacePlane[] mPlanes; private int mFormat = ImageFormat.UNKNOWN; private int mFormat = ImageFormat.UNKNOWN; Loading
media/java/android/media/ImageWriter.java +13 −4 Original line number Original line Diff line number Diff line Loading @@ -371,7 +371,7 @@ public class ImageWriter implements AutoCloseable { Rect crop = image.getCropRect(); Rect crop = image.getCropRect(); nativeQueueInputImage(mNativeContext, image, image.getTimestamp(), crop.left, crop.top, nativeQueueInputImage(mNativeContext, image, image.getTimestamp(), crop.left, crop.top, crop.right, crop.bottom, image.getTransform()); crop.right, crop.bottom, image.getTransform(), image.getScalingMode()); /** /** * Only remove and cleanup the Images that are owned by this * Only remove and cleanup the Images that are owned by this Loading Loading @@ -558,7 +558,7 @@ public class ImageWriter implements AutoCloseable { Rect crop = image.getCropRect(); Rect crop = image.getCropRect(); nativeAttachAndQueueImage(mNativeContext, image.getNativeContext(), image.getFormat(), nativeAttachAndQueueImage(mNativeContext, image.getNativeContext(), image.getFormat(), image.getTimestamp(), crop.left, crop.top, crop.right, crop.bottom, image.getTimestamp(), crop.left, crop.top, crop.right, crop.bottom, image.getTransform()); image.getTransform(), image.getScalingMode()); } } /** /** Loading Loading @@ -676,6 +676,7 @@ public class ImageWriter implements AutoCloseable { private long mTimestamp = DEFAULT_TIMESTAMP; private long mTimestamp = DEFAULT_TIMESTAMP; private int mTransform = 0; //Default no transform private int mTransform = 0; //Default no transform private int mScalingMode = 0; //Default frozen scaling mode public WriterSurfaceImage(ImageWriter writer) { public WriterSurfaceImage(ImageWriter writer) { mOwner = writer; mOwner = writer; Loading Loading @@ -720,6 +721,13 @@ public class ImageWriter implements AutoCloseable { return mTransform; return mTransform; } } @Override public int getScalingMode() { throwISEIfImageIsInvalid(); return mScalingMode; } @Override @Override public long getTimestamp() { public long getTimestamp() { throwISEIfImageIsInvalid(); throwISEIfImageIsInvalid(); Loading Loading @@ -866,11 +874,12 @@ public class ImageWriter implements AutoCloseable { private synchronized native void nativeDequeueInputImage(long nativeCtx, Image wi); private synchronized native void nativeDequeueInputImage(long nativeCtx, Image wi); private synchronized native void nativeQueueInputImage(long nativeCtx, Image image, private synchronized native void nativeQueueInputImage(long nativeCtx, Image image, long timestampNs, int left, int top, int right, int bottom, int transform); long timestampNs, int left, int top, int right, int bottom, int transform, int scalingMode); private synchronized native int nativeAttachAndQueueImage(long nativeCtx, private synchronized native int nativeAttachAndQueueImage(long nativeCtx, long imageNativeBuffer, int imageFormat, long timestampNs, int left, long imageNativeBuffer, int imageFormat, long timestampNs, int left, int top, int right, int bottom, int transform); int top, int right, int bottom, int transform, int scalingMode); private synchronized native void cancelImage(long nativeCtx, Image image); private synchronized native void cancelImage(long nativeCtx, Image image); Loading
media/java/android/media/MediaCodec.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -3574,6 +3574,7 @@ final public class MediaCodec { private final static int TYPE_YUV = 1; private final static int TYPE_YUV = 1; private final int mTransform = 0; //Default no transform private final int mTransform = 0; //Default no transform private final int mScalingMode = 0; //Default frozen scaling mode @Override @Override public int getFormat() { public int getFormat() { Loading @@ -3599,6 +3600,12 @@ final public class MediaCodec { return mTransform; return mTransform; } } @Override public int getScalingMode() { throwISEIfImageIsInvalid(); return mScalingMode; } @Override @Override public long getTimestamp() { public long getTimestamp() { throwISEIfImageIsInvalid(); throwISEIfImageIsInvalid(); Loading
media/jni/android_media_ImageReader.cpp +10 −0 Original line number Original line Diff line number Diff line Loading @@ -46,6 +46,7 @@ #define ANDROID_MEDIA_SURFACEIMAGE_BUFFER_JNI_ID "mNativeBuffer" #define ANDROID_MEDIA_SURFACEIMAGE_BUFFER_JNI_ID "mNativeBuffer" #define ANDROID_MEDIA_SURFACEIMAGE_TS_JNI_ID "mTimestamp" #define ANDROID_MEDIA_SURFACEIMAGE_TS_JNI_ID "mTimestamp" #define ANDROID_MEDIA_SURFACEIMAGE_TF_JNI_ID "mTransform" #define ANDROID_MEDIA_SURFACEIMAGE_TF_JNI_ID "mTransform" #define ANDROID_MEDIA_SURFACEIMAGE_SM_JNI_ID "mScalingMode" #define CONSUMER_BUFFER_USAGE_UNKNOWN 0; #define CONSUMER_BUFFER_USAGE_UNKNOWN 0; // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- Loading @@ -68,6 +69,7 @@ static struct { jfieldID mNativeBuffer; jfieldID mNativeBuffer; jfieldID mTimestamp; jfieldID mTimestamp; jfieldID mTransform; jfieldID mTransform; jfieldID mScalingMode; jfieldID mPlanes; jfieldID mPlanes; } gSurfaceImageClassInfo; } gSurfaceImageClassInfo; Loading Loading @@ -315,6 +317,12 @@ static void ImageReader_classInit(JNIEnv* env, jclass clazz) "can't find android/graphics/ImageReader.%s", "can't find android/graphics/ImageReader.%s", ANDROID_MEDIA_SURFACEIMAGE_TF_JNI_ID); ANDROID_MEDIA_SURFACEIMAGE_TF_JNI_ID); gSurfaceImageClassInfo.mScalingMode = env->GetFieldID( imageClazz, ANDROID_MEDIA_SURFACEIMAGE_SM_JNI_ID, "I"); LOG_ALWAYS_FATAL_IF(gSurfaceImageClassInfo.mScalingMode == NULL, "can't find android/graphics/ImageReader.%s", ANDROID_MEDIA_SURFACEIMAGE_SM_JNI_ID); gSurfaceImageClassInfo.mPlanes = env->GetFieldID( gSurfaceImageClassInfo.mPlanes = env->GetFieldID( imageClazz, "mPlanes", "[Landroid/media/ImageReader$SurfaceImage$SurfacePlane;"); imageClazz, "mPlanes", "[Landroid/media/ImageReader$SurfaceImage$SurfacePlane;"); LOG_ALWAYS_FATAL_IF(gSurfaceImageClassInfo.mPlanes == NULL, LOG_ALWAYS_FATAL_IF(gSurfaceImageClassInfo.mPlanes == NULL, Loading Loading @@ -606,6 +614,8 @@ static jint ImageReader_imageSetup(JNIEnv* env, jobject thiz, jobject image) { static_cast<jlong>(buffer->mTimestamp)); static_cast<jlong>(buffer->mTimestamp)); env->SetIntField(image, gSurfaceImageClassInfo.mTransform, env->SetIntField(image, gSurfaceImageClassInfo.mTransform, static_cast<jint>(buffer->mTransform)); static_cast<jint>(buffer->mTransform)); env->SetIntField(image, gSurfaceImageClassInfo.mScalingMode, static_cast<jint>(buffer->mScalingMode)); return ACQUIRE_SUCCESS; return ACQUIRE_SUCCESS; } } Loading