diff options
author | Dalai Felinto <dalai@blender.org> | 2020-12-10 13:05:49 +0300 |
---|---|---|
committer | Dalai Felinto <dalai@blender.org> | 2020-12-10 13:05:49 +0300 |
commit | c5a17d5ea1ff786cb91cbcf3f12cd02f730c4143 (patch) | |
tree | f03a5935ee7dbc4c7ddabaee1c06570a26f698f9 /source/blender/imbuf | |
parent | 390c4efa0c15b39e2d1971bc81464cffae56d102 (diff) | |
parent | e795ba1529a28ec276a5178fda2025e5ec071bbf (diff) |
Merge remote-tracking branch 'origin/master' into geometry-nodes
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r-- | source/blender/imbuf/intern/cineon/dpxlib.c | 33 | ||||
-rw-r--r-- | source/blender/imbuf/intern/cineon/dpxlib.h | 5 | ||||
-rw-r--r-- | source/blender/imbuf/intern/dds/BlockDXT.cpp | 4 | ||||
-rw-r--r-- | source/blender/imbuf/intern/dds/ColorBlock.cpp | 16 | ||||
-rw-r--r-- | source/blender/imbuf/intern/dds/DirectDrawSurface.cpp | 6 | ||||
-rw-r--r-- | source/blender/imbuf/intern/dds/FlipDXT.cpp | 4 | ||||
-rw-r--r-- | source/blender/imbuf/intern/dds/Image.cpp | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/dds/Stream.cpp | 4 | ||||
-rw-r--r-- | source/blender/imbuf/intern/dds/dds_api.cpp | 4 | ||||
-rw-r--r-- | source/blender/imbuf/intern/oiio/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/imbuf/intern/oiio/openimageio_api.cpp | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/openexr/openexr_api.cpp | 107 | ||||
-rw-r--r-- | source/blender/imbuf/intern/thumbs_blend.c | 4 |
13 files changed, 92 insertions, 100 deletions
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c index b7a15812547..4580bfd2cbf 100644 --- a/source/blender/imbuf/intern/cineon/dpxlib.c +++ b/source/blender/imbuf/intern/cineon/dpxlib.c @@ -123,16 +123,16 @@ static void fillDpxMainHeader(LogImageFile *dpx, header->televisionHeader.field_number = DPX_UNDEFINED_U8; header->televisionHeader.video_signal = DPX_UNDEFINED_U8; header->televisionHeader.padding = DPX_UNDEFINED_U8; - header->televisionHeader.horizontal_sample_rate = DPX_UNDEFINED_R32; - header->televisionHeader.vertical_sample_rate = DPX_UNDEFINED_R32; - header->televisionHeader.frame_rate = DPX_UNDEFINED_R32; - header->televisionHeader.time_offset = DPX_UNDEFINED_R32; + header->televisionHeader.horizontal_sample_rate = swap_float(DPX_UNDEFINED_R32, dpx->isMSB); + header->televisionHeader.vertical_sample_rate = swap_float(DPX_UNDEFINED_R32, dpx->isMSB); + header->televisionHeader.frame_rate = swap_float(DPX_UNDEFINED_R32, dpx->isMSB); + header->televisionHeader.time_offset = swap_float(DPX_UNDEFINED_R32, dpx->isMSB); header->televisionHeader.gamma = swap_float(dpx->gamma, dpx->isMSB); header->televisionHeader.black_level = swap_float(dpx->referenceBlack, dpx->isMSB); - header->televisionHeader.black_gain = DPX_UNDEFINED_R32; - header->televisionHeader.breakpoint = DPX_UNDEFINED_R32; + header->televisionHeader.black_gain = swap_float(DPX_UNDEFINED_R32, dpx->isMSB); + header->televisionHeader.breakpoint = swap_float(DPX_UNDEFINED_R32, dpx->isMSB); header->televisionHeader.white_level = swap_float(dpx->referenceWhite, dpx->isMSB); - header->televisionHeader.integration_times = DPX_UNDEFINED_R32; + header->televisionHeader.integration_times = swap_float(DPX_UNDEFINED_R32, dpx->isMSB); } LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t bufferSize) @@ -339,13 +339,11 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf dpx->element[i].refHighData = (unsigned int)dpx->element[i].maxValue; } - if (dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 || - isnan(dpx->element[i].refLowQuantity)) { + if (IS_DPX_UNDEFINED_R32(dpx->element[i].refLowQuantity)) { dpx->element[i].refLowQuantity = 0.0f; } - if (dpx->element[i].refHighQuantity == DPX_UNDEFINED_R32 || - isnan(dpx->element[i].refHighQuantity)) { + if (IS_DPX_UNDEFINED_R32(dpx->element[i].refHighQuantity)) { if (ELEM(dpx->element[i].transfer, transfer_PrintingDensity, transfer_Logarithmic)) { dpx->element[i].refHighQuantity = 2.048f; } @@ -370,13 +368,11 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf dpx->element[i].refHighData = 235.0f / 255.0f * dpx->element[i].maxValue; } - if (dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 || - isnan(dpx->element[i].refLowQuantity)) { + if (IS_DPX_UNDEFINED_R32(dpx->element[i].refLowQuantity)) { dpx->element[i].refLowQuantity = 0.0f; } - if (dpx->element[i].refHighQuantity == DPX_UNDEFINED_R32 || - isnan(dpx->element[i].refHighQuantity)) { + if (IS_DPX_UNDEFINED_R32(dpx->element[i].refHighQuantity)) { dpx->element[i].refHighQuantity = 0.7f; } @@ -391,10 +387,9 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf dpx->referenceWhite = swap_float(header.televisionHeader.white_level, dpx->isMSB); dpx->gamma = swap_float(header.televisionHeader.gamma, dpx->isMSB); - if ((dpx->referenceBlack == DPX_UNDEFINED_R32 || isnan(dpx->referenceBlack)) || - (dpx->referenceWhite == DPX_UNDEFINED_R32 || dpx->referenceWhite <= dpx->referenceBlack || - isnan(dpx->referenceWhite)) || - (dpx->gamma == DPX_UNDEFINED_R32 || dpx->gamma <= 0 || isnan(dpx->gamma))) { + if (IS_DPX_UNDEFINED_R32(dpx->referenceBlack) || + (dpx->referenceWhite <= dpx->referenceBlack || IS_DPX_UNDEFINED_R32(dpx->referenceWhite)) || + (dpx->gamma <= 0 || IS_DPX_UNDEFINED_R32(dpx->gamma))) { dpx->referenceBlack = 95.0f / 1023.0f * dpx->element[0].maxValue; dpx->referenceWhite = 685.0f / 1023.0f * dpx->element[0].maxValue; dpx->gamma = 1.7f; diff --git a/source/blender/imbuf/intern/cineon/dpxlib.h b/source/blender/imbuf/intern/cineon/dpxlib.h index 6b729dba59a..1228ac4ee66 100644 --- a/source/blender/imbuf/intern/cineon/dpxlib.h +++ b/source/blender/imbuf/intern/cineon/dpxlib.h @@ -24,6 +24,8 @@ #pragma once +#include <math.h> + #include "logImageCore.h" #ifdef __cplusplus @@ -34,7 +36,8 @@ extern "C" { #define DPX_UNDEFINED_U8 0xFF #define DPX_UNDEFINED_U16 0xFFFF #define DPX_UNDEFINED_U32 0xFFFFFFFF -#define DPX_UNDEFINED_R32 0xFFFFFFFF +#define DPX_UNDEFINED_R32 NAN +#define IS_DPX_UNDEFINED_R32(x) isnan(x) #define DPX_UNDEFINED_CHAR 0 typedef struct { diff --git a/source/blender/imbuf/intern/dds/BlockDXT.cpp b/source/blender/imbuf/intern/dds/BlockDXT.cpp index 2d9c300a147..4e4fca864a0 100644 --- a/source/blender/imbuf/intern/dds/BlockDXT.cpp +++ b/source/blender/imbuf/intern/dds/BlockDXT.cpp @@ -608,8 +608,8 @@ void mem_read(Stream &mem, BlockDXT1 &block) void mem_read(Stream &mem, AlphaBlockDXT3 &block) { - for (unsigned int i = 0; i < 4; i++) { - mem_read(mem, block.row[i]); + for (unsigned short &alpha : block.row) { + mem_read(mem, alpha); } } diff --git a/source/blender/imbuf/intern/dds/ColorBlock.cpp b/source/blender/imbuf/intern/dds/ColorBlock.cpp index 7c8b7c1d345..00fa0111d1c 100644 --- a/source/blender/imbuf/intern/dds/ColorBlock.cpp +++ b/source/blender/imbuf/intern/dds/ColorBlock.cpp @@ -150,12 +150,12 @@ static inline uint8 component(Color32 c, uint i) void ColorBlock::swizzle(uint x, uint y, uint z, uint w) { - for (int i = 0; i < 16; i++) { - Color32 c = m_color[i]; - m_color[i].r = component(c, x); - m_color[i].g = component(c, y); - m_color[i].b = component(c, z); - m_color[i].a = component(c, w); + for (Color32 &color : m_color) { + const Color32 c = color; + color.r = component(c, x); + color.g = component(c, y); + color.b = component(c, z); + color.a = component(c, w); } } @@ -243,8 +243,8 @@ Color32 ColorBlock::averageColor() const /** Return true if the block is not fully opaque. */ bool ColorBlock::hasAlpha() const { - for (uint i = 0; i < 16; i++) { - if (m_color[i].a != 255) { + for (const auto &i : m_color) { + if (i.a != 255) { return true; } } diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp index 37e30d30e2c..2a36946df8f 100644 --- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp +++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp @@ -52,9 +52,9 @@ #include <DirectDrawSurface.h> #include <PixelFormat.h> -#include <math.h> /* sqrt */ -#include <stdio.h> /* printf */ -#include <stdlib.h> /* malloc */ +#include <cmath> /* sqrt */ +#include <cstdio> /* printf */ +#include <cstdlib> /* malloc */ #include <sys/types.h> /*** declarations ***/ diff --git a/source/blender/imbuf/intern/dds/FlipDXT.cpp b/source/blender/imbuf/intern/dds/FlipDXT.cpp index 9b07084bf81..2acf072556a 100644 --- a/source/blender/imbuf/intern/dds/FlipDXT.cpp +++ b/source/blender/imbuf/intern/dds/FlipDXT.cpp @@ -36,7 +36,7 @@ #include "IMB_imbuf_types.h" -#include <string.h> +#include <cstring> #include <BlockDXT.h> #include <ColorBlock.h> @@ -45,7 +45,7 @@ #include <Stream.h> /* A function that flips a DXTC block. */ -typedef void (*FlipBlockFunction)(uint8_t *block); +using FlipBlockFunction = void (*)(uint8_t *block); /* Flips a full DXT1 block in the y direction. */ static void FlipDXT1BlockFull(uint8_t *block) diff --git a/source/blender/imbuf/intern/dds/Image.cpp b/source/blender/imbuf/intern/dds/Image.cpp index 7958a586c7d..9dfa5dd2621 100644 --- a/source/blender/imbuf/intern/dds/Image.cpp +++ b/source/blender/imbuf/intern/dds/Image.cpp @@ -30,7 +30,7 @@ #include <Color.h> #include <Image.h> -#include <stdio.h> /* printf */ +#include <cstdio> /* printf */ Image::Image() : m_width(0), m_height(0), m_format(Format_RGB), m_data(nullptr) { diff --git a/source/blender/imbuf/intern/dds/Stream.cpp b/source/blender/imbuf/intern/dds/Stream.cpp index 59892a0a228..3dab3c35675 100644 --- a/source/blender/imbuf/intern/dds/Stream.cpp +++ b/source/blender/imbuf/intern/dds/Stream.cpp @@ -20,8 +20,8 @@ #include <Stream.h> -#include <stdio.h> /* printf */ -#include <string.h> /* memcpy */ +#include <cstdio> /* printf */ +#include <cstring> /* memcpy */ static const char *msg_error_seek = "DDS: trying to seek beyond end of stream (corrupt file?)"; static const char *msg_error_read = "DDS: trying to read beyond end of stream (corrupt file?)"; diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp index 804d8130b4c..e767cb14b1a 100644 --- a/source/blender/imbuf/intern/dds/dds_api.cpp +++ b/source/blender/imbuf/intern/dds/dds_api.cpp @@ -23,10 +23,10 @@ #include <DirectDrawSurface.h> #include <FlipDXT.h> #include <Stream.h> +#include <cstddef> +#include <cstdio> /* printf */ #include <dds_api.h> #include <fstream> -#include <stddef.h> -#include <stdio.h> /* printf */ #if defined(WIN32) # include "utfconv.h" diff --git a/source/blender/imbuf/intern/oiio/CMakeLists.txt b/source/blender/imbuf/intern/oiio/CMakeLists.txt index 211b6a0b40e..ee5848dec36 100644 --- a/source/blender/imbuf/intern/oiio/CMakeLists.txt +++ b/source/blender/imbuf/intern/oiio/CMakeLists.txt @@ -49,6 +49,7 @@ if(WITH_OPENIMAGEIO) ) list(APPEND LIB ${OPENIMAGEIO_LIBRARIES} + ${PUGIXML_LIBRARIES} ) if(WITH_IMAGE_OPENEXR) list(APPEND INC_SYS diff --git a/source/blender/imbuf/intern/oiio/openimageio_api.cpp b/source/blender/imbuf/intern/oiio/openimageio_api.cpp index 1e8c3c25778..65c25194477 100644 --- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp +++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp @@ -48,7 +48,7 @@ OIIO_NAMESPACE_USING using std::string; using std::unique_ptr; -typedef unsigned char uchar; +using uchar = unsigned char; template<class T, class Q> static void fill_all_channels(T *pixels, int width, int height, int components, Q alpha) diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 56188fbe98a..9726eaeed2c 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -22,14 +22,14 @@ */ #include <algorithm> -#include <errno.h> +#include <cerrno> +#include <cstddef> +#include <cstdio> +#include <cstdlib> #include <fstream> #include <iostream> #include <set> -#include <stddef.h> #include <stdexcept> -#include <stdio.h> -#include <stdlib.h> #include <string> #include <Iex.h> @@ -120,11 +120,11 @@ class IMemStream : public Imf::IStream { _exrbuf = exrbuf; } - virtual ~IMemStream() + ~IMemStream() override { } - virtual bool read(char c[], int n) + bool read(char c[], int n) override { if (n + _exrpos <= _exrsize) { memcpy(c, (void *)(&_exrbuf[_exrpos]), n); @@ -135,17 +135,17 @@ class IMemStream : public Imf::IStream { return false; } - virtual Int64 tellg() + Int64 tellg() override { return _exrpos; } - virtual void seekg(Int64 pos) + void seekg(Int64 pos) override { _exrpos = pos; } - virtual void clear() + void clear() override { } @@ -175,7 +175,7 @@ class IFileStream : public Imf::IStream { } } - virtual bool read(char c[], int n) + bool read(char c[], int n) override { if (!ifs) { throw Iex::InputExc("Unexpected end of file."); @@ -186,18 +186,18 @@ class IFileStream : public Imf::IStream { return check_error(); } - virtual Int64 tellg() + Int64 tellg() override { return std::streamoff(ifs.tellg()); } - virtual void seekg(Int64 pos) + void seekg(Int64 pos) override { ifs.seekg(pos); check_error(); } - virtual void clear() + void clear() override { ifs.clear(); } @@ -227,7 +227,7 @@ class OMemStream : public OStream { { } - virtual void write(const char c[], int n) + void write(const char c[], int n) override { ensure_size(offset + n); memcpy(ibuf->encodedbuffer + offset, c, n); @@ -235,12 +235,12 @@ class OMemStream : public OStream { ibuf->encodedsize += n; } - virtual Int64 tellp() + Int64 tellp() override { return offset; } - virtual void seekp(Int64 pos) + void seekp(Int64 pos) override { offset = pos; ensure_size(offset); @@ -281,19 +281,19 @@ class OFileStream : public OStream { } } - virtual void write(const char c[], int n) + void write(const char c[], int n) override { errno = 0; ofs.write(c, n); check_error(); } - virtual Int64 tellp() + Int64 tellp() override { return std::streamoff(ofs.tellp()); } - virtual void seekp(Int64 pos) + void seekp(Int64 pos) override { ofs.seekp(pos); check_error(); @@ -322,7 +322,7 @@ struct _RGBAZ { half z; }; -typedef struct _RGBAZ RGBAZ; +using RGBAZ = _RGBAZ; extern "C" { @@ -620,7 +620,7 @@ bool imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags) static ListBase exrhandles = {nullptr, nullptr}; -typedef struct ExrHandle { +struct ExrHandle { struct ExrHandle *next, *prev; char name[FILE_MAX]; @@ -645,10 +645,10 @@ typedef struct ExrHandle { ListBase layers; /* hierarchical, pointing in end to ExrChannel */ int num_half_channels; /* used during filr save, allows faster temporary buffers allocation */ -} ExrHandle; +}; /* flattened out channel */ -typedef struct ExrChannel { +struct ExrChannel { struct ExrChannel *next, *prev; char name[EXR_TOT_MAXNAME + 1]; /* full name with everything */ @@ -658,10 +658,10 @@ typedef struct ExrChannel { char chan_id; /* quick lookup of channel char */ int view_id; /* quick lookup of channel view */ bool use_half_float; /* when saving use half float for file storage */ -} ExrChannel; +}; /* hierarchical; layers -> passes -> channels[] */ -typedef struct ExrPass { +struct ExrPass { struct ExrPass *next, *prev; char name[EXR_PASS_MAXNAME]; int totchan; @@ -672,13 +672,13 @@ typedef struct ExrPass { char internal_name[EXR_PASS_MAXNAME]; /* name with no view */ char view[EXR_VIEW_MAXNAME]; int view_id; -} ExrPass; +}; -typedef struct ExrLayer { +struct ExrLayer { struct ExrLayer *next, *prev; char name[EXR_LAY_MAXNAME + 1]; ListBase passes; -} ExrLayer; +}; /* ********************** */ @@ -733,8 +733,8 @@ static void imb_exr_get_views(MultiPartInputFile &file, StringVector &views) if (exr_has_multipart_file(file) == false) { if (exr_has_multiview(file)) { StringVector sv = multiView(file.header(0)); - for (StringVector::const_iterator i = sv.begin(); i != sv.end(); ++i) { - views.push_back(*i); + for (const std::string &view_name : sv) { + views.push_back(view_name); } } } @@ -991,21 +991,15 @@ int IMB_exr_begin_read(void *handle, const char *filename, int *width, int *heig std::vector<MultiViewChannelName> channels; GetChannelsInMultiPartFile(*data->ifile, channels); - for (size_t i = 0; i < channels.size(); i++) { - IMB_exr_add_channel(data, - nullptr, - channels[i].name.c_str(), - channels[i].view.c_str(), - 0, - 0, - nullptr, - false); + for (const MultiViewChannelName &channel : channels) { + IMB_exr_add_channel( + data, nullptr, channel.name.c_str(), channel.view.c_str(), 0, 0, nullptr, false); echan = (ExrChannel *)data->channels.last; - echan->m->name = channels[i].name; - echan->m->view = channels[i].view; - echan->m->part_number = channels[i].part_number; - echan->m->internal_name = channels[i].internal_name; + echan->m->name = channel.name; + echan->m->view = channel.view; + echan->m->part_number = channel.part_number; + echan->m->internal_name = channel.internal_name; } return 1; @@ -1311,9 +1305,8 @@ void IMB_exr_multilayer_convert(void *handle, } else { /* add views to RenderResult */ - for (StringVector::const_iterator i = data->multiView->begin(); i != data->multiView->end(); - ++i) { - addview(base, (*i).c_str()); + for (const std::string &view_name : *data->multiView) { + addview(base, view_name.c_str()); } } @@ -1554,15 +1547,15 @@ static ExrHandle *imb_exr_begin_read_mem(IStream &file_stream, imb_exr_get_views(*data->ifile, *data->multiView); - for (size_t i = 0; i < channels.size(); i++) { + for (const MultiViewChannelName &channel : channels) { IMB_exr_add_channel( - data, nullptr, channels[i].name.c_str(), channels[i].view.c_str(), 0, 0, nullptr, false); + data, nullptr, channel.name.c_str(), channel.view.c_str(), 0, 0, nullptr, false); echan = (ExrChannel *)data->channels.last; - echan->m->name = channels[i].name; - echan->m->view = channels[i].view; - echan->m->part_number = channels[i].part_number; - echan->m->internal_name = channels[i].internal_name; + echan->m->name = channel.name; + echan->m->view = channel.view; + echan->m->part_number = channel.part_number; + echan->m->internal_name = channel.internal_name; } /* now try to sort out how to assign memory to the channels */ @@ -1689,8 +1682,8 @@ static void exr_print_filecontents(MultiPartInputFile &file) const StringVector views = multiView(file.header(0)); printf("OpenEXR-load: MultiView file\n"); printf("OpenEXR-load: Default view: %s\n", defaultViewName(views).c_str()); - for (StringVector::const_iterator i = views.begin(); i != views.end(); ++i) { - printf("OpenEXR-load: Found view %s\n", (*i).c_str()); + for (const std::string &view : views) { + printf("OpenEXR-load: Found view %s\n", view.c_str()); } } else if (numparts > 1) { @@ -1835,10 +1828,10 @@ static void imb_exr_type_by_channels(ChannelList &channels, * with non-empty ones in the file. */ for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); i++) { - for (std::set<string>::iterator i = layerNames.begin(); i != layerNames.end(); i++) { + for (const std::string &layer_name : layerNames) { /* see if any layername differs from a viewname */ - if (imb_exr_get_multiView_id(views, *i) == -1) { - std::string layerName = *i; + if (imb_exr_get_multiView_id(views, layer_name) == -1) { + std::string layerName = layer_name; size_t pos = layerName.rfind('.'); if (pos == std::string::npos) { diff --git a/source/blender/imbuf/intern/thumbs_blend.c b/source/blender/imbuf/intern/thumbs_blend.c index 1d0964ebb62..d5ded02be62 100644 --- a/source/blender/imbuf/intern/thumbs_blend.c +++ b/source/blender/imbuf/intern/thumbs_blend.c @@ -68,7 +68,7 @@ ImBuf *IMB_thumb_load_blend(const char *blen_path, const char *blen_group, const printf("%s: error, found %d items, %d previews\n", __func__, nnames, nprevs); } BLI_linklist_free(previews, BKE_previewimg_freefunc); - BLI_linklist_free(names, free); + BLI_linklist_freeN(names); return ima; } @@ -93,7 +93,7 @@ ImBuf *IMB_thumb_load_blend(const char *blen_path, const char *blen_group, const } BLI_linklist_free(previews, BKE_previewimg_freefunc); - BLI_linklist_free(names, free); + BLI_linklist_freeN(names); } else { BlendThumbnail *data; |