2323
2424#include " ultrahdr_api.h"
2525#include " ultrahdr/ultrahdrcommon.h"
26- #include " ultrahdr/ultrahdr.h"
2726#include " ultrahdr/jpegr.h"
2827
2928#if (defined(UHDR_ENABLE_INTRINSICS) && (defined(__ARM_NEON__) || defined(__ARM_NEON)))
@@ -176,23 +175,23 @@ inline uint16_t floatToHalf(float f) {
176175constexpr int32_t kGainFactorPrecision = 10 ;
177176constexpr int32_t kGainFactorNumEntries = 1 << kGainFactorPrecision ;
178177struct GainLUT {
179- GainLUT (ultrahdr_metadata_ptr metadata) {
178+ GainLUT (uhdr_gainmap_metadata_ext_t * metadata) {
180179 this ->mGammaInv = 1 .0f / metadata->gamma ;
181180 for (int32_t idx = 0 ; idx < kGainFactorNumEntries ; idx++) {
182181 float value = static_cast <float >(idx) / static_cast <float >(kGainFactorNumEntries - 1 );
183- float logBoost = log2 (metadata->minContentBoost ) * (1 .0f - value) +
184- log2 (metadata->maxContentBoost ) * value;
182+ float logBoost = log2 (metadata->min_content_boost ) * (1 .0f - value) +
183+ log2 (metadata->max_content_boost ) * value;
185184 mGainTable [idx] = exp2 (logBoost);
186185 }
187186 }
188187
189- GainLUT (ultrahdr_metadata_ptr metadata, float displayBoost) {
188+ GainLUT (uhdr_gainmap_metadata_ext_t * metadata, float displayBoost) {
190189 this ->mGammaInv = 1 .0f / metadata->gamma ;
191- float boostFactor = displayBoost > 0 ? displayBoost / metadata->maxContentBoost : 1 .0f ;
190+ float boostFactor = displayBoost > 0 ? displayBoost / metadata->max_content_boost : 1 .0f ;
192191 for (int32_t idx = 0 ; idx < kGainFactorNumEntries ; idx++) {
193192 float value = static_cast <float >(idx) / static_cast <float >(kGainFactorNumEntries - 1 );
194- float logBoost = log2 (metadata->minContentBoost ) * (1 .0f - value) +
195- log2 (metadata->maxContentBoost ) * value;
193+ float logBoost = log2 (metadata->min_content_boost ) * (1 .0f - value) +
194+ log2 (metadata->max_content_boost ) * value;
196195 mGainTable [idx] = exp2 (logBoost * boostFactor);
197196 }
198197 }
@@ -432,7 +431,7 @@ inline Color identityConversion(Color e) { return e; }
432431/*
433432 * Get the conversion to apply to the HDR image for gain map generation
434433 */
435- ColorTransformFn getHdrConversionFn (ultrahdr_color_gamut sdr_gamut, ultrahdr_color_gamut hdr_gamut);
434+ ColorTransformFn getHdrConversionFn (uhdr_color_gamut_t sdr_gamut, uhdr_color_gamut_t hdr_gamut);
436435
437436/*
438437 * Convert between YUV encodings, according to ITU-R BT.709-6, ITU-R BT.601-7, and ITU-R BT.2100-2.
@@ -464,10 +463,10 @@ extern const int16_t kYuv2100To601_coeffs_neon[8];
464463 */
465464int16x8x3_t yuvConversion_neon (uint8x8_t y, int16x8_t u, int16x8_t v, int16x8_t coeffs);
466465
467- void transformYuv420_neon (jr_uncompressed_ptr image, const int16_t * coeffs_ptr);
466+ void transformYuv420_neon (uhdr_raw_image_t * image, const int16_t * coeffs_ptr);
468467
469- status_t convertYuv_neon (jr_uncompressed_ptr image, ultrahdr_color_gamut src_encoding,
470- ultrahdr_color_gamut dst_encoding);
468+ uhdr_error_info_t convertYuv_neon (uhdr_raw_image_t * image, uhdr_color_gamut_t src_encoding,
469+ uhdr_color_gamut_t dst_encoding);
471470#endif
472471
473472/*
@@ -479,7 +478,7 @@ status_t convertYuv_neon(jr_uncompressed_ptr image, ultrahdr_color_gamut src_enc
479478 * The chroma channels should be less than or equal to half the image's width and height
480479 * respectively, since input is 4:2:0 subsampled.
481480 */
482- void transformYuv420 (jr_uncompressed_ptr image, const std::array<float , 9 >& coeffs);
481+ void transformYuv420 (uhdr_raw_image_t * image, const std::array<float , 9 >& coeffs);
483482
484483// //////////////////////////////////////////////////////////////////////////////
485484// Gain map calculations
@@ -492,8 +491,8 @@ void transformYuv420(jr_uncompressed_ptr image, const std::array<float, 9>& coef
492491 * offsetHdr of 0.0, this function doesn't handle different metadata values for
493492 * these fields.
494493 */
495- uint8_t encodeGain (float y_sdr, float y_hdr, ultrahdr_metadata_ptr metadata);
496- uint8_t encodeGain (float y_sdr, float y_hdr, ultrahdr_metadata_ptr metadata,
494+ uint8_t encodeGain (float y_sdr, float y_hdr, uhdr_gainmap_metadata_ext_t * metadata);
495+ uint8_t encodeGain (float y_sdr, float y_hdr, uhdr_gainmap_metadata_ext_t * metadata,
497496 float log2MinContentBoost, float log2MaxContentBoost);
498497
499498/*
@@ -504,8 +503,8 @@ uint8_t encodeGain(float y_sdr, float y_hdr, ultrahdr_metadata_ptr metadata,
504503 * offsetSdr 0.0, offsetHdr 0.0, hdrCapacityMin 1.0, and hdrCapacityMax equal to
505504 * gainMapMax, as this library encodes.
506505 */
507- Color applyGain (Color e, float gain, ultrahdr_metadata_ptr metadata);
508- Color applyGain (Color e, float gain, ultrahdr_metadata_ptr metadata, float displayBoost);
506+ Color applyGain (Color e, float gain, uhdr_gainmap_metadata_ext_t * metadata);
507+ Color applyGain (Color e, float gain, uhdr_gainmap_metadata_ext_t * metadata, float displayBoost);
509508Color applyGainLUT (Color e, float gain, GainLUT& gainLUT);
510509
511510/*
@@ -516,46 +515,44 @@ Color applyGainLUT(Color e, float gain, GainLUT& gainLUT);
516515 * offsetSdr 0.0, offsetHdr 0.0, hdrCapacityMin 1.0, and hdrCapacityMax equal to
517516 * gainMapMax, as this library encodes.
518517 */
519- Color applyGain (Color e, Color gain, ultrahdr_metadata_ptr metadata);
520- Color applyGain (Color e, Color gain, ultrahdr_metadata_ptr metadata, float displayBoost);
518+ Color applyGain (Color e, Color gain, uhdr_gainmap_metadata_ext_t * metadata);
519+ Color applyGain (Color e, Color gain, uhdr_gainmap_metadata_ext_t * metadata, float displayBoost);
521520Color applyGainLUT (Color e, Color gain, GainLUT& gainLUT);
522521
523522/*
524523 * Helper for sampling from YUV 420 images.
525524 */
526- Color getYuv420Pixel (jr_uncompressed_ptr image, size_t x, size_t y);
525+ Color getYuv420Pixel (uhdr_raw_image_t * image, size_t x, size_t y);
527526
528527/*
529528 * Helper for sampling from P010 images.
530- *
531- * Expect narrow-range image data for P010.
532529 */
533- Color getP010Pixel (jr_uncompressed_ptr image, size_t x, size_t y);
530+ Color getP010Pixel (uhdr_raw_image_t * image, size_t x, size_t y);
534531
535532/*
536533 * Sample the image at the provided location, with a weighting based on nearby
537534 * pixels and the map scale factor.
538535 */
539- Color sampleYuv420 (jr_uncompressed_ptr map, size_t map_scale_factor, size_t x, size_t y);
536+ Color sampleYuv420 (uhdr_raw_image_t * map, size_t map_scale_factor, size_t x, size_t y);
540537
541538/*
542539 * Sample the image at the provided location, with a weighting based on nearby
543540 * pixels and the map scale factor.
544541 *
545542 * Expect narrow-range image data for P010.
546543 */
547- Color sampleP010 (jr_uncompressed_ptr map, size_t map_scale_factor, size_t x, size_t y);
544+ Color sampleP010 (uhdr_raw_image_t * map, size_t map_scale_factor, size_t x, size_t y);
548545
549546/*
550547 * Sample the gain value for the map from a given x,y coordinate on a scale
551548 * that is map scale factor larger than the map size.
552549 */
553- float sampleMap (jr_uncompressed_ptr map, float map_scale_factor, size_t x, size_t y);
554- float sampleMap (jr_uncompressed_ptr map, size_t map_scale_factor, size_t x, size_t y,
550+ float sampleMap (uhdr_raw_image_t * map, float map_scale_factor, size_t x, size_t y);
551+ float sampleMap (uhdr_raw_image_t * map, size_t map_scale_factor, size_t x, size_t y,
555552 ShepardsIDW& weightTables);
556- Color sampleMap3Channel (jr_uncompressed_ptr map, float map_scale_factor, size_t x, size_t y,
553+ Color sampleMap3Channel (uhdr_raw_image_t * map, float map_scale_factor, size_t x, size_t y,
557554 bool has_alpha);
558- Color sampleMap3Channel (jr_uncompressed_ptr map, size_t map_scale_factor, size_t x, size_t y,
555+ Color sampleMap3Channel (uhdr_raw_image_t * map, size_t map_scale_factor, size_t x, size_t y,
559556 ShepardsIDW& weightTables, bool has_alpha);
560557
561558/*
@@ -572,6 +569,11 @@ uint32_t colorToRgba1010102(Color e_gamma);
572569 */
573570uint64_t colorToRgbaF16 (Color e_gamma);
574571
572+ /*
573+ * Helper for copying raw image descriptor
574+ */
575+ uhdr_error_info_t copy_raw_image (uhdr_raw_image_t * src, uhdr_raw_image_t * dst);
576+
575577/*
576578 * Helper for preparing encoder raw inputs for encoding
577579 */
0 commit comments