Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: Checkout repository
uses: actions/checkout@v4
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ubuntu_address_sanitizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: remove openexr
run: sudo apt-get --purge remove libopenexr-dev -y

Expand Down Expand Up @@ -70,6 +73,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: remove openexr
run: sudo apt-get --purge remove libopenexr-dev -y

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/ubuntu_arm_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: install ilmbase
run: sudo apt-get -y install libilmbase-dev

Expand All @@ -52,6 +55,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: remove ilmbase
run: sudo apt-get --purge remove libilmbase-dev -y

Expand Down Expand Up @@ -108,6 +114,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: remove ilmbase
run: sudo apt-get --purge remove libilmbase-dev -y

Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/ubuntu_arm_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: remove ilmbase
run: sudo apt-get --purge remove libilmbase-dev -y

Expand Down Expand Up @@ -102,6 +105,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: remove ilmbase
run: sudo apt-get --purge remove libilmbase-dev -y

Expand Down Expand Up @@ -157,6 +163,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: remove ilmbase
run: sudo apt-get --purge remove libilmbase-dev -y

Expand Down Expand Up @@ -212,6 +221,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: remove ilmbase
run: sudo apt-get --purge remove libilmbase-dev -y

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/ubuntu_debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: install ilmbase
run: sudo apt-get -y install libilmbase-dev

Expand All @@ -52,6 +55,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: remove ilmbase
run: sudo apt-get --purge remove libilmbase-dev -y

Expand Down Expand Up @@ -108,6 +114,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: remove ilmbase
run: sudo apt-get --purge remove libilmbase-dev -y

Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ubuntu_no_libtiff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: remove libtiff
run: sudo apt-get --purge remove libtiff-dev -y

Expand All @@ -52,6 +55,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: remove libtiff-dev
run: sudo apt-get --purge remove libtiff-dev -y

Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/ubuntu_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: install libtiff
run: sudo apt-get -y install libtiff-dev

Expand Down Expand Up @@ -55,6 +58,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: remove ilmbase
run: sudo apt-get --purge remove libilmbase-dev -y

Expand Down Expand Up @@ -98,6 +104,9 @@ jobs:
runs-on: ubuntu-latest

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: remove ilmbase
run: sudo apt-get --purge remove libilmbase-dev -y
Expand Down Expand Up @@ -154,6 +163,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: remove ilmbase
run: sudo apt-get --purge remove libilmbase-dev -y

Expand Down Expand Up @@ -209,6 +221,9 @@ jobs:

steps:

- name: run apt-get update
run: sudo apt-get -y update

- name: remove ilmbase
run: sudo apt-get --purge remove libilmbase-dev -y

Expand Down
87 changes: 66 additions & 21 deletions ctlrender/exr_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@
#include <ImfChannelList.h>
#include <Iex.h>

void exr_read_standard_attributes(Imf::InputFile *file, format_t *format)
{
format->exr_standard_attributes.dataWindow = file->header().dataWindow();
format->exr_standard_attributes.displayWindow = file->header().displayWindow();
format->exr_standard_attributes.pixelAspectRatio = file->header().pixelAspectRatio();
format->exr_standard_attributes.screenWindowCenter = file->header().screenWindowCenter();
format->exr_standard_attributes.screenWindowWidth = file->header().screenWindowWidth();
format->exr_standard_attributes.lineOrder = file->header().lineOrder();
format->exr_standard_attributes.compression = file->header().compression();

format->is_exr_standard_attributes_set = true;
return;
}

