Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

starting with gain map API #3546

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/include/jxl/codestream_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,21 @@ typedef struct {
JxlLayerInfo layer_info;
} JxlFrameHeader;

/** Gain map information. This information is ...TODO
*/
typedef struct {
/* TODO : fill this with the stuff that is in ISO 21496-1,
for now we only store the binary blob
*/

uint32_t version;

uint32_t size;


} JxlGainMapInfo;


#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
Expand Down
51 changes: 51 additions & 0 deletions lib/include/jxl/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,24 @@ typedef enum {
* unprocessed.
*/
JXL_DEC_FRAME_PROGRESSION = 0x8000,

/**
* TODO: add documentation
*
*/
JXL_DEC_GAIN_MAP_INFO = 0x10000,

/**
* @brief Get raw bytes of the gain map
*
*/
JXL_DEC_GAIN_MAP_RAW = 0x20000,

/**
* @brief Get gain map as pixel buffer
*
*/
JXL_DEC_GAIN_MAP = 0x40000,
} JxlDecoderStatus;

/** Types of progressive detail.
Expand Down Expand Up @@ -1457,6 +1475,39 @@ JXL_EXPORT JxlDecoderStatus JxlDecoderFlushImage(JxlDecoder* dec);
JXL_EXPORT JxlDecoderStatus
JxlDecoderSetImageOutBitDepth(JxlDecoder* dec, const JxlBitDepth* bit_depth);

/**
* Outputs the size in bytes of the gain map info @ref
* JxlDecoderGetGainMapInfo, if available, or indicates there is none
* available.
*
* @param dec decoder object
* @param size variable to output the size into, or NULL to only check the
* return status.
* @return ::JXL_DEC_SUCCESS if the gain map info is available, @ref
* JXL_DEC_NEED_MORE_INPUT if the decoder has not yet received enough
* input data to determine whether a gain map is available or what its
* size is, ::JXL_DEC_ERROR in case the gain map info is not available.
*/
JXL_EXPORT JxlDecoderStatus JxlDecoderGetGainMapInfoSize(const JxlDecoder* dec,
size_t* size);

/**
* Outputs gain map info if available. The gain map info is only available if
* @ref JxlDecoderGetGainMapInfoSize returns success. The output buffer must
* have at least as many bytes as given by @ref JxlDecoderGetGainMapInfoSize.
*
* @param dec decoder object
* @param gain_map_info buffer to copy the gain map info info
* @param size size of the gain map info buffer in bytes
* @return @ref JXL_DEC_NEED_MORE_INPUT if the decoder has not yet received
* enough input data to determine whether a gain map is available,
* ::JXL_DEC_ERROR in case the gain map info is not available or the provided
* buffer is too small, otherwise ::JXL_DEC_SUCCESS.
*/
JXL_EXPORT JxlDecoderStatus JxlDecoderGetGainMapInfo(const JxlDecoder* dec,
uint8_t* gain_map_info,
size_t size);

#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
Expand Down
3 changes: 3 additions & 0 deletions lib/jxl/decode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ struct JxlDecoderStruct {
}
#endif

// Set to true after the JXL_DEC_GAIN_MAP event only.
bool gain_map_event;

const uint8_t* next_in;
size_t avail_in;
bool input_closed;
Expand Down
Loading