Skip to content

Commit 48d4b3d

Browse files
committed
fix(iinfo): iinfo was not reading MIP levels correctly (AcademySoftwareFoundation#4498)
A logical error was causing us to not correctly cycle through the successive MIP levels. Somehow, we missed this all these years. You can tell that there was something wrong all along by examining the testsuite/iinfo test output (which we have updated here) -- in the old/wrong one, the statistics "FiniteCount" suspiciously stayed the same for all MIP levels, which is clearly wrong. Now you can see that it does correctly reflect the reduced resolution of each MIP level. This bug was limited to 'iinfo' itself. There wasn't any inherent problem with reading MIP levels directly with ImageInput or ImageBuf. The line with the bug has been unchanged for 14 years! We were trying to be clever about not double-reading, except that the only context in which this was called, that would never have happened anyway, so that cleverness (which was incorrectly implemented) was unnecessary. Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent b35f438 commit 48d4b3d

File tree

4 files changed

+94
-98
lines changed

4 files changed

+94
-98
lines changed

src/iinfo/iinfo.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ static bool
6060
read_input(const std::string& filename, ImageBuf& img, int subimage = 0,
6161
int miplevel = 0)
6262
{
63-
if (img.subimage() >= 0 && img.subimage() == subimage)
64-
return true;
65-
6663
if (img.read(subimage, miplevel, false, TypeDesc::FLOAT))
6764
return true;
6865

src/oiiotool/printinfo.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,6 @@ static bool
225225
read_input(Oiiotool& ot, const std::string& filename, ImageBuf& img,
226226
int subimage = 0, int miplevel = 0)
227227
{
228-
if (img.subimage() >= 0 && img.subimage() == subimage)
229-
return true;
230-
231228
img.reset(filename, subimage, miplevel, nullptr, &ot.input_config);
232229
if (img.init_spec(filename, subimage, miplevel)) {
233230
// Force a read now for reasonable-sized first images in the

testsuite/iinfo/ref/out-fmt6.txt

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -35,102 +35,103 @@
3535
MIP 1 of 11 (512 x 512):
3636
Stats Min: 0 0 0 255 (of 255)
3737
Stats Max: 255 255 255 255 (of 255)
38-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
39-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
38+
Stats Avg: 153.82 153.67 153.75 255.00 (of 255)
39+
Stats StdDev: 70.25 70.16 70.21 0.00 (of 255)
4040
Stats NanCount: 0 0 0 0
4141
Stats InfCount: 0 0 0 0
42-
Stats FiniteCount: 1048576 1048576 1048576 1048576
42+
Stats FiniteCount: 262144 262144 262144 262144
4343
Constant: No
4444
Monochrome: No
4545
MIP 2 of 11 (256 x 256):
4646
Stats Min: 0 0 0 255 (of 255)
4747
Stats Max: 255 255 255 255 (of 255)
48-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
49-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
48+
Stats Avg: 154.37 154.24 154.31 255.00 (of 255)
49+
Stats StdDev: 64.32 64.28 64.33 0.00 (of 255)
5050
Stats NanCount: 0 0 0 0
5151
Stats InfCount: 0 0 0 0
52-
Stats FiniteCount: 1048576 1048576 1048576 1048576
52+
Stats FiniteCount: 65536 65536 65536 65536
5353
Constant: No
5454
Monochrome: No
5555
MIP 3 of 11 (128 x 128):
5656
Stats Min: 0 0 0 255 (of 255)
5757
Stats Max: 255 255 255 255 (of 255)
58-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
59-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
58+
Stats Avg: 155.63 155.49 155.56 255.00 (of 255)
59+
Stats StdDev: 56.95 56.92 56.89 0.00 (of 255)
6060
Stats NanCount: 0 0 0 0
6161
Stats InfCount: 0 0 0 0
62-
Stats FiniteCount: 1048576 1048576 1048576 1048576
62+
Stats FiniteCount: 16384 16384 16384 16384
6363
Constant: No
6464
Monochrome: No
6565
MIP 4 of 11 (64 x 64):
66-
Stats Min: 0 0 0 255 (of 255)
67-
Stats Max: 255 255 255 255 (of 255)
68-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
69-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
66+
Stats Min: 17 23 18 255 (of 255)
67+
Stats Max: 247 247 249 255 (of 255)
68+
Stats Avg: 155.94 155.81 155.89 255.00 (of 255)
69+
Stats StdDev: 52.47 52.34 52.44 0.00 (of 255)
7070
Stats NanCount: 0 0 0 0
7171
Stats InfCount: 0 0 0 0
72-
Stats FiniteCount: 1048576 1048576 1048576 1048576
72+
Stats FiniteCount: 4096 4096 4096 4096
7373
Constant: No
7474
Monochrome: No
7575
MIP 5 of 11 (32 x 32):
76-
Stats Min: 0 0 0 255 (of 255)
77-
Stats Max: 255 255 255 255 (of 255)
78-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
79-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
76+
Stats Min: 55 50 55 255 (of 255)
77+
Stats Max: 235 234 235 255 (of 255)
78+
Stats Avg: 156.16 156.03 156.11 255.00 (of 255)
79+
Stats StdDev: 50.28 50.22 50.34 0.00 (of 255)
8080
Stats NanCount: 0 0 0 0
8181
Stats InfCount: 0 0 0 0
82-
Stats FiniteCount: 1048576 1048576 1048576 1048576
82+
Stats FiniteCount: 1024 1024 1024 1024
8383
Constant: No
8484
Monochrome: No
8585
MIP 6 of 11 (16 x 16):
86-
Stats Min: 0 0 0 255 (of 255)
87-
Stats Max: 255 255 255 255 (of 255)
88-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
89-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
86+
Stats Min: 78 77 78 255 (of 255)
87+
Stats Max: 217 215 216 255 (of 255)
88+
Stats Avg: 156.27 156.18 156.25 255.00 (of 255)
89+
Stats StdDev: 48.66 48.93 48.99 0.00 (of 255)
9090
Stats NanCount: 0 0 0 0
9191
Stats InfCount: 0 0 0 0
92-
Stats FiniteCount: 1048576 1048576 1048576 1048576
92+
Stats FiniteCount: 256 256 256 256
9393
Constant: No
9494
Monochrome: No
9595
MIP 7 of 11 (8 x 8):
96-
Stats Min: 0 0 0 255 (of 255)
97-
Stats Max: 255 255 255 255 (of 255)
98-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
99-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
96+
Stats Min: 93 93 93 255 (of 255)
97+
Stats Max: 214 213 214 255 (of 255)
98+
Stats Avg: 156.45 156.28 156.45 255.00 (of 255)
99+
Stats StdDev: 47.08 48.06 48.01 0.00 (of 255)
100100
Stats NanCount: 0 0 0 0
101101
Stats InfCount: 0 0 0 0
102-
Stats FiniteCount: 1048576 1048576 1048576 1048576
102+
Stats FiniteCount: 64 64 64 64
103103
Constant: No
104104
Monochrome: No
105105
MIP 8 of 11 (4 x 4):
106-
Stats Min: 0 0 0 255 (of 255)
107-
Stats Max: 255 255 255 255 (of 255)
108-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
109-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
106+
Stats Min: 102 103 103 255 (of 255)
107+
Stats Max: 207 211 212 255 (of 255)
108+
Stats Avg: 157.06 156.88 156.75 255.00 (of 255)
109+
Stats StdDev: 44.74 46.80 46.81 0.00 (of 255)
110110
Stats NanCount: 0 0 0 0
111111
Stats InfCount: 0 0 0 0
112-
Stats FiniteCount: 1048576 1048576 1048576 1048576
112+
Stats FiniteCount: 16 16 16 16
113113
Constant: No
114114
Monochrome: No
115115
MIP 9 of 11 (2 x 2):
116-
Stats Min: 0 0 0 255 (of 255)
117-
Stats Max: 255 255 255 255 (of 255)
118-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
119-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
116+
Stats Min: 120 114 114 255 (of 255)
117+
Stats Max: 194 199 199 255 (of 255)
118+
Stats Avg: 157.00 156.75 156.75 255.00 (of 255)
119+
Stats StdDev: 37.00 42.25 42.25 0.00 (of 255)
120120
Stats NanCount: 0 0 0 0
121121
Stats InfCount: 0 0 0 0
122-
Stats FiniteCount: 1048576 1048576 1048576 1048576
122+
Stats FiniteCount: 4 4 4 4
123123
Constant: No
124124
Monochrome: No
125125
MIP 10 of 11 (1 x 1):
126-
Stats Min: 0 0 0 255 (of 255)
127-
Stats Max: 255 255 255 255 (of 255)
128-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
129-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
126+
Stats Min: 157 157 157 255 (of 255)
127+
Stats Max: 157 157 157 255 (of 255)
128+
Stats Avg: 157.00 157.00 157.00 255.00 (of 255)
129+
Stats StdDev: 0.00 0.00 0.00 0.00 (of 255)
130130
Stats NanCount: 0 0 0 0
131131
Stats InfCount: 0 0 0 0
132-
Stats FiniteCount: 1048576 1048576 1048576 1048576
133-
Constant: No
132+
Stats FiniteCount: 1 1 1 1
133+
Constant: Yes
134+
Constant Color: 157.00 157.00 157.00 255.00 (of 255)
134135
Monochrome: No
135136
Total size: 4.0 MB
136137
src/tiny-az.exr : 4 x 4, 3 channel, float openexr
@@ -457,7 +458,7 @@ src/mip.tif : 2 x 2, 3 channel, uint8 tiff
457458
Stats StdDev: 0.00 0.00 0.00 (of 255)
458459
Stats NanCount: 0 0 0
459460
Stats InfCount: 0 0 0
460-
Stats FiniteCount: 4 4 4
461+
Stats FiniteCount: 1 1 1
461462
Constant: Yes
462463
Constant Color: 64.00 128.00 191.00 (of 255)
463464
Monochrome: No

testsuite/iinfo/ref/out.txt

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -35,102 +35,103 @@
3535
MIP 1 of 11 (512 x 512):
3636
Stats Min: 0 0 0 255 (of 255)
3737
Stats Max: 255 255 255 255 (of 255)
38-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
39-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
38+
Stats Avg: 153.82 153.67 153.75 255.00 (of 255)
39+
Stats StdDev: 70.25 70.16 70.21 0.00 (of 255)
4040
Stats NanCount: 0 0 0 0
4141
Stats InfCount: 0 0 0 0
42-
Stats FiniteCount: 1048576 1048576 1048576 1048576
42+
Stats FiniteCount: 262144 262144 262144 262144
4343
Constant: No
4444
Monochrome: No
4545
MIP 2 of 11 (256 x 256):
4646
Stats Min: 0 0 0 255 (of 255)
4747
Stats Max: 255 255 255 255 (of 255)
48-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
49-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
48+
Stats Avg: 154.37 154.24 154.31 255.00 (of 255)
49+
Stats StdDev: 64.32 64.28 64.33 0.00 (of 255)
5050
Stats NanCount: 0 0 0 0
5151
Stats InfCount: 0 0 0 0
52-
Stats FiniteCount: 1048576 1048576 1048576 1048576
52+
Stats FiniteCount: 65536 65536 65536 65536
5353
Constant: No
5454
Monochrome: No
5555
MIP 3 of 11 (128 x 128):
5656
Stats Min: 0 0 0 255 (of 255)
5757
Stats Max: 255 255 255 255 (of 255)
58-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
59-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
58+
Stats Avg: 155.63 155.49 155.56 255.00 (of 255)
59+
Stats StdDev: 56.95 56.92 56.89 0.00 (of 255)
6060
Stats NanCount: 0 0 0 0
6161
Stats InfCount: 0 0 0 0
62-
Stats FiniteCount: 1048576 1048576 1048576 1048576
62+
Stats FiniteCount: 16384 16384 16384 16384
6363
Constant: No
6464
Monochrome: No
6565
MIP 4 of 11 (64 x 64):
66-
Stats Min: 0 0 0 255 (of 255)
67-
Stats Max: 255 255 255 255 (of 255)
68-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
69-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
66+
Stats Min: 17 23 18 255 (of 255)
67+
Stats Max: 247 247 249 255 (of 255)
68+
Stats Avg: 155.94 155.81 155.89 255.00 (of 255)
69+
Stats StdDev: 52.47 52.34 52.44 0.00 (of 255)
7070
Stats NanCount: 0 0 0 0
7171
Stats InfCount: 0 0 0 0
72-
Stats FiniteCount: 1048576 1048576 1048576 1048576
72+
Stats FiniteCount: 4096 4096 4096 4096
7373
Constant: No
7474
Monochrome: No
7575
MIP 5 of 11 (32 x 32):
76-
Stats Min: 0 0 0 255 (of 255)
77-
Stats Max: 255 255 255 255 (of 255)
78-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
79-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
76+
Stats Min: 55 50 55 255 (of 255)
77+
Stats Max: 235 234 235 255 (of 255)
78+
Stats Avg: 156.16 156.03 156.11 255.00 (of 255)
79+
Stats StdDev: 50.28 50.22 50.34 0.00 (of 255)
8080
Stats NanCount: 0 0 0 0
8181
Stats InfCount: 0 0 0 0
82-
Stats FiniteCount: 1048576 1048576 1048576 1048576
82+
Stats FiniteCount: 1024 1024 1024 1024
8383
Constant: No
8484
Monochrome: No
8585
MIP 6 of 11 (16 x 16):
86-
Stats Min: 0 0 0 255 (of 255)
87-
Stats Max: 255 255 255 255 (of 255)
88-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
89-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
86+
Stats Min: 78 77 78 255 (of 255)
87+
Stats Max: 217 215 216 255 (of 255)
88+
Stats Avg: 156.27 156.18 156.25 255.00 (of 255)
89+
Stats StdDev: 48.66 48.93 48.99 0.00 (of 255)
9090
Stats NanCount: 0 0 0 0
9191
Stats InfCount: 0 0 0 0
92-
Stats FiniteCount: 1048576 1048576 1048576 1048576
92+
Stats FiniteCount: 256 256 256 256
9393
Constant: No
9494
Monochrome: No
9595
MIP 7 of 11 (8 x 8):
96-
Stats Min: 0 0 0 255 (of 255)
97-
Stats Max: 255 255 255 255 (of 255)
98-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
99-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
96+
Stats Min: 93 93 93 255 (of 255)
97+
Stats Max: 214 213 214 255 (of 255)
98+
Stats Avg: 156.45 156.28 156.45 255.00 (of 255)
99+
Stats StdDev: 47.08 48.06 48.01 0.00 (of 255)
100100
Stats NanCount: 0 0 0 0
101101
Stats InfCount: 0 0 0 0
102-
Stats FiniteCount: 1048576 1048576 1048576 1048576
102+
Stats FiniteCount: 64 64 64 64
103103
Constant: No
104104
Monochrome: No
105105
MIP 8 of 11 (4 x 4):
106-
Stats Min: 0 0 0 255 (of 255)
107-
Stats Max: 255 255 255 255 (of 255)
108-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
109-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
106+
Stats Min: 102 103 103 255 (of 255)
107+
Stats Max: 207 211 212 255 (of 255)
108+
Stats Avg: 157.06 156.88 156.75 255.00 (of 255)
109+
Stats StdDev: 44.74 46.80 46.81 0.00 (of 255)
110110
Stats NanCount: 0 0 0 0
111111
Stats InfCount: 0 0 0 0
112-
Stats FiniteCount: 1048576 1048576 1048576 1048576
112+
Stats FiniteCount: 16 16 16 16
113113
Constant: No
114114
Monochrome: No
115115
MIP 9 of 11 (2 x 2):
116-
Stats Min: 0 0 0 255 (of 255)
117-
Stats Max: 255 255 255 255 (of 255)
118-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
119-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
116+
Stats Min: 120 114 114 255 (of 255)
117+
Stats Max: 194 199 199 255 (of 255)
118+
Stats Avg: 157.00 156.75 156.75 255.00 (of 255)
119+
Stats StdDev: 37.00 42.25 42.25 0.00 (of 255)
120120
Stats NanCount: 0 0 0 0
121121
Stats InfCount: 0 0 0 0
122-
Stats FiniteCount: 1048576 1048576 1048576 1048576
122+
Stats FiniteCount: 4 4 4 4
123123
Constant: No
124124
Monochrome: No
125125
MIP 10 of 11 (1 x 1):
126-
Stats Min: 0 0 0 255 (of 255)
127-
Stats Max: 255 255 255 255 (of 255)
128-
Stats Avg: 153.27 153.13 153.20 255.00 (of 255)
129-
Stats StdDev: 78.83 78.77 78.80 0.00 (of 255)
126+
Stats Min: 157 157 157 255 (of 255)
127+
Stats Max: 157 157 157 255 (of 255)
128+
Stats Avg: 157.00 157.00 157.00 255.00 (of 255)
129+
Stats StdDev: 0.00 0.00 0.00 0.00 (of 255)
130130
Stats NanCount: 0 0 0 0
131131
Stats InfCount: 0 0 0 0
132-
Stats FiniteCount: 1048576 1048576 1048576 1048576
133-
Constant: No
132+
Stats FiniteCount: 1 1 1 1
133+
Constant: Yes
134+
Constant Color: 157.00 157.00 157.00 255.00 (of 255)
134135
Monochrome: No
135136
Total size: 4.0 MB
136137
src/tiny-az.exr : 4 x 4, 3 channel, float openexr
@@ -457,7 +458,7 @@ src/mip.tif : 2 x 2, 3 channel, uint8 tiff
457458
Stats StdDev: 0.00 0.00 0.00 (of 255)
458459
Stats NanCount: 0 0 0
459460
Stats InfCount: 0 0 0
460-
Stats FiniteCount: 4 4 4
461+
Stats FiniteCount: 1 1 1
461462
Constant: Yes
462463
Constant Color: 64.00 128.00 191.00 (of 255)
463464
Monochrome: No

0 commit comments

Comments
 (0)