1*89a0ef05SAndroid Build Coastguard Worker /* 2*89a0ef05SAndroid Build Coastguard Worker * Copyright 2024 The Android Open Source Project 3*89a0ef05SAndroid Build Coastguard Worker * 4*89a0ef05SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*89a0ef05SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*89a0ef05SAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*89a0ef05SAndroid Build Coastguard Worker * 8*89a0ef05SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*89a0ef05SAndroid Build Coastguard Worker * 10*89a0ef05SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*89a0ef05SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*89a0ef05SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*89a0ef05SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*89a0ef05SAndroid Build Coastguard Worker * limitations under the License. 15*89a0ef05SAndroid Build Coastguard Worker */ 16*89a0ef05SAndroid Build Coastguard Worker 17*89a0ef05SAndroid Build Coastguard Worker /** \file ultrahdr_api.h 18*89a0ef05SAndroid Build Coastguard Worker * 19*89a0ef05SAndroid Build Coastguard Worker * \brief 20*89a0ef05SAndroid Build Coastguard Worker * Describes the encoder or decoder algorithm interface to applications. 21*89a0ef05SAndroid Build Coastguard Worker */ 22*89a0ef05SAndroid Build Coastguard Worker 23*89a0ef05SAndroid Build Coastguard Worker #ifndef ULTRAHDR_API_H 24*89a0ef05SAndroid Build Coastguard Worker #define ULTRAHDR_API_H 25*89a0ef05SAndroid Build Coastguard Worker 26*89a0ef05SAndroid Build Coastguard Worker #include <stddef.h> 27*89a0ef05SAndroid Build Coastguard Worker 28*89a0ef05SAndroid Build Coastguard Worker #if defined(_WIN32) || defined(__CYGWIN__) 29*89a0ef05SAndroid Build Coastguard Worker #if defined(UHDR_BUILDING_SHARED_LIBRARY) 30*89a0ef05SAndroid Build Coastguard Worker #define UHDR_API __declspec(dllexport) 31*89a0ef05SAndroid Build Coastguard Worker #elif defined(UHDR_USING_SHARED_LIBRARY) 32*89a0ef05SAndroid Build Coastguard Worker #define UHDR_API __declspec(dllimport) 33*89a0ef05SAndroid Build Coastguard Worker #else 34*89a0ef05SAndroid Build Coastguard Worker #define UHDR_API 35*89a0ef05SAndroid Build Coastguard Worker #endif 36*89a0ef05SAndroid Build Coastguard Worker #elif defined(__GNUC__) && (__GNUC__ >= 4) && \ 37*89a0ef05SAndroid Build Coastguard Worker (defined(UHDR_BUILDING_SHARED_LIBRARY) || defined(UHDR_USING_SHARED_LIBRARY)) 38*89a0ef05SAndroid Build Coastguard Worker #define UHDR_API __attribute__((visibility("default"))) 39*89a0ef05SAndroid Build Coastguard Worker #else 40*89a0ef05SAndroid Build Coastguard Worker #define UHDR_API 41*89a0ef05SAndroid Build Coastguard Worker #endif 42*89a0ef05SAndroid Build Coastguard Worker 43*89a0ef05SAndroid Build Coastguard Worker #ifdef __cplusplus 44*89a0ef05SAndroid Build Coastguard Worker #define UHDR_EXTERN extern "C" UHDR_API 45*89a0ef05SAndroid Build Coastguard Worker #else 46*89a0ef05SAndroid Build Coastguard Worker #define UHDR_EXTERN extern UHDR_API 47*89a0ef05SAndroid Build Coastguard Worker #endif 48*89a0ef05SAndroid Build Coastguard Worker 49*89a0ef05SAndroid Build Coastguard Worker /* 50*89a0ef05SAndroid Build Coastguard Worker * A Note on version numbering: 51*89a0ef05SAndroid Build Coastguard Worker * Over the course of development multiple changes were made to the interface that are not entirely 52*89a0ef05SAndroid Build Coastguard Worker * backward compatible. Some APIs were renamed for consistency and better readability. New APIs were 53*89a0ef05SAndroid Build Coastguard Worker * introduced to allow configuration of encoding/decoding parameters. As per convention, breaking 54*89a0ef05SAndroid Build Coastguard Worker * backward compatibility MUST be indicated with a major version update, introducing new APIs / 55*89a0ef05SAndroid Build Coastguard Worker * features MUST be indicated with a minor version update and bug fixes MUST be indicated with a 56*89a0ef05SAndroid Build Coastguard Worker * patch version update. This convention however, is not followed. Below table summarizes these 57*89a0ef05SAndroid Build Coastguard Worker * details: 58*89a0ef05SAndroid Build Coastguard Worker * 59*89a0ef05SAndroid Build Coastguard Worker * source version ultrahdr_api.h Details 60*89a0ef05SAndroid Build Coastguard Worker * version string 61*89a0ef05SAndroid Build Coastguard Worker * -------------- -------------- ------------- 62*89a0ef05SAndroid Build Coastguard Worker * 1.0.0 Not available This version did not have a public API. Apps, 63*89a0ef05SAndroid Build Coastguard Worker * directly included the project header files. 64*89a0ef05SAndroid Build Coastguard Worker * 1.1.0 Not available ultrahdr_api.h is introduced in this release. The 65*89a0ef05SAndroid Build Coastguard Worker * API header file did not advertise any version 66*89a0ef05SAndroid Build Coastguard Worker * string. 67*89a0ef05SAndroid Build Coastguard Worker * 1.1.1 Not available The API header file did not advertise any version 68*89a0ef05SAndroid Build Coastguard Worker * string. Some bug fixes and introduced one new API 69*89a0ef05SAndroid Build Coastguard Worker * which warrants a minor version update. But 70*89a0ef05SAndroid Build Coastguard Worker * indicated as a patch update. 71*89a0ef05SAndroid Build Coastguard Worker * 1.2.0 1.2.0 Some bug fixes, introduced new API and renamed 72*89a0ef05SAndroid Build Coastguard Worker * existing API which warrants a major version update. 73*89a0ef05SAndroid Build Coastguard Worker * But indicated as a minor update. 74*89a0ef05SAndroid Build Coastguard Worker * 1.3.0 1.3.0 Some bug fixes, introduced new API. 75*89a0ef05SAndroid Build Coastguard Worker */ 76*89a0ef05SAndroid Build Coastguard Worker 77*89a0ef05SAndroid Build Coastguard Worker // This needs to be kept in sync with version in CMakeLists.txt 78*89a0ef05SAndroid Build Coastguard Worker #define UHDR_LIB_VER_MAJOR 1 79*89a0ef05SAndroid Build Coastguard Worker #define UHDR_LIB_VER_MINOR 3 80*89a0ef05SAndroid Build Coastguard Worker #define UHDR_LIB_VER_PATCH 0 81*89a0ef05SAndroid Build Coastguard Worker 82*89a0ef05SAndroid Build Coastguard Worker #define UHDR_LIB_VERSION \ 83*89a0ef05SAndroid Build Coastguard Worker ((UHDR_LIB_VER_MAJOR * 10000) + (UHDR_LIB_VER_MINOR * 100) + UHDR_LIB_VER_PATCH) 84*89a0ef05SAndroid Build Coastguard Worker 85*89a0ef05SAndroid Build Coastguard Worker #define XSTR(s) STR(s) 86*89a0ef05SAndroid Build Coastguard Worker #define STR(s) #s 87*89a0ef05SAndroid Build Coastguard Worker #define UHDR_LIB_VERSION_STR \ 88*89a0ef05SAndroid Build Coastguard Worker XSTR(UHDR_LIB_VER_MAJOR) "." XSTR(UHDR_LIB_VER_MINOR) "." XSTR(UHDR_LIB_VER_PATCH) 89*89a0ef05SAndroid Build Coastguard Worker 90*89a0ef05SAndroid Build Coastguard Worker // =============================================================================================== 91*89a0ef05SAndroid Build Coastguard Worker // Enum Definitions 92*89a0ef05SAndroid Build Coastguard Worker // =============================================================================================== 93*89a0ef05SAndroid Build Coastguard Worker 94*89a0ef05SAndroid Build Coastguard Worker /*!\brief List of supported image formats */ 95*89a0ef05SAndroid Build Coastguard Worker typedef enum uhdr_img_fmt { 96*89a0ef05SAndroid Build Coastguard Worker UHDR_IMG_FMT_UNSPECIFIED = -1, /**< Unspecified */ 97*89a0ef05SAndroid Build Coastguard Worker UHDR_IMG_FMT_24bppYCbCrP010 = 0, /**< 10-bit-per component 4:2:0 YCbCr semiplanar format. 98*89a0ef05SAndroid Build Coastguard Worker Each chroma and luma component has 16 allocated bits in 99*89a0ef05SAndroid Build Coastguard Worker little-endian configuration with 10 MSB of actual data.*/ 100*89a0ef05SAndroid Build Coastguard Worker UHDR_IMG_FMT_12bppYCbCr420 = 1, /**< 8-bit-per component 4:2:0 YCbCr planar format */ 101*89a0ef05SAndroid Build Coastguard Worker UHDR_IMG_FMT_8bppYCbCr400 = 2, /**< 8-bit-per component Monochrome format */ 102*89a0ef05SAndroid Build Coastguard Worker UHDR_IMG_FMT_32bppRGBA8888 = 103*89a0ef05SAndroid Build Coastguard Worker 3, /**< 32 bits per pixel RGBA color format, with 8-bit red, green, blue 104*89a0ef05SAndroid Build Coastguard Worker and alpha components. Using 32-bit little-endian representation, 105*89a0ef05SAndroid Build Coastguard Worker colors stored as Red 7:0, Green 15:8, Blue 23:16, Alpha 31:24. */ 106*89a0ef05SAndroid Build Coastguard Worker UHDR_IMG_FMT_64bppRGBAHalfFloat = 107*89a0ef05SAndroid Build Coastguard Worker 4, /**< 64 bits per pixel, 16 bits per channel, half-precision floating point RGBA color 108*89a0ef05SAndroid Build Coastguard Worker format. colors stored as Red 15:0, Green 31:16, Blue 47:32, Alpha 63:48. In a pixel 109*89a0ef05SAndroid Build Coastguard Worker even though each channel has storage space of 16 bits, the nominal range is expected to 110*89a0ef05SAndroid Build Coastguard Worker be [0.0..(10000/203)] */ 111*89a0ef05SAndroid Build Coastguard Worker UHDR_IMG_FMT_32bppRGBA1010102 = 5, /**< 32 bits per pixel RGBA color format, with 10-bit red, 112*89a0ef05SAndroid Build Coastguard Worker green, blue, and 2-bit alpha components. Using 32-bit 113*89a0ef05SAndroid Build Coastguard Worker little-endian representation, colors stored as Red 9:0, Green 114*89a0ef05SAndroid Build Coastguard Worker 19:10, Blue 29:20, and Alpha 31:30. */ 115*89a0ef05SAndroid Build Coastguard Worker UHDR_IMG_FMT_24bppYCbCr444 = 6, /**< 8-bit-per component 4:4:4 YCbCr planar format */ 116*89a0ef05SAndroid Build Coastguard Worker UHDR_IMG_FMT_16bppYCbCr422 = 7, /**< 8-bit-per component 4:2:2 YCbCr planar format */ 117*89a0ef05SAndroid Build Coastguard Worker UHDR_IMG_FMT_16bppYCbCr440 = 8, /**< 8-bit-per component 4:4:0 YCbCr planar format */ 118*89a0ef05SAndroid Build Coastguard Worker UHDR_IMG_FMT_12bppYCbCr411 = 9, /**< 8-bit-per component 4:1:1 YCbCr planar format */ 119*89a0ef05SAndroid Build Coastguard Worker UHDR_IMG_FMT_10bppYCbCr410 = 10, /**< 8-bit-per component 4:1:0 YCbCr planar format */ 120*89a0ef05SAndroid Build Coastguard Worker UHDR_IMG_FMT_24bppRGB888 = 11, /**< 8-bit-per component RGB interleaved format */ 121*89a0ef05SAndroid Build Coastguard Worker UHDR_IMG_FMT_30bppYCbCr444 = 12, /**< 10-bit-per component 4:4:4 YCbCr planar format */ 122*89a0ef05SAndroid Build Coastguard Worker } uhdr_img_fmt_t; /**< alias for enum uhdr_img_fmt */ 123*89a0ef05SAndroid Build Coastguard Worker 124*89a0ef05SAndroid Build Coastguard Worker /*!\brief List of supported color gamuts */ 125*89a0ef05SAndroid Build Coastguard Worker typedef enum uhdr_color_gamut { 126*89a0ef05SAndroid Build Coastguard Worker UHDR_CG_UNSPECIFIED = -1, /**< Unspecified */ 127*89a0ef05SAndroid Build Coastguard Worker UHDR_CG_BT_709 = 0, /**< BT.709 */ 128*89a0ef05SAndroid Build Coastguard Worker UHDR_CG_DISPLAY_P3 = 1, /**< Display P3 */ 129*89a0ef05SAndroid Build Coastguard Worker UHDR_CG_BT_2100 = 2, /**< BT.2100 */ 130*89a0ef05SAndroid Build Coastguard Worker } uhdr_color_gamut_t; /**< alias for enum uhdr_color_gamut */ 131*89a0ef05SAndroid Build Coastguard Worker 132*89a0ef05SAndroid Build Coastguard Worker /*!\brief List of supported color transfers */ 133*89a0ef05SAndroid Build Coastguard Worker typedef enum uhdr_color_transfer { 134*89a0ef05SAndroid Build Coastguard Worker UHDR_CT_UNSPECIFIED = -1, /**< Unspecified */ 135*89a0ef05SAndroid Build Coastguard Worker UHDR_CT_LINEAR = 0, /**< Linear */ 136*89a0ef05SAndroid Build Coastguard Worker UHDR_CT_HLG = 1, /**< Hybrid log gamma */ 137*89a0ef05SAndroid Build Coastguard Worker UHDR_CT_PQ = 2, /**< Perceptual Quantizer */ 138*89a0ef05SAndroid Build Coastguard Worker UHDR_CT_SRGB = 3, /**< Gamma */ 139*89a0ef05SAndroid Build Coastguard Worker } uhdr_color_transfer_t; /**< alias for enum uhdr_color_transfer */ 140*89a0ef05SAndroid Build Coastguard Worker 141*89a0ef05SAndroid Build Coastguard Worker /*!\brief List of supported color ranges */ 142*89a0ef05SAndroid Build Coastguard Worker typedef enum uhdr_color_range { 143*89a0ef05SAndroid Build Coastguard Worker UHDR_CR_UNSPECIFIED = -1, /**< Unspecified */ 144*89a0ef05SAndroid Build Coastguard Worker UHDR_CR_LIMITED_RANGE = 0, /**< Y {[16..235], UV [16..240]} * pow(2, (bpc - 8)) */ 145*89a0ef05SAndroid Build Coastguard Worker UHDR_CR_FULL_RANGE = 1, /**< YUV/RGB {[0..255]} * pow(2, (bpc - 8)) */ 146*89a0ef05SAndroid Build Coastguard Worker } uhdr_color_range_t; /**< alias for enum uhdr_color_range */ 147*89a0ef05SAndroid Build Coastguard Worker 148*89a0ef05SAndroid Build Coastguard Worker /*!\brief List of supported codecs */ 149*89a0ef05SAndroid Build Coastguard Worker typedef enum uhdr_codec { 150*89a0ef05SAndroid Build Coastguard Worker UHDR_CODEC_JPG, /**< Compress {Hdr, Sdr rendition} to an {Sdr rendition + Gain Map} using jpeg */ 151*89a0ef05SAndroid Build Coastguard Worker UHDR_CODEC_HEIF, /**< Compress {Hdr, Sdr rendition} to an {Sdr rendition + Gain Map} using heif */ 152*89a0ef05SAndroid Build Coastguard Worker UHDR_CODEC_AVIF, /**< Compress {Hdr, Sdr rendition} to an {Sdr rendition + Gain Map} using avif */ 153*89a0ef05SAndroid Build Coastguard Worker } uhdr_codec_t; /**< alias for enum uhdr_codec */ 154*89a0ef05SAndroid Build Coastguard Worker 155*89a0ef05SAndroid Build Coastguard Worker /*!\brief Image identifiers in gain map technology */ 156*89a0ef05SAndroid Build Coastguard Worker typedef enum uhdr_img_label { 157*89a0ef05SAndroid Build Coastguard Worker UHDR_HDR_IMG, /**< Hdr rendition image */ 158*89a0ef05SAndroid Build Coastguard Worker UHDR_SDR_IMG, /**< Sdr rendition image */ 159*89a0ef05SAndroid Build Coastguard Worker UHDR_BASE_IMG, /**< Base rendition image */ 160*89a0ef05SAndroid Build Coastguard Worker UHDR_GAIN_MAP_IMG, /**< Gain map image */ 161*89a0ef05SAndroid Build Coastguard Worker } uhdr_img_label_t; /**< alias for enum uhdr_img_label */ 162*89a0ef05SAndroid Build Coastguard Worker 163*89a0ef05SAndroid Build Coastguard Worker /*!\brief uhdr encoder usage parameter */ 164*89a0ef05SAndroid Build Coastguard Worker typedef enum uhdr_enc_preset { 165*89a0ef05SAndroid Build Coastguard Worker UHDR_USAGE_REALTIME, /**< tune encoder settings for performance */ 166*89a0ef05SAndroid Build Coastguard Worker UHDR_USAGE_BEST_QUALITY, /**< tune encoder settings for quality */ 167*89a0ef05SAndroid Build Coastguard Worker } uhdr_enc_preset_t; /**< alias for enum uhdr_enc_preset */ 168*89a0ef05SAndroid Build Coastguard Worker 169*89a0ef05SAndroid Build Coastguard Worker /*!\brief Algorithm return codes */ 170*89a0ef05SAndroid Build Coastguard Worker typedef enum uhdr_codec_err { 171*89a0ef05SAndroid Build Coastguard Worker 172*89a0ef05SAndroid Build Coastguard Worker /*!\brief Operation completed without error */ 173*89a0ef05SAndroid Build Coastguard Worker UHDR_CODEC_OK, 174*89a0ef05SAndroid Build Coastguard Worker 175*89a0ef05SAndroid Build Coastguard Worker /*!\brief Generic codec error, refer detail field for more information */ 176*89a0ef05SAndroid Build Coastguard Worker UHDR_CODEC_ERROR, 177*89a0ef05SAndroid Build Coastguard Worker 178*89a0ef05SAndroid Build Coastguard Worker /*!\brief Unknown error, refer detail field for more information */ 179*89a0ef05SAndroid Build Coastguard Worker UHDR_CODEC_UNKNOWN_ERROR, 180*89a0ef05SAndroid Build Coastguard Worker 181*89a0ef05SAndroid Build Coastguard Worker /*!\brief An application-supplied parameter is not valid. */ 182*89a0ef05SAndroid Build Coastguard Worker UHDR_CODEC_INVALID_PARAM, 183*89a0ef05SAndroid Build Coastguard Worker 184*89a0ef05SAndroid Build Coastguard Worker /*!\brief Memory operation failed */ 185*89a0ef05SAndroid Build Coastguard Worker UHDR_CODEC_MEM_ERROR, 186*89a0ef05SAndroid Build Coastguard Worker 187*89a0ef05SAndroid Build Coastguard Worker /*!\brief An application-invoked operation is not valid */ 188*89a0ef05SAndroid Build Coastguard Worker UHDR_CODEC_INVALID_OPERATION, 189*89a0ef05SAndroid Build Coastguard Worker 190*89a0ef05SAndroid Build Coastguard Worker /*!\brief The library does not implement a feature required for the operation */ 191*89a0ef05SAndroid Build Coastguard Worker UHDR_CODEC_UNSUPPORTED_FEATURE, 192*89a0ef05SAndroid Build Coastguard Worker 193*89a0ef05SAndroid Build Coastguard Worker /*!\brief Not for usage, indicates end of list */ 194*89a0ef05SAndroid Build Coastguard Worker UHDR_CODEC_LIST_END, 195*89a0ef05SAndroid Build Coastguard Worker 196*89a0ef05SAndroid Build Coastguard Worker } uhdr_codec_err_t; /**< alias for enum uhdr_codec_err */ 197*89a0ef05SAndroid Build Coastguard Worker 198*89a0ef05SAndroid Build Coastguard Worker /*!\brief List of supported mirror directions. */ 199*89a0ef05SAndroid Build Coastguard Worker typedef enum uhdr_mirror_direction { 200*89a0ef05SAndroid Build Coastguard Worker UHDR_MIRROR_VERTICAL, /**< flip image over x axis */ 201*89a0ef05SAndroid Build Coastguard Worker UHDR_MIRROR_HORIZONTAL, /**< flip image over y axis */ 202*89a0ef05SAndroid Build Coastguard Worker } uhdr_mirror_direction_t; /**< alias for enum uhdr_mirror_direction */ 203*89a0ef05SAndroid Build Coastguard Worker 204*89a0ef05SAndroid Build Coastguard Worker // =============================================================================================== 205*89a0ef05SAndroid Build Coastguard Worker // Structure Definitions 206*89a0ef05SAndroid Build Coastguard Worker // =============================================================================================== 207*89a0ef05SAndroid Build Coastguard Worker 208*89a0ef05SAndroid Build Coastguard Worker /*!\brief Detailed return status */ 209*89a0ef05SAndroid Build Coastguard Worker typedef struct uhdr_error_info { 210*89a0ef05SAndroid Build Coastguard Worker uhdr_codec_err_t error_code; /**< error code */ 211*89a0ef05SAndroid Build Coastguard Worker int has_detail; /**< has detailed error logs. 0 - no, else - yes */ 212*89a0ef05SAndroid Build Coastguard Worker char detail[256]; /**< error logs */ 213*89a0ef05SAndroid Build Coastguard Worker } uhdr_error_info_t; /**< alias for struct uhdr_error_info */ 214*89a0ef05SAndroid Build Coastguard Worker 215*89a0ef05SAndroid Build Coastguard Worker /**\brief Raw Image Descriptor */ 216*89a0ef05SAndroid Build Coastguard Worker typedef struct uhdr_raw_image { 217*89a0ef05SAndroid Build Coastguard Worker /* Color Aspects: Color model, primaries, transfer, range */ 218*89a0ef05SAndroid Build Coastguard Worker uhdr_img_fmt_t fmt; /**< Image Format */ 219*89a0ef05SAndroid Build Coastguard Worker uhdr_color_gamut_t cg; /**< Color Gamut */ 220*89a0ef05SAndroid Build Coastguard Worker uhdr_color_transfer_t ct; /**< Color Transfer */ 221*89a0ef05SAndroid Build Coastguard Worker uhdr_color_range_t range; /**< Color Range */ 222*89a0ef05SAndroid Build Coastguard Worker 223*89a0ef05SAndroid Build Coastguard Worker /* Image storage dimensions */ 224*89a0ef05SAndroid Build Coastguard Worker unsigned int w; /**< Stored image width */ 225*89a0ef05SAndroid Build Coastguard Worker unsigned int h; /**< Stored image height */ 226*89a0ef05SAndroid Build Coastguard Worker 227*89a0ef05SAndroid Build Coastguard Worker /* Image data pointers. */ 228*89a0ef05SAndroid Build Coastguard Worker #define UHDR_PLANE_PACKED 0 /**< To be used for all packed formats */ 229*89a0ef05SAndroid Build Coastguard Worker #define UHDR_PLANE_Y 0 /**< Y (Luminance) plane */ 230*89a0ef05SAndroid Build Coastguard Worker #define UHDR_PLANE_U 1 /**< U (Chroma) plane */ 231*89a0ef05SAndroid Build Coastguard Worker #define UHDR_PLANE_UV 1 /**< UV (Chroma plane interleaved) To be used for semi planar format */ 232*89a0ef05SAndroid Build Coastguard Worker #define UHDR_PLANE_V 2 /**< V (Chroma) plane */ 233*89a0ef05SAndroid Build Coastguard Worker void* planes[3]; /**< pointer to the top left pixel for each plane */ 234*89a0ef05SAndroid Build Coastguard Worker unsigned int stride[3]; /**< stride in pixels between rows for each plane */ 235*89a0ef05SAndroid Build Coastguard Worker } uhdr_raw_image_t; /**< alias for struct uhdr_raw_image */ 236*89a0ef05SAndroid Build Coastguard Worker 237*89a0ef05SAndroid Build Coastguard Worker /**\brief Compressed Image Descriptor */ 238*89a0ef05SAndroid Build Coastguard Worker typedef struct uhdr_compressed_image { 239*89a0ef05SAndroid Build Coastguard Worker void* data; /**< Pointer to a block of data to decode */ 240*89a0ef05SAndroid Build Coastguard Worker size_t data_sz; /**< size of the data buffer */ 241*89a0ef05SAndroid Build Coastguard Worker size_t capacity; /**< maximum size of the data buffer */ 242*89a0ef05SAndroid Build Coastguard Worker uhdr_color_gamut_t cg; /**< Color Gamut */ 243*89a0ef05SAndroid Build Coastguard Worker uhdr_color_transfer_t ct; /**< Color Transfer */ 244*89a0ef05SAndroid Build Coastguard Worker uhdr_color_range_t range; /**< Color Range */ 245*89a0ef05SAndroid Build Coastguard Worker } uhdr_compressed_image_t; /**< alias for struct uhdr_compressed_image */ 246*89a0ef05SAndroid Build Coastguard Worker 247*89a0ef05SAndroid Build Coastguard Worker /**\brief Buffer Descriptor */ 248*89a0ef05SAndroid Build Coastguard Worker typedef struct uhdr_mem_block { 249*89a0ef05SAndroid Build Coastguard Worker void* data; /**< Pointer to a block of data to decode */ 250*89a0ef05SAndroid Build Coastguard Worker size_t data_sz; /**< size of the data buffer */ 251*89a0ef05SAndroid Build Coastguard Worker size_t capacity; /**< maximum size of the data buffer */ 252*89a0ef05SAndroid Build Coastguard Worker } uhdr_mem_block_t; /**< alias for struct uhdr_mem_block */ 253*89a0ef05SAndroid Build Coastguard Worker 254*89a0ef05SAndroid Build Coastguard Worker /**\brief Gain map metadata. */ 255*89a0ef05SAndroid Build Coastguard Worker typedef struct uhdr_gainmap_metadata { 256*89a0ef05SAndroid Build Coastguard Worker float max_content_boost; /**< Value to control how much brighter an image can get, when shown on 257*89a0ef05SAndroid Build Coastguard Worker an HDR display, relative to the SDR rendition. This is constant for a 258*89a0ef05SAndroid Build Coastguard Worker given image. Value MUST be in linear scale. */ 259*89a0ef05SAndroid Build Coastguard Worker float min_content_boost; /**< Value to control how much darker an image can get, when shown on 260*89a0ef05SAndroid Build Coastguard Worker an HDR display, relative to the SDR rendition. This is constant for a 261*89a0ef05SAndroid Build Coastguard Worker given image. Value MUST be in linear scale. */ 262*89a0ef05SAndroid Build Coastguard Worker float gamma; /**< Encoding Gamma of the gainmap image. */ 263*89a0ef05SAndroid Build Coastguard Worker float offset_sdr; /**< The offset to apply to the SDR pixel values during gainmap generation and 264*89a0ef05SAndroid Build Coastguard Worker application. */ 265*89a0ef05SAndroid Build Coastguard Worker float offset_hdr; /**< The offset to apply to the HDR pixel values during gainmap generation and 266*89a0ef05SAndroid Build Coastguard Worker application. */ 267*89a0ef05SAndroid Build Coastguard Worker float hdr_capacity_min; /**< Minimum display boost value for which the map is applied completely. 268*89a0ef05SAndroid Build Coastguard Worker Value MUST be in linear scale. */ 269*89a0ef05SAndroid Build Coastguard Worker float hdr_capacity_max; /**< Maximum display boost value for which the map is applied completely. 270*89a0ef05SAndroid Build Coastguard Worker Value MUST be in linear scale. */ 271*89a0ef05SAndroid Build Coastguard Worker } uhdr_gainmap_metadata_t; /**< alias for struct uhdr_gainmap_metadata */ 272*89a0ef05SAndroid Build Coastguard Worker 273*89a0ef05SAndroid Build Coastguard Worker /**\brief ultrahdr codec context opaque descriptor */ 274*89a0ef05SAndroid Build Coastguard Worker typedef struct uhdr_codec_private uhdr_codec_private_t; 275*89a0ef05SAndroid Build Coastguard Worker 276*89a0ef05SAndroid Build Coastguard Worker // =============================================================================================== 277*89a0ef05SAndroid Build Coastguard Worker // Function Declarations 278*89a0ef05SAndroid Build Coastguard Worker // =============================================================================================== 279*89a0ef05SAndroid Build Coastguard Worker 280*89a0ef05SAndroid Build Coastguard Worker // =============================================================================================== 281*89a0ef05SAndroid Build Coastguard Worker // Encoder APIs 282*89a0ef05SAndroid Build Coastguard Worker // =============================================================================================== 283*89a0ef05SAndroid Build Coastguard Worker 284*89a0ef05SAndroid Build Coastguard Worker /*!\brief Create a new encoder instance. The instance is initialized with default settings. 285*89a0ef05SAndroid Build Coastguard Worker * To override the settings use uhdr_enc_set_*() 286*89a0ef05SAndroid Build Coastguard Worker * 287*89a0ef05SAndroid Build Coastguard Worker * \return nullptr if there was an error allocating memory else a fresh opaque encoder handle 288*89a0ef05SAndroid Build Coastguard Worker */ 289*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_codec_private_t* uhdr_create_encoder(void); 290*89a0ef05SAndroid Build Coastguard Worker 291*89a0ef05SAndroid Build Coastguard Worker /*!\brief Release encoder instance. 292*89a0ef05SAndroid Build Coastguard Worker * Frees all allocated storage associated with encoder instance. 293*89a0ef05SAndroid Build Coastguard Worker * 294*89a0ef05SAndroid Build Coastguard Worker * \param[in] enc encoder instance. 295*89a0ef05SAndroid Build Coastguard Worker * 296*89a0ef05SAndroid Build Coastguard Worker * \return none 297*89a0ef05SAndroid Build Coastguard Worker */ 298*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN void uhdr_release_encoder(uhdr_codec_private_t* enc); 299*89a0ef05SAndroid Build Coastguard Worker 300*89a0ef05SAndroid Build Coastguard Worker /*!\brief Add raw image descriptor to encoder context. The function goes through all the fields of 301*89a0ef05SAndroid Build Coastguard Worker * the image descriptor and checks for their sanity. If no anomalies are seen then the image is 302*89a0ef05SAndroid Build Coastguard Worker * added to internal list. Repeated calls to this function will replace the old entry with the 303*89a0ef05SAndroid Build Coastguard Worker * current. 304*89a0ef05SAndroid Build Coastguard Worker * 305*89a0ef05SAndroid Build Coastguard Worker * \param[in] enc encoder instance. 306*89a0ef05SAndroid Build Coastguard Worker * \param[in] img image descriptor. 307*89a0ef05SAndroid Build Coastguard Worker * \param[in] intent UHDR_HDR_IMG for hdr intent and UHDR_SDR_IMG for sdr intent. 308*89a0ef05SAndroid Build Coastguard Worker * 309*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, 310*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CODEC_INVALID_PARAM otherwise. 311*89a0ef05SAndroid Build Coastguard Worker */ 312*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_enc_set_raw_image(uhdr_codec_private_t* enc, 313*89a0ef05SAndroid Build Coastguard Worker uhdr_raw_image_t* img, 314*89a0ef05SAndroid Build Coastguard Worker uhdr_img_label_t intent); 315*89a0ef05SAndroid Build Coastguard Worker 316*89a0ef05SAndroid Build Coastguard Worker /*!\brief Add compressed image descriptor to encoder context. The function goes through all the 317*89a0ef05SAndroid Build Coastguard Worker * fields of the image descriptor and checks for their sanity. If no anomalies are seen then the 318*89a0ef05SAndroid Build Coastguard Worker * image is added to internal list. Repeated calls to this function will replace the old entry with 319*89a0ef05SAndroid Build Coastguard Worker * the current. 320*89a0ef05SAndroid Build Coastguard Worker * 321*89a0ef05SAndroid Build Coastguard Worker * If both uhdr_enc_add_raw_image() and uhdr_enc_add_compressed_image() are called during a session 322*89a0ef05SAndroid Build Coastguard Worker * for the same intent, it is assumed that raw image descriptor and compressed image descriptor are 323*89a0ef05SAndroid Build Coastguard Worker * relatable via compress <-> decompress process. 324*89a0ef05SAndroid Build Coastguard Worker * 325*89a0ef05SAndroid Build Coastguard Worker * The compressed image descriptors has fields cg, ct and range. Certain media formats are capable 326*89a0ef05SAndroid Build Coastguard Worker * of storing color standard, color transfer and color range characteristics in the bitstream (for 327*89a0ef05SAndroid Build Coastguard Worker * example heif, avif, ...). Other formats may not support this (jpeg, ...). These fields serve as 328*89a0ef05SAndroid Build Coastguard Worker * an additional source for conveying this information. If the user is unaware of the color aspects 329*89a0ef05SAndroid Build Coastguard Worker * of the image, #UHDR_CG_UNSPECIFIED, #UHDR_CT_UNSPECIFIED, #UHDR_CR_UNSPECIFIED can be used. If 330*89a0ef05SAndroid Build Coastguard Worker * color aspects are present inside the bitstream and supplied via these fields both are expected to 331*89a0ef05SAndroid Build Coastguard Worker * be identical. 332*89a0ef05SAndroid Build Coastguard Worker * 333*89a0ef05SAndroid Build Coastguard Worker * \param[in] enc encoder instance. 334*89a0ef05SAndroid Build Coastguard Worker * \param[in] img image descriptor. 335*89a0ef05SAndroid Build Coastguard Worker * \param[in] intent UHDR_HDR_IMG for hdr intent, 336*89a0ef05SAndroid Build Coastguard Worker * UHDR_SDR_IMG for sdr intent, 337*89a0ef05SAndroid Build Coastguard Worker * UHDR_BASE_IMG for base image intent 338*89a0ef05SAndroid Build Coastguard Worker * 339*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, 340*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CODEC_INVALID_PARAM otherwise. 341*89a0ef05SAndroid Build Coastguard Worker */ 342*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_enc_set_compressed_image(uhdr_codec_private_t* enc, 343*89a0ef05SAndroid Build Coastguard Worker uhdr_compressed_image_t* img, 344*89a0ef05SAndroid Build Coastguard Worker uhdr_img_label_t intent); 345*89a0ef05SAndroid Build Coastguard Worker 346*89a0ef05SAndroid Build Coastguard Worker /*!\brief Add gain map image descriptor and gainmap metadata info that was used to generate the 347*89a0ef05SAndroid Build Coastguard Worker * aforth gainmap image to encoder context. The function internally goes through all the fields of 348*89a0ef05SAndroid Build Coastguard Worker * the image descriptor and checks for their sanity. If no anomalies are seen then the image is 349*89a0ef05SAndroid Build Coastguard Worker * added to internal list. Repeated calls to this function will replace the old entry with the 350*89a0ef05SAndroid Build Coastguard Worker * current. 351*89a0ef05SAndroid Build Coastguard Worker * 352*89a0ef05SAndroid Build Coastguard Worker * NOTE: There are apis that allow configuration of gainmap info separately. For instance 353*89a0ef05SAndroid Build Coastguard Worker * #uhdr_enc_set_gainmap_gamma, #uhdr_enc_set_gainmap_scale_factor, ... They have no effect on the 354*89a0ef05SAndroid Build Coastguard Worker * information that is configured via this api. The information configured here is treated as 355*89a0ef05SAndroid Build Coastguard Worker * immutable and used as-is in encoding scenario where gainmap computations are intended to be 356*89a0ef05SAndroid Build Coastguard Worker * by-passed. 357*89a0ef05SAndroid Build Coastguard Worker * 358*89a0ef05SAndroid Build Coastguard Worker * \param[in] enc encoder instance. 359*89a0ef05SAndroid Build Coastguard Worker * \param[in] img gain map image desciptor. 360*89a0ef05SAndroid Build Coastguard Worker * \param[in] metadata gainmap metadata descriptor 361*89a0ef05SAndroid Build Coastguard Worker * 362*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, 363*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CODEC_INVALID_PARAM otherwise. 364*89a0ef05SAndroid Build Coastguard Worker */ 365*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_enc_set_gainmap_image(uhdr_codec_private_t* enc, 366*89a0ef05SAndroid Build Coastguard Worker uhdr_compressed_image_t* img, 367*89a0ef05SAndroid Build Coastguard Worker uhdr_gainmap_metadata_t* metadata); 368*89a0ef05SAndroid Build Coastguard Worker 369*89a0ef05SAndroid Build Coastguard Worker /*!\brief Set quality factor for compressing base image and/or gainmap image. Default configured 370*89a0ef05SAndroid Build Coastguard Worker * quality factor of base image and gainmap image are 95 and 95 respectively. 371*89a0ef05SAndroid Build Coastguard Worker * 372*89a0ef05SAndroid Build Coastguard Worker * \param[in] enc encoder instance. 373*89a0ef05SAndroid Build Coastguard Worker * \param[in] quality quality factor. Any integer in range [0 - 100]. 374*89a0ef05SAndroid Build Coastguard Worker * \param[in] intent #UHDR_BASE_IMG for base image and #UHDR_GAIN_MAP_IMG for gain map image. 375*89a0ef05SAndroid Build Coastguard Worker * 376*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, 377*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CODEC_INVALID_PARAM otherwise. 378*89a0ef05SAndroid Build Coastguard Worker */ 379*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_enc_set_quality(uhdr_codec_private_t* enc, int quality, 380*89a0ef05SAndroid Build Coastguard Worker uhdr_img_label_t intent); 381*89a0ef05SAndroid Build Coastguard Worker 382*89a0ef05SAndroid Build Coastguard Worker /*!\brief Set Exif data that needs to be inserted in the output compressed stream. This function 383*89a0ef05SAndroid Build Coastguard Worker * does not generate or validate exif data on its own. It merely copies the supplied information 384*89a0ef05SAndroid Build Coastguard Worker * into the bitstream. 385*89a0ef05SAndroid Build Coastguard Worker * 386*89a0ef05SAndroid Build Coastguard Worker * \param[in] enc encoder instance. 387*89a0ef05SAndroid Build Coastguard Worker * \param[in] exif exif data memory block. 388*89a0ef05SAndroid Build Coastguard Worker * 389*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, 390*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CODEC_INVALID_PARAM otherwise. 391*89a0ef05SAndroid Build Coastguard Worker */ 392*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_enc_set_exif_data(uhdr_codec_private_t* enc, 393*89a0ef05SAndroid Build Coastguard Worker uhdr_mem_block_t* exif); 394*89a0ef05SAndroid Build Coastguard Worker 395*89a0ef05SAndroid Build Coastguard Worker /*!\brief Enable/Disable multi-channel gainmap. By default multi-channel gainmap is enabled. 396*89a0ef05SAndroid Build Coastguard Worker * 397*89a0ef05SAndroid Build Coastguard Worker * \param[in] enc encoder instance. 398*89a0ef05SAndroid Build Coastguard Worker * \param[in] use_multi_channel_gainmap enable/disable multichannel gain map. 399*89a0ef05SAndroid Build Coastguard Worker * 0 - single-channel gainmap is enabled, 400*89a0ef05SAndroid Build Coastguard Worker * otherwise - multi-channel gainmap is enabled. 401*89a0ef05SAndroid Build Coastguard Worker * 402*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, 403*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CODEC_INVALID_PARAM otherwise. 404*89a0ef05SAndroid Build Coastguard Worker */ 405*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t 406*89a0ef05SAndroid Build Coastguard Worker uhdr_enc_set_using_multi_channel_gainmap(uhdr_codec_private_t* enc, int use_multi_channel_gainmap); 407*89a0ef05SAndroid Build Coastguard Worker 408*89a0ef05SAndroid Build Coastguard Worker /*!\brief Set gain map scaling factor. The encoding process allows signalling a downscaled gainmap 409*89a0ef05SAndroid Build Coastguard Worker * image instead of full resolution. This setting controls the factor by which the renditions are 410*89a0ef05SAndroid Build Coastguard Worker * downscaled. For instance, gainmap_scale_factor = 2 implies gainmap_image_width = 411*89a0ef05SAndroid Build Coastguard Worker * primary_image_width / 2 and gainmap image height = primary_image_height / 2. 412*89a0ef05SAndroid Build Coastguard Worker * Default gain map scaling factor is 1. 413*89a0ef05SAndroid Build Coastguard Worker * NOTE: This has no effect on base image rendition. Base image is signalled in full resolution 414*89a0ef05SAndroid Build Coastguard Worker * always. 415*89a0ef05SAndroid Build Coastguard Worker * 416*89a0ef05SAndroid Build Coastguard Worker * \param[in] enc encoder instance. 417*89a0ef05SAndroid Build Coastguard Worker * \param[in] gainmap_scale_factor gain map scale factor. Any integer in range (0, 128] 418*89a0ef05SAndroid Build Coastguard Worker * 419*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, 420*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CODEC_INVALID_PARAM otherwise. 421*89a0ef05SAndroid Build Coastguard Worker */ 422*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_enc_set_gainmap_scale_factor(uhdr_codec_private_t* enc, 423*89a0ef05SAndroid Build Coastguard Worker int gainmap_scale_factor); 424*89a0ef05SAndroid Build Coastguard Worker 425*89a0ef05SAndroid Build Coastguard Worker /*!\brief Set encoding gamma of gainmap image. For multi-channel gainmap image, set gamma is used 426*89a0ef05SAndroid Build Coastguard Worker * for gamma correction of all planes separately. Default gamma value is 1.0. 427*89a0ef05SAndroid Build Coastguard Worker * 428*89a0ef05SAndroid Build Coastguard Worker * \param[in] enc encoder instance. 429*89a0ef05SAndroid Build Coastguard Worker * \param[in] gamma gamma of gainmap image. Any positive real number. 430*89a0ef05SAndroid Build Coastguard Worker * 431*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, 432*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CODEC_INVALID_PARAM otherwise. 433*89a0ef05SAndroid Build Coastguard Worker */ 434*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_enc_set_gainmap_gamma(uhdr_codec_private_t* enc, float gamma); 435*89a0ef05SAndroid Build Coastguard Worker 436*89a0ef05SAndroid Build Coastguard Worker /*!\brief Set min max content boost. This configuration is treated as a recommendation by the 437*89a0ef05SAndroid Build Coastguard Worker * library. It is entirely possible for the library to use a different set of values. Value MUST be 438*89a0ef05SAndroid Build Coastguard Worker * in linear scale. 439*89a0ef05SAndroid Build Coastguard Worker * 440*89a0ef05SAndroid Build Coastguard Worker * \param[in] enc encoder instance. 441*89a0ef05SAndroid Build Coastguard Worker * \param[in] min_boost min content boost. Any positive real number. 442*89a0ef05SAndroid Build Coastguard Worker * \param[in] max_boost max content boost. Any positive real number >= min_boost. 443*89a0ef05SAndroid Build Coastguard Worker * 444*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, 445*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CODEC_INVALID_PARAM otherwise. 446*89a0ef05SAndroid Build Coastguard Worker */ 447*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_enc_set_min_max_content_boost(uhdr_codec_private_t* enc, 448*89a0ef05SAndroid Build Coastguard Worker float min_boost, float max_boost); 449*89a0ef05SAndroid Build Coastguard Worker 450*89a0ef05SAndroid Build Coastguard Worker /*!\brief Set target display peak brightness in nits. This is used for configuring #hdr_capacity_max 451*89a0ef05SAndroid Build Coastguard Worker * of gainmap metadata. This value determines the weight by which the gain map coefficients are 452*89a0ef05SAndroid Build Coastguard Worker * scaled during decode. If this is not configured, then default peak luminance of HDR intent's 453*89a0ef05SAndroid Build Coastguard Worker * color transfer under test is used. For #UHDR_CT_HLG, this corresponds to 1000 nits and for 454*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CT_LINEAR and #UHDR_CT_PQ, this corresponds to 10000 nits. 455*89a0ef05SAndroid Build Coastguard Worker * 456*89a0ef05SAndroid Build Coastguard Worker * \param[in] enc encoder instance. 457*89a0ef05SAndroid Build Coastguard Worker * \param[in] nits target display peak brightness in nits. Any positive real number in range 458*89a0ef05SAndroid Build Coastguard Worker * [203, 10000]. 459*89a0ef05SAndroid Build Coastguard Worker * 460*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, 461*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CODEC_INVALID_PARAM otherwise. 462*89a0ef05SAndroid Build Coastguard Worker */ 463*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_enc_set_target_display_peak_brightness(uhdr_codec_private_t* enc, 464*89a0ef05SAndroid Build Coastguard Worker float nits); 465*89a0ef05SAndroid Build Coastguard Worker 466*89a0ef05SAndroid Build Coastguard Worker /*!\brief Set encoding preset. Tunes the encoder configurations for performance or quality. Default 467*89a0ef05SAndroid Build Coastguard Worker * configuration is #UHDR_USAGE_BEST_QUALITY. 468*89a0ef05SAndroid Build Coastguard Worker * 469*89a0ef05SAndroid Build Coastguard Worker * \param[in] enc encoder instance. 470*89a0ef05SAndroid Build Coastguard Worker * \param[in] preset encoding preset. #UHDR_USAGE_REALTIME - Tune settings for best performance 471*89a0ef05SAndroid Build Coastguard Worker * #UHDR_USAGE_BEST_QUALITY - Tune settings for best quality 472*89a0ef05SAndroid Build Coastguard Worker * 473*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, 474*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CODEC_INVALID_PARAM otherwise. 475*89a0ef05SAndroid Build Coastguard Worker */ 476*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_enc_set_preset(uhdr_codec_private_t* enc, 477*89a0ef05SAndroid Build Coastguard Worker uhdr_enc_preset_t preset); 478*89a0ef05SAndroid Build Coastguard Worker 479*89a0ef05SAndroid Build Coastguard Worker /*!\brief Set output image compression format. Selects the compression format for encoding base 480*89a0ef05SAndroid Build Coastguard Worker * image and gainmap image. Default configuration is #UHDR_CODEC_JPG 481*89a0ef05SAndroid Build Coastguard Worker * 482*89a0ef05SAndroid Build Coastguard Worker * \param[in] enc encoder instance. 483*89a0ef05SAndroid Build Coastguard Worker * \param[in] media_type output image compression format. Supported values are #UHDR_CODEC_JPG 484*89a0ef05SAndroid Build Coastguard Worker * 485*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, 486*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CODEC_INVALID_PARAM otherwise. 487*89a0ef05SAndroid Build Coastguard Worker */ 488*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_enc_set_output_format(uhdr_codec_private_t* enc, 489*89a0ef05SAndroid Build Coastguard Worker uhdr_codec_t media_type); 490*89a0ef05SAndroid Build Coastguard Worker 491*89a0ef05SAndroid Build Coastguard Worker /*!\brief Encode process call 492*89a0ef05SAndroid Build Coastguard Worker * After initializing the encoder context, call to this function will submit data for encoding. If 493*89a0ef05SAndroid Build Coastguard Worker * the call is successful, the encoded output is stored internally and is accessible via 494*89a0ef05SAndroid Build Coastguard Worker * uhdr_get_encoded_stream(). 495*89a0ef05SAndroid Build Coastguard Worker * 496*89a0ef05SAndroid Build Coastguard Worker * The basic usage of uhdr encoder is as follows: 497*89a0ef05SAndroid Build Coastguard Worker * - The program creates an instance of an encoder using, 498*89a0ef05SAndroid Build Coastguard Worker * - uhdr_create_encoder(). 499*89a0ef05SAndroid Build Coastguard Worker * - The program registers input images to the encoder using, 500*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_raw_image(ctxt, img, UHDR_HDR_IMG) 501*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_raw_image(ctxt, img, UHDR_SDR_IMG) 502*89a0ef05SAndroid Build Coastguard Worker * - The program overrides the default settings using uhdr_enc_set_*() functions 503*89a0ef05SAndroid Build Coastguard Worker * - If the application wants to control the compression level 504*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_quality() 505*89a0ef05SAndroid Build Coastguard Worker * - If the application wants to insert exif data 506*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_exif_data() 507*89a0ef05SAndroid Build Coastguard Worker * - If the application wants to set gainmap scale factor 508*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_gainmap_scale_factor() 509*89a0ef05SAndroid Build Coastguard Worker * - If the application wants to enable multi channel gain map 510*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_using_multi_channel_gainmap() 511*89a0ef05SAndroid Build Coastguard Worker * - If the application wants to set gainmap image gamma 512*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_gainmap_gamma() 513*89a0ef05SAndroid Build Coastguard Worker * - If the application wants to recommend min max content boost 514*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_min_max_content_boost() 515*89a0ef05SAndroid Build Coastguard Worker * - If the application wants to set target display peak brightness 516*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_target_display_peak_brightness() 517*89a0ef05SAndroid Build Coastguard Worker * - If the application wants to set encoding preset 518*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_preset() 519*89a0ef05SAndroid Build Coastguard Worker * - If the application wants to control target compression format 520*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_output_format() 521*89a0ef05SAndroid Build Coastguard Worker * - The program calls uhdr_encode() to encode data. This call would initiate the process of 522*89a0ef05SAndroid Build Coastguard Worker * computing gain map from hdr intent and sdr intent. The sdr intent and gain map image are 523*89a0ef05SAndroid Build Coastguard Worker * compressed at the set quality using the codec of choice. 524*89a0ef05SAndroid Build Coastguard Worker * - On success, the program can access the encoded output with uhdr_get_encoded_stream(). 525*89a0ef05SAndroid Build Coastguard Worker * - The program finishes the encoding with uhdr_release_encoder(). 526*89a0ef05SAndroid Build Coastguard Worker * 527*89a0ef05SAndroid Build Coastguard Worker * The library allows setting Hdr and/or Sdr intent in compressed format, 528*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_compressed_image(ctxt, img, UHDR_HDR_IMG) 529*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_compressed_image(ctxt, img, UHDR_SDR_IMG) 530*89a0ef05SAndroid Build Coastguard Worker * In this mode, the compressed image(s) are first decoded to raw image(s). These raw image(s) go 531*89a0ef05SAndroid Build Coastguard Worker * through the aforth mentioned gain map computation and encoding process. In this case, the usage 532*89a0ef05SAndroid Build Coastguard Worker * shall be like this: 533*89a0ef05SAndroid Build Coastguard Worker * - uhdr_create_encoder() 534*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_compressed_image(ctxt, img, UHDR_HDR_IMG) 535*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_compressed_image(ctxt, img, UHDR_SDR_IMG) 536*89a0ef05SAndroid Build Coastguard Worker * - uhdr_encode() 537*89a0ef05SAndroid Build Coastguard Worker * - uhdr_get_encoded_stream() 538*89a0ef05SAndroid Build Coastguard Worker * - uhdr_release_encoder() 539*89a0ef05SAndroid Build Coastguard Worker * If the set compressed image media type of intent UHDR_SDR_IMG and output media type are 540*89a0ef05SAndroid Build Coastguard Worker * identical, then this image is directly used for primary image. No re-encode of raw image is done. 541*89a0ef05SAndroid Build Coastguard Worker * This implies base image quality setting is un-used. Only gain map image is encoded at the set 542*89a0ef05SAndroid Build Coastguard Worker * quality using codec of choice. On the other hand, if the set compressed image media type and 543*89a0ef05SAndroid Build Coastguard Worker * output media type are different, then transcoding is done. 544*89a0ef05SAndroid Build Coastguard Worker * 545*89a0ef05SAndroid Build Coastguard Worker * The library also allows directly setting base and gain map image in compressed format, 546*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_compressed_image(ctxt, img, UHDR_BASE_IMG) 547*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_gainmap_image(ctxt, img, metadata) 548*89a0ef05SAndroid Build Coastguard Worker * In this mode, gain map computation is by-passed. The input images are transcoded (if necessary), 549*89a0ef05SAndroid Build Coastguard Worker * combined and sent back. 550*89a0ef05SAndroid Build Coastguard Worker * 551*89a0ef05SAndroid Build Coastguard Worker * It is possible to create a uhdr image solely from Hdr intent. In this case, the usage shall look 552*89a0ef05SAndroid Build Coastguard Worker * like this: 553*89a0ef05SAndroid Build Coastguard Worker * - uhdr_create_encoder() 554*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_raw_image(ctxt, img, UHDR_HDR_IMG) 555*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_quality() // optional 556*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_exif_data() // optional 557*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_output_format() // optional 558*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_gainmap_scale_factor() // optional 559*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_using_multi_channel_gainmap() // optional 560*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_gainmap_gamma() // optional 561*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_min_max_content_boost() // optional 562*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enc_set_target_display_peak_brightness() // optional 563*89a0ef05SAndroid Build Coastguard Worker * - uhdr_encode() 564*89a0ef05SAndroid Build Coastguard Worker * - uhdr_get_encoded_stream() 565*89a0ef05SAndroid Build Coastguard Worker * - uhdr_release_encoder() 566*89a0ef05SAndroid Build Coastguard Worker * In this mode, the Sdr rendition is created from Hdr intent by tone-mapping. The tone-mapped sdr 567*89a0ef05SAndroid Build Coastguard Worker * image and hdr image go through the aforth mentioned gain map computation and encoding process to 568*89a0ef05SAndroid Build Coastguard Worker * create uhdr image. 569*89a0ef05SAndroid Build Coastguard Worker * 570*89a0ef05SAndroid Build Coastguard Worker * In all modes, Exif data is inserted if requested. 571*89a0ef05SAndroid Build Coastguard Worker * 572*89a0ef05SAndroid Build Coastguard Worker * \param[in] enc encoder instance. 573*89a0ef05SAndroid Build Coastguard Worker * 574*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, uhdr_codec_err_t otherwise. 575*89a0ef05SAndroid Build Coastguard Worker */ 576*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_encode(uhdr_codec_private_t* enc); 577*89a0ef05SAndroid Build Coastguard Worker 578*89a0ef05SAndroid Build Coastguard Worker /*!\brief Get encoded ultra hdr stream 579*89a0ef05SAndroid Build Coastguard Worker * 580*89a0ef05SAndroid Build Coastguard Worker * \param[in] enc encoder instance. 581*89a0ef05SAndroid Build Coastguard Worker * 582*89a0ef05SAndroid Build Coastguard Worker * \return nullptr if encode process call is unsuccessful, uhdr image descriptor otherwise 583*89a0ef05SAndroid Build Coastguard Worker */ 584*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_compressed_image_t* uhdr_get_encoded_stream(uhdr_codec_private_t* enc); 585*89a0ef05SAndroid Build Coastguard Worker 586*89a0ef05SAndroid Build Coastguard Worker /*!\brief Reset encoder instance. 587*89a0ef05SAndroid Build Coastguard Worker * Clears all previous settings and resets to default state and ready for re-initialization and 588*89a0ef05SAndroid Build Coastguard Worker * usage 589*89a0ef05SAndroid Build Coastguard Worker * 590*89a0ef05SAndroid Build Coastguard Worker * \param[in] enc encoder instance. 591*89a0ef05SAndroid Build Coastguard Worker * 592*89a0ef05SAndroid Build Coastguard Worker * \return none 593*89a0ef05SAndroid Build Coastguard Worker */ 594*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN void uhdr_reset_encoder(uhdr_codec_private_t* enc); 595*89a0ef05SAndroid Build Coastguard Worker 596*89a0ef05SAndroid Build Coastguard Worker // =============================================================================================== 597*89a0ef05SAndroid Build Coastguard Worker // Decoder APIs 598*89a0ef05SAndroid Build Coastguard Worker // =============================================================================================== 599*89a0ef05SAndroid Build Coastguard Worker 600*89a0ef05SAndroid Build Coastguard Worker /*!\brief check if it is a valid ultrahdr image. 601*89a0ef05SAndroid Build Coastguard Worker * 602*89a0ef05SAndroid Build Coastguard Worker * @param[in] data pointer to input compressed stream 603*89a0ef05SAndroid Build Coastguard Worker * @param[in] size size of compressed stream 604*89a0ef05SAndroid Build Coastguard Worker * 605*89a0ef05SAndroid Build Coastguard Worker * @returns 1 if the input data has a primary image, gain map image and gain map metadata. 0 if any 606*89a0ef05SAndroid Build Coastguard Worker * errors are encountered during parsing process or if the image does not have primary 607*89a0ef05SAndroid Build Coastguard Worker * image or gainmap image or gainmap metadata 608*89a0ef05SAndroid Build Coastguard Worker */ 609*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN int is_uhdr_image(void* data, int size); 610*89a0ef05SAndroid Build Coastguard Worker 611*89a0ef05SAndroid Build Coastguard Worker /*!\brief Create a new decoder instance. The instance is initialized with default settings. 612*89a0ef05SAndroid Build Coastguard Worker * To override the settings use uhdr_dec_set_*() 613*89a0ef05SAndroid Build Coastguard Worker * 614*89a0ef05SAndroid Build Coastguard Worker * \return nullptr if there was an error allocating memory else a fresh opaque decoder handle 615*89a0ef05SAndroid Build Coastguard Worker */ 616*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_codec_private_t* uhdr_create_decoder(void); 617*89a0ef05SAndroid Build Coastguard Worker 618*89a0ef05SAndroid Build Coastguard Worker /*!\brief Release decoder instance. 619*89a0ef05SAndroid Build Coastguard Worker * Frees all allocated storage associated with decoder instance. 620*89a0ef05SAndroid Build Coastguard Worker * 621*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 622*89a0ef05SAndroid Build Coastguard Worker * 623*89a0ef05SAndroid Build Coastguard Worker * \return none 624*89a0ef05SAndroid Build Coastguard Worker */ 625*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN void uhdr_release_decoder(uhdr_codec_private_t* dec); 626*89a0ef05SAndroid Build Coastguard Worker 627*89a0ef05SAndroid Build Coastguard Worker /*!\brief Add compressed image descriptor to decoder context. The function goes through all the 628*89a0ef05SAndroid Build Coastguard Worker * fields of the image descriptor and checks for their sanity. If no anomalies are seen then the 629*89a0ef05SAndroid Build Coastguard Worker * image is added to internal list. Repeated calls to this function will replace the old entry with 630*89a0ef05SAndroid Build Coastguard Worker * the current. 631*89a0ef05SAndroid Build Coastguard Worker * 632*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 633*89a0ef05SAndroid Build Coastguard Worker * \param[in] img image descriptor. 634*89a0ef05SAndroid Build Coastguard Worker * 635*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, 636*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CODEC_INVALID_PARAM otherwise. 637*89a0ef05SAndroid Build Coastguard Worker */ 638*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_dec_set_image(uhdr_codec_private_t* dec, 639*89a0ef05SAndroid Build Coastguard Worker uhdr_compressed_image_t* img); 640*89a0ef05SAndroid Build Coastguard Worker 641*89a0ef05SAndroid Build Coastguard Worker /*!\brief Set output image color format 642*89a0ef05SAndroid Build Coastguard Worker * 643*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 644*89a0ef05SAndroid Build Coastguard Worker * \param[in] fmt output image color format. Supported values are 645*89a0ef05SAndroid Build Coastguard Worker * #UHDR_IMG_FMT_64bppRGBAHalfFloat, #UHDR_IMG_FMT_32bppRGBA1010102, 646*89a0ef05SAndroid Build Coastguard Worker * #UHDR_IMG_FMT_32bppRGBA8888 647*89a0ef05SAndroid Build Coastguard Worker * 648*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, 649*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CODEC_INVALID_PARAM otherwise. 650*89a0ef05SAndroid Build Coastguard Worker */ 651*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_dec_set_out_img_format(uhdr_codec_private_t* dec, 652*89a0ef05SAndroid Build Coastguard Worker uhdr_img_fmt_t fmt); 653*89a0ef05SAndroid Build Coastguard Worker 654*89a0ef05SAndroid Build Coastguard Worker /*!\brief Set output image color transfer characteristics. It should be noted that not all 655*89a0ef05SAndroid Build Coastguard Worker * combinations of output color format and output transfer function are supported. #UHDR_CT_SRGB 656*89a0ef05SAndroid Build Coastguard Worker * output color transfer shall be paired with #UHDR_IMG_FMT_32bppRGBA8888 only. #UHDR_CT_HLG, 657*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CT_PQ shall be paired with #UHDR_IMG_FMT_32bppRGBA1010102. #UHDR_CT_LINEAR shall be paired 658*89a0ef05SAndroid Build Coastguard Worker * with #UHDR_IMG_FMT_64bppRGBAHalfFloat. 659*89a0ef05SAndroid Build Coastguard Worker * 660*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 661*89a0ef05SAndroid Build Coastguard Worker * \param[in] ct output color transfer 662*89a0ef05SAndroid Build Coastguard Worker * 663*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, 664*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CODEC_INVALID_PARAM otherwise. 665*89a0ef05SAndroid Build Coastguard Worker */ 666*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_dec_set_out_color_transfer(uhdr_codec_private_t* dec, 667*89a0ef05SAndroid Build Coastguard Worker uhdr_color_transfer_t ct); 668*89a0ef05SAndroid Build Coastguard Worker 669*89a0ef05SAndroid Build Coastguard Worker /*!\brief Set output display's HDR capacity. Value MUST be in linear scale. This value determines 670*89a0ef05SAndroid Build Coastguard Worker * the weight by which the gain map coefficients are scaled. If no value is configured, no weight is 671*89a0ef05SAndroid Build Coastguard Worker * applied to gainmap image. 672*89a0ef05SAndroid Build Coastguard Worker * 673*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 674*89a0ef05SAndroid Build Coastguard Worker * \param[in] display_boost hdr capacity of target display. Any real number >= 1.0f 675*89a0ef05SAndroid Build Coastguard Worker * 676*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, 677*89a0ef05SAndroid Build Coastguard Worker * #UHDR_CODEC_INVALID_PARAM otherwise. 678*89a0ef05SAndroid Build Coastguard Worker */ 679*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_dec_set_out_max_display_boost(uhdr_codec_private_t* dec, 680*89a0ef05SAndroid Build Coastguard Worker float display_boost); 681*89a0ef05SAndroid Build Coastguard Worker 682*89a0ef05SAndroid Build Coastguard Worker /*!\brief This function parses the bitstream that is registered with the decoder context and makes 683*89a0ef05SAndroid Build Coastguard Worker * image information available to the client via uhdr_dec_get_() functions. It does not decompress 684*89a0ef05SAndroid Build Coastguard Worker * the image. That is done by uhdr_decode(). 685*89a0ef05SAndroid Build Coastguard Worker * 686*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 687*89a0ef05SAndroid Build Coastguard Worker * 688*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, uhdr_codec_err_t otherwise. 689*89a0ef05SAndroid Build Coastguard Worker */ 690*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_dec_probe(uhdr_codec_private_t* dec); 691*89a0ef05SAndroid Build Coastguard Worker 692*89a0ef05SAndroid Build Coastguard Worker /*!\brief Get base image width 693*89a0ef05SAndroid Build Coastguard Worker * 694*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 695*89a0ef05SAndroid Build Coastguard Worker * 696*89a0ef05SAndroid Build Coastguard Worker * \return -1 if probe call is unsuccessful, base image width otherwise 697*89a0ef05SAndroid Build Coastguard Worker */ 698*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN int uhdr_dec_get_image_width(uhdr_codec_private_t* dec); 699*89a0ef05SAndroid Build Coastguard Worker 700*89a0ef05SAndroid Build Coastguard Worker /*!\brief Get base image height 701*89a0ef05SAndroid Build Coastguard Worker * 702*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 703*89a0ef05SAndroid Build Coastguard Worker * 704*89a0ef05SAndroid Build Coastguard Worker * \return -1 if probe call is unsuccessful, base image height otherwise 705*89a0ef05SAndroid Build Coastguard Worker */ 706*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN int uhdr_dec_get_image_height(uhdr_codec_private_t* dec); 707*89a0ef05SAndroid Build Coastguard Worker 708*89a0ef05SAndroid Build Coastguard Worker /*!\brief Get gainmap image width 709*89a0ef05SAndroid Build Coastguard Worker * 710*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 711*89a0ef05SAndroid Build Coastguard Worker * 712*89a0ef05SAndroid Build Coastguard Worker * \return -1 if probe call is unsuccessful, gain map image width otherwise 713*89a0ef05SAndroid Build Coastguard Worker */ 714*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN int uhdr_dec_get_gainmap_width(uhdr_codec_private_t* dec); 715*89a0ef05SAndroid Build Coastguard Worker 716*89a0ef05SAndroid Build Coastguard Worker /*!\brief Get gainmap image height 717*89a0ef05SAndroid Build Coastguard Worker * 718*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 719*89a0ef05SAndroid Build Coastguard Worker * 720*89a0ef05SAndroid Build Coastguard Worker * \return -1 if probe call is unsuccessful, gain map image height otherwise 721*89a0ef05SAndroid Build Coastguard Worker */ 722*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN int uhdr_dec_get_gainmap_height(uhdr_codec_private_t* dec); 723*89a0ef05SAndroid Build Coastguard Worker 724*89a0ef05SAndroid Build Coastguard Worker /*!\brief Get exif information 725*89a0ef05SAndroid Build Coastguard Worker * 726*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 727*89a0ef05SAndroid Build Coastguard Worker * 728*89a0ef05SAndroid Build Coastguard Worker * \return nullptr if probe call is unsuccessful, memory block with exif data otherwise 729*89a0ef05SAndroid Build Coastguard Worker */ 730*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_mem_block_t* uhdr_dec_get_exif(uhdr_codec_private_t* dec); 731*89a0ef05SAndroid Build Coastguard Worker 732*89a0ef05SAndroid Build Coastguard Worker /*!\brief Get icc information 733*89a0ef05SAndroid Build Coastguard Worker * 734*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 735*89a0ef05SAndroid Build Coastguard Worker * 736*89a0ef05SAndroid Build Coastguard Worker * \return nullptr if probe call is unsuccessful, memory block with icc data otherwise 737*89a0ef05SAndroid Build Coastguard Worker */ 738*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_mem_block_t* uhdr_dec_get_icc(uhdr_codec_private_t* dec); 739*89a0ef05SAndroid Build Coastguard Worker 740*89a0ef05SAndroid Build Coastguard Worker /*!\brief Get base image (compressed) 741*89a0ef05SAndroid Build Coastguard Worker * 742*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 743*89a0ef05SAndroid Build Coastguard Worker * 744*89a0ef05SAndroid Build Coastguard Worker * \return nullptr if probe process call is unsuccessful, memory block with base image data 745*89a0ef05SAndroid Build Coastguard Worker * otherwise 746*89a0ef05SAndroid Build Coastguard Worker */ 747*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_mem_block_t* uhdr_dec_get_base_image(uhdr_codec_private_t* dec); 748*89a0ef05SAndroid Build Coastguard Worker 749*89a0ef05SAndroid Build Coastguard Worker /*!\brief Get gain map image (compressed) 750*89a0ef05SAndroid Build Coastguard Worker * 751*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 752*89a0ef05SAndroid Build Coastguard Worker * 753*89a0ef05SAndroid Build Coastguard Worker * \return nullptr if probe process call is unsuccessful, memory block with gainmap image data 754*89a0ef05SAndroid Build Coastguard Worker * otherwise 755*89a0ef05SAndroid Build Coastguard Worker */ 756*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_mem_block_t* uhdr_dec_get_gainmap_image(uhdr_codec_private_t* dec); 757*89a0ef05SAndroid Build Coastguard Worker 758*89a0ef05SAndroid Build Coastguard Worker /*!\brief Get gain map metadata 759*89a0ef05SAndroid Build Coastguard Worker * 760*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 761*89a0ef05SAndroid Build Coastguard Worker * 762*89a0ef05SAndroid Build Coastguard Worker * \return nullptr if probe process call is unsuccessful, gainmap metadata descriptor otherwise 763*89a0ef05SAndroid Build Coastguard Worker */ 764*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_gainmap_metadata_t* uhdr_dec_get_gainmap_metadata(uhdr_codec_private_t* dec); 765*89a0ef05SAndroid Build Coastguard Worker 766*89a0ef05SAndroid Build Coastguard Worker /*!\brief Decode process call 767*89a0ef05SAndroid Build Coastguard Worker * After initializing the decoder context, call to this function will submit data for decoding. If 768*89a0ef05SAndroid Build Coastguard Worker * the call is successful, the decoded output is stored internally and is accessible via 769*89a0ef05SAndroid Build Coastguard Worker * uhdr_get_decoded_image(). 770*89a0ef05SAndroid Build Coastguard Worker * 771*89a0ef05SAndroid Build Coastguard Worker * The basic usage of uhdr decoder is as follows: 772*89a0ef05SAndroid Build Coastguard Worker * - The program creates an instance of a decoder using, 773*89a0ef05SAndroid Build Coastguard Worker * - uhdr_create_decoder(). 774*89a0ef05SAndroid Build Coastguard Worker * - The program registers input images to the decoder using, 775*89a0ef05SAndroid Build Coastguard Worker * - uhdr_dec_set_image(ctxt, img) 776*89a0ef05SAndroid Build Coastguard Worker * - The program overrides the default settings using uhdr_dec_set_*() functions. 777*89a0ef05SAndroid Build Coastguard Worker * - If the application wants to control the output image format, 778*89a0ef05SAndroid Build Coastguard Worker * - uhdr_dec_set_out_img_format() 779*89a0ef05SAndroid Build Coastguard Worker * - If the application wants to control the output transfer characteristics, 780*89a0ef05SAndroid Build Coastguard Worker * - uhdr_dec_set_out_color_transfer() 781*89a0ef05SAndroid Build Coastguard Worker * - If the application wants to control the output display boost, 782*89a0ef05SAndroid Build Coastguard Worker * - uhdr_dec_set_out_max_display_boost() 783*89a0ef05SAndroid Build Coastguard Worker * - If the application wants to enable/disable gpu acceleration, 784*89a0ef05SAndroid Build Coastguard Worker * - uhdr_enable_gpu_acceleration() 785*89a0ef05SAndroid Build Coastguard Worker * - The program calls uhdr_decode() to decode uhdr stream. This call would initiate the process 786*89a0ef05SAndroid Build Coastguard Worker * of decoding base image and gain map image. These two are combined to give the final rendition 787*89a0ef05SAndroid Build Coastguard Worker * image. 788*89a0ef05SAndroid Build Coastguard Worker * - The program can access the decoded output with uhdr_get_decoded_image(). 789*89a0ef05SAndroid Build Coastguard Worker * - The program finishes the decoding with uhdr_release_decoder(). 790*89a0ef05SAndroid Build Coastguard Worker * 791*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 792*89a0ef05SAndroid Build Coastguard Worker * 793*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, uhdr_codec_err_t otherwise. 794*89a0ef05SAndroid Build Coastguard Worker */ 795*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_decode(uhdr_codec_private_t* dec); 796*89a0ef05SAndroid Build Coastguard Worker 797*89a0ef05SAndroid Build Coastguard Worker /*!\brief Get final rendition image 798*89a0ef05SAndroid Build Coastguard Worker * 799*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 800*89a0ef05SAndroid Build Coastguard Worker * 801*89a0ef05SAndroid Build Coastguard Worker * \return nullptr if decoded process call is unsuccessful, raw image descriptor otherwise 802*89a0ef05SAndroid Build Coastguard Worker */ 803*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_raw_image_t* uhdr_get_decoded_image(uhdr_codec_private_t* dec); 804*89a0ef05SAndroid Build Coastguard Worker 805*89a0ef05SAndroid Build Coastguard Worker /*!\brief Get gain map image 806*89a0ef05SAndroid Build Coastguard Worker * 807*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 808*89a0ef05SAndroid Build Coastguard Worker * 809*89a0ef05SAndroid Build Coastguard Worker * \return nullptr if decoded process call is unsuccessful, raw image descriptor otherwise 810*89a0ef05SAndroid Build Coastguard Worker */ 811*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_raw_image_t* uhdr_get_decoded_gainmap_image(uhdr_codec_private_t* dec); 812*89a0ef05SAndroid Build Coastguard Worker 813*89a0ef05SAndroid Build Coastguard Worker /*!\brief Reset decoder instance. 814*89a0ef05SAndroid Build Coastguard Worker * Clears all previous settings and resets to default state and ready for re-initialization and 815*89a0ef05SAndroid Build Coastguard Worker * usage 816*89a0ef05SAndroid Build Coastguard Worker * 817*89a0ef05SAndroid Build Coastguard Worker * \param[in] dec decoder instance. 818*89a0ef05SAndroid Build Coastguard Worker * 819*89a0ef05SAndroid Build Coastguard Worker * \return none 820*89a0ef05SAndroid Build Coastguard Worker */ 821*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN void uhdr_reset_decoder(uhdr_codec_private_t* dec); 822*89a0ef05SAndroid Build Coastguard Worker 823*89a0ef05SAndroid Build Coastguard Worker // =============================================================================================== 824*89a0ef05SAndroid Build Coastguard Worker // Common APIs 825*89a0ef05SAndroid Build Coastguard Worker // =============================================================================================== 826*89a0ef05SAndroid Build Coastguard Worker 827*89a0ef05SAndroid Build Coastguard Worker /*!\brief Enable/Disable GPU acceleration. 828*89a0ef05SAndroid Build Coastguard Worker * If enabled, certain operations (if possible) of uhdr encode/decode will be offloaded to GPU. 829*89a0ef05SAndroid Build Coastguard Worker * NOTE: It is entirely possible for this API to have no effect on the encode/decode operation 830*89a0ef05SAndroid Build Coastguard Worker * 831*89a0ef05SAndroid Build Coastguard Worker * \param[in] codec codec instance. 832*89a0ef05SAndroid Build Coastguard Worker * \param[in] enable enable enable/disbale gpu acceleration 833*89a0ef05SAndroid Build Coastguard Worker * 834*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, #UHDR_CODEC_INVALID_PARAM 835*89a0ef05SAndroid Build Coastguard Worker * otherwise. 836*89a0ef05SAndroid Build Coastguard Worker */ 837*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_enable_gpu_acceleration(uhdr_codec_private_t* codec, int enable); 838*89a0ef05SAndroid Build Coastguard Worker 839*89a0ef05SAndroid Build Coastguard Worker /*!\brief Add image editing operations (pre-encode or post-decode). 840*89a0ef05SAndroid Build Coastguard Worker * Below functions list the set of edits supported. Program can set any combination of these during 841*89a0ef05SAndroid Build Coastguard Worker * initialization. Once the encode/decode process call is made, before encoding or after decoding 842*89a0ef05SAndroid Build Coastguard Worker * the edits are applied in the order of configuration. 843*89a0ef05SAndroid Build Coastguard Worker */ 844*89a0ef05SAndroid Build Coastguard Worker 845*89a0ef05SAndroid Build Coastguard Worker /*!\brief Add mirror effect 846*89a0ef05SAndroid Build Coastguard Worker * 847*89a0ef05SAndroid Build Coastguard Worker * \param[in] codec codec instance. 848*89a0ef05SAndroid Build Coastguard Worker * \param[in] direction mirror directions. #UHDR_MIRROR_VERTICAL for vertical mirroring 849*89a0ef05SAndroid Build Coastguard Worker * #UHDR_MIRROR_HORIZONTAL for horizontal mirroing 850*89a0ef05SAndroid Build Coastguard Worker * 851*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, #UHDR_CODEC_INVALID_PARAM 852*89a0ef05SAndroid Build Coastguard Worker * otherwise. 853*89a0ef05SAndroid Build Coastguard Worker */ 854*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_add_effect_mirror(uhdr_codec_private_t* codec, 855*89a0ef05SAndroid Build Coastguard Worker uhdr_mirror_direction_t direction); 856*89a0ef05SAndroid Build Coastguard Worker 857*89a0ef05SAndroid Build Coastguard Worker /*!\brief Add rotate effect 858*89a0ef05SAndroid Build Coastguard Worker * 859*89a0ef05SAndroid Build Coastguard Worker * \param[in] codec codec instance. 860*89a0ef05SAndroid Build Coastguard Worker * \param[in] degrees clockwise degrees. 90 - rotate clockwise by 90 degrees 861*89a0ef05SAndroid Build Coastguard Worker * 180 - rotate clockwise by 180 degrees 862*89a0ef05SAndroid Build Coastguard Worker * 270 - rotate clockwise by 270 degrees 863*89a0ef05SAndroid Build Coastguard Worker * 864*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, #UHDR_CODEC_INVALID_PARAM 865*89a0ef05SAndroid Build Coastguard Worker * otherwise. 866*89a0ef05SAndroid Build Coastguard Worker */ 867*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_add_effect_rotate(uhdr_codec_private_t* codec, int degrees); 868*89a0ef05SAndroid Build Coastguard Worker 869*89a0ef05SAndroid Build Coastguard Worker /*!\brief Add crop effect 870*89a0ef05SAndroid Build Coastguard Worker * 871*89a0ef05SAndroid Build Coastguard Worker * \param[in] codec codec instance. 872*89a0ef05SAndroid Build Coastguard Worker * \param[in] left crop coordinate left in pixels. 873*89a0ef05SAndroid Build Coastguard Worker * \param[in] right crop coordinate right in pixels. 874*89a0ef05SAndroid Build Coastguard Worker * \param[in] top crop coordinate top in pixels. 875*89a0ef05SAndroid Build Coastguard Worker * \param[in] bottom crop coordinate bottom in pixels. 876*89a0ef05SAndroid Build Coastguard Worker * 877*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, #UHDR_CODEC_INVALID_PARAM 878*89a0ef05SAndroid Build Coastguard Worker * otherwise. 879*89a0ef05SAndroid Build Coastguard Worker */ 880*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_add_effect_crop(uhdr_codec_private_t* codec, int left, int right, 881*89a0ef05SAndroid Build Coastguard Worker int top, int bottom); 882*89a0ef05SAndroid Build Coastguard Worker 883*89a0ef05SAndroid Build Coastguard Worker /*!\brief Add resize effect 884*89a0ef05SAndroid Build Coastguard Worker * 885*89a0ef05SAndroid Build Coastguard Worker * \param[in] codec codec instance. 886*89a0ef05SAndroid Build Coastguard Worker * \param[in] width target width. 887*89a0ef05SAndroid Build Coastguard Worker * \param[in] height target height. 888*89a0ef05SAndroid Build Coastguard Worker * 889*89a0ef05SAndroid Build Coastguard Worker * \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, #UHDR_CODEC_INVALID_PARAM 890*89a0ef05SAndroid Build Coastguard Worker * otherwise. 891*89a0ef05SAndroid Build Coastguard Worker */ 892*89a0ef05SAndroid Build Coastguard Worker UHDR_EXTERN uhdr_error_info_t uhdr_add_effect_resize(uhdr_codec_private_t* codec, int width, 893*89a0ef05SAndroid Build Coastguard Worker int height); 894*89a0ef05SAndroid Build Coastguard Worker 895*89a0ef05SAndroid Build Coastguard Worker #endif // ULTRAHDR_API_H 896