summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.txt3
-rw-r--r--api/system-current.txt3
-rw-r--r--core/java/android/hardware/camera2/CameraCharacteristics.java25
-rw-r--r--core/java/android/hardware/camera2/CameraMetadata.java47
-rw-r--r--core/java/android/hardware/camera2/impl/CameraMetadataNative.java5
-rw-r--r--core/java/android/hardware/camera2/params/StreamConfigurationMap.java83
6 files changed, 93 insertions, 73 deletions
diff --git a/api/current.txt b/api/current.txt
index 58130a6446ef..b31ec1f71d57 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -13571,6 +13571,8 @@ package android.hardware.camera2.params {
method public android.util.Range<java.lang.Integer>[] getHighSpeedVideoFpsRangesFor(android.util.Size);
method public android.util.Size[] getHighSpeedVideoSizes();
method public android.util.Size[] getHighSpeedVideoSizesFor(android.util.Range<java.lang.Integer>);
+ method public final int[] getInputFormats();
+ method public android.util.Size[] getInputSizes(int);
method public final int[] getOutputFormats();
method public long getOutputMinFrameDuration(int, android.util.Size);
method public long getOutputMinFrameDuration(java.lang.Class<T>, android.util.Size);
@@ -13578,6 +13580,7 @@ package android.hardware.camera2.params {
method public android.util.Size[] getOutputSizes(int);
method public long getOutputStallDuration(int, android.util.Size);
method public long getOutputStallDuration(java.lang.Class<T>, android.util.Size);
+ method public final int[] getValidOutputFormatsForInput(int);
method public boolean isOutputSupportedFor(int);
method public static boolean isOutputSupportedFor(java.lang.Class<T>);
method public boolean isOutputSupportedFor(android.view.Surface);
diff --git a/api/system-current.txt b/api/system-current.txt
index 4fcf9f05739f..12ebc177d82d 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -13863,6 +13863,8 @@ package android.hardware.camera2.params {
method public android.util.Range<java.lang.Integer>[] getHighSpeedVideoFpsRangesFor(android.util.Size);
method public android.util.Size[] getHighSpeedVideoSizes();
method public android.util.Size[] getHighSpeedVideoSizesFor(android.util.Range<java.lang.Integer>);
+ method public final int[] getInputFormats();
+ method public android.util.Size[] getInputSizes(int);
method public final int[] getOutputFormats();
method public long getOutputMinFrameDuration(int, android.util.Size);
method public long getOutputMinFrameDuration(java.lang.Class<T>, android.util.Size);
@@ -13870,6 +13872,7 @@ package android.hardware.camera2.params {
method public android.util.Size[] getOutputSizes(int);
method public long getOutputStallDuration(int, android.util.Size);
method public long getOutputStallDuration(java.lang.Class<T>, android.util.Size);
+ method public final int[] getValidOutputFormatsForInput(int);
method public boolean isOutputSupportedFor(int);
method public static boolean isOutputSupportedFor(java.lang.Class<T>);
method public boolean isOutputSupportedFor(android.view.Surface);
diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java
index f28c96e8d85a..bfe4aa2b885e 100644
--- a/core/java/android/hardware/camera2/CameraCharacteristics.java
+++ b/core/java/android/hardware/camera2/CameraCharacteristics.java
@@ -1107,8 +1107,7 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
* that can be configured and used simultaneously by a camera device.</p>
* <p>When set to 0, it means no input stream is supported.</p>
* <p>The image format for a input stream can be any supported
- * format provided by
- * android.scaler.availableInputOutputFormatsMap. When using an
+ * format returned by StreamConfigurationMap#getInputFormats. When using an
* input stream, there must be at least one output stream
* configured to to receive the reprocessed images.</p>
* <p>When an input stream and some output streams are used in a reprocessing request,
@@ -1408,12 +1407,12 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
* </thead>
* <tbody>
* <tr>
- * <td align="left">OPAQUE</td>
+ * <td align="left">PRIVATE (ImageFormat#PRIVATE)</td>
* <td align="left">JPEG</td>
* <td align="left">OPAQUE_REPROCESSING</td>
* </tr>
* <tr>
- * <td align="left">OPAQUE</td>
+ * <td align="left">PRIVATE</td>
* <td align="left">YUV_420_888</td>
* <td align="left">OPAQUE_REPROCESSING</td>
* </tr>
@@ -1429,25 +1428,23 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
* </tr>
* </tbody>
* </table>
- * <p>OPAQUE refers to a device-internal format that is not directly application-visible.
- * An OPAQUE input or output surface can be acquired by
- * OpaqueImageRingBufferQueue#getInputSurface() or
- * OpaqueImageRingBufferQueue#getOutputSurface().
- * For a OPAQUE_REPROCESSING-capable camera device, using the OPAQUE format
+ * <p>PRIVATE refers to a device-internal format that is not directly application-visible.
+ * A PRIVATE input surface can be acquired by
+ * ImageReader.newOpaqueInstance(width, height, maxImages).
+ * For a OPAQUE_REPROCESSING-capable camera device, using the PRIVATE format
* as either input or output will never hurt maximum frame rate (i.e.
- * StreamConfigurationMap#getOutputStallDuration(klass,Size) is always 0),
- * where klass is android.media.OpaqueImageRingBufferQueue.class.</p>
+ * StreamConfigurationMap#getOutputStallDuration(format, size) is always 0),
+ * where format is ImageFormat#PRIVATE.</p>
* <p>Attempting to configure an input stream with output streams not
* listed as available in this map is not valid.</p>
- * <p>TODO: typedef to ReprocessFormatMap</p>
* <p><b>Optional</b> - This value may be {@code null} on some devices.</p>
*
* @see CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES
* @see CameraCharacteristics#REQUEST_MAX_NUM_INPUT_STREAMS
* @hide
*/
- public static final Key<int[]> SCALER_AVAILABLE_INPUT_OUTPUT_FORMATS_MAP =
- new Key<int[]>("android.scaler.availableInputOutputFormatsMap", int[].class);
+ public static final Key<android.hardware.camera2.params.ReprocessFormatsMap> SCALER_AVAILABLE_INPUT_OUTPUT_FORMATS_MAP =
+ new Key<android.hardware.camera2.params.ReprocessFormatsMap>("android.scaler.availableInputOutputFormatsMap", android.hardware.camera2.params.ReprocessFormatsMap.class);
/**
* <p>The available stream configurations that this
diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java
index 85c574aa136f..2192ab74f5e8 100644
--- a/core/java/android/hardware/camera2/CameraMetadata.java
+++ b/core/java/android/hardware/camera2/CameraMetadata.java
@@ -448,17 +448,18 @@ public abstract class CameraMetadata<TKey> {
* <p>The camera device supports the Zero Shutter Lag reprocessing use case.</p>
* <ul>
* <li>One input stream is supported, that is, <code>{@link CameraCharacteristics#REQUEST_MAX_NUM_INPUT_STREAMS android.request.maxNumInputStreams} == 1</code>.</li>
- * <li>OPAQUE is supported as an output/input format, that is,
- * StreamConfigurationMap#getOutputSizes(klass) and
- * StreamConfigurationMap#getInputSizes(klass) return non empty Size[] and have common
- * sizes, where klass is android.media.OpaqueImageRingBufferQueue.class. See
- * android.scaler.availableInputOutputFormatsMap for detailed information about
- * OPAQUE format.</li>
- * <li>android.scaler.availableInputOutputFormatsMap has the required map entries.</li>
- * <li>Using OPAQUE does not cause a frame rate drop
+ * <li>ImageFormat#PRIVATE is supported as an output/input format, that is,
+ * ImageFormat#PRIVATE is included in the lists of formats returned by
+ * StreamConfigurationMap#getInputFormats and
+ * StreamConfigurationMap#getOutputFormats.</li>
+ * <li>StreamConfigurationMap#getValidOutputFormatsForInput returns non empty int[] for
+ * each supported input format returned by StreamConfigurationMap#getInputFormats.</li>
+ * <li>Each size returned by StreamConfigurationMap#getInputSizes(ImageFormat#PRIVATE)
+ * is also included in StreamConfigurationMap#getOutputSizes(ImageFormat#PRIVATE)</li>
+ * <li>Using ImageFormat#PRIVATE does not cause a frame rate drop
* relative to the sensor's maximum capture rate (at that
- * resolution), see android.scaler.availableInputOutputFormatsMap for more details.</li>
- * <li>OPAQUE will be reprocessable into both YUV_420_888
+ * resolution).</li>
+ * <li>ImageFormat#PRIVATE will be reprocessable into both YUV_420_888
* and JPEG formats.</li>
* <li>The maximum available resolution for OPAQUE streams
* (both input/output) will match the maximum available
@@ -539,27 +540,29 @@ public abstract class CameraMetadata<TKey> {
public static final int REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE = 6;
/**
- * <p>The camera device supports the YUV420_888 reprocessing use case, similar as
+ * <p>The camera device supports the YUV_420_888 reprocessing use case, similar as
* OPAQUE_REPROCESSING, This capability requires the camera device to support the
* following:</p>
* <ul>
* <li>One input stream is supported, that is, <code>{@link CameraCharacteristics#REQUEST_MAX_NUM_INPUT_STREAMS android.request.maxNumInputStreams} == 1</code>.</li>
- * <li>YUV420_888 is supported as a common format for both input and output, that is,
- * StreamConfigurationMap#getOutputSizes(YUV420_888) and
- * StreamConfigurationMap#getInputSizes(YUV420_888) return non empty Size[] and have
- * common sizes.</li>
- * <li>android.scaler.availableInputOutputFormatsMap has the required map entries.</li>
- * <li>Using YUV420_888 does not cause a frame rate drop
- * relative to the sensor's maximum capture rate (at that
- * resolution), see android.scaler.availableInputOutputFormatsMap for more details.</li>
- * <li>YUV420_888 will be reprocessable into both YUV_420_888
+ * <li>YUV_420_888 is supported as an output/input format, that is,
+ * YUV_420_888 is included in the lists of formats returned by
+ * StreamConfigurationMap#getInputFormats and
+ * StreamConfigurationMap#getOutputFormats.</li>
+ * <li>StreamConfigurationMap#getValidOutputFormatsForInput returns non empty int[] for
+ * each supported input format returned by StreamConfigurationMap#getInputFormats.</li>
+ * <li>Each size returned by StreamConfigurationMap#getInputSizes(YUV_420_888)
+ * is also included in StreamConfigurationMap#getOutputSizes(YUV_420_888)</li>
+ * <li>Using YUV_420_888 does not cause a frame rate drop
+ * relative to the sensor's maximum capture rate (at that resolution).</li>
+ * <li>YUV_420_888 will be reprocessable into both YUV_420_888
* and JPEG formats.</li>
- * <li>The maximum available resolution for YUV420_888 streams
+ * <li>The maximum available resolution for YUV_420_888 streams
* (both input/output) will match the maximum available
* resolution of JPEG streams.</li>
* <li>Only the below controls are effective for reprocessing requests and will be
* present in capture results. The reprocess requests are from the original capture
- * results that are assocaited with the intermidate YUV420_888 output buffers.
+ * results that are assocaited with the intermidate YUV_420_888 output buffers.
* All other controls in the reprocess requests will be ignored by the camera device.<ul>
* <li>android.jpeg.*</li>
* <li>{@link CaptureRequest#NOISE_REDUCTION_MODE android.noiseReduction.mode}</li>
diff --git a/core/java/android/hardware/camera2/impl/CameraMetadataNative.java b/core/java/android/hardware/camera2/impl/CameraMetadataNative.java
index e926a98d9c2b..b8b7d1203a09 100644
--- a/core/java/android/hardware/camera2/impl/CameraMetadataNative.java
+++ b/core/java/android/hardware/camera2/impl/CameraMetadataNative.java
@@ -48,6 +48,7 @@ import android.hardware.camera2.marshal.impl.MarshalQueryableString;
import android.hardware.camera2.params.Face;
import android.hardware.camera2.params.HighSpeedVideoConfiguration;
import android.hardware.camera2.params.LensShadingMap;
+import android.hardware.camera2.params.ReprocessFormatsMap;
import android.hardware.camera2.params.StreamConfiguration;
import android.hardware.camera2.params.StreamConfigurationDuration;
import android.hardware.camera2.params.StreamConfigurationMap;
@@ -838,11 +839,13 @@ public class CameraMetadataNative implements Parcelable {
CameraCharacteristics.DEPTH_AVAILABLE_DEPTH_STALL_DURATIONS);
HighSpeedVideoConfiguration[] highSpeedVideoConfigurations = getBase(
CameraCharacteristics.CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS);
+ ReprocessFormatsMap inputOutputFormatsMap = getBase(
+ CameraCharacteristics.SCALER_AVAILABLE_INPUT_OUTPUT_FORMATS_MAP);
return new StreamConfigurationMap(
configurations, minFrameDurations, stallDurations,
depthConfigurations, depthMinFrameDurations, depthStallDurations,
- highSpeedVideoConfigurations);
+ highSpeedVideoConfigurations, inputOutputFormatsMap);
}
private <T> Integer getMaxRegions(Key<T> key) {
diff --git a/core/java/android/hardware/camera2/params/StreamConfigurationMap.java b/core/java/android/hardware/camera2/params/StreamConfigurationMap.java
index b41897125c5e..c231692db2f9 100644
--- a/core/java/android/hardware/camera2/params/StreamConfigurationMap.java
+++ b/core/java/android/hardware/camera2/params/StreamConfigurationMap.java
@@ -92,8 +92,8 @@ public final class StreamConfigurationMap {
StreamConfiguration[] depthConfigurations,
StreamConfigurationDuration[] depthMinFrameDurations,
StreamConfigurationDuration[] depthStallDurations,
- HighSpeedVideoConfiguration[] highSpeedVideoConfigurations) {
-
+ HighSpeedVideoConfiguration[] highSpeedVideoConfigurations,
+ ReprocessFormatsMap inputOutputFormatsMap) {
mConfigurations = checkArrayElementsNotNull(configurations, "configurations");
mMinFrameDurations = checkArrayElementsNotNull(minFrameDurations, "minFrameDurations");
mStallDurations = checkArrayElementsNotNull(stallDurations, "stallDurations");
@@ -167,6 +167,8 @@ public final class StreamConfigurationMap {
}
mHighSpeedVideoFpsRangeMap.put(fpsRange, sizeCount + 1);
}
+
+ mInputOutputFormatsMap = inputOutputFormatsMap;
}
/**
@@ -188,17 +190,42 @@ public final class StreamConfigurationMap {
}
/**
- * Get the image {@code format} input formats in this stream configuration.
+ * Get the image {@code format} output formats for a reprocessing input format.
+ *
+ * <p>When submitting a {@link CaptureRequest} with an input Surface of a given format,
+ * the only allowed target outputs of the {@link CaptureRequest} are the ones with a format
+ * listed in the return value of this method. Including any other output Surface as a target
+ * will throw an IllegalArgumentException. If no output format is supported given the input
+ * format, an empty int[] will be returned.</p>
*
* <p>All image formats returned by this function will be defined in either {@link ImageFormat}
* or in {@link PixelFormat} (and there is no possibility of collision).</p>
*
+ * <p>Formats listed in this array are guaranteed to return true if queried with
+ * {@link #isOutputSupportedFor(int)}.</p>
+ *
* @return an array of integer format
*
* @see ImageFormat
* @see PixelFormat
+ */
+ public final int[] getValidOutputFormatsForInput(int inputFormat) {
+ if (mInputOutputFormatsMap == null) {
+ return new int[0];
+ }
+ return mInputOutputFormatsMap.getOutputs(inputFormat);
+ }
+
+ /**
+ * Get the image {@code format} input formats in this stream configuration.
*
- * @hide
+ * <p>All image formats returned by this function will be defined in either {@link ImageFormat}
+ * or in {@link PixelFormat} (and there is no possibility of collision).</p>
+ *
+ * @return an array of integer format
+ *
+ * @see ImageFormat
+ * @see PixelFormat
*/
public final int[] getInputFormats() {
return getPublicFormats(/*output*/false);
@@ -212,8 +239,6 @@ public final class StreamConfigurationMap {
*
* @param format a format from {@link #getInputFormats}
* @return a non-empty array of sizes, or {@code null} if the format was not available.
- *
- * @hide
*/
public Size[] getInputSizes(final int format) {
return getPublicFormatSizes(format, /*output*/false);
@@ -390,12 +415,11 @@ public final class StreamConfigurationMap {
* Get a list of sizes compatible with {@code klass} to use as an output.
*
* <p>Since some of the supported classes may support additional formats beyond
- * an opaque/implementation-defined (under-the-hood) format; this function only returns
- * sizes for the implementation-defined format.</p>
- *
- * <p>Some classes such as {@link android.media.ImageReader} may only support user-defined
- * formats; in particular {@link #isOutputSupportedFor(Class)} will return {@code true} for
- * that class and this method will return an empty array (but not {@code null}).</p>
+ * {@link ImageFormat#PRIVATE}; this function only returns
+ * sizes for {@link ImageFormat#PRIVATE}. For example, {@link android.media.ImageReader}
+ * supports {@link ImageFormat#YUV_420_888} and {@link ImageFormat#PRIVATE}, this method will
+ * only return the sizes for {@link ImageFormat#PRIVATE} for {@link android.media.ImageReader}
+ * class .</p>
*
* <p>If a well-defined format such as {@code NV21} is required, use
* {@link #getOutputSizes(int)} instead.</p>
@@ -406,19 +430,15 @@ public final class StreamConfigurationMap {
* @param klass
* a non-{@code null} {@link Class} object reference
* @return
- * an array of supported sizes for implementation-defined formats,
- * or {@code null} iff the {@code klass} is not a supported output
+ * an array of supported sizes for {@link ImageFormat#PRIVATE} format,
+ * or {@code null} iff the {@code klass} is not a supported output.
+ *
*
* @throws NullPointerException if {@code klass} was {@code null}
*
* @see #isOutputSupportedFor(Class)
*/
public <T> Size[] getOutputSizes(Class<T> klass) {
- // Image reader is "supported", but never for implementation-defined formats; return empty
- if (android.media.ImageReader.class.isAssignableFrom(klass)) {
- return new Size[0];
- }
-
if (isOutputSupportedFor(klass) == false) {
return null;
}
@@ -647,7 +667,7 @@ public final class StreamConfigurationMap {
* Get the minimum {@link CaptureRequest#SENSOR_FRAME_DURATION frame duration}
* for the class/size combination (in nanoseconds).
*
- * <p>This assumes a the {@code klass} is set up to use an implementation-defined format.
+ * <p>This assumes a the {@code klass} is set up to use {@link ImageFormat#PRIVATE}.
* For user-defined formats, use {@link #getOutputMinFrameDuration(int, Size)}.</p>
*
* <p>{@code klass} should be one of the ones which is supported by
@@ -791,7 +811,7 @@ public final class StreamConfigurationMap {
/**
* Get the stall duration for the class/size combination (in nanoseconds).
*
- * <p>This assumes a the {@code klass} is set up to use an implementation-defined format.
+ * <p>This assumes a the {@code klass} is set up to use {@link ImageFormat#PRIVATE}.
* For user-defined formats, use {@link #getOutputMinFrameDuration(int, Size)}.</p>
*
* <p>{@code klass} should be one of the ones with a non-empty array returned by
@@ -946,11 +966,11 @@ public final class StreamConfigurationMap {
*
* <p>In particular these formats are converted:
* <ul>
- * <li>HAL_PIXEL_FORMAT_BLOB => ImageFormat.JPEG
+ * <li>HAL_PIXEL_FORMAT_BLOB => ImageFormat.JPEG</li>
* </ul>
* </p>
*
- * <p>Passing in an implementation-defined format which has no public equivalent will fail;
+ * <p>Passing in a format which has no public equivalent will fail;
* as will passing in a public format which has a different internal format equivalent.
* See {@link #checkArgumentFormat} for more details about a legal public format.</p>
*
@@ -977,9 +997,6 @@ public final class StreamConfigurationMap {
case ImageFormat.JPEG:
throw new IllegalArgumentException(
"ImageFormat.JPEG is an unknown internal format");
- case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
- throw new IllegalArgumentException(
- "IMPLEMENTATION_DEFINED must not leak to public API");
default:
return format;
}
@@ -1066,8 +1083,7 @@ public final class StreamConfigurationMap {
* </ul>
* </p>
*
- * <p>Passing in an implementation-defined format here will fail (it's not a public format);
- * as will passing in an internal format which has a different public format equivalent.
+ * <p>Passing in an internal format which has a different public format equivalent will fail.
* See {@link #checkArgumentFormat} for more details about a legal public format.</p>
*
* <p>All other formats are returned as-is, no invalid check is performed.</p>
@@ -1090,9 +1106,6 @@ public final class StreamConfigurationMap {
return HAL_PIXEL_FORMAT_BLOB;
case ImageFormat.DEPTH16:
return HAL_PIXEL_FORMAT_Y16;
- case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
- throw new IllegalArgumentException(
- "IMPLEMENTATION_DEFINED is not allowed via public API");
default:
return format;
}
@@ -1214,8 +1227,7 @@ public final class StreamConfigurationMap {
int i = 0;
for (int format : getFormatsMap(output).keySet()) {
- if (format != HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED &&
- format != HAL_PIXEL_FORMAT_RAW_OPAQUE) {
+ if (format != HAL_PIXEL_FORMAT_RAW_OPAQUE) {
formats[i++] = imageFormatToPublic(format);
}
}
@@ -1280,9 +1292,6 @@ public final class StreamConfigurationMap {
HashMap<Integer, Integer> formatsMap = getFormatsMap(output);
int size = formatsMap.size();
- if (formatsMap.containsKey(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED)) {
- size -= 1;
- }
if (formatsMap.containsKey(HAL_PIXEL_FORMAT_RAW_OPAQUE)) {
size -= 1;
}
@@ -1332,6 +1341,7 @@ public final class StreamConfigurationMap {
private final StreamConfigurationDuration[] mDepthStallDurations;
private final HighSpeedVideoConfiguration[] mHighSpeedVideoConfigurations;
+ private final ReprocessFormatsMap mInputOutputFormatsMap;
/** ImageFormat -> num output sizes mapping */
private final HashMap</*ImageFormat*/Integer, /*Count*/Integer> mOutputFormats =
@@ -1350,3 +1360,4 @@ public final class StreamConfigurationMap {
mHighSpeedVideoFpsRangeMap = new HashMap<Range<Integer>, Integer>();
}
+