Merge "Camera: Populate Image tranformation in reader and writer" into pi-dev am: d41fed72c7

am: b05f2511e2

Change-Id: I273321efbb1691fdbfe5610e19aa084cd47c6e9a
This commit is contained in:
Emilian Peev
2018-03-20 13:07:55 +00:00
committed by android-build-merger
6 changed files with 67 additions and 9 deletions

View File

@@ -185,6 +185,13 @@ public abstract class Image implements AutoCloseable {
*/
public abstract long getTimestamp();
/**
* Get the transformation associated with this frame.
* @return The window transformation that needs to be applied for this frame.
* @hide
*/
public abstract int getTransform();
/**
* Get the {@link android.hardware.HardwareBuffer HardwareBuffer} handle of the input image
* intended for GPU and/or hardware access.

View File

@@ -875,6 +875,12 @@ public class ImageReader implements AutoCloseable {
return mTimestamp;
}
@Override
public int getTransform() {
throwISEIfImageIsInvalid();
return mTransform;
}
@Override
public HardwareBuffer getHardwareBuffer() {
throwISEIfImageIsInvalid();
@@ -1013,6 +1019,11 @@ public class ImageReader implements AutoCloseable {
*/
private long mTimestamp;
/**
* This field is set by native code during nativeImageSetup().
*/
private int mTransform;
private SurfacePlane[] mPlanes;
private int mFormat = ImageFormat.UNKNOWN;
// If this image is detached from the ImageReader.

View File

@@ -371,7 +371,7 @@ public class ImageWriter implements AutoCloseable {
Rect crop = image.getCropRect();
nativeQueueInputImage(mNativeContext, image, image.getTimestamp(), crop.left, crop.top,
crop.right, crop.bottom);
crop.right, crop.bottom, image.getTransform());
/**
* Only remove and cleanup the Images that are owned by this
@@ -557,7 +557,8 @@ public class ImageWriter implements AutoCloseable {
// buffer caused leak.
Rect crop = image.getCropRect();
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());
}
/**
@@ -674,6 +675,8 @@ public class ImageWriter implements AutoCloseable {
private final long DEFAULT_TIMESTAMP = Long.MIN_VALUE;
private long mTimestamp = DEFAULT_TIMESTAMP;
private int mTransform = 0; //Default no transform
public WriterSurfaceImage(ImageWriter writer) {
mOwner = writer;
}
@@ -710,6 +713,13 @@ public class ImageWriter implements AutoCloseable {
return mHeight;
}
@Override
public int getTransform() {
throwISEIfImageIsInvalid();
return mTransform;
}
@Override
public long getTimestamp() {
throwISEIfImageIsInvalid();
@@ -856,11 +866,11 @@ public class ImageWriter implements AutoCloseable {
private synchronized native void nativeDequeueInputImage(long nativeCtx, Image wi);
private synchronized native void nativeQueueInputImage(long nativeCtx, Image image,
long timestampNs, int left, int top, int right, int bottom);
long timestampNs, int left, int top, int right, int bottom, int transform);
private synchronized native int nativeAttachAndQueueImage(long nativeCtx,
long imageNativeBuffer, int imageFormat, long timestampNs, int left,
int top, int right, int bottom);
int top, int right, int bottom, int transform);
private synchronized native void cancelImage(long nativeCtx, Image image);

View File

@@ -3528,6 +3528,8 @@ final public class MediaCodec {
private final static int TYPE_YUV = 1;
private final int mTransform = 0; //Default no transform
@Override
public int getFormat() {
throwISEIfImageIsInvalid();
@@ -3546,6 +3548,12 @@ final public class MediaCodec {
return mWidth;
}
@Override
public int getTransform() {
throwISEIfImageIsInvalid();
return mTransform;
}
@Override
public long getTimestamp() {
throwISEIfImageIsInvalid();