Skip to content

Commit

Permalink
Merge branch 'master' into build_zlib
Browse files Browse the repository at this point in the history
  • Loading branch information
zachlewis committed Sep 16, 2024
2 parents 0d33c4c + 89cc7dc commit 0bebbeb
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ jobs:
pybind11_ver: v2.10.0
skip_tests: 1
# abi_check: v2.6.2.0
abi_check: 1b839e5f78465c0aadca4e05e86982b762414ff4
abi_check: 6aba6e99fd02cea879f87a0ec08f898db37ab49b
setenvs: export OIIO_CMAKE_FLAGS="-DOIIO_BUILD_TOOLS=0 -DOIIO_BUILD_TESTS=0 -DUSE_PYTHON=0"
USE_OPENCV=0 USE_FFMPEG=0 USE_PYTHON=0 USE_FREETYPE=0
CMAKE_BUILD_TYPE=RelWithDebInfo
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

cmake_minimum_required (VERSION 3.15)

set (OpenImageIO_VERSION "2.6.5.1")
set (OpenImageIO_VERSION "2.6.6.0")
set (OpenImageIO_VERSION_OVERRIDE "" CACHE STRING
"Version override (use with caution)!")
mark_as_advanced (OpenImageIO_VERSION_OVERRIDE)
Expand Down
1 change: 0 additions & 1 deletion src/cmake/externalpackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ checked_find_package (Freetype
checked_find_package (OpenColorIO REQUIRED
VERSION_MIN 2.2
VERSION_MAX 2.9
PREFER_CONFIG
)
if (NOT OPENCOLORIO_INCLUDES)
get_target_property(OPENCOLORIO_INCLUDES OpenColorIO::OpenColorIO INTERFACE_INCLUDE_DIRECTORIES)
Expand Down
2 changes: 2 additions & 0 deletions src/doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -2576,3 +2576,5 @@ GENERATE_LEGEND = YES
# This tag requires that the tag HAVE_DOT is set to YES.

DOT_CLEANUP = YES

CLANG_ASSISTED_PARSING = YES
15 changes: 7 additions & 8 deletions src/doc/builtinplugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1293,29 +1293,28 @@ control aspects of the writing itself:
* - ``jpegxl:use_boxes``
- int (bool)
- If nonzero, will enable metadata (Exif, XMP, jumb, iptc) writing to the
output file. Default is 1.
output file. Default is 1.
* - ``jpegxl:compress_boxes``
- int (bool)
- If nonzero, will enable metadata compression. Default is 1.
* - ``jpegxl:exif_box``
- int (bool)
- If nonzero, will enable Exif metadata writing to the output file.
Default is 1.
Default is 1.
* - ``jpegxl:xmp_box``
- int (bool)
- If nonzero, will enable XMP metadata writing to the output file.
Default is 1.
Default is 1.
* - ``jpegxl:jumb_box``
- int (bool)
- If nonzero, will enable JUMBF metadata writing to the output file.
Default is 0.
(dows not supported at this moment in OIIO)
Default is 0. (dows not supported at this moment in OIIO)
* - ``jpegxl:iptc_box``
- int (bool)
- If nonzero, will enable IPTC metadata writing to the output file.
Default is 0.
(Do not work as expected at this moment. Box is written but content
unreadable in exif readers)
Default is 0.
(Does not work as expected at this moment. Box is written but content
unreadable in exif readers.)

.. _sec-bundledplugins-ffmpeg:

Expand Down
8 changes: 4 additions & 4 deletions src/doc/imagebuf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ Making an empty or uninitialized ImageBuf
Constructing a readable ImageBuf
--------------------------------

.. doxygenfunction:: OIIO::ImageBuf::ImageBuf(string_view name, int subimage = 0, int miplevel = 0, ImageCache *imagecache = nullptr, const ImageSpec *config = nullptr, Filesystem::IOProxy *ioproxy = nullptr)
.. doxygenfunction:: OIIO::ImageBuf::reset(string_view name, int subimage = 0, int miplevel = 0, ImageCache *imagecache = nullptr, const ImageSpec *config = nullptr, Filesystem::IOProxy *ioproxy = nullptr)
.. doxygenfunction:: OIIO::ImageBuf::ImageBuf(string_view name, int subimage = 0, int miplevel = 0, std::shared_ptr<ImageCache> imagecache = {}, const ImageSpec *config = nullptr, Filesystem::IOProxy *ioproxy = nullptr)
.. doxygenfunction:: OIIO::ImageBuf::reset(string_view name, int subimage = 0, int miplevel = 0, std::shared_ptr<ImageCache> imagecache = {}, const ImageSpec *config = nullptr, Filesystem::IOProxy *ioproxy = nullptr)


Constructing a writable ImageBuf
Expand Down Expand Up @@ -271,9 +271,9 @@ Cons/Limitations:
this approach, especially for operations where you expect inputs to be float
typically.

.. doxygenfunction:: perpixel_op(const ImageBuf &src, bool (*op)(span<float>, cspan<float>), int prepflags = ImageBufAlgo::IBAprep_DEFAULT, int nthreads = 0)
.. doxygenfunction:: perpixel_op(const ImageBuf &src, function_view<bool(span<float>, cspan<float>)> op, KWArgs options = {})

.. doxygenfunction:: perpixel_op(const ImageBuf &srcA, const ImageBuf &srcB, bool (*op)(span<float>, cspan<float>, cspan<float>), int prepflags = ImageBufAlgo::IBAprep_DEFAULT, int nthreads = 0)
.. doxygenfunction:: perpixel_op(const ImageBuf &srcA, const ImageBuf& srcB, function_view<bool(span<float>, cspan<float>, cspan<float>)> op, KWArgs options = {})

Examples:

Expand Down
13 changes: 6 additions & 7 deletions src/doc/oiiotool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ contents of an expression may be any of:

To illustrate how this works, consider the following command, which trims
a four-pixel border from all sides and outputs a new image prefixed with
"cropped_", without needing to know the resolution or filename of the
"`cropped_`", without needing to know the resolution or filename of the
original image::

oiiotool input.exr -cut "{TOP.width-2*4}x{TOP.height-2*4}+{TOP.x+4}+{TOP.y+4}" \
Expand Down Expand Up @@ -2781,8 +2781,7 @@ current top image.
`max=` *vals*
Specify the maximum range value(s), default 1.0.
`scontrast=` *vals*
Specify sigmoidal contrast slope value(s),
default 1.0.
Specify sigmoidal contrast slope value(s), default 1.0.
`sthresh=` *vals*
Specify sigmoidal threshold value(s) giving the position of maximum
slope, default 0.5.
Expand Down Expand Up @@ -4113,11 +4112,11 @@ current top image.
-fill:topleft=.1,.1,.1:topright=1,0,0:bottomleft=0,1,0:botromright=0,0,1 \
640x480 -o gradient.tif

.. |textimg1| image:: figures/gradient.jpg
.. |gradimg1| image:: figures/gradient.jpg
:width: 2.0 in
.. |textimg2| image:: figures/gradienth.jpg
.. |gradimg2| image:: figures/gradienth.jpg
:width: 2.0 in
.. |textimg2| image:: figures/gradient4.jpg
.. |gradimg3| image:: figures/gradient4.jpg
:width: 2.0 in
..
Expand Down Expand Up @@ -4175,7 +4174,7 @@ current top image.
:width: 2.0 in
.. |textimg2| image:: figures/textcentered.jpg
:width: 2.0 in
.. |textimg2| image:: figures/textshadowed.jpg
.. |textimg3| image:: figures/textshadowed.jpg
:width: 2.0 in
..
Expand Down
6 changes: 3 additions & 3 deletions src/include/OpenImageIO/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ class OIIO_UTIL_API IOProxy {
virtual const char* proxytype () const = 0;
virtual void close () { }
virtual bool opened () const { return mode() != Closed; }
virtual int64_t tell () { return m_pos; }
virtual int64_t tell() const { return m_pos; }
// Seek to the position, returning true on success, false on failure.
// Note the difference between this and std::fseek() which returns 0 on
// success, and -1 on failure.
Expand Down Expand Up @@ -440,7 +440,7 @@ class OIIO_UTIL_API IOProxy {

// Return the total size of the proxy data, in bytes.
virtual size_t size () const { return 0; }
virtual void flush () const { }
virtual void flush() { }

Mode mode () const { return m_mode; }
const std::string& filename () const { return m_filename; }
Expand Down Expand Up @@ -491,7 +491,7 @@ class OIIO_UTIL_API IOFile : public IOProxy {
size_t pread(void* buf, size_t size, int64_t offset) override;
size_t pwrite(const void* buf, size_t size, int64_t offset) override;
size_t size() const override;
void flush() const override;
void flush() override;

// Access the FILE*
FILE* handle() const { return m_file; }
Expand Down
5 changes: 3 additions & 2 deletions src/include/OpenImageIO/function_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ template<typename Ret, typename... Params> class function_view<Ret(Params...)> {
template<typename Callable>
static Ret callback_fn(intptr_t callable, Params... params)
{
return (*reinterpret_cast<Callable*>(callable))(params...);
return (*reinterpret_cast<Callable*>(callable))(
std::forward<Params>(params)...);
}

public:
Expand All @@ -97,7 +98,7 @@ template<typename Ret, typename... Params> class function_view<Ret(Params...)> {

Ret operator()(Params... params) const
{
return callback(callable, params...);
return callback(callable, std::forward<Params>(params)...);
}

operator bool() const { return callback; }
Expand Down
2 changes: 1 addition & 1 deletion src/include/OpenImageIO/imagebuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ class OIIO_API ImageBuf {
/// spec in the ImageBuf to reset the "full" image size (a.k.a.
/// "display window") to
///
/// [xbegin,xend) x [ybegin,yend) x [zbegin,zend)`
/// `[xbegin,xend) x [ybegin,yend) x [zbegin,zend)`
///
/// This does not affect the size of the pixel data window.
void set_full(int xbegin, int xend, int ybegin, int yend, int zbegin,
Expand Down
15 changes: 8 additions & 7 deletions src/include/OpenImageIO/imagebufalgo_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <functional>

#include <OpenImageIO/function_view.h>
#include <OpenImageIO/imagebufalgo.h>
#include <OpenImageIO/parallel.h>

Expand Down Expand Up @@ -610,6 +611,8 @@ inline TypeDesc type_merge (TypeDesc a, TypeDesc b, TypeDesc c)
#define IBA_FIX_PERCHAN_LEN_DEF(av,len) \
IBA_FIX_PERCHAN_LEN (av, len, 0.0f, av.size() ? av.back() : 0.0f);

// clang-format on



/// Simple image per-pixel unary operation: Given a source image `src`, return
Expand Down Expand Up @@ -658,22 +661,20 @@ inline TypeDesc type_merge (TypeDesc a, TypeDesc b, TypeDesc c)
/// version of the operation that allows specialization to any other pixel
/// data types
//
OIIO_NODISCARD OIIO_API
ImageBuf
perpixel_op(const ImageBuf& src, bool(*op)(span<float>, cspan<float>),
OIIO_NODISCARD OIIO_API ImageBuf
perpixel_op(const ImageBuf& src,
function_view<bool(span<float>, cspan<float>)> op,
KWArgs options = {});

/// A version of perpixel_op that performs a binary operation, taking two
/// source images and a 3-argument `op` function that receives a destination
/// and two source pixels.
OIIO_NODISCARD OIIO_API
ImageBuf
OIIO_NODISCARD OIIO_API ImageBuf
perpixel_op(const ImageBuf& srcA, const ImageBuf& srcB,
bool(*op)(span<float>, cspan<float>, cspan<float>),
function_view<bool(span<float>, cspan<float>, cspan<float>)> op,
KWArgs options = {});

} // end namespace ImageBufAlgo

// clang-format on

OIIO_NAMESPACE_END
10 changes: 6 additions & 4 deletions src/libOpenImageIO/imagebufalgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,8 @@ ImageBufAlgo::IBAprep(ROI& roi, ImageBuf& dst, cspan<const ImageBuf*> srcs,

ImageBuf
ImageBufAlgo::perpixel_op(const ImageBuf& src,
bool (*op)(span<float>, cspan<float>), KWArgs options)
function_view<bool(span<float>, cspan<float>)> op,
KWArgs options)
{
using namespace ImageBufAlgo;
ImageBuf result;
Expand Down Expand Up @@ -680,9 +681,10 @@ ImageBufAlgo::perpixel_op(const ImageBuf& src,


ImageBuf
ImageBufAlgo::perpixel_op(const ImageBuf& srcA, const ImageBuf& srcB,
bool (*op)(span<float>, cspan<float>, cspan<float>),
KWArgs options)
ImageBufAlgo::perpixel_op(
const ImageBuf& srcA, const ImageBuf& srcB,
function_view<bool(span<float>, cspan<float>, cspan<float>)> op,
KWArgs options)
{
using namespace ImageBufAlgo;
ImageBuf result;
Expand Down
58 changes: 51 additions & 7 deletions src/libOpenImageIO/imagebufalgo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,29 @@ test_yee()



// Raw function to reverse channels
bool
chan_reverse(span<float> d, cspan<float> s)
{
for (size_t c = 0, nc = size_t(d.size()); c < nc; ++c)
d[c] = s[nc - 1 - c];
return true;
}

// Functor to reverse channels
class ChannelReverser {
public:
ChannelReverser() {}
bool operator()(span<float> d, cspan<float> s)
{
for (size_t c = 0, nc = size_t(d.size()); c < nc; ++c)
d[c] = s[nc - 1 - c];
return true;
}
};



template<typename T>
static void
test_simple_perpixel()
Expand All @@ -1191,12 +1214,33 @@ test_simple_perpixel()
{
print(" unary op\n");
ImageBuf src = filled_image({ 0.25f, 0.5f, 0.75f, 1.0f }, 4, 4, td);
ImageBuf result
= ImageBufAlgo::perpixel_op(src, [](span<float> d, cspan<float> s) {
for (size_t c = 0, nc = size_t(d.size()); c < nc; ++c)
d[c] = s[nc - 1 - c];
return true;
});
ImageBuf result;
// Test with raw function pointer
result = ImageBufAlgo::perpixel_op(src, chan_reverse);
OIIO_CHECK_EQUAL(result.spec().format, td);
for (ImageBuf::ConstIterator<T> r(result); !r.done(); ++r) {
OIIO_CHECK_EQUAL(r[0], 1.0f);
OIIO_CHECK_EQUAL(r[1], 0.75f);
OIIO_CHECK_EQUAL(r[2], 0.5f);
OIIO_CHECK_EQUAL(r[3], 0.25f);
}
// Test with functor
result = ImageBufAlgo::perpixel_op(src, ChannelReverser());
OIIO_CHECK_EQUAL(result.spec().format, td);
for (ImageBuf::ConstIterator<T> r(result); !r.done(); ++r) {
OIIO_CHECK_EQUAL(r[0], 1.0f);
OIIO_CHECK_EQUAL(r[1], 0.75f);
OIIO_CHECK_EQUAL(r[2], 0.5f);
OIIO_CHECK_EQUAL(r[3], 0.25f);
}
// Test with lambda, including variable capture
float bias = 0.0; // Force capture of this variable
result = ImageBufAlgo::perpixel_op(src, [&](span<float> d,
cspan<float> s) {
for (size_t c = 0, nc = size_t(d.size()); c < nc; ++c)
d[c] = s[nc - 1 - c] + bias;
return true;
});
OIIO_CHECK_EQUAL(result.spec().format, td);
for (ImageBuf::ConstIterator<T> r(result); !r.done(); ++r) {
OIIO_CHECK_EQUAL(r[0], 1.0f);
Expand All @@ -1210,7 +1254,7 @@ test_simple_perpixel()
ImageBuf srcA = filled_image({ 0.25f, 0.5f, 0.75f, 1.0f }, 4, 4, td);
ImageBuf srcB = filled_image({ 1.0f, 2.0f, 3.0f, 4.0f }, 4, 4, td);
ImageBuf result = ImageBufAlgo::perpixel_op(
srcA, srcB, [](span<float> d, cspan<float> a, cspan<float> b) {
srcA, srcB, [&](span<float> d, cspan<float> a, cspan<float> b) {
for (size_t c = 0, nc = size_t(d.size()); c < nc; ++c)
d[c] = a[c] + b[c];
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/libutil/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ Filesystem::IOFile::size() const
}

void
Filesystem::IOFile::flush() const
Filesystem::IOFile::flush()
{
if (m_file)
fflush(m_file);
Expand Down

0 comments on commit 0bebbeb

Please sign in to comment.