Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-03-15 13:46:37 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-03-15 13:46:37 +0400
commit1ea16dcf9b5337a7f8983a09d7f92b6164a7670f (patch)
tree1e22b1bad4d657cb9d315ed51332b9366eb318b5 /source/blender/imbuf/intern/cineon/dpxlib.c
parent42660a204a553b331a7d99d4f49987c46707fa2c (diff)
Patch #34632: DPX/Cineon speed up
Done by Julien Enche (aka trap), thanks! From the patch comment: This patch speeds up Cineon/DPX file loading. Some more checks are done in dpxOpen and cineonOpen functions so IB_test flag can now be taken into account safely, and an unnecessary call to IMB_rect_from_float has been removed. DPX/Cineon file now loads around 3 times faster on my computer. Own comment: Ideally, IB_rect shall indeed indicate which buffers to load, however currently all places which reads image uses this flag. This fact already mentioned in OpenEXR reader and it shall be fine to skip doing rect_from_float in readers themselves.
Diffstat (limited to 'source/blender/imbuf/intern/cineon/dpxlib.c')
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c
index aeebf46a632..10c90b1b891 100644
--- a/source/blender/imbuf/intern/cineon/dpxlib.c
+++ b/source/blender/imbuf/intern/cineon/dpxlib.c
@@ -192,8 +192,21 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
dpx->srcFormat = format_DPX;
dpx->numElements = swap_ushort(header.imageHeader.elements_per_image, dpx->isMSB);
+ if (dpx->numElements == 0) {
+ if (verbose) printf("DPX: Wrong number of elements: %d\n", dpx->numElements);
+ logImageClose(dpx);
+ return 0;
+ }
+
dpx->width = swap_uint(header.imageHeader.pixels_per_line, dpx->isMSB);
dpx->height = swap_uint(header.imageHeader.lines_per_element, dpx->isMSB);
+
+ if (dpx->width == 0 || dpx->height == 0) {
+ if (verbose) printf("DPX: Wrong image dimension: %dx%d\n", dpx->width, dpx->height);
+ logImageClose(dpx);
+ return 0;
+ }
+
dpx->depth = 0;
for (i = 0; i < dpx->numElements; i++) {
@@ -242,8 +255,23 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
}
dpx->element[i].bitsPerSample = header.imageHeader.element[i].bits_per_sample;
+ if (dpx->element[i].bitsPerSample != 1 && dpx->element[i].bitsPerSample != 8 &&
+ dpx->element[i].bitsPerSample != 10 && dpx->element[i].bitsPerSample != 12 &&
+ dpx->element[i].bitsPerSample != 16)
+ {
+ if (verbose) printf("DPX: Unsupported bitsPerSample for elements %d: %d\n", i, dpx->element[i].bitsPerSample);
+ logImageClose(dpx);
+ return 0;
+ }
+
dpx->element[i].maxValue = powf(2, dpx->element[i].bitsPerSample) - 1.0f;
+
dpx->element[i].packing = swap_ushort(header.imageHeader.element[i].packing, dpx->isMSB);
+ if (dpx->element[i].packing > 2) {
+ if (verbose) printf("DPX: Unsupported packing for element %d: %d\n", i, dpx->element[i].packing);
+ logImageClose(dpx);
+ return 0;
+ }
/* Sometimes, the offset is not set correctly in the header */
dpx->element[i].dataOffset = swap_uint(header.imageHeader.element[i].data_offset, dpx->isMSB);
@@ -323,7 +351,6 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
(dpx->referenceWhite == DPX_UNDEFINED_R32 || dpx->referenceWhite <= dpx->referenceBlack || isnan(dpx->referenceWhite)) ||
(dpx->gamma == DPX_UNDEFINED_R32 || dpx->gamma <= 0 || isnan(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;