Skip to content

Commit 165f18b

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents bbfadc6 + 3c2e174 commit 165f18b

27 files changed

Lines changed: 255 additions & 151 deletions

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ if (TEX_BATCH_SIZE)
142142
add_compile_definitions (OIIO_TEXTURE_SIMD_BATCH_WIDTH=${TEX_BATCH_SIZE})
143143
endif ()
144144

145+
# If we're building this just for CI, define a symbol so the code can
146+
# tell (and reduce complexity of some tests)
147+
set_option (OIIO_CI "Set if this build is for our GHA CI" OFF)
148+
if (OIIO_CI)
149+
add_compile_definitions (OIIO_CI=1)
150+
endif ()
145151

146152
# Namespace settings
147153
#

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ MY_CMAKE_FLAGS += -DTEX_BATCH_SIZE:STRING="${TEX_BATCH_SIZE}"
159159
endif
160160

161161
ifneq (${TEST},)
162-
TEST_FLAGS += -R ${TEST}
162+
TEST_FLAGS += -R '${TEST}'
163163
endif
164164

165165
ifneq (${USE_CCACHE},)

src/bmp.imageio/bmpinput.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,28 @@ BmpInput::read_native_scanline(int subimage, int miplevel, int y, int /*z*/,
395395
if ((m_dib_header.compression == RLE4_COMPRESSION
396396
|| m_dib_header.compression == RLE8_COMPRESSION)
397397
&& m_colortable.size()) {
398-
for (int x = 0; x < m_spec.width; ++x) {
399-
int p = m_uncompressed[int64_t(m_spec.height - 1 - y) * m_spec.width
400-
+ x];
401-
auto& c = colortable(p);
402-
mscanline[3 * x] = c.r;
403-
mscanline[3 * x + 1] = c.g;
404-
mscanline[3 * x + 2] = c.b;
398+
if (m_spec.nchannels == 1) {
399+
OIIO_CONTRACT_ASSERT(m_allgray);
400+
for (int x = 0; x < m_spec.width; ++x) {
401+
int p
402+
= m_uncompressed[int64_t(m_spec.height - 1 - y) * m_spec.width
403+
+ x];
404+
auto& c = colortable(p);
405+
mscanline[x] = c.r;
406+
// For the "all gray" case, rgb are equal and we're filling in
407+
// a 1-channel data buffer.
408+
}
409+
} else {
410+
OIIO_CONTRACT_ASSERT(m_spec.nchannels == 3);
411+
for (int x = 0; x < m_spec.width; ++x) {
412+
int p
413+
= m_uncompressed[int64_t(m_spec.height - 1 - y) * m_spec.width
414+
+ x];
415+
auto& c = colortable(p);
416+
mscanline[3 * x] = c.r;
417+
mscanline[3 * x + 1] = c.g;
418+
mscanline[3 * x + 2] = c.b;
419+
}
405420
}
406421
return true;
407422
}

src/build-scripts/ci-startup.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export PYTHONPATH=$OpenImageIO_ROOT/lib/python${PYTHON_VERSION}/site-packages:$P
3636
export COMPILER=${COMPILER:=gcc}
3737
export CC=${CC:=gcc}
3838
export CXX=${CXX:=g++}
39-
export OpenImageIO_CI=true
39+
export OpenImageIO_CI=1
4040
export USE_NINJA=${USE_NINJA:=1}
4141
export CMAKE_GENERATOR=${CMAKE_GENERATOR:=Ninja}
4242
export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:=Release}

src/include/OpenImageIO/color.h

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,25 +121,27 @@ class OIIO_API ColorConfig {
121121
int getColorSpaceIndex(string_view name) const;
122122

123123
/// Get the name of the color space representing the named role,
124-
/// or NULL if none could be identified.
124+
/// or nullptr if none could be identified.
125125
const char* getColorSpaceNameByRole(string_view role) const;
126126

127127
/// Get the data type that OCIO thinks this color space is. The name
128-
/// may be either a color space name or a role.
128+
/// may be either a color space name or a role. For an unknown space or
129+
/// any error, return TypeUnknown.
129130
OIIO::TypeDesc getColorSpaceDataType(string_view name, int* bits) const;
130131

131132
/// Retrieve the full list of known color space names, as a vector
132133
/// of strings.
133134
std::vector<std::string> getColorSpaceNames() const;
134135

135136
/// Get the name of the color space family of the named color space,
136-
/// or NULL if none could be identified.
137+
/// or nullptr if none could be identified.
137138
const char* getColorSpaceFamilyByName(string_view name) const;
138139

139140
// Get the number of Roles defined in this configuration
140141
int getNumRoles() const;
141142

142-
/// Query the name of the specified Role.
143+
/// Query the name of the specified Role, or return nullptr if there is no
144+
/// role with that index.
143145
const char* getRoleByIndex(int index) const;
144146

145147
/// Retrieve the full list of known Roles, as a vector of strings.
@@ -148,7 +150,8 @@ class OIIO_API ColorConfig {
148150
/// Get the number of Looks defined in this configuration
149151
int getNumLooks() const;
150152

151-
/// Query the name of the specified Look.
153+
/// Query the name of the specified Look, or return nullptr if there is no
154+
/// look with that index.
152155
const char* getLookNameByIndex(int index) const;
153156

154157
/// Retrieve the full list of known look names, as a vector of strings.
@@ -157,7 +160,8 @@ class OIIO_API ColorConfig {
157160
/// Get the number of NamedTransforms defined in this configuration
158161
int getNumNamedTransforms() const;
159162

160-
/// Query the name of the specified NamedTransform.
163+
/// Query the name of the specified NamedTransform, or nullptr if there is
164+
/// no NamedTransform with that index.
161165
const char* getNamedTransformNameByIndex(int index) const;
162166

163167
/// Retrieve the full list of known NamedTransforms, as a vector of strings
@@ -221,7 +225,8 @@ class OIIO_API ColorConfig {
221225
/// Get the number of displays defined in this configuration
222226
int getNumDisplays() const;
223227

224-
/// Query the name of the specified display.
228+
/// Query the name of the specified display, or nullptr if there is no
229+
/// display with that index.
225230
const char* getDisplayNameByIndex(int index) const;
226231

227232
/// Retrieve the full list of known display names, as a vector of
@@ -236,7 +241,9 @@ class OIIO_API ColorConfig {
236241
/// display will be used.
237242
int getNumViews(string_view display = "") const;
238243

239-
/// Query the name of the specified view for the specified display
244+
/// Query the name of the specified view for the specified display, or
245+
/// nullptr if there is no view with that index or if the display is not
246+
/// found.
240247
const char* getViewNameByIndex(string_view display, int index) const;
241248

242249
/// Retrieve the full list of known view names for the display, as a
@@ -247,12 +254,14 @@ class OIIO_API ColorConfig {
247254
/// Query the name of the default view for the specified display. If the
248255
/// display is empty or not specified, the default display will be used.
249256
/// This version does not consider the input color space.
257+
/// Returns nullptr for failure.
250258
const char* getDefaultViewName(string_view display = "") const;
251259

252260
/// Query the name of the default view for the specified display, given
253261
/// the input color space. If `display` is "default" or an empty string,
254262
/// the default display will be used. The input color space is used to
255263
/// determine the most appropriate default view for the given display.
264+
/// Returns nullptr for failure.
256265
const char* getDefaultViewName(string_view display,
257266
string_view inputColorSpace) const;
258267

src/include/OpenImageIO/fmath.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ floor2(int x) noexcept
200200
template <typename V, typename M>
201201
inline OIIO_HOSTDEVICE V round_to_multiple (V value, M multiple)
202202
{
203+
OIIO_DASSERT(multiple > M(0));
203204
if (value >= 0)
204205
value += V(multiple) - 1;
205206
return value - (value % V(multiple));

src/include/OpenImageIO/imageio.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ class OIIO_API ImageSpec {
721721
/// Retrieve the named metadata attribute and return its value as an
722722
/// `int`. Any integer type will convert to `int` by truncation or
723723
/// expansion, string data will parsed into an `int` if its contents
724-
/// consist of of the text representation of one integer. Floating point
724+
/// consist of the text representation of one integer. Floating point
725725
/// data will not succeed in converting to an `int`. If no such metadata
726726
/// exists, or are of a type that cannot be converted, the `defaultval`
727727
/// will be returned.
@@ -730,7 +730,7 @@ class OIIO_API ImageSpec {
730730
/// Retrieve the named metadata attribute and return its value as a
731731
/// `float`. Any integer or floating point type will convert to `float`
732732
/// in the obvious way (like a C cast), and so will string metadata if
733-
/// its contents consist of of the text representation of one floating
733+
/// its contents consist of the text representation of one floating
734734
/// point value. If no such metadata exists, or are of a type that cannot
735735
/// be converted, the `defaultval` will be returned.
736736
float get_float_attribute (string_view name, float defaultval=0) const;

src/jpeg2000.imageio/jpeg2000input.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,9 @@ Jpeg2000Input::ojph_read_image()
392392
int ch = m_spec.nchannels;
393393
ojph::param_siz siz = codestream.access_siz();
394394

395-
const int bufsize = w * h * ch * buffer_bpp;
395+
const size_t bufsize
396+
= clamped_mult64(clamped_mult64(uint64_t(w), uint64_t(h)),
397+
clamped_mult64(uint64_t(ch), uint64_t(buffer_bpp)));
396398
m_buf.resize(bufsize);
397399
codestream.create();
398400

@@ -622,6 +624,14 @@ Jpeg2000Input::open(const std::string& name, ImageSpec& p_spec)
622624
m_spec.full_width = m_image->x1;
623625
m_spec.full_height = m_image->y1;
624626

627+
// Validation of resolution
628+
if (!check_open(m_spec,
629+
{ 0, std::numeric_limits<int>::max(), 0,
630+
std::numeric_limits<int>::max(), 0, 1, 0, 16384 })) {
631+
close();
632+
return false;
633+
}
634+
625635
m_spec.attribute("oiio:BitsPerSample", maxPrecision);
626636
m_spec.set_colorspace("srgb_rec709_scene");
627637

src/libOpenImageIO/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,13 @@ if (OIIO_BUILD_TESTS AND BUILD_TESTING)
263263
LINK_LIBRARIES OpenImageIO Imath::Imath
264264
FOLDER "Unit Tests" NO_INSTALL)
265265
add_test (unit_image_span ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/image_span_test)
266+
set_tests_properties (unit_image_span PROPERTIES COST 10)
266267

267268
fancy_add_executable (NAME imagebuf_test SRC imagebuf_test.cpp
268269
LINK_LIBRARIES OpenImageIO
269270
FOLDER "Unit Tests" NO_INSTALL)
270271
add_test (unit_imagebuf ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/imagebuf_test)
272+
set_tests_properties (unit_imagebuf PROPERTIES COST 30)
271273

272274
fancy_add_executable (NAME imagecache_test SRC imagecache_test.cpp
273275
LINK_LIBRARIES OpenImageIO
@@ -284,6 +286,7 @@ if (OIIO_BUILD_TESTS AND BUILD_TESTING)
284286
FOLDER "Unit Tests" NO_INSTALL)
285287
target_compile_definitions (imagebufalgo_test PRIVATE OIIO_USE_HWY=${_oiio_use_hwy})
286288
add_test (unit_imagebufalgo ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/imagebufalgo_test)
289+
set_tests_properties (unit_imagebufalgo PROPERTIES PROCESSORS 2 COST 60)
287290

288291
fancy_add_executable (NAME imagespec_test SRC imagespec_test.cpp
289292
LINK_LIBRARIES OpenImageIO
@@ -294,6 +297,7 @@ if (OIIO_BUILD_TESTS AND BUILD_TESTING)
294297
LINK_LIBRARIES OpenImageIO
295298
FOLDER "Unit Tests" NO_INSTALL)
296299
add_test (unit_imageinout ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/imageinout_test)
300+
set_tests_properties (unit_imageinout PROPERTIES PROCESSORS 2 COST 30)
297301

298302
if (NOT DEFINED ENV{OpenImageIO_CI})
299303
fancy_add_executable (NAME imagespeed_test SRC imagespeed_test.cpp

0 commit comments

Comments
 (0)