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

Commit 4e49f18a authored by Dichen Zhang's avatar Dichen Zhang
Browse files

JPEG/R: add restriction to max_display_boost input from user

Change-Id: I82c24c285fb01cab57ec004f1440ac9b5adacc39
parent b916b204
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -19,6 +19,10 @@

#include "jpegrerrorcode.h"

#ifndef FLT_MAX
#define FLT_MAX 0x1.fffffep127f
#endif

namespace android::jpegrecoverymap {

// Color gamuts for image data
@@ -206,7 +210,8 @@ public:
     *
     * @param compressed_jpegr_image compressed JPEGR image.
     * @param dest destination of the uncompressed JPEGR image.
     * @param max_display_boost (optional) the maximum available boost supported by a display
     * @param max_display_boost (optional) the maximum available boost supported by a display,
     *                          the value must be greater than or equal to 1.0.
     * @param exif destination of the decoded EXIF metadata. The default value is NULL where the
                   decoder will do nothing about it. If configured not NULL the decoder will write
                   EXIF data into this structure. The format is defined in {@code jpegr_exif_struct}
@@ -235,7 +240,7 @@ public:
     */
    status_t decodeJPEGR(jr_compressed_ptr compressed_jpegr_image,
                         jr_uncompressed_ptr dest,
                         float max_display_boost = -1.0f,
                         float max_display_boost = FLT_MAX,
                         jr_exif_ptr exif = nullptr,
                         jpegr_output_format output_format = JPEGR_OUTPUT_HDR_LINEAR,
                         jr_uncompressed_ptr recovery_map = nullptr,
+5 −3
Original line number Diff line number Diff line
@@ -339,6 +339,10 @@ status_t JpegR::decodeJPEGR(jr_compressed_ptr compressed_jpegr_image,
    return ERROR_JPEGR_INVALID_NULL_PTR;
  }

  if (max_display_boost < 1.0f) {
      return ERROR_JPEGR_INVALID_INPUT_TYPE;
  }

  if (output_format == JPEGR_OUTPUT_SDR) {
    JpegDecoderHelper jpeg_decoder;
    if (!jpeg_decoder.decompressImage(compressed_jpegr_image->data, compressed_jpegr_image->length,
@@ -680,9 +684,7 @@ status_t JpegR::applyRecoveryMap(jr_uncompressed_ptr uncompressed_yuv_420_image,
  dest->width = uncompressed_yuv_420_image->width;
  dest->height = uncompressed_yuv_420_image->height;
  ShepardsIDW idwTable(kMapDimensionScaleFactor);
  float display_boost = max_display_boost > 0 ?
          std::min(max_display_boost, metadata->maxContentBoost)
          : metadata->maxContentBoost;
  float display_boost = std::min(max_display_boost, metadata->maxContentBoost);
  RecoveryLUT recoveryLUT(metadata, display_boost);

  JobQueue jobQueue;