Compare commits

..
2214 Commits
Author SHA1 Message Date
Larry Gritz 9984e93000 Stage release v2.4.15.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-09-01 09:48:29 -07:00
Larry Gritz 1738e0a6a5 ci: Bump 'latest release' test to OpenEXR/Imath 3.2 and OCIO 2.3 (#3971)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-09-01 09:48:29 -07:00
Larry Gritz 904e8dfc37 build: Fix broken libheif < 1.13 (#3970)
Typo introduced in #3894 broke our ability to build against libheif <
1.13. A conditional compilation that should have kicked in for >=1.16
was mistakenly written as 1.6.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-31 17:11:33 -07:00
Larry Gritz f58124dd60 admin: Relicense code under Apache 2.0 (#3966)
This is Update 4, the original PR is ongoing and we will continue to
update as additional people relicense.

Per PR #3905 (https://github.com/OpenImageIO/oiio/pull/3905), update the
RELICENSING document with the names of people and companies who have
signed on to the relicensing thus far, and update the SPDX license
notices on source files whose extant authorship (per 'git blame')
comprises only authors who have relicensed.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-29 21:56:27 -07:00
Larry Gritz 21e10fb2c0 Admin: Add Jesse Yurkovich to the TSC (#3937)
Proposal from Thiago to add Jesse Yurkovich, representing Blender, to
the TSC.

Vote passed by majority of TSC members voting yes on the PR itself.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-27 22:01:42 -07:00
Jesse Yurkovich 4836a21950 fix(dds): Fix div by 0 during DXT4 DDS load (#3959)
Fixes #3950

Fix the div-by-0 when handling unassociated alpha during a DXT4 DDS
load. The code mirrors what other formats do by first checking to see if
the alpha value is not 0 before continuing.

Added the 218-byte file from the bug to the local test suite.

---------

Signed-off-by: Jesse Yurkovich <jesse.y@gmail.com>
2023-08-25 11:43:09 -07:00
Mikael Sundell 84cd074604 build: Added check for Boost_NO_BOOST_CMAKE, ignore if already set (#3961)
Enable set of Boost_NO_BOOST_CMAKE through make using
MY_CMAKE_FLAGS=-DBoost_NO_BOOST_CMAKE:BOOL=OFF.

Signed-off-by: Mikael Sundell <mikael.sundell@gmail.com>
2023-08-25 11:43:02 -07:00
Jesse Yurkovich 1f05697cbd Fix(rla): Invalid read from an empty vector during RLA load (#3960)
The incoming length of the RLE data could be 0. In this case we would
attempt to take the address of the 1st element of an empty vector.

Added a new 1004-byte file to the local test suite.

Fixes #3951

---------

Signed-off-by: Jesse Yurkovich <jesse.y@gmail.com>
2023-08-25 09:03:39 -07:00
Jesse Yurkovich 2031172953 cleanup: Fix typo in debug output (#3956)
Fixes a typo in the debug output triggered during the image plugin
search sequence.


Signed-off-by: Jesse Yurkovich <jesse.y@gmail.com>
2023-08-25 09:02:00 -07:00
Larry Gritz 88249cf59a fix: various protections against corrupted files (#3954)
Fixes #3952

Several interrelated fixes to guard against corrupted files:

* Extend the `limits:imagesize_MB` sanity check to Targa files to
address #3952 specifically, and check in that failing example file into
the testsuite. (N.B.: Only a couple readers use this, TIFF and now
Targa. it should be extended to the others. Mackerel!)

* Improve the error message used for the above, both for Targa and TIFF.

* For low-memory situations, perhaps the default of 32GB is too large.
Make the default be the minimum of 32GB and 1/2 the size of physical
memory on the machine. (An app that legit expects humongous files is
expected to raise the limit appropriately.)

* The generic "Read error: hit end of file" we sometimes issued from
`ImageInput::ioread()` was hard to discern which reader it came from, in
cases where the file extension was absent or misleading and a succession
of files were tried. By changing this error message to say which format
reader triggered the error, it might make these errors easier to track
down in the future. This also changed the reference output of a few test
involving truncated or corrupted files.

---------

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-24 22:31:51 -07:00
Larry Gritz cd1ffe5abf ci: Make more robust timer_test (#3953)
On overloaded VMs, the timer_test is ureliable and fails spuriously too
often.

Two strategies in this patch, hope some combination does the trick:

1. Increase the absolute error allowed for the timing tests when doing
CI runs.

2. Add just a bit more relative error (via a new unit test macro,
OIIO_CHECK_EQUAL_THRESH_REL).

Hopefully this will cut down on CI failures for unit_timer test case.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-24 18:09:36 -07:00
ShootfastandLarry Gritz 6cbd1e8fa2 build: Silence gcc new/delete warnings for texturesys (#3944)
Disable GCC warnings around mismatched new/delete for shared_texturesys
creation


Signed-off-by: Shootfast <markboo99@gmail.com>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
Co-authored-by: Larry Gritz <lg@larrygritz.com>
2023-08-24 18:09:20 -07:00
Larry Gritz e015ae4293 dev(ustring.h): string literal operator for ustring and ustringhash (#3939)
* Add string literal operators for ustring and ustringhash so you can
write: ``` "foo"_us "bar"_ush ``` Note that on Cuda (but not on the
host), this ustringhash construction is constexpr.

* Add a new `ustringhash(const char*, size_t)` constructor, which is
also constexpr on the device side.

* Mark the existing `ustringhash(string_view)` constructor as constexpr
on the device side.

We can mark those things as constexpr on the device side because on the
Cuda side, the implementation only takes the hash (which is constexpr),
and does not actually add a ustring to the table (which cannot be
constexpr). To make such declarations easy, add a new macro to
platform.h, `OIIO_DEVICE_CONSTEXPR` which is constexpr for the device,
merely inline for the host.

---------

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-24 18:09:11 -07:00
xiaoxiaoafeifei 672ed4c445 fix(bmp): fix signed integer overflow when computing total number of pixels (#3948)
fix #3947: runtime error: signed integer overflow in file
src/bmp.imageio/bmpinput.cpp:302
2023-08-20 11:21:34 -07:00
Larry Gritz c90efcf167 admin: Update pull request and issue templates (#3946)
The most important fix is to remove links to the old CLAs and update
references to the mail list to the new one.

Also spruced up some language while I was there, hopefully to coax out
improved PRs and Issues.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-20 11:21:14 -07:00
Anton Dukhovnikov 65e3838985 build: suppress Xcode warnings (#3940)
When building the code with Xcode ("cmake -G Xcode"), there are 1000+
warnings about implicit 64 to 32 bit conversion.
This change adds a compile option to suppress such warnings when
generating an Xcode project.

Signed-off-by: Anton Dukhovnikov <antond@wetafx.co.nz>
2023-08-12 08:51:08 -07:00
Larry Gritz 6d2b4194e7 admin: Relicense code under Apache 2.0 (#3938)
This is Update 3, the original PR is ongoing and we will continue to
update as additional people relicense.

Per PR #3905 (https://github.com/OpenImageIO/oiio/pull/3905), update the
RELICENSING document with the names of people and companies who have
signed on to the relicensing thus far, and update the SPDX license
notices on source files whose extant authorship (per 'git blame')
comprises only authors who have relicensed.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-03 21:06:20 -07:00
NicolasandLarry Gritz 99e4bc86ac fix: utf-8 text rendering (#3935)
Text rendering doesn't work with utf-8... 

I can't render chinese, arabic... or special chars as éèûîà...

It seems that the string function to convert utf-8 to unicode is quiet
simple.

Fixes #3933 

[Note]: OpenImageIO is used in the [gpx2video
project](https://github.com/progweb/gpx2video).

---------

Signed-off-by: Nicolas VIVIEN <nicolas@vivien.fr>
Signed-off-by: Larry Gritz <lg@larrygritz.com>
Co-authored-by: Larry Gritz <lg@larrygritz.com>
2023-08-03 20:55:56 -07:00
Larry Gritz 59953474b2 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-01 17:05:44 -07:00
Larry Gritz 40cff8d4a5 Docs: Make sure README has links for slack and meetings (#3936)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-08-01 13:15:24 -07:00
Larry Gritz 4d7fed6984 Stage for v2.4.14.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-30 17:06:27 -07:00
Jesse Yurkovich 9757e20694 fix(python): Fix arithmetic overflow in oiio_bufinfo (Python interop) (#3931)
When an incoming 1-dimensional, buffer-like, object was used in Python,
the corresponding check inside OIIO would overflow if its length
exceeded a signed 32bit value.

An error similar to `Pixel data array error: Python array shape is
[2304000000] but expecting h=24000, w=24000, ch=4` would be raised.

I modified a few similar calculations and tried to follow the
predominant pattern already used.

Tested using the following snippet which would previously fail:
```
import OpenImageIO as oiio
import numpy as np

filename = "t:/foo.png"
xres = 24000
yres = 24000
channels = 4  # RGB
pixels = np.zeros(xres * yres * channels, dtype=np.uint8)

spec = oiio.ImageSpec(xres, yres, channels, "uint8")
image = oiio.ImageOutput.create(filename)
image.open(filename, spec)
if not image.write_image(pixels):
    print("error = ", image.geterror())
image.close()
```

---------

Signed-off-by: Jesse Yurkovich <jesse.y@gmail.com>
2023-07-29 11:06:19 -07:00
Larry Gritz 0881ebdedb build: bump build_openexr and build_opencolorio defaults to latest versions (#3920)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-29 11:06:03 -07:00
Larry Gritz 20756dad13 admin: Relicense code under Apache 2.0 (#3926)
Per PR #3905 (https://github.com/OpenImageIO/oiio/pull/3905), update the
RELICENSING document with the names of people and companies who have
signed on to the relicensing thus far, and update the SPDX license
notices on source files whose extant authorship (per 'git blame')
comprises only authors who have relicensed.

This is part 2, the original PR is ongoing and we will continue to
update as additional people relicense.

Signed-off-by: Larry Gritz <lg@larrygritz.com>

---------

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-29 11:05:46 -07:00
Larry Gritz 39f2022aca docs: Put logo on the main readme (#3927)
Add some logo images in ASWF/logos for handy use.

---------

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-29 11:05:24 -07:00
Larry Gritz ec4ead0cbb ci: Lock down icx version (#3929)
Intel's servers have again updated the default icx that you get when you
install from their yum repository, and the new one seems incompatible
with our libstdc++ toolchain. So lock down on 2023.1.0 for now so that
our CI can pass.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-29 11:05:12 -07:00
jasonbaumeister 77c2a8b217 feat(ico): Add IOProxy support to ICOInput (#3919)
This updates ICOInput to use the IOProxy model so it can read from files
or the IOMemReader

Signed-off-by: Jason Baumeister <jason@jasonbaumeister.com>
2023-07-29 11:03:17 -07:00
jasonbaumeister c9d75870c6 fix(psd): CMYK PSD files should copy alpha (#3918)
During the CMYK to RGB conversion in PSDInput, the alpha channel was
never copied to the RGBA output. Converting a PSD to JPEG worked because
it ignored all the 0 alpha values, but converting to WebP would result
in a fully transparent image.

I added a cmyk-with-alpha.psd test to the psd-colormodes test to check
this

Signed-off-by: Jason Baumeister <jason@jasonbaumeister.com>
2023-07-29 11:02:53 -07:00
Larry Gritz b32e546d16 ci: Test against pybind11 v2.11 (#3912)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-29 11:02:39 -07:00
D-Spirits c1f43ae796 Admin: Add DevilishSpirits to RELICENSING.md (#3922)
For the relicensing request in #3905 and signed with my personal PGP
key.
2023-07-29 11:02:05 -07:00
Larry Gritz f8f342f08a build: Fix broken OIIO_NO_NEON definition (#3911)
Clean up the `#if` tests that disable Intel SIMD when not on Intel
architectures, which incorrectly disabled ARM NEON when on ARM.

Fixes #3909

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-16 21:48:49 -07:00
Jesse Y 5ca4b06516 docs: Update ImageInput docs to not use deprecated APIs (#3907)
Update the ImageInput documentation to not use the deprecated
`read_image` APIs.

Based on the discussion in #3902

---------

Signed-off-by: Jesse Yurkovich <jesse.y@gmail.com>
2023-07-15 16:46:20 -07:00
Larry Gritz 23751c1bf1 admin: Relicense code under Apache 2.0 (#3914)
Per PR #3905 (https://github.com/OpenImageIO/oiio/pull/3905), update the
RELICENSING document with the names of people and companies who have
signed on to the relicensing thus far, and update the SPDX license
notices on source files whose extant authorship (per 'git blame')
comprises only authors who have relicensed.

This is part 1, the original PR is ongoing and we will continue to
update as additional people relicense.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-15 16:46:15 -07:00
Benjamin Buch 110ed69660 build: Find OpenEXR equally well with our FindOpenEXR and exr's exported config file (#3862)
If OpenEXR is found by cmake config file, OpenEXR_VERSION is set instead of OPENEXR_VERSION

Signed-off-by: Benjamin Buch <benjamin.buch@technoteam.de>
2023-07-15 16:45:52 -07:00
Benjamin Buch 3ab3231304 build: Fix WebP linking if CMAKE_FIND_PACKAGE_PREFER_CONFIG is ON (#3863)
Our own FindWebP.cmake was setting up targets that didn't
match the capitalization of the cmake configs that come with WebP itself.

Signed-off-by: Benjamin Buch <benjamin.buch@technoteam.de>
2023-07-15 16:45:43 -07:00
Larry Gritz 99542f910d admin: Mark more files that LG has contributed to as 'and Apache-2.0' (#3906)
This batch is for files that LG (relicensed!) has contributed, in
addition to >2 other authors. Also add appropriate license notices to
some that had no posted license before due to oversight.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-13 18:19:29 -07:00
Larry Gritz a21aa460ff admin: Copyright and license notice updates (#3904)
* Add copyright/license notices to some mixed-authorship files that
lacked them before (all related to tests)
* Get rid of the pointless year in many copyright notices (change to the
current LF recommended wording)

---------

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-08 20:38:16 -04:00
Larry Gritz 95177f11a6 admin: update licensing (#3903)
Since LG has re-licensed all his old code under Apache-2.0, we can
change the license notice from BSD to Apache-2.0 for all files in which
LG is the only extant author. Also change all files that LG co-authored
with other people to specify "BSD-3-Clause and Apache-2.0".

Some files (mostly test scripts) had no license notice, so in those
cases, we added one.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-08 20:37:06 -04:00
Larry Gritz ab08205f6a admin: Change open source license to Apache 2.0 (#3899)
By majority vote of the TSC, we are changing OpenImageIO's main
incoming/outgoing open source license from BSD-3-Clause to Apache-2.0.
New code submitted from July 1, 2023 will be contributed under the
Apache 2.0 license.

Old code submitted prior to July 1 2023 is under the original BSD
3-clause license, unless relicensed per the process described in the new
RELICENSING.md file. We hope to get the vast majority of the code base
relicensed quickly and we will document which set of files contain a
mixture of licenses.

Instructions to everybody reading this:

* If you are contributing code under the authorization of an employer,
please let them know we are changing to Apache 2.0 and make sure that
you are authorized to make all future contributions to under that
license.

* If you made prior contributions to OpenImageIO over the years and are
willing to relicense your code under the Apache 2.0 license, please
submit a PR adding your name to the list in RELICENSING.md. If you were
working for a company that might own your IP output at the time you made
those contributions, please also ask somebody there (who has the
authority to do so) to submit a PR adding the company name as well,
indicating that they are re-submitting all of the old contributions
under the new license.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-08 20:33:56 -04:00
Larry Gritz d6c151efba docs: Document CVE
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-08 20:33:22 -04:00
Larry Gritz 50d51f58d7 admin: Remove old CLAs that are no longer in effect
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-05 21:34:11 -04:00
Larry Gritz 91341990f6 admin: Add charter and other ASWF documents to the repo (#3850)
By unanimous vote of the OpenImageIO TSC, as of July 1, 2023, we
adopt the technical charter, Code of Conduct, new CLAs, and GOVERNANCE
document.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-05 21:33:51 -04:00
Larry Gritz 7b3d368a87 Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-01 11:54:02 -07:00
Larry Gritz d308780e12 Stage v2.4.13.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-01 09:38:58 -07:00
Larry Gritz 8e8dab1215 fix(strutil.h): ensure proper constexpr of string hashing (#3901)
The underlying farmhash algorithm (which is the basis for
Strutil::strhash, and thus ustring's hash representation) turned out to
not be properly constexpr under certain circumstances and needed to be
expressed a different way to be fully constexpr on all platforms and for
all strings.

New implementation suggested by Alex Wells.

Also, make sure string_view ctr from char* can be constexpr, even for
C++14. This is related for the sake of the strhash calls that, when
taking string literals, actually choose the variety that accepts a
string_view.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-01 01:29:47 -07:00
Larry Gritz dfa76c7a5e testing: Fix missing simd test due to copy paste typo (#3896)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-01 00:08:38 -07:00
Larry Gritz b86d8ad011 docs: Document use of the DCO which is now required for all PRs (#3897)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-01 00:08:20 -07:00
Larry Gritz 9bcd4e7a1f ci: Simplify build_llvm.bash script (#3892)
* Remove leftover logic from when we used TravisCI.
* Pick a default for LLVM_DISTRO_NAME so it works when the script is run
standalone when not on GitHub Actions CI. (But it's still really only
meant to run on x86 Ubuntu, and not designed for anything useful outside
of our CI.)
* Eliminate all the complexity with old LLVM versions -- in practice,
our CI only uses this to download fairly modern clang versions.

Fixes #3891

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-01 00:07:51 -07:00
Larry Gritz f11dbfc40d ci: Fix broken heif dependency and test (#3894)
The strukturag repo for libheif recently upgraded the version it was
serving from 1.14 to 1.16, and that caused our tests to fail because (a)
some of the codec support has been moved to plugins that are loaded at
runtime and those are now distributed in packages we need to install
separately; (b) you must call heif_init() or it won't know about the
optional plugins.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-07-01 00:07:19 -07:00
Larry Gritz 84f8acdc56 docs(raw): Fix explanation of raw:Exposure config hint (#3889)
Fixes #3888

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-17 16:35:16 -07:00
Larry Gritz c79e11bfcf fix(IBA): Improve error message for IBA::ocio functions (#3887)
If colorconvert, ociolook, ociodisplay, ociofiletransform fail
because OCIO support is not enabled, make sure the error message
makes that clear.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-16 18:56:36 -07:00
Fabien Servant @ TCS 44ab7f4192 fix(exif): Convert paramvalue string to integer when needed (#3886)
Make sure we can input exif tags as strings containing numbers when
number are required.

E.G. if my input is "Orientation"=>"8", i would like the jpeg output to
contains the value 8 for the exif tag orientation.
2023-06-16 18:56:30 -07:00
Larry Gritz 55f97a43b7 fix(exr): correction to dwa vs zip logic when outputting OpenEXR (#3884)
PR #2147, addressing issue #1844, is related to an apparent OpenEXR bug
wherein single channel tiled images where the tile dimensions were not a
power of 2 and >= 16 would not work properly with dwa compression. We
work around the problem by automatically substituting zip compression in
those cases. But it was implemented with a subtle bug, forgetting that
tile_size == 0 for untiled images, and thus we were silently switching
from dwa to zip compression for all *untiled* single channel images of
any size (which presumably were never problematic). This patch fixes the
test so we are not changing the compression for the untiled files.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-14 13:30:32 -07:00
Larry Gritz 5b2d2066e6 fix(jpeg2000): better pixel type promotion logic (#3878)
J2K output was defaulting to UINT8 when asked to output an unsupported
type. It should have been UINT16 to try to minimize the amount of
precision loss.

Fixes #3876

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-14 13:30:32 -07:00
Larry Gritz bd588e5ca8 admin: Update mail list URL (#3880)
Everybody please go to https://lists.aswf.io/g/oiio-dev and sign up for
the new mail list as soon as possible. The old list is on its last legs
and having trouble, let's get this done.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-14 13:30:32 -07:00
Larry Gritz c7ff69ff59 ci: Add test with new aswf containers for VFX Platform 2023 (#3875)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-12 16:40:24 -07:00
Larry Gritz e97403c7ba build: Fix fmt vs gcc warning that had version typo (#3874)
The comment was right, but the test seems to have had a typo we didn't
catch in review.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-12 10:21:23 -07:00
Larry Gritz 8add832fa8 fix(psd): Prevent simultaneous psd thumbnail reads from clashing (#3877)
When reading a PSD file, if it contains a thumbnail, we read it from the
in-memory blob with a combination of an IOMemReader and an ImageBuf.
But... we always named it "thumbnail.jpg" without considering that
multiple simultaneous PSD files reading identically named images (but
which are in fact different) could cause a weird kind of clashing in any
underlying use of ImageCache!

The simple fix is to use ordinary ImageInput approach to reading the
thumbnail from the IOMemReader, but just store it in the ImageBuf.

Fixes #3824

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-12 10:21:14 -07:00
xiaoxiaoafeifei 749a557b5e fix(ico): heap-buffer-overflow (#3872)
heap-buffer-overflow in function ICOInput::readimg 

fixes #3871
2023-06-10 11:04:50 -07:00
Larry Gritz c095abae93 build: Fix use of OIIO_LOCAL_DEPS_PATH (#3865)
We set it, but we didn't use it where it was intended.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-10 11:04:43 -07:00
Jesse Y e43cbe830c docs: Many fixes to python code examples (#3869)
A variety of minor documentation fixups:
- Use Python 3 style 'print' statements consistently everywhere (some
snippets had a mix of both)
- Correct the usage of `ImageSpec::channels` that should be
`ImageSpec::nchannels`
- Template syntax errors in two C++ snippets
- Document the new default for `max_memory_MB`
2023-06-10 11:02:46 -07:00
Ziggy Cross 98ff1e57ae ImageInput and ImageOutput docs updated to Python 3. (#3866)
## Description

Fixes #3846 by updating Python examples.

Current code examples for
[ImageInput](https://openimageio.readthedocs.io/en/latest/imageinput.html)
and
[ImageOutput](https://openimageio.readthedocs.io/en/latest/imageoutput.html)
raise a SyntaxError in Python 3:
```python
File "<cwd>\main.py", line 13
    return
    ^^^^^^
SyntaxError: 'return' outside function
```

It seems these code examples might be for Python 2.7. Perhaps it would
be worth creating an extra tab instead of replacing the old code?

## Tests

Tested on Python 3.11, no issues.

## Checklist:

- [x] I have read the [contribution
guidelines](https://github.com/OpenImageIO/oiio/blob/master/CONTRIBUTING.md).
- [ ] If this is more extensive than a small change to existing code, I
  have previously submitted a Contributor License Agreement

([individual](https://github.com/OpenImageIO/oiio/blob/master/src/doc/CLA-INDIVIDUAL),
and if there is any way my
  employers might think my programming belongs to them, then also

[corporate](https://github.com/OpenImageIO/oiio/blob/master/src/doc/CLA-CORPORATE)).
- [x] I have updated the documentation, if applicable.
- [ ] I have ensured that the change is tested somewhere in the
testsuite
  (adding new test cases if necessary).
- [x] My code follows the prevailing code style of this project.
2023-06-07 16:04:17 -07:00
Larry Gritz 503fb7a511 feat(OpenCV): Improve OpenCV support -- errors, version, half (#3853)
Various improvements to OpenCV support:

* IBA::from_OpenCV and to_OpenCV now set error messages for every type
of failure they encounter, instead of returning false with no
explanation. For from_OpenCV, the error message can be retrieved from
the ImageBuf returned; for to_OpenCV, the error message can be retrieved
from the global OIIO::geterror(). Several assertions were removed,
instead relying on error return codes and messages.

* Add global OIIO attribute "opencv_version" which allows you to find
out what version of OpenCV OIIO was built against, which was previously
impossible to know without seeing the build-time status messages. This
can be retrieved via

      OIIO::get_int_attribute("opencv_version")

  and also you can find out from the command line with

      oiiotool --echo "{getattribute(opencv_version)}"

The return value is an integer encoded as `10000*major + 100*minor +
patch`, and it will return 0 if no OpenCV support was enabled when
OpenImageIO was built.

* For OpenCV >= 4.0, to_OpenCV can now correctly construct a 'half'
matrix. For OpenCV 3.x, we turn it into a float matrix as before, since
CV_16F was only supported starting in 4.0.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-02 11:38:35 -07:00
Larry Gritz a7ff737902 docs: Update CONTRIBUTING and SECURITY (#3852)
Just a routine update of these files as I proofread them in light of the
move to ASWF. This patch is addressing the "old" project, there will be
further ASWF-specific edits for changes that will take effect after the
project is fully moved.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-02 09:49:13 -07:00
Loïc Vital 1cd944338c fix(jpeg): fix density calculation for jpeg output (#3861)
In `jpegoutput.cpp` when computing the density fields the relationship
between `XRes`, `YRes` and `aspect` is `aspect = XRes / YRes`.

However this relationship was not respected in one specific case, when
`aspect >= 1.0` and `XRes` and `YRes` are not set.

This PR solves this problem by enforcing the correct relationship.

Related to: https://github.com/OpenImageIO/oiio/issues/2822
2023-06-02 09:49:03 -07:00
Larry Gritz 5cb94101ba Bump version after release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-01 13:02:37 -07:00
Larry Gritz e7fe406481 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-01 10:26:37 -07:00
Larry Gritz 73fdd4281a Stage for v2.4.12.0
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-01 10:11:09 -07:00
Larry Gritz 0c48ae1ae3 ci: Fix package name for icc (#3860)
The Intel yum repo renamed this package a couple weeks ago, and it broke
our CI. Update to the new name.

Adjust fmt use to solve icc warning.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-06-01 07:33:26 -07:00
Loïc Vital 0e9406e17a fix(raw): raw input fix user_flip usage (#3858)
When reading a raw image, setting the `user_flip` to 1 meant ignoring
the `flip` value (to avoid buffer rotation from LibRaw).

However the value 1 for the `user_flip` is **not neutral**: values lie
between 0 and 7 (see
https://www.libraw.org/docs/API-datastruct-eng.html#libraw_image_sizes_t),
and 1 corresponds to a horizontal mirror (in my understanding of the
source code).

The proposed fix is to use 0 as `user_flip` value for ignoring the
`flip` value.

This modification invalidates the changes made in this PR:
https://github.com/OpenImageIO/oiio/pull/3847.
Therefore, flip to orientation conversion has been adapted to match
exactly LibRaw's documentation, which handles only rotations (+90, +180,
-90 degrees).

The previous PR was only tested on images of landscape and human faces,
hence the mirroring issue remained unnoticed.
When reading images containing text however the problem is clearly
visible.
This PR fixes this mirroring issue on the following 4 orientations: 0,
+90, +180 and -90 degrees rotation.
Other orientations could not be tested as they don't seem to ever appear
on raw images datasets.
2023-06-01 07:33:19 -07:00
Larry Gritz 73d99b9733 build(Mac): Fixes for latest xcode on MacOS 13.3 Ventura (#3854)
I found that this was needed after weekend OS update of my laptop.

Also added MacOS-13 CI test.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2023-05-29 09:52:07 -07:00
Loïc Vital e28cffbf2a fix(raw): fix LibRaw flip to Exif orientation conversion (#3847)
When reading a raw image while having a `user_flip` set to 1, we set the
orientation Exif tag to LibRaw's flip value (so that LibRaw doesn't
rotate and/or mirror the buffer but the image still gets displayed
correctly).

However LibRaw's convention for flip values differ from Exif orientation
values: https://www.libraw.org/comment/5176#comment-5176.

In this PR we fix this issue by converting LibRaw flip values to Exif
orientation values. This conversion is based on:
- https://www.libraw.org/comment/5178#comment-5178 (conversion proposed
by LibRaw's maintainer)
-
https://github.com/LibRaw/LibRaw/blob/6fffd414bfda63dfef2276ae07f7ca36660b8888/src/write/file_write.cpp#L22
(LibRaw's function for applying the flip).

Tested on:
- CR2 images with flip values 1, 5 and 6
- ARW images with flip values 1 and 5
(unfortunately I could not find any image covering other flip values).

Since the conversion is `[1, 2, 3, 4, 5, 6, 7, 8] -> [1, 2, 4, 3, 5, 8,
6, 7]`, the only test that came out with different results before and
after the change is the one with flip value 6:
in that case, the image orientation got corrected by the fix.
2023-05-19 18:56:00 -07:00
xiaoxiaoafeifei 5ff2c56dd2 fix: prevent heap-buffer-overflow in file src/gif.imageio/gifinput.cpp, line 368 (#3841)
Fixes #3840
2023-05-19 18:55:49 -07:00
Larry Gritz 2d0e89bdab fix(int): prevent possible deadlock when reaading files with wrong extensions (#3845)
Make pvt::imageio_mutex be a recursive_mutex

Fixes #3842
2023-05-17 09:24:11 -07:00
Larry Gritz 1ebe68ca90 fix(oiiotool): don't propagate unsupported channels (#3838)
Fixes #3837

oiiotool already attempted to trim extra channels when outputting to a
format that can't support it. It correctly handled the two common cases:

* More than 4 channels for formats that don't have
`supports("nchannels")` will drop after the first 4 channels.
* More than 3 channels for formats that don't have `supports("alpha")`
will drop after the first 3 channels.

But this omits an interesting (but rare) corner case: a 4 channel file
where the last channel is NOT alpha, and the output file supports an
alpha channel but not arbitrary channels. A concrete example might be an
input file that is exr with channels R, G, B, Z, writing to a PNG file
(which can support RGB or RGBA). We wouldn't want to write what appears
to be an RGBA file if that last channel isn't really alpha.

Also, noticed that oiiotool --chnames didn't properly clear the
alpha_channel and z_channel flags, which is important if the new channel
lists drop one of those channels.
2023-05-15 14:49:27 -07:00
Larry Gritz 405909bf70 Improve make_texture for very large images (#3829)
`make_texture()` already took a configuration option "maketx:forcefloat"
(defaults to 1), which if set to 0 disables the conversion to a float
buffer for intermediate computation.

For `oiiotool -otex`, there was no way to specify this. This patch
allows it to be disabled with the new optional modifier
`-otex:forcefloat=0`.

Also, in make_texture, this option only controlled the initial
conversion of the whole buffer to float, but the downsized levels all
were float either way. This patch now uses the forcefloat config option
to also control the buffers used for downsizing.

Disabling forcefloat like this has a speed penalty (the downsizing math
on float buffers is faster than going in and out of float for every
indvidual value) and loses some precision in the process of repeatedly
downsizing to generate the MIP levels. But it can sure save a lot of
memory if you have a ginormous uint8 image and want to avod the 4x
balooning of memory. I don't recommend disabling forcefloat except for
images that can't fit into memory for the texture creation without it.
But when this is the right hammer to use, it can be the difference
between being able to create the texture, or not.

Some other improvements:

* `oiiotool -otex` wasn't outputting ANY status output during texture
output as maketx does, and for that matter, -v and -debug were not being
influencing the behavior of make_texture at all despite it having such
support. So fix to pass down the right flags. Now there are proper
verbose status and debug messages when requested.

* Eliminate useless call to is_monochrome by calling it only when the
previously-computed pixel stats indicate that the average value of all
the channels is the same (if they don't have the same average, there's
no way the pixel-by-pixel values will be the same in all channels for
all pixels). This saves an extra traversal of all the pixel memory
during texture creation.

* Use synchronized/flushed status messages so users can see them as they
are issued for very long maketx tasks. This also included some
conversion from old iostream stuff to fmt-based print.

* For verbose/debug, more fine-grained timing for make_texture, in
particular, print the time spent downsizing and writing each MIP level.
2023-05-15 12:00:45 -07:00
Larry Gritz aead17571b ci: Fix warnings (#3833)
I'm honestly not sure why some GHA CI jobs suddenly started warning
about this in the past day or so. Something must have updated on their
end. But switching to the safer Strutil equivalents fixes it.
2023-05-15 11:59:35 -07:00
Ray Molenkamp 61d234347c Fix: Build error with MSVC (#3832)
`ssize_t` is a posix type, msvc seemingly doesn't know about leading to
a build error with MSVC 2019

usage elsewhere in this files used the `py::ssize_t` type, which seems
to fix this
2023-05-15 11:59:19 -07:00
Larry Gritz adf95f683a build(deps): fmt 10.0 support (#3836)
fmt 10.0 was recently released, and it breaks a lot for us because they
have fully removed legacy support for automatically being able to format
anything that has an iostream `<<` operator. This facility was deprecatd
in 8.1 but could be re-enabled with FMT_DEPRECATED_OSTREAM, but even
that was removed in 10.0.

So this means that we had to write several explicit format handlers for
some types for use with format() and print().

Also, they are even more strict with sprintf/printf which don't honor
the custom formatters as far as I can tell, so in several cases I also
switched those to the std::format/print style.

Fixes #3835
2023-05-15 11:12:34 -07:00
Larry Gritz 5b59ff65e3 One more revision to synchronized Strutil::print (#3828)
This is a continuation/fix for #3825
2023-05-15 11:12:31 -07:00
Larry Gritz e29c89b136 cleanup(strutil): use forward properly for sync::print(). (#3825) 2023-05-15 11:12:26 -07:00
Larry Gritz fa5dd1b222 fix(psd): Improve memory efficiency of PSD read (#3807)
The PSD reader was written 12 years ago by a GSOC student and has
changed little since. The following is not a knock on that student, who
clearly did a good job if his code has survived mostly unomdified for
over a decade. In chasing down problems with handling extremely large
psd files, I've noticed some oddities and inefficiencies that need
fixing. It's not an emergency, so I'll handle it in pieces.

The item addressed by this patch is memory usage and thread concurrency.
It turns out that the reader allocates memory for the scanline reads as
it goes... and basically keeps it in the ImageInput until it's
destroyed, even though it will never actually be used again. I guess
it's just trying to save the next allocation if it reads the same
scanline again or on the next subimage? But this means that if you read
a really big psd image, it's basically doubling the memory use -- it
reads one copy into the user's buffer, but also holds on to this extra
copy for no reason. Also, a bunch of the decoding helper functions
implicitly use this memory, which means we lock a mutex for the duration
of read_native_scanline (which in theory should not be necessary since
all I/O is happening through thread-safe IOProxy calls).

So this patch does the following:

1. Remove both this retained scanline memory as well as some other
scratch memory from the ImageInput, and make it allocated and freed
local to read_native_scanline.

2. Change all the helper methods that used it implicitly so that they
are passed buffers to use. In many cases these have been changed to
`const` methods and in a few cases to `static`, making it much easier to
assure ourselves that they don't modify (or sometimes use at all)
anything in the PSDInput to do their task.

3. The result of these changes means that read_native_scanline doen't
need to modify any of the data methods of the class (though it does use,
without modifcation, some things set up in the course of open). Because
it's now non-mutable, we can also remove the mutex, now allowing
multiple threads to read scanlines from the same file simultaneously
without blocking each other.

4. Some other miscellaneous cleanup, including that some scratch memory
was allocated as std::string (!), whereas it should really be a
`vector<unsigned char>` or `unique_ptr<unsigned char>`, and also
changing some computations from double to float.

There is still some more work to do after this is merged. In particular,
I think now that scanline read is stateless / non-mutable with respect
to the PSDInput object, this is a candidate for adding a multi-scanline
read_native_scanlines method (replacing the default implementation of
looping and calling read_native_scanline serially for each scanline),
which should also be able to read multiple scanlines with some overhead
and allocations done once per block, and with blocks of scanlines
running in parallel using the thread pool. This should be a huge
efficiency gain when reading psd files. But it will wait until the next
patch.
2023-05-05 16:48:22 -07:00
Larry Gritz c903169614 Bump version after release 2023-04-30 22:51:32 -07:00
Larry Gritz 56449a9d72 Stage for v2.4.11.0 2023-04-30 22:50:12 -07:00
Larry Gritz d84fef0922 feat(oiiotool): expression eval NIMAGES gives current stack depth (#3822)
Based on a suggestion Matt Chaput on the oiio-dev mail list.
2023-04-30 11:09:31 -07:00
Edoardo DominiciandEdoardo Dominici 41ced5bf5b Fix float128 compilation of NVPTX backend for LLVM (#3823)
The latest version of libfmt began using the `__float128` type but this
is [not supported in the NVPTX backend for
LLVM](https://discourse.llvm.org/t/compiling-cuda-code-fails/61240/13).
A way to detect this particular platform seems to be to check both
`__CUDA_ARCH__` and `__clang__`.
I am not disabling it entirely on any CUDA target because NVCC 10+
understands `_float128` and generates instructions for it when tested on
godbolt.

Following up from https://github.com/OpenImageIO/oiio/issues/3809.

Co-authored-by: Edoardo Dominici <edoardod@sy1wse0003.al.com.au>
2023-04-30 10:44:18 -07:00
Larry Gritz c7e37e5c5c test: Change the few symbolic links to copies to help Windows (#3818)
Windows isn't smart about symbolic links. There were a few places in the
testsuite where we used symlinks to essentially de-duplicate test
reference images that were expected to be identical. But then the
resulting archive you get when you ask GitHub for a zip file of the
whole repo (which some people download to get OIIO source rather than
git clone) can't be unzipped correctly on Windows (at least not by
cmake's unzip command).

OK, so just change those links to full copies.

Fixes #3811
2023-04-25 17:04:46 -07:00
Jesse Y 561b1ed0f9 build: Fix incorrect branch name when cloning openexr-images for the tests (#3814)
The `openexr-images` repo was never updated after the default branch was
renamed to `main`. This will fix the following silent errors in CI:
```
Cloning into '/__w/oiio/oiio/build/testsuite/openexr-images'...
warning: Could not find remote branch master to clone.
fatal: Remote branch master not found in upstream origin
```

Additionally, the cmake attempted to symbolically link local repos like
`oiio-images` if they were found. Unfortunately this type of link will
fail unless running as admin on Windows (which is rare) and the
COPY_ON_ERROR directive did _not_ work here (cmake 3.24; weird;
sigh...). The output will now look something like the following:
```
-- Linking oiio-images from C:/Users/jesse/source/oiio-images
-- Link result failed to create symbolic link 'C:/Users/jesse/source/oiio/build/testsuite/oiio-images': A required privilege is not held by the client.
-- Copying oiio-images from C:/Users/jesse/source/oiio-images
```
2023-04-25 14:36:01 -07:00
AdamMainsTL 3c8ce0ed00 Support HIF extension (#3813)
I've come across some unsupported files from Canon cameras that have a
.hif extension. These are HEIC/HEIF files with a slightly changed
extension. I have no idea why Canon decided to do this. Without any
changes I am able to open the images, probably because it checks the
header, but I am unable to write to paths with a hif extension.

Some random articles/forum posts mentioning the HIF format in relation
to Canon cameras:
https://www.cameralabs.com/jpeg-vs-heif-canon-hif-comparison/
https://www.dpreview.com/forums/thread/4558661

https://www.reddit.com/r/canon/comments/kjc6xl/new_eos_r6_owner_here_photo_files_show_up_as_hif/
2023-04-24 22:03:20 -07:00
Larry Gritz 2e835bacdf build: ffmpeg 6.0 support (#3812)
It seems to work fine with the new 6.0 with no code modifications, other
than our cmake build misidentifying the version.
2023-04-22 23:15:37 -07:00
Larry Gritz 4646313d35 Refactor simd.h to disable Intel inrinsics when not on Intel (#3810)
Especially when compiling for Cuda.

Fixes #3809
2023-04-19 09:40:19 -07:00
Brad Smith 31bc1e6432 Fix building on OpenBSD (#3808) 2023-04-18 23:51:58 -07:00
Larry Gritz 534e47eef2 fix(psd): Handle very wide images (#3806)
When decoding RLE data, some arguments to decompress_packbits() were
inexplicably declared uint16_t (they were passed uint32_t arguments, and
I honestly don't know why we didn't get a warning all along). This
prevented us from correctly reading PSD images whose width was more than
64k, which I suppose are rare enough that it's not hard to understand
why this went unreported for so long.

But anyway, just changing those parameters to uint32_t does the trick.
2023-04-17 08:54:24 -07:00
Eric Mehl 8ec4a8dca3 Fix fast_exp2 with MSVC and sse4.2 (#3804)
I ran into the problem described in #2929 and did a little digging to
see if I could find the source of the bad color conversions. I tracked
it down to `fast_exp2()`
https://github.com/OpenImageIO/oiio/blob/a77e36250fadfb4c391688eb1df4b3dd88d5e367/src/include/OpenImageIO/fmath.h#L2050-L2080

and in particular the return statement on L2071. In the process of
trying to figure out what part of that return statement was going awry,
I found that separating the bitcasts to separate variables as in this
PR, the problem went away. All testing was done with the `color_test`
added in #3023.

It also succeeded when adding various `std::cout` lines to check what
the values of each computation were, so it does sound like a compiler
optimization that does or does not get triggered is the problem.

Unfortunately I don't know why it's not failing on the CI builds, I
double checked to make sure I'm using the same settings and flags. I
also tested on two different machines and get the same failures, and
success with this patch, on both.

One strange wrinkle is that even without this patch, color conversions
worked fine when using AVX2 for the SIMD mode.

Summary :
Previous results (without this patch)

- USE_SIMD=0 - PASS
- USE_SIMD=SSE4.2 - FAIL
- USE_SIMD=AVX - FAIL
- USE_SIMD=AVX2 - PASS

With this patch
- USE_SIMD=0 - PASS
- USE_SIMD=SSE4.2 - PASS
- USE_SIMD=AVX - PASS
- USE_SIMD=AVX2 - PASS

Visual Studio 2019 versions 16.11.32228.343, 16.11.33328.57 and
16.11.33423.256(same as current Github build runners) in RelWithDebInfo
mode.
2023-04-15 09:43:38 -07:00
Larry Gritz 5187a52dab fix(python): improve error messages of bad python array sizes (#3801)
For cases of calls like `ImageOutput.write_image(array)`, this improves
the error messages when the array dimensions don't match the size of the
image we're writing, in two ways:

1. For the case of 2D images where the dims don't match, print what the
array shape actually is and what was expected. That's more helpful than
just saying "can't figure out array shape" and printing the number of
dimensions (but not the shape).

2. A mistake caused a number of error messages to be substituted by a
cryptic "can't handle numpy array with noncontiguous channels", but that
was only supposed to be for one particular case; fix that.
2023-04-13 11:26:31 -07:00
Larry Gritz 65806259dd fix(raw): handle raw 1-channel raw images (#3798)
Fixes #3797
2023-04-13 11:26:18 -07:00
Larry Gritz f660d2d7fe Bump version after release 2023-04-02 08:43:29 -07:00
Larry Gritz 0b131b231b Stage for v2.4.10.0 2023-04-01 16:34:53 -07:00
Tom Knowles 448d05d51f fix(maketx): Add support for CDFs of bumpslopes channels (#3793)
Currently, if you run oiiotool with --bumpslopes and --cdf at the same time (or -obump:cdf=1), the CDF is only produced for the first four (of six) channels. The techniques described in Burley (2019) actually do apply reasonably to the squared derivative channels, so it's useful to allow all six channels to have CDFs here.

maketx and oiiotool-maketx tests updated with new relevant tests.
2023-04-01 12:42:02 -07:00
Larry Gritz c8559ea177 Testing: improve testing of maketx (#3748)
* Tests for maketx -u, --attrib, --sattrib, --cdf

* maketx was documeted to take --cdf as a simple flag, but was
  incorrectly implemented as requiring a (pointless) nonzero argument.
  Fix it and hope nobody was depending on the undocumented behavior.

* maketx -v arg never had any effect. Add it back.
2023-04-01 11:50:59 -07:00
Larry Gritz 5e386bc330 Document that OIIO builds fine with clang 16 2023-03-31 19:10:05 -07:00
Larry Gritz 9d933a75d1 CI: bump 'latest versions' test to the newest openexr release (#3796) 2023-03-30 23:41:42 -07:00
johnfeaandTuomas Tonteri d3c6fd2e4d Make project compile with clang 11.0.1-2 in Mac (#3795)
Co-authored-by: Tuomas Tonteri <e90@tuomastonteri.fi>
2023-03-30 23:41:38 -07:00
Larry Gritz 12931a4891 fix: unique_ptr type mismatch caught by sanitizer (#3790) 2023-03-12 00:53:21 -08:00
Larry Gritz 2f92fcb894 fix(gif): gif.h array overrun (#3789) 2023-03-12 00:09:41 -08:00
Larry Gritz 7fa327a634 docs: edit INSTALL to correctly reflect changed dependencies lately
There were still some bolded (indicating newly changed) dependency
minimums that actually were bumped in 2.3 and should have been
unbolded long ago.
2023-03-11 15:36:53 -08:00
Larry Gritz 9934ab38a9 ci: updates to runners, dependencies (#3786)
* Don't use deprecated ubuntu-18.04 runner. Switch to running on
  ubuntu-20.04, but use docker containers that supply ubundu-18.04.

* Bump 'latest' version of openexr, webp, pugixml.
2023-03-11 15:08:09 -08:00
Larry Gritz 3a0d7d068f fix(IC/TS): Avoid deadlock situations with file handle cache (#3784)
There turns out to be a way to get wedged into a mutual deadlock on
the file handle cache, with how get_texture_info on a udim pattern
checks to see if the attribute requested is present and equally valued
in all constituent files of the udim set. This hits the handle set
pretty hard, and if multiple threads are hammering the same sets and
rapidly cycling textures out of the cache, there can be trouble, it
seems.

Remedies in this patch:

* When it's trying to close files because the number of handles is too
  high, we already had it so that if we only exceeded the max_files
  limit by a little bit, we would simply try to get the lock, and
  abandon the attempt if somebody else is holding it, but if we are
  quite a bit over, then stay and wait for the lock to be released.

  In this patch, we make the that default behavior -- if we are over
  the limit and need to free some handles, simply try to get the lock,
  and if somebody else is holding it, leave it all up to them and
  return immediately. The pros of this are (a) snappier response by
  never waiting at this point, and (b) removing the possibility of a
  deadlock, because if you can't acquire the lock, you just move
  on. But the con is that lots of threads adding new files may run
  faster than the one thread who has the file and is trying to release
  files, so it's possible that the number of handles will exceed the
  limit by a wider margin now, but hopefully only momentarily.  (But
  note that this can be overridden with a new ImageCache attribute
  "max_open_files_strict", which if set to nonzero revert to the old
  behavior. At least for now, in case I am neglecting to understand
  some bad consequence of this change.)

* The recursive_mutex controlling access to the ImageInput in each
  tile cache record is changed to a recursive_timed_mutex, and when
  closing a handle by calling release(), instead of an unconditional
  lock, try acquiring a lock for 100ms. If it fails to do so, it may
  be in a possible deadlock, so just give up and move on. The only
  consequence is that maybe that handle isn't freed after all. It will
  then move on to the next one, not the end of the world, but at least
  it can't get stuck there.

* In find_file, eliminate the call to check_max_files -- it's not
  needed here, since it's also called by open(), which is the only
  time that new file handles might be opened. We just don't also need
  it again simply because we're adding a file to the cache.
2023-03-10 23:01:51 -08:00
Fabien Castan 8a0ac72b0f rawinput: fix typo on CameraElevationAngle (#3783) 2023-03-07 18:16:08 -08:00
Larry Gritz bc75a81fcf Bump version after release 2023-03-01 09:57:57 -08:00
Larry Gritz 246ee42759 CHANGES and stage for v2.4.9.0 2023-03-01 09:52:37 -08:00
Larry Gritz 7abc4faf89 Qt6 compatibility (#3779) 2023-03-01 09:11:42 -08:00
Larry Gritz 3954b098b4 api(ustringhash): make a public explicit ustringhash ctr from hash value (#3778) 2023-03-01 09:10:27 -08:00
jreichel-nvidia e191d3b9eb Add cmake option to disable the stacktrace functionality. (#3777)
Setting the cmake option OIIO_DISABLE_BOOST_STACKTRACE to ON disables the use of
Boost stacktrace at compile time. This avoids dependencies on helper libraries
like dbgeng.dll.
2023-03-01 09:00:54 -08:00
Larry Gritz b4b4dcd6e3 fix(ImageCache): Avoid bad IC stats when no files were read (#3765) 2023-02-13 13:57:30 -08:00
Russell Greene 92a34f8596 use check_cxx_source_compiles instead (#3774) 2023-02-13 13:57:09 -08:00
Larry Gritz c145b80833 Bump version after release 2023-02-13 09:01:31 -08:00
Larry Gritz f4b38d9c30 Stage v2.4.8.1 2023-02-13 08:59:19 -08:00
Larry Gritz a39692256b fix: race condition in TIFF reader (#3772)
* test: Add a corrupted test file

* fix(IC): upon tile read error, mark the file as broken

The idea is to keep fruitlessly reading from a corrupted file.

* fix: race condition in TIFF reader

TIFFInput::read_native_tiles had a very subtle race condition.  There
is a section where it has a task_set of decompression tasks that are
sent to the thread queue.  When the method ends, the task_set goes out
of scope, and its destructor will wait for all the remaining tasks to
finish. All fine, right? Except that other variables in the function
include unique_ptr's with allocated memory that the tasks need.  So
what can happen is that if the compiler generates the code such that
the destructor of the unique_ptr happens before the destructor of the
task_set, the memory that the unique_ptr held may be deallocated
before some of the tasks still running in threads have finished.

In practice, we seem only to hit this race condition for particular
cases involving corrupted files, because the early `return` seems
quite likely to run those destructors before all the threads are done,
but it was possible to encounter it for valid files as well, if the
timing is just right. Shocking that we never had it reported.

The solution is just to have an explitit tasks.wait(), which will
block until all the tasks have finished before hitting the actual end
of the method and letting the other destructors to run. And for the
"early return" case, change it to a break so that we go through the
wait call at the end.

I believe that this fix addresses TALOS-2023-1709 / CVE-2023-24472.
2023-02-13 08:38:19 -08:00
Larry Gritz 6a7e404804 fix(fits): Make sure to close if open fails to find right magic number (#3771)
There are two ways to fail the FITS magic number check: fail to read
the bytes, or the bytes don't match the magic number. It seemed
suspicious that we call close() for the latter but not the
former. Combine them into a single error response (they had the same
message, anyway).

Also, make sure FitsInput::init() fully clears some other data
structures.  Oversight?

I don't know if any of these things are real bugs, but they look
sloppy and potentially problematic, so fixing them up.
2023-02-12 21:32:49 -08:00
angusdavisadobeandLarry Gritz f222d05930 improve thread safety for concurrent tiff loads (#3767)
* Make lookups of const unordered_maps thread-safe

* added back deleted end brace

* clang-format

---------

Co-authored-by: Larry Gritz <lg@larrygritz.com>
2023-02-10 12:42:32 -08:00
Larry Gritz 209bb4c327 fix(targa): guard against corrupted tga files (#3768)
* Be more careful constructing strings from what we read in the header;
  corrupted files may make them not be zero-terminated.
  Fixes TALOS-2023-1707 / CVE-2023-24473

* Watch out for pixels with palette indices that exceed the size we
  allocated for the palette.
  Fixes TALOS-2023-1708 / CVE-2023-22845

* Check alpha_type for valid range.
2023-02-09 13:35:13 -08:00
jreichel-nvidiaandJoachim Reichel bd319821e8 Initialize OpenEXROutput::m_levelmode() in init(). (#3764)
Avoids conditional jump on uninitialised values in close().

Co-authored-by: Joachim Reichel <joachim.reichel@posteo.de>
2023-02-04 22:18:48 -08:00
Latios96 0ad9b297d8 Fix unresolved external symbol for MSVS 2017 (#3762) (#3763)
If char16_t is used as template argument, this leads to an unresolved symbol for MSVS 2017.
Use int16_t instead of char16_t in this case
2023-02-04 15:37:30 -08:00
Larry Gritz 1a72ae7c31 Bump version after release 2023-02-01 11:16:53 -08:00
Larry Gritz 4991ac482e CHANGES and stage for v2.4.8.0 2023-01-30 14:36:11 -08:00
Larry Gritz 069a1877af Fix CHANGES typo 2023-01-26 14:06:26 -08:00
Larry Gritz bed036cfd6 Update CVE designations in CHANGES 2023-01-19 13:52:32 -08:00
Brecht Van Lommel cf8d6bf5cd Fix wrong oiio:UnassociatedAlpha spec for PSD files (#3750)
Refactoring in #1641 incorrectly caused this to be set on the last layer
rather than the composite image as before. Now set it on the composite
image and every layer, as all of them use unassociated alpha.
2023-01-12 14:28:43 -08:00
Larry Gritz 8bb093b162 Comment out parts of libcineon that are not used by OIIO (#3747) 2023-01-08 19:24:16 -08:00
Larry Gritz d648187d04 Clarify comments in documentation of IBA::make_texture 2023-01-08 19:24:08 -08:00
Larry Gritz 0665bffad3 Additional testing and improved code coverage (and minor fixes) (#3745)
* Better Typedesc testing of 'tostring' with fmt style formatting
  commands, and fix a bug that uncovered.

* Refine 'make CODECOV=1' behavior

* Beef up python-imagecache test to test getpixels, more attribute,
  invalidate.

* Better testing of python IB construction from numpy array.

* testtex: Use correct guard to avoid compiling unused code for
  coverage analysis testtex: get rid of unused 3d warp code.

* Add texture-threadtimes test

* Eliminate redundant code in exroutput.c by implementing
  write_scanline using write_scanlines.
2023-01-08 19:23:57 -08:00
Joris NijsandJoris Nijs fdbf190e2b Add EXIF write support to PNG output. (#3736)
* Add Exif write support to PNG output.

Stores any Exif data from the given ImageSpec into the PNG eXIf chunk.

* add test for writing Exif data in png

* add test reference output for libpng versions not supporting the eXIf chunk.

* Update testsuite/png/ref/out-libpng15.txt

Co-authored-by: Joris Nijs <joris.nijs@esko.com>
2023-01-08 11:47:47 -08:00
Larry Gritz 3edc96fdea Docs: minor improvments in description of ociodisplay and others 2023-01-08 11:14:15 -08:00
Larry Gritz 2b663e0061 ImageSpec:set_colorspace() (#3734)
Sets color space metadata. While conceptually, the main job is to call
`attribute("oiio:ColorSpace",name)`, this is a central spot to add
logic that adjusts or removes other contradictory metadata.
2023-01-07 23:54:22 -08:00
Larry Gritz 161b2a4c12 Docs: for rtd, upgrade sphinx/breathe versions, use furo theme (#3737)
I think this looks better.

Also a few minor tweaks to typos and misquotes.
2023-01-07 23:52:07 -08:00
Larry Gritz 9d514db8c6 CI: Lock down to older icc so it's not broken (#3744)
The new 2023 one on the Intel site seems to require a glibc too new to
be compatible with the one on the ASWF CentOS-7 based containers, so
has been breaking our CI for a couple weeks.
2023-01-07 18:03:03 -08:00
Larry Gritz ad34901684 Testing: get rid of testtex's datatime query, for test consistency (#3741) 2023-01-07 11:59:42 -08:00
Larry Gritz cba5c59fe9 Add testing for maketx --lightprobe, fix bugs (#3732)
We never had a test for `maketx --lightprobe`, so add it to
testsuite/maketx.

Immediately discovered that it only worked correctly for float images,
fails for half or other types. Fix.
2023-01-07 11:59:08 -08:00
Larry Gritz 17daba2ec0 texture3d testing, fixes, refactoring, coverage (#3699)
* More extensive testing of texture3d: handle vs filename, subimages,
  >4 channels, closest sample interpolation.

* Fixes for tex3d > 4 chan that turned out to be broken.

* Some rearrangement for the >4 channel case

* Refactor and simplify accum3d_sample_bilinear so multiple data types
  all use the same templated code path.

* This all reduces the amount of untested code in OIIO by another 0.4%.
2023-01-07 11:59:00 -08:00
Larry Gritz 0433073464 Testing; better tests of environment mapping, minor fixes (#3694)
Would you believe we never had a testsuite test for environment
mapping?  Well, it wasn't totally untested, in the sense that OSL
testsuite had one, and obviously it's used in production all the
time. But OIIO's testsuite didn't have any tests of
TextureSystem::environmemt(). We now remedy that.

* Add testsuite/texture-env, contains several environment tests,
  including handles vs filenames, subimage selection, different interp
  and mip modes, ask for >4 channels.

* New CMake build option OIIO_TEX_IMPLEMENT_VARYINGREF can be used for
  testing to disable implementation of the old 1.x style of batch
  texture calls.  We don't use them, they are deprecated. This option
  give us a way to exclude them from code analysis, because we really
  don't care.

* Fix bug with >4 channels for environment batch shading!

* Avoid unnecessary spec lookup in TileID constructor.

* Avoid building testtex test_hash during code coverage -- it is an
  extremely specialized test, not run in the testsuite, it shouldn't
  really count againt good code coverage.
2023-01-06 23:25:12 -08:00
Larry Gritz 52e5d89129 Testing; Imagecache better testing coverage and some stats improvements (#3654)
* testtex: better control over temp file creation

* Additional texture tests to improve coverage of udim generation,
  and deadling with cache limits.

* Better ImageCache unit tests for perthread create/destroy and
  individual tile retrieval. Fix a bug in get_tile for nonexistant
  subimage or miplevel.

* Dead code removal: ImageCacheFile::udim_to_concrete() and
  find_file_no_add(), which were no longer called anywhere.

* IC stats: fix messed up 'slowest' list ordering when there are broken files

* IC stats: when stats level is high, enable printing of some stats that
  we previously skipped over when they were "uninteresting" (e.g., too
  little time spent on something, no problematic files, etc).

* IC testing: test a variety of get_pixels error conditions

* IC testing: more tests of IC::imagespec() and get_imagespec(), incluing
  error conditions.

* More get_texture_info query testing

* Minor bug fix for int-to-float data conversion in get_image_info

* Test IC query for resolution[3]

* Test IC::reset_stats()

* Fix ImageCache::reset_stats in cases where threads ended
2023-01-06 21:44:40 -08:00
Larry Gritz 7086a599fa CI/Testing: many improvements for testing and code coverage (#3730)
* When checking code coverage, don't abort for failed tests
* Rejigger imagebufalgo_test a bit for better IBA test coverage
* Test zover
* Have testsuite/oiiotool-fixnan test with deep images
* Add to the extisting --fixnan tests a test for 'error' mode.
* [Excluded from backport to 2.4] Make testsuite/oiiotool-color test all colormap names
* Test 2D filters in filter_test
* Exclude python scripts in src/doc from coverage analysis
* Remove redundant attribute-seting code from the python internals
* Remove unused python_array_code function
* Exclude some imported code from coverage testing
* Re-enable and improve coverage testing from 'make CODECOV=1'
* Exclude unused/unexposed parts of xxhash.cpp from compilation
2023-01-06 15:28:34 -08:00
Larry Gritz fae8da1a9f Fix long-broken ref images for texture-icwrite test (#3733) 2023-01-06 14:12:30 -08:00
Larry Gritz 76609e0a8c pbm: Fix for incorrect inverting (#3731)
We didn't have thorough tests of pbm/pgm/ppm files, add some.
That immediately uncovered a problem with pbp files.

By spec, pbm (1 bit) files use 1 to mean black, 0 for white.
Confusing, because pgm (grey) and ppm (rgb) use 0 for black.
2023-01-06 14:12:23 -08:00
Larry Gritz 400fb3dbd4 platform.h: set up macros for detecting MSVS 2019 and 2022 (#3727) 2023-01-06 12:43:40 -08:00
Larry Gritz e82040a939 typedesc.h: Extend TypeDescFromC template to the full set of pixel types (#3726) 2023-01-06 12:43:36 -08:00
Larry Gritz 628726e46a IBAprep should not zero out deep images when creating dst (#3724) 2023-01-06 12:43:26 -08:00
Larry Gritz 58e090e329 Fix static analysis warning about array extent 2023-01-06 12:43:18 -08:00
Larry Gritz ab8027fc42 oiiotool --pdiff: test, be sure to count it as making output (#3723)
We had no testsuite exercise of --pdiff, add it.

Along the way, I saw tha we were getting the "you didn't have any
output" warning when using pdiff, so fix that.

And some other minor changes: formatted output update, some other
tightening up of things.

A little bit of jiggling the contents of XYZtoLAB_color to work around
what I think is a compiler error with icx -- it was generating NaNs
for reasons I was unable to understand or fix, but not if I rearranged
the code slightly. All the other compilers and versions had correct
behavior.
2023-01-06 12:00:12 -08:00
Larry Gritz 417155cc18 BMP: set colorspace to sRGB (#3701)
Seems like a reasonable assumption for BMP files.  It's not strictly
correct -- there are header fields on V4 and V5 BMP files that
communicate color primaries and gamma, but honestly, I do not have any
idea if anybody uses them or whether they're more misleading than
helpful. For now, assuming that a BMP file is meant for output on
an sRGB display seems like it's likely to be true.
2023-01-06 11:29:10 -08:00
Larry Gritz 18caee105a Bump version after release 2023-01-05 23:39:20 -08:00
Larry Gritz b178a54ee3 CHANGES and stage for v2.4.7.1 2023-01-03 19:05:13 -08:00
Larry Gritz 91c3a7c4c4 CMake config should not include a find of fmt if it's internalized (#3739) 2023-01-03 18:12:54 -08:00
Larry Gritz 5590f2403b CI: Temporarily lock fmt to 9.1.0 because its master seems broken (#3738)
Investigate later. For now, this is necessary for us to pass CI.
2023-01-03 17:08:44 -08:00
Larry Gritz 6f684e6261 Update ref output 2023-01-03 17:08:19 -08:00
Larry Gritz 0cafbcd471 Fix typos 2023-01-03 11:41:38 -08:00
Larry Gritz 3fdee625f4 Move ARM_NEON definition and fix possible double define (#3735)
It should not have been set in platform.h (inside the cpuid function!)
in the first place. And apparently, though this was ok for Windows ARM,
on Mac ARM it's an error because that symbol is already defined.
So only redefine it if it's currently undefined. And move the whole
check and definition into simd.h where all the other ARM_NEON stuff
lives.
2023-01-03 11:41:15 -08:00
Larry Gritz 9e94856ff2 Fix date 2023-01-01 09:42:31 -08:00
Larry Gritz 24f253cce3 CHANGES and stage for 2.4.7.0 release 2022-12-31 23:45:00 -08:00
Larry Gritz fcc6cfdf9b Make sure to retrieve oiio-images tests data specific to this branch 2022-12-30 09:34:30 -08:00
Larry Gritz e9cfbfbce8 Retroactively fix release notes to document TALOS-2022-1631/CVE-2022-41649 2022-12-24 15:38:44 -08:00
Larry Gritz be1fd307c2 Build: fmt external version flexibility (#3598)
* Build: fmt external version flexibility

The current default behavior is to
1. Check if there's already a copy of fmt found.
2. If not (or if BUILD_FMT_FORCE is ON), download it locally.
3. Copy the relevant fmt .h files as part of the OIIO install in
   OpenImageIO_ROOT/include/OpenImageIO/detail/fmt

This patch adds a new INTERNALIZE_FMT option, which defaults to ON,
whch is the old behavior. But if set to OFF at build time, the fmt
headers will NOT be copied into OIIO's install area (instead, it will
have dummy files that in turn include the real ones).

Set INTERNALIZE_FMT to OFF if you are really sure you want users of
OIIO to use the system install of fmt and not have OIIO install a new
copy.

When an externalized fmt is used, also make sure our exported cmake
config files cause the downstream user to find fmt and pass on the
dependency properly (necessary because strutil.h actually requires
properly including fmt headers).

Eliminate extraneous include_directories of fmt

Bump the auto-download version of fmtlib to 9.1
2022-12-24 13:59:07 -08:00
Larry Gritz bf4e5a869e ustring.h: cuda guards (#3718)
Hide from Cuda some things that can't possibly work in Cuda.
2022-12-22 16:30:07 -08:00
Larry Gritz 065d36c756 Add testsuite coverage of igrep utility (#3715)
Add exception safety in igrep test.
2022-12-22 16:30:07 -08:00
Larry Gritz c8d49a4358 Add a test of the 'term' pseudo-output (#3714)
A few minor fixe to the term code, add a "term:filename" optional hint
to redirect output rather than go to stdout, and also change to the
new std::format notation for output.
2022-12-22 16:30:07 -08:00
Larry Gritz 39120c722d ARM: Fix signed/unsigned simd mismatch in vbool4::load (#3722)
Fixes #3721

Please read the comments in #3721. This is the "local" fix for the
build break due to the type mismatch. It is a band-aid. And it may be
the best solution for the 2.4 branch if we don't want to potentially
break ABIs by changing the definition of any public types.

Still pending is to examine the issue of whether it was a mistake to
define vbool4 storage for neon as uint32x4_t or if we should change it
to int32x4_t to better match the non-simd reference implementation.
After debating that (and identifying somebody with access to an
ARM-based machine to test the solution for us), we may return to
tackle this more fundamental change.
2022-12-22 16:28:40 -08:00
Larry Gritz fc2c2615d9 IOProxy read/write error handling improvements (#3712)
IOMemReader::pread catch out-of-range read positions.

Fixes #3711

Along the way, I noticed that the system pread & pwrite return a
ssize_t rather than a size_t as our IOProxy methods do, so I need to
catch the negative value returns that they use to indicate errors.
2022-12-18 11:54:23 -08:00
Larry Gritz 4c1bdcc752 Build: Suppress warnings about deprecated std::codecvt_utf8_utf16 (#3710)
Another fix for the latest Apple clang, continuing #3709 (I missed
these other spots).
2022-12-17 17:51:59 -08:00
Larry Gritz af3b98c344 Build: Suppress warnings about deprecated std::codecvt_utf8_utf16 on Apple clang (#3709) 2022-12-17 17:51:53 -08:00
Larry Gritz 6ec28a05d3 Revise changes to add a CVE that was fixed 2022-12-17 17:51:06 -08:00
Larry Gritz 7c4253d9fc CI: Fix iinfo test so it works on windows (#3706) 2022-12-11 16:09:56 -08:00
Larry Gritz 7d73c62e8b Excise the last instances of unsafe sprintf (#3705) 2022-12-11 12:11:25 -08:00
Larry Gritz 2a4a1505e4 Remove useless test in hdrinput (#3704) 2022-12-11 12:11:18 -08:00
Michael Oliver 80ef5cd65e build_openexr.bash: bump default version to 3.1.5 (#3703)
bump to 3.1.5 for vfxreferenceplatform cy2022
2022-12-11 12:11:08 -08:00
Larry Gritz 6617e8c865 CI: Fix broken Mac CI with proper numpy install (#3702)
Something changing in homebrew caused CI on the macos11 test case to
fail, starting a few days ago. This fixes.
2022-12-08 16:23:43 -08:00
Larry Gritz 0ba31990fc Refactor common parts out of iinfo and oiiotool printinfo, testing (#3688)
* There was lots of duplicated code between iinfo and `oiiotool -info`.
  Refactor much of that into a new src/libOpenImageIO/printinfo.cpp.
  These are internal functions, no change to public API.
* Test iinfo --hash, --stats, and with nonzero origin and full size
* Test iinfo and oiiotool --dumpdata of deep image
* Test iinfo for subimages, mips, -f, -s
* Some conversion to new print instead of printf

There is probably more such refactoring to do later, I did the easy
parts for now and that's a start.
2022-12-04 11:14:30 -08:00
Larry Gritz 5fd50a69be span minor improvements (#3685)
* Make sure the cspan alias also allows the Extent template argument.

* Add a custom formatter for {fmt} to print spans, like we did for
  Imath types.
2022-12-04 10:21:25 -08:00
Larry Gritz fddc816e80 Bump version after release 2022-12-04 10:21:25 -08:00
Larry Gritz f15d4f4f2d CMake: Adjust how version overrides work (#3653)
Kai Pastor (dg0yt) made an important observation that the way I
recently made OpenImageIO_VERSION be a cache variable might lead to
unexpeted behavior by inadvertently retaining a version number upon
recompiles if the cache itself was not cleared, and this can happen
unexpectedly even when the user isn't trying to override the version.

This patch changs the behavior as follows:

You must use the special `-DOpenImageIO_VERSION_OVERRIDE=...` to
override the version.

  * if you do so, you are playing with fire and get what you deserve
    if you misuse it or change branches and don't remember to clear
    the cache.

If you do a normal build (without _trying_ to override the version),

  * you will get the real version number because it IS NOT cached
  * if you switch branches, you'll always get the right version number
  * ...but switching branches without clearing the cache can still, as
    always, have other subtle behavior differences versus doing a
    truly fresh build from scratch.

So in short, it still allows a way to override the version if you
really want to, but if you are not trying to do that, you can no
longer get yourself inadvertently into unexpected trouble.
2022-12-03 22:36:58 -08:00
Larry Gritz d737268c82 Bump to 2.4.6.1 to fix readthedocs generation 2022-12-03 22:00:13 -08:00
Larry Gritz 847481997d Fix broken version designation in docs (#3698) 2022-12-03 21:56:22 -08:00
Larry Gritz b06d2aae8a CHANGES, stage for v2.4.6.0 2022-12-01 14:40:09 -08:00
Larry Gritz f86e0999e6 CI: test against latest webp, and deal with its master->main repo change (#3695)
Also be more robust to the libheif and libde265 repos being
occasionally down.
2022-12-01 14:40:09 -08:00
Larry Gritz 745a071080 Fix docs typo 2022-12-01 13:11:04 -08:00
Gerdya df783ef8b9 Some fixes for compilation with MSVC for Windows ARM64 (#3690) 2022-12-01 10:47:45 -08:00
Larry Gritz 190e8f3fef oiiotool --dumpdata : fix channel name output (#3687)
We weren't copying the full spec, so didn't get the channel names.
2022-11-25 18:54:11 -08:00
Larry Gritz 0df4bbd478 oiiotool --point fix problem when there's no alpha (#3684)
We were over-allocating the color vector, and that was throwing off
the operation of IBA::render_point for cases where the image had no
alpha channel.
2022-11-25 18:53:46 -08:00
Larry Gritz f7c0402f7d Catch possible exception, identified by static analysis (#3681) 2022-11-19 09:30:23 -08:00
Larry Gritz e210d934a9 DPXColorConverter.cpp: exclude unused portions (#3682)
Many parts of this imported file are unused by OIIO. `#if 0` them away,
so they aren't part of static analysis or code coverage.
2022-11-19 09:30:15 -08:00
Larry Gritz bf85b2eda8 PSD reading: don't reject padded thumbnails (#3677)
When reading PSD file, if reading the thumbnail doesn't pass basic
sanity checks, we consider that a hard error reading the file.  One
check that we do is to make sure that our computation of the byte
width of the uncompressed thumbnail (`bpp/8 * width`) matches what the
file says the `widthbytes` is.

BUT... it seems that it might round up to an even (or maybe 4-multiple?)
of columns, presumably for scanline alignment reasons. And so we were
considering whole PDF files unreadable if they fell into this case.

This PR primarily loosens the test to allow some padding up to a
multiple of 4.

Fixes #3658
2022-11-19 09:29:55 -08:00
Larry Gritz 99f17b8349 IFF output safety (#3676)
* Maya IFF documentation says IFF file has max resolution of 8192, and
  our implementation only allows writing RGB and RGBA, so check these
  limits when an IFF file is opened for output.

* Make sure scratch space allocates enough for tile padding.

* Check for non-zero image origin coordinates (which are not allowed
  in IFF files).

* Change some 16-bit loop variables to uint32_t to avoid possible
  overflow.

Fixes TALOS-2022-1654, TALOS-2022-1655, TALOS-2022-1656
2022-11-19 09:29:33 -08:00
Larry Gritz c18b3ef72c IOProxy support for IFF files (#3647) 2022-11-19 09:29:24 -08:00
Larry Gritz 3a71e8a162 BMP output safety (#3673)
In open(), check for non-zero image offsets, which is not supported by
BMP, and issue an error if found. If the spec passed in has nonzero
spec.y, other code in the write functions would fail because they
assumed spec.y == 0 and could therefore access memory incorrectly.

More generally, also put checks in the write functions that issue
errors and take early outs if they find that they are called on a
BMPOutput that is not currently open, for example if open() fails but
the user doesn't check the return codes and proceeds to call the write
functions anyway.

This addresses TALOS-2022-1653 / CVE-2022-43594-CVE-2022-43595
2022-11-19 09:22:20 -08:00
Larry Gritz 1413022687 DPX output: fix write errors (#3672)
There was a subtle error where we had a reference to an ImageSpec for
one of the subimages, confusingly called m_spec, which we altered, but
then didn't make the same change to the this->m_spec, and in a later
spot we referenced the `m_spec` meaning the one in `this`. This could
lead to a crash.

Fix, but not only that, also rename to avoid the confusion. `spec0` is the
alias we us for the spec for subimage 0, and `spec_s` is the alias we
use when referencing subimage S, and we really never use m_spec
anymore to avoid any confusion. This should make it easier to reason
about this code in the future and avoid these kinds of mistakes.

A second error resulted from the situation where a failure in open()
would return before one or both of m_buf or m_tilebuf were allocated.
If the return status of open() were ignored and the caller
subsequently attempted calls to write_scanline or write_tile, invalid
memory could be accessed. Fix this with a variety of guards not only
based on the allocation status of these buffers, but also issuing
errors (and exiting early) from write_scanline or write_tile if they
are called on an ImageInput that is not in fact open.

Addresses TALOS-2022-1651 / CVE-2022-43592 and 
TALOS-2022-1652 / CVE-2022-43593
2022-11-19 09:22:07 -08:00
Larry Gritz 7b2f76dc7c PSD: Fix thumbnail extraction for PSD files (#3668)
Fixes #3660

In investigating this issue, I also noticed that now that IOProxy
support can be relied on, the old code that in the psd reader that
directly fumbles with libjpeg is not needed and can be replaced by
just a couple of lines to make an ImageBuf read from an IOProxy.

And it fixes the bug, too. So I'm not even going to try to figure
out what was going wrong with the old code.
2022-11-19 09:21:29 -08:00
Larry Gritz e66ff05314 Try to squash warning in gcc 12.1 + C++20 (#3679) 2022-11-17 22:42:53 -08:00
wayne-arnold-adsk 5d23f2d69f Avoid sanitizer warning unsigned integer overflow (#3678)
/Volumes/DATA/local/S/Maya_master_CI_sanitizer/build/RelWithDebInfo/src/Components/ExternalLibraries/OpenImageIO/install/include/OpenImageIO/string_view.h:252:43: runtime error: unsigned integer overflow: 0 - 17 cannot be represented in type 'unsigned long'
    #0 0x10d0adf61 in OpenImageIOMaya_v2_4::basic_string_view<char, std::__1::char_traits<char> >::compare(OpenImageIOMaya_v2_4::basic_string_view<char, std::__1::char_traits<char> >) const string_view.h:252
2022-11-17 18:02:16 -08:00
Larry Gritz 344f816b2d Fix formatting 2022-11-16 10:47:34 -08:00
Fabien Servant @ TCS 45592eaeab [raw] update exif orientation with raw flip if user flip is set (#3669) 2022-11-16 10:40:20 -08:00
Larry Gritz 5d9ff6294a DPX input: Comment out assertions (#3674)
We shouldn't abort here, we should return and handle the error better
(which we do).
2022-11-15 08:04:41 -08:00
Larry Gritz 13ed669ae5 ImageBuf+IOProxy vs ImageCache subtle fixes (#3666)
I uncovered a very subtle problem that can happen with the interaction
between ImageBuf, using an IOProxy, and the underlying ImageCache.
Remember that when using an IOProxy, it is critical that the lifetime
of the proxy outlasts any ImageInput, ImageBuf, or ImageCache that was
told about it.

Consider the following code:

    IOProxy proxy(...);   // temporary proxy in this local scope
    ImageBuf A ("foo.exr", 0, 0, proxy);

We've set up an ImageBuf that will read from an IOProxy.  Behind the
scenes, it made an ImageCache entry that remembers the IOProxy, as it
has to, since it needs to use that proxy for subsequent reads.
Now we read the image, and we use the `force=true` parameter to
force an immediate read of the file:

    A.read (0, 0, true);

It reads from the proxy. But the IB and the underlying entry in the IC
still know about the proxy. But in the user's mind, they have fully
read the image, will never read from it again, so of course (they
think) it is safe to close or destroy the proxy, knowing that they
made it last past its use:

    proxy.close();

But -- oops! -- the cache entry still has a pointer to the proxy, and
even though it won't need to read from it again, it still will access
it, close it, etc., but the user's proxy may by that point be out of
scope.

This is *technically* not a "bug" in the sense that it is the user who
violated the contract by closing or destroying the proxy before its
last use by anything they passed it to. But in context, it's very easy
to be confused by this -- the user thinks that the only observer of
the proxy is the ImageBuf, and they're done using the ImageBuf at that
point, but because they don't explicitly mention an ImageCache, they
don't realize that the ImageBuf passed the proxy reference along to
the underlying IC that could be backing any ImageBuf.

It's the user's fault in some sense, but let's just say that we have
given them an "attractive nuisance."

That's a long bit of background explanation, but I wanted to force
myself to explain it clearly and make sure it was spelled out in the
commit comments. Now here is the fix:

* When IB::read does an immediate forced read involving an IOProxy,
  after the read is complete, tell the cache to invalidate the entry
  for the file so that it no longer retains a pointer to the proxy.

* When an IB itself is destroyed or cleared, if it used an IOProxy,
  also invalidate the IC entry for that file.

* Unrelated cleanup: avoid a redundant invalidate call in init_spec().
2022-11-14 20:22:10 -08:00
Larry Gritz efffa5f24d OpenColorIO 2.2 support -- preliminaries (#3662)
* Make it so that when we build against OCIO 2.2, it is possible to
  specify the built-in configs. The logic had previously precluded
  this, because at one point it checks to see if the passed config or
  contents of env $OCIO was an existing file. Now you can set OCIO to
  "ocio://default", for example, and it will be used by OIIO.

* Expose getAliases (I think that has been there for a while but we
  didn't expose in in our ColorConfig wrapper).

* Expose isColorSpaceLinear (new to OCIO 2.2)

* New OIIO global getattribute query: "opencolorio_version" returns the
  human-readable version string (such as "2.2.0").

* Some miscellaneous other cleanup in color_ocio.cpp

* Change in color methodology for test suite: Previously, for every
  call to oiiotool in the testsuite, we passed a `--colorconfig`
  argument to oiiotool pointing it to the sample colorconfig that we
  ship in the testsuite. Here, I'm changing it so that the cmake setup
  for tests sets the OCIO env variable for all tests, so no explicit
  --colorconfig is necessary, and thus you won't see a path to the
  config in any of the test output files if they need to echo the
  command line arguments (and you'll see several test outputs altered
  in this way). This is a prelude to later changes that will use the
  built-in configs themselves for tests, when available.

More interesting changes coming in subsequent PRs.
2022-11-14 20:22:02 -08:00
Larry Gritz 811a321f74 Zfile write safety (#3670)
When writing a zfile, anything that causes open() to fail will leave
m_tilebuffer at 0 size. Subsequent calls to write_tiles, and also
to close (which cleans up unwritten parts of the buffer at the end)
did not check for this condition and would access out of bounds memory.

While I was in there, I converted the zfile.cpp error messages to the
new formatting convention.

Fixes TALOS-2022-1657
2022-11-14 20:21:46 -08:00
Larry Gritz d08ca20fe1 CI: No longer add the ppa:ubuntu-toolchain-r/test repository (#3671)
Lately, it has been experiencing intermittent availability problems
that causes our CI to fail while setting up dependencies.

What happens if we don't use the problematic ubuntu-toolchain-r at all?

Nothing, it seems. So eliminate it.

I think that once upon a time, it was necessary to add this repo to
get certain new packages? But maybe they are mainstream enough now
that it's not necessary to add this repo? In any case, it doesn't seem
to hurt anything, it's one less moving part that can't fail if it's
not there.
2022-11-14 14:10:19 -08:00
Larry Gritz 14748d5aa1 Expose OIIO::Strutil::print in the main OIIO namespace (#3667)
We use this all the time in our internals, and I'm tired of having to
write Strutil::print. Too verbose. By putting it in the main OIIO
namespace, OIIO internals can reference as simply print(), and
external users now have a choice of saying Strutil::print() or
OIIO::print().
2022-11-14 08:41:13 -08:00
Larry Gritz 8bcc715235 IOMemReader ctr should take const buffer pointer (#3665)
The ctr is inline, so I don't think it breaks backwards link
compatibility to make this change, so I do intend to backport it.
2022-11-14 08:41:04 -08:00
Larry Gritz ba3f204158 Fix type mismatch warning in JPEG code (#3664)
Fixes #3663
2022-11-12 13:53:21 -08:00
Larry Gritz 43f806d53c Additional Strutil tests (#3655)
Better coverage of edge cases for escape_chars/unescape_chars, stoi
hex conversion, strtod, stod, freestanding c_str(), parse_nested
failure cases, base64_encode, debug.
2022-11-12 13:52:57 -08:00
Larry Gritz 30571a094c Filesystem::is_executable and find_program (#3638)
Also cull some cruft that no longer is used for OIIO >= 2.4
2022-11-12 13:52:24 -08:00
Larry Gritz 8f9bf9973b Fix ColorConfig::getColorSpaceDataType null ptr deref when no OCIO config is found (#3652) 2022-11-12 13:51:58 -08:00
Larry Gritz 750f89cd7f CMake: use of ${PROJECT_NAME} must be after call to project() (#3651) 2022-11-04 17:12:00 -07:00
Larry Gritz 34ea2fb548 oiiotool testing and minor subimage/miplevel fixes (#3649)
* Add casual tests of oiiotool with no args (print brief usage message)
  and when an unknown command.

* Also changed the meaning of -q (quiet mode) to be more quiet -- in
  particular, not to print the full help message for errors when quiet
  mode is used, only print the error.

* oiiotool test sequence errors.

* Test (and fix) --selectmip and --subimage with out of range indices
2022-11-04 17:09:04 -07:00
Larry Gritz 62ff91df5c CI: Test against OpenColorIO 2.2 (#3644) 2022-11-01 23:18:40 -07:00
Larry Gritz 14b6c11847 CI: adjust when workflows are run to cut needless CI runs (#3645)
Changes:

* Scorecards and analysis -- allow newly launched job to cancel
  running old job from the same PR.

* Scorecard only runs on main repo, no need to run on forks.

* Nightly CI only runs on main repo, no need to run on forks.
2022-11-01 23:18:28 -07:00
Larry Gritz c794d877e3 Analysis: more test related fixes to try to increase code coverage (#3643)
* Test oiiotool control flow syntax mistakes
* Test oiiotool --set with array of strings
* oiiotool: better adjust_geometry unit testing

Helper utility additions:

* oiiotool --no-error-exit

  `--no-error-exit` causes an error to not exit immediately, but
  rather to try its best to continue execuing command line
  operations. Use with caution! This is mainly for unit tests and
  debugging.

  `--unittest` also turns this on automatically, so that tests that
  are probing failures don't cause an exit.

* unittest.h: If OIIO_UNIT_TEST_QUIET_SUCCESS is defined, don't print
  anything extra for unit test success
2022-11-01 23:18:18 -07:00
Larry Gritz 9e987d5e5e Squash some alignment problems caught by ubsan (#3646) 2022-11-01 23:18:05 -07:00
Larry Gritz e5bffd8a84 maketexture: Ensure proper setting of some metadata (#3634)
Make extra sure to clear the oiio:ConstantColor, oiio:AverageColor,
and oio:SHA-1 metadata when writing textures, if those things are not
going to be set.
2022-11-01 23:17:45 -07:00
Larry Gritz 6aab6975f5 Analysis: Add tests to improve code coverage of oiiotool (#3637)
* Unit test adjust_geometry
* Tests of --set for various implicit and explicit types not
  previously covered in the testsuite
* Comment out Oiiotool:get_position, which seems to be unused
* Exercise --iconfig for explicit types
* Add test for --origin and --originoffset
* Add test for --ociodisplay
* Add test for --unmip and --selectmip
2022-11-01 23:16:45 -07:00
Larry Gritz c7c2830b45 Strutil: trimmed_whitespace (#3636)
It's similar to trim_whitespace, but returns the trimmed result, rather
than operating in-place on a `string_view&`.

Also add unit testing of trim_whitespace and trimmed_whitespace
2022-11-01 23:16:23 -07:00
Larry Gritz e6b52502ad Bump version after release 2022-10-31 18:55:33 -07:00
Larry Gritz 1e70f7862c CHANGES and stage for 2.4.5.0 2022-10-31 18:07:20 -07:00
Larry Gritz 5563449f01 TIFF: guard against buffer overflow for certain CMYK files (#3632) 2022-10-23 22:55:08 -07:00
Larry Gritz 5bfe48a16d PSD: protect against corrupted embedded thumbnails (#3629) 2022-10-23 14:00:28 -07:00
Larry Gritz 79824feaa4 TIFF: guard against corrupt files with buffer overflows (#3628)
Along the way, improve the runtest.py script by giving the
info_command() fuction the same silent, concat, and failureok
parameters that the oiiotool() function has. (This lets individual
tests assemble iinfo command lines with a little more flexibility.)
2022-10-23 14:00:22 -07:00
Larry Gritz 1a53aa4ade DDS: fix crashes and add tests (#3625)
* In the case of DDS cubemap files where a cube face was not present,
  we were filling m_buf with 0 bytes before allocating it.

* Add check for invalid bits per pixel.

* Add regression test for another bug that was perviously fixed in
  2.4.3.
2022-10-23 13:59:41 -07:00
Larry Gritz 85eae966f8 Fix EXIF bugs where corrupted exif blocks could overrun memory (#3627)
In one case, we actually had a check for this, but an assignment to an
int made the nonsensical offset appear negative, and we only tested
whether the necessary offset it was bigger than the buffer size.
Keeping it as (unsigned) size_t makes the test work as intended.

In another case, there were several places where we never checked that
we were staying within the exif block, and here we address this by
changing the utility decode_ifd so instead of passing it a pointer to
the ifd, it passes the offset (the pointer turned out to always be
inside the buffer) so it can check the extent for subsequent accesses.

Also some fixes related to squashing undefined behavior sanitizer
cases.
2022-10-22 12:48:08 -07:00
Larry Gritz feb2c9c46f RLA: fix potential buffer overrun (#3624) 2022-10-22 12:48:00 -07:00
Larry Gritz 3361e8d89b Custom fmt formatter for ustringhash prints the string, not the hash (#3614)
Also, change `operator<<` to output the string, not the hash itself.
These changes help push us more toward the original intent of
ustringhash being a drop-in replacement for ustring, any time it's
more desirable to be using around the hashes rather than the pointers.
2022-10-22 10:22:19 -07:00
Larry Gritz b288f3ada9 Improve oiiotool test coverage (#3626)
* oiiotool tests for expressions var() and getattribute()

* Make sure we test oiiotool IMG[] expressions and several specific
  special attributes to retrieve.

* Add coverage of oiiotool --keyword and --clear-keywords
2022-10-22 10:22:09 -07:00
Larry Gritz b971489267 Targa: String overflow safety (#3622)
Added utility functions safe_string_view and safe_string to strutil.h.
2022-10-21 09:03:54 -07:00
Larry Gritz 2b542b92c6 BMP: protect against corrupt pixel coordinates (#3620)
When reading the image (which can have signals to jump around in the
array), we checked for out-of-bounds x coordinate, but not y, and some
corrupted files could overrun buffers as a result.
2022-10-21 09:03:45 -07:00
Larry Gritz 2735f38b42 CI: eliminate xxhash and farmhash code from coverage analysis
Because we're not the originators of the code and we use only a tiny
subset of what's in those files.
2022-10-21 09:03:36 -07:00
Larry Gritz 37bb86d116 oiiotool: New metadata expression syntax (#3619)
The existing syntax `TOP.name`, if the name wasn't found, produced
an error.

This PR adds another syntax: `TOP[name]` which is identical if the
named metadata is found. But if not found, this syntax just evaluates
to the empty string, with no error.
2022-10-21 09:03:29 -07:00
Aras Pranckevičius 8701cf7dd0 Docs: write Windows build instructions (#3602)
I recently wrote down how to build OIIO from source for myself (https://gist.github.com/aras-p/6497703c9b52f67761e6191343e43f7b), and maybe a slightly cleaned up version would be good to put into actual docs.
2022-10-20 08:46:28 -07:00
Larry Gritz cc933a0ff7 Fix missing getattribute of limits:channels and limits:imagesize_MB (#3617)
I think it was just inadvertently left out when these were first added.
2022-10-20 08:46:20 -07:00
Larry Gritz 65c61ca759 Testing: optimize oiiotool-control test (#3618)
This test was taking almost 30 seconds to run, without a lot of images
being read or written. Turns out it was just a large number of separte
oiiotool invocations, and the overhead of all those shells and
programs launched adds up. Most of them were just firing up oiiotool
for the sake of doing an `--echo` to print things. A little bit of
restructuring to make fewer oiiotool invocations (each one doing a
bunch of echo commands, each testing a different thing) cuts the time
for the whole test by 50%.

I also made the runtest.py script allow certain test debugging by
letting a test set the `wrapper_cmd`, and if so, will prepend every
oiio utility launch with it. For example, a test could say
`wrapper_cmd='time'` to time every command.
2022-10-20 08:46:00 -07:00
Larry Gritz 3faa66b592 oiiotool: Add unit tests, minor internals utility refactoring (#3616)
Add a hidden --unittest command to oiiotool, only functional for Debug
builds, which enables additional testing of internal utility funcions
and other things that are difficult to fully exercise in the testsuite
from normal oiiotool commands (could be done, but would take tons of
additional tests to get into particular deep edge cases).

Prototype by adding unit tests for scan_box. More will be added later
now that the mechanism exists.

Simplify string_to_dataformat

Make sure to use --list-formats and --runstats during testing.
2022-10-19 13:06:35 -07:00
Larry Gritz 09bba709c5 Testing: eliminate redundant code in Python IBA bindings (#3615)
Also add a test for sub(imagebuf,tuple) that we didn't have before.
2022-10-19 13:06:21 -07:00
Larry Gritz 9379097d7c Add a test that forces stats to be computed (#3612)
Increases code coverage for dynamic analysis and coverage metrics.
2022-10-18 08:47:09 -07:00
Larry Gritz 58a51a3705 Testing: testsuite/iinfo -- make it compute stats, use MIPmaps (#3613)
Better coverage of the functionality of iinfo
2022-10-18 08:47:02 -07:00
Larry Gritz ab887c5c76 Testing: update cineon test image 2022-10-17 11:04:51 -07:00
Larry Gritz 521a6ba64c Fix exr core test options (#3610) 2022-10-17 11:04:40 -07:00
Larry Gritz 6e39b13e78 CI: Sonar analysis should exclude stb_sprintf.h (#3609)
It's not really "our code", and we use very little of that file, so
it's not helpful to include it in coverage or other analysis.
2022-10-16 22:33:23 -07:00
Larry Gritz 69917346c5 Testing: make a test specifically for iinfo (#3605)
Believe it or not, iinfo was never run in the testsuite before this!
2022-10-16 22:33:16 -07:00
Larry Gritz 9d2f6717fa Test fixes (#3608)
* We mis-named color_test, and that caused it to never get run!

* imagespeed_test is meant for benchmarking only, run by hand.
  We don't make a testsuite test, so don't even build the source
  (which would never be counted for code coverage because it doesn't
  run) during CI.
2022-10-16 22:33:04 -07:00
Larry Gritz b1513e8c43 Improve cineon build and test (#3607)
* Add a test for cineon -- we never directly tested it before

* Don't compile code used only for writing. We don't supporting
  writing cineon, so there is no point compiling the cineon module
  used only for writing.

* And of course, once cineon was in the testsuite, we immediately
  found a problem via the sanitizers! So fix buffer overflows when
  reading FilmEdgeCode in Cineon.  (And clean up the equally sloppy,
  though not technically buggy, code in DPX as well.)
2022-10-16 19:29:08 -07:00
Larry Gritz fc94095738 Testing: test both openexr old and core versions (#3604)
On any one platform, our testsuite was only testing the old C++ and
the new C core exr implementations.

Rig it to run the openexr-oriented tests twice -- once in each state
(when using OpenEXR new enough to support the core library).

Doing this cleanly required adding SUFFIX and ENVIRONMENT optional
parameters to the oiio_add_tests utility macro. Once that was added,
the texture batch testing could be implemented that way as well,
removing a bunch of hackier special purpose code.
2022-10-16 19:29:02 -07:00
Larry Gritz 54224dce05 Static analysis related fixes (#3603)
* Protect against 0-sized allocation
* Exception safety in IffOutput destructor
* Using sonar.coverage.exclusions as a better way to exclude files
  from coverage analysis
* Null pointer safety
2022-10-16 19:28:53 -07:00
Aras Pranckevičius 5e15e1cb3b SIMD: extend NEON implementation coverage, and include neon in oiio_simd_caps (#3599)
* Use hardware float<->half conversion (similar to F16C on Intel)
* Use hardware sqrt
* Use horizontal adds in more places ("reduce_add")
* Equivalents of _mm_movemask_ps for NEON in vbool4
* Other smaller bits & bobs

Testing on Apple M1 Max, Release build, notable simd_test Mvals/sec
changes:

vfloat4
* load from half[]: 2457 -> 5890
* store to half[]: 1041 -> 6074
* simd sqrt: 2151 -> 6075

vfloat8
* load from half[]: 2433 -> 10367
* store to half[]: 1235 -> 11192
* reduce_add: 7377 -> 11971

vfloat16
* load from half[]: 2672 -> 14505
* store to half[]: 1322 -> 12558
* reduce_add: 7123 -> 11858
* operator<:  3345 -> 7500 (similar with other compare ops)

vint4
* blend: 4403 -> 5007
* blend0: 5187 -> 6076
* rotl: 1775 -> 2932

vint8
* load from int[]: 9415 -> 12152

vint16
* operator<<: 4656 -> 5865 (similar for >>, srl)
* rotl : 4042 -> 5137

vbool4
* reduce_and: 875 -> 1361
* reduce_or: 985 -> 1373
2022-10-12 21:31:03 -07:00
Larry Gritz 1fdfff056b ustring hashing improvements (#3577)
I realized that the recently added ustringhash class is confusingly
similar to the (obscure, barely used, mostly forgotten) ustringHash
functor. But also ustringHash doesn't need to exist, because it's
equivalent to `std::hash<ustring>`, if we define it. So now we do define
it, and also `std::hash<ustringhash>`, and deprecate ustringHash, to
be removed entirely for 3.0.

Also, add a ustring ctr from ustringhash (explicit only for now),
and `operator<` for ustringhash.

And add from_hash(size_t) method to ustringhash, analogous to
ustring::from_hash().

Modernize a few places we still used `(void)` to just `()`.

Give ustring and ustringhash a `using rep_t =`
rep_t is the type of the underlying representation (const char* for
ustring, size_t for ustringhash).

Modernize some typedef into using.

Make `==` and `!=(ustringhash, const char*)` be constexpr for C++ >= 17
2022-10-12 11:32:03 -07:00
Aras Pranckevičius c1d44d5d5b Windows: fewer windows.h includes from platform.h (#3596)
In particular, defining NOGDI before including <windows.h> achieves
several things amongh others:
- No longer causes ERROR symbol to be defined to 0. ERROR being defined
  prevents using e.g. google/glog library, since it wants ERROR to mean
  something else.
- No longer defines some possibly widely used names e.g. GetObject.
2022-10-11 09:05:53 -07:00
Aras Pranckevičius 7154cc5949 BMP: fix reading 16bpp images (#2808) (#3592)
16 bit per pixel (e.g. 555, 565, 444) formats probably have never
worked. One part of the code was assuming 5 bits in the mask, another
was shifting by 4 bits, and the 16-bit pixel fetch code was reading just
one byte.
2022-10-08 12:31:57 -07:00
jreichel-nvidiaandJoachim Reichel 0195106930 Fix PSD import on ARM. (#3589)
The code assumes "char" is "signed char" (as on x86), but on ARM "char" is
"unsigned char".

Co-authored-by: Joachim Reichel <joachim.reichel@posteo.de>
2022-10-07 12:31:04 -07:00
Aras Pranckevičius c6cb668b88 oiiotool: work around static destruction order issue (#3295) (#3591)
In some cases (at least on Windows, with static linking) the oiiotool
main returns zero, but the full process returns 3 error code due to
abort() being called. And that is called because a global shared
image cache is already destroyed, but the image references from another
global (Oiiotool itself) try to use it, get a call into a "pure virtual
function" stub that is put by MSVC C runtime into a destroyed object
vtable, and that ends up in an abort().

Work around that by making sure various member variables holding
ImageRecRef are cleared before main() finishes and global destructors
are called.
2022-10-07 12:30:17 -07:00
Aras Pranckevičius ecab9e2080 HDR: speed up reading by around 4x (#3590)
Most of the cost in HDR file reading was converting from RGBE to floats,
inside ldexpf(), which at least on Windows/VS2022 spends most of the
time inside _ctrlfp(). But we only have 256 possible exponents in total,
so just use a precomputed table.

On my PC (Windows 10, VS2022, Ryzen 5950X) this change gets file read
time for an 8x resolution .HDR image from 1.10s down to 0.27s
2022-10-07 12:28:04 -07:00
Aras Pranckevičius 9d8aa265b3 HDR: fix read performance regression (#3585) (#3588)
HDR code overhaul to support IOProxy (#3218) changed all reads into
a `pread()` with explicit file position tracking. Turns out, that is
quite a larger overhead compared to simple sequential reads; even more
so on Windows.

On my PC (Windows 10, VS2022, Ryzen 5950X) this change gets file read
time for an 8x resolution .HDR image (with RLE compression) from
8.28s back to 1.10s just like it was in OIIO 2.3.

On Windows the extra cost when using pread() is a bit more extra mutex
locks, but the real cost is in enventual ReadFile; looks like any seek
operations make it take some sort of "way slower" path with various
callbacks and whatnot inside the kernel.

---

Note repoduced from discussion #3588 from LG: 

Switching from IOProxy::pread to using IOProxy::seek + IOProxy::read makes the IOProxy stateful and not thread-safe without an external lock (which this HdrInput has, so it's not going to break anything), precluding any future removal of the locks from read_native_scanline to make the whole ImageInput able to read concurrently. That's probably not important for this file format, but for others (especially crucial those usable as texture), it would be desirable to rely on those stateless pread calls and remove the lock from the ImageInput.

I think this patch is fine. We don't expect a lot of concurrent reads from hdr like we do for tiff and openexr that we use extensively for highly threaded on-demand reading of texture. It fixes the recent performance regression, and it doesn't really cost us concurrency because we already had the lock in HdrInput. But in general, we want to prefer eschewing read/seek and using pread instead, so we can expect maximum concurrency from multiple threads using an ImageInput (as we do in ImageCache/TextureSystem).

So I believe that a revised and more complete diagnosis is that the problem isn't the pread vs read per se, but that for RLE-compressed images we were calling pread separately for every 4 bytes! The calls to read are faster simply because they are buffered (in FILE) and require fewer OS system calls. But the real sin is that we call it way too many times.

I think that the rle case could go back to pread if we want, but do just one pread per scanline (rather than one per pixel value run), asking for the maximum amount that will be needed to read the scanline for the worst case rle representation (it's ok if it's the end of the file, pread will just read up to the end and return the true number of bytes read). In other words, we'd be doing the buffering ourselves.

But anyway, the real misdesign of this HDR reader is ancient, and consists of doing many many tiny reads. Even the buffered fread would be sped up a lot by not doing it separately for every 2-4 bytes of the file. I don't know if it's worth fixing for this format. Depends on whether anybody really needs to maximize its performance or expects multiple threads reading the same hdr file to be fully concurrent.
2022-10-07 12:27:52 -07:00
Larry Gritz f3f375fc5b Revise RELEASING to explain updating oiio-images branch (#3580) 2022-10-06 16:17:02 -07:00
Larry Gritz 34b643922a Build/security: Try FORTIFY_SOURCE (#3575)
Add a new build-time cmake cache variable: FORTIFY_SOURCE

Default to empty, but can be set to 1, 2, or 3, corresponding to
setting the _FORTIFY_SOURCE macro available in recent versions of
clang and gcc. (I'm not sure exactly which minimum compiler version is
needed for each fortification level, except that for level 3, gcc must
be 12+.)

Fortification involves replacing several "unsafe" memory-related
functions such as memcpy, memset, strcpy, etc, with special versions
that do bounds checking, aided by some compiler smarts for
understanding the likely bounds of different buffers. If I understand
correctly, at level 2 it can figure out bounds of constant-sized
arrays, and at level 3 it can figure out certain dynamic cases as
well.

There are two use cases for this:

1. For our own CI, this is yet another bit of static and dynamic
anslysis to enable (currently, just in the gcc12 test) to possibly
catch bugs.

2. Users who are building OIIO to deploy it in security-sensitive
environment may wish to build with some fortification level enabled to
help prevent certain memory errors or security issues, understanding
that it may slightly impact performance.
2022-10-06 16:17:02 -07:00
Larry Gritz 705c25c193 CI: improvements and minor refactoring (#3570)
* Refactor the clang-format job to be part of the aswf batch of jobs
  rather than separate (reduces redundant logic in the workflow file).
* Give proper names to distinguish the two Mac jobs' artifacts for
  broken builds and their caches.
* Revise scorecard workflow triggers: no need to run weekly, and run
  on push only to the main repo, no reason to run on forks.
2022-10-06 16:17:02 -07:00
Larry Gritz 5e8483b758 Use undefined behavior sanitizer (ubsan) as part of CI (#3565)
In addition to address and leak sanitizers, also turn on the undefined
behavior sanitizer in our CI run. We can do it in the same job as
asan/lsan.

Some things that come along for the ride, including fixes for things
that ubsan uncovered:

* src/build-scripts/ubsan-suppressions.txt can hold suppression list
  (though we don't have any now, it just sets up the space for it for
  future needs).

* Split the "targa" test so that the parts that directly need the OIIO
  python module (which are all related to thumbnails) are now in
  "targa-thumbnails" test. That has to be disabled for the sanitizers,
  since we can't arrange for python to b linked to the sanitizer
  libraries.

* Found vint4::store has a potentially unaligned integer store.

* Found Strutil::concat is not necessarily safe if either of the
  strings are empty.
2022-10-06 16:17:02 -07:00
Larry Gritz 7f02d29935 Update one more ref image after recent raw change (#3572)
Also remove three raw test reference output files that we apparently
no longer use (corresponding to platform + libraw combinations that
aren't in our current set of CI configurations).
2022-10-06 16:17:02 -07:00
Larry GritzandVincent Demoulinv 69c40cf320 Update ref output after recent raw change and clang-format (#3569)
This is an addendum to #3561 to fix reference output

Co-authored-by: Vincent Demoulinv <vincent.demoulin@technicolor.com>
2022-10-06 16:17:02 -07:00
demoulinvanddemoulinv c6a9c08bc7 Add color metadata from libraw. (#3561)
2 vectors, pre_mul and cam_mul.
2 matrices, cam_xyz[4][3] and rgb_cam[3][4], delivered as 1D tab.

Co-authored-by: demoulinv <vincent.demoulin@technicolor.com>
2022-10-06 16:17:02 -07:00
Larry Gritz 427406d084 CI/build: build_libtiff.bash should be sure to build shared library (#3586)
Something changed in libtiff master and it doesn't build shared libs
by default, breaking our "bleeding edge" CI test. So when we build it,
be sure to ask for it. It can be overridden in build_libtiff by
invoking it with env variable `LIBTIFF_BUILD_SHARED_LIBS=OFF`.
2022-10-06 16:16:02 -07:00
Larry Gritz fde8de5602 DDS: honor ImageInput thread policy (#3584) 2022-10-05 23:57:39 -07:00
Aras Pranckevičius 8fe2463d30 DDS: optimize loading of compressed images (3-5x) (#3583)
Comparing the time it takes to load DXT/BCn compressed DDS images via
OIIO, I noticed that it's several times slower than in another codebase
(Blender). So I started profiling, and fixing some low hanging fruit.

- After decoding a BCn block (always 4x4 pixels), it was written into
  destination image using quite many branches in the innermost loop.
  Now it still takes care of not writing outside of a destination image
  that might not be multiple-of-4 in size, just with way fewer branches.
- BCn decompression is multi-threaded via parallel_for_chunked, using
  at least 8 block rows per job (i.e. 32 pixel rows). This is
  similar to internal multi-threading done by EXR or TIF readers.
- Avoid one case of std::vector resize (which clears memory) followed
  by immediate overwriting of that buffer with bytes read from the file.
  Switched to using unique_ptr for that array, similar to how other
  input plugins do it.

Performance data: I'm timing how long it takes to do "iinfo --hash" on
24 DDS files, each 4096x4096 in size. Quite a lot of time there is taken
by just the SHA hash calculation which is not related to loading, so
also have timing info for just DDSInput::read_native_scanline where
all the actual DDS loading/decoding happens.

Timings on PC (Windows 10, VS2022 Release build), AMD Ryzen 5950X.
- BC1: total 3.68s -> 2.76s, read_native_scanline 1.54s -> 0.59s
- BC3: total 3.74s -> 2.84s, read_native_scanline 1.83s -> 0.66s
- BC4: total 1.26s -> 0.82s, read_native_scanline 0.74s -> 0.24s
- BC5: total 2.29s -> 1.57s, read_native_scanline 1.31s -> 0.46s
- BC6: total 7.50s -> 4.30s, read_native_scanline 4.67s -> 1.60s
- BC7: total 6.18s -> 3.09s, read_native_scanline 4.34s -> 0.84s

Possible future optimization: implement DDSInput::read_native_scanlines,
that could avoid one extra temporary memory buffer copy. This extra
buffer clear & eventual copy from it into final user destination pixels
is non-trivial cost from profiling. But it's also quite involved
to handle all the possible edge cases (e.g. user requests scanlines
not on 4-pixel row boundaries); the code would have to do similar
juggling as EXR reader does to handle "not on chunk boundaries" reads.
It could potentially also interplay with DDS cubemap/volume texture
reading ("tiled") code paths, for which there is no test coverage at all
right now. Maybe for some other day.
2022-10-05 22:43:16 -07:00
Aras Pranckevičius cddf3e175b DDS: alpha/luminance format fixes, add & enable more tests (#3581)
* DDS: fixes for A8, L8, A8L8 formats

While developing #3573 at one time I had them working properly, but then
while fixing the address sanitizer failure for 3-channel formats I
botched them again. Note to self: never again do a "yeah I'll add tests
later", since if I had all of them running all the time this would
not have happened. 🤦

* DDS: extend test coverage for more formats & channel size cases

With more test images recently added (https://github.com/OpenImageIO/oiio/pull/3459),
start using them for DDS tests. This covers now:
- Alpha, Luminance and Alpha+Luminance formats,
- RGB formats with rarer channel sizes (rgb10 a2, r3g3b2),
- Several "broken" DDS file cases
- Removed usage of sample-DXT1 since it is well covered by others.
2022-10-05 22:43:16 -07:00
Larry Gritz aff5ea242f Remove incorrect OIIO_API from inline method declaration (#3578)
This was causing build issues on MinGW.
2022-10-05 22:43:16 -07:00
Larry Gritz 8a5580c59e Add RELEASING.md to document our release procedures (#3564)
Adapted from the similar document I wrote for OSL.

This serves both as a checklist for me to make sure I don't miss any
steps during a release, but also so that other people could take over
release procedures if necessary or desired.

I also rearranged the order of some lines in CMakeLists.txt for
clarity (but did not change the logic).
2022-10-05 21:09:12 -07:00
Larry Gritz f54a109ffb Python internals: support int8[] metadata and ICCProfile, refactor (#3556)
This patch allows ParamValue, ParamValueList, and ImageSpec to support
attribute/getattribute of metadata consisting of uint8[] arrays, which
is how we store certain binary blobs or raw byte arrays.  We translate
this to Python as a numpy array of type uint8 (dtype='B').

This fixes a limitation where it was not possible to directly retrieve
or set the "ICCProfile" metadata (which is stored as a uint8 array)
from the Python APIs, as you could easily do from the C++ APIs.

In the process, I found similar bits of code in several different
places, in various states of incompleteness. I refactored to make a
single make_pyobject() utility and then used that call in place of
several other redundant pieces of functionality.
2022-10-05 21:09:12 -07:00
Larry Gritz 922ec699a1 Extract metadata from embedded ICC profiles. (#3554)
For a while, we have found embedded ICC profiles in TIFF, JPEG,
JPEG-2000, PNG, and PSD (PhotoShop) files and store them in the
metadata as a byte array with the name "ICCProfile".

With this patch, we further add the facility of parsing the binary ICC
profile data to extract a number of other fields that we add to the
ImageSpec metadata so that "oiiotool -info -v" or "iinfo 'v"
will print this info.

Important caveat: You can read this for informational purposes, but
changing it (e.g. with spec.attribute()) does not change the contents
of the ICCProfile byte array, which is still the canonical ground
truth of the profile. You have to replace the "ICCProfile" byte array
to actually change the profile.
2022-10-05 21:09:12 -07:00
Larry Gritz f2a2d59344 Strutil utf conversion improvements (#3553)
* Add `Strutil::utf16_to_utf8(const std::u16string& utf16str)`.
  This is subtly different from our existing utf16_to_utf8() that
  takes a std::wstring, because wchar_t is not the same on all
  platforms.  If it really and truly is utf16-in-char16_t, you need
  this and can't use the utf-in-wchar_t which may be 32 bit chars.

* Add `Strutil::utf8_to_utf16wstring()` (identical to the old
  utr8_to_utf16) to make it more self-documenting as returning a
  utf16-encoded wstring and NOT a u16string. Note that wchar_t is not
  necessarily char16_t on all platforms (it is on Windows, but it's 32
  bits on Linux).

* Deprecate the ambiguously named `utf8_to_utf16()` for OIIO >= 2.5 and
  remove it for OIIO >= 3.0.
2022-10-05 21:09:12 -07:00
Larry Gritz 8fbf27b69d Build: Make the version number be a cmake cache variable (#3549)
Rather than specify the version in the usual project() statement,

    project (OpenImageIO VERSION 2.5.0.0 ...)

this patch decouples it

    set (OpenImageIO_VERSION "2.5.0.0" CACHE STRING "Version")
    project (OpenImageIO VERSION ${OpenImageIO_VERSION} ...)

thus allowing the possibility of overriding the version number at
build confuguration time (`cmake -DOpenImageIO_VERSION=3.1.4.1`).

This should be used with extreme caution. Probably never used by most
people. I don't need to describe all the ways that things can go
sideways if you make your build of x.y.z.w actually be arbitrarily
different from the x.y.z.w that everyone else uses and that is
documented.

That said, there are two scenarios I have in mind for which this
ability is very useful:

1. Sometimes, we add or deprecate API features "in advance" by having
   an `#if` enable or disable code based on the version, essentially
   putting in place changes that can't be enabled yet because they
   would break compatibility rules, but we want to integrate the code
   now and have it become active upon reaching a particular future
   version in which that incompatibility will be allowed. The version
   number override makes it easy to test this by quickly doing a build
   "as if" we had already bumped the version number to see what will
   happen when we actually do.

2. Every once in a while we need to do an internal build that, to
   conform to version compatibility rules, needs to appear to still be
   part of a past version family. This lets individual sites play some
   games with version number overrides rather than have to create new
   branches and tags for certain one-off internal releases.
2022-10-05 21:09:12 -07:00
Larry Gritz 98181a584e oiiotool --iccread and --iccwrite
--iccread reads a named file and directly adds its contents as the
"ICCProfile" metadata of the top image (as a byte array).

--iccwrite takes the "ICCProfile" metadata of the top image and
writes it to a named file.
2022-10-05 21:09:12 -07:00
Larry Gritz 1983be7f16 oiiotool protect against OpenEXR thread deadlock on Windows (#3582)
Suggested by SideFX: explicitly shut down the OpenEXR thread pool
before exiting oiiotool, because sometimes on Windows it seems to hang
otherwise. A better solution is probably possible on the OpenEXR side,
but I don't know what it would be. (And in any case, we'd still need
to do this be be well behaved when using OpenEXR versions earlier than
where a fix might land.)

Solution tracked down by Edward Lam.
2022-10-05 21:09:12 -07:00
Larry Gritz 5dfe62d56d CI: Re-enable sanitizer tests (#3545)
Oops, at some point, something about the way we set up the CI test
that runs the sanitizers, and ever since then (embarrassingly, perhaps
as much as a couple years ago), the "sanitizer" test has not in fact
been running the sanitizers. Here we fix that up, get sanitizers
running again.
2022-10-03 21:38:36 -07:00
Larry Gritz 78cca33201 PNG fixes (#3544)
* Minor png refactoring to fix some memory leaks for broken png files.

* Remove unused string variable from read_info() and simplify the
  surrounding "if"

* Split png test into png and png-damaged, because I just can't seem
  to squash some very minor memory leaks for broken png files, I think
  it's not worth worrying about and I'll just exclude the broken case
  from testing for the address sanitizer.
2022-10-03 21:38:36 -07:00
Johannes Unterguggenberger 8f7c48dec3 Fixes a warning from an unsuitable format specifier (#3540)
Changed the assert  to use format specifier %d and casting the size to an int.
2022-10-03 21:38:36 -07:00
Larry Gritz e7769b6b0d PNG: fix memory leak when error takes early exit (#3543)
Found by leak sanitizer.
2022-10-03 21:38:36 -07:00
Larry Gritz 8c8c918e5c Targa internals: fix incorrect unique_ptr declaration (#3541) 2022-10-03 21:38:36 -07:00
Larry Gritz fafbec1737 Bump version after release 2022-10-03 21:38:21 -07:00
Larry Gritz 4327cd8560 Stage for 2.4.4.2 patch release 2022-10-02 20:02:14 -07:00
Aras Pranckevičius 6ca23b7753 DDS: various improvements (#3573)
- If a DDS pixel format header contains "this is a normal map" flag
  set, then handle that properly (#3525):
  - For a DXT5, this means it's a "DXT5nm" format. Normal X & Y
    components are in green and alpha channel respectively. Compute Z
    component from those, and the result is a 3-channel tangent space
    normal map.
  - For ATI2/BC5 format that also has a "normal map" flag set, compute
    the Z component automatically too, and result is a 3-channel image.
    However a bunch of ATI2/BC5 normal maps out there in the wild do
    not have that bit set, so also have a global "dds:bc5normal"
    attribute to optionally turn this on.
- Fix support of R10G10B10A2 format - was producing garbage data due to
  code assumption that truncation down to 8 bits never needs to happen.
- Fix bit expansion ("too dark") of very low-bit formats, e.g. R3G3B2.
  Code was simply shifting the bits, instead of properly repeating
  the high bits into new low bit positions (i.e. a 3-bit "111" needs
  to become an 8-bit "11111111" and not a "11100000").
- Support "RXGB" (DXT5, with red & alpha swapped) as well as "BC4U"
  and "BC5U" formats (the latter two are just BC4 and BC5, produced by
  some older tools).
- Support alpha-only (e.g. A8) formats.

All this mostly prompted by doing DDS improvements in Blender, and
wanting to get Cycles renderer (which uses OIIO) to the same feature
parity. See https://developer.blender.org/T101405 and
https://developer.blender.org/D16087.
2022-10-02 15:07:49 -07:00
Larry Gritz aa0550e07f Fix heap overflow in DDS input (#3542)
Reading uncompressed scanlines would copy 4 bytes from each pixel into
an int and then decode the bits, incrementing where it was reading
from by Bpp bytes each time.  But when Bpp == 3, the last pixel of
every row would therefore read an extra byte past the end of the heap
storage. Allocation padding would in practice keep it from crashing,
and that meaningless extra byte was not used in the decode because it
knew it only needed the first 3 of the integer. But found by address
sanitizer!
2022-10-02 15:07:49 -07:00
Larry Gritz a10a88fa12 Bump version after release 2022-10-02 10:52:42 -07:00
Larry Gritz dab1663d6d Full release of 2.4.4.1 -- first official 2.4 release 2022-09-29 17:39:07 -07:00
Larry Gritz c0e7eb56d7 Remove long deprecated/nonfunctional C API headers (#3567)
This was an experiment that was added to master at one point but
removed before we branched for a release. But we forgot to remove a
few headers. Removing them now is not a compatibility break, since we
never shipped a supported release that contained the library that
implemented the functions declared in these headers.
2022-09-27 14:39:41 -07:00
Larry Gritz d02ad116b4 Reinstate missing (obsolete) parallel_for_chunked_2D variant (#3566)
This was part of a set of obsolete calls where we recently removed the
implementations, but for link compatibility, made matching shim calls
and wrap the modern versions. But I missed one case.
2022-09-26 23:40:51 -07:00
Larry Gritz ab7dc1f728 Update ref output after recent python chage 2022-09-24 11:36:17 -07:00
Larry Gritz 31dbd3d699 2.4.4.0-RC2 second release candidate
Changes since RC1:

  - ImageCache/TextureSystem both have added a `getattributetype()`
    method, which retrieves just the type of a named attribute. #3559
    (2.4.4.0)  NOTE: THIS IS AN ABI BREAKING CHANGE
  - Python: Fix the ability to `getattribute()` of int64 and uint64
    metadata or attributes. #3555 (2.4.4.0)
  - Build: Improvements to the generated cmake config files when
    building static libraries. #3552 #3557 (2.4.4.0)
  - Support for gcc 12.1. #3480 (2.4.2.1) #3551 (2.4.4.0)
  - Support building with clang 15.0. #3563 (2.4.4.0)
  - Fix cross-compiling on Android failing due to `-latomic` check. #3560
    (2.4.4.0)
  - Fix building on iOS. #3562 (2.4.4.0)

Note that we bumped the version to from 2.4.3.x 2.4.4.0 to reflect the
ABI break introduced by the last minute by the IC/TS addition of a new
virtual function. ABI will not change again for 2.4.
2022-09-23 08:56:49 -07:00
Larry Gritz d83aee94d5 Changes to take care of new clang 15 warnings (#3563) 2022-09-22 22:59:35 -07:00
Larry Gritz 7c167dab0a IC and TS getattributetype() (#3559)
ImageSpec and ParamValueList have had (since 2.1) a getattributetype()
method, which simply returns the TypeDesc of the named attribute, or
TypeUnknown if no such attribute exits. This goes along well with the
related getattribute() and attribute() family of methods.

The getattribute() method was not present in ImageCache and
TextureSystem, despite their having very similar
getattribute()/attribute() interfaces.

A recent issue made me realize that in the Python bindings, the IC and
TS bindings for `getattribute(name)` did not work properly, always
returning None, and *required* you to use the full
`getattribute(name,type)` variety where you have to supply -- and
already know -- the type. This isn't especially Pythonic, where you
should just be able to ask by name and get a polymorphic result. And
when I went to look at how to repair this, it was going to be very
awkward without getattributetype(), but trivial with it.

So this patch sets up getattributetype() for both IC and TS, and
exposes them to both C++ and Python APIs, and also fully fixes the
getattribute() so that it works properly with the name only.

Unfortunately, because getattributename is a new virtual method, it
changes the vtable, breaking the ABI, and thus cannot be backported to
any supported release that makes ABI compatibility promises.
2022-09-22 22:59:26 -07:00
Povilas Kanapickas fe98cbfb9a Fix build on iOS by not using std::system() (#3562)
iOS and similar Apple platforms only support executing single process
per app. Calling std::system() there fails at compile time.
2022-09-22 22:59:19 -07:00
Povilas Kanapickas 6445022f11 Build: Fix cross-compiling on Android failing due to -latomic check (#3560)
Currently when cross-compiling for Android build fails due to usage of
TRY_RUN(). In the particular case it tries to figure out whether atomics
can be used without the libatomic library.

Fortunately we don't need this check because on Android NDK atomics are
built-in and libatomic.so is not present. Only static dummy libatomic.a
exists for compatibility with -latomic flag.
2022-09-19 18:43:58 -07:00
Larry Gritz ade4132ada Python: add ability to getattribute of int64 and uint64 data (#3555)
Just a couple missing pieces were preventing getattribute() from
retrieving attributes that were stored as int64 or uint64. That
doesn't come up very often, but one place is retrieving certain
statistics that use 64 bit counters. (This comes up in ImageCache,
among other places.)

While we're at it, there was no existing test dedicated to the python
binding of ImageCache. So to add these getattribute calls, I made one.

There is an important caveat about ImageCache.getattribute(): In this
process, I discovered that the flavor of IC.getattribute(name) where
you only pass the name is BROKEN, and will always return None. You
MUST use the form where you pass the type, like

    x = ic.getattribute("foo", "int")

This is unfortunate and not very Pythonic, but it is the workaround
for now. I will addess getting the name-only form working in a
separate PR.

Closes #3537
2022-09-18 14:37:50 -07:00
Povilas Kanapickas c5d17a32c5 cmake: Find TBB dependency in Config.cmake.in when building static (#3557)
TBB::tbb is added as a library dependency via TARGET_NAME_IF_EXISTS.
Therefore if an executable links OpenImageIO static library without the
executable itself depending on TBB, then TBB will not be linked in and
result in link time errors.
2022-09-18 14:36:58 -07:00
Povilas Kanapickas 9900536fce cmake: Add library dependencies in Config.cmake.in when building static (#3552)
This fixes builds in projects that compile OpenImageIO as static
libraries and don't themselves depend on the image libraries used by
OpenImageIO such as PNG, JPEG or TIFF.

When OpenImageIO is built as a static library its targets have e.g.
PNG::PNG among INTERFACE_LINK_LIBRARIES. If the including project does
not itself depend on PNG, the following error would be observed:

Target "<...>" links to target "PNG::PNG" but the target was not found.
Perhaps a find_package() call is missing for an IMPORTED target, or an
ALIAS target is missing?
2022-09-18 14:36:11 -07:00
Larry Gritz 8c40efdcc5 Slight change to avoid gcc12 warning (#3551) 2022-09-13 14:07:11 -07:00
Larry Gritz 449e1c7ea6 Designate as RC1 2022-09-07 21:36:45 -07:00
Larry Gritz 0a28dc0186 Bump version and branch for 2.4 release 2022-08-31 17:03:05 -07:00
Larry Gritz 5ef709c1b4 CHANGES, docs 2022-08-31 14:31:05 -07:00
Larry Gritz 27745db1da ImageCache: improve file handle limits under heavy thread contention. (#3515)
When enforcing the max open files limit, there's a heuristic where we
only "try" to get the lock, and if we can't, rather than block, we
just defer the cleanup step until the next time around. So what if we
go slightly over the limit temporarily?

Interesting edge case: what if max_open_files is relatively low, but
the number of threads is very high and you have a high contention rate?

Then you can end up *significantly* over the limit, because almost all
the threads say "somebody else has the lock, I'll leave it to them to
clean up" and blithely open new handles.

So this patch modifies the logic so we do the defer trick only if
we're only a little over the limit. If we've exceeded the limit by
16 handles, grab the lock unconditionally and do the cleanup.
2022-08-31 11:08:02 -07:00
Luc 736864dca0 Added checks in PNG_pvt::write_info (#3535) 2022-08-29 23:18:50 -07:00
Larry Gritz afa6c84f68 CI: test latest fmt version (#3536) 2022-08-29 23:17:00 -07:00
Larry Gritz a14523e9b7 Add --version to all the things (#3534)
* ArgParse::add_version(str) tells ArgParse the version string, and
  automatically adds an option --version that prints the version string
  and exits.

* Add this to oiiotool, iinfo, igrep, iv, maketx.

* OIIO::getattribute("version") retrieves the version string.
2022-08-26 10:10:16 -07:00
Larry Gritz 7e77d7b05d Improve JPEG output of 2-channel images (#3531)
JFIF/JPEG files only support 1 and 3 channels. For > 3 channels, we
had just been discarding the extra. For 2 channels, we had been
discarding the second, but maybe that's not always right. Try to
distinguish between files whose names appear to be YA -- in which case
output the Y as grayscale (JFIF has no way to represent alpha anyway),
and other cases which we now promote to RGB and just make B be black.
2022-08-23 00:02:51 -07:00
Larry Gritz 939c25988a DDS improvements (#3530)
* For 2-channel DDS files, label them as Y,A if the flags indicate
  luminance and/or alpha, otherwise label them as R,G.

* Do not set "oiio:BitsPerSample" for cases where the dds.fmt.bpp field
  is not assumed to be valid. MS docs say it's valid only if the flags
  field indicates RGB, LUMINANCE, or YUV types.
2022-08-23 00:02:38 -07:00
Larry Gritz f582b8b5ab Make Filesystem::extension work identically for C++14 and 17 (#3529)
The implementation of boost::filesystem::path::extension() and the
equivalent for std::filesystem disagreed about the result of
extension(".foo"). C++17 correctly considers ".foo" to have no
extension.
2022-08-23 00:02:17 -07:00
Larry Gritz 217c169543 Miscellaneous Sonar-inspired warning fixes (#3532) 2022-08-21 15:09:57 -07:00
Larry Gritz cace0c4b82 Fix warning wth C++20 + g++12 (#3533) 2022-08-21 13:21:57 -07:00
Larry Gritz c2ed61bb85 Remove 'socket' file type (#3527)
This was envisioned to be useful in the very earliest days of OIIO,
but we never really finished it or used it in any helpful way.
In addition to being essentially dead and untested code, it ties us
to boost.asio, which we use nowhere else.

So just get rid of it this vestigial piece.
2022-08-19 19:43:45 -07:00
Larry Gritz b6b3166d4e CI: For Mac, test python 3.9 for MacOS11, and 3.10 for MacOS12. (#3528) 2022-08-19 10:25:34 -07:00
Larry Gritz be30dfa241 Suppress incorrect warnings for gcc12 (#3524) 2022-08-15 22:56:05 -07:00
Larry Gritz e69b267e0f Build: Don't force MACOSX_RPATH on (#3523) 2022-08-14 17:59:05 -07:00
Larry Gritz 59408d630c Fix mail list refereces 2022-08-14 17:58:06 -07:00
Larry Gritz 9501cd71ab Fix analysis trigger typo 2022-08-13 22:58:52 -07:00
Larry Gritz 50286f3e03 Several minor fixes for Sonar warnings (#3522)
Knocking these out a few at a time
2022-08-13 21:56:57 -07:00
Larry Gritz ce3d45a812 Fix destructors that could throw an exception -- big no-no (#3521) 2022-08-12 18:21:11 -07:00
Michael Cho 01cf730d2f cmake: fix ffmpeg 5.1 detection (#3516) 2022-08-11 23:29:06 -07:00
Larry Gritz 79a4803db6 Some minor refatoring to address Sonar warnings (#3518) 2022-08-11 23:22:25 -07:00
toxie f21a666b2d Fix vector-subscript-out-of-range on MSVC Debug builds (#3517)
Also fix potential problems with >31bit pixelsizes
2022-08-11 19:21:15 -07:00
Larry Gritz 1af0a782d3 Fix crash with oiiotool -i:ch= (#3513)
* Any use of `-i:ch=...` would result in a crash because of
  dereferencing an empty shared pointer.

* In the case of `-i:ch=` specifying missing channels, improve the
  warning message to make it clear which channels were actually present.
2022-08-06 23:26:20 -07:00
Larry Gritz 9f4f6ae6cd CI fixes (#3514)
* Remove GHA CI for Mac OS 10.5, it faces imminent deprecation by GitHub.
* Update some dependency version numbers in INSTALL.md.
2022-08-06 23:25:52 -07:00
Larry Gritz f8616d9824 Miscellaneous static analysis warning issues (#3512)
Also re-split the scorecard workflow from the analysis workflow.
2022-08-05 09:10:01 -07:00
Larry Gritz 61a58a17f8 Get rid of redundant 'virtual' when we use 'override' (#3511) 2022-08-04 23:50:28 -07:00
Larry Gritz 540e7e2554 Fix broken workflow file -- copy/paste error (#3510) 2022-08-03 23:34:42 -07:00
Larry Gritz c530e48cb6 Relative image compare (#3508)
Extend ImageBufAlgo::compare() to take relative metrics, which if
nonzero check the symmetric mean relative error, in addition to the
current absolute error. To be formal, this means that a value
comparison will fail if

    abs(A-B) > failthresh && abs(A-B)/((abs(A)+abs(B))/2) > failrelative

Setting the failthresh to 0 is equivalent to only checking relative
error, and setting failrelative to 0 is equivalent to the (previous
behavior) of checking only absolute error.

The idiff utility is extended to take new `-failrelative` and
`-warnrelative` command line arguments.

The hope is that there are various kinds of image comparisons within
tolerances -- like we frequenty use for unit tests, shader
verification, etc. -- where this metric is more helpful than absolute
error.
2022-08-03 23:27:01 -07:00
lmarz c3740921b6 cmake: Escape argument in regex (#3507)
See https://gitlab.kitware.com/cmake/cmake/-/issues/18737 for why this is an issue
2022-08-03 08:35:01 -07:00
Larry Gritz 307fe02a49 Set up SonarQube for static analysis (#3505)
Set up SonarQube to run weekly (seems unnecessary to do on every PR,
it's a LONG run). Also required some build system fixes to enable code
coverage analysis.

This is handled by the "analysis.yml" workflow (into which I also
merged the scorecard analysis we were doing). This workflow runs once
weekly or on only those pushes/PRs with specially named branches.
There's no reason to run this expensive analysis on every last PR or
push.

A number of fixes come along related to things found by Sonar as I was
setting this up:

* Fix buffer warnings
* Address sonar warning: was reading wrong size into buffer
* warning reduction in dpxoutput, simplify string ops
* Clean up dubious uses of sprintf
* Add assertions
* Save a needless string construction in ParamValue::get_string_indexed
* Fix string safety warnings
* iptc: simplify encoding string data and improving safety
2022-08-01 07:23:51 -07:00
Larry Gritz 7ab1ee5108 Refactor TGAInput::open to simplify. (#3504)
It was getting too big. Split off the tga-2.0 header reading parts
into a separate method.
2022-07-29 09:45:00 -07:00
Larry Gritz c72154fa26 Use imath .xyz rather than [] to fix static analysis warnings (#3503)
Stranely, this made slightly numerically different texture test
results on icc.  Switching its math mode to precise brings it back in
line with the other compilers. The differences aren't visible, so this
isn't an issue in practice, but for tests it made it hard to compare
to reference images.
2022-07-29 07:48:09 -07:00
Larry Gritz bc9c931092 Strutil::safe_strlen (#3501) 2022-07-24 22:13:15 -07:00
Larry Gritz 7f90f51792 Fix bug in print_info_subimage -- botched condition (#3499) 2022-07-24 22:12:58 -07:00
Larry Gritz 04e32c9894 Fix aspect ratio logic in jpeg (#3500)
Typo, was checking XRes twice instead of XRes and YRes.
2022-07-24 22:12:32 -07:00
Larry Gritz afc2bd1649 parallel.h refactoring and add support for TBB (#3473)
Hide nearly all of the implementation of the parallel_for family of
methods rather than expose them as inline. This gives us more freedom
to change the implementation in the future without breaking ABI.

Deprecate the parallel methods that take task functions whose first
parameter is the thread ID. The only reason they existed is because
our cobbled together thread_pool used that in its inner workings.  But
there are good reasons why we should not expose that:

  * We never used it anyway.

  * It was not very useful, since sometimes it was a real thread ID, but
    other times it was -1 in cases where the calling thread executed the
    task directly.

  * It is inconsistent with other thread pool implementations that we may
    wish to try in the future.

So better just to not expose those thread IDs at all. Mark those
versions of the parallel loops as deprecated and schedule them for
removal in OIIO 3.0.

If TBB is detected at build time, support will be built in that allows
either the old OIIO built-in pool, or TBB, depending on the setting of
a new global OIIO attribute, "use_tbb" (default 0), if set to nonzero
will use the TBB thread pool.

In my experiments, the TBB thread pool seems slightly better -- I
think because there is less overhead, and maybe the clever
work-stealing it does elps to load balance. It's not used by default,
set the attribute if you want to use it (assuming the build
included. After we've had a chance to test more thoroughly, we may
change to use TBB by default. I'm interested to hear people's thoughts
on the matter.

One case where you almost certainly will want to use the TBB thread
pool is if you're using libOpenImageIO from within an application that
uses TBB for its own threding -- that way you're using one pool for
everything, rather than have two separate thread pools that don't know
about each other (and probably twice as many threads as you have
cores)..
2022-07-24 14:37:34 -07:00
Larry Gritz db1cdd6935 Fix incorrect assignment of oiio_missingcolor (#3497)
Incorrect use of reserve(), then writing past the end of the vector.
It should have been resize(). But it can be cleaned up even further by
using assign().
2022-07-24 09:23:42 -07:00
Larry Gritz f8a237cb80 Bug fix: posible null pointer dereference in inventory_udim (#3498)
If udimfile is null, it would get dereferenced anyway. Was missing
a `return` in that case.

While I was there, I realized that ImageCacheImpl::inventory_udim and
resolve_udim had no reason to be virtual, so I removed that
qualifier. (It was probably a cut/paste error, as the
identically-named methods in TextureSystem are virtual, on
purpose. But they don't need to be for this class.)
2022-07-24 08:28:18 -07:00
Larry Gritz 04137bbeb9 Upgrade to the latest PugiXML (#3494) 2022-07-23 15:34:31 -07:00
Povilas Kanapickas d6594f132f JPEG: Fix a race condition in read_native_scanline() (#3495)
All read_native_* methods of ImageInput are required to be thread-safe
with any other read_native_* call or with the varieties of read_tiles()
that take an explicit subimage and miplevel parameter.

JpgInput::read_native_scanline() does a seek_subimage() call internally,
so it's obviously not thread safe without additional locking.
2022-07-23 11:08:12 -07:00
Povilas Kanapickas 2bcbb06944 filesystem.h: Improve documentation of pread() and pwrite() (#3496)
The current description of IOProxy::pread() and IOProxy::pwrite() is a
little ambiguous. This commit expands the description to explicitly tell
what the functions are and are not required to do.
2022-07-23 10:22:16 -07:00
Povilas Kanapickas fb07a242b2 Make access to imageio_mutex not recursive (#3489)
This will allow switching imageio_mutex to std::shared_mutex to avoid
exclusively locking the internal format database for read operations.
2022-07-22 22:50:55 -07:00
Larry Gritz 43d8d543b6 Fix typos in comments and docs (#3492) 2022-07-22 22:02:24 -07:00
Larry Gritz 1d3bb460e2 Bump version 2022-07-21 22:50:44 -07:00
Larry Gritz 32557090ea Protections against 0-length string attributes (#3493)
Files that have string metadata with length 0 can cause trouble
if we aren't careful. But in a number of protections.
2022-07-21 22:47:06 -07:00
Larry Gritz a9fbf36560 Fix mistake in unordered_map_concurrent (#3485)
Should not have passed an argument. Went undetected for a long time
because I guess we didn't previously call the erase() method. (Until
I did when working on something unrelated.)
2022-07-20 11:14:20 -07:00
Povilas Kanapickas ebee2b7888 Fix -Wsuggest-override warnings (#3488)
Consistently applying override specifiers helps to ensure that functions
are actually overridden when they meant to be such.
2022-07-20 11:13:51 -07:00
Larry Gritz 1bc666a708 Bump version for developer preview 2.4.2.1 2022-07-19 22:32:34 -07:00
Larry Gritz 56e0bd05d8 TIFF: Protect against empty attribs when setting TIFF fields (#3491) 2022-07-19 22:00:06 -07:00
Larry Gritz 590ce5f8f0 Empty string / null pointer safety in metadata printing (#3490) 2022-07-19 15:49:52 -07:00
Povilas Kanapickas 31daceea03 Address -Winconsistent-missing-destructor-override warning (#3481)
Virtual destructors don't significantly differ from regular virtual
functions, so it is customary to add override specifier when virtual
destructor is overridden.
2022-07-19 15:48:08 -07:00
Povilas Kanapickas 2e30e71ef1 cmake: Fix value of OpenImageIO_INCLUDE_DIR in cmake config (#3487)
Current code assumes that CMAKE_INSTALL_INCLUDEDIR and
CMAKE_INSTALL_LIBDIR has exactly one filesystem component. This is not
the case on e.g. Debian, where standard paths are as follows:

CMAKE_INSTALL_INCLUDEDIR=include
CMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu

Fortunately the Config.cmake file is installed into a path that is
itself relative to CMAKE_INSTALL_LIBDIR, so we can get
CMAKE_INSTALL_LIBDIR from CMAKE_CURRENT_LIST_DIR and then get
CMAKE_INSTALL_INCLUDEDIR by applying relative path from
CMAKE_INSTALL_LIBDIR to CMAKE_INSTALL_INCLUDEDIR on top of that.

Fixes: c8dfbd7066
2022-07-19 14:25:51 -07:00
Larry Gritz 786a55479e Move guts of OIIO::debug to Strutil so it can be used from util library (#3486) 2022-07-19 11:56:25 -07:00
Povilas Kanapickas e7ad7cef20 Bump maxthreads to 512 (#3484)
The current limit has been already hit when AMD released
second-generation Epyc processors (codename Rome) back in 2019. Top
models have 64 cores per CPU, or 128 threads. This means 2 socket
configuration has 256 threads.

Fourth generation Epyc processors (codename Genoa) are rumored to have
96 cores per CPU, or 192 threads. This means 2 socket configuration has
384 threads. While the CPUs have not been announced yet, it makes sense
to prepare for them in advance.
2022-07-19 09:34:15 -07:00
Larry Gritz 431204b78a CI: Try newest ubuntu 22.04 and MacOS 12 images, test gcc12 (#3480)
Bump the bleeding edge test to use gcc12, C++20, and python 3.10.

Address the couple of new warnings that popped up.

Add a test on MacOS 12.
2022-07-18 08:47:39 -07:00
Larry Gritz 777e7730df Get rid of Boost::system (#3479)
I think whatever we needed it for originally is long since gone.
2022-07-18 08:46:08 -07:00
Larry Gritz 24f804dfd2 Test against pybind11 v2.10 (#3478) 2022-07-17 20:50:14 -07:00
Larry Gritz 07c538071e Build: Use std::filesystem when we can (#3477)
C++17 (and/or adequately new versions of the compilers) support
std::filesystem, and in those cases we no longer need boost.filesystem.
2022-07-17 18:38:33 -07:00
Larry Gritz 1521da6213 Replace unsafe strcpy/strcat in SHA1.cpp (#3476)
Revealed by clang-tidy. Use length-safe versions.

Also get rid of some dead code by disabling some memory-clearing
code that we don't need (we're not using SHA-1 for cryptographic
or security reasons, just for comparing images).
2022-07-16 20:45:57 -07:00
Larry Gritz 97254f625d Filesystem: provide alternate implementations of last_write_time() (#3472)
This is a discrete step in an attempt to wean us off of boost::filesystem
2022-07-15 00:05:32 -07:00
Michael Oliver 836bd0d113 build_opencolorio.bash: update default ocio build to 2.1.2 (#3475) 2022-07-14 23:57:43 -07:00
Larry Gritz 348c4fee6e Remove a stray reference to half.h in a public header (#3474)
There's no reason to expose this here.
2022-07-14 18:13:06 -07:00
Larry Gritz 879dc2fbdb Bump version to 2.4.2.0 for developer preview 2022-07-11 20:56:59 -07:00
Larry Gritz 7b57336a28 CHANGES update 2022-07-11 16:57:34 -07:00
Larry Gritz a12a0cebc7 Strutil::safe_strcat (#3471) 2022-07-11 10:42:37 -07:00
Anders Langlands 3ee1a4d410 Allow loading of dlls from PATH on Windows Python 3.8+ (#3470)
Python 3.8 stopped loading DLLs from PATH on Windows, meaning anything that relied
on that environment for shared library resolution breaks. This PR works around that
behviour by manually adding PATH back to DLL resolution using os.add_dll_directory()
in a new __init__.py which just re-exports everything in the current .pyd.

The new behaviour is enabled by default, but is easily disabled at runtime if the
environment variable OIIO_LOAD_DLLS_FROM_PATH is equal to "1".
2022-07-10 21:58:01 -07:00
Larry Gritz e9103925bb TIFF: Fix some longstanding IPTC buffer safety issues (#3465)
Found this coincidentally during some address sanitizer runs.

Some tiff files out in the wild that have RichTIFFIPTC tags
inexplicably mark them as if the data was LONG instead of BYTE or
NOTYPE. I guess early in our history, we came across one of those and
thought it was correct, because we were always treating it as if it
came in the form of longs. But that's not always true, and in
particular, the size in the tag I think is always expressed in
bytes. So this could make for buffer overruns (generally harmless, but
caught by the sanitizer!).

So this patch cleans this all up.

And also we update a few sample images with bad RichTIFFIPTC tags to
strip out the in the incorrect form of the tag.
2022-07-07 12:55:40 -07:00
William Krick 925a6b7c8a Correctly accumulate 'ofs' when the cubemap has mipmap levels. (#3467) 2022-07-07 12:54:57 -07:00
Larry Gritz ea127e8973 PSD: beef up error message to help track down PSD failures (#3469)
Try to have an error message for every possible failure.
2022-07-06 18:09:24 -07:00
Larry Gritz 7a662829b9 Docs: Clarify how ImageOutput::copy_image propagates read errors (#3468) 2022-07-06 14:59:05 -07:00
Larry Gritz 5c3355bed0 Extend stochastic texturing to anisotropic (#3457)
Recently, we added the ability to do stochastic sampling in texture
lookups, by choosing the MIP level stochastically rather than reading
two MIP levels and mixing them.

This PR adds the ability to also stochastically sample the anisotropic
filter footprint -- instead of multiple anisotropic samples, choose
just one sample well distributed over the footprint axis. On real
scenes, this seems to speed up overall rendering (not just texture) by
up to 2-3%, for scenes where average anisotropy is around 3-4.

It's much less dramatic a speedup than the stochastic MIP selection,
which sped up texturing by around 40% and in practice sped up overall
rendering by around 15% for us. Why doesn't cutting the number of
texture samples by another factor of 3 only speed up by 3% instead of
another 20%? Basically, it's because the stochastic MIP mapping *by
definition* means that each texture call touches half the number of
tiles as before. In contrast, those multiple probes along the
anisotropic axis are almost always within the same tile, and
frequently touch a very nearby pixel within the tile, so not only are
we not needing to look up a new tile from the tile cache, but also the
very memory we need to read is highly likely to be in L1$. But still,
we'll take 2-3% rendering gain any time we can get it, that's
equivalent to a lot of money if you have a really large compute farm.

Some other changes that come along for the ride:

Add a --bluenoise option to testtex (makes for prettier 1spp results),
and add tests for the aniso sampling.

Some internals changes to precompute min w,h of mip levels so there is
less per-texture-call rifling through the ImageSpec of each MIP level.
Sadly, this did not produce any consistently detectable speedup in
overall rendering.

And I changed the interface for stochastic texturing a bit. The old
way involved asking for new MIP modes, StochasticAniso or
StochasticTrilinear, in addition to being sure to set TextureOpt::rnd
to the stratified random number you are using for sampling. Now we are
deprecating StochasticAniso and StochasticTrilinear. Just use the same
old mip levels you always did. So the new interface can be summarized
as follows:

* On each texture call, setting opt.rnd >= 0.0f is itself a request for
  stochastic texturing on that call (opt.rnd will default to -1.0, and
  any negative value does the old fashioned non-stochastic filtering).

* A ShaderSystem-wide option "stochastic" (int) indicates which things
  should be sampled stochastically, for those lookups that have rnd >= 0.
  It's a bit field: 0 means no stochastic sampling (even if rnd >= 0),
  1 means to do stochastic MIP level selection 2 means to do stochastic
  anisotropic sampling (so 3 means to do both, and higher bits are reserved
  for future extensions). The default is 0, so renderers need to enable
  it to get any stochastic texturing.

Finally, let me give a reminder that you ONLY want to do stochastic
texturing for shading that involves multiple stochastic samples per
pixel, like orinary surface shades. For displacement (shade once per
mesh vertex) or "imager" (shade once per pixel), you just have a
single shade that you want perfectly filtered, so you probably don't
want to set opt.rnd >= 0 in those cases.
2022-07-05 19:00:28 -07:00
Larry Gritz f0c3cccd44 CI: Test against fmt 9.0.0 (#3466) 2022-07-05 15:37:42 -07:00
Aras Pranckevičius 62400c3de8 DDS: speed up reading of uncompressed images (#3463)
Previous code was doing ioread one pixel at a time. Change it to
read one scanline at a time, similar to e.g. how BMP reader does it.

On a 8192x8192 rgba8 image (256MB), on Apple M1 Max "iinfo --hash"
time goes from 2.19s down to 0.65s, and is now similar to the time
it takes on an uncompressed TIF or BMP image.
2022-07-04 10:01:49 -07:00
Aras Pranckevičius 8a13790cd5 PR template: fix links to work in actual PR page (#3464)
When viewing this .md file in Github UI, everything seems to work. But when creating an actual PR, the links to CONTRIBUTING and CLAs point to nothing that would exist. Looks like they try to be relative links from the "create a new PR" page. Workaround seems to be to use absolute links instead.
2022-07-04 09:26:46 -07:00
Larry Gritz 43247981c5 CHANGES 2022-07-02 22:33:03 -07:00
Aras Pranckevičius 5e67c09ece DDS: replace libsquish with bcdec, add BC4-BC7 (#3462)
Implements support for BC4, BC5, BC6H (unsigned and signed) and BC7
GPU texture compressed formats in DDS reader (#2338).

- BC4: loaded into 1 channel uint8,
- BC5: loaded into 2 channel uint8,
- BC6H: loaded into 3 channel half,
- BC7: loaded into 4 channel uint8.

This is implemented by replacing whole of libsquish (~4700 lines of
code) with bcdec.h (https://github.com/iOrange/bcdec, ~1300 lines of
code). bcdec.h has an advantage of being faster, smaller and supports
all BCn formats for decoding.

bcdec.h license is MIT or Unlicense (aka public domain), updated all
the relevant third party / license files that I could find.
2022-07-02 09:29:55 -07:00
Aras Pranckevičius 50f0e273a9 dds: Add more DDS test images (#3459) 2022-07-01 22:17:14 -07:00
Larry Gritz 249ccaf21b CI: Security fixes (#3454)
* Add a SECURITY.md detailing our security policy and the private
  email address to contact to report vulnerabilities.

* Create scorecards.yml, to run OSSF scorecard to check supply chain
  security issues. It has some false positives, but it's only advisory.

* Make sure actions we use don't get write perms on our repo.

* Use exact SHA's for actions versions to guard against hijacked
  actions repos that might try to substutite something else at the
  version tag we use.

* Tried to use harden-runner action to ensure no actions on the runner
  overwrite source code or have unauthorized outgoing net connections
  during the GHA run, but currently leaving it disabled because of too
  many false positives -- it flags every dependency download as a case
  of altering source code. Which it technically is, but it doesn't
  matter for any jobs that aren't producing any artifacts that will be
  consumed or relied on by users.

Learned about this from a security talk.
2022-06-30 17:24:04 -07:00
Larry Gritz 7492ef0d0b idiff: add --allowfailures and convert output (#3455)
* --allowfailures is a big hammer to allow a certain number of pixel
  mismatches by any amount.
* Convert diff to modern std::format based output.
2022-06-27 11:27:34 -07:00
Aras Pranckevičius 26cc78c464 Build: allow "arm64" arch in make (#3456)
On Apple Silicon, `uname -m` returns `arm64`. The make platform detection script was allowing `aarch64`, so similar to that one, also allow `arm64`.
2022-06-27 08:35:05 -07:00
Larry Gritz 9aeb9d512b Timer: use clock_gettime rather than gettimeofday (#3443)
On Linux, we'd been using gettimeofday, which gives results with usec
resolution. Switch to clock_gettime, which has nsec results.

In practice, the round trip time of a pair of "get time" system calls
is about 30-50ns in either case. But the new call at least nominally
returns ns resolution values. Another way of saying that is: the
answers we get should be more accurate with this call, but the call
itself is the same expense as before, so we should still be just as
cautious about not inserting timers around events that are so brief
that the timers themselves are going to be a significant addition to
the cost.

This only effects Linux (and maybe BSD?). On MacOS, we use
mach_absolute_time(), and on Windows we use QueryPeformanceCounter(),
so neither of those platforms is affected by this patch.
2022-06-25 08:24:34 -07:00
Larry Gritz 5cee511134 Fix crash when ioproxy is passed to a plugin that doesn't support it (#3453)
The plugin was freed before the error message printed that depends on
it.
2022-06-25 07:20:07 -07:00
Larry Gritz 1e74b7ecf5 ustring: add OIIO_USTRING_HAS_USTRINGHASH symbol (#3449)
This makes it easier for downstream users to test if ustringhash is
available in a particular version of OIIO.
2022-06-18 08:32:06 -07:00
Larry Gritz 2213f62991 Change DoNotOptimize declaration to not conflict (#3444)
More care with "forceinline" so it doesn't interfere with the
"optnone" on some platforms.
2022-06-17 15:09:15 -07:00
Larry Gritz bc617dd0d1 TextureSystem: Change internal hq_filter to std::unique_ptr (#3448)
It's a very minor internal idiom modernization.
2022-06-17 11:26:27 -07:00
Larry Gritz f1a8ea067c TextureSystem: fix typo in attribute name (#3447)
Oops, calling it "m_max_tile_channels" (the name of the member
variable) instead of "max_tile_channels" (the name of the attribute)
actually prevented properly setting or retrieving the attribute by
name.
2022-06-17 11:25:43 -07:00
Larry Gritz 1b9638864e ustringhash (#3436)
ustring is a unique string (that lives in an internal hash table) whose
representation is the pointer to the characters that live in the table.

ustring hash is its alter ego -- it also refers to a ustring in the
internal hash table, but the representation is just the hash itself.

It presents an interface that is a subset of that of ustring, and in
many ways they can be used interchangeably.  For ustringhash,
accessing the characters requires using the hash to find the string in
the table -- which is not hard, but more expensive than accessing the
charcters with a ustring, where the representation is the pointer
directly to the characters.

For some uses where you don't need access to the characters in any
performance-critical paths, this may be a more convenient
representation.  In particular, it's well suited to a GPU that doesn't
have access to the character memory. Another interesting difference is
that from run to run, a ustring may have a different literal value,
since there's no reason to expect that the pointer to a string like
"foo" will refer to the same memory location every time the program
executes, but in contrast, the hash is guaranteed to be identical
from run to run.

In the process of adding unit tests for ustringhash, I ended up
overhauling all of ustring_test.cpp, as I saw that the ustring tests
were extremely cursory. Did a tiny bit of (non-breaking) touch-ups
on a few ustring methods as well.
2022-06-17 11:25:12 -07:00
Larry Gritz 46d97b2cc4 PNG: beef up error detection and propagation (#3442)
Especially for corrupt/broken files.
2022-06-13 10:05:11 -07:00
Larry Gritz 9beaa93d3a JPEG2000: better detect failure to open the file (#3440)
We were missing cases where the underlying OpenJPEG library itself
had errors reading corrupted files, or errors didn't propagate around
correctly.
2022-06-12 17:57:46 -07:00
Larry Gritz 999a7a4b21 BMP: protect against corroptions with palette indices out of bound (#3435)
If the BMP image we're reading declares a certain sized palette, but
then has pixels that contain values outside the range of that palette
size, we would read past the end of arrays.
2022-06-10 19:28:26 -07:00
Larry Gritz b9905464fb BMP: detect corrupted images (#3434)
Check for nonsensical image dimensions or total size before doing
buffer allocation.
2022-06-10 09:52:14 -07:00
Larry Gritz 040d71bfaa Targa: fix reading of tiny image (#3433)
With a 1x1, 2bit image of a Targa 1.0 file, the entire image was only
22 bytes, so the seek to 26 bytes before the end to look for the
Targa 2.0 data... obviously failed.

Don't look for the Targa 2.0 block if the file itself is not long
enough to hold both the header (18 bytes) and the block (26 bytes).
2022-06-10 08:51:26 -07:00
Larry Gritz 069f079eb5 Rename src/dds.imageio/squish/simd.h -> squish-simd.h (#3424)
This tiny change is a quality-of-life fix for me, addressing the fact
that there are two different simd.h files in our code base. I never
would have done that on purpose, but one of them is part of the
imported "squish" source code that we use for dds encoding.

For years I've been frustrated that reflexively typing `CMD-P simd.h`
in the editor has a 50/50 chance of pulling in this file, when in fact
there is literally a 100% chance of my wanting
src/include/OpenImageIO/simd.h.

So finally put my editing brain out of its misery by renaming the file
that I never want to edit.
2022-06-06 23:30:46 -07:00
Larry Gritz 78a504c6a5 ci: Bump OpenColorIO for 'latest' tests (#3425) 2022-06-05 17:14:01 -07:00
Larry Gritz 6d3e16fae3 Minor Python fix -- allow setitem to process a py::bytes as a string. (#3423) 2022-06-02 19:25:20 -07:00
Larry Gritz 597b8e6775 Straighten up OpenColorIO_FOUND vs OPENCOLORIO_FOUND (#3422)
We were using it inconsistently.
2022-06-02 15:17:23 -07:00
Larry Gritz dff26bd738 CI: Test the latest libtiff (#3420) 2022-05-31 22:39:45 -07:00
Larry Gritz a7aa251db4 testtex --minthreads and --lowtrials (#3418)
When doing thread "wedge" tests, most of the time spent is for the
1-thread case. Who cares about 1 thread anyway? So we make two
improvements with new command line options:

* --minthreads sets the minimum number of threads that will be
  used. For example, `--minthreads 2` will skip the single-thread case
  and start the wedge with the 2 thread case.

* --lowtrials is an optional maximum number of trials just for the 1
  or 2-thread case (overriding --trials just for those thread counts,
  if it is a lower value).

By default, the old behavior is still the default. But these allow a
bit of customization in the tradeoff of how much time to invest in the
very low thread counts in a wedge of thread timings.
2022-05-31 09:53:43 -07:00
Larry Gritz 12346eaf09 TIFF: fix read problem with tiff files with non-zero y offset (#3419)
You'd think there would be no way that basic failure like this could
occur after 14 years, right?

But the TIFF reader code was a little mixed up about the fact that the
internal m_next_scanline field is relative to the starting scanline of
the image, not an absolute value. But in the case of the code that has
to deal with handling the stray scanlines at the end of a strip-read
file neglected to set it properly and the end of the stripped part.

Obviously, for TIFF files with a first scanline of 0 (the vast, vast
majority), failing to adjust by this offset doesn't matter. And also
as long as the reading continued to be strictly sequential, it also
was asymptomatic. But in the presence of certain multithreaded random
access patterns, it makes a difference. Oops.
2022-05-31 09:52:16 -07:00
Larry Gritz 593bd319a7 UDIM speedups by eliminating mutex (#3417)
The udim_lookup_mutex_pool is not necessary. Just using an atomic
pointer for udiminfo.icfile is enough.

I'm seeing about a 5-8% overall speed improvement in testtex-based
intense udim benchmarks under heavy threading, a ~2% overall
improvement in a real rendered scene that uses a bunch of udim
textures (I think there are bigger bottlenecks elsewhere that I'll
move on to next, but every little bit helps).

Some testtex enhancements coming along for the ride:

* UDIM-oriented tests (automatically decuded if the test textures
  contain `<UDIM>` in their name.

* --maketests will construct random test textures and use them (handy
  if you need lots of textures for a big test, but don't want to store
  them). The tests are based on a file pattern using std::format-like
  replacement with an index. Also, if the pattern contains `<UDIM>` in
  the name, it's understood to be a udim pattern and many individual
  udim piece files will be created.

An example of these two items in action is:

```
testtex --maketests 200 "tmp/foo{:04}_<UDIM>.exr" --threadtimes 8 -iters 100000000 -runstats -v --handle -maxfiles 1000  -trials 5 -wedge
```
2022-05-25 19:51:38 -07:00
Larry Gritz 7ca693842f Adjust string formatters after change in fmt master (#3416)
fmt master seems to have just deprecated the ability for
fmt::sprintf("%s") to default to printing anything that allows stream
output. This breaks use of Strutil::sprintf formatting ustrings.

This isn't yet in any tagged release of fmtlib, but I'm trying to get
ahead of it.

The quick fix is to just change those handful of places to use
std::format style calls, which we are slowly converting to anyway.

Also throw in a fmt::formater for ustrings for good measure.
2022-05-22 09:24:18 -07:00
Larry Gritz 0dde711a71 Convert testshade to modern string formatting (#3415) 2022-05-21 23:34:56 -07:00
Larry Gritz 7fd5f527c8 CI: Fix ci upload of clang-format diffs (used wrong syntax) (#3414) 2022-05-21 20:33:54 -07:00
Larry Gritz 116a75dc6c Fix comment typos 2022-05-13 10:31:29 -07:00
Larry Gritz e726597fca Build: Do NOT auto-download test images by default (#3409)
It's a lot of data, you don't need it if you don't want to run the
full testsuite, and a lot of places and distros have policies against
live downloads happening in the build step. Also, downstream projects
that need to build OIIO for their CI or other reasons don't want to
accidentally download a lot of test data they won't need.

So change the default of OIIO_DOWNLOAD_MISSING_TESTDATA to OFF.

Build with -DOIIO_DOWNLOAD_MISSING_TESTDATA=ON to turn on auto
download of the data images, or else run
src/build-scripts/install_test_images.

Now, this does have the following danger: That people who build OIIO
and do want to run the tests -- and don't know to turn this option
back on -- will end up with very few tests able to run.

We largely address this by observing that quite a lot of our tests
that depended on oiio-images actually depended only on one file
(grid.tif, which is not especially large). So by making a copy of that
file in testsuite/common, quite a few additional tests can run even
without oiio-images.

Though, to be clear, there are still many tests that want oiio-images,
particularly tests that validate support for various image file
formats, which often depend on large collections of images that are
stored in oiio-images. So remember, if you are developing OIIO, the
best policy is to run the whole testsuite. But on the other hand, if
you submit a PR, they'll all be run in CI as well.
2022-05-12 00:08:53 -07:00
Larry Gritz 2c093e6c5e CI improvements -- don't overwrite cmake caches (#3408)
For failed CI builds, save the cmake caches in a safe place, don't zip
them up in situ, because then when I unpack them in my build area
locally, they overwrite my working cache.
2022-05-08 18:01:51 -07:00
Larry Gritz 866c7ba2ae CI: adjust to upgrading Intel Clang compiler to 2022.1.0 (#3407)
The Intel OneAPI LLVM-based C++ compiler, as we download it from Intel
for our CI, bumped from 2022.0.0 to 2022.1.0.

New warning popped up -- newest Intel LLVM-based compiler warns about
overriding certain floating point math flags.

Also had to adjust thresholds on a couple texture tests that have a
few pixels change slightly due to numerical differences.
2022-05-08 08:50:17 -07:00
Larry Gritz 3f58a8dc78 More changes to hide Imath: new half.h, improve vecparam.h (#3406)
Another round to hide Imath externally to OIIO public headers as well
as speed up our own builds.

* Remove the external reference to Imath::M44f from color.h, and instead
  use M44fParam.

* The `<OpenImageIO/Imath.h>` includes the most commonly used Imath
  headers including half.h. But this is unnecessarily expensive (and
  presumptuous about wanting other Imath types as well as fmt.h) if
  you just need to know about `half`.  So we create a new
  `<OpenImageIO/half.h>` that only includes what you need for `half`
  (as before, with logic to handle the changing location of the half.h
  header depending on whether you're using Imath 3.x or OpenEXR 2.x).

* Several files that included Imath.h, but in reality only needed half
  all along, change to including OpenImageIO/half.h.

* simd.h leans more on vecparam.h and other template trickery to
  reduce exposure of methods that only work in the presence of Imath
  headers, and make fewer use cases that would care whether the Imath
  headers are included before or after simd.h (which is less
  controllable for unity builds).

* Vec3Param gains a `cast<V>()` templated method that allows easy
  casting to foreign vector types even if Imath headers are not
  included prior to vecparam.h being included (which is less
  controllable for unity builds).
2022-05-07 09:32:34 -07:00
Larry Gritz 9c42b0b30e New bitcast is closer to std::bit_cast (#3403)
We have a template OIIO::bit_cast which has served us for a while, but
it turns out that C++20 has std::bit_cast which operates ALMOST the
same -- unfortunately, the tempalte arguments are reversed from the
way we did it!

So here we:

* Set up a new `bitcast<>` that works exactly like C++20 std::bit_cast.
* Implement our old bit_cast in terms of the new one, for now.
* Set up `#if` trick so that the confusing OIIO::bit_cast will be
  marked as deprecated beginning with OIIO 2.5, and will be removed
  entirely from OIIO 3.0. (Farther out than that, we may choose to
  re-introduce bit_cast as truly being identical semantics to
  std::bit_cast. But before that is possible, we need to completely
  ween downstream users off the old one.)
* Took the opportunity to expand the set of compilers for which
  certain bitcast overloads use Intel intrinsics. Previously, we only
  did this for the Intel compiler, but it seems to work for modern
  versions of clang and gcc as well. Do a little bitcast testing in
  fmath_test.cpp to verify that the use of these intrinsics doesn't
  break for any of the compilers we use for CI.
2022-05-03 21:30:27 -07:00
Larry Gritz be78eccbde CI: add clang14 test (#3404)
A couple very minor changes were necessary to address new warnings.
2022-05-01 00:12:33 -07:00
Larry Gritz 5852749bb7 CI tests use unity builds for speed (#3402)
Over the span of several individual PRs, we've made the code base safe
for "unity" (a.k.a. "jumbo") builds -- a feature of CMake that
automatically combines multiple .cpp files into a single compilation
unit (basically making temporary .cpp that `#include`s each original
cpp) in order to, allegedly, speed up compilation by not re-parsing
headers multiple times, and other sources of per-module overhead.

We discovered early on that on a modern computer where modules are
built in parallel (another automatic feature of CMake), jumbo builds
are simply not an overall performance improvement for OIIO. Basically,
the efficiency gain from removing redundant parsing is mostly offset
by the loss of parallel efficiency -- fewer and larger modules means
there are periods where all cores are not able to find work to
do. (Reductive example to illustrate the basic problem: If you have 8
independent modules to compile, and each takes 1 second, 8 cores can
compile the entire collection in parallel in 1 second. But a unity
build that batches those files in groups of 4 and achieves a 2x
speedup, thus compiling each set of 4 modules in 2 seconds instead of
4, only can do two of these compilations in parallel, so it takes 2
seconds. We've cut the total work in half, and yet it takes twice as
long in real time to complete, and 6/8 of your cores are idle.

OK, but that's when you have several cores. If you had only one core
(or maybe two) so you weren't using much parallelism in the first
place, then the unity build would look like a win, since you'd really
see the improvement from the amortized overhead of the combined
modules.

Most of us don't have single core machines on our desks, or laps, or
even in our pockets (or on our wrists?).

But we do have single core machines (or close to it) in our CI runners!
We get 1.5-2 cores, roughly, in the slice of VMs we get to run CI on
GitHub Actions. So maybe this is the one place where a unity build would
be of benefit.

That's the theory anyway. Does it pan out? I tested it, and the answer
is basically yes. I can speed up the "build" step of our CI by
somewhere in the vacinity of 30% (varies a LOT from run to run). I
tried a whole bunch of different approaches, summarized in the table
below. I picked the best basic strategies revealed by those tests and
set up the CI to use them. (I didn't preserve all the other
permutations.)

| Name                    | try 1 build | try 2                | try 3          | try 4    |
|:----------------------- | ----------- | -------------------- | -------------- | -------- |
| **linux gcc9 BASELINE** | 14:19       | 11:46                | 11:56          | 13:32    |
| linux gcc9 group        | 9:39        | 8:06                 | 9:58           | **7:58** |
| linux gcc9 batch 8      | 8:06        | **7:17**             | **8:02**       | **7:59** |
| linux gcc9 batch 16     | 8:29        | 7:32                 | **7:56**       | 9:35     |
| linux gcc9 batch 4      | 8:39        | 8:38                 | 8:52           | 10:31    |
| linux gcc9 batch 2      | 13:34       | 12:43                | 11:22          | 9:32     |
| linux gcc9 batch mix 4  | 7:22        | 9:14                 | 9:01           | 9:39     |
| linux gcc9 batch mix 2  | 9:11        | 7:45                 | 10:55          | 9:36     |
| **linux icx BASELINE**  |             | 14:39                | 15:07          | 15:06    |
| linux icx group         |             | 11:59                | **10:36**      | 10:26    |
| linux icx batch 8       |             | **9:40**             | 11:31          | **9:14**     |
| linux icx batch mix 4   |             | 10:06                | 11:58          | 11:16    |
| **macos11 BASELINE**    | 25:41       | 27:53                | 26:30          | 28:32    |
| macos11 group           | 10:56       | 20:24                | 19:28          | 19:24    |
| macos11 batch 8         | 16:43       | 17:38                | **18:34**      | **17:42**         |
| macos11 batch mix 4     |             | **9:22**             | 19:12          | 18:26         |
| **windows BASELINE**    | 20:17       | 23:27                | 28:43          | 19:13         |
| windows group           | 23:05       | 15:57 (tests broken) | 21:57 (broken) | 15:33         |
| windows batch 8         | 21:16       | 15:57                | **17:38**      | **15:08**         |
| windows batch mix 4     |             | **15:30**            | 23:19          | 15:16         |

Notes:

* Timings vary wildly from run to run. You never know which VMs you'll
  get or how overloaded they are. But over 3 trials, the trends were
  clear.
* I rigged it to clear the ccache, so these are FULL uncached builds.
* This is only "build" time. The CI run also includes time to set up the
  VM, download docker images, build or install dependencies, and of course
  run the testsuite. So the overall speedup of the entire CI run will not
  be as improved overall as these numbers indicate for the build step.
  But still, saving several minutes per job means the CI tests turn
  around faster, and that's what we want.
2022-04-29 12:00:36 -07:00
Larry Gritz 815463344d Eliminate use of boost::gcd (#3401)
For C++17 and beyond (and maybe earlier in some compilers), we already
used std::gcd. Now for C++14 compilers without std::gcd, we roll our
own simple gcd implementation instead of using boost::gcd. Maybe it's
slightly slower, but this is nowhere near a performance-critical
path. It's worth it to take one more step at eliminating boost.
2022-04-28 22:03:16 -07:00
Larry Gritz 50062fc121 Improvements in opening unknown files (#3400)
Reminder: When opening a file by name, first it tries to open assuming
that the file's extension indicates the format. If that doesn't work,
it tries all known format readers to see if one will work.

This patch includes several improvements to this process and surrounding
code in imageioplugin.cpp:

* When trying all formats because the extension was wrong, instead of
  traversing the input_formats map in alphabetical order of the list
  of all format names + extensions, try the three most common formats
  we encounter (openexr, tiff, jpeg) FIRST, then try the other formats
  in alphabetical order. We do this by traversing the
  format_list_vector, which contains all format names in the order
  they were declared, and ensure that those common formats are
  declared first. Basically, this means that if the mislabeled file is
  one of those most common formats, the correct reader is found after
  only a couple tries, instead of having to try a dozen or more bad
  guesses of rarely encountered formats.

* Debug mode messages that make it easier to understand which readers
  are being tried for which files.

* Comments clarify that input_formats and output_formats hold not just
  the map from format names to creators, but also map extensions to
  creators. (That confused me while I was debugging this, so I figure
  the clarification is needed.)

* Establish a new extension_to_format_map that lets you get the format
  name if you know the extension.

* Get rid of input_extensions and output_extensions maps, which weren't
  ever used.

* Some other minor refactoring.
2022-04-28 22:03:04 -07:00
Larry Gritz 0318ea44c1 More changes to support unity/jumbo builds (#3398)
* Make gif, png, targa, tiff unity-ready
* Make exr unity-ready
2022-04-25 21:34:07 -07:00
Larry Gritz abb41e5d05 Adjust debug templates -- they can have a simpler template trick (#3399) 2022-04-23 22:44:59 -07:00
splidje 5dce57435f py_imagespec: added get_bytes_attribute to bypass decoding as utf-8 (#3396)
py_imagespec: added get_bytes_attribute to bypass decoding as utf-8 and instead returning as a Python3 bytes object.

Fixes #3395
2022-04-22 18:43:21 -07:00
Larry Gritz d4074f0b31 ustring::from_hash() (#3397)
If you know the hash of a ustring, this tells you the ustring.
(Caveat: in the very unlikely chance of two ustrings having the same
hash, this will return the first one it finds in the table.)
2022-04-22 09:21:21 -07:00
Larry Gritz f1d619e915 More work to enable unity/jumbo builds (#3393)
* Make dpx and cineon unity-ready

* Make jpeg2000 and dds unity-ready
2022-04-21 21:22:36 -07:00
Larry Gritz 965cf04d7d oiiotool: attribute actions get subimage controls (#3384)
I realized that --attrib (and several related actions) only set the
attribute as directed for the first subimage if it's a multi-image
file (such as a multi-part exr), or all of them if the -a flag is
used.  But there was no ability to set it for a particular (non-first)
subimage, like many other oiiotool actions have the ability to do.

So in this patch, I refactor the following commands to use the
OiiotoolOp and related macros, which automatically make it responsive
to the `:subimages=` optional modifiers:

    --attrib
    --sattrib
    --eraseattrib
    --caption
    --orientation
    --clear-keywords
    --iscolorspace

As a bonus aside, one thing this lets you do is set a different
compression method per-subimage using, e.g.,
`--attrib compression:subimages=3 dwaa:100`.
But if you set compression with `--attrib compression`, do not also
use `--compression`, which will override it and also apply to all
subimages.
2022-04-21 12:36:18 -07:00
Larry Gritz 5767c62394 More unity-ready changes (#3392)
* Everything in texture system
* simd.h
* thread.cpp
* paramlist
2022-04-17 11:16:44 -07:00
Larry Gritz 596210427a OIIO_ERRORHANDLER_HIDE_PRINTF as aid for fmt conversion (#3391)
When this symbol is defined, this marks as deprecated the ErrorHandler
class methods that use sprintf formatting notation. It's not enabled
by default, but a downstream project can define the symbol in order to
help root out any uses of the old style formatting functions, to aid
identifying and changing those spots to the new style, long before
they are truly deprecated or removed from OIIO.

This change also sets up an OIIO_INTERNAL symbol that will be present
when OIIO itself is compiling, but not a downstream project using the
OIIO headers.
2022-04-15 17:01:49 -07:00
Larry Gritz a330bae6a7 Make oiiotool unity-ready (#3389)
This is the first tiny step to fixing all the little things that break
in a unity build. This one is pretty small fry -- the oiiotool set of
modules only needed some minor rearrangement of header file include
order.
2022-04-15 17:01:03 -07:00
Nathan Rusch fdafe1c3dc ImageBufAlgo: Initial implementation of st_warp transform function (#3379)
* Initial implementation of `ImageBufAlgo::st_warp`

* Simplify default filter logic, and share it with `ImageBufAlgo::warp`

* Add st_warp to oiiotool

* Add tests for bespoke `st_warp` validations that are done before IBAprep

* Add st_warp test to oiiotool-xform testsuite

* Address review notes

- Remove ST buffer datatype guard
- Simplify additional ROI prep
- Remove unnecessary buffer reallocation

* Use sample accumulator type for source/dest iterator USERT

* Add `--st_warp` section to `oiiotool.rst`
2022-04-15 16:15:54 -07:00
Larry Gritz 092b6af752 Fix botched build from PR 3381, command line utils not installed (#3390)
Cut/paste error inadvertently deleted a critical cmake line that I
wasn't intending to alter or remove, that resulted in the command line
utilities not being tagged for part of the install step. Oops!
2022-04-14 10:22:57 -07:00
Larry Gritz 7fc5199231 CHANGES and set developer snapshot 2.4.1.1 2022-04-13 10:48:22 -07:00
Larry Gritz 7956ca328f Speed up case insensitive string comparisons (#3388)
Oh boy, never leave anything unbenchmarked.

Turns out the boost::algorithm functions we were relying on underneath
many Strutil "case-insensitive" comparisons were ridiculously slow.
We thought they were good enough because they allowed specification of
locale, so we could just pass the static classic locale, and so they
would be inexpensive because they didn't have to query the current
locale.  But this is wrong, they were still ghastly.

So here I rewrite Strutil::iequals, iless, starts_with, istarts_with,
ends_with, iends_with in terms of a new (internal) Strutil::strcasecmp
and strncasecmp (which underneath handle differences in platform, and
use the locale-independent versions). The net result is that most of
those case-independent comparisons speed up by a factor of
50-100x. Wow.

I still need to tackle the family of 'ifind' related functions. They
are a bit trickier. But I'll leave them for another time, because I
need to roll this present fix out right away to fix a real production
bottleneck.

(Worth noting: iequals is instrumental when you're searching a
ParamValueList for a particular name, which is what happens when you
look up attributes from an ImageSpec, which is what happens when you
call get_texture_info(), which is what underlies OSL gettextureinfo()
calls in the cases that they cannot be constant-folded during runtime
optimization. So this came to my attention when analyzing a slow scene
whose shaders had a pathological explosion of gettextureinfo calls that
couldn't be optimized away.)
2022-04-13 10:31:02 -07:00
Larry Gritz 47eac0dfa7 Speed up IBA::isConstantColor (#3383)
Reminder: isConstantColor() finds out if an ImageBuf is constant
color.  It uses the thread pool to check several areas in
parallel. Once any task finds that its subregion is not constant, it
sets a flag so that as other subregions are pulled off the task queue,
they will take an early out if one of their siblings already knows the
image is not constant.

Turns out this isn't much of a big savings in practice, because lots
of regions may be in flight by the time one region realizes it's
non-constant, and once a region task starts, it doesn't check the flag
again.

This patch speeds up isConstantColor by a pretty big factor for
non-constant images (it can't really help for images that ARE
constant) in the following ways:

1. Before doing anything, it checks to see if the FIRST TWO pixels of
   the image are unequal. If that's the case -- and it's a fairly
   common case for non-constant images -- then it immediately knows
   the whole image is not a constant and doesn't need to look at
   anything else or launch any of the threads at all. (If it is a
   constant image, or if the first two pixels are just coincidentally
   identical, this quick check of only two pixels didn't really cost
   us any masurable time.)

2. In addition to checking the result flag at the start of each
   parallel job, now we also check if the flag has been changed as we
   iterate to each pixel. So pretty much as soon as one thread finds
   unequal pixels, the other threads can spot this and stop their
   tasks early, no need to finish looking at their entire region.  (To
   make the more frequent checks of the flag inexpensive, I changed it
   from an atomic to just a regular bool. It doesn't need to be
   atomic, because the strict ordering is not important at all here
   and it doesn't change the result if the threads' access to the flag
   is unsynchronized.)
2022-04-13 08:50:45 -07:00
Larry Gritz a5d723be8a exr output: Fix dwaa compression default (#3387)
When outputting OpenEXR files, in a case where the "compression"
request was for "dwaa" (no compression specified in the main name,
like "dwaa:100") we accidentally forced a default quality level of 4,
which is the default we wanted for zip compression. But that's not a
good default for dwaa!
2022-04-13 08:50:06 -07:00
Larry Gritz 4e985f6347 Lay groundwork for unity builds (#3381)
As I learned recently, a "unity" (aka "jumbo") build is where multiple
.cpp files are combined into one translation unit -- imagine a unity.cpp
that simply has

    #include "file1.cpp"
    #include "file2.cpp"
    ...
    #include "fileN.cpp"

and so you compile unity.cpp instead of the separate file?.cpp files
individually.

Turns out that CMake understands this concept and can do it for you
automatically!

The benefit of a unity build is that file1...fileN probably include
most of the same headers, expand the same templates, etc., so a bunch
of the per-file work of the compiler can be done once rather than
redundantly for each file.

There are two potential downsides, however:

1. It may not be safe to concatenate your cpp files! For example, if
   both file1.cpp and file2.cpp each contain a `static int foo;`, that
   may have been safe when compiled separately, but is not allowed to
   happen twice in one compilation unit. Similarly, if you have headers
   that don't have proper guards against multiple includes, etc. So one
   should expect a whole lot of little fix-ups are needed for this to
   work properly. (We'll come back to that topic.)

2. Combining source file into these "jumbo" modules can make heavily
   parallelized builds on many-core machine not be able to load balance
   or keep all the cores busy. (Simplified examples: if you have 16 .cpp
   files on a 16 core machine, each core can compile one cpp file in
   parallel with the others. But if you mash the modules into just one
   huge cpp file, give that to one core, and your other 15 cores are
   idle, so the full build probably takes much longer.)

I tried this out, including the many fixups implied by (1) above, and
at first the unity builds were slower on both my laptop (8 cores) and
workstation at work (32 cores), because of downside (2) explained
earlier -- harder to take advantage of parallel builds when there are
fewer, bigger, compilation units. Some tweaking of strategy got me to
the point where I could always get the unity builds to go faster, but
not by a whole lot when many core were available. Slighty faster, but
not worth the trouble. A bit disappointing, nearly abandoned the whole
idea.

HOWEVER, in situation where you are limited to very few cores (like in our
CI, which allocates 2 cores, and it sure seems more like 1-1.5 for the
Windows and Mac CI runners), the unity builds are substantially faster --
there's already not much parallelism to exploit, so you come out ahead
with the savings of that redundant per-file work we talked about.

So my current thinking is to go ahead and make the changes that allow
unity builds. I don't particularly recommend them when highly parallel
builds are available to you, but it might help to cut our CI
turnaround time down on the GitHub runners. And maybe it will help in
other situations for other people.

Ok, then. The present patch introduces these concepts and makes the
CMake and other build system changes to allow unity builds. (N.B. It
won't WORK yet, so don't try it!) After we get that out of the way, in
subsequent PRs I'll show all the changs to the code that were
necessary to fix all the little things that went wrong when source
files got combined.
2022-04-11 22:11:59 -07:00
Larry Gritz 8c8e119d3a CI: Bump 'latest release' versions of openexr and pybind11 (#3386) 2022-04-11 21:37:46 -07:00
Larry Gritz 304e4cee5b Fix formatting 2022-04-08 22:51:28 -07:00
Christopher KullaandLarry Gritz 727be5ad8f Fix a number of small warnings on windows (#3382)
* Fix warning from duplicate define
* Fix warnings about bool/int expressions
* Fix discarded result warning in PSD input
* Fix codepage warning from unicode symbol in string constant
* Ensure the term object is initialized with the stream we intend to output to
* Fix pointer casts in paramlist test

Signed-off-by: Chris Kulla <ckulla@gmail.com>
Co-authored-by: Larry Gritz <lg@larrygritz.com>
2022-04-08 18:25:50 -07:00
Larry Gritz a4f422ccec CHANGES 2022-04-01 16:36:09 -07:00
Larry Gritz 7c660429a8 More format conversion (#3377)
Bit by bit, we convert all our formatted string from the sprintf
convention to the std::format convention.
2022-03-31 12:28:04 -07:00
Larry Gritz e3cc8e041c Python: support uint8 attributes in and out (#3378)
This is necessary for dealing correctly with ICCProfile ImageSpec
attributes, which are simply arrays of uint8's.
2022-03-31 12:24:52 -07:00
Larry Gritz 2dc807b4b5 Suppress MacOS warnings about OpenGL deprecation (#3380) 2022-03-31 12:24:29 -07:00
Larry Gritz 35b220ca02 ffmpeg reader: take care against possible double free (#3376)
In FFMpegInput::close(), some of the tear-down calls would happen
regardless of if their pointers were already null. Seemed safe, but
maybe not always? So check the pointers.

Fixes #3371
2022-03-27 09:37:22 -07:00
Larry Gritz 921fab6423 BMP files - read additional varieties (#3375)
There are two undocumented varieties of BMP files only written by
certain Adobe apps that we did not properly handle, identified by the
size value in their header.

This is the only explanation I could find about it:
https://web.archive.org/web/20150127132443/https://forums.adobe.com/message/3272950
2022-03-27 09:37:00 -07:00
Larry Gritz 429d4ac7a1 Convert texture and ImageCache stats output from stream io to fmt. (#3374) 2022-03-26 15:42:06 -07:00
Larry Gritz 98b434a819 Make ImageCache stats print openexr:core option status (#3373) 2022-03-25 19:11:25 -07:00
Larry Gritz ece2fd4f18 Fix conflict between RESTful and Windows long path notation (#3372)
When trying to break filenames into the base name and any "RESTful"
arguments (such as "/foo/bar.exr?name=value&dog=cat"), we were
just looking for presence of the "?" to determine if it was a RESTful
thingie and using that as the split position.

But this is thrown off by an odd Windows notation where names that
start with (get this) "\\?\" somehow designate long filepaths. See
See: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation

So the solution is to change Strutil::get_rest_arguments to explicitly
check for this pattern at the start of the string.
2022-03-25 14:57:36 -07:00
Larry Gritz 85e3913bb1 Fix writing deep exrs when buffer datatype doesn't match the file (#3369)
In OpenEXROutput::write_deep_scanlines and write_deep_tiles, don't
just pass the DeepData along -- handle the case of where the DD (the
buffer the caller is presenting) does not match the data types that
you said the file is going to hold. In this case, we need to make a
local temporary DD that holds a copy of the passed-in data, but with
the formats transcoded.

Some changes to DeepData were done to support this.
2022-03-24 22:33:48 -07:00
Larry Gritz 608e593f60 CI: Remove the windows-2016 that will be imminently removed (#3370)
GHA is retiring the windows-2016 image, we won't be able to use it soon.

Also bump openexr versions in a couple places.

There's some in-progress work on a VS2022 test, but ignore that for now,
it's commnted out.
2022-03-21 10:05:06 -07:00
Larry Gritz 9497022cda Custom fmt formatters for vector types (#3367)
I'm a total convert to fmt (and/or std::format, std::print) and slowly
converting all prior use of sprintf and iostream to it.

If I print an Imath::V3f or a simd::vfloat3,

    fmt::print ("v = {} {} {}\n", myvec[0], myvec[1], myvec[2]);

That's ok, I guess, but it's clunky and a big pain to put the format
specification for every element separately if it were a vfloat16,
say. I would like to be able to do this:

    fmt::print ("v = {}\n", myvec);

and in fact, it does print all elements (thanks to some nice behavior
by fmt)!  But this does not work as expected:

    fmt::print ("v = {:.3f}\n", myvec);

fmt's tricks will print all elements, but only using the default format
spec, and the spec above applied so the "whole thing", not each element,
if you see the distinction.

So this patch sets up the custom formatter infrastructure to be able
to print array-like things (and in particular, the Imath and
OIIO::simd vector and matrix classes) by specifying the format spec
used for the elements.

The important elements to note:

* detail/fmt.h adds custom formatter helpers for (a) any class with
  operator[] and size() ("index_formatter"); (b) any class that lacks
  these but nonetheless has an array-like memory layout and a known
  length ("array_formatter"). I also added a nonstandard extension to
  the format spec for these, which optionally lets you use a comma
  separator rather than just the space between elements.

* These building blocks are used to specify custom formatters for
  the commonly-used Imath types (in our Imath.h) and our internal
  SIMD vector types (in simd.h).

* simd.h also adds a few other goodies, including an `is_simd<>`
  template, and `size()` constexpr methods to each vector type. These
  make certain template metaprogramming tasks easier for these types.

* A new "type_traits.h" header for collecting a bunch of little utility
  templates, such as `has_subscript<>` and `has_size_method<>`.
2022-03-19 18:21:36 -07:00
Larry Gritz f846cb531a simd.h fixes for armv7 and aarch32 (#3361)
Some neon instructions are only aarch64, guard them better.

Fixes #3360
2022-03-19 18:14:34 -07:00
Larry Gritz 288d0ad096 Print all 4 version numbers in help messages (#3368) 2022-03-18 09:55:35 -07:00
Larry Gritz 313202fe5d JPEG: better handling of PixelAspectRatio (#3366)
JPEG expresses pixel aspect ratio implicitly as header fields
"xdensity" and "ydensity" (which we call "XResolution" and
"YResolution" in our metadata after the TIFF names). We also have
"PixelAspectRatio", so the three of them, if they are all used, form
an over-constrained system. Plus, they may come both in the JPEG
header and also (not necessarily having the same values) in any Exif
block.

And on top of that, the way Nuke and PhotoShop infer the aspect ratio
is BACKWARDS! (If pixelaspect = width/height of a displayed pixel,
then it's also = ydensity/xdensity. But Nuke is the other way
around. Only for JPEG, it gets it right for TIFF and OpenEXR.)

Anyhoo, there were some edge cases in which we were still getting
confused (specifically, that we were making some files that Nuke was
not properly recognizing as anamorphic). This patch tightens up
these cases.
2022-03-18 09:55:11 -07:00
Larry Gritz 7b09f5d4db Fix typo -- used old name for header guard 2022-03-15 14:19:27 -07:00
Larry Gritz 99aae072e7 V3fParam (#3330)
Create a small shim class template called
Vec3Param (and its specialization, V3fParam) that does nothing but
implicitly convert from and to things that looks like 3-vectors
(thanks to some template magic I developed a while back for the Imath
project). And similar for template MatrixParam (and specializations
M33fParam and M44fParam) to pass a square matrix.

Basically the idea is that we can replace the public API function
parameters where we take an Imath::V3f and instead use a
V3fParam. User code that passes an Imath::V3f still works because
V3fParam accepts and converts it.  Implementation code can implicitly
convert the V3fParam to an Imath::V3f, so it doesn't need to be
changed, either. Only the function declaration itself. (Same basic
situation for MatrixParam and Imath::M33f/M44f.)

So in the process, now we have laundered our public API so that it
doesn't reference the Imath types and headers any longer. This confers
two big advantages:

1. It allows OIIO itself and any downstream client code calling OIIO
   to use *different* versions of Imath if they want.

2. It allows client code to not need Imath at all, for example if they
   have their own proprietary vector type that they prefer to use
   internally.

I'm not necessarily 100% sold on this approach, but I think it's got
promise and am seeking feedback. It seems to work, and I was able
to compile OSL against this altered OIIO with *no changes*.
2022-03-13 21:34:39 -07:00
Larry Gritz 2340b90160 Minor tweaks to CI workflow (#3365)
Just some renames and minor refactoring as I settle into the "strategy"
style.
2022-03-07 20:46:03 -08:00
Larry Gritz e82063d163 ffmpeg: make supported file extension check be case-insensitive (#3364)
The use of ends_with instead of iends_with made it so that
capitizalized files (especially on case-independent filesystems like
Windows or some Mac filesystems) were rejected.

(And yes, I did grep the whole code base for ends_with to be sure that
this was the only place we made this mistake.)

Fixes #3362
2022-03-07 20:45:38 -08:00
Larry Gritz 134ea8cc44 Bump master version to reflect ABI changes with the recent string_view 2022-03-07 10:45:18 -08:00
Larry Gritz 41b2a31b7a Build and CI and support for the icx compiler (#3363)
icx is the *new* Intel LLVM-based compiler, and it behaves a lot like
clang (versus icc, which is the "classic" Intel compiler).

* An additional CI test in ci.yml for icx.

* Tweaks in compiler.cmake and platform.h to detect and set options for
  this compiler.

* A variety of warning fixes encountered for this compiler.

* Add a new cmake build-time option `ENABLE_FAST_MATH` (default: OFF)
  for enabling fast-math optimizations that trade IEEE compliance for
  speed. The Intel compiler enables it by default (!), so this build
  option makes icx behave like the other compilers (not fast math
  unless explicitly asked for), which makes the CI tests and other
  behavior more consisent across compilers and platforms.

* Note: The bug that prevents some versions of fmtlib from working
  with icc does not appear to be a problem for icx.
2022-03-07 10:33:53 -08:00
Larry Gritz fcdbd6cd4c Switch to using std::this_thread::yield() now that we are C++11 (#3359)
Fixes 3357, which reported problems with Clang + libc++ + Windows,
where our old code used something pthreads-specific.
2022-03-07 00:50:38 -08:00
Larry Gritz d3648ab272 Fully templatize our string_view (#3344)
Brings us more in line with C++17 std::string_view.
2022-03-07 00:50:16 -08:00
Larry Gritz 461c9c058f CI: Use GHA "strategy" to make test descriptions more compact (#3356)
I finally learned how the "strategy" stuff works and refactored our
CI workflow based on it.

In short, we previously treated each CI test as its own universe, with
a huge amount of repeated build logic. These changes cut down on
redundancy by, for each set of related tests, collapsing them into
just one recitation of the build script logic and a handful of
variables that create the different test variations.

Currently, the categories are (a) all tests based on ASWF containers and
corresponding to VFX Platform specs, (b) "off-year" combinations based
on the native Ubuntu installations, (c) Mac tests, (d) Windows tests,
(e) the clang-format checker.

This refactor cuts the size of the ci.yml file by more than 50%, and
makes it much easier to add or change individual test configurations
in the future.
2022-03-04 20:57:20 -08:00
Larry Gritz 20645f83a8 Strutil::print vs sync::print (#3348)
Strutil::print wraps fmt::format to render the formatted output into a
std::string, then sends the string to Strutil::sync_output(), which
ensures that every string printed (or sent to a FILE or stream) is
done so atomically, using an internal mutex, and with a stream flush
after each string. But this makes it a lot more expensive than it
needs to be, when you don't need such care -- either because buffered
output is ok, or because you don't need the thread safety.

This patch:

* Adds an optional `flush` parameter to sync_output(), defaulting to
  true, which controls whether sync_output flushes or not.

* Introduces Strutil::sync::print, which is the same fully
  synchronous, thread-safe, non-buffering behavior that Strutil::print
  has traditionally had. Use this when you need those features.

* Redefines Strutil::print to be an alias for fmt::print, which means

  - There is one fewer layer of template expansion and generated code,
    and possibly fewer internal string copies, so that should make for
    both faster compilation and faster runtime performance.
  - Results are buffered, no sync after every output, so much faster
    when you don't need that.
  - No internal mutex.

On the platforms we use -- and with the current implementation of
fmtlib -- fmtlib's underlying use of stream and FILE output appears to
be adequately thread-safe. But we can't 100% guarantee this on all
platforms or all future versions of fmtlib, so users who need the
stronger guarantees (and are willing to sacrifice performance) can
simply use sync::print.
2022-03-04 10:03:49 -08:00
Anthony Nemoff 9f74aa2108 Add UDIM pattern <uvtile> (in lower-case) (#3358)
* Add UDIM pattern `<uvtile>` (in lower-case)

This UDIM pattern is equivalent to `u<u>_v<v>`.
See also #3280.

References:
- Clarisse: https://clarissewiki.com/5.0/image-maps-texture.html
- V-Ray: https://docs.chaos.com/display/VMAYA/File+Names+for+Bitmap+Textures

* LG Updated test and ref output
2022-03-02 15:52:29 -08:00
Larry Gritz 16e2bad47d CI: first stab at CI builds for Intel compiler (#3355)
* New CI test downloads the Intel icc compiler and builds with it.
* A variety of minor fixes to address warnings from icc that were
  not apparent from the other compilers.
* Some minor changes to just a few tests and reference output where
  the icc-built compiler produces slightly different (usually LSB)
  results.
2022-02-28 12:35:59 -08:00
Larry Gritz 2669a7d939 Some denorm and flush utilities no longer need to consider gcc 4.8 (#3354) 2022-02-27 20:53:07 -08:00
Larry Gritz 90323d8130 Fix inline discrepancies between template decl and redecl (#3350)
These are cases where we declared a template, then later gave its full
definition, and we marked the declaration of the OIIO_FORCEINLINE but
omitted it from the later definition.

This addresses some compiler warnings from icc.
2022-02-27 19:21:55 -08:00
Larry Gritz 7171b07dd4 Beef up precision in computePixelStats (#3353)
We should have been doing this particular multiplication as doubles, and
in just a couple spots, it slightly changes the answer.
2022-02-27 09:19:00 -08:00
Larry Gritz 1f1510fca8 runtest.py: Rename oiio_relpath to make_relpath (#3349)
Just reconciling some differences between this file and the analogous
one in OSL.
2022-02-27 09:17:59 -08:00
Larry Gritz 829d337264 Build: allow -Werror to be disabled even on CI branches (#3351)
Slight reworking of -Werror logic to let the default behavior be
changed by setting a cmake variable. In particular, this allows us to
make a CI build disable -Werror when we need to.

Previously, having the "OpenmageIO_CI" env variable set trumped all
else and forced -Werror. Now it just contributes to the default behavior,
but setting `-DSTOP_ON_WARNING=OFF` and cmake config time can still
disable it.
2022-02-26 23:44:38 -08:00
Larry Gritz d0302f6333 Avoid internal use of OIIO::string_view::str() (#3345)
Seemed like a good idea when we wrote it, but subsequently,
std::string_view was accepted into C++17 without a str() method. So
for the sake of future full interchangeability with std::string_view,
stop using this method.  We will eventually deprecate it.
2022-02-26 23:43:31 -08:00
Larry Gritz 7b8f4b9b7e Fix broken iinfo --stats (#3352)
Inadvertently broken by PR 3328.
2022-02-26 23:37:09 -08:00
Larry Gritz d15fd4aa06 Improvements to ParamList and ImageSpec to reduce ustring construction (#3342)
Special case some methods of ParamValue, ParamList, and
ImageSpec::attribute for ustring and string_view data, to reduce some
redundant copies and/or ustring conversions.

The internal method init_noclear() is augmented with a flag that allows
the caller to specify that any string data it might point to is already
ustrings, and thus does avoid the costly default behavior of converting
strings in the data block to ustrings. (This is not publicly exposed, so
users can't screw it up.)

So the new ParamValue constructor directly from a ustring can use this
flag to avoid passing the already-ustring through the string-to-ustring
conversion a needless second time. But also, the copy constructor, move
constructor, and assignment can use the flag and avoid the extra
conversion, since by definition they are copying from the contents of an
existing ParamValue which is guaranteed to be already ustring-ified.

While I was at it, I turned the optional arguments of ParamValue
constructors into "strongly typed" flags, deprecating the ones that
take a raw bool, which might be confusing.
2022-02-21 21:20:14 -08:00
Larry Gritz f6fb1eb81a Wean ourselves off of string_view::c_str() (#3343)
c_str() was cute, but it's a little dicey and it's not present in
the C++20 std::string_view. We didn't use it in a ton of places,
so replace with other idioms so that in the future we are better
able to interchange with std::string_view or replace our own entirely
once we have flying cars and C++20 minimum.
2022-02-20 16:19:19 -08:00
Larry Gritz 8c714804a9 Auto conversion from among different string_view types (#3337)
* Allow ustring and OIIO::string_view to auto-cast to fmt::string_view
  (helps some fmt formattting of types without custom formatters).

* When std::string_view (C++17) and/or std::experimental::string_view
  (some compilers pre-C++17) are available, add OIIO::string_view
  auto-construction from and auto-casting to those types.
2022-02-19 14:39:37 -08:00
Larry Gritz 7ee7477c4f Mark a bunch of long-deprecated things as OIIO_DEPRECATED (#3328)
...and stop using them internally as well.

For some of the IBA functions, we were unable to fully mark them as
OIIO_DEPRECATED (so instead that hint is commented out) because the
function signatures of the deprecated and new ones can be
ambiguous. We're just going to have to delete those when we are at a
compatibility break point, without going through a period where they
are present but marked as deprecated.
2022-02-19 10:11:25 -08:00
Larry Gritz 4260a7cc81 Track down some integer overflow warnings (#3329) 2022-02-19 09:31:11 -08:00
Larry Gritz 4f1398a689 CHANGES and bump version for developer preview 2022-02-18 10:04:33 -08:00
Larry Gritz e800c05dfd oiiotool --warp improvements (#3341)
* New "wrap" optional modifier lets you specify which wrap mode to pass
  to IBA::warp().

* fix typo in error message.
2022-02-17 23:37:00 -08:00
Larry Gritz a53399deb5 oiiotool --pixelaspect : fix setting of attributes (#3340)
We weren't doing quite the right calls to set the attributes correctly
after performing the scale.
2022-02-17 23:36:31 -08:00
Larry Gritz 31b643a02f Testing: OIIO_CHECK_SIMD_EQUAL_THRESH to use <= eps (#3333) 2022-02-16 20:15:57 -08:00
Larry Gritz 1fad2a89dc Imath fiddling (#3339)
Make the imath includes respect the recently added
OPENIMAGEIO_IMATH_DEPENDENCY_VISIBILITY flag, just like the libraries
do.
2022-02-16 20:15:40 -08:00
Larry Gritz 00c09106fe Hide static library dependency symbols from the python module (#3338)
Just like we had done for the other libraries recently. And need
to make sure that the imath libs are added explicitly to the python
module's needs, since for hidden static libraries, they will not get
picked up merely by linking to libOpenImageIO.
2022-02-15 14:38:52 -08:00
Larry Gritz 4323093bdb CI: bump OpenEXR version used for 'latest' (#3336)
Also, for the bleeding edge test, OpenEXR's "master" has been renamed
to "main".
2022-02-12 14:50:24 -08:00
Larry Gritz a2e1ccd7d2 More Imath hiding controls (#3335)
Add an OIIO build-time option for forcing our exported
OpenImageIOConfig.cmake to skip the find_dependency of Imath and
OpenEXR.

This is helpful if you're at a site that is trying to build OIIO
against statically compiled Imath/OpenEXR, and want to be super sure
the downstream projects are definitely not going to encounter that
find_dependency(Imath) when the read the OIIO config files.
(They could do their own `-DOPENIMAGEIO_CONFIG_DO_NOT_FIND_IMATH`,
but I want even that to be unnecessary.)
2022-02-11 19:03:30 -08:00
Larry Gritz 4a345ad77e Bump developer preview version to 2.4.0.2 2022-02-10 22:21:48 -08:00
Larry Gritz 620cec2b5b CHANGES 2022-02-10 22:21:48 -08:00
Bernhard Rosenkraenzer e8bd39f078 Port to ffmpeg 5.0 (#3282)
Port to ffmpeg 5.0 -- av_register_all removed, AVPicture
removed, pkt_pts changed to pts

Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
2022-02-10 22:17:47 -08:00
Larry Gritz 54019aef35 Docs touchups
* Change example of set_write_tiles so that it uses a tile size I would
  more strongly recommend. (Very minor nit.)
2022-02-10 14:10:12 -08:00
Larry Gritz a07cb917ba Reduce Imath footprint even more (#3332)
There was that one pesky place where we were still including Imath
headers, from simd.h in the case where OIIO_SIMD==0 and we wanted to
fall back on some Imath::Matrix methods.

Ugh, but this backfired because when including this file from Cuda,
OIIO_SIMD==0 and it included the header. But what happens if a
downstream app (a) includes this file from Cuda, and (b) uses a
DIFFERENT Imath (so names clash) or doesn't want to use Imath at all?

So one more change:

* Remove the include of Imath.h from simd.h entirely.

* Most places where we fell back on the Imath::Matrix methods, just
  replace it with scalar code, it's not complicated. (For some technical
  reasons, this required some minor surgery on the matrix44 class, but
  not anything that changes anything from a caller's point of view.)

* The one complicated case is matrix44::inverse(). Punt! Just let that
  only be implemented if either (a) there is SIMD available, or (b)
  there is Imath available (i.e., included by the downstream code
  prior to this header). That's it. If you want to invert a 4x4 matrix
  without SIMD, you need to arrange inclusion of the correct
  ImathMatrix.h yourself before including this header.
2022-02-10 14:00:46 -08:00
Larry Gritz fd8bdbcfaf Add texture creation metadata: "handed" (#3331)
For vector displacement maps or normal maps that are in tangent space,
it is heplful to be able to record whether the data are intended to use
a local left-handed or right-handed coordinate system, and for that to
be querably from the shader accessing the map.

The `maketx --handed` option, or `oiiotool -attrib -otex:handed=...`,
or adding "handed" metadata to the configuration ImageSpec being
passed to `IBA::make_texture()` does this. It's easy for texture
formats like openexr that allow arbitrary metadata. For TIFF textures,
we embed it in the ImageDescription tag (as we do for several other
texture-specific hints).
2022-02-08 11:26:43 -08:00
jreichel-nvidia 475cf1eccd Targa: Fix parsing of TGA 2.0 extension area. (#3323)
Skip 3 bytes between "software" and "background (key) colour" for the "software
version" (was simply missing). Avoids that m_alpha_type is overwritten with
wrong values.
2022-02-08 10:17:13 -08:00
Larry Gritz f482be2d6a Update THIRD-PARTY info for OSL and OCIO with new URLs and copyright notices 2022-02-06 17:17:48 -08:00
Larry Gritz cc8b41b669 Split fmt setup into detail/fmt.h, fix fmt ostream problem (#3327)
The very latest fmt master changes a behavior: fmt functions no longer
automatically know how to format any type that can output to an
ostream, and instead need custom formtter objects. This breaks A LOT.
Fix by defining the preprocessor symbol `FMT_DEPRECATED_OSTREAM`,
which restores the old behavior (for now, at least).

While I was at it, I moved the fmt inclusion logic out of strutil.h
and into a new separate header, detail/fmt.h. This is in turn included
from strutil.h, so nothing in user code needs to change.
2022-02-06 17:12:06 -08:00
Larry Gritz 91f519ecfd Handle NUL (0) characters in ustrings by truncating. (#3326)
It turns out that this can crop up all the time, sometimes from
malformed metadata inside image files. We weren't noticing it because
in many cases, things ended up being turned into ustrings twice, and
the sequence string-with-nuls -> ustring() -> c_str() -> ustring()
will launder it. As I was tracking down and eliminating some of the
double ustring constructions, the metadata strings that were malformed
all along started becoming symptomatic.

Bad paradoxes follow from a ustring contain embedded NUL characters,
including ustring.c_str() and ustring.string() being different
character sequences, as well as ustring.hash() not being equal to
strhash(ustring.c_str()). One should definitely be able to count on
ustring(cstring) == ustring(ustring(cstring).c_str()).

So this patch checks for embedded NUL characters at the appropriate
time of ustring construction, and truncates the character sequence at
the point of any internal NUL character.
2022-02-06 17:11:48 -08:00
Larry Gritz 52f7c40b57 CMake: Remove redundant include of GNUInstallsDirs (#3325) 2022-02-06 17:11:26 -08:00
Larry Gritz 1921787fed Changes to make it easier to hide the Imath dependency (#3322)
* `OPENIMAGEIO_IMATH_DEPENDENCY_VISIBILITY` is a new CMake cache
  variable at OIIO build time that controls whether the Imath library
  dependencies will be declared as PUBLIC (default) or PRIVATE target
  dependencies of libOpenImageIO and libOpenImageIO_Util.

* For *downstream projects* that consume OIIO's exported cmake config
  files, setting CMake variable `OPENIMAGEIO_CONFIG_DO_NOT_FIND_IMATH`
  to true will skip the find_depencency() calls for Imath and OpenEXR.
  To clarify, this is not a variable that has any effect when building
  OIIO, it's something set in the downstream project itself.

* Add a `OIIO_IMATH_H_INCLUDED` header guard in OpenImageIO/Imath.h,
  which allows something downstream to pre-define it to prevent OIIO
  headers it needs to read from using the contents of that header.

Most builders of OIIO won't care and shouldn't change the defaults or
use any of these.  But here's the specific case it addresses: If you
are building OIIO against static libraries of Imath & OpenEXR, but the
libOpenImageIO will be consumed by a downstream project that wants to
use a different Imath version, this can help you avoid some build-time
conflicts in the downstream project.
2022-02-06 17:11:02 -08:00
Larry Gritz 5dd4cb224f Color space adjustment for PPM and PNG files. (#3321)
PPM by specification is Rec709! Make it so.

PNG files were getting marked as sRGB or Gamma if certain header
attributes were found in the file, but if they were absent, we didn't
designate a color space at all. Change so that the default assumes
sRGB, in the absence of any metadata telling us for sure.

Fixes #3084
2022-02-05 11:25:22 -08:00
Larry Gritz c6f9d40135 Expose additional OCIO utility functions via ColorConfig (#3319) 2022-02-02 13:21:25 -08:00
Daniel Flehner Heenanddaniel aef4227aed update example and definition to match C++ (#3320)
Co-authored-by: daniel <daniel@stormstudios.no>
2022-02-02 13:20:19 -08:00
Larry Gritz afd1d31d80 Correction to recent wstring changes: un-virtualize one method (#3318)
One new method that should have been inline and non-virtual (so that
this whole set of changes does not change ABI by shifting the vtable
around) was accidentally marked virtual -- cut and paste error. This
patch fixes it to restore ABI compatibility.
2022-02-01 22:37:43 -08:00
Larry Gritz d1a3d279ef TIFF: Mitigate IPTC corruptions (#3316)
IPTC data blocks seems buggy, and I don't know why. Our code?
Something in libtiff?  Since nobody is depending on it and none of our
testsuite appears to fail when disabled, only write the IPTC block if
the user explicitly asks for it.  Also, when reading them, don't
overwrite other metadata of the same name.
2022-01-31 09:38:21 -08:00
Merwan Achibet c8dfbd7066 Relocatable cmake package (#3302)
CMake: use relative paths in the config script
2022-01-31 09:35:34 -08:00
Larry Gritz ca75260255 Work toward eliminating string_view::c_str() (#3315)
We wrote our string_view before C++17 std::string_view was finalized,
and the std one doesn't have a c_str() method. For conformance with the
standard, I want to remove this over time from ours.

Part 1: There were some places we did not need to call c_str() at all,
and some places where it was much more appropriate to just use a
std::string.
2022-01-30 08:21:15 -08:00
Larry Gritz 2b01dd3350 string_view: beef up tests of constructors (#3314) 2022-01-30 08:20:47 -08:00
Larry Gritz 2b453321b7 wstring (almost) all the things (#3312)
As Doug Rogers points out in Issue 3304, it is customary for Windows
applications to use wstring extensively for Unicode support. But it's
especially critical for unicode filenames, because unlike Unix-like
OS's where fopen() and similar functions support UTF-8, on Windows
those functions are strictly ASCII, and Windows users are used to
calling _wfopen() and other nonstandard functions that expect
filenames to be std::wstring if they want to support Unicode.

This patch:

* More clearly documents through all of our classes when parameters that
  represent filenames or searchpaths are assumed to support UTF-8.

* Augments ImageInput, ImageOutput, and ImageBuf so that their methods
  that take file names or path lists have additional flavors that take
  wstring (always implemented as an inline shim that translates the
  UTF-16 wstring to a std::string with UTF-8 encoding to pass on to the
  usual method).

* Augments ImageCache and TextureSystem in just a couple places, the
  functions where a filename is turned into a handle. All the many
  other functions that take ustring for function names were left alone,
  because they are called very frequently and are performance-sensitive,
  so we don't want any translation from wstring to string happening on
  every call.

We do not attempt to add wstring-based versions of functions that take
strings for other purposes -- that is, that are not intended to
represent filenames.
2022-01-29 08:56:24 -08:00
Larry Gritz ac46f1f7f1 Avoid unsafe isspace() (#3310)
C isspace() takes an int, but on Windows when building in debug mode,
the implementation of isspace() can hit an assert if the value is < 0,
which of course it can be if you're looking at a character in a string
whose high bit is set (because char is signed).

Easiest solution is to make our own Strutil::isspace that does exactly
what we want and is safe.

Fixes #3300
2022-01-28 21:29:11 -08:00
Larry Gritz 8eb2c6a9da Embed Imath version symbols in oiioversion.h (#3305)
This makes sure that two new preprocessor symbols are defined in
oiioversion.h: `OIIO_USING_IMATH_VERSION_MAJOR` and
`OIIO_USING_IMATH_VERSION_MINOR`, revealing the version of Imath being
used by the build of OIIO (which may not be the same as the version
found or being used by the app that's calling OIIO). They also get
defined as CMake variables in our exported cmake configs, allowng
downstream cmake build systems to be able to easily test whether the
Imath they found is compatible with the version that we use in our
APIs.
2022-01-28 14:32:26 -08:00
Larry Gritz 71f0aa6a58 Hide Imath headers and types from most of the public API (#3301)
This patch sets out to minimize the extent to which Imath is a
necessary source dependency for using OIIO C++ header files and
APIs. The major changes are:

* Remove the unconditional `#include <OpenImageIO/Imath.h>` from
  fmath.h and simd.h. Those forced Imath headers on nearly all all
  code that uses OIIO's public APIs, whether or not they needed the
  very few calls where Imath types are used as parameters.

* Make sure all public OIIO non-virtual methods and freestanding
  functions that have Imath types as parameters are enclosed in header
  guards like `#ifdef INCLUDE_IMATHVECTOR_H`. Downstream client code
  needs to include Imath headers before including OIIO headers, if
  they want to call those few particular functions.

This means that client applications who don't need those particular
functions, but call other parts of the OIIO APIs, don't need to
`#include` any Imath headers (or pay the extra compilation time for
doing so), and don't need any knowledge of which specific version of
Imath is used by the OIIO they are using.

The small number of public API calls that will no longer be visible
downstream unless the client code also include Imath headers (before
the OIIO headers) are:

  - color.h: ColorConfig::createMatrixTransform (needs ImathColor.h)

  - fmath.h: type conversions involving `half` (needs half.h).

  - imagebufalgo.h: warp(), colormatrixtransform() (needs ImathMatrix.h)

  - simd.h: conversions between our SIMD types and Imath types (Vec3,
    Matrix33, Matrix44) and vtransform() calls involving those types
    (requires ImathVec.h and ImathMatrix.h), and SIMD load/store
    involving `half` data (requires half.h).

These changes necessitated adding including of Imath.h in a number of
internal .cpp files, the ones where those types are actually used.

The following header files do still unconditionally reference Imath
types or headers:

  - texture.h: Some virtual methods of TextureSystem use Imath types
    as parameters.
  - imagebufalgo_util.h: For `half` support. We use this a lot
    internally, but presume most client code never uses this header.
  - simd.h, ONLY IF USE_SIMD=0 (which is generally only used for
    development debugging and if porting to obscure platforms that are
    neither x86 nor ARM).

The bottom line is that the vast majority of downstream callers of OIIO
APIs who need ImageInput/ImageOutput, ImageBuf, ImageBufAlgo, and
generally everything in the OpenImageIO_Util library, do not need to
use Imath types, include Imath headers, or even be aware of which Imath
release OIIO is using.

Why would we do all this?

Because this paves the way for optionally building OIIO to link against
static libraries for OpenEXR and Imath, essentially embedding and
completely hiding an OpenEXR/Imath inside libOpenImageIO.

That allows libOpenImageIO to use the very latest Imath (3.1, say,
with the new faster core API), even though that libOpenImageIO is
being consumed by an application that for whatever reason is forced to
use an entirely different (older) OpenEXR or Imath library.  In other
words, it lets OIIO use OpenEXR/Imath fully embedded without
transitively passing that OpenEXR version as a downstream dependency
(except for the few use cases that need to call the tiny number of
OIIO API methods that require Imath types.

There is a small chance that client code that use Imath types and
SHOULD have been includeing Imath headers themselves actually omitted
those includes and dependd on the fact that certain OIIO headers
included them.  Now that they don't, it may require the client-side
code to add those includes. I'm going to claim that this is a "bug" in
the client code (they didn't include a header that defined a type they
used), and not a breaking incompatibility in OIIO's public calls
themselves. Thus, I feel comfortable with these changes being in OIIO
2.4 (today's master) and not necessitating a 3.0 release (in which
arbitrary loss of backward compatibility would be allowed). So watch
out for the occasional need for OIIO-calling code to need to add an
`#include` for Imath types the code was always using, but neglected
to explicitly include.
2022-01-28 13:04:40 -08:00
Larry Gritz 22a67bd24d CI: revise failed build artifact storage to capture cmake files (#3311) 2022-01-27 16:52:22 -08:00
Larry Gritz a7bd12b565 utf8 / utf16 conversion modernization. (#3307)
Our Strutil utilities for utf8 <-> utf16 conversion were based on
Windows specific calls that we had added even before C++11 was our
minimum. Replace the Windows-specific code with std calls, and
expose them in strutil.h for all platforms (why not?).
2022-01-26 20:33:50 -08:00
Larry Gritz cbd0917d03 Filesystem::searchpath_split handle empty paths (#3306)
Fixes #3274
2022-01-25 15:45:31 -08:00
Larry Gritz 7a4f0221cf Separate C++ that we build with from what we demand downstream (#3288)
We were passing along, in the exported cmake config files, a demand
for downstream clients to use a C++ standard version equal to that
which we used to build OpenImageIO itself. But that's not
necessary. We may choose to build with C++17 (for example), but all of
our public APIs are safe to use for C++14.

Split the build-time options to CMAKE_CXX_STANDARD for the standard we
build this project with, and DOWNSTREAM_CXX_STANDARD for the standard
we are declaring is the minimum to *use* the library.
2022-01-23 23:10:18 -08:00
Larry Gritz 7babbbfe79 Targa improvements: attribs, unassociated alpha handling, and more (#3279)
The main event:

* Assume that for a TGA 1.0 file (too old to have the header field
  that says if alpha is associated, unassociated, or meaningless), if
  the alpha is zero everywhere, it means that it's meaningless, not
  unassociated, so in that case we should skip the
  auto-premultiplication. (See issue 3277)

Public-ish stuff:

* Be more consistent with Targa-specific attributes all being called
  "targa:foo" (most were, but one was "tga:alpha_type").
* Document all the targa-specific attributes (a few were not).
* Add "targa:version" to reveal whether the file was a TGA 1.0 or
  2.0 version of the format.

Internal stuff, opportunistic:

* Some more minor conversions of string fomatting to fmt style.
* Convert some std::cerr debugging code (commented out) to the DBG macro
  we use anywhere.
* The `std::unique_ptr<uint8_t> m_buf` should always have been
  `unique_ptr<uint8_t[]>` because it's not a pointer to a single value.
2022-01-23 23:09:38 -08:00
Larry Gritz dc223d93c9 simd.h: more guards for Cuda are necessary (#3292) 2022-01-20 15:54:44 -08:00
Larry Gritz fc793ee786 oiiotool --ch : warn for unknown channels (#3290)
I realized recently that if you said something like

    oiiotool foo.exr --ch R,G,B,A -o out.exr

and there was no "A" channel... it would just silently fill the channel
with 0 in the output.

This patch adds a warning if --ch is told to copy a channel that doesn't
exist in the input.
2022-01-20 09:16:15 -08:00
Larry Gritz f22b1f7755 TIFF: Special hint to suppress output of EXTRASAMPLES tag (#3289)
Ugh, there's a situation where PhotoShop is misinterpreting an alpha
channel for certain OIIO-written TIFF files, but it's fine with some that
came from elsewhere, and the only thing that appears to be different is
that the non-OIIO one entirely lacks the EXTRASAMPLES TIFF tag.

So I'm adding an option (use with extreme caution) allowing you to
tell the TIFF output to not output this tag, even though clearly it
should be.
2022-01-20 09:16:01 -08:00
Larry Gritz 10a35e2d55 simd.h: when compiling with Cuda, don't include intrinsic headers (#3291) 2022-01-20 09:15:49 -08:00
Larry Gritz 2714b71bb5 TIFF: gracefully handle missing ExtraSamples tag (#3287)
Some rogue app out there is writing 4-channel TIFF files without the
ExtraSamples tag in the header that explains that the data is a valid
alpha channel.

We were using TIFFGetFieldDefaulted to retrieve this tag, and guess what?
The defaulted behavior changed between libtiff 4.0 and 4.3!

Changing to TIFFGetField actually turns out to fall back to the right
logic on our side, which boils down to assuming a 4th channel is alpha
if there's no other information. That seams reasonable -- RGB + mystery
channel is almost certainly RGBA.
2022-01-19 15:00:31 -08:00
Larry Gritz aa81e78006 Clarify UDIM docs (#3285) 2022-01-18 22:53:05 -08:00
Larry Gritz 35cb6a83e2 Add UDIM pattern <UVTILE> (specified by MaterialX) (#3280)
MaterialX documents a udim pattern that we hadn't previously supported,
`<UVTILE>`, which is equivalent to our `<U>_<V>`.

Fixes #3275
2022-01-17 11:25:00 -08:00
Merwan Achibet 0f1d5caf64 Fix OpenEXR build script for Windows (#3281) 2022-01-17 10:01:26 -08:00
Larry Gritz c2a41fc35e Minor build and compile fixes (#3278)
* Bugs fixed in build_opencolorio.bash, it botched some of the directory
  choices when customizing where to place and build it. Also, switch to
  the more standard BUILD_SHARED_LIBS cmake variable to control whether
  to build dynamic or static libraries.

* Correctly handle the cmake variable VISIBILITY_MAP_FILE being set to
  "" on the command line as a way to disable using the visibility map file
  entirely.

* FindOpenColorIO.cmake changes:
    - Prefer and use an exported cmake config for OCIO if found (is should
      be present for OCIO 2.1+), unless caller set OPENCOLORIO_NO_CONFIG=ON.
    - New hint OPENCOLORIO_INTERFACE_LINK_LIBRARIES lets caller force a
      list of interface link libraries. This is helpful when purposely using
      a static OCIO library, which itself has static dependencies, and you
      need to name those specific library filepaths.

* Simplify some of the logic for setting extra link flag arguments for the
  two main libraries.

* On Linux, also set link flags `--exclude-libs ALL` to hide symbols from
  any embedded static library dependencies, to prevent clashes with other
  versions of those libraries that may be compiled into a DCC app.
2022-01-16 21:55:28 -08:00
Larry Gritz c0ab86d423 make_texture: ensure that "maketx:ignore_unassoc" is honored (#3269)
I realized that a call to make_texture() with the "maketx:ignore_unassoc"
attribute set did not properly set the configuration attribute up when
opening a new ImageBuf.
2022-01-15 23:57:31 -08:00
Thiago IzeandThiago Ize 1259ca80c1 Fix clang 10 warning: (#3272)
```include/OpenImageIO/typedesc.h:620:10: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]
auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) const // c++11
```

Co-authored-by: Thiago Ize <thiago@solidangle.com>
2022-01-15 23:55:17 -08:00
Larry Gritz 65c457d6f5 Bump version after developer preview tag 2022-01-07 11:55:22 -08:00
Larry Gritz 5317863c45 CI: Update 'latest' fmt to 8.1.1 2022-01-06 22:36:09 -08:00
Larry Gritz 1e488aedc2 CHANGES 2022-01-05 17:17:07 -08:00
Larry Gritz c885e5b05c Python: fix clamp() when min or max are just a float (#3265)
The docs said that passing a tuple for min or max param of the clamp()
function gave per-channel values, but passing a single float gave one
value for all channels.

In fact, the implementation used the float to clamp only the first
channel. This patch fixes the behavior.

Fixes #3264
2022-01-05 12:59:50 -08:00
Larry Gritz 6d2df7095d Docs: supply more python and oiiotool examples to IBA docs (#3263)
In addition to C++ code examples for each IBA function, work toward
also having equivalent Python code. Also, where applicable, show the
equivalent operation using oiiotool.
2022-01-05 12:58:50 -08:00
Larry Gritz 908ce0cd56 TIFF: make it work for 16-bit palette images (#3260) 2022-01-04 10:26:12 -08:00
Larry Gritz f8fc2358cf oiiotool: don't warn for --colorcount or --rangecheck (#3262)
We had forgotten to mark --colorcount and --rangecheck as commands
that intentionally outputs to the console. This omission meant that an
oiiotool command consisting only of a those would warn about no
output.  But we didn't really want it to.
2022-01-03 23:51:50 -08:00
AdamMainsTL b4aa7aa40c Fix variable usage example in docs (#3261)
I found this while reading through the image output section and it seems wrong given the following examples.
2022-01-03 13:08:25 -08:00
Larry Gritz 01fbf4167d oiiotool: control flow (#3243)
How do you craft an oiiotool command that will examine a file and add
an alpha=1 channel if it's a 3-channel file, but leave the existing
alpha alone if it's already a 4 channel file?

This patch adds control flow, so you could express the above like this:

    oiiotool in.exr --if "{TOP.nchannels < 4}" --ch R,G,B,A=1 --endif -o out.exr

The following slate of new fetures is added:

* `--set name value` sets a "user variable".

* Expression evaluation will expand identifiers that are the names of
  user variables. For example, `{i}` is replaced by the value of user
  variable `i`, and `{i+3}` returns 3 more than the current numerical
  value of `i`.

* Expression evaluation has been extended to support the following
  numerical comparison operators: `<` `>` `<=` `>=` `==` `!=` and
  `<=>` (the last one being the 3-way comparison, like in C++20).
  Also logical operators `&&` and `||`. All return 1 for true, 0 for
  false. Note that the comprison and logical operators have the same
  precedence as `+` and `-`, so use parentheses liberally to
  disambiguate complex mixed expressions.

* New functions recognized within expressions:
  - the value held by a named user variable: `var(name)`
  - logical negation: `!`, `not()`
  - string comparison: `eq()`, `neq()`

* `--if condition commands... [--else commands...] --endif`

* `--while condition commands... --endwhile`

* `--for variable range commands... --endfor` where the range may be,
  like Python, any of `end` (implied begin=0, step=1), `begin,end`
  (implied step=1), or `begin,end,step`.

Also needed to modify ArgParse so that it has the notion of whether
it's "running" -- actually calling the actions for each argument, or
if it's merely parsing but taking no action -- and to be able to set
and retrieve which command line argument index an action is responding
to.
2022-01-03 11:12:20 -08:00
Larry Gritz f705510f14 ImageBufAlgo: Slightly more flexibility in inferring constants (#3257)
This little change makes this work:

    ImageBufAlgo::add (buf, { 0.2f, 0.2f, 0.2f });

instead of the more awkward

    ImageBufAlgo::add (buf, cspan<float>({ 0.2f, 0.2f, 0.2f }));

and for anyplace tht has Image_or_Const parameter types.
2022-01-02 20:11:51 -08:00
Larry Gritz c66a532352 CI: Bump OCIO and fmt versions (#3258)
New OpenColorIO and fmt versions are out.

* Bump "latest releases" test to fmt 8.1.0, and OCIO 2.1.1.
* Re-adjust CI test fmt versions across many tests to give a better
  spread over the supported releases.
* Bump the default version to download and use if none is found to 8.0.0.
2022-01-02 14:50:25 -08:00
Larry Gritz 15f4da1f2a oiiotool --point (#3256)
We had --line (wrapping IBA::render_line) and --box (wrapping
IBA::render_box).

This adds the obvious --point, wrapping the existing IBA::render_point.
2022-01-02 10:48:51 -08:00
Larry Gritz 71c2d3da71 Python: improve ParamValueList and ImageSpec dict interface (#3252)
The Python bindings for ParamValueList and ImageSpec allow a "dict"
style (associative array) interface:

    imagespec["key"] = value
    val = imagespec["key"]

This patch makes some minor improvements:

* Clarify in the docs that like a regular Python dict, the associative
  retrieval will raise a KeyError if the key is not found.

* Add `__contains__` python method as a synonym for contains(), thus
  implementing `key in dict`.

* Add `__delitem__` python method as a synonym for erase(), thus
  implementing `del dict[key]`.

* Add an `ImageSpec.get()` method that is a synonym for getattribute
  (which retrieves the item or returns None or a default if not
  found), mirroring the behavior of Python's `dict.get()`.
2022-01-02 10:48:34 -08:00
Larry Gritz 1fe7bcd6a0 Python: implement ROI.copy() (#3253)
Somehow I never implemented a copy() method for ROI, which of course is
super useful if you want to make an actual copy of an ROI and modify
the copy.

I also realized that ImageSpec.copy() unnecessarily/incorrectly set
return_value_policy to reference_internal, but actually it should be a
real copy, which it has to be anyway because the implementation
creates a separate copy.
2022-01-01 11:55:51 -08:00
Larry Gritz 7deafc4718 oiiotool --pattern checker tweak and documentation fix (#3255)
* Docs: we previously only documented the "width=" optional modifier.
  Add height, color1, color2.

* Change behavior ever so slightly so that if the "height=" modifier is
  not supplied, the height defaults to the "width".
2022-01-01 11:41:51 -08:00
Larry Gritz af030f3b07 Docs: add missing Python docs for ImageBufAlgo.bluenoise_image (#3254) 2021-12-31 15:04:29 -08:00
Larry Gritz 9d6daca9be Python: ImageBuf constructor/reset from numpy array (#3246)
Deduce the ImageSpec from the shape and type of the ndarray, and
copy its contents into the ImageBuf.

Closes #2954
2021-12-31 15:04:03 -08:00
Larry Gritz 7d8fd72654 Docs: better C++/Python examples in ImageInput chapter (#3250) 2021-12-29 13:25:17 -08:00
Larry Gritz ee146a8c3f CI: pybind11 version bumps (#3248)
* Use the new pybind11 v2.9.0 for 2022 and "latest" tests.
* Bump the default version built by build_pybind11.bash to 2.8.1.
* Adjust the pybind11 version used in many of the other CI tests, to
  give an even spread across versions, and to make each of the
  "vfx platform" CI tests use the pybind11 version that was available
  near the start of its repsective year.
2021-12-29 12:44:02 -08:00
Larry Gritz 3cf4e1b81e ImageSpec: allow getattribute("format") to retrieve the data type name (#3247) 2021-12-29 11:56:53 -08:00
Larry Gritz 84a61b11f8 ImageSpec: New constructors to accept string for data type (#3245)
For each ImageSpec ctr that takes a TypeDesc, add another one
that's the same but takes a string_view (which is just a simple
pass-through of the TypeDesc-from-string_view).
2021-12-28 09:56:37 -08:00
Larry Gritz 6b316f2d15 Docs: more C++/Python dual examples (#3244)
* Add Python examples comprehensively to the ImageOutput chapter.
* Clean up some of the C++ code, too, using more modern idioms.
2021-12-27 09:59:41 -08:00
Larry Gritz aeeb3e741b oiiotool internals: convert all error and warning to fmt style (#3240)
Also tagged Strutil and ustring::fmtformat as 'nodiscard', to produce
warnings if people call it and ignore the results. (As was the case in
my own bug that I tracked down in the course of this patch.)
2021-12-24 17:26:35 -08:00
Larry Gritz fe9d572160 oiiotool: allow all filtered ops to take highlightcomp= modifier (#3239)
When doing operations with filters that have negative lobes, you can
sometimes get visible ringing artifacts in very high contrast regions
of HDR images (you tend not to see these artifacts in images that have
range [0,1] because the ringing is very low amplitude unless the input
is very large).

You can do "highlight compensation" to reduce the artifacts when they
occur by doing --rangecompress, which does a log transform on the
input, then the filtered op, then --rangeexpand to transform back to a
linear space. But that makes for kind of verbose and clumsy command
lines, and makes it easy to err by doing the transforms in the wrong
sequence or omitting one.

The -otex command takes a highlightcomp=1 modifier, which does this
bracketing automatically, foolproof, with a compact notation.

This patch adds support for optional highlightcomp=1 modifier for all
of the oiiotool commands that let you specify a filter= option:
--rotate, --warp, --resize, --fit, and --pixelaspect.
2021-12-24 16:17:50 -08:00
Larry Gritz 399e1fad6e Docs improvements (#3238)
* Clean up intra-document section references.
* New explanations about input and output configuration hints.
* More code examples in both C++ and Python.
* Fix some formatting flubs.
2021-12-21 15:03:28 -08:00
Larry Gritz 88f2c26f25 Get rid of obsolete header (#3237)
This was an obsolete experiment in adding a C binding. We abandoned
this effort (a replacement will happen eventually), but this one file
was left behind when we intended to remove it all.
2021-12-19 15:41:26 -08:00
Larry Gritz 57fdf840b2 Improve error propagation from ImageCache to higher levels (#3233)
Errors encountered while reading tiles were getting lost as we used
ImageBuf::Iterator to iterate over an image. Have the iterator keep a
flag for whether it encountered an error, set to true if the
ImageBuf::retile indicates an error occurred during the read.

Also, some ImageCache errors might get lost on the way to
TextureSystem calls, fix that as well.
2021-12-16 11:24:26 -08:00
Larry Gritz 9792b753e0 Make texture system 64-bit safe for tile access (#3232)
TextureSystem is designed primarily for tiled images (typically 64x64
pixels each), but to handle untiled images, it just treats the whole
image as one big tile. That means for very large untiled images, you
might end up with one VERY large tile, and if the image is large
enough, the size and/or offset computations therein may overflow a
32 bit int.

This patch attempts to make all the offset computations in the texture
system be 64-bit safe.
2021-12-16 11:24:09 -08:00
Brady 8232c157b1 Fix the reference (#3234) 2021-12-14 18:19:14 -08:00
Larry Gritz e4cf482bf2 IOProxy cleanup -- use new helper methods for TIFF, DPX, and PNG. (#3231)
After setting up the new IOProxy helper methods for ImageInput and
ImageOutput, here we go back to the readers/writers that had used
proxies for a long time, and switch them to using the new helpers.
2021-12-14 10:41:36 -08:00
Larry Gritz d1ec7624bf Protect against corrupt headers with image size and channel limits (#3230)
Add two new global OIIO attributes: "limits:channels" and
"limits:imagesize_MB" which are imposed limits for validating a
reasonable number of channels and total uncompressed image size,
respectively. We presume that an image file header describing an image
that purports to exceed these is most likely corrupted or even
maliciously crafted. The limits, therefore, are designed to avoid
crashes, absurd memory allocations, or other cascading errors that
would result from taking such a claim at face value (for example,
a file that appears to have tens of thousands of color channels).

The limits default currently to a maximum of 1024 color channels, and
a maximum uncompressed data size of a single 2D image to 32GB.  These
seem reasonable today, but if such large sizes become likely to be
seen in the wild in legit files in the future, we may change the
defaults. They may be adjusted now simply by setting the attributes,
of course, as should be done by applications that legitimately expect
to see input that exceeds them. (Applications also may make the
validation limits even smaller if they wish.)

I've modified the TIFF reader to check these limits as a first step.
We'll expand to doing such validation checks on other readers over time,
as we have opportunities to visit them.
2021-12-14 10:41:08 -08:00
Larry Gritz 9e897fe9a0 Strutil::edit_distance() (#3229)
This string utility computes the "edit distance" between two strings.
Currently it only uses the Levenshtein metric, but it has room for
future expansion by taking a parameter that can specify which metric
to use. Levenshtein is an algorithm for computing how many single
character insertions or deletions are necessary to turn one string
into the other.

I have a few ideas for where this can be useful, but as one
demonstration, I also modify the ArgParse class internals so that if a
command is not found, it will print a suggestion naming the valid
command option that has the closest edit distance (but only if one
choice is <= 2 edis away, and only if it's not a single-character
option, in order to reduce the number of useless suggestions). Here's
its behavior in action:

    $ iinfo --stat foo.exr
    iinfo error: Invalid option "--stat" (did you mean --stats?)
    ...
2021-12-14 10:40:19 -08:00
Larry Gritz bfd99269f7 CMake: don't download missing test data if BUILD_TESTING is off (#3227)
Fixes #3189
2021-12-12 22:38:32 -08:00
Larry Gritz 43a8dbbed8 IOProxy support for JPEG2000 (#3226) 2021-12-10 12:45:01 -08:00
Paul Melis 3bd9e44796 Mention that git is needed for certain dependencies (#3228)
... if they cannot be found and are installed from source as part of the build process.
2021-12-10 11:31:05 -08:00
Larry Gritz 0541331cdb JPEG2000: enable multithreading, other fixes (#3225)
* The main event here is that we're now telling OpenJPEG to use
  threading when compressing/decompressing JPEG-2000 files.  This
  improves the speed of JPEG-2000 reading on my laptop by 2-3x!  The
  threading feature was added to OpenJPEG 2.2 for decode, and 2.4 for
  encode.

* CI: Build OpenJPEG 2.4 for the "latest releases" test, and build
  their master for our "bleeding edge" test.

* Fixes to deal with the in-progress 2.5 deprecating a struct field.

* Generally clean up our detection of what OpenJPEG version we are
  using.

* Some clean-up of the FindOpenJPEG.cmake file, use PATH_SUFFIXES.
2021-12-09 23:01:50 -08:00
Larry Gritz 794ec616b5 IOProxy support for BMP (#3223) 2021-12-09 12:20:03 -08:00
Larry Gritz 70f7991c5b Webp IOProxy support (#3224) 2021-12-09 11:48:36 -08:00
Larry Gritz d3521a3d37 Docs: touch-ups to maketx argument explanations 2021-12-09 10:23:10 -08:00
Larry Gritz 8f1e33b611 Targa: add IOProxy support (#3221) 2021-12-08 17:08:23 -08:00
Larry Gritz b74a2e9523 Refactor PSD input to support IOProxy (#3220) 2021-12-08 17:08:08 -08:00
Larry Gritz 85768195e5 PNM overhaul to support IOProxy (#3219)
Also fix longstanding bugs in PNM input:
* We weren't correctly emulating random scanline access, as is expected
  (but in practice rarely used) of all ImageInput implementations.
* We weren't marking the color space in any way, now we do mark as
  "Gamma2.2", which is the correct/preferred interpretation according
  to the PNM spec.
2021-12-07 16:15:33 -08:00
Larry Gritz c4d9b6e66d hdr overhaul (#3218)
* Add full IOProxy support to both input and output.

* This necessitated a major refactor, including sucking the I/O specific
  code from rgbe.{cpp,h} into hdr{input,output}.cpp and getting rid of
  the old files.

* Add a testsuite entry for hdr (shockingly, there was none before)
2021-12-07 16:15:10 -08:00
Larry Gritz 3e9cbd1950 DDS input IOProxy support (#3217)
As well,

* Add a DDS test, apparently we never had one.
* Remove DDS setting of "texturetype", we don't ever use that, it's only
  "textureformat" that we use. Not sure how that crept in there years ago.
2021-12-07 14:22:26 -08:00
Larry Gritz 36bfeb6694 Minor ImageInput/ImageOutput IOProxy handling tweaks: (#3222)
Helper functions ioproxy_opened() and iotell() should have been const
all along, since they just return back information and should not
change state of the proxy, and also ioproxy() should have both const
and non-const versions.
2021-12-07 14:21:52 -08:00
Larry Gritz 6cfba204be CMake: use the more compact TARGET_NAME_IF_EXISTS (#3215) 2021-12-07 10:13:12 -08:00
Larry Gritz 6d0c98e516 Build/CI openvdb tweaks (#3216)
* On Mac CI, use openvdb from Homebrew now that it's OpenVDB 9, which
  properly supports OpenEXR/Imath 3.1.

* Update our FindOpenVDB.cmake target names to match the names used in
  OpenVDB's own FindOpenVDB.cmake (even though we don't use their module,
  may as well stick to their convention, especially if they eventually have
  a properly exported config file).
2021-12-07 10:08:09 -08:00
Larry Gritz 91b60106e7 Name gamma-corrected color spaces "GammaX.Y" (#3202)
For some reason, in the early days I got in the habit of having OIIO
input readers call their color space "GammaCorrected2.2" (for example)
when they appeared to be a straight-up gamma. (Generally only used for
certain fairly old formats that date from before sRGB existed.)

But there appears to be a widely used convention of naming OpenColorIO
spaces "GammaX.Y", so I'm switching OIIO to conform that
convention. It's more straightforward and increases the chances that
it will match the names of color spaces that already exist in people's
OCIO configs.
2021-12-07 10:07:32 -08:00
Larry Gritz 5bf288be33 Better IOProxy support for image format implementations (#3203)
As we move toward fully equipping all image format implementations
with full IOProxy support, it's clear that a lot of repeated code is
error-prone. I first tried to collect this in a mixin class, but then
re-implemented after realizing that we can use the existing PIMPL
ImageInput::Impl and ImageInput::Impl classes, without changing any
ABI or making new headers.

This patch add a couple data members to the Impl data -- an
`IOProxy*`, (the current proxy, used for both passed-in and created
proxies) and also a `unique_ptr<IOProxy>` used when we have to create
our own and want to make sure it's destroyed with the ImageInput or
ImageOutput.

Then we add a number of protected member functions to ImageInput and
ImageOutput, not meant to be ever called by "users" of the OIIO APIs,
but used internally by II's and IO's to encapsulate several common
tasks related to managing IOProxy's.  This coalesces redundant code
that would need to appear separately in most of the plugins that
support IOProxy, helps to reduce cut-and-paste errors from having to
make these changes separately in many places, and centralizes the
logic so that as our ideas of how to implement IOProxy evolve, we can
easily change it in just one place and have it apply to all plugins.

GIF revise with new IOProxy utility methods

JPEG simplify with new IOProxy utilities.
2021-12-04 23:05:01 -08:00
Larry Gritz f423cde454 Build: Make sure to use tbb target if it exists (#3214) 2021-12-04 12:31:07 -08:00
Larry Gritz 1fe77f312b Refactor ImageBuf::Iterator, ConstIterator (#3195)
To try to combat long template instantiation times, did some refactoring
on the ImageBuf iterators:

* Pushed more functionality from the templated Iterator and
  ConstIterator to the non-templated base class IteratorBase. This
  should reduce the amount of code that is separately instantiated for
  every data type, in every module that uses iterators.

* Pushed many implementations from inline defined in imagebuf.h to
  separately compiled in imagebuf.cpp. The most important methods that
  are called on every pixel are still inline, but we are switching to
  separate compilation for all the methods that are only called upon
  construction (once per image being iterated over) and most of the
  code that is called only when we wrap to the next scanline.

* Some other miscellaneous refactor to remove redundant computation in
  those classes.
2021-12-03 20:27:23 -08:00
Larry Gritz 08e86b795d Use a project-specific var for whether we're running in CI (#3211)
Maybe somebody else is building this as a subproject or has a varible
called "CI"?

* For our CI runs, set an env variable "OpenImageIO_CI" (not just
  generic "CI").

* Make sure STOP_ON_WARNING is true for our CI runs, even for release
  branches -- but now check OpenImageIO_CI, not CI, in case somebody
  else has set that.
2021-12-03 20:25:38 -08:00
Larry Gritz 59ef613b90 fmath.h: bit_cast specializations should take refs, like the template (#3213) 2021-12-03 20:19:52 -08:00
Larry Gritz e481e40dc2 Testing: Gracefully handle failing to find git for test data download (#3212)
Fixes #3208
2021-12-03 13:34:21 -08:00
Larry Gritz ffe7c190c1 Fix typo 2021-12-02 17:06:04 -08:00
Larry Gritz e582e2e166 Restore code that finds Jasper when using static libraw (#3210)
This was deleted a few months back, but I think I did not realize
it still served a purpose. We don't use JasPer directly, but LibRaw
does, so if we are using static LibRaw, we still need it here.

Fixes #3209
2021-12-02 10:01:12 -08:00
Larry Gritz 028582817c Add documentation for new texture CDF options (#3206)
Also, fixed the fact that direct calls to make_texture() were not given
proper defaults for the cdfsigma and cdfbits options.

Related to PR #3159
2021-11-29 21:39:02 -08:00
Larry Gritz 5563aec0e5 make_texture()/maketx fix to channel name with monochrome_detect (#3205)
When the make_texture option monochrome_detect is used to collapse 3
identical channels to 1, it was leaving the first channel name in
place (for example, "R"). That was confusing, because at this point,
we're not trying to represent a red image, we're trying to represent a
grayscale image. A strategic call to `default_channel_names()` clears
it up, imposing the standard "Y" we use for a single channel luminance
image.

Also amended the documentation of IBA::channels(). It turned out not
to be the way I called channels() that was the problem here, but by
the time I figured that out, I had already seen that its docs could be
improved.

Fixes #3204
2021-11-29 21:17:28 -08:00
olegul 78a67fe6a0 Add support for writing Gaussian forward and inverse transform lookup tables (#3159) 2021-11-29 09:52:01 -08:00
Larry Gritz f0ac3e1022 imageinout_test debugging aids (#3201)
* --onlyformat or env IMAGEINOUT_TEST_ONLYFORMAT to test only one format.
* --no-delete to preserve the temporary files for inspection
* other debugging checks
2021-11-29 00:04:45 -08:00
Larry Gritz 9aca017113 DDS: add test, minor adjustments (#3200)
* Add a DDS test, apparently we never had one.
* Remove DDS setting of "texturetype", we don't ever use that, it's only
  "textureformat" that we use. Not sure how that crept in there years ago.
2021-11-29 00:04:22 -08:00
Larry Gritz 963b5673d2 filesystem.h: New write_binary_file utility template (#3199) 2021-11-28 22:01:42 -08:00
Larry Gritz df77c3fcfc Fix typo 2021-11-28 00:22:37 -08:00
Larry Gritz f2ae8a594e IBA::maxchan(), minchan(), and oiiotool --maxchan / --minchan (#3198)
The previously existing max and min take 2 images and compute the
pixel-by-pixel, channel-by-channel max or min of the two images.

The new maxchan/minchan take one multi-channel image and produce a
single-channel image where each pixel contains the max or min of the
*channels* of the corresponding pixel of the original image.

It is equivalent to this (for an RGB image):

    oiiotool in.exr -ch R in.exr -ch G in.exr -ch B -max -max -o max.exr

Except, of course, that --maxchan is a single command, is much more
efficient, and doesn't require you to know the number or names of the
channels of the input.

This was a specific user request.

Note: in the course of making the tests, I noticed that we did not
have documentation or testsuite coverage of the python bindings for
IBA.min() an max(), although they were implemented. So I added that as
well.
2021-11-27 10:22:25 -08:00
Larry Gritz 0a69fa3ceb CMake tweaks (#3197)
* Make PROJECT_VERSION_RELEASE_TYPE be a cache string, so individual
  build configs or sites can override it.

* Change OpenImageIO_IS_SUBPROJECT to PROJECT_IS_TOP_LEVEL (and with
  the opposite sense), to match CMake 21+ behavior. And no need to set
  it ourselves if using cmake 21+.
2021-11-27 10:21:57 -08:00
Larry Gritz bc4685ccdd oiiotool --repremult (#3192)
ImageBufAlgo has both premult and repremult (as well as unpremult).
But oiiotool only exposed unpremult and premult, but not repremult.
This little patch rectifies that oversight.

Just to remind everybody of the difference:

`premult` just multipies the color channels by alpha, like it says.
Note that for a pixel that has Alpha = 0 but nonzero color, this will
crush the color to black.

That's fine if you have an *original* image that's unpremultiplied and
you want to do a one-time conversion to premultiplied.

But there's another use case, which is when you start with a
premultiplied image, you need to temporarily unpremultiply it (like
for a color space conversion), and then re-premultiply it. In that
case, you may have those glowing pixels in the original image, the
unpremult will preserve them, and you DO NOT want to crush them to
black with the subsequent premult.  So there is a "repremult"
operation that's like premult, but preserves the color values when
alpha == 0. This is the preferred operation when you are doing the
sequence of "unpremult, do something, re-premult" so that the glowing
pixels make it through the round trip.
2021-11-22 23:25:56 -08:00
Larry Gritz d4da1fde87 Fix to oiiotool --invert : avoid losing the alpha channel values (#3191)
When I implemented `oiiotool --invert`, I knew that the default should
be to only invert the first three channels (presumably R,G,B) and not
anything beyond, because we wouldn't want to invert the Alpha channel.

But I botched it, and instead what happened is that if given an RGBA
image, it would just leave the A black in the result image.

So this patch has two improvements:

1. If there are more channels in the source image than we are
   inverting, make sure to copy the other channels unmodified, don't
   just leave them blank.

2. Allow optional modifiers chbegin= and chend=, so users can change
   the default if they want a different channel set to be inverted.
2021-11-22 23:24:54 -08:00
Larry Gritz 9206e45256 IBA::saturate() and oiiotool --saturate (#3190)
This new IBA/oiiotool command adjusts the saturation of a color image,
with a scale factor. Scale = 0 makes the image gray scale of
equivalent perceptual luminance, scale = 1 leaves color unchanged,
scale > 1 increases color saturation.
2021-11-22 23:24:23 -08:00
Larry Gritz 81aebd2f56 Build: option to time individual compile commands (#3194)
This adds a new cmake variable in our build system, TIME_COMMANDS,
that when set ON will adjust the compile and link rule launch to
include a time command. This is probably only useful when also setting
`CMAKE_BUILD_PARALLEL_LEVEL=1` so that build are happening serially.
The use case is to investigate how long each module takes to compile,
for optimizing the build.
2021-11-22 00:20:45 -08:00
Larry Gritz 85acf8b250 CI enhancements: MacOS 11, other updates (#3193)
* Add a test for MacOS 11
* Updated supported versions of dependencies
* Move linux clang test to clang13 on vfx2022 container
* Switch clang-format test to use clang12
2021-11-22 00:20:21 -08:00
Larry Gritz 1217102b0f GIF full IOProxy support (#3181) 2021-11-20 18:02:12 -08:00
Larry Gritz 32e00ada6a JPEG output IOProxy support (#3182)
IOProxy was already supported for JPEG input.
2021-11-19 23:41:43 -08:00
Larry Gritz 717b0bb175 Expand the list of TERM values supporting color (#3185) 2021-11-19 20:39:53 -08:00
Larry Gritz 82c7a5af94 Raise ImageCache default tile cache size to 1GB (#3180)
In the early days of OIIO, it was 100MB. Ten years ago, we bumped it
to 256MB. I've heard a rumor that computer memories have grown in the
last 10 years, and so have the size of images some people deal
with. So it seems reasonable to raise it to 1GB.
2021-11-19 20:37:52 -08:00
Larry Gritz 4b6bffafc9 Banish sscanf (#3178)
`sscanf()` still has locale-dependent behavior that we wish to avoid
because it can lead to subtle bugs for people whose machines are
configured for certain locales.

This patch removes from the OIIO codebase almost every remaining
sscanf use (and definitely every one that could harbor locale bugs).
Instead, we use the rich set of parsing functions we've added to
Strutil over the years, which are locale-independent, and in most
cases are also faster than the standard C/C++ equivalent.
2021-11-19 20:37:16 -08:00
Larry Gritz f046c42ee1 TypeDesc ctr from string: accept "box2f", "box3f" (#3186)
The official names we use are "box2" and "box3", but users of Imath
know these as box2f/box3f, so accept these as synonyms when
constructing a TypeDesc from a string.
2021-11-17 16:42:54 -08:00
olegulandOle Gulbrandsen da21b7a98e SPI Specific: default to LLVM 12.0.1 (#3187)
Co-authored-by: Ole Gulbrandsen <ogulbrandsen@imageworks.com>
2021-11-17 15:06:22 -08:00
cmstein 3092639295 adding host/device attributes to make TypeDesc methods GPU device-friendly (#3188) 2021-11-17 15:04:32 -08:00
Larry Gritz 476c02eb92 Fix docs/behavior with webp "LoopCount" (#3183)
* Typo in webp section -- said "gif:LoopCount" when we meant
  "webp:LoopCount".

* In the code, did not actually set the "oiio:LoopCount" metadata
  that the docs said would be set.

* Opportunistic fix: TIFF docs said we only suported IOProxy for input,
  but we have supported it for output for a while now.
2021-11-15 21:31:42 -08:00
Larry Gritz 985bda763a Strutil::parse_line (#3177) 2021-11-11 21:14:53 -08:00
Brecht Van Lommel 4f97ff6eef Fix excessive memory usage when saving EXR file with many channels (#3176)
Scratch memory allocation in ImageOutput::to_native_rectangle was using
the number of channels squared.
2021-11-11 13:25:55 -08:00
Larry Gritz 974f79b6aa Strutil: add new utilities for parsing values out of strings (#3173)
* `parse_values()` and `scan_values()` both can parse a series of
  values in a string, with optional prefix, suffix, and separator. The
  scan versions just figure out the values, the parse versions
  optionally can update a string_view& like the other parsing
  functions in Strutil.

* `scan_datetime` parses the int components of a string that looks like
  "YYYY:MM:DD hh:mm:ss" (and a few minor variants).

* Fix stoui -- it was previously casting stoi results, which is not
  correct.

* Add `from_string<>` specialties for `double`, `int64_t`, `uint64_t`.
2021-11-10 13:45:03 -08:00
Larry Gritz ba1d19dd74 SPI specific: updates to versions used by Makefile-bits 2021-11-08 11:44:28 -08:00
Larry Gritz e09a2e66bd oiiotool: better detection of file reading failures (#3165) 2021-11-07 18:07:07 -08:00
Larry Gritz b65412c22b oiiotool: Fix bug autocropping to positive area for all-negative data (#3164)
When outputting to formats that don't support negative pixel origins
(such as JPEG), we crop away the negative areas. But we did not
consider the case where the entire data window was in the negative
region!
2021-11-07 18:06:50 -08:00
Larry Gritz 1b22597371 RLA input: guard against malformed input (#3163) 2021-11-07 18:01:50 -08:00
Larry Gritz 429883dc88 Targa: more safety for corrupted files (#3162)
* Check for palette mode files that don't supply a color map.
* Fix implementation bug in handling x flipped images.
2021-11-07 14:38:48 -08:00
Larry Gritz 60e3ea8c28 tiff output: switch to "bigtiff" for really big images (#3158)
TIFF has an absolute limit of 4GB file size due to use of uint32
offsets within the file. If you try to write a big enough TIFF image,
it will fail. This is not a software problem, it's a limitation of the
original TIFF file specification itself.

The underlying libtiff supports a nonstandard "bigtiff" extension that
uses 64 bit offsets. This patch switches to this automatically for
images whose uncompressed size would get too close to (or exceed) the
4GB limit.  Any such files can be read by OIIO-based software, as well
as anything else using a relatively modern version of libtiff, but may
not be readable by independent TIFF reading implementations.

This is a mixed bag, though. On one hand, this at least lets us write
files that would have been an error before.  But note that some files
that would have worked as classic TIFF before -- because their
*compressed* size was still under the 4GB limit, even if their
uncompressed pixel size was not -- will now be written as bigtiff
because we have to commit at the time we open the file, before we've
seen the pixels and know the final compressed size.  We just can't
know for sure, for an image with > 4GB of pixels, if the file will get
lucky and be below the limit by the time the scanlines or tiles are
compressed.  So for those files, not all apps will be able to read
them (though anything using libtiff >= 4.0 or OIIO will be fine).

Fixes 3156
2021-11-07 08:21:53 -08:00
Larry Gritz 152f6c8849 New global OIIO attribute: "try_all_readers" (#3172)
When ImageInput::create() or open() is called, it first uses the
extension of the filename to guess which reader plugin to try (for
example, "foo.jpg" will try the jpeg reader). If that fails, however,
the default behavior is to then try EVERY reader to see if any will
open the file, in case it guessed wrong, or the extension is used by
more than one format, or the file was simply given the wrong
name. Thus, ultimately, OIIO will never fail to open a valid image
file in a known format, even if the file is wildly misnamed. However,
it's a lot faster to open a correctly named file, because it will try
that one first, before trying a long succession of readers in the hope
that eventually one will work.

There are three cases where this is not the desired behavior:

1. You are confident that files are named with the correct extensions,
and you want a corrupt or invalid file to fail QUICKLY, without trying
every format reader.

2. If the file is corrupt, rather than see a generic "Could not find
any format reader that will open the file" because they all failed,
you want to see the more specific error message for why the (presumed)
correct reader could not succeed.

3. When doing regression tests to make sure that sample corrupted
files are correctly reporting the right errors, we really do want to
see error messages from that one reader we are testing.

This PR exposes a global OIIO attribute, "try_all_readers", which
defaults to 1, but when set to 0, changes the behavior so that ONLY
the one format implied by the file extension is tried, and OIIO does
not subsequently try every known reader.
2021-11-07 08:21:30 -08:00
Larry Gritz eae19db2f9 oiiotool --oiioattrib (#3171)
This new oiiotool command lets you set global OIIO attributes, i.e.,
making calls to OIIO::attribute(). It allows oiiotool command lines to
set some additional OIIO-wide options for which no specific oiiotool
command flags could otherwise access.
2021-11-05 00:13:00 -07:00
Larry Gritz e058dc8c4a Fix per-file boilerplate to just link to the github project (#3170)
Not the specific license file. Users can find that. Better to use
the project link. I'd been meaning to do this for a long time.
2021-11-04 09:51:41 -07:00
Rémi Achard 26cd4113c2 Fix identifier not found error on MSVC (#3168)
Signed-off-by: Rémi Achard <remiachard@gmail.com>
2021-11-03 16:27:56 -07:00
Larry Gritz 3850e29ed6 CI: OCIO has renamed its master branch to main (#3169) 2021-11-03 13:20:34 -07:00
Larry Gritz 4c1bdfefbd build_libtiff.bash: Allow override of build type (#3161)
Also make the default version of libtiff we build be the current 4.3
2021-11-03 09:59:08 -07:00
Larry Gritz 25bbb7fa7f Update to newer stb_printf for our implementation of vsnprintf (#3160)
Solves some security problems and/or just false positives in
address sanitizer.
2021-11-03 09:58:49 -07:00
SebTV 022d42a871 Fix Typo that prevents setting Compile Definitions (#3167) 2021-11-03 09:58:17 -07:00
Larry Gritz 91bc398073 exr output: Support new OpenEXR zip compression level choices (#3157)
When building against OpenEXR >= 3.1.3, exr output now allows zip/zips
compression to take a quality metric (such as compression
"zip:4"). The range is from 1-9, 4 is the default, and it's a control
over speed of compression vs compression ratio (higher number is more
expensive but may result in smaller files). This only affects
compressed output -- it's lossless and will be read to the same pixel
values upon input.

This is also incentive to upgrade to OpenEXR >= 3.1.3, because its new
default (and ours) is 4, versus the old (implied, not directly
controlled) 6. This change was made because compared to 6, it's
significantly faster to write exr files with zip compression 4 (tens
of % faster), while only increasing file size by 1-2%, so that seemed
like the right tradeoff. Lower numbers make much larger files for
little speed gain, and larger numbers than 6 make for much slower
writes of exr files for very tiny compression improvements. But YMMV
and you may want to experiment to find the right trade-off for your
use cases.
2021-11-01 23:06:47 -07:00
Larry Gritz 00a6c6023a CHANGES 2021-10-31 12:15:50 -07:00
Larry Gritz 71177ff402 Field3D deprecation part 2: Remove field3d support (#3151)
OIIO 2.3 marked it as deprecated. This new change is for master (2.4+)
only -- removing all support for Field3D.

F3d is effectively unmaintained, is known to be incompatible with
the latest versions of OpenEXR/Imath, and we haven't found anyone
prepared to speak up as a user of it via OpenImageIO support.
2021-10-31 12:14:07 -07:00
Larry Gritz 5c89335ddc Rewrite Filesystem::searchpath_split to remove boost::tokenizer (#3154)
One more boost extraction:  tokenizer.

The only place we used it is Filesystem::searchpath_split, which can
easily be rewritten in terms of the Strutil parsing functions.
While I'm at it, add a new version that returns the vector instead
of needing to pass in a ref.
2021-10-29 21:28:20 -07:00
Larry Gritz 04293edaa3 Stochastic mipmap interpolation (#3127)
Suggested by Luke Emrose, the idea here is that we introduce two new
MIP interpolation modes: StochasticTrilinear and StochasticAniso.
These work similarly to Trilinear and Aniso, respectively, except that
instead of sampling both of the bracketing MIP levels and blending
between them, in stochastic mode we use a random variate to select ONE
of the two MIP levels with probability proportional to the computed
blending weight.

If these mip modes are used, the caller needs to pass a
well-stratified value in the new "rnd" field of TextureOpt. Also note
that the method only really makes sense in the context of a renderer
that is using many samples per pixel. As a single texture lookup, it
looks horrible and noisy, as you can see by the testshade-based tests
we do of this, which are 1spp and looks pretty rough.

My benchmarks (in a hard stress test of the texture system using
`testtex --threadtimes 8`) show that this approach has speedups of
35-40% when using between 1-4 threads, dropping to more like 25-30%
speedup as threads are in the 12-32 range (that makes sense, it's
doing the same amount of total I/O).

In this first implementation, in order to preserve ABI compatibility
if we decide to backport this feature to the release branch,
TextureOpt::rnd is added as a union co-member with the unused "bias"
field. For TextureOptBatch, we had to add it outright, but it's
guarded by an `#if` and will not be backported to 2.3. (We may change
our minds and not backport it at all, I just wanted to leave the
option open with this initial patch. Also, there will probably be
additional further ABI-breaking changes coming later that will
definitely not be backported.)

In this first phase, we only use the stochastic component to turn the
2-MIP-level lookup into one level lookup.  It has been further
suggested that we could apply stochastic techniques to anisotropic
filtering (instead of many samples spaced across the major axis of the
filter footprint, take one sample distributed across the axis), and
even for the ordinary bilinear or bicubic within each level (instead
of 4 or 16 weighted texels, just retrieve one texel chosen with the
weights as probabilities). But these deserve to be benchmarked and
have their quality evaluated separtely and deliberately, and so will
be relegated to a later investigation and implementation.
2021-10-28 14:02:52 -07:00
Larry Gritz b8f25e0541 Remove the last vestiges of the experimental C API (#3144)
We will have a C API eventually, but it will be implemented
differently, and this cruft will probably get in the way. If the new
code needs any of this (particularly the test cases), it's easy enough
to revive it from the project history).
2021-10-27 21:24:58 -07:00
Larry Gritz 3f0e12a822 raw: fix ProPhoto gamma, add ProPoto-linear (#3153)
When requesting that raw image be returned as "ProPhoto" color space,
we were using the wrong gamma. Also, at user request, add
"ProPhoto-linear", which is the same but with linear response. (This
is analogous to the existing "sRGB" and "sRGB-linear".)

Fixes #3152
2021-10-27 21:22:22 -07:00
Larry Gritz fff364ffce Fix bad alignment and simd assumptions in fill_gray_channels (#3145)
Thiago Ize points out that TextureSystemImpl::fill_gray_channels
assumes that the `float*` addresses it is passed are big enough for
a vfloat4, and also properly aligned as such. Not true.

This is an edge case anyway, only called in particular cases where
we are doing 3/4 channel lookups on 1/2 channel files with the option
turned on to expand single channel gray to RGB gray, and also doesn't
do enough SIMD to have a perf impact. So just recode as scalar and
have no more alignment mismatches to worry about.

Also make sure at least one of the Windows CI tests is explicitly
turning SSE on.

Fixes #3128
2021-10-27 21:21:27 -07:00
Larry Gritz 3715f15ce7 docs: formatting fixes 2021-10-24 22:40:33 -07:00
Larry Gritz 4cde5b72b9 Field3D deprecation -- stage 1 (#3140)
Field3D is essentially unmaintained, and is currently incompatible with
OpenEXR/Imath >= 3.

In this first stage (which will apply to OIIO 2.3):

* By default, Field3D support is disabled. To enable it, you must
  invoke CMake with `-DENABLE_FIELD3D=1`. No warning or other messages
  are printed by the build configure step when not enabled.

* If requested, but an incompatible OpenEXR is found, it will be disabled
  with a clear error message.

* If requested and enabled, a warning will be printed indicating that
  Field3D support will be removed from future versions (2.4 and beyond).

* Add a new test, texture-texture3d, that provides the same testing that
  texture-field3d did, but with openvdb.
2021-10-24 12:07:10 -07:00
Larry Gritz a844c7a0ed Improvements related to image dithering and low-bit-depth output (#3141)
We have options that allow adding random dither to images before
output, which when converting float images to 8 bit or less, can
greatly reduce the appearance of banding artifacts. This PR makes a
number of improvements:

* When the option is used, it should apply dither any time you are
  reducing an image with > 8 bits/channel to an output with <= 8
  bits/channel. Not just from float/half, but also from uint16, for
  example. (When outputting > 8 bits per channel, there are enough
  gradations that you tend not to see banding artifacts, so dithering
  is not necessary for 16 bit output, even if coming from a float data
  source.)

* Change the actual dither we use to blue noise. The old dither just
  used a hash to add uniformly distributed random numbers to each
  pixel value before quantization, completely uncorrelated from pixel
  to pixel. Blue noise is specially constructed to still have a
  uniform distribution of the output range, but it ensures that
  spatially, similar values are distributed as far away from each
  other as possible, rather than having similar values sometimes
  clumped together.  The result is a MUCH NICER appearance.

* Of course, this means the we needed to store a blue noise table in
  the library, and some access routines for it. We incorporate a
  public domain blue noise texture as a table.

* ImageBufAlgo::noise() and `oiiotool --noise` now take "blue" as a
  noise name to return blue noise. Also, make "white" the (preferred)
  synonym for "uniform" (to disambiguate the fact that both white and
  blue noise are uniformly distributed; the difference is that white
  is independently random for each pixel, whereas blue shapes the
  spectrum to favor high frequencies, making it better suited for
  dithering and sampling purposes.

* ImageBufAlgo::bluenoise_image() returns a reference to a stored
  periodic blue noise image.

* oiiotool -d would let you say "uint10" or "uint12" to indicate 10 or
  12 bit output (for formats that support it), but had no way to ask
  for less than 8 bit output (for example, TIFF supports that). So we
  add "uint6", "uint4", "uint2", "uint1" as recognized names for the
  `-d` option in those rare cases when you specifically want to
  produce a low bit depth file. And furthermore, if you ask for
  `--dither` when using lower bit depths, the dither amplitude is
  adjusted to be right sized for the bit depth you are using.

* Many format output modules that support 8 bit output honor the
  option to dither the output, but in the "built-in plugins" chapter
  of the docs, most did not list this option in the section that
  describes which special output options it knows. So now we've added
  this to the docs for all the output plugins that did support it.
2021-10-24 11:27:03 -07:00
Larry Gritz 77ff294664 Fix copy/paste error in ImageCache docs for 'failure_retries' attrib (#3147) 2021-10-24 11:25:30 -07:00
Larry Gritz c3cf7b9c08 heif: Handle unassociated alpha (#3146)
Turns out that heif files that contain alpha can have either
associated or unassociated alpha. We had been assuming
associated. With LibHeif 1.12 and beyond, you can ask, so now we
do. Thanks Frédéric Devernay for pointing this out.

Similar to other formats that optionally have unassociated alpha:

* The default behavior is to associate/premultiply automatically when
  reading, but set metadata "heif:UnassociatedAlpha" to indicate that
  it was unassociated in the file.

* Open configuration hint "oiio:UnassociatedAlpha", when nonzero,
  means to please keep the data unassociated and not premultiply. In
  that case, metadata "oiio:UnassociatedAlpha" will be set in the
  ImageSpec to indicate that the returned image (not just the file)
  consists of unassociated values.

I did a couple other minor docs touch-ups while I was at it.

Fixes #3129
2021-10-24 11:04:48 -07:00
Larry Gritz 6507724330 raw: Fix compat break in their 202110 snapshot (#3143) 2021-10-23 12:58:13 -07:00
Larry Gritz fb55e52843 [docs] Add an oiiotool example of putting a border around an image (#3138) 2021-10-21 23:46:13 -07:00
Larry Gritz f749be7bd3 oiiotool --dumpdata:C=name (#3136)
New ":C=name" modifier for --dumpdata will cause the dumped image data
to be formatted with the syntax of a C array, that can be dropped right
into source code.

    $ oiiotool --dumpdata:C=foo image.exr
    // image.exr       :  256 x  256, 4 channel, float openexr
    float foo[256][256][4] =
    {
      { /* (0, 0): */ { 0.517036676, 0.261921108, 0.017822538, 0.912108004 },
        /* (1, 0): */ { 0.653315008, 0.527794302, 0.359594107, 0.277836263 },
        ...
    };

Without this modifier, --dumpdata will keep the same formatting it
always had.

This works pretty well for ordinary boring flat, single subimage,
non-MIPmap images.  The option should probably not be used (or at
least is very unpolished) for multi-subimage, MIP-mapped, deep, or
other oddball cases (but you probably don't want to shove those into
a single C array anyway).
2021-10-21 23:46:01 -07:00
Larry Gritz 245ae961b1 cmake: Need OpenImageIO_SUPPORTED_RELEASE to be cache variable (3142)
I have a reason for needing to be able to override it on the command
line when we do a cmake config step.
2021-10-21 23:45:03 -07:00
Brad Smith 713b78d18b Sysutil: improvements to NetBSD and OpenBSD support (#3137) 2021-10-18 00:45:32 -07:00
Brad Smith b4787213e3 Fix building with Clang on big endian archs (#3133) 2021-10-16 11:27:44 -07:00
Larry Gritz 0ecea4e275 Fix sometimes build breaks related to OpenCV headers (#3135)
Reclassify the OpenCV headers as "system" includes, which will turn off
warnings for things that show up in those headers that we can't control.
2021-10-16 11:16:12 -07:00
nick black c1997ddc3d [jpeg] remove debugging cruft (#3134) 2021-10-16 09:20:35 -07:00
Larry Gritz 7cc7a3a816 Fix broken oiiotool --dumpdata: botched a formatting string (#3131) 2021-10-14 22:34:34 -07:00
Larry Gritz e1060c3d2a Fix typo (#3130) 2021-10-14 22:34:15 -07:00
Larry Gritz 4f77d8b8d1 Replace Imath::clamp with OIIO::clamp (#3126)
We had long ago established that the one in fmath was a slightly
faster formulation, as well as having the property of squashing
NaNs. There were a few remaining places where we used a different
clamp so fix them.
2021-10-13 21:02:27 -07:00
Larry Gritz 23de7648fa Clean up src/doc/Makefile (#3124)
It was still by default referencing the old latex files that we've
long since removed.
2021-10-13 20:57:14 -07:00
Larry Gritz 99085de393 libraw: add new color space names (#3123)
The DSLR raw format reader has the ability to pass hints to the
underlying LibRaw requesting that the pixel data be returned to us in
particular color spaces.

* Add new supported color spaces "DCI-P3" and "Rec2020" when using a
  LibRaw new enough to understand them -- which means the upcoming 0.21.

* A new name to request the data be returned using sRGB color
  primaries but a linear response curve: "sRGB-linear".

* The old name we used for sRGB-linear, "linear", is now considered
  deprecated since it's ambiguous -- since its first use, new color
  spaces "ACES", "DCI-P3", and "Rec2020" have been added, all of which
  are also linear response.
2021-10-12 22:34:26 -07:00
Larry Gritz dea9b1fa7b Beef up error checking in Targa read (#3120)
When reading tga files, make sure that every seek and every read
checks results and issues error messages. Also double check that
large allocations succeed.

Also improve error propagation in several spot of iinfo, oiiotool
2021-10-12 22:33:55 -07:00
Larry Gritz 7745ac72b9 Address new warnings revealed by clang13 (#3122) 2021-10-10 10:24:30 -07:00
Larry Gritz 37e9ac2bae ci: Bump versions for the 'latest' tests (#3121)
* OpenEXR -> 3.1.2
* pybind11 -> 2.8.0
* On Windows, no longer vcpkg install boost regex, we no longer need it.
2021-10-08 20:12:03 -07:00
Larry Gritz 780fce4dc7 Use inline constexpr for C++17 (#3119)
Owing to our C++11 focus in previous years, we had a number of places
were constants were declared as `static constexpr`. When done in
headers, this potentially causes separate copies of those constants to
be instantiated in each module that includes the header. It's not
really harmful the way we're using it for small constand objects, but
it's wasteful to potentially have dozens of copies of each those
constants by having it repeated in each module.

C++17 has a new idiom, `inline constexpr` that is more like we want --
makes it a true compiler constant that doesn't get instantiated in the
memory of each module.

We still have to cater to C++14, and in platform.h we already had a
C++-standard-dependent definition of OIIO_INLINE_CONSTEXPR that was
almost correct. Fix it (it wasn't previously used, but I must have
seen this coming at some point) so that it expands to
`inline constexpr` for C++17 and beyond, but stays as
`static constexpr` for C++14, and then use it for these constants.

Fixes #3117
2021-10-05 16:12:43 -07:00
Larry Gritz b7f470b68f Guard against invalid UDIM tile numbering (#3116)
If think that our inventory of UDIM tile files won't find names with
wildly out-of-range tile indices, you haven't been working in a
production studio! When those indices imply tile numbers < 0, we were
running off the beginning of the vector when filling in the udim
table, to hilarious results.
2021-10-01 15:08:04 -07:00
Larry Gritz 4d50578d9c Allow quotes in oiiotool command modifiers (#3112)
Oiiotool::extract_options was kind of fishy and brittle before --
splitting the string at ':' characters, then split each piece (which
should form a `name=value` pattern) at the first '=' character. There
are probably many malformed option strings that would have had weird
results with the prior naive parsing method. And it has been noted
that it can't handle a value that is intended to be a Windows filename
(like "C:/foo"), nor a searchpath (like "/usr/bin:/usr/local/bin").

Rewrite to parse it more carefully as name=value pairs delimited by
':'. In the process, we now have the ability to have the value be
enclosed by a single or double quoted string, in which case the
contents of the quote may themselves contain a colon, for example, the
following command and modifier is now no longer a problem:
`--foo:filename='C:/blah':count=3:`
2021-09-29 18:26:54 -07:00
Larry Gritz 2fbdbf9d9d TIFF output: Honor zip quality request when we do our own compression (#3110)
We were already passing this on to libtiff when it handles the
compression.  But for the case where we were calling zlib ourselves
(to facilitate multi-thread compression, which libtiff doesn't do),
we were just using the default compression.

This is inspired by a great [blog post](https://aras-p.info/blog/2021/08/05/EXR-Zip-compression-levels/)
by Aras Pranckevičius in which he made a similar change to OpenEXR
and benchmarked the results. He reported approximately a slightly more
than 2x write speed increase, while getting files that were only around
2% larger.

I tried replicating his experiment for TIFF, and while I don't quite
get results as good as he did, it still is really interesting.  I
tested with 100 images randomly selected from the [Animal Logic Lab
USD scene](https://animallogic.com/usd-alab/) (they are almost all
4k^2, a mix of 1- and 3-channel images), converted from half exr to
uint16 TIFF images. I ran the tests for both scanline and tiled
images.

Compared to the default zip level 6, using level 4 resulted in 3%
bigger files, and around 40% faster write times. That seems like it
is a potentially very helpful tradeoff.

I tested the same set of images also with zip levels 8 and 2. For
level 8, the files were only another 2% smaller than the default level
6, but the write speed was 45-50% slower, so there is little value to
asking it to work harder on compression -- it just burns up time. For
level 2, it went somewhat faster (maybe another 10% faster than level
4) but the files started getting bigger, level 2 was 12% bigger than
level 6, that's definitely getting into territory where people might
mind the larger files.

So I want to add the control now, though I'm deferring a decision on
changing the default value until I can do some more extensive
tests. In particular, I would like to assess how it behaves with 8 bit
files (I was testing uint16, specifically), how well it works with
rendered images and with natural/photographic images (I was testing a
set of textures, which may not have the same characteristics), and
perhaps also see if results are better or worse for lower resolution
images.
2021-09-29 18:24:19 -07:00
Larry Gritz 7b0352b58a Add multithreading to exr core read_scanlines and read_tiles (#3107)
The old libOpenEXR/libIlmImf (default) implementation handled
multithreading on the exr side of things, inside the readPixels method.

The new (experimental, enabled only by option) OpenEXRCore
implementation leaves the threading to the caller, and we weren't
doing it, so the performance was unsurprisingly awful.

This patch turns the implementations of the exrcore-based
read_native_scanlines and read_native_tiles (and also the deep
versions thereof) to use parallel-for loops, restoring parallel
processing to the exr reader when using OpenEXRCore.

Reading of whole scanline and tiled images now is on par or slightly
faster (a few %) than when using the main OpenEXR library. Reading of whole
scanline and tiled deep images is substantially faster (2-3x!) than
before.

I did some extra refactoring while I was there, simplifying and
eliminating some redundant error handling and using a new
DecoderDestroyer utility class.

STILL TO DO:

* See the long comment at the end of read_native_scanlines -- the error
  message strategy implemented here is temporary, I'd like to improve it,
  will probably involve both some work here as well as on the openexr
  side.
2021-09-29 13:05:30 -07:00
Larry Gritz f8aca7b0d3 SPI only: Minor tweaks to the site file. 2021-09-29 11:10:57 -07:00
Larry Gritz 6197716bf9 Suppress OCIO console info output (#3113)
Make sure OCIO isn't spraying info messages at the console when we
first ask for a config.
2021-09-28 10:32:55 -07:00
Larry Gritz ee36fd5b91 Build: Add ENABLE_INSTALL_testtex option (#3111)
If set to ON, will include the testtex program in the install.
The default is OFF, which builds it for tests, but doesn't install it
with the real command line utilities.
2021-09-28 10:32:23 -07:00
Larry Gritz 6a339bc957 Bump minimum supported OpenEXR/Imath to 2.3 (#3109)
In forward looking code (current master means OIIO 2.4, which won't
be released until mid-2022), get rid of some stray logic catering to
OpenEXR releases 2.2 and older.
2021-09-28 10:31:40 -07:00
Larry Gritz 8de11b8d73 Build: fix over-eager use of targets (#3108)
Background: Old style CMake was to use FindFoo.cmake modules, which
set FOO_INCLUDES and FOO_LIBRARIES variables. Best new cmake practices
are for the upstream packages themselves to export a FooConfig.cmake
and friends, which set up cmake targets. Of course, many packages don't
provide exported configs, so we use the old Find modules for many of
our dependencies.

I've slowly been migrating our Find modules to set up targets in addition
to the variables, and favoring use of the targets over the variables.

But I was wrong about this. It's more than just a choice of style.
When targets are used, use of transitive linkage (especially for static
library versions of dependencies) make the dependency targets show up in
our own exported OpenImageIOConfig.cmake. But to a downstream package,
now our config talks about a target like Libsquish::Libsquish, but it
doesn't know what that is, and it doesn't have the FindLibsquish.cmake
module that we used (internally) when we found that dependency.

This was causing particular problems for Libsquish on Windows with
vcpkg, but I see now that this could be a problem elsewhere as well:
field3d, libheif, openvdb, and webp.

So this patch:

* Reverts from the ill-advised targets back to the old style
  variables, for the dependencies where we use *custom* Find modules.
  (We presume that a dependency's exported configs, as well as any
  Find modules that are distributed as part of CMake itself and define
  targets, are done correctly, and will be available to downstream
  packages, and so we continue to use targets in those cases.)

* Beefs up our FindLibsquish.cmake module to correctly find debug
  versions of the library, to use in debug builds.

* Alters build_webp.bash to allow WEBP_BUILD_TYPE to override the build
  type, which had previously been hard-coded to Release.

* Removes search for HDF5, which as far as I can tell was unused
  directly by OIIO.
2021-09-27 21:49:57 -07:00
Larry Gritz 9d2a52341d strutil_test: add a test of split when the separator is not found (#3106)
I had a hunch about a problem. Was wrong, this function worked right
all along. But I'm keeping the beefed-up test.
2021-09-25 10:01:51 -07:00
Larry Gritz 93a16297e3 fmath: Improvements to round_to_multiple (#3104)
* More clearly document, test, and correctly handle the cases where
  the value < 0.

* Add `round_down_to_multiple`.
2021-09-20 23:10:14 -07:00
Larry Gritz 78901c3b04 Always have OpenEXRCore C library on tap -- with option (#3100)
Instead of a build-time option for enabling (and always using) the
experimental OpenEXR "core" library...

* Build support for it by default any time we're using a new enough
  OpenEXR version (>= 3.1). You can still hard-disable it being compiled
  in at all with `-DOIIO_USE_EXR_C_API=OFF`.

* Select whether it's actually used with the global OIIO attribute
  "openexr:core" (default to 0, disabled, for now).

This easily lets an app select support at runtime, and also may be
selected by user with environment variable
`OPENIMAGEIO_OPTIONS="openexr:core=1".

This all is intended to make it easier to benchmark use of this new
feature, switching back and forth without a rebuild.
2021-09-20 23:09:56 -07:00
Larry Gritz 31d5a6f1d3 Remove FindOpenImageIO.cmake (#3098)
Downstream clients should use the exported config.
2021-09-20 22:56:17 -07:00
Larry Gritz eb4b84e74d OCIO 2.1 now exports cmake config -- explain 2021-09-17 20:38:24 -07:00
Larry Gritz 4399477fd4 Improvements to font finding (#3096)
* Honor env $OPENIMAGEIO_FONTS as an additinal font searchpath.

* Global attribute "font_searchpath" as an additional font searchpath.

* Refactor and simplify the code that assembles the list of directories
  to search.
2021-09-16 19:53:05 -07:00
Larry Gritz 2d14cec834 Adjust logic of getting OCIO config (#3095)
When $OCIO was not set at all, the call to OCIO::GetCurrentConfig()
was checking it again and writing the info message that none was found
to stdout, which we really don't want.  And as Patrick pointed out
recently, asking for the "current" config is suspect, since who knows
exatly what the app has done.

So we're making the following executive decision: At least from OIIO's
viewpoint, if you want an OCIO color config, you either have to name it
expliticly, or have it determined by the `$OCIO` env variable. That makes
cleaner logic, and also rids us of the info messages.

I also now have the exported cmake config set
`OpenImageIO_HAS_OpenColorIO`. This makes it easier for downstream
consumers of our exported OpenImageIOConfig.cmake to know if the OIIO
build they have found has build-in support of OpenColorIO.
2021-09-15 10:24:59 -07:00
Larry Gritz 9dc2f971fd Fix ImageBuf::read bug for images of mixed per-channel data types (#3088)
When it comes time to read_image() into the ImageBuf's internal
memory, we should have said to convert to `m_spec.format`, which
describes the buffer we allocated. Instead, we asked for `convert`,
which is the user request, which at that time can still be UNKNOWN,
which indicates to preserve the file's data format, which in fact does
not necessarily match the internal buffer.

This becomes especially troublesome for images with mixed per-channel
data types, which will obviously never match the internal buffer since
ImageBuf only internally stores one data format for all channels.
2021-09-15 09:57:03 -07:00
Larry Gritz 689bfbfd54 When possible (>= C++17) use std::gcd instead of boost (#3076)
This is a very low priority change, but every little bit helps when it
comes to limiting boost's footprint as thing we used to require it for
become available in the standard library.
2021-09-15 09:46:43 -07:00
Larry Gritz cc67fab4f3 Rewrite ColorConfig::reset for clearer logic and better err handling (#3092)
Add tests to be sure we have reasonable error reporting for at least
two important cases: a specified OCIO config file is not found at all,
and an OCIO config is present but cannot be read (in particular, if
the config is newer than the library). Because the exact error spewage
is different for each OCIO version, and apparently also depending on
the exact version of the yaml library that OCIO used, we have a few
different possible output references.

* oiiotool --nostderr (new hidden command)

This hidden flag causes oiiotool errors to go to stdout instead of the
default stderr. It only does this for oiiotool's own error and warning
calls; if there are other places within library functions that
directly output to stderr, they will not be redirected by this
command.

The main purpose of this is for testsuite and debugging. I don't
expect ordinary users to have any use for this, and so it is currently
hidden from the oiiotool --help explanation.  If it seems useful for
something other than testsuite, I'll expose it in oiiotool --help.

It seems that for the case of OCIOv1 reading a v2 config, OCIO itself spews a bunch of warnings to stderr. And apparently the order is nondeterministic, because I just could not get any set of reference error output to match stably from run to run in CI. But the problem is, if I don't capture stderr, I also don't get the oiiotool error messages, which are the very thing I'm trying to test!

So what I did is add a new flag to oiiotool, --nostderr, which causes oiiotool's error and warnings to get sent to stdout rather than stderr. This lets me capture the usual output and the error messages from oiiotool, for this test, while allowing OCIO's stray stderr output to go into the ether where we don't care about its order.

I'm not sure if there's any non-CI, non-debugging application for oiiotool --nostderr, but maybe it'll turn out to be generally useful.
2021-09-11 19:10:36 -07:00
Larry Gritz 5506f34f85 Use latest aswf docker container for vfx platform 2022 (#3094) 2021-09-10 22:09:40 -07:00
Larry Gritz 7b22ba6305 CI: Adjust how we specify what to exclude from failure artifacts (#3091)
We weren't using a recognized notation, and so our artifacts were
including huge files unintentionally.
2021-09-04 18:20:34 -07:00
Larry Gritz d8661b783c OCIO: better catching of exceptions. (#3089)
When OIIO that was built against OCIO 1.x, but encounters an OCIO 2.x
config file, OCIO could throw an exception that was not caught by
OIIO.  The problem was the call to OCIO::GetCurrentConfig(), it should
have been inside the try/catch block.
2021-09-03 19:02:59 -07:00
Dalai Felinto 085aa98cc4 Update CREDITS.md (typo) (#3090) 2021-09-03 10:38:53 -07:00
Larry Gritz 6ba1f1faa4 CHANGES 2021-08-31 23:41:10 -07:00
Larry Gritz 7037cfba47 CI: Build VFXP2022 and latest releases against OCIO 2.1 (#3080) 2021-08-31 23:36:05 -07:00
Larry Gritz 112a318ad6 Additional TIFF IOProxy bug fix -- we don't want a full init inside open (#3077)
Calling close() in open will forget too much state. All we want to do
here is make sure the TIFF file itself is closed at that point (so it
can be re-opened in append mode to add a subsequent subimage).
2021-08-31 08:48:50 -07:00
0ea473527a tiffoutput: support ioproxy (#3075)
Co-authored-by: Alexandre Gauthier-Foichat <alexandre.gauthier@left-angle.com>
Co-authored-by: Larry Gritz <lg@larrygritz.com>
2021-08-30 14:51:10 -07:00
Larry Gritz b53cdeddc8 CI test for VP2022, fix revealed python binding bugs (#3074)
* CI test for VP2022, fix revealed python binding bugs

* CI test against ASWF's latest VFXPlatform-2022 docker container,
  including Python 3.9.

* Pesky crash resulted in testsuite/python-imagebufalgo, laboriously
  traced to IBA_color_range_check releasing the GIL too liberally. The
  scoped release cannot contain the tuple construction!

* Audited the rest of py_imagebufalgo.cpp and found the same mistake in
  only one other place: IBA_histogram. Was asymptomatic so far, but fixed
  now.

* Presumably we just got lucky and these bugs were never symptomatic
  until we started building against Python 3.9.

* Noticed that the recent change in build tree layout where we now
  copy the test images into the build/testsuite area, resulted in HUGE
  GHA build artifacts for failed tests. Modify ci.yml use of
  upload-artifact action to exclude those directories.

* more tweaks
2021-08-30 09:14:04 -07:00
Larry Gritz bdf6a40bad oiiotool: Overhaul operations timing (#3073)
oiiotool --runstats tries to report how much time was taken by each
operation.  But it has always had a major flaw: Because we try to read
input files lazily and use ImageCache underneath, only in certain
circumstances do the true cost of reading the files show up in the
entry for "-i"; often the cost gets wrongly credited to the other
command (like --add or -o) whose operations triggered the I/O.

This patch addresses the problem, and I think correctly credits I/O
time where it belongs.

The workhorse here is a new helper class within oiiotool,
OTScopedTimer, which does some tricks to try to account for both
direct read time and ImageCache I/O time, subtracting those from the
op it was instructed to time and instead adding it to the counter for
"-i".  Because the destructor apportions time to the right commands,
this eliminates a whole bunch of spots where we did that by hand.

Also fixed a few places where ops directly called ImageRec::read()
instead of Oiiotool::read(), which would also result in bypassing some
timers we relied on. I made the ImageRec one be private, so harder to
make that mistake in the future.
2021-08-30 09:13:40 -07:00
Larry Gritz 159d7e7ae9 Beef up strongparam.h comments and fix typo 2021-08-25 21:02:42 -07:00
Larry Gritz 218e1bd731 gitignore adjustments
Make it ignore a lot of the test case clutter I tend to accumulate
in the project root.
2021-08-25 21:02:24 -07:00
Larry Gritz be5dda397f Timer::add_seconds, add_ticks (#3070)
Add methods to the Timer class that allows you to add (or subtract, if
negtive) to the total elapsed value of a timer.
2021-08-24 21:22:47 -07:00
Larry Gritz 97532b814f Build: Be careful about default installation directory (#3069)
Use a cmake idiom so that you need an explicit `-DCMAKE_INSTALL_PREFIX=`
in order to write over /usr/local or any potentially sensitive area.
In the absence of this being set explicitly, it will configure the
cmake build so that an "install" ends up in ./dist (which is what the
Makefile wrapper did all along).
2021-08-24 21:21:37 -07:00
Larry Gritz 8b4f8f2321 oiiotool --ch : reduce expense for no-op (#3068)
Before doing all the work of copying the image, first see if the
`--ch` is actually specifying any change versus the image as it
stands. If not, skip all the copying and just stick to the image we
have.

The main benefit here is if you have a --ch primarily for "conformance",
e.g. you want to reduce to a known subset of channels and remove any
extra that may be unanticipated in the input, but it's possible that
the input will come to you already with only the desired channels. As
an example,

    oiiotool in.exr --ch R,G,B ...more ops... -o out.exr

Previously, if in.exr aleady had channels R,G,B (and no other), there
would be some unneceessary expense of creating (in memory) a new image
for the output of --ch copying data to fill it in. With this patch,
the --ch would very nearly turn into a no-op. In both cases, if
in.exr's channels were something other than R,G,B, channel copies
would need to be done identically in both old and new code.
2021-08-24 21:20:54 -07:00
Larry Gritz 0ab127226a Build scripts: rename OIIO_DEP_DOWNLOAD_ONLY to DEP_DOWNLOAD_ONLY (#3072)
I realized after this was merged that I often share and copy a lot of
these little dependency build scripts across multiple projects, so I
wanted to remove the OIIO-specific naming.
2021-08-24 21:20:17 -07:00
Larry Gritz 4ebae5f91e Update ref output for slightly different libjpeg 2021-08-23 16:18:09 -07:00
Shootfast 5024e8dd5e formatspec: Implemented deserialization of extra_attribs from XML (#3066) 2021-08-20 22:32:50 -07:00
Larry Gritz c6b4424564 More testsuite cleanup for arbitrary build directory (#3067)
To help make testsuite pass even with nonstandard relative path to the
build area, slightly change how we reference the OCIO config that is
in the testsuite.
2021-08-20 18:36:32 -07:00
Larry Gritz 741c6d7b51 Increase timer_test slop in CI to remove spurious failures 2021-08-20 13:07:47 -07:00
Larry Gritz 44bbf1f434 Testsuite: fix use of OIIO_TESTSUITE_ROOT (#3065)
Fixes python error about OIIO_TESTSUITE_ROOT not defined in the case
where the testsuite dir wasn't found in the standard places. This can
happen if you put the build directory in an unusual location that's
not right in the main project area.
2021-08-20 12:29:04 -07:00
Thomas MansencalandThomas Mansencal 1866f2fdb8 PR: Minor Windows Build Fixes (#3062)
* Ensure that "CMAKE" built "OpenCV" libraries can be found.

* Fix incorrect url to "openexr-images" repository.

* Fix typo in "FindTBB.cmake" module.

Co-authored-by: Thomas Mansencal <tmansencal@wetafx.co.nz>
2021-08-19 09:27:49 -07:00
Larry Gritz 8ff28a9d58 Fix typo in test generation 2021-08-18 16:28:38 -07:00
Larry Gritz 09766c95a9 Bump version to 2.4.0.0 after branching 2.3beta 2021-08-17 17:15:21 -07:00
Larry Gritz a17769cb57 CHANGES 2021-08-17 13:48:31 -07:00
Larry Gritz 231e885c21 Fewer spurious CI failures for timer_test 2021-08-17 13:48:31 -07:00
Larry Gritz 273952b642 cmake: checked_find_package enhancements (#3061)
* New SETVARIABLES option sets named cmake variabes to true if the
  package is found.
* DEBUG should print variables even if not found. Duh, failing to find
  the package is the most important debugging situation.
2021-08-16 09:01:14 -07:00
Larry Gritz f91d391b1a Build: collapse build and dist hierarchy (#3057)
For historical reasons, our wrapper makefiles assume that we build in
`build/ARCH[.variant]`, so maybe build/linux64, build/linux64.debug, etc.

I think this is a throwback to literally decades ago when I would
build multiple architectures from different machines that viewed a
common shared directory of code, this allowing them to build
simultaneously and/or erase one without needing to rebuild the others,
etc.

But now I find that:
* It's contrary to modern cmake practice, and there are many benefits
  to having our build directory structure identical to the vast majority
  of other open source projects.
* I never want or need those simultaneous builds in practice, haven't
  for a long, long time.
* ccache means that there is no longer an onerous cost to, for example,
  having to blow away a release build and do a debug build and then
  blow that away and do release again. It's just a few seconds to do a
  ccache-based full rebuild of a recently-built tree.

So this patch switches all our assumptions to having a single level
hierarchy to the build and dist areas.

Also, I'm changing the assumption that the oiio-images (and other data
sets used by the testsuite) live "up a level", but instead added code
that either copies it from there (or another area settable with the
cmake variable OIIO_LOCAL_TESTDATA_ROOT) or downloads it, into the
build/testsuite directory itself. This simplifies a great number of things
in the test scripts as well as the test reference output (a lot of which
changes slightly to accommodate the new paths to test files).
2021-08-15 15:00:24 -07:00
Larry Gritz 63f69cbca8 Try to decrease spurious CI failures (#3059)
* On Windows, increase number of tries for tests that timeout.
* On all CI runs, allow timer_test to be less accurate.
2021-08-15 14:25:11 -07:00
Larry Gritz 83e44727f5 Update FindTBB.cmake to create proper targets (#3060) 2021-08-15 14:24:54 -07:00
Shootfast b2f9a9be79 RAW plugin improvements (#3045)
* raw: Fixed output when raw:Demosaic == "none"

* raw: Include metadata regarding filter pattern

* raw: Added missing call to set unpacked status

* raw: Implement "balance_clamped" mode to help HDRI processing

* raw: Implement raw:apply_scene_linear_scale feature

* Fix up formatting with clang-format

* Update testsuite reference output

* raw: Fixed error message format handling

* raw: Updated documentation to include new raw features
2021-08-14 14:03:57 -07:00
Anders Langlands bbc2dfca2c Add flags to control stages of dependency build scripts (#3058)
* Ensure that all the `build_*.bash` scripts don't download anything if the packages appear to already be there.
* Env variable `OIIO_DEP_DOWNLOAD_ONLY` can be used to do the download only (if not present) and skip the actual build.

This combination allow the scripts to be run twice: once to do all the network I/O to download the packages we'll need, and a second time to trigger the builds.
2021-08-14 09:58:24 -07:00
Larry Gritz 0dd908f4e9 New oiiotool commands: --printinfo, --printstats (#3056)
The existing --info and --stats seem a little confusing and
inflexible.  Unlike the majority of oiiotool arguments which are
evaluated in order, these merely set flags which apply to the entire
oiiotool command (specifically, they cause all image inputs to print
the metadata or image statistics at the time that the input are read
from disk).  There isn't a way to make it apply to a single image, nor
to print the metadata or stats of any *computed* image, leading some
people to awkwardly save a computed image and re-read it merely to
print information about it.

So in this patch, we add new commands

* `--printinfo` which is like `-info -v` but is done immediately for
  the "current" image on the top of the stack (even if it's a computed
  image and does not correspond to any disk file).

* `--printstats` which is like `--stats` but is done immediately for
  the current image on top of the stack.

  Furthermore, `--printstats` takes an optional modifier `:window=`
  which can be given a rectangular region in either of the notations
  we use ("WxH+X+Y" or "xmin,xmax,ymin,ymax"), for example:

      oiiotool blah.exr --printstats:window=30x30+1000+500

  prints the statistics of the 30x30 region whose upper left corner
  is pixel (1000,500).

The code to implement this is actually pretty short and straightforward,
but this patch turns out to touch a lot more. I needed to plumb
some of the info-printing internals for this support and did some
refactoring along the way.

Also, upon adding these to the docs, I realized that it would be
better to reorganize a bit to separate descriptions of the "flags"
from the "actions", and so many of the oiiotool arguments got shuffled
between different subsections, and in a few cases the descriptions
themselves got rewritten for clarity.
2021-08-13 21:21:54 -07:00
Larry Gritz 2284dc038e Udim refactor and expose more helper functions (#3054)
To help applications that need to deal with UDIM textures, the
TextureSystem now exposes the following public API calls:

* is_udim() : is a filename (or a `TextureHandle*`) referring to a
  UDIM pattern / virtual file?

* resolve_udim() : given a filename (or handle) and s,t coordinates,
  return the handle for the concrete file corresponding to those
  coordinates.

* inventory_udim(): retrieve the full list of concrete filenames, as a
  vector indexed by `(utile + vtile * nvtiles)`, and the nutiles,
  nvtiles counts. Empty filenames in the vector indicate UDIM tiles
  that are not populated.

Some extra functionality falls out naturally from these and existing
ingredients:

* inventory_udim + get_texture_handle together can get you the list of
  handles corresponding to each found udim tile.

* resolve_udim + get_texture_info together can retrieve the attributes
  of the udim tile corresponding to a particular texture coordinate.

Additionally, I have done some refactoring and performance
improvements of the internals:

* The internal UdimInfo that's stored inside the ImageCacheFile record
  is now a vector, not a flat_map, so conversion of texture
  coordinates to a handle is now O(1) rather than O(log n).

* Per Luke Emrose's suggestion, use `rcontains()` when searching for
  UDIM pattern markers, since they will almost always occur close to the
  end of the full pathname.

* Added TextureSystem and ImageCache methods that lets you find out
  the filename that corresponds to a handle. (That's bound to be handy
  for somebody.)

* Beefed up the udim tests to be sure to test every udim notation that
  we support.
2021-08-11 20:51:38 -07:00
Thomas Mansencal 6a3b7569a0 Fix broken section links in "INSTALL.md" file. (#3055) 2021-08-09 16:08:11 -07:00
Larry Gritz 77217afe20 Strutil: Add rcontains, ircontains, improve contains, docs (#3053)
* At the suggestion of Luke Emrose, add rcontains() and ircontains(),
  which are like contains/icontains, but start the search at the end
  of the string rather than the beginning. This is measurably faster
  than contains() for the case when you are reasonably certain that if
  the search pattern is found at all, it is highly likely to be close
  to the end of the string. (They're approximately the same speed when
  the pattern is not found.)

* To verify this, I added a bunch of benchmarking to strutil_test.

* The benchmarks also revealed that contains was about 2x slower than
  calling find! It should be the same. I don't know what the underlying
  boost::algorithm::contains is doing differently than find, but whatever.
  Changing our implementation of Strutil::contains to simply call find
  doubles its speed.

* The new implementation of contains has an extremely minor behavior
  change for the degenerate case of `contains("", "")`, which used to
  return true and now returns false. Since the right behavior here is
  debatable at best (is it false because the first empty string
  contains nothing? or is it true because containts(a,b) should return
  true if a==b?), I'm going to accept this behavior change as well
  worth the 2x speed improvement (besides, "contains(a,b) should have
  the same result as find(a,b)!=npos" is also a reasonable
  expectation).

* The benchmarks also reveal that the case-insensitive functions (like
  ifind) are not just a little bit slower than their case-sensitive
  siblings (like find), they are 20x or more slower! I don't think
  there is anything to do about that, but I did note it in the
  documentation of those functions so that we are disuaded from using
  them except when a case-insensitive test is really necessary.
2021-08-07 20:33:55 -07:00
pumkinpal 57fe02c0e2 WebpInput: Fixed mismatched new[] and delete (#3052) 2021-08-05 14:09:14 -07:00
Larry Gritz 2c7e762774 Udim improvements (#3049)
The primary issue being addressed here was that get_texture_info() on a
udim pattern filename (like "foo_<UDIM>.exr") was unable to retrieve
info, except for an extremely narrow range of queries, because of course,
different UDIM "tiles" might have different attributes or be missing.

So in consultation with Lee Kerley, we decided that get_texture_info should
work as follows:

* If the attribute exists and has the same value for all of the
  matching UDIM file files, then succeed and return the value.

* If any of the tile files does not contain the attribute, or if the
  attribute doesn't have the same value in all found files, then it's
  a failure and the value cannot be retrieved.

This necessitated a more rebust accounting of all the tile files
comprising a UDIM pattern, by doing a full inventory the first time
the UDIM pattern is encountered, rather than (ick) iterating through
all possible tile files every time we retrieve an attribute, as we
were apparently doing before. And so the following improvements were
also made:

* get_texture_info now works for more queries -- in fact, any query
  that would be possible to ask about on an individual file, without
  restriction.  (Though, as I said, the query will fail if the value
  isn't identical across all the found tile files.)

* The info queries (even the few that were previously supported) will
  be MUCH FASTER than before, because we are doing the tile file
  inventory once per udim pattern, rather than on every query.

* That inventory will also pre-build the association between u,v tiles
  and the concrete filename (and texture handle!), so that each
  individual texture call does a simple map lookup to get all the way
  to the texture handle, without any string manipulation to first
  construct a concrete filename, then look that new filename up in the
  cache to get a handle, etc. I'm expecting this to reduce some of the
  overhead of using UDIM files with the TextureSystem.

Note: I added an ImageCacheImpl::find_file_no_add at some point in
this work, eventually not needing it by the time I got to the final
version of my implementation of this PR, but I'm going to keep it
because I can forsee its usefulness and I don't want to delete it only
to write it again some day.
2021-08-04 21:05:33 -07:00
Larry Gritz cd6c0f146f Remove the experimental C APIs (#3051)
We now think that this C API should be removed, and replaced by a
different one coming soon.

Merely commented out the option and other lines in the top-level
CMakeLists.txt, since almost the exact thing will be needed eventually.
Also kept libOpenImageIO-C/CMakeLists.txt since we'll eventually need
one much like it. But deleted the .cpp and .h files, since those will
be totally replaced.
2021-08-04 20:26:34 -07:00
Larry Gritz 263abf165a Build: Updates to handling OpenColorIO (#3050)
For the upcoming OCIO 2.1, the library names will incorporate the
major/minor version numbers, so our Find module needs to take that into
consideration.

Work towards eventually using OCIO exported configs (though still not
100% working now, may need fixes on their end).

Change CI to use the OCIO's that come in the aswf containers instead
of building from scratch in many cases.
2021-08-04 20:21:19 -07:00
Larry Gritz faac914959 filesystem.h: Switch some methods to using string_view (#3047)
Also improve comment documenting get_directory_entires, I realized it
was a little garbled.
2021-08-03 08:29:45 -07:00
Larry Gritz 1bc0cdcebf Filesystem::filename_to_regex (#3046)
Sometimes we use a filename, or pieces of it, as a regex.
But filenames can have characters that are interpreted differently when
part of a regex pattern (like `.`, which in a filename is literal, but
in a regex means to match any character!).

So this handy utility inserts the right backslashes so the filename will
end up as a literal match when part of a regex.
Furthermore, there's an optional parameter `simple_glob`, which when
true, will also substitute `?` with `.?` and `*` with `.*`.

We then use this to fix a latent bug in scan_for_matching_filenames():
it could have incorrectly matched files during the search.
2021-08-02 18:33:28 -07:00
Larry Gritz 5f2cdb5828 imagebuf.h: remove inclusion of imagecache.h (#3036)
I noticed when working on an ImageCache thing that even the smallest
change to imagecache.h was causing a substantial amount of the
codebase to needlessly recompile even though very few places really
need to use the IC APIs directly.

It took a little bit of juggling of some declarations, but this patch
allows imagebuf.h to be able to treat ImageCache and ImageCacheTile as
opaque, forward-declared types, without the need for every file that
needs imagebuf.h to also have to parse imagecache.h and everything it
might pull in.

This speeds up my development cycle substantially in many cases, and
it also speeds up compilation of user code (by a small amount) by
avoiding parsing of imagecache.h in circumstances where the user code
only needed to know about ImageBuf but not ImageCache.

There's a downside to this -- it's possible that user code that truly
needs both imagebuf.h and imagecache.h only includes the former
(inadvertently relying on the fact that the latter was transitively
included). These apps may need `#include <OpenImageIO/imagecache.h>`
to be added after upgrading to OIIO 2.3. Is that really really bad?
2021-08-02 18:32:52 -07:00
Larry Gritz 3e31830158 Strutil::contains_any_char (#3043)
Added this handy function that figures out if the first string contains
any character present in the second string.

Also rewrite the comments describing parse_until and parse_while for
better clarity and correctness.
2021-08-01 12:21:26 -07:00
Larry Gritz de53f325ef exr read: don't rename "version" attribute to "openexr:version" (#3044)
Some of the OpenEXR sample files had an attribute "version".
All along, I assumed this was telling me the version of the OpenEXR file
itself, so I was passing it along and also renaming "openexr:version".

Turns out I was wrong! This is just arbitrary metadata. Who knows why
it's in some of these files? Maybe nobody. But it's not meant to indicate
the file format version, and indeed it does not correctly reflect it.

In fact, there is no simple API call in the OpenEXR API that tells you
the file format version, you have to infer it from the features
present (multi-part or deep or long attribute name indicate changes
that came along with OpenEXR 2.x, but there is no version number in
the file per se).

So I'm just going to stop doing this rename, let "version" be "version",
it's just some user's metadata, I guess.
2021-08-01 12:20:37 -07:00
Larry Gritz b0b17a8f35 openexr reader internals: Remove unused fields (#3042) 2021-07-31 14:04:05 -07:00
Larry Gritz 3fdb3ecc21 Overhaul of how to read/write thumbnails (#3021)
A few image formats (but not most) support "thumbnails" -- low-res preview
images.

Traditionally, we have shoved them in the ImageSpec metadata as a byte
array (and ints for the width, height, nchannels). This is less than
ideal: It makes the metadata very bloated, taking more memory and
being more expensive to copy metadata, and potentially wastes time
doing I/O on this data that most applications don't want or
need. (Remember that any alterations to the image will make the
thumbnail "wrong", also. So it's rarely useful except for applications
that specifically want a preview image.)

Discussion in Issue 2902 led us to think that thumbnails should be
treated explicitly by the API, rather than shoved into the metadata in
this way. This patch is the attempt to overhaul thumbnail handling:

* ImageInput has a new `get_thumbnail()` method that can retrieve the
  thumbnail (if it exists) into an ImageBuf. The base class / default
  implementation does nothing; the image formats that support
  thumbnails should have their readers override this method. They are
  encouraged to read the thumbnails "lazily" if possible -- only
  if/when this method is called, and avoid the cost, memory, and I/O
  if not requested.

* ImageOutput likewise has a new `set_thumbnail` method.

* These are implemented for Targa and PSD, the only two formats for
  which we previously had implemented thumbnail functionality. (There
  are probably other formats that support thumbnails, but for which we
  never added OIIO support. Leave that for another day.)

* ImageBuf has new `has_thumbnail`, `get_thumbnail`, `set_thumbnail`,
  and `clear_thumbnail` methods.

* ImageCache has a new `get_thumbnail` method.

* oiiotool and iconvert attempt to preserve a thumbnail from input to
  output (but of course, only if both file types support it).

* ImageBufAlgo::IBAPrep clears the thumbnail in the destination image,
  on the theory that pretty much everything IBA would ever do will
  likely invalidate any preview image that it started with. This gets
  us to the point with oiiotool where a straight copy (like a format
  conversion) `oiiotool in.tga -o out.tga` will preserve the thumbnail,
  but just about anything else `oiiotool in.tga --stuff -o out.tga`
  will not transmit the original thumbnail to the output (which would
  almost certainly be wrong).

There is more work to do in the future. Some file formats that support
thumbnails don't yet have OIIO support for it. I'm not sure we ever
really want (except in the case of a truly straight copy) for oiiotool
to keep any input thumbnails; maybe if a thumbnail is wanted for
output, it should always be created anew (by downscaling) so that it
definitely matches the main image? Maybe also oiiotool needs a command
to explicitly extract and save the thumbnail (is that needed for any
legit use? or only as a debugging tool?).
2021-07-30 19:24:52 -07:00
Larry Gritz 7fe6710406 Streamline determination of whether file type is procedural. (#3039)
Imagecache repeatedly has to determine whether a filename is a type
of file that's "procedural" and does it expensively -- every time, it
creates the type of ImageInput in question just to ask it if it
supports("procedural").

We can ask this of each plugin type once, when we first register it.
Then just look it up when we need it.

This is strictly internal, has nothing to do with public APIs.
2021-07-30 10:06:21 -07:00
Larry Gritz b866cc9210 Augment PR 3037 to make it not break ABI compat (#3040) 2021-07-29 16:49:20 -07:00
Larry Gritz 0aaed34c2e Let CUE_THREADS help determine default number of threads for OIIO (#3038)
OpenCue-launched apps are encouraged to honor the setting of
CUE_THREADS to limit the number of threads they use. This change makes
oiiotool (and other OIIO-based tools and scripts) better citizens when run
as part of an OpenCue job.

CUE_THREADS has lower precedence than the more OIIO-specific
`OPENIMAGEIO_THREADS`.

For ordinary command line usage, this should not change behavior, since
you wouldn't expect CUE_THREADS to be set.

(Also fix docs which incorrectly named `OPENIMAGEIO_TEXTURE_OPTIONS`.)
2021-07-28 09:50:26 -07:00
Larry Gritz 4ba3380305 Extend Sysutil::getenv() to take a default if the env var is not found (#3037) 2021-07-27 09:31:39 -07:00
Larry Gritz 3df1923e5a CI: update "latest" releases we test against, notably OpenEXR 3.1 (#3033)
OpenEXR -> 3.1.0
pybind11 -> 2.7.0
OCIO -> 2.0.1
2021-07-25 16:04:50 -07:00
Larry Gritz bc1a8b3541 ImageCache: add a variety of invalidate() that takes an ImageHandle* (#3035)
Most of the rest of the IC methods that take a filename, also have
a version that takes a handle.
2021-07-25 14:08:03 -07:00
Larry Gritz d1fb156ebb Mark some long-deprecated things with OIIO_DEPRECATED (#3032)
And make sure to switch all of our internal uses of those to the
preferred new equivalents!

Also, hide some deprecated things from the documentation system so that
new people won't be tempted to use them.

These are all things that have been deprecated starting with OIIO 2.0
(or in some cases, even earlier). Multiple releases (2.0, 2.1, 2.2)
have gone by with them commented or documented as deprecated, but
without our adding the warnings. It's about time. We're still not
taking them away entirely, I usually don't do that until we've had at
least one release where it's been marked as OIIO_DEPRECATED, and also
only do true removals of API at major releases. But we're laying the
groundwork for being able to totally remove these when we eventually
have a 3.0 release.
2021-07-17 16:56:13 -07:00
zomgrolf d1073accae Make finding Boost more flexible. (#3031)
This patch modifies the build system to make it possible to control
whether OIIO should link Boost in the form of static or dynamic
libraries, independently from the LINKSTATIC setting, without
having to use the fully custom route (BOOST_CUSTOM).

This is done by preserving the value of the Boost_USE_STATIC_LIBS
variable, if it has been defined by the user. If the value
of Boost_USE_STATIC_LIBS has NOT been explicitly defined, it is
set to match the value of the LINKSTATIC variable, which should
result in Boost being linked in the same way as other dependencies.
2021-07-17 16:49:01 -07:00
Larry Gritz 23116709f5 Bump version after dev preview release 2021-07-16 14:56:53 -07:00
Larry Gritz 5f515f20bf CHANGES 2021-07-15 12:07:24 -07:00
Larry Gritz fea77d3f9d oiiotool: Get rid of long-deprecated, useless --histogram function (#3029) 2021-07-15 12:01:38 -07:00
Larry Gritz 280b337ccf Improve ImageBufAlgo docs 2021-07-13 22:07:06 -07:00
Larry Gritz 9b107a7e96 Document ImageOutput::copy_image as being not thread-safe 2021-07-13 13:45:30 -07:00
Larry Gritz 7f4806fde0 Document and minor changes to uvslopes_scale argument to bumpslopes (#3028)
Slightly amends PR 3012

* Add docs for this recently-added feature.

* Change the make_texture configuration hint to "maketx:uvslopes_scale"
  for symmetry with all the other texture conversion configuration names.
  Everything works as before, including setting "uvslopes_scale"
  metadata in the file.  (But still accept the name without the
  prefix as a synonym.)

* Change it to a float for a bit more flexibility.
2021-07-13 13:12:56 -07:00
Kimball Thurston 06ce4521e7 Updates after API simplification pass in EXR master (#3027)
The core API has been made consistent with the language in the file
layout documentation. 

Signed-off-by: Kimball Thurston <kdt3rd@gmail.com>
2021-07-12 11:58:26 -07:00
Larry Gritz a4e4114a91 Give oiiotool --mosaic a new optional fit=WxH modifier (#3026)
Ordinarily, --mosaic takes the N images you have, arranges them into a
rectangular array of "cells" where the cell size is simply the biggest
image of the collection.

This adds the optional modifier `:fit=WxH` that lets you specify a
cell size expliticly. Images will be sized to fit the dimensions in
the same way as the `--fit` works (maximally filling the dimensions
while preserving aspect ratio of the original image).

This is particularly helpful for creating a contact sheet from full-size
frames, without having to do any resizing as a separate step.
2021-07-11 09:49:04 -07:00
Larry Gritz 155b4571fb Allow oiiotool to print metadata of computed images (#3025)
The existing semantics of `oiiotool -info`, `-info -v` and `-stats`
are that these options set flags so that each time a file is opened
for the first time, it will print the metadata and/or stats. But these
do not allow you to create new images and print their metadata or stats
(at least, not without writing to disk and reading those files).

This patch extends the expression substition syntax to recognize the
following new metadata notations:

* `METABRIEF` : a string containing the brief one-line description that
  would be printed with `oiiotool -info`.
* `META` : a multi-line string containing the full metadata that would
  be printed with `oiiotool -info -v`.
* `STATS` : a multi-line string containing the image statistics that would
  be printed with `oiiotool -stats`.

Some interesting use cases are illustrated with these examples:

    # Roughly the same behavior as `oiiotool -info img.exr`:
    oiiotool img.exr -echo "{TOP.filename} : {TOP.METABRIEF}"

    # Perform computations on an image and print statistics about
    # the computed image (not the original):
    oiiotool img.exr -blur 3x3 -echo "blurred stats: {TOP.STATS}"

    # Print statistics on intermediate results... and keep going with
    # more operations:
    oiiotool fg.exr bg.exr -over -echo "{TOP.STATS}" -o comp.exr

    # Write metdata as "burn-in" on an image:
    oiiotool in.exr -text:x=10:y=20 "{TOP.META}" -o burned.exr

The implementation in the business logic of oiiotool.cpp was very
simple.  The more extensive change behind the scenes to make this
possible was a massive refactoring of printinfo.cpp, which previously
just wrote everything to stdout in a totally undisciplined fashion,
and transforming it to very carefully write to output streams instead,
which could be passed a stringstream to render the metadata listing or
stats output as a string. Also needed some refactoring to allow it to
take either the name of a file to read anew (as it did before), or an
existing ImageBuf/ImageRec (to support the new feature).
2021-07-07 22:36:31 -07:00
Larry Gritz 771bc2523a IBA::render_text and oiiotool --text honor linefeed chars (#3024)
Allow multiple lines of text to be specified per call, as long as you
don't mind single spacing.
2021-07-07 10:42:00 -07:00
Larry Gritz 4d52d34043 ImageBuf: Expose strides to ctr from wrapped buffer (#3022)
Internally, ImageBuf has for some time now supported strided or
non-contiguous buffers (for IBs that reside in memory, rather than in
an ImageCache). It was originally anticipated to accommodate cases
where we would want pixels or scanlines to have particular alignment
or spacing, such as to be even multiples of the SIMD width.

But we never allowed the kind of IB that "wraps" an application's
memory buffer to specify the strides, in case the app buffer was in
some layout that was not contiguous. This patch adds that ability, by
amending that constructor with stride values (which are optional and
default to AutoStride, which indicates that contiguity should be
assumed). This is 100% back compatible for source code.

This lets you do some cool things with in-memory buffers:

* More flexible about the kinds and layouts of buffers that you can wrap
  to look like an IB.

* Can easily make an IB that wraps an interior rectangular subset of
  another buffer (including another ImageBuf).

* To a limited extent, makes it possible to have an IB that is a "view"
  of another IB (if the second IB is in memory), including strided pixels
  or scanlines -- and even if the strides are negative (this lets you make
  an IB view of a buffer where copying the buffer can reverse left/right
  or top/bottom, however you can't use it to change the channel order or
  layout within each pixel).

* I think this also lets you make a 2D IB that wraps a 2D slice along any
  axis of a 3D volumetric IB.

Some other changes that came along for the ride:

* Added `ImageBuf::contiguous()`, which tells you if the memory layout is
  contiguous (will return false if it's not an in-memory buffer of some
  kind, so ImageCache-backed IBs are NOT considered contiguous).

* Renamed some internal types and fields, in particular, changes like
  `size_t ImageBufImpl::m_pixel_bytes` to `stride_t m_xstride` to make it
  clear that the values are strides and can be negative.
2021-07-05 16:13:10 -07:00
Kimball Thurston 596b124f1f Experimental use of openexr C layer in openimageio (#3009) 2021-07-05 16:09:55 -07:00
Larry Gritz 8cb12d8aa8 Make a unit test for color.h contents (#3023)
Currently, it only tests the linear <-> sRGB and linear <-> Rec709
transformations.
2021-07-05 09:18:39 -07:00
Larry Gritz 14ca518421 More conversions to fmt (#3020) 2021-07-01 18:17:56 -07:00
Larry Gritz 2086ed228b Targa: fix alpha handling (#3019)
There are several alpha choices. We were assuming that color values
were unassociated (need to be premultiplied) unless it was marked as
premultiplied alpha. But it seems that, actually, we should only
premultiply if it's "useful alpha". [Indeed, their terminology is
the worst.]

Rename the m_alpha member to m_alpha_type to clarifywhat it holds.
Also add the alpha type to the metadata as "tga:alpha_type" to make it
easier to inspect the value in tga files.
2021-07-01 18:15:15 -07:00
Larry Gritz eacf549e5c Beef up thread safety of ImageBuf init_spec() and read(). (#3018)
I don't think issues have been reported, so maybe this wasn't a
problem in practice for reasons I've long forgotten about, but doing
some other work in ImageBuf, I noticed what I think was a thread
safety problem.

ImageBuf reads are done lazily, a lot of operations call
validate_spec() or validate_pixels() which can trigger a call to
init_spec() or read() if they have not yet been done, and those had a
spin mutex protecting them from being called at the same time. But the
underlying read() and init_spec() themselves did not have any lock,
which made me worried about what would happen if one user thread was
explicitly calling read() while another was calling it implicitly
through validate.

Also, spin_lock is probably inappropriate for something that could
trigger an entire image read from disk -- it's meant specifically for
situtions where the lock only will be held for a few instructions.

So, this patch:

* Renames ImageBufImpl::m_valid_mutex to m_mutex, reflecting that it's
  not merely guarding access to `m_spec_valid` and `m_pixels_valid`,
  but to potentially anything internal to the ImageBufImpl that needs
  thread safety.

* Changes that mutex from a spin_mutex to a std::recursive_mutex, to
  reflect that it *may* block longer than a few cycles, so blocked
  threads should yield rather than spin. And recursive to simplify the
  hand-off logic between validate_spec, validate_pixels, init_spec,
  and read, the former two may call the latter two.

* Add locks to read() and init_spec(), which previously lacked them (I
  think in error), in addition to the existing ones in the validate
  methods.

* For some locking ImageBufImpl methods, add a param that lets the
  caller (which will always be internal code) specify that the lock is
  already held.

* Add a timing test of recursive_mutex to spinlock_test, just to verify
  that I'm not doing anything to totally botch performance. On my Intel
  Mac laptop, an uncontested lock acquisition/release is 6.4ns for a
  spin_mutex, 16ns for a std::mutex, and 27ns for std::recursive_mutex.
  So this is definitely a more expensive lock, but 27ns is still very
  reasonable, and *most* operations don't need to acquire the lock at
  all (first it checks the m_spec_valid or m_pixels_valid, once they are
  set there is no more locking).

* Improve ImageBuf docs, adding more explanation including some guideines
  about which methods are considered thread-safe.
2021-07-01 18:14:45 -07:00
Larry Gritz 8f055a9f09 Docs: improve description of IOProxy 2021-07-01 18:13:08 -07:00
Larry Gritz 29e3518158 Clarify docs that oiiotool --ociofiletransform doesn't need an OCIO config 2021-06-30 17:00:31 -07:00
Larry Gritz d93386b478 Clarify comments in ImageOutput::copy_image
Make it clear that this function is only copying the pixel data
from an ImageInput to an ImageOutput.
2021-06-29 23:23:15 -07:00
Larry Gritz 442d5f9397 Bump minimum OpenCV supported to >= 3.0 (#3015)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-06-29 23:18:09 -07:00
Larry Gritz 52758b817b More fmt transition aids (#3014)
* strutil.h already had a symbol called OIIO_FORMAT_IS_FMT defined to
  0 or 1 that reveals (to clients of OIIO) whether Strutil::format()
  behaves like printf (the old and current way) or like std::format
  (the future way). Now we adjust so that the caller may pre-set the
  value to force one implementation or the other, at least for the
  "inline" functions of the headers.

* As an aid to downstream packages trying to ensure that they aren't
  using the function slated for eventual deprecation or behavior
  change, you can now define OIIO_HIDE_FORMAT to cause a deprecation
  warning now on those functions that will eventually change or be
  deprecated. This can help to identify any places where you call the
  future-deprecated functions and change them to a "safe" variety.
2021-06-29 23:17:50 -07:00
Larry Gritz 44bc4cf971 TIFF: honor caller request for single threaded (#3016)
ImageInput and ImageOutput have ways for the caller to say that there
should be no "fan-out" in the internals of what the reader or writer
needs to do. But TIFF wasn't honoring this.
2021-06-28 23:13:33 -07:00
Pascal LecocqandPascal Lecocq 890bbb9502 Add a scaled slopes UV normalization options for --bumpslopes. (#3012)
This patch provides an additional but optional parameter for --bumpslopes option to mormalize the derivatives in UV space and scale them by a user defined constant. The scale factor is used to prevent half floating point overflow at time of the UV normalization. A value of 256 is recommended to prevent floating point overflow with texture resolutions up to 32k. The constant value is stored as an extra attribute in the output file for reverting the scaling when using the texture. Note that this options is only meaningful with height maps.

Co-authored-by: Pascal Lecocq <plecocq@imageworks.com>
2021-06-28 18:26:28 -07:00
Kimball Thurston 54c4e2fa95 Convert dpx output to be ioproxy enabled (#3013)
Signed-off-by: Kimball Thurston <kdt3rd@gmail.com>
2021-06-27 15:12:51 -07:00
Larry Gritz a78b45577b Fix typo 2021-06-26 16:39:47 -07:00
Larry Gritz 91008a3432 TypeDesc improvements (#3008)
* Add TypeDesc support for metadata that is a 2D or 3D bounding box,
  represented as an array of 2 VEC2 aggregates (for 2d) or VEC3
  aggregates (for 3d), having the BOX semantic. The basetype
  determines whether it's an integer-based (generally for pixel
  ranges) or float-based (generally for 3D spatial) bounds. The new
  text representations are "box2" and "box3" (for float-based), and
  "box2i" and "box3i" (for int-based).

* Somehow we never had a C++ test thoroughly exercising all the corners
  of TypeDesc. Now we do: typedesc_test.cpp

* The test revealed a number of edge cases we don't handle well, now
  shored up.
2021-06-26 13:58:53 -07:00
Larry Gritz 22036943e7 SPI: Fix compilers for lg 2021-06-26 13:56:13 -07:00
Larry Gritz acd0abfbf5 fmt related fixes (#3007)
* New fmt 8.0.0 is out -- make sure we test against both that and their
  current master.

* Starting with fmt 8.0, and in accordance with C++20 std::format's
  final incarnation, the format string needs to be constant, for the
  sake of compile time checks. To use a nonconstant format string, as
  we do for these wrapper functions, we need to lean on vformat.

* For Strutil::sprintf, just `using ::fmt::sprintf` and eliminate the
  wrapper entirely. (Though we express the wrapper inside
  `#ifdef OIIO_OXYGEN_ONLY` so that it fully appears in any docs we
  generate.)
2021-06-26 13:49:46 -07:00
Bernd c4d8a645a7 fix typo for REQUIRED_USE (#3011)
Signed-off-by: Bernd Waibel <waebbl-gentoo@posteo.net>
2021-06-25 13:28:35 -07:00
etheory a07efab5d8 Add Houdini and AL custom UDIM support (#3006)
Add custom UDIM support and Houdini UDIM convention support

For our (Animal Logic) in-house renderer, we need support for an additional UDIM format of `/path/to/file/textureName_u##v##.ext`

Added second line to ImageCacheImpl::resolve_udim to make this work.

Additionally add support for Houdini UDIM specification
2021-06-21 22:43:37 -07:00
Larry Gritz 6a9b7a3993 check_find_package now takes optional DEBUG to dump more info (#3005) 2021-06-16 21:56:38 -07:00
Larry Gritz 8a9ba9827a Build and test fixes related to Ptex (#3001)
* New Ptex (since 2.3.1) has exported cmake configs. Use those if
  available and seem to work.
* Rename FindPTex.cmake -> FindPtex.cmake to match the capitalization
  in the Ptex project itself, thus avoiding warnings from CMake.
* Fix our FindPtex.cmake to set up Ptex::Ptex_dynamic target. Use
  that instead of the old style variables. That makes a seamless future
  transition between the old Find module and future exported configs.
* Our FindPtex.cmake got the version number all wrong. Fix.
* gh-installdeps.bash tried to install ptex-base. That's not Ptex! So
  stop doing that.
* New build_Ptex.bash does a simple clone and build of Ptex. Do so for
  a few of the CI test cases so that we are more thoroughly testing Ptex
  in CI.
2021-06-16 21:56:21 -07:00
Larry Gritz f691a0749f Clean up preprocessor mess left by farmhash.h (#3002)
Try to `#undef` at the end all the things that are `#define` by
farmhash.h that do not begin with `FARMHASH_`.
2021-06-15 22:08:06 -07:00
Larry Gritz 240b0abe53 CI: make a specific test for buildling with clang11 and C++17 (#3004) 2021-06-15 22:07:36 -07:00
Larry Gritz c33035aded Clang + C++17 + LibRaw < 0.20 don't mutually get along (#3003)
LibRaw 0.19 and earlier use auto_ptr in public headers, which was
deprecated in C++11 and removed in C++17.

When this combo is detected, issue a warning message from CMake.
2021-06-15 20:37:58 -07:00
Larry Gritz eb8c6415e2 Bump ffmpeg minimum to 3.0, and other cleanup (#2999) 2021-06-15 18:37:50 -07:00
Larry Gritz 762b95c961 Change acknowledgment
We switched from Jasper to OpenJPEG many years ago, but apparently never
updated this acknowledgement.
2021-06-15 16:45:47 -07:00
Larry Gritz a5d8004313 More exception safety in Filesystem directory iteration (#2998)
When using filesystem::directory_iterator, I was using operator++,
which can throw exceptions for OS errors. I should have used
increment(ec) instead. Throw in a surrounding try/catch just in case,
since even increment is not marked as noexcept.
2021-06-14 14:17:07 -07:00
Larry Gritz 8ae8ac921b Add missing boost requirement to INSTALL.md 2021-06-08 21:25:07 -07:00
Larry Gritz 908c1832ec Have FindFFmpeg.cmake detect the version at cmake time. (#2994) 2021-06-08 21:23:04 -07:00
Larry Gritz 05a5448c3e Fix to accommodate changed preprocessor name in imath master. (#2996)
Also need to back off the top of fmt master when using gcc11, it seems
to have some trouble with.
2021-06-08 18:56:31 -07:00
Larry Gritz 3ae756b64f Less restrictive warning pragma, amend last PR 2021-06-06 23:47:20 -07:00
Larry Gritz 4cf8980129 gcc 11 support (#2995)
* Use g++11 on the bleeding edge CI test
* Remove OIIO_CONSTEXPR20 decls from string_view -- gcc 11, even in
  C++20 mode, doesn't have std::string fully constexpr plumbed, it's
  not ready for this.
* Suppress gcc11 warnings about arithmetic with enums that occur in the
  OpenCV headers.
* Suppress gcc11 warning (correct) in the spot where we were trying to
  force a crash for testing purposes.
2021-06-06 22:28:37 -07:00
Larry Gritz 36189e194f Bump version after tagger developer preview 2021-06-05 16:08:48 -07:00
Larry Gritz 48437c887c CHANGES 2021-06-05 09:04:51 -07:00
Larry Gritz df3c8e45c2 Fix redundant error message for maketx and oiiotool -otex (#2992)
We were double-printing error messages. If maketx/oiiotool is itself
printing errors returned by IBA::make_texture, it is not necessary to
pass std::cout to make_texture so that it can echo the message to the
console itself.
2021-06-05 08:46:50 -07:00
Larry Gritz 08b48c96eb make_texture now detects and rejects deep images (#2991)
It's meaningless to try to use make_texture on input images that are
"deep".  We never even thought to check for this, which led to a
cascade of problems resulting in a segfault.
2021-06-05 08:46:27 -07:00
Larry Gritz cac5c05019 Fix ustring crash on M1 (ARM) based Mac. (#2990)
There's something wrong with the behind the scenes tricks we're using
to doctor the internal string representation. Is it because of big
endian?  The "alternate" string rep? Something else different on
Apple's libc++ on M1?

Fix for now by just disabling that clause. The only harm is that
ustring internals will take more memory on that platform. That's
better than crashing!

When I have more hands-on access to an M1 (or when GitHub Actions
supports running CI tests on M1), I'll return to this for a proper
fix.
2021-06-03 14:48:38 -07:00
Larry Gritz 96eef33e65 Fix some ffmpeg encodings that didn't realize they were >8bit, alpha (#2989)
A few varieties of encoded videos with bit depth 12 and having alpha
were not marked as such, and falling to the default case that reported
them as 8 bit RGB.
2021-06-02 10:54:31 -07:00
Larry Gritz 1b884e1234 Clarify behavior of color conversion on image with > 4 channels (#2987)
The docs were ambiguous about what would happen for many-channel
image, and the behavor in fact was to copy and color transform only up
to the first 4 channels, leaving additional channels in the
destination undefined (though in practice they turned out black).

Clarify now that for colorconvert, colormatrixtransform, ociolook,
ociodisplay, and ociofiletransform, the first 4 channels are assumed
to be RGBA to undergo the transformation, and any additional channels
will be copied unaltered from source to destination (not set to black).
2021-05-31 21:11:42 -07:00
Larry Gritz 686573f162 If feature is disabled, skip its tests, don't report them broken (#2988) 2021-05-31 21:10:53 -07:00
Larry Gritz bf9d5fb906 Avoid divide-by-0 error computing chunk size for invalid image sizes (#2983)
In ImageInput::read_scanlines and read_image, if somehow the image has
a spec with 0 size, it will lead to a divide by zero error. Check this
and fail safely.

For BMP in particular, do some sanity checks to catch corrupted headers.
(This is in response to Issue 2982)
2021-05-30 08:12:50 -07:00
Larry Gritz 034c5e1a09 Fix broken build against TBB 2021 (#2985)
For TBB 2021, headers moved around, and our FindTBB.cmake was failing.
But actually, starting with TBB 2021, TBB exports a proper cmake config!
So take advantage of that by preferring to load TBB from a config file.

Fixes 2963
2021-05-30 08:12:32 -07:00
Larry Gritz 6e5bebbfce CMake: Make checked_find_package able to prefer configs (#2984)
Both global and per-package controls have been added to our
checked_find_package cmake function, to cause it to first check for
an exported config for the dependency, and only if not found, revert
to potentially using a FindPackage.cmake module.

This reflects our general leaning toward assuming that a package that
exports a cmake config probably does a better job of it than we would
do writing a Find module for it.
2021-05-29 18:49:46 -07:00
Larry Gritz 26650fa309 One more OpenJPEG rename that I missed in #2979 2021-05-29 16:24:08 -07:00
Larry Gritz 11f61e4b66 IBA::render_text did not properly account for alpha of the draw color (#2981) 2021-05-28 09:06:47 -07:00
Larry Gritz bc04e95194 Build: FindOpenJPEG.cmake improvements (#2979)
Rename FindOpenJpeg -> FindOpenJPEG to match the conventions used by
that project, in particular for its exported CMake config files.

(We don't yet rely on their exported configs, I need to do some
homework to see if they exist and are reliable as far back as the
oldest OpenJPEG release that we support.)

Add helper script to build OpenJPEG
2021-05-26 09:22:08 -07:00
Larry Gritz a55ab0216b Remove last remnants of boost regex (#2977)
This is safe in master, now that gcc4.8 is not on the menu.
2021-05-25 23:02:56 -07:00
Larry Gritz d90386ecc1 Change localtime() calls to Sysutil::get_local_time (#2978)
We still had a few stray localtime() calls (which is not reentrant,
because it depends on a global buffer), even though all along we had a
"safe" wrapper in Sysutil::get_local_time, which internally calls safe
versions localtime_r or localtime_s (depending on the OS).
2021-05-25 13:53:22 -07:00
Larry Gritz 7dc4821157 Improvements to BMP (#2976)
* Writing: Write single channel BMP as 8 bit palette images (not 24/32
  bit images). This fixes a problem I discovered related to the recent
  change that reads 8 bit palette images as if they were single channel.
  The lack of symmetry there made problems for round-tripping an image
  and having it end with the same apparent number of channels as it
  started with.

* Reading: respect a configuration hint "bmp:monochrome_detect" that if
  set to 0, will disable the detection of monochrome palettes and spoofing
  to look like a single-channel image. The default is 1.

* Read RLE-compressed images correcty now! Both 4 and 8 bpp varieties.

* Beef up the testsuite/bmp tests, now test against a wider set of sample
  BMP images from bmpsuite (including rle compressed images).
2021-05-24 12:32:24 -07:00
Larry Gritz 31a7613481 Fix oiiotool docs typo and clarify discussion about subimages 2021-05-24 12:13:44 -07:00
Larry Gritz 6a6b0518fc Change default postfix for debug libraries to '_d' (#2970) 2021-05-23 18:05:56 -07:00
Larry Gritz 1b05ae93f6 Fix exported cmake config, it confused imath and openexr versions (#2975)
OpenImageIO exported config has a dependency on Imath/OpenEXR.  For
Imath 3, I accidentally used OpenEXR_VERSION when I should have said
Imath_VERSION. Makes no differece if they're in sync. But should
somebody downstream have a separately compiled Imath and OpenEXR that
just might be different patch versions, it could break builds by
rejecting if the Imath version appears to be behind the OpenEXR
version. There's no guarantee that Imath and OpenEXR will always be
released exactly in sync.
2021-05-19 12:22:47 -07:00
Larry Gritz 2cfb281fef CI: Bump OpenEXR releases to the latest in each branch (#2974) 2021-05-19 00:13:31 -07:00
Larry Gritz 116ab5289e BMP refactor: move BMPInput and BMPOutput to the files where they are used. (#2973) 2021-05-18 22:53:23 -07:00
Larry Gritz 9373be97ad Clarify that our BMP implementation does not support RLE files. (#2972)
Separate patch coming later to add support for RLE.
2021-05-18 16:06:59 -07:00
Larry Gritz a3763dca95 CI: Mac: Adjust to homebrew using imath 3
Need to disable OpenVDB on Mac CI for now, because its homebrew version
wants ilmbase.
2021-05-15 16:44:23 -07:00
Larry Gritz 1d5081d9ce Fix runaway parsing time for pathological XMP metadata (#2968)
Found some files that encountered the problem described here:
https://prepression.blogspot.com/2017/06/metadata-bloat-photoshopdocumentancestors.html
https://feedback.photoshop.com/conversations/photoshop/photoshop-corrupt-ancestors-tag-in-xmp-causing-giant-file-sizes/5f5f45f74b561a3d426ba97f

The pathologically long lists of "photoshop:DocumentAncestors" tags (a
4MB PNG of which 3MB consisting of XMP) was tripping us up with an
O(n^2) handling of appending to lists for those attributes that could take
minutes per file.

It seems like this was a widely acknowledged problem that has been fixed
in Photoshop 20.0.2 (January 2019) and later.

Solution:

* Just skip the problem tag; I can discern no real use for preserving
  it in any OIIO context.

* More generally, be on the lookout for pathological or corrupt XMP by
  keeping track of the length of lists and just cutting them off from
  further appending when they seem senselessly long. I can imagine XMP
  with lots of attributes, but it's hard to imagine that any single
  attribute having thousands of list entries is intentional and useful.

* Fix some places where we were needlessly generating and then tearing
  down std::string's.
2021-05-13 10:08:00 -07:00
Larry Gritz cf0340ca14 CI script typo kept mac from recognizing ARCH properly (#2967) 2021-05-12 10:49:56 -07:00
Larry Gritz 479bbe6e07 Update the CI clang-format to use llvm 11 (from 10) (#2966)
This makes several minor formatting changes, mostly related to how
clang-format 11 has improved ability to track the alignment of = in
successive statements, even when one of those statements is split
across two lines.
2021-05-11 18:48:25 -07:00
Larry Gritz 3b32b92adc CMake: propagate min C++ requirement to cmake config exports (#2965) 2021-05-08 15:46:02 -07:00
Larry Gritz 6e700eb772 Adjustment for OpenColorIO 2.1 (in dev) deprecating method (#2961)
This started out as just trying to fix our CI on the "bleeding edge"
building against OCIO master and complaining about a recently committed
OCIO deprecation of Config::parseColorSpaceFromString.

But it turned out that the new OCIO v2 method, getColorSpaceFromFilepath,
didn't work quite the same way and broke our tests. So I ended up having
to implement a bit more of a complicated set of functionality:

* Config::parseColorSpaceFromString now wraps the OCIO version if it's
  available, but implements the equivalent logic if OCIO is new enough
  that the function is deprecated.

* As a bonus, our pCSFS now works (didn't before) in cases where lack of
  OCIO support or missing config meant the OCIO functionality wasn't
  available. That is, it works on our meager set of default color spaces
  that are present even without OCIO.

* New Config::getColorSpaceFromFilepath wraps the OCIO version if OCIO
  is new enough, but if it isn't, or if there's no OCIO, or if OCIO ends
  up not figuring it out and returning the default rule, we fall back
  to Config::parseColorSpaceFromString.

* Add OCIO to VFX Platform CI builds -- because it's not in the aswf-osl
  docker images, we weren't testing OCIO in as many versions as we had
  previously thought.

* Bump default OCIO version built by build-scripts/build_opencolorio.bash
  to 2.0 (from 1.1.1).
2021-05-04 23:46:25 -07:00
Damien Courtois 1ef9a17f39 fixed a crash is ImageCacheFile::read_unmipped when sampling non-zero-base channels. (#2962)
the temporary image buffer is created with only 3 channels, so the get_pixels call at the end of the
read_unmipped method must account for that when creating the ROI passed to it.
2021-05-04 09:08:18 -07:00
Larry Gritz 554f854f4a Bump C++ minimum to 14 (#2955)
This also bumps compiler minimums to gcc 6.1, clang 3.4, MSVS 2017,
and icc 17 (all because those are the first versions to fully support
C++14).

This has been coming and has been socialized for a long time, with
nobody voicing serious objection. So here it is.

This WILL NOT be backported to release branches. The new minimums only
affect OIIO 2.3 and later.

When last discussed on the oiio-dev mail list, I said I would aim to
introduce this change on May 1. I will not merge this PR earlier than
that, and I will tag a developer preview release before that happens.
2021-05-02 20:51:45 -07:00
Larry Gritz 2fd6ad15c6 Bump version after developer preview tag 2021-05-02 16:12:23 -07:00
Larry Gritz 331c0eb098 CHANGES and tag Release-2.3.4.0-dev, the last developer preview with C++11 support 2021-05-02 15:01:11 -07:00
Larry Gritz 311c23dd8d Strutil: add find, rfind, ifind, irfind (#2960) 2021-05-01 21:18:54 -07:00
Larry Gritz ad028f48b0 CHANGES 2021-04-30 22:55:43 -07:00
Matteo F. VescoviandMatteo F. Vescovi 4824fc7457 Rename TITLE to NAME in manpages script (#2958)
Co-authored-by: Matteo F. Vescovi <mfv@debian.org>
2021-04-30 14:47:09 -07:00
Larry Gritz bf598ba1e6 CMake: use modern targets for PNG and ZLIB (#2957) 2021-04-30 12:42:47 -07:00
Larry Gritz f46c8b9a0f Document support of libtiff 4.3 and test against it (#2953) 2021-04-26 21:28:49 -07:00
Larry Gritz b58e8c58d7 oiiotool --missingfile {error,black,checker} (#2949)
The new `--missingfile` argument (taking a value of either `error`,
`black`, or `checker`) specifies the policy for what oiiotool does
for input files that are entirely missing (not present but broken).
In all cases, an error messages is issued, but for the cases of
black and checker, an image is substituted and computation continues,
rather than immediately ending the attempt to execute the command
sequence.
2021-04-24 15:28:49 -07:00
Larry Gritz 9e985981be Fully separate libOpenImageIO and libOpenImageIO_Util (#2906)
On a personal project a while back, I wasted a full day chasing down
inexplicable behavior that turned out to stem from TWO implementations
of ustring being in the same application, a result of inadvertently
linking against both libOpenImageIO and libOpenImageIO_Util. This led
to two ustrings that contain the same character sequence, but with
different pointers because they resided in different ustring tables.

There is no way that anybody without very deep understanding of ustring
and a lot of patience could have tracked down the underlying issue.

This patch eliminates the possibility of duplicated modules in
libOpenImageIO and libOpenImageIO_Util.  Now libOpenImageIO depends on
and links to the latter. This should all be automatic for users -- as
before, link against libOpenImageIO if you want everything, link
against libOpenImageIO_Util if you just want the util helper classes
but don't need any of the image I/O functionality.  But now, if you
accidentally specify both... well, that's just the same thing as
asking for libOpenImageIO.

Fully separating libOpenImageIO from libOpenImageIO_Util requires new
OIIO_UTIL_API
2021-04-21 15:43:25 -07:00
Larry Gritz 20c50da66a Docs: Clarify the optional modifier of oiiotool --ociodisplay and --ociolook (#2952) 2021-04-20 22:55:10 -07:00
Larry Gritz d869a3c880 Add missing MakeTxBumpWithSlopes enum value to python bindings (#2951) 2021-04-20 22:54:48 -07:00
Larry Gritz ec782e3363 SPI minor adjustment 2021-04-20 22:53:57 -07:00
Larry Gritz 86c364a5b5 CMake: Adjust namespace digits (#2948)
Make whether namespace includes the patch number be dependent on
whether it's a dev or release branch. We generally want the patch
in the namespace for master, but not release.
2021-04-19 15:29:21 -07:00
Larry Gritz 5c96e9df6b oiiotool: allow expression substitution to include getattribute(name) (#2932)
This teaches oiiotool's command line expression substitution (`{...}`)
syntax to understand that

    getattribute(name)

should be replaced by the value that OIIO::getattribute(name,...) would
retrieve. The `name` may optionally be single or double quoted, but doesn't
have to be if it's a simple identifier.

Some examples:

    # Which SIMD features does this OIIO use?
    oiiotool --echo "{getattribute('oiio:simd')}"

    # Which dependencies are used for each format?
    oiiotool --echo "{getattribute(library_list)}"

    # Which file extensions are associated with each format?
    oiiotool --echo "{getattribute(extension_list)}"
2021-04-17 09:12:54 -07:00
Larry Gritz 9d9adf501f Adjustment on exported config: hint where to find OpenEXR/IlmBase (#2947) 2021-04-17 09:12:29 -07:00
pwm1234-sri 902ba1fd7b IBA::to_OpenCV(): use dst.create rather than constructor w/move (#2944)
The cv::Mat::create method does the same thing as the constructor but "Allocates new array data if needed." And when not needed, which is my use case when all the images I process are the same size, create does nothing. This is more efficient than the implementation where a new mat is constructed and then moved to the destination. This is a minor optimization, but it does avoid allocating an image size block of pixels when it is not necessary.
2021-04-12 22:11:25 -07:00
Larry Gritz 2b875975d2 Yet again, cmake adjustments to openexr, etc. (#2942)
Sorry this has taken so much tinkering to get right for downstream
projects. It's tricky business.

First, we start by adding testsuite/cmake-consumer -- a test that
consumes OIIO and its exported cmake modules, and is independent of
the rest of OIIO's build system, more accurately simulating whether
things will work for a downstream client.

Adjust our exported module, it needs to break out the OpenEXR 3 vs 2
cases separately, as well as whether it found an OpenEXR/Imath config
file or not. I think I have all the cases covered now. I also needed
to specify find_dependency of IlmBase and Threads, for the sake of
openexr 2.4 with config, and add the INCLUDES directory lists in the
case of no config files found.

Some adjustment of our library target_link_libraries -- better PRIVATE
hiding of things not needed in the interface by downstream builds.
In particular, the OpenEXR components and OpenCV should be private, not
public.
2021-04-12 19:12:27 -07:00
pwm1234-sri cf8bb4f888 Support single channel 8-bit bmp (#2943)
Add m_allgray field and color_table_is_all_gray method to detect
that the color table entries have the same r, g, b values and indicate
a single channel gray scale image rather than a 3 channel rgb image.
2021-04-12 19:11:52 -07:00
Larry Gritz 665af526df BMP: eliminate wasteful allocation and copying (#2934)
Temporary allocations were made and freed for each scanline read or
written. Do it once per image and reuse. When reading, eliminate one
temp buffer by writing data into its final location, also eliminating
a needless extra copy of each scanline.
2021-04-12 11:55:08 -07:00
Larry Gritz 1ac8a48393 Adjust openexr includes (#2941)
We broke things subtly for older OpenEXR when we added the 3.x
support.  Without this fix, our export CMake config files weren't
properly exporting the OpenEXR include path as the interface includes
for OIIO libraries. This doesn't affect the OIIO build itself, but it
can affect downstream libraries that use OIIO as a dependency and
rely on our exported cmake config files.

We also remove the need for OpenEXR/OpenEXRConfig.h entirely through
header configuration.
2021-04-09 12:29:10 -07:00
alister-chowdhury 9d4c6959b9 Added logic to copy along the alpha_channel when generating sub-images for fillholes_pushpull (#2939) 2021-04-08 10:14:18 -07:00
Larry Gritz 536dae3fa7 Build: be robust to certain OpenEXR 2.x config files (#2935)
Ever since adding OpenEXR 3.0 support, we had some cases where
installations that built the 2.x IlmBase and OpenEXR portions
separately and installing to separate areas.

Also make some minor changes to ci.yml to make sure we are documenting
the right openexr versions used for each test.
2021-04-07 12:14:32 -07:00
Larry Gritz 4430a0ef69 SPI specific: remove gcc4.8, C++11, old Boost
Also, we have a different script that controls building or Rez, there
is no need to clutter this here with Rez stuff we don't use.
2021-04-02 17:59:51 -07:00
Larry Gritz 796b3145fd CMake: don't use --config inappropriately (#2931)
It seems that for CMake, --config should only be used in conjunction
with --build. Who knew? Things are breaking right and left now, especially
on GitHub Actions CI. But also on my laptop.

Hypothesis: maybe this was silently ignored in older cmake versions, but
now with CMake 3.20 is a hard error?
2021-04-02 15:45:23 -07:00
Frédéric Devernay 9d5365b4f1 fix c++11 build (#2930) 2021-04-02 12:58:36 -07:00
Larry Gritz d0803608fc Fix typo for stdout change 2021-04-01 14:03:42 -07:00
Larry Gritz 867c25cbd1 Change default C++ standard to 14 (#2918)
This does not (YET) change the minimum to C++14. For now, you can still
build for C++11 -- and with compilers that only support C++11 -- by using
CMAKE_CXX_STANDARD=11.

By changing the default, we hope to more thoroughly test everybody's
ability to compile C++14, ahead of the actual cut-off when we make that
the true miimum.

Also, the latest OpenVDB 8.0 does has C++14 as a minimum, so compiling
in C++11 mode will automatically disable OpenVDB support if OpenVDB >=
8 is what is found. We expect an increasing number of our dependencies
to drop support for C++11, so we want our default compilation mode to
be one that doesn't silently drop format support without
users/builders being aware of it.
2021-04-01 11:49:28 -07:00
Larry Gritz 998a8d429e Eliminate the last few std::cerr and std::cout outputs (#2923)
In many cases, this informative debugging code was left over from when
parts of this code was strictly a command line utility. It's not
appropriate for a library call, especially on Windows.

Make sure every last output to std::cerr is guarded by some
preprocessor symbol that would only be enabled when one of the
developers is trying to do some "printf debugging". And similarly,
std::cout should only be used for standalone command line
utilities that are by design supposed to output to the console.
2021-04-01 11:48:53 -07:00
Larry Gritz b9644f9b03 TIFF: support IOProxy for input (#2921)
Also beef up docs, which had neglected to mention that proxy was
supported for a few other formats.
2021-04-01 11:47:20 -07:00
Larry Gritz 7b5bb507fe Allow reading of JPEG files with mildly corrupted headers (#2927)
We were treating some recoverable warnings from jpeglib as fatal errors.

Removed testsuite/jpeg-corrupt-header since now we can read it just
fine despite the very minor corruption! Also, turns out the image was
inappropriate, sorry, I had never actually seen it before because
OIIO wouldn't read and display it and I assumed it was just garbage.
2021-04-01 11:47:05 -07:00
Larry Gritz 8e6bad8783 Fix function name ambiguity in farmhash.h for C++11 and certain compilers (#2914)
Apparently all the recent farmhash changes are fine with C++14 mode,
and fine with C++11 mode on gcc 4.8, but gets some errors when
usig in newer compilers (gcc6+) using C++11 mode.

Add a CI test with gcc10 but with C++11 compatibility to verify this fix.
We will remove this test once we retire C++11 compatibility.
2021-03-28 09:42:27 -07:00
Larry Gritz cb2541c973 Avoid OCIO 2 exception by setting strides correctly (#2911)
For the case of applying a color transformation to just one color, we
were sloppy and set the strides to 0 (just one color means we are not
iterating from point to point using the strides).

OpenColorIO 1.x didn't care, but OpenColorIO 2.0 throws an exception if
the strides don't look valid.

Thanks to Thomas Metais for the fix suggestion.
2021-03-26 00:14:54 -07:00
Larry Gritz a610b38df1 Remove redundant format conversion code from imageio.cpp. (#2907)
Change imageio.cpp convert_from_float to use the convert_type function
from fmath.h, rather than defining redundant functionality in that
module.

This has the added benefit that the ones in fmath.h have some interesting
specializations to use SIMD ops and other optimizations that the one-offs
in imageio.cpp lacked.
2021-03-25 22:11:15 -07:00
Larry Gritz b249ffd8fb oiiotool --skip-bad-frames (#2905)
Ordinarily, oiiotool will exit upon encountering an error (such as an
input file not being found). When operating on a frame range or with
frame number wildcards, that means that it will exit without attempting
the rest of the frame range.

The new `--skip-bad-frames` command line argument means that an error
will skip the rest of that iteration, but not exit, instead starting
fresh on the next frame in the sequence. (But if any frame in the
sequence encounters an error, the exit code of the oiiotool command
will still be EXIT_FAILURE.)
2021-03-25 20:19:40 -07:00
Larry Gritz 9faf3cdbe9 CMake 3.20 dropped the -g3 flag (#2913) 2021-03-25 14:48:05 -07:00
Larry Gritz c7e986879c Fix missing boost path on recently broken GHA CI (#2912)
GitHub Actions in its wisdom has removed pre-installed Boost from the Windows
images, causing our CI to fail.

Instead, get boost from vcpkg, just the pieces we need.

Also needed some JPEG adjustments for Windows CI build.
2021-03-25 14:35:25 -07:00
Larry Gritz 54bc719a42 get_extension_map and oiiotool --list-formats (#2904)
Added utility function OIIO::get_extension_map() which returns a
`std::map<std::string, std::vector<std::string>>` listing all
image file formats and their presumed file extensions.

`oiiotool --list-formats` helps to test this and is useful in its own
right.
2021-03-24 22:58:04 -07:00
Larry Gritz 73c9a9e045 Bump version after developer preview tag 2021-03-24 22:03:43 -07:00
Larry Gritz 82683bdeb1 CHANGES and belated bump of developer snapshot version to 2.3.3.0 2021-03-22 12:39:46 -07:00
Larry Gritz 5e89f4f041 CHANGES 2021-03-22 11:19:15 -07:00
Nayden Dochev ef107cf6c4 Fix reading tiff files when size is not multiple of tile size (#2895)
Fix reading tiled tiff files when vertical read size is less than tile size, just for the code path where we use TIFFReadRGBATile (used for certain rarely encountered types of TIFF files). TIFFReadRGBATile returns the image data in bottom-to-top order, and we had been correctly reversing it all along, but neglected to account for the issue of a partially-filled tile ending up with the padding at the beginning of the buffer rather than the end.
2021-03-21 13:59:39 -07:00
Larry Gritz 11cae64880 strutil.h: Clarify the comment explanation of split. 2021-03-20 23:40:32 -07:00
Larry Gritz eab20ebac8 Targa read fix for tga files with 0-sized thumbnails (#2903)
All of our prior tga tests had valid thumbnails. The code skipped the
thumbnail if the "offset to the thumbnail" was 0. But if the offset was
nonzero but the thumbnail record at that spot had a 0x0 size, we just
ran merrily along, and on Windows in debug mode even it an assert.

This patch makes it understand that a 0x0 thumbnail size means no
thumbnail.

I added an image from Doug Rogers, the reporter of the problem, to the
oiio-images repo in the targa directory, and updated the OIIO testsuite
to also check that image. (So testsuite will fail for people who don't
update their oiio-images repo.)

Also changed some stray refs to &vector[0] to vector.data().

Fixes #2900
2021-03-20 21:21:37 -07:00
Larry Gritz 91e9852ac2 BMP: fix bug reading older variety (#2899)
The very old OS2_V1 variety of BMP files -- which dates from the OS/2
and Windows 2.0 circa 1987 -- could have undefined results by relying
on the cpalete header field that didn't exist in that early
version. Our failure to initialize it led to expecting color palettes
of undefined size (which could either cause a read failure or even a
crash if it vastly over-allocated).

Some other minor touch-ups to the bmp code while we're at it:

* Zero-initialize all the other fields that don't exist in the OS2_V1
  version of the header.

* Don't set the Resolution metadata if the values in the file aren't
  positive (including for the V1 header that lacks it entirely).

* Fix reading V1 header resolution on big endian architectures (I just
  happened to spot that potential bug).

* Fix longstanding error (that I only just noticed) in reading 4 bpp
  images with odd horizontal resolutions, wherein the very last column
  was not filled in correctly (that's the change at lines 188 and
  193).

* Beef up one of the error messages invoked for failures while reading
  the color palette.

* Rig the BMP reader to know the "dib" is another extension often
  associated with BMP files.

* Add a regression test case for this format variant.

* Make sure CI tests bmp -- the GHA CI did not download the bmpsuite and
  so was not actually running the testsuite/bmp tests.

* Add "bmp:bitsperpixel" (when not 24 or 32) and "bmp:version" metadata.
  This is primarily for debugging and understanding which encodings the
  BMP file is using.

* Recognize nonsensical values for the header's field for number of entries
  in the palette. Add a test for that.
2021-03-19 13:05:52 -07:00
Larry Gritz 006ffc9b30 CHANGES 2021-03-17 14:01:15 -07:00
Larry Gritz 163f703e35 CI: Bump latest and bleeding tests to OpenEXR 3.0 tags (#2897) 2021-03-17 11:26:50 -07:00
Larry Gritz 04aeea3d9d Remove old pre-C++11 use of boost::random (#2896) 2021-03-16 21:46:25 -07:00
Larry Gritz a64e302204 Minor fixes to keep up with OpenEXR build system changes 2021-03-16 13:09:43 -07:00
Larry Gritz 8d9303e8ba Overhaul ustring hash collision handling (#2870)
This patch ensures that two ustrings will never have the same hash value.
The basic strategy is that the usual 64 bit hash of the characters provides
an initial guess. If no other string has already used that hash (as is
almost always the case), we use it. However, if a different string already
took that hash value, we rehash, and repeat until we find an unused hash.

We maintain a "reverse hash map" that relates hashes to ustrings to
help figure this out efficiently. (Note: This adds at least another 16
bytes per unique ustring to maintain the reverse map. Do we care?
Probably few applications are in the business of creating more than a
few million distinct strings.)

Because we are recording the collisions as they happen, this also
greatly simplifies (and reduces to trivially low cost) the
recently-added ustring::hash_collisions() function, because there is
no complicated search when it is called.
2021-03-16 13:07:15 -07:00
Larry Gritz 166f4ce0dc make_texture: Clamp half values to prevent Inf values popping up (#2892)
When making a texture out of float values, but writing ultimately to a
`half` file, it's not too hard to end up with valid but large float
values that are outside the range representable by a `half` (fp16)
value and therefore will get converted to an `Inf`, which nobody wants
in their texture.

This patch prevents Inf from showing up in the output of make_texture
by clamping output buffers to the range of `half` when the source data
are float and the destination file is half.
2021-03-16 11:46:38 -07:00
Larry Gritz 8c118ab917 CI: test C++20 on the Linux bleeding edge test. (#2891)
Fix minor warnings and deprecations of C++20.

Bump to more modern ubuntu images for recent-year tests and make some
related adjustments. Also make sure that the "latest" and "bleeding edge"
tests are using python3, they were inadvertently still using python2.
2021-03-16 11:43:32 -07:00
Larry Gritz f3ca19ce60 Docs: Fix doxygen mismatch, bump breathe version 2021-03-16 11:05:03 -07:00
Larry Gritz 5a9bc7bd9a Fix build breaks against recent OpenEXR 3.x additions (#2894)
A recent commit in the OpenEXR master changed which headers are
transitively included by other OpenEXR headers, and that broke our
build until this patch adds the missing headers explicitly.

The change may or may not be reverted on the OpenEXR side, but this
patch to OIIO at least unbreaks our CI in the mean time, and has
no down-side.
2021-03-16 10:24:40 -07:00
Larry Gritz 05f215cb12 More format modernization (#2889)
Update old calls to Strutil::format to new fmt conventions, convert
some sprintf-like calls to std::format like calls.

This is not meant to be comprehensive; there is more work to do.
It's just an opportunistic bite at getting some of it done.
2021-03-11 23:06:05 -08:00
Larry Gritz 899878b66b oiiotool --autocc now has optional :unpremult=1 modifier (#2890)
The oiiotool --colorconvert operator (and the other color conversion ops)
have an optional modifier ":unpremult=1" that will bracket the color
transformation with an unpremultiply/premltiply. But the implied
colorconvert that happens upon input and output with --autocc has no such
option, which is an oversight. This patch adds the ability to control
with autocc transformations happen in an unpremultiplied state (which I
believe they SHOULD, generally speaking).

Also beef up the docs and help messages in some areas where I
coincidentally realized that -i and -o explanations omitted some of
the possible options.
2021-03-11 12:55:17 -08:00
Larry Gritz d346ae7cdf Make RAW files handle Unicode filenames on Windows (#2888) 2021-03-09 10:48:50 -08:00
Larry Gritz ae0173119b Fix crash related to ImageBuf::set_write_format (#2885)
There were some flaws in the logic of IB::set_write_format that could
cause a crash when used in conjunction with a file format that doesn't
support per-channel data types (even if the set_write_format call
specified a single type rather than per-channel types!).

There are basically two problems I fixed here.

First, in ImageBuf::write, where we are dealing with the fact that
set_write_format previously registered a request, be extra careful
that the "default" data format is the "biggest" type out of the
per-channel choices, and also make sure that if all the channels are
identical, we just use the default type and clear the channelformats
vector.

Secondly -- and more importantly to the crash itself -- in
ImageOutput::to_native_rectangle, if the output file format does not
suport per-channel data types, just use the main format.  Do NOT
consider this case a hard error, which previously took an early out by
returning NULL for the location where the native data was copied.  It
was that NULL that, when subsequently copied from (not noticing that
it was NULL indicating an error), actually produced the segfault that
caused the crash.  In other words, don't worry, be happy -- just do
your best by treating the unsatisfiable request as the next best
thing, as if it were the same type for all channels.
2021-03-05 09:29:31 -08:00
SRHMorris 9a3743af2c Fix error checking for file descriptor in gifinput on windows (#2886) 2021-03-05 09:28:20 -08:00
Larry Gritz 2c536aa048 Adjust to changed int type definitions in upcoming Imath 3.0 (#2883) 2021-03-04 21:15:12 -08:00
Larry Gritz c6ab3abcda CI: Use Qt5 as a temporary measure (#2884)
Homebrew just upgraded to Qt6, and that breaks us. Peg to Qt5 as a
temporary measure to let our CI pass, until somebody figures out what
needs to be fixed for full Qt6 compatibility.
2021-03-04 21:15:05 -08:00
Larry Gritz fc17e94c97 Changes to accommodate upcoming Imath vector conversion changes (#2878)
I have submitted a PR to Imath that adds "interopability" constructors
and assignment, that use some templates to allow seamless
construction, assignment, and passing of "foreign" vector types to
Imath vectors. This makes it easier library A that uses Imath vector
types in its API to interact with app or library B that has a custom
internal vector type, without a ton of ugly casts and copies.
(See https://github.com/AcademySoftwareFoundation/Imath/pull/91)

These created a few minor conflicts with OIIO's internal SIMD classes
and their construction and casting from Imath types. This patch cleans
up the ambiguities:

* Make Imath::V4f -> simd::vfloat4 and Imath::M44f -> simd::matrix44
  constructor `explicit`.

* Make the simd types `simd()` method (returning the underlying raw SIMD
  type) also have a variety that returns a ref to a non-const vector,
  to ensure proper working of the _MM_TRANSPOSE4_PS macro.

Now I am going to commit a sin. This MUST get backported to OIIO 2.2
in order for it to not break against the upcoming Imath 3.0.  This
doesn't break ABI compatibility, nor change OIIO's primary advertised
public APIs, but it does change the technically/informally public APIs
of simd.h in ways that introduce the possibility that an app using
those simd vector classes *might* need minor source code editing if
they relied on those implicit constructors. Such software might need
certain `simd::vector4 foo = imath_bar` to become `foo = vector4(bar)`
and the same for certain matrix44 assignments.  It is usually a big
no-no to backport any change that could require editing of source
code.  But since the alternative is not being able to use the new
Imath, I think this is the lesser evil, and maybe nobody out there is
doing the thing that would need to be changed?
2021-03-01 12:34:22 -08:00
SRHMorris 86d910bb1c Fix loading PSB with cinf tag (#2877) 2021-02-28 10:29:58 -08:00
Larry Gritz c622d52e15 Imath/OpenEXR 3.x fixes (#2876)
Need some include fixes to more gracefully handle the case where
Imath_ROOT points to a custom build (say, of Imath 3.x), but there is
a system installation of a different version (say, OpenEXR 2.x in
/usr/include, which could easily end up earlier in the path list).

Also update some reference output due to recent bug fixes in OpenEXR,
where error messages changed.
2021-02-27 00:06:44 -08:00
Larry Gritz ad6e7e9afd Remove unused variables that generated warnings (#2873) 2021-02-23 17:52:08 -08:00
Larry Gritz 566e4b128f For libOpenImageIO-C, use BUILD_SHARED_LIBS implicitly like the other libs. (#2872) 2021-02-22 23:26:02 -08:00
Larry Gritz a21dc4e48b Make failure artifacts include the CMake cache and log 2021-02-19 16:44:34 -08:00
Larry Gritz 0017405985 Remove last vestiges of Travis-CI (#2871)
* Some very minor CI cleanup

Mostly get rid of some needless verbosity.
2021-02-19 14:49:54 -08:00
Larry Gritz 796768ef48 unordered_map_concurrent additions: find_or_insert(), nobin_mask() (#2867) 2021-02-18 12:54:59 -08:00
Larry Gritz 1897ddfa70 pkgconfig OpenImageIO.pc was setting include dir one level too deep (#2869) 2021-02-18 08:42:48 -08:00
Larry Gritz 70fe65426b Improve parsing of xmp records (#2865)
* Better handling of lists/sequences -- append into attribute arrays
  instead of allowing each value to overwrite the previous one.

* Better inference of unknown attributes that look like int, float, or
  rational, rather than cramming into strings.

* Fixed what I now think were bugs in handling rational values.
2021-02-17 12:14:10 -08:00
Larry Gritz 4e5cd84e96 Re-enable libheif for Ubuntu (#2866)
Seems to work
2021-02-16 20:04:14 -08:00
alister-chowdhury 0a92880fcb Adding basic TextureSystem support for python. (#2842) 2021-02-15 15:27:11 -08:00
Larry Gritz d474f0b377 Switch to OpenEXR 2.5.5 in hopes of avoiding deadlock (#2863)
Turns out it doesn't -- we're still seeing timeouts on the Windows CI
tests, even with the OpenEXR that we thought fixed the threadpool
problem.

But let's keep this change anyway.
2021-02-14 14:16:04 -08:00
Larry Gritz 1e8f52629a CI overhaul: separate stages (#2862)
Background: In our GitHub Actions CI, we were doing environment setup,
dependency setup, OIIO build, and testsuite -- all in one action
"step" because each stage is its own shell process, so I couldn't
figure out how to communicate between them (for example, a dependency
setup might build and install a dep package, but then the later build
stage needs the CMake Pkg_ROOT variable set to that location).

Doing it all as one "step" was clumsy, not best GHA practice, and it
made it hard to understand which stages were taking different amounts
of time and how to optimize them.

The trick, it turns out, is that $GITHUB_ENV is the name of a file
that will be executed at the start of each step. So you put commands
into that location that restore whatever env variable you need to
restore between steps, or any other setup you need.

So in this patch, we:

* Elevate env setting to be for all steps.

* Split build-and-test.bash into separate build and test scripts.

* Separate setup, dependency installs, build, and test into separate
  GHA steps.

* Each step's script, at its very end, calls new script save-env.bash,
  which puts commands to restore the environment into the file named
  by $GITHUB_ENV, which will be read at the beginning of the subsequent
  step.

* Merge gh-installdeps and gh-centos-installdeps scripts -- there was a
  lot of redundancy between them anyway.

The net result of this is that when we examine the test results, it's
much easier to see which stage a failed test had trouble on, and
especially how much time each stage took. That's really handy with the
recent changes to add caching, and helps us verify that the caching is
working as intended, since it is expected to take a big bite out of
the dependency and build stages, but not the test stage.
2021-02-14 11:44:53 -08:00
Larry Gritz a99000fee4 Build: warn for incompatible OpenVDB 8.0 vs C++11 (#2860) 2021-02-12 20:54:04 -08:00
Larry Gritz fb44431573 Turn off STOP_ON_WARNING default for release branches (#2861) 2021-02-12 20:51:05 -08:00
Larry Gritz 8faa892903 Speed up CI with GitHub 'cache' action + ccache (#2859)
This speeds up CI builds by 1/2 - 2/3 of total time, for PRs that are
minor changes by reusing the compiled results from previous runs.
Most of the remaining time cannot be squeezed down -- it's the
instantiation of docker containers and running the testsuite
itself. But the build (including of dependencies we build from
scratch) is dramatically faster.

Currently, this depends on ccache, so is for Linux/Mac only. I'm also
working on doing something similar for Windows, but it's not ready for
review yet.
2021-02-09 16:29:32 -08:00
Larry Gritz 02ffd75c7d More thoroughly constexpr string_view (#2841)
This should not break backward compatibility.
2021-02-08 12:51:57 -08:00
Larry Gritz b8c5db73c3 CI: Don't build OpenEXR examples (#2857) 2021-02-04 22:34:38 -08:00
Larry Gritz e828f3e2a9 Modify hash_test to verify correctness and stability of the hashes (#2853)
Do some adjustment/simplification of the macros that set up the right
decorators on the new inline farmhash.

Some additional constexpr's, including Strutil::strhash().

Add to hash_test verification of the actual results of each of the
hashes, so we know that we don't break them over time, that they give
the same result on all platforms, and most immediately, to 100% verify
that the new constexpr inline version of the hash precisely matches
the old procedure call one.

Augment the existing benchmarking of the hashes to include
farmhash::inline.  It tries a variety of string sizes. I was worried
that the constexpr/inline version would be a performance hit because
it can't use any of the SSE intrinsics (which, ugh, aren't declared
constexpr in the headers).  But it turns out that the inline (but
SSE-free0 version is a little faster on some tests, a little slower on
other tests, overall a wash and never differing by more than
10%. Maybe that means that the inlining/constexpr makes up for the
lack of SSE? Maybe it means that the compiler optimization is adding
SSE back in well enough that losing the intrinsics isn't as bad as we
would have thought? In any case, the upshot is that this doesn't
represent a performance it, so I may consider a future change to just
go strictly with the inline constexpr versions and eliminating the
separately compiled version altogether. Will mull that over.
2021-02-03 19:14:50 -08:00
Shootfast 5c37eb1139 Static building (#2854)
* cmake: Make LibRaw Jasper and LCMS2 detection optional, add LIBRAW_NODLL

* cmake: Fix OpenColorIO defines on Windows to use correct cmake mechanism

* cmake: Add missing LibRaw defines (needed when linking statically)
2021-02-03 10:58:33 -08:00
Larry Gritz a666727e15 Update INSTALL regarding libheif versions 2021-02-02 09:19:35 -08:00
Larry Gritz a387b51318 CHANGES 2021-02-01 23:58:24 -08:00
Larry Gritz bfac82ab5c Build break fix for new Qt version in VFX Platform 2021 (#2852)
Also bump the number of allowed timeouts on Windows to help pass
tests until we fully track down the OpenEXR deadlock problem.
2021-02-01 17:54:07 -08:00
Larry Gritz 3a78c4ee23 CHANGES 2021-02-01 11:36:19 -08:00
Larry Gritz 0f48445451 CI: Temporarily lock 'bleeding edge' pybind11 to v2.6.3
Something seems to have broken in their master. Lock to the last known
working release so tests pass, while I sort this out.
2021-02-01 10:22:18 -08:00
Larry Gritz 3e74eae539 Fixes to support libraw 202101 snapshot, in progress 0.21.0 (#2850)
Some fields have disappeared from certain structures, so we need to make
adjustments to the various conditional compilation guards.

This patch just makes OIIO build against the new libraw, and is intended
to be backported to the release branch.

This patch does not incorporate any new fields added to libraw
structs, representing newly retrieved metadata. A separate PR patch
will address the newly added capabilities (TBD whether or not that
ends up safe to backport and when).
2021-01-30 16:28:57 -08:00
Larry Gritz fe9a0b85ea OpenColorIO v2 miscellany (#2849)
Bump CI "current releases" test to OCIO v2, it's released!

Oops, we used the wrong name for the env variable, and that CI test
wasn't getting the OCIOv2 RC all along!

Add OIIO::ColorConfig::OpenColorIO_version_hex().

Have oiiotool --help print the OCIO version.

Also Bump the pybind11 version for the "latest" test, and update
INSTALL.md a bit to document the latest versions known to work of
several dependencies.
2021-01-29 22:01:37 -08:00
Larry Gritz 2dc39c87c1 CI: Reduce redundant verbosity in the output during dependency building 2021-01-29 17:05:49 -08:00
Larry Gritz 172a8cc25c Use std types, not TIFF-defined types (#2848)
libtiff trunk is removing these custom types from future
versions. They have been there forever, since long before the std
versions were present.
2021-01-29 09:50:11 -08:00
Larry Gritz d985b0f337 Don't use the version of libheif that's known to be broken on Mac (#2847) 2021-01-28 14:23:50 -08:00
Larry Gritz 9675520247 Fix argument order mismatch on IBA::ociolook and ociofiletransform (#2844)
Ugh, the argument order of the headers and documentation didn't match
that of the implementation, with the inverse and unpremult args swapped.
2021-01-28 12:26:57 -08:00
Clifford Stein 1236e2289b Move farmhash.h to detail subdirectory 2021-01-27 22:53:30 -08:00
cmstein ddb87d9753 make hash functions constexpr friendly so we can compute string hashe… (#2843)
make hash functions constexpr friendly so we can compute string hashes at
compile-time for CUDA/OptiX shaders in OSL.
2021-01-27 16:19:46 -08:00
Larry Gritz b1ebfdaf4b StrongParam helper for disambiguating parameters (#2735)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2021-01-27 11:40:08 -08:00
Larry Gritz b187908e53 Start staging span and string_view size and ssize changes (#2827)
When we wrote our `span<>`, we based it off the draft for std::span,
which at that time specified span::size() as ptrdiff_t, which is
signed. By the time std::span got finalized in C++20, it was changed
to size_t, which is unsigned. Ick. Switching to size_t will be an API
break, so we can't do that until we're at a version where it's ok to
make breaking changes.

But we can stage a few changes that will make that future transition
easier.

* Add std::size() and std::ssize() wrappers for both span and
  string_view.  This gives downstream apps the opportunity to avoid
  span::size(), instead using std::size(the_span), which is guaranteed
  to be unsigned, and std::ssize(the_span), which is guaranteed to be
  signed, and both of these will work now as well as after we make the
  other breaking changes.

* Doing this properly required adding a couple 'constexpr' in places
  where they should have been all along.

* Define macros OIIO_SPAN_HAS_STD_SIZE and OIIO_STRING_VIEW_HAS_STD_SIZE
  making it easy to know if std::size and std::ssize are defined for
  span and string_view

* OIIO_SPAN_SIZE_IS_UNSIGNED will be defined when OIIO::span switches
  to having an unsigned size like std::span (making it easy for client
  software to know if span::size is signed or unsigned).

  Turn this on automatically for OIIO >= 3.0 so we don't forget.

  If client code predefines OIIO_SPAN_SIZE_IS_UNSIGNED before
  including span.h, that forces span::size to unsigned now (good for
  experimentation and compatibility testing, but I don't recommend
  anybody ship software in that state unless they really know what
  they are doing and don't mind potential incompatibility with the
  out-of-the-box OIIO).

These SHOULD NOT break any existing code or ABIs that uses our
existing span and string_view classes or their size() methods. It only
adds options that will help bridge compatibility.
2021-01-23 11:24:28 -08:00
Larry Gritz 7235dae2be Windows CI: get tiff-suite test passing on Windows (#2840)
We were failing this test because of lack of JPEG support in the TIFF we
were building. Rather than fight it, just use vcpkg to get tiff.
2021-01-23 11:22:47 -08:00
Larry Gritz 20bb4a782a Remove incorrect stray declaration (#2839) 2021-01-22 19:01:17 -08:00
Larry Gritz bb30c3fd05 Make testsuite/coiio work properly on Windows CI (#2838)
A variety of small problems were fixed:

* Symbols in libOpenImageIO-C that were not marked as OIIOC_API.

* MSVS not being happy with array length determined by a variable

* Issues with Windows paths
2021-01-22 13:27:47 -08:00
Larry Gritz 92593fc032 Changes to make filesystem_test work properly on Windows (#2836) 2021-01-20 09:58:00 -08:00
alister-chowdhury 038e3d1beb Changing pybind11 bindings to used SHARED rather than using MODULE (#2830) 2021-01-18 10:56:10 -08:00
Larry Gritz ec78315f20 Try to fix oiiotool-copy and oiiotool-maketx test for Windows CI (#2835) 2021-01-18 08:48:03 -08:00
Larry Gritz d99cc7a3ab imagebuf_test: reset the IB before we remove the file it's reading (#2834)
This is a weird thing we're doing in this very artificial test,
removing a file when the IB reading it is still alive. That's safe on
Unix, where a file with an open file handle still be safe to read even
if it's removed.  But it's not kosher on Windows.  Fix by simply making
sure that in this test, we aren't doing the unadvised thing of having
the IB still active on the file we're deleting. This should fix the
unit_imagebuf test that is failing our Windows CI.
2021-01-17 19:22:28 -08:00
Larry Gritz c63407a73c platform.h: define OIIO_INLINE_CONSTEXPR to be inline constexpr (#2832)
But only for C++ >= 17 when inline constexpr variables became available.
It defines to simply constexpr for older C++.
2021-01-16 22:38:07 -08:00
Larry Gritz 75d4fa9271 Simple macros for testing if OIIO is < or >= a certain version (#2831) 2021-01-16 22:37:06 -08:00
Larry Gritz ec12a0d578 CHANGES for 2.2.10 releases 2021-01-16 22:36:04 -08:00
Chris Whalen 100f9fc3ec added openjpeg-2.4 to OpenJpeg_include_paths (#2829) 2021-01-16 03:08:35 -08:00
Larry Gritz 6a368f4692 Windows CI fix: windows shell treats quotes differently (#2826) 2021-01-15 10:03:22 -08:00
Larry Gritz 3a8abbb55b Fix doc -- C++-like declaration crept into python docs 2021-01-14 12:52:12 -08:00
Larry Gritz 30f98ecdf2 CI: Bump some dependency versions that we test against (#2823)
* CI use latest PugiXML release

* Have the 'latest' test use OCIO v2 RC1

* Bump which version of fmt we download by default
2021-01-14 12:50:43 -08:00
Larry Gritz 3ed1f4a36e Update ref images after recent changes to oiiotool error messages (#2825) 2021-01-13 23:38:35 -08:00
Fabien Servant 9041d0d872 [exif] memory leak in exif parse (#2824) 2021-01-13 11:54:03 -08:00
Larry Gritz a5dd972bc8 Various fixes to make more Windows CI tests pass (#2821)
* Try to address the OpenEXR thread pool hanging when we call exit().

    * Strive to remove all exit() calls after any file reads happen,
      in oiiotool, iconvert, and idiff.

    * This DOES NOT stop all hanging. It's still a bit of a mystery whether
      there is anything we can do to fully prevent it without a fix on the
      OpenEXR side.

    * Temp workaround: for the Windows CI tests, use ctest commands to
      allow each test to timeout 3 times before giving up. To be clear,
      this does not solve the problem, it only masks it. But it helps
      us "pass" those tests, exposing any other problems occurring with
      them, and we will return later to find the source of any residual
      timeouts.

* Update ref output for several tests where the differ slightly under Windows.

* Make runtest.py convert text output line endings cr-lf -> lf before
  comparing to reference output. (This eliminates unnecessary diffs.)

* Update many tests' run.py file to use double quotes instead of single
  quotes for arguments containing some characters -- looks like the Windows
  shell invoked by Python system() does not handle the single quotes quite
  the same way as Unix shells.

* oiiotool: when printing the command line after errors, genericize
  identifiable filenames so they render the same on Windows and POSIX,
  and strip directory name from the oiiotool filepath. This makes
  error output comparison more equal between Windows and POSIX, making
  several more tests pass.

In total, this seems to get us down to failing only 7 tests (not counting
spurious timeouts that cause failures).
2021-01-12 10:26:38 -08:00
Larry Gritz 8b3bd4aa6e Argparse::abort() stops further processing of arguments (#2820) 2021-01-12 09:29:03 -08:00
Larry Gritz a19939c04f Filesystem::generic_filepath. (#2819)
Similar to C++17 std::filesystem::path::generic_string(), but for a
filepath sent as string_view.

While I was there, I noticed that a few Filesystem functions that I
declared as `noexcept` actually call things that can throw, so I put a
few try/catch in stratgic spots. Nobody had reported a problem with
this, and maybe it would be fine, but it's the right thing to do.
2021-01-12 09:28:46 -08:00
Harry Mallon 7e565f7fd4 Fix tests with libheif built without AV1 support (#2818) 2021-01-06 11:10:36 -08:00
Larry Gritz 67551c7d80 CI: fix Windows python tests (#2805)
* Change to finding a consistent Python version (3.7)

* Install numpy

* On Windows, convert crlf to lf before diffing reference output, so we
  don't get mismatches just because of LF vs CRLF.

* Update ref output on testsuite/python-imageinput

* Fix windows detection in runtest.py oiio_relpath

* Fix some semicolon problems that were making bash command lines conused

Along for the ride:

* Have ci-build-and-test.bash send OIIO_CTEST_FLAGS as extra args to ctest

* Remove some needless verbosity from the dependency building scripts.
2021-01-05 21:58:12 -08:00
Larry Gritz 8ecfe7799e Fix build break against OpenColorIO master -- headers disappeared (#2817)
The functions we depend on are all still there, they just moved from
these headers into the main OpenColorIO.h.
2021-01-05 20:20:52 -08:00
Larry Gritz 36422bce81 Fix build break for older libheif (#2814)
With some recent heic related packages, we lost the ability to build
against some older libheif versions that we purport to support. We may
eventually want to raise the minimum supported libheif, but in the
mean time, this restores the prior build abilities.
2021-01-05 15:10:34 -08:00
Larry Gritz a34e8dc5f6 Fix recently-symptomatic python2 vs clang warnings (#2815) 2021-01-05 14:36:37 -08:00
Harry Mallon 9eeac26847 Enabled AVIF encoding with libheif (#2811) (#2812)
Requires libheif built with libaom or dav1d/rav1e
2021-01-05 10:07:02 -08:00
Harry Mallon 5dda98cb63 Enabled AVIF decoding with libheif (#2811)
Requires libheif built with libaom or dav1d/rav1e

Add a test file and simple test for AVIF
2021-01-04 15:28:48 -08:00
Larry Gritz aaf6244e7f Some refactoring to remove unnecessary linkage to python libs (#2807)
Use pybind11 functions to set up python module, it's got superior logic
to what we were doing.

Bump pybind11 version default in build_pybind11.bash

Suppress clang warnings about python register use
2021-01-04 14:20:46 -08:00
Harry Mallon 64a894196f Re-add the HeifInput valid_file check (#2810)
Perhaps an earlier version of libheif was missing the defs? Not sure.
2021-01-04 11:36:34 -08:00
Harry Mallon aad41ce99b Fix error decoding Apple HEIF files (#2809)
* 0 size metadata causes an issue in the libheif cxx wrapper
* fixes #2794
2021-01-04 09:54:25 -08:00
Larry Gritz 8ac0f966e6 Fix several Windows CI tests involving text (#2798)
* Re-enable vcpkg installation of freetype on windows

* Add TESTSUITE-README.md file

We'll use this file to document how the testsuite works and how users
should update it when necessary.

* Re-enable windows tests
2020-12-31 13:36:31 -08:00
Larry Gritz 27baec6ffb Avoid stray pyconfig.h definition of 'copysign' causing problems (#2800)
Caused build errors on Windows due to conflicting definitions of copysign (one of which was a macro).
2020-12-30 21:46:15 -08:00
Chris CrosettoandChris Crosetto 0fb1ad5413 Fix crash parsing OpenEXR header with certain Rational attributes. (#2801)
Fix a few issues parsing rational values with large denominator in OpenEXR header.

Incorrect array index can cause divide by zero crash (observed consistently on Windows with repro image).

Conditional comparison was assigning 1 or 0 to int f declaration instead of gcd value.

Changed gcd type parameter to long long to avoid unsigned int->long int overflow on windows (long int is 4-bytes on windows).

Co-authored-by: Chris Crosetto <ccrosetto@gmail.com>
2020-12-30 12:02:50 -08:00
debaetsdandDieter De Baets bb7b04c7fa Windows CI fixes (#2796)
* fixes to make vs2019 CI run. Not passing yet as some tests fail

* added explicit ctest timeout (180sec) + misc fixes to run CI local

* disable Windows VS2019 tests again as they are not passing yet

Co-authored-by: Dieter De Baets <dieter.baets@unity3d.com>
2020-12-28 11:28:09 -08:00
Larry Gritz 8915b4b24f CI: Test against latest libtiff release (#2792) 2020-12-25 12:14:21 -08:00
Larry Gritz 6b6d45518a ustring hash collision instrumentation (#2786)
OSL has some concerns about how ustring hash collisions could impact
its strategy for strings on GPU.

This patch adds some instrumentation to ustring to detect hash
collisions.  Added static ustring methods total_ustrings() and
hash_collisions(). The latter tells you the number of collision pairs,
including optionally enumerating them into a vector of ustrings. Also,
`getstats(verbose=true)`, in Debug builds only, will print all of the
colliding pairs.  These are both somewhat expensive if there are lots
of strings (my laptop takes about 4 seconds to find and print all
collisions for 10M ustrings). So if you are concerned about
performance in debug builds, call getstats(false) instead if you have
a truly enormous ustring table.
2020-12-25 12:14:02 -08:00
Larry Gritz f6b7f21a93 Mac CI cleanup (#2791)
* No need to uninstall openssl for mac ci (in fact, it breaks things now)

* Mac CI python and numpy install refinement
2020-12-20 19:25:04 -08:00
SRHMorris 3dc00c602d Add ICC profile support for PSD input (#2788)
* Add ICC profile support for PSD input

* Update testsuite

* Hopefully make clang-format happy
2020-12-18 12:23:51 -08:00
Larry Gritz 55aa422a11 Docs: add missing modifiers to -otex (#2790) 2020-12-18 11:08:22 -08:00
Larry Gritz 9163402e14 IBA::fit(): special handling of wrap mode (2787)
This addresses slight ringing at image edges when using a combination of
black wrap mode and a filter with negative lobes. We need to be sure that
we really clamp the filter at the source image edges.

But we only want to do the clamping selectively. Works great for --fit,
not so much for more general warp and rotate. So add it as an internal
parameter to the underlying warp we're doing.

Needed to update a bunch of the fit-related output reference.
2020-12-14 21:02:14 -08:00
Patrick Piché ac4a3d44f2 Removed some duplicates in maketx.rst (#2785)
Removed some duplicates
2020-12-12 10:33:37 -08:00
Larry Gritz 417d6745f0 SPI - bump ffmpeg version 2020-12-10 10:36:54 -08:00
Larry Gritz 686689be32 CHANGES 2020-12-10 10:22:35 -08:00
Larry Gritz 205a48c5d1 Add fillmode parameter to IBA::fit (#2784)
There are several ways to make an image fit a new size while preserving
aspect ratio. Originally, fit() would do what we now call "letterbox"
mode, which tries to maximally fill the new size, retain the original
aspect ratio of the visible image, exactly fill one of the dimensions,
but not lose any visible image data -- this means that a dimension that
cannot be filled will be padded with black pixels. This is still the
default behavior.

But additional modes are not possible: "width" means to exactly fill
the horizontal dimension (the vertical may be letterboxed, or may be
cropped, depending on if it's too big or too small), "height" means to
exactly fill the vertical dimension (the horizontal may be letterboxed
or cropped).

* Add `fillmode` parameter to IBA::fit() in both C++ and Python.

* Old fit() without this parameter are still present for
  back-compatibility, but are deprecated and will eventually (when
  we're at an ABI-breaking release in the future) be removed.

* oiiotool: Add optional `:fillmode=` modifier to the `--fit` command.

* More comprehensive tests in testsuite/oiiotool-xform, testing every
  combination of portrait, landscape, shrinking, growing, each fill mode.

* Update docs
2020-12-10 10:03:04 -08:00
Larry Gritz ed03b43adf Fix webp compile break on 32 bit systems (#2783)
The WebPData::size is a size_t, on 32 bit systems it will balk at our
putting a uint64_t in it. Downcast explicitly so the warning doesn't
flag us.

Also some changes to ensure adequate testing of webp in CI. (Even though
we only CI test 64 bit systems, so this was not related to the specific
build break being fixed... but an excuse to make sure we are hitting it
a reasonable amount in CI.)
2020-12-09 22:10:06 -08:00
Larry Gritz 859020fdfe Better error reporting for IOFile, esp. for OpenEXR writes (#2780)
Filesystem::IOFile constructor now upon an error opening the file will
set the error message appropriately.

Move IOProxy::error() implementation from inline to be in
filesystem.cpp to hide its details, use a static mutex to make error
set and retrieval be thread-safe (we presume that the rare chance that
multiple threads will be setting or getting IOProxy errors
simultaneously are rare enough that it's not a thread performance
issue, and if the user is getting file I/O errors, a bit of minor
locking is the least of their worries).

Better checking of these errors in OpenEXR input and output open
operations.  Hopefully this means that exr file I/O errors will
percolate up more helpful error messages.
2020-12-09 22:09:27 -08:00
Larry Gritz 4851582f2d CI: Make sure we test the latest fmt, PugiXML, and pybind11 releases (#2778)
Also add build scripts for ninja and gif.
2020-12-06 23:33:18 -08:00
Larry Gritz 18fd917114 Bump master version because we're using 2.3.1.x for minor additions to 2.3.1.0 2020-12-06 21:59:51 -08:00
Larry Gritz de5081e3f8 Fix typo in last commit 2020-12-06 21:59:51 -08:00
Larry Gritz 300b3d1ffb Fix rare OpenEXR multithread output crash (#2781)
TL;DR: This could crash during openexr output, turned out to be a subtle
race condition.

Long explanation:

Metadata gets prefixed with `<formatname>:` in cases where it's only
meant to be understood by the reader or writer of one format.  Formats
that support arbitrary metadata filter out any items that are prefixed
by the name of a different format (so you don't, for example, when
converting file formats, incorrectly copy a TIFF-specific metadata
hint into an OpenEXR file as literal metadata).

The specific code we used in the OpenEXR writer tried to do this but
got the threading locks wrong, and this could lead to very rare, subtle
crashes. It could have been fixed by a 3-line very local fix, but...

I also noticed that the same code was replicated in Field3D output (and
quite incorrectly -- in the cut and paste from the openexr code, it was
still looking for "openexr:" prefix instead of the correcd field3d one!).

Since this idiom was happening (wrong) in two different places, and
seemed likely to crop up again some time, instead of fixing locally I
added a new API call, `is_imageio_format_name()`, to do this centrally
and correctly.  So most of this patch is implementing that and then
using it instead of the incorrect code elsewhere.

Also add python bindings and docs for the new API function
2020-12-06 19:55:43 -08:00
Larry Gritz b0d6c9481b Remove appveyor.yml -- broken and no longer needed. (#2782)
We test Windows build with GitHub Actions CI now, this is no longer
needed and a PITA to maintain.
2020-12-05 15:57:53 -08:00
Larry Gritz 30773617af Support UTF-8 filenames for GIF (#2777)
Required adding a utility function Filesystem::open that returns an
integer file descriptor.
2020-12-02 10:24:58 -08:00
Larry Gritz 9e0bd88c7d CHANGES 2020-12-01 10:57:58 -08:00
Larry Gritz cd26833fdf Extend checked_find_package with VERSION_MIN and VERSION_MAX (#2773)
Upon reading cmake docs mre carefully, it's clear that when you pass a
version to find_package (which does much of the heavy lifting inside
checked_find_package), it DOESN'T MEAN you want that version or
later. It means you want to find a version that is "compatible" with
the named version. The meaning of "compatible" is up to the package.
Some packages define it as being >= the requested version. Others
define it as being the same major release, or same major AND minor
release, or exact.

But generally speaking, we only care about the minimum version (e.g.,
"I want FooBar 8.0 or later"). And it's not guaranteed that is what
the package's compatibility will do. In fact, FooBar may be using
compatibility mode "SameMajorVersion", which will make our find of
FooBar succeed for 8.0, 8.1, 8.2, but if a user encounters FooBar 9.0,
our build will reject it, even though it's probably fine.

So I augmented our checked_find_package wrapper to take optional
VERSION_MIN to give the real minimum version, when that's the semantic
we really want (in which case we would omit the ordinary version
number used for the compatibility check and let VERSION_MIN do all the
work). There's also an optional (and usually omitted) VERSION_MAX that
you can use if you are sure that we must be less than a certain
version (the max is exclusive, you must be <, not <=, whereas the min
is inclusive >=).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-27 12:16:57 -08:00
SRHMorris 70ea9e71b9 Fix bmp row order (#2776) 2020-11-26 12:03:14 -08:00
Larry Gritz 45f6e801e7 Unbreak CI on Mac
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-21 21:57:05 -08:00
Larry Gritz f2d7aaf144 Unbreak CI on Windows (#2772)
Some permissions on GH changed due to security concerns, and that broke
the setup-nuget action we were using... which turned out to be obsolete,
anyway, and switching to the new recommended replacement fixes everything.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-21 11:52:36 -08:00
Larry Gritz 929a347526 Docs: Set up to try sphinx_tabs extension (#2768)
Inspired by OpenColorIO's beautiful docs, I'm adding the "sphinx_tabs"
extension to our docs, and testing them out in one little spot in
ImageBufAlgo to see if we like the effect.

Please look at https://openimageio.readthedocs.io/en/rtd/imagebufalgo.html
look at the first couple screenfuls to see the example of how the
tabs look. Opinions are welcome. Should we do this kind of thing more
extensively?

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-18 14:42:40 -08:00
Larry Gritz 3accbb9f3e CMake refactoring and subproject friendliness (#2770)
* Detect if OIIO is being built as a subproject, and if so, set
  `OpenImageIO_IS_SUBPROJECT` (a.k.a. `${PROJECT_NAME}_IS_SUBPROJECT`).

* Move all the testing logic out of the main CMakeLists.txt (and a few
  testing-related macros from oiio_macros.cmake) and into a new
  src/cmake/testing.cmake.

* Move all of the packaging logic out of the main CMakeLists.txt and
  into a new src/cmake/packaging.cmake.

* Make all the testing and packaging inactive if this is being built
  as a subproject. Also disable the clang-format target for subprojects.

* Move fancy_add_executable and add_oiio_plugin from oiio_macros.cmake
  into their own files (leaving oiio_macros.cmake empty and
  eliminating it).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-16 13:37:07 -08:00
Larry Gritz 6313484e35 Build against OpenEXR 3.0 + Imath 3.0 (#2771)
As OpenEXR works toward their 3.0 release, which includes splitting
Imath (the vector, matrix, math, and 'half' stuff) out into a separate
repo, their top of tree master finally breaks our "bleeding edge"
build.

This is a little tricky, because now our support of this dependency is
attempting to span 3 eras: 3.0 with the full split of openexr from
imath, recent openexr+ilmbase 2.x that supplies reliable exported
cmake configs, and older 2.x that predates cmake configs. Eventually
we'll phase out older versions and clean up.

Fixes in this patch generally include:

* Add a new CI test of VFX2021 + openexr/imath master. (This will go away
  when 3.0 is released and that's what we use for the main 2021 case.)

* For new enough versions of OpenEXR, use the exported config file and
  targets, rather than the old style OPENEXR_LIBRARIES style variables.
  We have kind of a mixed idiom use because we're still supporting older
  versions that predate use of the config files.

* Move imath includes to new OpenImageIO/Imath.h Deal with the fact
  that the Imath headers now live inside `<Imath/ImathBlah.h>` rather
  than `<OpenEXR/ImathBlah.h>`. But of course, you need to start
  including things just to find out the version. It's tricky.  The
  logic is to look at `<OpenEXR/OpenEXRConfig.h>` to determine the
  version we're dealing with, then include Imath stuff from one or the
  other depending on what we found. I rearranged quite a few includes
  to ensure that all this logic only happens in a couple spots and the
  rest gets included transitively. As it turns out, quite a few of our
  `#include`s of Imath headers were redundant.

* OpenImageIO-C depended on OpenImageIO publicly, but actually it
  should depend on OpenImageIO privately, but export its include
  needs.

* OIIO's exported config needs to look for OpenEXR.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-15 16:49:07 -08:00
Larry Gritz f4d2c85078 Read exif encoded in PNG files (#2767)
At present, it only reads Exif from png, it doesn't write.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-12 11:49:30 -08:00
Larry Gritz 2608e4693f Bump version after developer preview tag
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-11 16:18:24 -08:00
Larry Gritz 1ad75bcf89 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-09 11:36:16 -08:00
Larry Gritz ece16ea82a fmath.h: Use intrinsics for swap_endian (#2763)
Use __builtin_bswap when available. These seem to be 8-15x faster than
the std::swap-based implementation when multiple data values are
being swapped. (It's not dramatically better when swapping a single
value, either way it's pretty fast.)

Also add correctness unit test and benchmark for swap_endian.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-09 11:27:09 -08:00
Fabien Servant e9f9dc9a5e libraw user_flip configuation option (#2769) 2020-11-08 08:45:48 -08:00
Anders Langlands 5f362446f9 Add a plain C API (#2748)
The core ImageInput and ImageOutput (and auxiliary classes they use, such as ROI, ImageSpec, DeepData) now have C99 interfaces that wrap the native C++ classes. In addition to being good for using OIIO with C, this is an important step along the way to simplifying the implementation of Rust bindings (and other languages that have a simple ffi interface to C but are tricky to wrap C++).

Still to do: ImageBuf, ImageBufAlgo, etc.
2020-11-06 12:23:23 -08:00
Larry Gritz 4107d7d428 clang-format fix
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-03 12:29:16 -08:00
Larry Gritz 1896caa37a Improvements to docs and breathe setup (#2762)
* Bump breathe release to the latest (we'e been holding back because of
  errors that we fix in the other elements of this patch, below)

* Changing declaration formatting, particularly in the ImageBuf and
  ImageBufAlgo chapters, eliminates function ambiguity warnings and even
  python exceptions we were getting in Breathe before.

* Document missing texture option fields and improve formatting.

* Instruct Doxygen to not catalog deprecated ImageBufAlgo functions.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-02 16:17:23 -08:00
Larry Gritz fd273acf69 CHANGES, belatedly bump version to reflect recent ABI change in master
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-01 22:50:02 -08:00
Larry Gritz 59667abcf6 Document jpeg output hints
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-01 22:40:01 -08:00
Larry Gritz e46392b2c2 Build: Require exact version if PYTHON_VERSION is specified (#2764)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-01 17:42:25 -08:00
Larry Gritz 0c130968b8 CI: Just run all tests, don't try to cleverly exclude some (#2766)
We were running some CI tests only for PRs or for certain branches.
This may save some time, but I found that I was, more often than not,
naming my branches to trigger all tests to run. That's silly. Just run
all the tests every time, it's not that expensive.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-01 16:55:29 -08:00
Larry Gritz 822ac4f149 Changes for recent OpenColorIO v2 (#2765)
OCIO master recently renamed the symbol in its headers that we used to
detect its version, breaking OIIO's build against the current OCIO
top of tree master.

This change makes our FindOpenColorIO.cmake work with both old and new
OCIO.

Also, cut out other useless OCIO building (for our purposes) by having
our build_opencolorio.cmake disable buildig of GPU tests (which,
recently, became controlled by a different option than is used to
disable building all the other tests).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-11-01 16:43:43 -08:00
Larry Gritz f809c7b98e Clarify certain ImageBuf methods for copied images (#2759)
ImageBuf methods subimage(), nsubimages(), miplevel(), nmiplevels(),
and file_format_name(), which are concerned with the file to which the
ImageBuf refers, only make sense for an ImageBuf that directly refers
to a file -- either by being constructed/reset from a filename, or in
some cases, being a direct unmodified copy of such an imageBuf. All
other cases, including pixel-copies of other ImageBufs (even those
that came from files), it is merely an in-memory image and doesn't
really refer to a file.

Clarify the docs (and fix the implementation) to ensure that for
any ImageBuf that is not a simple reference to a file, these methods
return a suitale default value.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-31 15:58:29 -07:00
Larry Gritz 47bd962bc8 CI: Better libraw testing (#2761)
* Accommodate changes for 0.20.2 that Homebrew now has.

* Mistake in variable naming meant we weren't testing libraw master as
  we previously thought.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-29 18:59:11 -07:00
Larry Gritz 30d70594b0 Fix reading TIFF files with "separate" planarconfig (#2757)
There is a big bug lurking in how we read TIFF files with "separate"
planarconfig (RRRGGGBBB, versus "contig" RGBRGBRGB). I knew that
libtiff when reading scanline files doesn't support true "random
access" to scanline for most compression methods -- because you can't
seek to the start of a scanline in the middle of a compressed "strip,"
you have to read whole strips, or read individual scanlines
consecutively. But what somehow I've misunderstood for years (if not
decades) is that for "separate" planarconfig, this means that you
can't jump from scanline i in plane 0 to scanline i in plane 1! You
have to read all the scanlines (at least within one strip) in a single
plane before moving to the next plane.

This means that we get all sorts of read failures when reading TIFF
files meeting all of these conditions:

* "separate" planarconfig (these are rare in general)
* Scanline-oriented (tiles are fine, because they're read whole)
* More than one channel (with one channel, separate and contig are
  basically the same)
* Certain compression codecs (turns out the separate+scanline combo
  tests in the libtiff example suite are uncompressed, which is how
  our testsuite failed to catch this).
* rowsperstrip > 1 (if rps == 1, every scanline is a new strip, and
  that worked)
* written by an app that doesn't use OpenImageIO (because OIIO TIFF
  output forced rps=1 for separate planarconfig)

Things were very broken. There is a comment in tiffoutput.cpp that says

    // I can only seem to make separate planarconfig work when
    // rowsperstrip is 1.

and forces rps=1 for separate planarconfig output. So at some point
many years ago I realized that something odd was happening here, but I
apparently I thought it was a bug in libtiff when writing with rps > 1.
Probably we were writing correctly all along, and the real bug was in
the reading.  This also explains why we had mostly not seen this
problem before, which is because all OIIO-written files avoided
producing tiff files that fell into the failures case.

This patch mostly fixes it and also makes a number of performance
enhancements:

* Fix misunderstanding in read_scanlines where it was loose with thread
  safety in retrieving the rows per strip.

* In read_scanlines when deciding the "chunk size" to limit temp
  buffer size, and in read_image when deciding how many scanlines to
  read at a time via read_scanlines, these computations weren't the
  same, leaving slivers to be read alone instead of staying aligned
  with strips. Make those both compute the same way, so from read_image
  on down, we end up reading chunks that are always aligned with
  strips.

* TIFF read_scanlines used to try to read whole strips, except for
  reading individual scanlines that didn't comprise a whole strip
  length. Modify it to recognize that the one exception is the last
  strip in the file, in which the strip is shorter than usual if the
  total number of scanlines is not an even multiple of rps. This
  ensures that the last strip is read as a strip, not as individual
  scanlines.

* Imagecache autotile behavior is modified to force the pseudo-tile
  size to be a multiple of the strip length. Again, that keeps the
  resulting reads to always be in units of strips, which is much more
  efficient and is the safe way to seek and read separate
  planarconfig.  Also, always turn on autotile for any tiff file with
  rowsperstrip > 1, because it's already organized that way in the
  file. This is not only more efficient generally, but also makes it
  so that ImageCache will only do reads aligned safely to strip
  boundaries.

This is not a complete solution, in the sense that an app making
individual read_scanline calls for solo scanlines, or read_scanlines()
that is not aligned to strips, can still have read failures for TIFF
files that are just the right combination of separate planarconfig +
certain compressions + scanline order.

However, with this patch, the following common cases will ALWAYS work
correctly now: (a) read_image or read_scanlines of the whole image
size; (b) any reads mediated by ImageCache or TextureSystem; (c) all
images read by ImageBuf (which always use either (a) or (b)); (d) all
operations of oiiotool (which use ImageBuf).

After this patch is merged, solving the common cases, I'll return to
the topic to tackle the remaining issue of broken reads for these
files when doing individual ImageInput::read_scanline reads or
read_scanlines with ranges not aligned to strips. To make those work,
I'll need some kind of ugly internal strip buffering.

I'm going to leave the "force rps = 1 when writing planar separate tiff"
as it is, because even after this set of fixes, software using old
versions of OIIO will not be able to correctly read rps>1 planar files,
so we wouldn't want to be inadvertently writing them, at least not
until all the pre-fix OIIO releases are unlikely to be used by
anyone. Not writing planar files with rps>1 is not much of a
sacrifice, considering how rarely planar files are used at all.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-27 21:22:23 -07:00
Larry Gritz c07c983df9 Remove the unused old LaTeX documentation (#2758)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-25 22:14:33 -07:00
Jan Hettenkofer 05063ac2b2 Docs: illustrate reading image data into separate per-channel buffers (#2756)
Related to #2744
2020-10-25 21:31:47 -07:00
Larry Gritz d8c610653b CI: Simplify install_homebrew_deps.bash for modes we don't use (#2753)
Now that we use Linux and the ASWF docker containers for the
"clang-format" test, there's no reason to have logic in this setup
script for Mac to choose a more restrictive set of package for that
case.

Same for clang-tidy -- we don't have a test like that anyway, and
if we add one, we will surely do it with one of the Linux containers.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-25 12:02:13 -07:00
Larry Gritz 4dd4f25311 Fix propagation of errors from make_texture (#2747)
There was no formal error setting! Errors were echoed to the optional
output stream, if supplied. But that's not good enough.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-25 12:00:59 -07:00
Larry Gritz e22de63bd7 Fix thread safety in ImageInput error reporting (#2752)
Although we were careful to make sure that the new versions of
ImageInput `read_scanlines`/`read_tiles`/`read_image` methods were
thread-safe when called concurrently, one thing that slipped through
the cracks was error reporting. A failed read (or other) call would
return an error flag and use error() to set the error message, which
could be retrieved via geterror()/has_error().

Except the flaw was that the error itself was a single std::string in
the class. It was guarded by a mutex, so at least the threads wouldn't
clobber each other over access to the string. But it means that the
following call sequence would do the wrong thing:

    thread 1:   read_tile A  --> fails
    thread 2:   read_tile B  --> fails
    thread 1:   geterror()   --> gets both errors appended, oops!
    thread 2:   geterror()   --> gets an empty error message, oops!

Why hadn't we noticed until now? Because read failures of individual
scanlines or tiles are rare -- usually the failure or discovery of a
missing or corrupt file is in open().  So I guess it's not often that
two concurrent reads would both have just the right timing to have the
error retrieval problem described above.

There is no easy fix, so a bit of a bigger, ABI-breaking, change was
necessary to make this work properly once and for all:

* ImageInput and ImageOutput error messages are now thread-specific. That
  is, geterror() retrieves errors generated by method calls made by the
  same thread.

* ImageInput and ImgageOutput now use a PIMPL idiom to store some data
  behind an opaque pointer. This is good -- it means that the details
  are hidden from the public API, and can use classes we don't wish to
  expose (which we will do here with boost::thread_specific_pointer) as
  well as allow us to change what's behind the pointer without breaking
  the ABI.

* The error message uses a thread_specific_pointer.

* We therefore removed the m_errormessage member that was unfortunately
  in the public class. Also removed the mutex and the m_threads, which
  can now be safely tucked behind the PIMPL.

* With the mutex hidden from view, we now re-jigger references to it
  to use the lock/unlock methods we had already. In fact, instead of
  using lock_guard<mutex>, we can use lock_guard<ImageInput> because
  the presence of lock/unlock methods make ImageInput (and ImageOutput)
  themselves compliant with the BasicLockable concept.

Note that this changes the data layout of ImageInput and ImageOutput,
and therefore is an ABI break. So this is a change meant for master
only (future OIIO 2.3+), and will not be backported to the 2.2 release
branch.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-25 12:00:19 -07:00
Larry Gritz 1226202c0c CI: lock down on clang-format 10 (#2751)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-22 21:24:47 -07:00
Larry Gritz 4d21c3114c Work around GHCI Mac problem with homebrew openssl (#2750)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-22 21:17:21 -07:00
SRHMorris d8d7661b7f Add support for saving progressive jpegs (#2749) 2020-10-22 11:52:14 -07:00
Larry Gritz f391aa86e2 WebP input overhaul (including animated webp and metadata) (#2730)
* WebP input overhaul (including animated webp and metadata)

Huge overhaul of webp reading. Since webp support was first added in
2011 (with no major changes since, other than a couple minor bug
fixes), we have been using the basic/simplified webp API, which had
many limitations.  This patch rewrites it to use the more complete
API. This results in the following changes and new capabilities:

* RGB images are kept as 3-channel instead of forced to be RGBA upon
  input.

* Skip alpha premultiplication for RGB files. And for RGBA, skip the
  dubious color space transformation when doing premultiplication of
  RGBA files. I think this has been wrong all along.

* We can now read animated webp images (akin to animated GIFs, they look
  like multi-subimage files).

* Much more efficient to read just the header, the pixels are read and
  decoded lazily.

* Switch to the WebPDecode*Into API calls, which lets us preallocate
  and manage the decoded image buffer (as a unique_ptr). Also switch
  the encoded buffer from a std::vector to std::unique_ptr, which
  avoids an unnecessary zeroing out of the buffer.

* Close the file handle immediately after we're done reading, rather
  than leaving the handle open until the client is done with the
  ImageInput.

* Read Exif metadata properly from webp files.

* To use the more sophisticated API, we need to find and use the
  libwebpdemux library.

* Since there is a "LoopCount" metadata here, similarly to with GIF, I
  decided to make an OIIO metadata "oiio:LoopCount" that will work
  with both. GIF saves with this, too, and "gif:LoopCount" is now
  considered a deprecated synonym.

Fixes #2721

N.B. This only covers webp input, not output. A similar overhaul should be
done eventually on the output side.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-21 17:19:30 -07:00
Larry Gritz 2c8e1d8036 Make readthedocs generate downloadable html as well as pdf (#2746)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-21 09:43:17 -07:00
Larry Gritz 25f74995dd Confirm that we can build with Clang 11
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-20 22:36:22 -07:00
Larry GritzandDeclan Russell c9d7538a4e Fix Cuda build break (#2743)
Cuda 10.1 seems to have trouble because of the `__attribute__` used in
`OPENIMAGEIO_PRINTF_ARGS`. Declan Russell suggests modifying the `#if`
to avoid using it for `__CUDACC__`.

LG further observes that `OPENIMAGEIO_PRINTF_ARGS` is only used for
the declaration of two functions, it seems like a nice decluttering to
just directly use the short attribute exactly where it is needed
instead of having a lengthy explanation and possibly defining
`__attribute__` everywhere as a side effect.

Signed-off-by: Larry Gritz <lg@larrygritz.com>

Co-authored-by: Declan Russell <declan@solidangle.com>
2020-10-20 17:42:02 -07:00
Larry Gritz 665c634b12 IC bug fix: add_tile/get_tile not peroperly honoring chend < chbegin (#2742)
For IC::add_tile() and IC::get_tile(), the documentation advertised that
passing chend < chbegin meant "all channels". But the implementation was
setting chend=nchannels but not setting chbegin to 0.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-15 23:16:08 -07:00
Larry Gritz 4b55445489 Error policy overhaul to clear up inconsistencies (#2740)
Different classes and modules had minor inconsistencies on how errors
were reported and retrieved. Let's fix these up.

* geterror() should always take a `clear` parameter that allows the
  caller to control whether or not retrieving the error clears the
  internal error message (default is true, clear it after retrieving).

* Any class with a geterror() should also have a has_error() that merely
  reports whether there is an error message pending retrieval.

* geterror() will always *append* to an existing error message that
  has not yet been retrieved, with a newline separating error
  messages. Previously, some of our geterror implementations appended
  and others replaced.

* geterror() will trim a single trailing newline from the message it
  is passed, thus storing error messages that are not
  newline-terminated and making it so that callers of geterror() don't
  need to wonder whether or not they should terminate their error
  messages with a newline or what happens if you make the wrong
  choice.

* Usage guidance is therefore that individual errorf/errorfmt() calls
  not include a trailing newline (though if one is present, it will
  be harmlessly stripped), and that whoever retrieves with geterror()
  should, after outputting it, add a newline (which they seem to
  invariably do already).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-15 23:15:24 -07:00
Larry Gritz 619c2e0d29 Fix CI break (#2741)
One of our CI matrix entries -- building with clang -- has
mysteriously broken with compile errors complaining about reallocarray
being inconsistently declared in stdlib.h and gif_lib.h. It just broke
a few days ago, unrelated to any changes on our part. I have no idea
if it was the compiler or gif library that got updated and then broke.
Whatever. Insulate ourselves from random changes on GHCI by converting
this test to use one of the ASWF containers that we can count on to
have stable dependencies installed.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-11 15:11:50 -07:00
Larry Gritz f981098ace pugixml build fixes (#2733)
* Bring back the idea of a Findpugixml.cmake file because it turns out
  that (for pugixml <= 1.10) the exported config files are not reliable.

* Fix CI scripts to build PugiXML (with a few different versions). We
  previously were relying on the embedded version for all CI tests, which
  masked problems associated with using an external PugiXML.

* Fix deprecation warnings about xml_document.load(), the new call is
  xml_document::load_string().

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-10 11:18:24 -07:00
gbansal2andGaurav Bansal 8a64508a84 Fixed ARM NEON code path in simd.h, all tests in simd_test are passing (#2739)
Co-authored-by: Gaurav Bansal <gbansal@apple.com>
2020-10-09 13:36:59 -07:00
Larry Gritz 6612857298 make_texture was not correctly setting tile sizes (#2737)
It was setting it, but later, too late for the particular case where
constant_color_detect was used and found a constant color and also the
config spec came in without any tile preference (still 0's).  So move
the default initialization up to the top.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-07 20:52:43 -07:00
Larry Gritz 1003d1a287 Use 'final' liberally (#2734)
This is good for optimization, allowing "de-virtualization" of function
calls in cases when the compiler can be sure that there can be no further
subclassing.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-07 18:40:41 -07:00
Larry Gritz 12d81bd84a Fix broken read of 16 bit iff files (#2736)
This used to work, was inadvertently broken in #2398, in Nov 2019, and
no release of OIIO 2.1 ever had it working!  (I guess people don't
come across 16 bit iff files very often?)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-06 19:58:53 -07:00
debaetsd 051f16933c Fix boost linkage on Windows (#2727)
Boost date_time, though never explicitly called in OIIO code, can be transitively pulled in by boost threads. This seems to be a problem on Windows when you build a partial boost containing only the libraries you think you need.

The solution seems to be to set BOOST_ALL_NO_LIB on MSVC, even for the dynamic linking case.
2020-10-05 10:51:33 -07:00
Larry Gritz a43dbfcc15 oiiotool: Improve guessing about output format based on inputs (#2717)
What data format does oiiotool write for its outputs? The ones
specified by -d, if supplied, but otherwise it will make a guess based
on the types of inputs it has seen.

This patch makes several improvements:

* Multi-subimage files were getting very confused because different
  subimages may want different data formats, and it was at best
  remembering data formats overall and by channel name, but not taking
  subimages into consideration. Make this much more specific by
  remembering both raw channel names (for all subimages), as well as
  specific channels of named subimages.

* The way the input data formats were remembered had repeated (and
  non-matching) code depending on whether the input was read
  immediately or lazily.  That is now cleared up, with the logic
  refactored and expressed only once.

* The -d directive can specify a type (for all channels), a type for a
  particular channel name (`channel=type`), and -- this part is new --
  a type for all channels of a named subimage (specified as
  `subimage.*=type`) or just one channel of a specific subimage
  (`subimage.channel=type`).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-10-01 09:42:45 -07:00
Larry Gritz 89bcfbdde1 iv shouldn't open with config unless it really means it (#2728)
This can cause cache re-reads unnecessarily because it thinks you're
asking for potentially different configuration hints every time you
set the ImageBuf to a different subimage.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-29 15:50:23 -07:00
Larry Gritz d6c4c73b3c CI on Windows: Disable ffmpeg download, the link is broken (#2729)
The web site where we used to download pre-built ffmpeg binaries
seems to have disappeared.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-28 23:04:00 -07:00
Brice Gros f666b67369 WebP: add support for lossless attribute of image spec for webp (#2726) 2020-09-28 22:20:56 -07:00
alister-chowdhury 0604c1711e #2720 - Adding 1 bits per sample support to tiffs. (#2722) 2020-09-26 15:07:14 -07:00
Larry Gritz 1a00428732 More principled approach to alloca to avoid stack overflows (#2716)
A bug (issue 2713) revealed that an alloca in IBA::colorconvert could
cause a stack overflow on an image that had an unusually wide number of
columns per scanline.

This patch takes a number of measures to help root out these problems
in the future:

* The OIIO_ALLOCA macro is amended to assert (in DEBUG builds only)
  upon any attempt to alloca more than 1MB, which is surely a sign that
  we have used alloca in an inappropriate place.

* A new OIIO_ALLOCATE_STACK_OR_HEAP macro is used to encapsulate an
  idiom I have used before, to alloca small things but new[] big things,
  and ensure in both cases that the memory is freed when the function
  exists scope. I choose arbitrarily for "big thing" to mean <= 64 KB,
  which is big enough for one 64x64 tile or one scanline of a 4k image
  if it has 4 float channels, that means most of the time we'll safely
  allocate on the stack, but for anything larger, it will use heap.

* Use OIIO_ALLOCATE_STACK_OR_HEAP in those problematic spots of
  colorconvert.

* Use OIIO_ALLOCATE_STACK_OR_HEAP in a few other places that seem
  prudent.

* Grepped through the code for all instances of OIIO_ALLOCA and I think
  that all the potentiallly "big" ones are now using the safe idiom.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-26 15:06:06 -07:00
Larry Gritz 6a9bf72322 TIFF: Fix spec() and spec_dimensions() for mipmapped tiff files (#2723)
For "mip-mapped" TIFF files where we use the multiple images in the file
to emulate MIP-maps rather than what we ordinarily consider subimages,
a call to `ImageInput::spec(subimage,miplevel)` was not properly
recognizing invalid subimage values and returning an empty ImageSpec
as advertised. Basically, we assumed that they would only ask for a
valid subimage and miplevel and didn't properly handle out of range
values.

Same problem for spec_dimensions().

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-26 15:02:00 -07:00
Larry Gritz 9183e44b75 Update ref output after libheif 1.9 release (#2724)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-26 15:01:02 -07:00
Larry Gritz ed2ba9b2d9 Bump version after dev snapshot tag
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-26 15:00:16 -07:00
Larry Gritz 03210f9c9d CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-24 16:44:15 -07:00
Larry Gritz e9a7f8b160 oiiotool: Enhance --chappend and --siappend (#2709)
For both, allow an optional modifier ":n=" to specify the number of
images from the stack to be combined by having their channels or
subimages appended (versus the default of combining just the top 2
images).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-20 22:36:46 -07:00
Larry Gritz 2e79caed68 Move type_merge functionality from IBA to TypeDesc (#2715)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-19 00:16:57 -07:00
Larry Gritz b5fb702223 Strutil::splits, splitsv should return NO pieces for empty string (#2712)
Fix cause of a subtle bug: splitting an empty string returned one
string piece (also empty) instead of 0 pieces.

Beef up the Strutil unit tests in this area.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-17 23:31:35 -07:00
Larry Gritz 8e8ad987ee Fix crash in oiiotool --resize with multi-subimages (#2711)
This was subtle. Empty subimage include/exclude specifications would
confuse compute_subimages(), which in turn would MUCH later do a
mis-allocation and lead to a situation in --resize where it would
iterate over subimages that had not need allocated.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-17 23:31:04 -07:00
Larry Gritz c2ff09fff2 Convert iv to use new style argparse (#2707)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-14 20:58:55 -07:00
Larry Gritz 5273f478b9 python cleanup (#2705)
Switch from old cmake macros that were marked obsolete in cmake 3.12 to
the new FindPython.cmake module.

Instead of defaulting to python 2.7, default to whatever is found.
But user can still set PYTHON_VERSION variable to request a specific
one in case there are multiple.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-14 20:57:51 -07:00
Larry Gritz 3b5249bdb9 Robust to broken homebrew gpg transitive dependency
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-14 14:34:52 -07:00
Larry Gritz eb2818d52d Fix ImageBuf vs ImageCache out-of-date image problem (#2696)
ImageBuf uses ImageCache underneath. But this can lead to the following
unexpected behavior if you don't understand this:

1. Make an ImageBuf for an image, read it (even just header info).
2. Done with it, destroy the ImageBuf.
3. Some other part of the program, or even a different process, changes
   that file on disk.
4. Make another ImageBuf with the same filename, thinking you're getting
   the updated image, but in fact it's relying on the cached representation
   which doesn't contain the changes made in step 3.

So these tiny changes try to make this much harder to shoot yourself in the
foot:

* New ImageBufs automatically call cache->invalidate on the filename
  before they start reading, to ensure that if the file has changed on
  disk, anything in the cache is invalidated.
* When you destroy or clear an ImageBuf, it calls cache->close() on the
  file, to release the handle (especially helpful on Windows, where an
  open file handle can lock the file to other processes).

There is a chance that some image operations will have degraded
performance, if you are mixing direct ImageCache use (including
TextureSystem) and ImageBuf reads of the same files -- since creating
and destroying the IB's will flush tiles from the cache and close cached
file handles. But I think that this should not be a problem in practice,
since most apps that are heavy users of ImageBuf (like oiiotool) aren't
heavey users of IC/TS, and vice versa. And eliminating this confusing
behavior is probably more important than occasional over-eager
invalidation of the cache.

Also clarify in the docs (and imagebuf_test) that if you use the
variety of ImageBuf ctr where you give it a custom ImageCache, it's
important that the ImageBuf outlives the ImageCache, as it is a
non-owning reference.

Fixes 1987

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-13 18:24:44 -07:00
Larry Gritz 5e16ad0e53 oiiotool --pastemeta (#2708)
This new command takes two images as arguments, and appends all the
metadata (only) from the first image onto the second image's pixels
and metadata, producing a combined image.

This can be useful for users who have some (either non-OIIO-based or
just badly implemented) application that operates on image files but
fails to propagate the metadata, by having a simple way to transfer
metadata from one file to another:

    bad-app in.exr -o out.exr
    # oops, out.exr no longer has the crucial metadata from in.exr

    oiiotool in.exr out.exr --pastemeta -o out2.exr
    # Now out2.exr has the pixels of out.exr, but with all metadata
    # from in.exr added to or overwriting that found in out.exr.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-13 18:22:09 -07:00
Larry Gritz 98d7de6855 IBA::contrast_remap -- move alloca outside loop (#2704)
This could stack overflow for large images.

Fixes 2703

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-07 14:25:09 -07:00
Larry Gritz 7e6d9c4e34 Declare aligned_malloc and aligned_free as OIIO_API (#2701)
Fixes 2700

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-07 01:18:54 -07:00
Larry Gritz 19b7fefdff Python: be more forgiving in what's passed to attribute() (#2695)
We have many classes that have methods

    .attribute(name, intval)
    .attribute(name, floatval)
    .attribute(name, stringval)
    .attribute(name, TypeDesc, anyval)

For ImageSpec.attribute() and OIIO.attribute(), the anyval was
restricted to only accept tuples. Fix these to bring them in line with
many other classes' attribute calls in which the 'anyval' really can
be just about anything -- tuples, lists, numpy arrays or other buffer
objects, or scalar values.

Fixes #2674

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-03 21:51:52 -07:00
Larry Gritz abc544a5d7 Fix GIF min dependency (#2697)
Seems that cmake's FindGIF.cmake isn't good at discerning minor
releases (prior to GIF 5.x including more info in its headers), so
saying "find_package(GIF 4.1)" doesn't work the way we'd like, and
seems to fail to find a legit 4.1 installation.  Go back to
find_package(GIF 4).

We seem to have broken this in PR 2681, and I'm worried that people
with gif_lib 4.1 will find themselves mysteriously lacking GIF support
in their OIIO builds. I may do an emergency tweak release of 2.2 just
to address this.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-03 16:12:15 -07:00
patlefort 2d6831a5f8 Fix pugixml linkage and some mingw build problems (#2698)
- Fix external pugixml linkage. Also remove 'BEFORE' as it is unnecessary. 
- A few fixes for cross compiling with mingw on linux.
2020-09-03 15:38:27 -07:00
Larry Gritz ce6ac37c4a Python: Direct support for 'half' using numpy.float16 type (#2694)
When transferring blocks of pixels (for example, by ImageInput.read_image
or ImageOutput.write_image), "half" pixels ended up mangled into uint16,
the only type of the right bit width.

But NumPy has a numpy.float16 type! A little bit of extra hinting to
pybind11 makes this work as users probably expect.

Fixes #2689

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-03 12:06:36 -07:00
Larry Gritz 96b9cb9e95 ffmpeg reader: avoid potential crash when frame can't be read (#2693)
Don't copy from the data pointer if it's null, that indicates an error.

Related to issue 2688, but doesn't fully solve it.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-03 10:33:33 -07:00
Larry Gritz a5cb7089c4 Fix broken TIFF reads of multi-subimage non-spectral files (#2692)
For a few rare edge cases of photometric interpretation, we fall back
on libtiff's ability to auto-translate to an RGBA image for us. It
only does this for the whole image at once, so we do it for the first
scanline we read (storing the whole image in a buffer, skipping the
conversion for subsequent scanlines -- and it can tell it's the
"first" scanline because the buffer isn't yet allocated).

The bug was that for these cases (such as a photometric YCbCr), if the
file was *multi-subimage*, we were not clearing the rgba buffer, so
upon reading the second subimage, it thought its buffer was already
filled, so it wasn't actually doing the read and convert, just using
whatever was already living in the buffer. Oops.

Also, I noticed that we should clear m_use_rgba_interface for each
subimage -- it was previously just setting it when it found those edge
cases. We never saw a symptom from this, but I realized it would be
problematic for a file where the first subimage was YCbCr and the
second subimage was regular RGB, it wouldn't know to fall back to our
usual code path.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-02 18:52:32 -07:00
Larry Gritz a4aa992e80 Stop running the "openexr-damaged" test for CI. (#2690)
It's been endless trouble, because the nature of the test is malformed
images that fail in inconsistent ways. I can never seem to make a
stable set of reference output for it, especially for OpenEXR
development master, which is always adding new fixes or tinkering with
exceptions and error messages.

So just don't run that test in the automated CI.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-02 18:52:04 -07:00
Larry Gritz f9f925bbb3 Improved error message for corrupted input (#2687)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-09-02 09:27:54 -07:00
Larry Gritz d58dbe7799 Update ref image after Homebrew upgraded libraw to 0.20
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-30 15:29:08 -07:00
Larry Gritz 7f4bbe6bba CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-30 13:13:02 -07:00
Larry Gritz 05d58cf7c0 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-29 12:16:44 -07:00
Larry Gritz 061fd594a9 oiiotool: fix some multi-subimage bugs when outputting images (#2684)
Plain old bug in all cases:

--croptofull botched the subimage count by reserving space for results
based on the subimages in the input image, but then only producing
results for the first one if -a (or :allsubimages=1) was not used.

Output specific bugs:

There are some operations that happen ephemerally upon output, mostly
to account for output file formats that don't support some feature of
the top image (like action_croptofull if the output format doesn't
support differing display and data windows, or action_channels if
there are more channels than are supported by the format, or
action_colorconvert when --autocc is used).

In these cases, we were forgetting that those operations may tend to
drop all but the first subimages, if no -a or :allsubimages=1 is not
used.  But that's NOT the behavior we want in this case, because for
output specifically, we never want to drop subimages. This is because
we want a simple format conversion like

    oiiotool in.xyz -o out.pdq

to faithfully copy, not "narrow" to one subimage, even if some other
operations on their own will tend to drop all but the first subimage if
not instructed to preserve them all.

So the solution is that we need to add ":allsubimages=1" modifier to
these ephemerally called adjustments.
2020-08-29 12:12:17 -07:00
Larry Gritz 09cca88b1e Build system and CI touchups (#2686)
Periodic compare of analogous build scripts in OIIO & OSL and synchronize
to ensure that my current most favored idioms are in both.

The biggest change is that I split the checked_find_package into a separate
cmake file, for easier copying between projects.

Also fix some minor typos.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-28 23:15:22 -07:00
Larry Gritz bb1f88f44f Improve comments in openexr handling code
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-28 20:38:58 -07:00
Larry Gritz 177de5ece6 Support for libheif 1.8 (#2685)
HEIF is a lossy format, and it seems libheif 1.8 changed internally
in such a way that the bit-for-bit comparsions of the write-read
cycle we do in imageinout_test started failing. (Bummer on our Mac
CI, where the homebrew version of libheif updated automatically and
then started failing.)

The easy solution is that just for this test, write zeros to the image,
not 1.0 values (which were coming out 254, not the expected 255).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-28 14:23:30 -07:00
Larry Gritz 7b60accb8a Improve missing dependency hints (#2682)
In the case of a dependency not being found, we look for
src/build-scripts/build_{package}.bash and if it exists, suggest using
it. But the scripts were all lower case, and the packages were not, so
it was often not giving the hint! Also, in some cases, the package
might be named 'TIFF' but the script was 'build_libtiff.bash'.

So now, look for a build script with the package name straight, and
also all-upper and all-lower-case versions, and "lib<lower>".

Rename build_ocio.bash to build_opencolorio.bash, because it's the one
case where the script didn't match any of those obvious
transformations.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-26 16:24:23 -07:00
Larry Gritz f403a56ac5 Use .git-blame-ignore-revs (#2683)
This new file contains the hashes of commits whose only function was
to reformat large amounts of code.

Ordinarily, this would make for confusing 'git blame' output, by
making old code written by author A appear to have a new modification
date and authorship by B, when in fact we know that B just did some
reformatting. This can make it especially hard to discern code history
after after commits that establish the use of "clang-format".

A new git feature (requiring git >= 2.23) allows pointing to a file
containing hashes of commits to be ignored by git blame:

    git blame --ignore-revs-file .git-blame-ignore-revs

To avoid having to remember this all the time, consider adding this to
your git config:

    git config blame.ignoreRevsFile .git-blame-ignore-revs

Note that git supports this feature but does not dictate the name of
the file. I'm just following the convention I'm seeing pop up in other
projects of calling it ".git-blame-ignore-revs".

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-25 23:13:26 -07:00
Larry Gritz b630256745 Enhancements to checked_find_package (#2681)
Sometimes the true minimum version of a dependency that we are able to
build against is lower than the minimum *recommended* version (perhaps
because some important feature was added in a subsequent release that
we would like to expose if available).

This patch allows checked_find_package to take two new optional
arguments: RECOMMEND_MIN is the minimum *recommended* version (but not
the true rejection minimum) and RECOMMEND_MIN_REASON is some text to
add to the error message if there is a succinct explanation for why we
recommend a higher version than the true minimum.

As an example, we will (currently) build against any OpenEXR 2.x. But
if it's not at least 2.2, we can't support DWAA and DWAB compression.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-25 23:07:53 -07:00
Larry Gritz dd62deaddf Try renaming LICENSE-THIRD-PARTY to make GitHub recognize the license properly
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-25 14:11:14 -07:00
Larry Gritz f21698ce08 Remove old and misleading Windows install instructions (#2679)
These were so out of date and unhelpful, it has to be better to
have no instructions at all. Tear it down and make room for somebody
to do it right.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-25 13:27:31 -07:00
Larry Gritz 062dcdbf54 Fix typos in comments and docs (#2678)
Ran spell checker on all the comments.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-23 13:10:49 -07:00
Larry Gritz 37117f3513 Update ref output after changes in OpenEXR 2.5/3.0 error message text
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-22 11:47:48 -07:00
Larry Gritz cc59eb654c Try to make GitHub recognize the project license
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-22 09:31:50 -07:00
Larry Gritz a965f290bd Restore missing python read_image signature (#2677)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-20 19:36:26 -07:00
Larry Gritz 8f942a9dd4 Document design flaw in Python ParamValue (#2675)
Oops, ParamValue.type ought to be a TypeDesc, just like in C++.  In
the Python binding overhaul of 2.0, it seems that I made a mistake and
unintentionally changed it to appear to Python as a string (e.g.,
'int' rather than TypeDesc('int')).

Fixing it to be the way it was originally intended would involve a
breaking change and not appropriate until such things are allowed by a
2.x -> 3.0 transition, so we'll just have to live with it.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-18 09:27:56 -07:00
Larry Gritz e75ed3ddd4 Re-enable fmt formatting helper for TypeDesc (#2670)
A previous patch removed the definition of OIIO_USE_FMT, which
inadvertently removed this helper class from the compilation stream.
2020-08-14 16:22:07 -07:00
Michael Shigorin 714aae4cbb Fix build for Elbrus 2000 architecture (2671)
https://en.wikipedia.org/wiki/Elbrus_2000

From Michael Shigorin

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-14 15:09:36 -07:00
Larry Gritz 421e3bc3fb Fix Mac CI ref output for OpenEXR 2.5.3
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-14 13:50:18 -07:00
Larry Gritz 4af1d69212 CI: Bump exr 2.5 to 2.5.3; update ref output for failure case
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-12 22:13:12 -07:00
Larry Gritz 63152e7a5d Fix CI Linux oldest test
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-12 20:59:50 -07:00
marsupialandrzulak 9274692cb5 Add llvm-11.0.0 to Makefile-bits. (#2669)
Co-authored-by: rzulak <rzulak@imageworks.com>
2020-08-12 17:37:04 -07:00
Larry Gritz 05a7a7e37c CHANGES and docs tweaks
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-11 09:43:16 -07:00
Larry Gritz 0ee92483cf ImageCache should not close IOProxy-based files to stay in file limits (#2666)
The thing about IOProxy is, once closed, it can't be reopened. So it's
important that if an IOProxy-based file is in the IC, its ImageInput
should not be reclaimed by closing it (and that might not help the
file handle count anyway, since the main use of an IOProxy under those
circumstances is probably to read an image from memory).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-10 20:55:17 -07:00
Larry Gritz a045034243 Fix to DPX IOProxy support (#2665)
It's important not to mess with a passed-in IOProxy* in Input::close(),
because that proxy may not still exist.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-10 18:51:05 -07:00
ra-mt 84c38629c3 Add support for reading DPX files from memory (#2659)
* Add support for reading DPX files from any IOProxy
* Replace memcpy_s function with memcpy
* Fix IOProxy bug (not just for DPX) seeking from end

Signed-off-by: ra-mt <radu.arjocu@masstech.com>
2020-08-10 18:51:00 -07:00
Larry Gritz a62e9d4a13 Rejigger the build dir's detail area to be in the same spot as dist (#2667)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-10 17:44:55 -07:00
Larry Gritz 742173e395 clang-format: Adjust alignment of line continuation backslashes (#2664)
I just like this better than the prior habit of putting it one PAST
the column width, which made the backslashes go in column 81, ick.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-10 17:43:34 -07:00
Larry Gritz 81dbea5f9e bit_cast should take a reference, not a value (#2668)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-10 17:42:53 -07:00
Larry Gritz cb00167133 SPI: Mac newer compilers
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-09 16:39:24 -07:00
Larry Gritz 7ab3b5047c pybind11 version fix for CI
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-09 01:07:51 -07:00
Larry Gritz 56a4c9f868 Windows CI: build dependencies ourselves (#2663)
Last week, Vcpkg apparently had some flaw that recently caused it to
fail when building/installing libpng (among other things). It's been
fixed in the vcpkg main branch, but that hasn't propagated to the
vcpkg that's installed on the GitHub Actions CI runners, and that's
causing our Windows CI tests to fail.

Rather than wait out the fix, I'm just taking it into my own hands by
building all our dependencies from source on Windows. This means adding
bash scripts to download and build zlib, libpng, and libjpeg-turbo (and
maybe those will be helpful to others as well).

**Late breaking news** They beat me to it, vcpkg has been updated and
the GitHub CI Windows tests are passing again.

But I had already done this work! So I still would like to switch to
this methodology because:

* Sometimes it's faster to build ourselves rather than have vcpkg
  build, since vcpkg always builds both release and debug, but we only
  need the release builds of the dependencies.

* This makes it easier to customize the specific version of a
  dependency, or particular build options, which are hard or
  impossible to change for a vcpkg build.

* These same dependency-building scripts could be useful for people who
  are not on Windows or not interested in using vcpkg.

Also some minor changes to the build_libtiff and build_openexr scripts
to synchronize some of the idioms I use in these scripts.

Rename workflow.yml to ci.yml to adhere to convention and also make it
so we can have multiple workflows in the future.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-09 01:04:19 -07:00
lmarz af796c9e6c Fix compilation error with armv7, x86 (#2660)
Fixes a compilation error, that appears on alpine linux.
 /builds/lmarz/aports/testing/openimageio/src/oiio-Release-2.1.18.0/src/libOpenImageIO/exif.cpp: In function 'void OpenImageIO_v2_1::read_exif_tag(OpenImageIO_v2_1::ImageSpec&, const TIFFDirEntry*, OpenImageIO_v2_1::cspan<unsigned char>, bool, int, std::set<unsigned int>&, const OpenImageIO_v2_1::pvt::TagMap&)':
 /builds/lmarz/aports/testing/openimageio/src/oiio-Release-2.1.18.0/src/libOpenImageIO/exif.cpp:789:20: error: comparison of integer expressions of different signedness: 'unsigned int' and 'OpenImageIO_v2_1::span<const unsigned char, -1>::index_type' {aka 'int'} [-Werror=sign-compare]
   789 |         if (offset >= buf.size()) {
       |
2020-08-07 08:56:15 -07:00
Brecht Van Lommel 6ce93a1334 Fix poor performance with texture cache and HDR files (#2662)
When the texture cache reads scanlines in random order, the same pixels could
be read many times over. Now the file offset for scanlines is cached for quick
random access.
2020-08-06 15:20:00 -07:00
Biswapriyo Nath 736a52d645 Fix mingw compiler warnings (#2657)
* OpenImageIO/imagebufalgo.h: remove OIIO_API from enums
* OpenImageIO/strutil.h: remove OIIO_API from inlined lower and upper functions
* libutil/plugin.cpp: cast return value of GetProcAddress to void*
* libutil/sysutil.cpp: define _POSIX_C_SOURCE for localtime_r declaration
* libutil/thread.cpp: cast t->native_handle() to HANDLE type
* ptex.imageio/ptexinput.cpp: use perr.c_str() for %s string format
2020-08-06 09:13:10 -07:00
Larry Gritz c06a1d32a8 Minor fixes to ImageBuf error reporting (#2653)
* Fix some incorrect error calls in ImageBuf internals.
* Simplify because we know that ImageBuf::error() and warning(), with
  just one string argument, doesn't need a format command.
* Make sure that if no message bubbles up, we say "unknown error".

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-05 14:24:29 -07:00
Larry Gritz 44c2218aa6 Improved propagation of png write errors and fix sRGB profile check (#2655)
We weren't setting up the proper handler callbacks for libpng internal
errors to bubble up to the caller.

Tell libpng to turn off sRGB color profile check. There are many
false positives where embedded ICC profiles that don't match its
expectations (but that other people and apps consider fine) trigger
errors in libpng.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-05 11:11:12 -07:00
Larry Gritz 10b1049ba9 Fix python binding of ImageSpec.erase_attribute (#2654)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-05 10:29:52 -07:00
Larry Gritz 3c298539e0 PNG option: add "png:filter" to control PNG filter options (#2650)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-08-01 18:52:44 -07:00
Dustin Rodrigues ded1f0c02d fix minor typo in bug report issue template (#2652) 2020-08-01 08:38:35 -07:00
Larry Gritz bc1b634618 Branch 2.2, master is now 2.3 dev
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-31 12:31:23 -07:00
Larry Gritz e8f1202f0f changes
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-30 18:21:21 -07:00
Larry Gritz 3082bd7f2a More gradual fmt conversion (#2649)
Another step toward switching to std::format notation.

The basic strategy is to make sure that all the classes that have
errorf (etc) methods using printf notation will also have errorfmt
(etc) methods using std::format notation. These will coexist for a
while to let people switch, before the printf ones will be marked
deprecated and then eventually removed.

In some cases where the methods aren't really part of the public
API, but only are used internally, we are already skipping to the
deprecation marking.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-30 12:47:42 -07:00
Larry Gritz 1253a034f0 Move disted but non-public headers to "detail" subdirectory (#2648)
Policy change:

There are some headers that we just have to make part of the OIIO
distribution, but they aren't officially part of the supported OIIO
public API. We are moving them into an include/OpenImageIO/detail
subdirectory.

Anything in there is, therefore, allowed to be changed arbitrarily for
any minor version numbered release, including source back-incompatible
changes that would ordinarily require a change in major release
version if they were part of the public API. They nonetheless cannot
change in patch releases in ways that would break ABI or linkage.

Initially, this includes the imported headers from fmt and pugixml,
but in possible subsequent patches, I may move other headers there, or
split some headers to have declarations be public but certain inline
implementation details split into separate files in detail.

We were also able to move SHA1.h out of the public include area and
locally into libutil, since it should only be needed by SHA1.cpp.
It was also used by imagebufalgo_compiler.cpp, but didn't need to be,
so we changed the direct use into use of the hash.h wrapper.

Also add a build_pugixml.bash to make it easier for people to install
that dependency. We will eventually migrate to a fully external
pugixml, but right now old versions of OSL depend on it being part of
OIIO. We'll change on the OIIO side after another release.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-27 20:40:25 -07:00
Larry Gritz 14ee3c30e4 Remove tinyformat (#2647)
We relied on it for years and are very thankful for its existence.

It has been optional for some time now, as we have come to use the fmt
library, which is more similar to the upcoming C++20 std::format.

Now it's time to excise tinyformat completely.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-24 17:10:59 -07:00
Larry Gritz 41fe60cf4c Eliminate some needlessly included headers to speed up build time (#2646)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-24 09:16:10 -07:00
Larry Gritz a20766cd17 Dependency testing
* Bump Linux "latest deps" to use the newly release LibRaw 0.20.
* Document that we can successfully build with CMake 3.18.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-23 15:09:01 -07:00
Larry Gritz 129728f4e8 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-18 15:15:32 -07:00
Larry Gritz e35dc40e7a IBA::resize: Use heap instead of stack for an allocation (#2643)
Resizing an enormous image by a large scale factor could end up having
this allocation, which is xres*ntaps*sizeof(float), end up big enough
to overflow the stack. It's only done once per thread worker, so there
is no perf penalty to making it a heap allocation just in case it's
too big.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-15 11:54:47 -07:00
Larry Gritz 3d0be6561c Typo fix -- got 'ImageBuf.writable' name wrong (#2644)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-15 11:53:59 -07:00
Larry Gritz 6f15fb343d Handy macro to construct an integer version code (#2641)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-15 09:12:43 -07:00
Larry Gritz 7eea02d2ba Python version of ImageBuf that takes an open ImageOutput (#2640)
This is the key to writing a multi-subimage file from ImageBufs.
We previously could do that from C++, but not from Python.

Add a test to testsuite/python-imagebuf. Also rearrange the python in
that test a bit to cleave off a couple pieces into separate functions.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-14 19:37:12 -07:00
Larry Gritz c47dbb566c PNG: Document the "png:compressionLevel" output hint. (#2642)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-13 21:13:08 -07:00
Larry Gritz ec1843512f Minor fix to Python binding for ParamValueList (#2638)
The `__getitem__` method taking an integer index correctly set the
return value policy so it returns in internal reference rather than
a copy, but the `__getitem__` method taking a string did not.

Also fix indentation.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-13 21:12:12 -07:00
Larry Gritz 4827c23775 Build against more recent versions of {fmt} (#2639)
fmt is supposed to (if you include fmt/ostream.h) automatically
support any user type that defines an `operator<<()`. And so it did
through version 6.1.2.

Starting with 6.2.x, the presence of `operator bool()` throws it off,
particularly for our TypeDesc, which started rendering as "true" rather
than "uint8" or whatever. It seems that the fact that it can convert
to bool takes precedence, it formats as a bool, rather than notice that
there's a stream ouput option.

In this patch, we add a custom formatter for TypeDesc, which solves
the problem for `format("{}", typedesc)`, but unfortunately not for
`sprintf("%s", typedesc)`. I've filed an issue, but in any case, the
workaround to avoid incorrect formatting when using sprintf is to be
sure to use typedesc.c_str().

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-10 16:27:16 -07:00
Larry Gritz 276ff1656f Update ref output
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-10 16:26:43 -07:00
Larry Gritz 46fdc7fc0b Update ref image for evolving libraw
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-10 10:15:45 -07:00
Larry Gritz d7427ae376 CI: Make sure all tests run for RB and master
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-10 10:15:45 -07:00
Larry Gritz eec0106ad3 CI: use python 3.8 on Mac GH CI
Trying to force 3.7 when Homebrew has moved on is swimming upstream.
VFX Platform is also talking about moving to 3.8 next year anyway.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-09 10:53:32 -07:00
Larry Gritz 73842b9968 Update ref image for debug case
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-08 23:28:52 -07:00
Larry Gritz a25c31af5b Terminal I/O of images (#2631)
This is a little kooky maybe, but it was something I was playing a couple
years ago, finally inspired by Chris to clean it up and PR it.

This patch adds a "term" format which, instead of writing files,
outputs a preview image to a true color text terminal window.

Is any of this useful? I have no idea. But it's kinda fun.

The quick demo of this is:

    oiiotool myfile.exr -o out.term

It will only do something useful if on a color terminal emulator with
24 bit color capability and Unicode. (I've tested it on the
gnome-terminal on Linux, and iTerm2 on Mac.)

The best quality results are on Mac if you are using iTerm2, it can
additionally do an actual pixel output (iTerm2 has as a nonstandard
feature the ability to send inline images to the terminal). This is
the "iterm2" method, but it's only expected to work on Mac with
iTerm2. It will automatically use this method as the default if you
are running iTerm2.

Next best is (thanks, Chris) is to display two pixels (vertically) in
each character cell, by outputting the Unicode "upper half block"
glyph (\u2508) with the foreground color set to the top pixel's color
and the background color set to the bottom pixel's color. This is the
default if you're not on a Mac running iTerm2. To demo (if you're on
have iTerm2 but want to see this method):

    oiiotool myfile.exr -attrib term:method 24bit -o out.term

But some terminals and fonts don't support unicode, or don't display
this character, or display it with an ugly border. So you can also use
an alternate method:

    oiiotool myfile.exr -attrib term:method 24bit-space -o out.term

where doesn't use the unicode trick but instead outputs a space (' ')
for each 2 vertical pixels, simply setting the background color to the
average of those two pixels.

There's also a "256color" method that just uses the 6x6x6 color space
in the 256 color palette -- which looks horrible -- and an
experimental "dither" which does a half-assed Floyd-Steinberg
dithering, horizontally only, and frankly is not an improvement unless
you squint really hard.

In all cases, the image will automatically be resized to fit in the
terminal, as well as converted to sRGB so it looks kinda ok.

Along the way, I added a new ImageOutput::supports("procedural")
query.  If the existing input supports("procedural") query says
whether the input image is being generated procedurally and doesn't
correspond to an existing file on disk being ead, then the output
supports("procedural") is the opposite -- is the output doing
something procedural that does not correspond to a file being written.
(The specific use is to use this to avoid oiiotool attempting to
rename the file to move it into its final position.)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-08 22:16:59 -07:00
Larry Gritz d351cf3b32 Re-enable travis and include an arm64 (aka aarch64) build (#2634)
This is a step toward making sure we are habitually testing on ARM64.

It is incomplete at the moment, several individual tests fail and need
to be tracked down, so the test is marked as "allow_failures" so it
will never appear to fail.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-08 22:16:31 -07:00
Larry Gritz 1dcee8487d Adjust to API changes in OpenColorIO v2 (#2636)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-08 15:12:36 -07:00
Larry Gritz 363ed762b7 Fix build break due to pybind11 master recent change (#2637)
By using the explicit `cast<TypeDesc>()` instead of allowing the
template system to figure it out, we were losing the `const` detection
and making it fail to match templates. It used to work, but a recently
added change in pybind11's master branch caused this to finally fail.

Also change the "latest releases" to use pybind11 2.5. (Only semi-related,
2.5 was fine, it was post-2.5 where we broke.)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-08 13:28:14 -07:00
Larry Gritz 100897491e Update ref output
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-07 23:08:10 -07:00
Larry Gritz f0c3890eb5 raw: use mutex to guard non-reentrant LibRaw constructor (#2633)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-07 12:46:56 -07:00
Larry Gritz 63ee142750 oiiotool: Fix --eraseattrib not applying to all subimages (#2632)
Either -a or optional modifier :allsubimages=1 ought to have erased
an attribute from all subimages, but it was erased from only the first.

Add a test to verify that --attrib and --eraseattrib both apply
correctly to all subimages when requested.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-07 09:25:24 -07:00
Larry Gritz 3481ab058b Disable tests when support for format is disabled (#2629)
We previously disabled tests for a format when its library was not
found, but didn't consider if the library was found but the
`ENABLE_FOO` variable was set to intentionally disable it.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-06 09:13:33 -07:00
Larry Gritz f30f2b77bc simd.h improvements (#2621)
SIMD improvements for emulating 8-wide on 4-wide HW: for many methods
on 8-wide SIMD types when running on 4-wide hardware, it's better (as
revealed by benchmarks) to implement as two 4-wide ops rather than
falling back to a purely scalar path.

Add operator*(vfloat{4,6,16}, float). On SSE, it hardly matters, no
better than letting the float be promoted to vfloat. But NEON has
vec*float.

Add NEON implementation of blend, min, max, reduce_add.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-05 21:58:10 -07:00
Larry Gritz 2b6cfc76f9 Commit ref output for openexr-damanged test for exr 2.2
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-05 14:12:17 -07:00
Larry Gritz 7c26a62201 SPI touchup
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-05 14:12:10 -07:00
Larry Gritz 7e5b841a80 Fix broken clang-format test (#2627)
A few weeks back, I rearranged a bit of ci-build-and-test.bash to invoke
cmake directly instead of the makefile wrapper. But in the process, I
accidentally caused it to always build `--target install` instead of
using the optional target `$BUILDTARGET` which is how clang-format runs
were supposed to have been triggered.

The result was the 'clang-format' test did a full *build* instead of
running clang-format. This was both much more expensive, and also
pointless: we weren't testing clang-format during CI at all.  Oops.
Thus, some recent checkouts weren't properly formatted. We also amend
the minor fixes that bring us into format compliance.

I also noticed that I can use apt-get to install OCIO on the Ubuntu
instances used by GH CI, so modify to only build OCIO from source if a
specific version is requested. This speeds up some of our CI test
cases.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-05 14:03:48 -07:00
Larry Gritz 2ebf56fa47 unordered_map_concurrent: fix missing size decrement upon erase (#2624)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-03 22:57:39 -07:00
Larry Gritz 198258fd7e argparse -- try to resolve overload ambiguity (#2622)
To help track down build issues with MSVS 2015, re-enable appveyor.
Also split GHA CI to test windows for both MSVS 2019 and 2017.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-07-01 15:58:08 -07:00
Larry Gritz 489b443368 SPI: update libraw 0.20 beta
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-30 13:26:55 -07:00
Larry Gritz aa12d70274 fmath: add vint versions of clamp (#2617)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-29 00:16:33 -07:00
Larry Gritz e60789f6c0 Avoid unexplained build break with VS2015 -- presumed compiler bug (#2618)
Doesn't trigger an error on other compilers, or on newer MSVS. But this
minor rearrangement makes VS2015 happy, so let's just go with it and
not look under that rug.

Partially addresses #2611

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-27 18:58:02 -07:00
Larry Gritz ea2a846b70 simd.h: More support for ARM NEON (#2614)
Was browsing some NEON docs and took the opportunity to fill in
implementations of a few more simd methods.

I don't have a way to directly test this myself, but hopefully
simd_test.cpp has enough unit tests to uncover if I've used the wrong
intrinsics for any of this.

I'm hoping that soon GitHub will add a way to run CI jobs on ARM CPUs
for Mac, if nothing else, so we'll have a way to verify this
architecture.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-27 11:56:58 -07:00
Blazej Floch 830d55b76b Fix OIIO_VERSION_RELEASE_TYPE (#2616)
Fixes typo that prevents the release type being propagated from CMake.
The definition in distributed headers is currently empty without the patch.
2020-06-27 11:56:29 -07:00
Larry Gritz 4fc8ce3a29 simd.h: add abs,sign,ceil,floor,round for float3 (#2612)
They already existed for float{4,8,16}, but were never implemented for
float3.

Add to simd_test.cpp both unit sanity checks and benchmarks for these
functions (including for the other classes where it already existed,
they were nonetheless not unit tested).

Also beef up simd_test by testing and benchmarking load/construcution
from scalar. Rename some test functions for clarity.

Along the way I realized a difference between scalar std::round and
our vector simd::round() in how they handle exact middle values
i+0.5. Because our round is more efficient (one instruction, whereas
std::round cannot be done in one op on x64, because "round midpoint
away from zero" is not a native hw rounding mode), put a big fat
comment warning about the difference.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-25 19:18:30 -07:00
Jens Lindgren 7b602c1722 update libraw longitude (#2613) 2020-06-25 13:30:20 -07:00
Larry Gritz 975ed71af5 Fix Mac GH CI: freetype already installed
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-25 09:19:59 -07:00
Larry Gritz 7d3ba8fad2 Update INSTALL to reflect working with ffmpeg 4.3
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-18 23:23:42 -07:00
Larry Gritz 42e4a0b842 Fix comment typo
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-18 23:23:42 -07:00
Larry Gritz fed34425be EXR: Stop translating "worldToNDC" to "worldtoscreen". (#2609)
This seems wrong. EXR standard metadata "worldToNDC" is exactly what it
says, not screen space. I'm not sure how we ended up with the historical
accident of reading "worldToNDC" from exr headers and auto-translating
it to "worldtoscreen".

The hope is that nearly no one is affected by any of this, since the
primary use case for these matrices was shadow maps, which were never
fully implemented in OIIO's TextureSystem anyway (they were last on
the list, and the VFX world switched to ray tracing before anybody got
angry enough at my procrastination to force me to implement it).

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-18 18:45:45 -07:00
Travis Mosley b9e6dc5a0c Updated vcpkg instructions to aid discoverability (#2610)
Added a line for vcpkg users to discover additional opencolorio features they can build with that tool. This will help avoid people trying to build manually to enable features available via that relatively obscure package manager. Looking in the vcpkg repo isn't as helpful for people unfamiliar with that package manager or how it is configured.
2020-06-18 12:53:18 -07:00
Larry Gritz 4e34d10ff4 Add more exr compliance tests and improve error messages (#2607)
Test more images that have been part of the openexr-images suite for
a while. Three cases:

  * New images that weren't in the suite when I first set up these tests.

  * Images that were "broken" because of (originally) missing features
    in our exr support, that over the years are now supported.

  * Images I was unaware of or somehow fell through the cracks.

In the process, improve and uniformize a number of error messages in
oiiotool, iinfo, openexr reading.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-12 13:06:33 -07:00
Larry Gritz ee07290c2f Use GH CI to upload test output for any job that fails tests (#2606)
This will make it much easier to investigate failures or update ref
output when failures only happen on CI -- any test that fail tests
will produce a downloadable "artifact" consisting of the outputs
of all the failed tests.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-11 22:16:38 -07:00
Larry Gritz 812b8d329b Bump version after developer preview tag
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-10 22:37:37 -07:00
Larry Gritz 23092e6271 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-10 13:39:08 -07:00
Larry Gritz 727c325420 Support Qt 5.15 (#2605)
Homebrew upgrade to Qt 5.15 made it more urgent to change some
deprecated calls to newer idioms.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-10 13:26:57 -07:00
Larry Gritz 5e2b5b64e4 Work around broken OpenEXR definition of OPENEXR_PACKAGE_STRING (#2604)
In at least OpenEXR 2.4 and 2.5, is it quite broken!
But OPENEXR_VERSION_STRING seems ok, so use that.
Issue filed against OpenEXR, but I don't have time to fix it myself tonight.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-10 13:26:38 -07:00
Larry Gritz 6f69687c16 Implement Python version of IBA color_range_check (#2602)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-09 17:44:23 -07:00
Larry Gritz 1b5a726656 RLA: sanity checks to detect corrupt or non-RLA files and prevent crashes (#2600)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-08 10:55:32 -07:00
Larry Gritz 9491e78bcc Document python binding of ImageBufAlgo.nonzero_region
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-06 21:25:20 -07:00
Larry Gritz 7364048e9e Use aswf/osl-2021 container to test the planned VFX Platform 2021
Also unbreak Mac on GH CI

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-04 10:33:25 -07:00
Larry Gritz 710a30ba3d CI: unbreak Mac on GH CI
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-03 23:22:11 -07:00
Larry Gritz 012d3b45e4 Filesystem::write_text_file() (#2597)
One-line utility function to open file, write a string, close file,
return if it succeeded. Analogous to the existing read_text_file().

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-03 14:22:00 -07:00
Richard 1982eba11c Use discovered python executable (#2598)
On Fedora, Python must be run using version specific binaries, python2 or python3. Since we go to the trouble of finding python for the main library, we might as well use the discovered binary name and path.
2020-06-02 00:14:51 -07:00
Larry Gritz f9c64a8a26 SPI: Make sure we're using the non-debug TBB build 2020-06-01 17:43:01 -07:00
Larry Gritz 0d49080c10 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-01 09:56:35 -07:00
Larry Gritz 30ce101ec1 Revise OpenEXR sorting of channel names into canonical order (#2595)
Brief background: OpenEXR sorts channel names alphabetically. Most
formats dont allow channel naming at all, let alone forcing a
particular order contrary to the order the user tries to write it to
the file. OIIO promises that if there is RGB, they will be first and
in that order, next will be alpha if present, then depth, then
everything else.

So our exr reader will reshuffle channels into this canonical order
before presenting to the calling app. In addition to literal R, G, and
B being first, also obvious synonyms are accepted and understood to be
first ("Red", "Green", "Blue", and also "Y" in case it's just a
1-channel intensity and then maybe alpha).

A user noticed an interesting edge case: what if it's a normal map or
positional info, so the channel names are x, y, z? You want it in that
order (coincidentally alphabetical), duh. But the current heuristic
will reorder it as Y (mistaking for intensity), Z (mistaking for
depth), then X (a non-special name, so goes last). Ick!

The solution is that we need a more sophisticaed heuristic. This patch
changes the logic to first just sort by layer, then within each layer,
look to see if there are channels "x", and either "y" or "z", and if
so, then we can conclude that it means something spatial and that Y
isn't really intensity and Z isn't really depth for that particular
layer, so an alternate ordering is used. In all other cases, we
continue to use the old heuristic.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-06-01 09:06:34 -07:00
Larry Gritz d3ab6f631d TypeDesc additional helpers: Pointer, Vector2, Float4, Vector2i (#2592)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-30 14:08:39 -07:00
Larry Gritz a5dcf08dbc Fix minor issue with fmath's OIIO::clamp (#2594)
OIIO::clamp had the property that if `val <= low`, it sets `low`.
But actually, when `val == low`, we want to use `val`, not `low`.

This may seem like the same thing, and it is for ordinary types.  But
OSL uses this clamp template for "dual" types (implementing automatic
differentiation), and it causes a case where `val == low` but `val`
carries derivatives that we want preserved, not written over by the
0-derivatives of the fixed `low` value.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-28 10:52:38 -07:00
Larry Gritz 351f3979fd Extra test for multiplication (#2593)
SSE2 lacks an instruction for 32 bit SIMD int multiply. SSE4 has
it. We simulate it with a trick using unsigned multiply on SSE2. Chris
wondered if this alternate code path was adequately tested for
negative numbers, so I added a test to be sure.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-27 16:32:53 -07:00
Larry Gritz 24dacc7bc6 oiiotool continued refactor (#2589)
* Make sure the opname is always canonicalized

* Refactor to allow setup() to call skip_impl() to skip the impl and
  copy instead.

* --ummip : make OiiotoolOp subclass (but note, it doesn't honor the
  `:subimages=` modifier).

* --chnames : now OiiotoolOp and honors the `:subimages=` modifier.

* --chsum : now OiiotoolOp and honors the `:subimages=` modifier.

* --chappend : now OiiotoolOp and honors the `:subimages=` modifier.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-27 00:32:19 -07:00
Larry Gritz 5ac50bc72d Add CI test to exercise gcc10 (#2590)
* Turns out no code changes were needed for gcc10!

* Also updated some dependency ranges in INSTALL.md.

* Make a new CI test "latest" -- using the latest supported release of
  the toolchain and dependencies. That includes gcc10 in this case.
  (This is different than the "bleeding edge" test, which tests against
  the development master of many dependencies.)

* Make several test matrix entries (including bleeding edge, static
  libs, and sanitizers) no longer test on every push. That makes
  things take too long. They all still run nightly, and if you're
  pushing a branch with the name "RB", "release", or "master", so they
  will catch problems before releases. Also, all tests run any time
  the branch name is "gh", so if you are preparing a patch
  specifically to make changes to CI, make sure to do that. We will
  probably continue to fine-tune exatly when we run all tests, versus
  the common configurations.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-26 21:46:11 -07:00
Larry Gritz 052675f162 Fix config problem
In the changes of PR #2584, set_and_check was the wrong macro to use
when the path might be empty -- because it is an error if the path
doesn't exist. The "check" part bites us. So just use a regular "set".

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-25 15:07:31 -07:00
Larry Gritz 044c1bba59 Lots of minor docs rendering fixes
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-24 21:53:45 -07:00
Larry Gritz 6326c4d97b CI fixes
* The sanitizer test was using wrong setup script -- we switched to
  using a container, but didn't change the dependency install script
  accordingly.

* Mac seems slower and less reliable on GH, so switch the clang-format
  test to run on Linux.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-24 13:32:02 -07:00
Larry Gritz 4de0652f20 CI fixes (#2588)
* Build "bleeding edge" against fmt master

* Tests that build against OpenEXR 2.4.0, bump to 2.4.1.

* The "sanitizer" test, use ane aswf/ci-osl:2020 container.  This is a
  slow test, so may as well speed it up by using the container with
  pre-installed dependencies.

* Modify ci-build-and-test.bash to use straight cmake build and install,
  not the makefile wrapper.

* No need for atomic lib check on Apple

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-23 20:30:39 -07:00
Larry Gritz 5937c5a2eb python: Fix subtle bug that lost certain string args (#2587) 2020-05-23 20:26:26 -07:00
Larry Gritz f161d93001 Overhaul oiiotool internal idioms (#2586)
oiiotool dates from pre-C++11, and has grown by accretion. As a
result, the individual actions are implemented using multiple
different idioms, and there is a lot of complex boilerplate.

A recent PR added subimage selection widely to all commands that use
the idiom of an implementation that inherits from the OiiotoolOp
class. The convinced me that we want to migrate as many actions as
possible to this idiom. I also realized that the current use of
OiiotoolOp could be greatly simplified by using lambdas in most
cases, which weren't available in the pre-C++11 ancient times when
oiiotool was first being developed.

This patch:

* Has the OiiotoolOp base class contain (and accept in its ctr) a
  std::function for the meat of the impl() and setup() methods.

* If init() and setup() are the only bits that need customization for
  a particular action, they can just be passed as lambdas rather than
  needing to subclass OiiotoolOp.

* This eliminates a huge amount of per-action boilerplate, many helper
  subclasses and macros.

* In front of every action implemetation (however it is done), I
  inserted a comment with the command line argument (e.g.,
  `--colormap`) which is an aid for me to quickly find the
  implementation in this huge file.

This patch DOES NOT change any non-OiiotoolOp action idioms to
OiiotoolOp.  That will come later, first I wanted to make these
improvements.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-20 15:48:08 -07:00
Larry Gritz c835a1a656 Put PLUGIN_SEARCH_PATH in the exported config (#2584)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-18 13:55:49 -07:00
Larry Gritz 10d8f4058a oiiotool: allow optional subimages modifier for many ops (#2582)
For a large number of oiiotool commands (anything whose implementation
inherits from the OiiotoolOp class), allow the optional modifier
`:subimages=...` to control how the operation applies to different
subimages (when dealing with multi-subimage images).

Of course, previously, the default is that most commands operate only
on the first subimage, discarding the others. The global `-a` (and for
many commands the optional `:allsubimages=1` modifier) cause all
subimages to be preserved and the operation to be performed on all of
them.

This new `subimages=...` allows more fine-grained control by
specifying which subimages will be active, as a comma-separated list
of either numeric indices (starting at 0) or subimage names. The
special string "all" means all subimages (thus `:subimages=all` is
equivalent to `:allsubimages=1`). Any subimage number or name preceded
by a "-" excludes that subimage from the active list.  The operation
is performed on only on the active subimages, with excluded subimages
merely being copied from the first input image. The presence of any
`subimages` modifier implies that all subimages should be preserved.

For example, if a.exr is a "multi-part" OpenEXR image (what OIIO calls
multi-image):

    # color convert just the first subimage, discard the rest
    oiiotool a.exr --colorconvert linear sRGB -o out.exr

    # color convert and output all subimages: -a
    oiiotool -a a.exr --colorconvert linear sRGB -o out.exr

    # color convert just the subimage named "beauty", but output them all
    oiiotool a.exr --colorconvert:subimages=beauty linear sRGB -o out.exr

    # color convert all EXCEPT the subimage named "normal"
    oiiotool a.exr --colorconvert:subimages=-normal linear sRGB -o out.exr

    # color convert subimages 1, 2, and 5, leave the others unmodified
    oiiotool a.exr --colorconvert:subimages=1,3,5 linear sRGB -o out.exr

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-13 21:20:15 -07:00
Larry Gritz 2f0021a7d4 Docs improvements to the way we discuss optional modifiers
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-11 16:03:06 -07:00
Larry Gritz 37828b8305 Important fixups of the RTD documentation (#2581)
Seems that the default version of the 'breathe' sphinx plugin is broken on
RTD.

* Change minimum breathe version to the specific one that is the most
  recent release that I verified runs correctly on our docs.

* Remove unused and rusting sphinx extensions.

* Remove obsolete Doxyfile config settings

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-10 20:39:44 -07:00
Larry Gritz a04008c48b Prepare for release of libraw 0.20 (#2580)
* Have our CI "bleeding edge" test libraw master

* Update Fuji reference image and other reference output related to changes
  in libraw.

* Update install instructions to indicate LibRaw 0.20 support

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-10 17:51:28 -07:00
Larry Gritz 5cc51b5115 oiiotool --subimage:delete=1 (#2575)
The existing `oiiotool --subimage <n>` replaces the top multi-subimage
image with a single specified subimage.

This patch adds an optional modifier, so that `--subimage:delete=1`
performs the "inverse" operation: removing just the one specified
subimage from the top multi-subimage image.

One way this could be useful is if you want to perform some operation
on just one subimage, but sill leave the others intact. For example,

    oiiotool many.exr -subimage 0 -colorconvert foo bar many.exr -subimage:delete=1 0 -siappend -o new.exr

This command loads a multi-image file, extracts just the first image,
applies a color transformation, then loads the file again and deletes
the first image, then appends the two pieces, yielding a new
multi-image file whose first image is the color corrected first
subimage, then unaltered copies of all the other subimages.

Upon adding a test case to testsuite/oiiotool, I noticed that the
existing tests for subimage operations did not have reference output
images, and thus were not being tested after all! Fixed that now.
(Those commands were all working just fine anyway, just didn't have
their tests quite enabled.)

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-09 09:03:52 -07:00
Larry Gritz ee970e87e4 Add VFXPlatform 2020 based test to CI (#2579)
Add VFXPlatform 2020 based test to CI

Use the new OpenEXR 2.5 in the ~2021 test.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-09 00:02:48 -07:00
Larry Gritz 67a86bee32 SPI fix: bump OpenVDB, fix clang path 2020-05-08 16:06:59 -07:00
Larry Gritz d72e273ac5 Avoid CMake warnings by updating naming of found variable (#2578)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-08 12:31:01 -07:00
Larry Gritz cbd390aa2b Comment to document where to find PNM format descriptions
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-07 09:41:44 -07:00
Nick Black 64de894358 Break infinite loop in FFMpeg::read_frame() (#2576)
Codecs which set the CODEC_CAP_DELAY capability led to infinite
loops during reading (see #2571). Once AVERROR_EOF is returned,
no more packets are going to be received, regardless of internal
buffering. break out of the loop in that case.

I've verified that this resolves the livelock following decoding
of the first packet in the Notcurses AVI test case which
illustrated this problem. I've also verified that said AVI
advertises the CODEC_CAP_DELAY attribute, matching the proposed
fix. In addition, I verified that OIIO continues to decode all
my other test cases without trouble. I hand-inspected the media,
and verified that the frame counts were precisely correct.

It is legal to pass NULL/0 into the decoder regardless of
CODEC_CAP_DELAY, and thus this whole conditional can really
be eliminated (I have no mention of it in my FFmpeg wrappers).
I haven't bothered to do that here, but it's a thought for the
future. Closes #2571.
2020-05-07 09:10:22 -07:00
Larry Gritz 7b6e5ed388 writeable -> writable (#2567)
Nick Black points out that in many places we have used "writeable", which
is (depending on which dictionary you check) is either a less commonly
used variant of "writable", or just an outright misspelling.

Even charitably interpreting it as an alternate spelling, let's standardize
on the more common variant.

There's only one API function where this comes into play, so to preserve
link compatibility, we'll have both ImageBuf::make_writable() and
make_writeable() as a deprecated synonym that will eventually disappear.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-06 09:46:27 -07:00
Larry Gritz 9e911bddf2 Minor formatting changes in ustring with new clang-format (#2574)
From here on, clang-format 10 will be our official reference formatter.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-05 18:32:49 -07:00
Larry Gritz a78e6f476a Whitespace fix
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-05 17:31:05 -07:00
Larry Gritz 3ec69e283c Update ref output after raw change
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-05-05 15:57:57 -07:00
Fabien Servant 61327af960 Add the raw:flip attribute (#2572) 2020-05-05 15:57:18 -07:00
Larry Gritz ca8ca129bb SPI fix 2020-05-05 12:57:00 -07:00
Larry Gritz 6cb51486db Bump version after dev preview release
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-04-28 11:35:09 -07:00
Larry Gritz eefe022c3e ffmpeg and openvdb finding touch-ups 2020-04-27 10:34:09 -07:00
Larry Gritz 30561b62f9 CHANGES
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-04-27 09:39:34 -07:00
Larry Gritz 74066a6fad CMake modernization and warning suppression (#2569)
We were getting warnings from newer cmake versions in cases where we
had modules named FindFoo.cmake, but the "found" variable was FOO_FOUND
(instead of matching the module/package name with Foo_FOUND).

Clean that up, as well as imposing a few more namespaced imports to
change to a more modern notation.
2020-04-27 09:22:35 -07:00
Larry Gritz 1f83602e82 Fully hide IplImage references when no OpenCV headers are included (#2568)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
2020-04-27 09:21:51 -07:00
Nick Black 50bb052794 clean up spelling in image{buf,io}.h (#2565) 2020-04-26 12:34:32 -07:00
Christopher Kulla 74307605e2 Only add libraries from the tbb component of the TBB package for building the OpenVDB plugin (#2564) 2020-04-24 22:56:50 -07:00
Larry Gritz b37b9dfe71 GitHub Actions CI improvements (#2563)
* Use the aswf docker images to make sure we have one test that is an
  EXACT VFXPlatform 2019 test (all versions, and on CentOS image).

* The aswf docker also lets us test against g++ 4.8 on GHA, which I
  had never quite figured out before. That lets us disable the old
  Travis CI tests for now, since the only important use for them was
  to run the "oldest supported version" tests.

* In the future, we may use aswf containers for more test matrix entries,
  as they get fleshed out to support 2020 and future 2021. But for now,
  it's just 2019.

* Set up nightly CI test.

* Make CI tests skip for any pushes or PRs that consist of changes only
  to .md and .rst files (i.e., if only docs change, don't bother with
  an expensive build and test).
2020-04-22 11:28:26 -07:00
Larry Gritz 4ad6e013b2 Adjust where boost is found on GHA CI after recent change (#2562) 2020-04-22 11:27:54 -07:00
Larry Gritz 82a5af185c FindOpenJPEG.cmake: Fix incorrectly quoted variable name (#2560)
This error was preventing it from correctly identifying that a found version of libopenjpeg was too old.
2020-04-21 11:36:40 -07:00
Larry Gritz 1a105a6496 Fix all scripts to use /usr/bin/env to find bash (#2558) 2020-04-20 23:12:14 -07:00
Larry Gritz 657f3963e7 IC/TS: Plug a hole that led to redundant tile reads. (#2557)
I was investigating thread behavior while fixing a totally unrelated
bug, and I spotted a way that redundant I/O happens when the same tile
is needed by multiple threads at once. (And it really did happen, I
could see the extra reads in the stats.)

A small additional method to `unordered_map_current` allows us to
simplify the logic in `add_tile_to_cache` fully avoid the redundant
read.

Testing against our production benchmarks, this makes no measurable
difference to performance, even under heavy threading. I think that's
because we make sure that all our texture files are prepared with
'maketx', and thus are tiled, so even the presence of a few redundant
tile reads is essentially undetectable in a full render. However, for
somebody who is using untiled textures (such as jpegs), which will be
read as whole images, this might be a bigger performance gain because
those redundant reads are redundant reads of the entire file.
2020-04-20 23:12:00 -07:00
Larry Gritz 1991e28b6c Fix incorrect printf code 2020-04-19 18:55:59 -07:00
Larry Gritz bc51675223 Beef up the test of Filesystem::extension (#2552)
I suspected that extra dots within a filename was confusing `extension()`.
It's behaving correctly, it turns out. But this is a good test to add.
2020-04-19 18:53:18 -07:00
Larry Gritz 2c4c108988 Test pybind11 master on the bleeding edge CI test (#2556) 2020-04-19 18:53:02 -07:00
Larry Gritz 362162e51d Raise openjpeg minimum to 2.0 (#2555)
Openjpeg released 2.0 in 2015. Continuing to support 1.5 should not be
necessary for future releases.
2020-04-19 18:49:24 -07:00
Larry Gritz 5043b5e457 Fix compiler warning about incorrect extra braces (#2554) 2020-04-13 11:10:22 -07:00
Larry Gritz caa0760727 Improve docs of ImageInput::create and ImageOutput::create (#2551) 2020-04-12 13:35:33 -07:00
Larry Gritz b2b135284c JPEG & PNG: Fix loss of config info upon close and reopen (#2549)
Both the JPEG and PNG readers, because the can only read scanlines in
strictly ascending order, have a section where if they need to backtrack,
they do so by closing the file and re-opening.

But in this close/open, any 'config' settings they were passed when they
opened the first time would get lost. And this could include the IOProxy
they were supposed to be using.

The config info needs to be remembered and applied again if the file
is closed and reopened internal to the reader's operations.
2020-04-11 12:44:03 -07:00
Larry Gritz 547d88a21d Fix typo in license reproduction 2020-04-09 17:29:42 -07:00
Shootfast 531fdcfbd5 OCIO improvements (#2548)
* libOpenImageIO: Added OCIO Role accessors to ColorConfig

* FindOpenColorIO.cmake: Added OpenColorIO_STATIC definition (required for Windows static builds)

* py_colorconfig: Updated ColorConfig python bindings and unit tests
2020-04-09 13:58:19 -07:00
Larry Gritz 058a03ded3 Make the 'bleeding edge' CI test build libtiff and openexr from master (#2543)
The idea of this "bleeding edge" entry in the CI test matrix is to
really use the very latest toolchain, in order to spot problems long
before users will encounter them.

To that end, let's make sure we are building and testing the current
master of libtiff and OpenEXR.
2020-04-08 17:32:22 -07:00
Larry Gritz 6307f02457 Fix GH CI Mac for python (#2542)
Ugh, homebrew just updated some packages (including numpy!) to be
python 3.8-based, but the 'python' homebrew package is still 3.7.
Need to jump through some hoops to make it work.
2020-04-06 22:31:56 -07:00
Larry Gritz f657b40dd7 Fix some problems with the docs (#2541)
Some IBA functions specified the wrong version of the function, thus
leaving out the explanation from the header that was associated with
the other form of the function.

Some groups had bad identifiers, apparently, and were dropping
pieces of text.

Typo in the intro, oops!
2020-04-06 16:24:09 -07:00
Larry Gritz 706d9e9c56 TIFF: fix subtle bug when reading EXIF directory in header (#2540)
After a call to TIFFReadEXIFDirecory, we needed to call TIFFSetDirectory.
We were doing it if the call succeeded, but not if the call failed.
Also, just TIFFSetDirectory is enough, we never needed to close and reopen
the file again.

This had been asymptomatic all along, but some changes in the current
libtiff master made the problems apparent.
2020-04-06 15:23:31 -07:00
Larry Gritz cc72900b27 SPI build adjustments 2020-04-05 17:57:59 -07:00
Larry Gritz 09818a4bac Minor clarification of IC::get_pixels() and TS::get_texels() 2020-04-04 21:56:29 -07:00
Larry Gritz 571c8dd95c Protect against double definitions of GPSTAG values. (#2539)
Prerelease snapshots of libtiff now define these in tiff.h.
2020-04-03 09:47:07 -07:00
Larry Gritz c40c0d4ffe CHANGES 2020-04-01 22:17:43 -07:00
Shootfast 33b4b44c8b externalpackages.cmake: Fix static boost to not overlink (#2537)
When compiling OIIO against a static version of boost where only a subset of boost libs have been built:
(eg, boost configured with --link=static --with-filesystem --with-system --with-thread --with-headers)
We want to disable the automatic MSVC linking, which will otherwise also try to link against unused and non-existant boost libraries (such as date_time).
2020-04-01 18:04:59 -07:00
Larry Gritz 55138f5ee9 SPI changes for shifting compiler locations and versions 2020-03-31 08:50:15 -07:00
Larry Gritz 8af51a9f56 span: allow ctr from vector to allow nonstandard allocators (#2533)
A couple other spots, too.
2020-03-31 08:48:50 -07:00
Larry Gritz e81036b655 Overhaul ArgParse to make it more like python argparse (#2531)
I've been thinking about overhauling ArgParse for a couple years, and
did most of the work in December when I was home from work. Then sat
on it except for slow burn weekend tinkering, but finally got a chance
to put the final touches on and write the docs this week.

The bottom line is that this is a major rewrite of the APIs for
ArgParse to make them much richer, more flexible, and more closely
resembling those of python's argparse module.

Rather than trying to explain the syntax here, I simply will refer you
to the extensive inline documentation in argparse.h, as well as the
examples in the code base of where it's used.

It sill respects the old syntax, so this change is hoped to not alter
the behavior of any programs using the deprecated API.

Start by reading argparse.h, it's design review of the API that is the
most important for those inclined to weigh in.
2020-03-30 17:51:04 -07:00
Larry Gritz b2f0e40581 Build correctly against OCIO 2.x (in progress) (#2530)
And incorporate a build against OCIO master into the "bleeding edge"
CI test, so we don't drift out of sync again.
2020-03-30 12:25:35 -07:00
Larry Gritz 0762e96f7f AttrDelegate::as_vec<> returns the whole attribute as a std::vector (#2528) 2020-03-27 14:44:41 -07:00
Larry Gritz 0f9ed4c9eb FindOpenColorIO: set up a true target (#2529) 2020-03-27 14:44:24 -07:00
Larry Gritz 26929e9619 Add get_indexed() to ParmValueList and AttrDelegate. (#2526)
This lets you pull out a single base value from an aggregate and/or
array attribute.
2020-03-25 16:30:23 -07:00
Larry Gritz 5bcc3e1253 ParamValueList enhancements (#2527)
* New `find_pv()` method wraps `find()` but returns a pointer rather than
  an iterator, and nullptr if the attribute is not found.

* Fix `add_or_replace()` -- it was previously failing to "replace" if the
  new attribute had a different type than the existing one.
2020-03-25 11:32:09 -07:00
Larry Gritz ba42dc3f30 Strutil::upper, lower (#2525) 2020-03-24 09:02:57 -07:00
Larry Gritz c8ef50c6b3 cmake: Clean up comments and make sure to use the right enable var name. (#2523) 2020-03-24 09:02:30 -07:00
Larry Gritz 9cc19c3b64 Fix possible uncaught exceptions in Filesystem utils (#2522)
It is possible for the constructor for filesystem::directory_iterator
to throw an exception. Switch those to the ones that take an error code
reference and do not throw exceptions.

Also fix what must be a bug (how did it ever compile?) at line 208,
where we tried to find out if the status() (!!!) was a diretory, rather
than the path. Huh?

Closes #2517
2020-03-23 18:02:45 -07:00
Larry Gritz 3418f1c97e Better error messages when overscan texture is not possible (#2521)
Sometimes people try to make a texture from a source image that has
"overscan" (that is, when the pixel data window goes outside the
bounds of the "display" window that is assumed to be the 0-1 texture
space). Thiago Ize in particular noticed that this works fine when
outputting the texture as exr, but not as the default TIFF-based
mipmapped textures.

Alas, the only way this can work is if the texture file format has a
way to represent fully general display windows, and TIFF does not. So
it should never have been allowed, but there was no error message, just
strange runtime behavior.

This patch:

1. Tightens up some of the tests for whether the user is requesting an
overscan texture, so that it is an error to use overscan and the
output file type doesn't support display windows (previously this was
only checked if the sequence of operations also required an initial
resize, which was not stringent enough).

2. Fixes the TIFF output which I now believe should never have had
`supports("displaywindow")` return true; it should always have been
false.
2020-03-23 18:02:24 -07:00
Larry Gritz cc53a0eceb Comment fixes 2020-03-20 14:51:29 -07:00
Larry Gritz ebac2614e6 Make sure all build_foo.bash scripts exit upon any error. (#2520)
`set -ex` exists the whole script if any individual command fails.  I
think this will help ensure that people know when these dependency
building scripts have errors, instead of (hypothesized) seeming to
execute fully but actually the installation of that dependency was not
complete.
2020-03-20 12:07:37 -07:00
Larry Gritz 91302311fb Update build requirements for clang 10 and other things 2020-03-14 15:40:19 -07:00
Christopher Kulla a9d251597a Fix clang 10.x warnings (#2518)
Note that some of the warnings related to the dpx/cineon readers highlight suspicious code, but I've opted to retain the existing behavior. The offending variables to not appear to actually do anything, they are just carried around as metadata.
2020-03-13 14:44:07 -07:00
Larry Gritz 2deb8d9703 INSTALL cleanup 2020-03-12 10:08:56 -07:00
Larry Gritz 2c345ce943 Amend INSTALL vcpkg instructions to include tools
Thanks: Moe Myint Htet
2020-03-12 08:58:19 -07:00
Willem871 041b374b4d Fix resolution unit not properly set in JPEG export (#2516)
* Fix resolution unit not properly set in JPEG export

Bug description
-----------------
To give an indication of the physical dimensions (pixels per inch, pixels per mm,...) of the image we can set the "ResolutionUnit", "XResolution" and "YResolution" attributes in the image spec.
For instance for PNG and TIFF this works perfectly, for JPEG however the resolution unit is not properly written.

Root cause in the code
------------------------------
In jpegoutput.cpp in the open() function the "ResolutionUnit" attribute was read and set in the m_cinfo.density_unit entry. 
However this was overwritten by the jpeg_set_defaults(&m_cinfo) call. 

Fix explanation
-----------------
The resmeta_to_density() already contained the "XResolution" and "YResolution" code, but not yet the "ResolutionUnit" code.
So in this fix I moved that code into resmeta_to_density().
2020-03-12 08:43:53 -07:00
Larry Gritz 1f1c0a69db Cmake config fix: make sure Imath headers end up in config include path (#2515)
Also, for CI, some changes to the scripts that download and build some
dependencies, since CMake will give an error if you ask it to generate
configs tat have paths to within the source tree, as we were doing. Move
it out of the source tree.
2020-03-11 12:58:17 -07:00
Larry Gritz 52f2217ad6 Adjust testsuite after adding tga samples to oiio-images (#2512)
The place where the TGAUTILS samples were stored seems to have disappeared
from the web. So put them in oiio-images. Adjusted the targa-tgautils test
for the new location.

Also took the opportunity to clean up the pnm test and simplify how it's
declared.
2020-03-10 10:16:28 -07:00
Larry Gritz 636ea4eb5b Add definition of tweak in version header (#2513) 2020-03-10 10:15:19 -07:00
Larry Gritz 8853dd0b01 CI: allow homebrew field3d installation failure (#2514)
Seems that Homebrew has removed the field3d package, as its scons
build system needs discontinued python2.7 and other parts have fallen
into disrepair and are having trouble on modern compilers and cmake.
2020-03-10 10:14:56 -07:00
Larry Gritz 85b4bb66c8 SPI tweaks 2020-03-06 14:26:17 -08:00
Larry Gritz 1d2edfc349 TIFF improvements fixing some edge cases of tag retrieval (#2504)
Replace black magic with what I think is more principled and correct code,
deduced by carefully reading internals of TIFFGetField.
2020-03-05 14:25:52 -08:00
Larry Gritz 9ce868a956 cmake: Additional controls to customize required/optional dependencies (#2507)
New cmake variables `REQUIRED_DEPS` and `OPTIONAL_DEPS`.

`REQUIRED_DEPS` is a list of individual package dependencies that are
ordinarily optional (meaning, if not found, the build continues,
possibly disabling some functionality or format support), and forcing
them to be required (build failure if not found). Note that "ALL"
means everying.

`OPTIONAL_DEPS` is a list of individual package dependencies that
makes them optional even if ordinarily (or via `REQUIRED_DEPS`) would
be treated as optional. **Extreme caution necessary!** If you take
something required and force it to be optional, there's no telling
what else in the build might break as a result.

A typical use case might be if you have automated builds and want to be
sure that if for some reason they can't find all the dependencies (even the
optional ones), you will definitely fail the build. But maybe you have some
exceptions. For example,

    cmake ... -DREQUIRED_DEPS=ALL -DOPTIONAL_DEPS="DCMTK;R3DSDK"

That means that you want any missing package dependencies to cause the build
to fail, *except* for missing DCMTK and R3DSDK, which you don't care about.

Also did some cleanup to turn PNG into an optional dependency, including
graceful disabling of ICO if libpng is not found.
2020-03-05 14:25:29 -08:00
Larry Gritz 20d26c535c Make sure iinfo return code indicates failures for files that can't be opened (#2511)
Closes #2506
2020-03-05 14:23:15 -08:00
Larry Gritz 5707b804d3 fmath: change rintf to std::rint (#2510) 2020-03-05 11:15:11 -08:00
Larry Gritz 373f0c0119 Fix syntax error with R3DSDK_INCLUDE_DIR (#2509)
Changed R3DSDKK_INCLUDE_DIR to R3DSDK_INCLUDE_DIR to fix library find errors.
2020-03-04 22:04:10 -08:00
Shootfast 5a796bbee8 FindOpenEXR.cmake: Add detection of debug builds (#2505)
Debug builds of OpenEXR have an _d suffix (on Windows at least). This patch adds these file names to the searched library names.
2020-03-03 11:14:35 -08:00
Larry Gritz e29043f038 changes, and fix overdue version bumping 2020-03-02 21:52:58 -08:00
Mei Chu f3225507c4 Updated INSTALL instructions. (#2502)
* Updated INSTALL instructions.
- Include some of the various package manager that can be used to manage dependencies libraries.
- Removed some missing links in the instructions.
- Added vcpkg method for Windows build.

Signed-off-by: Mei Chu <meimchu@gmail.com>

* -INSTALL: Updated documentation per request. Now each package manager got a small section of its own that can be elaborated on in the future if necessary.

Signed-off-by: Mei Chu <meimchu@gmail.com>
2020-03-02 21:51:56 -08:00
Larry Gritz e20b956637 Build system: Revise pybind11 procedures (#2503)
The way we downloaded header-only library was a little janky inasmuch as it
did not actually "build" pybind11, which although there is nothing to compile
per se for this header-only project, nonetheless that's what would generate
the cmake config files defining the targets to import. And the presence of our
FindPybind11.cmake module inhibited cmake finding the config files even when
present elsewhere.

This patch:

* No longer automatically downloads pybind11 as part of our cmake config step.

* Eliminates FindPybind11.cmake module in favor of always expecting a
  pybind11Config.cmake as part of a true pybind11 install.

* Correctly uses the imported pybind11::pybind11 target instead of
  futzing with ${PYBIND11_INCLUDE_DIR}.

* Supplies a new src/build-scripts/build_pybind11.bash script that will do the
  download and "build" of pybind11 (into the ext/ area by default) for those
  users who need it and don't have it on their systems.
2020-03-02 14:37:05 -08:00
Larry Gritz 99886c1834 Exclude some macros from the generated documentation 2020-03-01 22:02:45 -08:00
Larry Gritz df630c0969 Protect against double definition of FMT_USE_GRISU (#2501) 2020-03-01 14:34:20 -08:00
Larry Gritz 9acae4f13b Add ext to .gitignore 2020-02-28 00:17:55 -08:00
Larry Gritz d2d93e72c5 SPI internal build tweaks 2020-02-27 15:36:13 -08:00
Larry Gritz d5c3f5adac Clarify comment persuant to Issue #2496 2020-02-27 10:29:16 -08:00
Larry Gritz a81c0f17fe Fix oiiotool --autotrim to use all subimages (#2497)
Previously, --autotrim when applied to a multi-subimage file would trim
all subimages to the nonzero region of just the first subimage.

This fixes, now examining all subimages and trimming them all to the
union of their nonzero regions (as --trim always did).

Technically, a multi-part OpenEXR can trim each subimage ("part")
separately, each having a different data window. But in practice, many
reading applications (including RV and Nuke!) seem to have trouble
reading files like that. So we go with the union approch.
2020-02-26 23:58:08 -08:00
Larry Gritz 6ed73c00fa Augment FindOpenColorIO to detect the version (#2498) 2020-02-26 23:57:46 -08:00
Larry Gritz 88feb65fc9 Backport fmath performance and other fixes from OSL (#2495)
A variety of minor rewrites of certain math functions to ensure they
generate better machine code and auto-vectorize more cleanly.

* Lots of inline -> OIIO_FORCEINLINE

* Improve clamp used in fast_sin and cos

* fast_safe_pow improve code gen with OIIO_UNLIKELY

* Introduce `OIIO_FMATH_SIMD_FRIENDLY` to allow application switching
  between implementations that give the best scalar performance versus
  sacrificing scalar perf to have the best SIMD vectorization of loops
  containing the fmath function. This is anticipated to be very rare,
  and of course we strive to be simultaneously fastest on scalar & simd,
  but we have one or two cases where such a tradeoff exists.

* Lots of additional fmath benchmarks to help us judge how good they are
  compared to std functions.

* New safe_fmod which not only prevents division by zero but even in other
  cases is much faster than std::fmod.

* New fast_neg is faster than `-float`, in cases where you are ok with
  -(0.0f) being 0.0f instead of actual floating point -0.0f. If you have
  no idea what I'm talking about or why it matters, you definitely will
  like this function!

* Most of these improvements were backported from OSL, made by Alex Wells,
  Intel.
2020-02-26 23:47:31 -08:00
Larry Gritz 7e8d5b5339 fmath.h bit_cast improvements (#2494)
* static_assert to check sizes
* use force inline
* use intrinsics where available
2020-02-25 14:37:07 -08:00
Larry Gritz b008da8bf5 Improve fmath.h madd function (#2492)
I was previously trying to use std::fma, but upon further investigation
it was turning into a single vfmadd instruction a lot less than I thought,
in many cases ending up as a function call (which itself was extra slow
when emulating fma on hardware that lacked it).

The better strategy seems to be just saying `a*b+c`, which on gcc &
icc compilers automatically turns into vfmadd when available on the
hardware, and adding a clang-specific pragma ensures this behavior for
clang as well.

Thanks to Alex Wells of Intel for pointing this out to me (in OSL land).
2020-02-23 11:59:22 -08:00
Larry Gritz 0786f5e633 Add multi-argument version of benchmark clobber() for brevity of use. (#2493) 2020-02-20 22:44:00 -08:00
Larry Gritz e7406560c8 Rewrite of clamp() from Alex Wells generates 2x faster code. (#2491)
Also add clamp unit test and benchmark, and the previously missing
implementation of clamp for vfloat16.
2020-02-19 10:02:56 -08:00
Larry Gritz bea16ced17 Comment 2020-02-17 15:41:14 -08:00
Larry Gritz 12c4a637c4 SPI touchups 2020-02-17 15:39:14 -08:00
Matteo F. Vescovi e999f405bf Fix relative path for oiiotool binary (#2489) 2020-02-17 13:28:55 -08:00
Larry Gritz dbab9b55d3 More nuance in how so name versioning works (#2488)
Versioning embedded in the shared library .so name should reflect ABI
compatibility level. For supported release branches, we guarantee
back-compatibility of the ABI, and therefore 2-digit naming
(major.minor) is appropriate, as we have always done. Changes to the
patch (and tweak) are guaranteed to not break ABI.

On the other hand, development in the master branch (as well as alpha
and probably to be safe betas also) may have ABI changes at any time,
so it is not sufficient for apps to link against libOpenImageIO.2.2.so.
They really should end up with major.minor.patch in order to not cause
trouble for people working from tagged developer previews in the
master branch. In master, "patch" level changes in master may change
ABI, but "tweak" level changes will not.
2020-02-14 10:33:51 -08:00
marsupial 99a751b857 Fix dst-stride not begin honored for format conversion. (#2487) 2020-02-12 11:53:08 -08:00
Larry Gritz e4da960d0a SPI touchups 2020-02-10 14:05:49 -08:00
Larry Gritz a2b5345c6a Fix test for whether OpenEXR has support for FloatVectorAttribute (#2486)
I was previously testing for whether the openexr version was >= 2.2,
which is when the ImfFloatVectorAttribute.h header was introduced.

BUT... OpenEXR has two build systems, and the CMake one (which I use
to build OpenEXR for OIIO's CI tests) worked fine, but the
autotools-based one had a bug that inadvertently omitted installation
of this and some other headers. This problem with openexr's buid system
was fixed in 2.4.

So my preprocessor tests for >= 2.2 was not good enough. This patch
refines the tests so that it's looking for openexr >= 2.4 (when
everything was fixed), or openexr >= 2.2 AND the header is present
(meaning it was built with cmake rather than autotools).
2020-02-10 11:24:18 -08:00
Larry Gritz 8cd5faf404 Bump version after tag 2020-02-09 11:33:32 -08:00
Larry Gritz a02eb8fd82 Overhaul rez build process for SPI 2020-02-08 13:02:13 -08:00
Larry Gritz 12af87c8a8 Add comment about FindOpenImageIO deprecation 2020-02-08 13:01:32 -08:00
Larry Gritz 42235001ee changes 2020-02-08 10:07:17 -08:00
Larry Gritz d0f865da2a Changes to build against newer libraw / support for .cr3 (#2484)
There are API changes in libraw soon-to-be 0.20.x.
Also, write a simple build_libraw.bash that can be used to build a
custom libraw from scratch (including from a specific commit, to test).

The reason I ended up down this road is because we needed to be able
to read .cr3 files, which are not in the released libraw 0.19.5, but
has initial support in the master branch.

Ref image updates for new libraw.
2020-02-07 18:46:27 -08:00
alister-chowdhury 38d4bfddf2 Use clamp wrap mode for IBA::resample() (#2481)
To avoid the black fringing and match the behavior of resize().
2020-02-04 18:07:16 -08:00
Larry Gritz 527591c4a7 Add IOProxy interface to ImageBuf (#2477)
Pass an optional IOProxy* to ImageBuf ctr for reading, supply via new
call set_write_ioproxy() to set one up for subsequent write().

This is much easier than fumbling around with a PTR attribute in the
configuration hints.

Add tests to imageinout_test to check that proxy reads and writes via
ImageBuf works for all the same file types as they did for ImageInput
and ImageOutput.

In the process, found some subtle bugs in the PNG proxy support, needs
to ensure it starts at the beginning when we open, or else multiple
open/close cycles (as will happen in some cases for ImageBuf) will
get all confused.
2020-02-01 21:44:52 -08:00
Larry Gritz 092a48ce41 Fix GH CI warning about obsolete Mac image 2020-02-01 15:39:51 -08:00
alister-chowdhury bf1a07162b Correcting documentation for opaque detection (#2483) 2020-01-31 01:20:22 -08:00
Larry Gritz 2650c9562f Overdue bump of version since the last tag 2020-01-30 22:47:03 -08:00
Larry Gritz ad31ad8ebf Docs touch-ups and cross-reference fixes 2020-01-28 10:21:42 -08:00
Larry Gritz 7fcf440112 Address strict warnings about unused parameters to functions (pt 3) (#2476) 2020-01-28 10:20:42 -08:00
Larry Gritz 8730b627b7 Add concat function to ustring and Strutil (#2478)
`concat(s,t)` is semantically equivalent to `sprintf("%s%s",s,t)`, but
concat carefully avoids copying any of the characters more than once,
and it performs at most one temporary allocation (typically it does
not allocate temp memory from the heap at all, if the sum of the
strings' lengths are not too long).

Added both a std::string-returning and a ustring-returning version.

Also reworked the implementation of `Strutil::repeat()` to similarly
perform at most one one temporary allocation (typically none) and
not perform any unnecessary copies.

Inspired by work Chris Kulla did in OSL.
2020-01-27 21:10:21 -08:00
Larry Gritz f21494e1fb More fixes for problems found by -Wextra (#2475)
More actual (unreported) buglets revealed by -Wextra pointing out function
parameters that were unused.

* Failed to properly swap endianness when decoding Canon camera info.

* ColorProcessor::apply methods were not using chanstride param.

* texture3d fixes: some deriv results dropped on the floor

* Get rid of unused parameters in some internal functions. Not a bug
  per se, but could be misleading about how the functions operate.
2020-01-27 14:22:34 -08:00
Larry Gritz 72e6a63d77 Comment typo fix 2020-01-26 12:19:07 -08:00
Larry Gritz 605ff8035a Address strict warnings about unused parameters to functions (pt 2) (#2471) 2020-01-24 12:13:29 -08:00
Larry Gritz 20fecc1da4 IBA min and max (per-pixel operations) (#2470) 2020-01-24 12:13:07 -08:00
Larry Gritz a210d86984 Fix docs typos 2020-01-24 12:05:47 -08:00
Larry Gritz 3323577dbc Refactor LICENSE-THIRD-PARTY.md (#2469)
Regroup embedded or derived-from projects by license type, with each
license text reproduced only once. I think this makes this file much
more readable, shorter, and easier to see at a glance exactly which
parts are covered by which compatible licenses.
2020-01-23 22:41:44 -08:00
Larry Gritz e081016fad farmhash cleanup (#2473)
* Remove the majority of farmhash.cpp that is about the self-test.

* Make sure absolutely everything is within the OIIO namespace.
2020-01-23 22:33:06 -08:00
Larry Gritz f0d7ef64d2 platform.h: helpful macros for dealing with pragmas (#2467)
Inspired by some work by Alex Wells in the OSL project.
2020-01-22 18:17:18 -08:00
Larry Gritz 48306822ed Work around GH CI problems building ocio
I don't know why, but in the past couple days, all the Linux tests on
GitHub CI have been failing because they can't build OCIO. Travis can do
so. Something changed on the GH end, I can tell because if I re-submit
CI for commits that passed just a few days ago, now they fail, too.

It seems to only be a problem when using Ninja. Falling back to makefiles
for just the OCIO build step appear to work fine.
2020-01-22 13:55:20 -08:00
Larry Gritz 4f220983e8 Fixes related to unused parameters. (#2465)
More exploring what -Wextra turns up.

Found several buglets!

* The string version of getsym didn't pass along report_error.

* ImageBuf::getchannel did not honor its wrap parameter.

* ImageSpec::erase_attribute did not honor its 'searchtype' parameter.

* IBA::reorient did not pass its nthreads params to its children.

* IBA::computePixelHashSHA1 did not honor its nthreads parameter.

* Get rid of useless parameter in internal helper function parse_elements.
2020-01-21 22:38:02 -08:00
Larry Gritz 95ac64fbbe Address strict warnings about unused parameters to functions (#2464)
Fool around with -Wextra (optional, off by default for now), see what
turns up.

No code changes in this batch -- just suppress warnings by commenting
out param names for functions where they are not used (often because
they are base class stubs and the like). For functions that are part
of the public API where we use Doxygen to extract the declarations, we
can't comment out the param names, so instead mark them with
OIIO_MAYBE_UNUSED (and tell Doxygen to make that word go away in the
docs).
2020-01-21 22:35:19 -08:00
Larry Gritz 8f6423487b Update gif.h from original source (#2466)
We have used this for a long time to write animated gifs. Just updating
from its git repo.

Also noticed that we neglected to list it in the docs where we
acknowledge 3rd party embedded software and licenses. Sorry.
2020-01-21 22:33:14 -08:00
Larry Gritz 9542d3e3d3 Fix broken CI when Homebrew field3d and hdf5 are updated slightly out of sync (#2468) 2020-01-20 13:28:02 -08:00
Larry Gritz 5cb002d92e First stab at support for using Conan for dependency installation (#2461)
To make the non-Conan build match the Conan build (and I rather prefer
it this way, as it more closely matches the eventual layout of the
install area), instruct to put the executables in build/bin and
libraries in build/lib.

Not all the dependencies set up right. In particular, the Conan central
repository doesn't have all the dep packages, or in some cases doesn't
have new enough versions. Still contemplating how to address that. But
this is a step in the right direction and maybe somebody with more
Conan knowledge can take it across the finish line.
2020-01-20 10:20:04 -08:00
Larry Gritz 6a43b6ecde Clarify comment 2020-01-19 11:41:50 -08:00
Larry Gritz 79ca384e70 simd: fix typo error in vbool16 == and != (#2463) 2020-01-17 11:01:35 -08:00
Larry Gritz ae331ae0f7 CI enhancements and cleanup (#2462)
* Add GH CI test for Linux + clang

* Needed to port build_llvm.bash from OSL to get the right clang.

* Some cleanup of build_ocio.bash, including renaming varibles more
  clearly and instructing the OCIO build to only make static libs if
  requested.

* Also touched up the travis -- we have recently pared the travis tests
  to just a few, so there's no perf-related reason to restrict some tests
  to just PRs, may as well do them on every push.

* GH CI: install libsquish & qt5 to get a more thorough build a tests.
2020-01-17 00:24:49 -08:00
Larry Gritz 79a5652493 Bump version after dev tag 2020-01-15 17:13:21 -08:00
Larry Gritz 3e3b1d896f SPI builds minor adjustments 2020-01-15 16:23:24 -08:00
Larry Gritz 17f8b71fc4 changes 2020-01-15 14:59:14 -08:00
Larry Gritz c3c4c371dd Extend OpenEXR to handle float vector metadata (in and out) (#2459) 2020-01-15 14:57:23 -08:00
Larry Gritz af889045e4 Fix BUILD_FMT_FORCE accidently left in the wrong position during debug 2020-01-13 16:02:07 -08:00
Larry Gritz b65466424a Remove redundant copy of install_targets macro (#2457) 2020-01-13 15:50:50 -08:00
Larry Gritz e3b92c8f76 Un-embed fmt headers, instead auto-download (#2439)
Like we do for robin-map or pybind11, auto-download the fmt headers
into ext. Remove embedded copies.

Disadvantages:

* One more build step, requires a download. Maybe additional things can
  go wrong? (Mitigating: we already do this for pybind11 and robin-map,
  with no complaints that I'm aware of.)
* This is sometimes a pain for people building behind firewalled networks
  that don't have internet access. (Mitigating: but they had to get the
  OIIO code from the net in the first place, so they could get fmt, too.)

Advantages:

* It's just bad form to fully embed other projects if you can help it.
  Some distros have rules against it, and ASWF (if we ever go that route)
  strongly discourages it.
* Makes it WAY easier for me to bump which version of fmt we prefer
  to use -- change one line with the tag we want, rather than updating
  several header files in their entirety.
* Allows users to use a system install of fmtlib, or to use a
  particular/alternate version than what we had embedded.
* Easier for us to benchmark new releases of fmtlib.
2020-01-13 15:50:27 -08:00
Larry Gritz 5b8b48a070 Slight revision of detection of C++ version (#2456)
The main change is recognizing which MSVS version is C++14 compliant.
Also fixed some comment typos, and initial support for C++20 detection.
2020-01-13 12:19:29 -08:00
Larry Gritz 0eacfc5178 Improve docs for ImageBuf, and some error detection and missing methods (#2460)
* Tried to expand and clarify explanations of the constructors and
  reset methods in particular, after an issue was filed with some
  confusion.

* Added checks to ensure that for the ctrs and reset methods that take
  an ImageSpec and allocate (or wrap) a buffer, if the spec doesn't
  have enough information to do the allocation or know the size of the
  wrapped memory (spec lacking nonzero width, height, depth,
  nchannels, and a concrete data format), the buffer stays marked as
  UNINITIALIZED.

* Added `ImageBuf::reset()` as a synonym for `clear()` and a reset
  variety corresponding to the "wrapped app buffer" constructor.
  This makes it so that every ctr has a corresponding reset method, and
  vice versa. As I was clarifying the docs, I realized that this would
  be better if fully symmetric. Because these are not virtual functions,
  these changes should not break ABI compatibility and should be safe to
  backport.

* In a few spots nearby I renamed NULL to nullptr, couldn't help myself.
2020-01-12 08:51:08 -08:00
Larry Gritz 9fedf96e50 changes 2020-01-10 22:06:42 -08:00
Larry Gritz 0ea3b4eca6 Fix typo in man pages 2020-01-09 15:12:22 -08:00
Larry Gritz b860e9f21f libatomic linkage fixes (#2455)
For apps using atomic.h, on architectures where certain atomic operations
need libatomic, they'll need to know about it. The `${GCC_ATOMIC_LIBRARIES}`
should have been a "PUBLIC" designaton for target_link_libraries, not a
private one (since atomic.h, which calls them, are public).
2020-01-07 12:20:43 -08:00
Larry Gritz d50da75fbe Use external libsquish if found (#2451)
This patch checks for libsquish already on the system, and if found,
uses it. If not found on the system, it falls back on the embedded
version in src/dds.imageio/squish. CMake option USE_EMBEDDED_LIBSQUISH
can be used to force use of the embedded version even if found on the
system.

Background: Our DDS support (by Leszek Godlewski in 2010, as a GSoC
student) relies on an embedded copy of libsquish (MIT license) for DXT
compression.  Embedding was a reasonable choice at the time, but in
2020 it's easily installed an Ubuntu, Homebrew, Vcpkg.  Furthermore,
it's also a Debian package and runs up against their rule that we
should never embed code that is available from other Debian packages
that can be used as dependencies.

This is all I want to do in this patch -- comply with Debian rules,
and also reduce OIIO build time by relying on a prebuilt libsquish if
found on the system. This won't break anybody's builds at this time if
they don't have libsquish already installed, and should be safe to
backport to 2.1 for Debian compliance.

But in the future, we might make it a purely external dependency --
expect it on the system, and if not found, simply disable DDS support
(like we do with many other optional dependency such as libwebp or
libheif).
2020-01-07 00:17:31 -08:00
Larry Gritz adc3fa4e05 Bump the minimum pybind11 that we need (#2453)
Recent changes (2347) seem to rely on some pybind declarations that
are newer than the minimum version we checked for. Bump the pybind11
required version.

If no pybind11 was found on the system, it would correctly auto-download.
I botched the test where, if a pybind11 was found but was an insufficient
version, it would not auto-download as intended. This was just an incorrect
test of PYBIND11_INCLUDES when it should have tested PYBIND11_FOUND.

I also augmented the logic to print a more helpful message pybind11
is found but is insufficient version, and furthermore if it's found
in the ext/ area (the auto-downloaded one) but still too old, it will
remind you that it needs to be blown away and refreshed. You'll see
something like this in the cmake configure output:

    -- Pybind11 was found in /Users/lg/code/oiio/oiio.lg/ext/pybind11/include
    -- ... but was version 2.4.3 (minimum is 2.4.4)
    -- Try removing ext/pybind11 and let me download a newer version.
2020-01-06 21:58:23 -08:00
Larry Gritz 191726fb82 simd: Add length(), length2() to vfloat3 to match Imath (#2452) 2020-01-06 21:31:14 -08:00
Larry Gritz e5035f712f Convert old style asserts to new style (#2435)
Lots of changes, a combination of:

* DASSERT -> OIIO_DASSERT (better name with no namespace pollution,
  same behavior as before)

* ASSERT -> OIIO_ASSERT (better name and better behavior -- no abort
  when in release mode, but error still printed; does both error and
  abort when in debug mode)

* Many cases of ASSERT -> OIIO_DASSERT, downgrading to checks that only
  need to happen in debug mode.

* Removal of a few assertions that are just not necessary nor helpful
  (e.g, return if x is null, then immediately pointlessly assert that
  x is not null).

* Change a few assertions to just plain old error handling, no assertion
  needed.
2020-01-06 21:30:49 -08:00
Larry Gritz 4bcce0fdb3 Modify ImageInput/ImageOutput APIs to directly support IOProxy (#2434)
Make it a first class thing the API knows about, not the very weird back
door of passing via configuration hint.

For the sake of backward compatibility, the "old" method of passing
config attribute "oiio:ioproxy" with a PTR data will continue to be
supported for at least a couple major releases.  But moving forward
for 2.2+ (which, remember, won't be a supported release for many
months), the preferred and documented way will be through these new
API calls.

It is still the case that only some format readers/writers support
IOProxies -- it is not only lots of work to extend support to more
formats (volunteers?) but since we rely on 3rd party libraries for
some of our important formats, if they don't have support for some way
to supply custom low level I/O function overrides, it would be very
hard to have a way for OIIO client applications to use proxies for
those formats.  So callers should always check supports("ioproxy") on
the format before relying on it.
2020-01-06 16:17:05 -08:00
Larry Gritz 14a22f40a4 Fix misdesign in unordered_map_concurrent that broke it for unordered_map (#2454)
Background: unordered_concurrent_map<> is a thread-safe map that is
parameterized by the type of the underlying "shard" maps. The default
underlying map type is std::unordered map. Though for a while, as used
by ImageCache, we have been using robin_map as the underlying map
type, having found it has superior performance.

PR 2314 improved performance even more by taking advantage of the fact
that robin_map has a find(key,hash) that lets you supply the
precomputed hash value (in situations where you already had it), thus
avoiding redundant hash computations.

BUT... we failed to notice that unordered_map doesn't have this kind
of find() variety, and so even though the u_c_m is templated on the
map type, this meant that it would no longer work with
std::unordered_map. That's especially painful since the underlying
type defaults to this.

The solution, in this patch, is to make a helper function
`find_with_hash(map, key, hash)` that uses the hash if the map type
has a find(key,hash) method, and otherwise falls back to the standard
find(key).

There is some template metaprogramming involved, and we add a couple
of handy idioms to platform.h (it sort of belongs there because the way
to express the idioms there depends on whether it's C++ 11 or 14+, and
platform.h is where we sort that kind of thing out).
2020-01-06 10:57:47 -08:00
Larry Gritz 5b868c7fef Detect whether we need to link libatomic (#2450)
* Detect whether we need to link libatomic

* Fix build errors for stb_sprintf on mips64el architecture
2020-01-03 12:18:42 -08:00
Larry Gritz d1f63a5382 repremult: Fix subtle edge case in color conversion with unpremult=1 (#2447)
Troy Sobotka pointed out to me that the implementation of colorconvert
where unpremult=1 (i.e., unpremult, then transform, then premult) was
wrong: the unpremult operation was careful to preserve the color value
of pixels where alpha==0, but the premult we did at the end was just a
straight multiply of the color by the alpha. This would have the
effect of crushing those "glow" (A==0, RGB > 0) pixels to black in
their round trip, whereas we want the original glow to be preserved.

So really, the kind of premult we want for a one-time conversion of
unpremultiplied to premultiplied is subtly different from the "re-premult"
that we want as part of a round-trip operation.

The fix in this patch is to add IBA::repremult() to do this modified
operation (multiply color by alpha, unless alpha is 0), and also that is
the correct operation to use in the unpremult-transform-repremult round
trip that we do as `colorconvert(unpremult=true)`.

Also noticed that the recent CMake overhaul inadvertently left
testsuite/oiiotool-color un-tested, so re-enable that (which also lets
us test this fix).
2020-01-02 17:23:05 -08:00
Larry Gritz bbd7675c8e Add vfloat3.normalize(), for compatibility with Imath::V3f (#2446) 2020-01-01 20:25:27 -08:00
Larry Gritz 2aae67f763 Fixes to cmake config generation (#2448)
* Relax version compatibility specification to just matching major version.
* Specify targets cmake name correctly.
* Make sure install include dir is listed in the public include dirs of the
  libraries.
* Some other cleanup and genericization.

I believe this corrects some deficiencies in the generated
OpenImageIOConfig.cmake that projects can use that exclusively (with
imported targets) and have no need for a copy of
FindOpenImageIO.cmake.
2020-01-01 20:15:33 -08:00
Larry Gritz fcd3580cca Add ImageBuf::setpixel() methods that use cspan instead of ptr/len. (#2443) 2019-12-30 12:01:44 -08:00
Larry Gritz 7357ca1bdc Extend Python ParamValueList to take lists and numpy arrays (#2437)
Previously the data passed had to be tuples.

Also add ParamValueList.attribute() variety that takes an nvalues
parameter.
2019-12-30 11:52:35 -08:00
Larry Gritz adfa94d535 Add missing include of dassert.h to refcnt.h (#2444)
We used the assertion macros, but didn't include the header. I guess
coincidentally, all other files that included refcnt happened to have
included dassert first? But 3rd party code that wants to use refcnt
for some reason shouldn't have this pop up as an error
2019-12-29 10:59:30 -08:00
Larry Gritz b350f5a88b Bump version of pybind11 that we auto-download (#2436) 2019-12-29 10:58:33 -08:00
Larry Gritz e662096012 Compensate for CI machine changs for python install (#2445)
Something changed about homebrew versons, I guess, and the combination
of python + cmake on both GitHub CI and TravisCI broke OSX. Modifying
install_homebrew_deps.bash to be sure it upgraded to the latest
version of both packages seems to solve the problem.
2019-12-28 23:00:40 -08:00
Larry Gritz ae47110077 Fix typo that set the wrong definition for static libs (#2442) 2019-12-25 10:10:43 -08:00
Larry Gritz 12dfb9a0ca Fix broken version in the built .pc file (#2441) 2019-12-24 20:47:31 -08:00
Matteo F. Vescovi ff662cb2ed Fix various typos in code and documentation (#2438) 2019-12-24 16:55:19 -08:00
Larry Gritz 78a53b9884 Fix occasional static destructor order fiasco. (#2432)
Never reported, not on CI tests, but I've seen it happen. Only on MacOS, only
for builds with EMBEDPLUGINS=0, only for tests involving Field3D files.

I seem to be able to fix it (or at least make it asymptomatic when I
run tests) by forcing all the open texture file handles to close
before the DSOs are unloaded, for a few of the utilities.
2019-12-18 18:35:12 -08:00
Larry Gritz b3f6a6824d Allow rw locking of texture caches (#2433)
To reduce thread contention on the IC/TS caches, change from unique
locks to reader-writer locks.

* unordered_map_concurrent: Change the shards from spin_lock to
  spin_rw_lock. Most operations (insert, erase, holding an iterator,
  and find, which returns an iterator) are unique (write) locks. But
  the underappreciated retrieve() method is stateless and so can be
  a reader lock!

* In imagecache.cpp, change a bunch of the find() calls and fiddling
  with iterators into simpler calls to retrieve(), which should be
  able to happen concurrently.

On a highly threaded machine (52 cores) this resulted in a 6% gain
(geometric mean) across a set of production render frames that we like
to test with, but that disguises what's really happening.  Most of the
individual tests in that suite don't change at all (or vary within the
+/- ~1% we expect from timing noise and run-to-run variation.  But a
handful of the tests sped up by 20-40%! So I think you are unlikely
to see any change for a few threads, or even many threads for most
situations. But for highly threaded renderings where the access pattern
really results in the cache locks as a major rendering bottleneck,
this should help a lot.
2019-12-18 15:30:44 -08:00
Larry Gritz 52d8934cae Fix docs typo 2019-12-16 13:55:54 -08:00
Larry Gritz 873b08b737 Replace most uses of boost::thread_specific_ptr with C++11 thread_local (#2431)
There is still one use left, in ImageCache. I'm not sure how to get rid
of that yet, because the C++11 std version only works for global or static
variables, but we are using it in a class. We'll come back to that later.
In the mean time, this gets rid of all other uses.

One thing this does is fix a link error I get on MacOS when building
with EMBEDPLUGINS=0.
2019-12-16 09:20:06 -08:00
Larry Gritz 8a4d2f933c Docs: fix some II and IO chapter examples that used old open() API 2019-12-12 10:19:27 -08:00
Larry Gritz 94174d27d8 Fix ffmpeg package availability problem on Travis (#2430)
The ffmpeg we were using was from a repo whose owner just took it offline.
This was making our TravisCI Linux builds fail. But it's well tested in
the GitHub CI matrix, so just remove it here.

Also... remove another Linux test from Travis that seems redundant, as
it is nearly an identical configuration to one in the GH test matrix.
And for that matter, we don't need to do the clang-format check on
both testing platforms, so remove it from Travis, too. Now we only use
Travis for the gcc 4.8 tests and Mac with Python 2.7 (I've had trouble
getting both of those working on GH CI).
2019-12-12 10:14:53 -08:00
Larry Gritz ad7938902d Exif read: guard better against out of range offests (#2429)
The dataptr() function returns nullptr if the offset is out of proper
range. But the array_to_spec function calling dataptr did not check for
a nullptr return, ended up segfaulting.

This can happen with JPEG files that have certain malformed (we think)
sections of their camera maker notes.
2019-12-10 09:25:32 -08:00
Larry Gritz 6879040647 docs -- edit changes, install 2019-12-08 11:29:21 -08:00
Larry Gritz ce03e8ed99 travis: switch ffmpeg source, old one no longer available 2019-12-08 10:34:40 -08:00
Larry Gritz 5133a8785f Upgrade to fmt 6.1.1, fix format mismatch, disable fmt exceptions (#2427)
* Upgrade to fmt 6.1.1 for some minor bug fixes

* Fix critical format mismatch!

* Disable fmt exceptions
2019-12-05 15:14:04 -08:00
Larry Gritz 5dcc332bf1 fmt fixes -- allow a way to fully disable it (#2426)
Oh boy, I discovered that something in the new fmt make Cuda unhappy,
and this in turn bites OSL. So I made it so that to really get out of
such a jam, one could `#define OIIO_USE_FMT 0` before including
strutil.h, and then the fmt headers will not be included nor called,
falling back on tinyformat where possible (for sprintf, to_string) and
for std::format style simply fail to format. This is sufficient for
now, we don't actually need the formatting to work from within Cuda at
the moment.

Also fixed some out of date comments while I was there.
2019-12-04 14:44:05 -08:00
Larry Gritz 302d9cc65c changes edits 2019-12-03 17:21:04 -08:00
Larry Gritz 2af3c4892f Remove obsolete pdf docs, rely on https://openimageio.readthedocs.io 2019-12-03 17:17:52 -08:00
Larry Gritz 4c3a24f7e8 changes 2019-12-03 16:01:44 -08:00
Larry Gritz 64bad0cc6f Python: add binding for missing ParamValue constructors (#2417)
We previously exposed the PV constructors from just a plain int, float,
or string, but there wasn't an easy way to construct from arbitrary data
like there is in C++.
2019-12-03 10:25:28 -08:00
Larry Gritz 479805991c Update embedded fmtlib to v6.1.0 (#2423)
This updated version of fmt has its floating point conversions locale-independent as we wanted.

Switch completely to relying on fmtlib instead of tinyformat by default, even for the printf-style formatting and to_string() implementation. (It's still controlled by a preprocessor symbol so we can switch back if there's an emergency bug.)

Be more careful about %d vs %u string formatting: tinyformat ignored the distinction, fmt does not.

Summary of performance results:

* float->string (printf style and to_string) is almost 10x faster than before, and now is ~3x faster than C++ std::sprintf to buffer.

* int->string is as fast or faster than std::sprintf to a buffer (despite also doing allocation!).

*  A 6-item conversion to string of mixed int/float/string values is 5.6x faster than before when using printf-style, 1.5x faster for fmt-style, and those two now approximately match and are each 2.7x faster than std::sprintf to pre-allocated buffer.
2019-12-03 10:24:53 -08:00
Larry Gritz 0eaa5f4810 More string format de-confusion: debug()->debugf() (#2424) 2019-12-02 15:32:59 -08:00
Larry Gritz caeb255bec Simplify isfinite idiom. (#2422)
This resulted from some post-commit discussion on issue #2301
2019-12-02 15:32:33 -08:00
Larry Gritz 47c16dea9f IC/TS option "trust_file_extensions" (#2421)
The default is 0, old behavior. If you set to nonzero, you are
promising the ImageCache that it will always be able to identify a
texture file's format based on the filename extension (e.g. ".exr"
always means it's an openexr file, ".tif" or "tx" for TIFF files, and
you will NEVER call a file ".tx" if it's really openexr, or if you do,
you are ok with it being unable to open it). When you enable it with
that promise, it can eliminate a few redundant file opens and header
reads, by not needing to verify file format types at certain stages of
processing.

I'm not sure I would recommend enabling this in general. But if you
are operating in a closed environment where you are sure that file
extensions will match their types (such as a studio with rigid naming
conventions, where all possible textures have been converted with
maketx), this can eliminate some unnecessary network traffic and file
server workload.
2019-12-02 15:32:02 -08:00
Larry Gritz e19c47a979 Fix occasional CI failure in imageinout_test (#2420)
One test is to write an image file to disk, then write the same image
as a "file" to an in-memory buffer, and make sure resulting bit patterns
match exactly.

Every once in a while, it would spuriously fail. I'm pretty sure it's
because of metadata not matching exactly if the two writes happen on
opposite sides of a minute boundary!

This patch attempts to preempt that by setting "DateTime" metadata to
a fixed value, so that individual format writers don't, in its absence,
supply the "now" value, which could vary from run to run.
2019-11-30 16:40:53 -08:00
Larry Gritz 7be26c2e22 oiiotool & ImageBuf improvements for huge images (#2414)
* Detect failed allocations when ImageBuf tries to allocate local memory
  but there is not enough memory -- catch the exception, leave the IB
  uninitialized, set an error in the IB. This at least allows oiiotool
  to issue an understandable error message if --create or --pattern fail
  because too high a resolution was specified.

* oiiotool --create and --pattern take a new optional parameter:
  `:type=name` that overrides the default behavior of allocating all
  internal buffers as float. An important application of this might be
  if you are creating a huge image that would not usually fit in memory
  as floats, might as a half or uint8. For example,

      oiiotool -pattern checker 64000x32000 3 -o big.exr

  writes a really big checkerboard, but will fail on a machine that can't
  muster an allocation of 23 GB RAM. However,

      oiiotool -pattern:type=uint8 checker 64000x32000 3 -o big.exr

  will create and write the same checkerboard using only 6 GB RAM.

* Noticed that oiiotool -o is the only command that used `:datatype=`
  as an optional type override. All others use `type=`, so change to
  that. (The old one is silently accepted as well.)
2019-11-29 14:08:38 -08:00
Larry Gritz 3c8dccd9e6 BMP fix uninitialized data in output (#2418)
Difference between padded scanline width and number of pixel values was
not properly considered or zeroed out. This was (nondeterministically)
botching occasional CI tests.
2019-11-28 10:19:43 -08:00
Larry Gritz 7c48edb09e Assertion overhaul (#2411)
The new preferred assertion macro, OIIO_ASSERT, tests a condition, and
if not true, prints an error message and aborts for debug builds. For
release builds, only tests and reports the error, but does not abort.

OIIO_DASSERT is identical for debug buils, but does nothing at all for
release builds (not even test the condition).

ASSERT and DASSERT are the old macros, but because of namespace
pollution and less desirable behavior, we consider them deprecated
want to phase out their use. (In a separate review we'll convert calls
to these.)

Moving forward, then, the attitude about assertions should be:

* OIIO_ASSERT for when you want an error message in all cases, and also
  abort for debug builds (but not release builds).

* OIIO_DASSERT when you want error/abort for debug builds, and nothing
  for release builds.

* ASSERT/DASSERT - old names and behavior, phase out over time.

* assert() - roughly equivalent to OIIO_DASSERT, ok to use as well,
  especially if you are desiring to have a particular header or module
  free of dependency on dassert.h.

* Overall: remember that you should only use assertions to test for
  "impossible" conditions that indicate a programming error. Never use
  them in place of error handling, or to detect bad input.
2019-11-27 22:35:53 -08:00
Larry Gritz e70f97d3ac ustring internals: properly guard libc++ preprocessor symbol references (#2415) 2019-11-26 20:59:40 -08:00
Larry Gritz 0ea0c7054c Better fallback for OIIO_ALIGN, rely on C++11 (#2412) 2019-11-26 20:59:07 -08:00
Larry Gritz ecbc249e5a More robust OIIO_PRETTY_FUNCTION definition (#2413) 2019-11-26 20:58:46 -08:00
Larry Gritz 227ded4afe Suppress warnings with old libraw on earlier gcc versions 2019-11-26 17:41:26 -08:00
Larry Gritz 639daadc4f Bump version to 2.2-dev after RB-2.1 branch 2019-11-19 17:38:33 -08:00
Larry Gritz 9e819babab changes and bump release designation to RC1 2019-11-19 17:34:40 -08:00
Larry Gritz e25d956ea2 Strutil::lstrip, rstrip (#2409)
We already had strip, which trims chars from both sides. Sometimes you
just want to trip the left or right.

Also add some missing unit tests. And saw a > vs >= improvement in
in string_view::substr().  (I don't think it was wrong before, just
failed to take an early out for an empty substring.)
2019-11-19 08:32:25 -08:00
Larry Gritz cb4176ea49 More care with locales -- Strutil::vsprintf was not locale independent (#2410)
We relied on vsnprintf underneath, which is locale dependent.  This is
important for OSL, which generates code that uses this (it will botch
the formatting of floating point values in OSL printf, format, error,
and other similar calls, if the user has their system set to a locale
with commas as decimal separators).

OSX, FreeBSD, and Windows have vsnprintf_l which allows passing a locale
(for which we use the "C" locale). But Linux does not.

Instead, we use the public domain stb_sprintf, which is locale independent,
for its vsnprintf implementation.

Also found a spot in rla output that could botch certain metadata when
in the wrong locale.
2019-11-18 22:29:06 -08:00
Larry Gritz d095f0da3a Reduce tile cache entry 'used' contention (#2407)
Each texture query may perform many samples, and each sample may fetch a
tile (or more). EVERY time it was making sure that the 'used' atomic int
was set to 1. That's potentially a lot of contention.

Idea: Only set it once for all those samples. We really only need to mark
it 'used' per texture call, not per sample.

So I augmented find_tile() with an optional parameter mark_same_tile_used
(defaulting to true), and the effect is that if it happens to be the
most recently used tile in the microcache, it will only call use() if
mark_same_tile_used is true. So then, when looping over sampling, it
passes sample==1 for that param, having the effect that for the first
sample only (or of course if any other tile is needed than the last one)
will it mark used and diddle the atomic variable.

In our production scene benchmarks at SPI, when run in a highly
threaded configuration with 52 cores, I'm seeing a 2% average speedup
in overall rendering time (geometric mean of many tests; on a few
tests I'm seeing up to 20% gain, which is crazy, but many other scenes
merely break even).
2019-11-18 09:47:23 -08:00
Larry Gritz 20e2430765 export.h: reverse sense of the ifdef OIIO_STATIC_DEFINE 2019-11-17 10:48:42 -08:00
Larry Gritz 6a289dd7b9 Add defined to argparse.h to test whether human readable args are supported 2019-11-17 10:48:37 -08:00
Larry Gritz 2c6787881c Improvements to Strutil::join() (#2408)
* Since it uses an ostrstream internally, make sure it is set up to be
  locale-independent (floats will always render with '.' decimal).

* Add a version with a parameter that allows you to set the number of
  items joined to something other than the length of the sequence,
  truncating or padding with default values as needed.

And I illustrate its use in make_texture.
2019-11-17 10:47:28 -08:00
Larry Gritz 3d06a4e356 Speed up hdr/rgbe read and write uncompressed by 5-10x (#2406)
It was calling fread/fwrite for each pixel! Allocate a little memory and
do just one write per scanline.
2019-11-15 23:16:26 -08:00
Larry Gritz e182f6d0b1 BMP safety for big files and int32 overflow for offsets, and speedups (#2404)
* Fix places that could overflow int32.

* Speed up read/write by about 40%, mostly by avoiding the pointless
  zeroing out of allocated memory in cerain std::vector temporary buffers.

* Replace fgetpos/fsetpos with Filesystem::ftell/fseek
2019-11-15 21:47:34 -08:00
Larry Gritz 0841e14c2d Targa big file and int overflow safety (#2405)
Several areas to be more careful, but ultimately Targa headers contain
uint16 resolution values and uint32 tag offsets within the file.
2019-11-15 16:06:11 -08:00
Larry Gritz f8807ad704 error -> errorf (#2393)
A while back we added errorf() in various places, which henceforth
will be the place to do printf-style formatting, trying to migrate to
a point where the "non-f" error() will eventually follow std::format
(python-like) formatting codes. But for now, error() and errorf() do
the same thing, we will only change the meaning of error() down the
road when it's safe.

This patch just rounds up a lot more places in the internals where
we use error() and changed to errorf().
2019-11-15 11:19:51 -08:00
Larry Gritz bf795758b0 Put checks in zfile output for largest possible resolution (#2403) 2019-11-14 23:39:03 -08:00
Larry Gritz 11f845e671 sgi: big file safety and speedups (#2402)
Watch out for int32 overflows, practice 64 bit seeking.

Also speedups by changing allocations from vector to unique_ptr
2019-11-14 23:38:28 -08:00
Larry Gritz 299fb4103d Refactor iff header reading for better error messages (#2398)
Ultimately this was to simplify the header reading and make sure that an
error message is returned to make it easier to understand where things
failed.
2019-11-13 23:52:19 -08:00
Larry Gritz c9a6e35269 Bump robin map version to latest release (#2401)
We were pegged to a fairly old commit. Also, modern versions have
changed their directory layout a bit (tsl/... -> include/tsl/..., so
compensate for that.
2019-11-13 18:16:49 -08:00
Larry Gritz 5155f94c80 IFF: be mindful of max resolution (#2397)
In the header, the total number of tiles is stored as uint16.
2019-11-13 13:47:49 -08:00
Ramon Montoya Vozmediano dcf2904888 upgrade to 3 channels when doing color conversions (#2400) 2019-11-13 13:21:22 -08:00
Larry Gritz f71328b113 unittest.h: add OIIO_CHECK_IMAGEBUF_STATUS (#2394) 2019-11-13 10:55:53 -08:00
Larry Gritz e5657f7492 Add Filesystem fseek & ftell, always are 64 bit offsets (#2399)
These utility functions are natively 64 bits, so you don't need to
worry about what nonstandard functions to call. Prefer Filesystem::fseek
and ftell over std to guarantee safety for enormous files.
2019-11-13 10:51:25 -08:00
Larry Gritz 8f2c03f02d DPX: guard against int32 overflow for very big images (#2396) 2019-11-13 10:50:30 -08:00
Larry Gritz f9b45b96ec Rename appveyor.yml to disable it in favor of GitHub CI (#2395)
Appveyor seems to have changed something on their end that is breaking
our vcpkg installs of dependencies. Now that I have GitHub CI working,
I don't feel like trying to figure out how to fix Appveyor. Let's just
retire it, since GH CI is testing the build on Windows adequately.
2019-11-11 23:47:49 -08:00
Larry Gritz 5f60237ea1 Docs typo fix
[ci skip]
2019-11-11 12:25:51 -08:00
Larry Gritz c728f433aa Enable python for windows ci test 2019-11-09 15:18:35 -08:00
Larry Gritz 8e47157088 Print defs for JPEGTurbo 2019-11-09 12:49:20 -08:00
Larry Gritz df8d37b632 Fix cast warning (#2392)
Was making lots of warnings on Windows.
2019-11-08 13:24:30 -08:00
Simone Gasparini d129c9a47c [cmake] add config based install and usage (#2387)
* [cmake] add config based install and usage

* [cmake] using OIIO_EXPORTED_TARGETS

* [cmake] cleaning and formatting

* [cmake] more comments
2019-11-08 10:23:37 -08:00
Jérôme Duval 14e174c9b6 strutil: specify the global namespace for strtof and strtod calls. (#2391)
thus avoids infinite loop.
2019-11-08 10:21:08 -08:00
Larry Gritz 4cc4b6e8d5 Disable webp for now on GH CI Mac 2019-11-08 08:31:19 -08:00
Larry Gritz e697e696b7 Bump GitHub CI on Mac image, they are obsoleting 10.14 2019-11-08 08:31:10 -08:00
Larry Gritz b09365187c We no longer need CircleCI, take it out of the test regime (#2389) 2019-11-07 14:45:42 -08:00
Christopher Kulla 4895dc0948 Switch Filesystem API to use string_view more consistently (#2388)
A number of calls in the Filesystem API were using std::string instead of
the more efficient string_view. This was leading to extra conversions in a few places in the code.

Also mask the usage of boost::system::error_code behind an alias so we can (one day) move to std::filesystem more easily.

Fix some internal roundtrip between string and path representations in the Filesystem module.
2019-11-07 12:16:20 -08:00
Larry Gritz c8ec93d515 Fix bugs in Strutil::parse_string that would fail for escaped quotes (#2386)
Two subtle bugs in Strutil::parse_string:

1. Toggling whether we are in an escape code based on the first
   character in the original string, rather than the next character to
   scan.  Big oops!

2. Not realizing that a second backslash in a row should *clear* the
   flag (i.e. `\\` does not leave you in an escaped state).

I beefed up the unit tests, looking at the example I added should
explain the edge case where this crops up -- a double-quoted string
with embedded \\\" within it, if you catch my drift. Just look at the
unit test, it explains better than I can do here. It's very hard to
talk and write (and reason correctly) about escaped strings with
embedded quotes!
2019-11-07 10:27:19 -08:00
Christopher Kulla 8fd114afef Reduce the number of stat calls when opening files (#2385)
* Simplify implementation of Filesystem wrappers

Use the version of boost::filesystem calls that return an error_code instead of catching
exceptions to make the OIIO noexcept.

Also remove extraneous calls to exists that were doubling the number of stat syscalls

* Reduce number of syscalls when opening files

Defer checking for filename existence when scanning for udim tokens in the filename

Avoid double-checking for file existence when measuring the file size, since the Filesystem wrapper already returns 0 on error
2019-11-07 08:51:16 -08:00
Larry Gritz 95cafb8725 Cleaner PIMPL idiom for ImageBuf (#2384)
This is a revision of #2350. I like this solution better.
2019-11-06 22:22:58 -08:00
Larry Gritz c1849f659e igrep and iinfo: more careful about --help returning success code (#2383) 2019-11-06 10:18:06 -08:00
Merwan Achibet fefafd5a86 Fix runtest.py copy when OIIO is a submodule (#2380) 2019-11-05 22:44:33 -08:00
Larry Gritz ae7ea1ad71 ImageCache per-thread file cache to deal with thread contention (#2379)
It's a wash for small thread counts, but for highly threaded renders,
I'm seeing 5% speedups to overall rendering across a large suite of
production scenes on a 52 core render.
2019-11-05 16:52:09 -08:00
Larry Gritz a72bbc5eaf Bug fix in deep image compare when pixels had different # of samples (#2381)
The IBA::compare for deep images A and B would loop over pixels in the
union of A's and B's ROIs (so far, so good), then for each pixel would
loop from 0 to A's number of samples in that pixel. Oops! That means
that if A had fewer samples than B (or if A had no samples but B had
samples) in that pixel, it would not notice that the images were
different.
2019-11-05 09:52:39 -08:00
Larry Gritz 02df886a2a Docs typo 2019-11-04 10:56:08 -08:00
Larry Gritz d733cb8d17 Bump version after beta tag 2019-11-01 17:05:30 -07:00
Larry Gritz 3c5b093d55 CHANGES and mark beta 2019-11-01 15:15:33 -07:00
Larry Gritz 0bc7e2bbe3 alloca cleanup (#2367)
* Make sure alloca is properly declared on all platforms

* Change all stray ALLOCA and alloca to OIIO_ALLOCA.
2019-10-31 15:54:18 -07:00
Larry Gritz d5b34df650 README fix 2019-10-31 11:55:08 -07:00
Larry Gritz 57e3cb968a FindOpenImageIO: document the imported targets 2019-10-31 11:55:08 -07:00
Larry Gritz 8248dc4fad Rig exr texture output to avoid dwa compression for 1-channel images (#2378)
We've run into bugs with DWAA/DWAB compression of OpenEXR images in
the specific case of 1-channel images where tile size is either < 16
or not a power of 2.  There was already special logic in the exr
output module that notices this problem case and switches to zip
compression.

However, in the case of outputting MIPmaps, the top level may satisfy
the conditions under which DWA compression works fine (power of 2,
tile size >= 16). But in the course of outputting the MIP levels, we
will eventually reach a tile size < 16, and the OpenEXR format doesn't
allow us to select a different tile size per MIP level (it's just
stored once in the header for the whole file).

So add some logic to our MIPmap generation (maketx, etc), so that
single channel exr texture maps preemptively switch from dwaa/dwab to
something safe. This still only affects 1-channel images, multiple
channels don't appear to tickle the bug.

I couldn't help myself, along the way I did a little refactoring,
coalescing several "if the texture is an exr..." clauses together
under one conditional, and also modernizing an initialization loop
and fixing a typo.
2019-10-31 11:23:05 -07:00
Larry Gritz 7a23ece04b Minor cosmetic touch-ups to cmake files 2019-10-29 23:40:23 -07:00
Larry Gritz eaf6f8f338 Use more standard convention for plugin_extension on OSX (#2376)
On OSX, Plugin::plugin_extension() returned "dylib". But actually, OSX
distinguishes between true shared libraries ("dylib") and what they
call "bundles" -- the latter is what we think of as a runtime-loadable
plugin and is traditionally given the extension "so".  This choice
also corresponds to what is chosen by new CMake conventions where we
use "MODULE" as the argument to add_library() when making plugins.

I apologize for not understanding this distinction previously.
2019-10-28 10:31:11 -07:00
Larry Gritz 872b2a9a54 Bump version after developer preview tag 2019-10-27 12:18:51 -07:00
Larry Gritz 94d1f5a28c Simplify Makefile wrapper a bit
Allow overrides of the build_dir and dist_dir.

For SPI, build debug & release libs in same place for better staging.
Also some other local build updates that won't affect anyone else.
2019-10-25 17:45:40 -07:00
Larry Gritz 7418ab20b5 Credits typo fix. Eyes getting old.
[ ci skip ]
2019-10-25 11:45:57 -07:00
Larry Gritz 03ac38ea44 CHANGES
[ ci skip ]
2019-10-25 11:32:25 -07:00
Harry Mallon 05cc7af9b7 Add imported library to FindOpenImageIO.cmake (#2373)
* Add macOS .DS_Store to gitignore

* Add imported library to FindOpenImageIO.cmake

* Fixes #2331
2019-10-24 22:30:36 -07:00
Larry Gritz 23f0806dfe More cmake refactoring (#2372)
* Split python utilities into its own file

* Move shrinking contents of install.cmake into compiler.cmake

* cmake refactoring: mostly moving options close to where they are used

* Comment the heck out of compiler.cmake

* Tweak build_openexr.bash - fix some 2.2 probs
2019-10-24 11:11:02 -07:00
Larry Gritz b6eee38318 ociofiletransform fixes (#2371)
* The Python bindings of both ociotransform and ociolook mixed up the
  order of inverse and unpremult params. Oh no!

* Python bindings of both ociotransform and ociolook sometimes called
  "inverse" "invert", which would be bad for named parameter binding.

* Underlying C++ IBA::ociofiletransform issued an error message when
  no color config was found. This is unnecessary, since the config is
  only used to make a processor, no color spaces need to be known
  since the LUT comes from the file.
2019-10-23 17:48:43 -07:00
Larry Gritz 00d8d7bee9 CI script touch-ups 2019-10-21 22:29:16 -07:00
Larry Gritz 94db179011 Enhancement of cut/paste functionality (#2369)
The details are below, but the summary of what this enables is that if
you have rendered "panels" yielding images A, B, ... Z that all have
nonoverlapping data windows correctly stored in each file, then you
can stitch them together into the correct composite image with:

    oiiotool A.exr B.exr ... Z.exr -paste:all=1:mergeroi=1 +0+0 -o out.exr

This works for deep files, too!

The individual changes:

* New `oiiotool --paste` optional modifiers:

  - `:all=1` Paste the entire stack of images. Normally, only the top
    two image on the stack are involved (`fg bg --paste`), but this
    allows `fg1 fg2 ... bg --paste:all=1`, which means "paste all of
    the fg images on top of bg").

  - `:mergeroi=1` Normally, the foreground image will "clip" against the
    extent of the background image's data window. This option makes the
    result of paste be sized to the *union* of the data windows fg and
    bg images.

* Extend IBA::paste() and `oiiotool --paste` to work with deep images.

* New `oiiotool --originoffset` offsets the data window origin
  relative to its previous value (versus the existing `--origin` which
  sets it to a specific value regardless of what it previously was).

* Change semantics of IBA::paste() and oiiotool --paste.

  When pasting image F on top of B at offset (x,y,z), we now clarify
  that pixel (0,0,0) of F will replace (x,y,z) in B. As before, only
  pixels within F's data window will be copied.

  Before, we were a little unclear and in fact the implementation was
  that the data origin of S would be the pixel that replaced (x,y,z) in
  B.  These two interpretations are identical for ordinary images whose
  data origin is (0,0). But for "crops" or "shrink-wrapped" images, the
  old behavior was confusing since especially in the shrink-wrap case it
  depended on the exact content of S, whereas intuitively we want the
  paste position to mean the same relative offset regardless of the
  pixel contents of F.

* Enable parallelizing of IBA::paste, making it much faster.

* oiiotool internals: give adjust_geometry an allow_size parameter,
  have it handle the warnings when sizes are specified but shouldn't
  be.

* Move the cut and paste tests from testsuite/oiiotool to
  testsuite/oiiotool-copy.
2019-10-21 21:41:00 -07:00
Larry Gritz ed46989e06 CMake touch-ups 2019-10-21 12:42:48 -07:00
Larry Gritz 828cfec4b8 Oops, disabled iv in the last round of cmake fixes 2019-10-21 12:41:39 -07:00
Larry Gritz 5c8e904583 CMake revision: Allow disabling of individual formats and utils (#2370)
* CMake revision: Allow disabling of individual formats and utils

`ENABLE_<name>=0`, as either a CMake variable or an environment
variable (or its antonym `DISABLE_<name>=1`), will turn off support
for the named format or command line utility. This is even the case if
the file-reading library is found, or if no external library is
required.

For example,

    make ENABLE_DPX=0 ENABLE_cineon=0 ENABLE_maketx=0

A compelling use case is for a package that has OIIO as a required
dependency, but only needs a subset of its features. Building a fresh
copy of OIIO is one step in a CI test and we would like to minimize
the time spent on this step, knowing that the CI tests themselves only
use a fraction of OIIOs's functionality.

Be careful, obviously if you disable enough some of the core formats
or components, you will have an OIIO that is nearly useless. The selective
disabling of components is really helpful for ephemeral builds such as

Along the way, we have some other refactoring:

* Rename macro oiio_install_targets to more generic install_targets.

* Move check_is_enabled to its own file, add ENABLE_foo synonyms and
  DISABLE_foo antonyms, in addition to USE_FOO. I'm starting to lean
  toward ENABLE_foo as the general switch name, the others may go away
  eventually.

* Move colors definitions to their own file.

* Overhaul build_openexr.bash for more options and standard nomenclature.

* Revise static compile defines
2019-10-21 00:23:57 -07:00
Larry Gritz d68ef4d258 Make DeepData more safe for huge images where pixels() could overflow an int (#2363) 2019-10-16 16:41:01 -07:00
Larry Gritz ec21cf3cab More CMake revision (#2368)
* Simplify Find cmake modules -- I now realize that many of the
  PATH_SUFFIXES I was using were redundant, specifying suffixes aleady
  appended by default by the find_*() commands.

* Make some warning suppression more targeted (push some global warning
  suppression to local to modules).

* Simplify and deprecate OIIO_BUILD_CPP macros.

* Switch to cmake idioms for symbol visibility. No more HIDE_SYMBOLS
  directive, hide by default. Expose standard CXX_VISIBILITY_PRESET
  (default to "hidden"), VISIBILITY_INLINES_HIDDEN (default to ON).

* Experimental option USE_GENERATED_EXPORT_HEADER (defaulting to OFF
  for now) uses CMake's ability to generate the export header rather
  than using our hand-coded one. I haven't decided whether to switch
  to using this or not. Will stew on it.

* Rename oiio_find_package -> checked_find_package for easier porting
  between projects

* Fix syntax error in FindOpenImageIO.cmake.

* Purge old OPENIMAGEIO_ROOT_DIR for standard OpenImageIO_ROOT

* Clean up build_openexr.bash
2019-10-16 16:33:32 -07:00
Larry Gritz d71ac830c9 Remove unnecessary comment
[ci skip]
2019-10-15 10:47:46 -07:00
Larry Gritz f68e1a4fd1 Fix docs reference 2019-10-15 10:47:31 -07:00
Larry Gritz 0a7054e442 Make all command line utilities --help return 0 exit code (#2364)
`command --help` is a well-formed command that should have a "success"
error code of 0. Most of the command line utilities returned a failure
code. (Only oiiotool got it right.)
2019-10-15 10:04:44 -07:00
Larry Gritz 7e048b1bd8 Extend oiiotool expression eval with // and % (#2362)
// is integer division (like in Python3)
% is integer modulus

Examples:

    {7/3}  --> 2.33333
    {7//3} --> 2
    {7%3}  --> 1
2019-10-15 10:04:25 -07:00
Larry Gritz e5e9e4f98d Tests: remove order dependency of some tests (#2365)
After a fresh build, sometimes a parallel test would fail because
certain tests tried to get ../oiiotool/src/... but that link is not
set up until oiiotool test runs. It is listed first, but sometimes
when doing parallel test runs (via CTEST_PARALLEL_LEVEL=...) the
timing can be just right to fail.
2019-10-15 08:29:48 -07:00
Larry Gritz b140760ec6 Fix SPI debug postfix 2019-10-10 13:39:13 -07:00
Larry Gritz 45f3d1aabb More CMake refactoring and touch-ups (#2360)
* More CMake refactoring and touch-ups

* Eschew directory-level include_directories and add_definitions in favor
  of explicitly tying them to targets and using PRIVATE/PUBLIC.

* Use standard idiom CMAKE_CXX_STANDARD instead of custom USE_CPP.

* Remove last remnants of CSTD manual settings
2019-10-10 12:30:41 -07:00
Larry Gritz ec05a3e78e Put proper copyright notice in cmake files 2019-10-09 12:15:31 -07:00
Larry Gritz 781bc97c35 More CMake revision (#2357)
* Use CMAKE_DEBUG_POSTFIX to add an optional suffix to debug libs

* For SPI, have the "spi" target build both debug and release libs, with
  a "_debug" suffix for debug libs, and dist it all.

* CMake: change obsolete COMPILE_FLAGS to modern COMPILE_OPTIONS

* Use HOMEPAGE_URL, print CMake system name
2019-10-08 13:05:59 -07:00
Larry Gritz a1ed5a1baf GitHub CI tweaks (#2356)
* Add more test matrix cases, include gcc8/9 builds.

* Fix some warnings with various compile versions.

* Remove redundant tests from Travis
2019-10-07 23:50:26 -07:00
Larry Gritz 99c137b203 Fix numpy issue on Travis 2019-10-07 22:55:02 -07:00
Larry Gritz 39e3c32e39 Python3 safety (#2358)
With this additional set of changes, we now have a 100% clean bill of
health from pylint --py3k.
2019-10-07 22:54:34 -07:00
Larry Gritz 18b8c2f9cf Python3 compatibility touch-ups (#2355) 2019-10-07 10:08:38 -07:00
Larry Gritz 12ac121b45 GH win: gif, freetype 2019-10-04 00:16:52 -07:00
Larry Gritz da8aaa406a Make sanitizers 'if' apply to the whole job, not just one step
And make it run for more branch names
2019-10-04 00:16:22 -07:00
Larry Gritz 8c340892ad CHANGES
[ci skip]
2019-10-04 00:15:15 -07:00
Larry Gritz e548a12e21 More CMake refactoring (#2352)
* CMake cleanup with shared vs static libs
  - Replace BUILDSTATIC with use of the standard BUILD_SHARED_LIBS.
  - Eschew add_library(SHARED|STATIC) and prefer relying on the automatic
    behavior of BUILD_SHARED_LIBS.
  - Get rid of my fPIC option, rely on CMake smarts to do it automatically
    for shared libs and modules.
  - Add static libs CI test to GitHub actions

* Fix: Robust to freetype not being found

* Eliminate DEBUGMODE symbol -- unneeded

* Mark library targets' target_link_libraries and target_include_directories
  with the correct PUBLIC and PRIVATE markers.

* Rely on cmake's transitive library dependencies to eliminate a lot of
  explicit library link directives.

* Eliminate almost all CMAKE_BUILD_TYPE references -- it's not
  considered safe for generators (such as MSVS and Xcode) that
  configure/generate once and then can build multiple configurations
  selectable at build time. It's still not perfect, but it's close.

* Eliminate platform.cmake -- unnecessary. Most of it worked around
  cmake limitations from long ago, or defined symbols that we didn't
  seem to actually need (and in some cases would have been
  ill-advised). The one compiler option that might be important, and a
  few helpful status messages, are moved to compiler.cmake and the
  rest is thrown off the side of the boat.

* Add a sanitizer run to GH test matrix, remove from Travis.

* Properly hint search for pybind11 and robinmap
2019-10-04 00:10:32 -07:00
Larry Gritz 2eafbec945 Define stride_t and imagesize_t in a modern way. (#2351)
In a C++11 world, we can define these using int64_t and uint64_t:
simple, standard, identical size on all platforms.

The prior convoluted definitions were from an earlier time when we
couldn't count on these being present.
2019-10-01 14:00:16 -07:00
Larry Gritz 42edb976e4 Docs: bump CMake minimum as documented in INSTALL.md 2019-09-30 15:43:47 -07:00
Larry Gritz 33838037f0 Fix undefined deleter for ImageBufImpl / MSVS errors (#2350)
This seems to have gone unnoticed by the compilers except for a very
recent update of MSVS 2019...

But the opaque class ImageBufImpl we deine publicly in imagebuf.h
in order to use PIMPL idiom has a problem where the std::unique_ptr
doesn't know what deleter to use for an incompletely declared class.

Do some magic to make a public well-defined base class with a deleter,
keeping the full ImageBufImpl private to imagebuf.cpp.
2019-09-28 12:14:04 -07:00
Larry Gritz ee9258db51 SPI: clang9 locations 2019-09-27 11:49:29 -07:00
Larry Gritz 75ecdc4d86 Bump CMake minimum to 3.12 and refactor accordingly. (#2348)
Must take steps to install a newer cmake for the one Travis matrix case
where the old "trusty" image didn't contain a new enough one. In all
the other CI cases, a new enough cmake was already present.

Get rid of legacy cmake policy directives.

With newer cmake, change many add_definitions to more proper
add_compile_options. Get rid of unnecessary cmake definitions.

Refactor Makefile wrapper with better/standard target names: install,
build, config, etc. And don't replicate code for make vs ninja --
instead, use cmake --build.

Now that CMake 3.12 is the minimum, we can count on any FindFoo.cmake
having its searches automatically include hints for having defined
`-DFoo_ROOT=...` or a defined environment variable `Foo_ROOT`, without
our needing to separately define or handle them. This leads to a huge
refactor ond simplification, as well as a normalization of this as the
one true naming convention for dependency location hints (versus a
hodgepodge of FOO_ROOT_DIR, FOOHOME, FOO_PATH, FOO_HOME, and more).

A lot of the repetitive logic of finding dependencies has been
coalesced in new oiio_find_package macro, which wraps the build-in
find_package() with some nicities, including color coded clear status
messages about which deps were found, which optional ones were not,
and which the user disabled.

Along the way, we bump the Travis macosx setup to xcode11.
2019-09-27 11:47:53 -07:00
Larry Gritz bd87d90121 Movie reader enhancement (#2349)
The original code was always asking ffmpeg to give it RGB uint8 frames.

This patch modifies it so that it asks for RGBA when alpha is present,
1-channel image when it's a greyscale movie, and retrieve as uint16
when >8 bits per channel are stored in the file.

If you are, to pick a hypothetical example at random, trying to
convert a 10 bit rgba quicktime of an fx element into individual
frames to save out as TIFF files, this will fully preserve the 10 bits
and alpha channel, whereas before you would just get back a crappy 8
bit rgb.

Also updated where the SPI build gets its ffmpeg, to pick up a newer
version.
2019-09-25 10:09:23 -07:00
Larry Gritz be0e6b96e5 Working towards Windows builds on GitHub Actions CI (#2346)
It's not entirely working yet -- I can get a more or less full build,
but am having trouble with tests. But I'd like to merge the
refactoring and progress I've made so far.
2019-09-23 09:35:29 -07:00
Larry Gritz 226e9b2788 Update pybind11 version logic to work around bugs (#2347)
The newly released pybind11 v2.4.0 and v2.4.1 are actually broken for
C++11 (accidentally used constexpr in a place where it's only valid
for C++14). Communication with the pybind11 team quickly resulted in a
v2.4.2 release that fixes the problem.

This patch adds logic to our build scripts so that if one of the two
broken versions are found on the system and we're building for C++11,
it falls back to our "download our own copy" logic. The new default
for downloading our own is updated to 2.3.0 (including updating some
ref output).
2019-09-21 18:06:04 -07:00
Larry Gritz 5ae8824c48 Bump version after developer preview release 2019-09-20 23:30:12 -07:00
Larry Gritz 9ca612087b Better CMake status messages upon config startup 2019-09-20 14:25:41 -07:00
Larry Gritz c18aa57283 Fixes that make multi-subimage and movie files faster (#2345)
Several small, subtle, interacting issues were making it particularly
difficult for oiiotool to process frames within movie files (and,
less noticeably, other multi-subimage files). The fixes:

* The ffmpeg reader had no valid_file() method, which meant it fell
  back to the default of doing a full open() and looking for success,
  which is expensive in this case. Replace it with the cheap and naive
  test of just ensuring that the file exists and its name has one of
  the proper file extensions.

* ImageCache::read_untiled(), when reading an untiled image as one
  single tile, closed the file immediately thereafter, which seems
  like a prudent thing to do because once you have read the whole
  image into the cache, you may as well free the resources associated
  with the open file, since you don't need to read any more from
  it. Except... if it's a multi-subimage file, you may need to read
  other subimages.  Especially for a movie file with many frames, you
  don't want to do a full open/close cycle for every frame
  individually just because you are using an ImageCache.

* In oiiotool, ImageRec::read was applying a heuristic to directly and
  fully read "small" images, but fall back on the ImageCache to manage
  "large" images. But it was just looking at the each subimage
  individually. For a movie file, that means that it will force read
  all the frames up front, which is silly. So adjust the heuristic to
  multiply the frame size by number of frames as a better estimate for
  the memory cost of the up-front read. This results in most movie
  files of moderate size falling back to the cache, and thus deferring
  the read until the frames are actually needed (especially helpful if
  not all frames will eventually need to be read).

* Oh boy, oiiotool was always keeping handy a config spec to pass to
  the image open, whether it was needed or not. But also some logic in
  the ImageCache was causing certain kinds of "find file" operations
  (which when asked to find an already in-cache file should just
  return it) to invalidate that previously read file and close+reopen
  when a config spec was supplied (in case the configuration hints
  were meant to change the read behavior or interpretation of the
  file from how it was opened before). These combine badly. So we
  change oiiotool to only pass the config spec when opening via the
  cache if there was a user option to actually set a configuration
  hint, and therefore when that doesn't happen, many needless cache
  invalidations were avoided.
2019-09-20 14:24:20 -07:00
Larry Gritz 46862d824d New attrib "oiio:subimages" says number of subimages, if known (#2344)
It's the number of frames for movie files, number of subimages for
other files.

Set and positive only if it can be known inexpensively from the file
header. If absent or zero, it means there was no easy way to determine
the number of frames or subimage from just reading the header (in that
case, you'll have to discover the subimages the old fashioned way,
repeatedly seeking to subimages until you fail).
2019-09-20 09:03:49 -07:00
Larry Gritz 195b3e87aa No need to set unneeded cmake variable 2019-09-17 23:04:19 -07:00
Larry Gritz d0c530901a appveyor: correctly do the install step 2019-09-17 23:00:07 -07:00
Larry Gritz 9dd7a24c73 FindOpenEXR and install_openexr cleanup (#2343)
I realized that HINTS is higher precedence than PATHS, and that
allowed some simplification of the exr finding logic.

Clean up install_openexr script, more control over the generator type
and build configuration. Use `cmake --build` instead of `make` so it
will work on all platforms and not only make.
2019-09-17 21:12:43 -07:00
Alex Hughes 32d579501c Initial R3D CMake support for OIIO (#2303) 2019-09-16 10:28:29 -07:00
Larry Gritz f1ba6fd2aa Upgraded to a more recent sha1 implementation. (#2342) 2019-09-15 21:27:57 -07:00
Larry Gritz 74267420f9 Fix lg's clang8 setup 2019-09-12 08:10:18 -07:00
Larry Gritz a21db2a06a Tested fine against clang 9 (#2340) 2019-09-11 16:41:56 -07:00
Larry Gritz e93cedacd4 Add library designation omitted from the Rez cmake (#2339) 2019-09-11 12:07:05 -07:00
Larry Gritz a902f2fb1a Update install notes 2019-09-10 12:07:58 -07:00
Larry Gritz 0d3aaa90d6 No need to vcpkg install several things needed only for Qt -- it's preinstalled 2019-09-06 20:11:26 -07:00
Larry Gritz 1ff2f4c21b Experiment with GitHub Actions Beta for CI (#2334)
Current prototype works for 2 Linux tests (default and debug), an OSX
test, and a clang-format check. I want to commit this as a basis for
moving forward, after which I'll flesh out the rest of the test matrix
(including Widows and static analysis).  I think this may be able to
eventually completely replace Travis-CI and Appveyor with an
all-GitHub solution.

Some things that came along for the ride:

* Changes to allow parallel running of tests. I didn't previously
  realize that CTest could do this, but it saves a lot of wall clock
  time in the testing phase. However, I needed to chase down some
  aspects of how I set up tests that precluded parallel execution or
  had inadvertently established order dependency to the test cases.

* For Travis as well, use Ninja to build, which is faster.

* Establish a minimum version of libgif of 4.1, and also take extra
  care on OSX not to pick up an errant version from certain Framework
  directories (such as for Mono).

* Updated ref output for yet more versions of libraw.
2019-09-06 15:09:44 -07:00
Larry Gritz 0ced42ecf1 Fix rotl<> for Cuda safety (#2335)
Two problems (sorry for not testing better):

1. I botched the template syntax for the Cuda specialization.

2. The Cuda specialization uses intrinsic __funnelshift_lc which is
   not constexpr, so let's just un-constexpr this whole thing for now.
2019-09-05 21:02:37 -07:00
Larry Gritz f5265cb2ec Fix DPX performance regression (#2333)
Quite some time ago (early in OIIO 2.0 development, after it was
separated from 1.8), we changed the ImageInput::read_native functions
to be thread-safe and stateless. This meant that a seek_subimage would
be called inside the read (which now had a lock) whereas it was
previously assumed that the user had already called it.

All good, as long as your seek_subimage checks whether it's seeking to the
subimage it's already on, in which case no work need be done.

DPX failed to do this, so every scanline read involved a costly header
examination.  Somehow nobody noticed this until now, but it's fairly
icky. It can slow down DPX reads by 2x, and this is greatly exacerbated
in a heavily multithreaded environment.

I found and fixed a similar error for psd files.

While I was at it, I also added a read_native_scanlines so it can read
multiple scanlines (the building block of read_image working efficiently)
with less work, though in my timings it's only barely worth it.
2019-09-05 13:41:21 -07:00
Larry Gritz e695e43582 Fix potential deadlock in TIFF I/O: minor flaw with threadpool method (#2327)
* Fix potential deadlock in TIFF I/O: minor flaw with threadpool method

This has *very* occasionally popped up for a while. I've only seen it
on OSX for some reason, too hard to reproduce but once every several
days.  But a totally unrelated set of changes caused me to see it
happen quite regularly and it's icky.

Long story short, our thread pool seemed to have two different ways of
finding out whether the current thread is a member of the pool, one of
them only used from the TIFF reader/writer, and they didn't match!
Specifically, the correct one tried to know if the calling thread was
doing work for the pool, either being a member of the pool itself or a
nonmember that was stealing work because the pool was too full to add
to. The other one merely said whether it was a fully fledged pool
worker thread. Turns out this difference could get you into trouble,
because you don't want to spawn new tasks from a work stealer, either.

It took me hours of debugging to isolate the trouble, it's too hard to
summarize the specific set of coincidences necessary for this
circumstance to lead to a deadlock.

* Back compatibility fix
2019-09-03 14:04:08 -07:00
Christopher Kulla d201a95e77 Avoid creating a new thread info struct while resolving udims (#2318) 2019-09-03 07:58:16 -07:00
Larry Gritz 04dc91f276 Replace python os.environ access with getenv/putenv (#2325) 2019-09-03 07:56:51 -07:00
Larry Gritz 68994151e6 Remove wayward assertion (#2328) 2019-09-03 07:56:26 -07:00
Larry Gritz 8563ac53f7 IBAprep: replace an assert with a more graceful error failure (#2326) 2019-09-02 23:55:13 -07:00
Larry Gritz ec4b371de0 Fix typo in font search path (#2324) 2019-08-31 19:49:43 -07:00
Larry Gritz d8c20bffd4 When building OpenColorIO from source, bump the default release to 1.1.1 (#2323) 2019-08-31 14:33:39 -07:00
Larry Gritz 5867a1c01f Updates after release of libheif 1.5 (#2322)
A little more flexibility in overriding where to find libheif

Update ref output after libheif 1.5 release
2019-08-31 14:32:57 -07:00
Larry Gritz cbef74aa58 Add new "turbo" color map (#2320)
It's much nicer than "jet" or the one we called "spectrum".

"Turbo" color map Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0
Author: Anton Mikhailov
https://gist.github.com/mikhailov-work/6a308c20e494d9e0ccc29036b28faa7a
2019-08-23 10:28:47 -07:00
Larry Gritz 90d61babf4 Some cleanup of recent SPI-specific build scripts (#2321)
Some synchronization with OSL build scripts, including making some
places that said "OpenImageIO_blah" into "${PROJECT_NAME}_blah" and
the like, for the sake of easy sharing between the projects.

build.py turns out to no longer be needed, but a new CMakeLists.txt for
the Rez distro makes downstream Rez packages happy. From Jon Ware.
2019-08-23 10:27:00 -07:00
Larry Gritz 9c0051e397 Adjust FindOpenImageIO.cmake after recent changes to versioning digits (#2319) 2019-08-22 09:47:44 -07:00
Larry Gritz f91282bec7 Bump version after dev preview release 2019-08-20 15:18:58 -07:00
Larry Gritz 88df5a70cc SPI touchups 2019-08-20 15:16:36 -07:00
Larry Gritz 2f9f424b1f SPI docs touchups 2019-08-19 16:03:11 -07:00
Larry Gritz 6e3199cea2 CHANGES 2019-08-19 15:29:13 -07:00
Larry Gritz 5b002d10a2 Docs & comments touch-ups 2019-08-19 15:29:13 -07:00
Larry Gritz 0c386b52f0 Changes to SPI custom build scripts, versioning/disting policy changes (#2313)
This mostly concerns builds at SPI, but a tiny bit touches the generic
build scripts. Most of you will want to tune out now, unless you're
especially curious.

Changes for everybody:

* Switching to a 4-part formal version number (e.g. 2.1.3.0), so there
  is an additional (rarely used) CMake variable
  OPENIMAGEIO_VERSION_TWEAK. This gives me a little more flexibility
  with certain tags and releases in the master branch but there are
  very few contexts in which anybody will care about or refer to the
  last tweak number, and in practice we may rarely or never use it.

* New CMake option `OIIO_NAMESPACE_INCLUDE_PATCH`, if turned on, will
  make the "inner namespace" include the patch number (such as
  namespace OpenImageIO_v2_1_3), whereas the default is the usual
  major/minor (OpenImageIO_v2_1). In general, for external/supported
  releases, we want just major/minor, since within a major/minor
  family we guarantee link compatibility and specifically DON'T want
  to force a recompile for patch updates only. But for studios like
  ours who build for production directly from master, link
  compatibility is not guaranteed at any time, so we make sure even
  down to the patch level is carefully namespaced.

Changes that only have an effect if you're building at SPI:

* The *default* build (regular old "make") now uses the generic
  default namespace. If you want to make the special namespaced
  version we use for Arnold, build with `make OIIO_ARNOLD=1`.

* Change SpComp2 versioning from consecutive low integer SpComp2
  versions (like v47, v48) to canonical multidigit numbers
  corresponding to external releases, such as v20101 for OIIO 2.1.1.
  Also install the bins in the same place (even though it's
  nonstandard SpComp2 practice).

* A new build mode enabled by `make OIIO_SPIREZ=1` does the kind of
  build we want for an experimental Rez packaging. Some notable details
  and options:

    - `REZ_PACKAGE_ROOT=path` overrides the usual root area where we
      store the packages.
    - `OIIO_REZ_NAME=name` overrides the default package name for the
      Rez distribution (default is "OpenImageIO").
    - An appropriate package.py is automatically generated.
    - The Rez variants fold in the SPI compiler compatibility platform,
      Python major/minor version, and Boost version.
    - The build automatically sets the Rpath for the Rez install area
      so that nobody needs to mess with their LD_LIBRARY_PATH to get
      the libraries to be found (especially if you're just importing the
      Python module).

* Make the appcfg xml for releasing the binaries to the facility.

* Instructions for building for the facility are now in
  site/spi/README-SPI.md
2019-08-19 15:14:41 -07:00
Christopher Kulla 169ff7bce3 Improve the hash function for the tile ID (#2316)
Use all bits of the hash to pick the bin in unordered concurrent map

Minor cleanups to the TileID struct
2019-08-19 15:05:24 -07:00
Christopher Kulla c4f7bbdedd Performance tuning for ustring table (#2315)
* Tweak ustring test to avoid benchmarking sprintf and allow auto detection of thread count

* Tune the default size and shard count for ustring table to perform better on machines with many CPUs

Comment out the num_lookups variable by default (since it is not used)

Make sure ustring table mutexes are cache aligned
2019-08-19 09:42:18 -07:00
Christopher Kulla bd78907ac7 Small improvements to concurrent map (#2314)
* Use robin_map for fingerprint map

* Improve concurrent map lookups by using methods that accept a precomputed hash
2019-08-17 13:05:20 -07:00
Larry Gritz 8c24e346a3 Fix docs typos
Also fiddling with license formatting to try to get GitHub to correctly
auto-detect the BSD 3-clause license. Not consistently working.
2019-08-16 12:28:55 -07:00
Larry Gritz b4e422c5d7 ArgParse: make it easy to have human-readable parameter names (#2312)
This is back-compatible, using argument lists like "--foo %s %s" works
as it always did.

But now the argument type specifier may be followed by an optional
colon (:) and then a human-readable parameter that will be printed in
the help message. For example,

    "--foo %d:WIDTH %d:HEIGHT", ...

indicates that `--foo` takes two integer arguments, and the help message
will be rendered as:

    --foo WIDTH HEIGHT    Set the foo size

I think that makes some of the command line help messages even more clear
and self-documenting.
2019-08-09 15:23:04 -07:00
Larry Gritz b5bb48746b oiiotool --metamerge gives output merged metdata of all inputs (#2311)
Most oiiotool commands copy metadata to their result from their first
input. Using `--metamerge` causes >2 arity image ops to try to merge
metadata from all of its input images (though earlier arguments have
precedence in the case of name clashes).

Also make IBAprep utility have a bitfield flag for the same purpose,
though it's not the mechanism we use for the oiiotool calls.

Along the way, added `ParamValueList::merge()` merges two PVLs together.

Also fixed a couple typos and updated the oiiotool --help message to point
to the new online docs.
2019-08-09 11:26:45 -07:00
Larry Gritz 702013f98e oiiotool internals: overhaul optional modifier processing (#2310)
The recent AttrDelegate and other notational improvements lead to a clearer and
more compact way to express and extract modifiers as ParamValueList instead
of parsed maps of strings.
2019-08-09 11:26:25 -07:00
Larry Gritz ad1ab61a56 Fix rotl for avx512 (#2309) 2019-08-06 09:03:35 -07:00
Алексей e77e5c383d Fix using macroses for Windows targets (#2308) 2019-08-05 08:21:58 -07:00
Larry Gritz 0bbd8a1982 Clarify oiiotool help 2019-08-02 16:42:27 -07:00
Larry Gritz 717b1a7f85 Several small improvements to the ParamValueList / delegate interface (#2297)
* ParamValueList::contains() should be const

* ustring: make an explicit conversion to std::string

* AttrDelegate: make `get<string_view>()` work correctly without
  improperly referencing a temp string whose lifetime is shorter than
  the string_view.

* AttrDelegate: allow default `get()` template to return a string_view. You need
  `get<T>()` to retrieve/convert some other type.

* ParamValueList: have getattribute of string do auto conversion.

If you getattribute() of any non-string type (like an int or float),
it will try hard to convert whatever it finds to that type, even if it
was stored as a different type internally. But if you asked for a
string, it would fail unless it was stored internally as a
string. Make these symmetric by always converting if possible.
2019-08-02 16:41:59 -07:00
ttddee 46583ed4cb Added half_size and user_mul options to rawinput.cpp (#2307) 2019-08-02 15:09:46 -07:00
Larry Gritz eead8fcc89 Remove references to fields deprecated in libraw master (#2306) 2019-08-02 15:07:21 -07:00
Larry Gritz ff2264b929 Appveyor fix
Appveyor updated vcpkg yesterday in a way that breaks things. This effectively
reverts their change until it gets sorted out.
2019-08-02 14:45:08 -07:00
Larry Gritz 41e887549a rotl template, instead of rotl32/rotl64 (#2299)
This matches the C++20 std notation.

Also use the avx512vl intrinsic when available.
2019-08-02 11:32:40 -07:00
Larry Gritz 39e3414801 CHANGES 2019-08-01 21:28:32 -07:00
Алексей 24a7c1218c Some fixes to allow build with mingw (#2304) 2019-08-01 08:07:17 -07:00
Larry Gritz b66073e9f6 Clarify comment of Strutil::splits/splitsv 2019-07-28 22:27:35 -07:00
Larry Gritz 7c31377882 Fix typo in cmake message 2019-07-28 22:27:01 -07:00
Larry Gritz 20da072d71 Strutil::remove_trailing_whitespace(), trim_whitespace() (#2298) 2019-07-28 07:56:31 -07:00
Nathan Rusch afab413640 ImageBufAlgo::fixNonFinite: Fix implicit float/double casts to half (#2301) 2019-07-24 14:11:39 -07:00
Larry Gritz 00921bea82 TIFF fixes: enhance r/w of 6, 14, and 24 bit per sample images. (#2296)
In the process, move some bit depth serializing functions into fmath.h so
we can reuse it. (It's not float math exactly, but it is bit depth conversion,
which for historical reasons we also have here.)
2019-07-24 14:11:01 -07:00
Larry Gritz dfab328086 Fix new dpx test -- we were accidentally allowing oiio version in the ref output 2019-07-24 11:31:32 -07:00
Larry Gritz 449c3cd5ee DPX: add support for 1-channel (luma, etc.) dpx images (#2294)
The bones of it were there, just needed some enabling and realizing
that the ConvertToNative/ConvertToRGB (that were unaware of the
1-channel cases and returned errors) were irrelevant for
single-channel images and should simply be bypassed.

Fixes #2291

Aside: Our output of DPX doesn't currently support compression
properly. Fix that someday? (Our input of compressed DPX is fine.)
But it probably doesn't matter much, since the only compression method
DPX allows is run length encoding, which you would expect performs
poorly on real-world photographic or rendered images with infrequent
runs of identical pixel values. I had not previously appreciated this
fact about DPX.  Why, why does the industry use this terrible format?
2019-07-24 10:11:04 -07:00
Larry Gritz b3949156e6 Fix copyright notice with awkward date construct 2019-07-16 01:23:41 -04:00
Larry Gritz 156919b712 Fix not allocating enough scratch space for cmyk tiff reads (#2292) 2019-07-15 21:30:34 -07:00
Jim Hourihan b5c4d96d8d Work around find_package() failure for newer boost versions with cmake output (#2293)
The FindBoost.cmake interface is broken if it uses boost's installed cmake
output (e.g. boost 1.70.0, cmake <= 3.14) at least in the case that boost
was installed to a non-standard prefix. Specifically it fails to set
variables as indicated in FindBoost.cmake documentation. So until that's
fixed force FindBoost.cmake to use the original path which is consistent
with its docs.
2019-07-15 21:27:35 -07:00
Nathan Rusch 8c56b85de4 [nuke] txWriter knob interface updates (#2290)
- Expose highlight compensation option
- Expose constant color, monochrome, and opaque image detection options
- Remove mostly redundant (and broken) "output stats" knob
- Write OIIO and Nuke version strings to "Software" metadata
2019-07-13 12:01:49 -07:00
Larry Gritz 2e3a61dfe2 In docs generation on rtd, need os.makedirs instead of os.mkdir. 2019-07-12 15:22:17 -07:00
Larry Gritz 88be2dfe45 More docs touch-ups 2019-07-12 11:12:53 -07:00
Larry Gritz abe06efa38 TIFF: subtle bug -- re-opening forgot about rawcolor hint. (#2285)
When scanlines are accessed out of order, to emulate true random access,
sometimes we close the file and re-open. But in this one spot, instead
of calling close_tif() we called close(), and the difference is that close()
also calls init() which resets the options that might have been set by
configuration hints -- such as "oiio:RawColor" and "oiio:UnassociatedAlpha".
In this case, we may want to close/open the TIFF file itself, but we don't
want to "forget" about any configuration hints from the original open call.

The circumstances that led to this being symptomatic are obscure and amusing:

- Scanline TIFF file with CMYK color space, and opened with a
  configuration hint "oiio:RawColor" which causes the CMYK values (4
  chans) to be preserved rather than it all get auto-converted to RGB
  and appear to the app as if it were a 3 channel file.

- The image was held in an ImageCache-backed ImageBuf. And the IC has
  the "autotile" feature turned on (so it will try to break it up into
  tiles in the cache, instead of storing the whole scanline image as a
  single tile).

- An IBA function was running parallelized over multiple threads, and
  it happened that a thread needing a lower part of the image (high
  scanline number) made the request for its tile before another thread
  that needed a tile with lower scanline numbers. This caused the actual
  reads of the scanlines to not be in proper order, therefore necessitating
  a close and re-open of the file.

- Upon the re-open, it had forgotten that "oiio:RawColor" was set, so
  even though the app had asked for the pixels to be written into a 2k
  x 4 chan CMYK buffer, the confused TIFF reader thought it was in the
  mode where it was emulating a 3 channel RGB file. So it would not
  only convert to RGB when it should have left it as cmyk, but since the
  RGB is only 3 channels, the 2048 pixels only filled in the left-most
  1536 (that is, 3/4!) of the value slots in each scanline of the app's
  buffer.

- When running valgrind on the app that was reading the image (for
  unrelated reasons), it was complaining about reading uninitialized
  memory when it would get to pixel 1536, mystifying everybody.

... And I'm so glad today I work on monster movies and cartoons, and not
nuclear power plant control software or life support systems.

Additional fixes included:

* And add a test case

* Python ImageBuf: add constructor that takes a configuration hint spec

* ImageBuf: when adding file to cache, careful with configuration.
If you open an ImageCache-backed ImageBuf, close, then have another
ImageBuf opened later with a different set of "config" hints... you
may not get expected behaviors. Instead, be sure to invalidate it and
add it to the cache in "replace" mode.
2019-07-11 17:31:18 -07:00
Larry Gritz 421d147844 oiiotool: use a shared IC (#2287)
I can't think of any reason why the old code was making a custom
cache, but it interfered with setting certain cache options from
the command line.
2019-07-10 21:03:19 -07:00
Larry Gritz 9d49dd0e2c IBA::computePixelStats was not properly controlling the number of threads. (#2289)
By not passing the nthreads param to the parallel_for_chunked loop,
it was always running fully threaded instead of being controlled by
the nthreads passed to it.
2019-07-10 21:02:56 -07:00
Larry Gritz 92bf8259fd oiiotool -stats not communicating the input configuration hints (#2288) 2019-07-10 21:02:24 -07:00
Larry Gritz 91804df24f iv: Add -rawcolor option to skip auto-convert to RGB (#2286)
For better inspection of raw values of CMYK or other non-RGB color
spaces that would ordinarily be automatically converted.
2019-07-10 21:01:52 -07:00
ThiagoIze 55ffef386a As explained in https://stackoverflow.com/a/32649327, we need to link against rt on linux machines, such as centos 6, that are before glibc 2.17 (#2284) 2019-07-10 16:06:38 -07:00
Larry Gritz 998b950ebd Fix embarrassing ustring::compare(string_view) bug (#2283)
The logic was wrong in cases where the string_view was longer than the
ustring, but they has the same character sequence up to the length of
the ustring.

Add some unit tests to ferret out this case.

To do: fully flesh out unit tests for every last bit of functionality
of ustring and string_view.
2019-07-09 22:44:50 -07:00
Larry Gritz 7348b3487b RLA: fix logic for determining single best type for all channels (#2282)
Previously, any 32 bit channel would force the "single best type" to be float.
But what if it was a 32 bit int?

Instead, use our standard type_merge logic, where we've carefully considered
all the edge cases.
2019-07-09 22:44:32 -07:00
Larry Gritz 0b27ebc66e Update fmt implementation to fix windows warnings (#2280) 2019-07-08 15:53:18 -07:00
Larry Gritz bb73df72bc Make things work on readthedocs
Needed to check in the figures -- we don't want to do an entire build to
generate a working oiiotool just to make docs on runthedocs.

Add sphinxtr extensions for some handy things I want moving forward
2019-07-06 12:42:31 -07:00
Larry Gritz 830d4267b2 Sphinx docs:
* add glossary
* add stdmetadata chapter
* deduce the version automatically from CMakeLists.txt
* working on setup for readthedocs
2019-07-05 09:52:57 -07:00
Larry Gritz 5799f247e0 Docs: Clarify udim metadata retrieval 2019-07-05 09:50:13 -07:00
Larry Gritz 11c03be811 clang-format fixes 2019-07-05 09:47:20 -07:00
marsupial 5216ddefcb Reorder includes for Python.h and POSIX_C_SOURCE macro (#2281) 2019-07-05 09:40:41 -07:00
Larry Gritz 64c034049c Fix inability for python to set timecode (#2279)
It actually boiled down to trouble with setting unsigned int array attribute
from Python int tuples.

Make sure to test this in testsuite/python-imagespec
2019-07-04 12:48:32 -07:00
Larry Gritz 7c050d7d59 Fix formatting from prior commit 2019-07-02 15:28:14 -07:00
Christopher Kulla 483cff53b2 Prevent error messages from getting doubled-up in get_image_info if a handle is created during the call
Minor optimization to how errors are cleared in exists queries
2019-07-02 15:17:38 -07:00
Larry Gritz 65748fdea5 More docs overhaul -- maketx, python bindings, oiiotool, touch-ups on others
Also more work prettifying imagebufalgo.h.
2019-07-02 12:07:22 -07:00
Larry Gritz b3f47645eb vdb reader build pulled in the tbb libraries using wrong CMake variable. (#2274)
Also some adjustments for SPI only for where to find it properly, we
have weird paths.
2019-07-02 08:08:11 -07:00
Larry Gritz 0f2da3fdb5 ociodisplay: let empty display/view names mean to use the default. (#2273) 2019-07-02 08:07:56 -07:00
Larry Gritz 9dcde4e293 Protect simd.h against stray #define of True or False (#2272) 2019-06-27 12:02:48 -07:00
Larry Gritz d25b9fa7f8 New issue templates. (#2271)
GitHub lets you create issue templates, in fact multiple kinds, so
when somebody files an issue they see a menu of the categories. Each
category can have a different template.

I'm making four categories: (1) bug report, (2) feature request, (3)
build problem, and (4) question.

I'm also making it very clear for (3) and (4) that they should not
file an issue at all, but rather use the oiio-dev mail list.

Hopefully this will direct people toward filing more helpful bug reports and
feature requests, and redirect the usual build troubles or usage questions
to the mail list where they belong.
2019-06-26 09:56:27 -07:00
Larry Gritz cbb04a6c4b More Doxygen/Breathe/Sphinx: ImageBufAlgo (#2270) 2019-06-25 21:17:31 -07:00
Larry Gritz c4d020da61 More Sphinx docs: iinfo, iconvert, igrep, idiff 2019-06-22 23:46:33 -07:00
Larry Gritz dd72c6bce2 More Doxygen/Breathe/Sphinx work: ImageBuf 2019-06-22 10:23:44 -07:00
Larry Gritz 2cdc53c21a Resolve environment subimage by name, as we do for texture and texture3d (#2263) 2019-06-21 16:06:52 -07:00
Larry Gritz 3c67faad74 Change copyright notices (#2264)
Replace wordy boilerplate with SPDX license identifier and link to full license.
This is a common practice nowadays, and is a much sleeker appearance IMHO.
2019-06-21 16:06:35 -07:00
Larry Gritz e8f1e6e105 More work on Doxygen/Sphinx docs: TextureSystem (#2265) 2019-06-21 16:06:15 -07:00
Larry Gritz 2c52dbe20c Spruce up ASSERT macros (#2262)
* Use pretty function printing to show what func it failed in.

* Changing wording to more closely match built in assert().

* Make DASSERT simply define to built in assert(), which has the
 advantage compiling without warnings and running correctly with Cuda!
 The ASSERT (works in debug mode as well) and [D]ASSERT_MSG macros
 still are not Cuda friendly because they specifically mention stderr.
2019-06-21 16:06:00 -07:00
Larry Gritz 44fb05c2a0 CONTRIBUTING touch-ups 2019-06-16 20:57:17 -07:00
Larry Gritz 3c55571ae8 Bump in-progress version after developer preview tag 2019-06-12 11:02:45 -07:00
Larry Gritz e26bcf0df3 CHANGES 2019-06-12 10:54:31 -07:00
Larry Gritz 73413b671e LICENSE.md reformat (#2259)
* Slight reformat to make it more automatically discoverable as exactly
  the 3-clause BSD license.

* Change copyright name from "me, et al" to "Contributors to the
  OpenImageIO project."  This is more accurate; it's always been the
  case that copyright belongs to each contributor for their own
  additions, we never have requested copyright assignment. The "et al"
  was supposed to indicate that, but I think taking my name out makes
  it even more clear.
2019-06-12 10:42:03 -07:00
Larry Gritz 87924d9dce More work on doxygen/sphinx docs: ImageCache chapter (#2258) 2019-06-12 10:41:26 -07:00
Larry Gritz 35d00c048a Revise raw processing (#2260)
We were not using certain libraw parameters correctly.

New default behavior is to decode to sRGB (both primaries and
response).  But configuration hints "raw:ColorSpace" can request
various other things, like "ACES" (linear ACES), "Adobe" (Adobe gamut
with 1.8 gamma), and so on. Asking for "linear" gives you sRGB
primaries with linear response.
2019-06-12 10:40:29 -07:00
Larry Gritz 4921f4d402 CHANGES and bump dev release version (forgot to do so before) 2019-06-09 17:57:51 -07:00
Larry Gritz 2f7f287706 gcc9 Travis build and warning fixes (#2257)
* Switch where I get gcc9 from in the Travis setup, the previous one has
  broken (it was a "gcc-latest", which is now an in-progress gcc10).

* Fix a gcc9 warning
2019-06-08 16:05:40 -07:00
Larry Gritz e36f86d720 ColorConfig additions (#2248)
Background: ColorConfig is our wrapper around some OpenColorIO
functionality, so that apps whose only need for OCIO is for the sake
of OIIO color conversion functions, they can go though this thin
interface instead of directly needing to navigate the more complicated
APIs of OCIO. It also allows us to abstract whether OCIO is actually
available, if it's not it understands just a couple hard-coded color
transformations.

* Add getColoSpaceFamilyByName, which was some OCIO functionality we
  did not expose before.

* Add methods that return a vector of strings containing the list of
  all color spaces, looks, displays, or views for a display.

* Expose all this to Python. And add a simple unit test.

* Make sure one Travis test disables OCIO support, so we know what
  breaks under those circumstances.
2019-06-06 17:49:48 -07:00
Larry Gritz dc298a6fda More doxygen/breathe/sphinx/rst: builtinplugins chapter (#2255) 2019-06-06 10:17:14 -07:00
Larry Gritz 871b2ecf84 Fix stof return type error and other windows warnings (#2254)
Submitted on behalf of Patrick Hodoul, with some minor mods by LG.

* Fixes error in return type of stof.

* Add several casts that fix MSVS warnings.
2019-06-06 10:12:15 -07:00
Larry Gritz e82379c934 More doxygen/breathe/sphinx/rst: ImageOutput, Writing Plugins chapters (#2253) 2019-06-05 23:46:00 -07:00
Larry Gritz beb9998deb Fix broken ability to specify compression of multipart exr files (#2252)
Typo! Was grabbing from this->spec before it was assigned, should have
looked in the parameter spec (to OpenEXROutput::spec_to_header).
2019-06-04 15:50:28 -07:00
Larry Gritz dcdffbb4ed SPI only: fixes to how we get certain boost and Python variants (#2249) 2019-06-04 10:11:25 -07:00
Larry Gritz 1e11bff948 More doxygen/breathe/sphinx/rst: Convert ImageOutput chapter (#2250)
A few virtual functions in ImageOutput have had their order changed
for the sake of clearer documentation, and that introduces link
incompatibility in the vtbl.  This is only in master, so we're allowed
to have breaking changes. But just mentioning it so it's noted in the
history.
2019-06-04 10:11:08 -07:00
Larry Gritz 37eaa33a7c Experiment: Try the combination of Doxygen + Sphinx + Breathe + rst (#2247)
Years ago we made Doxygen docs. I hated it, I think they look ugly and
are a poor user experience trying to make sense of them. So at some
point we stopped the charade and let it rust away. Though it lives on
a bit by the fact that I'd already established the habit of using
`///` for documentary comments.

This leaves us with the problem of how to make the header files
self-documenting, while also maintaining the beautiful LaTeX PDF book
that I consider the primary documentation of OIIO. I've been keeping
up as best as I can, but this leads to redundancy of the writing (at
best), and divergence (at worst, which is to say, always).

I'm not a huge fan of "restructured text" (rst), but the documentation
that Sphinx makes is fairly pleasing, it can generate html web pages
and also a PDF (via LaTeX) from the same source material, and I'm
really pleased with other projects that I see use sphinx-generated
documentation hosted on readthedocs.org.

Turns out that there is a Sphinx extension called "Breathe" that will
take Doxygen-generated XML and weave it into a Sphinx doc pretty
nicely.  In short, this allows me to write the book I want (in rst,
though, rather than LaTeX) and simply include by reference the
documentation for specific API calls (anything from a single function
to an entire class), which are taken directly from the header
declarations via Doxygen+Breathe. And in addition to the PDF book, it
simultaneously makes nice looking HTML version of the book, which can
be hosted on readthedocs.

For this PR, I'm not replacing any of the old stuff yet, but I set up
the skeleton of this scheme and convert just a single chapter of the
book.  I'm liking what I see, so I want to commit what I have so
far. Over time, I will convert the other chapters and eventually will
switch permanently to this scheme, assuming I don't discover a
horrible unintended consequence of this.

In the process of getting this first chapter done -- which happens to
be the one about helper classes like ImageSpec, TypeDesc, ustring,
etc. -- I did some very heavy editing of the header comments. No code
changes, but a LOT of beefed up comments, brining them into sync with
what was in the full latex documentation.
2019-06-02 08:15:30 -07:00
Larry Gritz b9f6e389ec TypeDesc: Beef up doxygen-like comments (#2245)
Also re-jigger some of the constructors to make them a little compact
by more liberally using default argument values and delegated
constructors.
2019-05-31 15:30:17 -07:00
Larry Gritz f16725978b oiiotool --ch did not honor allsubimages=1 modifier (#2242)
It worked with the global -a, but not the customary `:allsubimages=1`
modifier to that individual command. Either is supposed to make it
apply the channel shuffling to all subimages of a multi-subimage file
(for example, a multipart exr file).
2019-05-31 15:26:17 -07:00
Larry Gritz 4b9e6f440a More 'noexcept' marking (#2243) 2019-05-31 15:25:50 -07:00
Larry Gritz 51f784b93c Fix: somehow forgot to add crash stacktrace to oiiotool (#2244)
Also fix warning if symbol is already defined.
2019-05-30 11:22:20 -07:00
Larry Gritz 4878653a51 ImageBuf::set_write_format -- extend to per-format (#2239)
`ImageBuf::set_write_format` took just a single TypeDesc to set the
pixel data type that would be used when the file writes. But there was
not a simple way to specify per-channel data types from the ImageBuf
API (it could be easily done with raw ImageOutput).

This patch extends `set_write_format` to take a `cspan<TypeDesc>`
which could be a single type, as before, or a span of type that gives
the per-channel request.
2019-05-26 15:02:26 -07:00
Larry Gritz c09dd957d7 Fix docs typos 2019-05-24 20:54:15 -07:00
Larry Gritz fa3cc55847 Update llvm path on Travis OSX 2019-05-20 00:41:31 -07:00
Larry Gritz 1d653b61e0 Adjust boost gcd based on version (#2238)
The GCD functionality moved several versions ago, from boost::math to
boost::integer. It's been "replicated" in both places for a while, but
at least on 1.69, it issues warnings. At some point it will be
permanently moved. So let's get out ahead of that potential breakage.
2019-05-18 12:07:47 -07:00
Larry Gritz d9fbe1e359 Straighten out construction of ImageBuf from spec -- zero or not? (#2237)
* Straighten out construction of ImageBuf from spec -- zero or not?

* Docs, header, and implementation were not all consistent about
  whether the ImageBuf construct-from-ImageSpec (or the `reset()` call
  of the same flavor) zeroes out the newly allocated buffer, or if the
  pixel values are left uninitialized.

* Change the call signature to take an optional `zero` parameter -- which
  defaults to true, meaning that the pixels are zeroed out when allocated
  (this is the foolproof approach, at the cost of writing all the memory
  of the buffer). If zero==false, the newly allocated pixels will remain
  uninitialized (this is for power users who want to maximize performance
  when they know that they will soon overwrite all the vaues in the buffer
  and want to avoid any unnecessary writes).

* Touch up the docs and header comments to be consistent and explain the
  behavior correctly.

* Revision: use an enum instead of a bool
2019-05-13 14:13:18 -07:00
Larry Gritz 0f094d81f5 Adjustment to convert_type/convert_types functions (#2236)
I realized that there is a convert_type function in typedesc.h and a
convert_types function in imageio.h that are subtly and confusinginly
different in their meaning and arguments.

* Expand typedesc.h `convert_type()` to take an optional number of
  values parameter (defaulting to 1, old behavior of converting one
  value).

* Rename imageio.h `convert_types()` to `convert_pixel_values()` and
  clarify comments to emphasize the important differece -- that this
  one is dealing with pixel-like normalized values (e.g., the max
  value of an int-like type corresponds to float 1.0).

So you should use convert_type to do a straightforward "cast" of the
value from one data type to the same value in another data type, but
convert_pixel_values to convert a pixel-like intensity to the
equivalent normalized intensity in a different pixel data type.
2019-05-13 14:12:39 -07:00
Larry Gritz b000e5d313 Defensive programming to prevent integer overflow for large images (#2232)
Sometimes for very large images, either the number of pixels (w * h * d)
or the total data size (npixels * pixelbytes) can overflow int32 math.
Find several places where this may be a problem and use casts to ensure
64 bit multiplication.

I don't claim this is a comprehensive fix, but I did a cursory check of
some obvious places and found these to squash.
2019-05-11 20:19:03 -07:00
Larry Gritz 24c9cc3972 Get TIFF pics from http not ftp, it seems down 2019-05-11 08:52:56 -07:00
Larry Gritz b2dd2e1eed Add gcc9 to TravisCI matrix and fix gcc9 new warnings. (#2235) 2019-05-08 21:38:51 -07:00
Larry Gritz 49d5a45469 Travis overhaul for xenial (#2234)
* Switch to new TravisCI default 'xenial' ('trusty' is end of life)

* Install Travis linux dependencies per-matrix-entry. This should also
  save some build time because we are only installing gcc versions used
  for each test, as opposed to all tests needing to install all versions.

* Force 'trusty' for the test matrix entries that tries to approximate
  VFX Platform 2017, which uses gcc48. That's because xenial's libraries
  for the most part all use gcc 6 and the new string ABI, so it's a huge
  pain to use gcc 4.8. It can probably be made to work, but it's a lot
  of trouble and I gave up. We'll retire trusty when we retire support
  for gcc 4.8 and C++11. Note that VFXPlatformm 2018 (and 2019 and the
  draft for 2020) specify gcc 6.3 and C++14.

* Some revisions to the FindOpenEXR.cmake to get it working properly
  on Trusty. The most important issue is that pkgconfig should only
  be used if there is no manual override on `ILMBASE_ROOT_DIR` or
  `OPENEXR_ROOT_DIR`.
2019-05-07 14:17:56 -07:00
Larry Gritz bcbd6f460e CHANGES 2019-05-07 11:01:59 -07:00
Larry Gritz 3bd4f3204a Fix docs typo
Fixes #2233
2019-05-07 10:40:44 -07:00
Larry Gritz ab1dc2e669 Fix IOProxy::pread on Windows that botched PNG & JPEG read (#2231)
We've been plagued by recently-introduced bugs with PNG and JPEG
reading that stemmed from the first IOProxy-related patch.  The
problem was our use of the Windows ReadFile call, which seems to not
preserve the file pointer as we'd assumed (the MSDN docs are ambiguous
about this). I also began to doubt its thread safety, so in the end I
just replace the code with a simpler approach with a mutex and calls
to tell/seek/read.

Same changes to pwrite implementation.
2019-05-03 17:44:37 -07:00
Larry Gritz 1a857b75d8 Rebuild PDF docs 2019-05-01 18:26:02 -07:00
Larry Gritz fddbde5dae CHANGES and docs 2019-05-01 18:26:02 -07:00
Larry Gritz 248bd88179 Remove confusing deprecated Python call (#2228) 2019-04-30 17:51:07 -07:00
Larry Gritz 04d15611ba Sysutil: add utilities to get stack traces (#2229)
Set up signal handlers in all the command line utils so that if they
crash, they will print stack traces that will help track down CI or
user-side failure cases.

This relies on Boost >= 1.65 for its stacktrace library. When built
against older versions of boost, stacktrace() will return an empty
string and the stacktrace-printing signal handlers will have no
effect.  C'est la vie.
2019-04-30 17:49:23 -07:00
Larry Gritz 835cdd9343 Fix coredump bug from 2223 (#2227) 2019-04-30 14:47:43 -07:00
Larry Gritz cb39fa4bdd oiiotool: Fix resize and resample to honor -a and handle subimages (#2219) 2019-04-30 11:17:19 -07:00
Larry Gritz 7f452c8ff7 IC/TS: Count number of gettextureinfo calls like we do for texture, etc. (#2223) 2019-04-29 10:15:46 -07:00
Larry Gritz a6a9d38d8e Fix memory leak in AttrDelegate::as_string (#2220) 2019-04-27 21:23:42 -07:00
Larry Gritz 7b3cac4755 Fix test_paramlist output to be uniform across platforms / python versions (#2222)
Default was printing different number of digits of precision on
different python versions. So be specific about the format for floats
to get uniform test output on all platforms.
2019-04-27 15:11:41 -07:00
Larry Gritz 0a1c8627f8 Fix Travis -- broke ability for broken build to error (#2221) 2019-04-27 09:38:15 -07:00
Larry Gritz d2ac60011f Enhancements to the syntax for setting and retrieving attributes. (#2204)
Lots of important classes have "attributes", which are used as option
settings and the like, basically any kind of named/typed data that
objects carry around. The prototypical way we set and retrieve them
is:

    obj.attribute (name, typedesc, &data);
    found_ok = obj.getattribute (name, typedesc, &data);

This is very general, but it's kind of a wonky syntax. So this patch
introduces an additional synax that is super handy and aesthetically
pleasing:

    obj[name] = data;     // set, works for nearly any data!

    data = obj[name]->get<type>();   // any type
    mystring = obj[name];            // turns any data into a string

This magic is accomplished with a helper template called an
AttrDelegate, which we define in attrdelegate.h. This is pretty handy
and we anticipate using it more widely over time, as we add this syntax
to additional classes.

The first class we rig up in this way is ParamValueList, which
necessitates adding attribute() and getattribute() methods to begin
with. It's a natural fit, and you can get a feel for how it looks when
used by examining the new unit tests in paramlist_test.cpp.

Also added to ImageSpec, for which I think this will be a handy new
way to set and retrieve metadata.

There's a bunch more cleanup that should be fairly straightforward to
understand.

Also, we expose two new functions (pieces of which were used internally
before, though we have now made them public and refactored them):

    std::string tostring (typedesc, void* data,
                          const tostring_foratting& fmt={})

        Turns any data (described by the typedesc) into a string,
        with optional fine-grained control over the formatting.

    bool convert_type (TypeDesc srctype, const void* src,
                       TypeDesc dsttype, void* dst)

        Copies with data conversion.
2019-04-22 17:33:16 -07:00
Larry Gritz 1e805ed704 Fix ZLIB references (#2216)
* Correct use of ZLIB_INCLUDE_DIRS (not ZLIB_INCLUDE_DIR!).
* Only add include dirs for modules that need it.
* Also, change from obsolete PNG_INCLUDE_DIR to correct PNG_INCLUDE_DIRS.
2019-04-22 11:11:50 -07:00
Larry Gritz 0867e3cbd5 simd: add vbool ctrs from ints, avoiding windows warning about cast. (#2213) 2019-04-22 10:38:32 -07:00
Larry Gritz 17fdb24464 Fix compiler warnings on windows (#2214) 2019-04-22 10:33:17 -07:00
Larry Gritz 0415876f36 Travis: Fix clang-format test (#2212)
Oops, a few merges ago I changed the .travis.yml to "source" the
install_homebrew_deps.bash script (instead of making a subshell)
and this caused the "exit 0" early out in it to not just terminate
that script as intended, but to terminate the entire Travis test,
making it look like it passed even though it never got around to
running clang-format at all. Oh dear.

This fixes it. It also uncovers a few minor formatting changes
we should have made over the last few days, but missed.
2019-04-18 23:22:33 -07:00
Larry Gritz 283d744b87 Fix warning on Windows (#2209) 2019-04-18 10:08:03 -07:00
Larry Gritz 33a5a719bf IBA::resize -- fix precision for double images (#2211)
The innards of IBA::resize() has to accumulate the weighted
contributions of source pixels under the filter window, and that
accumulator used 'float'. This is fine except when the input image is
'double', in which case you might want just a touch more precision.

So we define an Accum_t typedef template that is double when double is
needed, and float for all other cases. Adds the precision that double
image resize needs, but retains the speed and precision of the prior
float behavior in all other cases.
2019-04-17 10:08:25 -07:00
Larry Gritz b32cc4edde Minor CI-related touch-ups, synchronize scripts with OSL 2019-04-15 07:46:35 -07:00
Larry Gritz 0105abd340 Add CII best practices and CircleCI status badges to main README
For anybody who doesn't know, CII is the Core Infrastructure
Initiative, which is a post-Heartbleed initiative to make sure that
critical (and really, any) open source projects are following best
development and security practices. The badge says the percentage of
their guidelines that we are currently following (you can click on it
to see exactly which ones), as we work toward full compliance.  More
info can be found here:
https://bestpractices.coreinfrastructure.org/en

[ci skip]
2019-04-12 11:32:51 -07:00
Larry Gritz 28f80864aa Fix crash reading certain old nconvert-written tiff files (#2207) 2019-04-12 10:48:16 -07:00
Larry Gritz 4ab496cf1b Revert "Fix crash reading certain old nconvert-written tiff files (#2206)"
This reverts commit 2203165543.
2019-04-11 18:01:08 -07:00
Larry Gritz 2203165543 Fix crash reading certain old nconvert-written tiff files (#2206)
I don't claim to understand exactly why is is problematic, but certain
files written by an older versin of "nconvert" have something strange
about their tags that was leading to a crash. Solved with use of
our existing safe_tiffgetfield() versus TIFFGetField when retrieving
the PREDICTOR tag.

Also refactored safe_tiffgetfield a bit so that for the calls that
"fail" (results are ignored), it doesn't overwrite the results. Do this
by retrieving into a temp buffer and then copying to the caller's
memory upon success.

TODO: How many other TIFFGetField calls ought to be replaced by
safe_tiffgetfield? All? Some? What are the circumstances that lead to
this inexplicable problem? Is there a better tag-reading idiom we
should be using? Investigating this on all on the side, but it need
not hold up this immediate fix to the one known problem case.
2019-04-10 21:34:01 -07:00
Larry Gritz 2162837b3c Better oiiotool support of multiple subimages (#2202)
Background:

By default, most oiiotool operations ignore multiple subimages. For
commands that modify metadata in place, that means it will only modify
the first subimage (leaving the rest untouched). For commands that
remove inputs from the stack and produce outputs to be put back on the
stack, generally their output will only be based on the first
subimage, and subsequent subimages will be dropped.

`-a` says that any ops ought to work on all subimages if at all
possible; that means that in-place metadata modifiers will apply to
all subimages, and stack ops should produce outputs with the same
number of subimages as their inputs, doing the right operation to each
subimage in turn.

Most commands (but not 100%) also respect an optional
`:allsubimages=VAL` that override `-a` on that one command, `=1` turns it
on even if you didn't use `-a`, and `=0` turns it off even if you did use
`-a`.

My goal is to make all commands respect the `-a` and `:allsubimages=VAL`
options, in all cases except where there is no sensible interpretation
to multiple subimages. There are a few now where there is a sensible
behavior, but it's just not implemented.

This patch fixes the following:

* These commands previously honored `-a` but did not respect a
  ":allsubimages=" modifier, but now they do:
    --sattrib   --attrib   --caption   --clear-keywords
    --iscolorspace  --orientation  --clamp  --fixnan

* These were totally unaware of subimages, neither responding to -a
  nor to ":allsubimages=", now they respect both:
    --crop  --fullsize  --zover  --fill

* These previously always operated on all subimages, but now work on
  only one subimage by default (like the rest) and respect the -a and
  ":allsubimages=" modifier:
    --origin   --fullpixels  --croptofull  --trim
2019-04-05 14:29:12 -07:00
Larry Gritz 1482c914ba Make OIIO_DISPATCH_COMMON_TYPES2/3 handle more type combinations. (#2203)
Internal to ImageBufAlgo functions, we are faced with the fact that we
have 1, 2, or 3 input images in addition to an output image, and they
each could be any of the 9 pixel data types we support (float, uint8,
uint16, half, int8, int16, uint, int, double).  This means that the
template expansion of all possible combination would tend to be 9^2=81
specializations for unary functions, 9^3=729 for binary functions, and
9^4=6561 for ternary functions (I think mad() is the only ternary
function we have).

This is unworkable, leads to infeasible compilation times, so for a
long time we have made the following shortcut: handle the full
cross-product of just the 4 commonly used types (uint8, uint16, float,
half), and in all other cases convert to and from float. So that means
unary needs 16 template specializations, binary 64, and ternary 256.

But... other cases do crop up, so with this patch, I'm expanding the
range of cases that OIIO_DISPATCH_COMMON handles without
conversion. If all of the types (result, and inputs) are identical, we
handle it with the native type. This is only slightly more expensive:
unary functions need 9+12=21 template specializations (why 12 instead
of 16? because 4 combinations are already handled by the "all same type"
case, and therefore don't need to be instantiated again), binary
functions need 9+60=69, and ternary 9+252=261.

We think that, outside the "common" cases, the most common uncommon
ones are the "all types the same" cases. So accommodating this seems
worth the slight increase in compile time, which is nowhere near the
combinatorial explosion of the full cross-product of all types,
and in the process we make it even more rare that we fall into the
"plan B" case of converting to and from float to handle the rare
oddball cases.
2019-04-05 09:42:46 -07:00
Larry Gritz 105f4abd64 Rename pow2roundup/pow2rounddown -> ceil2, floor2 (#2199)
This is in keeping with the nomenclature of the C++20 <bit> header which
contains the equivalent functions.

Also give them the constexpr and noexcept treatment.
2019-03-30 11:00:04 -07:00
Larry Gritz 3e106c3584 Adjustments from clang-format update 2019-03-30 10:08:38 -07:00
Brecht Van Lommel cad4ad5404 Add USE_WEBP option to disable building WebP. (#2200) 2019-03-29 07:17:40 -07:00
Larry Gritz 4dcec80203 Fix for #2195: forgot to include strutil.h 2019-03-21 19:22:01 -07:00
Larry Gritz 917bebf7da Timer dtr print, change from stream I/O to Strutil::printf (#2195)
Strutil::printf does its underlying output atomically, so if these
destructors are triggered from multiple threads, they won't get
"interleaved" on the terminal, making them unreadable, as they would be
with ordinary stream output.
2019-03-21 17:21:45 -07:00
marsupial 384678a8c5 Forward ProgressCallback in ImageBufImpl::read (#2196) 2019-03-18 11:31:30 -07:00
marsupial 40511558d4 Make OIIO:invert a host/device function (#2197) 2019-03-18 10:59:21 -07:00
Larry Gritz 735e07183e CircleCI - prototype (#2194)
A bit of material has been refactored out of .travis.yml into separate
scripts so it can be shared with circleci.

CircleCI is an alternative CI system like TravisCI or Appveyor.
Mostly I'm doing this as a prototype and to learn about it, because
it's under discussion as a potential favored CI system for ASWF.

But as it turns out, the VMs provisioned by CircleCI are more capable
CPUs than the ones with Travis. In particular, it looks like they
support AVX-512. Right now, the Travis VMs top out at AVX 1.0, so
although we have Travis test matrix entries that "build" for AVX2 and
AVX512 just to make sure we haven't broken the build, we aren't able
to run the tests when compiled for that architecture. But we can on
CircleCI. So I'm thinking of throwing CircleCI into the mix just for
certain build configurations that aren't possible with Travis, to get
better test coverage.
2019-03-15 23:05:44 -07:00
Larry Gritz 02640c5a70 Argparse -- add test, %1 (#2192)
ArgParse had no unit test! Add one.

Also, add a new feature: %1 is like %* (catch-all for all
miscalleneous arguments that aren't dash-led commands and their
following data).  But if %1 is present, its list will receive any
arguments that come BEFORE any other dash-led args, whereas the %*
will receive all the misc args that happen after the first dash-led
arg. If there is no %1, then %* will capture all the misc args
regardless of whether they are before or after the first dash-led arg.

Why is this useful? So you can have programs that require certain
arguments before any options. Like "git add ..." "git rm ...", you
would achieve something like that via:

    std::string mode;
    std::string files;

    static int
    callback(int argc, const char* argv[])
    {
        for (int i = 0; i < argc; i++)
            files.emplace_back(argv[i]);
        return 0;
    }

    static int
    mode_callback(int argc, const char* argv[])
    {
        if (mode == "" && argc == 2)
            mode = std::string(argv[1]);
        else
            callback(argc, argv);
        return 0;
    }

    ArgParse ap;
    ap.options(
        "My git replacement",
        "%1", initial_callback, "",
        "%*", callback, "",
        ...
        nullptr);
    std::cout << "Mode was " << mode << "\n";
    std::cout << "Files were: " << Strutil::join(files, ", ") << "\n";
2019-03-13 23:18:22 -07:00
Larry Gritz dcb5b45633 strutil_test -- guard against locale exception
Especially for CI or users systems that don't have the oddball locale
we used for some testing, make sure the tests complete rather than
crash with local exceptions.
2019-03-13 21:40:14 -07:00
Larry Gritz 1c9d5d5509 Appveyor: use pre-installed Qt and upgrade Boost to 1.66 2019-03-12 22:37:16 -07:00
Larry Gritz 8bc946e14d Revise commented-out debugging in fixholes-pushpull 2019-03-09 13:46:03 -08:00
Larry Gritz d4a88aa43c Uniformize 'could not open' messages across all writers (2189) 2019-03-09 13:27:07 -08:00
Larry Gritz 7ec7c61e6f Systematically test output formats for writing unwriteable file (2189)
Augment imageinout_test to try to write each format to a path that
includes a nonexistant directory (to test generally what happens when
asked to write to a place that doesn't exist or doesn't have write
permissions).

Also a bunch of other refactoring of imageinout_test.

This turned up failures in several format writers:
* DPX crashed (solved with PR #2186)
* HEIF silently failed, not returning any errors for this condition
  (solved with PR #2188)
* PNG silently failed (solved with PR #2187)
* JPG silently failed and sometimes crashed (solved with PR #2187)
2019-03-09 13:27:07 -08:00
Larry Gritz 47404a0b1e IOFile: did not properly set m_mode upon open failure. (#2187)
One consequence is that format readers or writers that relied on
IOFile (such as PNG and JPEG) would not properly notice certain I/O
errors.

This failure of JPEG masked a minor bug in the JPEG reader where we
could destroy the compressor that had never been created (crashing
inside jpeg library).
2019-03-07 17:38:48 -08:00
Larry Gritz b5b7df4b2f heif output: catch write errors (#2188)
Turns out that libheif's `write_to_file()` does not throw exceptions
upon write errors, as it is advertised to do. Solve by using the more
general `write()` that takes a custom Writer class.
2019-03-06 22:15:24 -08:00
Larry Gritz 014dce9c9f exr read: suppress empty string submage name (#2190)
It's been reported that V-Ray writes images with this metadata field
present but empty. If you happen to take those images (and their
metadata) and turn them into a multi-part exr, the names all being the
same is problematic. The expedient fix is just to ignore empty names
on input.  Suggested by Chris Allen.
2019-03-05 17:05:22 -08:00
Larry Gritz 923f30eb86 docs 2019-03-05 16:27:33 -08:00
Larry Gritz d6c936834b DPX: fix crash when file open fails (#2186) 2019-03-05 16:12:44 -08:00
Larry Gritz e598f8dd90 Fix failure to II/IO::create() the format name itself. (#2185)
ImageInput::create(name) and ImageOutput::create(name) are supposed to
create a new II or IO for given name, which can be a filename (such as
"foo.exr", the extension determines the format), or just an extension
(such as "exr"), or the name of the format itself (such as "openexr").

Except that the latter didn't work, due to a botched test of whether
the format name was already in the table. This has been a bug for
many years, so it seems!
2019-03-05 10:58:58 -08:00
Larry Gritz 6ac851999e TS: Fix possible nullptr dereference (#2184)
find_file() assumes a non-null thread_info parameter.  But it's called
from get_image_handle in a way that could pass a null pointer. Fix.

Fixes #2179
2019-03-02 15:56:42 -08:00
Larry Gritz 7677d498b5 More work on IOProxy support (#2180)
* Add read-from-memory for JPEG.
* Add ioproxy read to PNG (only write was supported before).
* Had forgotten before to add correct supports("ioproxy") response to exr
  and PNG.
2019-03-01 22:05:47 -08:00
Larry Gritz e1979ac66c imageinout_test -- test every format (#2181)
Added a new unit test, imageinout_test, which for every supported
format writes an image file, reads it back and makes sure it matches
the original.  For formats supporting "ioproxy", it also writes to
memory and makes sure it matches the disk file, and reads from memory
and makes sure it gets the original pixels back. I removed the
hard-coded tests for ioproxy on png and exr, this is more
comprehensive.

Over time, I'll add more to this test. It's a good central place to
test behaviors that should work for all formats.
2019-03-01 18:02:38 -08:00
Larry Gritz a7e97500f6 Turn off openjpeg < 2.0 when EMBEDPLUGINS=0 -- buggy (#2183)
Some new unit tests show crashes inside libopenjpeg, but only for
libjpeg<2.0 and only when we build with EMBEDPLUGINS=0 (apparently
it's fine when =1, which is the default, I don't know why).

I have no particular desire to try to track this down, especially
since it requires the combination of an obsolete version of libjpeg,
and a build mode that probably very few people use. So I'm taking the
easy way out: just disable jpeg2000 suppor for this unusual
combination.  If you need EMBEDPLUGINS=0 and care about openjpeg,
upgrade to 2.0.
2019-02-28 11:21:56 -08:00
Larry Gritz b19b3fd879 Asan-revealed bug touched beyond the bound of allocation (#2182) 2019-02-28 11:18:03 -08:00
Larry Gritz 5b65b3e3e4 SPI build script revisions, mostly for boost (#2177)
Non-SPI people can ignore this.

The motivation was to let us switch between several Boost versions,
including a new layout for our local boost install. But I took the
time to do a bunch of cleanup on the spi Makefile-bits.
2019-02-25 16:27:18 -08:00
Larry Gritz df8db4d592 Fixes to FITS file support
Upon reading FITS specs, I realized that 16 and 32 bit int pixels in
FITS are signed, not usigned. Also beefed up our support for what
appear to be multi-channel FITS files and other oddities in the
image dimensions.
2019-02-23 11:54:56 -08:00
Larry Gritz 3c4a7af184 TextureSystem option to limit mip levels
This patch adds a "max_mip_res" attribute for the TextureSystem that
limits filtered texture access to MIP levels that are no higher than
this resolution in any dimension. The default is 1<<30, which means
there is no effective limit. As an example, setting this attribute to
256 means that all texture access will be limited to the MIP levels
that are 256x256 pixels or lower. This can be useful for preview
renders where you want to cut down on the amount of disk or network
access for the sake of speed.

In a subsequent patch, I intend to also provide a way to set this
on a per-texture basis, but as a first step we'll start with the
global setting.
2019-02-20 10:55:35 -08:00
Larry Gritz 607c8dd6f1 Restore runtest.py ability to run from inside the individual test dir.
Restore its ability to run by hand from inside the
build/PLATFORM/testsuite/TEST directory, which had been lost recently
with some overhaul to the testing scripts.
2019-02-18 21:19:53 -08:00
Larry Gritz c9a0ba0322 Bump dev snapshot release number 2019-02-13 16:59:18 -08:00
Larry Gritz 0d4dbf464e CHANGES 2019-02-13 16:58:49 -08:00
Larry Gritz a70733e243 SPI: bump spcomp2 version 2019-02-13 15:46:14 -08:00
Larry Gritz 7cf6ff4f3b Avoid std::regex_replace (2173)
Certain regex_replace tasks seem to crash on Windows with MSVS's
implementation of std::regex.

After considering a more sophisticated test for when we should use
boost.regex instead, I instead settled on just replacing the few uses
of regex_replace with our own string processing. None were very
sophisticated or truly needed regex functionality.
2019-02-11 14:33:32 -08:00
Larry Gritz 339bdde3bf Strutil::excise_string_after_head (2173)
Utility to excise from a string a literal pattern, and whatever
non-whitespace characters follow it.
2019-02-11 14:33:32 -08:00
Larry Gritz 76cddc2ed8 oiiotool -o:all=1 : don't crash outputting 0x0 subimages (#2171) 2019-02-11 12:13:33 -08:00
Larry Gritz 4798ce7213 PSD read: properly extract layer/subimage name and data window offset coords (#2170) 2019-02-11 12:11:40 -08:00
Larry Gritz 037d674228 Color transform by matrix (#2168)
`IBA::colormatrixtransform()` uses a 4x4 matrix to apply a color
transform to all pixels in the image region. The matrix is, following
Imath, OpenGL, and RenderMan-ish conventions, laid out in the order
that assumes row-vector colors and does math as C' = C*M. (Another way
to put that is that the "translation" part of the matrix is the bottom
row, not the right column.)

`oiiotool --ccmatrix` does the same thing from the command line, and
is followed by an argument containing either 9 or 16 comma-separated
values to form a 3x3 or 4x4 matrix. (If 3x3, it will be extended in
the obvious way to 4x4 before passing to the underlying
colormatrixtransform() call.  Additionally, the `--ccmatrix` command
takes optional arguments that will first invert the matrix or use its
transpose (the latter in case you are given matrix values in an order
that implies column-vector colors).
2019-02-11 12:07:37 -08:00
Larry Gritz e50e794fa3 IB: Fix bug in propagating unassociated alpha behavior request (#2172)
The unassociated alpha handling setting of the ImageCache was
overriding the setting specific to the ImageBuf itself, for the path
where for "forced" reads bypass the cache. Good intentions to still
honor the IC setting, but IB-specific request should take precedent.
2019-02-11 12:05:31 -08:00
Larry Gritz e819ad0e29 License documentation that we missed 2019-02-09 16:32:33 -08:00
Larry Gritz 370264335a PNG: more careful catching of errors and corrupt png files (#2167) 2019-02-09 10:58:24 -08:00
Larry Gritz b66797aa93 simd.h: vec4 * matrix44 multiplication (#2165)
Also remove some conditionally-compiled clauses for Ilmbase 1.x. We've
had OpenEXR/Ilmbase 2.0+ as a minimum since OIIO 1.8.
2019-02-05 13:12:07 -08:00
Larry Gritz 3221001287 Improve precision of unpremult/premult of color conversion (#2164)
The fast_rcp had the strange effect of turning alpha=1 into alpha=0.99999994.
Ick!
2019-02-05 13:11:51 -08:00
Larry Gritz 40e2db598c Fix bug in IC::invalidate() (#2166)
When we recently made invalidate(file) have a 'force' parameter, we
botched it by not so forcing a particular call in invalidate_all().
In the line being changed here, we're dealing with a list of files
that definitely need invalidation due to special tests, so once
we've established that, we want to force it.

Pointed out by @ThiagoIze in a post-merge comment in #2133
2019-02-05 10:53:37 -08:00
Larry Gritz 7d4fe6179a Docs typo fix 2019-02-04 15:07:14 -08:00
Larry Gritz de70a17700 Update ref output 2019-02-04 12:16:19 -08:00
Larry Gritz 759f5ae994 SPI only: Coalesce the arnold and spcomp2 scripts into just one (#2162)
Build for SPI Arnold:

    make

Build for SpComp2:

    make OIIO_SPCOMP2=1 spcomp2
  or
    make OIIO_SPCOMP2=1 spcomp2_install_local

Build completely generic, avoiding any special Arnold build logic:

    make OIIO_ARNOLD=0

I know that the diffs are difficult to follow in this format. But
basically I was starting from a point where site/spi/Makefile-bits just
looked at the build targets, and if they looked like spcomp2 stuff, it
would include Makefile-bits-spcomp2, and otherwise would include
Makefile-bits-arnold.  Those two files were already pretty similar,
lined up well in the diffs.  So I just merged them, hiding the few
differences between them in conditionals, and then moved the result to
just plain old Makefile-bits and got rid of the separate customized
files. In reality, if you were to diff the new one to either one of the
old ones, it would be pretty close, with the obvious changes to merge
in the missing parts of the other.
2019-02-02 10:14:18 -08:00
etiam e58bf038ba Add support for pkgconfig. (#2158)
Use cmake's configure_file() and src/build-scripts/OpenImageIO.pc.in file for pkgconfig.
2019-02-02 08:50:32 -08:00
Larry Gritz 61b76f87cf Sprinkle noexcept widely over many of the core utility classes (#2156)
It shouldn't change anything about how you use these. Just marking a bunch
of things that already didn't/couldn't throw exceptions as 'noexcept'.

There will be more of this moving forward, I'm just getting some basic
classes now.
2019-01-27 16:54:00 -08:00
Fredrik Averpil bb2c617e83 Add ability to control Python version (#2161)
Set environment variable `OIIO_PYTHON_VERSION` to e.g. 3.6 to use Python 3.6.
2019-01-26 14:57:35 -08:00
Larry Gritz 569095b6c0 SPI: bump SpComp2 release number and update which clang we use
Also properly rpath the libs we need for HEIC support.
2019-01-25 15:10:06 -08:00
Larry Gritz c3d0d105c7 CHANGES
[ci skip]
2019-01-24 14:10:28 -08:00
Larry Gritz 628c12de20 HEIF support (#2160)
HEIF is a container for HEIC-compressed images. HEIC is the still image
sibling to HEVC video compression. Roughly speaking, it produces lossy
compressed images about half the file size of JPEGs but with higher
visual quality.

At the moment, it's hard to find software that will reliably read
heic/heif, except for recent cuts of software within the Apple ecosystem
(the only ones I've encountered so far are iPhone camera images). But
that will surely change, since it's a superior format to JPEG in many
ways.

This is the first stab at supporting heif/heic images using the open
source libheif.  I'm fairly confident in the reading, including exif
metadata, of RGB and RGBA images, including files with multiple images.
I've not yet figured out depth images.

This can also write images (but only single images per file, RGB or
RGBA), and although the exif metadata I write can be read again by
OIIO's heif reader, Apple's Preview.app does not recognize the metadata
for some reason. I don't know why, maybe I'll return to that later.
I also want to fix later the limitation of not being able to output
multi-image heif files.

Along the way, I converted decode_xmp() utility to be based on
string_view, and also changed encode_exif() to take an explicit
'endianreq' parameter so it's possible to request a specific
endianness. (Apple's Preview.app, which is the main way I was able to
test whether I'm writing them correctly, *requires* that the exif be
written as big endian, or it won't recognize the file as proper heic at
all. So that required some extensive changes in my exif blob code.)

The latest release of libheif, 1.3, doesn't fully support color
profiles.  The in-progress libheif master (future 1.4) does, so I'll add
support when that is released. For now, it always looks like sRGB, and
that seems to be the common case, but it can be incorrect.

Currently, we only will read and write uint8 pixel data. The libheif
authors are working on full support for HDR/extended range, but that's
not even merged into its master yet. I'll add support in the OIIO heif
reader as that gets merged into libheif releases.
2019-01-24 13:23:17 -08:00
Larry Gritz 74bd703308 iv info window: sort metadata, like we do for 'oiiotool -info' (#2159) 2019-01-24 13:22:23 -08:00
Larry Gritz c538fa006a OpenVDB build finding touch-ups (#2155)
Fix some vdb issues, including the fact that we weren't previously
detecting the version, and therefore not properly erroring for vdb
versions too old. Also a variety of other minor fixes and minor
refactorings.
2019-01-23 14:59:55 -08:00
Larry Gritz 1d35b92b69 Fix strided_ptr inc/dec return value mistakes (#2154) 2019-01-23 14:59:17 -08:00
Larry Gritz 77b8fb65be SPI: update which nuke we link against 2019-01-23 12:30:30 -08:00
Larry Gritz 8d0286741d simd: get rid of suspicious and useless constructor cruft (#2152) 2019-01-21 12:33:13 -08:00
Larry Gritz 71c3e6057d Fix potential memory leak found by static analyzer (#2153) 2019-01-21 12:32:46 -08:00
Larry Gritz 2383bfb248 platform.h: Clean up attribute comments and add OIIO_RETURN_NONNULL (#2150) 2019-01-20 15:31:40 -08:00
Larry Gritz fa7dc58331 Dead statement removal 2019-01-20 13:46:28 -08:00
Larry Gritz 034ed83160 OSX Mojave gives rude messages about OpenGL being deprecated (#2151)
Defining this symbol turns it off. Somewhere on my list is to remove the
OGL dependency from iv, but this band-aid will help until I get some
free time for that.
2019-01-19 22:30:28 -08:00
Larry Gritz 08954fd6e6 Bug: fixed possible null ptr dereference (#2149)
Found from static analysis!
2019-01-16 15:18:15 -08:00
Larry Gritz 571b2af872 Allow optional library name suffix (#2148)
This patch allows an optional suffix to be specified that will let you
produce something like libOpenImageIO_CIA.so or whatever. Use with
caution, or preferably not at all, if you don't absolutely need it).

Example of how it's used: Suppose you're at a facility that needs (don't
ask why) multiple versions of OpenImageIO to be built. And namespacing
is not enough, because if you have two copies of libOpenImageIO.so, you
can't separately rpath them.
2019-01-16 15:18:02 -08:00
Ramon Montoya Vozmediano 50fbaa0383 OpenEXROutput: skip dwa compression for single channel small tile images (#2147)
We've found that this is unsafe, dwaa/dwab compression crashes inside OpenEXR for certain tile sizes (only for 1-channel images, it seems). Until there is a fix on the exr end, we'll just revert to zip compression for the problematic cases. Power-of-two tiles larger than 16 seem fine, and that's all maketx uses anyway.
2019-01-15 14:18:35 -08:00
Larry Gritz a2382e2360 Fix MIA ImageCache errors from missing udim tiles (#2138)
When performing get_image_info() on udim files, we have to try out
lots of the individual tiles until we find one that exists (the set
is allowed to be sparse). We were not properly supressing any error
messages set for the missing files, once we hit one that worked.
2019-01-15 14:16:47 -08:00
Larry Gritz 7102029f7e pybind11: turns out we can't use < 2.2 (#2144)
So now we check the version, if system install is too old, fall back
to attempting to download a local copy.
2019-01-15 14:16:11 -08:00
Larry Gritz 7044542b96 Clean up warning suppression a bit (#2146) 2019-01-15 14:15:30 -08:00
Larry Gritz f8bf635fd7 Strutil::parse_while() (#2139)
A handy complement to parse_until().
2019-01-14 21:55:51 -08:00
Larry Gritz e96b6df7f0 Modify maketx command line directory stripping to be smarter (#2140)
For the purposes of deciding whether a `maketx -u` command is an
unnecessary repeat, we compare this command line to the last one to see
if it's the same. In so doing, we strip the directories off any
arguments that look like filenames so that changes is how relative path
names are expressed don't cause us to unnecessarily remake the texture.

It's a little naive to do this for all args. Thiago noticed situations
where color space names (args after `--colorconvert`) might have slashes
and so you don't want to strip them of their "directories."

This patch addresses that, and also several other maketx/oiiotool
commands that might have following args that look like filenames but in
fact are not. Also uniformize the interchangeable -cmd and --cmd so that
those pointless differences don't incorrectly trigger rebuilds by
looking different when they are not.
2019-01-14 20:59:59 -08:00
Larry Gritz f1d14ccb9c Filter selection enhancements (#2136)
* Main event: add "nuke-lanczos6" as an alias for our "lanczos3" filter.
  (Nuke names it according to the full width, which makes sense but is
  different than our more conventional lanczos3 nomenclature. Made the
  alias to make it more obvious which to choose if you want to exactly
  replicate what Nuke calls lanczos6.)

* Added new flavor of get_filterdesc() that returns a const ref,
  instead of copying into a parameter by pointer. (In retrospect, I'm
  not even sure why I did it that way.)

* Made `oiiotool --help -v` print the available filters, for handy
  reference.
2019-01-14 14:58:00 -08:00
Larry Gritz df710e9753 IC/TS: add optional force argument to invalidate() method (#2133)
This works the same way as the `force` argument to `invalidate_all()` --
if true, invalidates unconditionally; if false, invalidates only if the
file's modifiation date has changes since the cache first opened it.

The default is true for back compatibility, but probably you will often
want `false`, only invalidating if the file has changed.
2019-01-14 10:36:25 -08:00
Larry Gritz a4c0ca4b13 Fix wasning in OpenCV area (#2143) 2019-01-13 13:17:38 -08:00
Larry Gritz 1aeadbb47d Comment typo 2019-01-12 19:32:11 -08:00
Larry Gritz 1d012e1626 Allow "missingcolor" hint for missing tiles & scanlines by some readers (#2129)
It's not uncommon to encounter partially written files. They could be
the partial results of a long render with only some tiles written so
far, or could be a corrupted file or one where the process died partway
through writing the file.

Many formats will consider this hopelessly corrupted, but it's actually
legal to have missing tiles in an OpenEXR file, for example. So
sometimes people want to read this, without the whole file seeming like
an error.

This patch introduces a new configuration hint used for ImageInput
open-with-config: "oiio:missingcolor". Also a "global" attribute (set by
`OIIO::attribute()`) that is equivalent to setting the configuration
hint for all ImageInputs.

If the configuration hint (or global option) is set, it is a (non-required)
request to ImageInput implementations that failed reads of individual tiles
(or scanlines) should not be treated as hard errors by the II::read_blah()
calls, but instead should suppress the error reporting and simply fill in
the pixels of the missing tiles with the color specified.

The hint's value is either an array of floats (one per channel), or a
string containing the text of a comma-separated list of the values. If
it contains fewer values than channels in the image, the last value will
simply be repeated for all remaining channels past the end. As a special
bonus, if the first channel of the missingcolor is a negtive value, it
will draw stripes (of the absolute value) instead of a solid color.

Note that currently, the only format and task that supports this is
reading tiled OpenEXR files. We can try to extend the support as
requested to other formats where it makes sense.

As an example use case, if you have an exr file that is missing some
tiles (say, because it is still in the process of being written by a
long-computing render), ordinarily an attempt to read it such as

    oiiotool partial.exr -o out.exr

might get a hard error with a message such as:

    oiiotool ERROR: read partial.exr : Failed OpenEXR read: Error reading pixel data from image file "partial.exr". Tile (0, 0, 0, 0) is missing.

But now you could do this instead:

    oiiotool -iconfig oiio:missingcolor "-1,0,0" partial.exr -o out.exr

And that will result in a successful copy of the file, with red and
black stripes in place of the tiles that were missing in the original
file.
2019-01-12 16:40:41 -08:00
Larry Gritz 06e123756b Allow env OPENIMAGEIO_OPTIONS to set global OIIO::attribute()
Akin to how we have `OPENIMAGEIO_IMAGECACHE_OPTIONS` and
`OPENIMAGEIO_TEXTURE_OPTIONS`.

`OPENIMAGEIO_TEXTURE_OPTIONS` is a comma-separated list of name=val
pairs that upon startup will seed the global options that are usually
set by the OIIO::attribute() call.

Along the way, I beefed up the OptParser to be able to handle both
single and double quotes equally well. That lets you set an option that
is a string, that itself contains quotes.

Also document all of these options -- I realized the PDF docs don't talk
about even the existing env variables.
2019-01-12 09:51:05 -08:00
Larry Gritz d988904d54 Docs typo fixes related to array_view 2019-01-12 00:19:27 -08:00
Larry Gritz 8421ef8523 TS: Fix wrap_periodic_sharedborder to protect better against % by 0 (2121) 2019-01-11 14:07:10 -08:00
Larry Gritz 4f23c85f03 safe_mod() does integer % but protects against mod by 0 exceptions (2121) 2019-01-11 14:07:10 -08:00
Larry Gritz 3ef2c84d80 formatting touch-ups after clang-format update 2019-01-11 10:39:31 -08:00
marsupial 66283563f5 [OpenVDB] Don't allow any exceptions to escape and use Filesystem::fopen (#2135) 2019-01-11 08:50:25 -08:00
Larry Gritz e536411711 clang-format fixes (#2137)
Homebrew updated its copy of clang-format several days ago. Something
in it changed formatting rules and caused our builds to break on the
formatting verification test.

This patch changes the way we look for the clang-format binary -- you
can supply a hint about which directory it's in as
`CLANG_FORMAT_EXE_HINT` cmake variable, or an env variable of the same
name, or it will also try to find a clang-format in your LLVM distro if
you have a LLVM_DIRECTORY env variable set.

This lets us more easily lock down the clang-format to the one with llvm,
not separately installed, so it should get changed less frequenty and is
easier to standardize across users and platforms. Currently, then, we're
trying to tie it to clang 7.
2019-01-11 08:49:44 -08:00
Larry Gritz 304a03ce55 Improve Python error reporting for ImageOutput and IB.set_pixels (#2127)
The underlying decoding of pixel value arrays -- used by some of the
ImageOutput methods and ImageBuf.set_pixels -- threw exceptions when
the pixel array didn't conform to expectations. This led to very
confusing behavior, and crashes if the python program didn't carefully
catch them. Instead of throwing exceptions, bubble up an error message
for the usual OIIO error reporting, so wrongly-shaped pixel data arrays
are treated similarly to other kinds of error.

Also, detect with a better error message cases where user tries to write
scanlines to a tiled file or vice versa -- it was handled well in C++,
but the Python would start by parsing the pixel array, then have a
confusing error that it was the wrong shape, instead of the more clear
error message about using tiles instead of scanlines.
2019-01-09 00:02:18 -08:00
marsupial 8b9b6db0e4 [SPI] Fix OpenVDB rpath issue and update to latest version. (#2134) 2019-01-07 19:22:22 -08:00
Larry Gritz 3b7c7508a5 Relax channel restrictions on IBA::resize, fit, resample. (#2125)
They had previously outright rejected if the destination and source
images didn't have the same number of channels.

But actually, it doesn't matter. If they differ, it will only operate on
the minimum channel count in the two images. If dst has more channels
than src, that's fine, it just won't fill in the "missing" channels.  If
dst has fewer channels than src, then that's also fine, and in fact it
is totally reasonable to want to resize an RGBA image into an RGB
buffer, resizing while only copying the first 3 channels.
2019-01-05 20:59:13 -08:00
Larry Gritz 1eb692949f Update docs 2019-01-05 13:41:47 -08:00
Larry Gritz 90da925829 CHANGES 2019-01-05 13:37:13 -08:00
Larry Gritz 69a90f975a read_image ought to use the thread-safe forms of read_scanlines/tiles (#2123) 2019-01-05 08:52:22 -08:00
Larry Gritz 4a827b742f Fix subtle TIFF read problems with unassociated + channel ranges (#2122)
If you are reading a TIFF file with unassociated alpha, but you have
called the variety of read_scanlines or read_tiles that let you restrict
the channel range and your range doesn't include the alpha channel, the
automatic premult will be using bogus values. Oh brother.

Solution is to skip the premult if the alpha channel was not available.
Note that this makes it possible for read_scanlines() of channels 0-2 to
NOT MATCH the first three channels if you had read all 4 channels.
Seems odd, but what else can we expect? You get what you deserve if you
purposely exclude the alpha channel from the read, but it's an
unassociated alpha file that needs the alpha for the premult.

Also noticed that read_scanlines was not quite as careful with
thread safety as it should be, accessing m_spec outside the mutex.
The read_tiles implementation got it right, so do the same thing.
2019-01-05 08:50:28 -08:00
Larry Gritz 8093bbb7c6 Fix potential threadpool deadlock from recursive use (#2132)
The thread_pool already attempts to keep track of its worker threads,
and if they themselves attempt to submit tasks to the pool, it will just
execute those recursive tasks immediately rather than enqueuing. This
helps prevent deadlock where all the queue workers are running tasks
which themselves are waiting for other tasks, which are so far back in
the queue that nobody progresses.

But, as Thiago points out in #2131, if there are multiple app threads
submitting to the thread pool simultaneously, you can get into similar
trouble, and since those submitting threads are not themselves pool
worker threads, the "am I a worker" test fails.

Moment of honesty: I'm not sure exactly how this can happen. At first
blush, it seems like it shouldn't matter, but nonetheless it does and I
know from experience that reasoning about all the edge cases of queue
submission order is really tricky. The additional check proposed here
appears to solve the problem, so we're going for it.

The proposal here is Thiago's suggestion, but cleaned up a little bit
by LG to make sure it works for both `parallel_for_chunked` and
`parallel_for_chunked_2D`.

The gist is that we use a thread_local variable to keep direct track of
the recursve depth of calls to parallel_for (for each thread) and force
single threaded mode if recursion is detected.

Fixes #2131
2019-01-05 08:48:32 -08:00
Larry Gritz 0040ad581b Amend DPX to recognize new transfer/colorimetric code for ADX (#2119)
Fixes #1725
2019-01-04 23:48:09 -08:00
Larry Gritz ccaa8f597b Adjust webp testsuite output ref
Also, we weren't running the webp tests at all on Travis or Appveyor
because they weren't downloading the webp images. Move them to the
oiio-images project and adjust.
2019-01-04 23:00:21 -08:00
Larry Gritz e5646e6773 Fix WebP bugs (#2120)
WebpInput::read_native_scanline had

   if (y < 0 || y >= m_spec.width)  // out of range scanline
       return false;

when it should have been m_spec.height!

This had the effect of introducing read errors any time a webp image had
a height > width. Worked fine for "landscape" images, which is how it
went for so long without detection.

Fixes #1716.

While I was at it, I also noticed that webp seems to assume unassociated
alpha, so I added the code to premult/unpremult on the way in and out.

webp images seem to be always assumed sRGB, so also add that logic.
2019-01-04 17:23:49 -08:00
Larry Gritz 1cc9b46284 simd.h fix for gcc8 warnings when sse is disabled (#2130)
It's now a warning to use memcpy into a class with no trivial constructor.
2019-01-04 17:23:19 -08:00
Larry Gritz 78b6ce5da2 Fix oiiotool --dumpdata for uint8 pixels (#2124)
Sloppiness printed uint8 vals as characters themselves intead of
integer values.
2019-01-04 17:22:49 -08:00
Larry Gritz 31b030a662 Fix broken TIFF with JPEG compression (#2117)
JPEG compression was one of the cases where we fell back on the
TIFFRGBAImage interface of libtiff. This worked for some JPEG images,
but crashed on others, inside the TIFF library. Never did figure out
why.

But do we really need to to use the RGBAImage interface?  Turns out, no!
At least, not if it's still a spectral RGB image.

So just using the regular interface for ordinary RGB JPEG-compressed
TIFF images is fine, fixes the problem.

Also improved an error message while I was in there.
2019-01-02 22:36:43 -08:00
Larry Gritz f51163f2e1 Get rid of confusing/bogus ImageInput error (#2126)
read_tiles was calling all errors "no support for format", but that's
really weird. If it's a bad tile read, the error will already have
been set by the underlying read_native_tiles.
2019-01-02 11:33:10 -08:00
Larry Gritz 9cbc3a8ae9 Strutil::wordwrap enhancement (#2116)
Allow caller to specify the separation characters instead of hard-coding
to just ' '.  There are separate ordinary separators (default " ", break
on the separator), and pre-separators (default: none, break AFTER the
separator).

An example if when you might want to use the pre-separator is for sep=" "
and presep=",". That would mean to split at any blank, but if there are
areas with no blanks separated by commas, it's ok to break immediately
after a comma.
2019-01-02 11:29:34 -08:00
Larry Gritz c769b035e6 IC/TS: Detect failure due to updated texture file (#2115)
At the suggestion of Thiago Ize: After read errors on texture tiles,
check if the file it's reading from appears to have a different
modification time than when we first opened it, in which case being
overwritten by some other process is probably the source of the error,
so issue a message saying so.
2019-01-02 11:29:14 -08:00
Larry Gritz eb71231775 Compression convenience - improved notation (#2111)
Many of the file format writers have options for compression, expressed
as metadata "Compression" (e.g., "zip"), and a few of them also take
a second control called "CompressionQuality" (some compression methods
have size/quality or time/quality tradeoffs).

As a special case, the OpenEXR writer allowed the compression for dwaa
and dwab to be able to embed the compression amount in the name, like
"dwaa:100".

With some more thought, I realized that this is a superior notation and
that all of the writers should support this. This has two really nice
consequences:

1. Express compression method and amount in a single option.

2. Avoid possible bugs of "CompressionQuality" being inappropriately
passed from one method to another. For example, zip, jpeg, and dwaa have
totally different meanings to their scales. Making the compression scale
part of the name prevents some silly user errors.

For back compatibility, this patch still allows an explicitly set
"CompressionQuality" to function as it did before. But I'm changing all
the docs to favor the new notation.
2019-01-02 11:28:19 -08:00
Larry Gritz cb92d9b1df Bump SpComp2 version
(forgot to do this earlier)
2019-01-02 11:21:24 -08:00
Larry Gritz b770cfc68a TIFF output -- check for unsupported per-channel formats (#2112)
Our TIFF output doesn't support per-channel data types (because
the underlying libtiff does not).

This patch makes the TIFF writer check that the spec it's passed doesn't
have a filled-in `channelformats` and will refuse to open, with error,
if it does.  (Exception: if the vector is filled in but all elements are
equal to spec.format, then it's accepted.)
2019-01-02 01:00:24 -08:00
Larry Gritz a8e72296ee Docs touch-ups
[ci skip]
2019-01-01 23:56:23 -08:00
Larry Gritz da76ab9fef string_view: add pos parameter to find_first_of/find_last_of (#2114)
We already supported the position parameter for the character-based
versions, but not the string-based versions.
2018-12-27 13:57:05 -08:00
Larry Gritz 4dec369019 Appveyor overhaul (#2113)
Get rid of much cruft, install all dependencies with vcpkg. Super easy.
No messing with finding nuget packages and then weeping over their
oddities. And now we have a lot more optional dependencies in place,
which means we're building more of the OIIO code base (fewer parts
disabled for lack of deps), therefore more code coverage in the windows
test build.

There's a trick to this -- it can't actually build all these packages
from source within the 1 core hour it's allotted. It all depends on the
run-to-run caching that leaves the built vcpkg packages in place, and I
had to build it up a few packages at a time. The very expensive optional
dependent packages only build if there's enough time left on the clock.
2018-12-26 18:08:31 -08:00
Larry Gritz a408ed095b Adjust how maketx -u compares command lines (#2109)
maketx -u means "update mode", wherein if it looks like there's already
a texture in place that's the result of the same maketx command, it
won't re-make the texture.

The primary way of doing this is to compare file dates: when using -u,
the output texture will be given the same timestamp as the input source
image. So the next time it runs, it checks the two dates, and if they are
identical, the texture is presumed already made.

But wait, what if they used a different version of OIIO, or had
different command line args, such as choosing a different fileter? Then
you DO want to remake the texture. So we also compare the metadata that
gives the command from last time, with the command line from this time.

But... that can have false negatives, because what if they used an
absolute path one time and a relative path another time?

So in this patch, we add a little trick: before comparing the two
command lines, we take each of them and for any argument that looks like
a file path (has a directory separator in it), we strip out everything
before the last directory separator.  So

    /my/bin/maketx foo.exr -o ./foo.tx
    makex /path/to/foo.exr -o foo.tx

Used to look different, but now look the same.

How do we know that the things we strip are actual file paths? We don't,
and we do not care. No arguments to maketx that we care about are going
to have slashes in them. That won't be part of the filter name or any of
the other things we were trying to distinguish between.

Fixes #1472
2018-12-24 10:24:46 -08:00
Larry Gritz 3fad2a330c Allow ImageSpec::find_attribute of "datawindow" and "displaywindow" (#2110)
These are "pseudo-attributes", they aren't metadata themselves, but
aggreagate from x,y,z,width,height,depth (and the full_ versions).
The "datawindow" and "displaywindow" are OpenEXR nomenclature, but
it's likely that people will want to refer to them that way.

Also, minor fix to `ImageCache::get_image_info` and
`TextureSystem::get_texture_info`, to make the right kind of
ImageSpec::find call to retrieve the pseudo-attributes.
2018-12-22 11:12:39 -08:00
Larry Gritz e914c1bf72 Fix buffer stride logic in ImageInput read methods (#2108)
Reported in #2106, there was a subtle bug in read_image/scanline/tile
where we fell into the "contiguous and no data type translation"
case when that was not really the case.

The symptom could be triggered by the following case: You want to read a
1-channel float image into a buffer meant to hold a 4-channel UINT8
image with a 4-byte xstride. The correct behavior is to translate the
floats into uint8's and place them in channel 0 of each 4-channel pixel.
But because the buffer stride length (4 x uint8 = 4 bytes) matched the
native stride length (1 x float = 4 bytes), it was copying the floats
instead of translating and depositing them correctly in channel [0]
(leaving channels [1-3] unchanged).

The fix isn't too hard, but we made the same mistake in several places.
Basically, we were comparing whether the strides matched the native
spacing, instead of whether they matched the buffer spacing. Only
particular unusual combinations would trigger the false positive.

Add an explicit test of this case in imagebuf_test.cpp.
2018-12-22 11:11:40 -08:00
Larry Gritz 6f1c56ccae Minor fixups of including windows.h (#2107)
Since <windows.h> is included in platform.h, and with great care about
certain symbols being defined beforehand (such as `WIN32_LEAN_AND_MEAN`
and `NOMINMAX`), rely on that one and eliminate other places where we
may include windows.h. This ensures that we don't forget to define those
symbols in other places or get confused by include order.
2018-12-20 15:35:16 -08:00
Larry Gritz 59fdb390ea Change remaining atoi/atof to use Strutil::stoi/stof (#2105)
atoi/atof are frowned upon because they don't have ways to report
errors, so are typically flagged as unsafe by static analysis, they have
the "pipe-fitting" issue of taking only a `const char*`, and for atof in
particular can have is behavior changed by the system's current
locale. Instead, we prefer our Strutil::stoi and stof which take
string_view and are guaranteed locale-independent.

There are just a couple places where we keep the old functions -- one is
pugixml (because it's an import and we don't want to diverge from the
upstream source), and the other is in strutil_test where we are
specifically trying to benchmark our functions against atoi/atof (and so
therefore must call them). In these instances, we at least mark them as
exceptions for the static analyzer to not complain about.
2018-12-19 22:53:36 -08:00
Larry Gritz 1bf8e7ecd5 Clean up Python ability to iterate over ParamValueList (#2101)
The most important change is that we were missing the __iter__ method.
That was preventing proper iteration over the entries in a
ParamValueList (you could still iterate over the length and index like
an array to retrieve the entries). I did some other cleanup as well, to
conform to the pybind11 examples that handle similar cases.

Iterating still seems to fail for me on OSX, only for some image files,
dumps core after visiting the last item in the list (I guess, as it
iterates past the end).  Works on Linux, works on TravisCI (both Linux
and OSX).  I've struggled with this for a few days and I'm not sure what
to try next.  Maybe the problem is sensitive to particular python
versions?

In any case, if you can't get this to work:

    for attr in myparamvaluelist :
        print attr.name

Try this, which I'm sure works:

    for i in range(len(myparamvaluelist)) :
        print myparamvaluelist[i].name
2018-12-19 22:52:56 -08:00
Larry Gritz 3053dcf120 strided_ptr: fix subtly incorrect semantics of increment/decrement (#2103)
This is a very small nit to pick, but pre-increment and pre-decrement is
supposed to return a ref, not a const ref.
2018-12-18 23:05:49 -08:00
Larry Gritz c4a107aa34 Resolve conflict on some platforms where 'inline' and '__optnone__' can't coexist (#1899) 2018-12-18 23:05:25 -08:00
Larry Gritz 1dc9cbd649 Mark setjmp exceptions to clang-tidy cert-err52-cpp test (#2104)
Exceptions are better than setjmp, but that's how libpng does it,
what can you do?
2018-12-18 15:53:33 -08:00
Larry Gritz 412ca8e6d4 Fix instances of possibly unsafe string copying (#2102)
Use of clang-tidy found several instances of "unsafe" string copy or concatenation -- using functions that don't take a buffer length.

In truth, we humans know that these were probably fine in their context, but it's true that those unsafe string functions should be avoided and it's desirable to get clean static analysis on all the security-related tests.

It's worth noting that these changes in rgba.{h,cpp} diverge us from the original sources (they were imported from code by Greg Ward and Bruce Walter). I usually prefer that when we import entire modules of code from elsewhere, we don't make any changes at all, or even reformat to our conventions, so that we can easily integrate future improvements to the upstream sources. But after mulling this over, I think that in this case, it's not actively maintained code, and in 10 years we have never had to integrate fixes. So let's just consider these fully absorbed and able to change at will for our own purposes.
2018-12-18 15:52:37 -08:00
Larry Gritz 96c70ba7b0 oiiotool: -evaloff -evalon to temporarily disable expression evaluation. (#2100)
Because what if some loon has curly braces in a filename? It must be
rare because nobody has come across this problem in the years since
OIIO 1.6 added expression evaluation. But it happened today!

So you can do this:

    oiiotool -echo {3+4} -evaloff -echo {1+1} -evalon -echo {8*2}

And you will see ouput

    7
    {1+1}
    16
2018-12-18 14:21:30 -08:00
Larry Gritz cc55a91d83 IBA::channel_append(): improve result data type choice (#2095)
When the result image was uninitialized, it previously forced it to
be a float image result. Now we make it use our usual type_merge logic.
2018-12-16 22:08:40 -08:00
Larry Gritz 5817aea2c3 Cleanup and refinement of our "clang-tidy" pipeline. (#2093)
Clang-tidy is part of clang tooling that's a static analyzer of
everything from "unsafe" code that violates security guidelines, to
stylistic fixes.  There are many hundreds of tests. Initially we are
just enabling some basic security and correctness tests. Will add more
later.

All you need to do to run it is

    make CLANG_TIDY=1

Or if running cmake directly, use -DCLANG_TIDY=1

Warning: it is a long compile.

Set up a Travis test to run clang-tidy for static analysis. But after
much trial and error, I just couldn't get it to run in the 50 minutes
that Travis allows. So for now it's disabled. But if we ever have a CI
solution that executes faster or has longer time limits, I would love to
do a full static analysis on every PR. For now, I will have to be
content running it by hand on my own machine from time to time (and for
every tagged release).
2018-12-14 22:00:29 -08:00
Larry Gritz 1dfb59d165 Fix compiler warning on some platforms (#2099) 2018-12-14 09:55:21 -08:00
Larry Gritz 963ec31b20 Remove deprecated osdep.h (#2097)
Apparently we had deprecated this file 3 years ago, moved all the useful
content to platform.h. But never got around to removing the header that
was no longer needed.
2018-12-13 14:10:55 -08:00
Larry Gritz c847b6ffbf python: define __version__ for the module (#2096)
Had overlooked this.

Also fixed a couple spots where we should have used PY_STR to make
the right kind of python 2/3 type.
2018-12-11 09:45:21 -08:00
Larry Gritz ca5ecc1094 Make Travis OCIO build faster, only build the parts we need (#2092) 2018-12-10 16:36:02 -08:00
Larry Gritz 132dea273b Remove wayward missing_math.h reference from simd.h that broke OSL build 2018-12-10 12:12:03 -08:00
Larry Gritz e37094cc2c Deprecate missing_math.h (#2086)
Once we were fully C++11 and moved MSVS minimum to >= 2015, the contents
of this file were no longer needed as far as I can tell. What few things
were here that anybody might still rely on, are in fmath.h.
2018-12-07 23:04:43 -08:00
Larry Gritz a8337cc573 Rebuild docs 2018-12-07 13:55:37 -08:00
Larry Gritz 42e31341f2 OpenCV 4.0 support (#2089)
Should now build against OpenCV 2.x, 3.x, and 4.x.

Added more modern from_OpenCV and to_OpenCV, converting ImageBuf <->
cv::Mat, and taking the common ROI and nthreads parameters that we use
for the rest of IBA.  Deprecate the old IplImage-based functions, which
is an OpenCV 1.x thing.

Add a test of ImageBuf -> cv::Mat -> ImageBuf round trip to make sure
it works.
2018-12-07 13:46:39 -08:00
Larry Gritz 4c47083477 Remove unused channel arguments from convert_image() (#2088)
`convert_image()` and `parallel_convert_image()` had alpha_channel and
z_channel parameters that weren't actually used. I don't even remember
why they were present; I think I imagined that certain conversions might
dither the color channels or something and need to know not to do it to
these channels. But in any case, they were unused, so remove the
clutter.
2018-12-06 12:34:06 -08:00
Larry Gritz 7605327477 Bump version after branching 2.0 2018-12-01 10:14:28 -08:00
Larry Gritz 6229f0c765 Update PDF docs 2018-12-01 08:58:40 -08:00
Larry Gritz 7f98e4dae2 Touch up ociodisplay docs 2018-12-01 08:53:54 -08:00
Larry Gritz c3cf7ce801 changes 2018-11-30 23:17:07 -08:00
Larry Gritz 79b010b7b1 IBA::ociodisplay: better logic for missing 'from' space name (#2085)
If no 'from' space name was provided, it tried to look up the
"oiio:ColorSpace" metadata of the source image, and if that also wasn't
found, fell back on "linear."

But the OCIO config may not literally have "linear" as a color space
name. So instead, the fallback should be on whatever color space has the
*role* of linear (aka scene_linear). This in turn makes the default "no
'from' parameter supplied -> use linear" less prone to error.
2018-11-30 21:57:12 -08:00
Larry Gritz c579e8a4b2 Python: fix a couple string-returning functions (#2083)
Should be using PY_STR to return the right kind of string for python2
vs python3.
2018-11-30 21:57:01 -08:00
Larry Gritz 76dc04a924 Python: can't use 'from' as a parameter name -- it's a reserved word! (#2084)
It came to my attention that IBA.ociodisplay (and also it turns out
ociolook and colorconvert) have parameters named 'from', which it turns
out that if you use the `name=value` named argument syntax in Python
will actually be a syntax error because 'from' is a reserved word!

Rename that parameter 'fromspace', and to be symmetric, also rename
'to' to 'tospace'. And do the same in C++ bindings so that they match.
2018-11-30 21:56:47 -08:00
ThiagoIze b95c8c2fce vsnprintf only returns -1 on encoding error (#2082) 2018-11-29 22:49:45 -08:00
ThiagoIze db5af2f211 m_fingerprint key is the hash, not the filename. (#2081) 2018-11-29 22:34:12 -08:00
Larry Gritz 0ff07edb30 Release candidate 2018-11-27 17:48:51 -08:00
Larry Gritz 7c78aeccd7 Update PDF docs 2018-11-27 17:48:03 -08:00
Larry Gritz 98404d8039 CHANGES and other docs touch-ups for release candidate 2018-11-27 17:47:02 -08:00
Larry Gritz fb9f7b3dfb Start transition from tinyformat to fmt/std::format -- multi-stage (#2076)
For many years we have used Chris Foster's magnificent "tinyformat"
package to do a lot of the heavy lifting for our type-safe string
formatting with printf-like notation, which we use for Strutil::format,
nearly every error reporting facility in the major classes, etc. Thanks,
Chris!

The C++ committee has finally caught up to Chris, advancing drafts of a
"string formatting" proposal that now seems very likely to be part of
C++20. The best implementation at this point is the {fmt} package.

Unfortunately, {fmt} and the C++ draft papers differ from tinyformat in
that rather than traditional C printf notation for formatting, they use
a notation very similar to Python string formatting, e.g.,

    format ("%d %.3f", 1, 23.4)  -->  format ("{} {.3f}", 1, 23.4)

This compatibility break is one reason I've stayed away from {fmt},
despite that (no slight to Chris) it's at least twice twice the speed of
tinyformat.

But knowing that this is almost certainly the shape of the future C++
standard, I am confident that the best long-term path is to migrate to
its conventions. And it will be nice to reuse the same cognitive
machinery whether we're programming in C++ or Python, and get the speed
boost.

But how to do this migration without breaking every string format
operation in OIIO, and additionally in all the packages that call OIIO
and use any of its string formatting or error reporting facilities (and
indeed, we use it extensively in OSL)? This PR is the first step of
implementing the transition, which will occur over a couple major
releases. Here we go:

1. Introduce Strutil::sprintf(), ustring::sprintf(), and various
   errorf(), warningf(), etc., functions as needed that now and forever
   will use the printf notation (and for now are still implemented
   primarily with tinyformat, but that's not a detail you need to worry
   about).

   Neary all internal uses of the format() commands within OIIO internals
   have switched to sprintf().

   Calling apps that make use of OIIO's string formatting can therefore
   also change their calls from format() to sprintf() and everything
   will continue working for the forseeable future.

2. Introduce, in a namespace, Strutil::fmt::format() and certain
   fmterror(), etc., that use the NEW Python-like notation, implemented
   underneath with fmt::format().

   Calling apps may start using these now if they prefer the Python
   notation...

   But BEWARE! I have discovered that the fmt library does not correctly
   implement the promised locale-inedependent formatting for floating
   point values (it does for integers), and so could cause problems for
   those of you who might have apps running on platforms wth certain
   locales that, for example, use ',' as the decimal (sheesh). This is a
   known problem with fmt, will be fixed soon, and as soon as it does,
   I'll update our embedded copy of fmt and give you the all clear to go
   nuts with the new python style formatting directives.

3. For OIIO 2.0, Strutil::format, ustring::format, and the various error()
   functions will behave identically to sprintf (C printf notation), but
   for OIIO 2.1, I am planning on having them all switch to to the new
   python (a.k.a. C++20-ish std::format()) format designations.

So, the upshot is that NOTHING should break for your existing code's
format()/error() calls when switching from OIIO 1.x to 2.0.
(Proof: OSL master compiles against it and passes all tests, without a
single change.)

But after you upgrade to 2.0 and before 2.1 is released (I'm assuming in
the latter half of 2019 at the earliest), you'll want to either switch
all those calls to Strutil::sprintf()/errorf() and stick to the
printf-style formatting *OR* change them to
Strutil::fmt::format()/fmterror() using the new formatting specs.
Pretty much all of the OIIO internals (error calls, etc.) have been
changed to use the explicit printf-like forms. So they seem safe.

After 2.1, then, the old names format()/error() will be the new behavior
and you can switch back to those if you want. And by the time C++20
comes out, we'll all be on the same page, and some day OIIO won't even
need to use the fmt library because it can rely on std::format.

There you go. Here is the PR that implements the first phase.

We have put the relevant parts of fmt library in
include/OpenImageIO/fmt.  We are currently using commit 01640f44, with
one fix by me on top of it that fixes a Windows compile issue. We will
update the version of fmt as fixes and improvements come.

Sorry for such a weird change in the middle of the beta period. But
sometimes a looming deadline of a code freeze and major release (after
which I wouldn't want to introduce this kind of disrupction) really
makes one focus about doing it right now instead of having to wait
potentially an additional year.
2018-11-27 14:22:07 -08:00
Larry Gritz d4a9b73ce7 All platforms can rely on std::snprintf now. (#2080)
snprintf is a C++11 feature. No need for Windows to try to substitute
_snprintf, which in any case didn't behave quite the same (didn't add a
terminating null character in the case where the alotted space will
filled and the string had to truncate).
2018-11-27 14:10:43 -08:00
Larry Gritz ba085a4bac Fix __has_attribute vs __has_cpp_attribute and other C++ std things (#2078)
I had not correctly understood that __has_attribute is specifically for
GCC __attribute__((attr)) things, and __has_cpp_attribute is the new
C++20 test for standard [[attr]] style attributes. Fix up that use.

Also get rid of __has_builtin and __has_feature, those are gcc only,
not the way the standard works, and we don't use it anywhere.

Some other very minor fixes related to discerning which C++ standard
we're using.
2018-11-27 11:14:27 -08:00
Larry Gritz 3fa941c2b0 Formally bump MSVS minimum to 2015 (#2079)
We think that as a practical matter, this has been the case for a long
time. But the documentation didn't keep up.
2018-11-27 10:42:40 -08:00
Larry Gritz a4b5684d15 Docs touchups
[ci skip]
2018-11-26 14:45:54 -08:00
Larry Gritz 527df5b005 Documentation and config parameter naming conventions (#2075)
I noticed that an open() configuration hint that causes non-RGB color
channels (such as YCbCr) to not get auto-translated to RGB was
implemented in three different plugins, but not all with the same
name. Settle on "oiio:RawColor" for all of them, and also update the
docs accordingly.
2018-11-26 14:29:36 -08:00
Larry Gritz 90644b44c5 INSTALL touch-up 2018-11-24 21:25:12 -08:00
Larry Gritz f930dba5b7 Fix overlooked Python ImageOutput.open call for multiple subimages (#2074)
It was documented, but left out of the python binding implementation.
2018-11-24 13:10:37 -08:00
roelandschoukens b7baa23049 Fix build errors on Windows when making Unicode builds (#1454)
Always use the wide versions of the Win32 API functions, and always
assume strings are given as UTF-8.
2018-11-24 13:08:45 -08:00
Larry Gritz b35504a06c JPEG: Better detection of error conditions and corrupt files (#2073)
We weren't bubbling up all errors properly.

Fixes #1759
2018-11-20 17:32:42 -08:00
Larry Gritz f1ae482e37 Restore define symbol needed by older osl builds 2018-11-20 11:18:51 -08:00
Larry Gritz 9f86cc64d3 zfile fix and test (#2070)
Spurious problems on Windows seem to happen with improperly closed or leaking file handles.
Solved by using gzopen_w on Windows to handle UTF-8 filenames allows us to remove the odd idiom of opening with fopen() then passing fileno to gzdopen (we were botching exactly who was responsible for duplicating or closing those handles).

Also add a zfile testsuite entry.

Fixes #1817
2018-11-20 10:33:05 -08:00
Larry Gritz c0cf5944fb DPX: catch write errors (#2071)
It was reported that if you filled a disk while writing a DPX file, no
errors would be reported, just leaving a corrupted file. (Admittedly,
filling disk volumes is not something I had thoroughly tested.)

The problem turned out to be threefold:

First, inside the DPX library (which was an imported project from
Patrick Palmer, which to the best of my knowledge is no longer actively
maintained outside of OIIO), the underlying OutStream class was used
incorrectly throughout its own library -- in particular, the Write()
method returned the number of bytes correctly written, but the return
results were almost always used incorrectly by merely checking != 0 (as
if it was a bool return for success, when in fact it should check for
any value != the number of bytes being requested to write).

To fix, I added a WriteCheck() method, which returns a simple bool
success/fail, and fixed the call points to use this function. I didn't
replace the original Write() method because there really was one place
where it expected the number of bytes written to be returned.

Second, in our DPXOutput::write_buffer() method, we weren't checking
the return results of the underlying call to m_dpx.WriteElement().
Now we do, and in case of failure try to check `strerror(errno)` in
the hopes of finding a useful system error (and in fact, in this case
of filling the disk, we do!).

Finally, in oiiotool's output_file() function, while we did check the
return codes for the call to out->write_image(), we neglected to check
the return code for out->close(), figuring that nothing could go wrong.
But, oho, the particular workings of our DPX writer are that the
write_scanline calls just batch output, and all the real I/O happens on
the call to close(), so the exact place where the error would occur was
the one place we didn't check. Fun. For most file format types, real
I/O happens in the individual write calls, so this was particular to DPX,
in addition to its other internal bugs described above.

How did I test? On my Mac I created a disk image with the smallest possible
space (around 8MB, I think), then tried to write a big file, like this:

    oiiotool -pattern noise 8000x8000 3 -d uint16 -o /Volumes/SmallTest/out.dpx

which now results in the following error:

    oiiotool ERROR: -o : DPX write failed (No space left on device)

which is about as good as we can hope for.

I also double checked what happens when we fill the disk while writing
tiff, exr, jpg, and they all correctly reported a write error.

So case closed, and thanks to Pavel Jurkas for reporting the DPX error
when the disk volume is full.
2018-11-19 14:39:00 -08:00
Larry Gritz 8343b79c19 oiiotool error/warning cleanup (#2072)
Use of variadic templates cleans up a lot of awkward format calls in the
middle of error/warning calls.
2018-11-19 14:10:36 -08:00
Larry Gritz 1a187a58e0 Travis cleanup 2018-11-17 21:03:07 -08:00
Larry Gritz 9501777b4a Docs
Update CONTRIBUTING to describe the new use of clang-format, and other
minor touch-ups.

Now that we have a LICENSE-THIRD-PARTY file, move some of the explanation
for the bits that originally came from NVIDIA there. Remove them from the
original files in which they appeared, which are in any case no longer
correct since code has moved around and in some cases those files may
no longer have any of the original NVIDIA-inspired code left.

[ci skip]
2018-11-17 10:33:02 -08:00
Larry Gritz e0b3608025 timer_test: allow for sloppier timing on Travis on Mac 2018-11-16 15:39:49 -08:00
Larry Gritz f0dde00998 CHANGES and docs 2018-11-16 15:33:05 -08:00
Larry Gritz 5af338158a clang-format, final-ish update (#2069)
This fully uses clang-format on the entire codebase (except for a few
files, and a few sections of files, where we explicitly disable it for
reasons.

Henceforth, we will assume that any new code contributions should be
conformant and reject pull requests that are not. The basic idea is:

1. For large code changes, make sure you have a fairly recent version
   of clang-format installed on your end, and use

        make clang-format

   to format the code before sending off the PR.

2. The TravisCI tests include one entry that merely does a 'make
   clang-format' and considers it an error if there are any resulting
   diffs (i.e. if clang-format needed to reformat anything). In such a
   case, it will also print the diffs themselves if you click on the
   failed test.

Note that for small patches and users who aren't easily able to have a
local clang-format copy, you can essentially skip step 1, submit your PR
as-is and then examine the failure diffs of step 2, making the requested
changes by hand and then updating your PR.
2018-11-16 14:29:56 -08:00
Larry Gritz a2c684c371 oiiotool expression evaluation enhancements (#2068)
1. Allow embedded single or double quotes to group arbitrary text in
metadata name. This solves the problem that the default parsing of a
metadata name in the expression syntax uses "C identifier" rules. For
example, suppose somebody has put a metadata attribute in an exr file
named "foo/bar". If you do:

    oiiotool file.exr -echo "{TOP.foo/bar}"

it will be wrong, thinking that it's looking up TOP.foo ("foo" attribute,
which doesn't exist) and dividing by "bar", which isn't a value it knows.
Instead, we now allow

    oiiotool file.exr -echo "{TOP.'foo/bar'}"

It's not pretty, but it allows arbitrary strings to be used as metadata
lookups, like "foo/bar" or "foo.bar" or other ill-advised names. (Oh,
and for that matter, it was hard to retrieve "foo:bar", which we use all
the time, oops. Now it is possible by quoting.)

2. Ensure that retrieved "timecode" values, when retrieved as strings,
print as human readable timecodes ("00:00:00:00") not the underlying bit
patterns.

The sum of these means that you can set and retrieve timecodes like this:

    oiiotool foo.exr -attrib:type=timecode "smpte:TimeCode" "01:01:01:01" -o out.exr
    oiiotool out.exr -echo "{TOP.'smpte:TimeCode'}"

Fixes #2063
2018-11-15 23:45:15 -08:00
Larry Gritz 23e543d86b Strutil::parse_string accept single quote as well as double (#2066) 2018-11-15 10:29:26 -08:00
Larry Gritz 400e2340cf clang-format of src/libtexture and src/libOpenImageIO (#2067)
Also some tweaking to .clang-format rules did some minor changes
in other directories. Still finalizing our choice of values, we'll
lock it down by the last of these big reformat patches.
2018-11-14 23:44:05 -08:00
Larry Gritz 22e1af2ff0 clang-format stage 3 -- src/*.imageio/* (#2065)
And some very minor touch-ups to the previous areas, as I make a few
tweaks to the formatting rules.
2018-11-14 13:43:24 -08:00
Larry Gritz 62458d75b5 oiiotool fix logic with -d chan=datatype (#2061)
This didn't work properly. Example:

    oiiotool -pattern constant:color=.1,.2,.3,.4,.5 256x256 5 -chnames R,G,B,A,Z -d half -o 1.exr
    oiiotool 1.exr -d Z=float -o 2.exr

would end up with 2.exr having all half channels, not Z float as expected.
What can I say? It was a bug.
2018-11-14 08:57:02 -08:00
Larry Gritz 1a5b7aa00d clang-format stage 2: src/libutil (#2064) 2018-11-14 08:56:43 -08:00
Larry Gritz e99a168304 Finally do the full rename of array_view -> span (#2062) 2018-11-13 09:52:11 -08:00
Larry Gritz 6ad0c0b538 Windows: disable warning in the farmhash code (#2060) 2018-11-13 09:51:37 -08:00
Larry Gritz 5e76177f68 Reformatting via clang-format (part 1) (#2059)
This first pass only reformats the contents of src/include/*. We will
tackle other directories in later stages. I wanted to start with just
one directory first, to give people a chance to object to the style
it imposes or tweak the format rules before doing the rest of the
code base.

For a minority of headers, I added a `// clang-format off` switch
because I was just too particular about the formatting of those files,
since I consider those public headers to be "documentation" as much as
working code, and therefore am extremely picky about certain ways I
strive to have them readable even when it involves breaking the usual
rules. Note that in some of these cases, even though I added the switch
to turn off future automated reformatting, I nevertheless made extensive
formatting changes to conform to the new prevailing style where I felt
it did not negatively affect readability.

I also turned clang-format off for a couple of files "imported" from
other projects (such as pugixml) in order to preserve our ability to
diff against changes in the original code. In those cases, I made no
other changes to those files except to add that one line to turn off
future reformatting.

No "code" has changed, except for a few very minor bits of clean-up I
performed at the same time:

* Removed a whole lot of `#ifdef OPENIMAGEIO_FOO_H` include gaurds,
  changing them to use `#pragma once` instead. In a few cases, I did
  leave a `#define` so that certain other source can tell if a file had
  been included. (I have reasons.)

* Change NULL -> nullptr in ustring.h
2018-11-12 11:26:44 -08:00
Larry Gritz 64313c3e1b Bump version for next beta 2018-11-12 11:25:24 -08:00
Larry Gritz 88df1f5579 Bump version to 2.x, designate beta
Renamed LICENSE to LICENSE.md.

New file: LICENSE-THIRD-PARTY.TXT houses copies of all the licenses from
3rd party open source projects with code that we have incorporated in
any way into OIIO.

Updated several 3rd party package URLs that had changed over the years.

Break up our massive CHANGES.md file into pieces, storing the old
sets of release notes in src/doc/CHANGES-0.x.md and CHANGES-1.x.md.

Revamp CREDITS.md. It used to be separated into major and minor
contributors, but after years of rewrites and edits all over the code
base, it was no longer accurate (e.g., somebody who was a major
contributor for something in 2009 now may, after 10 years of expansion,
just be one of many people to touch that code). I no longer try to
distinguish size of contribution. If anyone cares to tease apart who
contributed to which parts specifically, they can look at the logs of
the files they are interested in.

Rebuild the PDF docs.
2018-11-10 11:44:48 -08:00
Larry Gritz ef9e107206 Add a .clang-format file and a 'make clang-format' target (#2053)
* Add a .clang-format file and a 'make clang-format' target

clang-format is a part of the LLVM/Clang compiler suite that will
reformat your code -- but much better than most code reformatters,
because this one is based on a compiler toolkit and is working on the
fully understood AST, not just text.

The idea here is that we give up a little bit of individual creativity
in code formatting, in exchange for every pull request trivially being
able to conform to the house style and never having to go through
multiple rounds of PR edits for formatting issues, nor ever have any
squabbles about it. I know that nobody will be 100% happy with the
require formatting (even me), but I think if we can make everybody 80%
happy and avoid those other problems forever after, it's worth it.
People I respect running othe projects consistently swear that adopting
clang-format was one of the best decisions they made.

Basically, after the initial cmake configuration, you can reformat
files with

    make clang-format

Configuration variables CLANG_FORMAT_INCLUDES and CLANG_FORMAT_EXCLUDES
let you customize the lists of glob patterns that get included, or
excluded, from reformatting. For example, if you only want to reformat
one file (and you should try this to see how the whole thing works!):

    make nuke
    make CLANG_FORMAT_INCLUDES="exrinput.cpp" clang-format

Currently, I'm thinking that public header files will NOT be reformatted
(i.e. the exclude list will default to including src/include).  I just
can't seem to get fully satisfied with the transformations, and I think
that's because I think of public headers as documentation, so I'm
extremely picky about the formatting and think that readability is
paramount, so I make little one-off rule breaks all the time to improve
the flow, readability, and appearance. Of public headers. I think for
everything else, I'm willing to live with a set of rigid rules.

I'm still experimenting with getting the parameters right. I may keep
tinkering a bit before committing any actual reformatting. For that
reason, I'm merely proposing the build script and style configuration
portions now. Only after people have tried it out and we think we can
live with it, will I do the great reformatting checkin.

Also, eventually, we'll make one of the Travis-CI tests do a
clang-format and fail if anything needs to be changed (and print the
diffs), thus making the CI make it very clear when any PR fails to
conform, and we will expect the submitter to run clang-format (or change
the offending parts by hand) and resubmit.

Addenda:

Make one Travis test matrix entry that only configures cmake and then
does a 'make clang-format'. Rig it so that if there are diffs produced
(i.e., the PR was not 100% conformant), it prints the diffs for
inspection and fails the test. If running clang-format produced no
changes to the source, the diffs will be empty and the test passes.

Also discovered the `name:` way of labeling Travis tests! Makes the
dashboard more readable.

Currently, no files are in the CLANG_FORMAT_INCLUDES list, so everything
should pass.
2018-11-09 17:54:10 -08:00
Dennis Schridde 8e9e68af81 Fix FindOpenEXR.cmake to use version detected by pkg-config, if available (#2057)
Detecting the OpenEXR version by parsing a C header can be unreliable.  Since
 we already use pkg-config to detect the presence of the library, we can also
 use the version number it gives us, if available, and only resort to parsing
 the header file if that failed.

See-Also: https://bugs.gentoo.org/668412
Fixes: ec4f679cd7
2018-11-09 16:03:14 -08:00
Larry Gritz 32fe269ac9 Travis: deal with new boost 1.68 2018-11-08 17:59:00 -08:00
ThiagoIze 43e894568c fix oiiotool --info windows_path (#2055) 2018-11-08 17:55:44 -08:00
Larry Gritz be88e4cdab Add thresholds to IBA::isConstantColor, isConstantChannel, isMonochrome (#2049)
A situation came up recently that made me realize it would be good to
have a handy way of knowing whether an image is *almost* a constant
color (e.g., allow the channels in a pixel to differ within some
expected threshold and still be considered monochrome).

So this patch proposes to add an optional `threshold` parameter to
these three IBA functions. The default is 0.0, which is identical to
the old behavior and checks for exact matches only.

While I was in there, I noticed that these three functions were not
previously parallelized/threaded, so I added that as well. That should
speed them up considerably when running on multicore machines.
2018-11-06 17:44:17 -08:00
Larry Gritz bd3cd3c189 Texture: Fix edge case bug in adjust_blur (#2052)
Mea culpa. Ramon Montoya alerted me to a problem in 2013 and I either
forgot about it, ignored it, or failed to understand it. But I
rediscovered his email while trying to purge my inbox of long-ago
unresponded emails and decided to look into it again.

The problem situation is that we figure out the filter ellipse based on
the derivatives, and then "thicken" it based on the amount of blur
requested.  Ramon pointed out that a very uneven amount of blur (very
different in s and t) could thicken the minor axis so much more than the
major axis that, you know, they aren't the proper axes any more. And
that could lead to odd behavior later on, because the samples are laid
out along the major axis and assuming in all the math that majorlegnth
>= minorlength.

I tried a few approaches, and the most streightforward was just to
notice when this happens, and swap the minor/major (rotating the ellipse
by PI/2).  This seems to basically work and looks quite good for the
common situations, although it's less than satisfactory for the
combination of very uneven blurs and extreme sheer that you get when the
ds and dt derivatives are nearly colinear (pointed in almost the same
direction or almost opposite, instead of the more typical and expected
nearly-perpendicular configuration). Though maybe it's right then, too,
I dunno, it's very hard to reason about what's "right" in that weird case.

That fix is 3 lines of code in adjust_blur().

The rest of the PR is comments trying to explain what works and doesn't,
and various improvements to the unit test visualizations (including
adding the ability to turn them on and control the amount of blur from
the env OPENIMAGEIO_TEXTURE_OPTIONS, drawing the ellipse axes, and drawing
the individual sample footprints in the visualization).

All my testsuite passes. Lookups should all be identical except for that
problem case -- certain situations of VERY uneven s and t blur amounts --
and in that case it's possible that you might have renders change the
appearance slightly.
2018-11-06 17:09:46 -08:00
Larry Gritz 907297a2a5 SPI: build SpComp2 for libOpenImageIO_Util 2018-11-06 15:23:24 -08:00
Larry Gritz c779ca7549 Fixes related to debugging half -> float conversion (#2048)
We found that certain 'half' pixel values that involved "denormalized"
values (very close to zero) were inexplicably getting squashed to exact
0.0f in some circumstances but not others. Long story short, we traced
this to an older version of libopenjpeg (in turn pulled in by ffmpeg's
libraries) that set the x86 DENORMALS_ZERO_MODE upon its DSO load, and
left it like that, which is a truly terrible thing to do because it can
inject math bugs elsewhere into the app, even in parts that seemingly
have nothing to do with decoding jpeg-2000 images.

The code is only symptomatic in OIIO when we build with SSE support but
not with f16c instruction support -- the symptom is specific to the
series of ops we use to accelerate the half->float conversion with SSE
but without f16c. There could be other effects, but we haven't seen
them.

This seems to be fixed in newer versions of libopenjpeg. But we
encountered it, so others may also. It seems equally evil for our
library to reset the flag and leave it that way. However, for a full
application like oiiotool, we can safely set the flag, and so we do (if
the intrinsic is available, which unfortunately it is not in gcc 4.8).
I think that's the best we can do for now, out of several options that
were less than satisfactory. (A different set of instructions for h->f
conversion also avoided the problem, but was much slower.) We also advise
people to use a sufficiently new version of libopenjpeg to avoid this.

Along the way...

* simd.h methods to get/set the flush_zero and denorms_zero modes.
  (Note: known gcc 4.8 bug omits access to those intrinsics.)

* Preemptively turn off the denorms zero mode in oiiotool, in case some
  rogue library has turned it on.

* `oiiotool --stats` : Don't force a conversion to float when reading
  the full image to compute stats on. This change also avoids the bug,
  though in a brittle way. Still probably good to compute the stats on
  the native data.

* fmath_test checks EVERY 'half' value and makes sure the h->f->h round
  trip works properly.

* Change the behavior of `oiiotool --dumpdata` do try to dump the values
  of each data type without conversion, rather than converting all to
  float and printing the float values. This is a more true representation
  of the raw data in the file, which I assume is why somebody wants to
  do the --dumpdata.

* fmath.h changes to speed up bulk h[]<->f[] conversions by using
  8-wide simd ops when f16c is available. (This is just incidental,
  something I saw along the way.)

* `oiiotool --help` prints the number of cores, main mem size, and set
  of processor capabilities (SIMD level, etc.) on the hardware it's
  currently running on, and which set of SIMD capabilities was requested
  at build time.
2018-11-05 15:22:29 -08:00
marsupial 67f1b9cd10 VDB tweaks for library initialization and CMake (#2051)
* Make sure to always add 'lib' for custom VDB locations

* Use OPENVDB_MAGIC to test files before initializing the library.
2018-11-05 15:05:54 -08:00
Larry Gritz 67ef1f40ff CHANGES 2018-10-31 23:09:15 -07:00
Larry Gritz b6119705ef IBA::contrast_remap() and oiiotool --contrast (#2043)
Allows flexible linear or sigmoidal contrast remapping.
2018-10-31 23:05:38 -07:00
Larry Gritz 07dcbc91f7 Remove ustring::operator int() (#2047)
As pointed out by Thiago Ize and John Haddon (but unfortunately not
heard by me until literally years later), this is error prone because
there are times when a ustring is converted to an int/bool in unexpected
situations. It even led to verifiable errors in OSL that I only
discovered after commenting out this operator to see what would happen.

Neither std::string nor std::string_view have this operator, bolstering
Thiago & John's arguments.

So we are removing it from OIIO 2.0. Hopefully this won't break too many
people's apps that happen to make use of ustring. The fix is simple, just
change:

    if (myustring)

to

    if (! myustring.empty())
2018-10-29 15:54:36 -07:00
Larry Gritz ce060c6775 platform.h enhancements for C++17 and 20 (#2041) 2018-10-28 20:24:11 -07:00
Larry Gritz 629ef65cc6 spinlock_test: modernize with Benchmarker; also time spin_mutex vs std::mutex (#2046) 2018-10-28 09:30:08 -07:00
Larry Gritz cbd40eafc1 Make unit test errors respect whether stdout is a terminal (#2045)
This causes the color only to be used to the terminal, not incorrectly
injected when the output is redirected to a file.
2018-10-28 09:29:54 -07:00
Larry Gritz 100de7d21d fix typo 2018-10-26 23:00:08 -07:00
Larry Gritz acc79c0ad1 Update docs for new bumpslopes option 2018-10-26 22:25:26 -07:00
Pascal Lecocq 823e8da62d Add a bumpformat option for the bumpslopes exporter (#2044)
Add a bumpformat option for the bumpslopes exporter

This option prevents situations where the bumpslopes exporter fails to detect an input bump format as an height map. The typical situation is a 3 channels RGB height map we would expect to be monochromatic (R=G=B) but that has subtle color variation introduced by a texture publication process (typically a precision or rounding error). In such situation the exporter will automatically interpret the bump map as a false normal map, resulting in a corrupted texture output.

The bumpformat option allows the user to bypass the automatic detection and manually specify the input bump format.
2018-10-26 21:50:26 -07:00
Yann Lanthony 9dc6abab9b Safer thread_pool destruction using native threads status (Windows) (#2038)
Prevent deadlock from illegal communication with already terminated threads when global shared thread_pool is being destroyed during DLL unloading.
2018-10-25 14:33:31 -07:00
Larry Gritz 4156cb38a9 null input reader: be more careful with "full" (display) size (#2042)
For the "null" reader, we were clobbering any configuration hints about
the "full" (i.e. "display window") size parameters. This had bad effects
when using a fake "null" image along with ImageCache::add_file() in
order to set up an in-memory buffer that behaves like a texture, if that
buffer was a crop region or had overscan.
2018-10-25 12:09:13 -07:00
Grégoire De Lillo db706bb42a [RAW] fix TimeStamp typo in exif (#2040) 2018-10-25 08:48:11 -07:00
marsupial c4ec9e616f Default to use vanilla boost (#2039) 2018-10-24 18:00:02 -07:00
Larry Gritz 636812bc65 Travis adjustments
* On OSX, need to install gcc in order to resolve a missing symbol that
  numpy needs.

* On Linux, remove the "sudo: false", Travis is phasing this out.

* Make sure that any branch with "travis" in the name runs all travis
  tests, not the abbreviated set.
2018-10-24 11:22:15 -07:00
Larry Gritz 96764a99d4 Add == and != to span and span_strided (#2037) 2018-10-22 10:59:45 -07:00
Larry Gritz d54109e2c5 Remove stale python examples (#2036)
These were never documented, never made part of the test suite,
and have not been maintained to keep up with the evolving APIs.
They serve no real purpose, so just get rid of them.

Fixes #1621
2018-10-22 10:48:27 -07:00
Larry Gritz 1d8739962f Fix docs typos 2018-10-21 23:00:03 -07:00
Larry Gritz eda9b2e4f8 Strutil enhancements (#2033)
1. Turn join() into a template that can act on any iterable container
   of objects that allow stream output.

2. New splits()/splitsv() that directly return a vector of string or
   string_view, respectively (more modern C++ idiom than passing a
   result vector as an argument).

3. A second version of extract_from_list_string that directly returns
   a std::vector (instead of being passed as an argument).

4. Minor fix in unittest.h to allow the OIIO_CHECK_EQUAL macro work to
   compare std::vectors. (This utilizes the new join() to turn them into
   strings and thus allow them to output with <<).
2018-10-19 10:27:39 -07:00
Larry Gritz 834d1b4b72 Release an official FindOpenImageIO.cmake (#2027)
* Make an official FindOpenImageIO.cmake, borrowed from OSL but with some
  minor changes. It will install into INSTALL_PREFIX/share/cmake/Modules

* We hope that downstream projects that have OIIO as a dependency will
  use/copy this file, rather than having a dozen or more slightly
  different versions that downstream projects all write themselves. And
  if there are any deficiencies, they will push fixes or improvements to
  this master copy.

* Change places where we expect the cmake and/or environment variable
  OPENIMAGEIOHOME to be named OPENIMAGEIO_ROOT_DIR (more standard naming
  convention by modern cmake standards).

* Simplify FindOpenEXR.cmake, to conform to conventions as well as to
  get rid of some flexibility that is nonstandard and that we didn't use
  anyway.

* Some other very minor fixes to the cmake files (INSTALL_DOCS was
  declared in two different places, etc.)
2018-10-13 14:29:58 -07:00
Larry Gritz c1dbc6c87b Fix for TIFF with unassociated alpha (#2032)
If read_scanlines (et al) was called with the 'format' parameter as
TypeUnknown -- which is supposed to mean "use the native format" --
would accidentally and silently fall through the switch statement inside
OIIO::premult(), causing it to do nothing.

If called with an explicit type, it all worked find. Subtle to track down.

The particular symptom was that if you were calling ImageBuf::read()
with `force=true` but relying on the default `convert` value of UNKNOWN
(meaning, no conversion, stay in native format), it would trigger this
bug and neglect to premultiply the unassociated colors.
2018-10-12 09:28:52 -07:00
marsupial b9f717889f [CMake] Allow builds outside the source tree to pass testsuite. (#2026)
Allow builds outside the source tree to pass testsuite. Defaults to finding oiio-images, openexr-images, libtiffpic in the usual ".." from the main oiio source directory, but now it can be overridden with the CMake variable OIIO_TESTSUITE_IMAGEDIR.

Also minor change to append to CMAKE_MODULE_PATH rather than clobber it.
2018-10-10 14:06:29 -07:00
Larry Gritz e962dede0e Improved memory-use debugging (#2028)
* ImageBuf: more careful tracking of allocations, print alloc/free/total
  messages when "debug" attrib (or env OPENIMAGEIO_DEBUG) > 1.

* Change interpretation of the debug attribute so that 1 is ordinary
  debug, values > 1 are extra debugging for developers.

* Add oiio query for process resident memory in MB (this is helpful
  for Python scripts that want to check how each OIIO call they make
  might have changed the overall memory footprint).
2018-10-10 08:58:39 -07:00
Larry Gritz 253ff36847 RAW: control of libraw's correction for chromatic aberration (#2030)
Using a new "raw:aber" (float[2]) input config attribute.

Fixes #2029
2018-10-09 17:50:03 -07:00
Larry Gritz 01b926bd5d SPI: change in python setup 2018-10-09 17:00:49 -07:00
Larry Gritz fee7495f39 Bump pybind11 version from 2.2.1 to 2.2.4 (#2031) 2018-10-09 16:48:24 -07:00
darkhorse64 797b7dff63 Export symbols for Windows target (#2025) 2018-10-03 15:36:19 -07:00
Larry Gritz 0ebf7b22a3 CHANGES 2018-10-02 12:14:47 -07:00
Larry Gritz 51692ba4d6 IBA::channel_append() -- lift same-type restriction on input images (#2022) 2018-10-01 14:24:44 -07:00
aconty 4be05f856e Fix a double free of imagecache and add a replace mode for add_file() (#2021)
* Fix crash deleting not owned imagecache

Now that we allow providing an external ImageCache to the texturesys,
destroy handles its destroying and it shouldn't be done in the
destructor.

* Override existing file entries in add_file

Instead of assuming the present file is equivalent, nuke it and reset it
with the new parameters. This fixes a problem adding files after
somebody has asked for a handle. Also allow non mip-mapped files when
coming from user buffers.
2018-10-01 09:13:32 -07:00
Larry Gritz cb64d6f2fd ImageCache/TextureSystem create/destroy adjustment (#2019)
* Add an optional argument to TS::create() that lets the caller directly
supply a pointer to an IC (which will not be freed when the TS destroys --
it's owned by the caller).

* Add a TextureSystem::imagecache() method that returns a blind,
non-owning pointer to the underlying IC.

* Clean up the 'destroy' methods, which previously for the sake of not
breaking compatibility mid-release had two separate varieties, but
clearly they can be one signature with an optional argument.
2018-09-29 11:30:11 -07:00
Larry Gritz f88449f1d0 Fix possibly broken operator= for ParamValue. (#2018)
Should be a no-op for self-assignment.
2018-09-29 10:14:29 -07:00
marsupial b09100e83f OpenVDB build tweaks (#2017)
Use debug libs where possible. 
For SPI, use bump up the version of Field3D that we use.
2018-09-28 12:16:31 -07:00
Larry Gritz 5e4955f275 A little extra control to allow PYTHON_VERSION to select among versions (#2015)
on systems with multiple Python versions installed.

Make sure Travis tests have at least one 3.x test case (OSX, it's easiest).

Additional fixups for Python3.

Some extra SPI specific bending over backwards for our weird install
locations. And uniformize the spcomp2 vs arnold build scripts. And
remove the "lion" cases, we don't use that any more.
2018-09-28 10:29:52 -07:00
Larry Gritz 52e7524e79 raw DSLR image read improvements to color space identification. (#2016)
We were previously reporting "oiio:ColorSpace" for raw images always as
"linear", but that's not really how the underlying libraw operates.  It
converts to one of several color spaces as part of the debayering
process (by default, sRGB), so make sure to report back the correct one,
which should be the one you ask for. Also, no need to set the
"raw:ColorSpace" attribute, that doesn't really tell you anything
useful (it just repeats back the hint you asked for, but that's the same
as the "oiio:ColorSpace").
2018-09-28 10:29:29 -07:00
marsupial 47e9a4c501 OpenVDB read support (#2010) 2018-09-26 08:24:18 -07:00
Larry Gritz 30ebb35fde ImageCache: add a way to add_tile without a pixel copy (#2012)
The point of this feature is that your app has a buffer of pixels, and
you want the IC or TextureSystem to use that buffer directly, without
copying the texels or owning the memory. It should also not count the
memory against the limits of the cache.

See imagecache_test.cpp, the test I added as text_app_buffer() which
pretty much spells out how to do it from the app point of view.

From an API standpoint, all that changes is an optional argument to
add_tile that lets you disable the copy.

You need to make it a tile of an image in the cache, though, and the
obvious no-drama choice is just to use a "null" ImageInput as a
placeholder.  In the process, I noticed two helpful enhancement I could
make to the null ImageInput better:

1. Make sure that passing a "config" spec results in the right resolution
   and data type -- in fact, there was a bug where the config's res would
   be overwritten by a 1024x1024x4xUINT8 default. Oops. So only overwrite
   those fields if they are not set in the config.

2. What if you want one of these fake inputs but you don't want the name
   of the texture to be "blah.null"? So I added it so that if the config
   has metadata hint "null:force" set to nonzero, it will always succeed
   in creating a null ImageInput.
2018-09-24 11:48:19 -07:00
ThiagoIze ebc51c68be Fixes rare crash when lowering number of threads, which causes the excess threads to be detached, and one of these deteached threads happens to not yet have terminated before the thread pool is destroyed. (#2013) 2018-09-23 22:47:10 -07:00
Larry Gritz 360c79afb5 SPI: fix missing rpath 2018-09-20 15:08:09 -07:00
Larry Gritz 6ff266f78e Docs build/install inadvertently disabled for some time, ugh (#2011) 2018-09-19 16:15:58 -07:00
Larry Gritz 8c127d6078 SPI: clang 6 and 7 build locations, switch default to clang7 2018-09-19 11:30:03 -07:00
Larry Gritz 015ab00347 Reorganize how texture3d transforms points to local space of the volume. (#2009)
* Reorganize how texture3d transforms points to local space of the volume.

What happens when texture3d is called on a point? There was a special
back door for Field3d, but this didn't generalize well. For example, we
want to support texture3d lookups from OpenVDB files (coming soon under
a separate PR -- this is a necessary prelude).

This patch:

* Makes each ImageCacheFile::SubimageInfo contain a unique_ptr to a 4x4
  matrix (so it doesn't use as much space except when needed, which is a
  small minority of all texture files).

* If reading the spec for that subimage yields a "worldtocamera" or
  "worldtolocal" matrix metada, we allocate the space and stash the
  matrix there.

* The texture3d() call looks for the matrix, and if found, uses it to
  transform the input point to the local volume space. Only if this is
  not found does it check for the special field3d back door (which
  exists because f3d supports time-varying transforms that aren't a
  single matrix). If that, too fails, then no transform is applied.

* Some unused fields that were disabled by USE_SHADOW_MATRICES were
  removed entirely, since we have no current plans to implement shadow
  maps (and could easily re-add if we change our minds).
2018-09-18 16:44:58 -07:00
Daniel Flehner Heen 67c2c7369b Use pkgconfig in FindOpenEXR.cmake if available (#2008)
* added search for IlmBase and OpenEXR with pkgconfig if found

* Added _ILMBASE/OPENEXR_LIBDIR variables found by pkgconfig to GENERIC_LIBRARY_PATHS
2018-09-16 22:49:57 -07:00
Larry Gritz b637b4ee0f For Travis Linux, build against OpenEXR 2.3.0 (#2007)
No longer need to build an lgritz private one, since 2.3.0 has some
fixes we needed for gcc7 and C++17 compatibility.

Also move the OpenEXR download and installation into the ext/ subdir
where we put other build dependencies.

For SPI, change the site/Makefile-bits files so that OPENEXR_HOME env
variable can override the default system install of OpenEXR (makes it
easier for me to test custom builds).
2018-09-13 10:13:08 -07:00
Larry Gritz 5612f83a8b SPI build updates, mostly for upgrade of our libraw (#2006)
Also includes some touch-ups for warning-free and test-pass use of the
particular flavor of libraw 0.18.11 we are using.
2018-09-11 14:42:12 -07:00
Pascal Lecocq 91899fcfb6 More robust detection of input bumpmap format. (#2005)
The bumpslopes exporter originally assumed that a 3 channels bumpmap input corresponds to a
normal map. However, depending on the bumpmap creation process, it's not unsual to end up
with grey RGB heightmaps that we incorrectly interpret as normal map.

To prevent this situation we added a safety check to determine if the input map is
monochromatic or not.
2018-09-07 15:22:31 -07:00
Larry Gritz 7b6328bd9a CHANGES 2018-09-02 12:03:58 -07:00
Justin Israel a9a731c229 Fix ImageSpec::erase_attribute using backwards logic for casesensitive (#2003) 2018-09-02 10:00:05 -07:00
Larry Gritz 803503eff5 JPEG output: more robust handling of "density" outputs. (#2002)
The X_density and Y_density fields in the JPEG header are uint16. We
were botching it if it happened to think the pixel densities were
expressed as values needing > 16 bits. Do some refactoring and handle
this case cleanly.

Fixes #1999
2018-08-30 23:07:06 -07:00
Simon Boorer 7434340a43 Fix segfault when reading gif with Comment Extension and no Comment Data (#2001) 2018-08-30 11:14:18 -07:00
Chris Kulla 9a99eef8fb Fix uninitialized read within texture system 2018-08-29 14:07:29 -07:00
Larry Gritz a50e0af020 Partial revision of 1998 -- didn't need to include simd.h in unittest.h 2018-08-29 10:54:53 -07:00
Larry Gritz ae4a57558e unittest.h: OIIO_CHECK_EQUAL_APPROX - fix namespace ambiguity (#1998) 2018-08-28 21:33:49 -07:00
Larry Gritz 97f665e594 Unit test for ImageBuf ROI access and roi_contains() and ImageSpec roi access (#1997)
Prompted by Justin Israel's patch 1996

... and in the process of making a good unit test, I found a minor bug
in the ImageSpec ctr from an ROI -- the data window was set properly, but
the display window (aka "full roi") got the proper width/height but not
the right origin. Yay unit tests!
2018-08-26 15:40:39 -07:00
Justin Israel e30c0e6e14 Fix ImageBuf::contains_roi always returning true (#1996) 2018-08-25 16:18:44 -07:00
Larry Gritz 4a5d5ef817 Fixes for clang 7.0 compile (#1995)
* Fix simd.h warnings revealed on clang 7.0 (1995)

C++17 allows "constexpr if" which would have fixed this. But with C++11/14
and clang 7, we get itcky warnings about some of the simd_test generating
code (that will never run) that overruns some bounds. Solved with some
template ugly.

* Fix clang 7 errors (1995)

It really doesn't like some 'const' issues on boost thread.  We only use
it a couple places.

Replace boost::call_once and boost::hardware_concurrency with std versions.

There's no std equivalent for physical_concurrency(), so just the
problematic compiler, punt and implement it as hardware_concurrency.
2018-08-16 18:16:20 -07:00
Larry Gritz 17ab627d6d ImageBufAlgo::fit() (#1993)
Like resize, but it preserves the original aspect ratio, resizing to
fill the ROI as well as it can without stretching.

This is really just moving the logic of "oiiotool --fit" into its own
ImageBufAlgo function.
2018-08-09 11:44:22 -07:00
Fabien Castan 9f3fac4cae [doc] INSTALL.md: add openjpeg optional dependency (#1989) 2018-08-01 05:21:54 -07:00
Larry Gritz cb229b4a6f CHANGES
[ci skip]
2018-07-24 15:34:02 -07:00
Larry Gritz a9c30bd5d0 oiiotool: Minor --help output reformatting 2018-07-24 14:22:22 -07:00
Larry Gritz 1dfbd8ebe0 Overhaul of raw handling of makernotes and metadata (#1985)
This was very incomplete before. It broke under libraw 0.19, and
investigating I realized that libraw had some recently-added bits
(as of 0.18) that lets met get at a whole lot more metadata. Also, we
now support many camera makes that we didn't before, and have added
new tests to reflect this.

Re-enable Travis testing of libraw on OSX, we had disabled it a few
commits ago, when libraw 0.19 was released and started failing tests.
This fixes it better than it was before.
2018-07-23 10:29:27 -07:00
Larry Gritz 2c25cac1a2 Fixes to handle input images with unassociated alpha ("unpremultiplied") (#1984)
It's an abomination, but it's one we have to sometimes live with.
This patch has several small goodies for people who are forced to
deal with "unpremultiplied" images.

* A variety of fixes to oiiotool --no-autopremult, which turns off the
  automatic premultiplication that is ordinaryily done for
  unpremultiplied inputs. It was only working for inputs that were
  backed by the ImageCache, which excluded small files read directly,
  and also excluded --info results (which bypass the cache and to
  straight for an ordinary ImageInput).

* iv: add a `--no-autopremult` flag, much like the one for oiiotool.
  This makes it easier to use iv to examine the unmodified input values.

* TIFF read: be sure to set an attribute called "tiff:UnaociatedAlpha"
  to indicate that the original input was unpremultiplied in the file,
  regardless of whether the usual auto-premultiplication was used upon
  input.
2018-07-19 22:07:25 -07:00
Larry Gritz abb52a2a42 RefCnt enhancement: release() (#1986)
refcntptr::release() sets the pointer to null and reduces the ref count,
returns the original pointer, but does NOT free the object even if the
new ref count is 0.
2018-07-19 18:13:24 -07:00
Larry Gritz fb280bc84c Print metadata (oiiotool -info -v, etc.) in sorted order.
Alphabetically, but case-insensitive, locale-independent, and with
"un-namespaced" metadata appearing before "namespace-prefixed" metadata.

The main purpose is to canonicalize the order of appearance of metadata
in test reference output. This minimizes the amount of reference output
churn that happens when we change code of image format readers, or upgrade
reader libraries, or add support for new metadata.
2018-07-10 00:10:13 -07:00
Larry Gritz abfe89362c Strutil: additional string comparisons
Add iless(), case-insensitive locale-independent string_view comparison.
Analogous to iequals, etc.

Also augment the StringEqual functor with StringIEqual, StringLess,
StringILess.

These collectively make it a bit more convenient to do certain
case-insensitive string sorting.
2018-07-10 00:10:13 -07:00
Larry Gritz d3174e6a78 Use TravisCI conditions to limit builds (#1983)
We have a growing matrix of tests, and there is development friction
from the fact that every push to a working branch kicks off the whole
matrix, many of which exist to test very specialized things that are
probably not changed by the vast majority of patches.

TravisCI recently started supporting "conditions" that can let you limit
which test cases or stages to run.

I'm proposing that the full test matrix always run when it's:

* a pull request
* a direct push of an updated "master" or "RB" top of tree.
* a nightly cron jobs (which, also, are only for "master" and certain
  "RB" branches)

But in other cases -- that is, ordinary work branch pushes while we
develop -- there are many tests that don't really need to run every
time, and just clog up our Travis queue. So I'm adding the following
exclusions:

- The tests that exist solely to make sure we don't break simd.h (builds
  that exercise AVX2, avx512, and no SIMD) will now only build for
  working branch pushes if the branch name includes the substring
  "simd". (Pro tip: if you are editing simd.h or using it heavily in
  your modified code, name your working branch to include that substring
  to force those tests to run on every push.)

- The tests for gcc8 and/or C++17 (which aren't yet documeted as blessed
  by VFXPlatform) only run for working branch pushes if the branch
  includes the substring "gcc" or "17", respectively.  (Note: since
  gcc6 and C++14 *are* VFXPlatform blessed, those tests are never
  excluded.)

- The test that runs sanitizers, which takes ~4x longer to run than
  other tests, only runs from ordinary working branch pushes if the
  branch name includes the substring "san".

The neat thing is that with the exclusions, an ordinary working branch
push that not have its name indicate that it cares specifically about
simd, san, gcc8, or C++17), only has 5 tests in the remaining matrix,
which is exactly the amount that TravisCI will parallelize. Thus, the
new "common case" will complete its CI in roughly the time it takes to
do just one matrix entry (~10-15 minutes), versus the full test suite
that would have taken 3-4x that.

Remember that this is just for working branch pushes. Once you submit
your work as a PR, the full test matrix will be run.
2018-07-10 00:06:19 -07:00
Larry Gritz 133b2e49aa Select gcc string ABI, etc. (#1980)
Add a build-time option to select which std::string ABI to use.
Building with GLIBCXX_USE_CXX11_ABI=1 uses the new (C++11 compliant) ABI,
building with =0 uses the traditional gcc string ABI for compatibility.
This only affects gcc builds.

Also automatically define _GLIBCXX_SANITIZE_VECTOR=1 when compiling for
sanitize mode, it turns on some extra instrumentation to detect running
off the end of a std::vector but still within its allocated capacity.
2018-07-05 16:38:55 -07:00
Larry Gritz 67ea7ea953 Travis: on OSX, don't load libraw from homebrew (#1981)
libraw on homebrew just upgraded to the new 0.19.0. This breaks our raw
tests (builds ok, but seems to not find all the metadata). I'm not sure
if this is a bug in 0.19.0, or if the API changed in some way that we need
to change things on our side. But in either case, it's a more lengthy
investigation than I have time for today, so disabling it on OSX Travis
tests seems like the expedient workaround. Libraw (0.15) is still exercised
on the Linux Travis tests.

As soon as I track down the real problems satisfactorally, I'll restore
the tests.
2018-07-04 15:50:18 -07:00
Fabien Castan a72af0036f [cmake] ffmpeg ensure minimal version 2.6 is required (#1963) 2018-06-30 12:04:15 -07:00
Daniel Flehner Heen 81a7f24c7f Added "zips" to the list of compressors in the OpenEXR plugin documentation (#1979)
* Added missing "zips" to the list of known compressions in the OpenEXR plugin documentation
2018-06-29 09:56:03 -07:00
Larry Gritz 00ae02c17e Fix gcc8 warning 2018-06-26 23:05:26 -07:00
Larry Gritz aa53a59652 Use -Wall on CI tests, even if disabled in branch 2018-06-26 21:47:02 -07:00
Larry Gritz ac8640815b Various fixes to allow clean C++17 compilation 2018-06-25 23:05:01 -07:00
Larry Gritz 0a170f0691 Replace function_view implementation with the one from LLVM.
I found that the one we'd been using has some pesky issues with C++17
that sometimes fails to match because of noexcept problems.

The equally short one from LLVM (UIUC license, for all practical purposes
equivalent to BSD) appears to work and does not suffer from these problems.
So just swap out the implementation.
2018-06-25 20:58:42 -07:00
Larry Gritz d7e239e99c Add C++17 to test matrix 2018-06-25 20:58:42 -07:00
Larry Gritz ec5df4b847 Make Travis on OSX tests include field3d, ffmpeg, opencv (1977) 2018-06-25 15:41:07 -07:00
Larry Gritz 60c96b3d30 Fix potential field3d mutex deadlock (1977) 2018-06-25 15:39:29 -07:00
Larry Gritz 33ba42bce9 Revert "Fix potential field3d mutex deadlock (#1972)"
This reverts commit 27ffc00e22.
2018-06-24 22:59:35 -07:00
Larry Gritz d544ac11ac Infrastructure to test against gcc8 (1974) 2018-06-24 16:31:06 -07:00
Larry Gritz 34e64cb544 Fix gcc8 warnings (1974)
Note the change to test_array_view_initlist... the warning text from gcc
was nearly impossible to understand, but we were indeed violating the
rule about the data needing to have a lifetime that outlasted the
span. Rearranged the code to be compliant, and the warning went away.
2018-06-24 16:31:01 -07:00
Larry Gritz 2a80494775 Fix gcc8 warnings (1974) 2018-06-24 16:30:56 -07:00
Larry Gritz 6eaaeba91f Fix gcc8 warnings about TextureOpt class (1974) 2018-06-24 16:30:51 -07:00
Larry Gritz 6fa11fb1a0 Eliminate memcpy from ParamValue implementation that gave gcc8 warnings (1974) 2018-06-24 16:30:47 -07:00
Larry Gritz 94629acaec Replace strncmp with our safer version, also fixes gcc8 warnings. (1974) 2018-06-24 16:30:41 -07:00
Larry Gritz da82c36cbd Fix potential bug of null memcpy (1974) 2018-06-24 16:30:29 -07:00
Larry Gritz efa132a692 More modern way to test endian. (#1973)
Replicate the `endian` enum class that will be in C++20 (eventually we'll
eliminate our own) instead of nonstandard tricks.
2018-06-21 18:10:24 -07:00
Larry Gritz 27ffc00e22 Fix potential field3d mutex deadlock (#1972)
Field3DInput::valid_file locked, then called open() which also locked.
How did this ever work? Yet, this was only symptomatic in one internal
renderer test, and only when OIIO was compiled in DEBUG mode.

The simple solution is just to change to a recursive lock. Field3d isn't
an important enough file type to try to be more clever than that.
2018-06-21 15:23:34 -07:00
Larry Gritz 9b3078bfd2 Overhaul ImageBufAlgo API (#1961)
We make four large changes across the board in ImageBufAlgo.

1. No more raw pointers.

All functions that take per-channel constants, or destinations for
per-channel outputs, in the form of (pointer, length) -- or worse, just
a pointer and an assumed length big enough to hold all channels -- are
being deprecated, in favor of passing span<>. This will let the IBA
function implementations check lengths and deal appropriately, also
makes it very easy for the caller to pass a single float that will be
understood to be replicated for all channels.

2. ImageBuf return results

All existing functions of the form

    bool IBA::func (ImageBuf& result, ...input args...)

are getting an additional variant,

    ImageBuf IBA::func (...input args...);

For most ordinary uses, this transforms the awkward

    ImageBuf Result;
    ImageBufAlgo::add (Result, A, B);

into the more compact and intuitive

    ImageBuf Result = ImageBufAlgo::add (A, B);

Through the magic of C++11 "move" semantics (aka "rvalue assignment"),
this does not incur an unnecessary copy of the whole ImageBuf.

The old function forms will remain as first class citizens and are stil
useful in cases where you are repeatedly doing operations (so want to avoid
repeated allocation), or you want to use ROI's to write partial results of
the operation into a sub-region of an existing image.

This carries over to the Python API as well, where the old idiom

    Result = ImageBuf()
    ImageBufAlgo.add (Result, A, B)

was especially "non-Pythonic" looking, compared to

    Result = ImageBufAlgo.add (A, B)

3. Reduce combinatorics of Image vs constant.

For some functions, such as mad(), which computes A*B+C, a whole bunch
of clutter is necessary to handle the various combinations of

    image * image + image  ->  mad (const IB&, const IB&, const IB&)
    image * const + image  ->  mad (const IB&, span<const float>, const IB&)
    image * image + const  ->  mad (const IB&, const IB&, span<>)
    const * image + const      ...
    etc.

In fact, we need 7 variants (excluding const*const+const, which is not
useful because you don't know how big the resulting image would be).

These have all been replaced by a single variant,

    mad (Image_or_Const A, Image_or_Const B, Image_or_Const C)

using a special new class just used for parameter passing,
Image_or_Const, which can "wrap" either an ImageBuf or a float or a
span<const float>, and let the implementation sort it all out
internally.  It really de-clutters the declarations! And it also forces
us to ensure in these cases that all the combinations are accounted for.

4. Some IBA functions that generate structs with data, such as compare(),
computePixelStats(), and histogram(), now directly return those structures
instead of needing them pre-declared and passed as reference paramters.
Thanks to the magic of C++11 'move' semantics, this is no longer expensive,
and it's a more intuitive way to structure the API. (The old versions of
the functions still are available, but are considered deprecated and will
be removed in future releases.)

In the process of these changes, I've done a substantial rewrite of both
the IBA and Python chapters of the docs, as well as all the verbose
comments in imagebufalgo.h itself that explains the functions.
2018-06-18 16:47:31 -07:00
Larry Gritz 42f9fee236 Fix typo in windows code for Filesystem::IOFile::pread (#1969) 2018-06-14 17:13:40 -07:00
Larry Gritz bf1c9ccbc0 More flexibility for IC::get_image_info / TS::get_texture_info (#1968)
What happens when you use IC/TS to retrieve metadata and get the type
slightly wrong? Like if the actual metadata is an OpenEXR box2f (which
OIIO represents as TypeDesc(FLOAT,VEC2,NOXFORM,2)), but you have asked
to retrieve it as float[4] (OIIO TypeDesc(FLOAT,4)).

It was failing, because the array lengths didn't match. But I think it
should succeed because they are both 4 floats underneath. This is
especially important if the query is coming from OSL, which doesn't have
a vec2 or a box2f type, and the only way you can ask for this metadata
would be into a float[4].

Simple fix: check for compatibility of basetype and basevalues(), not
for matching arraylength().
2018-06-14 16:22:38 -07:00
Larry Gritz 7c104d572b Texture map overscan + clamp (#1965)
Add a test case for this. It worked fine on the runtime side.  The
maketx side needed a minor fix to know that overscan was ok with clamp
(instead of forcing black wrap for all overscan cases).
2018-06-14 09:58:32 -07:00
Larry Gritz 309afb834a Modify robin-map download to look in system first (#1964)
Instead of downloading unconditionally, look for system install.
2018-06-14 08:42:42 -07:00
Larry Gritz ba05d3f08f docs typos 2018-06-12 00:10:34 -07:00
Larry Gritz 6c9a21db28 docs: pdflatex --file-line-error for better errors
Just discovered the --file-line-error option to pdflatex, which causes
error messages to explicitly mention the file and line number in the
.tex. Saves so much work! I can't imagine why that's an option. Who in
their right mind would want pdftex to halt on error, but make it
difficult to debug by not telling you what line and file the error
occurred on?

Also fixed a stray nonstandard character, that I guess was missed by
older TeX but caught now that on my personal machine I upgraded LaTeX
to a more modern TeXLive release.

[ci skip]
2018-06-11 11:21:06 -07:00
Larry Gritz 3f2f379ca6 Fully move the guts of array_view to span. (#1956)
Now array_view is a synonym for span, rather than the other way around.
Both will work for legacy client apps for some time, but for OIIO internals
we should start favoring span when convenient.

A few minor fixups to make some existing methods and in-class types
match the C++ standard. One change, as dictated by C++20 std::span<>
specification, is that span.size() returns a ptrdiff_t (signed) rather
than a size_t.  This may create some minor build issues with signed vs
unsigned warnings. Something to watch out for.
2018-06-08 10:46:49 -07:00
Larry Gritz 732d9884d0 Fix Python typo bug (#1960)
Spotted an obvious typo in make_numpy_array.

The manefestation of the bug is that ImageInput.read_scanline would
make the wrong "shape" of the numpy array, mashing all channels of all
pixels in the scanline into a 1D array of values, instead of properly
making it a 2D array of pixels which are each arrays of the channels
within a pixel.
2018-06-08 10:45:47 -07:00
Gonzalo Garramuño 3aebf5f66a Bug fixed FindLibRaw to work also on Windows. (#1959) 2018-06-04 09:03:46 -07:00
Larry Gritz be0d20076b CHANGES 2018-05-31 22:06:48 -07:00
Larry Gritz 92b5bc4eca ImageBuf: add pixel data type override to write() method (#1953)
This avoids the need for separate set_write_format() call if you're only
needing it to affect this one write call. Less clunky this way.
2018-05-31 22:02:29 -07:00
Larry Gritz 5c8549fbe5 ImageBuf: tweak copy and assignment (#1952)
* Add a 'move' constructor
* Add variety of copy() that returns a copy of *this.
* Add operator=, both copy and move varieties.
2018-05-31 22:02:17 -07:00
Chris Kulla 749f40154a Implement fast version of cbrt
This uses an approximation found in the classic Hacker's Delight book. It is slightly less accurate but roughly 3x faster than glibc on my machine.
2018-05-31 17:46:27 -07:00
Larry Gritz 41e7bdbc64 span.h: Work towards the C++20 nomenclature (instead of array_view) (#1954)
Something exactly like our array_view<> template is coming to standard
C++20, but it's named span<>. Slowly, we will migrate our nomenclature
and behavior to match it exactly, eventually (I assume in the late
2020's) just switching entirely to std.

In this first step, we merely establish a span.h that defines span<> as
a template alias for array_view<>. This will let applications (and our
internals) freely use array_view or span as synonyms. I will even
backport this change to older branches, since it's totally harmless to
existing code that uses array_view.

In a later step (not this patch) in master only, we'll swap those roles,
so that moving forward, span<> will be the "real" template, and
array_view will be the synonym for compatibility with legacy apps.
2018-05-31 17:45:22 -07:00
Christopher Kulla 25b8e4cd47 Specify gcc-toolchain for clang explicitly for SPI builds 2018-05-30 16:01:35 -07:00
Larry Gritz 99e6599fb3 IC/TS close() and close_all() methods (#1950)
The existing methods invalidate() and invalidate_all() fully invalidate
everything the IC/TS knows about a file (or all files) -- the specs,
the pixels, etc.

But sometimes you just want to close any currently-open handles, but not
necessarily forget about what you know about those images, or any pixel
tiles in the cache. That wasn't possible before, but this patch adds the
functionality as close(filename) and close_all() methods to both IC and
TS.

One interesting use case that this enables is a render-paint loop:

    render();
    ts->close_all();
    ... here, it's ok to modify the texture files ...
    ts->invalidate_all (false);
    render();
    ... repeat

The close_all(), performed after the render, closes any open file
handles, which is especially important on Windows where the IC holding
the file open essentially locks the files. Then, right before the
next render, invalidate_all(false) will fully invalidate any files that
have been modified since they were last opened, but not any whose
modification time has not changed.

Note that the act of closing means that if additional tiles need to be
read from disk, it will need to re-open the file. But as long as
any pixels needed are already in the cache from last time, it may not
need to re-open at all.

To make it easier for apps to detect if the new methods are available,
we define preprocessor symbols OIIO_IMAGECACHE_SUPPORTS_CLOSE and
OIIO_TEXTURESYSTEM_SUPPORTS_CLOSE in imagecache.h and texture.h,
respectively.
2018-05-29 21:17:00 -07:00
Larry Gritz 535f7d8df1 ImageBuf::set_origin() (#1949)
We had set_roi_full() to change the display window metadata, needed an
equally easy way to alter the pixel data window origin. (But note that
for pixel data, it's only safe to change the origin with metadata, not
the size, which would change the whole pixel data layout, lead to
reallocations, etc.)
2018-05-25 13:36:48 -07:00
llamafilm c721ad3618 Update FindOpenJpeg.cmake directory search (#1948)
Add MacPorts installation directories
2018-05-25 10:16:58 -07:00
aconty 8c49d0d4ee Fix iv on OS X with QT5 (#1946)
* Fix iv on OS X with QT5

* Stop updating the progress bar in iv int paintGL

* Fix pixel view in iv viewer
2018-05-24 11:54:48 -07:00
Larry Gritz e93d7f84f3 Bump dev version 2018-05-22 15:13:48 -07:00
Larry Gritz 07ed160a85 CHANGES 2018-05-22 15:11:44 -07:00
Larry Gritz a019fbdec4 Fix unique_ptr use (#1945)
I really over-engineered the previous commit.  The awkward
unique_ptr-with-deleter is not needed after all. I don't need the
deleter to live in every individual plugin, as long as I can ensure that
the allocation and free both happen in the same place -- libOpenImageIO.
And I can do that by overloading operator new and operator delete, then
using the standard unique_ptr flavor.

This patch backs out of much of the previous one (no individual deleter
functions are needed). Simpler. Not sure why I didn't realize earlier
that this would work.
2018-05-22 13:20:02 -07:00
Larry Gritz 29110dae8d ImageInput and ImageOutput creators change to return unique_ptr (#1934)
ALERT! This is a breaking change! But I think it's a simplification,
more modern code style, make using OIIO easier and less error prone.

Previously, ImageInput::create(), ImageInput::open() [the static one],
and ImageOutput::create() returned a raw pointer, allocated by the
plugin's create function, and it was up to the client code to properly
manage and free it.

On Windows, it's not safe to delete in one dll when the new came from a
different dll. That's why we had ImageInput::destroy(), but
unfortunately I realized recently that only works properly for the
readers/writers compiled into libOpenImageIO itself.  It could
potentially fail with mysterious heap corruptions if you used a true dll
plugin to implement a custom format reader/writer.

This patch proposes to change all of these functions to return a
unique_ptr with built-in deleter, so all resources are managed and will
automatically be released when the pointer goes out of scope or is reset.
Because the deleter is supplied by and in each individual module where
the new occurs, the possible heap corruptions are fixed once and for all
for ordinary C++ ImageInput & ImageOutput usage.

It touches a LOT of files, but it's repetition of conceptually simple
changes:

1. Some new type definitions are added to the ImageInput class definition:

        /// Call signature of a function that creates and returns an ImageInput*
        typedef ImageInput* (*Creator)();
        /// Call signature of an ImageInput deleter.
        typedef void (*Deleter)(ImageInput*);
        /// unique_ptr to an ImageInput, with custom deleter.
        using unique_ptr = std::unique_ptr<ImageInput,Deleter>;
        /// Return an empty unique_ptr (no default ctr of unique_ptr with deleter)
        static unique_ptr empty_ptr() { return unique_ptr(nullptr, destroy); }

2. For each plugin, in addition to a creator like this:

        OIIO_EXPORT ImageInput *tiff_input_imageio_create () { return new TIFFInput; }

   the plugin must also supply a deleter:

        OIIO_EXPORT void tiff_input_imageio_delete (ImageInput *p) { delete p; }

3. The signature of the static ImageInput::create() and open() methods
   change to returning a unique_ptr, for example, from

        static ImageInput *open (const std::string &filename,
                                 const ImageSpec *config = NULL);

   to

        static unique_ptr open (const std::string &filename,
                                const ImageSpec *config = nullptr);

4. App code therefore gets a lot safer and easier. Old:

       ImageInput *in = ImageInput::open (filename);
       in->read_image (...);
       in->close ();
       ImageInput::destroy (in);

   new:

       ImageInput::unique_ptr in = ImageInput::open (filename);
       in->read_image (...);
       in->close ();

   and if you are a fan of `auto` and take advantage of the fact that
   destroying an ImageInput forces a close if not already done, it's just:

       auto in = ImageInput::open (filename);
       in->read_image (...);

5. Analogous changes for ImageOutput.

6. Note: It's a little tricky to default-construct a unique_ptr that
   has a deleter.

        ImageInput::unique_ptr A = ImageInput::open (filename); // YES
        ImageInput::unique_ptr B;    // NO! Compiler rejects!

   If you need to do this, use the empty_ptr method:

        ImageInput::unique_ptr B = ImageInput::empty_ptr();  // YES

7. The OIIO_PLUGIN_VERSION definition has been changed from 21 to 22.
   So if you have client code that must work with new and old OIIO APIs,
   it might be handy to do something like this:

       #if OIIO_PLUGIN_VERSION >= 22
           ImageInput::unique_ptr in = ImageInput::create(...);
       #else
           ImageInput *in = ImageInput::create(...);
       #endif
2018-05-18 17:07:18 -07:00
Chris Kulla 5f90bf5186 Fix discontinuitity in atan approximations near 1.0 by nudging the coefficients of the approximation 2018-05-17 15:05:12 -07:00
Larry Gritz d950aeb272 Avoid warning from pybind11 vs Python.h interaction (#1939) 2018-05-16 20:51:52 -07:00
Larry Gritz 604e8aa602 Filesystem UTF-8 cleanup (#1940)
* unique_path() and temp_directory() were not properly handling UTF-8
  results on Windows.

* A whole lot of #if cleanup by adding u8path and pathstr functions.
2018-05-16 20:44:24 -07:00
Larry Gritz 9cbb4789b7 OpenEXR better UTF-8 filename support (1941)
We already were careful when opening the file to use the
OpenEXRInputStream to ensure proper UTF-8 filename handling.

But valid_file() used Imf::isOpenExrFile, which is not careful enough.
So we instead switch to making an IStream and then calling the version
of isOpenExrFile that takes the stream. Should be correct.
2018-05-16 20:21:06 -07:00
Larry Gritz 791597c473 Fixes to un-break the EMBEDPLUGINS=0 build (#1942) 2018-05-16 08:42:40 -07:00
Larry Gritz f34a2f4905 Adjust __GLIBCXX__ test guarding use of std::atomic_load(ptr) (#1937)
I didn't realize that the prior number I picked inadvertently included
a 4.9 version that did not in fact support this feature.

Changing to the new value will not have ny more "false positives" (error
by incorrectly thinking the feature is present), but does make a "false
negative" (avoid the feature even though it's supported) for gcc 5 and
gcc < 6.2, even though it would work there. That will still behave
correctly, though at a very slight performance penalty, but VFXPlatform
skips from gcc 4.8 to gcc 6.3, thus leapfrogging over those false
negative cases. So I'm going to not care that we get less than maximal
performance from some compiler+library versions that we are unlikely to
use.
2018-05-11 09:11:51 -07:00
Larry Gritz 8352f5bad7 New feature: I/O proxies (1931)
ImageOutput and ImageInput supports("ioproxy") will return true for a
format reador or writer that supports the ability to use a
Filesystem::IOProxy object for customized I/O.

For supporting formats, the caller can pass the IOProxy via
a special attribute in the ImageSpec that is passed to
ImageOutput::open() or the configuration ImageSpec passed to
ImageInput::open():

    "oiio:ioproxy" (PTR) is a pointer to a `Filesystem::IOProxy`.

One use for this is to read an image "file" from an in-memory buffer
(using the IOProxy subclass IOMemReader), or to write an image "file" to
an in-memory buffer (using the IOProxy subclass IOVecOutput).

The documentation (in the ImageInput and ImageOutput chapters) and
imagebuf_test.cpp contain examples showing how to do this.

It's also pretty straightforward for both ImageBuf and ImageCache to do
this, since in both cases there is a way to declare the configuration
spec to use when the file is opened.

We implement both reading and writing with I/O proxies for OpenEXR,
and writing with prixies for PNG. More format support will be added
as needed.

Turns out it was harder than I originally thought to absolutely ensure
that a config spec is associated with any opening of an ImageBuf,
incuding when it draws on ImageCache.

Along the way, this necessitated a new variant of ImageInput::create().
So be it.
2018-05-10 17:53:36 -07:00
Larry Gritz 84ccdb7ae1 filesystem.h: Wrapper classes for file I/O proxies (1931)
IOProxy is an abstract base class that presents a very simple API that
encapsulates fundamental file methods: seek, tell, read, write, pread,
pwrite, close.

We implement three concrete subclasses of IOProxy:

* IOFile : wraps a FILE*, can be used for either input and output (but
  not both).

* IOMemReader : wraps a memory buffer, so it can be read "like a file".

* IOVecOutput : wraps a std::vector<unsigned char>, so writing "like a
  file" stores the bytes in the vector.
2018-05-10 17:53:36 -07:00
Larry Gritz 701a9b1774 ffmpeg: more precise time for switching symbol to AV_CODEC_CAP_DELAY (#1936) 2018-05-10 17:51:33 -07:00
Larry Gritz aebc1c5bfd SIMD Fixes for 32 bit windows builds (#1933)
* Disable SSE for 32 bit Windows patforms

It's unreliable to get clean builds on some of these platforms, and very
hard for us to test thoroughly. We presume that anybody needing high
performance badly enough to want SIMD also is on a 64 bit CPU, so
falling back to scalar on these chips is probably fine.

* Fix up const sloppiness in simd_test.cpp
2018-05-10 11:55:53 -07:00
Larry Gritz 5c4db63ba5 docs fixes 2018-05-05 09:17:43 -07:00
Larry Gritz 72924b80c8 CHANGES 2018-05-03 11:45:08 -07:00
Larry Gritz ba041c20c7 ImageInput::spec(s,m) and spec_dimensions(s,m)
The previously existing spec() is not thread-safe, since it depends on
retained state of the last seek_subimage. It also returns a const
reference to a single ImageSpec, so it's not even safe to access the
resulting reference if there may be other threads that might change the
current subimage or miplevel.

The new spec(s,m) is thread-safe, and it COPIES the result. The base
class default implementation just locks, does the seek, and
copies. Individual ImageInput subclass implementations may do something
more clever, for example if they are already inventorying and retaining
the ImageSpec's for all subimages, they may not need to lock or seek at
all.

Beware, though, that because it makes a full copy of the ImageSpec, it
may be expensive if the spec in quesiton contains a lot of arbitrary
metadata (which need to be allocated and copied individually).

So there is a second thread-safe method, spec_dimensions(s,m), which
only copies the dimensional and type fields of the spec (just like
ImageSpec::copy_dimensions()), omitting the channel names and the
arbitrary named metadata in the extra_attribs field. This is very
inexpensive copared to copying the rest of the metadata.

Overload these with custom versions for OpenEXR and TIFF. For OpenEXR,
we already collected all the specs, so we can return it without doing a
lock, seek, or read at all. For TIFF, we change to save the specs (not
unlike what we did all along with OpenEXR), and now for the cost of a
shortly-held lock, we can usually avoid the seek and read and just copy.
2018-05-01 16:42:43 -07:00
Larry Gritz 741d3020d2 ImageCacheFile refactor to eliminate most locking of m_input_mutex
std::shared_ptr<T> is thread-safe with respect to the "control block",
which means that two threads that each hold their own shared_ptr to the
same object can safely reference copy, or release their shared pointers,
and all is fine.  When the very last thread holding a shared pointer to
the object releases it, the object will be deleted.

But a single shared_ptr itself is NOT thread-safe. You have to control
access to a shared_ptr if it may be referenced by multiple threads, as
is the case for the shared_ptr<ImageInput> in the ImageCacheFile.  So
the ICF has a m_input_mutex that threads held for quite some time when
they need to access anything about the ImageInput.

This patch is a refactor that eliminates most of those locks. Instead,
when a thread needs to use the ImageInput, it uses a new thread-safe
get_imageinput() method that returns a shared_ptr safely, using the
wonderful std::atomic_load(const std::shared_ptr<T>* p) method that
lets us get a copy of the shared_ptr atomically, with no lock. The
original m_input_mutex is now only held in a few circumstances, and
for less time when it is needed.

The idea is that this should help remove some thread bottlenecking in
the TextureSystem when heavily threaded.

This is also heavily dependent on a previous change that made several of
the thread-safe ImageInput::read_{tiles,scanlines,image} take explicit
subimage and miplevel parameters (which removed the need for any
stateful calls to seek_subimage),
2018-05-01 15:58:16 -07:00
Larry Gritz 74dee4b6d4 Field3d cleanup 2018-05-01 15:58:12 -07:00
Larry Gritz e6eb42af9a ImageInput overhaul for better thread safety and efficiency
The point of all this is to take client code that looks like this:

    lock();  // necessary because of implied state of the current
             // subimage/miplevel between the seek_subimage and
             // subsequent read.
    imageinput->seek_subimage (subimage, miplevel);
    read_scanlines (ybegin, yend, z, pixels);
    unlock();

and replace it with this:

    read_scanlines (subimage, miplevel, ybegin, yend, z, pixels);

with no implied saved state (at least, none that is relevant and visible
to the client), and thus with no client-side lock necessary.

* Change signature of seek_subimage to no longer take an ImageSpec&,
  to avoid an obligatory ImageSpec copy that is often unnecessary.
  The preferred idiom, if one must call seek_subimage at all, is to
  call it and then separately copy the spec(). For back compatibility,
  a non-overloadable entry point exists that matches the old call
  signature, but should be considered a candidate for deprecation.

* All of the read_native_*() methods take subimage and miplevel
  parameters, are expected to do a seek_subimage if necessary.
  For the read_native_deep_*() methods, which are the only ones that
  user could would ordinarily have called, back-compatible entry points
  exist (but should be considered deprecated and not thread-safe).

* New varieties of read_scanlines, read_tiles(), and read_image() are
  available that takes explicit subimage and miplevel parameters (and
  thus do not require a stateful prior call to seek_subimage).

* All of the read_* calls that take explicit subimage/miplevel parameters
  are guaranteed to be thread-safe against concurrent calls to any other
  of the read_* calls with explicit subimage/miplevel (but not necessarily
  against any other ImageInput methods).

* The ImageInput base class contains a mutex now, to be used internally
  by functions that need to lock.

* The generic implementations of read_scanlines/tiles, and the specific
  implementations for TIFF and OpenEXR, are very carefully constructed
  to hold their internal locks for as little time as possible, only when
  required by the underlying format-reading library).
2018-05-01 15:52:25 -07:00
Larry Gritz 7cb1096db9 Bump version 2018-05-01 15:20:31 -07:00
Larry Gritz e25e200588 changes 2018-05-01 15:09:37 -07:00
Larry Gritz 41dd1c7bc8 TIFF: Overhaul read_native_scanlines to speed up more cases (#1925)
Extend the recent work on reading "raw" strips and then decompressing
them ourselves concurrently, to handle "separate" planarconfig as well
as "contiguous". This required another big refactor of
read_native_scanlines.

With this change, even contig images now take the fast path for some
combiations that it didn't before: uncompressed, and zip compressed but
without the horizontal predictor selected.
2018-05-01 15:08:37 -07:00
Larry Gritz 6daaefd806 Minor docs/build fixes 2018-04-23 15:51:55 -07:00
Larry Gritz 810a023583 Changes to allow building against the new ffmpeg 4.0 (#1926) 2018-04-23 15:50:14 -07:00
Larry Gritz 19a22ad889 TIFF header read speedup (#1922)
Calls to TIFFSetDirectory are redundant if the file was just opened
and you are positioning to the first subdirectory.

Yet, libtiff seems not to notice that, and will happily repeat a bunch
of the header reading that it already did for the TIFFOpen.

So making sure that we only call TIFFSetDirectory when we need to
actually change the current subimage, saves some work (and in fact
can approximately double the speed of reading the header).
2018-04-23 08:10:03 -07:00
Larry Gritz e5bb13af68 ImageBuf::write should be careful about the effect on ImageCache. (#1916)
When we write an IB, it presumably changes the pixels, so we should
invalidate the file we're writing if it's in an ImageCache. Also, be
careful that were not writing an "in-place" file that hasn't been read
fully yet (because it's IC-backed).
2018-04-23 08:06:57 -07:00
Larry Gritz 96cc991a2a Update location of tiff images 2018-04-23 08:05:54 -07:00
Larry Gritz 1139a41d53 TIFF bug fix: don't forget byte swap when we uncompress ourselves
The recent patch that greatly speeds up reading whole TIFF images,
where we do our own decompression, forgot to consider the case where
the TIFF was written with the opposite byte order.
2018-04-23 08:05:54 -07:00
Larry Gritz bf95d48b16 PNG: Fix redundant png_write_end call and missing info ptr. (#1910) 2018-04-22 08:21:43 -07:00
Larry Gritz 0d8d9163ee texture()/texture3d() -- don't let subimage error be nondeterministic (#1917)
We realized that for the error condition of the optional "subimage"
specifying a nonexistant subimage would issue an error and return
without writing any values into the location of the color result.

The proposed patch treats the nonexistant-subimage case just like we
always treated the nonexistant-texture case: issue an error and store
the "fill" color in the result, unless the "missingcolor" optional
parameter is supplied, in which case return the missingcolor and do
not issue an error.
2018-04-18 17:59:14 -07:00
maxnbk 9f8fca7237 add up to date nuke versions to cmake module (#1920) 2018-04-18 09:05:02 -07:00
miqlas 05e7073efa Comparing is ==. Possibly typo. (#1918) 2018-04-16 11:58:22 -07:00
Larry Gritz 1e0490fb69 Update ref output 2018-04-11 13:50:53 -07:00
Pascal Lecocq 3380422324 Fix floating point precision issues on stored slope values. (#1913)
This patch stores slopes values in i,j texture space rather than normalized s,t space to prevent
floating point overflow with half precision float format.

testsuite update
2018-04-10 14:51:06 -07:00
Larry Gritz d64d435a4b oiiotool help message fix 2018-04-03 17:11:07 -07:00
Larry Gritz db206f50c3 CHANGES 2018-03-31 11:19:04 -07:00
Larry Gritz 9e2c49634d Bug fix: wrong dimensions for premult in TIFFInput::read_tiles (#1907)
Also didn't pass strides correctly
2018-03-23 16:55:51 -07:00
Larry Gritz 88f2d79334 Move ROI from imagebuf.h to imageio.h (#1906)
This sets us up for planned changes to use the ROI class more extensively
in other imageio.h declarations.

Add roi(), roi_full(), set_roi(), and set_roi_full() methods to
ImageSpec.

Try to constexpr everything possible in ROI.
2018-03-23 14:17:54 -07:00
timgrant 6f7583dcf2 Add CUDA decorations and guards to hash.h, color.h (#1905)
Add HOSTDEVICE decorators to some inline hash functions. Guard some color conversion functions when compiling for CUDA devices. Use the CUDA funnel shift intrinsic for left rotate when it is available.
2018-03-22 11:22:19 -07:00
Larry Gritz ecfe24b7f0 Fix up docs after override change 2018-03-21 22:13:42 -07:00
Larry Gritz ef664087a9 Use override keyword on ImageInput and ImageOutput subclasses (#1904)
The C++11 `override` keyword is helpful in preventing coding errors by
ensuring that your subclasses aren't using virtual functions with the
wrong signature (and thus making a new, useless methods rather than
correctly overloading the method you intended).
2018-03-21 22:06:49 -07:00
Larry Gritz f4763cfbd8 Docs: clarify how float to int quantization works
Remove some outdated material that implies that dither and quantization
values are stored in the ImageSpec. They have been gone from there for a
long time.

[ci skip]
2018-03-19 22:43:11 -07:00
Larry Gritz 85d4242f15 Docs: use needspace to control page breaks better 2018-03-19 15:51:11 -07:00
Larry Gritz 05bf1ad2f2 More care with /bigobj on Windows (#1902)
Expand the set of files to all the imagebufalgo_*.cpp, which are the
most likely files to need it because they tend to have template expansion
for big sets of data type pairings.

FIXME: Does anybody know if there is an advantage to limiting it to
just the files that most need it? Or is it better to make it totally
foolproof by using /bigobj for all our modules on Windows?
2018-03-16 13:06:14 -07:00
Larry Gritz 1b3775a035 Fix Cuda conditional compilaton (#1896)
__CUDACC__ is not the right symbol to use, but rather __CUDA_ARCH__
2018-03-15 12:40:00 -07:00
Larry Gritz 0307c5abe2 Fix for certain libtiff versions 2018-03-14 13:13:22 -07:00
Larry Gritz 6c18be06ea TIFF whole-file I/O speedup 5-10x with multithreading (#1853)
OpenEXR's library has a neat feature where it maintains a thread pool
and if you are using the multi-scanline or multi-tile I/O API calls, it
will do the compression/decompression of the scanlines or tiles in
parallel, even though the disk I/O itself is serial (but the codec work
accounts for most of the time, so this is a big speed win). The result
is that with many threads, a 5-7x speedup in I/O is typical, versus the
single threaded case.

libtiff doesn't do this -- it is not thread-safe or reentrant (for a
single file), and lacks API calls to write multiple tiles or scanlines
at once (small exception: it will output a "strip" of several scanlines,
but not in a flexible way like OpenEXR's). So any straightforward use of
libtiff means using one core to do all the work writing (or reading) a
file, and all the other cores just waiting around, unable to contribute.

So with this patch, I take an end run around these libtiff limitations.
Instead of using the TIFFWriteScanline or TIFFWriteTile calls, I use the
alternative TIFFWriteRaw{Scanline,Tile}, where you have to hand it a
"raw" buffer (already compressed, ready for direct write to disk), which
means we have to compress it ourselves. But for the very common case of
"zip/deflate" compression, we can do this with our own call to zlib and
get the same compressed data blob that libtiff would have produced. And
in doing so, we can do that compression, and a bunch of other data
wrangling and format conversion, in parallel using our thread pool! We
can also pipeline the operation, having the serialized write happen even
while later chunks are still in the queue waiting to be compressed.

And of course, the same process in reverse for reading.

Some limitations: for now, this fast path is taken only for uint8 and
uint16 images, only deflate/zip compression, only "contig" planarconfig,
no weird modes like cmyk or palette images, etc.  But these are the
most common (nearly exclusive) settings for TIFF files, as we use them.

Note also that this ONLY applies when writing multiple scanlines or
tiles at once. It can't parallelize this work if the calling app is only
reading or writing (from the OIIO API perspective) a single scanline or
tile at a time. But again, a very common use pattern is to read or write
the whole image at once. (Important exception: ImageCache/TextureSystem,
which is inherently single-tile based).

The results are stunning: I'm easily getting a 5-10x performance
improvement in TIFF input or output time, sometimes even much more. This
translates directly into large performance improvements for oiiotool as
well as maketx texture creation (of which by far the biggest portion of
runtime is the output of the texture, and most of that was due to the
compression, which is now multithreaded).

As a specific example, when doing "maketx" of an 8192 x 8192, 4 channel,
uint16 data TIFF input file on my 16 core (32 hyperthread) workstation,

   Old:  28.2s total (1.13s read, 23.3s write)
   New:   1.6s total (0.13s read,  1.0s write)
2018-03-14 12:45:48 -07:00
Larry Gritz a36b769cf1 MSVC: use /bigobj on some other large files (#1900) 2018-03-14 09:48:41 -07:00
Larry Gritz fc1b0802e0 Fine tuning of AVX512 partial load/store (#1893)
At least on the system I have, some of the masked partial load/store are
actually slower than the non-avx512 fallbacks, so disable the fancy one
until I find hardware where it truly runs faster.
2018-03-08 14:58:03 -08:00
Larry Gritz b9fa6389f0 Improvements for frame sequence wildcards (#1894)
Fixes #1889, which reported that frame sequence wildcards involving
negative frame numbers were not correctly supported. For example,

    oiiotool --frames 1-5 ...      # 1, 2, 3, 4, 5  (as usual)
    oiiotool --frames -3-3 ...     # -3, -2, -1, 0, 1, 2, 3
    oiiotool --frames -3--1 ...    # -3, -2, -1

In addition to handling negative frame numbers and ranges, I also made a
change to facilitate testing and benchmarking, which is that the
presence of `--frames` is now itself enough to trigger the looping +
wildcard expansion. Previously, if there were no numeric wildcards in
any of the filenames, it would not execute the frame loop (even if there
was a --frames).
2018-03-08 14:57:37 -08:00
timgrant 66c6a0ef80 Modifying fmath.h to allow CUDA compilation (#1888)
* Add CUDA-friendly __device__ specializations for a subset of functions in fmath.h. Add preprocessor guards in fmath.h to allow for device compilation.

* Add HOSTDEVICE macro to platform.h, used to decorate functions in fmath.h. Move CUDA specializations into the original function/template definitions, instead of placing them in a block at the end of the file. Use anonymous namespace for sincos to avoid infinite recursion. Add note and TODO about fast math.

* Fix some wrong infdefs (inverted sense). Fall back to std math functions where no CUDA intrinsic is available, leaving it to the compiler to select the appropriate version.

Fall back to some std math functions.

* Remove #ifndef __CUDACC__ guard from fast_pow_pos. Use std::exp in fast_correct_exp.
2018-03-06 13:52:38 -08:00
Larry Gritz 107c394c86 Remove accommodations for MSVS older than 2013 (#1887)
We've advertised for some time that 2013 was the minimum version. Get
rid of some cruft from before that.
2018-03-05 16:43:43 -08:00
Larry Gritz 71f53ccae2 Thread pool and parallel-for refactor/improvements (#1884)
1. Move the body of parallel_for_chunked and parallel_for_chunked_2D
from an inline in parallel.h to being non-inlined in thread.cpp.
The main advantage is so that as I tinker with the internals of these
functions, it's just one module that needs to recompile, rather than
the fact that an altered parallel.h forces a rebuild of most of the
project.

2. Implement a thread_pool::jobs_in_queue() that reports how many tasks
are waiting to execute (but haven't started yet) and a
thread_pool::very_busy() method that basically tells whether the number
of tasks waiting in the queue is significantly larger (currently: >4x)
than the number of threads in the pool. The idea here is that clients of
the thread pool could use this to avoid putting things onto the end of a
greatly oversubscribed queue and therefore avoid a long latency waiting
for other tasks to be completed.

3. And so the parallel_for loops use this -- before adding tasks to the
queue, it checks if it's very_busy() and if so, will execute the
sub-task directly. This helps reduce latency in situations where the
queue is heavily oversubscribed, which can happen if several threads are
each adding lots of jobs, oblivious that all the others are also piling
tasks on. This shouldn't come up commonly, but it makes things more sane
for this particular edge case.

4. Add an optional name field to parallel_options. This make it vastly
easier for me, when debugging, to have a particular launching of a
parallel loop have a unique name, and then trigger various debugging
scaffolding inside the execution of the parallel loops, only when
certain ones are called.
2018-03-05 16:43:01 -08:00
Larry Gritz 1f317f1888 Travis tweaks
* Remove unneessary gcc5 test
* Temporarily disable osx static linkage test, which is broken after some
  recent Travis+homebrew package upgrades, and I don't have time to fully
  track it down at this time.
2018-03-05 14:26:37 -08:00
Larry Gritz ff1a9502a1 Fix homebrew dependencies now that brew switched to python3 default 2018-03-05 14:26:37 -08:00
Larry Gritz e905fa4649 Fix order dependency that made a test fail on python3 2018-03-05 14:26:37 -08:00
Larry Gritz 7902291c74 Remove USE_PYTHON3 build flag, it wasn't actually used in any way 2018-03-05 14:26:37 -08:00
Larry Gritz 50338d2eae Fix testsuite to be python 2/3 agnostic 2018-03-05 14:26:37 -08:00
Richard 33f19f3da1 Make building and installing of documentation more packaging friendly. (#1890) 2018-03-05 09:38:29 -08:00
Larry Gritz 64e43f7233 CHANGES
[ci skip]
2018-02-28 21:40:11 -08:00
Larry Gritz e2663fac43 Option to time all IBA functions (#1885)
* Option to time all IBA functions

All ImageBufAlgo functions (for now; other functionality may be added
to logging down the line) are outfitted with optional timers to count
the number of executions and total time spent for each.

This is enabled by a new global OIIO attribute "log_times", which can be
enabled and disabled at any time (for example, to only log a certain
phase of execution of an app).

The default is 0, meaning not to log -- and I believe that when turned
off, there is no added runtime cost (except for checking the flag once
per IBA function).

The initial default can be changed with the OPENIMAGEIO_LOG_TIMES
environment variable.

When log_times is nonzero, logging will occur, with a slight increase in
runtime expense to check the times and to lock and access the map that
stores all the running totals (stored separately, indexed by name). This
extra cost is probably not significant for whole-image operations such
as IBA calls, but it would not be an especially accurate way to time
fine-grained operations that work on one or a few pixels at a time.

The global getattribute() call may be used to retrieve "timing_report",
which will return a string containing a list of all the timing totals,
alphabetized by name, like this:

    IBA::computePixelStats        2   0.003s  (avg   1.34ms)
    IBA::make_texture             1  0.074s  (avg  74.05ms)
    IBA::mul                      8   0.002s  (avg   0.30ms)
    IBA::over                    10  0.024s  (avg   2.38ms)
    IBA::resize                  20   0.240s   (avg  12.18ms)
    IBA::zero                     8   0.001s  (avg   0.08ms)

If the log_times option has a value > 1 at the time that the program
terminates, the destructor of the timing data structure will
automatically print the timing report to stdout.

So, even for a program (that uses OIIO ImageBufAlgo internally) that has
no exposed option to retrieve and print the report, you can still find
out how it's spending its time by launching as

    OPENIMAGEIO_LOG_TIMES=2 my_application

Some caveats to keep in mind:
* It's possible that in situations where one IBA function ends up
  calling another, the time could be doubled-counted.
* This measures "wall clock time", so interpret carefully in the
  presence of multithreading.
2018-02-27 23:49:27 -08:00
Larry Gritz 5d248d0ac8 Speed up IBA::fill of constant color (#1886)
Convert the (float[]) values to the data type of the buffer once, rather
than building float->buftype data conversion into every channel of every
pixel.

Fill of float and half buffers speed up by about 1.5x.
Fill of uint8 and uint15 buffers speed up by about 2.5x.
2018-02-27 23:45:56 -08:00
Larry Gritz c45d66e081 Docs touch-ups
[ci skip]
2018-02-23 11:01:01 -08:00
Larry Gritz 6355fbbff7 task_set refactor (#1883)
There was no reason for task_set to be a template -- the templated type
was no longer used for anything. Changing it from template to normal
class also means that it was convenient to move task_set::wait() and
wait_for_task() from inline to be in thread.cpp. This makes it so that
tinkering with these methods just rebuilds one file, whereas when it's
in thread.h, any changes to it forces a recompile of most of OIIO.

Be sure to disable task_set operator= and copy ctr.
2018-02-22 18:04:43 -08:00
Larry Gritz fe111cb0d0 ImageBuf::pixeladdr() -- extend with channel parameter (#1880)
Let the pixeladdr also take a channel offset.

Clean up some legacy versions of pixeladdr(); only one version is
needed with parameter defaults properly used.

Simplify the implementation of pixel_stride, scanline_stride, z_stride
to be based on the already-computed byte counts (I just didn't remember
that they existed when I exposed those functions).

With the new pixeladdr method that takes a channel offset, I can
lift the restrictions on special cases of copy and crop that require
starting at channel 0.
2018-02-22 17:28:36 -08:00
Larry Gritz 8553641cd3 Fix ImageBuf::read python bindings (#1881)
Only one of the two read methods was properly exposed.

This could be really bad if you tried using the other one, as the
default arguments could kick in and make the interpretation quite
different. In particular, your 'force' and 'convert' hints may be
misinterpreted, ugh.
2018-02-22 17:01:34 -08:00
Larry Gritz a0476e3422 Speed up IBA::over (#1879)
I'm seeing a little over 2x improvement for the common special case
of both fg and bg being RGBA float buffers in memory.
2018-02-20 10:55:54 -08:00
Larry Gritz b261656a8d Speed up IBA::copy and IBA::crop (#1877)
Both of these were threaded, but used iterators to be fully general.

Much like the recent ImageBuf::get_pixels fix, using
parallel_convert_image (which has been heavily optimized) speeds up the
common situation where the source image is already in local memory and
the ROI being copied is fully contained in the pixel data window.

I'm seeing speedup of copy about 35-45% when copying a 4 channel float
image to either a float buffer, 2.5-3x speedup when a data conversion is
involved (copying a 4 channel float to a 4 channel uint8 buffer), and
2-4x improvement copying 4-chan half to 4-chan half (because the general
code did an expensive half->float->half set of conversions in the
process). Note: the uncertainties are from trying on a few different
machines / processor revisions / number of cores.
2018-02-19 19:16:43 -08:00
Larry Gritz a385c45ee6 Add ROI::contains(ROI) (#1878)
To both C++ and Python. Also add unit tests for this as well as the
recently-added contains(x,y,z,ch).
2018-02-19 15:04:47 -08:00
Larry Gritz 5f2cf48480 simd.h: speed up some load/store ops especially to/from uint16, uint8 (#1873)
Big improvements on avx512 and in some cases avx2.
2018-02-19 14:42:23 -08:00
Larry Gritz a7f5448e75 Fix for RAW files that are taken with rotated orientation (#1863)
Fixes #1854

This was quite tricky. A while back, #1741 was intended to do the
"unpack" lazily, so that opens that only needed to read metadata didn't
take several seconds to do the full image nupack. But it inadvertently
broke vertical rotated images.

I went round and round on this, unable to make it work with a single open.
I finally just settled on opening it the first time without the unpack,
and if the pixels are needed, close and re-open with the full pack. Seems
to work, so taking this victory where I can get it. It also needed
the m_processor to be changed from a member to a pointer, as I couldn't
seem to fully re-initialize it properly without starting with a new one.

Also added a testsuite/raw that tests a couple raw images.  Somehow we
previously had no testsuite verification of raw at all!  The source
images are stored in the oiio-images project, originally from
https://www.rawsamples.ch (big stash of raw images from many cameras).
2018-02-19 14:16:55 -08:00
Larry Gritz 1a2207e9b7 Bug fix in IBA::copy -- uninitialized dst botched its ROI. (#1876) 2018-02-18 09:58:29 -08:00
Larry Gritz 815d0be872 Bug fix addendum to recent get_pixels speedup (#1875)
I realized/remembered that the "general" version that uses iterators is
not only necessary for the ImageCache-backed case, but also handles wrap
modes and samples outside the data window. Thus, it is not safe to use
the fast parallel_convert_image unless the ROI we are dealing with stays
strictly within the pixel data window of the image. So add that check.
2018-02-18 09:55:48 -08:00
Larry Gritz c390f188d9 ROI::contains() -- test if a coordinate is in the ROI (#1874) 2018-02-18 08:50:14 -08:00
Larry Gritz c0eebf1fca Fix docs after recent colorconvert() changes
* Forgot to update C++ and Python docs about the change to default value
  for the `unpremult` optional parameter.

* Forgot to actually change the default value in the Python binding setup.
2018-02-16 15:32:13 -08:00
Larry Gritz 9c8aea21b0 SPI only: bump SpComp2 version 2018-02-16 15:15:21 -08:00
Larry Gritz 2f4249fdd3 CHANGES 2018-02-16 14:56:20 -08:00
Larry Gritz 862bb635b9 Add docs for recent raw enhancement 2018-02-15 16:58:52 -08:00
Larry Gritz 8485028fdc Speed up ImageBuf::get_pixels() (#1872)
The fully general case uses IB::iterator element by element and can
handle ImageCache-backed images.

For the common case of the image being fully in memory, it reduces to
a call to parallel_convert_image, which is about 3x faster.
2018-02-15 15:49:15 -08:00
Christopher Kulla 5dbef6908d Upgrade SPI makefiles to Clang 5.0.1 final 2018-02-15 08:24:10 -08:00
Larry Gritz a53976e136 Update FindOpenJpeg for openjpeg-2.3 (#1871)
Fixes #1867
2018-02-14 10:08:17 -08:00
Larry Gritz ee76ecd4fb Reduce warnings for appveyor compile of OpenEXR 2018-02-14 01:00:22 -08:00
Larry Gritz bbc564f676 Fix Windows warning because of redundant OIIO_API 2018-02-14 00:17:38 -08:00
Larry Gritz 986ad08fb3 IBA::colorconvert(): Speed up color conversions with SIMD (#1868)
This speeds up the general case by about 30%, and the special case of
4 channel float -> 4 channel float by 50%.

Note that all the IBA::ocio* functions also use colorconvert underneath,
so these will all speed up proportionally.
2018-02-13 16:52:01 -08:00
Larry Gritz e6d722b4b9 Remove some vestigages of long-disabled OpenSSL 2018-02-12 18:08:39 -08:00
Christopher Kulla 407597928d Add support for Clang 6.0.0rc2 to SPI makefiles 2018-02-12 17:21:56 -08:00
Larry Gritz 567ba9a217 Add sample OCIO config to testsuite/common for use in unit tests (#1870)
Run testsuite unit tests with a fixed sample OCIO config.

This makes it easier to have unit tests for the wrapped OCIO functionality
without worrying that the user's system might not have an OCIO config, or
might have one with differing transformations than we used when making the
testsuite reference images.

Move color-related oiiotool tests into separate testsuite/oiiotool-color,
and add a few basic test the OCIO functions.

Make src/build-scripts/build_ocio.bash, run it on Linux for Travis so the
CI unit tests have a fully working OCIO.
2018-02-11 20:59:46 -08:00
Larry Gritz 8aee6714cb Add ColorConfig method to retrieve config name. oiiotool --help prints it. (#1869)
Helps to diagnoise that oiiotool is getting the color config you think it is.
2018-02-11 10:49:47 -08:00
Larry Gritz 44fdcbaf6a CHANGES
[CI skip]
2018-02-11 08:37:31 -08:00
Larry Gritz 0af3c91d09 Color transform unpremult logic changes. (#1864)
After some deep thinking and discussion with people who know more color
than me, I have become convinced that you *almost always* want to make
sure to un-premultiply colors (i.e. divide by alpha) before doing color
space transformations with OCIO, and then re-multiply by alpha (to get
back to "associated alpha") immediately after the color transformation.

To support this,

* For the ImageBufAlgo color transformation functions, change the default
  value of the `unpremult` parameter from `false` to `true`.

* `oiiotool --autocc` will do the unpremult/premult steps surrounding any
  automatic color transformations that it does upon input and output.

* `oiiotool --colorconvert` and the various `--ocio` commands now take
  an optional modifier `:unpremult=1` which will cause the conversion to
  be internally bracked by a unpremult/premult step (when you do this,
  you no longer need an explicit --unpremult and --premult on the
  command line).

* oiiotool now issues warnings for cases where it has a good reason to
  think you might be double-unpremulting (for example, if you do both
  --unpremult and follow it by a --colorconvert:unpremult=1).

Later, we'll stage a second part of this where we change the default
value for unpremult= to be 1, so that the modifier is not needed (at which
point you REALLY don't want the explicit --unpremult/--premult, or it will
be wrong).

On the whole, I think this makes the situation less error prone for
casual users. Most oiiotool command lines should just use --autocc and
then not need to worry about any explicit use of `--colorconvert` or
`--unpremult/--premult`. For the rare case when more control is needed,
the individual commands and modifiers can be used.

Note that for oiiotool, `--autocc` is not on by default. If you want
images auto-converted to linear space and ouputs auto-converted from
linear to the desired output space, you need to use `--autocc`.
2018-02-09 15:24:26 -08:00
Larry Gritz 41bc41ecb3 ImageBufAlgo mad(): allow image*color+image variety (#1866)
We had img*img+img, and img*col+col, but for some reason no
img*col+img. Seems like an oversight.
2018-02-07 11:00:39 -08:00
Larry Gritz 653d83f4a7 ArgParse: modernize, no raw new/delete, use pimpl to hide implementation (#1858) 2018-02-05 21:19:18 -08:00
Larry Gritz 75810aab37 Parallelize computePixelStats (#1852)
ImageBufAlgo::computePixelStats was completely serialized. Turns out that
this was a big chunk of "unaccounted" time in maketx.

So parallelize it in the usual way, with parallel_for_chunked_2D,
and some other cleanup to the PixelStats struct.

Also modify the stats keeping in make_texture() to account for and
report the computePixelStats time separately.
2018-02-03 10:57:04 -08:00
Larry Gritz 5c46681439 CHANGES 2018-02-01 23:36:49 -08:00
Shootfast 5aef490349 Added explicit link to CMAKE_DL_LIBS for OpenImageIO target (#1860) 2018-01-29 13:14:41 -08:00
Larry Gritz a1173fe0bb oiiotool: autotile off by default. (#1856)
I think it's possible to deadlock when doing certain parallel IBA
functions in combination with autotile. When the deadlock possibility is
fixed, maybe we'll turn it back to on by default, but for now this seems
safer.  Users can always turn it on with the --autotile command line
flag to oiiotool.
2018-01-27 10:57:36 -08:00
Larry Gritz da8ad6d2c0 Clean up spurious leak sanitizer errors (#1855)
* Add a few places (mainly in boost) to the nosanitize.txt exception
  list for lsan.

* Make runtest.py skip any test directory that contains a file called
  TRAVIS_SKIP_LSAN, but only if it's running the sanitize test case on
  Travis. On local machines, or for all other test matrix entries, it
  will run as usual.  So we set up this file for 4 testsuite directories
  where it's just not practical to fix the extremely minor leaks.

This cleans up a handful of tests that recently started to fail the
Travis test that runs the sanitizer. (Nothing changed on my side; I
suspect some minor compiler upgrade on the Travis side started catching
additional cases.) It all passes with this patch, now that I'm ignoring
a few specific cases where I've verified that the "leaks" are small
one-time allocations that are just too much trouble to clean up.
2018-01-25 22:38:21 -08:00
Shootfast d500fbe1aa raw: Added raw:HighlightMode attribute to control highlight clamping (#1851) 2018-01-23 14:01:54 -08:00
Larry Gritz 445578bc8e task_set : add wait_for_task (#1847)
This lets you wait for just one task in the task set to finish. Versus
the usual wait() that waits for all tasks in the set to be completed.

This is handy for "pipelining", where you are using the tasks as a
queue, and as they are done, you can pass them off to the next
stage. There's no reason to wait for all to complete to begin processing
the first-completed tasks coming out of the queue.
2018-01-22 20:43:12 -08:00
Pino Toscano 195d3e6f88 Fix Strutil::strtod_l/strtod_l on Hurd (#1850)
* Strutil: use the right variable

* Strutil: use strtod_l/strtod_l on GNU libc

Since they are available on any platform that uses GNU libc, enable it
directly.
2018-01-21 13:49:55 -08:00
Larry Gritz 7e6683a9ad OpenEXR reader: gracefully reject subsampled channels (#1849)
The EXR spec allows for channels to be subsampled, but we don't handle
this properly in the exr ImageInput, and it can lead to a crash.  Since
it's a rarely used feature (if ever), I'm not inclined to fix it for
real until somebody says they actually need it. Instead, let's just
detect this unusual case and correctly issue an error saying that we
don't support it.

This required a bit of housekeeping to allow the errors to be propagated
up from the place where it was convenient to notice this.
2018-01-20 18:50:26 -08:00
Larry Gritz 9b4f91eb21 Field3d: don't crash under opening failures (#1848)
Field3D is supposed to just throw an exception that we can catch if it
can't open the file, but under some circumstances it just plain crashes
when asked to open a file that isn't a f3d file at all.

The reason this comes up is that OIIO's behaveior when the usual reader
can't open a file is to try ALL of them (hoping that maybe the file is
just mis-named) or the hint heuristics are wrong.

I'm not inclined to try to fix the field3d internals myself at this
moment, so for now I'm just making the OIIO field3d reader fail if the
file is not named ".f3d". This violates our intended rule of "it doesn't
matter what the file is called", but I can only rely on that if the
underlying format library is rock solid when presented a file of the
wrong type.
2018-01-20 18:49:30 -08:00
Larry Gritz e35be2311e simd.h touchups (#1846)
* Minor improvements to rcp_fast, rsqrt_fast for AVX512.

* Maked load/store tweaks:
  * Remove some concern comments on 4-wide masked load/store for AVX
    because benchmarks show it to be no concern (the lines of potential
    concern were indeed faster on AVX).
  * Change implementation of 4-wide scatter and masked scatter for avx512
    after benchmarks show that the non-SIMD way is faster. Come back to
    retest on future hardware.

* Speed up reduce_and / reduce_or for vbool16

* Fix typo
2018-01-20 14:55:19 -08:00
Larry Gritz 13cd109455 TextureOptBatch: Rearrange structure layout (#1845)
* Properly align per-point SIMD fields
* Rearrange TextureOptBatch members
2018-01-18 10:55:48 -08:00
Larry Gritz 9dda546ba5 Fix dcmtk build errors on some platforms (#1843)
* Fix some type mismatch issues on 32 bit platforms. Fixes #1841 

* DCMTK version enforcement

Have CMake figure out the version of DCMTK found.
Reject anything older than 3.6.1.
Older versions botched some preprocessor symbols in ways that are painful
to deal with, so since the ones that work (>= 3.6.1) date from 2011 (!),
I don't think it's too stringent a requirement.

* More conservative goards on certain symbols.

EVR_OD, EVR_UC, EVR_UR were added part way through 3.6.1 releases.
So test for them with 3.6.2 minimum not 3.6.1.

(Thanks, Richard Shaw, for the tip on this one.)
2018-01-17 08:38:34 -08:00
Richard 0f9b9fed38 Linking with OpenCV highgui componenet is not needed for 3.X and newer. (#1842) 2018-01-14 21:12:38 -08:00
StefanBruens 6622788272 Use QOpenGLFunctions for GL extensions, drop GLEW and obsolete GL stuff (#1834)
Instead of relying on GLEW for resolution of GL extension function entry
points use QOpenGLFunctions, which provides the same, but also allows to
run on both OpenGL desktop and GLES platforms.

Also drop extension based shader support. Shaders are supported since
OpenGL 2.0, so ARB shaders are likely no longer used and make the code
harder to read. Assume PBOs are available, which is true since OpenGL 1.5.

Text rendering in the pixelview overlay was apparently broken (no text
drawn at all), switch to QPainter based text drawing, as
QGLWidget::renderText() is not supported by QOpenGLWidget.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
2018-01-03 14:20:52 -08:00
Larry Gritz 31b12b9bcd testtex fixes (#1840)
* For more realism in the "thread_workout" tests, which I noticed had
  filter shape with exactly 1.0 aspect ratio, add a --anisoratio option
  that lets you set anisotropic shape. By making a 2.0 or 4.0 aspect
  ratio, that's a bit more realistic in terms of what a 3D renderer will
  see for average aspect ratio.

* For clarity, change the older --aniso option to --anisomax, to emphasize
  that it's setting the maximum allowable anisotropy.

* Make test thread_working samples twice as big, so it's sampling between
  levels 1 and 2 instead of between levels 0 and 1, that's more realistic,
  I think. The old way biased the tests much more to bicubic sampling which
  is probably less common than the tests made it out to be.

* Stats were printing only for the ImageCache, not for the TextureSystem.
  Fix by getting the stats explicitly, instead of relying on verbosity
  to print them when the TS/IC is destroyed (because the way testtex is
  written, the IC destroys but the TS doesn't because it's the default).

* Replace awkward mutex locking for stderr output with Strutil::fprintf,
  which automatically keeps threads from clobbering each other's output.
2018-01-03 10:23:47 -08:00
Larry Gritz e81961a5aa ImageOutput: avoid needless data conversion in to_native_rectangle (#1836) 2018-01-02 16:31:38 -08:00
Larry Gritz a7e92b265e More careful gzopen on windows. (#1839)
This could make crashes with certain filenames on Windows. And even
though zfiles are rare, when OIIO is not sure which plugin to use, it
tries them all, so when given a bogus filename or a file that isn't
really an image, it will be called sooner or later.
2018-01-02 11:48:38 -08:00
Akihiro Yamasaki 239f38cc6f PSD: Fix parse issue of layer mask data (#1777)
The length of the layer mask data was assumed to be several fixed sizes, but it actually varies depending on the mask parameter flags.
2017-12-21 16:32:31 -08:00
Larry Gritz 686c27dae9 Speed up TIFF scanlines output (#1833)
TIFF didn't have write_scanlines() of its own, just depending on the
default implementation, which calls write_scanline repeatedly.  So we
give it a proper write_scanlines implementation, which tries to speed
things up by first doing all the conversions and data shuffling on the
whole block (which can be parallelized by our code), before writing the
individual scanlines.

Slightly adjust the chunk size for write_image (it was a little too
conservative).

In parallel_convert_from_float, instead of a hard-coded block size, let
parallel_for_chunked make the choice on its own, which will be better
because it takes into account the number of threads in the pool

These changes, cumulatively, speed up whole-image writes of scanline TIFF
files by about 10%. I was hoping for more than this, but the bottleneck
is the unthreaded code in libtiff that's doing the compression encoding.

This wasn't a problem on the specific images I was testing, but I also
noticed an odditity in the way we did image checkpointing for TIFF
output -- it tries to only checkpoint every 5 seconds (which is longer
than most image writes, so it usually doesn't happen anyway), but the
timer started running when the ImageOutput was created. Seems to me now
that it's better to start the timer when the output opens, not merely
when the ImageOutput is constructed (in case there's a delay between
the two).
2017-12-21 11:43:55 -08:00
Chris Kulla 7d03b0d510 Add a new hash functions and revamp hash_test program
Adding fasthash64, a high quality 64 bit hash which happens to be both portable and quite short. It works particularly well when hashing a sequence of 64 bit values

Revamp the hash_test program to benchmark a bigger variety of sizes, and do so on a larger buffer of random values to test both aligned and unaligned reads and reduce the compiler's temptation to optimize the loops away

The hash_test also contains falkhash which is not quite viable on current hardware, but interesting for benchmarking purposes.
2017-12-19 10:10:11 -08:00
Chris Kulla b99a9f0627 Add Intel AES instruction support in the USE_SIMD flag 2017-12-19 10:10:11 -08:00
Chris Kulla d53c950c12 Minor optimization for udim textures
Replace a find/insert sequence with emplace (which will not add if already present)
2017-12-19 10:10:10 -08:00
Larry Gritz ea45077b98 oiiotool: Better channel name logic when combining images (#1827)
Interesting edge case I came across:

    oiiotool rgb.exr rgba.exr -add -o out.exr

The logic was that the result had 4 channels (the greater of the two
inputs), but the channel names were just copied straight from the first
input, and it was (coincidentally, in this example) the one with fewer
channels, so it did not know that channel 3 was alpha, it would just get
"R", "G", "B", "channel3".

The new logic is that for all channels, it tries to get the name from
the first image, and if it doesn't exist, then it gets it from the
second. Also it's smarter about setting alpha_channel and z_channel in
the spec of the output, even if those didn't come along with the first
input.
2017-12-18 10:23:26 -08:00
Larry Gritz ec605b9c46 Simplify from_float (#1832) 2017-12-17 19:32:43 -08:00
Larry Gritz 742cf524d4 After Travis image changes, need to explicitly add pthread lib when using asan 2017-12-15 17:46:00 -08:00
Larry Gritz dc9c636131 Bug fix with ImageBuf::copy of rare types (#1829) 2017-12-15 17:30:24 -08:00
Larry Gritz b7264d9152 testex improvements (#1828)
* Only print the detailed stats if -v is used.

* New option --noinvalidate instructs it to not invalidate the cache
  when starting each threadtimes trial. Combined with setting --cachesize
  very large, this makes it possible to time the texturing math and
  resident cache behavior without any disk access (because after the
  first trial, all the needed tiles will probalby be resident).
2017-12-14 10:24:56 -08:00
Larry Gritz 7933b6b9ae New and improved color maps for IBA::color_map and oiiotool --colormap (#1820)
Inspired by Matplotlib, which has added new color maps called inferno,
magma, plasma, and viridis. These color maps, developed by Nathaniel
Smith & Stefan van der Walt, are public domain, and were specially
designed to be (a) perceptually uniform, (b) strictly increasing in
luminance, (c) looking good when converted to grayscale for printing,
(d) usable by people with various forms of color blindness. They are
therefore superior to most of the ad-hoc visualization color maps used
elsewhere, including the original ones used in OIIO, which have none of
these desirable qualities.

The authors cite studies (in diagnostic radiology) showing that older,
ad-hoc non-perceptually-uniform color maps have empirically worse
performance, i.e. a lower rate of correct diagnoses. Bad color maps
literally have blood on their hands!

I took the tables for these new maps (https://github.com/bids/colormap)
and converted the values from sRGB to a linear response (since that's
how OIIO wants to operate), and also decimated from 256 entries to 17
entries (good enough, since we interpolate rather than needing a value
for each of 256 integer levels).
2017-12-14 10:23:52 -08:00
Chris Kulla 7b90ec1f5e Replace std::unordered_map in the concurrent hash map used for storing tiles and files in the image cache
This introduces a new small dependency on an external package: Tessil/robin-map which is automatically fetched from github by Cmake
2017-12-12 12:02:31 -08:00
Larry Gritz 16f42c633d IC Cache "clock" algorithm -- fix iterator invalidation problem
It seems that the clock sweeping algorithm for finding cache pages to
evict (i.e., the uts of ImageCacheImpl::check_max_mem) relied on the
fact that it could erase entries from the cache and continue sweeping
with the iterator.

This worked fine for the original unordered_map, and as well for the
unordered_map_concurrent as long as the individual shards were also
implemented by unordered_map -- but only because unordered_map used
chaining and thus an iterator would still be valid after an erase
(assuming the iterator wasn't pointing to the erased item itself).

But when Chris tried using a different underlying hash table which
didn't have this property, things broke.

Some refactoring of check_max_mem fixes the problem. Basically, I just
save the ID of the advanced iterator, allow the iterator to be
invalidated by the erase operation and then re-establish a new iterator
by using the ID we saved in the previous step. Some other cleanup of the
loop also helps make the logic of the whole affair a little more clear.
2017-12-12 10:54:04 -08:00
Larry Gritz 3f11cf2142 SPI: bump up which llvm build we are using 2017-12-08 14:58:18 -08:00
Chris Kulla 1b29674beb Remove read_before_insert parameter, it has been set to false by default for a while now and setting it to true seems to be always slightly slower 2017-12-08 11:12:16 -08:00
Chris Kulla 6712956034 unordered_map_concurrent performance improvement
Use the upper bits of the hash for bin selection instead of hashing the hash
2017-12-07 16:13:31 -08:00
Chris Kulla 8f4bdb657b Add aligned_malloc/free functions (along with new/delete wrappers) and use them when creating ImageCache objects
The current implementation requires over-alignment which isn't required to be followed until C++17 at least
2017-12-07 08:33:54 -08:00
Chris Kulla 5c398d297c Report number of threads we are averaging over for the image cache file I/O time 2017-12-06 17:23:02 -08:00
Chris Kulla 7df3a10aa4 Use C++11 semantics of unordered_map to avoid double-lookups on the fingerprint hash when adding or deleting 2017-12-06 17:21:28 -08:00
Larry Gritz 3145c1a048 Fix sqrt call that could warn if ambiguous 2017-12-04 16:23:45 -08:00
Pascal Lecocq 7686b020c6 New "--bumpslopes" exporter option for maketx command
The main purpose of this option is to export additional gradient
informations along bump maps to ease the implementation of bump to
roughness techniques.

The resulting output is a single 6 channels bump map containing the
height, the first and second slopes moment values stored in subsequent
mip-map levels.

Channel data layout:

    channel  quantity             channel name
    -------  --------             ------
      0       h                   "b0_h"
      1       dh/ds               "b1_dhds"
      2       dh/dt               "b2_dhdt"
      3       (dh/ds)^2           "b3_dhds2"
      4       (dh/dt)^2           "b4_dhdt2"
      5       (dh/ds) * (dh/dt)   "b5_dh2dsdt"

Excuse the odd channel names -- because OpenEXR is obliged to re-sort
channels into their alphabetical order, we had to make absolutely sure
that the channels were named in such a way that would not be reordered.

Note that if the input texture is a normal map, then channel[0] = -1.0f
and the corresponding normal can be simply retreived as follows:

    n = normalize( -(dh/ds), -(dh/dt), 1.0 )

The normals are assumed to be defined in the tangent space.

Subtle point: on MIP level 0, channels 3-5 are simple multiples of
channels 1 & 2, but as we filter to get the higher level (lower res)
MIP levels, this is no longer the case, and in fact we depend on this
fact to give us the right standard deviations.

References:

The technique we're using that requires information is based on this
technical report:

Christophe Hery, Michael Kass, and Junhi Ling. "Geometry into Shading."
Technical Memo 14-04, Pixar Animation Studios, 2014.
https://graphics.pixar.com/library/BumpRoughness/
https://graphics.pixar.com/library/BumpRoughness/paper.pdf

And the following references may also be useful in understanding:

Mark Olano and Dan Baker. "LEAN Mapping." Proceedings of I3D 2010.
https://www.csee.umbc.edu/~olano/papers/lean/
https://www.csee.umbc.edu/~olano/papers/lean/lean.pdf

Jonathan Dupuy, et al. "Linear Efficient Antialiased Displacement and
Reflectance (LEADR) Mapping." ACM TOG 32(6), 2013 (Proceedings of
Siggraph Asia 2013).
https://hal.inria.fr/hal-00858220/en
https://hal.inria.fr/hal-00858220v4/document
2017-12-04 15:33:45 -08:00
Larry Gritz 9b8f73dcdb Fixes to maketx image hashing (#1819)
I'm worried there are some edge cases where the hashes aren't quite as
deterministic as we want, across all platforms and use cases.

I decided to also get rid of the option to use OpenSSL for its hash, the
different for the two code paths, we could have different hashes for
people who build with OpenSSL versus those who build without it.

I also beefed up the code in ImageCacheImpl::verify_file where we check
for duplicates using the hash fingerprints. I became worried about what
could happen if you had two textures that were different "shapes" but
the same hashes -- such as a 64x64 4 channel texture and a 128x128
single channel texture, where the "unwrapped pixel sequence" (if you
know what I mean) was the same, they would end up with the same hash.
So I modified the check to only count identical hashes as a match if the
width, height, depth, channels, number of subimages, and miplevels also
were the same for the two images.
2017-12-04 15:33:05 -08:00
Larry Gritz 084f577e71 Simplify and speed up some unit tests (#1818)
For compute_test and filter_test, switch from time_trial to Benchmarker.
This reduces the code complexity, and because Benchmarker figures out
on its own how many iterations to do in order to get good timings, it
runs MUCH faster overall (we were using too many iterations), so this
will speed up testsuite runs.

Also reduce time spend on atomic_test by lowering iterations, raising trials.
2017-12-02 10:23:06 -08:00
Larry Gritz 0a094db008 parallel utility improvements (#1807)
* Move parallel_image_options to OIIO level in parallel.h as parallel_options.
* Add field to parallel_options to allow for recursion within the
  thread pool (use with caution to avoid thread explosion!).
* Use parallel_options as a control parameter to the various parallel_for
  family of functions as a way of communicating preferences for maximum
  threads, custom thread pool, and recursion.
* Some minor logic changes in chunking logic.
* More careful tracking of which threads are participating in the pool --
  not only pool threads, but also the *calling* threads that opportunistically
  execute tasks from the queue while they are waiting for the rest of the
  task set to be done... those also need to be protected from inadvertent
  recursively adding things to the queue.

Note that this should be source back-compatible, since the places we add
parallel_options to functions all are either (a) adding it to the end of
the parameter listings, with a default value, or (b) putting it in place
of a `nthreads` parameter (a parallel_options struct can be implicitly
constructed from an int, which does in fact initialize the maxthreads
field).
2017-11-30 16:24:31 -08:00
Larry Gritz e75a9b8bc3 Fix xmp parsing bug (#1816)
A strange edge case turned up: when parsing a file with XMP data block,
and the XMP contained metadata "Exif:PixelXDimension" (or PixelYDimension),
a cascade of failures eventually led to a crash in `oiiotool -info -v`.

Fixes herein include:

* Add those two entries to the table of xmp fields we expect to see, in
  xmp.cpp.
* In xmp.cpp's add_attrib(), if something is not found in the xmp table
  (which among other things translates the XMP name into an OIIO name),
  stick with the xmp name it came with. We were actually adding it as an
  attribute using 'oiioname', which for that case was uninitialized!
* Finally, in ImageSpec::attribute(), check for empty names, which are
  obviously errors, and don't add those attributes.
2017-11-29 15:48:39 -08:00
Larry Gritz b9b00101e3 Bump Travis OSX image to xcode 8.3
But we still use 7.3 for the test case for static build, there's some
reason it's not finding something it needs in PNG static linkage in 8.3.
2017-11-29 09:36:39 -08:00
Larry Gritz 9373f158bf ParamList convenience methods: remove(), contains(), add_or_replace() (#1813) 2017-11-28 12:50:08 -08:00
Larry Gritz 28e361fd2f Add Strutil::to_string<> utility template (#1814) 2017-11-28 09:30:56 -08:00
Larry Gritz 73952aef06 Some documentation, help, and error message improvements (1811)
Most notable is that `oiio --help` now prints some important usage tips
that explain command parsing, syntax of optional modifiers, and the path
where you can find the full PDF docs.
2017-11-27 21:16:13 -08:00
Larry Gritz 29bb78b1b8 argparse: add pre- and post- option help printing callbacks (1811)
This lets you provide callbacks that will print extended information
into the verbose usage output: one that prints before all the options
are detailed, one that prints after all the options are detailed.
2017-11-27 21:16:13 -08:00
Larry Gritz d8421d99a4 Remove debugging output to stderr (#1815) 2017-11-27 21:15:35 -08:00
Larry Gritz 1c6a17de82 Increase "local" space of ParamValue (#1812)
ParamValue holds "small" data locally (in the struct), and only
allocates when above that threshold. Previously, the threshold was 8
bytes, the size that the allcoated pointer would be anyway. But it seems
to me that the way we us ParamValue frequently must contain a color (3
floats), so I bumped the local space from 8 to 16 bytes (meaning it can
hold up to 4 floats or ints before a malloc). This increases the total
size of a ParamValue from 32 to 40 bytes, but I think it will make it
fairly rare to allocate, so we'll come out ahead.

This should all be inconsequential from an API perspective.
2017-11-27 09:28:02 -08:00
Larry Gritz e52896a797 Python ImageBuf.get_pixels, set_pixels bugs with some ROI constructors (1802)
Python bindings for ImageBuf.get_pixels() and set_pixels(), when passed
an ROI without a channel range specified -- which should assume you mean
to include all the channels of the image -- calculated that number wrong,
making it one channel too many.

If you pass an ROI that is fully constructed (with all of x, y, z, chan
ranges explicitly specified), it worked fine, which I guess is why nobody
noticed this problem before.
2017-11-26 20:35:38 -08:00
Larry Gritz 7956ff0cd1 More build time reduction (#1809)
Break the longest-compiling file, imagebufalgo_mathops.cpp, into
imagebufalgo_addsub.cpp, imagebufalgo_muldiv.cpp, imagebufalgo_mad.cpp,
and a teensy bit of refactoring within those files to reduce compilation
effort.

Also changed the src/libOpenImageIO/CMakeLists.txt to list the most
expensive files first, in the hope that if it does that first, it can
load balance easier by having lots of inexpensive files to work on with
the other cores.

The net result is that it saves another 15 seconds of wall clock time
when building with 24 cores, down from about 2 minutes (so around another
12%).
2017-11-24 10:12:19 -08:00
Thomas Mansencal 06635cf8e0 Format table in "INSTALL.md" file. (#1805) 2017-11-24 10:08:33 -08:00
Larry Gritz 81ea41cb76 Improve compile times of the most expensive source modules (#1806)
Some source modules took minutes to compile, mostly because they involve
lots of template instatiation for many type combinations.

So, first, some of the functions that had a very wide cross-product of
type combinations could be changed to the variety that only handles the
common types and uses float as an intermediate format for the outlier
cases. That reduces total compile work substantially.

But also, particularly long-compiling modules can screw up parallel
builds, because that all the other modules for a library may get done
compiling while that one with an extra long compile is still going, but
nothing else can proceed until that's done, so only one core is doing
work while the others wait. So to combat this, I took the two files with
the very longest times (imagebufalgo_pixelmath and imagebufalgo_copy)
and split them up into multiple pieces. That doesn't reduce the total
amount of compilation work, but it does make it easier to parallelize it
over multiple cores.

The net result can be seen by these stats for fresh full builds (after
clearing ccache) on my 4-core laptop:

         before:       315.85 real       850.53 user        42.60 sys
         after:        200.44 real       725.09 user        36.21 sys

The "real" time is the important one -- reduce wall clock time by ~35%
when doing a full parallel build on a 4-core machine.
2017-11-21 12:17:15 -08:00
Larry Gritz 21d3d9951b bump version 2017-11-17 11:25:00 -08:00
Larry Gritz 78775bae18 Update CHANGES and bump version to isolate the Python binding overhaul 2017-11-14 14:31:48 -08:00
Larry Gritz 1457daf86d Rewrite Python bindings using pybind11 (#1801)
pybind is a great project by Wenzel Jakob, very much in the spirit of
Boost.Python (and with substantially similar syntax), but is
C++11-based, light-weight, header-only, and compiles in a fraction of
the time as code that uses Boost.Python.

So the primary change here is to switch underlying implementation of our
Python bindings. But in the process, I made a number of improvements and
changes to the Python bindings, some of which are not strictly backwards
compatible, so this is a BREAKING CHANGE that may require some (hopefully
minor) changes to your OIIO-using Python code.

* All of the functions that read and write blocks of pixels (such as
  ImageInput.read_image(), ImageOutput.write_tile(), or
  ImageBuf.get_pixels()) no longer use old-style Python arrays, but now
  use NumPy ndarray objects. I'm guessing that NumPy is such a common
  Python package that it's not an onerous dependency to add, the n-D
  array syntax is really handy for images (e.g., pixel regions are
  naturally structured as [y][x][channel] multidimensional arrays and
  very easy to use that way), and pybind11 makes it very easy to
  manipulate NumPy ndarray objects but comparitively difficult to use
  old Python arrays.

* We now transparently accept strings anyplace that a TypeDesc is used
  as a function parameter. For example,
  `ImageBuf.set_write_format(TypeFloat)` can alternatively be called as
  `ImageBuf.set_write_format("float")`.

* Some specialized enum types (such as ImageInput.OpenMode) have been
  replaced by strings: `ImageInput.open (filename, ImageInput.Create)`
  should now be called as `ImageInput.open (filename, "create")`

It should be encouraging that of all the Python test files in our test
suite, `testsuite/python-*/src/test-*.py`, a very small number of source
lines needed to be changed.

If pybind11 is not found on the system, we just git clone as needed, with
the following logic:

* If BUILD_PYBIND11_FORCE is true, download a local copy (regardless of
  any system install).

* Otherwise, look for a system-installed copy, and use it if found.

* Otherwise, if BUILD_MISSING_PYBIND11 is true (default), download
  a local copy.

So, the default behavior is to use an installed copy, or auto-download
if that's not found. But it's possible to force a download (ignoring system)
or to disallow a download (making missing pybind11 simply an error).

Also, none of this happens if the build is USE_PYTHON=0.
2017-11-14 14:03:43 -08:00
Larry Gritz df6156afae TextureSys: bump max_tile_channels limit to 6 (#1803) 2017-11-10 14:44:06 -08:00
Larry Gritz e35b5ab5bb Travis: Cut back on package load time by only dling the parts of boost we need 2017-11-10 01:09:25 -08:00
Larry Gritz 465e94ad67 Remove some long-deprecated cruft (#1802) 2017-11-08 09:24:22 -08:00
Larry Gritz dfaa94f36f Docs: remove NEW markers from old versions 2017-11-04 20:58:43 -07:00
Larry Gritz 01b0e65be0 File output safety for oiiotool (#1797)
maketx (really, the underlying IBA::make_texture() call) writes to a
temporary output file, then after it's done, atomically moves the file
to its requested destination. This ensures proper operation if the user
foolishly specifies that output should overwrite input (same file), and
also is a guard against a crashing program leaving a corrupted
half-written file behind that could be mistaken for proper output.

This patch employs the same trick to oiiotool. It was "safe" to have

    oiiotool in.exr ...blah... -o in.exr

if in.exr was small enough -- in which case it would be fully read into
its ImageBuf when first encountered. But if it was a large file, it would
rely on ImageCache, so it was possible that when the output started to
overwrite it, trashing the file, not all the parts of the image had been
read into memory. With this patch, that should no longer be a danger.
We also do an ImageCache invalidation of the file that was output, in case
an portions are being used somehow.
2017-10-31 11:30:21 -07:00
Larry Gritz 83002bfcf9 Minor Python binding fix: did not expose RATIONAL enum value (#1799) 2017-10-31 11:30:01 -07:00
Larry Gritz a265c12c5d Fix USE_FREETYPE=0 build (#1800)
When USE_FREETYPE=0, the resolve_font() function was declared but never
called, generating a warning on some platforms.
2017-10-31 11:29:48 -07:00
Larry Gritz b5d4b7f510 CHANGES and docs
[ci skip]
2017-10-30 20:29:29 -07:00
Larry Gritz f6dc750440 Indentation vs brace typo bug (#1798) 2017-10-27 20:10:37 -07:00
Larry Gritz eaa27b7cec ImageCache: improve thread contention (#1780)
Increase the number of shards in the unordered_map_concurrent used by
the ImageCache for file and tile caches. As we get machines with larger
core counts and thread them more heavily, the previous limits were causing
bottlenecks.

This solution is not perfect nor complete. But it does push the
bottleneck from ~16 to more like ~32 threads. I'm separately working on
some other strategies to reduce the amount of locking, with an eye
toward every-growing core counts. But this is a solid step forward for
our newer machines.
2017-10-27 17:29:03 -07:00
Larry Gritz 3fc64b4674 Fix testsuite ref output 2017-10-27 15:40:44 -07:00
Larry Gritz 89f855cf17 More principled handling of string<->numeric conversions. (#1796)
This refactor comes after a belated realization that our numeric
conversion routines (principally from_string<> and format) are
"locale-dependent" via their use of strtod, as well as atof() scattered
through the code.

In particular, this means that when software using this code is running
with a locale in which the decimal mark is something other than '.'
(e.g., many European locales that use ',' for decimal mark), these
functions will incorrectly parse text floating point numbers that use
the standard period as decimal mark.  For example, if the locale is
"fr_FR", atof("123.45") will return 123.0, rather than the correct
123.45.

After much debate, and a few implementations, we are declaring that
since the whole point of OIIO is about reading and writing persistent
data (image files!), that in order to be consistent, ALL of OIIO's
string parsing and formatting, including that done by utility library
functions, will be locale-independent by using the "C" locale (in
particular, we will use the usual North American default of '.' for
decimal separator).

Additionally:

* Added a new stof(), stoi(), stoul() to replace the clunkier template
syntax of from_string<>. As explained, these are hard-coded to "C" locale,
not the native/global locale.

* Much more attention to string_view safety, finding a number of subtle
bugs (including Strutil::parse_int, etc.)  where it was definitely not
safe to assume that the string_view passed was the null-terminated edge
of the string, and so, for example if a string_view pointed to the
characters "12" but the very next characters were "345" parse_int would
return 12345 instead of the correct 12.

* Strutil::format and ustring::format (and our copy of tinyformat
underneath) were touched up so that the versions of format() that return
strings will use the "C" locale, versions added that return strings and
use an explicitly-passed locale, and the versions that append their
results to existing streams continue to operate as before by honoring
the existing locale conventions of the streams they are using.
We may revise this later depending on what the upstream tinyformat
chooses to do about the issue.

* Several places where we assembled strings using std::ostringstream,
I forced the stream to use classic "C" locale in cases where it was
likely to have any floating-point data output.

* For maketx and oiiotool, globally set the locale to classic. In these
cases, we control the whole app, so this is safe to do.

If we ever decide that we want versions of these functions that take
explicit locales, it's not hard to add.
2017-10-27 13:47:59 -07:00
Arkady Shapkin 198aec9a7d Fix CMake error with MSVC compiler (#1794) 2017-10-25 00:21:38 -07:00
Larry Gritz b409c02125 Change CODECOV handling to prevent accidental activation of debug mode 2017-10-24 15:54:10 -07:00
Larry Gritz 1e89b9c85f Remove unnecessary debug output 2017-10-24 15:54:10 -07:00
Larry Gritz 7cb31f158a Fix Windows build issue (#1793) 2017-10-24 15:53:36 -07:00
Larry Gritz 82bc88724c Made a preprocessor symbol to know if fmath.h was included 2017-10-24 11:38:24 -07:00
Larry Gritz 4e1418ae89 unittest.h: Make the reference to Strutil fully qualified with OIIO: (#1791)
It previously worked for the OIIO tests that all seemed to have a
'using namespace OIIO', but failed for external projects that just wanted
to use unittest.h and weren't inside namespace OIIO.
2017-10-23 20:59:34 -07:00
Larry Gritz c940875457 New spin_rw_mutex implementation with greatly improved performance (#1787)
You can see the performance in the following two tables. It's a
benchmark using our unit test spin_rw_test.cpp. We vary the ratio of
writers to readers from 1:9 (one write lock and modify for every 9 read
locks) to 1:9999.

All times are in seconds for this workload (smaller is better), and
they were executed on Linux on a machine with 32 physical cores (64
hyperthread cores).

Old code:

    threads  1:9     1:99      1:999     1:9999
    --------------------------------------------
     1       0.3      0.3       0.3        0.3
     2       0.5      0.5       0.6        0.5
     4       5.4      3.4       3.2        2.8
     8       9.9      9.5      10.6        9.0
    12      12.3     13.1      11.8       12.1
    16      13.7     14.3      14.0       14.8
    20      15.4     16.2      16.1       17.5
    24      17.9     16.9      18.3       18.1
    28      20.0     21.0      21.2       20.9
    32      21.4     22.2      22.8       20.9
    64      20.9     22.4      22.2       21.4

New code (this patch):

    threads  1:9     1:99      1:999     1:9999
    --------------------------------------------
     1	     0.2      0.2       0.2        0.2
     2	     0.9      0.7       0.5        0.5
     4	     1.4      1.0       0.8        0.8
     8	     3.6      1.5       1.1        1.0
    12	     5.1      2.4       1.4        1.2
    16	     6.0      2.8       1.8        1.4
    20	     6.8      3.6       2.1        1.7
    24	     8.4      4.4       2.4        2.0
    28	     9.1      5.0       2.8        2.2
    32	    10.8      5.3       3.2        2.4
    64	    11.8      5.8       4.2        3.0

So the performance of the new code has three interesting properties:
(a) For every thread count, and every write-to-read ratio, it is
superior to the old code (only exception: 2 threads, heavily weighted
to writers). (b) For every workload, the new code scales better,
versus thread count, than the old code did. (c) Whereas the old
code has similar performance regardless of workload, the new code
gets remarkably more efficient as use is dominated by readers --
there is VERY little interference between simultaneous readers.

I don't expect much in OIIO to speed up *today* as a result of this,
because there are only a couple places where we use the spin_rw_mutex.
But I'm laying the groundwork for some improvements I'm doing to the
ImageCache/TextureSystem, which currently doesn't use rw locks but I'm
trying out an improvement that will utilize them, and I think this is
going to be a key component to making it scale better with larger number
of cores.
2017-10-21 22:05:04 -07:00
Larry Gritz e94bc7e43f Correction to the test for C++17 compatibility 2017-10-21 19:59:55 -07:00
Larry Gritz fd4bfc41e4 ColorConfig refactor (#1788)
* Change ColorConfig to return shared ptrs to ColorProcessors. This frees
  the caller from having to own the resource and remember to delete it.
  It also makes leaks impossible.

* Establish an internal cache of ColorProcessors, so that repeated requests
  for the same processor (i.e., same color space transformation) doesn't
  need to do any allocations or trigger anything expensive on the OCIO
  side.

* Added new create...() methods that take ustring arguments, in addition
  to the existing ones that take string_view. That version is faster
  if you already have ustrings on the app side -- especially the part of
  looking it up in the cache. The string_view ones are still fine to use,
  they just build ustrings on their own.

* Move ColorProcessor class declaration to color.h so client code that
  gets a CP handle can actually apply the transformation to colors with it.

* Allow "rgb" and "default" to be additional alias for the "linear"
  role. (This really helps OSL, where "rgb" is a longstanding name for
  'the default color space'.)

* A little bit of C++ modernization.

NOTE that this is a breaking change, although a minor one. Any applications
that had explicitly asked for a ColorConfig and used it to request a raw
ColorProcessor will need to make some minor changes:
  - The return type of the ColorConfig::create... has changed from
    ColorProcessor* to ColorProcessorHandle.
  - You don't need to free the handle, it's a shared pointer now and will
    clean itself up.
2017-10-16 21:54:57 -07:00
Larry Gritz 9898804497 Fix recent build break against old libtiff (#1789)
The recent Exif patch broke for old TIFF versions. Fix.

Also document more clearly what the TIFF library version requirements
are.
2017-10-16 08:17:39 -07:00
Larry Gritz 0e79643552 Travis touch-ups 2017-10-15 22:55:49 -07:00
Larry Gritz a98826853f Fix build break for old libraw (#1786) 2017-10-12 22:17:25 -07:00
Larry Gritz 5b8bc22565 Refactor of metadata printing and Exif read/write (#1774)
"Maker notes" are extra camera manufacturer-specific metadata stored as
opaque blobs inside Exif records. The manufacturers don't seem to
publish the specs for these blobs, but they have been reverse engineered
and with some hunting you can find tinkerer-prouced documentation (at a
range of levels of completeness or correctness).

With this patch, we do a substantial refactor of exif.cpp (and a bit of
work in formatspec, rawinput, and other places) to incorporate full
awareness of maker notes into our metadata processing. At this stage, we
only read Canon makernotes, and quite incompletely. But we get a lot
more of the metadata than we used to (previously we just ignored any
makernotes we found), and the structure is now sound for adding more
complete support for this and other cameras.

This will be an ongoing project to support more cameras, but the foundation
is now set for this work.
2017-10-12 14:22:10 -07:00
Larry Gritz a346101340 simd.h: fix a bunch of broken code for AVX512VL (#1781) 2017-10-12 14:15:13 -07:00
Larry Gritz 5ba67515a2 SPI build files and cleanup 2017-10-12 11:43:20 -07:00
Larry Gritz e950829e99 IC: collect stats on how long we wait for imageinput mutexes (#1779) 2017-10-08 19:50:06 -07:00
Larry Gritz becd8400a1 testtex: make the tex_thread_workout cases all honor --handle (#1778)
There was a --handle flag that lets you test performance differences
between the texture calls that take handles, versus the ones that take
filenames and figure out the handles by looking it up in the file
cache. But it turns out I had implemented that option fully for the
usual "make a texture image" tests, but not for the special thread
workload test you get with the --threadtimes option.
2017-10-07 23:16:50 -07:00
Larry Gritz a5b934ddb3 Avoid sanitizer probs inside boost when file doesn't exist 2017-10-05 15:29:52 -07:00
Larry Gritz 0c073528a8 II::create - smarter analysis of file extension in presence of RESTful name 2017-10-05 15:29:52 -07:00
Larry Gritz 27e0d838f6 null image input & output
This I/O plugin for "null" images are a file "format" where output of a
null file does nothing at all (no I/O, not even any data copying), and
input of a null file just fills the result buffers with black pixels (0
values), with no I/O or data copying.

What's this good for?

* Benchmarking, if you want to have OIIO's input or output truly take
  as close to no time whatsoever.

* "Dry run" of applications where you don't want it to produce any real
  output (akin to a Unix command that you redirect output to /dev/null).

* Make "fake" input that looks like a file, but the file doesn't exist
  (if you are happy with constant-colored pixels).

The filename allows a REST-ful syntax, where you can append little doodads
that specify things like resolution (of the non-existent file), etc.
For example,

    foo.null?RES=640x480&CHANNELS=3

would specify a null file with resolution 640x480 and 3 channels.
Token/value pairs accepted are

    RES=1024x1024        set resolution (3D example: 256x256x100)
    CHANNELS=4           set number of channels
    TILES=64x64          makes it look like a tiled image with tile size
    TYPE=uint8           set the pixel data type
    PIXEL=r,g,b,...      set pixel values (comma separates channel values)
    TEX=1                make it look like a full MIP-mapped texture
    attrib=value         anything else will set metadata!
2017-10-05 15:29:52 -07:00
Larry Gritz 890e4c309c SPI: minor tweaks for SpComp2 release 2017-10-04 15:42:05 -07:00
Larry Gritz b55dd69ac7 string_view -- document a subtle but rare bug, turn off address sanitizer (#1775)
See the comments in the patch for details. It's been like this for a
long time. I think in practice, we'll never hit the bug. But we'll
probably phase this method out anyway, since it's not part of the C++17
std::string_view.
2017-10-02 21:44:36 -07:00
Larry Gritz 66038d3173 ParamValue -- add get_int_indexed() and get_float_indexed() methods. (#1773)
These are handy for extracting values from aggregates or arrays.

They still do the conversion to int or float, even if the real data
in the ParamValue is stored in a different (vaguely compatible) type,
such as converting a uint16 data to an int when requested.
2017-10-01 21:23:35 -07:00
Larry Gritz 99499d8682 array_view enhancements
* added begin, end, cbegin, cend
* ctr from pointer pair, ctr from std::array
2017-09-28 00:46:03 -07:00
Larry Gritz 0262a94d99 oiiotool: Revamp of logic for propagating data format. (#1769)
So, oiiotool reads one or more images, might combine them, might
generate some from whole cloth. And the ones read from disk might not be
stored internally with the same data format as it existed on disk (it's
biased to store in float internally). How does it decide what data
format to write to disk for output?

We thought we were doing something sensible -- which is to allow an
explicit override (via `-d`), but in other cases to write using the
same data format as whatever was the FIRST file input. That at least
guarantees that a basic read-write cycle preserved the format.

But Chris Allen pointed out an interesting corner case, which is that
when you use `--siappend`, it will write out all subimages using the
first format it encountered.  But it seems like in this case, it ought
to be able to keep each subimage in the format it started in.

This sent me down a bit of a rabbit hole.

The logic is hereby modified to:

1. Explicit format requests (`-d`) are honored.
2. Otherwise, a file that appears to be an unmodified copy of a file read
   from disk will write using its native (i.e., from disk) format.
3. Otherwise (for a modified or generated file), it will write using
   a data format taken from whatever was the first file read.
4. If all those fail, it will just use the format of the buffer.

Note that (2) is the new bit of logic.

Turned out to take a fair bit of refactoring to really track this
through all the corner cases, and also make it understand that the
"subimage append" operation does not lose the "it's a directly read
image" property.

I implemented similar logic for tracking tile sizes as well. So output
tiling should more accurately reflect input tiling, except when overridden.

Some other miscellaneous things that came along for the ride:

* New testsuite entry: oiiotool-copy to test these cases.
* A bit more care internal to ImageBuf::copy() of keeping track of the
  "native" format info.
* Some C++ modernization of some ImageRec and Oiiotool internals.
* Minor fixes to how regex matching is done for `oiiotool -info` when
  `-metamatch` is used.
* The `-o` command now takes additional arguments: `scanline=1`,
  `tile=XxY`, which can override the tile size or scanlineness
  on a per-output basis (just like how it could override data type
  or contig/separate).
2017-09-28 00:16:21 -07:00
Christopher Kulla 8cc6145da1 Upgrade spi builds to use clang 5 2017-09-19 14:11:00 -07:00
Larry Gritz 7c8be73680 Post-branch of RB-1.8: kick off 1.9 development 2017-09-15 15:26:38 -07:00
Larry Gritz 8317f18682 CHANGES 2017-09-15 13:23:08 -07:00
Larry Gritz f754c03c1f Rebuild PDF docs 2017-09-15 12:35:29 -07:00
Jonathan Scruggs fca7ed62bd Make python and boost detection more generic (#1760)
Fix boost and python detection for certain systems.
Clean up boost and python detection.
Remove redundant code.
2017-09-15 12:19:04 -07:00
Larry Gritz 9eb6a02abe Fix IBA::fillholes_pushpull when display window != data window (#1768)
We pasted the result into the dest to be aligned with the dst's data
origin, instead of the correct source origin.

While I was there, I slightly simplified the error checking by using
existing IBAPrep functionality to check for the same edge cases.
2017-09-15 09:48:17 -07:00
Larry Gritz 0eedae38ad TypeDesc: add constexpr typedescs at the OIIO scope (#1761)
Previously, we had pre-constructed TypeDescs of common types as static
data members of TypeDesc itself. This presented two (minor) problems:
1. Because their full definitions were in typedesc.cpp, all other modules
did not know what was actually in the fields, so optimization opportunities
were potentially missed.
2. There existed the potential for the static initialization order fiasco,
if the compiler could not figure out that the definitions in typedesc.cpp
could be expressed as POD and baked into the module without running the
constructor at module load time.

So we are deprecating these, though they will stick around for another
major release in order to not break any apps that are depending on them.

In their place, we are making OIIO-scoped 'static constexpr' versions.
These serve the same purpose, but by being constexpr (yay, C++11!),
they are should be turned into compile-time constants everyplace they
are used, which is what we ideally wanted all along.
2017-09-14 23:21:57 -07:00
Larry Gritz 7601a8c6af Protect against bogus texture SHA-1 and other attributes (#1762)
It came to my attention that somebody could take a maketx-generated (or,
`oiiotool -otex`, same thing) texture, load it in Photoshop or other
utility, change it, and save it, and it just might still have some of
the maketx-specific metadata in the altered file, such as the SHA-1 hash
that allows us to find duplicates, and those data may be totally wrong
in the new file.

So this patch is intended to do a sanity check: if there is no
"textureformat" metadata present, or if it's not tiled, or if the
"Software" metadata doesn't say maketx or OpenImageIO, then it can't
have come straight out of maketx/oiiotool, so erase any of the
problematic attributes that maketx writes, because they are very likely
wrong and no longer match the potentially modified pixel values in the
file.

Photoshop always writes scanline images, so the check for tiling works
for that case. It will catch others as well. Not perfect by any means,
but it's better than before and I'm not sure if we can ever be certain.
We still rely on users not being foolish -- please only use textures
that have passed through `maketx` or `oiiotool -otex` and don't modify
the pixels after that step without re-maketxing it.
2017-09-14 14:42:35 -07:00
Larry Gritz 5c9dc68391 Fixes for ifloor, fast_ifloor, floatfrac (#1766)
* Fix fmath.h's ifloor() turned out to have an icky bug where it gave the
  wrong value for negative integers! It was because of the bit fiddling trick
  we were using to avoid the call to floor(). Worked fine for positive values,
  but failed for exact negative integers. The new formulation is a little
  slower, but is always correct.

* The simd versions have the same problem. Fix them there as well, and
  also rename (floori -> ifloor) so that the simd and fmath versions
  have the same naming convention. Add unit tests and benchmarks, and in
  light of that, tighten up some of the SIMD code paths a bit.

* floorfrac uses the same trick. I realized that a slightly different idiom
  was much faster -- even slightly faster than the "fast but buggy"
  version we used previously. So in that case I managed to fix without
  any performance penalty.

* Added simd versions of floorfrac, in fmath.h (where the float version
  was defined).

* texturesys.cpp: use the fmath floorfrac (remember, we put simd versions
  there now) instead of defining it locally, which also lets us remove
  a redundant quick_floor() that was identical to the old buggy
  ifloor anyway.

* Various unit tests for both the scalar and simd cases of these related
  functions, which led to...

* unittest.h: added an "OIIO_CHECK_EQUAL_APPROX" unit test macro,
  basically it checks a result and considers it ok if it's within
  0.1% of the larger of the quantities being compared. Some extra
  trickery makes it work with either scalar or simd values.
2017-09-14 14:40:41 -07:00
Larry Gritz ee7bd6f6b3 Fix SPI build 2017-09-08 14:52:36 -07:00
Larry Gritz e8ba0afc3a strided_ptr<> improvements (#1758)
Templatize based on the stride units. The default strided_ptr<T>
is equivalent to strided_ptr<T,sizeof(T)>, which means that strides
are measured in terms of the size of the element type. But, if you
really want to, you could make strided_ptr<T,1> which would be a
strided pointer where the strides are bytes rather than T's.

Note that this is a compatibility break -- previously, strided_ptr<>
used byte addressing all the time. This was counter-intuitive in many
circumstances, so now the default is to use array-like addressing where
the strides are measured in units of sizeof(T)>. But we have the ability
to still use byte addressing when really needed.

While I was in there, I changed a lot of the declarations to use
constexpr and noexcept very liberally, to maximize the chances that the
compiler can exploit certain optimizations.
2017-09-07 07:48:33 -07:00
Larry Gritz 34e292be01 SPI fixes for recent cmake shuffle 2017-09-05 20:38:43 -07:00
Jonathan Scruggs 1383ba314e oiio/master: Use GNUInstallDirs for installation paths (#1747)
Change all hard coded paths to GNUInstallDirs varibles.

Remove variable setting in install.cmake file since
GNUInstallDirs does all this for you.

Added new search paths for fonts.

Changed location of INSTALL_DOCS test to stop all the document
building when it would never be installed.

Signed-off by: Jonathan Scruggs <j.scruggs@gmail.com>
2017-09-05 20:38:12 -07:00
Larry Gritz 94214e101f Bump minimum OpenEXR/Ilmbase to 2.0 (#1756)
VFXPlatform has dictated a minimum OpenEXR version of 2.0 since 2014,
and 2.2 since 2015.

Upgrading our minimum to 2.0 eliminates a lot of #if nonsense that was
necessary to continue supporting OpenEXR 1.x. There's no real burden
in continuing to support 2.0 & 2.1 for now. But we will continue to
re-evaluate the appropriate minimum in future releases.
2017-08-31 21:22:54 -07:00
Clement Champetier f28fc4dbc5 FindLibRaw: fix access to the version info thanks to LibRaw_INCLUDE_DIR (1749)
According to the includes found in src/raw.imageio/*.cpp, the
LibRaw_INCLUDE_DIR should be a path to 'libraw/libraw_version.h'.
2017-08-30 21:36:48 -07:00
Larry Gritz 4d0d545f89 Fix statics contributing to static initialization order fiasco (#1757)
Fixes #1750

These two spots were implicated in the initialization order fiasco.
(See: https://isocpp.org/wiki/faq/ctors#static-init-order )

The solution for maketx.cpp is that since we only are using the
ColorConfig for the sake of generating a help message, there's no reason
it can't be an ordinary local variable in the one (rarely called)
function where it's used.

For the std::locale involved in strutil.cpp, use the old trick where
instead of a file static, we have a function returning a reference,
which itself has a function-static pointer that's allocated the first
time it's needed. This leaks (a single std::locale), but who cares?
2017-08-30 15:31:55 -07:00
Larry Gritz 951cd57608 Benchmark utilities (#1755)
* Move "benchmarking" utilities -- time_trial, timed_thread_wedge,
  DoNotOptimize, clobber_all_memory -- to a separate benchmark.h
  and benchmark.cpp. The stuff in timer.h is JUST the Timer and
  directly related material.

* New Benchmarker class tries to do micro-benchmarking more cleverly.
  Wrap up some stuff we had done elsewhere (often redundantly).
  Benchmark multiple trials, report the statistics. Select number of
  iterations automatically (!), also try to correctly compute and
  subtract all the loop overhead. Read the comments in benchmark.h for
  explanation.
2017-08-28 19:39:05 -07:00
Larry Gritz c0d261a7b9 raw: unpack the pixels when you need them, not when you open (#1741) 2017-08-28 14:39:36 -07:00
Larry Gritz a7d6352338 CHANGES
[ci skip]
2017-08-28 13:16:38 -07:00
Larry Gritz 6c69c896a0 Refine terminal analysis for color console output (#1752)
For Unix/Linux, check the TERM env variable to be sure the particular
terminal supports color output. Inspired by Google Benchmark.
2017-08-26 15:48:05 -07:00
Larry Gritz f67ae87d82 Repair breaks after boost python 1.65 changes (#1753)
Alas, the new Boost 1.65 moves some boost python material from one
namespace to another in a way that breaks compatibility related to
support for numpy arrays. This breaks the build, including all of
our MacOS-based TravisCI tests, which of course pick up the latest
Boost via Homebrew.
2017-08-26 10:57:00 -07:00
Larry Gritz 24bb353b20 IC/TS: Improve error messages for broken files. (#1751)
If a file is "broken", remember the error message that caused us to
consider it broken, so it can be properly reported later.

This is particularly helpful for files that are rejected for being
untiled or not mip-mapped (if "accept_untiled" or "accept_unmipped" are
false).  It's confusing to see "invalid file" as if the image file
itself was corrupted, much more helpful to see a specific error message
about the reason why it was rejected.
2017-08-24 16:27:10 -07:00
Larry Gritz a9a8aff504 Support (and minor fixes) for building with clang 5.0 (#1746) 2017-08-18 12:40:36 -07:00
Larry Gritz 43a80fbae1 Convert to range-for loops (#1744)
Suggestions courtesy of clang-tidy.
2017-08-16 21:25:01 -07:00
Larry Gritz c4011f9942 Fix regression in environment() (#1745)
My stupid bug, introduced during a minor refactoring related to the
static analysis from two commits ago. The static analysis was right,
by my fix to an apparent possible null ptr dereference was flawed. I
avoided the null dereference, alright, but broke some other logic in
the process.
2017-08-16 17:38:04 -07:00
Larry Gritz 3b4a77fb62 Rearrange ALLOCA macro to evade warning on gcc7 2017-08-15 22:25:34 -07:00
Larry Gritz 60e89a8823 Modernize include header names 2017-08-15 14:06:06 -07:00
Larry Gritz 77f3c01fa8 SIMD batched texture APIs (#1733)
There was previously a set of TextureSystem API calls (with multi-point
TextureOptions struct and a fancy VaryingRef helper class) that was a
multi-point interface, but we never did much with it and in retrospect,
it does not use a data organization that is good for future-looking
architectures. We are therefore depcrecating it, it will remain for 1.8
in case anybody is using it, but will thereafter be removed.

But we are adding a new set of batched routines that are organized
differently, we think in a way that will be well-suited for better
parallelism.

The new API assumes that the inputs and outputs have a SOA rather than
AOS layout, and the arrays are a fixed width, defined by
Tex::BatchWidth, which is a constant and set to 16. Build-time overrides
let us change this for experimentation and future expansion. You can
texture fewer points than this using the RunMask, which is a bit field
saying which "lanes" should be used. Inputs will not be read, or outputs
written, for the lanes where the run mask is 0.

The goal is for this to really fly on chips with ISA that includes
AVX-512 support (naturally 16 wide), and to also perform very well for
AVX2 class machines (emulating 16x operations with pairs of 8x SIMD
instructions). I'm not very hopeful that old SSE hardware (4x wide) will
have a high payoff using the batched functionality rather than the
single-point texturing, but we'll see what happens. We'll also
experiment with 32 wide (there's no true 32 wide hardware, but pairs of
16-wide instructions may dual-issue in nice ways that provides an
advantage, we'll see).

I'm not planning to ever remove the single-point scalar API calls. There
will always be a use for them and they'll certainly be more efficient
for applications that don't have a good way to batch the calls.

This pull request only implements the batched APIs -- the internals are
still scalar, they just loop over the enabled lanes and call the scalar
functionality.

I'm actually working on the true batched reversions right now, but they
aren't ready to review yet. Expect a second PR for that as soon as I
have good results. But in the mean time, this allows applications to
start experimenting with the batched interface.

The testtex program now has modes that exercise the batched interfaces,
and the testsuite has been doctored so that every test whose name
contains the substring "texture" will run twice: once using the old
scalar mode, and once using the batched API calls. This means that
starting now, we will immediately notice any breakages or regressions in
the batched versions, as well as have a convenient way to benchmark the
scalar versus batched calls.
2017-08-15 14:05:26 -07:00
Larry Gritz 71a0d41fe7 Fix many warnings and buglets found by clang-tidy static analysis 2017-08-15 13:20:13 -07:00
Larry Gritz 3de2fdae90 Mark ImageInput/ImageOutput derived classes as final.
Among other things, this helps with some clang tidy warnings that the
virtual destructors of these classes should not be calling the virtual
close() methods, as is common. Its safe for a final class, but in the
general (potentially sub-classable) case, it's considered unsafe.
2017-08-15 13:20:13 -07:00
Larry Gritz cacb22f23c Add gcc7 to Travis test matrix, various fixes for its warnings 2017-08-15 13:09:33 -07:00
Larry Gritz 9dbda5a11e Strutil::safe_strcpy refinement
* Make it take a string_view
* Make it conform more closely to the behavior of strncpy by filling
  in the extra space with 0 pad.
2017-08-15 13:09:33 -07:00
Larry Gritz 72f9d923b4 RLA bug fix: potential buffer overrun -- AspectRatio[] only 8 chars wide 2017-08-15 13:09:33 -07:00
Larry Gritz 2dfc285e78 TIFF: Change interpretation of XPOSITION,YPOSITION. (#1631)
The TIFF spec says these (which we use to generate the ImageSpec x,y
fields giving the data window origin of the image) should be relative
to the "resolution units" described by the XRESOLUTION and YRESOLUTION.

But OIIO has always just stored the data origin directly in this field,
without regard to any scaling factor of the [XY]RESOLUTION fields.

Now, let's realize that it's not very common to have files with nonzero
data origin (crop windows) in TIFF files, also not common to have any
RESOLUTION tags in the files. So the problematic combination, which
would be interpreted differently by versions on either side of this
patch, is rare.

But one way that we can get into trouble is the following sequence: (a)
a JPEG from a camera (or any number of other cases) has resolution or
density data (common for cameras); (b) that JPEG is converted to TIFF,
thereby copying the fields; (c) the TIFF file is cropped, and written by
a version of OIIO prior to this patch. Oops.

Mitigation strategy: OIIO (at least insofar as oiiotool and maketx)
likes to store its name and version in the "Software" TIFF field. So
upon input, we check this, and if the file seems to have been written
by OIIO with a version prior to this patch, use the old interpretation.

Fixes #1623
2017-08-13 21:47:48 -07:00
Larry Gritz d7661bb951 Simplify array_view and array_view_strided to 1D only. (1734)
These were templated on dimensionality of the array, and that made the
implementation much more complex and quite hard to read and
understand. But we never used anything but the 1D case. The reason it
was templated on rank before was to emulate the array_view that was
proposed for C++17, but that has since been scrapped, so keeping
compatibility with it is no longer a priority.

When we remove "Rank" from the template and take away all the machinery
that isn't needed for the simple 1D case, a lot of the complexity goes
away, and these templates will be a lot easier to understand and modify
in the future.
2017-08-12 15:21:14 -07:00
Larry Gritz c2f1529768 Try to detect C++17 (#1737)
Also finally remove the long-deprecated OIIO_USING_CPP11 macro.
Because (1) C++11 is the minimum now anyway, and (2) we switched
some time back to using OIIO_CPLUSPLUS_VERSION.
2017-08-09 10:39:54 -07:00
Du Bois Eloi 062dfab88d oiio: fixed move constructor of ParamValue class. (#1740) 2017-08-08 16:13:19 -07:00
Larry Gritz e50099dccc Update ref SHA for new libjpeg 2017-08-08 14:18:42 -07:00
Larry Gritz 3780c161d7 CHANGES and docs 2017-08-04 23:30:58 -07:00
Larry Gritz f0ea5f3f41 Fix python site-packges path for install (#1722) 2017-07-28 09:51:45 -07:00
Larry Gritz d90e65fd27 Remove unused OIIO_NOTHROW macro -- should use C++11 'noexcept' instead (#1736)
Obsolete -- this is the standard noexcept declaration in C++11.
We don't seem to use it anywhere, so I'm going to take a chance and
just remove it straightaway, rather than deprecating it.
2017-07-27 16:16:15 -07:00
Larry Gritz 22236be57e Fixes for parallel_for_2D (#1730)
Upon reviewing parallel.h, it was apparent that there was a cut-and-paste
error that resulted in parallel_2D() having extra unused parameters.
Put it like I clearly meant it to be.
2017-07-27 16:15:40 -07:00
Larry Gritz df4aa60757 Fix important performance issues with IBA::deep_merge() (#1735)
When merging, high number of splits was crippling performance due to
constant realocation.

New strategy more carefully pre-computes the NUMBER of splits expected
in the merged pixel, and allocates enough storage for the result pixel
to hold the number of samples in both of the input images, and also the
expected number of new segments that will result from splitting.

This speeds things up for very complicated frames by several orders of
magnitude.
2017-07-26 20:57:44 -07:00
Larry Gritz 0cdae8e015 OIIO_SIMD fix for neon (disabled anyway) 2017-07-24 12:49:29 -07:00
Larry Gritz 658cd0724b Add data() method to simd types to return ptr to underlying scalar array 2017-07-24 12:48:31 -07:00
Larry Gritz 7f459591cf simd: load_mask and store_mask for 4-wide, scatter/gather (#1732)
We had load_mask and store_mask for the 8x and 16x classes, but
neglected to add them to the 4x classes.

Also, add scatter/gather operations for all classes (not expected to
be efficient until AVX2), both regular and masked.
2017-07-24 12:47:57 -07:00
Larry Gritz 47a77e20f9 unittest.h improvements (#1731)
* Move the SIMD-oriented comparisons from simd_test.cpp into unittest.h.

* Use Strutil::Term() to use color in the unit test error message macros,
  it makes it a lot easier to spot the assertion messages in the middle
  of a long console output. I had used this in the simd_test.cpp ones
  and really liked it and wanted to propagate the practice to all
  unit test checks.

* Change the global unit_test_failures from a regular int to a special
  counter class that will automatically print an OK/ERRORS message at
  the end of execution when it destructs, and also automatically call
  std::exit() with a nonzero return code if errors occurred, making it
  impossible for a file using the unit tests to accidentail forget to
  return an error code if there were errors.
2017-07-24 12:47:18 -07:00
Larry Gritz 08c309df52 simd.h: fix some typedefs forgotten in the recent foo -> vfoo rename (#1729) 2017-07-22 00:38:43 -07:00
Larry Gritz 25b260db0d Minor simd.h fixes to ensure proper build 2017-07-20 16:22:08 -07:00
Larry Gritz 568f760447 Travis: do test builds with AVX2 and AVX512 (can't test, but can check build) 2017-07-20 16:22:08 -07:00
Manuel Leonhardt dde0c6392d Make search for boost_python3 more reliable (#1727) 2017-07-17 13:24:08 -07:00
Larry Gritz 4fa19aa6ec Travis: try switching to trusty image 2017-07-17 09:58:39 -07:00
Larry Gritz 1eca8ae337 array_view: enable front() and back() (#1724)
I don't remember exactly why these were commented out. But now I want them.
So there.
2017-07-14 17:35:23 -07:00
Larry Gritz 655e58716b TIFF: clean up alpha channel handling (#1718)
For 2-channel images where the first channel is intensity and the second
is alpha, TIFF output was neglecting to set the TIFF "EXTRASAMPLES" tag
to mark the alpha channel.  In particular, it just didn't consider
extrasamples for images that had fewer than 4 channels.

This was in turn causing the file, when re-input, to not realize that
the second channel was "A" or that there was an alpha channel at all
(since TIFF does not store channel names, we infer it all from the
EXTRASAMPLES tag).

One consequence of this mistake was that a grey-alpha image (say, coming
from OpenEXR or PNG or some other format that allows it) and run through
'maketx' (converting to TIFF if not otherwise specified) would lose this
knowledge, which in turn would affect the ability of the TextureSystem's
"gray_to_rgb" mode, which only applies to certain channel combinations.

Also noticed that for TIFF input, 2-channel images where the second is
alpha were still being named "R","A", but we actually changed the convention
some time ago for a single intensity channel to be named "Y", no "R", since
it's almost certainly representing luminance and not "red" per se.
2017-07-13 11:00:17 -07:00
Larry Gritz 441597754a OpenEXR: ensure that "YA" images get channels presented in the right order. (#1717)
Background: OpenEXR forces channels to be stored (or at least presents
it through its API) in strictly alphabetical order. But OIIO expects
uniform channel orders for all the common cases such as RGBA.

For a 2-channel image that's intensity and alpha, we name the channels
"Y" and "A", and expect it to be presented with alpha second, as usual.
But OpenEXR was flipping the channel order because "A" comes before "Y"
alphabetically. Sheesh. It was because we neglected to put "Y" in the
list of special channel names that have order imposed. Easy fix.
2017-07-13 10:33:49 -07:00
Larry Gritz d4269bfc93 simd class rename floatN/intN/boolN -> vfloatN/vintN/vboolN (1719)
Somehow float4 and float8 never bothered me, and seemed obvious that it
menat 4 or 8 float (what else could it mean?).

But after adding the 16-wide classes, it seemed we'd backed ourselves
into some confusion: float16 could be confused for a 16-bit float (aka
half), and int16 looks confusingly like int16_t (aka short). If some day
we ever have 32-wide or 64-wide simd classes, it's only going to get
worse.

So to reduce future confusion, we're renaming to vfloatN, vintN, vboolN.

For a couple major releases, we will maintain typedefs so that float[48],
int[48], bool[48] continues to work for any 3rd party apps that use
OIIO's simd.h.
2017-07-11 17:25:46 -07:00
Larry Gritz 4c61db72b7 simd.h overhaul to support AVX-512 (1719)
* Add float16, int16, bool16 classes

* Preliminary support for masked loads & stores (including propagating those
  to 8x and 4x, which admittedly will not be very efficient for older HW).

* When 16x HW support is not selected, just fall back to 8x[2] style
  implementation. The aim is to make it convenient to code AS IF we were
  on AVX-512, but have pretty decent performance for AVX.

* Lots of miscellaneous fixes to the 4x and 8x classes and cleanup of
  this big header file (lessons learned, and conform to more clear
  semantics apparent when expanding to 16x).
2017-07-11 17:25:42 -07:00
Larry Gritz 21ac4b951c New OIIO attributes to query hardware and build-time SIMD capabilties (1719)
`getattribute("oiio:simd")` retrieves the comma-separated list of
mostly-SIMD-related capabilities that were enabled at build time (e.g.,
"sse2,sse3,sse41,sse42,avx").

`getattribute("hw:simd")` is a similar list of the capabilities detected
on the actual hardware at runtime.

Note that the two don't need to match -- it's very common to compile
with build time flags set to use only the least capable hardware you
expect to run on. But this can help you detect if you are leaving
important hardware facilities unused by your build flags.
2017-07-11 17:25:38 -07:00
Larry Gritz a9ca38753f More cpu_has tests for avx2 and avx512 features (1719) 2017-07-11 17:25:34 -07:00
Larry Gritz 9646fc3438 Disable a tiff test that breaks due to regression bug in libtiff 4.0.8 2017-07-11 16:51:40 -07:00
Chris Foster eccd9028f1 Fix invalid string_view return from channel_name() (#1723)
In this case implicit conversion caused the allocation of a temporary
std::string, which is deallocated before the string_view can be used.
2017-07-11 00:53:15 -07:00
Shootfast 8d744d10e2 iv / Qt5 added fix for qt built with -reduce-relocations 2017-07-10 11:11:24 -07:00
Shootfast 4a5d99d56e Fixed uninitialized variable 2017-07-10 11:11:24 -07:00
Shootfast e079212a08 Added missing functional include 2017-07-10 11:11:24 -07:00
Larry Gritz 491e471b7e Remove C++11 guards that are no longer needed (#1720) 2017-07-07 17:31:37 -07:00
Akihiro Yamasaki 9eef9a7738 PSD: Fix load_layer_channel issue for the layer mask channel (#1714)
The layer mask channel has independent rectangle position from the regular channels. Mostly, they are same position, but sometimes not. PSDInput::open fails by reading wrong data as ChannelInfo::compression when the pixel size of the layer mask channel is different from the image pixel size.
2017-07-05 13:58:00 -07:00
Larry Gritz f0f626c2dc simd.h: Minor fixes to comments & declarations (does not change behavior) 2017-07-05 02:03:24 -07:00
Larry Gritz 1b36573122 Remove unnecessary cmake files (#1713)
The equivalent to these files are included with cmake these days, these
are safe deletions now that we require a minimum cmake 3.0.
2017-07-05 02:01:54 -07:00
Larry Gritz a4c784575b iv / Qt5 -- compensate for display scaling (#1715)
After upgrading to Qt5, display scaling was all wrong on my Mac laptop
with retina display. Some web searching revealed how to retrieve the
device pixel ratio and use it as a scaling factor for GL.

This seems to mostly fix things.
2017-06-30 09:42:00 -07:00
Larry Gritz 7cfbc10162 Proper const on bool4/8 constructors from bool* 2017-06-29 20:34:08 -07:00
Larry Gritz 08604a764f bool[48]::setcomp() is a safer version of int& operator[]
The int& operator[]() was always sketchy, and really isn't going to work
well as we look forward to avx512. So let's set up a safe version and
call it setcomp. It is "safe" because it sets the bit you want, and
doesn't claim you can get a reference to an underlying integer. That
gives us freedom to implement it with an underlying bitfield, among
other helpful things.
2017-06-29 20:34:08 -07:00
Larry Gritz 23913500d2 Cleanup of bool8 2017-06-29 20:34:08 -07:00
Larry Gritz dfb3f2ef12 Qt5 build touchups 2017-06-29 16:19:00 -07:00
Pino Toscano 81b20775cc Port iv to Qt5 (#1711)
- switch the cmake search from Qt4 and Qt5, making use of the components
  for the Qt5 libraries
- adopt the automoc handling provided by cmake, so there is no more need
  to manually run & add moc sources
- make use of the cmake imported targets for the Qt5 libraries, so there
  is no need to manually care about variables for libraries and include
  directories
2017-06-29 16:18:03 -07:00
Larry Gritz aed29ec284 More rational type work (Follow up to #1698) (#1709)
Building on Joseph Goldstone's adding support for "rational" metadata type,

* Allow setting of rational data with oiiotool like this:

    $ oiiotool foo.exr --attrib:type=rational onehalf "50/100" -o rat.exr

* Allow nice human readable printing from iinfo or oiiotool --info, like:

    $ iinfo -v frame.0.exr
    ...
    captureRate: 24000/1000 (24)
    framesPerSecond: 24000/1000 (24)
    onehalf: 50/100 (0.5)
    ...

* Change the definition of the "FramesPerSecond" standard metadata from
  float to rational. This only affects GIF and ffmpeg-based movie files,
  and if you retrieve it with get_float_attribute(), it will auto-convert
  anyway. So we hope this will not break anybody.

* Add test cases

* Artifact: removed some code redundancies between formatspec.cpp and
  paramlist.cpp.
2017-06-26 00:50:53 -07:00
Larry Gritz 744b8b1e4f Allow a way for IBAprep to enforce same channel names on all images. (#1708) 2017-06-22 21:51:30 -07:00
Larry Gritz d73cc9fcd9 Fix build break on appveyor
Also update appveyor boost to 1.63
2017-06-16 14:32:57 -07:00
Joseph Goldstone 30ee9c115d Add support for OpenEXR rationals, implementing TypeDesc::TypeRationa… (#1698)
* Add support for OpenEXR rationals, implementing TypeDesc::TypeRational along the way. Comment out some unused typedefs in simd_test that were stopping the compile.

* Change (1 << 31) to (1UL << 31) for the sake of GCC

* Remove unused typedefs in simd_test that clang found problematic
2017-06-15 23:21:17 -07:00
Larry Gritz b3244dd9cf ImageSpec::channel_name(int) returns channel name safely (#1706)
Safely means, even if the channelnames is not filled out or you ask
for an out-of-range index, it will not crash or overrun the array, but
rather just return an empty channel name.
2017-06-13 22:34:28 -07:00
Larry Gritz bf67e35d0d Beef up strutil unit tests
Caught edge case bug in string_is<> where we needed to check for
empty string.
2017-06-09 23:55:34 -07:00
Larry Gritz ec16d4b75b Fix ref images
See #1700, at some point when we made some ref images, it was doing
something on tiff write that was making images that some readers would
give warnings about. All seems fine now, so just fix the refs.
2017-06-06 17:42:58 -07:00
Brecht Van Lommel 8bf4136e5b Fix Windows build to not force enable /MT, it is not need for BUILDSTATIC. (#1702) 2017-06-06 14:25:57 -07:00
Brecht Van Lommel 384b34ae95 Fix Ilmbase linker warning with LINKSTATIC on Windows. (#1701) 2017-06-06 14:25:57 -07:00
Larry Gritz aa5665eba2 bump version 2017-06-06 14:25:57 -07:00
Larry Gritz 49ecb7ea00 CHANGES
[ci skip]
2017-05-31 21:32:38 -07:00
Larry Gritz ed0e34bcc5 Fix broken diff printing for deep images (1694) 2017-05-31 21:08:03 -07:00
Larry Gritz 757c0ca701 Fix IBA::resample half pixel shift (1694) 2017-05-31 21:07:58 -07:00
Larry Gritz 015caefd0e oiiotool --resample:interp=0 (1694)
Sometimes you really, REALLY just want closest pixel blocky appearance
rather than bilinear sampling. ImageBufAlgo::resample() had that option,
but `oiotool --resample` didn't expose it.
2017-05-31 21:07:54 -07:00
Larry Gritz 7c9c732b58 Guard against dereferencing invalid file cache iterator. (#1697)
Analogous to #1696, but for the file cache.
2017-05-30 23:01:26 -07:00
Larry Gritz 403fcf4c83 Allow 'alpha' alternate channel name in deep files (1693) 2017-05-30 16:05:04 -07:00
Larry Gritz 5ca7fcfcc9 Update docs 2017-05-30 14:37:49 -07:00
Larry Gritz db30d8e587 Adjust deprecated IBA color conversion functions (#1695)
For several ImageBufAlgo functions related to color conversion:

* Deprecated in 1.7 -> turn on the OIIO_DEPRECATED attribute.

* Deprecated in 1.6, attribute turned on in 1.7 -> remove them.
2017-05-30 14:35:53 -07:00
John Haddon 4f03209d2c ImageCache : Fix crash caused by dereferencing end iterator (#1696)
In issue #1239, @lgritz described a situation in which the assertion in `check_max_mem()` could be triggered because `m_tilecache` could be empty, but `m_mem_used` could still be over the limit due to "dead man walking" tiles still being held in per-thread microcaches. A temporary fix was created in PR #1240, simply replacing the ASSERT with a DASSERT so that release builds wouldn't trigger the assertions. But this just allowed release builds to execute exactly the code path that the assertions were intended to protect - leading to the dereferencing of an invalid TileCache iterator. Here we simply replace the DASSERT with an early return if we detect this unexpected (but still entirely possible) situation.
2017-05-30 13:20:47 -07:00
Larry Gritz 91eabe1ca9 Fix which is_regular is called in searchpath_find (thanks Thiago) 2017-05-25 18:18:45 -07:00
Larry Gritz e66405f8e8 maketx: add --colorconfig option, works just like with oiiotool. (#1692) 2017-05-25 09:54:08 -07:00
Larry Gritz 47537e7d63 Merge pull request #1691 from lgritz/lg-deepholdout
deep holdout operation
2017-05-24 18:49:11 -07:00
Larry Gritz fd3e81d3b6 deep_holdout
The deep holdout function is one that culls the deep samples in one deep
image (A) that are behind the opaque depth of a second deep image (B).
No samples of B are included in the output, it is only used to mask
parts of A. Samples of A that straddle the opaque frontier are split.

This is implemented as ImageBufAlgo::deep_holdout(), and also in
oiiotool --deepholeout.
2017-05-22 21:31:03 -07:00
Larry Gritz 0b9021c338 DeepData::split() -- return whether or not any splits occurred 2017-05-22 21:31:03 -07:00
Larry Gritz 01ad7ceb00 DeepData::initialized() and allocated() 2017-05-22 21:31:03 -07:00
Larry Gritz b00af55a2b DeepData::opaque_z find the z where a deep pixel is fully opaque 2017-05-22 21:31:03 -07:00
Larry Gritz 3c15b560c6 Have DeepData::impl find, store, and retrieve important channel indices 2017-05-22 21:31:03 -07:00
Larry Gritz 1b7600bf3b ImageSpec::channelindex() retrieves index of named channel 2017-05-22 21:31:03 -07:00
Larry Gritz bb9b9036eb Stop using typedefs ImageIOParameter & ImageIOParameterList (#1690)
Just use ParamValue and ParamValueList. Those typedefs never served
any purpose, just deprecate them.
2017-05-22 21:27:25 -07:00
Larry Gritz 2cf2135c33 Better extraction of XMP from PNG files. (#1689)
Also, recognize some additional xmp tags in the tiff namespace.
2017-05-21 21:57:44 -07:00
Larry Gritz 0f503db63f ParamValue/ParamValueList/ImageSpec refactor (#1686)
Push a bunch of the logic previously in ImageSpec, to retrieve typed
attributes and do type conversions in the process, down to the ParamValue
and ParamValueList levels. Makes it a little more generally useful.
2017-05-18 18:53:37 -07:00
Larry Gritz ded35bebe6 TypeDesc: add utility function basevalues() (#1688) 2017-05-17 14:47:57 -07:00
Larry Gritz b49ff7c7aa Overhaul handling of gamma-corrected images. (1684)
Some (older, not very color-smart) image formats store a gamma exponent
-- neither defining a good color space nor being in a standard like
sRGB.  We were previously haphazardly labeling these as color space
"GammaCorrected", storing the gamma value in the "oiio:Gamma" metadata,
and hoping for the best. But the best, unfortunately, was total
ignorance by our standard color conversion functions (including the
likes of `oiiotool --autocc`).  And we just have too many places where
simply the name of the color space itself (without access to other
metadata) is assumed to be enough to perform color conversions.

So this patch does the following:

1. Adopts a new convention of calling the color space of such images
"GammaCorrectedX.Y", where the X.Y is the decimal gamma value. As an
example, we might now set the "oiio:ColorSpace" metadata for such files
to "GammaCorrected2.2".

2. Follow this convention when reading and writing the formats
supporting an explicit gamma exponent, including Cineon, DPX, HDR/RGBE,
PNG, RLA, Targa.

3. Augment the color transformation engine to recognize these names,
decode the exponent from the name, and thus be capable of (at the very
least) transforming between linear and gamma space. This means that
`oiiotool --autocc` should now be able to properly linearize input files
of this kind (previously it would give a warning and fail to linearize).
And also, it means that you can apply gamma corrections using commands
such as `oiiotool in.exr -colorconvert linear GammaCorrected2.2 -o out.png`

4. Makes `iv` recognize plain old gamma corrected images and not impose
a second correction on it. This is a band-aid, and what it really needs
is a full-blown OCIO support. But it's still a small step forward in
seeing some images properly that previously were incorrect.
2017-05-14 12:31:20 -07:00
Larry Gritz f29092e4cb Modernize and constexpr-ify typedesc.h (#1683) 2017-05-14 12:30:41 -07:00
Larry Gritz c03c351b61 Fix cpack rename issue on OSX (#1687)
Fixes #1682
2017-05-14 11:29:04 -07:00
LazyDodo 7373a25446 Remove empty destructors to resolve MSVC warning C4714 (function marked as __forceinline not inlined) (#1685) 2017-05-11 22:14:26 -07:00
Larry Gritz 25a754cd69 Make oiiotool -autocc gracefully handle unknown color spaces. (1681)
When using --autocc, previously having the deduced color space be one
whose transformation was unknown was a hard error that would exit
oiiotool.  This patch changes an unknown color space be a warning, with
the rest of the oiiotool commands proceeding despite not transforming
the colors (this is just for the automatic transformations triggered by
--autocc).
2017-05-09 23:05:35 -07:00
Larry Gritz 929ca1e64d Improve XMP parsing (1679)
1. If pugi load_buffer finds syntax errors in the XML it is parsing, it
returns an error code, which caused us to ignore the XMP block entirely.
It turns out that's a poor strategy, because lots of files have XMP that
is ever so slightly malformed, so we weren't picking up their XMP at
all! So, just ignore the fact there was a parsing error, go ahead and
try to make sense of whatever portion (maybe all?) of the block was able
to be parsed.  It works!

2. Added a additional XMP tags for GPano, Google's Photo Sphere metadata
schema.

3. Replace linear search of the XMP tag list with a flat_map::find
(which underneath is a sorted vector with binary search).

4. Also add a bunch of camera raw (crs: prefix) XMP tags to the table.
2017-05-09 23:04:47 -07:00
Larry Gritz 7725fd4879 Upgrade local pugi to 1.8.1 (1679) 2017-05-09 23:04:34 -07:00
Larry Gritz 70166b20f7 Fix typo in comment 2017-05-06 01:33:02 +02:00
Larry Gritz fcb1d5749a Clarify confusing header comments about simd blend functions.
[ci skip]
2017-05-05 18:54:21 +02:00
Larry Gritz f7ea75877e Avoid latex2html, get rid of html style, use hyperref package instead 2017-05-05 14:03:11 +02:00
Larry Gritz 5b25ba0d36 Improve TIFF I/O of color separation images (1658)
I had been assuming that for TIFF photometric mode "separate",
it would always be 4 channels and they would be CMYK. Not so!

Turns out that there's a tag called InkSet which says if it's really
CMYK or not. If it's not, check the InkNames to provide channel names.
Also, the auto-conversion of CMYK to RGB should only happen if it's
truly CMYK, because the conversion wouldn't be correct for arbitrary inks.

On output, also, if the request is made to output color separated mode
(by setting the attribute "tiff:ColorSpace" to "CMYK" or "color
separated"), set those attribute as correctly as we can -- to true CMYK
if it appears to be so (4 channels, named C,M,Y,K or Cyan, Magenta,
Yellow, Black), but otherwise say it's custom inks and output the
channel names as ink names.

Aside: It has always bothered us that TIFF doesn't support channel names
(like OpenEXR does). But it does support the InkNames tag. What if we
always output the channel names as InkNames, even for non-separated
photometric mode. Would there be any negative consequences? Would apps
ever misbehave in the presence of an InkNames tag for an RGB photometric
image, or would it just be ignored?
2017-05-04 07:17:58 +02:00
Larry Gritz b5862ba415 Exception safety improvements for Filesystem::searchpath_find. (1680)
searchpath_find had a couple calls to the underlying is_directory
and is_regular_file without catching any exceptions they might throw.
Those should be changed to Filesystem is_directory and is_regular
which are our existing wrappers that already catch any exceptions.
2017-05-04 00:29:34 +02:00
Larry Gritz 8af14aa14b RAW input: add config hint for maximum camera value (1666) 2017-05-02 08:53:35 +02:00
Larry Gritz 7b351d8e26 CHANGES 2017-05-01 21:32:57 +02:00
Larry Gritz f6b4a50951 Deprecate OIIO_CONSTEXPR, OIIO_CONSTEXPR_OR_CONST, OIIO_NOEXCEPT (#1678)
Use C++11 constexpr and noexcept instead.
2017-04-26 17:12:44 -07:00
Larry Gritz e838b22921 Refactor ParamValueList (#1677)
We can remove most of the complexity of this class by making
ParamValueList inherit from std::vector<ParamValue> and just add the few
extra methods we want (like a version of find that is case-insensitive
on name, but excludes potential matches that are the wrong data type).
In other words, a change of "has-a" to "is-a" makes most of the code go
away.
2017-04-25 22:55:18 -07:00
Larry Gritz ac268423c9 oiiotool: make --fit:exact=1 work for all subimages (#1676)
It was just fitting the first subimage and dropping the others on the floor.
2017-04-21 16:02:13 -07:00
Larry Gritz 4ad51421da deep_merge: add check for the inputs to have the same channels (#1675) 2017-04-20 14:23:02 -07:00
Larry Gritz 87bc7bf9a9 EXR input: Fix to canonical sorting order -- typo bug fix (1673)
A finger malfunction ages ago botched the list of channel names that
help us sort channels into canonical order. Where I wanted to say
RA, GA, BA, somehow I said RA, RG, RB. Oh boy.
2017-04-20 12:01:15 -07:00
Larry Gritz e923ba321b format of PR template 2017-04-20 12:00:42 -07:00
Larry Gritz f3cd9cf75f Revise PR and Issue templates
[ci skip]
2017-04-20 09:40:02 -07:00
Larry Gritz 3a637eb2eb intrusive_ptr bug fix (#1674)
I realized that if intrusive_ptr<T>::reset(T*) is called with a pointer
to the same object it already refers to, it could be erroneously freed
because it was decrementing the existing refcnt before incrementing the
refcnt of the new value. So rewrote reset() to be safe under that
circumstance.
2017-04-20 09:37:35 -07:00
Larry Gritz 102a9f2556 Fix broken TextureSystem::get_texels() that would crash (1669)
Simon Smith pointed out on oiio-dev a flaw in TS::get_texels(filename,...)
where it called itself recursively instead of correctly calling
get_texels(handle,...).

This patch contains the fix (the 2-line change in texturesys.cpp).

I also added a new testsuite entry, and needed to beef up testtex.cpp
a bit to make it work smoothly to test get_texels().
2017-04-18 15:59:07 -07:00
Larry Gritz c7c0677ee8 OSX rpath fix and Makefile INSTALL_PREFIX setting (1671)
1. Some complaints (including failures in OSL TravisCI builds) led me to
believe that the 'cmake_policy (SET CMP0042 OLD)' was not correct and
that we should remove that and set MACOS_RPATH ON. This seems to clean
up some rpath troubles on OSX. It should not have any effect on non-OSX
builds.

2. For the Makefile wrapper, allow INSTALL_PREFIX to be set, which is
passed along to cmake as CMAKE_INSTALL_PREFIX. It defaults to the usual
of ./dist/PLATFORM, but this lets you override to, for example, instruct
the build to put the full installed files in another location. You could
always do this if invoking cmake directly, but it was tricky for those
who preferred to use the make wrapper.
2017-04-18 15:43:55 -07:00
Larry Gritz 0420bb75ed Fix broken ImageBuf copy constructor from ImageBuf that wraps app buffer (1665)
It was not working, had an assertion.

Remove the assertion, fix the logic to make it work, add a test.

While I was there, I moved a histogram test from imagebuf_test.cpp to
imagebufalgo_test.cpp, it seemed to be more on-topic there.
2017-04-18 14:18:18 -07:00
Larry Gritz fed7b2f36a Protect IC::get_image_info against out-of-range subimage or miplevel. (1672)
Fixes #1670
2017-04-18 14:16:05 -07:00
Larry Gritz 3ea0f08fb6 IBA::resample() and oiiotool --resample extended to work for deep images. (1668)
Remember that "resample" is a resize with no filtering or interpolation:
for each pixel in the destination, is merely copies the source pixel whose
center is closest to the corresponding spot in the image.

This patch extends the functionality of ImageBufAlgo::resample() and
oiiotool --resample, to happily do the obvious thing for "deep" images.

This lets you quickly (but inaccurately) resize or create different-sized
proxies for deep images as you would for regular images.

Some day, it would be nice to extend a true resize() to work for deep
images, so we can have high-quality deep resizes. But that is going to
take some head-scratching about how to properly interpolate or filter
deep images.
2017-04-18 11:16:15 -07:00
Larry Gritz d8f1f443da oiiotool -resize/-resample: revise logic for nonzero origin, crop, overscan (#1667)
The 'size' specification argument to oiiotool --resize and --resample
had very unintiutive behavior for images where the display and pixel
data windows were not the same, especially if the data window had a
nonzero origin (such as crop or overscan cases).

The underlying ImageBufAlgo::resize is mapping a display window and
is more straightforward. So in this patch, we take the oiiotool --resize
(and --resample) and interpret it as the desired display window size,
and then compute the approprate pixel window from it, rather than the
other way around (which was really strange).

So now you are saying: "oiiotool, here is the size and offset of the
display window I want for the output. Resize the input image so that its
original display window maps exactly to the new display window I've told
you about. Figure out what pixel data window you will need in the output
to ensure that all of the data pixels in the input will be represented."

For the usual 99% case where display == data and origins are 0, the
behavior does not change. But this is definitely easier to control for
the oddball cases.
2017-04-18 11:15:40 -07:00
Larry Gritz 461315a10e Minor build system cleanup and synchronization with OSL (#1664) 2017-04-14 09:14:13 -07:00
Chris Kulla 8074ac9b28 Pad the length of pool allocations for ustring::TableRep so that the next one allocated will also be aligned
This was noticed by the undefined behavior sanitizer
2017-04-12 17:48:21 -07:00
Larry Gritz 2460f7b638 Namespace overhaul (#1662)
Mimics recent fix in OSL:

* Explicitly and automatically build the vMAJOR_MINOR versioning into
  the namespace.

* Simplify double nested namespace to just one level.

* Change OIIO_NAMESPACE_USING with `using namespace OIIO` (the macro
was obfuscating without being short or helpful).
2017-04-12 12:34:32 -07:00
Larry Gritz c4dde5a860 Fix docs typo that misclassified a section as a subsection 2017-04-07 15:04:11 -07:00
Larry Gritz 9a02c305b1 Overhaul ErrorHandler to Remove remaining varargs use. (1653)
Use variadic template, C++11.

Also opportunistically eliminated inclusion of some useless headers.
2017-04-06 16:14:54 -07:00
Larry Gritz 741417c51e atomic.h: remove all the parts needed only for C++ < 11 (1661)
Now that we have std::atomic, the vast majority of atomic.h can be
removed. We only keep the things we like that add to the facilities
of C++11.
2017-04-06 16:14:37 -07:00
Larry Gritz 5eee7ff217 atomic.h improvements (1661)
1. atomic_min/max: Some web reading makes me think that our
implementation of atomic_min and atomic_max ought to use
compare_exchange_weak rather than compare_exchange_strong. As I
understand it, the stricter requirements of the strong versions
(basically, guaranteeing to never have a "false negative" where it
thinks it needs to try again but it's actually unnecessary) can on some
architectures lead to much worse performance.

2. New atomic_fetch_add for std::atomic<float> and <double>. They
exist, but don't in the current standard support atomic add (so we
implement them in terms of compare_exchange, which is supported).
2017-04-06 16:14:27 -07:00
Larry Gritz bf76a46581 timer.h: Add handy timed_thread_wedge() (1660)
It's for helping with benchmarks where you want to see how something scales
with number of threads.

Example output:

    threads    time   speedup  efficient  its/thread   range (best of 1)
       1        2.3     1.00x    100.00%   20000000     0.00
       2        1.2     1.97x     98.50%   10000000     0.00
       4        0.7     3.59x     89.86%    5000000     0.00
2017-04-06 11:42:14 -07:00
Larry Gritz 367226b0d0 function_view (1660)
New file, function_view.h, contains the definition for a function_view<>
template that is a lightweight, non-owning wrapper for a callable
object. It has much less overhead than a std::function<>, but at the
expense of being non-owning and needing to ensure that its use does not
outlast the lifetime of the callable entity it wraps (very analogous to
the limitations of string_view and array_view).
2017-04-05 19:05:09 -07:00
Ray Molenkamp 7c7dbaaa9a Fix some bool vs int warnings on Windows (1659) 2017-04-03 14:36:58 -07:00
Ray Molenkamp f6eb68fba3 Fix Windows warnings about simd types as function args (1659)
Seems that MSVC will give errors if the simd types are passed on the
stack by value, since they can't guarantee proper alignment.

Changing a few instances of these from, say, `float4` to `const float4&`
fixes it, and should make no performance difference for small inline
functions.
2017-04-03 14:36:51 -07:00
Larry Gritz 4e6383f08a Use C++11 vector::emplace_back() (1657)
Using vector::push_back when constructing a new object can cause
extra copies or allocations/deallocations. The new (C++11) emplace_back
grows the vector first and then constructs the object in place, avoiding
any unnecessary moves, copies, or allocations.

Thanks, clang-tidy, for finding all of these for us with no hassle.
2017-04-03 08:01:53 -07:00
Larry Gritz 08910329ab Strutil: extend type-safe variadic fprintf to stream output. (1656)
Same interface, just pass a std::ostream& instead of a FILE*.
2017-04-03 07:59:18 -07:00
Larry Gritz 8d4bcefac3 Comment typo and clarification 2017-04-02 16:40:27 -07:00
Larry Gritz 4ef45ae4f0 Fix cmake typo 2017-04-01 14:48:07 -07:00
Larry Gritz 621ba23645 ImageCache stats: don't print files as "broken" if they aren't (#1655)
At the end of the IC/TS stats, there's a list of "broken" files, and
what printed there were those files which were either broken() or
!validspec().

Two circumstances lead to the spec being not valid:

(1) Calls to invalidate() mark the spec as invalid, of course! But just
because the app invalidated the file (perhaps because it thought the
file might be subsequently updated on disk and wanted a fresh look at
it) doesn't mean the file was ever broken.

(2) When the app requests an ImageCacheFile handle up front (as OSL
does) but then never opens the file. That also doesn't mean it was
broken. You just never read from it.

For both of these circumstances, it's misleading to list the file among
those that are known to be broken (presumed corrupted or missing).
2017-03-31 17:01:11 -07:00
Larry Gritz 73403f7e4d More conversion of old C header includes to modern C++ style 2017-03-30 17:27:41 -07:00
Larry Gritz ee5d5c6f36 Adjust tidy header filter to include the foo_pvt.h files 2017-03-30 17:27:41 -07:00
Larry Gritz 032497dc9f Fix includes -- change lots to full <OpenImageIO/blah.h>
Previously we used a mix of quotes, and sometimes not having the
OpenImageIO/ qualifier.

This is helpful in clang-tidy use, because we're including headers
based on matching OpenImageIO/*.h, as a way to have it analyze all our
own headers, but no system headers.
2017-03-30 16:30:58 -07:00
Larry Gritz 9a56c39c9e clang-tidy fixes: include headers in analysys
The first review of clang-tidy support neglected to use the --header-filter=
command, thus excluding headers from analysys.

Also, when tidying headers, if you use -fix, it's very important to
ensure that only one module is compiled at a time, or two processes
might try to modify a header at the same time, garbling it.
2017-03-29 23:04:27 -07:00
Larry Gritz b71a0c0cc3 Modernize deprecated C style headers to C++ ones (1649)
This is our first set of changes made by clang-tidy!
2017-03-29 16:29:59 -07:00
Larry Gritz bc34ad73b2 New build flags: CLANG_TIDY, CLANG_TIDY_CHECKS, CLANG_TIDY_ARGS, CLANG_TIDY_FIX (1649)
All off by default, but allows really easy use of clang-tidy while building.
For example,

make CLANG_TIDY=1 CLANG_TIDY_CHECKS="-*,modernize-*"

or if you are really adventurous

make CLANG_TIDY=1 CLANG_TIDY_CHECKS="-*,modernize-*" CLANG_TIDY_FIX=1
2017-03-29 16:29:52 -07:00
Larry Gritz aa20116e64 Bump dev version, update CHANGES 2017-03-29 16:22:12 -07:00
Larry Gritz c086ce6442 SPI: updates for new SpComp2 build 2017-03-28 17:53:29 -07:00
Larry Gritz c069f1b9a5 Rebuild PDF docs
[ci skip]
2017-03-27 23:46:46 -07:00
Larry Gritz 86299c1e1d CHANGES 2017-03-27 23:37:38 -07:00
Larry Gritz 39a8fa7e56 Add Python bindings & unit tests for new ImageSpec(ROI) constructor. 2017-03-27 22:58:11 -07:00
Larry Gritz 1b8f76b8a3 Text drawing overhaul (#1646)
1. Extend ImageBufAlgo::render_text in several ways:
(a) Text color is now passed as an array_view<const float>, which is
    safer than passing a raw pointer and hoping it points to enough
    data.
(b) New parameters: alignx and aligny, which can be used to control
    the alignment of the text with the (x,y) coordinates passed.
    Options for alignx are ImageBufAlgo::TextAlignX::Left (default),
    Right, and Center, and options for aligny are TextAlignY::Baseline
    (default), Top, Bottom, Center.
(c) New parameter: int shadow, default to 0 (old behavior), with nonzero
    values causing the rendered text to be dilated with black halo to be
    more visible on backgrounds with similar color.
(d) The destination image no longer is required to be initialized. If not,
    it will be initialized to be just large enough to hold the rendered
    text. Pre-initialized images will continue to draw the text overtop
    of the existing pixel values (as if an "over" composite).

2. Add a new ImageBufAlgo::text_size() function, which is related to
IBA::render_text(), except that rather than modifying an ImageBuf, it
merely computes the bounding box (relative to the left edge of the
baseline of the first character) as a ROI. But with this knowledge, it
becomes easy to do things like align or center text in tricky ways.

3. oiiotool --text has also been extended to have optional xalign= and
yalign= modifiers to align the text to the coordinates
passed. Horizontal alignment choices are "left" (default), "right", and
"center", and vertical alignment choices are "baseline" (default),
"top", and "bottom." Also, an optional modifier shadow= can control the
drop shadow.

So, for example, to make your text centered along the horizontal axis of
an image at scanline 100, and use some shadowing to clarify the text,
you could:

    oiiotool in.exr -text:x={TOP.width/2}:y=100:xalign=center:shadow=1 \
        "Hello, world" -o out.exr
2017-03-27 16:04:47 -07:00
Larry Gritz 15ff362f21 oiiotool: expressions recognize FRAME_NUMBER and FRAME_NUMBER_PAD (#1648)
On oiiotool command line {expressions}, FRAME_NUMBER is replaced based
on the numeric wildcard iteration, and FRAME_NUMBER_PAD is the same
value but as a string that appears zero padded to the number of digits
specificed by --framepadding.

So, for example, to burn in frame numbers to every image in a sequence:

    oiiotool -framepadding 4 -frames 1-100 in.#.exr \
        -text:x=50:y={TOP.height-50} "Frame {FRAME_NUMBER_PAD}" \
        -o out.#.exr
2017-03-27 12:20:38 -07:00
Larry Gritz a2faae39c8 Strutil::parse_identifier_if (#1647)
Utility to return whether the identifier at the head of a string matches
a pattern, and advance the pointer only if it does.
2017-03-27 09:11:34 -07:00
Larry Gritz e775ac2514 Docs typo fixes
[ci skip]
2017-03-26 12:42:41 -07:00
Larry Gritz e2eaa743d0 New OIIO::getattribute() queries: "input_format_list", "output_format_list" (#1577)
Just like the existing "format_list" returns a comma-separated list of
all formats supported by any built-in or found plugins, the new queries
return the lists of input and output formats, respectively. An example
of how they may differ is if a particular format is available for
reading but not writing.

At the time of this writing, cineon, dds, dicom, ffmpeg, psd, ptex, raw,
and softimage are input formats but not output formats. Presently, there
are no output-only formats.

In organizing this, we removed entirely the *output.cpp files for
several formats that did not support outputs, with those now-unneeded
files containing only nonfunctional stubs.
2017-03-23 14:49:09 -07:00
Larry Gritz 4ec6c396de Fix compiler warning on gcc 5.4 2017-03-23 12:38:51 -07:00
Christopher Kulla 11108470be Upgrade compiler path for SPI Arnold builds 2017-03-23 09:43:37 -07:00
Larry Gritz 83a564f78c Synchronize some build scripts between OIIO and OSL.
They are very similar. From time to time I do two-directional transfers
to migrate the best practices of each to the other.

I also try to nudge them even closer in various ways, such as using
${PROJECT_NAME}_BLAH in both instead of OSL_BLAH in one and
OpenImageIO_BLAH in the other.
2017-03-22 21:01:37 -07:00
Larry Gritz df4858959c JPEG: auto conform to supported channel count. (#1643)
JFIF files, as you know, only support 1 or 3 channels (grayscale and
RGB, respectively).

Previously, we accepted the special case of 4 channel output (presumably
RGBA) by silently dropping the last channel (A, not representable in
JFIF files), but for any other channel count (2, or >= 5) would just
allow open() to fail.

With this patch, we make the JPEG writer even more forgiving. For
nchannels > 3, we truncate to just the first three channels, and for 2
channels, we truncate to just the first channel (outputting grayscale).

The reason why we want this extra flexibility is that JPEG is such a
common format for "proxies", "thumbnails", and other kinds of embedded
or web-facing images, where we might want to just quickly generate such
a proxy for arbitrary images without wanting to think hard about the
logic of how to conform unusual channel counts to JPEG's limitations.
And let's face it, if the user really wanted high fidelity, they would
not be using JPEG -- a usually-lossy, 8-bit-only, 1-and-3-channel-only
format -- and so silently dropping a channel that can't be represented
is probably not the biggest compromise being made to the original data
when saving to this format.
2017-03-22 21:00:57 -07:00
Larry Gritz 6da510788c PSD: add support for 'cmyk', 'multichannel', and 'grayscale' color modes. (#1641)
Also support 32 bit RGB and grayscale. We thought we had 32 bit working
before, but we were wrong -- PhotoShop stores linear float for "32 bit",
not uint8 as we assumed.
2017-03-22 19:22:47 -07:00
Sergey Sharybin 0772aa61f2 Fix over-allocation when trying to open directory as a file (1640)
There are two main things changed here:

- First we check whether requested filename points to a regular file.
  This solves the issue of ftell() returning really huge value for
  file stream opened for a directory.

- Second we check ftell() output and compare it to -1 to catch possible
  acess issues.

In theory it'll be nice to use Filesystem::get_size() which does all
the checking already, but leaving it as a TODO. Also the thing to note
here is that Filesystem::get_size() returns 0 for directory, which
wouldn't let us to report more meaningful error to the user about
what's exactly wrong with file one tries to open.

---

WebP: Use Filesystem::file_size instead of ftell()

This allows us to keep all file-size related magic in a single place
and simplifies the code.

Additionally made m_image_size an explicit 64bit type to avoid possible
narrowing type casts and possible issue loading big images on 32bit
platforms.

---

WebP: Perform preliminary header check prior to full file read

This way we can avoid read of unnecessary big file just to realize
it is not a valid WebP image.

New validation code goes as following:

- We check that regular file was passed.

  This way we can give reasonable error message to user. Perhaps
  this could happen on a higher level so we always know regular
  files are coming to the image readers. On another hand, one
  might want to implement an image sequence reader where we pass
  a directory containing images.

- We check that file size is 12 bytes at least.

  This goes according to the file specification

    https://developers.google.com/speed/webp/docs/riff_container

- We read 64 bytes at a max which we use for WebPGetInfo()

  This 64 bytes constant comes from Blender, which seems to be
  safe for all the file formats we support.

  If decoding of this chunk fails we avoid reading the whole file.
  Otherwise we read the whole file and decode that.

Things which can still be improved:

- There is some duplicated code around reading file data and verifying
  it's size. While it's possible to de-duplicate it within this particular
  file it probably makes more sense to have common utility which does
  error() on the case of fread() failure.

- There is still some place in OIIO which causes slow behavior of iinfo
  when trying to get info of 1Gig file filled with zeroes, but this does
  not come from WebP codec. While it's something to be investigates still
  it does not really belong to this commit.

- Not sure it's more clear to re-set file position before reading the
  whole buffer or resize the buffer and read the remaining part with
  a header offset.

  Never liked the offset magic, so for now used simple file position
  reset.
2017-03-22 13:52:48 -07:00
Larry Gritz 8517de0f2c Fix test for ability to use std::regex (#1644)
1. Wasn't setting the C++ standard flags properly for the test, so it failed
on some platforms and didn't use std::regex when it could.

2. Revised test -- the prior C++ did not properly discriminate between
what was implemented vs unimplemented on the broken gcc 4.8 (at least
some subsets of regex_match work, but regex_replace does not, until
it was all fully implemented in gcc 4.9).
2017-03-21 11:05:26 -07:00
Larry Gritz b54423c416 TIFF: Make and Model fields left out of written metadata (#1642) 2017-03-20 14:16:27 -07:00
Larry Gritz 777dc35b8a Tweak testsuite/runtest.py 2017-03-18 21:44:05 -04:00
Larry Gritz 82767ff1cb Add test case for #1635 2017-03-16 22:16:26 -04:00
Larry Gritz bd67e0ba43 oiiotool --eraseattrib [regex] (#1638)
Extend ImageSpec::erase_attribute so that the name of the attribute to
erase is a regex, and any matching attributes will be erased.

Add oiiotool --eraseattrib, taking an argument with regex pattern,
and it will strip any matching metadata from the top image.

Example uses:

    oiiooool in.jpg --eraseattrib smpte:TimeCode -o no_timecode.jpg
    oiiotool in.jpg --eraseattrib "GPS:.*" -o no_gps_metadata.jpg
    oiiotool in.jpg --eraseattrib ".*" -o no_metadata_at_all.jpg
2017-03-16 10:28:26 -04:00
Sergey Sharybin b91db514e9 Add some extra checks to exif parser to avoid memory access issues (#1639)
This is an attempt to solve #1635. This avoids the crash by ignoring
any directory entry which is outside of the parsing buffer (that would
be really weird if there is a legit memory pointer to an outside memory
block).

There are much more places where there is potential crash is burried
in here, but those i don't feel like going into.

For such things it's really good idea to trust no input data and verify
it, otherwise it's really easy to run into crashes and even possibly
security issues.

Maybe it's also not a bad idea to add an option tyo ignore exif headers
reading for the applications which doesn't need exif.
2017-03-15 22:15:56 -04:00
Larry Gritz 93d8432387 Improvement to printing of long metadata (#1637)
In various contexts (such as oiiotool -v -info) when printing metadata
that consists of an arbitrarily long array of values, it will print
the first several values and then "..." to avoid going haywire if there
are 100000 values, say.

But, hmmm, in such a case you just might want to know how many values
there are and their type. So now instead of

    Foobar: 0, 0, 0, 0, 0, 0, 0, 0, ...

it will more helpfully say

    Foobar: 0, 0, 0, 0, 0, 0, 0, 0, ... [557168 x uint8]

And then you know who you can yell at about what.
2017-03-14 12:46:23 -04:00
Larry Gritz de6c8a80e1 DICOM: be robust to slightly older versions of DCMTK (#1636) 2017-03-11 08:57:41 -08:00
Larry Gritz 9105bae580 oiiotool --echo (#1633)
This adds an --echo MESSAGE command to oiiotool, which will print the
message to the console at that point the left-to-right evaluation of
command line arguments.

For example:

    oiiotool test.tif --resize 256x0 --echo "result is {TOP.width}x{TOP.height}"

This will resize the input to be 256 pixels wide and automatically size
it vertically to preserve the original aspect ratio, and then print
a message to the console revealing the resolution of the resulting image.
2017-03-10 20:41:42 -08:00
Larry Gritz 3bb8f8e456 Fix date formatting to use "%02" for hour. (#1630) 2017-03-08 14:08:38 -08:00
Larry Gritz 7c89022c5c oiiotool: better error reporting for file open errors when -iconfig is used. (1626)
For the particular cases of "open with config" (triggered by the
--iconfig option), we had a different code path that goes through the
ImageCache and were not properly propagating any errors that were
encountered upon opening the file.
2017-03-05 21:51:20 -08:00
Larry Gritz 9788ce2a22 RAW: Support RAW input to ACES color space. (1626)
The "raw" reader by default will convert its input to sRGB color space,
but allows you to request that it be converted upon read to other
color space (or not alter the values) by setting the "configuration"
option "raw:ColorSpace" to the name of the color space you want.

This patch adds "ACES" to the list of color spaces it understands,
at least for the versions of libraw that support it (version 0.18 and
newer, it seems).

While I was in there, I changed the color space names it recognizes
to be case-insensitive.
2017-03-05 21:51:20 -08:00
Larry Gritz 6bd1d7fa08 Docs typo fix
[ci skip]
2017-03-05 12:23:41 -08:00
Larry Gritz 5cb3a68ffc Minor bug fixes in raw file input. (1629)
Fixes #1628

1. The default value for missing "raw:use_camera_matrix" attribute should
have been 1, not 0, in order to match the default behavior of libraw/dcraw.

2. The demosicing control logic wanted to erase the "raw:Exposure"
attribute, but incorrectly specified the search to be constrainted to a
string attribute (thereby failing to erase the attribute which is
actually a float). The simple solution is that those erase_attribute
calls really don't need to constrain the type at all.

3. Add support for newer (as of LibRaw 0.16) demosaic algorithms "DMT"
(mode 11) and "AAHD" (mode 12). Also allow the demosaic algorithm names
to be case insensitive.

4. Rename "Modified AHD" to "AHD-Mod", to simplify the name and
match libraw terminology.
2017-03-04 13:42:49 -08:00
Larry Gritz 52ad38d09c Improvement to decoding metadata from files with XMP blocks (#1627)
OK, this is subtle. When decoding XMP, I originally thought that it
wouldn't include Exif data, but sometimes it does. But the XML is just
string data.  So this patch will look up the name to see if it's a known
Exif field, and if so, use the type we know it ought to be to correctly
decode from a string.

Also in exif.cpp, changed the implementation of the tag map used by
exif_tag_lookup so that it's case insensitive (because, ugh, some
raw images have their Exif data in XMP as "exif" rather than "Exif").

The bottom line is that these changes improve proper recognition of
certain metadata when reading RAW files.
2017-03-03 16:45:56 -08:00
Larry Gritz b5eb1ac766 Extend Strutil::from_string to handle unsigned int 2017-03-01 23:59:24 -08:00
Frédéric Devernay c371a2f70a Fix typo that prevented reading of all possible Exif tags in TIFF files. (1625)
Obvious cut and paste error. Spotted by Frédéric Devernay.

Fixes #1624
2017-02-28 10:53:28 -08:00
Larry Gritz 6acdba29fc Determine at build time whether to use boost::regex or if std::regex works. (#1620)
Prefer C++11 std::regex when available.
2017-02-22 21:59:52 -08:00
Larry Gritz f043f80b5e CHANGES 2017-02-22 13:45:32 -08:00
Larry Gritz 17edebc563 Upgrade tinyformat to more recent snapshot. (1618) 2017-02-22 13:39:54 -08:00
Larry Gritz 9e52d298bf Cleanup of Strutil::format and similar functions. (1618)
* Found a bug in Srutil::format and ustring::format that was introduced
  recently when we switched it to use variadic templates -- when passed
  just a single bare format string (with no arguments), it was just
  passing back the original string, without doing correct conversion of
  %% to % as it should to match printf-like behavior. We need to run
  even the format-string-only case through tinyformat.

* Convert all the other places that used TINYFORMAT_WRAP_FORAMT into
  much more straightforward use of variadic templates, now that we are
  C++11 minimum.
2017-02-22 13:39:54 -08:00
1258 changed files with 367224 additions and 127212 deletions

No files matched your search

+132
View File
@@ -0,0 +1,132 @@
Language: Cpp
BasedOnStyle: WebKit
SpaceBeforeParens: ControlStatements
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
#AlignConsecutiveAssignments: Consecutive
#AlignConsecutiveBitFields: Consecutive
AlignConsecutiveDeclarations: false
#AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: TopLevel
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: All
BreakBeforeBraces: WebKit
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentExternBlock: NoIndent
IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 3
NamespaceIndentation: Inner
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 40
PenaltyBreakBeforeFirstCallParameter: 100
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 75
PenaltyReturnTypeOnItsOwnLine: 50
PointerAlignment: Left
ReflowComments: false
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++14
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseTab: Never
#...
+11
View File
@@ -0,0 +1,11 @@
Checks: '-*,clang-analyzer-security*'
WarningsAsErrors: ''
HeaderFilterRegex: '(OpenImageIO/[a-zA-Z0-9_]+\.h)|(imageio)|(oiio)|(iv/)|(_pvt\.h)'
AnalyzeTemporaryDtors: false
User: lg
CheckOptions:
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: modernize-use-emplace.SmartPointers
value: 'OIIO::intrusive_ptr'
...
+38
View File
@@ -0,0 +1,38 @@
# Reformatting via clang-format (part 1) (#2059)
5e76177f6850a8d04c544dc98128bcdfe55ca40a
# clang-format stage 2: src/libutil (#2064)
1a5b7aa00dd34883a8829875ee05c55b2a1f6736
# clang-format stage 3 -- src/*.imageio/* (#2065)
22e1af2ff0caa2c9aa31c0d7a69eb7762c04302d
# clang-format of src/libtexture and src/libOpenImageIO (#2067)
400e2340cf12ae84792f9a0146426b6022474dc9
# clang-format, final-ish update (#2069)
5af338158ad47fc84e7b0d03086fece04e0e2d24
# Adjustments from clang-format update
3e106c35845715875c3b3ce7b1621cb62ea41f0d
# clang-format fixes (#2137)
e536411711367ed7309ca884ebc9de4cea4d0da0
c31816192691562e96b4ebc10dd7e5fd2e9c801b
# Minor formatting changes in ustring with new clang-format (#2574)
9e911bddf275206867643d0009f0bd7b9a20e463
9fa2a5d42465870ae370afe5e3298433b2ecb56c
# Fix broken clang-format test (#2627)
7e5b841a80ed63b38f6d343889de615ef8cc4316
# Adjustments from clang-format update with clang 8
e83809b77e4d895dbf48fb6c2b5fb914a5f8eb06
# Touch up formatting with clang-format
f701a76b745b6ddba41c77b24a1ea7e1f48ae0b4
# clang-format: Adjust alignment of line continuation backslashes (#2664)
742173e39588e07cf43cbe7b49dd22d624a48388
d8810c5365ea88e2b1bce6155b7b495c18f2f9bc
-36
View File
@@ -1,36 +0,0 @@
Please ask questions ("how do I...?") on the [oiio-dev](http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org) mail list, not by filing issues.
Make concrete suggestions for fixing the code ("here is a patch") by filing
a pull request, not an issue.
### Problem
Describe the problem or suggestion here.
**Expected behavior:** [What you expected to happen]
**Actual behavior:** [What actually happened]
If your problem is a broken build, please create a [gist](https://gist.github.com)
that contains the _full_ verbose build log, which you can create like this:
```make nuke ; make VERBOSE=1 > build.log```
If you are reporting a problem about a release branch, have you already
tried the current head of `master` to see if the problem has been fixed?
### Steps to Reproduce
1. [First Step]
2. [Second Step]
3. [and so on...]
### Versions
* OIIO branch/version:
* OS:
* C++ compiler:
+37
View File
@@ -0,0 +1,37 @@
---
name: Bug report
about: I think I have identified a legit bug and can describe it.
title: "[BUG]"
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is. What happened, and
what did you expect to happen instead.
**To Reproduce**
Steps to reproduce the behavior:
1. Do this...
2. Then this...
3. Then THIS happens (reproduce the exact error message if you can)
**Expected behavior**
A clear and concise description of what you expected to happen.
**Evidence**
Do you have error messages? (please quote exactly) Screenshots? Example
command lines or scripts that reliably reproduce the error? If it only
happens with certain image files, can you attach the smallest image you
can make that reproduces the problem?
**Platform information:**
- OIIO branch/version:
- OS:
- C++ compiler:
- Any non-default build flags when you build OIIO:
**IF YOU ALREADY HAVE A CODE FIX:** There is no need to file a separate issue,
please just go straight to making a [pull request](https://github.com/OpenImageIO/oiio/pulls).
+21
View File
@@ -0,0 +1,21 @@
---
name: Build problems
about: I'm having trouble building OIIO. Help!
title: "[BUILD]"
labels: ''
assignees: ''
---
**PLEASE DO NOT REPORT BUILD TROUBLES AS GITHUB "ISSUES" UNLESS YOU ARE RALLY SURE IT'S A BUG**
The best way to get help with your build problems is to ask a question on the
[oiio-dev developer mail list](https://lists.aswf.io/g/oiio-dev).
When you email about this, please attach one or both of the following:
1. The full verbose build log, which you can create like this:
```make clean ; make VERBOSE=1 > build.log```
2. The `CMakeCache.txt` file from your build directory.
If you are pretty sure that you have identified a **BUG** in the OpenImageIO
build scripts, please file a [bug report issue](https://github.com/OpenImageIO/oiio/issues/new?template=bug_report.md).
+20
View File
@@ -0,0 +1,20 @@
---
name: Feature request
about: I have a concrete idea about how to improve OpenImageIO.
title: "[FEATURE REQUEST]"
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context about the feature request here.
+27
View File
@@ -0,0 +1,27 @@
---
name: Question
about: How do I... I need help with...
title: "[HELP]"
labels: ''
assignees: ''
---
**PLEASE DO NOT ASK USAGE QUESTIONS USING GITHUB "ISSUES"**
If you are pretty sure that you have identified a **BUG** in OpenImageIO,
please file a [bug report issue](https://github.com/OpenImageIO/oiio/issues/new?template=bug_report.md).
But if you are just asking a question:
* How do I...?
* I need help with...
* Am I doing something wrong?
* I can't build OpenImageIO
For anything of this nature, the best way to get help using OpenImageIO is
to ask a question on the [oiio-dev developer mail list](https://lists.aswf.io/g/oiio-dev).
The [documentation](https://openimageio.readthedocs.org)
is pretty comprehensive, so please check there first; you may find the answer
more quickly than you can get your question answered on the mail list.
+24 -8
View File
@@ -1,16 +1,32 @@
NOTE: delete this section after reading, it is just to give guidance for new contributors.
<!-- This is just a guideline and set of reminders about what constitutes -->
<!-- a good PR. Feel free to delete all this matter and replace it with -->
<!-- your own detailed message about the PR, assuming you hit all the -->
<!-- important points made below. -->
Please read the [contribution guidelines](https://github.com/OpenImageIO/oiio/blob/master/CONTRIBUTING.md), and be sure we have a Contributor License Agreement ([individual](https://github.com/OpenImageIO/oiio/blob/master/src/doc/CLA-INDIVIDUAL) or [corporate](https://github.com/OpenImageIO/oiio/blob/master/src/doc/CLA-CORPORATE)) on record with the project.
## Description
Please provide a description of what this PR is meant to fix,
and how it works (if it's not going to be very clear from the code).
<!-- Please provide a description of what this PR is meant to fix, and -->
<!-- how it works (if it's not going to be very clear from the code). -->
## Tests
Did you / should you add a testsuite case (new test, or add to an existing
test) to verify that this works?
<!-- Did you / should you add a testsuite case (new test, or add to an -->
<!-- existing test) to verify that this works? -->
------
## Checklist:
<!-- Put an 'x' in the boxes as you complete the checklist items -->
- [ ] I have read the [contribution guidelines](https://github.com/OpenImageIO/oiio/blob/master/CONTRIBUTING.md).
- [ ] I have updated the documentation, if applicable.
- [ ] I have ensured that the change is tested somewhere in the testsuite
(adding new test cases if necessary).
- [ ] If I added or modified a C++ API call, I have also amended the
corresponding Python bindings (and if altering ImageBufAlgo functions, also
exposed the new functionality as oiiotool options).
- [ ] My code follows the prevailing code style of this project. If I haven't
already run clang-format before submitting, I definitely will look at the CI
test that runs clang-format and fix anything that it highlights as being
nonconforming.
+134
View File
@@ -0,0 +1,134 @@
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/OpenImageIO/oiio
name: Analysis
on:
schedule:
# Run nightly while we're still working our way through the warnings
- cron: "0 8 * * *"
# Run unconditionally once weekly
# - cron: "0 0 * * 0"
push:
# Run on pushes only to master or if the branch name contains "analysis"
branches:
- master
- '*analysis*'
- '*sonar*'
# Allow manual kicking off of the workflow from github.com
workflow_dispatch:
# Uncomment the following line if we want to run analysis on all PRs:
# pull_request:
permissions: read-all
# Allow subsequent pushes to the same PR or REF to cancel any previous jobs.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
aswf:
name: "SonarCloud Analysis"
# Exclude runs on forks, since only the main org has the SonarCloud
# account credentials.
if: github.repository == 'OpenImageIO/oiio'
strategy:
fail-fast: false
matrix:
include:
- desc: sonar gcc9/C++14 py39 boost1.76 exr3.1 ocio2.1
nametag: static-analysis-sonar
os: ubuntu-latest
vfxyear: 2022
vfxsuffix: -clang11
cxx_std: 14
python_ver: 3.9
simd: "avx2,f16c"
fmt_ver: 8.1.1
pybind11_ver: v2.9.0
coverage: 1
# skip_tests: 1
sonar: 1
setenvs: export SONAR_SCANNER_VERSION=4.7.0.2747
SONAR_SERVER_URL="https://sonarcloud.io"
BUILD_WRAPPER_OUT_DIR=bw_output
OIIO_CMAKE_BUILD_WRAPPER="build-wrapper-linux-x86-64 --out-dir bw_output"
CMAKE_BUILD_TYPE=Debug
CMAKE_UNITY_BUILD=OFF
CODECOV=1
CTEST_TEST_TIMEOUT=1200
OIIO_CMAKE_FLAGS="-DOIIO_TEX_IMPLEMENT_VARYINGREF=OFF"
runs-on: ${{ matrix.os }}
container:
image: aswf/ci-osl:${{matrix.vfxyear}}${{matrix.vfxsuffix}}
env:
CXX: ${{matrix.cxx_compiler}}
CC: ${{matrix.cc_compiler}}
CMAKE_CXX_STANDARD: ${{matrix.cxx_std}}
USE_SIMD: ${{matrix.simd}}
FMT_VERSION: ${{matrix.fmt_ver}}
OPENEXR_VERSION: ${{matrix.openexr_ver}}
PYBIND11_VERSION: ${{matrix.pybind11_ver}}
PYTHON_VERSION: ${{matrix.python_ver}}
# DEBUG_CI: 1
steps:
# We would like to use harden-runner, but it flags too many false
# positives, every time we download a dependency. We should use it only
# on CI runs where we are producing artifacts that users might rely on.
# - name: Harden Runner
# uses: step-security/harden-runner@248ae51c2e8cc9622ecf50685c8bf7150c6e8813 # v1.4.3
# with:
# egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
with:
fetch-depth: '0'
- name: Prepare ccache timestamp
id: ccache_cache_keys
run: echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d # v3.0.4
with:
path: /tmp/ccache
key: ${{github.job}}-${{matrix.nametag}}-${{steps.ccache_cache_keys.outputs.date}}
restore-keys: ${{github.job}}-
- name: Build setup
run: |
${{matrix.setenvs}}
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
${{matrix.depcmds}}
src/build-scripts/gh-installdeps.bash
- name: Build
run: src/build-scripts/ci-build.bash
- name: Testsuite
if: matrix.skip_tests != '1'
run: src/build-scripts/ci-test.bash
- name: Code coverage
if: matrix.coverage == '1'
run: src/build-scripts/ci-coverage.bash
- name: Sonar-scanner
if: matrix.sonar == 1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="build/bw_output" --define sonar.cfamily.gcov.reportsPath="_coverage"
# - uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
# if: failure()
# with:
# name: oiio-${{github.job}}-${{matrix.nametag}}
# path: |
# build/cmake-save
# build/testsuite/*/*.*
# !build/testsuite/oiio-images
# !build/testsuite/openexr-images
# !build/testsuite/fits-images
# !build/testsuite/j2kp4files_v1_5
+532
View File
@@ -0,0 +1,532 @@
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: BSD-3-Clause
# https://github.com/OpenImageIO/oiio
name: CI
on:
push:
# Skip jobs when only documentation files are changed
paths-ignore:
- '**.md'
- '**.rst'
pull_request:
paths-ignore:
- '**.md'
- '**.rst'
schedule:
# Full nightly build
- cron: "0 8 * * *"
if: github.repository == 'OpenImageIO/oiio'
permissions: read-all
jobs:
aswf:
name: "VFX${{matrix.vfxyear}} ${{matrix.desc}}"
strategy:
fail-fast: false
matrix:
include:
- desc: gcc6/C++14 py2.7 boost1.66 exr2.3 ocio1.1
nametag: linux-vfx2019
os: ubuntu-latest
container: aswf/ci-osl:2019
vfxyear: 2019
cxx_std: 14
python_ver: 2.7
simd: sse4.2
fmt_ver: 6.1.2
pybind11_ver: v2.4.2
setenvs: export PUGIXML_VERSION=v1.9
- desc: gcc6/C++14 py3.7 boost1.70 exr2.4 ocio1.1
nametag: linux-vfx2020
os: ubuntu-latest
container: aswf/ci-osl:2020
vfxyear: 2020
cxx_std: 14
python_ver: 3.7
simd: avx
fmt_ver: 7.0.1
pybind11_ver: v2.5.0
setenvs: export PUGIXML_VERSION=v1.9 WEBP_VERSION=v1.1.0
- desc: gcc9/C++17 py3.7 boost1.73 exr2.5 ocio2.0
nametag: linux-vfx2021
os: ubuntu-latest
container: aswf/ci-osl:2021
vfxyear: 2021
cxx_std: 17
python_ver: 3.7
simd: "avx2,f16c"
fmt_ver: 7.1.0
pybind11_ver: v2.7.0
setenvs: export PUGIXML_VERSION=v1.9 WEBP_VERSION=v1.1.0
- desc: clang10/C++14 avx2 exr2.5 ocio2.0
nametag: linux-clang10-cpp14
os: ubuntu-latest
container: aswf/ci-osl:2021-clang10
vfxyear: 2021
cc_compiler: clang
cxx_compiler: clang++
cxx_std: 14
pybind11_ver: v2.6.2
python_ver: 3.7
simd: "avx2,f16c"
fmt_ver: 8.1.1
- desc: gcc9/C++17 py39 boost1.76 exr3.1 ocio2.1
nametag: linux-vfx2022
os: ubuntu-latest
container: aswf/ci-osl:2022-clang11
vfxyear: 2022
cxx_std: 17
python_ver: 3.9
simd: "avx2,f16c"
fmt_ver: 8.1.1
pybind11_ver: v2.9.0
- desc: clang13/C++17 py39 avx2 exr3.1 ocio2.1
nametag: linux-vfx2022-clang13
os: ubuntu-latest
container: aswf/ci-osl:2022-clang13
vfxyear: 2022
cc_compiler: clang
cxx_compiler: clang++
cxx_std: 17
python_ver: 3.9
simd: "avx2,f16c"
fmt_ver: 8.1.1
pybind11_ver: v2.8.1
- desc: icc/C++17 py3.9 boost1.76 exr3.1 ocio2.1 qt5.15
nametag: linux-vfx2022-icc
os: ubuntu-latest
container: aswf/ci-osl:2022
vfxyear: 2022
cxx_std: 17
python_ver: 3.9
# simd: "avx2,f16c"
fmt_ver: 7.1.3
# icc MUST use this older FMT version
pybind11_ver: v2.9.0
setenvs: export USE_ICC=1 USE_OPENVDB=0
OIIO_EXTRA_CPP_ARGS="-fp-model=precise"
# For icc, use fp-model precise to eliminate needless LSB errors
# that make test results differ from other platforms.
- desc: icx/C++17 py3.9 boost1.76 exr3.1 ocio2.1 qt5.15
nametag: linux-vfx2022-icx
os: ubuntu-latest
container: aswf/ci-osl:2022
vfxyear: 2022
cc_compiler: icx
cxx_compiler: icpx
cxx_std: 17
python_ver: 3.9
simd: "avx2,f16c"
pybind11_ver: v2.9.0
setenvs: export USE_OPENVDB=0
- desc: sanitizers
nametag: sanitizer
os: ubuntu-latest
container: aswf/ci-osl:2022-clang13
vfxyear: 2022
cc_compiler: clang
cxx_compiler: clang++
cxx_std: 17
python_ver: 3.9
setenvs: export SANITIZE=address,undefined
OIIO_CMAKE_FLAGS="-DSANITIZE=address,undefined -DUSE_PYTHON=0"
CMAKE_BUILD_TYPE=Debug
CTEST_TEST_TIMEOUT=1200
CTEST_EXCLUSIONS="broken|cmake-consumer|png-damaged"
- desc: gcc11/C++17 py3.10 boost1.80 exr3.1 ocio2.2
nametag: linux-vfx2023
os: ubuntu-latest
container: aswftesting/ci-osl:2023-clang15
vfxyear: 2023
cxx_std: 17
python_ver: "3.10"
simd: "avx2,f16c"
fmt_ver: 9.1.0
pybind11_ver: v2.10.0
- desc: oldest/hobbled gcc6.3/C++14 py2.7 boost-1.66 exr-2.3 no-sse no-ocio
# Oldest versions of the dependencies that we can muster, and various
# things disabled (no SSE, OCIO, or OpenCV, don't embed plugins).
nametag: linux-oldest
os: ubuntu-latest
container: aswf/ci-osl:2019
vfxyear: 2019
cxx_std: 14
fmt_ver: 6.1.2
openexr_ver: v2.3.0
pybind11_ver: v2.4.2
python_ver: 2.7
simd: 0
setenvs: export EMBEDPLUGINS=0
PTEX_VERSION=v2.3.1
USE_JPEGTURBO=0
USE_OPENCOLORIO=0
USE_OPENCV=0
WEBP_VERSION=v1.0.0
depcmds: sudo rm -rf /usr/local/include/OpenEXR
# Test formatting. This test entry doesn't do a full build, it
# just runs clang-format on everything, and passes if nothing is
# misformatted. Upon failure, the build artifact will be the full
# source code with the formatting fixed (diffs will also appear in
# the console output).
- desc: "clang-format"
nametag: clang-format
os: ubuntu-latest
container: aswf/ci-osl:2022-clang12
vfxyear: 2022
cxx_std: 17
skip_tests: 1
setenvs: export BUILDTARGET=clang-format
OIIO_CMAKE_FLAGS=-DUSE_PYTHON=0
runs-on: ${{ matrix.os }}
container:
image: ${{ matrix.container }}
env:
CXX: ${{matrix.cxx_compiler}}
CC: ${{matrix.cc_compiler}}
CMAKE_CXX_STANDARD: ${{matrix.cxx_std}}
USE_SIMD: ${{matrix.simd}}
FMT_VERSION: ${{matrix.fmt_ver}}
OPENEXR_VERSION: ${{matrix.openexr_ver}}
PYBIND11_VERSION: ${{matrix.pybind11_ver}}
PYTHON_VERSION: ${{matrix.python_ver}}
steps:
# We would like to use harden-runner, but it flags too many false
# positives, every time we download a dependency. We should use it only
# on CI runs where we are producing artifacts that users might rely on.
# - name: Harden Runner
# uses: step-security/harden-runner@248ae51c2e8cc9622ecf50685c8bf7150c6e8813 # v1.4.3
# with:
# egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
- name: Prepare ccache timestamp
id: ccache_cache_keys
run: echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d # v3.0.4
with:
path: /tmp/ccache
key: ${{github.job}}-${{matrix.nametag}}-${{steps.ccache_cache_keys.outputs.date}}
restore-keys: ${{github.job}}-
- name: Build setup
run: |
${{matrix.setenvs}}
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
${{matrix.depcmds}}
src/build-scripts/gh-installdeps.bash
- name: Build
run: src/build-scripts/ci-build.bash
- name: Testsuite
if: matrix.skip_tests != '1'
run: src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
if: failure()
with:
name: oiio-${{github.job}}-${{matrix.nametag}}
path: |
build/cmake-save
build/testsuite/*/*.*
!build/testsuite/oiio-images
!build/testsuite/openexr-images
!build/testsuite/fits-images
!build/testsuite/j2kp4files_v1_5
ubuntu:
name: "Ubuntu ${{matrix.desc}}"
strategy:
fail-fast: false
matrix:
include:
- desc: latest releases gcc11 C++17 avx2 exr3.2 ocio2.3
nametag: linux-latest-releases
os: ubuntu-22.04
cc_compiler: gcc-11
cxx_compiler: g++-11
cxx_std: 17
fmt_ver: 9.1.0
openexr_ver: v3.2.0
pybind11_ver: v2.11.1
python_ver: "3.10"
simd: avx2,f16c
setenvs: export LIBRAW_VERSION=0.20.2
LIBTIFF_VERSION=v4.5.0
OPENCOLORIO_VERSION=v2.3.0
OPENIMAGEIO_OPTIONS="openexr:core=1"
OPENJPEG_VERSION=v2.4.0
PTEX_VERSION=v2.4.0
PUGIXML_VERSION=v1.13
USE_OPENVDB=0
WEBP_VERSION=v1.3.0
# The installed OpenVDB has a TLS conflict with Python 3.8
- desc: bleeding edge gcc12 C++20 py3.10 OCIO/libtiff/exr-master boost1.74 avx2
nametag: linux-bleeding-edge
os: ubuntu-22.04
cc_compiler: gcc-12
cxx_compiler: g++-12
cxx_std: 20
fmt_ver: 10.0.0
openexr_ver: main
pybind11_ver: master
python_ver: "3.10"
simd: avx2,f16c
setenvs: export LIBRAW_VERSION=master
LIBTIFF_VERSION=master
OPENCOLORIO_VERSION=main
OPENIMAGEIO_OPTIONS="openexr:core=1"
OPENJPEG_VERSION=master
PTEX_VERSION=main
PUGIXML_VERSION=master
USE_OPENVDB=0
WEBP_VERSION=main
OIIO_CMAKE_FLAGS="-DFORTIFY_SOURCE=2"
# The installed OpenVDB has a TLS conflict with Python 3.8
- desc: clang14 C++20 avx2 exr3.1 ocio2.1
nametag: linux-clang14
os: ubuntu-20.04
cxx_compiler: clang++
cc_compiler: clang
cxx_std: 20
fmt_ver: 9.0.0
openexr_ver: v3.1.5
pybind11_ver: v2.9.2
python_ver: 3.8
simd: avx2,f16c
setenvs: export LLVM_VERSION=14.0.0
OPENCOLORIO_VERSION=v2.1.2
OPENIMAGEIO_OPTIONS="openexr:core=1"
USE_OPENVDB=0
# The installed OpenVDB has a TLS conflict with Python 3.8
- desc: debug gcc7/C++14, sse4.2, exr2.4
nametag: linux-gcc7-cpp14-debug
os: ubuntu-20.04
container:
image: ubuntu-18.04
cxx_compiler: g++-7
cxx_std: 14
python_ver: 2.7
simd: sse4.2
openexr_ver: v2.4.3
pybind11_ver: v2.6.2
setenvs: export CMAKE_BUILD_TYPE=Debug
PUGIXML_VERSION=v1.9
CTEST_TEST_TIMEOUT=1200
- desc: gcc8 C++17 avx exr2.5
nametag: linux-gcc8
os: ubuntu-20.04
container:
image: ubuntu-18.04
cc_compiler: gcc-8
cxx_compiler: g++-8
cxx_std: 17
openexr_ver: v2.5.8
pybind11_ver: v2.5.0
simd: avx
- desc: static libs gcc7 C++14 exr2.4
nametag: linux-static
os: ubuntu-20.04
container:
image: ubuntu-18.04
cxx_compiler: g++-7
cxx_std: 14
openexr_ver: v2.4.3
pybind11_ver: v2.6.2
setenvs: export BUILD_SHARED_LIBS=OFF
depcmds: |
sudo rm -rf /usr/local/include/OpenEXR
sudo rm -rf /usr/local/lib64/cmake/{IlmBase,OpenEXR}
runs-on: ${{ matrix.os }}
env:
CXX: ${{matrix.cxx_compiler}}
CC: ${{matrix.cc_compiler}}
CMAKE_CXX_STANDARD: ${{matrix.cxx_std}}
USE_SIMD: ${{matrix.simd}}
FMT_VERSION: ${{matrix.fmt_ver}}
OPENEXR_VERSION: ${{matrix.openexr_ver}}
PYBIND11_VERSION: ${{matrix.pybind11_ver}}
PYTHON_VERSION: ${{matrix.python_ver}}
steps:
# We would like to use harden-runner, but it flags too many false
# positives, every time we download a dependency. We should use it only
# on CI runs where we are producing artifacts that users might rely on.
# - name: Harden Runner
# uses: step-security/harden-runner@248ae51c2e8cc9622ecf50685c8bf7150c6e8813 # v1.4.3
# with:
# egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
- name: Prepare ccache timestamp
id: ccache_cache_keys
run: echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d # v3.0.4
with:
path: /tmp/ccache
key: ${{github.job}}-${{matrix.nametag}}-${{ steps.ccache_cache_keys.outputs.date }}
restore-keys: ${{github.job}}-
- name: Build setup
run: |
${{matrix.setenvs}}
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
${{matrix.depcmds}}
src/build-scripts/gh-installdeps.bash
- name: Build
run: src/build-scripts/ci-build.bash
- name: Testsuite
if: matrix.skip_tests != '1'
run: src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
if: failure()
with:
name: oiio-${{github.job}}-${{matrix.nametag}}
path: |
build/cmake-save
build/testsuite/*/*.*
!build/testsuite/oiio-images
!build/testsuite/openexr-images
!build/testsuite/fits-images
!build/testsuite/j2kp4files_v1_5
macos:
name: "${{matrix.os}} appleclang${{matrix.aclang}}/C++${{matrix.cxx_std}} py${{matrix.python_ver}} ${{matrix.desc}} boost1.76 exr3.1 ocio2.1"
strategy:
fail-fast: false
matrix:
include:
- desc: MacOS-11
os: macos-11
nametag: macos11-py39
cxx_std: 17
python_ver: "3.9"
aclang: 13
setenvs: export QT_VERSION=@5
- desc: MacOS-12
os: macos-12
nametag: macos12-py310
cxx_std: 20
python_ver: "3.10"
aclang: 13
setenvs: export CTEST_TEST_TIMEOUT=600
- desc: MacOS-13
os: macos-13
nametag: macos13-py311
cxx_std: 20
python_ver: "3.11"
aclang: 14
setenvs: export CTEST_TEST_TIMEOUT=600
runs-on: ${{ matrix.os }}
env:
CC: clang
CXX: clang++
CMAKE_CXX_STANDARD: ${{ matrix.cxx_std }}
PYTHON_VERSION: ${{ matrix.python_ver }}
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
- name: Prepare ccache timestamp
id: ccache_cache_keys
run: echo "::set-output name=date::`date -u +'%Y-%m-%dT%H:%M:%SZ'`"
- name: ccache
id: ccache
uses: actions/cache@c3f1317a9e7b1ef106c153ac8c0f00fed3ddbc0d # v3.0.4
with:
path: /Users/runner/.ccache
key: ${{github.job}}-${{matrix.nametag}}-${{ steps.ccache_cache_keys.outputs.date }}
restore-keys: ${{github.job}}-
- name: Build setup
run: |
${{matrix.setenvs}}
src/build-scripts/ci-startup.bash
- name: Dependencies
run: |
src/build-scripts/install_homebrew_deps.bash
${{matrix.depcmds}}
- name: Build
run: |
export PYTHONPATH=/usr/local/lib/python${PYTHON_VERSION}/site-packages:$PYTHONPATH
src/build-scripts/ci-build.bash
- name: Testsuite
run: src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
if: failure()
with:
name: oiio-${{github.job}}-${{matrix.nametag}}
path: |
build/cmake-save
build/testsuite/*/*.*
!build/testsuite/oiio-images
!build/testsuite/openexr-images
!build/testsuite/fits-images
!build/testsuite/j2kp4files_v1_5
windows:
name: "${{matrix.desc}} VS${{matrix.vsver}}"
strategy:
fail-fast: false
matrix:
include:
- desc: windows-2019
os: windows-2019
vsver: 2019
generator: "Visual Studio 16 2019"
openexr_ver: v2.5.8
python_ver: 3.7
simd: sse4.2
# - desc: windows-2022
# os: windows-2022
# vsver: 2022
# generator: "Visual Studio 17 2022"
# openexr_ver: main
# # v3.1.4
# python_ver: 3.7
# simd: sse4.2
runs-on: ${{ matrix.os }}
env:
PYTHON_VERSION: ${{matrix.python_ver}}
CMAKE_GENERATOR: ${{matrix.generator}}
OPENEXR_VERSION: ${{matrix.openexr_ver}}
USE_SIMD: ${{matrix.simd}}
CTEST_ARGS: "--timeout 180 --repeat after-timeout:6"
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
- name: Setup Nuget.exe
uses: nuget/setup-nuget@b2bc17b761a1d88cab755a776c7922eb26eefbfa # v1.0.6
- name: Build setup
shell: bash
run: |
${{matrix.setenvs}}
src/build-scripts/ci-startup.bash
- name: Dependencies
shell: bash
run: src/build-scripts/gh-win-installdeps.bash
- name: Build
shell: bash
run: src/build-scripts/ci-build.bash
- name: Testsuite
shell: bash
run: src/build-scripts/ci-test.bash
- uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
if: failure()
with:
name: oiio-${{github.job}}-VS${{matrix.vsver}}
path: |
build/cmake-save
build/testsuite/*/*.*
!build/testsuite/oiio-images
!build/testsuite/openexr-images
!build/testsuite/fits-images
!build/testsuite/j2kp4files_v1_5
+73
View File
@@ -0,0 +1,73 @@
name: Scorecards supply-chain security
on:
# Only the default branch is supported.
branch_protection_rule:
push:
# Run on pushes to master, but only the main repo, not forks
branches: [ "master" ]
if: github.event.pull_request.head.repo.full_name == github.repository
pull_request:
# Only run on individual PRs if the workflow file itself is changed.
paths:
- .github/workflows/scorecard.yml
# Declare default permissions as read only.
permissions: read-all
# Allow subsequent pushes to the same PR or REF to cancel any previous jobs.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
analysis:
name: Scorecards analysis
if: github.repository == 'OpenImageIO/oiio'
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Used to receive a badge. (Upcoming feature)
id-token: write
# Needs for private repositories.
contents: read
actions: read
steps:
- name: "Checkout code"
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@3e15ea8318eee9b333819ec77a36aca8d39df13e # v1.1.1
with:
results_file: results.sarif
results_format: sarif
# (Optional) Read-only PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecards on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
# repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
# Publish the results for public repositories to enable scorecard badges. For more details, see
# https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories, `publish_results` will automatically be set to `false`, regardless
# of the value entered here.
publish_results: true
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v3.0.0
with:
name: SARIF file
path: results.sarif
retention-days: 5
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26
with:
sarif_file: results.sarif
+16 -2
View File
@@ -1,8 +1,22 @@
*~
*.bak
branches/
build/
dist/
testsuite/runtest.pyc
src/doc/figures/
ext/
.idea
.vscode
.cproject
.project
.DS_Store
*.pyc
_coverage/
# Exclude test files I tend to leave around at the top level. The leading
# slash ensures that files with these extensions within subdirectories are not
# ignored.
/*.exr
/*.tif
/*.jpg
/*.tx
/*.log
+1
View File
@@ -0,0 +1 @@
Claire Foster <aka.c42f@gmail.com> <chris42f@gmail.com>
+21
View File
@@ -0,0 +1,21 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: src/doc/conf.py
# Optionally build your docs in additional formats such as PDF and ePub
formats:
- pdf
- htmlzip
# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: src/doc/requirements.txt
-193
View File
@@ -1,193 +0,0 @@
# .travis.yml for OIIO
language: cpp
sudo: false
osx_image: xcode7.3
dist: precise
# Add-ons: specify apt packages for Linux
addons:
apt:
sources:
- boost-latest
- ubuntu-toolchain-r-test
- george-edison55-precise-backports
packages:
- gcc-4.8
- g++-4.8
- libboost1.55-all-dev
- libgif-dev
- libtiff4-dev
- libopenjpeg-dev
- libwebp-dev
- ffmpeg
- libfreetype6-dev
- libjpeg-turbo8-dev
- dcmtk
# - bzip2
# - libtinyxml-dev
# - liblcms2-dev
# - libyaml-cpp-dev
cache:
ccache: true
apt: true
directories:
- $HOME/.ccache
- $PWD/oiio-images
- $PWD/libtiffpic
before_install:
- if [ "$WHICHGCC" == "" ]; then export WHICHGCC="4.8" ; fi
- if [ $TRAVIS_OS_NAME == osx ] ; then
export PLATFORM=macosx ;
sysctl machdep.cpu.features ;
elif [ $TRAVIS_OS_NAME == linux ] ; then
export PLATFORM=linux64 ;
head -40 /proc/cpuinfo ;
fi
- if [ "$DEBUG" == 1 ] ; then export PLATFORM=${PLATFORM}.debug ; fi
- echo "Build platform name is $PLATFORM"
install:
- if [ "$CXX" == "g++" ]; then export CXX="g++-${WHICHGCC}" ; fi
- export USE_CCACHE=1
- export CCACHE_CPP2=1
- if [ $TRAVIS_OS_NAME == osx ] ; then
src/build-scripts/install_homebrew_deps.bash ;
elif [ $TRAVIS_OS_NAME == linux ] ; then
CXX="ccache $CXX" CCACHE_CPP2=1 src/build-scripts/build_openexr.bash ;
export ILMBASE_HOME=$PWD/openexr-install ;
export OPENEXR_HOME=$PWD/openexr-install ;
fi
- src/build-scripts/install_test_images.bash
# before_script:
script:
- make VERBOSE=1 $BUILD_FLAGS cmakesetup
- make -j2 $BUILD_FLAGS
- export OPENIMAGEIOHOME=$PWD/dist/$PLATFORM
- export DYLD_LIBRARY_PATH=$OPENIMAGEIOHOME/lib:$DYLD_LIBRARY_PATH
- export LD_LIBRARY_PATH=$OPENIMAGEIOHOME/lib:$LD_LIBRARY_PATH
- export OIIO_LIBRARY_PATH=$OPENIMAGEIOHOME/lib
- echo "OIIO_LIBRARY_PATH is ${OIIO_LIBRARY_PATH}"
# - echo "list of library path:"
# - ls -R $OIIO_LIBRARY_PATH
- export PYTHONPATH=$OPENIMAGEIOHOME/python:$PYTHONPATH
- export LSAN_OPTIONS=suppressions=$PWD/src/build-scripts/nosanitize.txt
- make $BUILD_FLAGS test
after_success:
- if [ "$CODECOV" == 1 ] ; then bash <(curl -s https://codecov.io/bash) ; fi
after_failure:
# FIXME: find failed logs, stash them or send them to lg?
branches:
only:
- master
- /RB-/
- /lg-/
matrix:
fast_finish: true
exclude:
- os: osx
compiler: gcc
- os: linux
compiler: clang
include:
# test default compile: C++11, optimized, default compilers
- os: linux
compiler: gcc
- os: osx
compiler: clang
# test debug build
- os: linux
compiler: gcc
env: DEBUG=1
# - os: osx
# compiler: clang
# env: DEBUG=1
# test with C++14, most modern compiler, latest SIMD flags
# - os: osx
# compiler: clang
# env: USE_CPP=14
- os: linux
compiler: gcc
addons:
apt:
sources: [ 'ubuntu-toolchain-r-test', 'boost-latest', 'george-edison55-precise-backports' ]
packages: [ 'g++-6', 'cmake', 'cmake-data', 'libboost1.55-all-dev',
'libtiff4-dev', 'libgif-dev', 'libopenjpeg-dev', 'libwebp-dev',
'ffmpeg', 'libfreetype6-dev', 'libjpeg-turbo8-dev', 'dcmtk' ]
env: WHICHGCC=6 USE_CPP=14 USE_SIMD=avx,f16c
# Test LINKSTATIC on both platforms. This is incomplete and to make it
# work we still need to disable a bunch of specific plugins.
# FIXME: Don't have LINKSTATIC working on Travis for Linux, it's
# complaining about PIC issues.
# - os: linux
# compiler: gcc
# env: LINKSTATIC=1 USE_FFMPEG=0 USE_OCIO=0 USE_OPENCV=0 MY_CMAKE_FLAGS="-DUSE_fPIC=1"
- os: osx
compiler: clang
env: LINKSTATIC=1 USE_FFMPEG=0 USE_OCIO=0 USE_OPENCV=0
# Linux only: test gcc 4.9, and simultaneously, test with a higher SIMD
# level (SSE4.2).
- os: linux
compiler: gcc
addons:
apt:
sources: [ 'ubuntu-toolchain-r-test', 'boost-latest', 'george-edison55-precise-backports' ]
packages: [ 'g++-4.9', 'cmake', 'cmake-data', 'libboost1.55-all-dev',
'libtiff4-dev', 'libgif-dev', 'libopenjpeg-dev', 'libwebp-dev',
'ffmpeg', 'libfreetype6-dev', 'libjpeg-turbo8-dev', 'dcmtk' ]
env: WHICHGCC=4.9
# Linux only: test gcc 5
- os: linux
compiler: gcc
addons:
apt:
sources: [ 'ubuntu-toolchain-r-test', 'boost-latest', 'george-edison55-precise-backports' ]
packages: [ 'g++-5', 'cmake', 'cmake-data', 'libboost1.55-all-dev',
'libtiff4-dev', 'libgif-dev', 'libopenjpeg-dev', 'libwebp-dev',
'ffmpeg', 'libfreetype6-dev', 'libjpeg-turbo8-dev', 'dcmtk' ]
env: WHICHGCC=5
# Build with sanitizers
- os: linux
compiler: gcc
addons:
apt:
sources: [ 'ubuntu-toolchain-r-test', 'boost-latest', 'george-edison55-precise-backports' ]
packages: [ 'g++-6', 'cmake', 'cmake-data', 'libboost1.55-all-dev',
'libtiff4-dev', 'libgif-dev', 'libopenjpeg-dev', 'libwebp-dev',
'ffmpeg', 'libfreetype6-dev', 'libjpeg-turbo8-dev', 'dcmtk' ]
env: WHICHGCC=6 SANITIZE=address USE_PYTHON=0
# One more, just for the heck of it, turn all SIMD off, and also make
# sure we're falling back on libjpeg, not jpeg-turbo. I guess this
# should/could be both platforms, but in the interest of making the
# tests go faster, don't bother doing it on OSX.
- os: linux
compiler: gcc
env: USE_SIMD=0 USE_JPEGTURBO=0
# Build with EMBEDPLUGINS=0, both platforms.
# FIXME: doesn't work yet on Travis
# - os: linux
# compiler: gcc
# env: EMBEDPLUGINS=0
# FIXME: don't have OSX EMBEDPLUGINS=0 working yet on Travis (though
# it works fine on my laptop).
# - os: osx
# compiler: clang
# env: EMBEDPLUGINS=0
notifications:
email:
recipients:
- lg@openimageio.org
on_success: change
on_failure: always
+149
View File
@@ -0,0 +1,149 @@
Project Name: OpenImageIO
Project Entity: OpenImageIO Project a Series of LF Projects, LLC
If emailing signed PDF, send to: manager@lfprojects.org
**Software Grant and Corporate Contributor License Agreement ("Agreement") v2.1**
Thank you for your interest in the project specified above (the “Project”). In
order to clarify the intellectual property license granted with Contributions
from any person or entity, the Project must have a Contributor License Agreement
(CLA) on file that has been signed by each Contributor, indicating agreement to
the license terms below. This license is for your protection as a Contributor as
well as the protection of the Project and its users; it does not change your
rights to use your own Contributions for any other purpose.
This version of the Agreement allows an entity (the “Corporation”) to submit
Contributions to the Project, to authorize Contributions submitted by its
designated employees to the Project, and to grant copyright and patent licenses
thereto.
If you have not already done so, please complete and sign this Agreement using
the electronic signature portal made available to you by the Project or its
third-party service providers, or email a PDF of the signed agreement to the
email address specified above. Please read this document carefully before
signing and keep a copy for your records.
You accept and agree to the following terms and conditions for Your present and
future Contributions submitted to the Project. In return, the Project shall not
use Your Contributions in a way that is contrary to the public benefit or
inconsistent with its charter at the time of the Contribution. Except for the
license granted herein to the Project and recipients of software distributed by
the Project, You reserve all right, title, and interest in and to Your
Contributions.
1. Definitions.
“You” (or “Your”) shall mean the copyright owner or legal entity authorized by
the copyright owner that is making this Agreement with the Project. For legal
entities, the entity making a Contribution and all other entities that
control, are controlled by, or are under common control with that entity are
considered to be a single Contributor. For the purposes of this definition,
“control” means (i) the power, direct or indirect, to cause the direction or
management of such entity, whether by contract or otherwise, or (ii) ownership
of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial
ownership of such entity.
“Contribution” shall mean the code, documentation or other original works of
authorship, including any modifications or additions to an existing work, that
is intentionally submitted by You to the Project for inclusion in, or
documentation of, any of the products owned or managed by the Project (the
“Work”). For the purposes of this definition, “submitted” means any form
of electronic, verbal, or written communication sent to the Project or its
representatives, including but not limited to communication on electronic
mailing lists, source code control systems, and issue tracking systems that
are managed by, or on behalf of, the Project for the purpose of discussing and
improving the Work, but excluding communication that is conspicuously marked
or otherwise designated in writing by You as “Not a Contribution.”
2. Grant of Copyright License. Subject to the terms and conditions of this
Agreement, You hereby grant to the Project and to recipients of software
distributed by the Project a perpetual, worldwide, non-exclusive, no-charge,
royalty-free, irrevocable copyright license to reproduce, prepare
derivative works of, publicly display, publicly perform, sublicense,
and distribute Your Contributions and such derivative works.
3. Grant of Patent License. Subject to the terms and conditions of this
Agreement, You hereby grant to the Project and to recipients of software
distributed by the Project a perpetual, worldwide, non-exclusive, no-charge,
royalty-free, irrevocable (except as stated in this section) patent
license to make, have made, use, offer to sell, sell, import, and
otherwise transfer the Work, where such license applies only to
those patent claims licensable by You that are necessarily infringed
by Your Contribution(s) alone or by combination of Your
Contribution(s) with the Work to which such Contribution(s) were
submitted. If any entity institutes patent litigation against You or
any other entity (including a cross-claim or counterclaim in a
lawsuit) alleging that your Contribution, or the Work to which
you have contributed, constitutes direct or contributory patent
infringement, then any patent licenses granted to that entity under
this Agreement for that Contribution or Work shall terminate as of
the date such litigation is filed.
4. You represent that You are legally entitled to grant the above license. You
represent further that the employee of the Corporation designated as the Initial
CLA Manager below (and each who is designated in a subsequent written
modification to the list of CLA Managers) (each, a “CLA Manager”) is
authorized to maintain with the Project (1) the list of employees of the
Corporation who are authorized to submit Contributions on behalf of the
Corporation, and (2) the list of CLA Managers.
5. You represent that each of Your Contributions is Your original creation (see
section 7 for submissions on behalf of others).
6. You are not expected to provide support for Your Contributions, except to the
extent You desire to provide support. You may provide support for free, for a
fee, or not at all. Unless required by applicable law or agreed to in writing,
You provide Your Contributions on an “AS IS” BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied, including, without
limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
7. Should You wish to submit work that is not Your original creation, You may
submit it to the Project separately from any Contribution, identifying the
complete details of its source and of any license or other restriction
(including, but not limited to, related patents, trademarks, and license
agreements) of which you are personally aware, and conspicuously marking the
work as “Submitted on behalf of a third-party: [named here]”.
8. It is your responsibility to notify the Project when any change is required
to the list of designated employees authorized to submit Contributions on behalf
of the Corporation, or to the list of the CLA Managers.
\[Please complete and sign on the next page.\]
::: {style="page-break-after: always; visibility: hidden"}
```{=tex}
\pagebreak
```
:::
Please sign:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Date:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Signatory Name:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Signatory E-mail:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Signatory Title:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Corporation Name:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Corporation Address:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Initial CLA Manager Name:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Initial CLA Manager E-Mail:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
+137
View File
@@ -0,0 +1,137 @@
Project Name: OpenImageIO
Project Entity: OpenImageIO Project a Series of LF Projects, LLC
If emailing signed PDF, send to: manager@lfprojects.org
**Individual Contributor License Agreement ("Agreement") v2.1**
Thank you for your interest in the project specified above (the “Project”). In
order to clarify the intellectual property license granted with Contributions
from any person or entity, the Project must have a Contributor License Agreement
(CLA) on file that has been signed by each Contributor, indicating agreement to
the license terms below. This license is for your protection as a Contributor as
well as the protection of the Project and its users; it does not change your
rights to use your own Contributions for any other purpose.
If you have not already done so, please complete and sign this Agreement using
the electronic signature portal made available to you by the Project or its
third-party service providers, or email a PDF of the signed agreement to the
email address specified above. Please read this document carefully before
signing and keep a copy for your records.
You accept and agree to the following terms and conditions for Your present and
future Contributions submitted to the Project. In return, the Project shall not
use Your Contributions in a way that is contrary to the public benefit or
inconsistent with its charter at the time of the Contribution. Except for the
license granted herein to the Project and recipients of software distributed by
the Project, You reserve all right, title, and interest in and to Your
Contributions.
1. Definitions.
“You” (or “Your”) shall mean the copyright owner or legal entity authorized by
the copyright owner that is making this Agreement with the Project. For legal
entities, the entity making a Contribution and all other entities that control,
are controlled by, or are under common control with that entity are considered
to be a single Contributor. For the purposes of this definition, “control”
means (i) the power, direct or indirect, to cause the direction or management
of such entity, whether by contract or otherwise, or (ii) ownership of fifty
percent (50%) or more of the outstanding shares, or (iii) beneficial ownership
of such entity.
“Contribution” shall mean the code, documentation or other original works of
authorship, including any modifications or additions to an existing work, that
is intentionally submitted by You to the Project for inclusion in, or
documentation of, any of the products owned or managed by the Project (the
“Work”). For the purposes of this definition, “submitted” means any form of
electronic, verbal, or written communication sent to the Project or its
representatives, including but not limited to communication on electronic
mailing lists, source code control systems, and issue tracking systems that are
managed by, or on behalf of, the Project for the purpose of discussing and
improving the Work, but excluding communication that is conspicuously marked or
otherwise designated in writing by You as “Not a Contribution.”
2. Grant of Copyright License. Subject to the terms and conditions of this
Agreement, You hereby grant to the Project and to recipients of software
distributed by the Project a perpetual, worldwide, non-exclusive, no-charge,
royalty-free, irrevocable copyright license to reproduce, prepare
derivative works of, publicly display, publicly perform, sublicense,
and distribute Your Contributions and such derivative works.
3. Grant of Patent License. Subject to the terms and conditions of this
Agreement, You hereby grant to the Project and to recipients of software
distributed by the Project a perpetual, worldwide, non-exclusive, no-charge,
royalty-free, irrevocable (except as stated in this section) patent
license to make, have made, use, offer to sell, sell, import, and
otherwise transfer the Work, where such license applies only to
those patent claims licensable by You that are necessarily infringed
by Your Contribution(s) alone or by combination of Your
Contribution(s) with the Work to which such Contribution(s) were
submitted. If any entity institutes patent litigation against You or
any other entity (including a cross-claim or counterclaim in a
lawsuit) alleging that your Contribution, or the Work to which
you have contributed, constitutes direct or contributory patent
infringement, then any patent licenses granted to that entity under
this Agreement for that Contribution or Work shall terminate as of
the date such litigation is filed.
4. You represent that you are legally entitled to grant the above license. If
your employer(s) has rights to intellectual property that you create that
includes your Contributions, you represent that you have received permission to
make Contributions on behalf of that employer, that your employer has waived
such rights for your Contributions to the Project, or that your employer has
executed a separate Corporate CLA with the Project.
5. You represent that each of Your Contributions is Your original creation (see
section 7 for submissions on behalf of others). You represent that Your
Contribution submissions include complete details of any third-party license or
other restriction (including, but not limited to, related patents and
trademarks) of which you are personally aware and which are associated with
any part of Your Contributions.
6. You are not expected to provide support for Your Contributions, except to the
extent You desire to provide support. You may provide support for free, for a
fee, or not at all. Unless required by applicable law or agreed to in writing,
You provide Your Contributions on an “AS IS” BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied, including, without
limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
7. Should You wish to submit work that is not Your original creation, You may
submit it to the Project separately from any Contribution, identifying the
complete details of its source and of any license or other restriction
(including, but not limited to, related patents, trademarks, and license
agreements) of which you are personally aware, and conspicuously marking the
work as “Submitted on behalf of a third-party: [named here]”.
8. You agree to notify the Project of any facts or circumstances of which you
become aware that would make these representations inaccurate in any respect.
\[Please complete and sign on the next page.\]
::: {style="page-break-after: always; visibility: hidden"}
```{=tex}
\pagebreak
```
:::
Please sign:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Date: \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Full name:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Mailing Address:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
------------------------------------------------------------------------
------------------------------------------------------------------------
Country:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
E-Mail:
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
+21
View File
@@ -0,0 +1,21 @@
OpenImageIO has been accepted to be an ASWF-administered project, by vote of
the ASWF Technical Advisory Council (TAC) on May 3, 2023.
At this time, the ASWF subdirectory contains *proposed* (and sometimes TBD/WIP
placeholders) project organization and policy documents that will be formally
adopted as the OpenImageIO project is formally turned over to ASWF and moved
to the AcademySoftwareFoundation GitHub account. Please file issues or PRs
or review comments against these documents to make any suggested changes while
we are revising the drafts.
Summary of the current state of documents:
| File | Status | Notes |
| ---- | ------ | ----- |
| CLA-corporate.md | Final | Standard ASWF corporate CLA, approved by the TSC. Will take effect when the repo moves. |
| CLA-individual.md | Final | Standard ASWF individual CLA, approved by the TSC. Will take effect when the repo moves. |
| CODE_OF_CONDUCT.md | Final | Links to the standard LF CoC, approved by the TSC and now in effect. |
| CONTRIBUTING.md | Preliminary | Modified version of our existing CONTRIBUTING guidelines, lightly amended to reflect the changes that will come along with moving the repo, the new CLA/DCO rules, etc.
| GOVERNANCE.md | Final | Approved by the TSC and now in effect. |
| project_intake.md | Ongoing | This is the latest ASWF project intake checklist. We will check off items as we get them done. |
| Technical-Charter.md | Final | Approved by the TSC. |
+242
View File
@@ -0,0 +1,242 @@
# Technical Charter (the "Charter") for OpenImageIO a Series of LF Projects, LLC
Adopted July 1, 2023 by unanimous vote of the TSC.
This Charter sets forth the responsibilities and procedures for technical
contribution to, and oversight of, the OpenImageIO open source project, which
has been established as OpenImageIO a Series of LF Projects, LLC (the
“Project”). LF Projects, LLC (“LF Projects”) is a Delaware series limited
liability company. All contributors (including committers, maintainers, and
other technical positions) and other participants in the Project
(collectively, “Collaborators”) must comply with the terms of this Charter.
### 1. Mission and Scope of the Project
* **a.** The mission of the Project is to develop software to read, write,
and manipulate image files of any image file format relevant to vfx /
animation via a format-agnostic API, with a feature set, scalability, and
robustness needed for production.
* **b.** The scope of the Project includes collaborative development under
the Project License (as defined herein) supporting the mission, including
documentation, testing, integration and the creation of other artifacts
that aid the development, deployment, operation or adoption of the open
source project.
### 2. Technical Steering Committee
* **a.** The Technical Steering Committee (the “TSC”) will be responsible
for all technical oversight of the open source Project.
* **b.** The TSC voting members are initially the Project’s Committers. At
the inception of the project, the Committers of the Project will be as set
forth within the “GOVERNANCE” file within the Project’s code repository.
The TSC may choose an alternative approach for determining the voting
members of the TSC, and any such alternative approach will be documented
in the GOVERNANCE file. Any meetings of the Technical Steering Committee
are intended to be open to the public, and can be conducted
electronically, via teleconference, or in person.
* **c.** TSC projects generally will involve Contributors and Committers.
The TSC may adopt or modify roles so long as the roles are documented in
the GOVERNANCE file. Unless otherwise documented:
- **i.** Contributors include anyone in the technical community that
contributes code, documentation, or other technical artifacts to the
Project;
- **ii.** Committers are Contributors who have earned the ability to
modify (“commit”) source code, documentation or other technical
artifacts in a project’s repository; and
- **iii.** A Contributor may become a Committer by a majority approval of
the existing Committers. A Committer may be removed by a majority
approval of the other existing Committers.
* **d.** Participation in the Project through becoming a Contributor and
Committer is open to anyone so long as they abide by the terms of this
Charter.
* **e.** The TSC may (1) establish work flow procedures for the submission,
approval, and closure/archiving of projects, (2) set requirements for the
promotion of Contributors to Committer status, as applicable, and (3)
amend, adjust, refine and/or eliminate the roles of Contributors, and
Committers, and create new roles, and publicly document any TSC roles, as
it sees fit.
* **f.** The TSC may elect a TSC Chair, who will preside over meetings of
the TSC and will serve until their resignation or replacement by the TSC.
The TSC Chair, or any other TSC member so designated by the TSC, will
serve as the primary communication contact between the Project and the
Academy Software Foundation, a directed fund of The Linux Foundation.
* **g.** Responsibilities: The TSC will be responsible for all aspects of
oversight relating to the Project, which may include:
- **i.** coordinating the technical direction of the Project;
- **ii.** approving project or system proposals (including, but not
limited to, incubation, deprecation, and changes to a sub-project’s
scope);
- **iii.** organizing sub-projects and removing sub-projects;
- **iv.** creating sub-committees or working groups to focus on
cross-project technical issues and requirements;
- **v.** appointing representatives to work with other open source or open
standards communities;
- **vi.** establishing community norms, workflows, issuing releases, and
security issue reporting policies;
- **vii.** approving and implementing policies and processes for
contributing (to be published in the CONTRIBUTING file) and coordinating
with the series manager of the Project (as provided for in the Series
Agreement, the “Series Manager”) to resolve matters or concerns that may
arise as set forth in Section 7 of this Charter;
- **viii.** discussions, seeking consensus, and where necessary, voting on
technical matters relating to the code base that affect multiple
projects; and
- **ix.** coordinating any marketing, events, or communications regarding
the Project.
### 3. TSC Voting
* **a.** While the Project aims to operate as a consensus-based community,
if any TSC decision requires a vote to move the Project forward, the
voting members of the TSC will vote on a one vote per voting member basis.
* **b.** Quorum for TSC meetings requires at least fifty percent of all
voting members of the TSC to be present. The TSC may continue to meet if
quorum is not met but will be prevented from making any decisions at the
meeting.
* **c.** Except as provided in Section 7.c. and 8.a, decisions by vote at a
meeting require a majority vote of those in attendance, provided quorum is
met. Decisions made by electronic vote without a meeting require a
majority vote of all voting members of the TSC.
* **d.** In the event a vote cannot be resolved by the TSC, any voting
member of the TSC may refer the matter to the Series Manager for
assistance in reaching a resolution.
### 4. Compliance with Policies
* **a.** This Charter is subject to the Series Agreement for the Project and
the Operating Agreement of LF Projects. Contributors will comply with the
policies of LF Projects as may be adopted and amended by LF Projects,
including, without limitation the policies listed at
https://lfprojects.org/policies/.
* **b.** The TSC may adopt a code of conduct (“CoC”) for the Project, which
is subject to approval by the Series Manager. In the event that a
Project-specific CoC has not been approved, the LF Projects Code of
Conduct listed at https://lfprojects.org/policies will apply for all
Collaborators in the Project.
* **c.** When amending or adopting any policy applicable to the Project, LF
Projects will publish such policy, as to be amended or adopted, on its web
site at least 30 days prior to such policy taking effect; provided,
however, that in the case of any amendment of the Trademark Policy or
Terms of Use of LF Projects, any such amendment is effective upon
publication on LF Project’s web site.
* **d.** All Collaborators must allow open participation from any individual
or organization meeting the requirements for contributing under this
Charter and any policies adopted for all Collaborators by the TSC,
regardless of competitive interests. Put another way, the Project
community must not seek to exclude any participant based on any criteria,
requirement, or reason other than those that are reasonable and applied on
a non-discriminatory basis to all Collaborators in the Project community.
* **e.** The Project will operate in a transparent, open, collaborative, and
ethical manner at all times. The output of all Project discussions,
proposals, timelines, decisions, and status should be made open and easily
visible to all. Any potential violations of this requirement should be
reported immediately to the Series Manager.
### 5. Community Assets
* **a.** LF Projects will hold title to all trade or service marks used by
the Project (“Project Trademarks”), whether based on common law or
registered rights. Project Trademarks will be transferred and assigned to
LF Projects to hold on behalf of the Project. Any use of any Project
Trademarks by Collaborators in the Project will be in accordance with the
license from LF Projects and inure to the benefit of LF Projects.
* **b.** The Project will, as permitted and in accordance with such license
from LF Projects, develop and own all Project GitHub and social media
accounts, and domain name registrations created by the Project community.
* **c.** Under no circumstances will LF Projects be expected or required to
undertake any action on behalf of the Project that is inconsistent with
the tax-exempt status or purpose, as applicable, of the Joint Development
Foundation or LF Projects, LLC.
### 6. General Rules and Operations.
* **a.**. The Project will:
- **i.** engage in the work of the Project in a professional manner
consistent with maintaining a cohesive community, while also maintaining
the goodwill and esteem of LF Projects, Joint Development Foundation and
other partner organizations in the open source community; and
- **ii.** respect the rights of all trademark owners, including any
branding and trademark usage guidelines.
### 7. Intellectual Property Policy
* **a.** Collaborators acknowledge that the copyright in all new
contributions will be retained by the copyright holder as independent
works of authorship and that no contributor or copyright holder will be
required to assign copyrights to the Project.
* **a.** Except as described in Section 7.c., all contributions to the
Project are subject to the following:
- **i.** All new inbound code contributions to the Project must be made
using the Apache License, Version 2.0 available at
http://www.apache.org/licenses/LICENSE-2.0 (the “Project License”).
- **ii.** All new inbound code contributions must also be accompanied by
(i) a Developer Certificate of Origin (http://developercertificate.org)
sign-off in the source code system that is submitted through a
TSC-approved contribution process which will bind the authorized
contributor and, if not self-employed, their employer to the applicable
license and (ii) a duly executed contribution license agreement in the
form approved by the TSC;
- **iii.** All outbound code will be made available under the Project
License.
- **iv.** Documentation will be received and made available by the Project
under the Creative Commons Attribution 4.0 International License
(available at http://creativecommons.org/licenses/by/4.0/).
- **v.** The Project may seek to integrate and contribute back to other
open source projects (“Upstream Projects”). In such cases, the Project
will conform to all license requirements of the Upstream Projects,
including dependencies, leveraged by the Project. Upstream Project code
contributions not stored within the Project’s main code repository will
comply with the contribution process and license terms for the
applicable Upstream Project.
* **c.** The TSC may approve the use of an alternative license or licenses
for inbound or outbound contributions on an exception basis. To request an
exception, please describe the contribution, the alternative open source
license(s), and the justification for using an alternative open source
license for the Project. License exceptions must be approved by a
two-thirds vote of the entire TSC.
* **d.** Contributed files should contain license information, such as SPDX
short form identifiers, indicating the open source license or licenses
pertaining to the file.
### 8. Amendments
* **a.** This charter may be amended by a two-thirds vote of the entire TSC
and is subject to approval by LF Projects.
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 KiB

+66
View File
@@ -0,0 +1,66 @@
# Project Intake checklist
This is a checklist for TSC's to review as part of the intake process. The TSC should review this entire list during the kickoff meeting. For anything outstanding, create an [issue](../issues) to track and link to it in the list
- Existing Project Governance
- [X] A [LICENSE.md](../LICENSE.md) file in every code repository, with the license chosen an OSI-approved license.
- [X] Any third-party components/dependencies included are listed along with thier licenses ( [THIRD-PARTY.md](../THIRD-PARTY.md) )
- [X] A [README.md](../README.md) file welcoming new community members to the project and explaining why the project is useful and how to get started.
- [X] A [CONTRIBUTING.md](../CONTRIBUTING.md) file explaining to other developers and your community of users how to contribute to the project. The file should explain what types of contributions are needed and how the process works, along with how to disclose security issues responsibly ( may also point to a [SECURITY.md](../SECURITY.md) file ).
- [ ] A [CODEOWNERS](../CODEOWNERS) or [COMMITTERS](../COMMITERS.csv) file to define individuals or teams that are responsible for code in a repository; document current project owners and current and emeritus committers.
- [X] A [CODE_OF_CONDUCT.md](../CODE_OF_CONDUCT.md) file that sets the ground rules for participants’ behavior associated and helps to facilitate a friendly, welcoming environment. By default, projects should leverage the Linux Foundation Code of Conduct unless an alternate Code of Conduct was previously approved.
- [X] A [RELEASING.md](../RELEASING.md) file that provides documentation on the release methodology, cadence, criteria, etc.
- [X] A [GOVERNANCE.md](../GOVERNANCE.md) file that documents the project’s technical governance.
- [ ] A [SUPPORT.md](../SUPPORT.md) file to let users and developers know about ways to get help with your project.
- Infrastructure/Assets
- [X] Technical Charter Approved
- [ ] **(Awaiting scan from LF)** License scan completed and no issues found
- [ ] Code repository imported to ASWF GitHub organization or ownership of current GitHub organization given to `thelinuxfoundation` user
- [X] Developer Certificate of Origin past commit signoff done and DCO Probot enabled.
- [X] Issue/feature tracker established (JIRA, GitHub issues)
- [X] Mailing lists ( one of )
- [X] Setup new lists ( -dev@ and -tsc@ ) on [ASWF groups.io](https://lists.aswf.io) ( create [issue on foundation repo](https://github.com/AcademySoftwareFoundation/foundation/issues/new) to setup )
- [X] (In progress) Move to [ASWF groups.io](https://lists.aswf.io) ( create [issue on foundation repo](https://github.com/AcademySoftwareFoundation/foundation/issues/new) to transfer )
- [X] Slack ( create [issue on foundation repo](https://github.com/AcademySoftwareFoundation/foundation/issues/new) to setup project channel on [ASWF Slack](https://slack.aswf.io) )
- [ ] Website
- [X] CI/build environment
- [X] Trademarks/mark ownership rights ( complete 'LF Projects - Form of Trademark and Account Assignment' - create [issue on foundation repo](https://github.com/AcademySoftwareFoundation/foundation/issues/new) - only needed if project using existing name )
- [ ] Domain name ( create [issue with the LF IT staff](https://jira.linuxfoundation.org/plugins/servlet/theme/portal/2/group/19) to setup/transfer )
- [ ] Zoom account access ( create [issue on foundation repo](https://github.com/AcademySoftwareFoundation/foundation/issues/new) to get access to credentials )
- [X] (N/A) Social media accounts or other project accounts ( create [issue on foundation repo](https://github.com/AcademySoftwareFoundation/foundation/issues/new) to transfer )
- [X] Logo(s) ( create [issue on artwork repo](https://github.com/AcademySoftwareFoundation/artwork/issues/new) to add in SVG and PNG format and color/black/white )
- New Project Governance
- [X] TSC members identified
- [X] First TSC meeting held
- [X] TSC meeting cadence set and added to project calendar
- [X] CLA Approved ( if used ) ( [CCLA](CLA-corporate.md) and [ICLA](CLA-individual.md) )
- Project charter ( [Technical-Charter.md](Technical-Charter.md) )
- [X] Approved by TSC
- [ ] Filed ( create pull request against [foundation repo](https://github.com/AcademySoftwareFoundation/foundation) )
- [X] [Core Infrastructure Initiative Best Practices Badge](https://bestpractices.coreinfrastructure.org/) achieved as the 'Passing' level.
- Outreach
- [ ] New project announcement done ( create [issue on foundation repo](https://github.com/AcademySoftwareFoundation/foundation/issues/new) to trigger )
- [X] Project added to ASWF website and ASWF landscape
- Incubation Stage requirements
- [X] Have achieved and maintained a [OpenSSF Best Practices Badge at the passing level](https://bestpractices.coreinfrastructure.org/en/criteria).
- [ ] Have had a successful license scan with any critical issues remedied.
- [ ] Have a defined project mission and scope
- [ ] An overview of the project’s architecture and features defined.
- [ ] A project roadmap defined, which should address the following questions.
- What use cases are possible now?
- What does the next year look like in terms of additional features and use cases covered?
- [ ] Community and contributor growth assessment
- The current number of contributors and committers, and the number of different organizations contributing to the project.
- Demonstrate a sustained flow of commits / merged contributions
- A credible plan for developing a thriving user community, in particular expanding the number of committers and contributors?
- Outline of the plan for the project to complete the requirements for Adopted Stage
- [ ] Obtain an affirmative vote of the TAC.
- Adopted Stage graduation requirements
- [ ] Demonstrate a substantial ongoing flow of commits and merged contributions, authored by a healthy number of diverse contributors.
- [ ] Demonstrable roadmap progress.
- [ ] A healthy number of public adopters that are identified within the project ( using an ADOPTERS file or showcased on the project’s website ).
- [ ] Have achieved and maintained an [OpenSSF Best Practices Badge at the gold level](https://bestpractices.coreinfrastructure.org/en/criteria/2).
- [ ] Have a technical lead appointed for voting representation of the project to the TAC.
- [ ] Be deemed by the TAC to add value to the mission of ASWF.
- [ ] 2/3 supermajority vote of the TAC
- [ ] Affirmative majority vote of the Governing Board
+4211 -4028
View File
File diff suppressed because it is too large. Load diff
+212 -296
View File
@@ -1,44 +1,87 @@
project (OpenImageIO)
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: BSD-3-Clause and Apache-2.0
# https://github.com/OpenImageIO/oiio
# Release version of the library
set (OIIO_VERSION_MAJOR 1)
set (OIIO_VERSION_MINOR 8)
set (OIIO_VERSION_PATCH 2)
set (OIIO_VERSION_RELEASE_TYPE "dev") # "dev", "betaX", "RCY", ""
cmake_minimum_required (VERSION 3.12)
message (STATUS "CMake version is ${CMAKE_VERSION}")
cmake_minimum_required (VERSION 2.8)
if (NOT CMAKE_VERSION VERSION_LESS 2.8.4)
cmake_policy (SET CMP0017 NEW)
set (OpenImageIO_VERSION "2.4.15.0")
set (OpenImageIO_VERSION_OVERRIDE "" CACHE STRING
"Version override (use with caution)!")
mark_as_advanced (OpenImageIO_VERSION_OVERRIDE)
if (OpenImageIO_VERSION_OVERRIDE)
set (OpenImageIO_VERSION ${OpenImageIO_VERSION_OVERRIDE})
endif ()
if (NOT CMAKE_VERSION VERSION_LESS 3.0)
cmake_policy (SET CMP0025 NEW) # Detect AppleClang for new CMake
endif ()
if (NOT CMAKE_VERSION VERSION_LESS 3.2.2)
cmake_policy (SET CMP0042 OLD)
cmake_policy (SET CMP0046 OLD)
endif ()
set (CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
# N.B./FIXME - after CMake 3.0 is our minimum, we should change many of the
# add_definitions to add_compile_options. In newer cmake versions, the
# former is designated for definitions (-Dblah) and the latter is for
# compile flags (-Wno-foo).
project (OpenImageIO VERSION ${OpenImageIO_VERSION}
HOMEPAGE_URL "https://openimageio.org"
LANGUAGES CXX C)
if (VERBOSE)
message (STATUS "Project source dir = ${PROJECT_SOURCE_DIR}")
set (PROJ_NAME OIIO) # short name, caps
string (TOLOWER ${PROJ_NAME} PROJ_NAME_LOWER) # short name lower case
string (TOUPPER ${PROJ_NAME} PROJ_NAME_UPPER) # short name upper case
set (PROJECT_VERSION_RELEASE_TYPE "" CACHE STRING
"Build type, for example: dev, beta2, RC1 (empty string for normal release)")
set (${PROJECT_NAME}_VERSION_RELEASE_TYPE ${PROJECT_VERSION_RELEASE_TYPE})
set (PROJECT_AUTHORS "Contributors to the OpenImageIO project")
option (${PROJECT_NAME}_SUPPORTED_RELEASE
"Set ON for supported release branch, OFF for master" ON)
if (${PROJECT_NAME}_SUPPORTED_RELEASE)
set (${PROJECT_NAME}_DEV_RELEASE OFF)
else ()
set (${PROJECT_NAME}_DEV_RELEASE ON)
endif ()
message (STATUS "Project build dir = ${CMAKE_BINARY_DIR}")
if ("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message (FATAL_ERROR "Not allowed to run in-source build!")
# Set PROJECT_IS_TOP_LEVEL to ON if if this is the top level project (not
# if this is included as a subproject of something else). Note that this is
# handled automatically for CMake >= 3.21.
if (CMAKE_VERSION VERSION_LESS 3.21)
if ("${CMAKE_PROJECT_NAME}" STREQUAL "${PROJECT_NAME}")
set (PROJECT_IS_TOP_LEVEL ON)
endif ()
endif ()
# If the user wants to use Conan to build dependencies, they will have done
# this prior to the cmake config:
# cd <build area>
# conan install <source area>
# and that will leave a conanbuildinfo.cmake in the build area for us.
if (EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include (${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
message (STATUS "Using Conan for dependencies")
conan_basic_setup()
endif()
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Release")
endif ()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set (DEBUGMODE ON)
# If the user hasn't configured cmake with an explicit
# -DCMAKE_INSTALL_PREFIX=..., then set it to safely install into ./dist, to
# help prevent the user from accidentally writing over /usr/local or whatever.
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
AND PROJECT_IS_TOP_LEVEL)
set (CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/dist" CACHE PATH
"Installation location" FORCE)
endif()
message (STATUS "Configuring ${PROJECT_NAME} ${PROJECT_VERSION}")
message (STATUS "CMake ${CMAKE_VERSION}")
message (STATUS "CMake system = ${CMAKE_SYSTEM}")
message (STATUS "CMake system name = ${CMAKE_SYSTEM_NAME}")
message (STATUS "Project source dir = ${PROJECT_SOURCE_DIR}")
message (STATUS "Project build dir = ${CMAKE_BINARY_DIR}")
message (STATUS "Project install prefix = ${CMAKE_INSTALL_PREFIX}")
message (STATUS "Configuration types = ${CMAKE_CONFIGURATION_TYPES}")
message (STATUS "Build type = ${CMAKE_BUILD_TYPE}")
message (STATUS "Supported release = ${${PROJECT_NAME}_SUPPORTED_RELEASE}")
# Make the build area layout look a bit more like the final dist layout
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
if ("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message (FATAL_ERROR "Not allowed to run in-source build!")
endif ()
option (CMAKE_USE_FOLDERS "Use the FOLDER target property to organize targets into folders." ON)
@@ -47,92 +90,106 @@ if (CMAKE_USE_FOLDERS)
set_property (GLOBAL PROPERTY USE_FOLDERS ON)
endif ()
set (CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/src/cmake/modules"
"${PROJECT_SOURCE_DIR}/src/cmake")
include (oiio_macros)
include (platform)
include (compiler)
option (VERBOSE "Print lots of messages while compiling")
option (VERBOSE "Print lots of messages while compiling" OFF)
option (${PROJ_NAME}_BUILD_TOOLS "Build the command-line tools" ON)
option (${PROJ_NAME}_BUILD_TESTS "Build the unit tests" ON)
set (OIIO_LIBNAME_SUFFIX "" CACHE STRING
"Optional name appended to ${PROJECT_NAME} libraries that are built")
option (BUILD_OIIOUTIL_ONLY "If ON, will build *only* libOpenImageIO_Util" OFF)
option (BUILD_DOCS "If ON, build documentation and man pages." ON)
option (INSTALL_DOCS "If ON, install documentation and man pages." ON)
option (INSTALL_FONTS "If ON, install default fonts" ON)
option (EMBEDPLUGINS "Embed format plugins in libOpenImageIO" ON)
option (OIIO_BUILD_TOOLS "Build the command-line tools" ON)
option (OIIO_BUILD_TESTS "Build the unit tests" ON)
option (USE_OPENGL "Include OpenGL support" ON)
option (USE_QT "Include Qt support" ON)
option (FORCE_OPENGL_1 "Force iv to use OpenGL's fixed pipeline")
option (USE_PYTHON "Build the Python bindings" ON)
option (USE_PYTHON3 "Build the Python3 bindings")
set (PYTHON_VERSION 2.6)
set (PYTHON3_VERSION 3.2)
option (PYLIB_INCLUDE_SONAME "If ON, soname/soversion will be set for Python module library")
option (PYLIB_LIB_PREFIX "If ON, prefix the Python module with 'lib'")
option (USE_FIELD3D "Use Field3D if found" ON)
option (USE_FFMPEG "Use FFmpeg if found" ON)
set (JPEG_PATH "" CACHE STRING "Custom JPEG path")
option (USE_JPEGTURBO "Use JPEG-Turbo if found" ON)
set (JPEGTURBO_PATH "" CACHE STRING "Custom JPEG-Turbo path")
option (USE_OPENJPEG "Use OpenJpeg if found" ON)
option (USE_OCIO "Use OpenColorIO for color management if found" ON)
option (USE_OPENCV "Use OpenCV if found" ON)
option (USE_OPENSSL "Use OpenSSL if found (for faster SHA-1)")
option (USE_FREETYPE "Use Freetype if found" ON)
option (USE_GIF "Use GIF if found" ON)
option (USE_PTEX "Use PTex if found" ON)
option (USE_LIBRAW "Use LibRaw if found" ON)
set (LIBRAW_PATH "" CACHE STRING "Custom LibRaw path")
set (PLUGIN_SEARCH_PATH "" CACHE STRING "Default plugin search path")
file (TO_NATIVE_PATH "${PLUGIN_SEARCH_PATH}" PLUGIN_SEARCH_PATH_NATIVE)
set (CMAKE_DEBUG_POSTFIX "_d" CACHE STRING "Library naming postfix for Debug builds")
if (CMAKE_UNITY_BUILD_BATCH_SIZE)
set (UNITY_SMALL_BATCH_SIZE "${CMAKE_UNITY_BUILD_BATCH_SIZE}" CACHE STRING "Unity batch mode size for expensive files")
else ()
set (UNITY_SMALL_BATCH_SIZE 8 CACHE STRING "Unity batch mode size for expensive files")
endif ()
message(STATUS "CMAKE_UNITY_BUILD_MODE = ${CMAKE_UNITY_BUILD_MODE}")
message(STATUS "CMAKE_UNITY_BUILD_BATCH_SIZE = ${CMAKE_UNITY_BUILD_BATCH_SIZE}")
option (OIIO_THREAD_ALLOW_DCLP "OIIO threads may use DCLP for speed" ON)
option (USE_NUKE "Build Nuke plugins, if Nuke is found" ON)
set (Nuke_ROOT "" CACHE STRING "Where to find Nuke installation")
set (NUKE_VERSION 7.0)
set (USE_EXTERNAL_PUGIXML OFF CACHE BOOL
"Use an externally built shared library version of the pugixml library")
set (PUGIXML_HOME "" CACHE STRING "Hint about where to find external PugiXML library")
option (USE_DICOM "Use DICOM if DCMTK is found" ON)
set (SOVERSION ${OIIO_VERSION_MAJOR}.${OIIO_VERSION_MINOR}
CACHE STRING "Set the SO version in the SO name of the output library")
option (BUILD_OIIOUTIL_ONLY "If ON, will build *only* libOpenImageIO_Util")
if (NOT OIIO_THREAD_ALLOW_DCLP)
add_definitions ("-DOIIO_THREAD_ALLOW_DCLP=0")
endif ()
if (DEFINED ENV{TRAVIS} OR DEFINED ENV{APPVEYOR} OR DEFINED ENV{CI})
add_definitions ("-DOIIO_CI=1" "-DBUILD_CI")
set (TEX_BATCH_SIZE "" CACHE STRING "Force TextureSystem SIMD batch size (e.g. 16)")
if (TEX_BATCH_SIZE)
add_definitions ("-DOIIO_TEXTURE_SIMD_BATCH_WIDTH=${TEX_BATCH_SIZE}")
endif ()
option (OIIO_TEX_IMPLEMENT_VARYINGREF "Implement the deprecated batch texture functions taking VaryingRef params" ON)
if (NOT OIIO_TEX_IMPLEMENT_VARYINGREF)
add_definitions (-DOIIO_TEX_NO_IMPLEMENT_VARYINGREF=1)
endif ()
# Set the default namespace
set (OIIO_NAMESPACE OpenImageIO CACHE STRING
"Specify the master C++ namespace: Options include OpenImageIO OpenImageIO_<YOURFACILITY> etc.")
message(STATUS "Setting Namespace to: ${OIIO_NAMESPACE}")
set (${PROJ_NAME}_NAMESPACE ${PROJECT_NAME} CACHE STRING
"Customized outer namespace base name (version will be added)")
option (${PROJ_NAME}_NAMESPACE_INCLUDE_PATCH
"Should the inner namespace include the patch number" ${${PROJECT_NAME}_DEV_RELEASE})
set (PROJ_NAMESPACE "${${PROJ_NAME}_NAMESPACE}")
set (PROJ_NAMESPACE_V "${PROJ_NAMESPACE}_v${PROJECT_VERSION_MAJOR}_${PROJECT_VERSION_MINOR}")
if (${PROJ_NAME}_NAMESPACE_INCLUDE_PATCH)
set (PROJ_NAMESPACE_V "${PROJ_NAMESPACE_V}_${PROJECT_VERSION_PATCH}")
endif ()
message(STATUS "Setting Namespace to: ${PROJ_NAMESPACE_V}")
if (BUILDSTATIC)
add_definitions(-DOIIO_STATIC_BUILD=1)
endif()
# Define OIIO_INTERNAL symbol only when building OIIO itself, will not be
# defined for downstream projects using OIIO.
add_definitions (-DOIIO_INTERNAL=1)
list (APPEND CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/src/cmake/modules"
"${PROJECT_SOURCE_DIR}/src/cmake")
include (GNUInstallDirs)
# Utilities
include (colors)
include (check_is_enabled)
include (checked_find_package)
include (fancy_add_executable)
include (add_oiio_plugin)
# All the C++ and compiler related options and adjustments
include (compiler)
# Utilities and options related to finding python and making python bindings
include (pythonutils)
# Dependency finding utilities and all dependency-related options
include (externalpackages)
include (install)
# Include all our testing apparatus and utils, but not if it's a subproject
if (PROJECT_IS_TOP_LEVEL)
include (testing)
else ()
macro (oiio_add_tests)
endmacro ()
macro (oiio_add_all_tests)
endmacro ()
endif ()
include_directories (
BEFORE
"${CMAKE_SOURCE_DIR}/src/include"
"${CMAKE_BINARY_DIR}/include/${CMAKE_PROJECT_NAME}"
"${CMAKE_BINARY_DIR}/src/include"
"${CMAKE_BINARY_DIR}/include"
"${CMAKE_BINARY_DIR}/include/OpenImageIO"
)
# We want CTest for testing
# N.B. This needs to be added before any of the subdirectories, or
# their add_test commands will not register.
include (CTest)
# Tell CMake to process the sub-directories
add_subdirectory (src/libutil)
find_or_download_robin_map ()
# Add IO plugin directories -- if we are embedding plugins, we need to visit
# these directories BEFORE the OpenImageIO target is established (in
# src/libOpenImageIO). For each plugin, we append to the lists of source
@@ -161,14 +218,14 @@ if (NOT BUILD_OIIOUTIL_ONLY)
endif ()
if (OIIO_BUILD_TOOLS AND NOT BUILD_OIIOUTIL_ONLY)
add_subdirectory (src/iconvert)
add_subdirectory (src/idiff)
add_subdirectory (src/igrep)
add_subdirectory (src/iinfo)
add_subdirectory (src/maketx)
add_subdirectory (src/oiiotool)
add_subdirectory (src/testtex)
add_subdirectory (src/iv)
add_subdirectory (src/iconvert)
add_subdirectory (src/idiff)
add_subdirectory (src/igrep)
add_subdirectory (src/iinfo)
add_subdirectory (src/maketx)
add_subdirectory (src/oiiotool)
add_subdirectory (src/testtex)
add_subdirectory (src/iv)
endif ()
# Add IO plugin directories -- if we are not embedding plugins, we need to
@@ -180,220 +237,79 @@ if (NOT EMBEDPLUGINS AND NOT BUILD_OIIOUTIL_ONLY)
endforeach ()
endif ()
if (USE_PYTHON AND boost_PYTHON_FOUND AND NOT BUILD_OIIOUTIL_ONLY)
if (USE_PYTHON AND Python_Development_FOUND AND NOT BUILD_OIIOUTIL_ONLY)
add_subdirectory (src/python)
endif ()
if (USE_PYTHON3 AND boost_PYTHON_FOUND AND NOT BUILD_OIIOUTIL_ONLY)
#build the python3 module in a different binary directory since it will
#have the same name as the python2 module (e.g. OpenImageIO.so)
add_subdirectory (src/python src/python3)
endif ()
add_subdirectory (src/include)
add_subdirectory (src/doc)
if (BUILD_DOCS)
add_subdirectory (src/doc)
endif ()
add_subdirectory (src/fonts)
add_subdirectory (src/nuke)
#########################################################################
# Testing
#
# Just call oiio_add_tests(testname...) for each test. Additional
# optional arguments include:
# FOUNDVAR specifies the name of a CMAKE variable; if not defined,
# the test will not be added for 'make test' (helpful
# for excluding tests for libraries not found).
# IMAGEDIR specifies a directory for test images, one level higher
# than where the oiio top level source lives -- a
# message will be printed if not found.
# URL URL where the test images can be found, will be
# incorporated into the error message if the test
# image directory is not found.
# LABEL If set to "broken", will designate the test as one
# that is known to be broken, so will only be run
# for "make testall", but not "make test".
#
# Make a build/platform/testsuite directory, and copy the master runtest.py
# there. The rest is up to the tests themselves.
file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/testsuite")
add_custom_command (OUTPUT "${CMAKE_BINARY_DIR}/testsuite/runtest.py"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_SOURCE_DIR}/testsuite/runtest.py"
"${CMAKE_BINARY_DIR}/testsuite/runtest.py"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/testsuite/runtest.py")
add_custom_target ( CopyFiles ALL DEPENDS "${CMAKE_BINARY_DIR}/testsuite/runtest.py" )
# Basic tests that apply even to continuous integration tests:
oiio_add_tests (
gpsread misnamed-file nonwhole-tiles
oiiotool oiiotool-composite oiiotool-deep oiiotool-fixnan
oiiotool-pattern oiiotool-readerror
oiiotool-subimage oiiotool-text oiiotool-xform
maketx oiiotool-maketx
diff
dither dup-channels
dpx ico iff png psd rla sgi
texture-interp-bicubic
texture-blurtube
texture-crop texture-cropover
texture-derivs texture-fill texture-filtersize
texture-flipt texture-gray
texture-mip-nomip texture-mip-trilinear
texture-overscan texture-pointsample
texture-uint8
texture-width0blur
texture-fat texture-skinny texture-wrapfill
texture-missing texture-res texture-udim texture-udim2
)
# Add tests that require the Python bindings if we built the Python
# bindings. This is mostly the test that are specifically about testing
# the Python bindings themselves, but also a handful of tests that are
# mainly about other things but happen to use Python in order to perform
# thee test.
# We also exclude these tests if this is a sanitizer build on Linux,
# because the Python interpreter itself won't be linked with the right asan
# libraries to run correctly.
if (USE_PYTHON AND boost_PYTHON_FOUND AND NOT BUILD_OIIOUTIL_ONLY)
if (NOT SANITIZE_ON_LINUX)
oiio_add_tests (
python-typedesc python-imagespec python-roi python-deep
python-imageinput python-imageoutput
python-imagebuf python-imagebufalgo
)
endif ()
if (NUKE_FOUND)
add_subdirectory (src/nuke/txReader)
add_subdirectory (src/nuke/txWriter)
endif ()
# Advanced tests that are done by hand and for releases:
# FIXME -- at some point, try to fix these or provide new ref images
if (NOT DEFINED ENV{TRAVIS})
oiio_add_tests (
texture-half texture-uint16
texture-interp-bilinear
texture-interp-closest
texture-mip-onelevel
texture-icwrite
)
# Last minute site-specific instructions, if they exist
if (OIIO_SITE AND EXISTS "${PROJECT_SOURCE_DIR}/site/${OIIO_SITE}/cmake/sitecustom.cmake")
include ("${PROJECT_SOURCE_DIR}/site/${OIIO_SITE}/cmake/sitecustom.cmake")
endif ()
# List testsuites which need special external reference images from the web
# here:
oiio_add_tests (bmp
IMAGEDIR bmpsuite
URL http://entropymine.com/jason/bmpsuite/bmpsuite.zip)
# install pkgconfig file
if (NOT MSVC)
configure_file(src/build-scripts/OpenImageIO.pc.in "${CMAKE_BINARY_DIR}/OpenImageIO.pc" @ONLY)
install (FILES "${CMAKE_BINARY_DIR}/OpenImageIO.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT developer)
endif()
oiio_add_tests (tiff-suite tiff-depths tiff-misc
IMAGEDIR libtiffpic
URL http://www.remotesensing.org/libtiff/images.html)
# Export the configuration files. There are also library-specific config
# exports in the CMakeLists.txt of libOpenImageIO.
include (CMakePackageConfigHelpers)
oiio_add_tests (openexr-suite openexr-multires openexr-chroma openexr-v2 perchannel
IMAGEDIR openexr-images
URL http://www.openexr.com/downloads.html)
# the file containing the exported targets
set (OIIO_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets.cmake")
# the version file
set (OIIO_VERSION_CONFIG "${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
# the config file that is actually looked for by find_package
set (OIIO_PROJECT_CONFIG "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake")
# where all these files will be installed
set (OIIO_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
oiio_add_tests (gif
FOUNDVAR GIF_FOUND
IMAGEDIR oiio-images
URL "Recent checkout of oiio-images")
# first generate the version file in the binary dir
write_basic_package_version_file (
${OIIO_VERSION_CONFIG}
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
oiio_add_tests (jpeg2000
FOUNDVAR OPENJPEG_FOUND
IMAGEDIR j2kp4files_v1_5
URL http://www.itu.int/net/ITU-T/sigdb/speimage/ImageForm-s.aspx?val=10100803)
# generate the Targets file in the binary dir using the targets collected in
# OIIO_EXPORTED_TARGETS each target is added to OIIO_EXPORTED_TARGETS
# through the macro install_target().
export (EXPORT OIIO_EXPORTED_TARGETS FILE "${CMAKE_BINARY_DIR}/${OIIO_TARGETS_EXPORT_NAME}")
oiio_add_tests (pnm
IMAGEDIR oiio-images/pnm
URL "Recent checkout of oiio-images")
# generate the config file from the template in the binary dir
configure_package_config_file ("${PROJECT_SOURCE_DIR}/src/cmake/Config.cmake.in"
"${OIIO_PROJECT_CONFIG}"
INSTALL_DESTINATION "${OIIO_CONFIG_INSTALL_DIR}")
oiio_add_tests (targa-tgautils
IMAGEDIR TGAUTILS
URL http://tgautils.inequation.org/)
# generate the config file from the template in the binary dir
install (FILES "${OIIO_PROJECT_CONFIG}" "${OIIO_VERSION_CONFIG}"
DESTINATION "${OIIO_CONFIG_INSTALL_DIR}")
oiio_add_tests (fits
IMAGEDIR fits-images
URL http://www.cv.nrao.edu/fits/data/tests/)
oiio_add_tests (webp
FOUNDVAR WEBP_FOUND
IMAGEDIR webp-images
URL http://code.google.com/speed/webp/gallery.html)
oiio_add_tests (ptex
FOUNDVAR PTEX_FOUND)
# install targets files
install (EXPORT OIIO_EXPORTED_TARGETS
DESTINATION ${OIIO_CONFIG_INSTALL_DIR}
FILE ${OIIO_TARGETS_EXPORT_NAME}
NAMESPACE ${PROJECT_NAME}::)
if (NOT DEFINED ENV{TRAVIS})
oiio_add_tests (texture-field3d field3d
FOUNDVAR FIELD3D_FOUND)
if (PROJECT_IS_TOP_LEVEL AND BUILD_TESTING)
oiio_setup_test_data()
oiio_add_all_tests()
endif ()
if (SPI_TESTS)
oiio_add_tests (oiiotool-spi
FOUNDVAR SPI_TESTS
IMAGEDIR spi-oiio-tests
URL "noplace -- it's SPI specific tests")
if (PROJECT_IS_TOP_LEVEL)
include (packaging)
endif ()
#########################################################################
# Packaging
set (CPACK_PACKAGE_VERSION_MAJOR ${OIIO_VERSION_MAJOR})
set (CPACK_PACKAGE_VERSION_MINOR ${OIIO_VERSION_MINOR})
set (CPACK_PACKAGE_VERSION_PATCH ${OIIO_VERSION_PATCH})
# "Vendor" is only used in copyright notices, so we use the same thing that
# the rest of the copyright notices say.
set (CPACK_PACKAGE_VENDOR "Larry Gritz et al.")
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenImageIO is an open source library for reading and writing image file formats, a nice format-agnostic image viewer, and other image-related classes and utilities.")
set (CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/src/doc/Description.txt")
set (CPACK_PACKAGE_FILE_NAME OpenImageIO-${OIIO_VERSION_MAJOR}.${OIIO_VERSION_MINOR}.${OIIO_VERSION_PATCH}-${platform})
#SET (CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_SOURCE_DIR}")
file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/cpack")
file (COPY "${PROJECT_SOURCE_DIR}/LICENSE" DESTINATION "${CMAKE_BINARY_DIR}/cpack")
file (RENAME "${CMAKE_BINARY_DIR}/cpack/LICENSE" "${CMAKE_BINARY_DIR}/cpack/License.txt")
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/cpack/License.txt")
file (COPY "${PROJECT_SOURCE_DIR}/README.md" DESTINATION "${CMAKE_BINARY_DIR}/cpack")
file (RENAME "${CMAKE_BINARY_DIR}/cpack/README.md" "${CMAKE_BINARY_DIR}/cpack/Readme.md")
set (CPACK_RESOURCE_FILE_README "${CMAKE_BINARY_DIR}/cpack/Readme.md")
set (CPACK_RESOURCE_FILE_WELCOME "${PROJECT_SOURCE_DIR}/src/doc/Welcome.txt")
#SET (CPACK_STRIP_FILES Do we need this?)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set (CPACK_GENERATOR "TGZ;STGZ;RPM;DEB")
set (CPACK_SOURCE_GENERATOR "TGZ")
endif ()
if (APPLE)
set (CPACK_GENERATOR "TGZ;STGZ;PackageMaker")
set (CPACK_SOURCE_GENERATOR "TGZ")
endif ()
if (WIN32)
set (CPACK_GENERATOR "NSIS")
set(CPACK_PACKAGE_EXECUTABLES "iv" "iv - Image Viewer")
# set(CPACK_CREATE_DESCTOP_LINKS "iv" "iv - Image Viewer")
set(CPACK_NSIS_MODIFY_PATH ON)
include (InstallRequiredSystemLibraries)
endif ()
set (CPACK_SOURCE_PACKAGE_FILE_NAME OpenImageIO-${OIIO_VERSION_MAJOR}.${OIIO_VERSION_MINOR}.${OIIO_VERSION_PATCH}-source)
#set (CPACK_SOURCE_STRIP_FILES Do we need this?)
set (CPACK_SOURCE_IGNORE_FILES ".*~")
set (CPACK_COMPONENT_UNSPECIFIED_HIDDEN TRUE)
set (CPACK_COMPONENT_UNSPECIFIED_REQUIRED TRUE)
set (CPACK_COMPONENTS_ALL user developer documentation Unspecified)
set (CPACK_COMPONENT_USER_DISPLAY_NAME "Applications")
set (CPACK_COMPONENT_DEVELOPER_DISPLAY_NAME "Developer files")
set (CPACK_COMPONENT_DOCUMENTATION_DISPLAY_NAME "Documentation")
set (CPACK_COMPONENT_USER_DESCRIPTION
"Applications: iv, iinfo, iconvert, idiff, igrep, maketx and libraries")
set (CPACK_COMPONENT_DEVELOPER_DESCRIPTION "Include files")
set (CPACK_COMPONENT_DOCUMENTATION_DESCRIPTION "OpenImageIO documentation")
set (CPACK_COMPONENT_DEVELOPER_DEPENDS user)
include (CPack)
# TODO: equivalents of the old:
# * make doxygen
# * BOOST_DYNAMIC
# Do TIFF, JPEG, PNG actually look in external?
+7
View File
@@ -0,0 +1,7 @@
# Code of Conduct
The OpenImageIO project abides by Linux Foundation's code of conduct, which
you can read in full [here](https://lfprojects.org/policies/code-of-conduct).
To report incidents or to appeal reports of incidents, send email to
the Manager of LF Projects at manager@lfprojects.org.
+195 -176
View File
@@ -1,73 +1,137 @@
Contributing to OpenImageIO
===========================
Code contributions to OpenImageIO are always welcome. That's a big part of
why it's an open source project. Please review this document to get a
briefing on our process.
> NOTE: This is the proposed post-ASWF-move version of CONTRIBUTING. After the
> project is legally transferred and moved to the new repo, this file will
> replace the one at the project root.
>
> TO DO:
>
> - [X] Update the mail list sign-up page after the mail list moves.
> - [ ] Update the repo URL
> - [ ] Double check the security and info email addresses.
>
Code contributions to OpenImageIO are always welcome, and [nearly 200
people](https://github.com/OpenImageIO/oiio/blob/master/CREDITS.md) have done
so over the years. Please review this document to get a briefing on our
process.
Mail Lists
----------
Mail List and Slack
-------------------
There are two mail lists associated with OpenImageIO development:
Contributors should be reading the oiio-dev mail list:
* [oiio-dev](http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org) For developers of the OpenImageIO code itself, or users who are
really interested in the OIIO internals. This is where we discuss the code
(including bug reports).
* [oiio-dev](https://lists.aswf.io/g/oiio-dev)
For developers of the OpenImageIO code itself, or users who are really
interested in the OIIO internals. This is where we mostly discuss the code
(including bug reports), but are also happy to answer user questions about
use or working of OIIO.
* [oiio-announce](http://lists.openimageio.org/listinfo.cgi/oiio-announce-openimageio.org) For announcements about major OIIO releases or other important news.
You can sign up for the mail list on your own using the link above.
You can sign up for these mail lists on your own using the links above.
The [ASWF Slack](https://slack.aswf.io/) has an `openimageio` channel. Sign up
for the Slack on your own, then under "channels", select "browse channels" and
you should see the openimageio channel (among those of the other projects and
working groups).
How to Ask for Help
-------------------
If you have trouble installing, building, or using OpenImageIO, but there's
not yet a solid reason to suspect you've encountered a genuine bug, start by
posting a question to the [oiio-dev mailing
list](https://lists.aswf.io/g/oiio-dev).
This is the place for questions such has "How do I...".
Bug Reports and Issue Tracking
------------------------------
We use GitHub's issue tracking system for bugs and enhancements:
https://github.com/OpenImageIO/oiio/issues
We use GitHub's issue tracking system for reporting bugs and requesting
enhancements: https://github.com/OpenImageIO/oiio/issues
**If you are merely asking a question ("how do I...")**, please do not file an
issue, but instead ask the question on the [OIIO developer mail
list](http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org).
issue, but instead ask the question on the [oiio-dev mailing
list](https://lists.aswf.io/g/oiio-dev).
If you are submitting a bug report, please be sure to note which version of
OIIO you are using, on what platform (OS/version, which compiler you used,
and any special build flags or other unusual environmental issues). Please
give an account of
give a specific, as-detailed-as-possible account of
* what you tried
* what happened
* what you expected to happen instead
* what you tried (command line, source code example)
* what you expected to happen
* what actually happened (crash? error message? ran but didn't give the
correct result?)
with enough detail that others can reproduce the problem.
with enough detail that others can easily reproduce the problem just by
following your instructions. Please quote the exact error message you
received. If you are having trouble building, please post the full cmake
output of a fresh VERBOSE=1 build.
Suspected security vulnerabilities should be reported by the same process.
If confidentiality precludes a public question or issue for any reason, you
may contact us privately at [security@openimageio.org](security@openimageio.org).
Contributor License Agreement (CLA) and Intellectual Property
-------------------------------------------------------------
To protect the project -- and the contributors! -- we do require a
Contributor License Agreement (CLA) for anybody submitting substantial
changes. Trivial changes (such as an alteration to the Makefiles, a one-line
bug fix, etc.) may be accepted without a CLA, at the sole discretion of the
project leader, but anything complex needs a CLA. This is for your own
safety.
To protect the project -- and the contributors! -- we do require a Contributor
License Agreement (CLA) for anybody submitting changes. This is for your own
safety, as it prevents any possible future disputes between code authors and
their employers or anyone else who might think they might own the IP output of
the author.
* If you are an individual writing the code on your own time and you're SURE
you are the sole owner of any intellectual property you contribute, use the
[Individual CLA](https://github.com/OpenImageIO/oiio/blob/master/src/doc/CLA-INDIVIDUAL).
* [Corporate CLA](https://github.com/OpenImageIO/oiio/blob/master/ASWF/CLA-corporate.md) :
If you are writing the code as part of your job, or if there is any
possibility that your employers might think they own any intellectual
property you create. This needs to be executed by someone who has
signatory power for the company.
* If you are writing the code as part of your job, or if there is any
possibility that your employers might think they own any intellectual
property you create, then you should use the [Corporate
CLA](https://github.com/OpenImageIO/oiio/blob/master/src/doc/CLA-CORPORATE).
* [Individual CLA](https://github.com/OpenImageIO/oiio/blob/master/ASWF/CLA-individual.md) :
If you are an individual writing the code on your own time, using your own
equipment, and you're SURE you are the sole owner of any intellectual
property you contribute.
Download the appropriate CLA from the links above (or find them in the
src/doc directory of the software distribution), print, sign, and rescan it
(or just add a digital signature directly), and email it back to us
(info@openimageio.org).
The easiest way to sign CLAs is digitally [using EasyCLA](https://corporate.v1.easycla.lfx.linuxfoundation.org).
Companies who prefer not to use the online tools may sign, scan, and email
the executed copy to manager@lfprojects.org.
Our CLA's are identical to those used by Apache and many other open source
projects.
The CLA allows a company to name a "CLA Manager" (who does not need
signatory power) who has the ability to use the online system to add or
delete individual employees of the company who are authorized to submit pull
requests, without needing to get an executive to amend and sign the
agreement each time.
Please note that these CLAs are based on the Apache 2.0 CLAs, and differ
minimally, only as much as was required to correctly describe the EasyCLA
process and our use of a CLA manager.
**Contribution sign off**
This project requires the use of the [Developer’s Certificate of Origin 1.1
(DCO)](https://developercertificate.org/), which is the same mechanism that
the [Linux®
Kernel](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst#n416)
and many other communities use to manage code contributions. The DCO is
considered one of the simplest tools for sign offs from contributors as the
representations are meant to be easy to read and indicating signoff is done
as a part of the commit message.
Here is an example Signed-off-by line, which indicates that the submitter
accepts the DCO:
Signed-off-by: John Doe <john.doe@example.com>
You can include this automatically when you commit a change to your local
git repository using `git commit -s`. You might also want to
leverage this [command line tool](https://github.com/coderanger/dco) for
automatically adding the signoff message on commits.
Pull Requests and Code Review
@@ -76,157 +140,119 @@ Pull Requests and Code Review
The best way to submit changes is via GitHub Pull Request. GitHub has a
[Pull Request Howto](https://help.github.com/articles/using-pull-requests/).
All code must be formally reviewed before being merged into the official repository. The protocol is like this:
All code must be formally reviewed before being merged into the official
repository. The protocol is like this:
1. Get a GitHub account, fork OpenImageIO/oiio to create your own repository on GitHub, and then clone it to get a repository on your local machine.
1. Get a GitHub account, fork OpenImageIO/oiio to create your own repository
on GitHub, and then clone it to get a repository on your local machine.
2. Edit, compile, and test your changes.
1. Edit, compile, and test your changes. Run clang-format (see the
instructions on coding style below).
3. Push your changes to your fork (each unrelated pull request to a separate
1. Push your changes to your fork (each unrelated pull request to a separate
"topic branch", please).
4. Make a "pull request" on GitHub for your patch.
1. Make a "pull request" on GitHub for your patch.
5. If your patch will induce a major compatibility break, or has a design
2. If your patch will induce a major compatibility break, or has a design
component that deserves extended discussion or debate among the wider OIIO
community, then it may be prudent to email oiio-dev pointing everybody to
the pull request URL and discussing any issues you think are important.
6. The reviewer will look over the code and critique on the "comments" area,
or discuss in email. Reviewers may ask for changes, explain problems they
found, congratulate the author on a clever solution, etc. But until somebody
says "LGTM" (looks good to me), the code should not be committed. Sometimes
this takes a few rounds of give and take. Please don't take it hard if your
first try is not accepted. It happens to all of us.
1. All pull requests automatically launch CI jobs on GitHub Actions to
ensure that the build completes and that the tests suite runs correctly, for
a variety of platform, compiler, library, and flag combinations. The status
of the CI tests for your PR will be displayed on the GitHub PR page. We will
not accept PRs that don't build cleanly or pass the existing testsuite.
7. After approval, one of the senior developers (with commit approval to the official main repository) will merge your fixes into the master branch.
1. The reviewer will look over the code and critique on the "comments" area.
Reviewers may ask for changes, explain problems they found, congratulate the
author on a clever solution, etc. But until somebody says "LGTM" (looks good
to me), the code should not be committed. Sometimes this takes a few rounds
of give and take. Please don't take it hard if your first try is not
accepted. It happens to all of us.
1. After approval, one of the senior developers (with commit approval to the
official main repository) will merge your fixes into the master branch.
Coding Style
------------
There are two overarching rules:
1. When making changes, conform to the style and conventions of the surrounding code.
2. Strive for clarity, even if that means occasionally breaking the
guidelines. Use your head and ask for advice if your common sense seems to
disagree with the conventions.
Below we try to enumerate the guidelines embodied in the code.
#### File conventions
### File conventions
C++ implementation should be named `*.cpp`. Headers should be named `.h`.
All headers should contain
#pragma once
All source files should begin with these three lines:
All source files should begin with the copyright and license, which can be
found in the LICENSE file (or cut and pasted from any other other source
file). Two notes on this:
// Copyright Contributors to the OpenImageIO project.
// SPDX-License-Identifier: Apache-2.0
// https://github.com/OpenImageIO/oiio
* For NEW source files, please change the copyright year to the present. DO
NOT edit existing files only to update the copyright year, it just creates
pointless deltas and offers no increased protection.
as a comment in the syntax of whatever source code is used in that file.
* One or two files also credit NVIDIA. Do NOT copy that line to any new files,
it really only applies to the small number of files where it already
appears.
#### Formatting
NEVER alter somebody else's code to reformat just because you found
something that violates the rules. Let the group/author/leader know, and
resist the temptation to change it yourself.
Each line of text in your code should be at most 80 characters long.
Exceptions are allowed for those rare cases where letting a line be longer
(and wrapping on an 80-character window) is actually a better and clearer
alternative than trying to split it into two lines. Sometimes this happens,
but it's extremely rare.
Indent 4 spaces at a time, and use actual spaces, not tabs. For files that
must use tabs for some reason, tabs should always be on 8's. Most editors
have a setting that forces indentations to be spaces. With emacs, you can do
this:
(setq c-default-style "bsd")
(setq-default indent-tabs-mode nil)
Opening brace on the same line as the condition or loop.
One statement per line, except in rare cases where violating this rule makes
the code more clear.
Three (3) consecutive empty lines between function or class method
implementations, one blank line between method declarations within a class
definition. Put a single blank line within a function if it helps to
visually separate different sequential tasks. Don't put multiple blank lines
in a row within a function, or blank lines right after an opening brace or
right before a closing brace. The goal is to use just enough white space to
help developers visually parse the code (for example, spotting at a glance
where new functions begin), but not so much as to spread it out or be
confusing.
For if, for, while, etc., put a space before the paren, but NOT inside the parens. For example:
if (foo) // Yes
if(foo) // No
if ( foo ) // No
Function calls should have a space between the function name and the opening
parenthesis, NO space inside the parenthesis, except for a single blank
space between each argument. For example:
x = foo (a, b); // Yes, this is always ok
x = foo ( a, b ); // No
x = foo (a,b); // No
x = foo(a, b); // No
x = foo(a); // Occasionally, this just looks better, when the function name is short,
// and there's just one very short argument. What can I say, I do it too.
Function declarations: function names should begin at column 0 for a full
function definition. (It's ok to violate this rule for very short inline
functions within class definitions.)
Occasionally a file may contain substantial code from another project and will
also list its original copyright and license information. Do NOT alter that
notice or copy it to any new files, it really only applies to the particular
file in which it appears.
Here is a short code fragment that shows some of these rules in action:
### Formatting
static int
function (int a, int b)
{
int x = a + b;
if (a == 0 || b == 0) {
x += 1;
x *= 4;
} else {
x -= 3;
}
for (int i = 0; i < 3; ++i) {
x += a * i;
x *= foo (i); // function call
}
return x;
}
We use [clang-format](https://clang.llvm.org/docs/ClangFormat.html)
to uniformly format our source code prior to PR submission. Make sure that
clang-format is installed on your local machine, and just run
Don't ever reformat, re-indent, change whitespace, or make any other such
changes to working code. If you're adding just a few lines or fixing a bug
in existing code, stick to the style of the surrounding code. In very rare
circumstances, and with consensus of the group, reformatting is sometimes
helpful to improve code readability, but it should be done as a separate
formatting-only checkin.
make clang-format
#### Identifiers
and it will automatically reformat your code according to the configuration
file found in the `.clang-format` file at the root directory of the OIIO
source code checkout.
In general, classes and templates should start with upper case and capitalize new words:
One of the CI test matrix entries runs clang-format and fails if any
diffs were generated (that is, if any of your code did not 100% conform to
the `.clang-format` formatting configuration). If it fails, clicking on that
test log will show you the diffs generated, so that you can easily correct
it on your end and update the PR with the formatting fixes.
class CustomerList;
If you don't have clang-format set up on your machine, and your patch is not
very long, you may find that it's more convenient to just submit it and hope
for the best, and if it doesn't pass the CI test, look at the diffs in the log
for the "clang-format" CI run and make the corrections by hand and then submit
an update to the patch (i.e. relying on CI to run clang-format for you).
In general, local variables should start with lower case.
Because the basic formatting is automated by clang-format, we won't
enumerate the rules here.
For the occasional non-clang-format regions of code, NEVER alter somebody
else's code to reformat just because you found something that violates the
rules. Let the group/author/leader know, and resist the temptation to change
it yourself.
Each line of text in your code, including comments, should be at most 80
characters long. Exceptions are allowed for those rare cases where letting a
line be longer (and wrapping on an 80-character window) is actually a better
and clearer alternative than trying to split it into two lines. Sometimes this
happens, but it's extremely rare.
We prefer three (3) consecutive empty lines between freestanding functions or
class definitions, one blank line between method declarations within a class
definition. Put a single blank line within a function if it helps to visually
separate different sequential tasks, but don't put multiple blank lines in a
row within a function, or blank lines right after an opening brace or right
before a closing brace. The goal is to use just enough white space to help
developers visually parse the code (for example, spotting at a glance where
new functions begin), but not so much as to spread it out or be confusing.
### Identifiers
In general, classes and templates should start with upper case and
capitalize new words: `class CustomerList;` In general, local variables
should start with lower case. Macros should be `ALL_CAPS`, if used at all.
If your class is extremely similar to, or modeled after, something in the
standard library, Boost, or something else we interoperate with, it's ok to
@@ -238,13 +264,11 @@ were standards.
template <class T> shared_ptr;
class scoped_mutex;
Macros should be ALL_CAPS, if used at all.
Names of data should generally be nouns. Functions/methods are trickier: a
the name of a function that returns a value but has no side effects should
be a noun, but a procedure that performs an action should be a verb.
#### Class structure
### Class structure
Try to avoid public data members, although there are some classes that serve
a role similar to a simple C struct -- a very straightforward collection of
@@ -264,51 +288,46 @@ Avoid multiple inheritance.
Namespaces: yes, use them!
#### Third-party libraries
### Third-party libraries
Prefer C++11 `std` rather than Boost, where both can do the same task.
Feel free to use Boost classes you already see in the code base, but don't
use any Boost you don't see us already using, without first checking with
the project leader.
Please do use IlmBase vector, matrix, and utility classes where applicable.
Please do use Imath vector, matrix, and utility classes where applicable.
Don't write your own vector or matrix code!
Use these libraries for OIIO internals, but please DO NOT require them in
any of our main external APIs unless it's been thoroughly discussed and
approved by the group.
#### Comments and Doxygen
### Comments and Doxygen
Comment philosophy: try to be clear, try to help teach the reader what's
going on in your code.
Prefer C++ comments (starting line with `//`) rather than C comments (`/* ... */`).
For any function that may be used by other programmers (e.g., public or
protected members of classes), please use Doxygen-style comments. They looks
like this:
For public APIs we tend to use Doxygen-style comments (start with `///`).
They looks like this:
/// Explanation of a class. Note THREE slashes!
/// Also, you need at least two lines like this. If you don't have enough
/// for two lines, make one line blank like this:
///
class myclass {
....
float foo; ///< Doxygen comments on same line look like this
}
If you know Doxygen well, please feel free to use the various other markups.
But don't go so crazy with Doxygen markups that the comment itself, in an
ordinary editor, is not as readable as possible. The Doxygen-generated pages
are nice, but the place that needs to be most readable is in the code.
#### Miscellaneous
### Miscellaneous
Macros should be used only rarely -- prefer inline functions, templates,
enums, or "const" values wherever possible.
Prefer `std::unique_ptr` over raw new/delete.
#### Bottom Line
When in doubt, look elsewhere in the code base for examples of similar
structures and try to format your code in the same manner.
structures and try to format your code in the same manner, or ask on the
oiio-dev mail list.
+196 -131
View File
@@ -1,140 +1,205 @@
This is a list of all the authors of OpenImageIO. Any such list is very
inexact, and can't convey everybody's precise level of contribution (which
is constantly shifting, anyway). However, I've made two tiers: (1) major
developers who have contributed at least several hundred lines of code and
noting their main contributions, if easily identifiable; (2) everybody else
who has contributed any code at all. In both cases, I never remove anybody
from the list, even if over the years all their code is altered or removed.
This is a list of all the contributors to OpenImageIO, sorted alphabetically
by first name.
If you know of somebody that I missed or have corrections, please email:
lg@openimageio.org
Major contributors (roughly in order of joining the project):
* Larry Gritz : core classes & API, ImageCache/TextureSystem, iv,
TIFF, JPEG, OpenEXR, HDR, PNG, zfile, Field3D, docs
* Philip Nemec : original unit testing framework
* Dan Wexler : Windows port
* Chris Kulla : texture system improvements
* Chris Foster : lots of odds and ends, tinyformat, best code reviewer!
* Leszek Godlewski : ICO, Targa, DDS, DPX, Cineon, RLA
* David Gordon : build issues, Python bindings
* Robert Matusewicz : Windows port, BMP, JPEG-2000, FITS, SGI, WebP
* Ismael Cortes : iv improvements
* Dinko Galetik : Python bindings
* Malcolm Humphreys : color transfer methods
* Alan Jones : Softimage PIC
* Krzysztof Blicharski : sockets
* Nuno Cardoso : PNM
* Mikael Sundell : IFF, FFmpeg-based movie formats
* Jeremy Selan : Color space issues, maketx improvements, OpenColorIO
integration
* Daniel Wyatt : PSD
* Mariusz Szczepanczyk : GIF
* Mark Boorer : RAW
* Nathan Rusch : Nuke plugins
Other contributors (alphabetically):
* Vishal Agrawal
* David Aguilar
* Jeph Alapat
* Shane Ambler
* Basileios Anastasatos
* Cassian Andrei
* Dominik Bartkiewicz
* Heiko Becker
* Solomon Boulos
* John Burnett
* Nicolas Burtnyk
* Kevin Brightwell
* Fabien Castan
* Clément Champetier
* Duncan Chan
* Guillaume Chatelet
* Irena Damsky
* Brent Davis
* Ben De Luca
* Frédéric Devernay
* Thomas Dinges
* Chad Dombrova
* Seifeddine Dridi
* Nandan Dubey
* Sebastian Elsner
* Julien Enche
* Marcos Fajardo
* Delai Felinto
* Marie Fetiveau
* Henri Fousse
* Vitor Franchi
* Manuel Gamito
* Ananth Garre
* Alexandre Gauthier
* Deepak Gopinath
* John Haddon
* Brian Hall
* Jep Hill
* Changlin Hsieh
* Justin Israel
* Thiago Ize
* Puneet Jain
* Saket Jalan
* Pavel Karneliuk
* Vinod Khare
* Konrad Kleine
* Alexander Kuleshov
* Nixon Kwok
* Pete Larabell
* Michel Lerenard
* Manuel Leonhardt
* Matthew E. Levine
* Rui Li
* Elvic Liang
* Max Liani
* Hugh Macdonald
* Lukasz Maliszewski
* Justina Mikonyte
* Paul Molodowitch
* Bastien Montagne
* Ramon Montoya
* Gregor Mueckl
* Alexander Murashko
* Hanspeter Niederstrasser
* Samuel Nicholas
* Michel Normand
* Alexis Oblet
* Leonid Onokhov
* Lucas Panian
* M Joonas Pihlaja
* Morteza Ramezanali
* Carl Rand
* Sam Richards
* Mike Root
* Jeremy Rose
* Will Rosecrans
* Ryen
* Lukas Schrangl
* Adam Mains
* Akihiro Yamasaki
* Alan Jones
* Alejandro Conty
* Alex Hughes
* Alex Schworer
* Alexander Kuleshov
* Alexander Murashko
* Alexandre Gauthier
* Alexis Oblet
* Alexy Pawlow
* Alister Chowdhury
* Aman Shah
* Sergey Sharybin
* Richard Shaw
* Tim D. Smith
* Troy James Sobotka
* Stefan Stavrev
* Cliff Stein
* Mariusz Szczepanczyk
* Ananth Garre
* Anders Langlands
* Angus Davis
* Anthony Nemoff
* Aras Pranckevičius
* Arkady Shapkin
* Basileios Anastasatos
* Bastien Montagne
* Ben De Luca
* Bernhard Rosenkraenzer
* Biswapriyo Nath
* Blair Tennessy
* Ott Tinn
* Edgar Velazquez-Armendariz
* Ghislain Antony Vaillant
* Matteo F. Vescovi
* Mark Visser
* Blazej Floch
* Brad Smith
* Brecht Van Lommel
* Brent Davis
* Brian Hall
* Brice Gros
* Carl Rand
* Cassian Andrei
* Chad Dombrova
* Changlin Hsieh
* Chris Crosetto
* Chris Foster
* Chris Kulla
* Chris Whalen
* Christoph Willing
* Cliff Stein
* Clément Champetier
* Dalai Felinto
* Dan Wexler
* Daniel Dresser
* Daniel Flehner Heen
* Daniel Wyatt
* David Aguilar
* David Gordon
* Deepak Gopinath
* Dennis Schridde
* Dieter De Baets
* Dinko Galetik
* Dominik Bartkiewicz
* Duncan Chan
* Dustin Rodrigues
* Edgar Velazquez-Armendariz
* Eloi Du Bois
* Elvic Liang
* Fabien Castan
* Fabien Servant
* Fredrik Averpil
* Frédéric Devernay
* Gaurav Bansal
* Gerdya
* Ghislain Antony Vaillant
* Gonzalo Garramuño
* Gregor Mueckl
* Grégoire De Lillo
* Guillaume Chatelet
* Hanspeter Niederstrasser
* Harry Mallon
* Heiko Becker
* Henri Fousse
* Hugh Macdonald
* Imarz
* Irena Damsky
* Ismael Cortes
* Jan Hettenkofer
* Jan Honsbrok
* Jens Lindgren
* Jep Hill
* Jeph Alapat
* Jeremy Rose
* Jeremy Selan
* Jim Hourihan
* Joachim Reichel
* Johannes Unterguggenberger
* John Burnett
* John Fea
* John Haddon
* Jonathan Hearn
* Jonathan Scruggs
* Joris Nijs
* Joseph Goldstone
* Julien Enche
* Justin Israel
* Justina Mikonyte
* Kazuki Takahashi
* Kevin Brightwell
* Kimball Thurston
* Konrad Kleine
* Krzysztof Blicharski
* Larry Gritz (project leader)
* LazyDodo
* Leonid Onokhov
* Leszek Godlewski
* Lucas Panian
* Lucille Caillaud
* Lukas Schrangl
* Lukasz Maliszewski
* Luke Emrose
* M Joonas Pihlaja
* Malcolm Humphreys
* Manuel Gamito
* Manuel Leonhardt
* Marcos Fajardo
* Marie Fetiveau
* Mariusz Szczepanczyk
* Mark Boorer
* Mark Visser
* Massimo Paladin
* Matteo F. Vescovi
* Matthew E. Levine
* Max Liani
* Merwan Achibet
* Michael Cho
* Michael Oliver
* Michel Lerenard
* Michel Normand
* Mikael Sundell
* Mike Root
* Morteza Ramezanali
* Nandan Dubey
* Nathan Rusch
* Nicholas Yue
* Nick Black
* Nicolas Burtnyk
* Nixon Kwok
* Noah Rahm (designer of our logo!)
* Northon Patrick
* Nuno Cardoso
* Ole Gulbrandsen
* Ott Tinn
* Pascal Lecocq
* Patrick Hodoul
* Patrick Piché
* Paul Melis
* Paul Molodowitch
* Pavel Karneliuk
* Pete Larabell
* Philip Nemec
* Pino Toscano
* Povilas Kanapickas
* Puneet Jain
* Radu Arjocu
* Ramon Montoya
* Ray Molenkamp
* Rémi Achard
* Richard Shaw
* Robert Matusewicz
* Roeland Schoukens
* Roman Zulak
* Rui Li
* Russell Greene
* Ryen
* Saket Jalan
* Sam Richards
* Samuel Nicholas
* Scott Wilson
* Sebastian Elsner
* SebTV
* Seifeddine Dridi
* Sergey Sharybin
* Shane Ambler
* Simon Boorer
* Solomon Boulos
* SRHMorris
* Stefan Bruens
* Stefan Stavrev
* Thiago Ize
* Thomas Dinges
* Thomas Mansencal
* Till Dechent
* Tim D. Smith
* Tim Grant
* Tom Knowles
* Troy James Sobotka
* Vinod Khare
* Vishal Agrawal
* Vitor Franchi
* Wayne Arnold
* Will Rosecrans
* William Krick
* Wormszer
* Xo Wang
* Christoph Willing
* Scott Wilson
* Yang Yang
* Nicholas Yue
If you know of somebody that I missed, please let me know:
lg (at) openimageio.org
* Yann Lanthony
* zomgrolf
+215
View File
@@ -0,0 +1,215 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the OpenImageIO Project. -->
# OpenImageIO Project Governance
OpenImageIO is a project of the Academy Software Foundation and relies on the
ASWF governance policies, supported by the Linux Foundation.
There are three primary project roles: Contributors submit code to the
project; Committers approve code to be included into the project; and the
Technical Steering Committee (TSC) provides overall high-level project
guidance.
* [Contributors](#Contributors)
* [Committers](#Committers)
* [Technical Steering Committee](#Technical-Steering-Committee)
## Contributors
The OpenImageIO project grows and thrives from assistance from Contributors.
Contributors include anyone in the community who contributes code,
documentation, or other technical artifacts that have been incorporated into
the project repository.
Anyone can be a Contributor. You need no formal approval from the project,
beyond the legal forms.
### How to Become a Contributor
* Review the coding standards and [contributing
guidelines](../CONTRIBUTING.md) to ensure your contribution is in line with
the project's coding and styling guidelines.
* Sign the Individual CLA, or if you are employed by an organization that
might have any claim to IP you create, have your organization sign the
Corporate CLA.
* Submit your code as a PR with the appropriate DCO sign-off on each commit.
The easiest way to do this is to ensure that you commit your code with `git
commit -s`.
## Committers
Project Committers have merge access on the OpenImageIO GitHub repository
and are responsible for approving submissions by Contributors.
### Committer Responsibilities
Typical activities of a Committer include:
* Helping users and novice contributors.
* Ensuring a response to questions posted to the
[Oiio-dev developer mail list](https://lists.aswf.io/g/oiio-dev)
* Contributing code and documentation changes that improve the project.
* Reviewing and commenting on issues and pull requests.
* Ensuring that changes and new code meet acceptable standards and are in
the long-term interest of the project.
* Participation in working groups.
* Merging pull requests.
### How to Become a Committer
Any member of the OpenImageIO community (though typically an existing
Committer or TSC member) may nominate an individual making significant and
valuable contributions to the OpenImageIO project to become a new Committer.
To nominate a new Committer, open an issue in the OpenImageIO repository, send
mail to the TSC mail list, or raise the issue at a TSC meeting.
The TSC may periodically review the Committer list to identify inactive
Committers. Past Committers are typically given Emeritus status. Emeriti may
request that the TSC restore them to active Committer status.
## Technical Steering Committee
The Technical Steering Committee (TSC) has final authority over this project.
As defined in the project charter, in addition to committer activities, TSC
responsibilities also include, but are not limited to:
* Coordinating technical direction of the Project.
* Project governance and contribution policy.
* GitHub repository administration.
* Maintaining the list of additional Committers
* Appointing representatives to work with other open source or open
standards communities.
* Discussions, seeking consensus, and where necessary, voting on technical
matters relating to the code base that affect multiple projects.
* Coordinating any marketing, events, or communications regarding the
project.
Within the TSC are two elected leadership roles to be held by its members
and voted on annually. Any TSC member can express interest in serving in a
role, or nominate another member to serve. There are no term limits, and one
person may hold multiple roles simultaneously. Should a TSC member resign
from a leadership role before their term is complete, a successor shall be
elected through the standard nomination and voting process to complete the
remainder of the term. The leadership roles are:
* **Chair**: This position acts as the project manager, organizing meetings
and providing oversight to project administration.
* **Chief Architect**: This position makes all the final calls on design and
technical decisions, and is responsible for avoiding "design by committee"
pitfalls.
The chair role is assumed to rotate annually (though there are no term
limits, so the TSC may reelect an existing chair). The chief architect
position should be a source of stability and coherent design vision, so the
TSC is encouraged to choose an architect who can serve for many years and
only change architects when it is necessary for the health of the project
and its community.
At the time of election, the TSC will also agree upon which of these two
leaders will serve as the OpenImageIO ASWF (Academy Software Foundation) TAC
(Technical Advisory Council) representative for the term. This member
represents the project at all ASWF TAC meetings.
### TSC Members
Current voting members of the TSC are:
* **Chair and TAC representative**: Daniel Greenstein - Sony Pictures Imageworks (possibly interim?)
* **Chief Architect**: Larry Gritz - Sony Pictures Imageworks
* Anton Dukhovnikov - Wētā Digital / Unity
* Jesse Yurkovich - Blender
* Joseph Goldstone - ARRI
* Lewis Wakeland - Disney TV Animation
* Luke Emrose - Animal Logic (interim?)
* Martin Davies - LAIKA
* Robin Rowe - Heroic Robots
* Thiago Ize - Autodesk
### TSC Nomination and Succession
Any proposal for additional members of the TSC may be submitted by Committers,
TSC members, or other major stakeholders of the OpenImageIO community by
opening an issue outlining their case or raising the issue at a TSC meeting.
New TSC members are accepted or rejected by majority vote of the TSC.
If a TSC member is for an extended period not regularly participating or
performing the responsibilities expected of TSC members, the TSC may by
majority vote request an alternate TSC member be submitted by that
organization, or remove the inactive member from the TSC.
A voting member of the TSC may nominate a successor in the event that such
voting member decides to leave the TSC, and the TSC, including the departing
member, shall confirm or reject such nomination by a vote. In the event that
the departing member's nomination for successor is rejected by vote of the
TSC, the departing member shall be entitled to continue nominating successors
until one such successor is confirmed by vote of the TSC. If the departing
member fails or is unable to nominate a successor, the TSC may nominate one on
the departing member's behalf.
TSC membership is presumed to be retained by the individual even if they
change employers, provided they remain active in the project. The TSC may take
action to ensure that organizational stakeholder representation not become
severely disproportionate, for example by urging an organization that loses
its sole TSC representative to nominate a new member, or by limiting the total
number of voting members from any one organization if too many members all
move to the same organization.
### TSC Meetings
Any meetings of the TSC are intended to be open to the public, except where
there is a reasonable need for privacy. The TSC meets regularly in a voice
conference call, at a cadence deemed appropriate by the TSC. The TSC Chair
moderates the meeting, or appoints another TSC member to moderate in his or
her absence. Meetings may also be streamed online where appropriate;
connection details will be posted to the oiio-dev mail list in advance of the
scheduled meeting.
The biweekly TSC meetings can be found on the [ASWF Calendar](https://www.aswf.io/meeting-calendar),
just click on the OpenImageIO meeting entries to get the Zoom link.
Items are added to the TSC agenda which are considered contentious or are
modifications of governance, contribution policy, TSC membership, or release
process, in addition to topics involving the high-level technical direction
of the project.
The intention of the agenda is not to approve or review all patches. That
should happen continuously on GitHub and be handled by the larger group of
Committers.
Any community member or Contributor can ask that something be reviewed by
the TSC at the meeting by logging a GitHub issue. Any Committer, TSC member,
or the meeting chair can bring the issue to the TSC's attention by applying
the `TSC` label.
Prior to each TSC meeting, the meeting chair will share the agenda with
members of the TSC. TSC members can also add items to the agenda at the
beginning of each meeting. The meeting chair and the TSC cannot veto or
remove items.
The TSC may invite additional persons to participate in a non-voting
capacity.
The meeting chair is responsible for ensuring that minutes are taken and
archived in the project repository or other designated accessible location.
Due to the challenges of scheduling a global meeting with participants in
several time zones, the TSC will seek to resolve as many agenda items as
possible outside of meetings on the public mailing list or through GitHub
issues, discussions, and pull requests.
+279 -118
View File
@@ -1,10 +1,84 @@
Installation instructions for OpenImageIO
=========================================
For the most up-to-date build instructions (and in any case somewhat
more detailed than here), please see our wiki:
# Table of Contents
1. [OpenImageIO's Dependencies](#dependencies)
2. [Installing binaries from package managers](#installing-from-package-managers)
3. [Building OIIO from source](#building-from-source)
Dependencies
------------
NEW or CHANGED MINIMUM dependencies since the last major release are **bold**.
### Required dependencies -- OIIO will not build at all without these
* C++14 (also builds with C++17, and C++20)
* The default build mode is C++14. This can be controlled by via the
CMake configuration flag: `-DCMAKE_CXX_STANDARD=17`, etc.
* Compilers: gcc 6.1 - 12.1, clang 3.4 - 16, MSVS 2017 - 2019,
Intel icc 17+, **Intel OneAPI C++ compiler 2022+**.
* CMake >= 3.12 (tested through 3.26)
* **OpenEXR/Imath >= 2.3** (recommended: 2.4 or higher; tested through 3.2 and main)
* libTIFF >= 3.9 (recommended: 4.0+; tested through 4.5)
* libjpeg >= 8, or libjpeg-turbo >= 1.1 (tested through jpeg9d and jpeg-turbo
2.1)
* Boost >= 1.53 (recommended: at least 1.66; tested through 1.81)
* [fmtlib](https://github.com/fmtlib/fmt) >= 6.1.2 (tested through 10.0). If
not found at build time, this will be automatically downloaded unless the
build sets `-DBUILD_MISSING_FMT=OFF`.
### Optional dependencies -- features may be disabled if not found
* If you are building the `iv` viewer (which will be disabled if any of
these are not found):
* Qt5 >= 5.6 (tested through 5.15) or Qt6 (tested through 6.4)
* OpenGL
* If you are building the Python bindings or running the testsuite:
* Python >= 2.7 (tested against 2.7, 3.7, 3.8, 3.9, 3.10, 3.11)
* pybind11 >= 2.4.2 (Tested through 2.11. Note that pybind11 v2.10+ does
not support Python < 3.6.)
* NumPy
* If you want support for camera "RAW" formats:
* LibRaw >= 0.15 (tested 0.15 - 0.21.1; LibRaw >= 0.18 is necessary for
ACES support and much better recognition of camera metadata; if
building with C++17 or higher, LibRaw >= 0.20 is necessary)
* If you want support for a wide variety of video formats:
* ffmpeg >= 3.0 (tested through 6.0)
* If you want support for jpeg 2000 images:
* OpenJpeg >= 2.0 (tested through 2.5; we recommend 2.4 or higher
for multithreading support)
* If you want support for OpenVDB files:
* OpenVDB >= 5.0 (tested through 10.0)
* If you want to use TBB as the thread pool:
* TBB >= 2018 (tested through 2021 and OneTBB)
* If you want support for converting to and from OpenCV data structures,
or for capturing images from a camera:
* OpenCV 3.x, or 4.x (tested through 4.5)
* If you want support for GIF images:
* giflib >= 4.1 (tested through 5.2; 5.0+ is strongly recommended for
stability and thread safety)
* If you want support for HEIF/HEIC or AVIF images:
* libheif >= 1.3 (1.7 required for AVIF support, tested through 1.16)
* libheif must be built with an AV1 encoder/decoder for AVIF support.
* Avoid libheif 1.10 on Mac, it is very broken. Libheif 1.11+ is fine.
* If you want support for DICOM medical image files:
* DCMTK >= 3.6.1 (tested through 3.6.7)
* If you want support for WebP images:
* WebP >= 0.6.1 (tested through 1.3.1)
* If you want support for OpenColorIO color transformations:
* OpenColorIO >= 1.1 (tested through 2.3; 2.0+ is recommended)
* If you want support for Ptex:
* Ptex >= 2.3.1 (probably works for older; tested through 2.4.2)
* If you want to be able to do font rendering into images:
* Freetype (minimum unknown, tested 2.8 through 2.13)
* We use PugiXML for XML parsing. There is a version embedded in the OIIO
tree, but if you want to use an external, system-installed version (as
may be required by some software distributions with policies against
embedding other projects), then just build with `-DUSE_EXTERNAL_PUGIXML=1`.
Any PugiXML >= 1.8 should be fine (we have tested through 1.13).
https://sites.google.com/site/openimageio/checking-out-and-building-openimageio
Supported platforms at present include Linux (32 and 64 bit),
Mac OS X, and Windows.
@@ -12,21 +86,104 @@ Mac OS X, and Windows.
Our build system is based upon 'CMake'. If you don't already have it
installed on your system, you can get it from http://www.cmake.org
After you build OpenImageIO, if you compiled with the EMBEDPLUGINS=0 flag
you will need to set the environment variable OIIO_LIBRARY_PATH to point
If certain dependencies (robin-map and fmtlib) are not found, their sources
will be retrieved and built into libraries, as part of the build process. The
sources of those dependencies are cloned from their Git repo, hence `git` must
be available as a command.
After you build OpenImageIO, if you compiled with the `EMBEDPLUGINS=0` flag
you will need to set the environment variable `OIIO_LIBRARY_PATH` to point
to the 'lib' directory where OpenImageIO is installed, or else it will
not be able to find the plugins.
Installing from package managers
================================
If all you want to do is install the OIIO libraries, headers, and command
line tools as quickly as possible (don't need OIIO source or any custom
build options), maybe one of these packages managers will do it for you:
* vcpkg (https://github.com/Microsoft/vcpkg)
* https://github.com/Microsoft/vcpkg/tree/master/ports/openimageio
* `vcpkg install openimageio [tools]`
* For a full list of supported build features: `vcpkg search openimageio`
* Instructions for building a Python wheel on Windows:
https://github.com/Correct-Syntax/py-oiio
* homebrew (https://github.com/Homebrew/brew)
* https://formulae.brew.sh/formula/openimageio
* `brew install openimageio`
* macports (https://github.com/macports/macports-ports)
* https://www.macports.org/ports.php?by=name&substr=openimageio
* `port install openimageio`
* fink (https://github.com/fink/fink)
* http://pdb.finkproject.org/pdb/package.php/libopenimageio2.1-shlibs
* `fink install openimageio`
* conan (https://github.com/conan-io/conan)
If these work for you and it's all you need, bingo! You are done.
Building from source
====================
Dependency control and disabling components
-------------------------------------------
**Hints for finding dependencies**
For each external dependency PkgName, our CMake build system will recognize
the following optional variable:
PkgName_ROOT=...
to specify a hint about where the package is installed. It can either be
a CMake variable (set by `-DPkgName_ROOT=...` on the CMake command line),
or an environment variable of the same name, or a variable setting on the
Make wrapper (`make PkgName_ROOT=...`).
**Disabling optional dependencies and individual components**
`USE_PYTHON=0` : Omits building the Python bindings.
`OIIO_BUILD_TESTS=0` : Omits building tests (you probably don't need them
unless you are a developer of OIIO or want to verify that your build
passes all tests).
`OIIO_BUILD_TOOLS=0` : Disables building all the command line tools (such
as iinfo, oiiotool, maketx, etc.).
`ENABLE_toolname=0` : Disables building the named command line tool (iinfo,
oiiotool, etc.). This works both as a CMake variable and also as an
environment variable.
`ENABLE_formatname=0` : Disables building support for the particular named
file format (jpeg, fits, png, etc.). This works both as a CMake variable and
also as an environment variable.
`ENABLE_PkgName=0` : Disables use of an *optional* dependency (such as
FFmpeg, OpenVDB, Webp, etc.) -- even if the dependency is found on the
system. This will obviously disable any functionality that requires the
dependency. This works both as a CMake variable and
also as an environment variable.
Building OpenImageIO on Linux or OS X
-------------------------------------
The following dependencies must be installed to build the core of
OpenImageIO: Boost, libjpeg, libtiff, libpng and OpenEXR. These can be
installed using the standard package managers on your system.
Optionally, to build the image viewing tools, you will need Qt, OpenGL,
and GLEW.
OpenImageIO:
* Boost
* libjpeg
* libtiff
* libpng
* OpenEXR.
These can be installed using the standard package managers on your system.
Optionally, to build the image viewing tools, you will need Qt and OpenGL.
On OS X, these dependencies can be installed using Fink, MacPorts or
Homebrew. After installation of any of these package installers, use
@@ -47,46 +204,44 @@ directories must notify the CMake system using environment variables.
For example, set QTDIR to point at the root of the Qt library location
so that CMake can find it (see CMake configuration output).
On Linux and OS X, you can build from source from the top-level
**On Linux and OS X, you can build from source from the top-level
directory by just typing 'make'. (Yes, we have a 'make' wrapper around
our CMake build, it simplifies things.)
our CMake build, it simplifies things.)**
During the make, various temporary files (object files, etc.) will
be put in build/PLATFORM, where 'PLATFORM' will be the name of the
platform you are building for (e.g., linux, linux64, macosx).
The result of the make will be a full binary distribution in
The result of the make will be a full binary distribution in
dist/PLATFORM.
Make targets you should know about:
| Target | Command |
| ------------------- | -------------------------------------------------- |
| make | Build an optimized distro in dist/PLATFORM, with temp files created while building in build/PLATFORM.
| make debug | Build a debugging (symbols, not stripped) distro, will end up in dist/PLATFORM.debug
| make clean | Get rid of all the temporary files in build/PLATFORM
| make realclean | Get rid of both build/PLATFORM and dist/PLATFORM
| make nuke | Get rid of all build/ and dist/, for all platforms
| make profile | Build a profilable version dist/PLATFORM.profile
| make doxygen | Build the Doxygen docs
| make help | Print all the make options
| Target | Command |
| ----------------- | -------------------------------------------------- |
| make | Build an optimized distro in dist/PLATFORM, with temp files created while building in build/PLATFORM. |
| make debug | Build a debugging (symbols, not stripped) distro, will end up in dist/PLATFORM.debug |
| make clean | Get rid of all the temporary files in build/PLATFORM |
| make realclean | Get rid of both build/PLATFORM and dist/PLATFORM |
| make nuke | Get rid of all build/ and dist/, for all platforms |
| make profile | Build a profilable version dist/PLATFORM.profile |
| make help | Print all the make options |
Additionally, a few helpful modifiers alter some build-time options:
| Target | Command |
| :------------------ | -------------------------------------------------- |
| make VERBOSE=1 ... | Show all compilation commands
| make STOP_ON_WARNING=0 | Do not stop building if compiler warns
| make EMBEDPLUGINS=0 ... | Don't compile the plugins into libOpenImageIO
| make USE_OPENGL=0 ... | Skip anything that needs OpenGL
| make USE_QT=0 ... | Skip anything that needs Qt
| make MYCC=xx MYCXX=yy ... | Use custom compilers
| make FORCE_OPENGL_1=1 ... | Force iv to use OpenGL's fixed pipeline
| make USE_PYTHON=0 ... | Don't build the Python binding
| make BUILDSTATIC=1 ... | Build static library instead of shared
| make LINKSTATIC=1 ... | Link with static external libraries when possible
| make SOVERSION=nn ... | Include the specifed major version number in the shared object metadata
| make NAMESPACE=name | Wrap everything in another namespace
| Target | Command |
| ------------------------- | ---------------------------------------------- |
| make VERBOSE=1 ... | Show all compilation commands |
| make STOP_ON_WARNING=0 | Do not stop building if compiler warns |
| make EMBEDPLUGINS=0 ... | Don't compile the plugins into libOpenImageIO |
| make USE_OPENGL=0 ... | Skip anything that needs OpenGL |
| make USE_QT=0 ... | Skip anything that needs Qt |
| make MYCC=xx MYCXX=yy ... | Use custom compilers |
| make USE_PYTHON=0 ... | Don't build the Python binding |
| make BUILD_SHARED_LIBS=0 | Build static library instead of shared |
| make LINKSTATIC=1 ... | Link with static external libraries when possible |
| make SOVERSION=nn ... | Include the specified major version number in the shared object metadata |
| make NAMESPACE=name | Wrap everything in another namespace |
The command 'make help' will list all possible options.
@@ -97,7 +252,7 @@ CMake directly:
cd build
cmake ..
If the compile stops because of warnings, try again with
If the compile stops because of warnings, try again with
make nuke
make STOP_ON_WARNING=0
@@ -113,104 +268,110 @@ or, if you are using CMake directly,
Building on Windows
-------------------
See the latest Windows build docs on our web site:
https://sites.google.com/site/openimageio/building-oiio-on-windows
**Method 1 - from source**
1. Check out the trunk or a branch of your choice. The remainder of
these instructions assume that you checked out the trunk to the
D:\OIIO\trunk directory.
You will need to have Git, CMake and Visual Studio installed.
2. Download the package with precompiled external libraries from
http://www.openimageio.org/external.zip
The minimal set of dependencies for OIIO is: Boost, zlib, libTIFF, OpenEXR, and libjpeg or libjpeg-turbo. If you have them built somewhere then you skip
the section below, and will only have to point OIIO build process so their locations.
Next, unpack it. The directory with downloaded code from the repository
and the directory with unpacked libraries should be siblings. For example,
* Boost: get the boost source archive, extract into `{BOOST_ROOT}`.
```
cd {BOOST_ROOT}
bootstrap
b2
```
* zlib: this will build it, and then delete the non-static library, so they don't get picked up:
```
cd {ZLIB_ROOT}
git clone https://github.com/madler/zlib .
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=. ..
cmake --build . --config Release --target install
del lib\zlib.lib
```
* libTIFF:
```
cd {TIFF_ROOT}
git clone https://gitlab.com/libtiff/libtiff.git .
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=. ..
cmake --build . --target install
```
* libjpeg-turbo:
```
cd {JPEG_ROOT}
git clone https://github.com/libjpeg-turbo/libjpeg-turbo .
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_SHARED=OFF -DCMAKE_INSTALL_PREFIX=. ..
cmake --build . --config Release --target install
```
* OpenEXR: you'll have to point it to your `{ZLIB_ROOT}` location from the above. If copy-pasting the multi-line command (with lines ending in `^`) into
cmd.exe prompt, make sure to copy all the lines at once.
```
cd {EXR_ROOT}
git clone https://github.com/AcademySoftwareFoundation/openexr .
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=dist ^
-DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DOPENEXR_BUILD_TOOLS=OFF ^
-DOPENEXR_INSTALL_TOOLS=OFF -DOPENEXR_INSTALL_EXAMPLES=OFF ^
-DZLIB_ROOT={ZLIB_ROOT}\build ..
cmake --build . --target install --config Release
```
```
D:
\OIIO
\trunk // this is my tree
\src // directory with src files for OIIO
\build // directory that is created by cmake
\external // this is extracted external package
\dist
\windows
\glew-1.5.1
\ilmbase-1.0.1
\jpeg-6b
\libpng-1.2.3
\openexr-1.6.1
\tbb-21_20080605oss
\zlib-1.2.3
\tiff-3.8.2
```
Now get the OIIO source and do one-time CMake configuration step. Replace `{*_ROOT}` below with folders where you have put the 3rd party
dependencies.
```
cd {OIIO_ROOT}
git clone https://github.com/OpenImageIO/oiio .
mkdir build
cd build
cmake -DVERBOSE=ON -DCMAKE_BUILD_TYPE=Release ^
-DBoost_USE_STATIC_LIBS=ON -DBoost_NO_WARN_NEW_VERSIONS=ON -DBoost_ROOT={BOOST_ROOT} ^
-DZLIB_ROOT={ZLIB_ROOT}\build ^
-DTIFF_ROOT={TIFF_ROOT}\build ^
-DOpenEXR_ROOT={EXR_ROOT}\build\dist ^
-DImath_DIR={EXR_ROOT}\build\dist\lib\cmake\Imath ^
-DJPEG_ROOT={JPEG_ROOT}\build ^
-DUSE_PYTHON=0 -DUSE_QT=0 -DBUILD_SHARED_LIBS=0 -DLINKSTATIC=1 ..
```
3. Download precompiled Qt4 binaries for Windows from here:
http://qt.windows.binaries.googlepages.com/index.html
This will produce `{OIIO_ROOT}/build/OpenImageIO.sln` that can be opened in Visual Studio IDE. Note that the solution will be
only for the Intel x64 architecture only; and will only target "min-spec" (SSE2) SIMD instruction set.
Unpack it (it doesn't matter where). After unpacking, add the path to
the Qt bin directory to the PATH variable. For example, if you unpacked
this package to the D:\qt-win directory, you should add D:\qt-win\bin to
your PATH. It's important to add the Qt bin directory to PATH because
the FindQt4 module uses it to search for qmake applications.
Optional packages that OIIO can use (e.g. libpng, Qt) can be build and pointed to OIIO build process in a similar way.
4. Also, just to be safe, add QTDIR to the environment variables. It
should point to directory where you unpacked Qt.
In Visual Studio, open `{OIIO_ROOT}/build/OpenImageIO.sln` and pick Release build configuration. If you pick Debug, you
might need to re-run the CMake command above with `-DCMAKE_BUILD_TYPE=Debug` and also have all the dependencies above built
with `Debug` config too.
5. Download precompiled BOOST 1.53 or newer libraries from
http://www.boostpro.com/download
The main project that builds the library is `OpenImageIO`. The library is built into `{OIIO_ROOT}/build/lib/{CONFIG}` folder.
The various OIIO command line tools (`oiiotool`, `iconvert` etc.) are projects under Tools subfolder in VS IDE solution explorer.
They all build into `{OIIO_ROOT}/build/bin/{CONFIG}` folder.
Install it on your system. Choose two versions: Multithread Debug, DLL
and Multithread, DLL for Your Visual Studio version.
There's a `CMakePredefinedTargets/INSTALL` project that you can build to produce a `{OIIO_ROOT}/dist` folder with `bin`, `include`,
`lib`, `share` folders as an OIIO distribution.
6. Download precompiled BOOST 1.53 or newer libraries from here (unfficial
mirror) or from here (unofficial mirror, registration required). Install
it on Your system. Choose two versions: Multithread Debug, DLL and
Multithread, DLL for Your Visual Studio version.
7. Install cmake. You can download precompiled binaries from here:
http://www.cmake.org/cmake/resources/software.html
After installing, run cmake-gui. Set the field that specifies the source
code location (for example, to D:\OIIO\trunk\src). Then set the field
that specifies where to build binaries to the directory you want to
build project for OIIO (for example, D:\OIIO\trunk\build).
8. Set the THIRD_PARTY_TOOLS_HOME environment variable to the directory
where are stored unpacked external libraries (for example,
D:\OIIO\external\dist\windows). You can add variables by clicking Add
entry button.
9. Hit the Configure button. Cmake should automatically find externals
libraries and prepare the environment for creating the OIIO project. If
the configuration process ends without errors go to next step. If not,
read the instructions from the end of this tutorial.
10. Hit the Generate button. Cmake will build Visual Studio a solution in
the build directory.
11. That's all. You can open the OpenImageIO solution and start developing
OIIO! Potential problems:
The instructions above use options for building statically-linked OIIO library and tools. Adjust options passed to CMake to
produce a dynamic-linked version.
It may happen that cmake won't find zlib, png, tiff or jpeg
libraries. If so you have to set CMAKE_PREFIX_PATH to point to the
directory where the missing libraries are stored. For example, if cmake
can't find ZLIB, add to CMAKE_PREFIX_PATH the
D:\OIIO\external\dist\windows\zlib-1.2.3 directory. If it can't find
ZLIB and PNG, add
D:\OIIO\external\dist\windows\zlib-1.2.3;D:\OIIO\external\dist\windows\libpng-1.2.3.
**Method 2 - Using vcpkg**
Also, if cmake won't find GLEW set up GLEW_INCLUDES and GLEW_LIBRARIES
in cmake-gui. Don't add them (they are already added), just set them.
1. Visit Microsoft's vcpkg GitHub page: https://github.com/Microsoft/vcpkg. Also note that the openimageio package is located here: https://github.com/Microsoft/vcpkg/tree/master/ports/openimageio
2. Follow vcpkg installation instructions and complete the install. Please note vcpkg has its own list of prerequisites listed on their page.
3. Execute the PowerShell command from where vcpkg is located in directory. ``vcpkg install openimageio``
Test Images
-----------
We have yet another SVN project just for containing a set of sample
images for testing OpenImageIO. We split test images into a separate
SVN project in order to make the main source code tree smaller and
simpler for people who don't need the test suite.
We have yet another project containing a set of sample images for testing
OpenImageIO. We split test images into a separate project in order to make
the main source code tree smaller and simpler for people who don't need the
test suite.
git clone https://github.com/OpenImageIO/oiio-images.git
@@ -218,7 +379,7 @@ Also, there are collections of images for some of the file formats we
support, and make test expects them to also be present. To run full tests,
you will need to download and unpack the test image collections from:
* http://www.remotesensing.org/libtiff/images.html
* http://www.simplesystems.org/libtiff/images.html
* http://www.openexr.com/downloads.html
* http://www.itu.int/net/ITU-T/sigdb/speimage/ImageForm-s.aspx?val=10100803
* http://www.cv.nrao.edu/fits/data/tests/
-30
View File
@@ -1,30 +0,0 @@
OpenImageIO and all code, documentation, and other materials contained
therein are:
Copyright 2008-2016 Larry Gritz et al. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the software's owners nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
(This is the Modified BSD License)
+27
View File
@@ -0,0 +1,27 @@
Copyright (c) 2008-present by Contributors to the OpenImageIO project.
All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+201
View File
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+161 -224
View File
@@ -2,51 +2,45 @@
#
# This is the master makefile.
# Here we put all the top-level make targets, platform-independent
# rules, etc.
# rules, etc. This is just a fancy wrapper around cmake, but for many
# people, it's a lot simpler to just type "make" and have everything
# happen automatically.
#
# Run 'make help' to list helpful targets.
#
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: BSD-3-Clause and Apache-2.0
# https://github.com/OpenImageIO/oiio
#########################################################################
.PHONY: all debug profile clean realclean nuke doxygen
working_dir := ${shell pwd}
INSTALLDIR =${working_dir}
# Figure out which architecture we're on
include ${working_dir}/src/make/detectplatform.mk
# Presence of make variables DEBUG and PROFILE cause us to make special
# builds, which we put in their own areas.
ifdef DEBUG
variant +=.debug
endif
ifdef PROFILE
variant +=.profile
endif
MY_MAKE_FLAGS ?=
MY_NINJA_FLAGS ?=
MY_CMAKE_FLAGS += -g3 -DSELF_CONTAINED_INSTALL_TREE:BOOL=TRUE
MY_CMAKE_FLAGS ?=
BUILDSENTINEL ?= Makefile
NINJA ?= ninja
CMAKE ?= cmake
CMAKE_BUILD_TYPE ?= Release
# Site-specific build instructions
ifndef OPENIMAGEIO_SITE
OPENIMAGEIO_SITE := ${shell uname -n}
endif
ifneq (${shell echo ${OPENIMAGEIO_SITE} | grep imageworks},)
OPENIMAGEIO_SITE ?= ${shell uname -n}
ifneq (${shell echo ${OPENIMAGEIO_SITE} | grep imageworks.com},)
include ${working_dir}/site/spi/Makefile-bits
endif
# Set up variables holding the names of platform-dependent directories --
# set these after evaluating site-specific instructions
top_build_dir := build
build_dir := ${top_build_dir}/${platform}${variant}
top_dist_dir := dist
dist_dir := ${top_dist_dir}/${platform}${variant}
build_dir ?= build
dist_dir ?= dist
INSTALL_PREFIX ?= ${working_dir}/${dist_dir}
VERBOSE ?= ${SHOWCOMMANDS}
ifneq (${VERBOSE},)
@@ -58,25 +52,13 @@ ifneq (${VERBOSE},0)
endif
$(info OPENIMAGEIO_SITE = ${OPENIMAGEIO_SITE})
$(info dist_dir = ${dist_dir})
$(info INSTALLDIR = ${INSTALLDIR})
$(info INSTALL_PREFIX = ${INSTALL_PREFIX})
endif
ifneq (${EMBEDPLUGINS},)
MY_CMAKE_FLAGS += -DEMBEDPLUGINS:BOOL=${EMBEDPLUGINS}
endif
ifneq (${USE_OPENGL},)
MY_CMAKE_FLAGS += -DUSE_OPENGL:BOOL=${USE_OPENGL}
endif
ifneq (${USE_QT},)
MY_CMAKE_FLAGS += -DUSE_QT:BOOL=${USE_QT}
endif
ifneq (${FORCE_OPENGL_1},)
MY_CMAKE_FLAGS += -DFORCE_OPENGL_1:BOOL=${FORCE_OPENGL_1}
endif
ifneq (${OIIO_THREAD_ALLOW_DCLP},)
MY_CMAKE_FLAGS += -DOIIO_THREAD_ALLOW_DCLP:BOOL=${OIIO_THREAD_ALLOW_DCLP}
endif
@@ -85,18 +67,10 @@ ifneq (${NAMESPACE},)
MY_CMAKE_FLAGS += -DOIIO_NAMESPACE:STRING=${NAMESPACE}
endif
ifneq (${HIDE_SYMBOLS},)
MY_CMAKE_FLAGS += -DHIDE_SYMBOLS:BOOL=${HIDE_SYMBOLS}
endif
ifneq (${USE_PYTHON},)
MY_CMAKE_FLAGS += -DUSE_PYTHON:BOOL=${USE_PYTHON}
endif
ifneq (${USE_PYTHON3},)
MY_CMAKE_FLAGS += -DUSE_PYTHON3:BOOL=${USE_PYTHON3}
endif
ifneq (${PYTHON_VERSION},)
MY_CMAKE_FLAGS += -DPYTHON_VERSION:STRING=${PYTHON_VERSION}
endif
@@ -109,92 +83,16 @@ ifneq (${PYLIB_INCLUDE_SONAME},)
MY_CMAKE_FLAGS += -DPYLIB_INCLUDE_SONAME:BOOL=${PYLIB_INCLUDE_SONAME}
endif
ifneq (${USE_FFMPEG},)
MY_CMAKE_FLAGS += -DUSE_FFMPEG:BOOL=${USE_FFMPEG}
endif
ifneq (${USE_FIELD3D},)
MY_CMAKE_FLAGS += -DUSE_FIELD3D:BOOL=${USE_FIELD3D}
endif
ifneq (${FIELD3D_HOME},)
MY_CMAKE_FLAGS += -DFIELD3D_HOME:STRING=${FIELD3D_HOME}
endif
ifneq (${USE_OPENJPEG},)
MY_CMAKE_FLAGS += -DUSE_OPENJPEG:BOOL=${USE_OPENJPEG}
endif
ifneq (${OPENJPEG_HOME},)
MY_CMAKE_FLAGS += -DOPENJPEG_HOME:STRING=${OPENJPEG_HOME}
endif
ifneq (${USE_JPEGTURBO},)
MY_CMAKE_FLAGS += -DUSE_JPEGTURBO:BOOL=${USE_JPEGTURBO}
endif
ifneq (${JPEGTURBO_PATH},)
MY_CMAKE_FLAGS += -DJPEGTURBO_PATH:STRING=${JPEGTURBO_PATH}
endif
ifneq (${USE_GIF},)
MY_CMAKE_FLAGS += -DUSE_GIF:BOOL=${USE_GIF}
endif
ifneq (${GIF_DIR},)
MY_CMAKE_FLAGS += -DGIF_DIR:STRING=${GIF_DIR}
endif
ifneq (${USE_OCIO},)
MY_CMAKE_FLAGS += -DUSE_OCIO:BOOL=${USE_OCIO}
endif
ifneq (${USE_NUKE},)
MY_CMAKE_FLAGS += -DUSE_NUKE:BOOL=${USE_NUKE}
endif
ifneq (${USE_OPENSSL},)
MY_CMAKE_FLAGS += -DUSE_OPENSSL:BOOL=${USE_OPENSSL}
endif
ifneq (${USE_OPENCV},)
MY_CMAKE_FLAGS += -DUSE_OPENCV:BOOL=${USE_OPENCV}
endif
ifneq (${USE_LIBRAW},)
MY_CMAKE_FLAGS += -DUSE_LIBRAW:BOOL=${USE_LIBRAW}
endif
ifneq (${LIBRAW_PATH},)
MY_CMAKE_FLAGS += -DLIBRAW_PATH:STRING=${LIBRAW_PATH}
endif
ifneq (${USE_PTEX},)
MY_CMAKE_FLAGS += -DUSE_PTEX:BOOL=${USE_PTEX}
endif
ifneq (${USE_EXTERNAL_PUGIXML},)
MY_CMAKE_FLAGS += -DUSE_EXTERNAL_PUGIXML:BOOL=${USE_EXTERNAL_PUGIXML} -DPUGIXML_HOME=${PUGIXML_HOME}
MY_CMAKE_FLAGS += -DUSE_EXTERNAL_PUGIXML:BOOL=${USE_EXTERNAL_PUGIXML}
endif
ifneq (${OPENEXR_HOME},)
MY_CMAKE_FLAGS += -DOPENEXR_HOME:STRING=${OPENEXR_HOME}
ifneq (${OPENEXR_ROOT},)
MY_CMAKE_FLAGS += -DOPENEXR_ROOT:STRING=${OPENEXR_ROOT}
endif
ifneq (${ILMBASE_HOME},)
MY_CMAKE_FLAGS += -DILMBASE_HOME:STRING=${ILMBASE_HOME}
endif
ifneq (${OCIO_HOME},)
MY_CMAKE_FLAGS += -DOCIO_PATH:STRING=${OCIO_HOME}
endif
ifneq (${BOOST_HOME},)
MY_CMAKE_FLAGS += -DBOOST_ROOT:STRING=${BOOST_HOME}
endif
ifneq (${NUKE_HOME},)
MY_CMAKE_FLAGS += -DNuke_ROOT:STRING=${NUKE_HOME}
ifneq (${ILMBASE_ROOT},)
MY_CMAKE_FLAGS += -DILMBASE_ROOT:STRING=${ILMBASE_ROOT}
endif
ifneq (${NUKE_VERSION},)
@@ -205,8 +103,8 @@ ifneq (${STOP_ON_WARNING},)
MY_CMAKE_FLAGS += -DSTOP_ON_WARNING:BOOL=${STOP_ON_WARNING}
endif
ifneq (${BUILDSTATIC},)
MY_CMAKE_FLAGS += -DBUILDSTATIC:BOOL=${BUILDSTATIC}
ifneq (${BUILD_SHARED_LIBS},)
MY_CMAKE_FLAGS += -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
endif
ifneq (${LINKSTATIC},)
@@ -225,16 +123,20 @@ ifneq (${SOVERSION},)
MY_CMAKE_FLAGS += -DSOVERSION:STRING=${SOVERSION}
endif
ifneq (${OIIO_LIBNAME_SUFFIX},)
MY_CMAKE_FLAGS += -DOIIO_LIBNAME_SUFFIX:STRING=${OIIO_LIBNAME_SUFFIX}
endif
ifneq (${BUILD_OIIOUTIL_ONLY},)
MY_CMAKE_FLAGS += -DBUILD_OIIOUTIL_ONLY:BOOL=${BUILD_OIIOUTIL_ONLY}
endif
ifdef DEBUG
MY_CMAKE_FLAGS += -DCMAKE_BUILD_TYPE:STRING=Debug
CMAKE_BUILD_TYPE=Debug
endif
ifdef PROFILE
MY_CMAKE_FLAGS += -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
CMAKE_BUILD_TYPE=RelWithDebInfo
endif
ifneq (${MYCC},)
@@ -245,13 +147,21 @@ MY_CMAKE_FLAGS += -DCMAKE_CXX_COMPILER:STRING="${MYCXX}"
endif
ifneq (${USE_CPP},)
MY_CMAKE_FLAGS += -DUSE_CPP=${USE_CPP}
MY_CMAKE_FLAGS += -DCMAKE_CXX_STANDARD=${USE_CPP}
endif
ifneq (${CMAKE_CXX_STANDARD},)
MY_CMAKE_FLAGS += -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
endif
ifneq (${USE_LIBCPLUSPLUS},)
MY_CMAKE_FLAGS += -DUSE_LIBCPLUSPLUS:BOOL=${USE_LIBCPLUSPLUS}
endif
ifneq (${GLIBCXX_USE_CXX11_ABI},)
MY_CMAKE_FLAGS += -DGLIBCXX_USE_CXX11_ABI=${GLIBCXX_USE_CXX11_ABI}
endif
ifneq (${EXTRA_CPP_ARGS},)
MY_CMAKE_FLAGS += -DEXTRA_CPP_ARGS:STRING="${EXTRA_CPP_ARGS}"
endif
@@ -260,6 +170,10 @@ ifneq (${USE_SIMD},)
MY_CMAKE_FLAGS += -DUSE_SIMD:STRING="${USE_SIMD}"
endif
ifneq (${TEX_BATCH_SIZE},)
MY_CMAKE_FLAGS += -DTEX_BATCH_SIZE:STRING="${TEX_BATCH_SIZE}"
endif
ifneq (${TEST},)
TEST_FLAGS += -R ${TEST}
endif
@@ -273,16 +187,43 @@ MY_CMAKE_FLAGS += -G Ninja
BUILDSENTINEL := build.ninja
endif
ifneq (${CODECOV},)
MY_CMAKE_FLAGS += -DCMAKE_BUILD_TYPE:STRING=Debug -DCODECOV:BOOL=${CODECOV}
ifneq (${UNITY},)
MY_CMAKE_FLAGS += -DCMAKE_UNITY_BUILD=ON -DCMAKE_UNITY_BUILD_MODE=${UNITY}
endif
ifeq (${CODECOV},1)
CMAKE_BUILD_TYPE=Debug
MY_CMAKE_FLAGS += -DCODECOV:BOOL=${CODECOV}
endif
ifneq (${SANITIZE},)
MY_CMAKE_FLAGS += -DSANITIZE=${SANITIZE}
MY_CMAKE_FLAGS += -DSANITIZE=${SANITIZE}
endif
ifneq (${USE_FREETYPE},)
MY_CMAKE_FLAGS += -DUSE_FREETYPE:BOOL=${USE_FREETYPE}
ifneq (${CLANG_TIDY},)
MY_CMAKE_FLAGS += -DCLANG_TIDY:BOOL=1
endif
ifneq (${CLANG_TIDY_CHECKS},)
MY_CMAKE_FLAGS += -DCLANG_TIDY_CHECKS:STRING=${CLANG_TIDY_CHECKS}
endif
ifneq (${CLANG_TIDY_ARGS},)
MY_CMAKE_FLAGS += -DCLANG_TIDY_ARGS:STRING=${CLANG_TIDY_ARGS}
endif
ifneq (${CLANG_TIDY_FIX},)
MY_CMAKE_FLAGS += -DCLANG_TIDY_FIX:BOOL=${CLANG_TIDY_FIX}
MY_NINJA_FLAGS += -j 1
# N.B. when fixing, you don't want parallel jobs!
endif
ifneq (${CLANG_FORMAT_INCLUDES},)
MY_CMAKE_FLAGS += -DCLANG_FORMAT_INCLUDES:STRING=${CLANG_FORMAT_INCLUDES}
endif
ifneq (${CLANG_FORMAT_EXCLUDES},)
MY_CMAKE_FLAGS += -DCLANG_FORMAT_EXCLUDES:STRING=${CLANG_FORMAT_EXCLUDES}
endif
ifneq (${BUILD_MISSING_DEPS},)
MY_CMAKE_FLAGS += -DBUILD_MISSING_DEPS:BOOL=${BUILD_MISSING_DEPS}
endif
@@ -297,7 +238,7 @@ endif
#########################################################################
# Top-level documented targets
all: dist
all: install
# 'make debug' is implemented via recursive make setting DEBUG
debug:
@@ -307,85 +248,87 @@ debug:
profile:
${MAKE} PROFILE=1 --no-print-directory
# 'make cmakesetup' constructs the build directory and runs 'cmake' there,
# 'make config' constructs the build directory and runs 'cmake' there,
# generating makefiles to build the project. For speed, it only does this when
# ${build_dir}/Makefile doesn't already exist, in which case we rely on the
# cmake generated makefiles to regenerate themselves when necessary.
cmakesetup:
config:
@ (if [ ! -e ${build_dir}/${BUILDSENTINEL} ] ; then \
${CMAKE} -E make_directory ${build_dir} ; \
cd ${build_dir} ; \
${CMAKE} -DCMAKE_INSTALL_PREFIX=${INSTALLDIR}/${dist_dir} \
${MY_CMAKE_FLAGS} -DBOOST_ROOT=${BOOST_HOME} \
../.. ; \
${CMAKE} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
${MY_CMAKE_FLAGS} ${working_dir} ; \
fi)
ifeq (${USE_NINJA},1)
# 'make cmake' does a basic build (after first setting it up)
cmake: cmakesetup
@ ( cd ${build_dir} ; ${NINJA} ${MY_NINJA_FLAGS} )
# 'make build' does a basic build (after first setting it up)
build: config
@ ( cd ${build_dir} ; \
${CMAKE} --build . --config ${CMAKE_BUILD_TYPE} \
)
# 'make cmakeinstall' builds everthing and installs it in 'dist'.
# 'make install' builds everthing and installs it in 'dist'.
# Suppress pointless output from docs installation.
cmakeinstall: cmake
@ ( cd ${build_dir} ; ${NINJA} ${MY_NINJA_FLAGS} install | grep -v '^-- \(Installing\|Up-to-date\|Set runtime path\)' )
install: build
@ ( cd ${build_dir} ; \
${CMAKE} --build . --target install --config ${CMAKE_BUILD_TYPE} | grep -v '^-- \(Installing\|Up-to-date\|Set runtime path\)' \
)
# 'make package' builds everything and then makes an installable package
# (platform dependent -- may be .tar.gz, .sh, .dmg, .rpm, .deb. .exe)
package: cmakeinstall
@ ( cd ${build_dir} ; ${NINJA} ${MY_NINJA_FLAGS} package )
package: install
@ ( cd ${build_dir} ; \
${CMAKE} --build . --target package --config ${CMAKE_BUILD_TYPE} \
)
# 'make package_source' makes an installable source package
# (platform dependent -- may be .tar.gz, .sh, .dmg, .rpm, .deb. .exe)
package_source: cmakeinstall
@ ( cd ${build_dir} ; ${NINJA} ${MY_NINJA_FLAGS} package_source )
package_source: install
@ ( cd ${build_dir} ; \
${CMAKE} --build . --target package_source --config ${CMAKE_BUILD_TYPE} \
)
else
# 'make clang-format' runs clang-format on all source files (if it's installed)
clang-format: config
@ ( cd ${build_dir} ; \
${CMAKE} --build . --target clang-format --config ${CMAKE_BUILD_TYPE} \
)
# 'make cmake' does a basic build (after first setting it up)
cmake: cmakesetup
@ ( cd ${build_dir} ; ${MAKE} ${MY_MAKE_FLAGS} )
# 'make cmakeinstall' builds everthing and installs it in 'dist'.
# Suppress pointless output from docs installation.
cmakeinstall: cmake
@ ( cd ${build_dir} ; ${MAKE} ${MY_MAKE_FLAGS} install | grep -v '^-- \(Installing\|Up-to-date\|Set runtime path\)' )
# 'make package' builds everything and then makes an installable package
# (platform dependent -- may be .tar.gz, .sh, .dmg, .rpm, .deb. .exe)
package: cmakeinstall
@ ( cd ${build_dir} ; ${MAKE} ${MY_MAKE_FLAGS} package )
# 'make package_source' makes an installable source package
# (platform dependent -- may be .tar.gz, .sh, .dmg, .rpm, .deb. .exe)
package_source: cmakeinstall
@ ( cd ${build_dir} ; ${MAKE} ${MY_MAKE_FLAGS} package_source )
endif
# 'make dist' is just a synonym for 'make cmakeinstall'
dist : cmakeinstall
# DEPRECATED: 'make dist' is just a synonym for 'make install'
dist : install
TEST_FLAGS += --force-new-ctest-process --output-on-failure
# 'make test' does a full build and then runs all tests
test: cmake
test: build
@ ${CMAKE} -E cmake_echo_color --switch=$(COLOR) --cyan "Running tests ${TEST_FLAGS}..."
@ # if [ "${CODECOV}" == "1" ] ; then lcov -b ${build_dir} -d ${build_dir} -z ; rm -rf ${build_dir}/cov ; fi
@ ( cd ${build_dir} ; PYTHONPATH=${PWD}/${build_dir}/src/python ctest -E broken ${TEST_FLAGS} )
@ ( if [ "${CODECOV}" == "1" ] ; then \
@ ( cd ${build_dir} ; \
PYTHONPATH=${PWD}/${build_dir}/lib/python/site-packages \
ctest -E broken ${TEST_FLAGS} \
)
@ ( if [[ "${CODECOV}" == "1" ]] ; then \
cd ${build_dir} ; \
lcov -b . -d . -c -o cov.info ; \
lcov --remove cov.info "/usr*" -o cov.info ; \
genhtml -o ./cov -t "OIIO test coverage" --num-spaces 4 cov.info ; \
lcov --remove cov.info "*/usr/incude" -o cov.info ; \
lcov --remove cov.info "/Library/Developer/*" -o cov.info ; \
lcov --remove cov.info "*/detail/pugixml/*" -o cov.info ; \
lcov --remove cov.info "*/detail/fmt/*" -o cov.info ; \
lcov --remove cov.info "*/detail/farmhash.h" -o cov.info ; \
lcov --remove cov.info "*/v1/*" -o cov.info ; \
lcov --remove cov.info "*/ext/robin-map/*" -o cov.info ; \
lcov --remove cov.info "*/kissfft.hh" -o cov.info ; \
lcov --remove cov.info "*/stb_sprintf.h" -o cov.info ; \
genhtml -o ../_coverage -t "Test coverage" --num-spaces 4 cov.info ; \
fi )
# 'make testall' does a full build and then runs all tests (even the ones
# that are expected to fail on some platforms)
testall: cmake
testall: build
${CMAKE} -E cmake_echo_color --switch=$(COLOR) --cyan "Running all tests ${TEST_FLAGS}..."
( cd ${build_dir} ; PYTHONPATH=${PWD}/${build_dir}/src/python ctest ${TEST_FLAGS} )
( cd ${build_dir} ; PYTHONPATH=${PWD}/${build_dir}/lib/python/site-packages ctest ${TEST_FLAGS} )
# 'make clean' clears out the build directory for this platform
clean:
@@ -395,10 +338,8 @@ clean:
realclean: clean
${CMAKE} -E remove_directory ${dist_dir}
# 'make nuke' blows away the build and dist areas for all platforms
nuke:
${CMAKE} -E remove_directory ${top_build_dir}
${CMAKE} -E remove_directory ${top_dist_dir}
# DEPRECATED: 'make nuke' blows away the build and dist areas for all platforms
nuke: realclean
doxygen:
doxygen src/doc/Doxyfile
@@ -410,18 +351,17 @@ doxygen:
# 'make help' prints important make targets
help:
@echo "Targets:"
@echo " make Build optimized binaries and libraries in ${dist_dir},"
@echo " temporary build files in ${build_dir}"
@echo " make debug Build unoptimized with symbols in ${dist_dir}.debug,"
@echo " temporary build files in ${build_dir}.debug"
@echo " make profile Build for profiling in ${dist_dir}.profile,"
@echo " temporary build files in ${build_dir}.profile"
@echo " make Build and install optimized binaries and libraries"
@echo " make install Build and install optimized binaries and libraries"
@echo " make build Build only (no install) optimized binaries and libraries"
@echo " make config Just configure cmake, don't build"
@echo " make debug Build and install unoptimized with symbols"
@echo " make profile Build and install for profiling"
@echo " make clean Remove the temporary files in ${build_dir}"
@echo " make realclean Remove both ${build_dir} AND ${dist_dir}"
@echo " make nuke Remove ALL of build and dist (not just ${platform})"
@echo " make test Run tests"
@echo " make testall Run all tests, even broken ones"
@echo " make doxygen Build the Doxygen docs in ${top_build_dir}/doxygen"
@echo " make clang-format Run clang-format on all the source files"
@echo ""
@echo "Helpful modifiers:"
@echo " C++ compiler and build process:"
@@ -429,59 +369,56 @@ help:
@echo " STOP_ON_WARNING=0 Do not stop building if compiler warns"
@echo " OPENIMAGEIO_SITE=xx Use custom site build mods"
@echo " MYCC=xx MYCXX=yy Use custom compilers"
@echo " USE_CPP=14 Compile in C++14 mode (default is C++11)"
@echo " USE_LIBCPLUSPLUS=1 Use clang libc++"
@echo " CMAKE_CXX_STANDARD=14 C++ standard to build with (default is 14)"
@echo " USE_LIBCPLUSPLUS=1 For clang, use libc++"
@echo " GLIBCXX_USE_CXX11_ABI=1 For gcc, use the new string ABI"
@echo " EXTRA_CPP_ARGS= Additional args to the C++ command"
@echo " USE_NINJA=1 Set up Ninja build (instead of make)"
@echo " USE_CCACHE=0 Disable ccache (even if available)"
@echo " UNITY=BATCH Do a 'Unity' build (BATCH or GROUP or nothing)"
@echo " CODECOV=1 Enable code coverage tests"
@echo " SANITIZE=name1,... Enablie sanitizers (address, leak, thread)"
@echo " SANITIZE=name1,... Enable sanitizers (address, leak, thread)"
@echo " CLANG_TIDY=1 Run clang-tidy on all source (can be modified"
@echo " by CLANG_TIDY_ARGS=... and CLANG_TIDY_FIX=1"
@echo " CLANG_FORMAT_INCLUDES=... CLANG_FORMAT_EXCLUDES=..."
@echo " Customize files for 'make clang-format'"
@echo " Linking and libraries:"
@echo " HIDE_SYMBOLS=1 Hide symbols not in the public API"
@echo " SOVERSION=nn Include the specifed major version number "
@echo " SOVERSION=nn Include the specified major version number "
@echo " in the shared object metadata"
@echo " BUILDSTATIC=1 Build static library instead of shared"
@echo " OIIO_LIBNAME_SUFFIX=name Optional name appended to library names"
@echo " BUILD_SHARED_LIBS=0 Build static library instead of shared"
@echo " LINKSTATIC=1 Link with static external libs when possible"
@echo " Dependency hints:"
@echo " For each dependeny Foo, defining ENABLE_Foo=0 disables it, even"
@echo " if found. And you can hint where to find it with Foo_ROOT=path"
@echo " Note that it is case sensitive! The list of package names is:"
@echo " DCMTK FFmpeg Freetype GIF JPEGTurbo"
@echo " LibRaw OpenColorIO OpenCV OpenGL OpenJpeg OpenVDB"
@echo " PTex R3DSDK TBB TIFF Webp"
@echo " Finding and Using Dependencies:"
@echo " BOOST_HOME=path Custom Boost installation"
@echo " OPENEXR_HOME=path Custom OpenEXR installation"
@echo " ILMBASE_HOME=path Custom IlmBase installation"
@echo " BOOST_ROOT=path Custom Boost installation"
@echo " OPENEXR_ROOT=path Custom OpenEXR installation"
@echo " ILMBASE_ROOT=path Custom IlmBase installation"
@echo " USE_EXTERNAL_PUGIXML=1 Use the system PugiXML, not the one in OIIO"
@echo " USE_QT=0 Skip anything that needs Qt"
@echo " USE_OPENGL=0 Skip anything that needs OpenGL"
@echo " FORCE_OPENGL_1=1 Force iv to use OpenGL's fixed pipeline"
@echo " USE_PYTHON=0 Don't build the Python binding"
@echo " USE_PYTHON3=1 If 1, try to build against Python3, not 2.x"
@echo " PYTHON_VERSION=2.6 Specify the Python version"
@echo " USE_FIELD3D=0 Don't build the Field3D plugin"
@echo " FIELD3D_HOME=path Custom Field3D installation"
@echo " USE_FFMPEG=0 Don't build the FFmpeg plugin"
@echo " USE_JPEGTURBO=0 Don't build the JPEG-Turbo even if found"
@echo " JPEGTURBO_PATH=path Custom path for JPEG-Turbo"
@echo " USE_OPENJPEG=0 Don't build the JPEG-2000 plugin"
@echo " USE_GIF=0 Don't build the GIF plugin"
@echo " GIF_DIR=path Custom GIFLIB installation"
@echo " USE_OCIO=0 Don't use OpenColorIO even if found"
@echo " OCIO_HOME=path Custom OpenColorIO installation"
@echo " USE_NUKE=0 Don't build Nuke plugins"
@echo " NUKE_HOME=path Custom Nuke installation"
@echo " Nuke_ROOT=path Custom Nuke installation"
@echo " NUKE_VERSION=ver Custom Nuke version"
# @echo " USE_OPENSSL=1 Use OpenSSL's SHA-1 implementation"
@echo " USE_LIBRAW=0 Don't use LibRaw, even if found"
@echo " LIBRAW_PATH=path Custom LibRaw installation"
@echo " USE_OPENCV=0 Skip anything that needs OpenCV"
@echo " USE_PTEX=0 Skip anything that needs PTex"
@echo " USE_FREETYPE=0 Skip anything that needs Freetype"
@echo " OIIO build-time options:"
@echo " NAMESPACE=name Wrap everything in another namespace"
@echo " INSTALL_PREFIX=path Set installation prefix (default: ./${INSTALL_PREFIX})"
@echo " NAMESPACE=name Override namespace base name (default: OpenImageIO)"
@echo " EMBEDPLUGINS=0 Don't compile the plugins into libOpenImageIO"
@echo " OIIO_THREAD_ALLOW_DCLP=0 Don't allow threads.h to use DCLP"
@echo " OIIO_BUILD_TOOLS=0 Skip building the command-line tools"
@echo " OIIO_BUILD_TESTS=0 Skip building the unit tests"
@echo " BUILD_OIIOUTIL_ONLY=1 Build *only* libOpenImageIO_Util"
@echo " USE_SIMD=arch Build with SIMD support (choices: 0, sse2, sse3,"
@echo " ssse3, sse4.1, sse4.2, f16c, avx, avx2"
@echo " comma-separated ok)"
@echo " USE_SIMD=arch Build with SIMD support (comma-separated choices:"
@echo " 0, sse2, sse3, ssse3, sse4.1, sse4.2, f16c,"
@echo " avx, avx2, avx512f)"
@echo " TEX_BATCH_SIZE=16 Override TextureSystem SIMD batch size"
@echo " BUILD_MISSING_DEPS=1 Try to download/build missing dependencies"
@echo " make test, extra options:"
@echo " TEST=regex Run only tests matching the regex"
@echo ""
+74 -49
View File
@@ -1,10 +1,10 @@
README for OpenImageIO
======================
[![License](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](https://github.com/OpenImageIO/oiio/blob/master/LICENSE)
[![Build Status](https://travis-ci.org/OpenImageIO/oiio.svg?branch=master)](https://travis-ci.org/OpenImageIO/oiio)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/a0l32ti7gcoergtf/branch/master?svg=true)](https://ci.appveyor.com/api/projects/status/a0l32ti7gcoergtf/branch/master)
<p align="center">
<img src="ASWF/logos/openimageio-horizontal-gradient.png">
</p>
[![License](https://img.shields.io/badge/license-Apache2.0-blue.svg?style=flat-square)](https://github.com/OpenImageIO/oiio/blob/master/LICENSE.md)
[![CI](https://github.com/OpenImageIO/oiio/actions/workflows/ci.yml/badge.svg)](https://github.com/OpenImageIO/oiio/actions/workflows/ci.yml)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/2694/badge)](https://bestpractices.coreinfrastructure.org/projects/2694)
Introduction
@@ -19,7 +19,7 @@ OpenImageIO consists of:
* Simple but powerful ImageInput and ImageOutput APIs that provide
an abstraction for reading and writing image files of nearly any
format, without the calling application needing to know any of the
details of these file formats, and indeed without the calling
details of these file formats, and indeed without the calling
application needing to be aware of which formats are available.
* A library that manages subclasses of ImageInput and ImageOutput that
@@ -31,9 +31,9 @@ OpenImageIO consists of:
* Plugins implementing I/O for several popular image file formats,
including TIFF, JPEG/JFIF, OpenEXR, PNG, HDR/RGBE, ICO, BMP, Targa,
JPEG-2000, RMan Zfile, FITS, DDS, Softimage PIC, PNM, DPX, Cineon,
IFF, Field3D, Ptex, Photoshop PSD, Wavefront RLA, SGI, WebP, GIF,
DICOM, many "RAW" digital camera formats, and a variety of movie
formats (readable as individual frames). More are being developed
IFF, OpenVDB, Ptex, Photoshop PSD, Wavefront RLA, SGI, WebP,
GIF, DICOM, HEIF/HEIC/AVIF, many "RAW" digital camera formats, and a variety
of movie formats (readable as individual frames). More are being developed
all the time.
* Several command line image tools based on these classes, including
@@ -66,14 +66,15 @@ OpenImageIO consists of:
Licensing
---------
OpenImageIO is (c) Copyright 2008-2016 by Larry Gritz et al.
All Rights Reserved.
OpenImageIO is (c) Copyright Contributors to the OpenImageIO project.
OpenImageIO is distributed using the modified BSD license (also known as
the "new BSD" or "3-clause BSD" license). Please read the "LICENSE"
file for the legal wording. The documentation is licensed under the
Creative Commons Attribution 3.0 Unported License
(http://creativecommons.org/licenses/by/3.0/).
OpenImageIO is distributed using primarily the Apache 2.0 license -- see the
[LICENSE.md](LICENSE.md) file for details. The documentation is licensed
under the [Creative Commons Attribution 4.0 Unported
License](http://creativecommons.org/licenses/by/4.0/). A small amount of code
imported from other projects, and also some pre-July-2023 code that has not
yet been relicensed under Apache-2.0, is covered by other compatible licenses
-- see [THIRD-PARTY](THIRD-PARTY.md) file for details.
The plain English bottom line is that OpenImageIO is free, as well as
freely modifiable and redistributable (in both source and binary form).
@@ -84,46 +85,70 @@ particular licensing terms in your own application.
Some code and resources are distributed along with OIIO that have highly
compatible, though slightly different, licenses (generally MIT or Apache).
See the PDF documentation Acknowledgements section for details.
Web Resources
-------------
Main web page: http://www.openimageio.org
GitHub page: http://github.com/OpenImageIO/oiio
Mail list subscriptions and archives:
* Developer mail list: http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
* Just release announcements: http://lists.openimageio.org/listinfo.cgi/oiio-announce-openimageio.org
Contact
-------
info@openimageio.org
See the PDF documentation Acknowledgements section, and the
[THIRD-PARTY](THIRD-PARTY.md) file for details.
Building and Installation
-------------------------
Please read the "INSTALL" file for detailed instructions on how to
build and install OpenImageIO.
Please read the [INSTALL.md](INSTALL.md) file for detailed instructions on
how to build and install OpenImageIO.
If you build with EMBEDPLUGINS=0, remember that you need to set the
environment variable OIIO_LIBRARY_PATH to point to the 'lib' directory where
OpenImageIO is installed, or else it will not be able to find the plugins.
If you build with `EMBEDPLUGINS=0`, remember that you need to set the
environment variable `OIIO_LIBRARY_PATH` to point to the 'lib' directory
where OpenImageIO is installed, or else it will not be able to find the
plugins.
Documentation
-------------
The primary user and programmer documentation can be found in
src/doc/openimageio.pdf (in a source distribution) or in the
doc/openimageio.pdf file of an installed binary distribution.
The primary user and programmer documentation can be found
on [openimageio.readthedocs.io](https://openimageio.readthedocs.io/en/latest/)
as html or as [PDF](https://readthedocs.org/projects/openimageio/downloads/pdf/latest/).
Contact & reporting problems
----------------------------
Simple "how do I...", "I'm having trouble", or "is this a bug" questions are
best asked on the [oiio-dev developer mail
list](https://lists.aswf.io/g/oiio-dev).
That's where the most people will see it and potentially be able to answer
your question quickly (more so than a GH "issue").
Bugs, build problems, and discovered vulnerabilities that you are relatively
certain is a legit problem in the code, and for which you can give clear
instructions for how to reproduce, should be [reported as
issues](https://github.com/OpenImageIO/oiio/issues).
If confidentiality precludes a public question or issue, you may contact us
privately at [info@openimageio.org](info@openimageio.org), or for
security-related issues [security@openimageio.org](security@openimageio.org).
Contributing
------------
OpenImageIO welcomes code contributions, and [nearly 200 people](CREDITS.md)
have done so over the years. We take code contributions via the usual GitHub
pull request (PR) mechanism. Please see [CONTRIBUTING](CONTRIBUTING.md) for
detailed instructions.
Web Resources
-------------
* Main web page: http://www.openimageio.org
* GitHub page: http://github.com/OpenImageIO/oiio
* Developer mail list subscriptions and archives:
https://lists.aswf.io/g/oiio-dev
* ASWF Slack: https://slack.aswf.io
(look for the `#openimageio` channel)
* Biweekly TSC meetings are on the ASWF Calendar: https://www.aswf.io/meeting-calendar/
(click on the OpenImageIO meeting entries, every second Monday, to get the Zoom link, anyone may join)
+352
View File
@@ -0,0 +1,352 @@
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
<!-- Copyright Contributors to the OpenImageIO Project. -->
# Release Procedures for OpenImageIO
## Version nomenclature and release cadence
### The meaning of the version parts
Our release numbers are of the form `MAJOR.MINOR.PATCH.TWEAK`, and we follow
an almost-semantic-versioning scheme.
MAJOR changes are those that break backward-compatibility of the public APIs,
requiring existing application code to change their source code where it calls
OIIO API functions in order to compile and work correctly.
MINOR changes guarantee API backward-compatibility with prior releases that
have the same major number, but can introduce ABI or link incompatibilities.
Applications using OIIO need to be recompiled to move to a new minor release,
but should not need to change their source code. Minor releases are allowed
to drop support for sufficiently old compilers and dependencies.
PATCH changes guarantee both API and ABI/link backward-compatibility with
prior releases that have the same minor number. Features and new public API
calls may be added (thus deviating from strict semantic versioning), but only
if they preserve ABI/link compatibility. This means that standalone functions
or static methods may be added, but existing functions will not change their
parameters, and no new virtual methods or struct data layouts change for patch
releases (for classes in public header files). Application code can be
re-linked to a new patch release without needing to be recompiled. We also
guarantee that any compilers or dependencies supported for the first release
of a minor series will continue to be supported for all patches to that minor
series.
TWEAK changes are restricted to critical bug fixes or build breaks that do
not alter public APIs in any way.
### Cadence of releases
Major (arbitrarily incompatible) releases happen rarely, usually with multiple
years between them.
Minor (API backward-compatible) releases are scheduled annually, targeted at
late summer (SIGGRAPH time) to be in beta, and early autumn for a full
release.
Patch (API and ABI backward-compatible) releases are scheduled monthly,
usually aiming for the first day of each month.
Tweak (fully forward and backward compatible) releases are not regularly
scheduled, and only happen sporadically, when a critical fix is needed in
between scheduled patch releases.
### Things are different in "master"
The "master" branch is where ongoing development occurs without any
compatibility guarantees. We don't always know if the next year's release from
master will turn out to be major (API breaking) or minor (only ABI breaking).
Some studios or products need the most up-to-date enhancements, and thus tend
to build OIIO from the "master" branch rather than using tagged releases. For
these users, we try to set version numbers and occasionally tag in master, to
send a signal about which points in master seem safe to rely on various
compatibility levels. However, the rules are slightly different than we use
for releases.
In the "master" branch:
- TWEAK changes within "master" only guarantee ABI back-compatibility, but may
have additions or non-bug-fix behavior changes (akin to patch releases
within a release branch).
- PATCH changes within "master" are allowed to break ABI or API (changes that
would require minor or major releases, if they were not in "master").
- Beware of unmarked breaks in compatibility of commits in master that are
in between developer preview tags.
---
## Branch and tag names
**Branches** are places where commits containing new development may be added
(and thus the branch markers will move over time). Branch names obey the
following conventions:
- `master` is the area for arbitrary changes intended for the next year's
major or minor release.
- `dev-1.2` are the areas for staging additions to the next month's patch
release for the designated minor version series.
- `release` is a special branch marker that is always set to the latest tag of
the currently supported, stable release family. People can count on
"release" always being the latest stable release, whatever that may be at
the time.
**Tags** indicate releases or developer previews, and once a commit is
tagged, it is permanent and will never be moved. Tag names obey the following
conventions:
- `v1.2.3.4` is a specific public stable release, corresponding to official
major, minor, public, or tweak releases.
- `v1.2.3.4-alpha`, `v1.2.3.4-beta`, or `v1.2.3.4-RC1` are pre-releases for an
upcoming public stable release, at the alpha, beta, or release candidate
stages, respectively.
- `v1.2.3.4-dev` is a "developer preview" within "master." It is not an official
supported release, and while the numbering may indicate compatibility versus
other recent developer previews, they should not be assumed to be compatible
with any prior official stable releases.
*Very* occasionally, other branch or tag names (with custom suffixes or
different naming schemes) may be used for special purposes by particular
developers or users, but should not be considered reliable or permanent, and
in general should be ignored by anyone who didn't make the tag or branch.
---
## Release Procedures
### Soft freeze for monthly tweak releases:
We freely backport *safe*, non-ABI-breaking changes by cherry-picking them
from master to the supported branch continually throughout most of the month.
In the seven days before the new month, we do a "soft freeze" where only
important bug fixes are backported. Hold on to any other patches you wish to
backport until after the monthly patch release (i.e., save them for the next
month's release so you never have a release that contains changes that are
only a few days old, and therefore not as well tested). You may, of course,
continue to backport fixes to documentation or other non-code parts of the
project during this soft freeze.
### Branching for annual major/minor releases
By mid-June (about 1-2 months before the beta of a new annual big release),
you should branch and mark it as an alpha.
At the tip of "master", create a new branch named `dev-MAJOR.MINOR` that will
be the staging area for the next release.
Customarily, at that point we add a commit to master (but not to the new
dev-MAJ.MIN branch) that bumps master's version to the next minor level, to
avoid any confusion between builds from master versus what will be the next
release branch. This starts the divergence between master and the release
branch, and henceforth, any big or compatibility-breaking changes will only be
committed to master and not backported to the release branch. (Though we are
loose about this rule during the alpha period and allow continued breaking
changes in the alpha, but by the time we call it beta, we allow no more
breaking changes.) Also at this stage, the master branch's CHANGES.md should
have a heading added at the top for the *next* version.
### Prior to a release
1. Update CI dependencies: Ensure that the "latest" CI test specifies the
current releases of the dependencies and compilers (check their home
pages), and that the [INSTALL.md](../INSTALL.md) file correctly documents
the version ranges that we expect to work and that we actively test.
2. Release notes: [CHANGES.md](../CHANGES.md) should be updated to reflect
all the new features and fixes. Looking at the notes from older releases
should provide a good example of what we're aiming for.
- Patch and tweak releases can be brief one-line descriptions (often the
first line of the commit messages involved), presented in a single
section in either chronological or any other order that seems right.
- Minor or major releases have a much more extensive, prose-based
description of all changes since the last minor release, broken into
sections (dependency changes, major new features, enhancements and fixes,
internals and developer goodies, testing/CI/ports, etc.) and ordered for
readability and relevance.
3. Ensure docs are up to date:
- Actually read the [README.md](README.md), [INSTALL.md](INSTALL.md),
and other repository docs and make sure all the information is up to
date. Check the [CREDITS.md](CREDITS.md) against the recent repo history
to be sure new contributors are listed.
- Skim the primary user documentation to look for any obvious errors,
especially the parts that describe new features.
- If we are using any online docs (like readthedocs), make sure it is
building and looks correct on the web site.
4. Make sure the the top-level CMakeLists.txt file is updated:
- The `OpenImageIO_VERSION` should be correct.
- The `PROJECT_VERSION_RELEASE_TYPE` variable should be set to "alpha" or
"beta" if appropriate, "RC" for release candidate, or empty string `""`
for most supported releases, and "dev" only for the master branch or
developer previews.
- The `${PROJECT_NAME}_SUPPORTED_RELEASE` variable should be `ON` for any
release branch, `OFF` for master.
5. In the https://github.com/OpenImageIO/oiio-images project, create a branch
`RB-x.y` for the major/minor branch, and in the main oiio repo, update
src/build-scripts/install_test_images.bash to specify `-b RB-x.y` in the
checkout of oiio-images to ensure CI tests are against the set of test
images corresponding to that major/minor release (just in the branch, not
in master!).
6. Make sure everything passes the usual CI workflow. Also check the daily or
weekly "analysis" workflows to make sure there aren't any important
warnings that should be fixed.
### Staging alpha / beta / release candidate (annual minor/major releases only)
For monthly patch releases, we don't have any formal alpha/beta/RC stages.
For the annual minor or major releases we have a staged release:
- `alpha` is everything after we have branched, in which we think all the big
new features have been added, and while we will make continued changes and
fixes, we are aiming for increased stability and to minimize additional
breaking changes prior to the release.
- `beta` should be about one month prior to the final release date. We create
a tag `v1.2.3.4-beta` and announce the beta (see below "Making the
release"). Once we tag a beta, we try very hard not to allow any further
changes that change the API or are not ABI-compatible (i.e., safe fixes
only).
- `RC` or release candidates around one week prior to the final release date.
This is a trial run, hopefully identical to the final release (except for
removing the RC label and making a new tag). The only changes allowed after
RC are fixes to the most critical bugs or build breaks that would be bad for
users to encounter. If critical problems are found with RC1, they should be
fixed and immediately re-tagged as RC2, etc. All other fixes should be
postponed until the next month's patch release.
### Making the release
A final release is made on the scheduled date, provided the latest RC has
survived for at least a few days of testing without finding any critical
problems. Don't make the release final until you are sure there are no
truly critical bugs or build breaks that users will encounter.
The following are the steps for making the release:
1. Edit the top-level CMakeLists.txt to remove any RC designation
(i.e., `PROJECT_VERSION_RELEASE_TYPE` should be set to `""`).
2. Edit CHANGES.md to reflect the correct date of the release and ensure it
includes any last-minute changes that were made during beta or release
candidate stages.
3. Push it to **your** GitHub, make sure it passes CI.
4. Tag the release: `git tag v1.2.3.4` (no more beta, RC, or dev suffix).
5. If this will now be the recommended stable release, move the `release`
branch marker to the same position.
6. Push it to GitHub: `git push OpenImageIO release --tags`
(This example assumes "OpenImageIO" is the name of the remote for the
GitHub `OpenImageIO/oiio` repo.)
7. Draft a release on GitHub: On https://github.com/OpenImageIO/oiio/releases
select "Draft a new release." Choose the new tag you just pushed. Make the
release title "OpenImageIO v1.2.3.4" (and beta, etc., designation
if applicable). In the description, paste the release notes for this
release (from CHANGES.md). If this is a beta or release candidate, check
"this is a pre-release" box at the bottom.
8. Announce the release on the [oiio-dev mail list](https://lists.aswf.io/g/oiio-dev)
with the subject "Release: OpenImageIO v1.2.3.4" and using one of these
templates for the body of the email.
For a monthly patch release:
> We have tagged v1.2.3.4 as the latest production release and moved the
> "release" branch marker to that point. This is guaranteed to be API,
> ABI, and link back-compatible with prior 1.2 releases. Release notes
> are below.
>
> (Paste the full set of 1.2 changes here, just copy the appropriate
> part of CHANGES.md)
For an annual major/minor release:
> OpenImageIO version 1.2 has been released! Officially tagged as
> "v1.2.3.4", we have also moved the "release" branch tag to this
> position. Henceforth, 1.2 is the supported production release family.
> The API is now frozen -- we promise that subsequent 1.2.x releases
> (which should happen monthly) will not break back-compatibility of API,
> ABI, or linkage, compared to this release. Please note that this release
> is *not* ABI or link compatible with 1.1 or older releases.
>
> Release notes for 1.2 outlining all the changes since last year's
> release are below.
>
> Please note that a few of the build and runtime dependencies have
> changed their minimum supported versions. (List here any important
> changes to dependencies, compilers, or C++ standard that users should be
> aware of.)
>
> (List here anything else that people should know about this release
> family that may be surprising if they haven't followed the last year of
> development closely, or that they must know even if they are too lazy to
> read the release notes. If this is a major release that is not
> backward-compatible with prior versions, warn about that here.)
>
> Enjoy, and please report any problems. We will continue to make patch
> releases to the 1.2 family roughly monthly, which will contain bug fixes
> and non-breaking enhancements.
>
> The older 1.1 series of releases is now considered obsolete. We will
> continue for now to make 1.1 patch releases, but over time, these will
> become less frequent and be reserved for only the most critical bug
> fixes.
>
> The "master" branch is now progressing toward an eventual 1.3 release next
> summer. As usual, you are welcome to use master for real work, but we do
> not make any compatibility guarantees and don't guarantee continuing API
> compatibility in master.
>
> (Paste the full set of 1.2 changes here, just copy the appropriate
> part of CHANGES.md)
For a beta leading up to the annual major/minor release:
> OpenImageIO version 1.2 is now in beta, tagged as "v1.2.3.4-beta". We
> will try very hard not to make any further API or ABI changes between
> now and the final release (unless it is absolutely necessary to fix
> an important problem identified during beta testing). The final 1.2
> release is scheduled for [DATE GOES HERE], so please try building and
> testing the beta so we are sure to find any problems.
>
> Release notes for 1.2 outlining all the changes since last year's
> release are below.
>
> (Paste the full set of 1.2 changes here, just copy the appropriate
> part of CHANGES.md)
### After the release
Odds and ends to do after the tag is pushed and the announcements are sent:
- Re-read RELEASING.md and ensure that the instructions match what you
have done. Update as necessary.
- Go to readthedocs.org, and ensure that the new release is built and visible
and is the default release shown (specified in the Admin section). I tend to
keep the latest patch of each minor release available for reference
indefinitely, but hide the docs for earlier patch releases within that minor
release series.
- Edit the top-level CMakeList.txt to update the version to the *next*
anticipated release on the branch, in order to ensure that anybody building
from subsequent patches won't get a release number that advertises itself
incorrectly as a prior tagged release. Also edit CHANGES.md to add a new
(blank) heading for the next patch or release.
+151
View File
@@ -0,0 +1,151 @@
New code entering the OpenImageIO repository from July 1 2023 onward is
subject to the [Apache 2.0 license](LICENSE.md).
Code dating from earlier than July 1 2023 was contributed under the [BSD
3-clause license](LICENSE-BSD-3-Clause.md), unless relicensed below.
The following copyright holders agree that all of their contributions
originally submitted to this project under the 3-Clause BSD License are hereby
relicensed to the Apache License, Version 2.0, and are submitted pursuant to
the Developer Certificate of Origin, version 1.1:
- Larry Gritz (@lgritz)
- Chris Kulla (fpsunflower)
- Brecht Van Lommel (brechtvl)
- Daniel Flehner Heen (apetrynet)
- Daniel Wyatt (dewyatt)
- Aras Pranckevičius (aras-p)
- Leszek Godlewski (inequation)
- Dalai Felinto (dfelinto)
- Jesse Yurkovich (jessey-git)
- Sergey Sharybin (sergeyvfx)
- Ray Molenkamp (LazyDodo)
- Nathan Rusch (nrusch)
- Ismael Cortes (leamsi)
- AdamMainsTL
- Sony Pictures Imageworks (cmstein, olegul, fpsunflower, brianhall77, jeremyselan, drg, richardssam, lecocqp)
- Richard Shaw (hobbes1069)
- Robert Matusewicz
- Mariusz Szczepańczyk (mszczepanczyk)
- Scott Wilson
- Kevin Brightwell (Nava2)
- Simon Boorer
- Alex Hughes (Ahuge)
- Alister Chowdhury
- Manuel Leonhardt (skycaptain)
- Alexandre Gauthier (MrKepzie)
- Mark Boorer (shootfast)
- Povilas Kanapickas (p12tic)
- Mikael Sundell
- Roman Zulak (marsupial)
- Autodesk (includes Thiago Ize, Elvic Liang, Wayne Arnold, William Krick, Brecht Van Lommel, Marcos Fajardo)
- Thiago Ize
- Nick Black (dankamongmen)
- Michel Lerenard (micler)
- Stefan Bruens (StefanBruens)
- David Gordon
- Claire Foster (c42f)
- Konrad Kleine (kwk)
- Simone Gasparini (simogasp)
- Radu Arjocu (ra-mt)
- Dominik Bartkiewicz (fafik23)
- 360highdynamicrangehdr (?)
- Leonid Onokhov (sopvop)
- Nuno Cardoso (npcardoso)
- Todica Ionut (360highdynamicrangehdr)
- Till Dechent (ttddee)
- Tom Knowles (knowlsie)
- SRHMorris
- Biswapriyo Nath (Biswa96)
- Edoardo Dominici (dedoardo)
- Frédéric Devernay (devernay)
- Simone Gasparini (simogasp)
- roelandschoukens
- Nayden Dochev (nayyden)
- Yann Lanthony (yann-lty)
- Benjamin Buch (bebuch)
- Joris Nijs (joris-nijs)
- Jan Honsbrok (Latios96)
- Matteo F. Vescovi (mfvescovi)
- Patrick Northon (patlefort)
- Eric Mehl (ericmehl)
- Xo Wang (GHF)
- etiam
- Fabien Servant (servantftechnicolor)
- Loïc Vital (mugulmd)
- Thomas Mansencal (Wētā FX)
- Brent Davis (btdavis)
- pwm1234-sri
- toxieainc
- demoulinv
- Julien Enche (jenche)
- Justin Israel
- xiaoxiaoafeifei
- Brad Smith (brad0)
- lmarz
- Seifeddine Dridi (seifeddinedridi)
- Daniel Dresser (danieldresser)
- Luc Bournaud (DevilishSpirits)
- Dennis Schridde (devurandom)
- Dieter De Baets (debaetsd)
- Gonzalo Garramuño (ggarra13)
- Alan Jones (@skyphyr)
- pumkinpal
- Christopher Crosetto (ccrosetto)
- Russell Greene (russelltg)
- Sam Richards (richardssam)
- Guillaume Chatelet (gchatelet)
- extrowerk
- Heiko Becker (heirecka)
- Mark Visser (mjmvisser)
- Harry Mallon (hjmallon)
- Henri Fousse (darkhorse64)
- Krzysztof Blicharski (blicharski)
- Hugh Macdonald (HughMacdonald)
- Pascal Lecocq (lecocqp)
- Ramon Montoya Vozmediano (rmv)
- Dan Wexler (danwexler)
- Jérôme Duval (korli)
- Tim Grant (timgrant)
- Shane Ambler (sambler)
- Wētā
- Kimball Thurston (kdt3rd)
- Anders Langlands (anderslanglands)
- Алексей (Alexpux)
- Fabien Castan (fabiencastan)
- Grégoire De Lillo (gregoire-dl)
- Edgar Velázquez-Armendáriz (edgarv)
- Malcolm Humphreys (malcolmhumphreys)
- johnfea
- Max Liani (maxliani)
- Michael Görner (v4hn)
**Prior authors, please submit a PR against this file that adds your name
above. If, at the time of your prior contributions, you were employed by a
company who would have owned your IP output, then please have someone from
that company who is authorized to do so submit a PR to add their company’s
name to the list under the statement in this file.**
---
Here are the instructions we have been given by the Linux Foundation for how
to document the contents of each file:
a. Files that consist of only contributions made entirely by companies that
have submitted PRs as described above can have, once those PRs are merged,
the BSD-3-Clause license information replaced with Apache-2.0 license
information.
b. Files that contain contributions made after the change to the Apache-2.0
license as the license for the project should include only the Apache-2.0
license information.
c. Files that contain contributions made both before the Apache-2.0 license
change and after the Apache-2.0 license change should include both
BSD-3-Clause and Apache-2.0 license information. The SPDX identifier for
these files is “BSD-3-Clause and Apache-2.0”.
d. Files that contain only contributions made prior to the Apache-2.0 license
change should continue to include BSD-3-Clause license information (e.g.,
no changes to BSD-3-Clause information included in those files).
+25
View File
@@ -0,0 +1,25 @@
# Security Policy
## Supported Versions
This gives guidance about which branches are supported with patches to
security vulnerabilities.
| Version / branch | Supported |
| ----------------- | ---------------------------------------------------- |
| master | :white_check_mark: :construction: ALL fixes immediately, but this is a branch under development with a frequently unstable ABI and occasionally unstable API. |
| 2.4.x | :white_check_mark: All fixes that can be backported without breaking ABI compatibility. New tagged releases monthly. |
| 2.3.x | :x: Only receives occasional critical fixes, upon request. |
| <= 2.2.x | :x: No longer receiving patches of any kind. |
## Reporting a Vulnerability
If you think you've found a potential vulnerability in OpenImageIO, please
report it by emailing security@openimageio.org. Only the project administrators
have access to these messages. Include detailed steps to reproduce the issue,
and any other information that could aid an investigation. Our policy is to
respond to vulnerability reports within 14 days.
Our policy is to address critical security vulnerabilities rapidly and post
patches as quickly as possible.
+302
View File
@@ -0,0 +1,302 @@
See [LICENSE.md](LICENSE.md) for the main open source license of original
code written for the OpenImageIO project, which is the Apache-2.0 license.
The remainder of this file reproduces the open source licensing details
of other projects that have been imported, incorporated into, or derived
into parts of OIIO.
In no particular order:
-------------------------------------------------------------------------
BSD 3-Clause License
SPDX-License-Identifier: BSD-3-Clause
* OpenImageIO prior to July 1, 2023
Code that was contributed to OpenImageIO prior to July 1 2023, and has not
yet been [relicensed](RELICENSING.md), was contributed under the [BSD
3-clause license](LICENSE-BSD.md). Currently, this is less than 2% of the
codebase (by lines of code).
* Gelato, Copyright (c) 2004 by NVIDIA Corp.
The initial (version 0.1) code found in imageio.h, fmath.h, filter.h,
argparse, and the JPEG reader/writer had elements derived from
BSD-licensed example code and headers from NVIDIA's Gelato Renderer. It's
not clear that any of that original code still survives in the modern
OIIO, but since some elements are derived from that, we still acknowledge
the original copyright here.
* Open Shading Language. Copyright contributors to the OSL project.
https://github.com/AcademySoftwareFoundation/OpenShadingLanguage
A few parts here and there, notably parts of fmath.h and many of the CMake
files, contain code that was originally developed for Open Shading
Language but subsequently moved to OIIO.
* OpenColorIO (c) Copyright contributors to the OpenColorIO Project.
https://github.com/AcademySoftwareFoundation/OpenColorIO
The sample OpenColorIO configurations in our testsuite are borrowed from
this ASWF project, also BSD-3-Clause licensed.
* OpenEXR/Imath (c) Copyright contributors to the OpenEXR Project.
https://github.com/AcademySoftwareFoundation/Imath
Some templates in vecparam.h were first developed for Imath.
* DPX reader/writer (c) Copyright 2009 Patrick A. Palmer.
https://github.com/patrickpalmer/dpx
* KissFFT (c) Copyright 2003-2010 Mark Borgerding
https://github.com/mborgerding/kissfft
* FindOpenVDB.cmake (c) Copyright 2015 Blender Foundation, BSD license.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
SPDX-License-Identifier: BSD-2-Clause
* xxHash - Fast Hash algorithm
Copyright (C) 2012-2014, Yann Collet.
You can contact the author at :
- xxHash source repository : https://github.com/Cyan4973/xxHash
- public discussion board : https://groups.google.com/forum/#!forum/lz4c
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------
MIT License
SPDX-License-Identifier: MIT
* PugiXML http://pugixml.org/ https://github.com/zeux/pugixml
Copyright (c) 2006-2018 Arseny Kapoulkine
* FarmHash, by Geoff Pike https://github.com/google/farmhash
(c) Copyright 2014 Google, Inc., MIT license.
* FindTBB.cmake. Copyright (c) 2015 Justus Calvin
* {fmt} library - https://github.com/fmtlib/fmt
Copyright (c) 2012 - present, Victor Zverovich
* UTF-8 decoder function from http://bjoern.hoehrmann.de/utf-8/decoder/dfa/
Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
* fasthash
Copyright (C) 2012 Zilong Tan (eric.zltan@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------
Apache 2.0 License.
SPDX-License-Identifier: Apache-2.0
* CTPL thread pool https://github.com/vit-vit/CTPL
Copyright 2014 Vitaliy Vitsentiy.
* Droid fonts from the Android SDK. http://www.droidfonts.com
Copyright Google, Inc.
* function_view.h contains code derived from LLVM. https://llvm.org
Copyright (c) 2003-2018 University of Illinois at Urbana-Champaign.
This is licensed under the Apache 2.0 license with LLVM Exceptions.
https://llvm.org/docs/DeveloperPolicy.html#open-source-licensing-terms
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-------------------------------------------------------------------------
Boost Software License - Version 1.0
SPDX-License-Identifier: BSL-1.0
* Some math functions in fmath.h are derived from the
[Sleef library](https://sleef.org)
Copyright Naoki Shibata and contributors 2010 - 2017.
https://github.com/shibatch/sleef/blob/master/LICENSE.txt
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------
Zlib license
SPDX-License-Identifier: Zlib
* Base-64 encoder from http://www.adp-gmbh.ch/cpp/common/base64.html
Copyright (C) 2004-2008 René Nyffenegger
This source code is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this source code must not be misrepresented; you must not
claim that you wrote the original source code. If you use this source code
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original source code.
3. This notice may not be removed or altered from any source distribution.
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
-------------------------------------------------------------------------
Unlicense
SPDX-License-Identifier: Unlicense
* gif.h by Charlie Tangora. Public domain / Unlicense.
https://github.com/ginsweater/gif-h
* bcdec.h by Sergii "iOrange" Kudlai. MIT or Unlicense.
https://github.com/iOrange/bcdec
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org>
-------------------------------------------------------------------------
Public domain
* lookup3 code by Bob Jenkins, Public Domain.
http://burtleburtle.net/bob/c/lookup3.c
* The SHA-1 implementation we use is public domain by Dominik Reichl.
http://www.dominik-reichl.de
-------------------------------------------------------------------------
If we have left anything out, it is unintentional. Please let us know.
-131
View File
@@ -1,131 +0,0 @@
version: '{branch}-{build}'
image: Visual Studio 2015
clone_folder: C:\projects\oiio
test: off
configuration:
- Release
# - Debug
platform:
- x64
# branches:
# only:
# - master
environment:
matrix:
# - CMAKE_PLATFORM: "Visual Studio 14 2015"
# PYTHON_DIR: "C:\\Python27"
- CMAKE_PLATFORM: "Visual Studio 14 2015 Win64"
PYTHON_DIR: "C:\\Python27-x64"
tbs_arch: "x64"
tbs_tools: "msvc14"
tbs_static_runtime: 0
# BUILD_STATIC: 1
install:
- cinstall: python
- set CMAKE_PREFIX_PATH=C:/Sys;%APPVEYOR_BUILD_FOLDER%/deps
- set CMAKE_LIBRARY_PATH=C:/Sys/lib;%APPVEYOR_BUILD_FOLDER%/deps/lib
- set CMAKE_INCLUDE_PATH=C:/Sys/include;%APPVEYOR_BUILD_FOLDER%/deps/include
- mkdir c:\sys
- mkdir deps
- cd deps
- mkdir lib
- mkdir include
# ZLIB
- appveyor DownloadFile https://github.com/madler/zlib/archive/v1.2.8.tar.gz
- 7z x v1.2.8.tar.gz -so | 7z x -si -ttar
- cd zlib-1.2.8
- cmake -G "%CMAKE_PLATFORM%" . -DCMAKE_INSTALL_PREFIX=C:/Sys
- cmake --build . --config Release
- cmake --build . --config Release --target install
- cd ..
# TIFF
- nuget install libtiff-%tbs_tools%-%tbs_arch%-master -Version 4.0.6.85 -Source https://ci.appveyor.com/nuget/libtiff-i3h8tqqy7o7b &&
powershell -Command "move libtiff*\* . -force"
# PNG
- nuget install libpng-%tbs_tools%-%tbs_arch%-master -Version 1.6.18.44 -Source https://ci.appveyor.com/nuget/libpng-7hwq4pmmrc48
- set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%APPVEYOR_BUILD_FOLDER%/deps/libpng-msvc14-x64-master.1.6.18.44
# OpenEXR FIXME - this is 2.0?
- set EXRINSTALLDIR=%APPVEYOR_BUILD_FOLDER%/deps/openexr-install
- set EXRVERSION=2.2.0
- mkdir openexr-install
- git clone -b v%EXRVERSION% https://github.com/openexr/openexr.git ./openexr
- cd openexr
- dir
- cd IlmBase
- mkdir build
- cd build
- cmake -G "%CMAKE_PLATFORM%" --config Release -DCMAKE_CXX_FLAGS=/W0 -DCMAKE_INSTALL_PREFIX=C:/Sys ..
- cmake --build . --config Release
- cmake --build . --config Release --target install
- dir C:\Sys
- dir C:\Sys\lib
- dir C:\Sys\include
- cd ../../OpenEXR
- mkdir build
# Huge cheat -- substitute our own tables to save compile time, and
# a modified IlmImf/CMakeLists.txt that skips the files if already present
- copy %APPVEYOR_BUILD_FOLDER%\src\build-scripts\OpenEXR-CMakeLists.txt CMakeLists.txt
- copy %APPVEYOR_BUILD_FOLDER%\src\build-scripts\OpenEXR-IlmImf-CMakeLists.txt IlmImf\CMakeLists.txt
- cd build
- mkdir IlmImf
- 7z x -oIlmImf "%APPVEYOR_BUILD_FOLDER%/src/build-scripts/b44ExpLogTable.h.zip"
- 7z x -oIlmImf "%APPVEYOR_BUILD_FOLDER%/src/build-scripts/dwaLookups.h.zip"
- dir IlmImf
- cmake -G "%CMAKE_PLATFORM%" --config Release -DCMAKE_CXX_FLAGS=/W0 -DCMAKE_INSTALL_PREFIX=C:/Sys -DCMAKE_PREFIX_PATH=c:/sys -DILMBASE_PACKAGE_PREFIX=c:/sys -DBUILD_UTILS=0 -DBUILD_TESTS=0 ..
- cmake --build . --config Release
- cmake --build . --config Release --target install
- cd ../../..
- dir
# JPEG
- nuget install libjpeg-%tbs_tools%-%tbs_arch%-master -Version 1.4.80.21 -Source https://ci.appveyor.com/nuget/libjpegturbo-o6k4js4y7pjw
- set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%APPVEYOR_BUILD_FOLDER%/deps/libjpeg-msvc14-x64-master.1.4.80.21
# Boost
- set BOOST_ROOT=C:\Libraries\boost_1_59_0
- dir %BOOST_ROOT%
- set BOOST_LIBRARYDIR=C:\Libraries\boost_1_59_0\lib64-msvc-14.0
- set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%BOOST_ROOT%
# OpenColorIO
# - svn co https://svn.blender.org/svnroot/bf-blender/trunk//lib/win64_vc14/OpenColorIO
# - set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%APPVEYOR_BUILD_FOLDER%/deps/OpenColorIO
# FFmpeg
# - svn co https://svn.blender.org/svnroot/bf-blender/trunk//lib/win64/ffmpeg
# - set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%APPVEYOR_BUILD_FOLDER%/deps/ffmpeg
# Freetype
# - nuget install freetype-%tbs_tools%-%tbs_arch%-master -Version 2.6.2.1 -Source https://ci.appveyor.com/nuget/freetype-vf7bw7v5ec29
# - ps: move freetype*\* deps -force
# - set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%APPVEYOR_BUILD_FOLDER%/deps/freetype
- cd ..
- dir C:\Sys
- dir C:\Sys\include
- dir C:\Sys\lib
- dir C:\projects\oiio\deps
- dir C:\projects\oiio\deps\include
- dir C:\projects\oiio\deps\lib
build_script:
- echo Running cmake...
- cd c:\projects\oiio
- mkdir build
- mkdir build\windows64
- cd build\windows64
- cmake -G "%CMAKE_PLATFORM%" -DPYTHON_INCLUDE_DIR:PATH=%PYTHON_DIR%/include -DPYTHON_LIBRARY:FILEPATH=%PYTHON_DIR%/libs/python27.lib -DPYTHON_EXECUTABLE:FILEPATH=%PYTHON_DIR%/python.exe -DCMAKE_LIBRARY_PATH=%CMAKE_LIBRARY_PATH% -DCMAKE_INCLUDE_PATH=%CMAKE_INCLUDE_PATH% -DCMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH% -DOPENEXR_HOME=C:\projects\oiio\deps -DVERBOSE=1 ../..
- dir c:\projects\oiio
- dir c:\projects\oiio\build
- dir c:\projects\oiio\build\windows64
- cmake --build . --config %CONFIGURATION%
matrix:
fast_finish: true
+32
View File
@@ -0,0 +1,32 @@
[requires]
zlib/1.2.11
libtiff/4.0.9
libpng/1.6.37
openexr/2.4.0
boost/1.70.0
libjpeg/9c
libjpeg-turbo/2.0.2
giflib/5.1.4
freetype/2.10.0
#opencv/4.1.1@conan/stable
openjpeg/2.3.1
libwebp/1.0.3
tsl-robin-map/0.6.1@tessil/stable
tbb/2020.0
# To do:
# opencolorio? not on conan?
# pybind11/2.4.3 - conan doesn't have this minimum version
# dcmtk
# ffmpeg
# libheif
# libraw
# openvdb
# ptex
# qt5
[generators]
cmake
[options]
#libpng:shared=False
+250 -16
View File
@@ -3,23 +3,257 @@ ifneq (${VERBOSE},)
$(info Including spi/Makefile-bits)
endif
use_spcomp2_bits := 0
# Is the string literal 'spcomp2' in the command goals?
# If so, use the spcomp2 makefile instead of arnold.
ifneq (,$(findstring spcomp2,$(MAKECMDGOALS)))
use_spcomp2_bits := 1
# Export a variable that can be checked for in sub-makes to know
# to stay in spcomp2 mode.
export TARGETING_SPCOMP2 = 1
endif
ifeq (1,$(TARGETING_SPCOMP2))
use_spcomp2_bits := 1
endif
# For Arnold builds, do:
#
# make OIIO_ARNOLD=1
#
# Otherwise a default 'make' will make a fully generic OIIO build.
ifeq (1,$(use_spcomp2_bits))
include ${working_dir}/site/spi/Makefile-bits-spcomp2
OIIO_ARNOLD ?= 0
OIIO_VERS = $(shell grep "OpenImageIO VERSION" CMakeLists.txt | egrep -o "[0-9.]+")
ifeq (${OIIO_ARNOLD},1)
$(info Building for Arnold)
NAMESPACE ?= 'OpenImageIO_Arnold'
$(info Building generic OpenImageIO)
# NAMESPACE ?= 'OpenImageIO'
endif
#$(info MAKECMDGOALS = $(MAKECMDGOALS))
## Detect which SPI platform and set $platform, $COMPILER, $SPCOMP2_COMPILER,
## and PYTHON_VERSION. Lots of other decisions are based on these.
ifeq (${SP_OS}, rhel7)
# Rhel7 (current)
platform := rhel7
SPI_COMPILER_PLATFORM ?= gcc-6.3
ifeq (${SPI_COMPILER_PLATFORM},gcc-6.3)
SPCOMP2_COMPILER ?= gcc63
CMAKE_CXX_STANDARD ?= 14
LLVM_VERSION ?= 12.0.1
endif
SP_PLATFORM ?= linux
else ifeq (${platform}, macosx)
# Generic OSX machines (including LG's laptop)
COMPILER ?= clang
SPCOMP2_COMPILER ?= clang
CMAKE_CXX_STANDARD ?= 14
SP_OS ?= macosx
SP_PLATFORM ?= macosx
else
include ${working_dir}/site/spi/Makefile-bits-arnold
$(error Unknown SP_OS=${SP_OS} platform=${platform})
endif # endif ${SP_OS}
MY_CMAKE_FLAGS += -DSP_OS=${SP_OS} -DSP_PLATFORM=${SP_PLATFORM}
MY_CMAKE_FLAGS += -DSPI_COMPILER_PLATFORM=${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DEXTRA_CPP_ARGS:STRING="-DOIIO_SPI=1" -DOIIO_SITE:STRING=spi
MY_CMAKE_FLAGS += -DSPI_TESTS=1 -DPROJECT_VERSION_RELEASE_TYPE=spi
MY_CMAKE_FLAGS += -DOIIO_NAMESPACE_INCLUDE_PATCH=1
MY_CMAKE_FLAGS += -DCMAKE_DEBUG_POSTFIX=${CMAKE_DEBUG_POSTFIX:-_d}
REZ_PACKAGE_ROOT ?= /shots/spi/home/software/packages
SPCOMP2_ROOT ?= /shots/spi/home/lib/SpComp2
## Rhel7 (current)
ifeq (${SP_OS}, rhel7)
PYTHON_VERSION ?= 2.7
USE_SIMD ?= sse4.1,aes
CMAKE ?= cmake
USE_NINJA ?= 1
NINJA ?= ninja
ifeq ($(USE_NINJA),1)
MY_CMAKE_FLAGS += -DCMAKE_MAKE_PROGRAM=${NINJA}
endif
export CCACHE_CPP2 ?= 1
# Override lib64 and use SPI convention of lib
MY_CMAKE_FLAGS += -DCMAKE_INSTALL_LIBDIR="${INSTALL_PREFIX}/lib"
ifeq (${OIIO_SPCOMP2},1)
MY_CMAKE_FLAGS += -DPYTHON_SITE_DIR="${INSTALL_PREFIX}/python"
else ifeq (${OIIO_ARNOLD},1)
OIIO_LIBNAME_SUFFIX=_Arnold
endif
#
# Compilers:
#
# A variety of tags can be used to try specific versions of gcc or
# clang from the site-specific places we have installed them.
LLVM_DIRECTORY ?= ${REZ_PACKAGE_ROOT}/llvm/${LLVM_VERSION}/${SPI_COMPILER_PLATFORM}
ifeq (${COMPILER},clang9)
LLVM_DIRECTORY := ${REZ_PACKAGE_ROOT}/llvm/9.0.1-1/${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang -DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang10)
LLVM_DIRECTORY := ${REZ_PACKAGE_ROOT}/llvm/10.0.0-1/${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang -DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang11)
LLVM_DIRECTORY := ${REZ_PACKAGE_ROOT}/llvm/11.0.0/${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang -DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
else ifeq (${COMPILER}, gcc6)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/opt/rh/devtoolset-6/root/usr/bin/gcc \
-DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-6/root/usr/bin/g++
else ifeq (${COMPILER},gcc)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
else ifeq (${COMPILER},)
# default compiler is clang, taken from the LLVM directory
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
endif
#
# Boost
#
BOOSTVERS ?= 1.70
SPBOOST_INC_DIR := /usr/include/boostroot/boost${BOOSTVERS}.0
SPBOOST_LIB_DIR := /usr/lib64/boostroot/boost${BOOSTVERS}.0
MY_CMAKE_FLAGS += \
-DBOOST_INCLUDEDIR=${SPBOOST_INC_DIR} \
-DBOOST_LIBRARYDIR=${SPBOOST_LIB_DIR}
#
# Python
#
PYTHON_INCLUDE_DIR ?= /usr/include/python${PYTHON_VERSION}
PYTHON_LIBRARY_DIR ?= /usr/lib64
PYTHON_LIBRARY ?= ${PYTHON_LIBRARY_DIR}/libpython${PYTHON_VERSION}.so
ifeq (${PYTHON_VERSION},3.7)
# Special sauce for Python 3.7
PYTHON_INCLUDE_DIR := /usr/include/python${PYTHON_VERSION}m
PYTHON_LIBRARY := ${PYTHON_LIBRARY_DIR}/libpython${PYTHON_VERSION}m.so
MY_CMAKE_FLAGS += \
-DPYTHONINTERP_FOUND=1 \
-DPYTHON_VERSION_STRING=3.7.3 \
-DPYTHON_VERSION_MAJOR=3 \
-DPYTHON_VERSION_MINOR=7 \
-DPYTHON_VERSION_PATCH=3 \
-DPython_ADDITIONAL_VERSIONS="${PYTHON_VERSION}"
else ifeq (${PYTHON_VERSION},2.7)
# Special sauce for Python 2.7
PYTHON_INCLUDE_DIR := /usr/include/python${PYTHON_VERSION}
PYTHON_LIBRARY := ${PYTHON_LIBRARY_DIR}/libpython${PYTHON_VERSION}.so
MY_CMAKE_FLAGS += \
-DPYTHONINTERP_FOUND=1 \
-DPYTHON_VERSION_STRING=2.7.5 \
-DPYTHON_VERSION_MAJOR=2 \
-DPYTHON_VERSION_MINOR=7 \
-DPYTHON_VERSION_PATCH=5 \
-DPython_ADDITIONAL_VERSIONS="${PYTHON_VERSION}"
endif
MY_CMAKE_FLAGS += \
-DPYTHON_INCLUDE_DIR:STRING=${PYTHON_INCLUDE_DIR} \
-DPYTHON_LIBRARY:STRING=${PYTHON_LIBRARY} \
-Dpybind11_ROOT:STRING=${REZ_PACKAGE_ROOT}/pybind11/2.6.2/python-${PYTHON_VERSION}
# Set our preferred OpenEXR path, but allow env variable to override
# with custom/test version.
OPENEXR_VERSION ?= 2.4.3
OpenEXR_ROOT ?= ${REZ_PACKAGE_ROOT}/OpenEXR/${OPENEXR_VERSION}/${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DOpenEXR_ROOT=${OpenEXR_ROOT}
#
# SpComp2 and other weird SPI-installed packages
#
NUKE_VERSION ?= 11.2v3
SPCOMP2_FULLBOOST_SUFFIX = ${SP_OS}-${SPCOMP2_COMPILER}-boost${shell echo ${BOOSTVERS} | sed "s/\\.//"}
# $(info SPCOMP2_FULLBOOST_SUFFIX ${SPCOMP2_FULLBOOST_SUFFIX})
OPENCOLORIO_VERSION ?= 2.1.0
OpenColorIO_ROOT ?= ${REZ_PACKAGE_ROOT}/OpenColorIO/${OPENCOLORIO_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}
#MY_CMAKE_FLAGS += -DOPENCOLORIO_LIBRARY=${OpenColorIO_ROOT}/lib/libOpenColorIO_SPI.so
OPENVDB_VERSION ?= 8.0.0-2
OpenVDB_ROOT ?= ${REZ_PACKAGE_ROOT}/OpenVDB/${OPENVDB_VERSION}/${SPI_COMPILER_PLATFORM}/python-${PYTHON_VERSION}/boost-${BOOSTVERS}
TBB_ROOT ?= /net/apps/rhel7/intel/tbb
TBB_LIBRARY ?= /net/apps/rhel7/intel/tbb/lib/intel64/gcc4.7
Libheif_ROOT ?= /shots/spi/home/lib/arnold/rhel7/libheif-1.3.2
MY_CMAKE_FLAGS += \
-DOpenColorIO_ROOT=${OpenColorIO_ROOT} \
-DOpenVDB_ROOT=${OpenVDB_ROOT} \
-DTBB_ROOT=${TBB_ROOT} \
-DTBB_LIBRARY=${TBB_LIBRARY} \
-DTBB_USE_DEBUG_BUILD=0 \
-DHDF5_CUSTOM=1 \
-DHDF5_LIBRARIES=/usr/lib64/libhdf5.so \
-DNuke_ROOT=/net/apps/rhel7/foundry/nuke${NUKE_VERSION} \
-DLibheif_ROOT=${Libheif_ROOT} \
-DFFMPEG_INCLUDES=/usr/include/ffmpegroot/ffmpeg42 \
-DFFMPEG_LIBRARIES="/usr/lib64/ffmpegroot/ffmpeg424/libavcodec.so;/usr/lib64/ffmpegroot/ffmpeg424/libavformat.so;/usr/lib64/ffmpegroot/ffmpeg424/libavutil.so;/usr/lib64/ffmpegroot/ffmpeg424/libswscale.so;" \
-DUSE_OPENCV=0 \
-DVISIBILITY_MAP_FILE:STRING="${working_dir}/site/spi/hidesymbols.map"
# LibRaw
LibRaw_ROOT ?= ${REZ_PACKAGE_ROOT}/LibRaw/0.21.0.0/${SPI_COMPILER_PLATFORM}
MY_CMAKE_FLAGS += -DLibRaw_ROOT=${LibRaw_ROOT}
LIBRAW_LIBDIR = ${LibRaw_ROOT}/lib
MY_CMAKE_FLAGS += -DWebP_ROOT=${REZ_PACKAGE_ROOT}/webp/1.2.1/${SPI_COMPILER_PLATFORM}
# Use libtiff I built myself, static, and try to hide its symbols.
MY_CMAKE_FLAGS += \
-DTIFF_INCLUDE_DIR:STRING=/usr/include \
-DTIFF_LIBRARIES:STRING=/net/soft_scratch/users/lg/tiff-4.0.3/rhel7/lib/libtiff.a \
-DEXTRA_DSO_LINK_ARGS:STRING="-Wl,--exclude-libs,libtiff.a"
# end rhel7
## Generic OSX machines (including LG's laptop)
else ifeq (${platform}, macosx)
USE_SIMD ?= sse4.2
MY_CMAKE_FLAGS += \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=1 \
-DCMAKE_INSTALL_NAME_DIR="${working_dir}/dist/lib"
# A variety of tags can be used to try specific versions of gcc or
# clang from the site-specific places we have installed them.
ifeq (${COMPILER}, gcc6)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-6 -DCMAKE_CXX_COMPILER=g++-6
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER}, gcc9)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-9 -DCMAKE_CXX_COMPILER=g++-9
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER}, gcc10)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER}, gcc11)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER},clang13)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=/usr/local/opt/llvm@13/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@13/bin/clang++
else ifeq (${COMPILER},clang14)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=/usr/local/opt/llvm@14/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@14/bin/clang++
else ifeq (${COMPILER},clang15)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=/usr/local/opt/llvm@15/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@15/bin/clang++
else ifeq (${COMPILER},clang16)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=/usr/local/opt/llvm@16/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@16/bin/clang++
else ifeq (${COMPILER},clang)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
else ifeq (${COMPILER},gcc)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
else ifeq (${COMPILER},)
# default compiler is clang, taken from the LLVM directory
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
endif
# end generic OSX
else
$(error Unknown SP_OS=${SP_OS} platform=${platform})
endif # endif ${SP_OS}
ifneq (${VERBOSE},)
$(info MY_CMAKE_FLAGS: $(MY_CMAKE_FLAGS))
endif
MY_CMAKE_FLAGS += -DSPI_TESTS=1
-248
View File
@@ -1,248 +0,0 @@
# SPI-specific settings
ifneq (${VERBOSE},)
$(info Including spi/Makefile-bits-arnold)
endif
# READ THIS FIRST
#
# If you are building for Arnold, just make.
# Default namespace
NAMESPACE ?= 'OpenImageIO_Arnold'
MY_CMAKE_FLAGS += -DEXTRA_CPP_ARGS:STRING="-DOIIO_SPI=1" -DOIIO_SITE:STRING=SPI
SPCOMP2_SHOTTREE_LOCATION = /shots/spi/home/lib/SpComp2
INSTALL_SPCOMP2_LOCATION = /shots/spi/home/lib/SpComp2
NUKE_VERSION ?= 10.0v4
## Detect which SPI platform and set $platform, $COMPILER, $SPCOMP2_COMPILER,
## and PYVER. Lots of other decisions are based on these.
ifeq ($(SP_OS), rhel7)
# Rhel7 (current)
platform := rhel7
COMPILER ?= clang40
SPCOMP2_COMPILER=gcc48m64
else ifeq (${SP_OS}, lion)
# Official OS X build machines with special conventions
platform := lion
COMPILER ?= clang
SPCOMP2_COMPILER ?= clang
else ifeq (${platform}, macosx)
# Generic OSX machines (including LG's laptop)
COMPILER ?= clang
SPCOMP2_COMPILER ?= clang
PYVER ?= 2.6
else
$(error Unknown SP_OS)
endif # endif $(SP_OS)
PYVER ?= 2.7
OCIO_SPCOMP_VERSION ?= 2
## Rhel7 (current)
ifeq ($(SP_OS), rhel7)
USE_CPP ?= 11
USE_SIMD ?= sse4.1
CMAKE ?= cmake
USE_NINJA ?= 1
NINJA ?= ninja
ifeq ($(USE_NINJA),1)
MY_CMAKE_FLAGS += -DCMAKE_MAKE_PROGRAM=${NINJA}
endif
export CCACHE_CPP2 ?= 1
BOOSTVERS ?= 1.55
SPCOMP2_USE_BOOSTVERS ?= 1
OCIO_PATH ?= "${SPCOMP2_SHOTTREE_LOCATION}/OpenColorIO/${SP_OS}-${SPCOMP2_COMPILER}/v${OCIO_SPCOMP_VERSION}"
FIELD3D_HOME ?= "${INSTALL_SPCOMP2_LOCATION}/Field3D/${SP_OS}-${SPCOMP2_COMPILER}-boost155sp/v408"
## If not overridden, here is our preferred LLVM installation
## (may be changed as new versions are rolled out to the facility)
LLVM_DIRECTORY ?= /shots/spi/home/lib/arnold/spinux1/llvm_3.5
# A variety of tags can be used to try specific versions of gcc or
# clang from the site-specific places we have installed them.
ifeq (${COMPILER}, clang342)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/shots/spi/home/lib/arnold/spinux1/llvm_3.4.2/bin/clang \
-DCMAKE_CXX_COMPILER=/shots/spi/home/lib/arnold/spinux1/llvm_3.4.2/bin/clang++
else ifeq (${COMPILER}, clang35)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/shots/spi/home/lib/arnold/spinux1/llvm_3.5/bin/clang \
-DCMAKE_CXX_COMPILER=/shots/spi/home/lib/arnold/spinux1/llvm_3.5/bin/clang++
else ifeq (${COMPILER},clang38)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang-3.8 -DCMAKE_CXX_COMPILER=clang++-3.8
else ifeq (${COMPILER},clang39)
LLVM_DIRECTORY := /shots/spi/home/lib/arnold/rhel7/llvm_3.9
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang -DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang40)
LLVM_DIRECTORY := /shots/spi/home/lib/arnold/rhel7/llvm_4.0
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang -DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
else ifeq (${COMPILER}, gcc490)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.9-20130512-test/bin/gcc \
-DCMAKE_CXX_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.9-20130512-test/bin/g++
else ifeq (${COMPILER},gcc)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
else ifeq (${COMPILER},)
# default compiler is clang, taken from the LLVM directory
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
endif
MY_CMAKE_FLAGS += \
-DOPENEXR_CUSTOM_INCLUDE_DIR=/usr/include/OpenEXR2 \
-DOPENEXR_CUSTOM_LIB_DIR=/usr/lib64/OpenEXR2 \
-DOCIO_PATH=${OCIO_PATH} \
-DFIELD3D_HOME=${FIELD3D_HOME} \
-DHDF5_CUSTOM=1 \
-DHDF5_LIBRARIES=/usr/lib64/libhdf5.so \
-DNuke_ROOT=/net/apps/rhel7/foundry/nuke${NUKE_VERSION}
BOOSTVERSSP=${BOOSTVERS}sp
BOOSTVERS_SUFFIX = -${shell echo ${BOOSTVERS} | sed "s/\\./_/"}
BOOSTVERS_PREFIX = ${shell echo ${BOOSTVERS} | sed "s/\\./_/"}_0
CONSTRUCTED_BOOSTVERS = ${shell echo ${BOOSTVERS} | sed "s/\\./0/"}00
MY_CMAKE_FLAGS += \
-DBOOST_CUSTOM=1 \
-DBoost_VERSION=${CONSTRUCTED_BOOSTVERS} \
-DBoost_INCLUDE_DIRS=/usr/include/boost_${BOOSTVERSSP} \
-DBoost_LIBRARY_DIRS=/usr/lib64/boost_${BOOSTVERSSP} \
-Dboost_PYTHON_FOUND=1 -DPYTHONLIBS_FOUND=1 \
-DBoost_LIBRARIES:STRING="/usr/lib64/boost_${BOOSTVERSSP}/libspboost_${BOOSTVERS_PREFIX}_filesystem-gcc48-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERSSP}/libspboost_${BOOSTVERS_PREFIX}_filesystem-gcc48-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERSSP}/libspboost_${BOOSTVERS_PREFIX}_regex-gcc48-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERSSP}/libspboost_${BOOSTVERS_PREFIX}_system-gcc48-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERSSP}/libspboost_${BOOSTVERS_PREFIX}_thread-gcc48-mt${BOOSTVERS_SUFFIX}.so" \
-DBoost_PYTHON_LIBRARIES:STRING="/usr/lib64/boost_${BOOSTVERSSP}/libspboost_${BOOSTVERS_PREFIX}_python-gcc48-mt${BOOSTVERS_SUFFIX}.so" \
-DPYTHON_LIBRARIES:STRING="/usr/lib64/libpython${PYVER}.so"
# FIXME: Force use of libtiff 3.9.4 because libtiff symbols are not
# namespaced, and if we compile OIIO against the system default of
# 4.0.x, but it's used by a Maya plugin and Maya links against the old
# libtiff.so.3, we get crashes. Hopefully we can come back to this and
# upgrade to libtiff 4.x later.
# MY_CMAKE_FLAGS += -DTIFF_INCLUDE_DIR:STRING=/usr/include/libtiff-3.9.4 \
# -DTIFF_LIBRARIES:STRING=/usr/lib64/libtiff.so.3
# No, for now, just use libtiff I built myself, static, and try to
# hide its symbols.
MY_CMAKE_FLAGS += -DTIFF_INCLUDE_DIR:STRING=/usr/include \
-DTIFF_LIBRARIES:STRING=/net/soft_scratch/users/lg/tiff-4.0.3/rhel7/lib/libtiff.a
MY_CMAKE_FLAGS += -DHIDE_SYMBOLS=1
MY_CMAKE_FLAGS += -DVISIBILITY_MAP_FILE:STRING="${working_dir}/site/spi/hidesymbols.map"
MY_CMAKE_FLAGS += -DEXTRA_DSO_LINK_ARGS:STRING="-Wl,--exclude-libs,libtiff.a"
MY_CMAKE_FLAGS += -DUSE_OPENCV=0
# end rhel7
## Official OS X build machines with special conventions
else ifeq ($(SP_OS), lion)
USE_CPP ?= 11
USE_SIMD ?= sse4.2
MACPORTS_PREFIX=/opt/local-10.7-2012-08
OCIO_PATH ?= "${SPCOMP2_SHOTTREE_LOCATION}/OpenColorIO/${SP_OS}-${SPCOMP2_COMPILER}/v${OCIO_SPCOMP_VERSION}"
FIELD3D_HOME ?= "${INSTALL_SPCOMP2_LOCATION}/Field3D/${SP_OS}-${SPCOMP2_COMPILER}-boost151/v306"
# CMAKE_CXX_COMPILER:
# otherwise g++ is used and SPI standardized on clang.
# CMAKE_INSTALL_NAME_DIR:
# without libraries and applications linking against this
# library will not be able to find it at run time; prepends
# "@rpath/" to the internal ID
# OVERRIDE_SHARED_LIBRARY_SUFFIX:
# Set to .so so that shared libraries end in .so to be consistent
# with Linux SpComp2 shared libraries
# PYTHON_EXECUTABLE:
# PYTHON_INCLUDE_DIR:
# PYTHON_LIBRARY:
# Use MacPorts' Python
# ZLIB_ROOT:
# Needed to use SPI's MacPorts' zlib.
MY_CMAKE_FLAGS += \
-DOCIO_PATH="${OCIO_PATH}" \
-DFIELD3D_HOME=${FIELD3D_HOME} \
-DOPENJPEG_HOME=${MACPORTS_PREFIX} \
-DOVERRIDE_SHARED_LIBRARY_SUFFIX=.so \
-DPYTHON_EXECUTABLE=${MACPORTS_PREFIX}/bin/python${PYVER} \
-DPYTHON_INCLUDE_DIR=${MACPORTS_PREFIX}/Library/Frameworks/Python.framework/Versions/2.7/Headers \
-DPYTHON_LIBRARIES=${MACPORTS_PREFIX}/Library/Frameworks/Python.framework/Versions/2.7/Python \
-DZLIB_ROOT=${MACPORTS_PREFIX}
MY_CMAKE_FLAGS += \
-DCMAKE_INSTALL_NAME_DIR="${working_dir}/dist/${SP_OS}${variant}/lib"
ifeq (${SPCOMP2_USE_BOOSTVERS}, 1)
BOOSTVERS_UNDERSCORE = ${shell echo ${BOOSTVERS} | sed "s/\\./_/"}
MY_CMAKE_FLAGS += \
-DBOOST_CUSTOM=1 \
-DBoost_INCLUDE_DIRS=/usr/include/boost_${BOOSTVERS} \
-DBoost_LIBRARY_DIRS=/usr/lib64/boost_${BOOSTVERS} \
-DBoost_LIBRARIES=optimized;/usr/lib64/boost_${BOOSTVERS}/libboost_filesystem-gcc44-mt-${BOOSTVERS_UNDERSCORE}.so;optimized;/usr/lib64/boost_${BOOSTVERS}/libboost_filesystem-gcc44-mt-${BOOSTVERS_UNDERSCORE}.so;optimized;/usr/lib64/boost_${BOOSTVERS}/libboost_regex-gcc44-mt-${BOOSTVERS_UNDERSCORE}.so;optimized;/usr/lib64/boost_${BOOSTVERS}/libboost_system-gcc44-mt-${BOOSTVERS_UNDERSCORE}.so;optimized;/usr/lib64/boost_${BOOSTVERS}/libboost_thread-gcc44-mt-${BOOSTVERS_UNDERSCORE}.so
endif
# end SPI lion
## Generic OSX machines (including LG's laptop)
else ifeq (${platform}, macosx)
USE_SIMD ?= sse4.2
MY_CMAKE_FLAGS += \
-DCMAKE_INSTALL_NAME_DIR="${working_dir}/dist/${platform}${variant}/lib"
# don't need this? -DBUILD_WITH_INSTALL_RPATH=1
# A variety of tags can be used to try specific versions of gcc or
# clang from the site-specific places we have installed them.
ifeq (${COMPILER}, gcc48)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-4.8 -DCMAKE_CXX_COMPILER=g++-4.8
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER}, gcc49)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-4.9 -DCMAKE_CXX_COMPILER=g++-4.9
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER}, gcc5)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-5 -DCMAKE_CXX_COMPILER=g++-5
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER}, gcc6)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=gcc-6 -DCMAKE_CXX_COMPILER=g++-6
USE_LIBCPLUSPLUS := 0
else ifeq (${COMPILER},clang35)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang-3.5 -DCMAKE_CXX_COMPILER=clang++-3.5
else ifeq (${COMPILER},clang38)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang-3.8 -DCMAKE_CXX_COMPILER=clang++-3.8
else ifeq (${COMPILER},clang)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
else ifeq (${COMPILER},gcc)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
else ifeq (${COMPILER},)
# default compiler is clang, taken from the LLVM directory
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
endif
# end generic OSX
else
$(error Unknown SP_OS)
endif # endif $(SP_OS)
SPARCH=$(SP_OS)-$(SPCOMP2_COMPILER)
ifdef SPCOMP2_USE_BOOSTVERS
ifneq ($(BOOSTVERS),1.42)
SPARCH=$(SP_OS)-$(SPCOMP2_COMPILER)-boost$(subst .,,$(BOOSTVERS))
endif
endif
PYVERNOSPACE=${shell echo ${PYVER} | sed "s/\\.//"}
SPPYARCH=$(SPARCH)-py$(PYVERNOSPACE)
all: dist
.PHONY: spcomp2_install spcomp2_install_local clean all
comma:= ,
empty:=
space:= $(empty) $(empty)
local: dist
-356
View File
@@ -1,356 +0,0 @@
# SPI-specific settings
ifneq (${VERBOSE},)
$(info Including spi/Makefile-bits-spcomp2)
endif
# READ THIS FIRST
#
# If you are building for installation as an SpComp2, make like this:
# 1) On Linux, you must be setshot, for patchelf to be found; on
# Mac OS X, no need to be setshot, just make sure SP_OS=lion and
# COMPILER=clang.
# 2) make spcomp2_install_local
# or 2) make spcomp2_install
#
# Other notes about the SpComp2:
# - it also tries to install OIIO's binaries alongside the libs. It would
# be really nice if somebody would either appwrap those binaries or
# symlink them to an spi show path on each install. For the moment
# though, they are just there for people who know.
# - it would also be nice if we had a convention for tagging SpComp2
# release versions on the svn server.
#
OPENIMAGEIO_SPCOMP2_VERSION=41
# Default namespace
NAMESPACE ?= 'OpenImageIO_SPI'
MY_CMAKE_FLAGS += -DEXTRA_CPP_ARGS:STRING="-DOIIO_SPI=1" -DOIIO_SITE:STRING=SPI
SOVERSION ?= ${OPENIMAGEIO_SPCOMP2_VERSION}
SPCOMP2_SHOTTREE_LOCATION = /shots/spi/home/lib/SpComp2
INSTALL_SPCOMP2_LOCATION = /shots/spi/home/lib/SpComp2
NUKE_VERSION ?= 10.0v4
PYLIB_LIB_PREFIX ?= 1
PYLIB_INCLUDE_SONAME ?= 1
CPPSTDSUFFIX=
## Detect which SPI platform and set $platform, $COMPILER, $SPCOMP2_COMPILER,
## and PYVER. Lots of other decisions are based on these.
ifeq ($(SP_OS), rhel7)
# Rhel7 (current)
platform := rhel7
SPCOMP2_COMPILER ?= gcc48m64
# On RHEL7, we need to make a variant that disables C++11 to link
# cleanly with Maya 2015, which is built against gcc 4.1, ugh.
ifeq ($(USE_CPP11),0)
CPPSTDSUFFIX=-c++03
endif
else ifeq (${SP_OS}, lion)
# Official OS X build machines with special conventions
platform := lion
COMPILER ?= clang
SPCOMP2_COMPILER ?= clang
else ifeq (${platform}, macosx)
# Generic OSX machines (including LG's laptop)
COMPILER ?= clang
SPCOMP2_COMPILER ?= clang
PYVER ?= 2.6
else
$(error Unknown SP_OS)
endif # endif $(SP_OS)
PYVER ?= 2.7
OCIO_SPCOMP_VERSION ?= 2
OIIO_SPCOMP2_PATH ?= ${SPCOMP2_SHOTTREE_LOCATION}/OpenImageIO/${SP_OS}-${SPCOMP2_COMPILER}$(CPPSTDSUFFIX)/v${OPENIMAGEIO_SPCOMP2_VERSION}
## Rhel7 (current)
ifeq ($(SP_OS), rhel7)
USE_CPP ?= 11
USE_SIMD ?= sse4.1
CMAKE ?= cmake
USE_NINJA ?= 0
NINJA ?= ninja
ifeq ($(USE_NINJA),1)
MY_CMAKE_FLAGS += -DCMAKE_MAKE_PROGRAM=${NINJA}
endif
export CCACHE_CPP2 ?= 1
BOOSTVERS ?= 1.55
SPCOMP2_USE_BOOSTVERS ?= 1
BOOSTSPSUFFIX ?= sp
BOOSTVERSSP=${BOOSTVERS}${BOOSTSPSUFFIX}
BOOSTVERS_SUFFIX = -${shell echo ${BOOSTVERS} | sed "s/\\./_/"}
BOOSTVERS_PREFIX = ${shell echo ${BOOSTVERS} | sed "s/\\./_/"}_0
CONSTRUCTED_BOOSTVERS = ${shell echo ${BOOSTVERS} | sed "s/\\./0/"}00
SPCOMP2_BOOSTVERS_SUFFIX = ${shell echo ${BOOSTVERSSP} | sed "s/\\.//"}
# $(info BOOSTVERSSP ${BOOSTVERSSP})
# $(info BOOSTVERS_SUFFIX ${BOOSTVERS_SUFFIX})
# $(info BOOSTVERS_PREFIX ${BOOSTVERS_PREFIX})
# $(info CONSTRUCTED_BOOSTVERS ${CONSTRUCTED_BOOSTVERS})
# $(info SPCOMP2_BOOSTVERS_SUFFIX ${SPCOMP2_BOOSTVERS_SUFFIX})
OCIO_PATH ?= ${SPCOMP2_SHOTTREE_LOCATION}/OpenColorIO/${SP_OS}-${SPCOMP2_COMPILER}/v${OCIO_SPCOMP_VERSION}
# FIELD3D_HOME ?= ${SPCOMP2_SHOTTREE_LOCATION}/Field3D/${SP_OS}-${SPCOMP2_COMPILER}-boost155${BOOSTSPSUFFIX}/v408
OIIO_SPCOMP2_PATH := ${SPCOMP2_SHOTTREE_LOCATION}/OpenImageIO/${SP_OS}-${SPCOMP2_COMPILER}$(CPPSTDSUFFIX)-boost${SPCOMP2_BOOSTVERS_SUFFIX}/v${OPENIMAGEIO_SPCOMP2_VERSION}
$(info New rhel7 OIIO_SPCOMP2_PATH is ${OIIO_SPCOMP2_PATH})
## If not overridden, here is our preferred LLVM installation
## (may be changed as new versions are rolled out to the facility)
LLVM_DIRECTORY ?= /shots/spi/home/lib/arnold/spinux1/llvm_3.5
# A variety of tags can be used to try specific versions of gcc or
# clang from the site-specific places we have installed them.
ifeq (${COMPILER}, clang342)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/shots/spi/home/lib/arnold/spinux1/llvm_3.4.2/bin/clang \
-DCMAKE_CXX_COMPILER=/shots/spi/home/lib/arnold/spinux1/llvm_3.4.2/bin/clang++
else ifeq (${COMPILER}, clang35)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/shots/spi/home/lib/arnold/spinux1/llvm_3.5/bin/clang \
-DCMAKE_CXX_COMPILER=/shots/spi/home/lib/arnold/spinux1/llvm_3.5/bin/clang++
else ifeq (${COMPILER},clang38)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang-3.8 -DCMAKE_CXX_COMPILER=clang++-3.8
else ifeq (${COMPILER},clang39)
LLVM_DIRECTORY := /shots/spi/home/lib/arnold/rhel7/llvm_3.9
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang -DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang40)
LLVM_DIRECTORY := /shots/spi/home/lib/arnold/rhel7/llvm_4.0
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang -DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
else ifeq (${COMPILER},clang)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
else ifeq (${COMPILER}, gcc490)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.9-20130512-test/bin/gcc \
-DCMAKE_CXX_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.9-20130512-test/bin/g++
else ifeq (${COMPILER},gcc)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
else ifeq (${COMPILER},)
# default compiler is clang, taken from the LLVM directory
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
endif
MY_CMAKE_FLAGS += \
-DOPENEXR_CUSTOM_INCLUDE_DIR=/usr/include/OpenEXR2 \
-DOPENEXR_CUSTOM_LIB_DIR=/usr/lib64/OpenEXR2 \
-DOCIO_PATH=${OCIO_PATH} \
-DFIELD3D_HOME=${FIELD3D_HOME} \
-DHDF5_CUSTOM=1 \
-DHDF5_LIBRARIES=/usr/lib64/libhdf5.so \
-DNuke_ROOT=/net/apps/rhel7/foundry/nuke${NUKE_VERSION}
MY_CMAKE_FLAGS += \
-DBOOST_CUSTOM=1 \
-DBoost_VERSION=${CONSTRUCTED_BOOSTVERS} \
-DBoost_INCLUDE_DIRS=/usr/include/boost_${BOOSTVERSSP} \
-DBoost_LIBRARY_DIRS=/usr/lib64/boost_${BOOSTVERSSP} \
-Dboost_PYTHON_FOUND=1 -DPYTHONLIBS_FOUND=1 \
-DPYTHON_LIBRARIES:STRING="/usr/lib64/libpython${PYVER}.so"
ifeq (${BOOSTSPSUFFIX}, sp)
MY_CMAKE_FLAGS += \
-DBoost_LIBRARIES:STRING="/usr/lib64/boost_${BOOSTVERSSP}/lib${BOOSTSPSUFFIX}boost_${BOOSTVERS_PREFIX}_filesystem-gcc48-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERSSP}/lib${BOOSTSPSUFFIX}boost_${BOOSTVERS_PREFIX}_filesystem-gcc48-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERSSP}/lib${BOOSTSPSUFFIX}boost_${BOOSTVERS_PREFIX}_regex-gcc48-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERSSP}/lib${BOOSTSPSUFFIX}boost_${BOOSTVERS_PREFIX}_system-gcc48-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERSSP}/lib${BOOSTSPSUFFIX}boost_${BOOSTVERS_PREFIX}_thread-gcc48-mt${BOOSTVERS_SUFFIX}.so" \
-DBoost_PYTHON_LIBRARIES:STRING="/usr/lib64/boost_${BOOSTVERSSP}/lib${BOOSTSPSUFFIX}boost_${BOOSTVERS_PREFIX}_python-gcc48-mt${BOOSTVERS_SUFFIX}.so"
else
MY_CMAKE_FLAGS += \
-DBoost_LIBRARIES:STRING="/usr/lib64/boost_${BOOSTVERSSP}/lib${BOOSTSPSUFFIX}boost_filesystem-gcc48-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERSSP}/lib${BOOSTSPSUFFIX}boost_filesystem-gcc48-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERSSP}/lib${BOOSTSPSUFFIX}boost_regex-gcc48-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERSSP}/lib${BOOSTSPSUFFIX}boost_system-gcc48-mt${BOOSTVERS_SUFFIX}.so;/usr/lib64/boost_${BOOSTVERSSP}/lib${BOOSTSPSUFFIX}boost_thread-gcc48-mt${BOOSTVERS_SUFFIX}.so" \
-DBoost_PYTHON_LIBRARIES:STRING="/usr/lib64/boost_${BOOSTVERSSP}/lib${BOOSTSPSUFFIX}boost_python-gcc48-mt${BOOSTVERS_SUFFIX}.so"
endif
ifneq (${USE_TIFF3},)
# FIXME: for the sake of Maya 2015 (and 2016, and 2017, ugh!), we
# need to link against old libtiff 3.9.4, not the system default
# 4.0.x, to avoid runtime problems when the SpComp2 OIIO is used
# by Maya plugins. We only need to do this for the set of libs we
# build with BOOSTSPSUFFIX == "sp", since that's the only one used
# from within Maya plugins.
MY_CMAKE_FLAGS += -DTIFF_INCLUDE_DIR:STRING=/usr/include/libtiff-3.9.4 \
-DTIFF_LIBRARIES:STRING=/usr/lib64/libtiff.so.3
endif
# No, for now, just use libtiff I built myself, static, and try to
# hide its symbols.
MY_CMAKE_FLAGS += -DTIFF_INCLUDE_DIR:STRING=/usr/include \
-DTIFF_LIBRARIES:STRING=/net/soft_scratch/users/lg/tiff-4.0.3/rhel7/lib/libtiff.a
MY_CMAKE_FLAGS += -DHIDE_SYMBOLS=1
MY_CMAKE_FLAGS += -DVISIBILITY_MAP_FILE:STRING="${working_dir}/site/spi/hidesymbols.map"
MY_CMAKE_FLAGS += -DEXTRA_DSO_LINK_ARGS:STRING="-Wl,--exclude-libs,libtiff.a"
# end rhel7
## Official OS X build machines with special conventions
else ifeq ($(SP_OS), lion)
USE_CPP ?= 11
USE_SIMD ?= sse4.2
MACPORTS_PREFIX=/opt/local-10.7-2012-08
OCIO_PATH ?= "${SPCOMP2_SHOTTREE_LOCATION}/OpenColorIO/${SP_OS}-${SPCOMP2_COMPILER}/v${OCIO_SPCOMP_VERSION}"
FIELD3D_HOME ?= "${INSTALL_SPCOMP2_LOCATION}/Field3D/${SP_OS}-${SPCOMP2_COMPILER}-boost151/v306"
# CMAKE_CXX_COMPILER:
# otherwise g++ is used and SPI standardized on clang.
# CMAKE_INSTALL_NAME_DIR:
# without libraries and applications linking against this
# library will not be able to find it at run time; prepends
# "@rpath/" to the internal ID
# OVERRIDE_SHARED_LIBRARY_SUFFIX:
# Set to .so so that shared libraries end in .so to be consistent
# with Linux SpComp2 shared libraries
# PYTHON_EXECUTABLE:
# PYTHON_INCLUDE_DIR:
# PYTHON_LIBRARY:
# Use MacPorts' Python
# ZLIB_ROOT:
# Needed to use SPI's MacPorts' zlib.
MY_CMAKE_FLAGS += \
-DOCIO_PATH="${OCIO_PATH}" \
-DFIELD3D_HOME=${FIELD3D_HOME} \
-DOPENJPEG_HOME=${MACPORTS_PREFIX} \
-DOVERRIDE_SHARED_LIBRARY_SUFFIX=.so \
-DPYTHON_EXECUTABLE=${MACPORTS_PREFIX}/bin/python${PYVER} \
-DPYTHON_INCLUDE_DIR=${MACPORTS_PREFIX}/Library/Frameworks/Python.framework/Versions/2.7/Headers \
-DPYTHON_LIBRARIES=${MACPORTS_PREFIX}/Library/Frameworks/Python.framework/Versions/2.7/Python \
-DZLIB_ROOT=${MACPORTS_PREFIX}
MY_CMAKE_FLAGS += \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
-DCMAKE_INSTALL_NAME_DIR=@rpath
ifeq (${SPCOMP2_USE_BOOSTVERS}, 1)
BOOSTVERS_UNDERSCORE = ${shell echo ${BOOSTVERS} | sed "s/\\./_/"}
MY_CMAKE_FLAGS += \
-DBOOST_CUSTOM=1 \
-DBoost_INCLUDE_DIRS=/usr/include/boost_${BOOSTVERS} \
-DBoost_LIBRARY_DIRS=/usr/lib64/boost_${BOOSTVERS} \
-DBoost_LIBRARIES=optimized;/usr/lib64/boost_${BOOSTVERS}/libboost_filesystem-gcc44-mt-${BOOSTVERS_UNDERSCORE}.so;optimized;/usr/lib64/boost_${BOOSTVERS}/libboost_filesystem-gcc44-mt-${BOOSTVERS_UNDERSCORE}.so;optimized;/usr/lib64/boost_${BOOSTVERS}/libboost_regex-gcc44-mt-${BOOSTVERS_UNDERSCORE}.so;optimized;/usr/lib64/boost_${BOOSTVERS}/libboost_system-gcc44-mt-${BOOSTVERS_UNDERSCORE}.so;optimized;/usr/lib64/boost_${BOOSTVERS}/libboost_thread-gcc44-mt-${BOOSTVERS_UNDERSCORE}.so
endif
# end SPI lion
## Generic OSX machines (including LG's laptop)
else ifeq (${platform}, macosx)
USE_SIMD ?= sse4.2
MY_CMAKE_FLAGS += \
-DCMAKE_INSTALL_NAME_DIR="${working_dir}/dist/${platform}${variant}/lib"
# don't need this? -DBUILD_WITH_INSTALL_RPATH=1
# A variety of tags can be used to try specific versions of gcc or
# clang from the site-specific places we have installed them.
ifeq (${COMPILER}, gcc5)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/usr/local/bin/gcc-5 -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-5
else ifeq (${COMPILER}, gcc6)
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=/usr/local/bin/gcc-6 -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-6
else ifeq (${COMPILER},clang35)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang-3.5 -DCMAKE_CXX_COMPILER=clang++-3.5
else ifeq (${COMPILER},clang38)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang-3.8 -DCMAKE_CXX_COMPILER=clang++-3.8
else ifeq (${COMPILER},clang)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
else ifeq (${COMPILER},gcc)
MY_CMAKE_FLAGS += -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
else ifeq (${COMPILER},)
# default compiler is clang, taken from the LLVM directory
MY_CMAKE_FLAGS += \
-DCMAKE_C_COMPILER=${LLVM_DIRECTORY}/bin/clang \
-DCMAKE_CXX_COMPILER=${LLVM_DIRECTORY}/bin/clang++
endif
# end generic OSX
else
$(error Unknown SP_OS)
endif # endif $(SP_OS)
SPARCH=$(SP_OS)-$(SPCOMP2_COMPILER)$(CPPSTDSUFFIX)
BOOSTVERSSP?=${BOOSTVERS}${BOOSTSPSUFFIX}
ifdef SPCOMP2_USE_BOOSTVERS
ifneq ($(BOOSTVERS),1.42)
SPARCH=$(SP_OS)-$(SPCOMP2_COMPILER)$(CPPSTDSUFFIX)-boost$(subst .,,$(BOOSTVERSSP))
endif
endif
PYVERNOSPACE=${shell echo ${PYVER} | sed "s/\\.//"}
SPPYARCH=$(SPARCH)-py$(PYVERNOSPACE)
all: dist
.PHONY: spcomp2_install spcomp2_install_local clean all
comma:= ,
empty:=
space:= $(empty) $(empty)
INSTALL_BIN_LOCATION = /shots/spi/home/bin/$(SP_OS)
INSTALL_SPCOMP2_CURRENT = $(INSTALL_SPCOMP2_LOCATION)/OpenImageIO/$(SPARCH)/v$(OPENIMAGEIO_SPCOMP2_VERSION)
SPCOMP2_RPATH_OPT ?= ${OCIO_PATH}/lib:${FIELD3D_HOME}/lib
SPCOMP2_RPATH_DEBUG ?= ${OCIO_PATH}/lib/debug:${FIELD3D_HOME}/lib/debug
PYSPCOMP2_RPATH_OPT ?= ${SPCOMP2_RPATH_OPT}:${OIIO_SPCOMP2_PATH}/lib
PYSPCOMP2_RPATH_DEBUG ?= ${SPCOMP2_RPATH_DEBUG}:${OIIO_SPCOMP2_PATH}/lib/debug
spcomp2_install_local: INSTALL_SPCOMP2_LOCATION = $(SPCOMP2_LOCAL_PATH)
spcomp2_install_local: INSTALL_BIN_LOCATION = $(INSTALL_SPCOMP2_CURRENT)/bin
spcomp2_install_local: spcomp2_install
local: dist
spcomp2: MY_CMAKE_FLAGS += \
-DCMAKE_SKIP_BUILD_RPATH:BOOL=ON \
-DCMAKE_INSTALL_RPATH=$(INSTALL_SPCOMP2_LOCATION)/OpenImageIO/$(SPARCH)/v$(OPENIMAGEIO_SPCOMP2_VERSION)/lib \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON \
-DPYLIB_INCLUDE_SONAME:BOOL=ON \
-DPYLIB_LIB_PREFIX:BOOL=ON
spcomp2: dist
spcomp2_debug: MY_CMAKE_FLAGS += \
-DCMAKE_SKIP_BUILD_RPATH:BOOL=ON \
-DCMAKE_INSTALL_RPATH=$(INSTALL_SPCOMP2_LOCATION)/OpenImageIO/$(SPARCH)/v$(OPENIMAGEIO_SPCOMP2_VERSION)/lib \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON \
-DPYLIB_INCLUDE_SONAME:BOOL=ON \
-DPYLIB_LIB_PREFIX:BOOL=ON
spcomp2_debug: debug
spcomp2_install_fixup_lion: spcomp2 spcomp2_debug
echo $(INSTALL_SPCOMP2_LOCATION)
install_name_tool -add_rpath ${OCIO_PATH}/lib ${dist_dir}/python/libPyOpenImageIO.so
install_name_tool -add_rpath ${OIIO_SPCOMP2_PATH}/lib ${dist_dir}/python/libPyOpenImageIO.so
install_name_tool -add_rpath ${OCIO_PATH}/lib/debug ${dist_dir}.debug/python/libPyOpenImageIO.so
install_name_tool -add_rpath ${OIIO_SPCOMP2_PATH}/lib/debug ${dist_dir}.debug/python/libPyOpenImageIO.so
spcomp2_install_fixup_rhel7: spcomp2 spcomp2_debug
echo $(INSTALL_SPCOMP2_LOCATION)
patchelf --set-rpath ${SPCOMP2_RPATH_OPT} ${dist_dir}/lib/libOpenImageIO.so
patchelf --set-rpath ${SPCOMP2_RPATH_DEBUG} ${dist_dir}.debug/lib/libOpenImageIO.so
patchelf --set-rpath ${PYSPCOMP2_RPATH_OPT} ${dist_dir}/python/libPyOpenImageIO.so
patchelf --set-rpath ${PYSPCOMP2_RPATH_DEBUG} ${dist_dir}.debug/python/libPyOpenImageIO.so
# This goal can't start with 'install' because something elsewhere picks
# it up and starts doing bad things
spcomp2_install: spcomp2_install_fixup_$(SP_OS)
perl -I/usr/local/spi/lib/make /usr/local/spi/bin/spcomp_install.pl -m installhost \
--project=OpenImageIO \
--version=$(OPENIMAGEIO_SPCOMP2_VERSION) \
--root=$(INSTALL_SPCOMP2_LOCATION) \
--arch=$(SPARCH) \
--headers=$(subst $(space),$(comma),$(wildcard ${dist_dir}/include/OpenImageIO/*)) \
--cflags= --static_lflags="$(LINK_BOOST) $(LINK_OPENEXR) -lpthread" \
--namespace=${NAMESPACE} \
--srcdir=${dist_dir}/lib \
--builddir_o=${dist_dir}/lib \
--builddir_d=${dist_dir}.debug/lib
perl -I/usr/local/spi/lib/make /usr/local/spi/bin/spcomp_install.pl -m installhost \
--project=PyOpenImageIO \
--version=$(OPENIMAGEIO_SPCOMP2_VERSION) \
--root=$(INSTALL_SPCOMP2_LOCATION) \
--arch=$(SPPYARCH) \
--cflags= --static_lflags="$(LINK_BOOST) $(LINK_OPENEXR) -lpthread"\
--namespace=${NAMESPACE} \
--srcdir=${dist_dir}/python \
--builddir_o=${dist_dir}/python \
--builddir_d=${dist_dir}.debug/python
+6
View File
@@ -0,0 +1,6 @@
<cfg>
<version>@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.@PROJECT_VERSION_TWEAK@</version>
<appdir architecture="@SP_OS@">@OIIO_REZ_INSTALL_PATH@</appdir>
<launchprogram></launchprogram>
<setup></setup>
</cfg>
+7
View File
@@ -0,0 +1,7 @@
option (${PROJ_NAME}_SPIREZ "Enable extra bits for building for SPI Rez install" OFF)
set (${PROJ_NAME}_REZ_PACKAGE_NAME CACHE STRING "${PROJECT_NAME}")
if (${PROJ_NAME}_SPIREZ)
set (appcfg_filename "${CMAKE_BINARY_DIR}/${PROJECT_NAME}_${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK}.xml")
configure_file ("${PROJECT_SOURCE_DIR}/site/spi/appcfg.xml.in" "${appcfg_filename}")
endif ()
+25
View File
@@ -0,0 +1,25 @@
# SPDX-License-Identifier: BSD-3-Clause and Apache-2.0
# Copyright Contributors to the OpenImageIO Project.
sonar.host.url=https://sonarcloud.io
# Required metadata
sonar.organization=openimageio
sonar.projectName=OpenImageIO
sonar.projectVersion=1.0
sonar.projectKey=OpenImageIO_oiio
# Source properties
sonar.sources=src
sonar.exclusions=src/doc/**,src/include/OpenImageIO/detail/pugixml/**,src/libutil/stb_sprintf.h,src/libutil/xxhash.cpp,src/include/OpenImageIO/detail/farmhash.h,src/libutil/farmhash.cpp
sonar.sourceEncoding=UTF-8
# C/C++ analyzer properties
sonar.cfamily.build-wrapper-output=build/bw_output
sonar.cfamily.gcov.reportsPath=_coverage
sonar.coverage.exclusions=src/iv/**,src/include/OpenImageIO/detail/pugixml/**,src/include/OpenImageIO/detail/fmt/**,src/libOpenImageIO/kissfft.hh
sonar.cfamily.cache.enabled=true
sonar.cfamily.cache.path=/tmp/sonarcache
sonar.verbose=false
+4
View File
@@ -1 +1,5 @@
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
add_oiio_plugin (bmpinput.cpp bmpoutput.cpp bmp_pvt.cpp)
+100 -139
View File
@@ -1,81 +1,58 @@
/*
Copyright 2008-2009 Larry Gritz and the other authors and contributors.
All Rights Reserved.
// Copyright Contributors to the OpenImageIO project.
// SPDX-License-Identifier: Apache-2.0
// https://github.com/OpenImageIO/oiio
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the software's owners nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
(This is the Modified BSD License)
*/
#include <OpenImageIO/filesystem.h>
#include <OpenImageIO/fmath.h>
#include <OpenImageIO/imageio.h>
#include "bmp_pvt.h"
OIIO_PLUGIN_NAMESPACE_BEGIN
namespace bmp_pvt {
/// Helper - write, with error detection
template <class T>
bool fwrite (FILE *fd, const T *buf) {
size_t n = std::fwrite (buf, sizeof(T), 1, fd);
return n == 1;
template<class T>
bool
fwrite(Filesystem::IOProxy* fd, const T* buf)
{
return fd->write(buf, sizeof(T)) == sizeof(T);
}
/// Helper - read, with error detection
template <class T>
bool fread (FILE *fd, T *buf, size_t itemsize=sizeof(T)) {
size_t n = std::fread (buf, itemsize, 1, fd);
return n == 1;
template<class T>
bool
fread(Filesystem::IOProxy* fd, T* buf, size_t itemsize = sizeof(T))
{
return fd->read(buf, itemsize) == itemsize;
}
bool
BmpFileHeader::read_header (FILE *fd)
BmpFileHeader::read_header(Filesystem::IOProxy* fd)
{
if (!fread(fd, &magic) ||
!fread(fd, &fsize) ||
!fread(fd, &res1) ||
!fread(fd, &res2) ||
!fread(fd, &offset)) {
if (!fread(fd, &magic) || !fread(fd, &fsize) || !fread(fd, &res1)
|| !fread(fd, &res2) || !fread(fd, &offset)) {
return false;
}
if (bigendian ())
swap_endian ();
if (bigendian())
swap_endian();
return true;
}
bool
BmpFileHeader::write_header (FILE *fd)
BmpFileHeader::write_header(Filesystem::IOProxy* fd)
{
if (bigendian ())
swap_endian ();
if (bigendian())
swap_endian();
if (!fwrite(fd, &magic) ||
!fwrite(fd, &fsize) ||
!fwrite(fd, &res1) ||
!fwrite(fd, &res2) ||
!fwrite(fd, &offset)) {
if (!fwrite(fd, &magic) || !fwrite(fd, &fsize) || !fwrite(fd, &res1)
|| !fwrite(fd, &res2) || !fwrite(fd, &offset)) {
return false;
}
@@ -85,147 +62,131 @@ BmpFileHeader::write_header (FILE *fd)
bool
BmpFileHeader::isBmp () const
BmpFileHeader::isBmp() const
{
switch (magic) {
case MAGIC_BM:
case MAGIC_BA:
case MAGIC_CI:
case MAGIC_CP:
case MAGIC_PT:
return true;
case MAGIC_BM:
case MAGIC_BA:
case MAGIC_CI:
case MAGIC_CP:
case MAGIC_PT: return true;
default: return false;
}
return false;
}
void
BmpFileHeader::swap_endian (void)
BmpFileHeader::swap_endian(void)
{
OIIO::swap_endian (&magic);
OIIO::swap_endian (&fsize);
OIIO::swap_endian (&offset);
OIIO::swap_endian(&magic);
OIIO::swap_endian(&fsize);
OIIO::swap_endian(&offset);
}
bool
DibInformationHeader::read_header (FILE *fd)
DibInformationHeader::read_header(Filesystem::IOProxy* fd)
{
if (!fread (fd, &size))
if (!fread(fd, &size))
return false;
if (size == WINDOWS_V3 || size == WINDOWS_V4 || size == WINDOWS_V5) {
if (!fread(fd, &width) ||
!fread(fd, &height) ||
!fread(fd, &cplanes) ||
!fread(fd, &bpp) ||
!fread(fd, &compression) ||
!fread(fd, &isize) ||
!fread(fd, &hres) ||
!fread(fd, &vres) ||
!fread(fd, &cpalete) ||
!fread(fd, &important)) {
if (size == WINDOWS_V3 || size == WINDOWS_V4 || size == WINDOWS_V5
|| size == UNDOCHEADER52 || size == UNDOCHEADER56) {
if (!fread(fd, &width) || !fread(fd, &height) || !fread(fd, &cplanes)
|| !fread(fd, &bpp) || !fread(fd, &compression)
|| !fread(fd, &isize) || !fread(fd, &hres) || !fread(fd, &vres)
|| !fread(fd, &cpalete) || !fread(fd, &important)) {
return false;
}
if ((size == WINDOWS_V3 && bpp == 16 && compression == 3)
|| size == WINDOWS_V4 || size == WINDOWS_V5 || size == UNDOCHEADER52
|| size == UNDOCHEADER56) {
if (!fread(fd, &red_mask) || !fread(fd, &green_mask)
|| !fread(fd, &blue_mask)) {
return false;
}
if (size != UNDOCHEADER52 && !fread(fd, &alpha_mask)) {
return false;
}
}
if (size == WINDOWS_V4 || size == WINDOWS_V5) {
if (!fread (fd, &red_mask) ||
!fread (fd, &blue_mask) ||
!fread (fd, &green_mask) ||
!fread (fd, &alpha_mask) ||
!fread (fd, &cs_type) ||
!fread (fd, &red_x) ||
!fread (fd, &red_y) ||
!fread (fd, &red_z) ||
!fread (fd, &green_x) ||
!fread (fd, &green_y) ||
!fread (fd, &green_z) ||
!fread (fd, &blue_x) ||
!fread (fd, &blue_y) ||
!fread (fd, &blue_z) ||
!fread (fd, &gamma_x) ||
!fread (fd, &gamma_y) ||
!fread (fd, &gamma_z)) {
if (!fread(fd, &cs_type) || !fread(fd, &red_x) || !fread(fd, &red_y)
|| !fread(fd, &red_z) || !fread(fd, &green_x)
|| !fread(fd, &green_y) || !fread(fd, &green_z)
|| !fread(fd, &blue_x) || !fread(fd, &blue_y)
|| !fread(fd, &blue_z) || !fread(fd, &gamma_x)
|| !fread(fd, &gamma_y) || !fread(fd, &gamma_z)) {
return false;
}
}
if (size == WINDOWS_V5) {
if (!fread (fd, &intent) ||
!fread (fd, &profile_data) ||
!fread (fd, &profile_size) ||
!fread (fd, &reserved)) {
if (!fread(fd, &intent) || !fread(fd, &profile_data)
|| !fread(fd, &profile_size) || !fread(fd, &reserved)) {
return false;
}
}
}
else if (size == OS2_V1) {
// some of theses fields are smaller then in WINDOWS_Vx headers,
// so we use hardcoded counts
width = 0;
height = 0;
if (!fread (fd, &width, 2) ||
!fread (fd, &height, 2) ||
!fread (fd, &cplanes) ||
!fread (fd, &bpp)) {
} else if (size == OS2_V1) {
// some of these fields are smaller than in WINDOWS_Vx headers,
// so we read into 16 bit ints and copy.
uint16_t width16 = 0;
uint16_t height16 = 0;
if (!fread(fd, &width16) || !fread(fd, &height16)
|| !fread(fd, &cplanes) || !fread(fd, &bpp)) {
return false;
}
width = width16;
height = height16;
}
if (bigendian ())
swap_endian ();
if (bigendian())
swap_endian();
return true;
}
bool
DibInformationHeader::write_header (FILE *fd)
DibInformationHeader::write_header(Filesystem::IOProxy* fd)
{
if (bigendian ())
swap_endian ();
if (bigendian())
swap_endian();
if (!fwrite (fd, &size) ||
!fwrite (fd, &width) ||
!fwrite (fd, &height) ||
!fwrite (fd, &cplanes) ||
!fwrite (fd, &bpp) ||
!fwrite (fd, &compression) ||
!fwrite (fd, &isize) ||
!fwrite (fd, &hres) ||
!fwrite (fd, &vres) ||
!fwrite (fd, &cpalete) ||
!fwrite (fd, &important)) {
if (!fwrite(fd, &size) || !fwrite(fd, &width) || !fwrite(fd, &height)
|| !fwrite(fd, &cplanes) || !fwrite(fd, &bpp)
|| !fwrite(fd, &compression) || !fwrite(fd, &isize)
|| !fwrite(fd, &hres) || !fwrite(fd, &vres) || !fwrite(fd, &cpalete)
|| !fwrite(fd, &important)) {
return false;
}
return (true);
return true;
}
void
DibInformationHeader::swap_endian ()
DibInformationHeader::swap_endian()
{
OIIO::swap_endian (&size);
OIIO::swap_endian (&width);
OIIO::swap_endian (&height);
OIIO::swap_endian (&cplanes);
OIIO::swap_endian (&bpp);
OIIO::swap_endian (&compression);
OIIO::swap_endian (&isize);
OIIO::swap_endian (&hres);
OIIO::swap_endian (&vres);
OIIO::swap_endian (&cpalete);
OIIO::swap_endian (&important);
OIIO::swap_endian(&size);
OIIO::swap_endian(&width);
OIIO::swap_endian(&height);
OIIO::swap_endian(&cplanes);
OIIO::swap_endian(&bpp);
OIIO::swap_endian(&compression);
OIIO::swap_endian(&isize);
OIIO::swap_endian(&hres);
OIIO::swap_endian(&vres);
OIIO::swap_endian(&cpalete);
OIIO::swap_endian(&important);
}
} // bmp_pvt namespace
} // namespace bmp_pvt
OIIO_PLUGIN_NAMESPACE_END
+111 -192
View File
@@ -1,214 +1,133 @@
/*
Copyright 2008-2009 Larry Gritz and the other authors and contributors.
All Rights Reserved.
// Copyright Contributors to the OpenImageIO project.
// SPDX-License-Identifier: Apache-2.0
// https://github.com/OpenImageIO/oiio
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the software's owners nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
(This is the Modified BSD License)
*/
#ifndef OPENIMAGEIO_BMP_H
#define OPENIMAGEIO_BMP_H
#include <cstdio>
#include "OpenImageIO/imageio.h"
#include "OpenImageIO/filesystem.h"
#include "OpenImageIO/fmath.h"
#pragma once
OIIO_PLUGIN_NAMESPACE_BEGIN
// Docs reminders:
// https://en.wikipedia.org/wiki/BMP_file_format
// https://web.archive.org/web/20150127132443/https://forums.adobe.com/message/3272950
namespace bmp_pvt {
// size of the BMP file header (the first header that occur in BMP file)
const int BMP_HEADER_SIZE = 14;
// size of the BMP file header (the first header that occur in BMP file)
const int BMP_HEADER_SIZE = 14;
// sizes of various DIB haders
const int OS2_V1 = 12;
const int WINDOWS_V3 = 40;
const int WINDOWS_V4 = 108;
const int WINDOWS_V5 = 124;
// sizes of various DIB headers
const int OS2_V1 = 12;
const int WINDOWS_V3 = 40;
const int UNDOCHEADER52 = 52; // 0x34
const int UNDOCHEADER56 = 56; // 0x38
const int WINDOWS_V4 = 108;
const int WINDOWS_V5 = 124;
// bmp magic numbers
const int16_t MAGIC_BM = 0x4D42;
const int16_t MAGIC_BA = 0x4142;
const int16_t MAGIC_CI = 0x4943;
const int16_t MAGIC_CP = 0x5043;
const int16_t MAGIC_PT = 0x5450;
// bmp magic numbers
const int16_t MAGIC_BM = 0x4D42;
const int16_t MAGIC_BA = 0x4142;
const int16_t MAGIC_CI = 0x4943;
const int16_t MAGIC_CP = 0x5043;
const int16_t MAGIC_PT = 0x5450;
//const int32_t RLE4_COMPRESSION = 2;
// store informations about BMP file
class BmpFileHeader {
public:
// reads informations about BMP file
bool read_header (FILE *fd);
const int32_t NO_COMPRESSION = 0; // BI_RGB
const int32_t RLE8_COMPRESSION = 1; // BI_RLE8
const int32_t RLE4_COMPRESSION = 2; // BI_RLE4
// writes information about bmp file to given file
bool write_header (FILE *fd);
// return true if given file is BMP file
bool isBmp () const;
int16_t magic; // used to identify BMP file
int32_t fsize; // size of the BMP file
int16_t res1; // reserved
int16_t res2; // reserved
int32_t offset; //offset of image data
private:
void swap_endian (void);
};
// stores information about bitmap
class DibInformationHeader {
public:
// reads informations about bitmap
bool read_header (FILE *fd);
// writes informations about bitmap
bool write_header (FILE *fd);
int32_t size; // size of the header
int32_t width; // bitmap width in pixels
int32_t height; // bitmap height in pixels
int16_t cplanes; // number of color planes - always 1
int16_t bpp; // number of bits per pixel, image color depth
int32_t compression; // compression used in file
int32_t isize; // size of the raw image data
int32_t hres; // horizontal resolution in pixels per meter
int32_t vres; // vertical resolutions in pixels per meter
int32_t cpalete; // number of entries in the color palete
int32_t important; // number of importatn color used,
// 0 - all colors are important,
// in most cases ignored
// added in Version 4 of the format
int32_t red_mask;
int32_t blue_mask;
int32_t green_mask;
int32_t alpha_mask;
int32_t cs_type; //color space type
int32_t red_x;
int32_t red_y;
int32_t red_z;
int32_t green_x;
int32_t green_y;
int32_t green_z;
int32_t blue_x;
int32_t blue_y;
int32_t blue_z;
int32_t gamma_x;
int32_t gamma_y;
int32_t gamma_z;
// added in Version 5 of the format
int32_t intent;
int32_t profile_data;
int32_t profile_size;
int32_t reserved;
private:
void swap_endian (void);
};
struct color_table {
uint8_t b;
uint8_t g;
uint8_t r;
uint8_t unused;
};
} //namespace bmp_pvt
class BmpInput : public ImageInput {
public:
BmpInput () { init (); }
virtual ~BmpInput () { close (); }
virtual const char *format_name (void) const { return "bmp"; }
virtual bool valid_file (const std::string &filename) const;
virtual bool open (const std::string &name, ImageSpec &spec);
virtual bool close (void);
virtual bool read_native_scanline (int y, int z, void *data);
private:
int m_padded_scanline_size;
int m_pad_size;
FILE *m_fd;
bmp_pvt::BmpFileHeader m_bmp_header;
bmp_pvt::DibInformationHeader m_dib_header;
std::string m_filename;
std::vector<bmp_pvt::color_table> m_colortable;
fpos_t m_image_start;
void init (void) {
m_padded_scanline_size = 0;
m_pad_size = 0;
m_fd = NULL;
m_filename.clear ();
m_colortable.clear ();
}
bool read_color_table (void);
enum class CSType {
CalibratedRGB = 0,
DeviceDependentRGB = 1,
DeviceDependentCMYK = 2
};
class BmpOutput : public ImageOutput {
public:
BmpOutput () { init (); }
virtual ~BmpOutput () { close (); }
virtual const char *format_name (void) const { return "bmp"; }
virtual int supports (string_view feature) const;
virtual bool open (const std::string &name, const ImageSpec &spec,
OpenMode mode);
virtual bool close (void);
virtual bool write_scanline (int y, int z, TypeDesc format,
const void *data, stride_t xstride);
virtual bool write_tile (int x, int y, int z, TypeDesc format,
const void *data, stride_t xstride,
stride_t ystride, stride_t zstride);
private:
int m_padded_scanline_size;
FILE *m_fd;
std::string m_filename;
bmp_pvt::BmpFileHeader m_bmp_header;
bmp_pvt::DibInformationHeader m_dib_header;
fpos_t m_image_start;
unsigned int m_dither;
std::vector<unsigned char> m_tilebuffer;
// store information about BMP file
class BmpFileHeader {
public:
// reads information about BMP file
bool read_header(Filesystem::IOProxy* fd);
void init (void) {
m_padded_scanline_size = 0;
m_fd = NULL;
m_filename.clear ();
}
// writes information about bmp file to given file
bool write_header(Filesystem::IOProxy* fd);
void create_and_write_file_header (void);
// return true if given file is BMP file
bool isBmp() const;
void create_and_write_bitmap_header (void);
int16_t magic; // used to identify BMP file
int32_t fsize; // size of the BMP file
int16_t res1; // reserved
int16_t res2; // reserved
int32_t offset; // offset of image data (pixels)
private:
void swap_endian(void);
};
// stores information about bitmap
class DibInformationHeader {
public:
// reads information about bitmap
bool read_header(Filesystem::IOProxy* fd);
// writes information about bitmap
bool write_header(Filesystem::IOProxy* fd);
int32_t size; // size of the header
int32_t width; // bitmap width in pixels
int32_t height; // bitmap height in pixels
int16_t cplanes; // number of color planes - always 1
int16_t bpp; // number of bits per pixel, image color depth
// Added after Version 1 of the format
int32_t compression = 0; // compression used in file
int32_t isize = 0; // size of the raw image data
int32_t hres = 0; // horizontal resolution in pixels per meter
int32_t vres = 0; // vertical resolutions in pixels per meter
int32_t cpalete = 0; // number of entries in the color palette
int32_t important = 0; // number of important color used,
// 0 - all colors are important,
// in most cases ignored
// added in Version 4 of the format
int32_t red_mask = 0;
int32_t blue_mask = 0;
int32_t green_mask = 0;
int32_t alpha_mask = 0;
int32_t cs_type = 0; // color space type
int32_t red_x = 0;
int32_t red_y = 0;
int32_t red_z = 0;
int32_t green_x = 0;
int32_t green_y = 0;
int32_t green_z = 0;
int32_t blue_x = 0;
int32_t blue_y = 0;
int32_t blue_z = 0;
int32_t gamma_x = 0;
int32_t gamma_y = 0;
int32_t gamma_z = 0;
// added in Version 5 of the format
int32_t intent;
int32_t profile_data;
int32_t profile_size;
int32_t reserved;
private:
void swap_endian(void);
};
struct color_table {
uint8_t b;
uint8_t g;
uint8_t r;
uint8_t unused;
};
} //namespace bmp_pvt
OIIO_PLUGIN_NAMESPACE_END
#endif // OPENIMAGEIO_BMP_H
+475 -190
View File
@@ -1,269 +1,554 @@
/*
Copyright 2008-2009 Larry Gritz and the other authors and contributors.
All Rights Reserved.
// Copyright Contributors to the OpenImageIO project.
// SPDX-License-Identifier: Apache-2.0
// https://github.com/OpenImageIO/oiio
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the software's owners nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cstdio>
#include <OpenImageIO/filesystem.h>
#include <OpenImageIO/imageio.h>
(This is the Modified BSD License)
*/
#include "bmp_pvt.h"
OIIO_PLUGIN_NAMESPACE_BEGIN
using namespace bmp_pvt;
// Obligatory material to make this a recognizeable imageio plugin
class BmpInput final : public ImageInput {
public:
BmpInput() { init(); }
~BmpInput() override { close(); }
const char* format_name(void) const override { return "bmp"; }
int supports(string_view feature) const override
{
return feature == "ioproxy";
}
bool valid_file(const std::string& filename) const override;
bool open(const std::string& name, ImageSpec& newspec) override;
bool open(const std::string& name, ImageSpec& newspec,
const ImageSpec& config) override;
bool close(void) override;
bool read_native_scanline(int subimage, int miplevel, int y, int z,
void* data) override;
private:
int64_t m_padded_scanline_size;
int m_pad_size;
bmp_pvt::BmpFileHeader m_bmp_header;
bmp_pvt::DibInformationHeader m_dib_header;
std::string m_filename;
std::vector<bmp_pvt::color_table> m_colortable;
std::vector<unsigned char> fscanline; // temp space: read from file
std::vector<unsigned char> m_uncompressed; // uncompressed palette image
uint32_t m_right_shifts[3];
uint32_t m_bit_counts[3];
bool m_allgray;
void init(void)
{
m_padded_scanline_size = 0;
m_pad_size = 0;
m_filename.clear();
m_colortable.clear();
m_allgray = false;
fscanline.shrink_to_fit();
m_uncompressed.shrink_to_fit();
ioproxy_clear();
}
bool read_color_table();
bool color_table_is_all_gray();
bool read_rle_image();
bool ioeof() { return size_t(ioproxy()->tell()) == ioproxy()->size(); }
// Safe, clamped access to color table
const bmp_pvt::color_table& colortable(int i)
{
return m_colortable[clamp(i, 0, int(m_colortable.size() - 1))];
}
};
// Obligatory material to make this a recognizable imageio plugin
OIIO_PLUGIN_EXPORTS_BEGIN
OIIO_EXPORT int bmp_imageio_version = OIIO_PLUGIN_VERSION;
OIIO_EXPORT const char* bmp_imageio_library_version () { return NULL; }
OIIO_EXPORT ImageInput *bmp_input_imageio_create () {
return new BmpInput;
}
OIIO_EXPORT const char *bmp_input_extensions[] = {
"bmp", NULL
};
OIIO_EXPORT int bmp_imageio_version = OIIO_PLUGIN_VERSION;
OIIO_EXPORT const char*
bmp_imageio_library_version()
{
return nullptr;
}
OIIO_EXPORT ImageInput*
bmp_input_imageio_create()
{
return new BmpInput;
}
OIIO_EXPORT const char* bmp_input_extensions[] = { "bmp", "dib", nullptr };
OIIO_PLUGIN_EXPORTS_END
bool
BmpInput::valid_file (const std::string &filename) const
BmpInput::valid_file(const std::string& filename) const
{
FILE *fd = Filesystem::fopen (filename, "rb");
if (!fd)
bmp_pvt::BmpFileHeader header;
Filesystem::IOFile file(filename, Filesystem::IOProxy::Read);
return file.opened() && header.read_header(&file) && header.isBmp();
}
bool
BmpInput::open(const std::string& name, ImageSpec& newspec)
{
ImageSpec emptyconfig;
return open(name, newspec, emptyconfig);
}
inline void
calc_shifts(uint32_t mask, uint32_t& count, uint32_t& right)
{
if (mask == 0) {
count = right = 0;
return;
}
uint32_t i;
for (i = 0; i < 32; i++, mask >>= 1) {
if (mask & 1)
break;
}
right = i;
for (i = 0; i < 32; i++, mask >>= 1) {
if (!(mask & 1))
break;
}
count = i;
}
bool
BmpInput::open(const std::string& name, ImageSpec& newspec,
const ImageSpec& config)
{
// saving 'name' for later use
m_filename = name;
// BMP cannot be 1-channel, but config hint "bmp:monochrome_detect" is a
// hint to try to detect when all palette entries are gray and pretend
// that it's a 1-channel image to allow the calling app to save memory
// and time. It does this by default, but setting the hint to 0 turns
// this behavior off.
bool monodetect = config["bmp:monochrome_detect"].get<int>(1);
ioproxy_retrieve_from_config(config);
if (!ioproxy_use_or_open(name))
return false;
bmp_pvt::BmpFileHeader bmp_header;
bool ok = bmp_header.read_header(fd) && bmp_header.isBmp();
fclose (fd);
ioseek(0);
// we read header of the file that we think is BMP file
if (!m_bmp_header.read_header(ioproxy())) {
errorfmt("\"{}\": wrong bmp header size", name);
close();
return false;
}
if (!m_bmp_header.isBmp()) {
errorfmt("\"{}\" is not a BMP file, magic number doesn't match", name);
close();
return false;
}
// Strutil::print(
// "Header: magic={:x} {}{} fsize={} res1={} res2={} offset={}\n",
// m_bmp_header.magic, char(m_bmp_header.magic & 0xff),
// char(m_bmp_header.magic >> 8), m_bmp_header.fsize, m_bmp_header.res1,
// m_bmp_header.res2, m_bmp_header.offset);
if (!m_dib_header.read_header(ioproxy())) {
errorfmt("\"{}\": wrong bitmap header size", name);
close();
return false;
}
// Strutil::print(
// "Header: size={}(0x{:02x}) width={} height={} cplanes={} bpp={}\n",
// m_dib_header.size, m_dib_header.size, m_dib_header.width,
// m_dib_header.height, m_dib_header.cplanes, m_dib_header.bpp);
const int nchannels = (m_dib_header.bpp == 32) ? 4 : 3;
const int height = (m_dib_header.height >= 0) ? m_dib_header.height
: -m_dib_header.height;
m_spec = ImageSpec(m_dib_header.width, height, nchannels, TypeDesc::UINT8);
if (m_dib_header.hres > 0 && m_dib_header.vres > 0) {
m_spec.attribute("XResolution", (int)m_dib_header.hres);
m_spec.attribute("YResolution", (int)m_dib_header.vres);
m_spec.attribute("ResolutionUnit", "m");
}
if (m_spec.width < 1 || m_spec.height < 1 || m_spec.nchannels < 1
|| m_spec.image_bytes() < 1
|| m_spec.image_pixels() > std::numeric_limits<uint32_t>::max()) {
errorfmt(
"Invalid image size {} x {} ({} chans, {}), is likely corrupted",
m_spec.width, m_spec.height, m_spec.nchannels, m_spec.format);
close();
return false;
}
// Compute channel shifts & masks (only relevant for 16bpp case)
if (m_dib_header.red_mask == 0 || m_dib_header.green_mask == 0
|| m_dib_header.blue_mask == 0) {
m_dib_header.red_mask = 0b111110000000000;
m_dib_header.green_mask = 0b000001111100000;
m_dib_header.blue_mask = 0b000000000011111;
}
calc_shifts(m_dib_header.red_mask, m_bit_counts[0], m_right_shifts[0]);
calc_shifts(m_dib_header.green_mask, m_bit_counts[1], m_right_shifts[1]);
calc_shifts(m_dib_header.blue_mask, m_bit_counts[2], m_right_shifts[2]);
// computing size of one scanline - this is the size of one scanline that
// is stored in the file, not in the memory
int swidth = 0;
switch (m_dib_header.bpp) {
case 32:
case 24:
m_padded_scanline_size = ((m_spec.width * m_spec.nchannels) + 3) & ~3;
break;
case 16:
m_padded_scanline_size = ((m_spec.width << 1) + 3) & ~3;
m_spec.attribute("oiio:BitsPerSample", m_bit_counts[0]);
break;
case 8:
m_padded_scanline_size = (m_spec.width + 3) & ~3;
if (!read_color_table())
return false;
m_allgray = monodetect && color_table_is_all_gray();
if (m_allgray) {
m_spec.nchannels = 1; // make it look like a 1-channel image
m_spec.default_channel_names();
}
break;
case 4:
swidth = (m_spec.width + 1) / 2;
m_padded_scanline_size = (swidth + 3) & ~3;
if (!read_color_table())
return false;
break;
case 1:
swidth = (m_spec.width + 7) / 8;
m_padded_scanline_size = (swidth + 3) & ~3;
if (!read_color_table())
return false;
break;
default:
errorfmt("Unsupported BMP bit depth: {}", m_dib_header.bpp);
return false;
}
if (m_dib_header.bpp <= 16)
m_spec.attribute("bmp:bitsperpixel", m_dib_header.bpp);
switch (m_dib_header.size) {
case OS2_V1: m_spec.attribute("bmp:version", 1); break;
case WINDOWS_V3: m_spec.attribute("bmp:version", 3); break;
case WINDOWS_V4: m_spec.attribute("bmp:version", 4); break;
case WINDOWS_V5: m_spec.attribute("bmp:version", 5); break;
}
// Default presumption is that a BMP file is meant to look reasonable on a
// display, so assume it's sRGB. This is not really correct -- see the
// comments below.
m_spec.attribute("oiio:ColorSpace", "sRGB");
#if 0
if (m_dib_header.size >= WINDOWS_V4
&& m_dib_header.cs_type == CSType::CalibratedRGB) {
// FIXME: V4 and newer BMP files have color primary information, but
// we currently ignore it and presume sRGB. I don't know how
// frequently the color primaries are reliable or if anybody cares for
// this ancient format. We may come back to this later.
}
if (m_dib_header.size >= WINDOWS_V4
&& m_dib_header.cs_type == CSType::DeviceDependentCMYK) {
// FIXME: I've never encountered a BMP file that holds CMYK data. If
// this is a problem for people, we can return to fix this later.
}
#endif
// Bite the bullet and uncompress now, for simplicity
if (m_dib_header.compression == RLE4_COMPRESSION
|| m_dib_header.compression == RLE8_COMPRESSION) {
if (!read_rle_image()) {
errorfmt("BMP error reading rle-compressed image");
close();
return false;
}
}
newspec = m_spec;
return true;
}
bool
BmpInput::read_rle_image()
{
int rletype = m_dib_header.compression == RLE4_COMPRESSION ? 4 : 8;
m_spec.attribute("compression", rletype == 4 ? "rle4" : "rle8");
m_uncompressed.clear();
m_uncompressed.resize(m_spec.image_pixels());
// Note: the clear+resize zeroes out the buffer
bool ok = true;
int y = 0, x = 0;
while (ok) {
// Strutil::print("currently at {},{}\n", x, y);
unsigned char rle_pair[2];
if (!ioread(rle_pair, 2)) {
ok = false;
// Strutil::print("hit end of file at {},{}\n", x, y);
break;
}
if (y >= m_spec.height) { // out of y bounds
errorfmt(
"BMP might be corrupted, it is referencing an out-of-bounds pixel coordinte ({},{})",
x, y);
ok = false;
break;
}
int npixels = rle_pair[0];
int value = rle_pair[1];
if (npixels == 0 && value == 0) {
// [0,0] is end of line marker
x = 0;
++y;
// Strutil::print("end of line, moving to {},{}\n", x, y);
} else if (npixels == 0 && value == 1) {
// [0,1] is end of bitmap marker
// Strutil::print("end of bitmap\n");
break;
} else if (npixels == 0 && value == 2) {
// [0,2] is a "delta" -- two more bytes reposition the
// current pixel position that we're reading.
unsigned char offset[2];
ok &= ioread(offset, 2);
x += offset[0];
y += offset[1];
// Strutil::print("offset by {:d},{:d} to {},{}\n", offset[0],
// offset[1], x, y);
} else if (npixels == 0) {
// [0,n>2] is an "absolute" run of pixel data.
// n is the number of pixel indices that follow, but note
// that it pads to word size.
npixels = value;
int nbytes = (rletype == 4)
? round_to_multiple((npixels + 1) / 2, 2)
: round_to_multiple(npixels, 2);
// Strutil::print("rle of {} pixels at {},{}\n", npixels, x, y);
unsigned char absolute[256];
ok &= ioread(absolute, nbytes);
for (int i = 0; i < npixels; ++i, ++x) {
if (rletype == 4)
value = (i & 1) ? (absolute[i / 2] & 0x0f)
: (absolute[i / 2] >> 4);
else
value = absolute[i];
if (x < m_spec.width)
m_uncompressed[y * m_spec.width + x] = value;
}
} else {
// [n>0,p] is a run of n pixels.
// Strutil::print("direct read {} pixels at {},{}\n", npixels, x, y);
for (int i = 0; i < npixels; ++i, ++x) {
int v;
if (rletype == 4)
v = (i & 1) ? (value & 0x0f) : (value >> 4);
else
v = value;
if (x < m_spec.width)
m_uncompressed[y * m_spec.width + x] = v;
}
}
}
return ok;
}
bool
BmpInput::open (const std::string &name, ImageSpec &spec)
BmpInput::read_native_scanline(int subimage, int miplevel, int y, int /*z*/,
void* data)
{
// saving 'name' for later use
m_filename = name;
m_fd = Filesystem::fopen (m_filename, "rb");
if (!m_fd) {
error ("Could not open file \"%s\"", name.c_str());
lock_guard lock(*this);
if (!seek_subimage(subimage, miplevel))
return false;
}
// we read header of the file that we think is BMP file
if (! m_bmp_header.read_header (m_fd)) {
error ("\"%s\": wrong bmp header size", m_filename.c_str());
close ();
return false;
}
if (! m_bmp_header.isBmp ()) {
error ("\"%s\" is not a BMP file, magic number doesn't match",
m_filename.c_str());
close ();
return false;
}
if (! m_dib_header.read_header (m_fd)) {
error ("\"%s\": wrong bitmap header size", m_filename.c_str());
close ();
return false;
}
const int nchannels = (m_dib_header.bpp == 32) ? 4 : 3;
const int height = (m_dib_header.height >= 0) ? m_dib_header.height
: -m_dib_header.height;
m_spec = ImageSpec (m_dib_header.width, height, nchannels, TypeDesc::UINT8);
m_spec.attribute ("XResolution", (int)m_dib_header.hres);
m_spec.attribute ("YResolution", (int)m_dib_header.vres);
m_spec.attribute ("ResolutionUnit", "m");
// comupting size of one scanline - this is the size of one scanline that
// is stored in the file, not in the memory
int swidth = 0;
switch (m_dib_header.bpp) {
case 32 :
case 24 :
m_padded_scanline_size = ((m_spec.width * m_spec.nchannels) + 3) & ~3;
break;
case 16 :
m_padded_scanline_size = ((m_spec.width << 1) + 3) & ~3;
m_spec.attribute ("oiio:BitsPerSample", 4);
break;
case 8 :
m_padded_scanline_size = (m_spec.width + 3) & ~3;
if (! read_color_table ())
return false;
break;
case 4 :
swidth = (m_spec.width + 1) / 2;
m_padded_scanline_size = (swidth + 3) & ~3;
if (! read_color_table ())
return false;
break;
case 1 :
swidth = (m_spec.width + 7) / 8;
m_padded_scanline_size = (swidth + 3) & ~3;
if (! read_color_table ())
return false;
break;
}
// file pointer is set to the beginning of image data
// we save this position - it will be helpfull in read_native_scanline
fgetpos (m_fd, &m_image_start);
spec = m_spec;
return true;
}
bool
BmpInput::read_native_scanline (int y, int z, void *data)
{
if (y < 0 || y > m_spec.height)
return false;
// if the height is positive scanlines are stored bottom-up
if (m_dib_header.width >= 0)
y = m_spec.height - y - 1;
const int scanline_off = y * m_padded_scanline_size;
size_t scanline_bytes = m_spec.scanline_bytes();
uint8_t* mscanline = (uint8_t*)data;
if (m_dib_header.compression == RLE4_COMPRESSION
|| m_dib_header.compression == RLE8_COMPRESSION) {
for (int x = 0; x < m_spec.width; ++x) {
int p = m_uncompressed[(m_spec.height - 1 - y) * m_spec.width + x];
auto& c = colortable(p);
mscanline[3 * x] = c.r;
mscanline[3 * x + 1] = c.g;
mscanline[3 * x + 2] = c.b;
}
return true;
}
std::vector<unsigned char> fscanline (m_padded_scanline_size);
fsetpos (m_fd, &m_image_start);
fseek (m_fd, scanline_off, SEEK_CUR);
size_t n = fread (&fscanline[0], 1, m_padded_scanline_size, m_fd);
if (n != (size_t)m_padded_scanline_size) {
if (feof (m_fd))
error ("Hit end of file unexpectedly");
else
error ("read error");
return false; // Read failed
// if the height is positive scanlines are stored bottom-up
if (m_dib_header.height >= 0)
y = m_spec.height - y - 1;
const int64_t scanline_off = y * m_padded_scanline_size;
fscanline.resize(m_padded_scanline_size);
ioseek(m_bmp_header.offset + scanline_off);
if (!ioread(fscanline.data(), m_padded_scanline_size)) {
return false; // Read failed
}
// in each case we process only first m_spec.scanline_bytes () bytes
// as only they contain information about pixels. The rest are just
// because scanline size have to be 32-bit boundary
if (m_dib_header.bpp == 24 || m_dib_header.bpp == 32) {
for (unsigned int i = 0; i < m_spec.scanline_bytes (); i += m_spec.nchannels)
std::swap (fscanline[i], fscanline[i+2]);
memcpy (data, &fscanline[0], m_spec.scanline_bytes());
for (unsigned int i = 0; i < m_spec.scanline_bytes();
i += m_spec.nchannels)
std::swap(fscanline[i], fscanline[i + 2]);
memcpy(data, fscanline.data(), m_spec.scanline_bytes());
return true;
}
std::vector<unsigned char> mscanline (m_spec.scanline_bytes());
if (m_dib_header.bpp == 16) {
const uint16_t RED = 0x7C00;
const uint16_t GREEN = 0x03E0;
const uint16_t BLUE = 0x001F;
for (unsigned int i = 0, j = 0; j < m_spec.scanline_bytes(); i+=2, j+=3) {
uint16_t pixel = (uint16_t)*(&fscanline[i]);
mscanline[j] = (uint8_t)((pixel & RED) >> 8);
mscanline[j+1] = (uint8_t)((pixel & GREEN) >> 4);
mscanline[j+2] = (uint8_t)(pixel & BLUE);
for (unsigned int i = 0, j = 0; j < scanline_bytes; i += 2, j += 3) {
uint16_t pixel = *(uint16_t*)&fscanline[i];
mscanline[j + 0]
= (uint8_t)bit_range_convert((pixel & m_dib_header.red_mask)
>> m_right_shifts[0],
m_bit_counts[0], 8);
mscanline[j + 1]
= (uint8_t)bit_range_convert((pixel & m_dib_header.green_mask)
>> m_right_shifts[1],
m_bit_counts[1], 8);
mscanline[j + 2]
= (uint8_t)bit_range_convert((pixel & m_dib_header.blue_mask)
>> m_right_shifts[2],
m_bit_counts[2], 8);
}
}
if (m_dib_header.bpp == 8) {
for (unsigned int i = 0, j = 0; j < m_spec.scanline_bytes(); ++i, j+=3) {
mscanline[j] = m_colortable[fscanline[i]].r;
mscanline[j+1] = m_colortable[fscanline[i]].g;
mscanline[j+2] = m_colortable[fscanline[i]].b;
if (m_allgray) {
// Keep it as 1-channel image because all colors are gray
for (unsigned int i = 0; i < scanline_bytes; ++i) {
mscanline[i] = colortable(fscanline[i]).r;
}
} else {
// Expand palette image into 3-channel RGB (existing code)
for (unsigned int i = 0, j = 0; j < scanline_bytes; ++i, j += 3) {
auto& c = colortable(fscanline[i]);
mscanline[j] = c.r;
mscanline[j + 1] = c.g;
mscanline[j + 2] = c.b;
}
}
}
if (m_dib_header.bpp == 4) {
for (unsigned int i = 0, j = 0; j + 6 < m_spec.scanline_bytes(); ++i, j+=6) {
for (unsigned int i = 0, j = 0; j < scanline_bytes; ++i, j += 6) {
uint8_t mask = 0xF0;
mscanline[j] = m_colortable[(fscanline[i] & mask) >> 4].r;
mscanline[j+1] = m_colortable[(fscanline[i] & mask) >> 4].g;
mscanline[j+2] = m_colortable[(fscanline[i] & mask) >> 4].b;
{
auto& c = colortable((fscanline[i] & mask) >> 4);
mscanline[j] = c.r;
mscanline[j + 1] = c.g;
mscanline[j + 2] = c.b;
}
if (j + 3 >= scanline_bytes)
break;
mask = 0x0F;
mscanline[j+3] = m_colortable[fscanline[i] & mask].r;
mscanline[j+4] = m_colortable[fscanline[i] & mask].g;
mscanline[j+5] = m_colortable[fscanline[i] & mask].b;
{
auto& c = colortable(fscanline[i] & mask);
mscanline[j + 3] = c.r;
mscanline[j + 4] = c.g;
mscanline[j + 5] = c.b;
}
}
}
if (m_dib_header.bpp == 1) {
for (unsigned int i = 0, k = 0; i < fscanline.size (); ++i) {
for (int j = 7; j >= 0; --j, k+=3) {
if (k + 2 >= mscanline.size())
for (int64_t i = 0, k = 0; i < m_padded_scanline_size; ++i) {
for (int j = 7; j >= 0; --j, k += 3) {
if (size_t(k + 2) >= scanline_bytes)
break;
int index = 0;
if (fscanline[i] & (1 << j))
index = 1;
mscanline[k] = m_colortable[index].r;
mscanline[k+1] = m_colortable[index].g;
mscanline[k+2] = m_colortable[index].b;
auto& c = colortable(index);
mscanline[k] = c.r;
mscanline[k + 1] = c.g;
mscanline[k + 2] = c.b;
}
}
}
memcpy (data, &mscanline[0], m_spec.scanline_bytes());
return true;
}
bool inline
BmpInput::close (void)
{
if (m_fd) {
fclose (m_fd);
m_fd = NULL;
}
init ();
return true;
}
bool
BmpInput::read_color_table (void)
BmpInput::close(void)
{
init();
return true;
}
bool
BmpInput::read_color_table(void)
{
// size of color table is defined by m_dib_header.cpalete
// if this field is 0 - color table has max colors:
// pow(2, m_dib_header.cpalete) otherwise color table have
// m_dib_header.cpalete entries
const int32_t colors = (m_dib_header.cpalete) ? m_dib_header.cpalete :
1 << m_dib_header.bpp;
size_t entry_size = 4;
// if the file is OS V2 bitmap color table entr has only 3 bytes, not four
if (m_dib_header.cpalete < 0
|| m_dib_header.cpalete > (1 << m_dib_header.bpp)) {
errorfmt("Possible corrupted header, invalid palette size");
return false;
}
const int32_t colors = (m_dib_header.cpalete) ? m_dib_header.cpalete
: 1 << m_dib_header.bpp;
size_t entry_size = 4;
// if the file is OS V2 bitmap color table entry has only 3 bytes, not four
if (m_dib_header.size == OS2_V1)
entry_size = 3;
m_colortable.resize (colors);
m_colortable.resize(colors);
for (int i = 0; i < colors; i++) {
size_t n = fread (&m_colortable[i], 1, entry_size, m_fd);
if (n != entry_size) {
if (feof (m_fd))
error ("Hit end of file unexpectedly while reading color table");
if (!ioread(&m_colortable[i], entry_size)) {
if (ioeof())
errorfmt(
"Hit end of file unexpectedly while reading color table on color {}/{})",
i, colors);
else
error ("read error while reading color table");
return false; // Read failed
errorfmt("read error while reading color table");
return false; // Read failed
}
}
return true; // ok
}
OIIO_PLUGIN_NAMESPACE_END
bool
BmpInput::color_table_is_all_gray(void)
{
size_t ncolors = m_colortable.size();
for (size_t i = 0; i < ncolors; i++) {
color_table& color = m_colortable[i];
if (color.b != color.g || color.g != color.r)
return false;
}
return true;
}
OIIO_PLUGIN_NAMESPACE_END
+170 -126
View File
@@ -1,34 +1,13 @@
/*
Copyright 2008-2009 Larry Gritz and the other authors and contributors.
All Rights Reserved.
// Copyright Contributors to the OpenImageIO project.
// SPDX-License-Identifier: BSD-3-Clause and Apache-2.0
// https://github.com/OpenImageIO/oiio
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the software's owners nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cstdio>
(This is the Modified BSD License)
*/
#include <OpenImageIO/filesystem.h>
#include <OpenImageIO/imageio.h>
#include <OpenImageIO/strutil.h>
#include "OpenImageIO/strutil.h"
#include "bmp_pvt.h"
OIIO_PLUGIN_NAMESPACE_BEGIN
@@ -36,68 +15,120 @@ OIIO_PLUGIN_NAMESPACE_BEGIN
using namespace bmp_pvt;
// Obligatory material to make this a recognizeable imageio plugin
class BmpOutput final : public ImageOutput {
public:
BmpOutput() { init(); }
~BmpOutput() override { close(); }
const char* format_name(void) const override { return "bmp"; }
int supports(string_view feature) const override;
bool open(const std::string& name, const ImageSpec& spec,
OpenMode mode) override;
bool close(void) override;
bool write_scanline(int y, int z, TypeDesc format, const void* data,
stride_t xstride) override;
bool write_tile(int x, int y, int z, TypeDesc format, const void* data,
stride_t xstride, stride_t ystride,
stride_t zstride) override;
private:
int64_t m_padded_scanline_size;
std::string m_filename;
bmp_pvt::BmpFileHeader m_bmp_header;
bmp_pvt::DibInformationHeader m_dib_header;
int64_t m_image_start;
unsigned int m_dither;
std::vector<unsigned char> m_tilebuffer;
std::vector<unsigned char> m_scratch;
std::vector<unsigned char> m_buf; // more tmp space for write_scanline
void init(void)
{
m_padded_scanline_size = 0;
m_filename.clear();
ioproxy_clear();
}
void create_and_write_file_header(void);
void create_and_write_bitmap_header(void);
};
// Obligatory material to make this a recognizable imageio plugin
OIIO_PLUGIN_EXPORTS_BEGIN
OIIO_EXPORT ImageOutput *bmp_output_imageio_create () {
return new BmpOutput;
}
OIIO_EXPORT const char *bmp_output_extensions[] = {
"bmp", NULL
};
OIIO_EXPORT ImageOutput*
bmp_output_imageio_create()
{
return new BmpOutput;
}
OIIO_EXPORT const char* bmp_output_extensions[] = { "bmp", nullptr };
OIIO_PLUGIN_EXPORTS_END
int
BmpOutput::supports (string_view feature) const
BmpOutput::supports(string_view feature) const
{
return (feature == "alpha");
return (feature == "alpha" || feature == "ioproxy");
}
bool
BmpOutput::open (const std::string &name, const ImageSpec &spec,
OpenMode mode)
BmpOutput::open(const std::string& name, const ImageSpec& spec, OpenMode mode)
{
if (mode != Create) {
error ("%s does not support subimages or MIP levels", format_name());
errorfmt("{} does not support subimages or MIP levels", format_name());
return false;
}
// saving 'name' and 'spec' for later use
m_filename = name;
m_spec = spec;
m_spec = spec;
if (m_spec.nchannels != 3 && m_spec.nchannels != 4) {
error ("%s does not support %d-channel images\n",
format_name(), m_spec.nchannels);
if (m_spec.nchannels != 1 && m_spec.nchannels != 3
&& m_spec.nchannels != 4) {
errorfmt("{} does not support {}-channel images\n", format_name(),
m_spec.nchannels);
return false;
}
m_fd = Filesystem::fopen (m_filename, "wb");
if (! m_fd) {
error ("Unable to open file \"%s\"", m_filename.c_str ());
if (m_spec.x || m_spec.y || m_spec.z) {
errorfmt("{} does not support images with non-zero image origin offset",
format_name());
return false;
}
create_and_write_file_header ();
create_and_write_bitmap_header ();
// Scanline size is rounded up to align to 4-byte boundary
m_padded_scanline_size = ((m_spec.width * m_spec.nchannels) + 3) & ~3;
fgetpos (m_fd, &m_image_start);
// Only support 8 bit channels for now.
m_spec.set_format (TypeDesc::UINT8);
m_dither = m_spec.get_int_attribute ("oiio:dither", 0);
m_spec.set_format(TypeDesc::UINT8);
m_dither = m_spec.get_int_attribute("oiio:dither", 0);
int64_t file_size = m_spec.image_bytes() + BMP_HEADER_SIZE + WINDOWS_V3;
if (file_size >= int64_t(1) << 32) {
errorfmt("{} does not support files over 4GB in size\n", format_name());
return false;
}
ioproxy_retrieve_from_config(m_spec);
if (!ioproxy_use_or_open(name))
return false;
// Scanline size is rounded up to align to 4-byte boundary
m_padded_scanline_size = round_to_multiple(m_spec.scanline_bytes(), 4);
create_and_write_file_header();
create_and_write_bitmap_header();
m_image_start = iotell();
// If user asked for tiles -- which this format doesn't support, emulate
// it by buffering the whole image.
if (m_spec.tile_width && m_spec.tile_height)
m_tilebuffer.resize (m_spec.image_bytes());
m_tilebuffer.resize(m_spec.image_bytes());
return true;
}
@@ -105,124 +136,137 @@ BmpOutput::open (const std::string &name, const ImageSpec &spec,
bool
BmpOutput::write_scanline (int y, int z, TypeDesc format, const void *data,
stride_t xstride)
BmpOutput::write_scanline(int y, int z, TypeDesc format, const void* data,
stride_t xstride)
{
if (y > m_spec.height) {
error ("Attempt to write too many scanlines to %s", m_filename.c_str());
close ();
if (!ioproxy_opened()) {
errorfmt("write_scanline called but file is not open.");
return false;
}
if (y > m_spec.y + m_spec.height) {
errorfmt("Attempt to write too many scanlines to {}", m_filename);
close();
return false;
}
y -= m_spec.y;
if (m_spec.width >= 0)
y = (m_spec.height - y - 1);
int scanline_off = y * m_padded_scanline_size;
fsetpos (m_fd, &m_image_start);
fseek (m_fd, scanline_off, SEEK_CUR);
int64_t scanline_off = y * m_padded_scanline_size;
ioseek(m_image_start + scanline_off);
std::vector<unsigned char> scratch;
data = to_native_scanline (format, data, xstride, scratch,
m_dither, y, z);
std::vector<unsigned char> buf (m_padded_scanline_size);
memcpy (&buf[0], data, m_spec.scanline_bytes());
m_scratch.clear();
data = to_native_scanline(format, data, xstride, m_scratch, m_dither, y, z);
m_buf.assign((const unsigned char*)data,
(const unsigned char*)data + m_spec.scanline_bytes());
m_buf.resize(m_padded_scanline_size, 0); // pad with zeroes if needed
// Swap RGB pixels into BGR format
if (m_spec.nchannels >= 3)
for (int i = 0, iend = buf.size() - 2; i < iend; i += m_spec.nchannels)
std::swap (buf[i], buf[i+2]);
for (int i = 0, iend = m_buf.size() - 2; i < iend;
i += m_spec.nchannels)
std::swap(m_buf[i], m_buf[i + 2]);
size_t byte_count = fwrite (&buf[0], 1, buf.size (), m_fd);
return byte_count == buf.size (); // true if wrote all bytes (no error)
return iowrite(&m_buf[0], m_buf.size());
}
bool
BmpOutput::write_tile (int x, int y, int z, TypeDesc format,
const void *data, stride_t xstride,
stride_t ystride, stride_t zstride)
BmpOutput::write_tile(int x, int y, int z, TypeDesc format, const void* data,
stride_t xstride, stride_t ystride, stride_t zstride)
{
if (!ioproxy_opened()) {
errorfmt("write_tile called but file is not open.");
return false;
}
// Emulate tiles by buffering the whole image
return copy_tile_to_image_buffer (x, y, z, format, data, xstride,
ystride, zstride, &m_tilebuffer[0]);
return copy_tile_to_image_buffer(x, y, z, format, data, xstride, ystride,
zstride, m_tilebuffer.data());
}
bool
BmpOutput::close (void)
BmpOutput::close(void)
{
if (! m_fd) { // already closed
init ();
if (!ioproxy_opened()) { // already closed
init();
return true;
}
bool ok = true;
if (m_spec.tile_width) {
if (m_spec.tile_width && m_tilebuffer.size()) {
// Handle tile emulation -- output the buffered pixels
ASSERT (m_tilebuffer.size());
ok &= write_scanlines (m_spec.y, m_spec.y+m_spec.height, 0,
m_spec.format, &m_tilebuffer[0]);
std::vector<unsigned char>().swap (m_tilebuffer);
OIIO_DASSERT(m_tilebuffer.size());
ok &= write_scanlines(m_spec.y, m_spec.y + m_spec.height, 0,
m_spec.format, m_tilebuffer.data());
std::vector<unsigned char>().swap(m_tilebuffer);
}
fclose (m_fd);
m_fd = NULL;
init();
return ok;
}
void
BmpOutput::create_and_write_file_header (void)
BmpOutput::create_and_write_file_header(void)
{
m_bmp_header.magic = MAGIC_BM;
const int data_size = m_spec.width * m_spec.height * m_spec.nchannels;
const int file_size = data_size + BMP_HEADER_SIZE + WINDOWS_V3;
int64_t data_size = m_padded_scanline_size * m_spec.height;
int palettesize = (m_spec.nchannels == 1) ? 4 * 256 : 0;
int64_t file_size = data_size + BMP_HEADER_SIZE + WINDOWS_V3 + palettesize;
m_bmp_header.fsize = file_size;
m_bmp_header.res1 = 0;
m_bmp_header.res2 = 0;
m_bmp_header.offset = BMP_HEADER_SIZE + WINDOWS_V3;
m_bmp_header.res1 = 0;
m_bmp_header.res2 = 0;
m_bmp_header.offset = BMP_HEADER_SIZE + WINDOWS_V3 + palettesize;
m_bmp_header.write_header (m_fd);
m_bmp_header.write_header(ioproxy());
}
void
BmpOutput::create_and_write_bitmap_header (void)
BmpOutput::create_and_write_bitmap_header(void)
{
m_dib_header.size = WINDOWS_V3;
m_dib_header.width = m_spec.width;
m_dib_header.height = m_spec.height;
m_dib_header.cplanes = 1;
m_dib_header.compression = 0;
m_dib_header.size = WINDOWS_V3;
m_dib_header.width = m_spec.width;
m_dib_header.height = m_spec.height;
m_dib_header.cplanes = 1;
m_dib_header.compression = NO_COMPRESSION;
m_dib_header.bpp = m_spec.nchannels << 3;
m_dib_header.isize = m_spec.width * m_spec.height * m_spec.nchannels;
m_dib_header.hres = 0;
m_dib_header.vres = 0;
m_dib_header.cpalete = 0;
m_dib_header.important = 0;
ImageIOParameter *p = NULL;
p = m_spec.find_attribute ("ResolutionUnit", TypeDesc::STRING);
if (p && p->data()) {
std::string res_units = *(char**)p->data ();
if (Strutil::iequals (res_units, "m") ||
Strutil::iequals (res_units, "pixel per meter")) {
ImageIOParameter *resx = NULL, *resy = NULL;
resx = m_spec.find_attribute ("XResolution", TypeDesc::INT32);
if (resx && resx->data())
m_dib_header.hres = *(int*)resx->data ();
resy = m_spec.find_attribute ("YResolution", TypeDesc::INT32);
if (resy && resy->data())
m_dib_header.vres = *(int*)resy->data ();
}
if (m_spec.nchannels == 1) {
// Special case -- write a 1-channel image as a gray palette
m_dib_header.bpp = 8;
m_dib_header.cpalete = 256;
m_dib_header.important = 256;
} else {
m_dib_header.bpp = m_spec.nchannels * 8;
m_dib_header.cpalete = 0;
m_dib_header.important = 0;
}
m_dib_header.write_header (m_fd);
m_dib_header.isize = int32_t(m_spec.image_pixels());
m_dib_header.hres = 0;
m_dib_header.vres = 0;
string_view res_units = m_spec.get_string_attribute("ResolutionUnit");
if (Strutil::iequals(res_units, "m")
|| Strutil::iequals(res_units, "pixel per meter")) {
m_dib_header.hres = m_spec.get_int_attribute("XResolution");
m_dib_header.vres = m_spec.get_int_attribute("YResolution");
}
m_dib_header.write_header(ioproxy());
// Write palette, if there is one. This is only used for grayscale
// images, and the palette is just the 256 possible gray values.
for (int i = 0; i < m_dib_header.cpalete; ++i) {
unsigned char val[4] = { uint8_t(i), uint8_t(i), uint8_t(i), 255 };
iowrite(&val, 4);
}
}
OIIO_PLUGIN_NAMESPACE_END
-266
View File
@@ -1,266 +0,0 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT (openexr)
SET(OPENEXR_VERSION_MAJOR "2")
SET(OPENEXR_VERSION_MINOR "2")
SET(OPENEXR_VERSION_PATCH "0")
SET(OPENEXR_VERSION ${OPENEXR_VERSION_MAJOR}.${OPENEXR_VERSION_MINOR}.${OPENEXR_VERSION_PATCH})
SET(OPENEXR_VERSION_API ${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR})
# enable the tests
ENABLE_TESTING()
# distro building
SET(CPACK_PACKAGE_VERSION_MAJOR "${OPENEXR_VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${OPENEXR_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${OPENEXR_VERSION_PATCH}")
SET(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}-${OPENEXR_VERSION}"
)
set(CPACK_SOURCE_IGNORE_FILES
"/.git*;/.cvs*;${CPACK_SOURCE_IGNORE_FILES}")
INCLUDE ( CPack )
# Allow the developer to select if Dynamic or Static libraries are built
OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" ON)
OPTION (USE_ZLIB_WINAPI "Use ZLib Win API" OFF)
OPTION (NAMESPACE_VERSIONING "Use Namespace Versioning" ON)
OPTION (BUILD_UTILS "Build the binary/utility programs" ON)
OPTION (BUILD_TESTS "Build the tests" ON)
# Setup osx rpathing
SET (CMAKE_MACOSX_RPATH 1)
SET (BUILD_WITH_INSTALL_RPATH 1)
ADD_DEFINITIONS ( -DHAVE_CONFIG_H -DILM_IMF_TEST_IMAGEDIR="${CMAKE_SOURCE_DIR}/IlmImfTest/" )
INCLUDE_DIRECTORIES (
${CMAKE_CURRENT_BINARY_DIR}/config
IlmImf
IlmImfUtil
exrmaketiled
exrenvmap
exrmakepreview
exrmultiview
IlmImfFuzzTest
)
FIND_PACKAGE(ZLIB REQUIRED)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
IF (NOT WIN32)
SET ( PTHREAD_LIB pthread )
ENDIF()
INCLUDE_DIRECTORIES ( ${ILMBASE_PACKAGE_PREFIX}/include/OpenEXR )
LINK_DIRECTORIES ( ${ILMBASE_PACKAGE_PREFIX}/lib )
MESSAGE ( "ILMBASE_PACKAGE_PREFIX = " ${ILMBASE_PACKAGE_PREFIX})
SET (LIB_TYPE STATIC)
IF (BUILD_SHARED_LIBS)
# User wants to build Dynamic Libraries, so change the LIB_TYPE variable to CMake keyword 'SHARED'
SET (LIB_TYPE SHARED)
IF (WIN32)
ADD_DEFINITIONS(-DOPENEXR_DLL)
ENDIF ()
ENDIF ()
IF (USE_ZLIB_WINAPI)
ADD_DEFINITIONS(-DZLIB_WINAPI)
ENDIF ()
# Test for GCC-style inline asm support with AVX instructions
INCLUDE (CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES (
"
int main()
{
#if defined(__GNUC__) && defined(__SSE2__)
int n = 0;
int eax = 0;
int edx = 0;
__asm__(
\"xgetbv ;\"
\"vzeroupper \"
: \"=a\"(eax), \"=d\"(edx) : \"c\"(n) : );
#else
#error No GCC style inline asm supported for AVX instructions
#endif
}
" HAVE_GCC_INLINE_ASM_AVX)
# Check if sysconf(_SC_NPROCESSORS_ONLN) can be used for CPU count
CHECK_CXX_SOURCE_COMPILES (
"
#include <unistd.h>
int main()
{
sysconf(_SC_NPROCESSORS_ONLN);
}
" HAVE_SYSCONF_NPROCESSORS_ONLN)
##########################
# OpenEXRConfig.h generation
##########################
IF (WIN32)
FILE ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1\n" )
ELSEIF (APPLE)
FILE ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_DARWIN 1\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#include <string.h>\n" )
ELSE ()
# Linux
FILE ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_LINUX_PROCFS 1\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_LARGE_STACK 1\n" )
ENDIF()
IF (NAMESPACE_VERSIONING)
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE_CUSTOM 1\n")
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_NAMESPACE Imf\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE Imf_${OPENEXR_VERSION_API}\n\n" )
ELSE ()
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE_CUSTOM 0\n")
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_NAMESPACE Imf\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE Imf\n\n" )
ENDIF ()
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_VERSION_STRING \"${OPENEXR_VERSION}\"\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_PACKAGE_STRING \"OpenEXR ${OPENEXR_VERSION}\"\n" )
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "
#define OPENEXR_VERSION_MAJOR ${OPENEXR_VERSION_MAJOR}
#define OPENEXR_VERSION_MINOR ${OPENEXR_VERSION_MINOR}
#define OPENEXR_VERSION_PATCH ${OPENEXR_VERSION_PATCH}
")
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "
// Version as a single hex number, e.g. 0x01000300 == 1.0.3
#define OPENEXR_VERSION_HEX ((OPENEXR_VERSION_MAJOR << 24) | \\
(OPENEXR_VERSION_MINOR << 16) | \\
(OPENEXR_VERSION_PATCH << 8))\n
")
IF (HAVE_GCC_INLINE_ASM_AVX)
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX 1\n" )
ENDIF()
IF (HAVE_SYSCONF_NPROCESSORS_ONLN)
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_SYSCONF_NPROCESSORS_ONLN 1\n" )
ENDIF()
SET (OPENEXR_LIBSUFFIX "")
SET (ILMBASE_LIBSUFFIX "")
IF (NAMESPACE_VERSIONING)
SET ( OPENEXR_LIBSUFFIX "-${OPENEXR_VERSION_API}" )
# assume same NAMESPACE_VERSION setting for IlmBase for now
SET ( ILMBASE_LIBSUFFIX "-${OPENEXR_VERSION_API}" )
ENDIF ()
##########################
# IlmImf library
##########################
ADD_SUBDIRECTORY ( IlmImf )
SET_TARGET_PROPERTIES ( IlmImf
PROPERTIES
VERSION 22.0.0
SOVERSION 22
OUTPUT_NAME "IlmImf${OPENEXR_LIBSUFFIX}"
)
##########################
# IlmImfUtil library
##########################
ADD_SUBDIRECTORY ( IlmImfUtil )
SET_TARGET_PROPERTIES ( IlmImfUtil
PROPERTIES
VERSION 22.0.0
SOVERSION 22
OUTPUT_NAME "IlmImfUtil${OPENEXR_LIBSUFFIX}"
)
##########################
# Example Code
##########################
ADD_SUBDIRECTORY ( IlmImfExamples )
##########################
# Tests
##########################
if (BUILD_TESTS)
ADD_SUBDIRECTORY ( IlmImfTest )
ADD_SUBDIRECTORY ( IlmImfUtilTest )
ADD_SUBDIRECTORY ( IlmImfFuzzTest )
endif ()
##########################
# Binaries / Utilities
##########################
if (BUILD_UTILS)
ADD_SUBDIRECTORY ( exrheader )
ADD_SUBDIRECTORY ( exrmaketiled )
ADD_SUBDIRECTORY ( exrstdattr )
ADD_SUBDIRECTORY ( exrmakepreview )
ADD_SUBDIRECTORY ( exrenvmap )
ADD_SUBDIRECTORY ( exrmultiview )
ADD_SUBDIRECTORY ( exrmultipart )
endif ()
##########################
# Installation
##########################
INSTALL ( FILES
${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h
DESTINATION
${CMAKE_INSTALL_PREFIX}/include/OpenEXR
)
# Documentation
INSTALL ( FILES
doc/TechnicalIntroduction.pdf
doc/ReadingAndWritingImageFiles.pdf
doc/OpenEXRFileLayout.pdf
doc/MultiViewOpenEXR.pdf
doc/InterpretingDeepPixels.pdf
doc/TheoryDeepPixels.pdf
DESTINATION
${CMAKE_INSTALL_PREFIX}/share/doc/OpenEXR-${OPENEXR_VERSION}
)
# Examples
INSTALL ( FILES
IlmImfExamples/main.cpp
IlmImfExamples/drawImage.cpp
IlmImfExamples/rgbaInterfaceExamples.cpp
IlmImfExamples/rgbaInterfaceTiledExamples.cpp
IlmImfExamples/generalInterfaceExamples.cpp
IlmImfExamples/lowLevelIoExamples.cpp
IlmImfExamples/previewImageExamples.cpp
IlmImfExamples/generalInterfaceTiledExamples.cpp
IlmImfExamples/generalInterfaceTiledExamples.h
IlmImfExamples/drawImage.h
IlmImfExamples/rgbaInterfaceExamples.h
IlmImfExamples/generalInterfaceExamples.h
IlmImfExamples/rgbaInterfaceTiledExamples.h
IlmImfExamples/lowLevelIoExamples.h
IlmImfExamples/previewImageExamples.h
IlmImfExamples/namespaceAlias.h
DESTINATION
${CMAKE_INSTALL_PREFIX}/share/doc/OpenEXR-${OPENEXR_VERSION}/examples
)
@@ -1,273 +0,0 @@
# yue.nicholas@gmail.com
SET(CMAKE_INCLUDE_CURRENT_DIR 1)
if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h")
ADD_EXECUTABLE ( b44ExpLogTable
b44ExpLogTable.cpp
)
TARGET_LINK_LIBRARIES ( b44ExpLogTable
Half
Iex${ILMBASE_LIBSUFFIX}
IlmThread${ILMBASE_LIBSUFFIX}
${PTHREAD_LIB}
)
ADD_CUSTOM_COMMAND (
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/b44ExpLogTable > ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
DEPENDS b44ExpLogTable
)
else ()
message (STATUS "Skipping build of b44ExpLogTable.h")
endif ()
if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h")
ADD_EXECUTABLE ( dwaLookups
dwaLookups.cpp
)
TARGET_LINK_LIBRARIES ( dwaLookups
Half
Iex${ILMBASE_LIBSUFFIX}
IlmThread${ILMBASE_LIBSUFFIX}
${PTHREAD_LIB}
)
ADD_CUSTOM_COMMAND (
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/dwaLookups > ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
DEPENDS dwaLookups
)
else ()
message (STATUS "Skipping build of dwaLookups.h")
endif ()
SET ( ILMIMF_SRCS
ImfAttribute.cpp
ImfBoxAttribute.cpp
ImfCRgbaFile.cpp
ImfChannelList.cpp
ImfChannelListAttribute.cpp
ImfFloatAttribute.cpp
ImfFrameBuffer.cpp
ImfHeader.cpp
ImfIO.cpp
ImfInputFile.cpp
ImfIntAttribute.cpp
ImfLineOrderAttribute.cpp
ImfMatrixAttribute.cpp
ImfOpaqueAttribute.cpp
ImfOutputFile.cpp
ImfRgbaFile.cpp
ImfStringAttribute.cpp
ImfVecAttribute.cpp
ImfHuf.cpp
ImfThreading.cpp
ImfWav.cpp
ImfLut.cpp
ImfCompressor.cpp
ImfRleCompressor.cpp
ImfZipCompressor.cpp
ImfPizCompressor.cpp
ImfB44Compressor.cpp
ImfDwaCompressor.cpp
ImfMisc.cpp
ImfCompressionAttribute.cpp
ImfDoubleAttribute.cpp
ImfConvert.cpp
ImfPreviewImage.cpp
ImfPreviewImageAttribute.cpp
ImfVersion.cpp
ImfChromaticities.cpp
ImfChromaticitiesAttribute.cpp
ImfKeyCode.cpp
ImfKeyCodeAttribute.cpp
ImfTimeCode.cpp
ImfTimeCodeAttribute.cpp
ImfRational.cpp
ImfRationalAttribute.cpp
ImfFramesPerSecond.cpp
ImfStandardAttributes.cpp
ImfStdIO.cpp
ImfEnvmap.cpp
ImfEnvmapAttribute.cpp
ImfScanLineInputFile.cpp
ImfTiledInputFile.cpp
ImfTiledMisc.cpp
ImfTiledOutputFile.cpp
ImfTiledRgbaFile.cpp
ImfTileDescriptionAttribute.cpp
ImfTileOffsets.cpp
ImfRgbaYca.cpp
ImfPxr24Compressor.cpp
ImfTestFile.cpp
ImfStringVectorAttribute.cpp
ImfMultiView.cpp
ImfAcesFile.cpp
ImfMultiPartOutputFile.cpp
ImfGenericOutputFile.cpp
ImfOutputPartData.cpp
ImfMultiPartInputFile.cpp
ImfGenericInputFile.cpp
ImfPartType.cpp
ImfInputPartData.cpp
ImfOutputPart.cpp
ImfTiledOutputPart.cpp
ImfInputPart.cpp
ImfTiledInputPart.cpp
ImfDeepScanLineInputPart.cpp
ImfDeepScanLineOutputPart.cpp
ImfDeepScanLineInputFile.cpp
ImfDeepScanLineOutputFile.cpp
ImfDeepTiledInputPart.cpp
ImfDeepTiledOutputPart.cpp
ImfDeepTiledInputFile.cpp
ImfDeepTiledOutputFile.cpp
ImfDeepFrameBuffer.cpp
ImfDeepCompositing.cpp
ImfCompositeDeepScanLine.cpp
ImfDeepImageStateAttribute.cpp
ImfFastHuf.cpp
ImfFloatVectorAttribute.cpp
ImfRle.cpp
ImfSystemSpecific.cpp
ImfZip.cpp
)
IF (BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DILMIMF_EXPORTS)
ENDIF()
ADD_LIBRARY ( IlmImf ${LIB_TYPE}
${ILMIMF_SRCS}
)
TARGET_LINK_LIBRARIES ( IlmImf
Half
Iex${ILMBASE_LIBSUFFIX}
Imath${ILMBASE_LIBSUFFIX}
IlmThread${ILMBASE_LIBSUFFIX}
${PTHREAD_LIB} ${ZLIB_LIBRARIES}
)
ADD_DEPENDENCIES ( IlmImf b44ExpLogTable )
SET_SOURCE_FILES_PROPERTIES (
ImfB44Compressor.cpp
PROPERTIES
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
)
ADD_DEPENDENCIES ( IlmImf dwaLookups )
SET_SOURCE_FILES_PROPERTIES (
ImfDwaCompressor.cpp
PROPERTIES
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
)
# Libraries
INSTALL ( TARGETS
IlmImf
DESTINATION
${CMAKE_INSTALL_PREFIX}/lib
)
# Headers
INSTALL ( FILES
ImfForward.h
ImfExport.h
ImfAttribute.h
ImfBoxAttribute.h
ImfCRgbaFile.h
ImfChannelList.h
ImfChannelListAttribute.h
ImfCompressionAttribute.h
ImfDoubleAttribute.h
ImfFloatAttribute.h
ImfFrameBuffer.h
ImfHeader.h
ImfIO.h
ImfInputFile.h
ImfIntAttribute.h
ImfLineOrderAttribute.h
ImfMatrixAttribute.h
ImfOpaqueAttribute.h
ImfOutputFile.h
ImfRgbaFile.h
ImfStringAttribute.h
ImfVecAttribute.h
ImfHuf.h
ImfWav.h
ImfLut.h
ImfArray.h
ImfCompression.h
ImfLineOrder.h
ImfName.h
ImfPixelType.h
ImfVersion.h
ImfXdr.h
ImfConvert.h
ImfPreviewImage.h
ImfPreviewImageAttribute.h
ImfChromaticities.h
ImfChromaticitiesAttribute.h
ImfKeyCode.h
ImfKeyCodeAttribute.h
ImfTimeCode.h
ImfTimeCodeAttribute.h
ImfRational.h
ImfRationalAttribute.h
ImfFramesPerSecond.h
ImfStandardAttributes.h
ImfEnvmap.h
ImfEnvmapAttribute.h
ImfInt64.h
ImfRgba.h
ImfTileDescription.h
ImfTileDescriptionAttribute.h
ImfTiledInputFile.h
ImfTiledOutputFile.h
ImfTiledRgbaFile.h
ImfRgbaYca.h
ImfTestFile.h
ImfThreading.h
ImfB44Compressor.h
ImfStringVectorAttribute.h
ImfMultiView.h
ImfAcesFile.h
ImfMultiPartOutputFile.h
ImfGenericOutputFile.h
ImfMultiPartInputFile.h
ImfGenericInputFile.h
ImfPartType.h
ImfPartHelper.h
ImfOutputPart.h
ImfTiledOutputPart.h
ImfInputPart.h
ImfTiledInputPart.h
ImfDeepScanLineOutputFile.h
ImfDeepScanLineOutputPart.h
ImfDeepScanLineInputFile.h
ImfDeepScanLineInputPart.h
ImfDeepTiledInputFile.h
ImfDeepTiledInputPart.h
ImfDeepTiledOutputFile.h
ImfDeepTiledOutputPart.h
ImfDeepFrameBuffer.h
ImfDeepCompositing.h
ImfCompositeDeepScanLine.h
ImfNamespace.h
ImfMisc.h
ImfDeepImageState.h
ImfDeepImageStateAttribute.h
ImfFloatVectorAttribute.h
DESTINATION
${CMAKE_INSTALL_PREFIX}/include/OpenEXR
)
+10
View File
@@ -0,0 +1,10 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/include
Name: OpenImageIO
Description: OpenImageIO is a library for reading and writing images.
Version: @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.@PROJECT_VERSION_TWEAK@
Libs: -L${libdir} -lOpenImageIO -lOpenImageIO_Util
Cflags: -I${includedir}
Binary file not shown.
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
# Utility script to download and build OpenJPEG
#
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Exit the whole script if any command fails.
set -ex
# Repo and branch/tag/commit of OpenJPEG to download if we don't have it yet
OPENJPEG_REPO=${OPENJPEG_REPO:=https://github.com/uclouvain/openjpeg.git}
OPENJPEG_VERSION=${OPENJPEG_VERSION:=v2.4.0}
# Where to put OpenJPEG repo source (default to the ext area)
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
OPENJPEG_SRC_DIR=${OPENJPEG_SRC_DIR:=${LOCAL_DEPS_DIR}/OpenJPEG}
OPENJPEG_BUILD_DIR=${OPENJPEG_BUILD_DIR:=${OPENJPEG_SRC_DIR}/build}
OPENJPEG_INSTALL_DIR=${OPENJPEG_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
#OPENJPEG_CONFIG_OPTS=${OPENJPEG_CONFIG_OPTS:=}
pwd
echo "OpenJPEG install dir will be: ${OPENJPEG_INSTALL_DIR}"
mkdir -p ./ext
pushd ./ext
# Clone OpenJPEG project from GitHub and build
if [[ ! -e ${OPENJPEG_SRC_DIR} ]] ; then
echo "git clone ${OPENJPEG_REPO} ${OPENJPEG_SRC_DIR}"
git clone ${OPENJPEG_REPO} ${OPENJPEG_SRC_DIR}
fi
cd ${OPENJPEG_SRC_DIR}
echo "git checkout ${OPENJPEG_VERSION} --force"
git checkout ${OPENJPEG_VERSION} --force
mkdir -p ${OPENJPEG_BUILD_DIR} && true
cd ${OPENJPEG_BUILD_DIR}
if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${OPENJPEG_INSTALL_DIR} \
-DBUILD_CODEC=OFF \
${OPENJPEG_CONFIG_OPTS} ..
time cmake --build . --config Release --target install
fi
# ls -R ${OPENJPEG_INSTALL_DIR}
popd
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export OpenJPEG_ROOT=$OPENJPEG_INSTALL_DIR
+48
View File
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# Utility script to download and build Ptex
#
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Exit the whole script if any command fails.
set -ex
# Repo and branch/tag/commit of ptex to download if we don't have it yet
: ${PTEX_REPO:=https://github.com/wdas/ptex.git}
: ${PTEX_VERSION:=v2.4.0}
: ${PTEX_SRC_DIR:=${PWD}/ext/ptex}
: ${PTEX_BUILD_DIR:=${PTEX_SRC_DIR}/build}
: ${PTEX_INSTALL_DIR:=${PWD}/ext/dist}
pwd
echo "Ptex install dir will be: ${PTEX_INSTALL_DIR}"
mkdir -p ./ext
pushd ./ext
# Clone ptex project from GitHub and build
if [[ ! -e ${PTEX_SRC_DIR} ]] ; then
echo "git clone ${PTEX_REPO} ${PTEX_SRC_DIR}"
git clone ${PTEX_REPO} ${PTEX_SRC_DIR}
fi
cd ${PTEX_SRC_DIR}
echo "git checkout ${PTEX_VERSION} --force"
git checkout ${PTEX_VERSION} --force
mkdir -p ${PTEX_BUILD_DIR}
cd ${PTEX_BUILD_DIR}
time cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PTEX_INSTALL_DIR} \
${PTEX_CONFIG_OPTS} ..
time cmake --build . --config Release --target install
# ls -R ${PTEX_INSTALL_DIR}
popd
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export Ptex_ROOT=$PTEX_INSTALL_DIR
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${PTEX_INSTALL_DIR}/lib:${PTEX_INSTALL_DIR}/lib64
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
# Utility script to download and build cmake
#
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Exit the whole script if any command fails.
set -ex
echo "Building cmake"
uname
CMAKE_VERSION=${CMAKE_VERSION:=3.12.4}
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
CMAKE_INSTALL_DIR=${CMAKE_INSTALL_DIR:=${LOCAL_DEPS_DIR}/cmake}
if [[ `uname` == "Linux" && `uname -m` == "x86_64" ]] ; then
mkdir -p ${CMAKE_INSTALL_DIR} || true
curl --location "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.sh" -o "cmake.sh"
sh cmake.sh --skip-license --prefix=${CMAKE_INSTALL_DIR}
export PATH=${CMAKE_INSTALL_DIR}/bin:$PATH
fi
if [[ `uname` == "Linux" && `uname -m` == "aarch64" ]] ; then
mkdir -p ${CMAKE_INSTALL_DIR} || true
curl --location https://anaconda.org/conda-forge/cmake/3.17.0/download/linux-aarch64/cmake-3.17.0-h28c56e5_0.tar.bz2 -o cmake-3.17.0-h28c56e5_0.tar.bz2
tar -xjf cmake-3.17.0-h28c56e5_0.tar.bz2 -C ${CMAKE_INSTALL_DIR}
export PATH=${CMAKE_INSTALL_DIR}/bin:$PATH
# In case we ever need to build from scratch:
# curl --location "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz" -o cmake.tar.gz
# tar xzf cmake.tar.gz
# pushd cmake-${CMAKE_VERSION}
# CXX="ccache $CXX" ./bootstrap --parallel=${PARALLEL:=4} --enable-ccache
# CXX="ccache $CXX" timeout 2100 time make ${PAR_MAKEFAGS} || true
# export PATH=${CMAKE_INSTALL_DIR}/bin:$PWD/bin:$PATH
# popd
fi
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env bash
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Utility script to download and build giflib
# Exit the whole script if any command fails.
set -ex
GIFLIB_REPO=${GIFLIB_REPO:=https://gitlab.com/giflib/giflib.git}
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
GIFLIB_BUILD_DIR=${GIFLIB_BUILD_DIR:=${LOCAL_DEPS_DIR}/giflib}
GIFLIB_INSTALL_DIR=${GIFLIB_INSTALL_DIR:=${PWD}/ext/dist}
GIFLIB_VERSION=${GIFLIB_VERSION:=5.2.1}
GIFLIB_CC=${GIFLIB_CC:=gcc}
BASEDIR=`pwd`
pwd
echo "giflib install dir will be: ${GIFLIB_INSTALL_DIR}"
mkdir -p ${LOCAL_DEPS_DIR}
pushd ${LOCAL_DEPS_DIR}
# Clone giflib project and build
if [[ ! -e giflib-${GIFLIB_VERSION} ]] ; then
curl --location https://downloads.sourceforge.net/project/giflib/giflib-${GIFLIB_VERSION}.tar.gz -o giflib.tar.gz
tar xzf giflib.tar.gz
pushd giflib-${GIFLIB_VERSION}
cp Makefile Makefile.old
curl --location https://sourceforge.net/p/giflib/bugs/_discuss/thread/4e811ad29b/c323/attachment/Makefile.patch -o Makefile.patch
patch -p0 < Makefile.patch
popd
fi
cd giflib-${GIFLIB_VERSION}
if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time make PREFIX=${GIFLIB_INSTALL_DIR} CC=${GIFLIB_CC} install
fi
popd
# ls -R ${GIFLIB_INSTALL_DIR} && true
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export GIF_ROOT=$GIFLIB_INSTALL_DIR
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${GIFLIB_INSTALL_DIR}/lib
+56
View File
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
# Utility script to download and build libjpeg-turbo
#
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Exit the whole script if any command fails.
set -ex
# Repo and branch/tag/commit of libjpeg-turbo to download if we don't have it yet
LIBJPEGTURBO_REPO=${LIBJPEGTURBO_REPO:=https://github.com/libjpeg-turbo/libjpeg-turbo.git}
LIBJPEGTURBO_VERSION=${LIBJPEGTURBO_VERSION:=2.0.5}
# Where to put libjpeg-turbo repo source (default to the ext area)
LIBJPEGTURBO_SRC_DIR=${LIBJPEGTURBO_SRC_DIR:=${PWD}/ext/libjpeg-turbo}
# Temp build area (default to a build/ subdir under source)
LIBJPEGTURBO_BUILD_DIR=${LIBJPEGTURBO_BUILD_DIR:=${LIBJPEGTURBO_SRC_DIR}/build}
# Install area for libjpeg-turbo (default to ext/dist)
LIBJPEGTURBO_INSTALL_DIR=${LIBJPEGTURBO_INSTALL_DIR:=${PWD}/ext/dist}
#LIBJPEGTURBO_CONFIG_OPTS=${LIBJPEGTURBO_CONFIG_OPTS:=}
pwd
echo "libjpeg-turbo install dir will be: ${LIBJPEGTURBO_INSTALL_DIR}"
mkdir -p ./ext
pushd ./ext
# Clone libjpeg-turbo project from GitHub and build
if [[ ! -e ${LIBJPEGTURBO_SRC_DIR} ]] ; then
echo "git clone ${LIBJPEGTURBO_REPO} ${LIBJPEGTURBO_SRC_DIR}"
git clone ${LIBJPEGTURBO_REPO} ${LIBJPEGTURBO_SRC_DIR}
fi
cd ${LIBJPEGTURBO_SRC_DIR}
echo "git checkout ${LIBJPEGTURBO_VERSION} --force"
git checkout ${LIBJPEGTURBO_VERSION} --force
mkdir -p ${LIBJPEGTURBO_BUILD_DIR}
cd ${LIBJPEGTURBO_BUILD_DIR}
if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${LIBJPEGTURBO_INSTALL_DIR} \
${LIBJPEGTURBO_CONFIG_OPTS} ..
time cmake --build . --config Release --target install
fi
# ls -R ${LIBJPEGTURBO_INSTALL_DIR}
popd
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export JPEGTurbo_ROOT=$LIBJPEGTURBO_INSTALL_DIR
+60
View File
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
# Utility script to download and build libpng
#
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Exit the whole script if any command fails.
set -ex
# Repo and branch/tag/commit of libpng to download if we don't have it yet
LIBPNG_REPO=${LIBPNG_REPO:=https://github.com/glennrp/libpng.git}
LIBPNG_VERSION=${LIBPNG_VERSION:=v1.6.35}
# Where to put libpng repo source (default to the ext area)
LIBPNG_SRC_DIR=${LIBPNG_SRC_DIR:=${PWD}/ext/libpng}
# Temp build area (default to a build/ subdir under source)
LIBPNG_BUILD_DIR=${LIBPNG_BUILD_DIR:=${LIBPNG_SRC_DIR}/build}
# Install area for libpng (default to ext/dist)
LIBPNG_INSTALL_DIR=${LIBPNG_INSTALL_DIR:=${PWD}/ext/dist}
#LIBPNG_CONFIG_OPTS=${LIBPNG_CONFIG_OPTS:=}
pwd
echo "libpng install dir will be: ${LIBPNG_INSTALL_DIR}"
mkdir -p ./ext
pushd ./ext
# Clone libpng project from GitHub and build
if [[ ! -e ${LIBPNG_SRC_DIR} ]] ; then
echo "git clone ${LIBPNG_REPO} ${LIBPNG_SRC_DIR}"
git clone ${LIBPNG_REPO} ${LIBPNG_SRC_DIR}
fi
cd ${LIBPNG_SRC_DIR}
echo "git checkout ${LIBPNG_VERSION} --force"
git checkout ${LIBPNG_VERSION} --force
mkdir -p ${LIBPNG_BUILD_DIR}
cd ${LIBPNG_BUILD_DIR}
if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${LIBPNG_INSTALL_DIR} \
-DPNG_EXECUTABLES=OFF \
-DPNG_TESTS=OFF \
${LIBPNG_CONFIG_OPTS} ..
time cmake --build . --config Release --target install
fi
# ls -R ${LIBPNG_INSTALL_DIR}
popd
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export PNG_ROOT=$LIBPNG_INSTALL_DIR
+59
View File
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Utility script to download and build LibRaw
# Exit the whole script if any command fails.
set -ex
# Which LibRaw to retrieve, how to build it
LIBRAW_REPO=${LIBRAW_REPO:=https://github.com/LibRaw/LibRaw.git}
LIBRAW_VERSION=${LIBRAW_VERSION:=0.20.2}
# Where to install the final results
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
LIBRAW_SOURCE_DIR=${LIBRAW_SOURCE_DIR:=${LOCAL_DEPS_DIR}/libraw}
LIBRAW_BUILD_DIR=${LIBRAW_BUILD_DIR:=${LOCAL_DEPS_DIR}/libraw-build}
LIBRAW_INSTALL_DIR=${LIBRAW_INSTALL_DIR:=${LOCAL_DEPS_DIR}/libraw-install}
LIBRAW_BUILD_TYPE=${LIBRAW_BUILD_TYPE:=Release}
pwd
echo "Building LibRaw ${LIBRAW_VERSION}"
echo " build dir will be: ${LIBRAW_BUILD_DIR}"
echo " install dir will be: ${LIBRAW_INSTALL_DIR}"
echo " build type is ${LIBRAW_BUILD_TYPE}"
# Clone LibRaw project (including IlmBase) from GitHub and build
if [[ ! -e ${LIBRAW_SOURCE_DIR} ]] ; then
echo "git clone ${LIBRAW_REPO} ${LIBRAW_SOURCE_DIR}"
git clone ${LIBRAW_REPO} ${LIBRAW_SOURCE_DIR}
fi
mkdir -p ${LIBRAW_INSTALL_DIR} && true
mkdir -p ${LIBRAW_BUILD_DIR} && true
pushd ${LIBRAW_SOURCE_DIR}
git checkout ${LIBRAW_VERSION} --force
if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
aclocal
autoreconf --install
./configure --prefix=${LIBRAW_INSTALL_DIR}
time make -j ${PARALLEL:=4} && make install
fi
popd
#ls -R ${LIBRAW_INSTALL_DIR}
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export LibRaw_ROOT=$LIBRAW_INSTALL_DIR
export LibRaw_LIBRARY_DIR=$LIBRAW_INSTALL_DIR/lib
export LD_LIBRARY_PATH=$LIBRAW_ROOT/lib:$LD_LIBRARY_PATH
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Utility script to download and build libtiff
# Exit the whole script if any command fails.
set -ex
LIBTIFF_REPO=${LIBTIFF_REPO:=https://gitlab.com/libtiff/libtiff.git}
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
LIBTIFF_BUILD_DIR=${LIBTIFF_BUILD_DIR:=${LOCAL_DEPS_DIR}/libtiff}
LIBTIFF_INSTALL_DIR=${LIBTIFF_INSTALL_DIR:=${PWD}/ext/dist}
LIBTIFF_VERSION=${LIBTIFF_VERSION:=v4.3.0}
LIBTIFF_BUILD_TYPE=${LIBTIFF_BUILD_TYPE:=Release}
if [[ `uname` == `Linux` ]] ; then
LIBTIFF_CXX_FLAGS=${LIBTIFF_CXX_FLAGS:="-O3 -Wno-unused-function -Wno-deprecated-declarations -Wno-cast-qual -Wno-write-strings"}
fi
LIBTIFF_BUILDOPTS="${LIBTIFF_BUILDOPTS}"
BASEDIR=`pwd`
pwd
echo "libtiff install dir will be: ${LIBTIFF_INSTALL_DIR}"
mkdir -p ${LOCAL_DEPS_DIR}
pushd ${LOCAL_DEPS_DIR}
# Clone libtiff project from GitHub and build
if [[ ! -e libtiff ]] ; then
echo "git clone ${LIBTIFF_REPO} libtiff"
git clone ${LIBTIFF_REPO} libtiff
fi
cd libtiff
echo "git checkout ${LIBTIFF_VERSION} --force"
git checkout ${LIBTIFF_VERSION} --force
mkdir -p build
cd build
if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time cmake -DCMAKE_BUILD_TYPE=${LIBTIFF_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=${LIBTIFF_INSTALL_DIR} \
-DCMAKE_CXX_FLAGS="${LIBTIFF_CXX_FLAGS}" \
-DBUILD_SHARED_LIBS=${LIBTIFF_BUILD_SHARED_LIBS:-ON} \
${LIBTIFF_BUILDOPTS} ..
time cmake --build . --target install
fi
popd
# ls -R ${LIBTIFF_INSTALL_DIR}
#echo "listing .."
#ls ..
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export LIBTIFF_ROOT=$LIBTIFF_INSTALL_DIR
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${LIBTIFF_INSTALL_DIR}/lib
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# Utility script to download and build LLVM & clang
#
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Exit the whole script if any command fails.
set -ex
echo "Building LLVM"
uname
if [[ `uname` == "Linux" ]] ; then
: ${LLVM_VERSION:=13.0.0}
: ${LLVM_INSTALL_DIR:=${PWD}/llvm-install}
: ${LLVM_DISTRO_NAME:=ubuntu-18.04}
LLVMTAR=clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-${LLVM_DISTRO_NAME}.tar.xz
echo LLVMTAR = $LLVMTAR
curl --location https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/${LLVMTAR} -o $LLVMTAR
ls -l $LLVMTAR
tar xf $LLVMTAR
rm -f $LLVMTAR
echo "Installed ${LLVM_VERSION} in ${LLVM_INSTALL_DIR}"
mkdir -p $LLVM_INSTALL_DIR && true
mv clang+llvm*/* $LLVM_INSTALL_DIR
export LLVM_DIRECTORY=$LLVM_INSTALL_DIR
export PATH=${LLVM_INSTALL_DIR}/bin:$PATH
# ls -a $LLVM_DIRECTORY
fi
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Exit the whole script if any command fails.
set -ex
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
DOWNLOADS_DIR=${DOWNLOADS_DIR:=${LOCAL_DEPS_DIR}/downloads}
NINJA_REPO=${NINJA_REPO:=https://github.com/ninja-build/ninja}
NINJA_VERSION=${NINJA_VERSION:=1.10.2}
NINJA_BRANCH=${NINJA_BRANCH:=v${NINJA_VERSION}}
NINJA_INSTALL_DIR=${NINJA_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist/bin}
if [ ! -f $DOWNLOADS_DIR/ninja-${NINJA_VERSION}.zip ]; then
curl --location ${NINJA_REPO}/archive/${NINJA_BRANCH}.tar.gz -o $DOWNLOADS_DIR/ninja-${NINJA_BRANCH}.tar.gz
fi
tar xf $DOWNLOADS_DIR/ninja-${NINJA_BRANCH}.tar.gz
pushd ninja-${NINJA_VERSION}
./configure.py --bootstrap
mkdir -p ${NINJA_INSTALL_DIR}
cp ninja ${NINJA_INSTALL_DIR}
popd
+63
View File
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Utility script to download and build OpenColorIO
# Exit the whole script if any command fails.
set -ex
# Which OCIO to retrieve, how to build it
OPENCOLORIO_REPO=${OPENCOLORIO_REPO:=https://github.com/AcademySoftwareFoundation/OpenColorIO.git}
OPENCOLORIO_VERSION=${OPENCOLORIO_VERSION:=v2.2.1}
# Where to install the final results
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
OPENCOLORIO_SOURCE_DIR=${OPENCOLORIO_SOURCE_DIR:=${LOCAL_DEPS_DIR}/OpenColorIO}
OPENCOLORIO_BUILD_DIR=${OPENCOLORIO_BUILD_DIR:=${LOCAL_DEPS_DIR}/OpenColorIO-build}
OPENCOLORIO_INSTALL_DIR=${OPENCOLORIO_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
OPENCOLORIO_CXX_FLAGS=${OPENCOLORIO_CXX_FLAGS:="-Wno-unused-function -Wno-deprecated-declarations -Wno-cast-qual -Wno-write-strings"}
# Just need libs:
OPENCOLORIO_BUILDOPTS="-DOCIO_BUILD_APPS=OFF -DOCIO_BUILD_NUKE=OFF \
-DOCIO_BUILD_DOCS=OFF -DOCIO_BUILD_TESTS=OFF \
-DOCIO_BUILD_GPU_TESTS=OFF \
-DOCIO_BUILD_PYTHON=OFF -DOCIO_BUILD_PYGLUE=OFF \
-DOCIO_BUILD_JAVA=OFF \
-DBUILD_SHARED_LIBS=${OPENCOLORIO_BUILD_SHARED_LIBS:=ON}"
BASEDIR=`pwd`
pwd
echo "OpenColorIO install dir will be: ${OPENCOLORIO_INSTALL_DIR}"
mkdir -p ${LOCAL_DEPS_DIR}
pushd ${LOCAL_DEPS_DIR}
# Clone OpenColorIO project from GitHub and build
if [[ ! -e ${OPENCOLORIO_SOURCE_DIR} ]] ; then
echo "git clone ${OPENCOLORIO_REPO} ${OPENCOLORIO_SOURCE_DIR}"
git clone ${OPENCOLORIO_REPO} ${OPENCOLORIO_SOURCE_DIR}
fi
cd ${OPENCOLORIO_SOURCE_DIR}
echo "git checkout ${OPENCOLORIO_VERSION} --force"
git checkout ${OPENCOLORIO_VERSION} --force
mkdir -p ${OPENCOLORIO_BUILD_DIR}
cd ${OPENCOLORIO_BUILD_DIR}
time cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${OPENCOLORIO_INSTALL_DIR} \
-DCMAKE_CXX_FLAGS="${OPENCOLORIO_CXX_FLAGS}" \
${OPENCOLORIO_BUILDOPTS} ${OPENCOLORIO_SOURCE_DIR}
time cmake --build . --config Release --target install
popd
# ls -R ${OPENCOLORIO_INSTALL_DIR}
#echo "listing .."
#ls ..
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export OpenColorIO_ROOT=$OPENCOLORIO_INSTALL_DIR
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${OPENCOLORIO_INSTALL_DIR}/lib
+76 -37
View File
@@ -1,48 +1,87 @@
#!/bin/bash
#!/usr/bin/env bash
# The Linux VM used by Travis has OpenEXR 1.x. We really want 2.x.
# Utility script to download and build OpenEXR & IlmBase
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: BSD-3-Clause and Apache-2.0
# https://github.com/OpenImageIO/oiio
# Exit the whole script if any command fails.
set -ex
# Which OpenEXR to retrieve, how to build it
OPENEXR_REPO=${OPENEXR_REPO:=https://github.com/AcademySoftwareFoundation/openexr.git}
OPENEXR_VERSION=${OPENEXR_VERSION:=v3.1.9}
# Where to install the final results
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
OPENEXR_SOURCE_DIR=${OPENEXR_SOURCE_DIR:=${LOCAL_DEPS_DIR}/openexr}
OPENEXR_BUILD_DIR=${OPENEXR_BUILD_DIR:=${LOCAL_DEPS_DIR}/openexr-build}
OPENEXR_INSTALL_DIR=${OPENEXR_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
OPENEXR_BUILD_TYPE=${OPENEXR_BUILD_TYPE:=Release}
OPENEXR_CMAKE_FLAGS=${OPENEXR_CMAKE_FLAGS:=""}
OPENEXR_CXX_FLAGS=${OPENEXR_CXX_FLAGS:=""}
BASEDIR=$PWD
EXRINSTALLDIR=${EXRINSTALLDIR:=${PWD}/openexr-install}
EXRVERSION=${EXRVERSION:=2.2.0}
BASEDIR=`pwd`
pwd
echo "EXR install dir will be: ${EXRINSTALLDIR}"
if [ ! -e ${EXRINSTALLDIR} ] ; then
mkdir ${EXRINSTALLDIR}
fi
echo "Building OpenEXR ${OPENEXR_VERSION}"
echo "OpenEXR build dir will be: ${OPENEXR_BUILD_DIR}"
echo "OpenEXR install dir will be: ${OPENEXR_INSTALL_DIR}"
echo "OpenEXR Build type is ${OPENEXR_BUILD_TYPE}"
echo "CMAKE_PREFIX_PATH is ${CMAKE_PREFIX_PATH}"
# Clone OpenEXR project (including IlmBase) from GitHub and build
if [ ! -e ./openexr ] ; then
git clone -b v${EXRVERSION} https://github.com/openexr/openexr.git ./openexr
if [[ ! -e ${OPENEXR_SOURCE_DIR} ]] ; then
echo "git clone ${OPENEXR_REPO} ${OPENEXR_SOURCE_DIR}"
git clone ${OPENEXR_REPO} ${OPENEXR_SOURCE_DIR}
fi
mkdir -p ${OPENEXR_INSTALL_DIR} && true
mkdir -p ${OPENEXR_BUILD_DIR} && true
pushd ${OPENEXR_SOURCE_DIR}
git checkout ${OPENEXR_VERSION} --force
if [[ ${OPENEXR_VERSION} == "v2.3.0" ]] ; then
# Simplified setup for 2.3+
cd ${OPENEXR_BUILD_DIR}
cmake -DCMAKE_BUILD_TYPE=${OPENEXR_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}" \
-DILMBASE_PACKAGE_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DOPENEXR_BUILD_UTILS=0 \
-DOPENEXR_BUILD_TESTS=0 \
-DOPENEXR_BUILD_PYTHON_LIBS=0 \
-DCMAKE_CXX_FLAGS="${OPENEXR_CXX_FLAGS}" \
${OPENEXR_CMAKE_FLAGS} ${OPENEXR_SOURCE_DIR}
time cmake --build . --target install --config ${OPENEXR_BUILD_TYPE}
else
# Simplified setup for 2.4+
cd ${OPENEXR_BUILD_DIR}
cmake -DCMAKE_BUILD_TYPE=${OPENEXR_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}" \
-DILMBASE_PACKAGE_PREFIX="${OPENEXR_INSTALL_DIR}" \
-DOPENEXR_BUILD_UTILS=0 \
-DBUILD_TESTING=0 \
-DPYILMBASE_ENABLE=0 \
-DOPENEXR_VIEWERS_ENABLE=0 \
-DINSTALL_OPENEXR_EXAMPLES=0 \
-DOPENEXR_INSTALL_EXAMPLES=0 \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_CXX_FLAGS="${OPENEXR_CXX_FLAGS}" \
${OPENEXR_CMAKE_FLAGS} ${OPENEXR_SOURCE_DIR}
time cmake --build . --target install --config ${OPENEXR_BUILD_TYPE}
fi
flags=
if [ ${LINKSTATIC:=0} == 1 ] ; then
flags=${flags} --enable-static --enable-shared=no --with-pic
fi
pushd ./openexr
git checkout v${EXRVERSION} --force
cd IlmBase
mkdir build
cd build
cmake --config Release -DCMAKE_INSTALL_PREFIX=${EXRINSTALLDIR} .. && make clean && make -j 4 && make install
cd ..
cd ../OpenEXR
cp ${BASEDIR}/src/build-scripts/OpenEXR-CMakeLists.txt CMakeLists.txt
cp ${BASEDIR}/src/build-scripts/OpenEXR-IlmImf-CMakeLists.txt IlmImf/CMakeLists.txt
mkdir build
mkdir build/IlmImf
cd build
unzip -d IlmImf ${BASEDIR}/src/build-scripts/b44ExpLogTable.h.zip
unzip -d IlmImf ${BASEDIR}/src/build-scripts/dwaLookups.h.zip
cmake --config Release -DCMAKE_INSTALL_PREFIX=${EXRINSTALLDIR} -DILMBASE_PACKAGE_PREFIX=${EXRINSTALLDIR} -DBUILD_UTILS=0 -DBUILD_TESTS=0 .. && make clean && make -j 4 && make install
popd
ls -R ${EXRINSTALLDIR}
#ls -R ${OPENEXR_INSTALL_DIR}
#echo "listing .."
#ls ..
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export ILMBASE_ROOT=$OPENEXR_INSTALL_DIR
export OPENEXR_ROOT=$OPENEXR_INSTALL_DIR
export ILMBASE_LIBRARY_DIR=$OPENEXR_INSTALL_DIR/lib
export OPENEXR_LIBRARY_DIR=$OPENEXR_INSTALL_DIR/lib
export LD_LIBRARY_PATH=$OPENEXR_ROOT/lib:$LD_LIBRARY_PATH
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Utility script to download and build pugixml
#
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Exit the whole script if any command fails.
set -ex
# Repo and branch/tag/commit of pugixml to download if we don't have it yet
PUGIXML_REPO=${PUGIXML_REPO:=https://github.com/zeux/pugixml.git}
PUGIXML_VERSION=${PUGIXML_VERSION:=v1.11.4}
# Where to put pugixml repo source (default to the ext area)
PUGIXML_SRC_DIR=${PUGIXML_SRC_DIR:=${PWD}/ext/pugixml}
# Temp build area (default to a build/ subdir under source)
PUGIXML_BUILD_DIR=${PUGIXML_BUILD_DIR:=${PUGIXML_SRC_DIR}/build}
# Install area for pugixml (default to ext/dist)
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
PUGIXML_INSTALL_DIR=${PUGIXML_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
#PUGIXML_BUILD_OPTS=${PUGIXML_BUILD_OPTS:=}
pwd
echo "pugixml install dir will be: ${PUGIXML_INSTALL_DIR}"
mkdir -p ./ext
pushd ./ext
# Clone pugixml project from GitHub and build
if [[ ! -e ${PUGIXML_SRC_DIR} ]] ; then
echo "git clone ${PUGIXML_REPO} ${PUGIXML_SRC_DIR}"
git clone ${PUGIXML_REPO} ${PUGIXML_SRC_DIR}
fi
cd ${PUGIXML_SRC_DIR}
echo "git checkout ${PUGIXML_VERSION} --force"
git checkout ${PUGIXML_VERSION} --force
mkdir -p ${PUGIXML_BUILD_DIR}
cd ${PUGIXML_BUILD_DIR}
if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PUGIXML_INSTALL_DIR} \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_TESTS=OFF \
${PUGIXML_BUILD_OPTS} ..
time cmake --build . --config Release --target install
fi
# ls -R ${PUGIXML_INSTALL_DIR}
popd
#echo "listing .."
#ls ..
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export pugixml_ROOT=$PUGIXML_INSTALL_DIR
export LD_LIBRARY_PATH=$pugixml_ROOT/lib:$pugixml_ROOT/lib64:$LD_LIBRARY_PATH
+65
View File
@@ -0,0 +1,65 @@
#!/usr/bin/env bash
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Utility script to download and build pybind11
# Exit the whole script if any command fails.
set -ex
# Repo and branch/tag/commit of pybind11 to download if we don't have it yet
PYBIND11_REPO=${PYBIND11_REPO:=https://github.com/pybind/pybind11.git}
PYBIND11_VERSION=${PYBIND11_VERSION:=v2.8.1}
# Where to put pybind11 repo source (default to the ext area)
PYBIND11_SRC_DIR=${PYBIND11_SRC_DIR:=${PWD}/ext/pybind11}
# Temp build area (default to a build/ subdir under source)
PYBIND11_BUILD_DIR=${PYBIND11_BUILD_DIR:=${PYBIND11_SRC_DIR}/build}
# Install area for pybind11 (default to ext/dist)
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
PYBIND11_INSTALL_DIR=${PYBIND11_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
#PYBIND11_BUILD_OPTS=${PYBIND11_BUILD_OPTS:=}
if [[ "${PYTHON_VERSION}" != "" ]] ; then
PYBIND11_BUILD_OPTS+=" -DPYBIND11_PYTHON_VERSION=${PYTHON_VERSION}"
fi
pwd
echo "pybind11 install dir will be: ${PYBIND11_INSTALL_DIR}"
mkdir -p ./ext
pushd ./ext
# Clone pybind11 project from GitHub and build
if [[ ! -e ${PYBIND11_SRC_DIR} ]] ; then
echo "git clone ${PYBIND11_REPO} ${PYBIND11_SRC_DIR}"
git clone ${PYBIND11_REPO} ${PYBIND11_SRC_DIR}
fi
cd ${PYBIND11_SRC_DIR}
echo "git checkout ${PYBIND11_VERSION} --force"
git checkout ${PYBIND11_VERSION} --force
mkdir -p ${PYBIND11_BUILD_DIR}
cd ${PYBIND11_BUILD_DIR}
if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PYBIND11_INSTALL_DIR} \
-DPYBIND11_TEST=OFF \
${PYBIND11_BUILD_OPTS} ..
time cmake --build . --config Release --target install
fi
# ls -R ${PYBIND11_INSTALL_DIR}
popd
#echo "listing .."
#ls ..
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export pybind11_ROOT=$PYBIND11_INSTALL_DIR
+66
View File
@@ -0,0 +1,66 @@
#!/usr/bin/env bash
# Utility script to download and build webp
#
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Exit the whole script if any command fails.
set -ex
# Repo and branch/tag/commit of webp to download if we don't have it yet
WEBP_REPO=${WEBP_REPO:=https://github.com/webmproject/libwebp.git}
WEBP_VERSION=${WEBP_VERSION:=v1.1.0}
# Where to put webp repo source (default to the ext area)
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
WEBP_SRC_DIR=${WEBP_SRC_DIR:=${LOCAL_DEPS_DIR}/webp}
WEBP_BUILD_DIR=${WEBP_BUILD_DIR:=${WEBP_SRC_DIR}/build}
WEBP_INSTALL_DIR=${WEBP_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
WEBP_BUILD_TYPE=${WEBP_BUILD_TYPE:=${CMAKE_BUILD_TYPE:-Release}}
#WEBP_CONFIG_OPTS=${WEBP_CONFIG_OPTS:=}
pwd
echo "webp install dir will be: ${WEBP_INSTALL_DIR}"
mkdir -p ./ext
pushd ./ext
# Clone webp project from GitHub and build
if [[ ! -e ${WEBP_SRC_DIR} ]] ; then
echo "git clone ${WEBP_REPO} ${WEBP_SRC_DIR}"
git clone ${WEBP_REPO} ${WEBP_SRC_DIR}
fi
cd ${WEBP_SRC_DIR}
echo "git checkout ${WEBP_VERSION} --force"
git checkout ${WEBP_VERSION} --force
mkdir -p ${WEBP_BUILD_DIR}
cd ${WEBP_BUILD_DIR}
if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time cmake -DCMAKE_BUILD_TYPE=${WEBP_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=${WEBP_INSTALL_DIR} \
-DWEBP_BUILD_ANIM_UTILS=OFF \
-DWEBP_BUILD_CWEBP=OFF \
-DWEBP_BUILD_DWEBP=OFF \
-DWEBP_BUILD_VWEBP=OFF \
-DWEBP_BUILD_GIF2WEBPx=OFF \
-DWEBP_BUILD_IMG2WEBP=OFF \
-DWEBP_BUILD_EXTRAS=OFF \
-DBUILD_SHARED_LIBS=ON \
${WEBP_CONFIG_OPTS} ..
time cmake --build . --target install
fi
# ls -R ${WEBP_INSTALL_DIR}
popd
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export WebP_ROOT=$WEBP_INSTALL_DIR
+58
View File
@@ -0,0 +1,58 @@
#!/usr/bin/env bash
# Utility script to download and build zlib
#
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Exit the whole script if any command fails.
set -ex
# Repo and branch/tag/commit of zlib to download if we don't have it yet
ZLIB_REPO=${ZLIB_REPO:=https://github.com/madler/zlib.git}
ZLIB_VERSION=${ZLIB_VERSION:=v1.2.11}
# Where to put zlib repo source (default to the ext area)
ZLIB_SRC_DIR=${ZLIB_SRC_DIR:=${PWD}/ext/zlib}
# Temp build area (default to a build/ subdir under source)
ZLIB_BUILD_DIR=${ZLIB_BUILD_DIR:=${ZLIB_SRC_DIR}/build}
# Install area for zlib (default to ext/dist)
ZLIB_INSTALL_DIR=${ZLIB_INSTALL_DIR:=${PWD}/ext/dist}
#ZLIB_CONFIG_OPTS=${ZLIB_CONFIG_OPTS:=}
pwd
echo "zlib install dir will be: ${ZLIB_INSTALL_DIR}"
mkdir -p ./ext
pushd ./ext
# Clone zlib project from GitHub and build
if [[ ! -e ${ZLIB_SRC_DIR} ]] ; then
echo "git clone ${ZLIB_REPO} ${ZLIB_SRC_DIR}"
git clone ${ZLIB_REPO} ${ZLIB_SRC_DIR}
fi
cd ${ZLIB_SRC_DIR}
echo "git checkout ${ZLIB_VERSION} --force"
git checkout ${ZLIB_VERSION} --force
mkdir -p ${ZLIB_BUILD_DIR} && true
cd ${ZLIB_BUILD_DIR}
if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
time cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${ZLIB_INSTALL_DIR} \
${ZLIB_CONFIG_OPTS} ..
time cmake --build . --config Release --target install
fi
# ls -R ${ZLIB_INSTALL_DIR}
popd
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export ZLIB_ROOT=$ZLIB_INSTALL_DIR
+68
View File
@@ -0,0 +1,68 @@
#!/usr/bin/env bash
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Important: set -ex causes this whole script to terminate with error if
# any command in it fails. This is crucial for CI tests.
set -ex
OIIO_CMAKE_FLAGS="$MY_CMAKE_FLAGS $OIIO_CMAKE_FLAGS"
if [[ "$USE_SIMD" != "" ]] ; then
OIIO_CMAKE_FLAGS="$OIIO_CMAKE_FLAGS -DUSE_SIMD=$USE_SIMD"
fi
if [[ -n "$FMT_VERSION" ]] ; then
OIIO_CMAKE_FLAGS="$OIIO_CMAKE_FLAGS -DBUILD_FMT_VERSION=$FMT_VERSION"
fi
if [[ -n "$CODECOV" ]] ; then
OIIO_CMAKE_FLAGS="$OIIO_CMAKE_FLAGS -DCODECOV=${CODECOV}"
fi
# On GHA, we can reduce build time with "unity" builds.
if [[ ${GITHUB_ACTIONS} == true ]] ; then
OIIO_CMAKE_FLAGS+=" -DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD:=ON} -DCMAKE_UNITY_BUILD_MODE=${CMAKE_UNITY_BUILD_MODE:=BATCH}"
fi
pushd build
cmake .. -G "$CMAKE_GENERATOR" \
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
-DCMAKE_INSTALL_PREFIX="$OpenImageIO_ROOT" \
-DPYTHON_VERSION="$PYTHON_VERSION" \
-DCMAKE_INSTALL_LIBDIR="$OpenImageIO_ROOT/lib" \
-DCMAKE_CXX_STANDARD="$CMAKE_CXX_STANDARD" \
-DOIIO_DOWNLOAD_MISSING_TESTDATA=ON \
-DEXTRA_CPP_ARGS="${OIIO_EXTRA_CPP_ARGS}" \
$OIIO_CMAKE_FLAGS -DVERBOSE=1
# Save a copy of the generated files for debugging broken CI builds.
mkdir cmake-save || /bin/true
cp -r CMake* *.cmake cmake-save
: ${BUILDTARGET:=install}
if [[ "$BUILDTARGET" != "none" ]] ; then
echo "Parallel build ${CMAKE_BUILD_PARALLEL_LEVEL} of target ${BUILDTARGET}"
time ${OIIO_CMAKE_BUILD_WRAPPER} cmake --build . --target ${BUILDTARGET} --config ${CMAKE_BUILD_TYPE}
fi
popd
if [[ "${DEBUG_CI:=0}" != "0" ]] ; then
echo "PATH=$PATH"
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
echo "PYTHONPATH=$PYTHONPATH"
echo "ldd oiiotool"
ldd $OpenImageIO_ROOT/bin/oiiotool
fi
if [[ "$BUILDTARGET" == clang-format ]] ; then
git diff --color
THEDIFF=`git diff`
if [[ "$THEDIFF" != "" ]] ; then
echo "git diff was not empty. Failing clang-format or clang-tidy check."
exit 1
fi
fi
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Run code coverage analysis
# This assumes that the build occurred with CODECOV=1 and tests have already
# fully run.
set -ex
echo "Performing code coverage analysis"
mkdir _coverage
pushd _coverage
# The sed command below converts from:
# ../build/src/libOpenImageIO/CMakeFiles/OpenImageIO.dir/foo.gcno
# to:
# ../src/libOpenImageIO/foo.cpp
for g in $(find ../build -name "*.gcno" -type f); do
echo "Processing $g"
echo "dirname $g = $(dirname $g) to " `$(echo "$g" | sed -e 's/\/build\//\//' -e 's/\.gcno/\.cpp/' -e 's/\.cpp\.cpp/\.cpp/' -e 's/\/CMakeFiles.*\.dir\//\//')`
gcov -l -p -o $(dirname "$g") $(echo "$g" | sed -e 's/\/build\//\//' -e 's/\.gcno/\.cpp/' -e 's/\/CMakeFiles.*\.dir\//\//')
done
popd
+76
View File
@@ -0,0 +1,76 @@
#!/usr/bin/env bash
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# This script is run when CI system first starts up.
# Since it sets many env variables needed by the caller, it should be run
# with 'source', not in a separate shell.
# Environment variables we always need
export PATH=/usr/local/bin/_ccache:/usr/lib/ccache:$PATH
export USE_CCACHE=${USE_CCACHE:=1}
export CCACHE_CPP2=
export CCACHE_DIR=/tmp/ccache
if [[ "${RUNNER_OS}" == "macOS" ]] ; then
export CCACHE_DIR=$HOME/.ccache
fi
mkdir -p $CCACHE_DIR
export OpenImageIO_ROOT=$PWD/dist
export DYLD_LIBRARY_PATH=$OpenImageIO_ROOT/lib:$DYLD_LIBRARY_PATH
export LD_LIBRARY_PATH=$OpenImageIO_ROOT/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$OpenImageIO_ROOT/lib64:$LD_LIBRARY_PATH
export OIIO_LIBRARY_PATH=$OpenImageIO_ROOT/lib
export LSAN_OPTIONS=suppressions=$PWD/src/build-scripts/nosanitize.txt
export ASAN_OPTIONS=print_suppressions=0
export UBSAN_OPTIONS=suppressions=$PWD/src/build-scripts/ubsan-suppressions.txt
export PYTHON_VERSION=${PYTHON_VERSION:="2.7"}
export PYTHONPATH=$OpenImageIO_ROOT/lib/python${PYTHON_VERSION}/site-packages:$PYTHONPATH
export BUILD_MISSING_DEPS=${BUILD_MISSING_DEPS:=1}
export COMPILER=${COMPILER:=gcc}
export CC=${CC:=gcc}
export CXX=${CXX:=g++}
export OpenImageIO_CI=true
export USE_NINJA=${USE_NINJA:=1}
export CMAKE_GENERATOR=${CMAKE_GENERATOR:=Ninja}
export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:=Release}
export CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD:=11}
export PARALLEL=${PARALLEL:=4}
export PAR_MAKEFLAGS=-j${PARALLEL}
export CMAKE_BUILD_PARALLEL_LEVEL=${CMAKE_BUILD_PARALLEL_LEVEL:=${PARALLEL}}
export CTEST_PARALLEL_LEVEL=${CTEST_PARALLEL_LEVEL:=${PARALLEL}}
export LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=$HOME/ext}
export PATH=${LOCAL_DEPS_DIR}/dist/bin:$PATH
export LD_LIBRARY_PATH=${LOCAL_DEPS_DIR}/dist/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=${LOCAL_DEPS_DIR}/dist/lib64:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=${LOCAL_DEPS_DIR}/dist/lib:$DYLD_LIBRARY_PATH
export OCIO="$PWD/testsuite/common/OpenColorIO/nuke-default/config.ocio"
export TESTSUITE_CLEANUP_ON_SUCCESS=${TESTSUITE_CLEANUP_ON_SUCCESS:=1}
mkdir -p build dist
echo "HOME = $HOME"
echo "PWD = $PWD"
echo "LOCAL_DEPS_DIR = $LOCAL_DEPS_DIR"
echo "uname -a: " `uname -a`
echo "uname -m: " `uname -m`
echo "uname -s: " `uname -s`
echo "uname -n: " `uname -n`
pwd
ls
env | sort
if [[ `uname -s` == "Linux" ]] ; then
head -40 /proc/cpuinfo
elif [[ "${RUNNER_OS}" == "macOS" ]] ; then
sysctl machdep.cpu.features
fi
# Save the env for use by other stages
src/build-scripts/save-env.bash
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Important: set -ex causes this whole script to terminate with error if
# any command in it fails. This is crucial for CI tests.
# (Though we let it run all the way through for code coverage workflows.)
if [[ "${CODECOV}" == "" ]]; then
set -ex
fi
: ${CTEST_EXCLUSIONS:="broken"}
: ${CTEST_TEST_TIMEOUT:=180}
#
# Try a few command line options to test them and also get some important
# debugging info in the CI logs.
#
echo ; echo "Results of oiiotool --version:"
$OpenImageIO_ROOT/bin/oiiotool --version || true
echo ; echo "Results of oiiotool brief help:"
$OpenImageIO_ROOT/bin/oiiotool || true
echo ; echo "Results of oiiotool full --help:"
$OpenImageIO_ROOT/bin/oiiotool --help || true
echo ; echo "Results of oiiotool with no args (should get short help message):"
$OpenImageIO_ROOT/bin/oiiotool || true
echo ; echo "Run unit tests and simple stats:"
$OpenImageIO_ROOT/bin/oiiotool --unittest --list-formats --threads 0 \
--cache 1000 --autotile --autopremult --runstats || true
echo ; echo "Try unknown command:"
$OpenImageIO_ROOT/bin/oiiotool -q --unknown || true
#
# Full test suite
#
echo "Parallel test ${CTEST_PARALLEL_LEVEL}"
echo "Default timeout ${CTEST_TEST_TIMEOUT}"
echo "Test exclusions '${CTEST_EXCLUSIONS}'"
echo "CTEST_ARGS '${CTEST_ARGS}'"
pushd build
time ctest -C ${CMAKE_BUILD_TYPE} --force-new-ctest-process --output-on-failure \
-E "${CTEST_EXCLUSIONS}" --timeout ${CTEST_TEST_TIMEOUT} ${CTEST_ARGS}
popd
Binary file not shown.
+201
View File
@@ -0,0 +1,201 @@
#!/usr/bin/env bash
#
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
set -ex
#
# Install system packages when those are acceptable for dependencies.
#
if [[ "$ASWF_ORG" != "" ]] ; then
# Using ASWF CentOS container
#ls /etc/yum.repos.d
sudo yum install -y giflib giflib-devel && true
sudo yum install -y opencv opencv-devel && true
sudo yum install -y ffmpeg ffmpeg-devel && true
if [[ "${EXTRA_DEP_PACKAGES}" != "" ]] ; then
time sudo yum install -y ${EXTRA_DEP_PACKAGES}
fi
if [[ "${CONAN_LLVM_VERSION}" != "" ]] ; then
mkdir conan
pushd conan
# Simple way to conan install just one package:
# conan install clang/${CONAN_LLVM_VERSION}@aswftesting/ci_common1 -g deploy -g virtualenv
# But the below method can accommodate multiple requirements:
echo "[imports]" >> conanfile.txt
echo "., * -> ." >> conanfile.txt
echo "[requires]" >> conanfile.txt
echo "clang/${CONAN_LLVM_VERSION}@aswftesting/ci_common1" >> conanfile.txt
time conan install .
echo "--ls--"
ls -R .
export PATH=$PWD/bin:$PATH
export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH
export LLVM_ROOT=$PWD
popd
fi
if [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" ]] ; then
# Lock down icc to 2022.1 because newer versions hosted on the Intel
# repo require a glibc too new for the ASWF CentOS7-based containers
# we run CI on.
sudo cp src/build-scripts/oneAPI.repo /etc/yum.repos.d
sudo /usr/bin/yum install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2022.1.0.x86_64
set +e; source /opt/intel/oneapi/setvars.sh --config oneapi_2022.1.0.cfg; set -e
elif [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" || "$CXX" == "icpx" || "$CC" == "icx" || "$USE_ICX" != "" ]] ; then
# Lock down icx to 2023.1 because newer versions hosted on the Intel
# repo require a libstd++ too new for the ASWF containers we run CI on
# because their default install of gcc 9 based toolchain.
sudo cp src/build-scripts/oneAPI.repo /etc/yum.repos.d
sudo yum install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2023.1.0.x86_64
# sudo yum install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
set +e; source /opt/intel/oneapi/setvars.sh; set -e
echo "Verifying installation of Intel(r) oneAPI DPC++/C++ Compiler:"
icpx --version
fi
else
# Using native Ubuntu runner
time sudo apt-get update
time sudo apt-get -q install -y \
git cmake ninja-build ccache g++ \
libboost-dev libboost-thread-dev libboost-filesystem-dev \
libilmbase-dev libopenexr-dev \
libtbb-dev \
libtiff-dev libgif-dev libpng-dev libraw-dev libwebp-dev \
libavcodec-dev libavformat-dev libswscale-dev libavutil-dev \
dcmtk libopenvdb-dev \
libfreetype6-dev \
locales wget \
libopencolorio-dev \
libopencv-dev \
libhdf5-dev
if [[ "${QT_VERSION:-5}" == "5" ]] ; then
time sudo apt-get -q install -y \
qt5-default || /bin/true
elif [[ "${QT_VERSION}" == "6" ]] ; then
time sudo apt-get -q install -y qt6-base-dev || /bin/true
fi
if [[ "${EXTRA_DEP_PACKAGES}" != "" ]] ; then
time sudo apt-get -q install -y ${EXTRA_DEP_PACKAGES}
fi
# Nonstandard python versions
if [[ "${PYTHON_VERSION}" == "3.9" ]] ; then
time sudo apt-get -q install -y python3.9-dev python3-numpy
pip3 --version
pip3 install numpy
elif [[ "$PYTHON_VERSION" == "2.7" ]] ; then
time sudo apt-get -q install -y python-dev python-numpy
else
pip3 install numpy
fi
if [[ "$USE_LIBHEIF" != "0" ]] ; then
sudo add-apt-repository ppa:strukturag/libde265 || true
sudo add-apt-repository ppa:strukturag/libheif || true
time sudo apt-get -q install -y libheif-plugin-aomdec \
libheif-plugin-aomenc libheif-plugin-libde265 \
libheif-plugin-x265 libheif-dev || true
fi
export CMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu:$CMAKE_PREFIX_PATH
if [[ "$CXX" == "g++-6" ]] ; then
time sudo apt-get install -y g++-6
elif [[ "$CXX" == "g++-7" ]] ; then
time sudo apt-get install -y g++-7
elif [[ "$CXX" == "g++-8" ]] ; then
time sudo apt-get install -y g++-8
elif [[ "$CXX" == "g++-9" ]] ; then
time sudo apt-get install -y g++-9
elif [[ "$CXX" == "g++-10" ]] ; then
time sudo apt-get install -y g++-10
elif [[ "$CXX" == "g++-11" ]] ; then
time sudo apt-get install -y g++-11
elif [[ "$CXX" == "g++-12" ]] ; then
time sudo apt-get install -y g++-12
fi
if [[ "$CXX" == "icpc" || "$CC" == "icc" || "$USE_ICC" != "" || "$USE_ICX" != "" ]] ; then
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
time sudo apt-get update
time sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
set +e; source /opt/intel/oneapi/setvars.sh; set -e
fi
fi
cmake --version
#
# If we're using clang to compile on native Ubuntu, we need to install it.
# If on an ASWF CentOS docker container, it already is installed.
#
if [[ "$CXX" == "clang++" && "$ASWF_ORG" == "" ]] ; then
source src/build-scripts/build_llvm.bash
fi
#
# Packages we need to build from scratch.
#
source src/build-scripts/build_pybind11.bash
if [[ "$OPENEXR_VERSION" != "" ]] ; then
source src/build-scripts/build_openexr.bash
fi
if [[ "$WEBP_VERSION" != "" ]] ; then
source src/build-scripts/build_webp.bash
fi
if [[ "$LIBTIFF_VERSION" != "" ]] ; then
source src/build-scripts/build_libtiff.bash
fi
if [[ "$LIBRAW_VERSION" != "" ]] ; then
source src/build-scripts/build_libraw.bash
fi
if [[ "$OPENJPEG_VERSION" != "" ]] ; then
source src/build-scripts/build_OpenJPEG.bash
fi
if [[ "$PUGIXML_VERSION" != "" ]] ; then
source src/build-scripts/build_pugixml.bash
export MY_CMAKE_FLAGS+=" -DUSE_EXTERNAL_PUGIXML=1 "
fi
if [[ "$OPENCOLORIO_VERSION" != "" ]] ; then
source src/build-scripts/build_opencolorio.bash
fi
if [[ "$PTEX_VERSION" != "" ]] ; then
source src/build-scripts/build_Ptex.bash
fi
if [[ "$USE_ICC" != "" ]] ; then
# We used gcc for the prior dependency builds, but use icc for OIIO itself
echo "which icpc:" $(which icpc)
export CXX=icpc
export CC=icc
fi
# Save the env for use by other stages
src/build-scripts/save-env.bash
+145
View File
@@ -0,0 +1,145 @@
#!/usr/bin/env bash
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# DEP_DIR="$PWD/ext/dist"
DEP_DIR="$PWD/dist/$PLATFORM"
mkdir -p "$DEP_DIR"
mkdir -p ext && true
INT_DIR="build/$PLATFORM"
VCPKG_INSTALLATION_ROOT=/c/vcpkg
export CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH:=.}
export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;$DEP_DIR"
export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;$VCPKG_INSTALLATION_ROOT/installed/x64-windows"
export PATH="$PATH:$DEP_DIR/bin:$DEP_DIR/lib:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/bin:/bin:$PWD/ext/dist/bin:$PWD/ext/dist/lib"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$DEP_DIR/bin:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/bin"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$DEP_DIR/lib:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib"
# export MY_CMAKE_FLAGS="$MY_CMAKE_FLAGS -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
# export OPENEXR_CMAKE_FLAGS="$OPENEXR_CMAKE_FLAGS -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
#ls -l "C:/Program Files (x86)/Microsoft Visual Studio/*/Enterprise/VC/Tools/MSVC" && true
#ls -l "C:/Program Files (x86)/Microsoft Visual Studio" && true
if [[ "$PYTHON_VERSION" == "3.6" ]] ; then
export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;/c/hostedtoolcache/windows/Python/3.6.8/x64"
elif [[ "$PYTHON_VERSION" == "3.7" ]] ; then
export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;/c/hostedtoolcache/windows/Python/3.7.9/x64"
export Python_EXECUTABLE="/c/hostedtoolcache/windows/Python/3.7.9/x64/python.exe"
export PYTHONPATH=$OpenImageIO_ROOT/lib/python${PYTHON_VERSION}/site-packages
elif [[ "$PYTHON_VERSION" == "3.9" ]] ; then
export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;/c/hostedtoolcache/windows/Python/3.9.10/x64"
export Python_EXECUTABLE="/c/hostedtoolcache/windows/Python/3.9.10/x64/python3.exe"
export PYTHONPATH=$OpenImageIO_ROOT/lib/python${PYTHON_VERSION}/site-packages
fi
pip install numpy
########################################################################
# Dependency method #1: Use vcpkg (disabled)
#
# Currently we are not using this, but here it is for reference:
#
echo "All pre-installed VCPkg installs:"
vcpkg list
echo "---------------"
# vcpkg update
#
time vcpkg install boost-container:x64-windows
time vcpkg install boost-filesystem:x64-windows
time vcpkg install boost-math:x64-windows
time vcpkg install boost-stacktrace:x64-windows
time vcpkg install boost-system:x64-windows
time vcpkg install boost-thread:x64-windows
# # vcpkg install zlib:x64-windows
vcpkg install tiff:x64-windows
# vcpkg install libpng:x64-windows
# vcpkg install giflib:x64-windows
vcpkg install freetype:x64-windows
# # vcpkg install openexr:x64-windows
vcpkg install libjpeg-turbo:x64-windows
#
# vcpkg install libraw:x64-windows
# vcpkg install openjpeg:x64-windows
# # vcpkg install ffmpeg:x64-windows # takes FOREVER!
# # vcpkg install webp:x64-windows # No such vcpkg package?a
#
# #echo "$VCPKG_INSTALLATION_ROOT"
# #ls "$VCPKG_INSTALLATION_ROOT"
# #echo "$VCPKG_INSTALLATION_ROOT/installed/x64-windows"
# #ls "$VCPKG_INSTALLATION_ROOT/installed/x64-windows"
# #echo "$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib"
# #ls "$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib"
# #echo "$VCPKG_INSTALLATION_ROOT/installed/x64-windows/bin"
# #ls "$VCPKG_INSTALLATION_ROOT/installed/x64-windows/bin"
#
# # export PATH="$PATH:$DEP_DIR/bin:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/bin"
# export PATH="$DEP_DIR/lib:$DEP_DIR/bin:$PATH:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib"
export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib"
# export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$VCPKG_INSTALLATION_ROOT/installed/x64-windows/lib:$DEP_DIR/lib:$DEP_DIR/bin"
#
echo "All VCPkg installs:"
vcpkg list
#
########################################################################
########################################################################
# Dependency method #2: Build from source ourselves
#
#
# src/build-scripts/build_zlib.bash
# export ZLIB_ROOT=$PWD/ext/dist
# src/build-scripts/build_libpng.bash
# export PNG_ROOT=$PWD/ext/dist
# We're currently getting libtiff from vcpkg
#src/build-scripts/build_libtiff.bash
#export TIFF_ROOT=$PWD/ext/dist
# We're currently getting jpeg from vcpkg
# LIBJPEGTURBO_CONFIG_OPTS=-DWITH_SIMD=OFF
# # ^^ because we're too lazy to build nasm
# src/build-scripts/build_libjpeg-turbo.bash
# export JPEGTurbo_ROOT=$PWD/ext/dist
source src/build-scripts/build_pybind11.bash
#export pybind11_ROOT=$PWD/ext/dist
# curl --location https://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-4.2.1-win64-dev.zip -o ffmpeg-dev.zip
# unzip ffmpeg-dev.zip
# FFmpeg_ROOT=$PWD/ffmpeg-4.2.1-win64-dev
echo "CMAKE_PREFIX_PATH = $CMAKE_PREFIX_PATH"
OPENEXR_CXX_FLAGS=" /W1 /EHsc /DWIN32=1 "
#OPENEXR_BUILD_TYPE=$CMAKE_BUILD_TYPE
OPENEXR_INSTALL_DIR=$DEP_DIR
source src/build-scripts/build_openexr.bash
export PATH="$OPENEXR_INSTALL_DIR/bin:$OPENEXR_INSTALL_DIR/lib:$PATH"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PATH
# the above line is admittedly sketchy
cp $DEP_DIR/lib/*.lib $DEP_DIR/bin
cp $DEP_DIR/bin/*.dll $DEP_DIR/lib
echo "DEP_DIR $DEP_DIR :"
ls -R -l "$DEP_DIR"
# source src/build-scripts/build_openexr.bash
# export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH;$ILMBASE_ROOT;$OPENEXR_ROOT"
# source src/build-scripts/build_opencolorio.bash
# Save the env for use by other stages
src/build-scripts/save-env.bash
+44 -20
View File
@@ -1,39 +1,63 @@
#!/bin/bash
#!/usr/bin/env bash
# This script, which assumes it is runnign on a Mac OSX with Homebrew
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# This script, which assumes it is running on a Mac OSX with Homebrew
# installed, does a "brew install" in all packages reasonably needed by
# OIIO.
if [ `uname` != "Darwin" ] ; then
if [[ `uname` != "Darwin" ]] ; then
echo "Don't run this script unless you are on Mac OSX"
exit 1
fi
if [ `which brew` == "" ] ; then
if [[ `which brew` == "" ]] ; then
echo "You need to install Homebrew before running this script."
echo "See http://brew.sh"
exit 1
fi
brew update >/dev/null
#brew update >/dev/null
echo ""
echo "Before my brew installs:"
brew list --versions
brew install ccache cmake
brew install ilmbase openexr
brew install boost-python
brew install opencolorio
brew install freetype
brew install libraw libpng webp jpeg-turbo
brew install openjpeg20
brew install dcmtk
if [ "$LINKSTATIC" == "1" ] ; then
brew install little-cms2 tinyxml szip
brew install homebrew/dupes/bzip2
brew install yaml-cpp --with-static-lib
fi
#brew install homebrew/science/hdf5 --with-threadsafe
#brew install field3d webp ffmpeg openjpeg opencv
# All cases except for clang-format target, we need the dependencies.
brew install --display-times -q gcc ccache cmake ninja boost || true
brew link --overwrite gcc
brew install --display-times -q python@${PYTHON_VERSION} || true
brew unlink python@3.8 || true
brew unlink python@3.9 || true
brew unlink python@3.10 || true
brew link --overwrite --force python@${PYTHON_VERSION} || true
#brew upgrade --display-times -q cmake || true
#brew install --display-times -q libtiff
brew install --display-times -q imath openexr opencolorio
#brew install --display-times -q libpng giflib webp
brew install --display-times -q jpeg-turbo openjpeg
brew install --display-times -q freetype libraw dcmtk pybind11 numpy || true
brew install --display-times -q ffmpeg libheif ptex || true
brew install --display-times -q tbb || true
brew install --display-times -q openvdb || true
brew install --display-times -q opencv || true
brew install --display-times -q qt${QT_VERSION}
echo ""
echo "After brew installs:"
brew list --versions
# Needed on some systems
pip${PYTHON_VERSION} install numpy
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export PATH=/usr/local/opt/qt5/bin:$PATH
export PATH=/usr/local/opt/python/libexec/bin:$PATH
export PYTHONPATH=/usr/local/lib/python${PYTHON_VERSION}/site-packages:$PYTHONPATH
#export PATH=/usr/local/opt/llvm/bin:$PATH
# Save the env for use by other stages
src/build-scripts/save-env.bash
+17 -9
View File
@@ -1,14 +1,22 @@
#!/bin/bash
#!/usr/bin/env bash
if [ ! -e ../oiio-images ] ; then
git clone https://github.com/OpenImageIO/oiio-images.git ../oiio-images
if [[ ! -e ../oiio-images ]] ; then
git clone https://github.com/OpenImageIO/oiio-images.git -b RB-2.4 --depth 1 ../oiio-images
# NOTE: on release branches, this should include `-b RB-x.y`` so that
# updates to the master oiio-images don't break tests in release branches.
fi
if [ ! -e ../libtiffpic ] ; then
wget ftp://ftp.remotesensing.org/pub/libtiff/pics-3.8.0.tar.gz
tar xf pics-3.8.0.tar.gz -C ..
# if [[ ! -e ../libtiffpic ]] ; then
# curl -o pics-3.8.0.tar.gz https://download.osgeo.org/libtiff/pics-3.8.0.tar.gz
# tar xf pics-3.8.0.tar.gz -C ..
# fi
if [[ ! -e ../openexr-images ]] ; then
git clone https://github.com/openexr/openexr-images.git --depth 1 ../openexr-images
fi
if [ ! -e ../openexr-images ] ; then
git clone https://github.com/openexr/openexr-images.git ../openexr-images
fi
# if [[ ! -e ../bmpsuite ]] ; then
# mkdir ../bmpsuite
# curl -o bmpsuite.zip http://entropymine.com/jason/bmpsuite/bmpsuite.zip
# unzip bmpsuite.zip -d ../bmpsuite
# fi
+2 -2
View File
@@ -1,2 +1,2 @@
leak:Imf_2_2
leak:libIlmImf
leak:libtbb
leak:libjpeg
+7
View File
@@ -0,0 +1,7 @@
[oneAPI]
name=Intel® oneAPI repository
baseurl=https://yum.repos.intel.com/oneapi
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
# Save the env for use by other stages. Exclude things that we know aren't
# needed.
printenv \
| sort \
| grep -v ASWF_ \
| grep -v GITHUB_ \
| grep -v NVIDIA_ \
| grep -v RUNNER_ \
| grep -v _= \
| fgrep -v "\*" \
>> $GITHUB_ENV
echo "save-env: GITHUB_ENV=${GITHUB_ENV}"
cat $GITHUB_ENV
echo "---------"
Whitespace-only changes.
+11 -4
View File
@@ -1,4 +1,11 @@
add_oiio_plugin (cineoninput.cpp cineonoutput.cpp
libcineon/Cineon.cpp libcineon/OutStream.cpp libcineon/Codec.cpp libcineon/Reader.cpp
libcineon/Writer.cpp libcineon/CineonHeader.cpp libcineon/ElementReadStream.cpp
libcineon/InStream.cpp)
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
add_oiio_plugin (cineoninput.cpp
libcineon/Cineon.cpp libcineon/OutStream.cpp libcineon/Codec.cpp
libcineon/Reader.cpp libcineon/CineonHeader.cpp
libcineon/ElementReadStream.cpp libcineon/InStream.cpp)
# Note: OIIO doesn't support cineon output, so we don't compile
# libcineon/Writer.cpp
+217 -274
View File
@@ -1,238 +1,195 @@
/*
Copyright 2010 Larry Gritz and the other authors and contributors.
All Rights Reserved.
// Copyright Contributors to the OpenImageIO project.
// SPDX-License-Identifier: Apache-2.0
// https://github.com/OpenImageIO/oiio
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the software's owners nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
(This is the Modified BSD License)
*/
#include <cmath>
#include "libcineon/Cineon.h"
#include "OpenImageIO/dassert.h"
#include "OpenImageIO/typedesc.h"
#include "OpenImageIO/imageio.h"
#include "OpenImageIO/fmath.h"
#include "OpenImageIO/strutil.h"
#include <OpenImageIO/dassert.h>
#include <OpenImageIO/imageio.h>
#include <OpenImageIO/strutil.h>
#include <OpenImageIO/typedesc.h>
using namespace cineon;
OIIO_PLUGIN_NAMESPACE_BEGIN
class CineonInput : public ImageInput {
class CineonInput final : public ImageInput {
public:
CineonInput () : m_stream(NULL) { init(); }
virtual ~CineonInput () { close(); }
virtual const char * format_name (void) const { return "cineon"; }
virtual bool open (const std::string &name, ImageSpec &newspec);
virtual bool close ();
virtual bool read_native_scanline (int y, int z, void *data);
CineonInput() { init(); }
~CineonInput() override { close(); }
const char* format_name(void) const override { return "cineon"; }
bool open(const std::string& name, ImageSpec& newspec) override;
bool close() override;
bool read_native_scanline(int subimage, int miplevel, int y, int z,
void* data) override;
private:
InStream *m_stream;
InStream* m_stream = nullptr;
cineon::Reader m_cin;
std::vector<unsigned char> m_userBuf;
/// Reset everything to initial state
///
void init () {
void init()
{
if (m_stream) {
m_stream->Close ();
m_stream->Close();
delete m_stream;
m_stream = NULL;
m_stream = nullptr;
}
m_userBuf.clear ();
m_userBuf.clear();
}
/// Helper function - retrieve string for libcineon descriptor
///
char *get_descriptor_string (cineon::Descriptor c);
char* get_descriptor_string(cineon::Descriptor c);
};
// Obligatory material to make this a recognizeable imageio plugin:
// Obligatory material to make this a recognizable imageio plugin:
OIIO_PLUGIN_EXPORTS_BEGIN
OIIO_EXPORT ImageInput *cineon_input_imageio_create () { return new CineonInput; }
OIIO_EXPORT ImageInput*
cineon_input_imageio_create()
{
return new CineonInput;
}
OIIO_EXPORT int cineon_imageio_version = OIIO_PLUGIN_VERSION;
OIIO_EXPORT const char* cineon_imageio_library_version () { return NULL; }
OIIO_EXPORT const char*
cineon_imageio_library_version()
{
return nullptr;
}
OIIO_EXPORT const char * cineon_input_extensions[] = {
"cin", NULL
};
OIIO_EXPORT const char* cineon_input_extensions[] = { "cin", nullptr };
OIIO_PLUGIN_EXPORTS_END
bool
CineonInput::open (const std::string &name, ImageSpec &newspec)
CineonInput::open(const std::string& name, ImageSpec& newspec)
{
// open the image
m_stream = new InStream();
if (! m_stream->Open(name.c_str())) {
error ("Could not open file \"%s\"", name.c_str());
if (!m_stream->Open(name.c_str())) {
errorfmt("Could not open file \"{}\"", name);
return false;
}
m_cin.SetInStream(m_stream);
if (! m_cin.ReadHeader()) {
error ("Could not read header");
if (!m_cin.ReadHeader()) {
errorfmt("Could not read header");
return false;
}
// create imagespec
TypeDesc typedesc;
int maxbits = 0;
for (int i = 0; i < m_cin.header.NumberOfElements (); i++) {
if (maxbits < m_cin.header.BitDepth (i))
maxbits = m_cin.header.BitDepth (i);
for (int i = 0; i < m_cin.header.NumberOfElements(); i++) {
if (maxbits < m_cin.header.BitDepth(i))
maxbits = m_cin.header.BitDepth(i);
}
switch ((maxbits + 7) / 8) {
case 1:
typedesc = TypeDesc::UINT8;
case 1: typedesc = TypeDesc::UINT8; break;
case 2: typedesc = TypeDesc::UINT16; break;
case 3:
case 4: typedesc = TypeDesc::UINT32; break;
default: errorfmt("Unsupported bit depth {}", maxbits); return false;
}
m_spec = ImageSpec(m_cin.header.Width(), m_cin.header.Height(),
m_cin.header.NumberOfElements(), typedesc);
// fill channel names
m_spec.channelnames.clear();
int gscount = 0, rcount = 0, gcount = 0, bcount = 0;
for (int i = 0; i < m_cin.header.NumberOfElements(); i++) {
switch (m_cin.header.ImageDescriptor(i)) {
case cineon::kGrayscale:
if (++gscount > 1) {
std::string ch = Strutil::fmt::format("I{}", gscount);
m_spec.channelnames.push_back(ch);
} else
m_spec.channelnames.emplace_back("I");
break;
case 2:
typedesc = TypeDesc::UINT16;
case cineon::kPrintingDensityRed:
case cineon::kRec709Red:
if (++gscount > 1) {
std::string ch = Strutil::fmt::format("R{}", rcount);
m_spec.channelnames.push_back(ch);
} else
m_spec.channelnames.emplace_back("R");
break;
case 3:
case 4:
typedesc = TypeDesc::UINT32;
case cineon::kPrintingDensityGreen:
case cineon::kRec709Green:
if (++gcount > 1) {
std::string ch = Strutil::fmt::format("G{}", gcount);
m_spec.channelnames.push_back(ch);
} else
m_spec.channelnames.emplace_back("G");
break;
case cineon::kPrintingDensityBlue:
case cineon::kRec709Blue:
if (++bcount > 1) {
std::string ch = Strutil::fmt::format("B{}", bcount);
m_spec.channelnames.push_back(ch);
} else
m_spec.channelnames.emplace_back("B");
break;
default:
error ("Unsupported bit depth %d", maxbits);
return false;
}
m_spec = ImageSpec (m_cin.header.Width(), m_cin.header.Height(),
m_cin.header.NumberOfElements (), typedesc);
// fill channel names
m_spec.channelnames.clear ();
int gscount = 0, rcount = 0, gcount = 0, bcount = 0;
char buf[3];
for (int i = 0; i < m_cin.header.NumberOfElements (); i++) {
switch (m_cin.header.ImageDescriptor (i)) {
case cineon::kGrayscale:
if (++gscount > 1) {
std::string ch = Strutil::format ("I%d", gscount);
m_spec.channelnames.push_back (ch);
} else
m_spec.channelnames.push_back ("I");
break;
case cineon::kPrintingDensityRed:
case cineon::kRec709Red:
if (++gscount > 1) {
std::string ch = Strutil::format ("R%d", rcount);
m_spec.channelnames.push_back (ch);
} else
m_spec.channelnames.push_back ("R");
break;
case cineon::kPrintingDensityGreen:
case cineon::kRec709Green:
if (++gcount > 1) {
std::string ch = Strutil::format ("G%d", gcount);
m_spec.channelnames.push_back (ch);
} else
m_spec.channelnames.push_back ("G");
break;
case cineon::kPrintingDensityBlue:
case cineon::kRec709Blue:
if (++bcount > 1) {
std::string ch = Strutil::format ("B%d", bcount);
m_spec.channelnames.push_back (ch);
} else
m_spec.channelnames.push_back ("B");
break;
default:
std::string ch = Strutil::format ("channel%d", (int)m_spec.channelnames.size());
m_spec.channelnames.push_back (ch);
break;
std::string ch = Strutil::fmt::format("channel{}",
m_spec.channelnames.size());
m_spec.channelnames.push_back(ch);
break;
}
}
// bits per sample
m_spec.attribute ("oiio:BitsPerSample", maxbits);
m_spec.attribute("oiio:BitsPerSample", maxbits);
// image orientation - see appendix B.2 of the OIIO documentation
int orientation;
switch (m_cin.header.ImageOrientation ()) {
case cineon::kLeftToRightTopToBottom:
orientation = 1;
break;
case cineon::kRightToLeftTopToBottom:
orientation = 2;
break;
case cineon::kLeftToRightBottomToTop:
orientation = 4;
break;
case cineon::kRightToLeftBottomToTop:
orientation = 3;
break;
case cineon::kTopToBottomLeftToRight:
orientation = 5;
break;
case cineon::kTopToBottomRightToLeft:
orientation = 6;
break;
case cineon::kBottomToTopLeftToRight:
orientation = 8;
break;
case cineon::kBottomToTopRightToLeft:
orientation = 7;
break;
default:
orientation = 0;
break;
switch (m_cin.header.ImageOrientation()) {
case cineon::kLeftToRightTopToBottom: orientation = 1; break;
case cineon::kRightToLeftTopToBottom: orientation = 2; break;
case cineon::kLeftToRightBottomToTop: orientation = 4; break;
case cineon::kRightToLeftBottomToTop: orientation = 3; break;
case cineon::kTopToBottomLeftToRight: orientation = 5; break;
case cineon::kTopToBottomRightToLeft: orientation = 6; break;
case cineon::kBottomToTopLeftToRight: orientation = 8; break;
case cineon::kBottomToTopRightToLeft: orientation = 7; break;
default: orientation = 0; break;
}
m_spec.attribute ("Orientation", orientation);
m_spec.attribute("Orientation", orientation);
#if 1
// This is not very smart, but it seems that as a practical matter,
// all Cineon files are log. So ignore the gamma field and just set
// the color space to KodakLog.
m_spec.attribute ("oiio:ColorSpace", "KodakLog");
m_spec.attribute("oiio:ColorSpace", "KodakLog");
#else
// image linearity
// FIXME: making this more robust would require the per-channel transfer
// function functionality which isn't yet in OIIO
switch (m_cin.header.ImageDescriptor (0)) {
case cineon::kRec709Red:
case cineon::kRec709Green:
case cineon::kRec709Blue:
m_spec.attribute ("oiio:ColorSpace", "Rec709");
default:
// either grayscale or printing density
if (!isinf (m_cin.header.Gamma ()) && m_cin.header.Gamma () != 0.0f)
// actual gamma value is read later on
m_spec.attribute ("oiio:ColorSpace", "GammaCorrected");
break;
switch (m_cin.header.ImageDescriptor(0)) {
case cineon::kRec709Red:
case cineon::kRec709Green:
case cineon::kRec709Blue: m_spec.attribute("oiio:ColorSpace", "Rec709");
default:
// either grayscale or printing density
if (!std::isinf(m_cin.header.Gamma()) && m_cin.header.Gamma() != 0.0f)
// actual gamma value is read later on
m_spec.attribute("oiio:ColorSpace",
Strutil::fmt::format("Gamma{:.2g}", g));
break;
}
// gamma exponent
if (!isinf (m_cin.header.Gamma ()) && m_cin.header.Gamma () != 0.0f)
m_spec.attribute ("oiio:Gamma", (float) m_cin.header.Gamma ());
if (!std::isinf(m_cin.header.Gamma()) && m_cin.header.Gamma() != 0.0f)
m_spec.attribute("oiio:Gamma", (float)m_cin.header.Gamma());
#endif
// general metadata
@@ -242,68 +199,65 @@ CineonInput::open (const std::string &name, ImageSpec &newspec)
if (m_cin.header.creationDate[0] && m_cin.header.creationTime[0]) {
// libcineon's date/time format is pretty close to OIIO's (libcineon
// uses %Y:%m:%d:%H:%M:%S%Z)
m_spec.attribute ("DateTime", Strutil::format ("%s %s",
m_cin.header.creationDate, m_cin.header.creationTime));
m_spec.attribute("DateTime",
Strutil::fmt::format("{} {}",
m_cin.header.creationDate,
m_cin.header.creationTime));
// FIXME: do something about the time zone
}
// cineon-specific metadata
char *strings[8];
char* strings[8];
int ints[8];
float floats[8];
// image descriptor
for (int i = 0; i < m_cin.header.NumberOfElements (); i++)
strings[i] = get_descriptor_string (m_cin.header.ImageDescriptor (i));
m_spec.attribute ("cineon:ImageDescriptor", TypeDesc (TypeDesc::STRING,
m_cin.header.NumberOfElements ()), &strings);
for (int i = 0; i < m_cin.header.NumberOfElements(); i++)
strings[i] = get_descriptor_string(m_cin.header.ImageDescriptor(i));
m_spec.attribute("cineon:ImageDescriptor",
TypeDesc(TypeDesc::STRING, m_cin.header.NumberOfElements()),
&strings);
// save some typing by using macros
// "internal" macros
// per-file attribs
#define CINEON_SET_ATTRIB_S(x, n, s) m_spec.attribute (s, \
m_cin.header.x (n))
#define CINEON_SET_ATTRIB(x, n) CINEON_SET_ATTRIB_S(x, n, \
"cineon:" #x)
#define CINEON_SET_ATTRIB_BYTE(x) if (m_cin.header.x () != 0xFF) \
CINEON_SET_ATTRIB(x, )
#define CINEON_SET_ATTRIB_INT(x) if (static_cast<unsigned int> \
(m_cin.header.x ()) \
!= 0xFFFFFFFF) \
CINEON_SET_ATTRIB(x, )
#define CINEON_SET_ATTRIB_FLOAT(x) if (! isinf(m_cin.header.x ())) \
CINEON_SET_ATTRIB(x, )
#define CINEON_SET_ATTRIB_COORDS(x) m_cin.header.x (floats); \
if (!isinf (floats[0]) \
&& !isinf (floats[1]) \
&& !(floats[0] == 0. && floats[1] == 0.)) \
m_spec.attribute ("cineon:" #x, \
TypeDesc (TypeDesc::FLOAT, 2), \
&floats[0])
#define CINEON_SET_ATTRIB_STR(X, x) if (m_cin.header.x[0] \
&& m_cin.header.x[0] != char(-1)) \
m_spec.attribute ("cineon:" #X, \
m_cin.header.x)
#define CINEON_SET_ATTRIB_S(x, n, s) m_spec.attribute(s, m_cin.header.x(n))
#define CINEON_SET_ATTRIB(x, n) CINEON_SET_ATTRIB_S(x, n, "cineon:" #x)
#define CINEON_SET_ATTRIB_BYTE(x) \
if (m_cin.header.x() != 0xFF) \
CINEON_SET_ATTRIB(x, )
#define CINEON_SET_ATTRIB_INT(x) \
if (static_cast<unsigned int>(m_cin.header.x()) != 0xFFFFFFFF) \
CINEON_SET_ATTRIB(x, )
#define CINEON_SET_ATTRIB_FLOAT(x) \
if (!std::isinf(m_cin.header.x())) \
CINEON_SET_ATTRIB(x, )
#define CINEON_SET_ATTRIB_COORDS(x) \
m_cin.header.x(floats); \
if (!std::isinf(floats[0]) && !std::isinf(floats[1]) \
&& !(floats[0] == 0. && floats[1] == 0.)) \
m_spec.attribute("cineon:" #x, TypeDesc(TypeDesc::FLOAT, 2), &floats[0])
#define CINEON_SET_ATTRIB_STR(X, x) \
if (m_cin.header.x[0] && m_cin.header.x[0] != char(-1)) \
m_spec.attribute("cineon:" #X, m_cin.header.x)
// per-element attribs
#define CINEON_SET_ATTRIB_N(x, a, t, c) for (int i = 0; i < m_cin.header. \
NumberOfElements (); i++) { \
c(x) \
a[i] = m_cin.header.x (i); \
} \
m_spec.attribute ("cineon:" #x, \
TypeDesc (TypeDesc::t, \
m_cin.header.NumberOfElements()),\
&a)
#define CINEON_CHECK_ATTRIB_FLOAT(x) if (!isinf (m_cin.header.x (i)))
#define CINEON_SET_ATTRIB_FLOAT_N(x) CINEON_SET_ATTRIB_N(x, floats, \
FLOAT, CINEON_CHECK_ATTRIB_FLOAT)
#define CINEON_CHECK_ATTRIB_INT(x) if (m_cin.header.x (i) != 0xFFFFFFFF)
#define CINEON_SET_ATTRIB_INT_N(x) CINEON_SET_ATTRIB_N(x, ints, \
UINT32, CINEON_CHECK_ATTRIB_INT)
#define CINEON_CHECK_ATTRIB_BYTE(x) if (m_cin.header.x (i) != 0xFF)
#define CINEON_SET_ATTRIB_BYTE_N(x) CINEON_SET_ATTRIB_N(x, ints, \
UINT32, CINEON_CHECK_ATTRIB_BYTE)
#define CINEON_SET_ATTRIB_N(x, a, t, c) \
for (int i = 0; i < m_cin.header.NumberOfElements(); i++) { \
c(x) a[i] = m_cin.header.x(i); \
} \
m_spec.attribute("cineon:" #x, \
TypeDesc(TypeDesc::t, m_cin.header.NumberOfElements()), \
&a)
#define CINEON_CHECK_ATTRIB_FLOAT(x) if (!std::isinf(m_cin.header.x(i)))
#define CINEON_SET_ATTRIB_FLOAT_N(x) \
CINEON_SET_ATTRIB_N(x, floats, FLOAT, CINEON_CHECK_ATTRIB_FLOAT)
#define CINEON_CHECK_ATTRIB_INT(x) if (m_cin.header.x(i) != 0xFFFFFFFF)
#define CINEON_SET_ATTRIB_INT_N(x) \
CINEON_SET_ATTRIB_N(x, ints, UINT32, CINEON_CHECK_ATTRIB_INT)
#define CINEON_CHECK_ATTRIB_BYTE(x) if (m_cin.header.x(i) != 0xFF)
#define CINEON_SET_ATTRIB_BYTE_N(x) \
CINEON_SET_ATTRIB_N(x, ints, UINT32, CINEON_CHECK_ATTRIB_BYTE)
CINEON_SET_ATTRIB_STR(Version, version);
@@ -331,13 +285,13 @@ CineonInput::open (const std::string &name, ImageSpec &newspec)
CINEON_SET_ATTRIB_STR(InputDeviceSerialNumber, inputDeviceSerialNumber);
CINEON_SET_ATTRIB_FLOAT(XDevicePitch);
CINEON_SET_ATTRIB_FLOAT(YDevicePitch);
CINEON_SET_ATTRIB_INT(FramePosition);
CINEON_SET_ATTRIB_FLOAT(FrameRate);
CINEON_SET_ATTRIB_STR(Format, format);
CINEON_SET_ATTRIB_STR(FrameId, frameId);
CINEON_SET_ATTRIB_STR(SlateInfo, slateInfo);
#undef CINEON_SET_ATTRIB_BYTE_N
#undef CINEON_CHECK_ATTRIB_BYTE
#undef CINEON_SET_ATTRIB_INT_N
@@ -353,66 +307,60 @@ CineonInput::open (const std::string &name, ImageSpec &newspec)
#undef CINEON_SET_ATTRIB_S
std::string tmpstr;
switch (m_cin.header.ImagePacking () & ~cineon::kPackAsManyAsPossible) {
case cineon::kPacked:
tmpstr = "Packed";
break;
case cineon::kByteLeft:
tmpstr = "8-bit boundary, left justified";
break;
case cineon::kByteRight:
tmpstr = "8-bit boundary, right justified";
break;
case cineon::kWordLeft:
tmpstr = "16-bit boundary, left justified";
break;
case cineon::kWordRight:
tmpstr = "16-bit boundary, right justified";
break;
case cineon::kLongWordLeft:
tmpstr = "32-bit boundary, left justified";
break;
case cineon::kLongWordRight:
tmpstr = "32-bit boundary, right justified";
break;
switch (m_cin.header.ImagePacking() & ~cineon::kPackAsManyAsPossible) {
case cineon::kPacked: tmpstr = "Packed"; break;
case cineon::kByteLeft: tmpstr = "8-bit boundary, left justified"; break;
case cineon::kByteRight: tmpstr = "8-bit boundary, right justified"; break;
case cineon::kWordLeft: tmpstr = "16-bit boundary, left justified"; break;
case cineon::kWordRight: tmpstr = "16-bit boundary, right justified"; break;
case cineon::kLongWordLeft:
tmpstr = "32-bit boundary, left justified";
break;
case cineon::kLongWordRight:
tmpstr = "32-bit boundary, right justified";
break;
}
if (m_cin.header.ImagePacking () & cineon::kPackAsManyAsPossible)
if (m_cin.header.ImagePacking() & cineon::kPackAsManyAsPossible)
tmpstr += ", as many fields as possible per cell";
else
tmpstr += ", at most one pixel per cell";
if (!tmpstr.empty ())
m_spec.attribute ("cineon:Packing", tmpstr);
if (!tmpstr.empty())
m_spec.attribute("cineon:Packing", tmpstr);
if (m_cin.header.sourceDate[0] && m_cin.header.sourceTime[0]) {
// libcineon's date/time format is pretty close to OIIO's (libcineon
// uses %Y:%m:%d:%H:%M:%S%Z)
m_spec.attribute ("DateTime", Strutil::format ("%s %s",
m_cin.header.sourceDate, m_cin.header.sourceTime));
m_spec.attribute("DateTime",
Strutil::fmt::format("{} {}", m_cin.header.sourceDate,
m_cin.header.sourceTime));
// FIXME: do something about the time zone
}
m_cin.header.FilmEdgeCode(buf);
if (buf[0])
m_spec.attribute ("cineon:FilmEdgeCode", buf);
{
char filmedge[17];
m_cin.header.FilmEdgeCode(filmedge, sizeof(filmedge));
if (filmedge[0])
m_spec.attribute("cineon:FilmEdgeCode", filmedge);
}
// read in user data
if (m_cin.header.UserSize () != 0
&& m_cin.header.UserSize () != 0xFFFFFFFF) {
m_userBuf.resize (m_cin.header.UserSize ());
m_cin.ReadUserData (&m_userBuf[0]);
if (m_cin.header.UserSize() != 0 && m_cin.header.UserSize() != 0xFFFFFFFF) {
m_userBuf.resize(m_cin.header.UserSize());
m_cin.ReadUserData(&m_userBuf[0]);
}
if (!m_userBuf.empty ())
m_spec.attribute ("cineon:UserData", TypeDesc (TypeDesc::UCHAR,
m_cin.header.UserSize ()), &m_userBuf[0]);
if (!m_userBuf.empty())
m_spec.attribute("cineon:UserData",
TypeDesc(TypeDesc::UCHAR, m_cin.header.UserSize()),
&m_userBuf[0]);
newspec = spec ();
newspec = spec();
return true;
}
bool
CineonInput::close ()
CineonInput::close()
{
init(); // Reset to initial state
return true;
@@ -421,13 +369,17 @@ CineonInput::close ()
bool
CineonInput::read_native_scanline (int y, int z, void *data)
CineonInput::read_native_scanline(int subimage, int miplevel, int y, int /*z*/,
void* data)
{
cineon::Block block(0, y, m_cin.header.Width () - 1, y);
lock_guard lock(*this);
if (!seek_subimage(subimage, miplevel))
return false;
cineon::Block block(0, y, m_cin.header.Width() - 1, y);
// FIXME: un-hardcode the channel from 0
if (!m_cin.ReadBlock (data, m_cin.header.ComponentDataSize (0),
block))
if (!m_cin.ReadBlock(data, m_cin.header.ComponentDataSize(0), block))
return false;
return true;
@@ -435,29 +387,20 @@ CineonInput::read_native_scanline (int y, int z, void *data)
char *
CineonInput::get_descriptor_string (cineon::Descriptor c)
char*
CineonInput::get_descriptor_string(cineon::Descriptor c)
{
switch (c) {
case cineon::kGrayscale:
return (char *)"Grayscale";
case cineon::kPrintingDensityRed:
return (char *)"Red, printing density";
case cineon::kRec709Red:
return (char *)"Red, Rec709";
case cineon::kPrintingDensityGreen:
return (char *)"Green, printing density";
case cineon::kRec709Green:
return (char *)"Green, Rec709";
case cineon::kPrintingDensityBlue:
return (char *)"Blue, printing density";
case cineon::kRec709Blue:
return (char *)"Blue, Rec709";
//case cineon::kUndefinedDescriptor:
default:
return (char *)"Undefined";
case cineon::kGrayscale: return (char*)"Grayscale";
case cineon::kPrintingDensityRed: return (char*)"Red, printing density";
case cineon::kRec709Red: return (char*)"Red, Rec709";
case cineon::kPrintingDensityGreen: return (char*)"Green, printing density";
case cineon::kRec709Green: return (char*)"Green, Rec709";
case cineon::kPrintingDensityBlue: return (char*)"Blue, printing density";
case cineon::kRec709Blue: return (char*)"Blue, Rec709";
//case cineon::kUndefinedDescriptor:
default: return (char*)"Undefined";
}
}
OIIO_PLUGIN_NAMESPACE_END
-124
View File
@@ -1,124 +0,0 @@
/*
Copyright 2010 Larry Gritz and the other authors and contributors.
All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the software's owners nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
(This is the Modified BSD License)
*/
#include "libcineon/Cineon.h"
#include "OpenImageIO/typedesc.h"
#include "OpenImageIO/imageio.h"
#include "OpenImageIO/fmath.h"
using namespace cineon;
OIIO_PLUGIN_NAMESPACE_BEGIN
class CineonOutput : public ImageOutput {
public:
CineonOutput ();
virtual ~CineonOutput ();
virtual const char * format_name (void) const { return "cineon"; }
virtual bool open (const std::string &name, const ImageSpec &spec,
ImageOutput::OpenMode mode);
virtual bool close ();
virtual bool write_scanline (int y, int z, TypeDesc format,
const void *data, stride_t xstride);
private:
// Initialize private members to pre-opened state
void init (void) {
}
};
// Obligatory material to make this a recognizeable imageio plugin:
OIIO_PLUGIN_EXPORTS_BEGIN
OIIO_EXPORT ImageOutput *cineon_output_imageio_create () { return new CineonOutput; }
// OIIO_EXPORT int cineon_imageio_version = OIIO_PLUGIN_VERSION; // it's in cineoninput.cpp
OIIO_EXPORT const char * cineon_output_extensions[] = {
"cin", NULL
};
OIIO_PLUGIN_EXPORTS_END
CineonOutput::CineonOutput ()
{
init ();
}
CineonOutput::~CineonOutput ()
{
// Close, if not already done.
close ();
}
bool
CineonOutput::open (const std::string &name, const ImageSpec &userspec,
ImageOutput::OpenMode mode)
{
error ("Cineon writer is not implemented yet, please poke Leszek in the "
"mailing list");
return false;
}
bool
CineonOutput::close ()
{
init(); // Reset to initial state
return true; // How can we fail?
// Epicly. -- IneQuation
}
bool
CineonOutput::write_scanline (int y, int z, TypeDesc format,
const void *data, stride_t xstride)
{
error ("Cineon writer is not implemented yet, please poke Leszek in the "
"mailing list");
return false;
}
OIIO_PLUGIN_NAMESPACE_END
+52 -57
View File
@@ -33,7 +33,6 @@
*/
#include <cassert>
#include <cstdio>
#include <cstdlib>
@@ -41,7 +40,8 @@
#include <ctime>
#include <limits>
#include "OpenImageIO/strutil.h"
#include <OpenImageIO/strutil.h>
#include <OpenImageIO/sysutil.h>
#include "CineonHeader.h"
#include "EndianSwap.h"
@@ -82,7 +82,7 @@ cineon::GenericHeader::GenericHeader()
void cineon::GenericHeader::Reset()
{
// File Information
this->magicNumber = MAGIC_COOKIE;
this->magicNumber = CINEON_MAGIC_COOKIE;
this->imageOffset = ~0;
EmptyString(this->version);
OIIO::Strutil::safe_strcpy(this->version, SPEC_VERSION, sizeof(this->version));
@@ -160,10 +160,10 @@ void cineon::IndustryHeader::Reset()
cineon::ImageElement::ImageElement()
{
this->lowData = 0xffffffff;
this->lowQuantity = 0xffffffff;
this->highData = 0xffffffff;
this->highQuantity = 0xffffffff;
this->lowData = R32(0xffffffff);
this->lowQuantity = R32(0xffffffff);
this->highData = R32(0xffffffff);
this->highQuantity = R32(0xffffffff);
this->bitDepth = 0xff;
}
@@ -212,6 +212,8 @@ bool cineon::Header::Check()
#ifdef OIIO_DOES_NOT_NEED_THIS
bool cineon::Header::Write(OutStream *io)
{
// write the header to the file
@@ -254,7 +256,7 @@ bool cineon::Header::WriteOffsetData(OutStream *io)
//const long IMAGE_STRUCTURE = 72; // sizeof the image data structure
/*int i;
for (i = 0; i < MAX_ELEMENTS; i++)
for (i = 0; i < CINEON_MAX_ELEMENTS; i++)
{
// only write if there is a defined image description
if (this->chan[i].descriptor == kUndefinedDescriptor)
@@ -272,11 +274,12 @@ bool cineon::Header::WriteOffsetData(OutStream *io)
return true;
}
#endif /* OIIO_DOES_NOT_NEED_THIS */
bool cineon::Header::ValidMagicCookie(const U32 magic)
{
U32 mc = MAGIC_COOKIE;
U32 mc = CINEON_MAGIC_COOKIE;
if (magic == mc)
return true;
@@ -289,7 +292,7 @@ bool cineon::Header::ValidMagicCookie(const U32 magic)
bool cineon::Header::DetermineByteSwap(const U32 magic) const
{
U32 mc = MAGIC_COOKIE;
U32 mc = CINEON_MAGIC_COOKIE;
bool byteSwap = false;
@@ -317,7 +320,7 @@ bool cineon::Header::Validate()
SwapBytes(this->fileSize);
// Image information
for (int i = 0; i < MAX_ELEMENTS; i++)
for (int i = 0; i < CINEON_MAX_ELEMENTS; i++)
{
SwapBytes(this->chan[i].pixelsPerLine);
SwapBytes(this->chan[i].linesPerElement);
@@ -372,7 +375,7 @@ int cineon::GenericHeader::ImageElementCount() const
{
int i = 0;
while (i < MAX_ELEMENTS )
while (i < CINEON_MAX_ELEMENTS )
{
if (this->ImageDescriptor(i) == kUndefinedDescriptor)
break;
@@ -383,6 +386,7 @@ int cineon::GenericHeader::ImageElementCount() const
}
#ifdef OIIO_DOES_NOT_NEED_THIS
void cineon::GenericHeader::CalculateNumberOfElements()
{
int i = this->ImageElementCount();
@@ -398,7 +402,7 @@ void cineon::Header::CalculateOffsets()
{
int i;
for (i = 0; i < MAX_ELEMENTS; i++)
for (i = 0; i < CINEON_MAX_ELEMENTS; i++)
{
// only write if there is a defined image description
if (this->chan[i].designator[1] == kUndefinedDescriptor)
@@ -407,11 +411,12 @@ void cineon::Header::CalculateOffsets()
}
}
#endif /* OIIO_DOES_NOT_NEED_THIS */
cineon::DataSize cineon::GenericHeader::ComponentDataSize(const int element) const
{
if (element < 0 || element >= MAX_ELEMENTS)
if (element < 0 || element >= CINEON_MAX_ELEMENTS)
return kByte;
cineon::DataSize ret;
@@ -444,7 +449,7 @@ cineon::DataSize cineon::GenericHeader::ComponentDataSize(const int element) con
int cineon::GenericHeader::ComponentByteCount(const int element) const
{
if (element < 0 || element >= MAX_ELEMENTS)
if (element < 0 || element >= CINEON_MAX_ELEMENTS)
return kByte;
int ret;
@@ -500,76 +505,66 @@ int cineon::GenericHeader::DataSizeByteCount(const DataSize ds)
}
void cineon::IndustryHeader::FilmEdgeCode(char *edge) const
void cineon::IndustryHeader::FilmEdgeCode(char *edge, size_t size) const
{
if (this->filmManufacturingIdCode == 0xff
&& this->filmType == 0xff
&& this->perfsOffset == 0xff
&& this->prefix == 0xffffffff
&& this->count == 0xffffffff)
*edge = 0;
else
sprintf(edge, "%02u%02u%02u%06u%04u",
(unsigned int)this->filmManufacturingIdCode,
(unsigned int)this->filmType,
(unsigned int)this->perfsOffset,
this->prefix,
this->count);
if (this->filmManufacturingIdCode == 0xff && this->filmType == 0xff
&& this->perfsOffset == 0xff && this->prefix == 0xffffffff
&& this->count == 0xffffffff)
*edge = 0;
else {
std::string e = OIIO::Strutil::sprintf(
"%02u%02u%02u%06u%04u",
(unsigned int)this->filmManufacturingIdCode,
(unsigned int)this->filmType,
(unsigned int)this->perfsOffset, this->prefix, this->count);
OIIO::Strutil::safe_strcpy(edge, e, size);
}
}
#ifdef OIIO_DOES_NOT_NEED_THIS
void cineon::IndustryHeader::SetFilmEdgeCode(const char *edge)
{
char buf[7];
strncpy(buf, edge, 2);
this->filmManufacturingIdCode = atoi(buf);
strncpy(buf, edge + 2, 2);
this->filmType = atoi(buf);
strncpy(buf, edge + 4, 2);
this->perfsOffset = atoi(buf);
strncpy(buf, edge + 6, 6);
this->prefix = atoi(buf);
strncpy(buf, edge + 12, 4);
this->count = atoi(buf);
this->filmManufacturingIdCode = OIIO::Strutil::stoi(OIIO::string_view(edge, 2));
this->filmType = OIIO::Strutil::stoi(OIIO::string_view(edge + 2, 2));
this->perfsOffset = OIIO::Strutil::stoi(OIIO::string_view(edge + 4, 2));
this->prefix = OIIO::Strutil::stoi(OIIO::string_view(edge + 6, 6));
this->count = OIIO::Strutil::stoi(OIIO::string_view(edge + 12, 4));
}
#endif /* OIIO_DOES_NOT_NEED_THIS */
void cineon::GenericHeader::SetCreationTimeDate(const long sec)
{
struct tm *tm_time;
char str[32];
#ifdef WIN32
#ifdef _WIN32
_tzset();
#endif
const time_t t = time_t(sec);
tm_time = ::localtime(&t);
::strftime(str, 32, "%Y:%m:%d:%H:%M:%S%Z", tm_time);
::strncpy(this->creationDate, str, 10);
::strncpy(this->creationTime, str + 11, 12);
struct tm localtm;
OIIO::Sysutil::get_local_time(&t, &localtm);
::strftime(str, 32, "%Y:%m:%d:%H:%M:%S%Z", &localtm);
OIIO::Strutil::safe_strcpy(this->creationDate, str, 11);
OIIO::Strutil::safe_strcpy(this->creationTime, str + 11, 12);
}
void cineon::GenericHeader::SetSourceTimeDate(const long sec)
{
struct tm *tm_time;
char str[32];
#ifdef WIN32
#ifdef _WIN32
_tzset();
#endif
const time_t t = time_t(sec);
tm_time = ::localtime(&t);
::strftime(str, 32, "%Y:%m:%d:%H:%M:%S%Z", tm_time);
::strncpy(this->sourceDate, str, 10);
::strncpy(this->sourceTime, str + 11, 12);
struct tm localtm;
OIIO::Sysutil::get_local_time(&t, &localtm);
::strftime(str, 32, "%Y:%m:%d:%H:%M:%S%Z", &localtm);
OIIO::Strutil::safe_strcpy(this->sourceDate, str, 11);
OIIO::Strutil::safe_strcpy(this->sourceTime, str + 11, 12);
}
+98 -115
View File
@@ -43,6 +43,7 @@
#include <cstring>
#include <limits>
#include <OpenImageIO/strutil.h>
#if defined(_MSC_VER) && _MSC_VER < 1600
typedef __int32 int32_t;
@@ -50,7 +51,7 @@
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
# include <stdint.h>
# include <cstdint>
#endif
#include "CineonStream.h"
@@ -63,24 +64,17 @@
*/
#define SPEC_VERSION "V4.5"
/*!
* \def MAX_ELEMENTS
/*!
* \def CINEON_MAX_ELEMENTS
* \brief Maximum number of image elements
*/
#define MAX_ELEMENTS 8
#define CINEON_MAX_ELEMENTS 8
/*!
* \def MAX_COMPONENTS
* \brief Maximum number of components per image element
*/
#define MAX_COMPONENTS 8
/*!
* \def MAGIC_COOKIE
/*!
* \def CINEON_MAGIC_COOKIE
* \brief HEX value of 0x802A5FD7
*/
#define MAGIC_COOKIE 0x802A5FD7
#define CINEON_MAGIC_COOKIE 0x802A5FD7
@@ -274,8 +268,8 @@ namespace cineon
U8 imageOrientation; //!< Image orientation \see Orientation
U8 numberOfElements; //!< Number of elements (1-8)
U8 unused1[2]; //!< Unused (word alignment)
ImageElement chan[MAX_ELEMENTS]; //!< Image element data structures
R32 whitePoint[2]; //!< White point (x, y pair)
ImageElement chan[CINEON_MAX_ELEMENTS]; //!< Image element data structures
R32 whitePoint[2]; //!< White point (x, y pair)
R32 redPrimary[2]; //!< Red primary chromaticity (x, y pair)
R32 greenPrimary[2]; //!< Green primary chromaticity (x, y pair)
R32 bluePrimary[2]; //!< Blue primary chromaticity (x, y pair)
@@ -855,7 +849,7 @@ namespace cineon
inline void SetXDevicePitch(const R32 size);
/*!
* \brief Get the veritcal pitch of the device
* \brief Get the vertical pitch of the device
* \return pitch in samples/mm
*/
inline R32 YDevicePitch() const;
@@ -961,7 +955,7 @@ namespace cineon
* \brief Get the film edge code information that is machine readable
* \param edge buffer to write film edge code information (16+1 chars)
*/
void FilmEdgeCode(char *edge) const;
void FilmEdgeCode(char *edge, size_t size) const;
/*!
* \brief Set the film edge code information that is machine readable
@@ -1055,6 +1049,7 @@ namespace cineon
*/
bool Read(InStream *);
#ifdef OIIO_DOES_NOT_NEED_THIS
/*!
* \brief Set the Output Stream object to write header to
*/
@@ -1062,6 +1057,7 @@ namespace cineon
// write the offset within the header
bool WriteOffsetData(OutStream *);
#endif
/*!
* \brief Validate the header
@@ -1084,7 +1080,7 @@ namespace cineon
* \brief Returns the size of the header
* \return 2048 as defined by the standard
*/
const U32 Size() const;
U32 Size() const;
/*!
* \brief Calculate all of the offset members in the header
@@ -1127,7 +1123,7 @@ namespace cineon
return this->DetermineByteSwap(this->magicNumber);
}
inline const U32 Header::Size() const
inline U32 Header::Size() const
{
return 2048;
}
@@ -1151,13 +1147,12 @@ namespace cineon
inline void GenericHeader::Version(char *v) const
{
::strncpy(v, this->version, 8);
v[8] = '\0';
OIIO::Strutil::safe_strcpy(v, this->version, 8);
}
inline void GenericHeader::SetVersion(const char * v)
{
::strncpy(this->version, v, 8);
OIIO::Strutil::safe_strcpy(this->version, v, 8);
}
inline U32 GenericHeader::FileSize() const
@@ -1192,35 +1187,32 @@ namespace cineon
inline void GenericHeader::FileName(char *fn) const
{
::strncpy(fn, this->fileName, 100);
fn[100] = '\0';
OIIO::Strutil::safe_strcpy(fn, this->fileName, 100);
}
inline void GenericHeader::SetFileName(const char *fn)
{
::strncpy(this->fileName, fn, 100);
OIIO::Strutil::safe_strcpy(this->fileName, fn, 100);
}
inline void GenericHeader::CreationDate(char *ct) const
{
::strncpy(ct, this->creationDate, 12);
ct[24] = '\0';
OIIO::Strutil::safe_strcpy(ct, this->creationDate, 12);
}
inline void GenericHeader::SetCreationDate(const char *ct)
{
::strncpy(this->creationDate, ct, 12);
OIIO::Strutil::safe_strcpy(this->creationDate, ct, 12);
}
inline void GenericHeader::CreationTime(char *ct) const
{
::strncpy(ct, this->creationTime, 12);
ct[24] = '\0';
OIIO::Strutil::safe_strcpy(ct, this->creationTime, 12);
}
inline void GenericHeader::SetCreationTime(const char *ct)
{
::strncpy(this->creationTime, ct, 12);
OIIO::Strutil::safe_strcpy(this->creationTime, ct, 12);
}
inline Orientation GenericHeader::ImageOrientation() const
@@ -1245,30 +1237,30 @@ namespace cineon
inline U32 GenericHeader::PixelsPerLine(const int i) const
{
if (i < 0 || i >= MAX_ELEMENTS)
return 0xffffffff;
return this->chan[i].pixelsPerLine;
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return 0xffffffff;
return this->chan[i].pixelsPerLine;
}
inline void GenericHeader::SetPixelsPerLine(const int i, const U32 ppl)
{
if (i < 0 || i >= MAX_ELEMENTS)
return;
this->chan[i].pixelsPerLine = ppl;
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return;
this->chan[i].pixelsPerLine = ppl;
}
inline U32 GenericHeader::LinesPerElement(const int i) const
{
if (i < 0 || i >= MAX_ELEMENTS)
return 0xffffffff;
return this->chan[i].linesPerElement;
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return 0xffffffff;
return this->chan[i].linesPerElement;
}
inline void GenericHeader::SetLinesPerElement(const int i, const U32 lpe)
{
if (i < 0 || i >= MAX_ELEMENTS)
return;
this->chan[i].linesPerElement = lpe;
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return;
this->chan[i].linesPerElement = lpe;
}
inline U8 GenericHeader::DataSign() const
@@ -1283,100 +1275,100 @@ namespace cineon
inline R32 GenericHeader::LowData(const int i) const
{
if (i < 0 || i >= MAX_ELEMENTS)
return std::numeric_limits<R32>::infinity();
return this->chan[i].lowData;
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return std::numeric_limits<R32>::infinity();
return this->chan[i].lowData;
}
inline void GenericHeader::SetLowData(const int i, const R32 data)
{
if (i < 0 || i >= MAX_ELEMENTS)
return;
this->chan[i].lowData = data;
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return;
this->chan[i].lowData = data;
}
inline R32 GenericHeader::LowQuantity(const int i) const
{
if (i < 0 || i >= MAX_ELEMENTS)
return std::numeric_limits<R32>::max();
return this->chan[i].lowQuantity;
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return std::numeric_limits<R32>::max();
return this->chan[i].lowQuantity;
}
inline void GenericHeader::SetLowQuantity(const int i, const R32 quant)
{
if (i < 0 || i >= MAX_ELEMENTS)
return;
this->chan[i].lowQuantity = quant;
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return;
this->chan[i].lowQuantity = quant;
}
inline R32 GenericHeader::HighData(const int i) const
{
if (i < 0 || i >= MAX_ELEMENTS)
return std::numeric_limits<R32>::max();
return this->chan[i].highData;
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return std::numeric_limits<R32>::max();
return this->chan[i].highData;
}
inline void GenericHeader::SetHighData(const int i, const R32 data)
{
if (i < 0 || i >= MAX_ELEMENTS)
return;
this->chan[i].highData = data;
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return;
this->chan[i].highData = data;
}
inline R32 GenericHeader::HighQuantity(const int i) const
{
if (i < 0 || i >= MAX_ELEMENTS)
return std::numeric_limits<R32>::max();
return this->chan[i].highQuantity;
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return std::numeric_limits<R32>::max();
return this->chan[i].highQuantity;
}
inline void GenericHeader::SetHighQuantity(const int i, const R32 quant)
{
if (i < 0 || i >= MAX_ELEMENTS)
return;
this->chan[i].highQuantity = quant;
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return;
this->chan[i].highQuantity = quant;
}
inline U8 GenericHeader::Metric(const int i) const
{
if (i < 0 || i >= MAX_ELEMENTS)
return 0xff;
return this->chan[i].designator[0];
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return 0xff;
return this->chan[i].designator[0];
}
inline void GenericHeader::SetMetric(const int i, const U8 m)
{
if (i < 0 || i >= MAX_ELEMENTS)
return;
this->chan[i].designator[0] = m;
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return;
this->chan[i].designator[0] = m;
}
inline Descriptor GenericHeader::ImageDescriptor(const int i) const
{
if (i < 0 || i >= MAX_ELEMENTS)
return Descriptor(0xff);
return Descriptor(this->chan[i].designator[1]);
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return Descriptor(0xff);
return Descriptor(this->chan[i].designator[1]);
}
inline void GenericHeader::SetImageDescriptor(const int i, const Descriptor desc)
{
if (i < 0 || i >= MAX_ELEMENTS)
return;
this->chan[i].designator[1] = (U8)desc;
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return;
this->chan[i].designator[1] = (U8)desc;
}
inline U8 GenericHeader::BitDepth(const int i) const
{
if (i < 0 || i >= MAX_ELEMENTS)
return 0xff;
return this->chan[i].bitDepth;
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return 0xff;
return this->chan[i].bitDepth;
}
inline void GenericHeader::SetBitDepth(const int i, const U8 depth)
{
if (i < 0 || i >= MAX_ELEMENTS)
return;
this->chan[i].bitDepth = depth;
if (i < 0 || i >= CINEON_MAX_ELEMENTS)
return;
this->chan[i].bitDepth = depth;
}
inline Interleave GenericHeader::ImageInterleave() const
@@ -1425,12 +1417,12 @@ namespace cineon
inline void GenericHeader::LabelText(char *desc) const
{
strncpy(desc, this->labelText, 200);
OIIO::Strutil::safe_strcpy(desc, this->labelText, 200);
}
inline void GenericHeader::SetLabelText(const char *desc)
{
::strncpy(this->labelText, desc, 200);
OIIO::Strutil::safe_strcpy(this->labelText, desc, 200);
}
@@ -1496,68 +1488,62 @@ namespace cineon
inline void GenericHeader::SourceImageFileName(char *fn) const
{
::strncpy(fn, this->sourceImageFileName, 100);
fn[100] = '\0';
OIIO::Strutil::safe_strcpy(fn, this->sourceImageFileName, 100);
}
inline void GenericHeader::SetSourceImageFileName(const char *fn)
{
::strncpy(this->sourceImageFileName, fn, 100);
OIIO::Strutil::safe_strcpy(this->sourceImageFileName, fn, 100);
}
inline void GenericHeader::SourceDate(char *td) const
{
::strncpy(td, this->sourceDate, 12);
td[12] = '\0';
OIIO::Strutil::safe_strcpy(td, this->sourceDate, 12);
}
inline void GenericHeader::SetSourceDate(const char *td)
{
::strncpy(this->sourceDate, td, 12);
OIIO::Strutil::safe_strcpy(this->sourceDate, td, 12);
}
inline void GenericHeader::SourceTime(char *td) const
{
::strncpy(td, this->sourceTime, 12);
td[12] = '\0';
OIIO::Strutil::safe_strcpy(td, this->sourceTime, 12);
}
inline void GenericHeader::SetSourceTime(const char *td)
{
::strncpy(this->sourceTime, td, 12);
OIIO::Strutil::safe_strcpy(this->sourceTime, td, 12);
}
inline void GenericHeader::InputDevice(char *dev) const
{
::strncpy(dev, this->inputDevice, 32);
dev[32] = '\0';
OIIO::Strutil::safe_strcpy(dev, this->inputDevice, 32);
}
inline void GenericHeader::SetInputDevice(const char *dev)
{
::strncpy(this->inputDevice, dev, 32);
OIIO::Strutil::safe_strcpy(this->inputDevice, dev, 32);
}
inline void GenericHeader::InputDeviceModelNumber(char *sn) const
{
::strncpy(sn, this->inputDeviceModelNumber, 32);
sn[32] = '\0';
OIIO::Strutil::safe_strcpy(sn, this->inputDeviceModelNumber, 32);
}
inline void GenericHeader::SetInputDeviceModelNumber(const char *sn)
{
::strncpy(this->inputDeviceModelNumber, sn, 32);
OIIO::Strutil::safe_strcpy(this->inputDeviceModelNumber, sn, 32);
}
inline void GenericHeader::InputDeviceSerialNumber(char *sn) const
{
::strncpy(sn, this->inputDeviceSerialNumber, 32);
sn[32] = '\0';
OIIO::Strutil::safe_strcpy(sn, this->inputDeviceSerialNumber, 32);
}
inline void GenericHeader::SetInputDeviceSerialNumber(const char *sn)
{
::strncpy(this->inputDeviceSerialNumber, sn, 32);
OIIO::Strutil::safe_strcpy(this->inputDeviceSerialNumber, sn, 32);
}
inline R32 GenericHeader::XDevicePitch() const
@@ -1582,13 +1568,12 @@ namespace cineon
inline void IndustryHeader::Format(char *fmt) const
{
::strncpy(fmt, this->format, 32);
fmt[32] = '\0';
OIIO::Strutil::safe_strcpy(fmt, this->format, 32);
}
inline void IndustryHeader::SetFormat(const char *fmt)
{
::strncpy(this->format, fmt, 32);
OIIO::Strutil::safe_strcpy(this->format, fmt, 32);
}
inline U32 IndustryHeader::FramePosition() const
@@ -1613,24 +1598,22 @@ namespace cineon
inline void IndustryHeader::FrameId(char *id) const
{
::strncpy(id, this->frameId, 32);
id[32] = '\0';
OIIO::Strutil::safe_strcpy(id, this->frameId, 32);
}
inline void IndustryHeader::SetFrameId(const char *id)
{
::strncpy(this->frameId, id, 32);
OIIO::Strutil::safe_strcpy(this->frameId, id, 32);
}
inline void IndustryHeader::SlateInfo(char *slate) const
{
::strncpy(slate, this->slateInfo, 100);
slate[100] = '\0';
OIIO::Strutil::safe_strcpy(slate, this->slateInfo, 100);
}
inline void IndustryHeader::SetSlateInfo(const char *slate)
{
::strncpy(this->slateInfo, slate, 100);
OIIO::Strutil::safe_strcpy(this->slateInfo, slate, 100);
}
inline R32 GenericHeader::Gamma() const
+2 -2
View File
@@ -35,7 +35,7 @@
#include <cstdio>
#include "OpenImageIO/filesystem.h"
#include <OpenImageIO/filesystem.h>
#include "CineonStream.h"
@@ -96,7 +96,7 @@ bool InStream::Seek(long offset, Origin origin)
}
if (this->fp == 0)
return -1;
return false;
return (::fseek(this->fp, offset, o) == 0);
}
+2 -2
View File
@@ -34,7 +34,7 @@
#include <cstdio>
#include "OpenImageIO/filesystem.h"
#include <OpenImageIO/filesystem.h>
#include "CineonStream.h"
@@ -97,7 +97,7 @@ bool OutStream::Seek(long offset, Origin origin)
}
if (this->fp == 0)
return -1;
return false;
return (::fseek(this->fp, offset, o) == 0);
}
@@ -94,7 +94,7 @@ namespace cineon
offset += block.x1 * numberOfComponents / 3 * 4;
// get the read count in bytes, round to the 32-bit boundry
// get the read count in bytes, round to the 32-bit boundary
int readSize = (block.x2 - block.x1 + 1) * numberOfComponents;
readSize += readSize % 3;
readSize = readSize / 3 * 4;
@@ -110,7 +110,7 @@ namespace cineon
for (int count = (block.x2 - block.x1 + 1) * numberOfComponents - 1; count >= 0; count--)
{
// unpacking the buffer backwords
// unpacking the buffer backwards
U16 d1 = U16(readBuf[(count + index) / 3] >> ((2 - (count + index) % 3) * 10 + PADDINGBITS) & 0x3ff);
BaseTypeConvertU10ToU16(d1, d1);
BaseTypeConverter(d1, obuf[count]);
@@ -146,7 +146,7 @@ namespace cineon
for (int i = count - 1; i >= 0; i--)
{
// unpacking the buffer backwords
// unpacking the buffer backwards
// find the byte that the data starts in, read in as a 16 bits then shift and mask
// the pattern with byte offset is:
// 10 bits datasize rotates every 4 data elements
+14 -11
View File
@@ -35,6 +35,10 @@
#include <cstring>
#include <ctime>
#if defined(__GNUC__)
# pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
#include "Cineon.h"
#include "CineonStream.h"
#include "EndianSwap.h"
@@ -78,12 +82,12 @@ void cineon::Writer::SetImageInfo(const U32 width, const U32 height)
}
// returns next available or MAX_ELEMENTS if full
// returns next available or CINEON_MAX_ELEMENTS if full
int cineon::Writer::NextAvailElement() const
{
unsigned int i;
for (i = 0; i < MAX_ELEMENTS; i++)
for (i = 0; i < CINEON_MAX_ELEMENTS; i++)
{
if (this->header.ImageDescriptor(i) == kUndefinedDescriptor)
break;
@@ -135,7 +139,7 @@ void cineon::Writer::SetElement(const int num, const Descriptor desc, const U8 b
const R32 highData, const R32 highQuantity)
{
// make sure the range is good
if (num < 0 || num >= MAX_ELEMENTS)
if (num < 0 || num >= CINEON_MAX_ELEMENTS)
return;
// set values
@@ -156,7 +160,7 @@ void cineon::Writer::SetElement(const int num, const Descriptor desc, const U8 b
bool cineon::Writer::WriteElement(const int element, void *data, const long count)
{
// make sure the range is good
if (element < 0 || element >= MAX_ELEMENTS)
if (element < 0 || element >= CINEON_MAX_ELEMENTS)
return false;
// make sure the entry is valid
@@ -176,7 +180,7 @@ bool cineon::Writer::WriteElement(const int element, void *data, const long coun
bool cineon::Writer::WriteElement(const int element, void *data)
{
// make sure the range is good
if (element < 0 || element >= MAX_ELEMENTS)
if (element < 0 || element >= CINEON_MAX_ELEMENTS)
return false;
// make sure the entry is valid
@@ -193,7 +197,7 @@ bool cineon::Writer::WriteElement(const int element, void *data, const DataSize
bool status = true;
// make sure the range is good
if (element < 0 || element >= MAX_ELEMENTS)
if (element < 0 || element >= CINEON_MAX_ELEMENTS)
return false;
// make sure the entry is valid
@@ -239,8 +243,7 @@ bool cineon::Writer::WriteElement(const int element, void *data, const DataSize
(bitDepth == 16 && size == cineon::kWord))
{
status = this->WriteThrough(data, width, height, noc, bytes, eolnPad, eoimPad, blank);
if (blank)
delete [] blank;
delete [] blank;
return status;
}
else
@@ -280,6 +283,7 @@ bool cineon::Writer::WriteElement(const int element, void *data, const DataSize
break;
default:
delete [] blank;
return false;
}
}
@@ -293,8 +297,7 @@ bool cineon::Writer::WriteElement(const int element, void *data, const DataSize
}
// rid of memory
if (blank)
delete [] blank;
delete [] blank;
return status;
}
@@ -305,7 +308,7 @@ bool cineon::Writer::WriteElement(const int element, void *data, const DataSize
bool cineon::Writer::WriteThrough(void *data, const U32 width, const U32 height, const int noc, const int bytes, const U32 eolnPad, const U32 eoimPad, char *blank)
{
bool status = true;
const int count = width * height * noc;
const size_t count = size_t(width) * size_t(height) * noc;
unsigned int i;
unsigned char *imageBuf = reinterpret_cast<unsigned char*>(data);
@@ -83,12 +83,13 @@ namespace cineon
void RleCompress(IB *src, IB *dst, const int bufsize, const int len, BufferAccess &access)
{
IB ch;
int count;
// int count;
int i;
int index = bufsize - 1;
bool start = true;
//bool match = true;
#if 0 /* This seems to not be used */
// for each data type, have maximum length of rle datum
// subtract one so it the LSBit can be used to state
int maxCount;
@@ -102,13 +103,13 @@ namespace cineon
maxCount = 0xffff - 1;
else
maxCount = 1000000; // high number for floats, doubles
#endif
for (i = len - 1; i >= 0; i--)
{
if (start)
{
count = 1;
// count = 1;
start = false;
ch = src[i];
dst[index--] = ch;
+76
View File
@@ -0,0 +1,76 @@
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
# add here all the find_dependency() whenever switching to config based dependencies
if (NOT @OPENIMAGEIO_CONFIG_DO_NOT_FIND_IMATH@ AND NOT OPENIMAGEIO_CONFIG_DO_NOT_FIND_IMATH)
if (@OpenEXR_VERSION@ VERSION_GREATER_EQUAL 3.0)
find_dependency(Imath @Imath_VERSION@
HINTS @Imath_DIR@)
elseif (@OpenEXR_VERSION@ VERSION_GREATER_EQUAL 2.4 AND @FOUND_OPENEXR_WITH_CONFIG@)
find_dependency(IlmBase @OpenEXR_VERSION@
HINTS @IlmBase_DIR@ @OpenEXR_DIR@)
find_dependency(OpenEXR @OpenEXR_VERSION@
HINTS @OpenEXR_DIR@)
find_dependency(ZLIB @ZLIB_VERSION@) # Because OpenEXR doesn't do it
find_dependency(Threads) # Because OpenEXR doesn't do it
endif ()
endif ()
if (NOT @OIIO_USING_FMT_LOCAL@ AND NOT @INTERNALIZE_FMT@)
find_dependency(fmt)
endif ()
if (NOT @BUILD_SHARED_LIBS@)
# This is required in static library builds, as e.g. PNG::PNG appears among
# INTERFACE_LINK_LIBRARIES. If the project does not know about PNG target, it will cause
# configuration error about unknown targets being linked in.
find_dependency(TIFF)
if (@JPEG_FOUND@)
find_dependency(JPEG)
endif()
if (@PNG_FOUND@)
find_dependency(PNG)
endif()
# The following have the same problem except that INTERFACE_LINK_LIBRARIES use
# TARGET_NAME_IF_EXISTS, so the error only happens on link time.
if (@OIIO_TBB@)
find_dependency(TBB)
endif ()
endif ()
# Compute the installation prefix relative to this file. Note that cmake files are installed
# to ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} (see OIIO_CONFIG_INSTALL_DIR)
get_filename_component(_CURR_INSTALL_LIBDIR "${CMAKE_CURRENT_LIST_DIR}/../../" ABSOLUTE)
get_filename_component(_ABS_CMAKE_INSTALL_LIBDIR "@CMAKE_INSTALL_FULL_LIBDIR@" ABSOLUTE)
get_filename_component(_ABS_CMAKE_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@" ABSOLUTE)
file(RELATIVE_PATH _INCLUDEDIR_RELATIVE_TO_LIBDIR
"${_ABS_CMAKE_INSTALL_LIBDIR}" "${_ABS_CMAKE_INSTALL_INCLUDEDIR}")
get_filename_component(_CURR_INSTALL_INCLUDE_DIR
"${_CURR_INSTALL_LIBDIR}/${_INCLUDEDIR_RELATIVE_TO_LIBDIR}" ABSOLUTE)
set_and_check (@PROJECT_NAME@_INCLUDE_DIR "${_CURR_INSTALL_INCLUDE_DIR}")
set_and_check (@PROJECT_NAME@_INCLUDES "${_CURR_INSTALL_INCLUDE_DIR}")
set_and_check (@PROJECT_NAME@_LIB_DIR "${_CURR_INSTALL_LIBDIR}")
set (@PROJECT_NAME@_PLUGIN_SEARCH_PATH "@PLUGIN_SEARCH_PATH_NATIVE@")
if (NOT @FOUND_OPENEXR_WITH_CONFIG@)
list (APPEND @PROJECT_NAME@_INCLUDES ${IMATH_INCLUDES} ${OPENEXR_INCLUDES})
endif ()
set (OIIO_USING_IMATH_VERSION_MAJOR @Imath_VERSION_MAJOR@)
set (OIIO_USING_IMATH_VERSION_MINOR @Imath_VERSION_MINOR@)
#...logic to determine installedPrefix from the own location...
#set (@PROJECT_NAME@_CONFIG_DIR "${installedPrefix}/@CONFIG_INSTALL_DIR@")
include ("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
check_required_components ("@PROJECT_NAME@")
# Set a CMake variable that says if this OpenImageIO build has OCIO support
set (@PROJECT_NAME@_HAS_OpenColorIO @OpenColorIO_FOUND@)
Loaded 100 of 1258 files, more files were not shown because too many files have changed in this diff. Show more