Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95cbb9fb authored by Dichen Zhang's avatar Dichen Zhang
Browse files

libjpegrecoverymap: refactor encode APIs

1. remove hdr_ratio as an input parameter
2. pass quality into encoder

Bug: b/252835416
Test: build

Change-Id: If877e153f786e9b7daeacb7a65ab1296455faf67
parent 28fc04d6
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -82,16 +82,13 @@ public:
     * @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,
                         jr_compressed_ptr dest,
                         int quality,
                         jr_exif_ptr exif,
                         float hdr_ratio = 0.0f);
                         jr_exif_ptr exif);

    /*
     * Compress JPEGR image from 10-bit HDR YUV, 8-bit SDR YUV and compressed 8-bit JPEG.
@@ -104,15 +101,12 @@ 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,
                         jr_compressed_ptr compressed_jpeg_image,
                         jr_compressed_ptr dest,
                         float hdr_ratio = 0.0f);
                         jr_compressed_ptr dest);

    /*
     * Compress JPEGR image from 10-bit HDR YUV and 8-bit SDR YUV.
@@ -125,14 +119,11 @@ public:
     * @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,
                         jr_compressed_ptr compressed_jpeg_image,
                         jr_compressed_ptr dest,
                         float hdr_ratio = 0.0f);
                         jr_compressed_ptr dest);

    /*
     * Decompress JPEGR image.
+4 −8
Original line number Diff line number Diff line
@@ -64,8 +64,7 @@ status_t RecoveryMap::encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image,
                                  jr_uncompressed_ptr uncompressed_yuv_420_image,
                                  jr_compressed_ptr dest,
                                  int quality,
                                  jr_exif_ptr /* exif */,
                                  float /* hdr_ratio */) {
                                  jr_exif_ptr /* exif */) {
  if (uncompressed_p010_image == nullptr
   || uncompressed_yuv_420_image == nullptr
   || dest == nullptr) {
@@ -93,11 +92,10 @@ status_t RecoveryMap::encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image,
  JPEGR_CHECK(compressRecoveryMap(&map, &compressed_map));

  JpegEncoder jpeg_encoder;
  // TODO: what quality to use?
  // TODO: ICC data - need color space information
  if (!jpeg_encoder.compressImage(uncompressed_yuv_420_image->data,
                                  uncompressed_yuv_420_image->width,
                                  uncompressed_yuv_420_image->height, 95, nullptr, 0)) {
                                  uncompressed_yuv_420_image->height, quality, nullptr, 0)) {
    return ERROR_JPEGR_ENCODE_ERROR;
  }
  jpegr_compressed_struct jpeg;
@@ -112,8 +110,7 @@ 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,
                                  jr_compressed_ptr compressed_jpeg_image,
                                  jr_compressed_ptr dest,
                                  float /* hdr_ratio */) {
                                  jr_compressed_ptr dest) {
  if (uncompressed_p010_image == nullptr
   || uncompressed_yuv_420_image == nullptr
   || compressed_jpeg_image == nullptr
@@ -144,8 +141,7 @@ status_t RecoveryMap::encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image,

status_t RecoveryMap::encodeJPEGR(jr_uncompressed_ptr uncompressed_p010_image,
                                  jr_compressed_ptr compressed_jpeg_image,
                                  jr_compressed_ptr dest,
                                  float /* hdr_ratio */) {
                                  jr_compressed_ptr dest) {
  if (uncompressed_p010_image == nullptr
   || compressed_jpeg_image == nullptr
   || dest == nullptr) {