From d1d27c1543a2de464938c068115f2f8dfa5b790a Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Thu, 23 Apr 2015 16:32:38 -0700 Subject: media: add flexible YUV422, 444, and RGB/RGBA formats These are used by Media.Image on getOutputImage. Change-Id: I171c5b90423800eeab4e36625dcf727a2a2affcd --- api/current.txt | 4 + api/system-current.txt | 4 + graphics/java/android/graphics/ImageFormat.java | 143 +++++++++++++++++++++++- media/java/android/media/Image.java | 32 ++++++ media/java/android/media/ImageReader.java | 2 +- 5 files changed, 183 insertions(+), 2 deletions(-) diff --git a/api/current.txt b/api/current.txt index 5c366ba..53d627b 100644 --- a/api/current.txt +++ b/api/current.txt @@ -11337,6 +11337,8 @@ package android.graphics { method public static int getBitsPerPixel(int); field public static final int DEPTH16 = 1144402265; // 0x44363159 field public static final int DEPTH_POINT_CLOUD = 257; // 0x101 + field public static final int FLEX_RGBA_8888 = 42; // 0x2a + field public static final int FLEX_RGB_888 = 41; // 0x29 field public static final int JPEG = 256; // 0x100 field public static final int NV16 = 16; // 0x10 field public static final int NV21 = 17; // 0x11 @@ -11347,6 +11349,8 @@ package android.graphics { field public static final int RGB_565 = 4; // 0x4 field public static final int UNKNOWN = 0; // 0x0 field public static final int YUV_420_888 = 35; // 0x23 + field public static final int YUV_422_888 = 39; // 0x27 + field public static final int YUV_444_888 = 40; // 0x28 field public static final int YUY2 = 20; // 0x14 field public static final int YV12 = 842094169; // 0x32315659 } diff --git a/api/system-current.txt b/api/system-current.txt index 8546f48..30c01ea 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -11632,6 +11632,8 @@ package android.graphics { method public static int getBitsPerPixel(int); field public static final int DEPTH16 = 1144402265; // 0x44363159 field public static final int DEPTH_POINT_CLOUD = 257; // 0x101 + field public static final int FLEX_RGBA_8888 = 42; // 0x2a + field public static final int FLEX_RGB_888 = 41; // 0x29 field public static final int JPEG = 256; // 0x100 field public static final int NV16 = 16; // 0x10 field public static final int NV21 = 17; // 0x11 @@ -11642,6 +11644,8 @@ package android.graphics { field public static final int RGB_565 = 4; // 0x4 field public static final int UNKNOWN = 0; // 0x0 field public static final int YUV_420_888 = 35; // 0x23 + field public static final int YUV_422_888 = 39; // 0x27 + field public static final int YUV_444_888 = 40; // 0x28 field public static final int YUY2 = 20; // 0x14 field public static final int YV12 = 842094169; // 0x32315659 } diff --git a/graphics/java/android/graphics/ImageFormat.java b/graphics/java/android/graphics/ImageFormat.java index c63c8ba..d6f8cca 100644 --- a/graphics/java/android/graphics/ImageFormat.java +++ b/graphics/java/android/graphics/ImageFormat.java @@ -181,7 +181,7 @@ public class ImageFormat { public static final int JPEG = 0x100; /** - *

Multi-plane Android YUV format

+ *

Multi-plane Android YUV 420 format

* *

This format is a generic YCbCr format, capable of describing any 4:2:0 * chroma-subsampled planar or semiplanar buffer (but not fully interleaved), @@ -219,6 +219,135 @@ public class ImageFormat { public static final int YUV_420_888 = 0x23; /** + *

Multi-plane Android YUV 422 format

+ * + *

This format is a generic YCbCr format, capable of describing any 4:2:2 + * chroma-subsampled (planar, semiplanar or interleaved) format, + * with 8 bits per color sample.

+ * + *

Images in this format are always represented by three separate buffers + * of data, one for each color plane. Additional information always + * accompanies the buffers, describing the row stride and the pixel stride + * for each plane.

+ * + *

The order of planes in the array returned by + * {@link android.media.Image#getPlanes() Image#getPlanes()} is guaranteed such that + * plane #0 is always Y, plane #1 is always U (Cb), and plane #2 is always V (Cr).

+ * + *

In contrast to the {@link #YUV_420_888} format, the Y-plane may have a pixel + * stride greater than 1 in + * {@link android.media.Image.Plane#getPixelStride() yPlane.getPixelStride()}.

+ * + *

The U/V planes are guaranteed to have the same row stride and pixel stride + * (in particular, + * {@link android.media.Image.Plane#getRowStride() uPlane.getRowStride()} + * == {@link android.media.Image.Plane#getRowStride() vPlane.getRowStride()} and + * {@link android.media.Image.Plane#getPixelStride() uPlane.getPixelStride()} + * == {@link android.media.Image.Plane#getPixelStride() vPlane.getPixelStride()}; + * ).

+ * + *

For example, the {@link android.media.Image} object can provide data + * in this format from a {@link android.media.MediaCodec} + * through {@link android.media.MediaCodec#getOutputImage} object.

+ * + * @see android.media.Image + * @see android.media.MediaCodec + */ + public static final int YUV_422_888 = 0x27; + + /** + *

Multi-plane Android YUV 444 format

+ * + *

This format is a generic YCbCr format, capable of describing any 4:4:4 + * (planar, semiplanar or interleaved) format, + * with 8 bits per color sample.

+ * + *

Images in this format are always represented by three separate buffers + * of data, one for each color plane. Additional information always + * accompanies the buffers, describing the row stride and the pixel stride + * for each plane.

+ * + *

The order of planes in the array returned by + * {@link android.media.Image#getPlanes() Image#getPlanes()} is guaranteed such that + * plane #0 is always Y, plane #1 is always U (Cb), and plane #2 is always V (Cr).

+ * + *

In contrast to the {@link #YUV_420_888} format, the Y-plane may have a pixel + * stride greater than 1 in + * {@link android.media.Image.Plane#getPixelStride() yPlane.getPixelStride()}.

+ * + *

The U/V planes are guaranteed to have the same row stride and pixel stride + * (in particular, + * {@link android.media.Image.Plane#getRowStride() uPlane.getRowStride()} + * == {@link android.media.Image.Plane#getRowStride() vPlane.getRowStride()} and + * {@link android.media.Image.Plane#getPixelStride() uPlane.getPixelStride()} + * == {@link android.media.Image.Plane#getPixelStride() vPlane.getPixelStride()}; + * ).

+ * + *

For example, the {@link android.media.Image} object can provide data + * in this format from a {@link android.media.MediaCodec} + * through {@link android.media.MediaCodec#getOutputImage} object.

+ * + * @see android.media.Image + * @see android.media.MediaCodec + */ + public static final int YUV_444_888 = 0x28; + + /** + *

Multi-plane Android RGB format

+ * + *

This format is a generic RGB format, capable of describing most RGB formats, + * with 8 bits per color sample.

+ * + *

Images in this format are always represented by three separate buffers + * of data, one for each color plane. Additional information always + * accompanies the buffers, describing the row stride and the pixel stride + * for each plane.

+ * + *

The order of planes in the array returned by + * {@link android.media.Image#getPlanes() Image#getPlanes()} is guaranteed such that + * plane #0 is always R (red), plane #1 is always G (green), and plane #2 is always B + * (blue).

+ * + *

All three planes are guaranteed to have the same row strides and pixel strides.

+ * + *

For example, the {@link android.media.Image} object can provide data + * in this format from a {@link android.media.MediaCodec} + * through {@link android.media.MediaCodec#getOutputImage} object.

+ * + * @see android.media.Image + * @see android.media.MediaCodec + */ + public static final int FLEX_RGB_888 = 0x29; + + /** + *

Multi-plane Android RGBA format

+ * + *

This format is a generic RGBA format, capable of describing most RGBA formats, + * with 8 bits per color sample.

+ * + *

Images in this format are always represented by four separate buffers + * of data, one for each color plane. Additional information always + * accompanies the buffers, describing the row stride and the pixel stride + * for each plane.

+ * + *

The order of planes in the array returned by + * {@link android.media.Image#getPlanes() Image#getPlanes()} is guaranteed such that + * plane #0 is always R (red), plane #1 is always G (green), plane #2 is always B (blue), + * and plane #3 is always A (alpha). This format may represent pre-multiplied or + * non-premultiplied alpha.

+ * + *

All four planes are guaranteed to have the same row strides and pixel strides.

+ * + *

For example, the {@link android.media.Image} object can provide data + * in this format from a {@link android.media.MediaCodec} + * through {@link android.media.MediaCodec#getOutputImage} object.

+ * + * @see android.media.Image + * @see android.media.MediaCodec + */ + public static final int FLEX_RGBA_8888 = 0x2A; + + /** *

General raw camera sensor image format, usually representing a * single-channel Bayer-mosaic image. Each pixel color sample is stored with * 16 bits of precision.

@@ -543,6 +672,14 @@ public class ImageFormat { return 12; case YUV_420_888: return 12; + case YUV_422_888: + return 16; + case YUV_444_888: + return 24; + case FLEX_RGB_888: + return 24; + case FLEX_RGBA_8888: + return 32; case RAW_SENSOR: return 16; case RAW10: @@ -574,6 +711,10 @@ public class ImageFormat { case JPEG: case NV21: case YUV_420_888: + case YUV_422_888: + case YUV_444_888: + case FLEX_RGB_888: + case FLEX_RGBA_8888: case RAW_SENSOR: case RAW10: case RAW12: diff --git a/media/java/android/media/Image.java b/media/java/android/media/Image.java index 9ae468a..75901fd 100644 --- a/media/java/android/media/Image.java +++ b/media/java/android/media/Image.java @@ -86,6 +86,38 @@ public abstract class Image implements AutoCloseable { * Each plane has its own row stride and pixel stride. * * + * {@link android.graphics.ImageFormat#YUV_422_888 YUV_422_888} + * 3 + * A luminance plane followed by the Cb and Cr chroma planes. + * The chroma planes have half the width and the full height of the luminance + * plane (4:2:2 subsampling). Each pixel sample in each plane has 8 bits. + * Each plane has its own row stride and pixel stride. + * + * + * {@link android.graphics.ImageFormat#YUV_444_888 YUV_444_888} + * 3 + * A luminance plane followed by the Cb and Cr chroma planes. + * The chroma planes have the same width and height as that of the luminance + * plane (4:4:4 subsampling). Each pixel sample in each plane has 8 bits. + * Each plane has its own row stride and pixel stride. + * + * + * {@link android.graphics.ImageFormat#FLEX_RGB_888 FLEX_RGB_888} + * 3 + * A R (red) plane followed by the G (green) and B (blue) planes. + * All planes have the same widths and heights. + * Each pixel sample in each plane has 8 bits. + * Each plane has its own row stride and pixel stride. + * + * + * {@link android.graphics.ImageFormat#FLEX_RGBA_8888 FLEX_RGBA_8888} + * 4 + * A R (red) plane followed by the G (green), B (blue), and + * A (alpha) planes. All planes have the same widths and heights. + * Each pixel sample in each plane has 8 bits. + * Each plane has its own row stride and pixel stride. + * + * * {@link android.graphics.ImageFormat#RAW_SENSOR RAW_SENSOR} * 1 * A single plane of raw sensor image data, with 16 bits per color diff --git a/media/java/android/media/ImageReader.java b/media/java/android/media/ImageReader.java index 3d8f9a0..e54525d 100644 --- a/media/java/android/media/ImageReader.java +++ b/media/java/android/media/ImageReader.java @@ -130,7 +130,7 @@ public class ImageReader implements AutoCloseable { *

*

* Opaque ImageReaders are more efficient to use when application access to - * image data is not necessary, comparing to ImageReaders using a non-opaque + * image data is not necessary, compared to ImageReaders using a non-opaque * format such as {@link ImageFormat#YUV_420_888 YUV_420_888}. *

* -- cgit v1.1