0
      ˆ¾‘äÇò 8àGÍ6'ÄÿŸÂƒh¹ÁÀ¿      0
  @   ˆl–äY>”TÜZÔ%+‚~ã`S�ÿ�þDËãY²¾)Bü�–7�üÿÃƒ|!kÂ_ˆI|¥�+y,ÂÁ #š    /* Copyright (c) the JPEG XL Project Authors. All rights reserved.
 *
 * Use of this source code is governed by a BSD-style
 * license that can be found in the LICENSE file.
 */

/** @addtogroup libjxl_common
 * @{
 * @file cms_interface.h
 * @brief Interface to allow the injection of different color management systems
 * (CMSes, also called color management modules, or CMMs) in JPEG XL.
 *
 * A CMS is needed by the JPEG XL encoder and decoder to perform colorspace
 * conversions. This defines an interface that can be implemented for different
 * CMSes and then passed to the library.
 */

#ifndef JXL_CMS_INTERFACE_H_
#define JXL_CMS_INTERFACE_H_

#include "jxl/color_encoding.h"
#include "jxl/types.h"

#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif

/** Represents an input or output colorspace to a color transform, as a
 * serialized ICC profile. */
typedef struct {
  /** The serialized ICC profile. This is guaranteed to be present and valid. */
  struct {
    const uint8_t* data;
    size_t size;
  } icc;

  /** Structured representation of the colorspace, if applicable. If all fields
   * are different from their "unknown" value, then this is equivalent to the
   * ICC representation of the colorspace. If some are "unknown", those that are
   * not are still valid and can still be used on their own if they are useful.
   */
  JxlColorEncoding color_encoding;

  /** Number of components per pixel. This can be deduced from the other
   * representations of the colorspace but is provided for convenience and
   * validation. */
  size_t num_channels;
} JxlColorProfile;

/** Allocates and returns the data needed for @p num_threads parallel transforms
 * from the @p input colorspace to @p output, with up to @p pixels_per_thread
 * pixels to transform per call to JxlCmsInterface::run. @p init_data comes
 * directly from the JxlCmsInterface instance. Since @c run only receives the
 * data returned by @c init, a reference to @p init_data should be kept there
 * if access to it is desired in @c run. Likewise for JxlCmsInterface::destroy.
 *
 * The ICC data in @p input and @p output is guaranteed to outlive the @c init /
 * @c run / @c destroy cycle.
 *
 * @param init_data JxlCmsInterface::init_data passed as-is.
 * @param num_threads the maximum number of threads from which
 *        JxlCmsInterface::run will be called.
 * @param pixels_per_thread the maximum number of pixels that each call to
 *        JxlCmsInterface::run will have to transform.
 * @param input_profile the input colorspace for the transform.
 * @param output_profile the colorspace to which JxlCmsInterface::run should
 *        convert the input data.
 * @param intensity_target for colorspaces where luminance is relative
 *        (essentially: not PQ), indicates the luminance at which (1, 1, 1) will
 *        be displayed. This is useful for conversions between PQ and a relative
 *        luminance colorspace, in either direction: @p intensity_target cd/mÂ²
 *        in PQ should map to and from (1, 1, 1) in the relative one.\n
 *        It is also used for conversions to and from HLG, as it is
 *        scene-referred while other colorspaces are assumed to be
 *        display-referred. That is, conversions from HLG should apply the OOTF
 *        for a peak display luminance of @p intensity_target, and conversions
 *        to HLG should undo it. The OOTF is a gamma function applied to the
 *        luminance channel (https://www.itu.int/rec/R-REC-BT.2100-2-201807-I
 *        page 7), with the gamma value computed as
 *        <tt>1.2 * 1.111^log2(intensity_target / 1000)</tt> (footnote 2 page 8
 *        of the same document).
 * @return The data needed for the transform, or @c NULL in case of failure.
 *         This will be passed to the other functions as @c user_data.
 */
typedef void* (*jpegxl_cms_init_func)(void* init_data, size_t num_threads,
                                      size_t pixels_per