Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 741dcc52 authored by Emilian Peev's avatar Emilian Peev
Browse files

Camera: Add support for Jpeg/R

Introduce support for the new Jpeg/R format that includes 10-bit recovery
map.

Bug: 241284696
Test: atest -c -d
cts/tests/camera/src/android/hardware/camera2/cts/ImageReaderTest.java#testJpegR

Change-Id: I85f4cf130ab37b351595608943c92ce2844c40cb
parent d741b93f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -15032,6 +15032,7 @@ package android.graphics {
    field public static final int FLEX_RGB_888 = 41; // 0x29
    field public static final int HEIC = 1212500294; // 0x48454946
    field public static final int JPEG = 256; // 0x100
    field public static final int JPEG_R = 4101; // 0x1005
    field public static final int NV16 = 16; // 0x10
    field public static final int NV21 = 17; // 0x11
    field public static final int PRIVATE = 34; // 0x22
@@ -17213,6 +17214,7 @@ package android.hardware {
    field public static final int DATASPACE_DYNAMIC_DEPTH = 4098; // 0x1002
    field public static final int DATASPACE_HEIF = 4100; // 0x1004
    field public static final int DATASPACE_JFIF = 146931712; // 0x8c20000
    field public static final int DATASPACE_JPEG_R = 4101; // 0x1005
    field public static final int DATASPACE_SCRGB = 411107328; // 0x18810000
    field public static final int DATASPACE_SCRGB_LINEAR = 406913024; // 0x18410000
    field public static final int DATASPACE_SRGB = 142671872; // 0x8810000
+14 −0
Original line number Diff line number Diff line
@@ -408,6 +408,19 @@ public final class DataSpace {
     */
    public static final int DATASPACE_HEIF = 4100;

    /**
     * ISO/IEC TBD
     *
     * JPEG image with embedded recovery map following the Jpeg/R specification.
     *
     * <p>This value must always remain aligned with the public ImageFormat Jpeg/R definition and is
     * valid with formats:
     *    HAL_PIXEL_FORMAT_BLOB: JPEG image encoded by Jpeg/R encoder according to ISO/IEC TBD.
     * The image contains a standard SDR JPEG and a recovery map. Jpeg/R decoders can use the
     * map to recover the input image.</p>
     */
     public static final int DATASPACE_JPEG_R = 4101;

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(flag = true, value = {
@@ -626,6 +639,7 @@ public final class DataSpace {
        DATASPACE_DEPTH,
        DATASPACE_DYNAMIC_DEPTH,
        DATASPACE_HEIF,
        DATASPACE_JPEG_R,
        DATASPACE_UNKNOWN,
        DATASPACE_SCRGB_LINEAR,
        DATASPACE_SRGB,
+109 −0
Original line number Diff line number Diff line
@@ -5562,6 +5562,115 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
    public static final Key<Integer> AUTOMOTIVE_LOCATION =
            new Key<Integer>("android.automotive.location", int.class);

    /**
     * <p>The available Jpeg/R stream
     * configurations that this camera device supports
     * (i.e. format, width, height, output/input stream).</p>
     * <p>The configurations are listed as <code>(format, width, height, input?)</code> tuples.</p>
     * <p>If the camera device supports Jpeg/R, it will support the same stream combinations with
     * Jpeg/R as it does with P010. The stream combinations with Jpeg/R (or P010) supported
     * by the device is determined by the device's hardware level and capabilities.</p>
     * <p>All the static, control, and dynamic metadata tags related to JPEG apply to Jpeg/R formats.
     * Configuring JPEG and Jpeg/R streams at the same time is not supported.</p>
     * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p>
     * <p><b>Limited capability</b> -
     * Present on all camera devices that report being at least {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED HARDWARE_LEVEL_LIMITED} devices in the
     * {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL android.info.supportedHardwareLevel} key</p>
     *
     * @see CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL
     * @hide
     */
    public static final Key<android.hardware.camera2.params.StreamConfiguration[]> JPEGR_AVAILABLE_JPEG_R_STREAM_CONFIGURATIONS =
            new Key<android.hardware.camera2.params.StreamConfiguration[]>("android.jpegr.availableJpegRStreamConfigurations", android.hardware.camera2.params.StreamConfiguration[].class);

    /**
     * <p>This lists the minimum frame duration for each
     * format/size combination for Jpeg/R output formats.</p>
     * <p>This should correspond to the frame duration when only that
     * stream is active, with all processing (typically in android.*.mode)
     * set to either OFF or FAST.</p>
     * <p>When multiple streams are used in a request, the minimum frame
     * duration will be max(individual stream min durations).</p>
     * <p>See {@link CaptureRequest#SENSOR_FRAME_DURATION android.sensor.frameDuration} and
     * android.scaler.availableStallDurations for more details about
     * calculating the max frame rate.</p>
     * <p><b>Units</b>: (format, width, height, ns) x n</p>
     * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p>
     * <p><b>Limited capability</b> -
     * Present on all camera devices that report being at least {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED HARDWARE_LEVEL_LIMITED} devices in the
     * {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL android.info.supportedHardwareLevel} key</p>
     *
     * @see CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL
     * @see CaptureRequest#SENSOR_FRAME_DURATION
     * @hide
     */
    public static final Key<android.hardware.camera2.params.StreamConfigurationDuration[]> JPEGR_AVAILABLE_JPEG_R_MIN_FRAME_DURATIONS =
            new Key<android.hardware.camera2.params.StreamConfigurationDuration[]>("android.jpegr.availableJpegRMinFrameDurations", android.hardware.camera2.params.StreamConfigurationDuration[].class);

    /**
     * <p>This lists the maximum stall duration for each
     * output format/size combination for Jpeg/R streams.</p>
     * <p>A stall duration is how much extra time would get added
     * to the normal minimum frame duration for a repeating request
     * that has streams with non-zero stall.</p>
     * <p>This functions similarly to
     * android.scaler.availableStallDurations for Jpeg/R
     * streams.</p>
     * <p>All Jpeg/R output stream formats may have a nonzero stall
     * duration.</p>
     * <p><b>Units</b>: (format, width, height, ns) x n</p>
     * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p>
     * <p><b>Limited capability</b> -
     * Present on all camera devices that report being at least {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED HARDWARE_LEVEL_LIMITED} devices in the
     * {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL android.info.supportedHardwareLevel} key</p>
     *
     * @see CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL
     * @hide
     */
    public static final Key<android.hardware.camera2.params.StreamConfigurationDuration[]> JPEGR_AVAILABLE_JPEG_R_STALL_DURATIONS =
            new Key<android.hardware.camera2.params.StreamConfigurationDuration[]>("android.jpegr.availableJpegRStallDurations", android.hardware.camera2.params.StreamConfigurationDuration[].class);

    /**
     * <p>The available Jpeg/R stream
     * configurations that this camera device supports
     * (i.e. format, width, height, output/input stream).</p>
     * <p>Refer to android.jpegr.availableJpegRStreamConfigurations for details.</p>
     * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p>
     * @hide
     */
    public static final Key<android.hardware.camera2.params.StreamConfiguration[]> JPEGR_AVAILABLE_JPEG_R_STREAM_CONFIGURATIONS_MAXIMUM_RESOLUTION =
            new Key<android.hardware.camera2.params.StreamConfiguration[]>("android.jpegr.availableJpegRStreamConfigurationsMaximumResolution", android.hardware.camera2.params.StreamConfiguration[].class);

    /**
     * <p>This lists the minimum frame duration for each
     * format/size combination for Jpeg/R output formats for CaptureRequests where
     * {@link CaptureRequest#SENSOR_PIXEL_MODE android.sensor.pixelMode} is set to
     * {@link android.hardware.camera2.CameraMetadata#SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION }.</p>
     * <p>Refer to android.jpegr.availableJpegRMinFrameDurations for details.</p>
     * <p><b>Units</b>: (format, width, height, ns) x n</p>
     * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p>
     *
     * @see CaptureRequest#SENSOR_PIXEL_MODE
     * @hide
     */
    public static final Key<android.hardware.camera2.params.StreamConfigurationDuration[]> JPEGR_AVAILABLE_JPEG_R_MIN_FRAME_DURATIONS_MAXIMUM_RESOLUTION =
            new Key<android.hardware.camera2.params.StreamConfigurationDuration[]>("android.jpegr.availableJpegRMinFrameDurationsMaximumResolution", android.hardware.camera2.params.StreamConfigurationDuration[].class);

    /**
     * <p>This lists the maximum stall duration for each
     * output format/size combination for Jpeg/R streams for CaptureRequests where
     * {@link CaptureRequest#SENSOR_PIXEL_MODE android.sensor.pixelMode} is set to
     * {@link android.hardware.camera2.CameraMetadata#SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION }.</p>
     * <p>Refer to android.jpegr.availableJpegRStallDurations for details.</p>
     * <p><b>Units</b>: (format, width, height, ns) x n</p>
     * <p><b>Optional</b> - The value for this key may be {@code null} on some devices.</p>
     *
     * @see CaptureRequest#SENSOR_PIXEL_MODE
     * @hide
     */
    public static final Key<android.hardware.camera2.params.StreamConfigurationDuration[]> JPEGR_AVAILABLE_JPEG_R_STALL_DURATIONS_MAXIMUM_RESOLUTION =
            new Key<android.hardware.camera2.params.StreamConfigurationDuration[]>("android.jpegr.availableJpegRStallDurationsMaximumResolution", android.hardware.camera2.params.StreamConfigurationDuration[].class);

    /*~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~
     * End generated code
     *~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~O@*/
+22 −0
Original line number Diff line number Diff line
@@ -859,6 +859,28 @@ public abstract class CameraDevice implements AutoCloseable {
     * format {@link android.graphics.ImageFormat#YUV_420_888} with a 10-bit profile
     * will cause a capture session initialization failure.
     * </p>
     * <p>{@link android.graphics.ImageFormat#JPEG_R} may also be supported if advertised by
     * {@link android.hardware.camera2.params.StreamConfigurationMap}. When initializing a capture
     * session that includes a Jpeg/R camera output clients must consider the following items w.r.t.
     * the 10-bit mandatory stream combination table:
     *
     * <ul>
     *     <li>To generate the compressed Jpeg/R image a single
     *     {@link android.graphics.ImageFormat#YCBCR_P010} output will be used internally by
     *     the camera device.</li>
     *     <li>On camera devices that are able to support concurrent 10 and 8-bit capture requests
     *     see {@link android.hardware.camera2.params.DynamicRangeProfiles#getProfileCaptureRequestConstraints}
     *     an extra {@link android.graphics.ImageFormat#JPEG} will also
     *     be configured internally to help speed up the encoding process.</li>
     * </ul>
     *
     * Jpeg/R camera outputs will typically be able to support the MAXIMUM device resolution.
     * Clients can also call {@link StreamConfigurationMap#getOutputSizes(int)} for a complete list
     * supported sizes.
     * Camera clients that register a Jpeg/R output within a stream combination that doesn't fit
     * in the mandatory stream table above can call
     * {@link CameraDevice#isSessionConfigurationSupported} to ensure that this particular
     * configuration is supported.</p>
     *
     * <p>Devices with the STREAM_USE_CASE capability ({@link
     * CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES} includes {@link
+26 −0
Original line number Diff line number Diff line
@@ -1351,6 +1351,9 @@ public class CameraMetadataNative implements Parcelable {
                            /*heicconfiguration*/ null,
                            /*heicminduration*/ null,
                            /*heicstallduration*/ null,
                            /*jpegRconfiguration*/ null,
                            /*jpegRminduration*/ null,
                            /*jpegRstallduration*/ null,
                            /*highspeedvideoconfigurations*/ null,
                            /*inputoutputformatsmap*/ null, listHighResolution, supportsPrivate[i]);
                    break;
@@ -1365,6 +1368,9 @@ public class CameraMetadataNative implements Parcelable {
                            /*heicconfiguration*/ null,
                            /*heicminduration*/ null,
                            /*heicstallduration*/ null,
                            /*jpegRconfiguration*/ null,
                            /*jpegRminduration*/ null,
                            /*jpegRstallduration*/ null,
                            highSpeedVideoConfigurations,
                            /*inputoutputformatsmap*/ null, listHighResolution, supportsPrivate[i]);
                    break;
@@ -1379,6 +1385,9 @@ public class CameraMetadataNative implements Parcelable {
                            /*heicconfiguration*/ null,
                            /*heicminduration*/ null,
                            /*heicstallduration*/ null,
                            /*jpegRconfiguration*/ null,
                            /*jpegRminduration*/ null,
                            /*jpegRstallduration*/ null,
                            /*highSpeedVideoConfigurations*/ null,
                            inputOutputFormatsMap, listHighResolution, supportsPrivate[i]);
                    break;
@@ -1393,6 +1402,9 @@ public class CameraMetadataNative implements Parcelable {
                            /*heicconfiguration*/ null,
                            /*heicminduration*/ null,
                            /*heicstallduration*/ null,
                            /*jpegRconfiguration*/ null,
                            /*jpegRminduration*/ null,
                            /*jpegRstallduration*/ null,
                            /*highSpeedVideoConfigurations*/ null,
                            /*inputOutputFormatsMap*/ null, listHighResolution, supportsPrivate[i]);
            }
@@ -1546,6 +1558,12 @@ public class CameraMetadataNative implements Parcelable {
                CameraCharacteristics.HEIC_AVAILABLE_HEIC_MIN_FRAME_DURATIONS);
        StreamConfigurationDuration[] heicStallDurations = getBase(
                CameraCharacteristics.HEIC_AVAILABLE_HEIC_STALL_DURATIONS);
        StreamConfiguration[] jpegRConfigurations = getBase(
                CameraCharacteristics.JPEGR_AVAILABLE_JPEG_R_STREAM_CONFIGURATIONS);
        StreamConfigurationDuration[] jpegRMinFrameDurations = getBase(
                CameraCharacteristics.JPEGR_AVAILABLE_JPEG_R_MIN_FRAME_DURATIONS);
        StreamConfigurationDuration[] jpegRStallDurations = getBase(
                CameraCharacteristics.JPEGR_AVAILABLE_JPEG_R_STALL_DURATIONS);
        HighSpeedVideoConfiguration[] highSpeedVideoConfigurations = getBase(
                CameraCharacteristics.CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS);
        ReprocessFormatsMap inputOutputFormatsMap = getBase(
@@ -1557,6 +1575,7 @@ public class CameraMetadataNative implements Parcelable {
                dynamicDepthConfigurations, dynamicDepthMinFrameDurations,
                dynamicDepthStallDurations, heicConfigurations,
                heicMinFrameDurations, heicStallDurations,
                jpegRConfigurations, jpegRMinFrameDurations, jpegRStallDurations,
                highSpeedVideoConfigurations, inputOutputFormatsMap,
                listHighResolution);
    }
@@ -1589,6 +1608,12 @@ public class CameraMetadataNative implements Parcelable {
                CameraCharacteristics.HEIC_AVAILABLE_HEIC_MIN_FRAME_DURATIONS_MAXIMUM_RESOLUTION);
        StreamConfigurationDuration[] heicStallDurations = getBase(
                CameraCharacteristics.HEIC_AVAILABLE_HEIC_STALL_DURATIONS_MAXIMUM_RESOLUTION);
        StreamConfiguration[] jpegRConfigurations = getBase(
                CameraCharacteristics.JPEGR_AVAILABLE_JPEG_R_STREAM_CONFIGURATIONS_MAXIMUM_RESOLUTION);
        StreamConfigurationDuration[] jpegRMinFrameDurations = getBase(
                CameraCharacteristics.JPEGR_AVAILABLE_JPEG_R_MIN_FRAME_DURATIONS_MAXIMUM_RESOLUTION);
        StreamConfigurationDuration[] jpegRStallDurations = getBase(
                CameraCharacteristics.JPEGR_AVAILABLE_JPEG_R_STALL_DURATIONS_MAXIMUM_RESOLUTION);
        HighSpeedVideoConfiguration[] highSpeedVideoConfigurations = getBase(
                CameraCharacteristics.CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS_MAXIMUM_RESOLUTION);
        ReprocessFormatsMap inputOutputFormatsMap = getBase(
@@ -1601,6 +1626,7 @@ public class CameraMetadataNative implements Parcelable {
                dynamicDepthConfigurations, dynamicDepthMinFrameDurations,
                dynamicDepthStallDurations, heicConfigurations,
                heicMinFrameDurations, heicStallDurations,
                jpegRConfigurations, jpegRMinFrameDurations, jpegRStallDurations,
                highSpeedVideoConfigurations, inputOutputFormatsMap,
                listHighResolution, false);
    }
Loading