Skip to content

Commit c362379

Browse files
Issues/0108 ctlrender exr file support (#110)
* set HAVE_OPENEXR define * add #include <fstream> to exr_file.cc * add ctlrender unit tests with EXR files * add windows vcpkg debug test workflow * add debugging info output to /unittest/ctlrender/test.sh * print message if input exr file is unavailable * fix run-time check about uninitialized variable * add valgrind tests for ctlrender using EXR files
1 parent 0fb587b commit c362379

File tree

7 files changed

+177
-14
lines changed

7 files changed

+177
-14
lines changed

.github/workflows/windows_vcpkg_debug.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,43 @@ jobs:
5151
# Build your program with the given configuration
5252
run: cmake --build ${{github.workspace}}/build --target install --config ${{env.BUILD_TYPE}}
5353
working-directory: ${{github.workspace}}
54+
55+
test:
56+
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
57+
# You can convert this to a matrix build if you need cross-platform coverage.
58+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
59+
runs-on: windows-latest
60+
61+
steps:
62+
63+
- name: install dependencies - imath
64+
run: vcpkg install imath
65+
66+
- name: install dependencies - openexr
67+
run: vcpkg install openexr
68+
69+
- name: install dependencies - tiff
70+
run: vcpkg install tiff
71+
72+
- name: check vcpkg install status
73+
run: vcpkg list
74+
75+
- uses: actions/checkout@v3
76+
77+
- name: Configure CMake
78+
# # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
79+
# # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
80+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -D "CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
81+
82+
- name: Build
83+
# Build your program with the given configuration
84+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
85+
86+
- name: Install
87+
# Build your program with the given configuration
88+
run: cmake --build ${{github.workspace}}/build --target install --config ${{env.BUILD_TYPE}}
89+
working-directory: ${{github.workspace}}
90+
91+
- name: Test
92+
working-directory: ${{github.workspace}}/build
93+
run: ctest -V --output-on-failure -C ${{env.BUILD_TYPE}}

ctlrender/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ target_link_libraries(ctlrender
2626
$<$<TARGET_EXISTS:OpenEXR::IlmImf>:OpenEXR::IlmImf>
2727
)
2828

29+
if( OpenEXR_FOUND )
30+
target_compile_definitions(ctlrender
31+
PRIVATE
32+
-DHAVE_OPENEXR=1
33+
)
34+
else()
35+
message( STATUS "OPENEXR not found, ctlrender will not support EXR files" )
36+
endif()
37+
2938
find_package(TIFF)
3039
if(TARGET TIFF::TIFF)
3140
message( STATUS "found TIFF, TIFF_LIBRARIES : ${TIFF_LIBRARIES}" )
@@ -38,7 +47,7 @@ if(TARGET TIFF::TIFF)
3847
TIFF::TIFF
3948
)
4049
else()
41-
message( STATUS "TIFF not found" )
50+
message( STATUS "TIFF not found, ctlrender will not support TIF files" )
4251
endif()
4352

4453
find_package(AcesContainer)

ctlrender/exr_file.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
///////////////////////////////////////////////////////////////////////////
5454

5555
#include "exr_file.hh"
56+
#include <fstream>
5657

