Skip to content

Commit

Permalink
Merge pull request #224 from Tom94/update-openexr
Browse files Browse the repository at this point in the history
Update OpenEXR dependency
  • Loading branch information
Tom94 authored Mar 14, 2024
2 parents fdc8ae0 + eb40611 commit 2132336
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 27 deletions.
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[submodule "dependencies/args"]
path = dependencies/args
url = https://github.com/Taywee/args
[submodule "dependencies/Imath"]
path = dependencies/Imath
url = https://github.com/AcademySoftwareFoundation/Imath
[submodule "dependencies/openexr"]
path = dependencies/openexr
url = https://github.com/mitsuba-renderer/openexr
url = https://github.com/AcademySoftwareFoundation/openexr
[submodule "dependencies/zlib"]
path = dependencies/zlib
url = https://github.com/Tom94/zlib
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines")
endif()

set(TEV_LIBS clip IlmImf nanogui ${NANOGUI_EXTRA_LIBS})
set(TEV_LIBS clip OpenEXR::OpenEXR nanogui ${NANOGUI_EXTRA_LIBS})
if (MSVC)
set(TEV_LIBS ${TEV_LIBS} zlibstatic DirectXTex wsock32 ws2_32)
endif()
Expand Down
21 changes: 5 additions & 16 deletions dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ if (WIN32)
endif()

# Compile OpenEXR
set(PYILMBASE_ENABLE OFF CACHE BOOL " " FORCE)
set(ILMBASE_BUILD_SHARED_LIBS OFF CACHE BOOL " " FORCE)
set(OPENEXR_BUILD_SHARED_LIBS OFF CACHE BOOL " " FORCE)
set(ILMBASE_NAMESPACE_VERSIONING OFF CACHE BOOL " " FORCE)
set(OPENEXR_NAMESPACE_VERSIONING OFF CACHE BOOL " " FORCE)
add_subdirectory(openexr EXCLUDE_FROM_ALL)
set_property(TARGET Half Iex IlmImf IlmThread Imath PROPERTY FOLDER "dependencies")
add_subdirectory(Imath)

set(OPENEXR_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE)
set(OPENEXR_BUILD_TOOLS OFF CACHE BOOL " " FORCE)
add_subdirectory(openexr)

# Compile clip
set(CLIP_EXAMPLES OFF CACHE BOOL " " FORCE)
Expand All @@ -82,15 +80,6 @@ set(NANOGUI_EXTRA_INCS ${NANOGUI_EXTRA_INCS} PARENT_SCOPE)
set(NANOGUI_EXTRA_DEFS ${NANOGUI_EXTRA_DEFS} PARENT_SCOPE)
set(NANOGUI_EXTRA_LIBS ${NANOGUI_EXTRA_LIBS} PARENT_SCOPE)

set(OPENEXR_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/openexr/IlmBase/Imath
${CMAKE_CURRENT_SOURCE_DIR}/openexr/IlmBase/Iex
${CMAKE_CURRENT_SOURCE_DIR}/openexr/IlmBase/Half
${CMAKE_CURRENT_SOURCE_DIR}/openexr/OpenEXR/IlmImf
${CMAKE_CURRENT_BINARY_DIR}/openexr/OpenEXR/config
${CMAKE_CURRENT_BINARY_DIR}/openexr/IlmBase/config
PARENT_SCOPE)

set(QOI_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/qoi PARENT_SCOPE)

set(STB_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/stb PARENT_SCOPE)
Expand Down
1 change: 1 addition & 0 deletions dependencies/Imath
Submodule Imath added at 1f167f
2 changes: 1 addition & 1 deletion dependencies/openexr
1 change: 0 additions & 1 deletion src/ImageViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <nanogui/vscrollpanel.h>

#include <chrono>
#include <iostream>
#include <stdexcept>

using namespace nanogui;
Expand Down
9 changes: 5 additions & 4 deletions src/imageio/ExrImageLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <ImfChannelList.h>
#include <ImfChromaticities.h>
#include <ImfFrameBuffer.h>
#include <ImfInputFile.h>
#include <ImfInputPart.h>
#include <ImfMultiPartInputFile.h>
Expand Down Expand Up @@ -36,11 +37,11 @@ class StdIStream: public Imf::IStream
return checkError(mStream, n);
}

Imf::Int64 tellg() override {
uint64_t tellg() override {
return streamoff(mStream.tellg());
}

void seekg(Imf::Int64 pos) override {
void seekg(uint64_t pos) override {
mStream.seekg(pos);
checkError(mStream);
}
Expand Down Expand Up @@ -110,12 +111,12 @@ class RawChannel {
template <typename T>
Task<void> copyToTyped(Channel& channel, int priority) const {
int width = channel.size().x();
int widthSubsampled = width/mImfChannel.ySampling;
int widthSubsampled = width / mImfChannel.ySampling;

auto data = reinterpret_cast<const T*>(mData.data());
co_await ThreadPool::global().parallelForAsync<int>(0, channel.size().y(), [&, data](int y) {
for (int x = 0; x < width; ++x) {
channel.at({x, y}) = data[x/mImfChannel.xSampling + (y/mImfChannel.ySampling) * widthSubsampled];
channel.at({x, y}) = data[x / mImfChannel.xSampling + (y / mImfChannel.ySampling) * widthSubsampled];
}
}, priority);
}
Expand Down
8 changes: 5 additions & 3 deletions src/imageio/ExrImageSaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
#include <tev/imageio/ExrImageSaver.h>

#include <ImfChannelList.h>
#include <ImfHeader.h>
#include <ImfFrameBuffer.h>
#include <ImfOutputFile.h>
#include <ImfInputPart.h>
#include <ImfMultiPartInputFile.h>
#include <ImfIO.h>
#include <Iex.h>

#include <ostream>
Expand All @@ -30,11 +32,11 @@ class StdOStream: public Imf::OStream
checkError(mStream);
}

Imf::Int64 tellp() {
uint64_t tellp() {
return std::streamoff(mStream.tellp());
}

void seekp(Imf::Int64 pos) {
void seekp(uint64_t pos) {
mStream.seekp(pos);
checkError(mStream);
}
Expand Down

0 comments on commit 2132336

Please sign in to comment.