Add YCBCR_P210 format
YCBCR_P210 is a 10-bit 4:2:2 YCbCr color format.
Add the definition in HardwareBuffer, ImageFormat, and MediaCodecInfo.
Test: New tests pass
Flag: android.media.codec.p210_format_support
Bug: 368395888
Merged-In: I515478ecd1aa4aa22346f4a88bd900f6c3e97889
Change-Id: I515478ecd1aa4aa22346f4a88bd900f6c3e97889
diff --git a/core/api/current.txt b/core/api/current.txt
index e2feb20..7974a4b 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -16231,6 +16231,7 @@
field public static final int UNKNOWN = 0; // 0x0
field public static final int Y8 = 538982489; // 0x20203859
field public static final int YCBCR_P010 = 54; // 0x36
+ field @FlaggedApi("android.media.codec.p210_format_support") public static final int YCBCR_P210 = 60; // 0x3c
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
@@ -18579,6 +18580,7 @@
field public static final long USAGE_VIDEO_ENCODE = 65536L; // 0x10000L
field public static final int YCBCR_420_888 = 35; // 0x23
field public static final int YCBCR_P010 = 54; // 0x36
+ field @FlaggedApi("android.media.codec.p210_format_support") public static final int YCBCR_P210 = 60; // 0x3c
}
@FlaggedApi("android.hardware.flags.overlayproperties_class_api") public final class OverlayProperties implements android.os.Parcelable {
@@ -22870,6 +22872,7 @@
field public static final int COLOR_FormatYUV444Flexible = 2135181448; // 0x7f444888
field @Deprecated public static final int COLOR_FormatYUV444Interleaved = 29; // 0x1d
field public static final int COLOR_FormatYUVP010 = 54; // 0x36
+ field @FlaggedApi("android.media.codec.p210_format_support") public static final int COLOR_FormatYUVP210 = 60; // 0x3c
field @Deprecated public static final int COLOR_QCOM_FormatYUV420SemiPlanar = 2141391872; // 0x7fa30c00
field @Deprecated public static final int COLOR_TI_FormatYUV420PackedSemiPlanar = 2130706688; // 0x7f000100
field public static final String FEATURE_AdaptivePlayback = "adaptive-playback";
diff --git a/core/java/android/hardware/HardwareBuffer.java b/core/java/android/hardware/HardwareBuffer.java
index ce0f9f59..0e73978 100644
--- a/core/java/android/hardware/HardwareBuffer.java
+++ b/core/java/android/hardware/HardwareBuffer.java
@@ -66,6 +66,7 @@
DS_FP32UI8,
S_UI8,
YCBCR_P010,
+ YCBCR_P210,
R_8,
R_16,
RG_1616,
@@ -111,6 +112,16 @@
* little-endian value, with the lower 6 bits set to zero.
*/
public static final int YCBCR_P010 = 0x36;
+ /**
+ * <p>Android YUV P210 format.</p>
+ *
+ * P210 is a 4:2:2 YCbCr semiplanar format comprised of a WxH Y plane
+ * followed by a WxH CbCr plane. Each sample is represented by a 16-bit
+ * little-endian value, with the lower 6 bits set to zero.
+ */
+ @FlaggedApi(android.media.codec.Flags.FLAG_P210_FORMAT_SUPPORT)
+ public static final int YCBCR_P210 = 0x3c;
+
/** Format: 8 bits red */
@FlaggedApi(com.android.graphics.hwui.flags.Flags.FLAG_REQUESTED_FORMATS_V)
public static final int R_8 = 0x38;
diff --git a/graphics/java/android/graphics/ImageFormat.java b/graphics/java/android/graphics/ImageFormat.java
index cb3b64c..93d94c9 100644
--- a/graphics/java/android/graphics/ImageFormat.java
+++ b/graphics/java/android/graphics/ImageFormat.java
@@ -16,6 +16,7 @@
package android.graphics;
+import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import java.lang.annotation.Retention;
@@ -41,6 +42,7 @@
Y8,
Y16,
YCBCR_P010,
+ YCBCR_P210,
NV16,
NV21,
YUY2,
@@ -206,6 +208,26 @@
public static final int YCBCR_P010 = 0x36;
/**
+ * <p>Android YUV P210 format.</p>
+ *
+ * P210 is a 4:2:2 YCbCr semiplanar format comprised of a WxH Y plane
+ * followed by a WxH CbCr plane. Each sample is represented by a 16-bit
+ * little-endian value, with the lower 6 bits set to zero.
+ *
+ * <p>For example, the {@link android.media.Image} object can provide data
+ * in this format from a {@link android.hardware.camera2.CameraDevice}
+ * through a {@link android.media.ImageReader} object if this format is
+ * supported by {@link android.hardware.camera2.CameraDevice}.</p>
+ *
+ * @see android.media.Image
+ * @see android.media.ImageReader
+ * @see android.hardware.camera2.CameraDevice
+ *
+ */
+ @FlaggedApi(android.media.codec.Flags.FLAG_P210_FORMAT_SUPPORT)
+ public static final int YCBCR_P210 = 0x3c;
+
+ /**
* YCbCr format, used for video.
*
* <p>For the {@link android.hardware.camera2} API, the {@link #YUV_420_888} format is
@@ -849,6 +871,8 @@
return 16;
case YCBCR_P010:
return 24;
+ case YCBCR_P210:
+ return 32;
case RAW_DEPTH10:
case RAW10:
return 10;
@@ -899,7 +923,9 @@
case JPEG_R:
return true;
}
-
+ if (android.media.codec.Flags.p210FormatSupport() && format == YCBCR_P210) {
+ return true;
+ }
return false;
}
}
diff --git a/media/java/android/media/MediaCodecInfo.java b/media/java/android/media/MediaCodecInfo.java
index 8ff4305..3a19f46 100644
--- a/media/java/android/media/MediaCodecInfo.java
+++ b/media/java/android/media/MediaCodecInfo.java
@@ -462,6 +462,33 @@
@SuppressLint("AllUpper")
public static final int COLOR_FormatYUVP010 = 54;
+ /**
+ * P210 is 10-bit-per component 4:2:2 YCbCr semiplanar format.
+ * <p>
+ * This format uses 32 allocated bits per pixel with 20 bits of
+ * data per pixel. Chroma planes are subsampled by 2 both
+ * horizontally. Each chroma and luma component
+ * has 16 allocated bits in little-endian configuration with 10
+ * MSB of actual data.
+ *
+ * <pre>
+ * byte byte
+ * <--------- i --------> | <------ i + 1 ------>
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * | UNUSED | Y/Cb/Cr |
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ * 0 5 6 7 0 7
+ * bit
+ * </pre>
+ *
+ * Use this format with {@link Image}. This format corresponds
+ * to {@link android.graphics.ImageFormat#YCBCR_P210}.
+ * <p>
+ */
+ @SuppressLint("AllUpper")
+ @FlaggedApi(android.media.codec.Flags.FLAG_P210_FORMAT_SUPPORT)
+ public static final int COLOR_FormatYUVP210 = 60;
+
/** @deprecated Use {@link #COLOR_FormatYUV420Flexible}. */
public static final int COLOR_TI_FormatYUV420PackedSemiPlanar = 0x7f000100;
// COLOR_FormatSurface indicates that the data will be a GraphicBuffer metadata reference.