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:
Diffstat (limited to 'source/blender/imbuf/intern/cineon/dpxlib.c')
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.c93
1 files changed, 66 insertions, 27 deletions
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c
index b769d1e6132..8a9adc73cdc 100644
--- a/source/blender/imbuf/intern/cineon/dpxlib.c
+++ b/source/blender/imbuf/intern/cineon/dpxlib.c
@@ -58,15 +58,15 @@ fillDpxChannelInfo(DpxFile* dpx, DpxChannelInformation* chan, int des) {
static void
dumpDpxChannelInfo(DpxChannelInformation* chan) {
- d_printf(" Signage %ld", (long)ntohl(chan->signage));
- d_printf(" Ref low data %ld\n", (long)ntohl(chan->ref_low_data));
+ d_printf(" Signage %ld", (intptr_t)ntohl(chan->signage));
+ d_printf(" Ref low data %ld\n", (intptr_t)ntohl(chan->ref_low_data));
d_printf(" Ref low quantity %f\n", ntohf(chan->ref_low_quantity));
- d_printf(" Ref high data %ld\n", (long)ntohl(chan->ref_high_data));
+ d_printf(" Ref high data %ld\n", (intptr_t)ntohl(chan->ref_high_data));
d_printf(" Ref high quantity %f\n", ntohf(chan->ref_high_quantity));
d_printf(" Designator1: %d,", chan->designator1);
d_printf(" Bits per pixel %d\n", chan->bits_per_pixel);
d_printf(" Packing: %d,", ntohs(chan->packing));
- d_printf(" Data Offset: %ld,", (long)ntohl(chan->data_offset));
+ d_printf(" Data Offset: %ld,", (intptr_t)ntohl(chan->data_offset));
}
static void
@@ -110,19 +110,19 @@ static void
dumpDpxFileInfo(DpxFileInformation* fileInfo) {
d_printf("\n--File Information--\n");
d_printf("Magic: %8.8lX\n", (unsigned long)ntohl(fileInfo->magic_num));
- d_printf("Image Offset %ld\n", (long)ntohl(fileInfo->offset));
+ d_printf("Image Offset %ld\n", (intptr_t)ntohl(fileInfo->offset));
d_printf("Version \"%s\"\n", fileInfo->vers);
- d_printf("File size %ld\n", (long)ntohl(fileInfo->file_size));
- d_printf("Ditto key %ld\n", (long)ntohl(fileInfo->ditto_key));
- d_printf("Generic Header size %ld\n", (long)ntohl(fileInfo->gen_hdr_size));
- d_printf("Industry Header size %ld\n", (long)ntohl(fileInfo->ind_hdr_size));
- d_printf("User Data size %ld\n", (long)ntohl(fileInfo->user_data_size));
+ d_printf("File size %ld\n", (intptr_t)ntohl(fileInfo->file_size));
+ d_printf("Ditto key %ld\n", (intptr_t)ntohl(fileInfo->ditto_key));
+ d_printf("Generic Header size %ld\n", (intptr_t)ntohl(fileInfo->gen_hdr_size));
+ d_printf("Industry Header size %ld\n", (intptr_t)ntohl(fileInfo->ind_hdr_size));
+ d_printf("User Data size %ld\n", (intptr_t)ntohl(fileInfo->user_data_size));
d_printf("File name \"%s\"\n", fileInfo->file_name);
d_printf("Creation date \"%s\"\n", fileInfo->create_date);
d_printf("Creator \"%s\"\n", fileInfo->creator);
d_printf("Project \"%s\"\n", fileInfo->project);
d_printf("Copyright \"%s\"\n", fileInfo->copyright);
- d_printf("Key %ld\n", (long)ntohl(fileInfo->key));
+ d_printf("Key %ld\n", (intptr_t)ntohl(fileInfo->key));
}
static void
@@ -150,8 +150,8 @@ dumpDpxImageInfo(DpxImageInformation* imageInfo) {
d_printf("Image orientation %d,", ntohs(imageInfo->orientation));
n = ntohs(imageInfo->channels_per_image);
d_printf("Channels %d\n", n);
- d_printf("Pixels per line %ld\n", (long)ntohl(imageInfo->pixels_per_line));
- d_printf("Lines per image %ld\n", (long)ntohl(imageInfo->lines_per_image));
+ d_printf("Pixels per line %ld\n", (intptr_t)ntohl(imageInfo->pixels_per_line));
+ d_printf("Lines per image %ld\n", (intptr_t)ntohl(imageInfo->lines_per_image));
for (i = 0; i < n; ++i) {
d_printf(" --Channel %d--\n", i);
dumpDpxChannelInfo(&imageInfo->channel[i]);
@@ -166,12 +166,12 @@ fillDpxOriginationInfo(
static void
dumpDpxOriginationInfo(DpxOriginationInformation* originInfo) {
d_printf("\n--Origination Information--\n");
- d_printf("X offset %ld\n", (long)ntohl(originInfo->x_offset));
- d_printf("Y offset %ld\n", (long)ntohl(originInfo->y_offset));
+ d_printf("X offset %ld\n", (intptr_t)ntohl(originInfo->x_offset));
+ d_printf("Y offset %ld\n", (intptr_t)ntohl(originInfo->y_offset));
d_printf("X centre %f\n", ntohf(originInfo->x_centre));
d_printf("Y centre %f\n", ntohf(originInfo->y_centre));
- d_printf("Original X %ld\n", (long)ntohl(originInfo->x_original_size));
- d_printf("Original Y %ld\n", (long)ntohl(originInfo->y_original_size));
+ d_printf("Original X %ld\n", (intptr_t)ntohl(originInfo->x_original_size));
+ d_printf("Original Y %ld\n", (intptr_t)ntohl(originInfo->y_original_size));
d_printf("File name \"%s\"\n", originInfo->file_name);
d_printf("Creation time \"%s\"\n", originInfo->creation_time);
d_printf("Input device \"%s\"\n", originInfo->input_device);
@@ -275,8 +275,10 @@ dpxGetRowBytes(DpxFile* dpx, unsigned short* row, int y) {
/* extract required pixels */
for (pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) {
- /* row[pixelIndex] = dpx->lut10[dpx->pixelBuffer[pixelIndex]]; */
- row[pixelIndex] = dpx->pixelBuffer[pixelIndex] << 6;
+ if(dpx->params.doLogarithm)
+ row[pixelIndex] = dpx->lut10_16[dpx->pixelBuffer[pixelIndex]];
+ else
+ row[pixelIndex] = dpx->pixelBuffer[pixelIndex] << 6;
}
/* save remaining pixels */
@@ -316,8 +318,10 @@ dpxSetRowBytes(DpxFile* dpx, const unsigned short* row, int y) {
/* put new pixels into pixelBuffer */
for (pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) {
- /* dpx->pixelBuffer[dpx->pixelBufferUsed + pixelIndex] = dpx->lut8[row[pixelIndex]]; */
- dpx->pixelBuffer[dpx->pixelBufferUsed + pixelIndex] = row[pixelIndex] >> 6;
+ if(dpx->params.doLogarithm)
+ dpx->pixelBuffer[dpx->pixelBufferUsed + pixelIndex] = dpx->lut16_16[row[pixelIndex]];
+ else
+ dpx->pixelBuffer[dpx->pixelBufferUsed + pixelIndex] = row[pixelIndex] >> 6;
}
dpx->pixelBufferUsed += numPixels;
@@ -413,7 +417,7 @@ intern_dpxOpen(int mode, const char* bytestuff, int bufsize) {
/* let's assume dpx files are always network order */
if (header.fileInfo.magic_num != ntohl(DPX_FILE_MAGIC)) {
if (verbose) d_printf("Bad magic number %8.8lX in \"%s\".\n",
- (unsigned long)ntohl(header.fileInfo.magic_num), filename);
+ (uintptr_t)ntohl(header.fileInfo.magic_num), filename);
dpxClose(dpx);
return 0;
}
@@ -437,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) {
@@ -467,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;
@@ -559,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");
@@ -566,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;