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:
authorDiego Borghetti <bdiego@gmail.com>2008-06-16 11:15:09 +0400
committerDiego Borghetti <bdiego@gmail.com>2008-06-16 11:15:09 +0400
commitf445dfbfb6113c0465491a5e1c275e81b602cc58 (patch)
treef73ce9b501bcf1b789aea2b1107022aa4dd1edd9 /source/blender/imbuf/intern/cineon/dpxlib.c
parentad023e108a59331a454a8c4fb2cea99500b49528 (diff)
Patch [#13777]
This commit fix the following problem in the DPX code: 1) The code always assume a depth of 10 bits 2) The code don't check the file type (Log or Linear)
Diffstat (limited to 'source/blender/imbuf/intern/cineon/dpxlib.c')
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.c45
1 files changed, 40 insertions, 5 deletions
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c
index a81e632a797..500c09ba265 100644
--- a/source/blender/imbuf/intern/cineon/dpxlib.c
+++ b/source/blender/imbuf/intern/cineon/dpxlib.c
@@ -441,10 +441,15 @@ intern_dpxOpen(int mode, const char* bytestuff, int bufsize) {
default: break;
}
}
- dpx->bitsPerPixel = 10;
- /* dpx->bitsPerPixel = header.imageInfo.channel[0].bits_per_pixel; */
- dpx->imageOffset = ntohl(header.fileInfo.offset);
+ /* dpx->bitsPerPixel = 10; */
+ dpx->bitsPerPixel = header.imageInfo.channel[0].bits_per_pixel;
+ if (dpx->bitsPerPixel != 10) {
+ if (verbose) d_printf("Don't support depth: %d\n", dpx->bitsPerPixel);
+ dpxClose(dpx);
+ return 0;
+ }
+ dpx->imageOffset = ntohl(header.fileInfo.offset);
dpx->lineBufferLength = pixelsToLongs(dpx->width * dpx->depth);
dpx->lineBuffer = malloc(dpx->lineBufferLength * 4);
if (dpx->lineBuffer == 0) {
@@ -471,6 +476,26 @@ intern_dpxOpen(int mode, const char* bytestuff, int bufsize) {
dpx->fileYPos = 0;
logImageGetByteConversionDefaults(&dpx->params);
+ /* The SMPTE define this code:
+ * 2 - Linear
+ * 3 - Logarithmic
+ *
+ * Note that transfer_characteristics is U8, don't need
+ * check the byte order.
+ */
+ switch (header.imageInfo.channel[0].transfer_characteristics) {
+ case 2:
+ dpx->params.doLogarithm= 0;
+ break;
+ case 3:
+ dpx->params.doLogarithm= 1;
+ break;
+ default:
+ if (verbose) d_printf("Un-supported Transfer Characteristics: %d\n", header.imageInfo.channel[0].transfer_characteristics);
+ dpxClose(dpx);
+ return 0;
+ break;
+ }
setupLut(dpx);
dpx->getRow = &dpxGetRowBytes;
@@ -563,6 +588,18 @@ dpxCreate(const char* filename, int width, int height, int depth) {
++shortFilename;
}
initDpxMainHeader(dpx, &header, shortFilename);
+ logImageGetByteConversionDefaults(&dpx->params);
+ /* Need set the file type before write the header!
+ * 2 - Linear
+ * 3 - Logarithmic
+ *
+ * Note that transfer characteristics is U8, don't need
+ * check the byte order.
+ */
+ if (dpx->params.doLogarithm == 0)
+ header.imageInfo.channel[0].transfer_characteristics= 2;
+ else
+ header.imageInfo.channel[0].transfer_characteristics= 3;
if (fwrite(&header, sizeof(header), 1, dpx->file) == 0) {
if (verbose) d_printf("Couldn't write image header\n");
@@ -570,8 +607,6 @@ dpxCreate(const char* filename, int width, int height, int depth) {
return 0;
}
dpx->fileYPos = 0;
-
- logImageGetByteConversionDefaults(&dpx->params);
setupLut(dpx);
dpx->getRow = 0;