diff options
| author | 2021-02-16 19:27:13 +0000 | |
|---|---|---|
| committer | 2021-02-16 19:27:13 +0000 | |
| commit | 1cc73a9adf8a46bc63a16430d2d78ddd778ff045 (patch) | |
| tree | 3f17be63c717c2d128473ac2fa090c3a018f73c5 | |
| parent | 766326b69ae9ba43e1df927a7bfbf4d3f1501e01 (diff) | |
| parent | 534a9ba1b52b5a518d24d7b492f731a2a5509a25 (diff) | |
Merge "ImageWriter: Convert Blob native format to respective public value" into sc-dev
| -rw-r--r-- | core/java/android/hardware/camera2/params/StreamConfigurationMap.java | 15 | ||||
| -rw-r--r-- | media/java/android/media/ImageWriter.java | 20 |
2 files changed, 32 insertions, 3 deletions
diff --git a/core/java/android/hardware/camera2/params/StreamConfigurationMap.java b/core/java/android/hardware/camera2/params/StreamConfigurationMap.java index 8bb0b184ce02..10a814acd70b 100644 --- a/core/java/android/hardware/camera2/params/StreamConfigurationMap.java +++ b/core/java/android/hardware/camera2/params/StreamConfigurationMap.java @@ -1917,9 +1917,18 @@ public final class StreamConfigurationMap { (3 << HAL_DATASPACE_TRANSFER_SHIFT) | (1 << HAL_DATASPACE_RANGE_SHIFT); - private static final int HAL_DATASPACE_DEPTH = 0x1000; - private static final int HAL_DATASPACE_DYNAMIC_DEPTH = 0x1002; - private static final int HAL_DATASPACE_HEIF = 0x1003; + /** + * @hide + */ + public static final int HAL_DATASPACE_DEPTH = 0x1000; + /** + * @hide + */ + public static final int HAL_DATASPACE_DYNAMIC_DEPTH = 0x1002; + /** + * @hide + */ + public static final int HAL_DATASPACE_HEIF = 0x1003; private static final long DURATION_20FPS_NS = 50000000L; /** * @see #getDurations(int, int) diff --git a/media/java/android/media/ImageWriter.java b/media/java/android/media/ImageWriter.java index 92db946ab5ba..44f8385b715e 100644 --- a/media/java/android/media/ImageWriter.java +++ b/media/java/android/media/ImageWriter.java @@ -23,6 +23,7 @@ import android.graphics.ImageFormat; import android.graphics.ImageFormat.Format; import android.graphics.PixelFormat; import android.graphics.Rect; +import android.hardware.camera2.params.StreamConfigurationMap; import android.hardware.camera2.utils.SurfaceUtils; import android.hardware.HardwareBuffer; import android.os.Handler; @@ -202,6 +203,25 @@ public class ImageWriter implements AutoCloseable { if (format == ImageFormat.UNKNOWN) { format = SurfaceUtils.getSurfaceFormat(surface); } + // Several public formats use the same native HAL_PIXEL_FORMAT_BLOB. The native + // allocation estimation sequence depends on the public formats values. To avoid + // possible errors, convert where necessary. + if (format == StreamConfigurationMap.HAL_PIXEL_FORMAT_BLOB) { + int surfaceDataspace = SurfaceUtils.getSurfaceDataspace(surface); + switch (surfaceDataspace) { + case StreamConfigurationMap.HAL_DATASPACE_DEPTH: + format = ImageFormat.DEPTH_POINT_CLOUD; + break; + case StreamConfigurationMap.HAL_DATASPACE_DYNAMIC_DEPTH: + format = ImageFormat.DEPTH_JPEG; + break; + case StreamConfigurationMap.HAL_DATASPACE_HEIF: + format = ImageFormat.HEIC; + break; + default: + format = ImageFormat.JPEG; + } + } // Estimate the native buffer allocation size and register it so it gets accounted for // during GC. Note that this doesn't include the buffers required by the buffer queue // itself and the buffers requested by the producer. |