Skip to content

Commit 53deb76

Browse files
committed
jpeg: add code comments for Ultra HDR integration
Signed-off-by: loicvital <[email protected]>
1 parent b8988d6 commit 53deb76

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/jpeg.imageio/jpeg_pvt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class JpgInput final : public ImageInput {
9999
jvirt_barray_ptr* m_coeffs;
100100
std::vector<unsigned char> m_cmyk_buf; // For CMYK translation
101101
std::unique_ptr<ImageSpec> m_config; // Saved copy of configuration spec
102-
bool m_is_uhdr;
102+
bool m_is_uhdr; // Is interpreted as Ultra HDR image
103103
#if defined(USE_UHDR)
104104
uhdr_codec_private_t* m_uhdr_dec;
105105
#endif

src/jpeg.imageio/jpeginput.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,22 +418,33 @@ bool
418418
JpgInput::read_uhdr(Filesystem::IOProxy* ioproxy)
419419
{
420420
#if defined(USE_UHDR)
421+
// Read entire file content into buffer.
421422
const size_t buffer_size = ioproxy->size();
422423
std::vector<unsigned char> buffer(buffer_size);
423424
ioproxy->pread(buffer.data(), buffer_size, 0);
424425

426+
// Check if this is an actual Ultra HDR image.
425427
const bool detect_uhdr = is_uhdr_image(buffer.data(), buffer.size());
426428
if (!detect_uhdr)
427429
return false;
428430

431+
// Create Ultra HDR decoder.
432+
// Do not forget to release it once we don't need it,
433+
// i.e if this function returns false
434+
// or when we call close().
429435
m_uhdr_dec = uhdr_create_decoder();
430436

437+
// Prepare decoder input.
438+
// Note: we currently do not override any of the
439+
// default settings.
431440
uhdr_compressed_image_t uhdr_compressed;
432441
uhdr_compressed.data = buffer.data();
433442
uhdr_compressed.data_sz = buffer.size();
434443
uhdr_compressed.capacity = buffer.size();
435444
uhdr_dec_set_image(m_uhdr_dec, &uhdr_compressed);
436445

446+
// Decode Ultra HDR image
447+
// and check for decoding errors.
437448
uhdr_error_info_t err_info = uhdr_decode(m_uhdr_dec);
438449

439450
if (err_info.error_code != UHDR_CODEC_OK) {
@@ -445,6 +456,9 @@ JpgInput::read_uhdr(Filesystem::IOProxy* ioproxy)
445456
return false;
446457
}
447458

459+
// Update spec with decoded image properties.
460+
// Note: we currently only support a subset of all possible
461+
// Ultra HDR image formats.
448462
uhdr_raw_image_t* uhdr_raw = uhdr_get_decoded_image(m_uhdr_dec);
449463

450464
int nchannels;

0 commit comments

Comments
 (0)