diff options
| -rw-r--r-- | libs/jpegrecoverymap/include/jpegrecoverymap/recoverymap.h | 64 | ||||
| -rw-r--r-- | libs/jpegrecoverymap/recoverymap.cpp | 20 |
2 files changed, 75 insertions, 9 deletions
diff --git a/libs/jpegrecoverymap/include/jpegrecoverymap/recoverymap.h b/libs/jpegrecoverymap/include/jpegrecoverymap/recoverymap.h index 31f1872491..d8647b6737 100644 --- a/libs/jpegrecoverymap/include/jpegrecoverymap/recoverymap.h +++ b/libs/jpegrecoverymap/include/jpegrecoverymap/recoverymap.h @@ -18,6 +18,13 @@ namespace android::recoverymap { +typedef enum { + JPEGR_COLORSPACE_UNSPECIFIED, + JPEGR_COLORSPACE_BT709, + JPEGR_COLORSPACE_P3, + JPEGR_COLORSPACE_BT2100, +} jpegr_color_space; + /* * Holds information for uncompressed image or recovery map. */ @@ -28,6 +35,8 @@ struct jpegr_uncompressed_struct { int width; // Height of the recovery map or image in pixels. int height; + // Color space. + jpegr_color_space colorSpace; }; /* @@ -36,12 +45,25 @@ struct jpegr_uncompressed_struct { struct jpegr_compressed_struct { // Pointer to the data location. void* data; + // Data length. + int length; + // Color space. + jpegr_color_space colorSpace; +}; + +/* + * Holds information for EXIF metadata. + */ +struct jpegr_exif_struct { + // Pointer to the data location. + void* data; // Data length; int length; }; typedef struct jpegr_uncompressed_struct* jr_uncompressed_ptr; typedef struct jpegr_compressed_struct* jr_compressed_ptr; +typedef struct jpegr_exif_struct* jr_exif_ptr; class RecoveryMap { public: @@ -53,14 +75,24 @@ public: * @param uncompressed_p010_image uncompressed HDR image in P010 color format * @param uncompressed_yuv_420_image uncompressed SDR image in YUV_420 color format * @param dest destination of the compressed JPEGR image + * @param quality target quality of the JPEG encoding, must be in range of 0-100 where 100 is + * the highest quality + * @param exif pointer to the exif metadata. + * @param hdr_ratio HDR ratio. If not configured, this value will be calculated by the JPEG/R + * encoder. * @return NO_ERROR if encoding succeeds, error code if error occurs. */ status_t encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image, jr_uncompressed_ptr uncompressed_yuv_420_image, - void* dest); + void* dest, + int quality, + jr_exif_ptr exif, + float hdr_ratio = 0.0f); /* - * Compress JPEGR image from 10-bit HDR YUV and 8-bit SDR YUV. + * Compress JPEGR image from 10-bit HDR YUV, 8-bit SDR YUV and compressed 8-bit JPEG. + * + * This method requires HAL Hardware JPEG encoder. * * Generate recovery map from the HDR and SDR inputs, append the recovery map to the end of the * compressed JPEG. @@ -68,35 +100,57 @@ public: * @param uncompressed_yuv_420_image uncompressed SDR image in YUV_420 color format * @param compressed_jpeg_image compressed 8-bit JPEG image * @param dest destination of the compressed JPEGR image + * @param hdr_ratio HDR ratio. If not configured, this value will be calculated by the JPEG/R + * encoder. * @return NO_ERROR if encoding succeeds, error code if error occurs. */ status_t encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image, jr_uncompressed_ptr uncompressed_yuv_420_image, void* compressed_jpeg_image, - void* dest); + void* dest, + float hdr_ratio = 0.0f); /* * Compress JPEGR image from 10-bit HDR YUV and 8-bit SDR YUV. * + * This method requires HAL Hardware JPEG encoder. + * * Decode the compressed 8-bit JPEG image to YUV SDR, generate recovery map from the HDR input * and the decoded SDR result, append the recovery map to the end of the compressed JPEG. * @param uncompressed_p010_image uncompressed HDR image in P010 color format * @param compressed_jpeg_image compressed 8-bit JPEG image * @param dest destination of the compressed JPEGR image + * @param hdr_ratio HDR ratio. If not configured, this value will be calculated by the JPEG/R + * encoder. * @return NO_ERROR if encoding succeeds, error code if error occurs. */ status_t encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image, void* compressed_jpeg_image, - void* dest); + void* dest, + float hdr_ratio = 0.0f); /* * Decompress JPEGR image. * * @param compressed_jpegr_image compressed JPEGR image * @param dest destination of the uncompressed JPEGR image + * @param exif destination of the decoded EXIF metadata. Default value is nullptr where EXIF + * metadata will not be decoded. + * @param request_sdr flag that request SDR output, default to false (request HDR output). If + * set to true, decoder will only decode the primary image which is SDR. + * Setting of request_sdr and input source (HDR or SDR) can be found in + * the table below: + * | input source | request_sdr | output of decoding | + * | HDR | true | SDR | + * | HDR | false | HDR | + * | SDR | true | SDR | + * | SDR | false | SDR | * @return NO_ERROR if decoding succeeds, error code if error occurs. */ - status_t decodeJPEGR(void* compressed_jpegr_image, jr_uncompressed_ptr dest); + status_t decodeJPEGR(void* compressed_jpegr_image, + jr_uncompressed_ptr dest, + jr_exif_ptr exif = nullptr, + bool request_sdr = false); private: /* * This method is called in the decoding pipeline. It will decode the recovery map. diff --git a/libs/jpegrecoverymap/recoverymap.cpp b/libs/jpegrecoverymap/recoverymap.cpp index 67c23e9788..7cedae9e0b 100644 --- a/libs/jpegrecoverymap/recoverymap.cpp +++ b/libs/jpegrecoverymap/recoverymap.cpp @@ -20,13 +20,20 @@ namespace android::recoverymap { status_t RecoveryMap::encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image, jr_uncompressed_ptr uncompressed_yuv_420_image, - void* dest) { + void* dest, + int quality, + jr_exif_ptr /* exif */, + float /* hdr_ratio */) { if (uncompressed_p010_image == nullptr || uncompressed_yuv_420_image == nullptr || dest == nullptr) { return ERROR_JPEGR_INVALID_NULL_PTR; } + if (quality < 0 || quality > 100) { + return ERROR_JPEGR_INVALID_INPUT_TYPE; + } + // TBD return NO_ERROR; } @@ -34,7 +41,8 @@ status_t RecoveryMap::encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image, status_t RecoveryMap::encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image, jr_uncompressed_ptr uncompressed_yuv_420_image, void* compressed_jpeg_image, - void* dest) { + void* dest, + float /* hdr_ratio */) { if (uncompressed_p010_image == nullptr || uncompressed_yuv_420_image == nullptr @@ -49,7 +57,8 @@ status_t RecoveryMap::encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image, status_t RecoveryMap::encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image, void* compressed_jpeg_image, - void* dest) { + void* dest, + float /* hdr_ratio */) { if (uncompressed_p010_image == nullptr || compressed_jpeg_image == nullptr || dest == nullptr) { @@ -60,7 +69,10 @@ status_t RecoveryMap::encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image, return NO_ERROR; } -status_t RecoveryMap::decodeJPEGR(void* compressed_jpegr_image, jr_uncompressed_ptr dest) { +status_t RecoveryMap::decodeJPEGR(void* compressed_jpegr_image, + jr_uncompressed_ptr dest, + jr_exif_ptr /* exif */, + bool /* request_sdr */) { if (compressed_jpegr_image == nullptr || dest == nullptr) { return ERROR_JPEGR_INVALID_NULL_PTR; } |