diff --git a/api/current.txt b/api/current.txt index a61bb5f78b0f9..d84a17169a29e 100644 --- a/api/current.txt +++ b/api/current.txt @@ -11545,6 +11545,7 @@ package android.graphics { field public static final int PRIVATE = 34; // 0x22 field public static final int RAW10 = 37; // 0x25 field public static final int RAW12 = 38; // 0x26 + field public static final int RAW_PRIVATE = 36; // 0x24 field public static final int RAW_SENSOR = 32; // 0x20 field public static final int RGB_565 = 4; // 0x4 field public static final int UNKNOWN = 0; // 0x0 diff --git a/api/system-current.txt b/api/system-current.txt index 970b0297d0e92..c05556160cc47 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -11888,6 +11888,7 @@ package android.graphics { field public static final int PRIVATE = 34; // 0x22 field public static final int RAW10 = 37; // 0x25 field public static final int RAW12 = 38; // 0x26 + field public static final int RAW_PRIVATE = 36; // 0x24 field public static final int RAW_SENSOR = 32; // 0x20 field public static final int RGB_565 = 4; // 0x4 field public static final int UNKNOWN = 0; // 0x0 diff --git a/api/test-current.txt b/api/test-current.txt index 4c8d361c3dd2a..c362f0215cedf 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -11545,6 +11545,7 @@ package android.graphics { field public static final int PRIVATE = 34; // 0x22 field public static final int RAW10 = 37; // 0x25 field public static final int RAW12 = 38; // 0x26 + field public static final int RAW_PRIVATE = 36; // 0x24 field public static final int RAW_SENSOR = 32; // 0x20 field public static final int RGB_565 = 4; // 0x4 field public static final int UNKNOWN = 0; // 0x0 diff --git a/core/java/android/hardware/camera2/params/StreamConfigurationMap.java b/core/java/android/hardware/camera2/params/StreamConfigurationMap.java index b8d69601976eb..8be49e8f3ccff 100644 --- a/core/java/android/hardware/camera2/params/StreamConfigurationMap.java +++ b/core/java/android/hardware/camera2/params/StreamConfigurationMap.java @@ -834,6 +834,7 @@ public final class StreamConfigurationMap { *
Private raw camera sensor image format, a single channel image with + * implementation depedent pixel layout.
+ * + *RAW_PRIVATE is a format for unprocessed raw image buffers coming from an + * image sensor. The actual structure of buffers of this format is + * implementation-dependent.
+ * + */ + public static final int RAW_PRIVATE = 0x24; + /** ** Android 10-bit raw format @@ -748,6 +759,7 @@ public class ImageFormat { case FLEX_RGB_888: case FLEX_RGBA_8888: case RAW_SENSOR: + case RAW_PRIVATE: case RAW10: case RAW12: case DEPTH16: diff --git a/include/android_runtime/android_view_Surface.h b/include/android_runtime/android_view_Surface.h index ed8331410feea..b1e552a810e8c 100644 --- a/include/android_runtime/android_view_Surface.h +++ b/include/android_runtime/android_view_Surface.h @@ -45,7 +45,9 @@ enum class PublicFormat { RAW_SENSOR = 0x20, PRIVATE = 0x22, YUV_420_888 = 0x23, + RAW_PRIVATE = 0x24, RAW10 = 0x25, + RAW12 = 0x26, JPEG = 0x100, DEPTH_POINT_CLOUD = 0x101, YV12 = 0x32315659, diff --git a/media/java/android/media/Image.java b/media/java/android/media/Image.java index 045216b8a7345..3e75759bdfce4 100644 --- a/media/java/android/media/Image.java +++ b/media/java/android/media/Image.java @@ -141,6 +141,16 @@ public abstract class Image implements AutoCloseable { * {@link android.hardware.camera2.CameraDevice CameraDevice}. * * + *
The row stride for this color plane, in bytes.
* *This is the distance between the start of two consecutive rows of - * pixels in the image. The row stride is always greater than 0.
+ * pixels in the image. Note that row stried is undefined for some formats + * such as + * {@link android.graphics.ImageFormat#RAW_PRIVATE RAW_PRIVATE}, + * and calling getRowStride on images of these formats will + * cause an UnsupportedOperationException being thrown. + * For formats where row stride is well defined, the row stride + * is always greater than 0. */ public abstract int getRowStride(); /** @@ -350,7 +366,12 @@ public abstract class Image implements AutoCloseable { *This is the distance between two consecutive pixel values in a row * of pixels. It may be larger than the size of a single pixel to * account for interleaved image data or padded formats. - * The pixel stride is always greater than 0.
+ * Note that pixel stride is undefined for some formats such as + * {@link android.graphics.ImageFormat#RAW_PRIVATE RAW_PRIVATE}, + * and calling getPixelStride on images of these formats will + * cause an UnsupportedOperationException being thrown. + * For formats where pixel stride is well defined, the pixel stride + * is always greater than 0. */ public abstract int getPixelStride(); /** diff --git a/media/java/android/media/ImageReader.java b/media/java/android/media/ImageReader.java index 66a174c35f5ce..397ab15c5aba4 100644 --- a/media/java/android/media/ImageReader.java +++ b/media/java/android/media/ImageReader.java @@ -570,7 +570,7 @@ public class ImageReader implements AutoCloseable { nativeDetachImage(image); si.setDetached(true); - } + } private boolean isImageOwnedbyMe(Image image) { if (!(image instanceof SurfaceImage)) { @@ -675,6 +675,7 @@ public class ImageReader implements AutoCloseable { switch(getFormat()) { case ImageFormat.JPEG: case ImageFormat.DEPTH_POINT_CLOUD: + case ImageFormat.RAW_PRIVATE: width = ImageReader.this.getWidth(); break; default: @@ -690,6 +691,7 @@ public class ImageReader implements AutoCloseable { switch(getFormat()) { case ImageFormat.JPEG: case ImageFormat.DEPTH_POINT_CLOUD: + case ImageFormat.RAW_PRIVATE: height = ImageReader.this.getHeight(); break; default: @@ -791,12 +793,20 @@ public class ImageReader implements AutoCloseable { @Override public int getPixelStride() { SurfaceImage.this.throwISEIfImageIsInvalid(); + if (ImageReader.this.mFormat == ImageFormat.RAW_PRIVATE) { + throw new UnsupportedOperationException( + "getPixelStride is not supported for RAW_PRIVATE plane"); + } return mPixelStride; } @Override public int getRowStride() { SurfaceImage.this.throwISEIfImageIsInvalid(); + if (ImageReader.this.mFormat == ImageFormat.RAW_PRIVATE) { + throw new UnsupportedOperationException( + "getRowStride is not supported for RAW_PRIVATE plane"); + } return mRowStride; } diff --git a/media/java/android/media/ImageUtils.java b/media/java/android/media/ImageUtils.java index eefd69c4cb3c2..abf6b203daaf5 100644 --- a/media/java/android/media/ImageUtils.java +++ b/media/java/android/media/ImageUtils.java @@ -57,6 +57,7 @@ class ImageUtils { case ImageFormat.Y8: case ImageFormat.Y16: case ImageFormat.RAW_SENSOR: + case ImageFormat.RAW_PRIVATE: case ImageFormat.RAW10: case ImageFormat.RAW12: case ImageFormat.DEPTH16: @@ -98,6 +99,10 @@ class ImageUtils { dst.getFormat() == ImageFormat.PRIVATE) { throw new IllegalArgumentException("PRIVATE format images are not copyable"); } + if (src.getFormat() == ImageFormat.RAW_PRIVATE) { + throw new IllegalArgumentException( + "Copy of RAW_OPAQUE format has not been implemented"); + } if (!(dst.getOwner() instanceof ImageWriter)) { throw new IllegalArgumentException("Destination image is not from ImageWriter. Only" + " the images from ImageWriter are writable"); @@ -193,7 +198,8 @@ class ImageUtils { case ImageFormat.YV12: case ImageFormat.YUV_420_888: case ImageFormat.NV21: - case ImageFormat.PRIVATE: // A really rough estimate because the real size is unknown. + case ImageFormat.RAW12: + case ImageFormat.PRIVATE: // A rough estimate because the real size is unknown. estimatedBytePerPixel = 1.5; break; case ImageFormat.NV16: @@ -201,6 +207,7 @@ class ImageUtils { case ImageFormat.YUY2: case ImageFormat.Y16: case ImageFormat.RAW_SENSOR: + case ImageFormat.RAW_PRIVATE: // round estimate, real size is unknown case ImageFormat.DEPTH16: estimatedBytePerPixel = 2.0; break; @@ -245,6 +252,7 @@ class ImageUtils { case ImageFormat.Y16: case ImageFormat.RAW_SENSOR: case ImageFormat.RAW10: + case ImageFormat.RAW12: return new Size(image.getWidth(), image.getHeight()); case ImageFormat.PRIVATE: return new Size(0, 0); diff --git a/media/jni/android_media_ImageReader.cpp b/media/jni/android_media_ImageReader.cpp index 9a53186365e18..1c043e0706814 100644 --- a/media/jni/android_media_ImageReader.cpp +++ b/media/jni/android_media_ImageReader.cpp @@ -101,6 +101,8 @@ public: void setOpaqueConsumer(const sp