Camera: Add HEIC encoding support

- Add new BlobId to specify JPEG APP segments.
- Add new gralloc usage flag for HEIC encoder.

Test: testHeic CTS test
Bug: 79465976
Change-Id: Ie70654504eecb280e3a51b60c104124035c5fbe5
This commit is contained in:
Shuzhen Wang 2019-01-24 16:32:31 -08:00
parent 77972f7c48
commit f43b544c0e
2 changed files with 23 additions and 11 deletions

View file

@ -196,6 +196,10 @@
* stream_configuration_counter to camera3_stream_configuration_t to address the potential
* race condition between signal_stream_flush() call and configure_streams() call.
*
* - Add CAMERA3_JPEG_APP_SEGMENTS_BLOB_ID to support BLOB with only JPEG apps
* segments and thumbnail (without main image bitstream). Camera framework
* uses such stream togerther with a HAL YUV_420_888/IMPLEMENTATION_DEFINED
* stream to encode HEIC (ISO/IEC 23008-12) image.
*/
/**
@ -1964,21 +1968,25 @@ typedef struct camera3_stream_buffer_set {
/**
* camera3_jpeg_blob:
*
* Transport header for compressed JPEG buffers in output streams.
* Transport header for compressed JPEG or JPEG_APP_SEGMENTS buffers in output streams.
*
* To capture JPEG images, a stream is created using the pixel format
* To capture JPEG or JPEG_APP_SEGMENTS images, a stream is created using the pixel format
* HAL_PIXEL_FORMAT_BLOB. The buffer size for the stream is calculated by the
* framework, based on the static metadata field android.jpeg.maxSize. Since
* compressed JPEG images are of variable size, the HAL needs to include the
* final size of the compressed image using this structure inside the output
* stream buffer. The JPEG blob ID field must be set to CAMERA3_JPEG_BLOB_ID.
* framework, based on the static metadata field android.jpeg.maxSize for JPEG,
* and android.jpeg.maxAppsSegments for JPEG_APP_SEGMENTS.
*
* Transport header should be at the end of the JPEG output stream buffer. That
* Since compressed JPEG/JPEG_APP_SEGMENTS images are of variable size, the HAL needs to
* include the final size of the image using this structure inside the output
* stream buffer. The JPEG blob ID field must be set to CAMERA3_JPEG_BLOB_ID for
* JPEG and CAMERA3_JPEG_APP_SEGMENTS_BLOB_ID for APP segments.
*
* Transport header should be at the end of the output stream buffer. That
* means the jpeg_blob_id must start at byte[buffer_size -
* sizeof(camera3_jpeg_blob)], where the buffer_size is the size of gralloc buffer.
* Any HAL using this transport header must account for it in android.jpeg.maxSize
* The JPEG data itself starts at the beginning of the buffer and should be
* jpeg_size bytes long.
* The blob data itself starts at the beginning of the buffer and should be
* jpeg_size bytes long. HAL using this transport header for JPEG must account for
* it in android.jpeg.maxSize. For JPEG APP segments, camera framework makes
* sure that the output stream buffer is large enough for the transport header.
*/
typedef struct camera3_jpeg_blob {
uint16_t jpeg_blob_id;
@ -1986,7 +1994,8 @@ typedef struct camera3_jpeg_blob {
} camera3_jpeg_blob_t;
enum {
CAMERA3_JPEG_BLOB_ID = 0x00FF
CAMERA3_JPEG_BLOB_ID = 0x00FF,
CAMERA3_JPEG_APP_SEGMENTS_BLOB_ID = 0x0100,
};
/**********************************************************************

View file

@ -131,6 +131,9 @@ enum {
* handle this flag. */
GRALLOC_USAGE_FOREIGN_BUFFERS = 0x00200000U,
/* buffer will be used as input to HW HEIC image encoder */
GRALLOC_USAGE_HW_IMAGE_ENCODER = 0x08000000U,
/* Mask of all flags which could be passed to a gralloc module for buffer
* allocation. Any flags not in this mask do not need to be handled by
* gralloc modules. */