5758
#if defined(HAVE_OPENEXR)
5859
#include <ImfInputFile.h>
@@ -70,6 +71,13 @@ bool exr_read(const char *name, float scale, ctl::dpx::fb<float> *pixels,
7071

7172
ins.open(name);
7273

74+
if (!ins.good())
75+
{
76+
fprintf(stderr, "WARNING on line %d of file %s in function %s(): unable to open file %s\n",
77+
__LINE__, __FILE__, __FUNCTION__, name);
78+
return false;
79+
}
80+
7381
ins.read((char *)&magic, sizeof(magic));
7482
endian=0x01020304;
7583
if(((unsigned char *)(&endian))[0]==0x01) {

lib/IlmCtl/CtlTypeStorage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ void TypeStorage::copy(const TypeStoragePtr &src, size_t src_offset,
656656
src->type()->cDataType()==UIntTypeEnum ||
657657
src->type()->cDataType()==HalfTypeEnum ||
658658
src->type()->cDataType()==StringTypeEnum)) {
659-
va_list empty;
659+
va_list empty = {};
660660
// fprintf(stderr, "_set %p %d %d %d %d %d\n", out, src->type()->cDataType(), type()->cDataType(), type()->objectSize(), dst_offset, count);
661661
_set(in, src->type()->cDataType(), src->type()->objectSize(),
662662
dst_offset, count, "", empty);

resources/test/scripts/run_valgrind.sh

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,37 @@ test_03_label="IlmImfCtlTest"
2424
cd ../ctlrender
2525
valgrind -s --error-exitcode=1 --leak-check=full --track-origins=yes --show-leak-kinds=all ../../ctlrender/ctlrender -force -ctl ../../../unittest/ctlrender/unity.ctl ../../../unittest/ctlrender/bars_nuke_10_be.dpx out.dpx
2626
test_04_status=$?
27-
test_04_label="ctlrender"
27+
test_04_label="ctlrender-dpx-to-dpx"
28+
29+
valgrind -s --error-exitcode=1 --leak-check=full --track-origins=yes --show-leak-kinds=all ../../ctlrender/ctlrender -force -ctl ../../../unittest/ctlrender/unity.ctl ../../../unittest/ctlrender/bars_nuke_10_be.dpx out.tif
30+
test_05_status=$?
31+
test_05_label="ctlrender-dpx-to-tif"
32+
33+
valgrind -s --error-exitcode=1 --leak-check=full --track-origins=yes --show-leak-kinds=all ../../ctlrender/ctlrender -force -ctl ../../../unittest/ctlrender/unity.ctl ../../../unittest/ctlrender/bars_photoshop_16_le_interleaved.tif out.tif
34+
test_06_status=$?
35+
test_06_label="ctlrender-tif-to-tif"
36+
37+
valgrind -s --error-exitcode=1 --leak-check=full --track-origins=yes --show-leak-kinds=all ../../ctlrender/ctlrender -force -ctl ../../../unittest/ctlrender/unity.ctl ../../../unittest/ctlrender/bars_photoshop_16_le_interleaved.tif out.dpx
38+
test_07_status=$?
39+
test_07_label="ctlrender-tif-to-dpx"
40+
41+
valgrind -s --error-exitcode=1 --leak-check=full --track-origins=yes --show-leak-kinds=all ../../ctlrender/ctlrender -force -ctl ../../../unittest/ctlrender/unity.ctl ../../../unittest/ctlrender/bars_photoshop.exr out.exr
42+
test_08_status=$?
43+
test_08_label="ctlrender-exr-to-exr"
44+
45+
valgrind -s --error-exitcode=1 --leak-check=full --track-origins=yes --show-leak-kinds=all ../../ctlrender/ctlrender -force -format exr16 -ctl ../../../unittest/ctlrender/unity.ctl ../../../unittest/ctlrender/bars_photoshop.exr out.exr
46+
test_09_status=$?
47+
test_09_label="ctlrender-exr-to-exr16"
48+
49+
valgrind -s --error-exitcode=1 --leak-check=full --track-origins=yes --show-leak-kinds=all ../../ctlrender/ctlrender -force -format exr32 -ctl ../../../unittest/ctlrender/unity.ctl ../../../unittest/ctlrender/bars_photoshop.exr out.exr
50+
test_10_status=$?
51+
test_10_label="ctlrender-exr-to-exr32"
2852

2953
# go back to initial path
3054
cd $SCRIPTPATH
3155

3256
# return valgrind exit codes
33-
if [ $test_01_status -eq 0 ] && [ $test_02_status -eq 0 ] && [ $test_03_status -eq 0 ] && [ $test_04_status -eq 0 ]
57+
if [ $test_01_status -eq 0 ] && [ $test_02_status -eq 0 ] && [ $test_03_status -eq 0 ] && [ $test_04_status -eq 0 ] && [ $test_05_status -eq 0 ] && [ $test_06_status -eq 0 ] && [ $test_07_status -eq 0 ] && [ $test_08_status -eq 0 ] && [ $test_09_status -eq 0 ] && [ $test_10_status -eq 0 ]
3458
then
3559
echo "Success: valgrind detected no errors"
3660
exit 0
@@ -57,5 +81,35 @@ else
5781
echo "$test_04_label: valgrind detected errors"
5882
fi
5983

84+
if [ $test_05_status -ne 0 ]
85+
then
86+
echo "$test_05_label: valgrind detected errors"
87+
fi
88+
89+
if [ $test_06_status -ne 0 ]
90+
then
91+
echo "$test_06_label: valgrind detected errors"
92+
fi
93+
94+
if [ $test_07_status -ne 0 ]
95+
then
96+
echo "$test_07_label: valgrind detected errors"
97+
fi
98+
99+
if [ $test_08_status -ne 0 ]
100+
then
101+
echo "$test_08_label: valgrind detected errors"
102+
fi
103+
104+
if [ $test_09_status -ne 0 ]
105+
then
106+
echo "$test_09_label: valgrind detected errors"
107+
fi
108+
109+
if [ $test_10_status -ne 0 ]
110+
then
111+
echo "$test_10_label: valgrind detected errors"
112+
fi
113+
60114
exit 1
61115
fi

unittest/ctlrender/CMakeLists.txt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,24 @@ if (BASH_PROGRAM)
99
COMMAND ${BASH_PROGRAM} ./test.sh $<TARGET_FILE:ctlrender>
1010
)
1111
else()
12-
MESSAGE( STATUS "BASH not found, able to run ctlrender unit test" )
12+
MESSAGE( STATUS "BASH not found, not able to run ctlrender unit test" )
1313
endif (BASH_PROGRAM)
1414

1515

1616

1717
find_package(TIFF)
18-
if ( TARGET TIFF::TIFF )
19-
set_property(TEST ctlrender PROPERTY ENVIRONMENT "IS_TIFF_FOUND=1")
20-
else()
21-
message(WARNING "LibTIFF not found, skipping tiff-related ctlrender unit tests")
22-
set_property(TEST ctlrender PROPERTY ENVIRONMENT "IS_TIFF_FOUND=0")
18+
if ( TARGET TIFF::TIFF AND OpenEXR_FOUND )
19+
message(WARNING "LibTIFF found, OpenEXR found, including TIF and EXR files in ctlrender unit tests")
20+
set_property(TEST ctlrender PROPERTY ENVIRONMENT "IS_TIFF_FOUND=1;IS_OPENEXR_FOUND=1")
21+
elseif( TARGET TIFF::TIFF AND NOT OpenEXR_FOUND )
22+
message(WARNING "LibTIFF found, OpenEXR not found, including TIF files in ctlrender unit tests")
23+
set_property(TEST ctlrender PROPERTY ENVIRONMENT "IS_TIFF_FOUND=1;IS_OPENEXR_FOUND=0")
24+
elseif( NOT TARGET TIFF::TIFF AND OpenEXR_FOUND )
25+
message(WARNING "LibTIFF not found, OpenEXR found, including EXR files in ctlrender unit tests")
26+
set_property(TEST ctlrender PROPERTY ENVIRONMENT "IS_TIFF_FOUND=0;IS_OPENEXR_FOUND=1")
27+
elseif( NOT TARGET TIFF::TIFF AND NOT OpenEXR_FOUND )
28+
message(WARNING "LibTIFF not found, OpenEXR not found, not including TIF or EXR files in ctlrender unit tests")
29+
set_property(TEST ctlrender PROPERTY ENVIRONMENT "IS_TIFF_FOUND=0;IS_OPENEXR_FOUND=0")
2330
endif()
2431

2532

unittest/ctlrender/test.sh

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,70 @@ CTLRENDER=$1
33

44
mkdir output
55

6+
printf 'printing environment variables...\n'
7+
printenv
8+
9+
printf 'printing current path...\n'
10+
pwd
11+
12+
printf 'printing directory contents...\n'
13+
dir
14+
15+
set -e
16+
617
for J in tiff8 tiff16 tiff32 dpx8 dpx10 dpx12 dpx16; do
18+
19+
echo ${J} unity test
20+
721
for I in bars_cinepaint_10.dpx bars_nuke_10_be.dpx bars_nuke_10_le.dpx bars_nuke_12_be.dpx bars_nuke_12_le.dpx bars_nuke_16_be.dpx bars_nuke_16_le.dpx bars_nuke_8_be.dpx bars_nuke_8_le.dpx bars_photoshop_16_be_interleaved.tif bars_photoshop_16_be_planar.tif bars_photoshop_16_le_interleaved.tif bars_photoshop_16_le_planar.tif bars_photoshop_32_be_interleaved.tif bars_photoshop_32_be_planar.tif bars_photoshop_32_le_interleaved.tif bars_photoshop_32_le_planar.tif bars_photoshop_8_be_interleaved.tif bars_photoshop_8_be_planar.tif bars_photoshop_8_le_interleaved.tif bars_photoshop_8_le_planar.tif ; do
822
name=`echo $I | sed -e 's/\..*//'`
923
ext=`echo $J | sed -e 's/[0-9]//g'`
1024
echo ${I} '->' ${J}
1125
if [[ $IS_TIFF_FOUND == 0 ]] && [[ $J == *"tif"* ]] ; then
12-
printf 'skipping %s because no tiff\n' $J
26+
printf 'skipping %s because tiff support was not detected\n' $J
1327
elif [[ $IS_TIFF_FOUND == 0 ]] && [[ $I == *"tif"* ]] ; then
14-
printf 'skipping %s because no tiff\n' $I
28+
printf 'skipping %s because tiff support was not detected\n' $I
1529
else
1630
$CTLRENDER -ctl unity.ctl -format ${J} -force ${I} output/${name}_${J}.${ext}
1731
fi
1832
done
1933

20-
echo ${J} unity test
21-
34+
# test TIFF32 conversions
2235
if [[ $IS_TIFF_FOUND == 1 ]] ; then
36+
printf 'bars_photoshop_32_be_planar.tif -> output/bars_tiff32_%s.%s \n' ${J} ${ext}
2337
$CTLRENDER -ctl unity.ctl -format ${J} -force bars_photoshop_32_be_planar.tif output/bars_tiff32_${J}.${ext}
38+
printf 'output/bars_tiff32_%s.%s -> output/bars_tiff32_%s_tiff32.tiff \n' ${J} ${ext} ${J}
2439
$CTLRENDER -ctl unity.ctl -format tiff32 -force output/bars_tiff32_${J}.${ext} output/bars_tiff32_${J}_tiff32.tiff
2540
fi
2641
done
2742

43+
# test EXR to EXR support
44+
if [[ $IS_OPENEXR_FOUND == 1 ]] ; then
45+
printf 'bars_photoshop.exr -> output/bars_exr_exr.exr \n'
46+
$CTLRENDER -ctl unity.ctl -format exr -force bars_photoshop.exr output/bars_exr_exr.exr
47+
printf 'bars_photoshop.exr -> output/bars_exr_exr16.exr \n'
48+
$CTLRENDER -ctl unity.ctl -format exr16 -force bars_photoshop.exr output/bars_exr_exr16.exr
49+
printf 'bars_photoshop.exr -> output/bars_exr_exr32.exr \n'
50+
$CTLRENDER -ctl unity.ctl -format exr32 -force bars_photoshop.exr output/bars_exr_exr32.exr
51+
fi
52+
53+
# test TIFF32 to EXR and EXR to TIFF32 support
54+
if [[ $IS_OPENEXR_FOUND == 1 ]] && [[ $IS_TIFF_FOUND == 1 ]] ; then
55+
56+
for J in exr exr16 exr32 tiff32; do
57+
58+
for I in bars_photoshop_32_be_interleaved.tif bars_photoshop_32_be_planar.tif bars_photoshop_32_le_interleaved.tif bars_photoshop_32_le_planar.tif bars_photoshop.exr; do
59+
name=`echo $I | sed -e 's/\..*//'`
60+
ext=`echo $J | sed -e 's/[0-9]//g'`
61+
echo ${I} '->' ${J}
62+
if [[ $IS_TIFF_FOUND == 0 ]] && [[ $J == *"tif"* ]] ; then
63+
printf 'skipping %s because tiff support was not detected\n' $J
64+
elif [[ $IS_TIFF_FOUND == 0 ]] && [[ $I == *"tif"* ]] ; then
65+
printf 'skipping %s because tiff support was not detected\n' $I
66+
else
67+
$CTLRENDER -ctl unity.ctl -format ${J} -force ${I} output/${name}_${J}.${ext}
68+
fi
69+
70+
done
71+
done
72+
fi

0 commit comments

Comments
 (0)