From 734db4eec9aa4b15c3c8f1ff85d6f7a6bc9bd976 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Tue, 9 Jan 2024 00:21:38 -0800 Subject: [PATCH 1/2] dpx: use OIIO functions for byte swapping to make Sonar happy Signed-off-by: Larry Gritz --- src/dpx.imageio/libdpx/EndianSwap.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/dpx.imageio/libdpx/EndianSwap.h b/src/dpx.imageio/libdpx/EndianSwap.h index cb21ebb58c..d3300abbc8 100644 --- a/src/dpx.imageio/libdpx/EndianSwap.h +++ b/src/dpx.imageio/libdpx/EndianSwap.h @@ -36,10 +36,32 @@ #ifndef _DPX_ENDIANSWAP_H #define _DPX_ENDIANSWAP_H 1 +#include + +#define USE_OIIO_BYTESWAP 1 + namespace dpx { +#if USE_OIIO_BYTESWAP + +template +inline T +SwapBytes(T& value) +{ + return value = OIIO::byteswap(value); +} + +template +void +SwapBuffer(T* buf, unsigned int len) +{ + OIIO::byteswap_span(OIIO::span(buf, len)); +} + +#else + template T SwapBytes(T& value) { @@ -92,6 +114,8 @@ void SwapBuffer(T *buf, unsigned int len) SwapBytes(buf[i]); } +#endif + template void EndianSwapImageBuffer(void *data, int length) From 905be88b6bcf7a6cfc2e349555b1f254652a79e8 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Mon, 4 Mar 2024 21:48:09 -0800 Subject: [PATCH 2/2] Explain why we try to keep libdpx as close as possible to the original. Signed-off-by: Larry Gritz --- src/dpx.imageio/dpxinput.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/dpx.imageio/dpxinput.cpp b/src/dpx.imageio/dpxinput.cpp index dd4639f5ed..286d9720a8 100644 --- a/src/dpx.imageio/dpxinput.cpp +++ b/src/dpx.imageio/dpxinput.cpp @@ -10,6 +10,17 @@ // Note: libdpx originally from: https://github.com/PatrickPalmer/dpx // But that seems not to be actively maintained. +// +// Nevertheless, because the contents of the libdpx subdirectory is "imported" +// code, we have always strived to keep our copy as textually close to the +// original as possible, to enable us to diff it against the original and keep +// up with any changes (if there ever are any). So we exclude this file from +// clang-format and try to keep changes as minimal as possible. +// +// At some point, we may want to consider just accepting that we forked long +// ago and are probably the sole maintainers of this code, and just allow +// ourselves to diverge from the original. + #include "libdpx/DPX.h" #include "libdpx/DPXColorConverter.h" #include "libdpx/DPXHeader.h"