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

Commit e8b23cf5 authored by Nick Deakin's avatar Nick Deakin Committed by Automerger Merge Worker
Browse files

ultrahdr: update metadata requirements am: 094946bd

parents 8b58cc0d 094946bd
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -249,7 +249,7 @@ void UltraHdrEncFuzzer::process() {
                        jpegGainMap.data = gainMapEncoder.getCompressedImagePtr();
                        jpegGainMap.data = gainMapEncoder.getCompressedImagePtr();
                        jpegGainMap.colorGamut = ULTRAHDR_COLORGAMUT_UNSPECIFIED;
                        jpegGainMap.colorGamut = ULTRAHDR_COLORGAMUT_UNSPECIFIED;
                        ultrahdr_metadata_struct metadata;
                        ultrahdr_metadata_struct metadata;
                        metadata.version = "1.3.1";
                        metadata.version = "1.0";
                        if (tf == ULTRAHDR_TF_HLG) {
                        if (tf == ULTRAHDR_TF_HLG) {
                            metadata.maxContentBoost = kHlgMaxNits / kSdrWhiteNits;
                            metadata.maxContentBoost = kHlgMaxNits / kSdrWhiteNits;
                        } else if (tf == ULTRAHDR_TF_PQ) {
                        } else if (tf == ULTRAHDR_TF_PQ) {
@@ -258,6 +258,11 @@ void UltraHdrEncFuzzer::process() {
                            metadata.maxContentBoost = 1.0f;
                            metadata.maxContentBoost = 1.0f;
                        }
                        }
                        metadata.minContentBoost = 1.0f;
                        metadata.minContentBoost = 1.0f;
                        metadata.gamma = 1.0f;
                        metadata.offsetSdr = 0.0f;
                        metadata.offsetHdr = 0.0f;
                        metadata.hdrCapacityMin = 1.0f;
                        metadata.hdrCapacityMax = metadata.maxContentBoost;
                        status = jpegHdr.encodeJPEGR(&jpegImg, &jpegGainMap, &metadata, &jpegImgR);
                        status = jpegHdr.encodeJPEGR(&jpegImg, &jpegGainMap, &metadata, &jpegImgR);
                    }
                    }
                }
                }
