Add RAW_DEPTH image format

- Add support for opaque RAW_DEPTH image format.
- Add support for RAW_DEPTH in ImageReader.

Bug: 36015382
Test: testPDStats
Change-Id: Id77b8e9fb22c2616a938c394c9ddc6c34bfff655
This commit is contained in:
Emilian Peev
2017-03-17 19:54:30 +00:00
parent fbd54b4263
commit f7fec7397e
5 changed files with 34 additions and 2 deletions

View File

@ -1112,6 +1112,8 @@ public final class StreamConfigurationMap {
return ImageFormat.DEPTH_POINT_CLOUD;
case HAL_PIXEL_FORMAT_Y16:
return ImageFormat.DEPTH16;
case HAL_PIXEL_FORMAT_RAW16:
return ImageFormat.RAW_DEPTH;
case ImageFormat.JPEG:
throw new IllegalArgumentException(
"ImageFormat.JPEG is an unknown internal format");
@ -1179,6 +1181,8 @@ public final class StreamConfigurationMap {
return HAL_PIXEL_FORMAT_BLOB;
case ImageFormat.DEPTH16:
return HAL_PIXEL_FORMAT_Y16;
case ImageFormat.RAW_DEPTH:
return HAL_PIXEL_FORMAT_RAW16;
default:
return format;
}
@ -1220,6 +1224,7 @@ public final class StreamConfigurationMap {
return HAL_DATASPACE_V0_JFIF;
case ImageFormat.DEPTH_POINT_CLOUD:
case ImageFormat.DEPTH16:
case ImageFormat.RAW_DEPTH:
return HAL_DATASPACE_DEPTH;
default:
return HAL_DATASPACE_UNKNOWN;
@ -1609,6 +1614,8 @@ public final class StreamConfigurationMap {
return "DEPTH16";
case ImageFormat.DEPTH_POINT_CLOUD:
return "DEPTH_POINT_CLOUD";
case ImageFormat.RAW_DEPTH:
return "RAW_DEPTH";
case ImageFormat.PRIVATE:
return "PRIVATE";
default:

View File

@ -135,6 +135,7 @@ int android_view_Surface_mapPublicFormatToHalFormat(PublicFormat f) {
case PublicFormat::DEPTH16:
return HAL_PIXEL_FORMAT_Y16;
case PublicFormat::RAW_SENSOR:
case PublicFormat::RAW_DEPTH:
return HAL_PIXEL_FORMAT_RAW16;
default:
// Most formats map 1:1
@ -149,6 +150,7 @@ android_dataspace android_view_Surface_mapPublicFormatToHalDataspace(
return HAL_DATASPACE_V0_JFIF;
case PublicFormat::DEPTH_POINT_CLOUD:
case PublicFormat::DEPTH16:
case PublicFormat::RAW_DEPTH:
return HAL_DATASPACE_DEPTH;
case PublicFormat::RAW_SENSOR:
case PublicFormat::RAW_PRIVATE:
@ -182,8 +184,12 @@ PublicFormat android_view_Surface_mapHalFormatDataspaceToPublicFormat(
// Enums overlap in both name and value
return static_cast<PublicFormat>(format);
case HAL_PIXEL_FORMAT_RAW16:
// Name differs, though value is the same
return PublicFormat::RAW_SENSOR;
switch (dataSpace) {
case HAL_DATASPACE_DEPTH:
return PublicFormat::RAW_DEPTH;
default:
return PublicFormat::RAW_SENSOR;
}
case HAL_PIXEL_FORMAT_RAW_OPAQUE:
// Name differs, though value is the same
return PublicFormat::RAW_PRIVATE;

View File

@ -53,6 +53,7 @@ enum class PublicFormat {
RGBA_1010102 = 0x2b,
JPEG = 0x100,
DEPTH_POINT_CLOUD = 0x101,
RAW_DEPTH = 0x1002, // @hide
YV12 = 0x32315659,
Y8 = 0x20203859, // @hide
Y16 = 0x20363159, // @hide

View File

@ -661,6 +661,15 @@ public class ImageFormat {
*/
public static final int DEPTH_POINT_CLOUD = 0x101;
/**
* Unprocessed implementation-dependent raw
* depth measurements, opaque with 16 bit
* samples.
*
* @hide
*/
public static final int RAW_DEPTH = 0x1002;
/**
* Android private opaque image format.
* <p>
@ -723,6 +732,7 @@ public class ImageFormat {
return 24;
case FLEX_RGBA_8888:
return 32;
case RAW_DEPTH:
case RAW_SENSOR:
return 16;
case RAW10:
@ -765,6 +775,7 @@ public class ImageFormat {
case DEPTH16:
case DEPTH_POINT_CLOUD:
case PRIVATE:
case RAW_DEPTH:
return true;
}

View File

@ -62,6 +62,7 @@ class ImageUtils {
case ImageFormat.RAW12:
case ImageFormat.DEPTH16:
case ImageFormat.DEPTH_POINT_CLOUD:
case ImageFormat.RAW_DEPTH:
return 1;
case ImageFormat.PRIVATE:
return 0;
@ -103,6 +104,10 @@ class ImageUtils {
throw new IllegalArgumentException(
"Copy of RAW_OPAQUE format has not been implemented");
}
if (src.getFormat() == ImageFormat.RAW_DEPTH) {
throw new IllegalArgumentException(
"Copy of RAW_DEPTH format has not been implemented");
}
if (!(dst.getOwner() instanceof ImageWriter)) {
throw new IllegalArgumentException("Destination image is not from ImageWriter. Only"
+ " the images from ImageWriter are writable");
@ -206,6 +211,7 @@ class ImageUtils {
case PixelFormat.RGB_565:
case ImageFormat.YUY2:
case ImageFormat.Y16:
case ImageFormat.RAW_DEPTH:
case ImageFormat.RAW_SENSOR:
case ImageFormat.RAW_PRIVATE: // round estimate, real size is unknown
case ImageFormat.DEPTH16:
@ -253,6 +259,7 @@ class ImageUtils {
case ImageFormat.RAW_SENSOR:
case ImageFormat.RAW10:
case ImageFormat.RAW12:
case ImageFormat.RAW_DEPTH:
return new Size(image.getWidth(), image.getHeight());
case ImageFormat.PRIVATE:
return new Size(0, 0);