bool exr_read(const char *name, float scale, ctl::dpx::fb<float> *pixels,
format_t *format) {
std::ifstream ins;
Expand Down Expand Up @@ -92,7 +106,9 @@ bool exr_read(const char *name, float scale, ctl::dpx::fb<float> *pixels,
//////////////////////////

Imf::InputFile file(name);
Imath::Box2i dw = file.header().dataWindow();
// read the exr standard attributes for potential later use in exr_write()
exr_read_standard_attributes(&file, format);
Imath::Box2i dw = format->exr_standard_attributes.dataWindow;

if (file.header().channels().begin().channel().type == Imf::HALF)
format->src_bps=16;
Expand All @@ -112,30 +128,34 @@ bool exr_read(const char *name, float scale, ctl::dpx::fb<float> *pixels,

Imf::FrameBuffer frameBuffer;
frameBuffer.insert ("R",
Imf::Slice (pixelType,
Imf::Slice::Make (pixelType,
(char *) pixels->ptr(),
dw,
xstride, ystride,
1, 1,
0.0));

frameBuffer.insert ("G",
Imf::Slice (pixelType,
Imf::Slice::Make (pixelType,
(char *) (pixels->ptr()+1),
dw,
xstride, ystride,
1, 1,
0.0));

frameBuffer.insert ("B",
Imf::Slice (pixelType,
Imf::Slice::Make (pixelType,
(char *) (pixels->ptr()+2),
dw,
xstride, ystride,
1, 1,
0.0));

if (has_alpha){
frameBuffer.insert ("A",
Imf::Slice (pixelType,
Imf::Slice::Make (pixelType,
(char *) (pixels->ptr()+3),
dw,
xstride, ystride,
1, 1,
1.0));
Expand Down Expand Up @@ -166,8 +186,8 @@ void exr_write(const char *name, float scale, const ctl::dpx::fb<float> &pixels,
bool is_half = format->bps == 16 ? true : false;

int depth = pixels.depth();
float width = pixels.width();
float height = pixels.height();
int width = pixels.width();
int height = pixels.height();
float const* pixelPtr = pixels.ptr();

// Do any scaling on a full float buffer
Expand All @@ -189,13 +209,33 @@ void exr_write(const char *name, float scale, const ctl::dpx::fb<float> &pixels,
Imf::PixelType pixelType = is_half ? Imf::HALF : Imf::FLOAT;

Imf::Header header(width, height);
header.compression() = (Imf::Compression)compression->exrCompressionScheme;

if (format->is_exr_standard_attributes_set) {
header.dataWindow() = format->exr_standard_attributes.dataWindow;
header.displayWindow() = format->exr_standard_attributes.displayWindow;
header.pixelAspectRatio() = format->exr_standard_attributes.pixelAspectRatio;
header.screenWindowCenter() = format->exr_standard_attributes.screenWindowCenter;
header.screenWindowWidth() = format->exr_standard_attributes.screenWindowWidth;
header.lineOrder() = format->exr_standard_attributes.lineOrder;
if (true == format->is_compression_set) {
// the user specified a specific compression type
header.compression() = (Imf::Compression)compression->exrCompressionScheme;
}
else {
header.compression() = format->exr_standard_attributes.compression;
}
}
else {
header.compression() = (Imf::Compression)compression->exrCompressionScheme;
}
Imath::Box2i dataWindow = header.dataWindow();

header.channels().insert("R", Imf::Channel(pixelType));
header.channels().insert("G", Imf::Channel(pixelType));
header.channels().insert("B", Imf::Channel(pixelType));
if (depth == 4)
header.channels().insert("A", Imf::Channel(pixelType));
if (depth == 4) {
header.channels().insert("A", Imf::Channel(pixelType));
}

Imf::OutputFile file(name, header);
Imf::FrameBuffer frameBuffer;
Expand All @@ -219,27 +259,32 @@ void exr_write(const char *name, float scale, const ctl::dpx::fb<float> &pixels,
int ystride = sizeof(*halfPixelPtr) * depth * width;

// Insert the half buffer into the framebuffer
frameBuffer.insert("R", Imf::Slice(pixelType, (char*)halfPixelPtr, xstride, ystride));
frameBuffer.insert("G", Imf::Slice(pixelType, (char*)(halfPixelPtr + 1), xstride, ystride));
frameBuffer.insert("B", Imf::Slice(pixelType, (char*)(halfPixelPtr + 2), xstride, ystride));
if (depth == 4)
frameBuffer.insert("A", Imf::Slice(pixelType, (char*)(halfPixelPtr + 3), xstride, ystride));
frameBuffer.insert("R", Imf::Slice::Make(pixelType, (char*)(halfPixelPtr + 0), dataWindow, xstride, ystride));
frameBuffer.insert("G", Imf::Slice::Make(pixelType, (char*)(halfPixelPtr + 1), dataWindow, xstride, ystride));
frameBuffer.insert("B", Imf::Slice::Make(pixelType, (char*)(halfPixelPtr + 2), dataWindow, xstride, ystride));
if (depth == 4) {
frameBuffer.insert("A", Imf::Slice::Make(pixelType, (char*)(halfPixelPtr + 3), dataWindow, xstride, ystride));
}

}
else {
// No conversion needed so insert the float buffer into the frambuffer
int xstride = sizeof(*pixelPtr) * depth;
int ystride = sizeof(*pixelPtr) * depth * width;

frameBuffer.insert("R", Imf::Slice(pixelType, (char*)pixelPtr, xstride, ystride));
frameBuffer.insert("G", Imf::Slice(pixelType, (char*)(pixelPtr + 1), xstride, ystride));
frameBuffer.insert("B", Imf::Slice(pixelType, (char*)(pixelPtr + 2), xstride, ystride));
if (depth == 4)
frameBuffer.insert("A", Imf::Slice(pixelType, (char*)(pixelPtr + 3), xstride, ystride));
frameBuffer.insert("R", Imf::Slice::Make(pixelType, (char*)(pixelPtr + 0), dataWindow, xstride, ystride));
frameBuffer.insert("G", Imf::Slice::Make(pixelType, (char*)(pixelPtr + 1), dataWindow, xstride, ystride));
frameBuffer.insert("B", Imf::Slice::Make(pixelType, (char*)(pixelPtr + 2), dataWindow, xstride, ystride));
if (depth == 4) {
frameBuffer.insert("A", Imf::Slice::Make(pixelType, (char*)(pixelPtr + 3), dataWindow, xstride, ystride));
}

}

file.setFrameBuffer(frameBuffer);
file.writePixels(height);
file.writePixels(dataWindow.max.y - dataWindow.min.y + 1);

return;
}

#else
Expand Down
8 changes: 8 additions & 0 deletions ctlrender/format.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,19 @@ format_t::format_t() {
bps=0;
squish=0;
descriptor=0;
is_compression_set = false;
#if defined(HAVE_OPENEXR)
is_exr_standard_attributes_set = false;
#endif
};

format_t::format_t(const char *_ext, uint8_t _bps) {
ext=_ext;
bps=_bps;
squish=0;
descriptor=0;
is_compression_set = false;
#if defined(HAVE_OPENEXR)
is_exr_standard_attributes_set = false;
#endif
};
Loading
Loading