+8 −0
Original line number Original line Diff line number Diff line
@@ -414,6 +414,10 @@ void transformYuv420(jr_uncompressed_ptr image, size_t x_chroma, size_t y_chroma
/*
/*
 * Calculate the 8-bit unsigned integer gain value for the given SDR and HDR
 * Calculate the 8-bit unsigned integer gain value for the given SDR and HDR
 * luminances in linear space, and the hdr ratio to encode against.
 * luminances in linear space, and the hdr ratio to encode against.
 *
 * Note: since this library always uses gamma of 1.0, offsetSdr of 0.0, and
 * offsetHdr of 0.0, this function doesn't handle different metadata values for
 * these fields.
 */
 */
uint8_t encodeGain(float y_sdr, float y_hdr, ultrahdr_metadata_ptr metadata);
uint8_t encodeGain(float y_sdr, float y_hdr, ultrahdr_metadata_ptr metadata);
uint8_t encodeGain(float y_sdr, float y_hdr, ultrahdr_metadata_ptr metadata,
uint8_t encodeGain(float y_sdr, float y_hdr, ultrahdr_metadata_ptr metadata,
@@ -422,6 +426,10 @@ uint8_t encodeGain(float y_sdr, float y_hdr, ultrahdr_metadata_ptr metadata,
/*
/*
 * Calculates the linear luminance in nits after applying the given gain
 * Calculates the linear luminance in nits after applying the given gain
 * value, with the given hdr ratio, to the given sdr input in the range [0, 1].
 * value, with the given hdr ratio, to the given sdr input in the range [0, 1].
 *
 * Note: similar to encodeGain(), this function only supports gamma 1.0,
 * offsetSdr 0.0, offsetHdr 0.0, hdrCapacityMin 1.0, and hdrCapacityMax equal to
 * gainMapMax, as this library encodes.
 */
 */
Color applyGain(Color e, float gain, ultrahdr_metadata_ptr metadata);
Color applyGain(Color e, float gain, ultrahdr_metadata_ptr metadata);
Color applyGain(Color e, float gain, ultrahdr_metadata_ptr metadata, float displayBoost);
Color applyGain(Color e, float gain, ultrahdr_metadata_ptr metadata, float displayBoost);
+8 −1
Original line number Original line Diff line number Diff line
@@ -222,7 +222,11 @@ public:
     * Decompress JPEGR image.
     * Decompress JPEGR image.
     *
     *
     * This method assumes that the JPEGR image contains an ICC profile with primaries that match
     * This method assumes that the JPEGR image contains an ICC profile with primaries that match
     * those of a color gamut that this library is aware of; Bt.709, Display-P3, or Bt.2100.
     * those of a color gamut that this library is aware of; Bt.709, Display-P3, or Bt.2100. It also
     * assumes the base image uses the sRGB transfer function.
     *
     * This method only supports single gain map metadata values for fields that allow multi-channel
     * metadata values.
     *
     *
     * @param compressed_jpegr_image compressed JPEGR image.
     * @param compressed_jpegr_image compressed JPEGR image.
     * @param dest destination of the uncompressed JPEGR image.
     * @param dest destination of the uncompressed JPEGR image.
@@ -265,6 +269,9 @@ public:
    /*
    /*
    * Gets Info from JPEGR file without decoding it.
    * Gets Info from JPEGR file without decoding it.
    *
    *
    * This method only supports single gain map metadata values for fields that allow multi-channel
    * metadata values.
    *
    * The output is filled jpegr_info structure
    * The output is filled jpegr_info structure
    * @param compressed_jpegr_image compressed JPEGR image
    * @param compressed_jpegr_image compressed JPEGR image
    * @param jpegr_info pointer to output JPEGR info. Members of jpegr_info
    * @param jpegr_info pointer to output JPEGR info. Members of jpegr_info
+2 −0
Original line number Original line Diff line number Diff line
@@ -42,6 +42,8 @@ enum {
    ERROR_JPEGR_BUFFER_TOO_SMALL        = JPEGR_IO_ERROR_BASE - 4,
    ERROR_JPEGR_BUFFER_TOO_SMALL        = JPEGR_IO_ERROR_BASE - 4,
    ERROR_JPEGR_INVALID_COLORGAMUT      = JPEGR_IO_ERROR_BASE - 5,
    ERROR_JPEGR_INVALID_COLORGAMUT      = JPEGR_IO_ERROR_BASE - 5,
    ERROR_JPEGR_INVALID_TRANS_FUNC      = JPEGR_IO_ERROR_BASE - 6,
    ERROR_JPEGR_INVALID_TRANS_FUNC      = JPEGR_IO_ERROR_BASE - 6,
    ERROR_JPEGR_INVALID_METADATA        = JPEGR_IO_ERROR_BASE - 7,
    ERROR_JPEGR_UNSUPPORTED_METADATA    = JPEGR_IO_ERROR_BASE - 8,


    JPEGR_RUNTIME_ERROR_BASE            = -20000,
    JPEGR_RUNTIME_ERROR_BASE            = -20000,
    ERROR_JPEGR_ENCODE_ERROR            = JPEGR_RUNTIME_ERROR_BASE - 1,
    ERROR_JPEGR_ENCODE_ERROR            = JPEGR_RUNTIME_ERROR_BASE - 1,
+15 −1
Original line number Original line Diff line number Diff line
@@ -49,14 +49,28 @@ typedef enum {


/*
/*
 * Holds information for gain map related metadata.
 * Holds information for gain map related metadata.
 *
 * Not: all values stored in linear. This differs from the metadata encoding in XMP, where
 * maxContentBoost (aka gainMapMax), minContentBoost (aka gainMapMin), hdrCapacityMin, and
 * hdrCapacityMax are stored in log2 space.
 */
 */
struct ultrahdr_metadata_struct {
struct ultrahdr_metadata_struct {
  // Ultra HDR library version
  // Ultra HDR format version
  std::string version;
  std::string version;
  // Max Content Boost for the map
  // Max Content Boost for the map
  float maxContentBoost;
  float maxContentBoost;
  // Min Content Boost for the map
  // Min Content Boost for the map
  float minContentBoost;
  float minContentBoost;
  // Gamma of the map data
  float gamma;
  // Offset for SDR data in map calculations
  float offsetSdr;
  // Offset for HDR data in map calculations
  float offsetHdr;
  // HDR capacity to apply the map at all
  float hdrCapacityMin;
  // HDR capacity to apply the map completely
  float hdrCapacityMax;
};
};
typedef struct ultrahdr_metadata_struct* ultrahdr_metadata_ptr;
typedef struct ultrahdr_metadata_struct* ultrahdr_metadata_ptr;


Loading