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

Commit cc024ecd authored by Ravneet Dhanjal's avatar Ravneet Dhanjal
Browse files

Camera: Enable 10-bit in extensions

- Add format YCBCR_P010 along with ability to
set dynamic range and color space for advanced
extensions
- Enable support for synthetic keys in extensions
to allow dynamic range and color space camera characteristics
to be set in the extensions

Test: Camera CTS on CF, checked if dynamic range +
color space was propogated to CameraService
Bug: 316375635

Change-Id: I1c721ecca8f180700db91bb570a39abb6837bfa7
parent 487d8fa9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4911,7 +4911,6 @@ package android.hardware.camera2.extension {
    method @FlaggedApi("com.android.internal.camera.flags.concert_mode") public int getImageFormat();
    method @FlaggedApi("com.android.internal.camera.flags.concert_mode") @NonNull public android.util.Size getSize();
    method @FlaggedApi("com.android.internal.camera.flags.concert_mode") @NonNull public android.view.Surface getSurface();
    method @FlaggedApi("com.android.internal.camera.flags.extension_10_bit") public void setColorSpace(int);
    method @FlaggedApi("com.android.internal.camera.flags.extension_10_bit") public void setDynamicRangeProfile(long);
  }
@@ -4922,6 +4921,7 @@ package android.hardware.camera2.extension {
  @FlaggedApi("com.android.internal.camera.flags.concert_mode") public class ExtensionConfiguration {
    ctor @FlaggedApi("com.android.internal.camera.flags.concert_mode") public ExtensionConfiguration(int, int, @NonNull java.util.List<android.hardware.camera2.extension.ExtensionOutputConfiguration>, @Nullable android.hardware.camera2.CaptureRequest);
    method @FlaggedApi("com.android.internal.camera.flags.extension_10_bit") public void setColorSpace(int);
  }
  @FlaggedApi("com.android.internal.camera.flags.concert_mode") public class ExtensionOutputConfiguration {
+36 −14
Original line number Diff line number Diff line
@@ -180,6 +180,16 @@ public final class CameraExtensionCharacteristics {
            EXTENSION_HDR,
            EXTENSION_NIGHT};

    /**
     * List of synthetic CameraCharacteristics keys that are supported in the extensions.
     */
    private static final List<CameraCharacteristics.Key>
            SUPPORTED_SYNTHETIC_CAMERA_CHARACTERISTICS =
            Arrays.asList(
                    CameraCharacteristics.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES,
                    CameraCharacteristics.REQUEST_AVAILABLE_COLOR_SPACE_PROFILES
            );

    private final Context mContext;
    private final String mCameraId;
    private final Map<String, CameraCharacteristics> mCharacteristicsMap;
@@ -874,11 +884,17 @@ public final class CameraExtensionCharacteristics {
                Class<CameraCharacteristics.Key<?>> keyTyped =
                        (Class<CameraCharacteristics.Key<?>>) key;

                // Do not include synthetic keys. Including synthetic keys leads to undefined
                // behavior. This causes inclusion of capabilities that may not be supported in
                // camera extensions.
                ret.addAll(chars.getAvailableKeyList(CameraCharacteristics.class, keyTyped, keys,
                        /*includeSynthetic*/ false));

                // Add synthetic keys to the available key list if they are part of the supported
                // synthetic camera characteristic key list
                for (CameraCharacteristics.Key charKey :
                        SUPPORTED_SYNTHETIC_CAMERA_CHARACTERISTICS) {
                    if (chars.get(charKey) != null) {
                        ret.add(charKey);
                    }
                }
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Failed to query the extension for all available keys! Extension "
@@ -990,6 +1006,7 @@ public final class CameraExtensionCharacteristics {
                    case ImageFormat.YUV_420_888:
                    case ImageFormat.JPEG:
                    case ImageFormat.JPEG_R:
                    case ImageFormat.YCBCR_P010:
                        break;
                    default:
                        throw new IllegalArgumentException("Unsupported format: " + format);
@@ -1021,8 +1038,9 @@ public final class CameraExtensionCharacteristics {
                    return generateJpegSupportedSizes(
                            extenders.second.getSupportedPostviewResolutions(sz),
                                    streamMap);
                }  else if (format == ImageFormat.JPEG_R) {
                    // Jpeg_R/UltraHDR is currently not supported in the basic extension case
                }  else if (format == ImageFormat.JPEG_R || format == ImageFormat.YCBCR_P010) {
                    // Jpeg_R/UltraHDR + YCBCR_P010 is currently not supported in the basic
                    // extension case
                    return new ArrayList<>();
                } else {
                    throw new IllegalArgumentException("Unsupported format: " + format);
@@ -1118,16 +1136,16 @@ public final class CameraExtensionCharacteristics {
     *
     * <p>Device-specific extensions currently support at most three
     * multi-frame capture surface formats. ImageFormat.JPEG will be supported by all
     * extensions while ImageFormat.YUV_420_888 and ImageFormat.JPEG_R may or may not be
     * supported.</p>
     * extensions while ImageFormat.YUV_420_888, ImageFormat.JPEG_R, or ImageFormat.YCBCR_P010
     * may or may not be supported.</p>
     *
     * @param extension the extension type
     * @param format    device-specific extension output format
     * @return non-modifiable list of available sizes or an empty list if the format is not
     * supported.
     * @throws IllegalArgumentException in case of format different from ImageFormat.JPEG,
     *                                  ImageFormat.YUV_420_888, ImageFormat.JPEG_R; or
     *                                  unsupported extension.
     *                                  ImageFormat.YUV_420_888, ImageFormat.JPEG_R,
     *                                  ImageFormat.YCBCR_P010; or unsupported extension.
     */
    public @NonNull
    List<Size> getExtensionSupportedSizes(@Extension int extension, int format) {
@@ -1151,6 +1169,7 @@ public final class CameraExtensionCharacteristics {
                        case ImageFormat.YUV_420_888:
                        case ImageFormat.JPEG:
                        case ImageFormat.JPEG_R:
                        case ImageFormat.YCBCR_P010:
                            break;
                        default:
                            throw new IllegalArgumentException("Unsupported format: " + format);
@@ -1183,8 +1202,9 @@ public final class CameraExtensionCharacteristics {
                        } else {
                            return generateSupportedSizes(null, format, streamMap);
                        }
                    } else if (format == ImageFormat.JPEG_R) {
                        // Jpeg_R/UltraHDR is currently not supported in the basic extension case
                    } else if (format == ImageFormat.JPEG_R || format == ImageFormat.YCBCR_P010) {
                        // Jpeg_R/UltraHDR + YCBCR_P010 is currently not supported in the
                        // basic extension case
                        return new ArrayList<>();
                    } else {
                        throw new IllegalArgumentException("Unsupported format: " + format);
@@ -1213,7 +1233,8 @@ public final class CameraExtensionCharacteristics {
     * @return the range of estimated minimal and maximal capture latency in milliseconds
     * or null if no capture latency info can be provided
     * @throws IllegalArgumentException in case of format different from {@link ImageFormat#JPEG},
     *                                  {@link ImageFormat#YUV_420_888}, {@link ImageFormat#JPEG_R};
     *                                  {@link ImageFormat#YUV_420_888}, {@link ImageFormat#JPEG_R}
     *                                  {@link ImageFormat#YCBCR_P010};
     *                                  or unsupported extension.
     */
    public @Nullable Range<Long> getEstimatedCaptureLatencyRangeMillis(@Extension int extension,
@@ -1222,6 +1243,7 @@ public final class CameraExtensionCharacteristics {
            case ImageFormat.YUV_420_888:
            case ImageFormat.JPEG:
            case ImageFormat.JPEG_R:
            case ImageFormat.YCBCR_P010:
                //No op
                break;
            default:
@@ -1269,8 +1291,8 @@ public final class CameraExtensionCharacteristics {
                    // specific and cannot be estimated accurately enough.
                    return  null;
                }
                if (format == ImageFormat.JPEG_R) {
                    // JpegR/UltraHDR is not supported for basic extensions
                if (format == ImageFormat.JPEG_R || format == ImageFormat.YCBCR_P010) {
                    // JpegR/UltraHDR + YCBCR_P010 is not supported for basic extensions
                    return null;
                }

+7 −1
Original line number Diff line number Diff line
@@ -61,7 +61,6 @@ public abstract class AdvancedExtender {
    private CameraUsageTracker mCameraUsageTracker;
    private static final String TAG = "AdvancedExtender";


    /**
     * Initialize a camera extension advanced extender instance.
     *
@@ -263,6 +262,13 @@ public abstract class AdvancedExtender {
     *
     * <p>For example, an extension may limit the zoom ratio range. In this case, an OEM can return
     * a new zoom ratio range for the key {@link CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE}.
     *
     * <p> Currently, the only synthetic keys supported for override are
     * {@link CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES} and
     * {@link CameraCharacteristics#REQUEST_AVAILABLE_COLOR_SPACE_PROFILES}. To enable them, an OEM
     * should override the respective native keys
     * {@link CameraCharacteristics#REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES_MAP} and
     *  {@link CameraCharacteristics#REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP}.
     */
    @FlaggedApi(Flags.FLAG_CAMERA_EXTENSIONS_CHARACTERISTICS_GET)
    @NonNull
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ parcelable CameraOutputConfig
    int imageFormat;
    int capacity;
    long usage;
    long dynamicRangeProfile;

    const int TYPE_SURFACE = 0;
    const int TYPE_IMAGEREADER = 1;
+0 −11
Original line number Diff line number Diff line
@@ -133,15 +133,4 @@ public final class CameraOutputSurface {
            @DynamicRangeProfiles.Profile long dynamicRangeProfile) {
        mOutputSurface.dynamicRangeProfile = dynamicRangeProfile;
    }

    /**
     * Set the color space. The default colorSpace
     * will be
     * {@link android.hardware.camera2.params.ColorSpaceProfiles.UNSPECIFIED}
     * unless explicitly set using this method.
     */
    @FlaggedApi(Flags.FLAG_EXTENSION_10_BIT)
    public void setColorSpace(int colorSpace) {
        mOutputSurface.colorSpace = colorSpace;
    }
}
Loading