Skip to content

Commit b634748

Browse files
authored
Merge branch 'AcademySoftwareFoundation:main' into CUDA
2 parents badc9db + ff89654 commit b634748

File tree

14 files changed

+227
-32
lines changed

14 files changed

+227
-32
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
---
22
name: Bug report
33
about: I think I have identified a legit bug and can describe it.
4-
title: "[BUG]"
4+
title: "bug:"
55
labels: ''
66
assignees: ''
77

88
---
99

10+
<!-- THESE ARE JUST SUGGESTIONS. FEEL FREE TO DELETE ALL OF THIS AND -->
11+
<!-- WRITE YOUR OWN THOROUGH BUG REPORT. -->
12+
1013
**Describe the bug**
1114

1215
A clear and concise description of what the bug is. What happened, and

.github/ISSUE_TEMPLATE/build_problem.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: Build problems
33
about: I'm having trouble building OIIO. Help!
4-
title: "[BUILD]"
4+
title: "build:"
55
labels: ''
66
assignees: ''
77

@@ -10,7 +10,8 @@ assignees: ''
1010
**PLEASE DO NOT REPORT BUILD TROUBLES AS GITHUB "ISSUES" UNLESS YOU ARE REALLY SURE IT'S A BUG**
1111

1212
The best way to get help with your build problems is to ask a question on the
13-
[oiio-dev developer mail list](https://lists.aswf.io/g/oiio-dev).
13+
[oiio-dev developer mail list](https://lists.aswf.io/g/oiio-dev) or on the
14+
[ASWF Slack](https://slack.aswf.io) `#openimageio` channel.
1415

1516
When you email about this, please attach one or both of the following:
1617
1. The full verbose build log, which you can create like this:

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
---
22
name: Feature request
33
about: I have a concrete idea about how to improve OpenImageIO.
4-
title: "[FEATURE REQUEST]"
4+
title: "feat:"
55
labels: ''
66
assignees: ''
77

88
---
99

10+
<!-- THESE ARE JUST SUGGESTIONS. FEEL FREE TO DELETE ALL OF THIS AND -->
11+
<!-- WRITE YOUR OWN THOROUGH FEATURE REQUEST. -->
12+
1013
**Is your feature request related to a problem? Please describe.**
1114
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
1215

.github/ISSUE_TEMPLATE/question.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: Question
33
about: How do I... I need help with...
4-
title: "[HELP]"
4+
title: "help:"
55
labels: ''
66
assignees: ''
77

@@ -18,8 +18,8 @@ But if you are just asking a question:
1818
* Am I doing something wrong?
1919
* I can't build OpenImageIO
2020

21-
For anything of this nature, the best way to get help using OpenImageIO is
22-
to ask a question on the [oiio-dev developer mail list](https://lists.aswf.io/g/oiio-dev).
21+
For anything of this nature, the best way to get help using OpenImageIO is to
22+
ask a question on the [oiio-dev developer mail list](https://lists.aswf.io/g/oiio-dev) or the [ASWF Slack](https://slack.aswf.io) `#openimageio` channel.
2323

2424
The [documentation](https://docs.openimageio.org)
2525
is pretty comprehensive, so please check there first; you may find the answer

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
1-
<!-- This is just a guideline and set of reminders about what constitutes -->
2-
<!-- a good PR. Feel free to delete all this matter and replace it with -->
3-
<!-- your own detailed message about the PR, assuming you hit all the -->
4-
<!-- important points made below. -->
1+
YOU MAY DELETE ALL OF THIS IF YOU ALREADY HAVE A DESCRIPTIVE COMMIT MESSAGE!
52

3+
This is just a template and set of reminders about what constitutes a good PR.
4+
But please look over the checklist at the bottom.
65

7-
## Description
6+
If THIS TEXT is still in your PR description, we'll know you didn't read the
7+
instructions!
8+
9+
10+
11+
12+
### Description
813

914
<!-- Please provide a description of what this PR is meant to fix, and -->
1015
<!-- how it works (if it's not going to be very clear from the code). -->
1116

12-
## Tests
17+
### Tests
1318

1419
<!-- Did you / should you add a testsuite case (new test, or add to an -->
1520
<!-- existing test) to verify that this works? -->
1621

1722

18-
## Checklist:
23+
### Checklist:
1924

2025
<!-- Put an 'x' in the boxes as you complete the checklist items -->
2126

22-
- [ ] I have read the [contribution guidelines](https://github.com/AcademySoftwareFoundation/OpenImageIO/blob/main/CONTRIBUTING.md).
23-
- [ ] I have updated the documentation, if applicable. (Check if there is no
24-
need to update the documentation, for example if this is a bug fix that
25-
doesn't change the API.)
26-
- [ ] I have ensured that the change is tested somewhere in the testsuite
27-
(adding new test cases if necessary).
28-
- [ ] If I added or modified a C++ API call, I have also amended the
29-
corresponding Python bindings (and if altering ImageBufAlgo functions, also
30-
exposed the new functionality as oiiotool options).
31-
- [ ] My code follows the prevailing code style of this project. If I haven't
32-
already run clang-format before submitting, I definitely will look at the CI
33-
test that runs clang-format and fix anything that it highlights as being
34-
nonconforming.
27+
- [ ] **I have read the guidelines** on [contributions](https://github.com/AcademySoftwareFoundation/OpenImageIO/blob/main/CONTRIBUTING.md) and [code review procedures](https://github.com/AcademySoftwareFoundation/OpenImageIO/blob/main/docs/dev/CodeReview.md).
28+
- [ ] **I have updated the documentation** if my PR adds features or changes
29+
behavior.
30+
- [ ] **I am sure that this PR's changes are tested somewhere in the
31+
testsuite**.
32+
- [ ] **I have run and passed the testsuite in CI** *before* submitting the
33+
PR, by pushing the changes to my fork and seeing that the automated CI
34+
passed there. (Exceptions: If most tests pass and you can't figure out why
35+
the remaining ones fail, it's ok to submit the PR and ask for help. Or if
36+
any failures seem entirely unrelated to your change; sometimes things break
37+
on the GitHub runners.)
38+
- [ ] **My code follows the prevailing code style of this project** and I
39+
fixed any problems reported by the clang-format CI test.
40+
- [ ] If I added or modified a public C++ API call, I have also amended the
41+
corresponding Python bindings. If altering ImageBufAlgo functions, I also
42+
exposed the new functionality as oiiotool options.

src/jpegxl.imageio/jxlinput.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <cassert>
1717
#include <cstdio>
1818

19+
#include <OpenImageIO/color.h>
1920
#include <OpenImageIO/filesystem.h>
2021
#include <OpenImageIO/fmath.h>
2122
#include <OpenImageIO/imageio.h>
@@ -54,7 +55,6 @@ class JxlInput final : public ImageInput {
5455
std::string m_filename;
5556
int m_next_scanline; // Which scanline is the next to read?
5657
uint32_t m_channels;
57-
JxlColorEncoding m_color_encoding;
5858
JxlDecoderPtr m_decoder;
5959
JxlResizableParallelRunnerPtr m_runner;
6060
std::unique_ptr<ImageSpec> m_config; // Saved copy of configuration spec
@@ -224,6 +224,8 @@ JxlInput::open(const std::string& name, ImageSpec& newspec)
224224
JxlDataType jxl_data_type;
225225
TypeDesc m_data_type;
226226
uint32_t bits = 0;
227+
JxlColorEncoding color_encoding {};
228+
bool have_color_encoding = false;
227229

228230
for (;;) {
229231
JxlDecoderStatus status = JxlDecoderProcessInput(m_decoder.get());
@@ -300,6 +302,16 @@ JxlInput::open(const std::string& name, ImageSpec& newspec)
300302
errorfmt("JxlDecoderGetColorAsICCProfile failed\n");
301303
return false;
302304
}
305+
306+
// Get the color encoding of the pixel data
307+
// This will return JXL_DEC_ERR for a valid file without color
308+
// encoding information, so don't report an error.
309+
if (JXL_DEC_SUCCESS
310+
== JxlDecoderGetColorAsEncodedProfile(
311+
m_decoder.get(), JXL_COLOR_PROFILE_TARGET_DATA,
312+
&color_encoding)) {
313+
have_color_encoding = true;
314+
}
303315
} else if (status == JXL_DEC_NEED_IMAGE_OUT_BUFFER) {
304316
DBG std::cout << "JXL_DEC_NEED_IMAGE_OUT_BUFFER\n";
305317

@@ -348,6 +360,7 @@ JxlInput::open(const std::string& name, ImageSpec& newspec)
348360

349361
m_spec = ImageSpec(info.xsize, info.ysize, m_channels, m_data_type);
350362

363+
// Read ICC profile
351364
if (m_icc_profile.size() && m_icc_profile.data()) {
352365
m_spec.attribute("ICCProfile",
353366
TypeDesc(TypeDesc::UINT8, m_icc_profile.size()),
@@ -365,6 +378,21 @@ JxlInput::open(const std::string& name, ImageSpec& newspec)
365378
}
366379
}
367380

381+
// Read CICP from color encoding. Custom primaries, custom white point and
382+
// arbitrary gamma not supported currently.
383+
if (have_color_encoding && color_encoding.primaries != JXL_PRIMARIES_CUSTOM
384+
&& color_encoding.white_point != JXL_WHITE_POINT_CUSTOM
385+
&& color_encoding.transfer_function != JXL_TRANSFER_FUNCTION_GAMMA) {
386+
const int cicp[4] = { color_encoding.primaries,
387+
color_encoding.transfer_function, 0 /* RGB */,
388+
1 /* Full range */ };
389+
m_spec.attribute("CICP", TypeDesc(TypeDesc::INT, 4), cicp);
390+
const ColorConfig& colorconfig(ColorConfig::default_colorconfig());
391+
string_view interop_id = colorconfig.get_color_interop_id(cicp);
392+
if (!interop_id.empty())
393+
m_spec.attribute("oiio:ColorSpace", interop_id);
394+
}
395+
368396
newspec = m_spec;
369397
return true;
370398
}

src/jpegxl.imageio/jxloutput.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <cstdio>
77
#include <vector>
88

9+
#include <OpenImageIO/color.h>
910
#include <OpenImageIO/filesystem.h>
1011
#include <OpenImageIO/fmath.h>
1112
#include <OpenImageIO/imageio.h>
@@ -538,6 +539,8 @@ JxlOutput::save_image(const void* data)
538539
return false;
539540
}
540541

542+
bool wrote_colorspace = false;
543+
541544
// Write the ICC profile, if available
542545
const ParamValue* icc_profile_parameter = m_spec.find_attribute(
543546
"ICCProfile");
@@ -551,6 +554,59 @@ JxlOutput::save_image(const void* data)
551554
length)) {
552555
errorfmt("JxlEncoderSetICCProfile failed\n");
553556
}
557+
wrote_colorspace = true;
558+
}
559+
}
560+
561+
// Write CICP
562+
const ColorConfig& colorconfig(ColorConfig::default_colorconfig());
563+
const ParamValue* p = m_spec.find_attribute("CICP",
564+
TypeDesc(TypeDesc::INT, 4));
565+
string_view colorspace = m_spec.get_string_attribute("oiio:ColorSpace");
566+
cspan<int> cicp = (p) ? p->as_cspan<int>()
567+
: (!wrote_colorspace) ? colorconfig.get_cicp(colorspace)
568+
: cspan<int>();
569+
if (!cicp.empty()) {
570+
// JXL only has a subset of CICP, only write if supported. Custom
571+
// primaries and white point are not currently used but could help
572+
// support more CICP codes.
573+
JxlColorEncoding color_encoding {};
574+
color_encoding.primaries = JxlPrimaries(cicp[0]);
575+
color_encoding.transfer_function = JxlTransferFunction(cicp[1]);
576+
color_encoding.color_space = JXL_COLOR_SPACE_RGB;
577+
578+
bool supported_primaries = false;
579+
bool supported_transfer = false;
580+
581+
switch (color_encoding.primaries) {
582+
case JXL_PRIMARIES_SRGB:
583+
case JXL_PRIMARIES_2100:
584+
case JXL_PRIMARIES_P3:
585+
supported_primaries = true;
586+
color_encoding.white_point = JXL_WHITE_POINT_D65;
587+
break;
588+
case JXL_PRIMARIES_CUSTOM: // Not an actual CICP code in JXL
589+
break;
590+
}
591+
592+
switch (color_encoding.transfer_function) {
593+
case JXL_TRANSFER_FUNCTION_709:
594+
case JXL_TRANSFER_FUNCTION_UNKNOWN:
595+
case JXL_TRANSFER_FUNCTION_LINEAR:
596+
case JXL_TRANSFER_FUNCTION_SRGB:
597+
case JXL_TRANSFER_FUNCTION_PQ:
598+
case JXL_TRANSFER_FUNCTION_DCI:
599+
case JXL_TRANSFER_FUNCTION_HLG: supported_transfer = true; break;
600+
case JXL_TRANSFER_FUNCTION_GAMMA: // Not an actual CICP code
601+
break;
602+
}
603+
604+
if (supported_primaries && supported_transfer) {
605+
if (JXL_ENC_SUCCESS
606+
!= JxlEncoderSetColorEncoding(m_encoder.get(),
607+
&color_encoding)) {
608+
errorfmt("JxlEncoderSetColorEncoding failed\n");
609+
}
554610
}
555611
}
556612

src/openexr.imageio/exroutput.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <numeric>
1414

1515
#include <OpenImageIO/Imath.h>
16+
#include <OpenImageIO/color.h>
1617
#include <OpenImageIO/platform.h>
1718

1819
#include <OpenEXR/IlmThreadPool.h>
@@ -1026,6 +1027,15 @@ OpenEXROutput::spec_to_header(ImageSpec& spec, int subimage,
10261027
}
10271028
}
10281029

1030+
// Set color interop ID from colorspace
1031+
if (spec.get_string_attribute("colorInteropID").empty()) {
1032+
const ColorConfig& colorconfig(ColorConfig::default_colorconfig());
1033+
string_view colorspace = spec.get_string_attribute("oiio:ColorSpace");
1034+
string_view interop_id = colorconfig.get_color_interop_id(colorspace);
1035+
if (!interop_id.empty())
1036+
spec.attribute("colorInteropID", interop_id);
1037+
}
1038+
10291039
// Deal with all other params
10301040
for (const auto& p : spec.extra_attribs)
10311041
put_parameter(p.name().string(), p.type(), p.data(), header);

src/png.imageio/png_pvt.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,12 +568,30 @@ put_parameter(png_structp& sp, png_infop& ip, const std::string& _name,
568568
return true;
569569
}
570570
#endif
571+
572+
// Before handling general named metadata, suppress format-specific
573+
// metadata hints meant for other formats that are not meant to be literal
574+
// metadata written to the file. This includes anything with a namespace
575+
// prefix of "oiio:" or the name of any other file format.
576+
auto colonpos = name.find(':');
577+
if (colonpos != std::string::npos) {
578+
std::string prefix = Strutil::lower(name.substr(0, colonpos));
579+
if (prefix != "png" && is_imageio_format_name(prefix))
580+
return false;
581+
if (prefix == "oiio")
582+
return false;
583+
}
584+
571585
if (type == TypeDesc::STRING) {
586+
// We can save arbitrary string metadata in multiple png text entries.
587+
// Is that ok? Should we also do it for other types by converting to
588+
// string?
572589
png_text t;
573590
t.compression = PNG_TEXT_COMPRESSION_NONE;
574591
t.key = (char*)ustring(name).c_str();
575592
t.text = *(char**)data; // Already uniquified
576593
text.push_back(t);
594+
return true;
577595
}
578596

579597
return false;

testsuite/jxl/ref/out.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,26 @@ tahoe-icc.jxl : 128 x 96, 3 channel, uint8 jpegxl
1919
ICCProfile:profile_size: 560
2020
ICCProfile:profile_version: "2.1.0"
2121
ICCProfile:rendering_intent: "Perceptual"
22+
Reading tahoe-cicp-pq.jxl
23+
tahoe-cicp-pq.jxl : 128 x 96, 3 channel, uint8 jpegxl
24+
SHA-1: 069F1A3E5567349C2D34E535B29913029EF1B09C
25+
channel list: R, G, B
26+
CICP: 9, 16, 0, 1
27+
ICCProfile: 0, 0, 16, 248, 106, 120, 108, 32, 4, 64, 0, 0, 109, 110, 116, 114, ... [4344 x uint8]
28+
ICCProfile:attributes: "Reflective, Glossy, Positive, Color"
29+
ICCProfile:cmm_type: 1786276896
30+
ICCProfile:color_space: "RGB"
31+
ICCProfile:copyright: "CC0"
32+
ICCProfile:creation_date: "2019:12:01 00:00:00"
33+
ICCProfile:creator_signature: "6a786c20"
34+
ICCProfile:device_class: "Display device profile"
35+
ICCProfile:flags: "Not Embedded, Independent"
36+
ICCProfile:manufacturer: "0"
37+
ICCProfile:model: "0"
38+
ICCProfile:platform_signature: "Apple Computer, Inc."
39+
ICCProfile:profile_connection_space: "CIELAB"
40+
ICCProfile:profile_description: "RGB_D65_202_Per_PeQ"
41+
ICCProfile:profile_size: 4344
42+
ICCProfile:profile_version: "4.4.0"
43+
ICCProfile:rendering_intent: "Perceptual"
44+
oiio:ColorSpace: "pq_rec2020_display"

0 commit comments

Comments
 (0)