Skip to content

Commit cab32b6

Browse files
vernalchenlgritz
authored andcommitted
fix(exr): fill in OpenEXR lineOrder attribute when reading (#4628)
Fill in OpenEXR lineOrder attribute when parsing the header in OpenEXRCoreInput::PartInfo::parse_header() --------- Signed-off-by: vernalchen <[email protected]>
1 parent 8191f12 commit cab32b6

File tree

28 files changed

+183
-3
lines changed

28 files changed

+183
-3
lines changed

src/openexr.imageio/exrinput.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ OIIO_GCC_PRAGMA(GCC diagnostic ignored "-Wunused-parameter")
4747
#include <OpenEXR/ImfInputPart.h>
4848
#include <OpenEXR/ImfIntAttribute.h>
4949
#include <OpenEXR/ImfKeyCodeAttribute.h>
50+
#include <OpenEXR/ImfLineOrderAttribute.h>
5051
#include <OpenEXR/ImfMatrixAttribute.h>
5152
#include <OpenEXR/ImfMultiPartInputFile.h>
5253
#include <OpenEXR/ImfPartType.h>
@@ -128,7 +129,6 @@ static std::map<std::string, std::string> exr_tag_to_oiio_std {
128129
{ "envmap", "" },
129130
{ "tiledesc", "" },
130131
{ "tiles", "" },
131-
{ "openexr:lineOrder", "" },
132132
{ "type", "" },
133133

134134
// FIXME: Things to consider in the future:
@@ -467,6 +467,7 @@ OpenEXRInput::PartInfo::parse_header(OpenEXRInput* in,
467467
const Imf::V3dAttribute* v3dattr;
468468
const Imf::M33dAttribute* m33dattr;
469469
const Imf::M44dAttribute* m44dattr;
470+
const Imf::LineOrderAttribute* lattr;
470471
const char* name = hit.name();
471472
auto found = exr_tag_to_oiio_std.find(name);
472473
std::string oname(found != exr_tag_to_oiio_std.end() ? found->second
@@ -635,6 +636,18 @@ OpenEXRInput::PartInfo::parse_header(OpenEXRInput* in,
635636
oname, n, d);
636637
}
637638
}
639+
} else if (type == "lineOrder"
640+
&& (lattr
641+
= header->findTypedAttribute<Imf::LineOrderAttribute>(
642+
name))) {
643+
const char* lineOrder = "increasingY";
644+
switch (lattr->value()) {
645+
case Imf::INCREASING_Y: lineOrder = "increasingY"; break;
646+
case Imf::DECREASING_Y: lineOrder = "decreasingY"; break;
647+
case Imf::RANDOM_Y: lineOrder = "randomY"; break;
648+
default: break;
649+
}
650+
spec.attribute("openexr:lineOrder", lineOrder);
638651
} else {
639652
#if 0
640653
print(std::cerr, " unknown attribute '{}' name '{}'\n",

src/openexr.imageio/exrinput_c.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ static std::map<std::string, std::string> cexr_tag_to_oiio_std {
275275
{ "envmap", "" },
276276
{ "tiledesc", "" },
277277
{ "tiles", "" },
278-
{ "openexr:lineOrder", "" },
279278
{ "type", "" },
280279

281280
// FIXME: Things to consider in the future:
@@ -729,12 +728,23 @@ OpenEXRCoreInput::PartInfo::parse_header(OpenEXRCoreInput* in,
729728
break;
730729
}
731730

731+
case EXR_ATTR_LINEORDER: {
732+
std::string lineOrder = "increasingY";
733+
switch (attr->uc) {
734+
case EXR_LINEORDER_INCREASING_Y: lineOrder = "increasingY"; break;
735+
case EXR_LINEORDER_DECREASING_Y: lineOrder = "decreasingY"; break;
736+
case EXR_LINEORDER_RANDOM_Y: lineOrder = "randomY"; break;
737+
default: break;
738+
}
739+
spec.attribute("openexr:lineOrder", lineOrder);
740+
break;
741+
}
742+
732743
case EXR_ATTR_PREVIEW:
733744
case EXR_ATTR_OPAQUE:
734745
case EXR_ATTR_ENVMAP:
735746
case EXR_ATTR_COMPRESSION:
736747
case EXR_ATTR_CHLIST:
737-
case EXR_ATTR_LINEORDER:
738748
case EXR_ATTR_TILEDESC:
739749
default:
740750
#if 0

testsuite/dup-channels/ref/out.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ out.exr : 64 x 64, 6 channel, half openexr
88
screenWindowWidth: 1
99
oiio:ColorSpace: "lin_rec709"
1010
oiio:subimages: 1
11+
openexr:lineOrder: "increasingY"
1112
Reading out2.exr
1213
out2.exr : 64 x 64, 6 channel, half openexr
1314
SHA-1: 6FECD5769C727E137B7580AE3B1823B06EE6F9D9
@@ -21,3 +22,4 @@ out2.exr : 64 x 64, 6 channel, half openexr
2122
oiio:subimagename: "Aimg"
2223
oiio:subimages: 1
2324
openexr:chunkCount: 4
25+
openexr:lineOrder: "increasingY"

testsuite/iinfo/ref/out-fmt6.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ src/tiny-az.exr : Software: "OpenImageIO 2.5.0.0spi : oiiotool -pattern cons
149149
src/tiny-az.exr : Exif:ImageHistory: "oiiotool -pattern constant:color=0.25,0.5,0.75 4x4 3 --origin +2+2 --fullsize 20x20+1+1 -o tiny-az.exr"
150150
src/tiny-az.exr : oiio:ColorSpace: "lin_rec709"
151151
src/tiny-az.exr : oiio:subimages: 1
152+
src/tiny-az.exr : openexr:lineOrder: "increasingY"
152153
src/tiny-az.exr : Stats Min: 0.250000 0.500000 0.750000 (float)
153154
Stats Max: 0.250000 0.500000 0.750000 (float)
154155
Stats Avg: 0.250000 0.500000 0.750000 (float)
@@ -176,6 +177,7 @@ src/tiny-az.exr : 4 x 4, 3 channel, float openexr
176177
Exif:ImageHistory: "oiiotool -pattern constant:color=0.25,0.5,0.75 4x4 3 --origin +2+2 --fullsize 20x20+1+1 -o tiny-az.exr"
177178
oiio:ColorSpace: "lin_rec709"
178179
oiio:subimages: 1
180+
openexr:lineOrder: "increasingY"
179181
Pixel (2, 2): 0.250000000 0.500000000 0.750000000
180182
Pixel (3, 2): 0.250000000 0.500000000 0.750000000
181183
Pixel (4, 2): 0.250000000 0.500000000 0.750000000
@@ -215,6 +217,7 @@ src/tinydeep.exr : 4 x 4, 2 channel, deep float openexr
215217
Exif:ImageHistory: "oiiotool -pattern constant:color=1e38,0 4x4 2 --chnames Z,A --point:color=10.0,1.0 2,2 --deepen -o tinydeep.exr"
216218
oiio:subimages: 1
217219
openexr:chunkCount: 4
220+
openexr:lineOrder: "increasingY"
218221
Stats Min: 1.000000 10.000000 (float)
219222
Stats Max: 1.000000 10.000000 (float)
220223
Stats Avg: 1.000000 10.000000 (float)
@@ -249,6 +252,7 @@ src/tinydeep.exr : 4 x 4, 2 channel, deep float openexr
249252
Exif:ImageHistory: "oiiotool -pattern constant:color=1e38,0 4x4 2 --chnames Z,A --point:color=10.0,1.0 2,2 --deepen -o tinydeep.exr"
250253
oiio:subimages: 1
251254
openexr:chunkCount: 4
255+
openexr:lineOrder: "increasingY"
252256
Pixel (0, 0): 0 samples
253257
Pixel (1, 0): 0 samples
254258
Pixel (2, 0): 0 samples

testsuite/iinfo/ref/out.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ src/tiny-az.exr : Software: "OpenImageIO 2.5.0.0spi : oiiotool -pattern cons
149149
src/tiny-az.exr : Exif:ImageHistory: "oiiotool -pattern constant:color=0.25,0.5,0.75 4x4 3 --origin +2+2 --fullsize 20x20+1+1 -o tiny-az.exr"
150150
src/tiny-az.exr : oiio:ColorSpace: "lin_rec709"
151151
src/tiny-az.exr : oiio:subimages: 1
152+
src/tiny-az.exr : openexr:lineOrder: "increasingY"
152153
src/tiny-az.exr : Stats Min: 0.250000 0.500000 0.750000 (float)
153154
Stats Max: 0.250000 0.500000 0.750000 (float)
154155
Stats Avg: 0.250000 0.500000 0.750000 (float)
@@ -176,6 +177,7 @@ src/tiny-az.exr : 4 x 4, 3 channel, float openexr
176177
Exif:ImageHistory: "oiiotool -pattern constant:color=0.25,0.5,0.75 4x4 3 --origin +2+2 --fullsize 20x20+1+1 -o tiny-az.exr"
177178
oiio:ColorSpace: "lin_rec709"
178179
oiio:subimages: 1
180+
openexr:lineOrder: "increasingY"
179181
Pixel (2, 2): 0.250000000 0.500000000 0.750000000
180182
Pixel (3, 2): 0.250000000 0.500000000 0.750000000
181183
Pixel (4, 2): 0.250000000 0.500000000 0.750000000
@@ -215,6 +217,7 @@ src/tinydeep.exr : 4 x 4, 2 channel, deep float openexr
215217
Exif:ImageHistory: "oiiotool -pattern constant:color=1e38,0 4x4 2 --chnames Z,A --point:color=10.0,1.0 2,2 --deepen -o tinydeep.exr"
216218
oiio:subimages: 1
217219
openexr:chunkCount: 4
220+
openexr:lineOrder: "increasingY"
218221
Stats Min: 1.000000 10.000000 (float)
219222
Stats Max: 1.000000 10.000000 (float)
220223
Stats Avg: 1.000000 10.000000 (float)
@@ -249,6 +252,7 @@ src/tinydeep.exr : 4 x 4, 2 channel, deep float openexr
249252
Exif:ImageHistory: "oiiotool -pattern constant:color=1e38,0 4x4 2 --chnames Z,A --point:color=10.0,1.0 2,2 --deepen -o tinydeep.exr"
250253
oiio:subimages: 1
251254
openexr:chunkCount: 4
255+
openexr:lineOrder: "increasingY"
252256
Pixel (0, 0): 0 samples
253257
Pixel (1, 0): 0 samples
254258
Pixel (2, 0): 0 samples

testsuite/maketx/ref/out-macarm.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ nan.exr : 64 x 64, 3 channel, half openexr
319319
oiio:SHA-1: "44B96A7C3AFBF8D7621E7C6453266E5DD1962D36"
320320
oiio:subimages: 1
321321
openexr:levelmode: 0
322+
openexr:lineOrder: "increasingY"
322323
Stats Min: 0.000000 0.000000 0.000000 (float)
323324
Stats Max: 1.000000 1.000000 1.000000 (float)
324325
Stats Avg: 0.500000 0.500000 0.500000 (float)
@@ -346,6 +347,7 @@ checker-exr.pdq : 128 x 128, 4 channel, half openexr
346347
oiio:ColorSpace: "lin_rec709"
347348
oiio:SHA-1: "D924CA144A02479D1507F5910F5FC8F51EF78765"
348349
oiio:subimages: 1
350+
openexr:lineOrder: "increasingY"
349351
openexr:roundingmode: 0
350352
Reading small.tif
351353
small.tif : 64 x 64, 3 channel, uint8 tiff
@@ -437,6 +439,7 @@ bumpslope.exr : 64 x 64, 6 channel, half openexr
437439
oiio:AverageColor: "0.499779,-0.000457942,-4.17233e-05,0.00197116,0.00178894,3.45764e-05"
438440
oiio:SHA-1: "49B533110A914CE89BE0B14753A6A4CC037C964F"
439441
oiio:subimages: 1
442+
openexr:lineOrder: "increasingY"
440443
openexr:roundingmode: 0
441444
Reading cdf.exr
442445
cdf.exr : 64 x 64, 1 channel, half openexr
@@ -457,6 +460,7 @@ cdf.exr : 64 x 64, 1 channel, half openexr
457460
oiio:AverageColor: "0.499779"
458461
oiio:SHA-1: "00DFB31D0260CC466CDCF9FE42446D4896E655FE"
459462
oiio:subimages: 1
463+
openexr:lineOrder: "increasingY"
460464
openexr:roundingmode: 0
461465
Reading bumpslope-cdf.exr
462466
bumpslope-cdf.exr : 64 x 64, 6 channel, half openexr
@@ -488,6 +492,7 @@ bumpslope-cdf.exr : 64 x 64, 6 channel, half openexr
488492
oiio:AverageColor: "0.499779,-0.000457942,-4.17233e-05,0.00197116,0.00178894,3.45764e-05"
489493
oiio:SHA-1: "49B533110A914CE89BE0B14753A6A4CC037C964F"
490494
oiio:subimages: 1
495+
openexr:lineOrder: "increasingY"
491496
openexr:roundingmode: 0
492497
Reading checker-attribs.tx
493498
checker-attribs.tx : 128 x 128, 4 channel, uint8 tiff

testsuite/maketx/ref/out.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ nan.exr : 64 x 64, 3 channel, half openexr
319319
oiio:SHA-1: "44B96A7C3AFBF8D7621E7C6453266E5DD1962D36"
320320
oiio:subimages: 1
321321
openexr:levelmode: 0
322+
openexr:lineOrder: "increasingY"
322323
Stats Min: 0.000000 0.000000 0.000000 (float)
323324
Stats Max: 1.000000 1.000000 1.000000 (float)
324325
Stats Avg: 0.500000 0.500000 0.500000 (float)
@@ -346,6 +347,7 @@ checker-exr.pdq : 128 x 128, 4 channel, half openexr
346347
oiio:ColorSpace: "lin_rec709"
347348
oiio:SHA-1: "D924CA144A02479D1507F5910F5FC8F51EF78765"
348349
oiio:subimages: 1
350+
openexr:lineOrder: "increasingY"
349351
openexr:roundingmode: 0
350352
Reading small.tif
351353
small.tif : 64 x 64, 3 channel, uint8 tiff
@@ -437,6 +439,7 @@ bumpslope.exr : 64 x 64, 6 channel, half openexr
437439
oiio:AverageColor: "0.499779,-0.000457942,-4.17233e-05,0.00197116,0.00178894,3.45764e-05"
438440
oiio:SHA-1: "49B533110A914CE89BE0B14753A6A4CC037C964F"
439441
oiio:subimages: 1
442+
openexr:lineOrder: "increasingY"
440443
openexr:roundingmode: 0
441444
Reading cdf.exr
442445
cdf.exr : 64 x 64, 1 channel, half openexr
@@ -457,6 +460,7 @@ cdf.exr : 64 x 64, 1 channel, half openexr
457460
oiio:AverageColor: "0.499779"
458461
oiio:SHA-1: "00DFB31D0260CC466CDCF9FE42446D4896E655FE"
459462
oiio:subimages: 1
463+
openexr:lineOrder: "increasingY"
460464
openexr:roundingmode: 0
461465
Reading bumpslope-cdf.exr
462466
bumpslope-cdf.exr : 64 x 64, 6 channel, half openexr
@@ -488,6 +492,7 @@ bumpslope-cdf.exr : 64 x 64, 6 channel, half openexr
488492
oiio:AverageColor: "0.499779,-0.000457942,-4.17233e-05,0.00197116,0.00178894,3.45764e-05"
489493
oiio:SHA-1: "49B533110A914CE89BE0B14753A6A4CC037C964F"
490494
oiio:subimages: 1
495+
openexr:lineOrder: "increasingY"
491496
openexr:roundingmode: 0
492497
Reading checker-attribs.tx
493498
checker-attribs.tx : 128 x 128, 4 channel, uint8 tiff

testsuite/oiiotool-attribs/ref/out-jpeg9d.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ attrib2.exr : 64 x 64, 3 channel, half openexr
7272
oiio:subimagename: "subimage00"
7373
oiio:subimages: 2
7474
openexr:chunkCount: 4
75+
openexr:lineOrder: "increasingY"
7576
subimage 1: 64 x 64, 3 channel, half openexr
7677
SHA-1: EBDD38B69CD5B9F2D00D273C981E16960FBBB4F7
7778
channel list: R, G, B
@@ -85,6 +86,7 @@ attrib2.exr : 64 x 64, 3 channel, half openexr
8586
oiio:subimagename: "subimage01"
8687
oiio:subimages: 2
8788
openexr:chunkCount: 4
89+
openexr:lineOrder: "increasingY"
8890
Reading attrib0.exr
8991
attrib0.exr : 64 x 64, 3 channel, half openexr
9092
2 subimages: 64x64 [h,h,h], 64x64 [h,h,h]
@@ -100,6 +102,7 @@ attrib0.exr : 64 x 64, 3 channel, half openexr
100102
oiio:subimagename: "subimage00"
101103
oiio:subimages: 2
102104
openexr:chunkCount: 4
105+
openexr:lineOrder: "increasingY"
103106
subimage 1: 64 x 64, 3 channel, half openexr
104107
SHA-1: EBDD38B69CD5B9F2D00D273C981E16960FBBB4F7
105108
channel list: R, G, B
@@ -112,6 +115,7 @@ attrib0.exr : 64 x 64, 3 channel, half openexr
112115
oiio:subimagename: "subimage01"
113116
oiio:subimages: 2
114117
openexr:chunkCount: 4
118+
openexr:lineOrder: "increasingY"
115119
Reading tahoe-icc.jpg
116120
tahoe-icc.jpg : 128 x 96, 3 channel, uint8 jpeg
117121
SHA-1: 9119399610EF6CACDAD0EBAF4D663E4EDEF70B58

testsuite/oiiotool-attribs/ref/out.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ attrib2.exr : 64 x 64, 3 channel, half openexr
7272
oiio:subimagename: "subimage00"
7373
oiio:subimages: 2
7474
openexr:chunkCount: 4
75+
openexr:lineOrder: "increasingY"
7576
subimage 1: 64 x 64, 3 channel, half openexr
7677
SHA-1: EBDD38B69CD5B9F2D00D273C981E16960FBBB4F7
7778
channel list: R, G, B
@@ -85,6 +86,7 @@ attrib2.exr : 64 x 64, 3 channel, half openexr
8586
oiio:subimagename: "subimage01"
8687
oiio:subimages: 2
8788
openexr:chunkCount: 4
89+
openexr:lineOrder: "increasingY"
8890
Reading attrib0.exr
8991
attrib0.exr : 64 x 64, 3 channel, half openexr
9092
2 subimages: 64x64 [h,h,h], 64x64 [h,h,h]
@@ -100,6 +102,7 @@ attrib0.exr : 64 x 64, 3 channel, half openexr
100102
oiio:subimagename: "subimage00"
101103
oiio:subimages: 2
102104
openexr:chunkCount: 4
105+
openexr:lineOrder: "increasingY"
103106
subimage 1: 64 x 64, 3 channel, half openexr
104107
SHA-1: EBDD38B69CD5B9F2D00D273C981E16960FBBB4F7
105108
channel list: R, G, B
@@ -112,6 +115,7 @@ attrib0.exr : 64 x 64, 3 channel, half openexr
112115
oiio:subimagename: "subimage01"
113116
oiio:subimages: 2
114117
openexr:chunkCount: 4
118+
openexr:lineOrder: "increasingY"
115119
Reading tahoe-icc.jpg
116120
tahoe-icc.jpg : 128 x 96, 3 channel, uint8 jpeg
117121
SHA-1: BC4C6090E793819E1A2869AAA8FBEE3587CC6947

testsuite/oiiotool-copy/ref/out.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ allhalf.exr : 38 x 38, 5 channel, half openexr
1515
screenWindowWidth: 1
1616
oiio:ColorSpace: "lin_rec709"
1717
oiio:subimages: 1
18+
openexr:lineOrder: "increasingY"
1819
Reading rgbahalf-zfloat.exr
1920
rgbahalf-zfloat.exr : 38 x 38, 5 channel, half/half/half/half/float openexr
2021
SHA-1: 9324AFD44451321A8D87E09F656C7B86E827E5CD
@@ -28,6 +29,7 @@ rgbahalf-zfloat.exr : 38 x 38, 5 channel, half/half/half/half/float openexr
2829
screenWindowWidth: 1
2930
oiio:ColorSpace: "lin_rec709"
3031
oiio:subimages: 1
32+
openexr:lineOrder: "increasingY"
3133
explicit -d uint save result:
3234
uint8.tif : 128 x 128, 3 channel, uint8 tiff
3335
tile size: 16 x 16
@@ -68,6 +70,7 @@ chname.exr : 38 x 38, 5 channel, float openexr
6870
screenWindowWidth: 1
6971
oiio:ColorSpace: "lin_rec709"
7072
oiio:subimages: 1
73+
openexr:lineOrder: "increasingY"
7174
Reading green.exr
7275
green.exr : 64 x 64, 3 channel, half openexr
7376
SHA-1: 8B61993247469F3C208CA894D71856727B11606A
@@ -78,6 +81,7 @@ green.exr : 64 x 64, 3 channel, half openexr
7881
screenWindowWidth: 1
7982
oiio:ColorSpace: "lin_rec709"
8083
oiio:subimages: 1
84+
openexr:lineOrder: "increasingY"
8185
Reading greenmeta.exr
8286
greenmeta.exr : 64 x 64, 3 channel, half openexr
8387
SHA-1: 8B61993247469F3C208CA894D71856727B11606A
@@ -91,6 +95,7 @@ greenmeta.exr : 64 x 64, 3 channel, half openexr
9195
weight: 20.5
9296
oiio:ColorSpace: "lin_rec709"
9397
oiio:subimages: 1
98+
openexr:lineOrder: "increasingY"
9499
Reading nometamerge.exr
95100
nometamerge.exr : 64 x 64, 6 channel, float openexr
96101
SHA-1: 9F13A523321C66208E90D45F87FA0CD9B370E111
@@ -102,6 +107,7 @@ nometamerge.exr : 64 x 64, 6 channel, float openexr
102107
screenWindowWidth: 1
103108
oiio:ColorSpace: "lin_rec709"
104109
oiio:subimages: 1
110+
openexr:lineOrder: "increasingY"
105111
Reading metamerge.exr
106112
metamerge.exr : 64 x 64, 6 channel, float openexr
107113
SHA-1: 9F13A523321C66208E90D45F87FA0CD9B370E111
@@ -114,6 +120,7 @@ metamerge.exr : 64 x 64, 6 channel, float openexr
114120
screenWindowWidth: 1
115121
oiio:ColorSpace: "lin_rec709"
116122
oiio:subimages: 1
123+
openexr:lineOrder: "increasingY"
117124
Testing -o with no image
118125
oiiotool WARNING: -o : out.tif did not have any current image to output.
119126
Comparing "rgonly.exr" and "ref/rgonly.exr"

0 commit comments

Comments
 (0)