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:
authorCampbell Barton <ideasman42@gmail.com>2013-03-22 09:34:10 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-03-22 09:34:10 +0400
commita79e10157dc7a1c8a102bf88f236d325ecdd8d80 (patch)
tree2026c37ec8c7da9094bbb20d3aedcdd82d565765 /source/blender/imbuf/intern/cineon
parentdd0e2da7847d31cbaf02c665e2c55b5e8c384ed4 (diff)
code cleanup: use NULL rather then 0 for pointers, and make vars static where possible.
also found unintentionally defined enum/struct variables that where only meant to be defining the type.
Diffstat (limited to 'source/blender/imbuf/intern/cineon')
-rw-r--r--source/blender/imbuf/intern/cineon/cineon_dpx.c22
-rw-r--r--source/blender/imbuf/intern/cineon/cineonlib.c44
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.c50
-rw-r--r--source/blender/imbuf/intern/cineon/logImageCore.c40
4 files changed, 78 insertions, 78 deletions
diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c
index 48bda418d82..255af7dc039 100644
--- a/source/blender/imbuf/intern/cineon/cineon_dpx.c
+++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c
@@ -63,24 +63,24 @@ static struct ImBuf *imb_load_dpx_cineon(unsigned char *mem, size_t size, int us
image = logImageOpenFromMemory(mem, size);
- if (image == 0) {
+ if (image == NULL) {
printf("DPX/Cineon: error opening image.\n");
- return 0;
+ return NULL;
}
logImageGetSize(image, &width, &height, &depth);
ibuf = IMB_allocImBuf(width, height, 32, IB_rectfloat | flags);
- if (ibuf == 0) {
+ if (ibuf == NULL) {
logImageClose(image);
- return 0;
+ return NULL;
}
if (!(flags & IB_test)) {
if (logImageGetDataRGBA(image, ibuf->rect_float, 1) != 0) {
logImageClose(image);
IMB_freeImBuf(ibuf);
- return 0;
+ return NULL;
}
IMB_flipy(ibuf);
}
@@ -127,12 +127,12 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon
logImage = logImageCreate(filename, use_cineon, ibuf->x, ibuf->y, bitspersample, (depth == 4),
(ibuf->ftype & CINEON_LOG), -1, -1, -1, "Blender");
- if (logImage == 0) {
+ if (logImage == NULL) {
printf("DPX/Cineon: error creating file.\n");
return 0;
}
- if (ibuf->rect_float != 0 && bitspersample != 8) {
+ if (ibuf->rect_float != NULL && bitspersample != 8) {
/* don't use the float buffer to save 8 bpp picture to prevent color banding
* (there's no dithering algorithm behing the logImageSetDataRGBA function) */
@@ -150,11 +150,11 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon
MEM_freeN(fbuf);
}
else {
- if (ibuf->rect == 0)
+ if (ibuf->rect == NULL)
IMB_rect_from_float(ibuf);
fbuf = (float *)MEM_mallocN(ibuf->x * ibuf->y * 4 * sizeof(float), "fbuf in imb_save_dpx_cineon");
- if (fbuf == 0) {
+ if (fbuf == NULL) {
printf("DPX/Cineon: error allocating memory.\n");
logImageClose(logImage);
return 0;
@@ -191,7 +191,7 @@ ImBuf *imb_load_cineon(unsigned char *mem, size_t size, int flags, char colorspa
{
if (imb_is_cineon(mem))
return imb_load_dpx_cineon(mem, size, 1, flags, colorspace);
- return 0;
+ return NULL;
}
int imb_save_dpx(struct ImBuf *buf, const char *myfile, int flags)
@@ -208,5 +208,5 @@ ImBuf *imb_load_dpx(unsigned char *mem, size_t size, int flags, char colorspace[
{
if (imb_is_dpx(mem))
return imb_load_dpx_cineon(mem, size, 0, flags, colorspace);
- return 0;
+ return NULL;
}
diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c
index 4b9ca1dd539..1481b2aaa66 100644
--- a/source/blender/imbuf/intern/cineon/cineonlib.c
+++ b/source/blender/imbuf/intern/cineon/cineonlib.c
@@ -75,7 +75,7 @@ static void fillCineonMainHeader(LogImageFile *cineon, CineonMainHeader *header,
strcpy(header->fileHeader.version, "v4.5");
strncpy(header->fileHeader.file_name, filename, 99);
header->fileHeader.file_name[99] = 0;
- fileClock = time(0);
+ fileClock = time(NULL);
fileTime = localtime(&fileClock);
strftime(header->fileHeader.creation_date, 12, "%Y:%m:%d", fileTime);
strftime(header->fileHeader.creation_time, 12, "%H:%M:%S%Z", fileTime);
@@ -142,28 +142,28 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
int i;
unsigned int dataOffset;
- if (cineon == 0) {
+ if (cineon == NULL) {
if (verbose) printf("Cineon: Failed to malloc cineon file structure.\n");
- return 0;
+ return NULL;
}
/* zero the header */
memset(&header, 0, sizeof(CineonMainHeader));
/* for close routine */
- cineon->file = 0;
+ cineon->file = NULL;
if (fromMemory == 0) {
/* byteStuff is then the filename */
cineon->file = BLI_fopen(filename, "rb");
- if (cineon->file == 0) {
+ if (cineon->file == NULL) {
if (verbose) printf("Cineon: Failed to open file \"%s\".\n", filename);
logImageClose(cineon);
- return 0;
+ return NULL;
}
/* not used in this case */
- cineon->memBuffer = 0;
- cineon->memCursor = 0;
+ cineon->memBuffer = NULL;
+ cineon->memCursor = NULL;
cineon->memBufferSize = 0;
}
else {
@@ -175,7 +175,7 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
if (logimage_fread(&header, sizeof(header), 1, cineon) == 0) {
if (verbose) printf("Cineon: Not enough data for header in \"%s\".\n", byteStuff);
logImageClose(cineon);
- return 0;
+ return NULL;
}
/* endianness determination */
@@ -191,7 +191,7 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
if (verbose) printf("Cineon: Bad magic number %lu in \"%s\".\n",
(unsigned long)header.fileHeader.magic_num, byteStuff);
logImageClose(cineon);
- return 0;
+ return NULL;
}
cineon->width = swap_uint(header.imageHeader.element[0].pixels_per_line, cineon->isMSB);
@@ -200,7 +200,7 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
if (cineon->width == 0 || cineon->height == 0) {
if (verbose) printf("Cineon: Wrong image dimension: %dx%d\n", cineon->width, cineon->height);
logImageClose(cineon);
- return 0;
+ return NULL;
}
cineon->depth = header.imageHeader.elements_per_image;
@@ -213,7 +213,7 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
else {
if (verbose) printf("Cineon: Data interleave not supported: %d\n", header.imageHeader.interleave);
logImageClose(cineon);
- return 0;
+ return NULL;
}
if (cineon->depth == 1) {
@@ -244,7 +244,7 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
else {
if (verbose) printf("Cineon: Cineon image depth unsupported: %d\n", cineon->depth);
logImageClose(cineon);
- return 0;
+ return NULL;
}
dataOffset = swap_uint(header.fileHeader.offset, cineon->isMSB);
@@ -274,7 +274,7 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
/* Not supported */
if (verbose) printf("Cineon: packing unsupported: %d\n", header.imageHeader.packing);
logImageClose(cineon);
- return 0;
+ return NULL;
}
if (cineon->element[i].refLowData == CINEON_UNDEFINED_U32 || isnan(cineon->element[i].refLowData))
@@ -329,20 +329,20 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
LogImageFile *cineonCreate(const char *filename, int width, int height, int bitsPerSample, const char *creator)
{
CineonMainHeader header;
- const char *shortFilename = 0;
+ const char *shortFilename = NULL;
/* unsigned char pad[6044]; */
LogImageFile *cineon = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
- if (cineon == 0) {
+ if (cineon == NULL) {
if (verbose) printf("cineon: Failed to malloc cineon file structure.\n");
- return 0;
+ return NULL;
}
/* Only 10 bits Cineon are supported */
if (bitsPerSample != 10) {
if (verbose) printf("cineon: Only 10 bits Cineon are supported.\n");
logImageClose(cineon);
- return 0;
+ return NULL;
}
cineon->width = width;
@@ -366,16 +366,16 @@ LogImageFile *cineonCreate(const char *filename, int width, int height, int bits
cineon->gamma = 1.7f;
shortFilename = strrchr(filename, '/');
- if (shortFilename == 0)
+ if (shortFilename == NULL)
shortFilename = filename;
else
shortFilename++;
cineon->file = BLI_fopen(filename, "wb");
- if (cineon->file == 0) {
+ if (cineon->file == NULL) {
if (verbose) printf("cineon: Couldn't open file %s\n", filename);
logImageClose(cineon);
- return 0;
+ return NULL;
}
fillCineonMainHeader(cineon, &header, shortFilename, creator);
@@ -383,7 +383,7 @@ LogImageFile *cineonCreate(const char *filename, int width, int height, int bits
if (fwrite(&header, sizeof(header), 1, cineon->file) == 0) {
if (verbose) printf("cineon: Couldn't write image header\n");
logImageClose(cineon);
- return 0;
+ return NULL;
}
return cineon;
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c
index 10c90b1b891..5a4371d84ba 100644
--- a/source/blender/imbuf/intern/cineon/dpxlib.c
+++ b/source/blender/imbuf/intern/cineon/dpxlib.c
@@ -76,7 +76,7 @@ static void fillDpxMainHeader(LogImageFile *dpx, DpxMainHeader *header, const ch
header->fileHeader.user_data_size = DPX_UNDEFINED_U32;
strncpy(header->fileHeader.file_name, filename, 99);
header->fileHeader.file_name[99] = 0;
- fileClock = time(0);
+ fileClock = time(NULL);
fileTime = localtime(&fileClock);
strftime(header->fileHeader.creation_date, 24, "%Y:%m:%d:%H:%M:%S%Z", fileTime);
header->fileHeader.creation_date[23] = 0;
@@ -138,28 +138,28 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
char *filename = (char *)byteStuff;
int i;
- if (dpx == 0) {
+ if (dpx == NULL) {
if (verbose) printf("DPX: Failed to malloc dpx file structure.\n");
- return 0;
+ return NULL;
}
/* zero the header */
memset(&header, 0, sizeof(DpxMainHeader));
/* for close routine */
- dpx->file = 0;
+ dpx->file = NULL;
if (fromMemory == 0) {
/* byteStuff is then the filename */
dpx->file = BLI_fopen(filename, "rb");
- if (dpx->file == 0) {
+ if (dpx->file == NULL) {
if (verbose) printf("DPX: Failed to open file \"%s\".\n", filename);
logImageClose(dpx);
- return 0;
+ return NULL;
}
/* not used in this case */
- dpx->memBuffer = 0;
- dpx->memCursor = 0;
+ dpx->memBuffer = NULL;
+ dpx->memCursor = NULL;
dpx->memBufferSize = 0;
}
else {
@@ -171,7 +171,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
if (logimage_fread(&header, sizeof(header), 1, dpx) == 0) {
if (verbose) printf("DPX: Not enough data for header in \"%s\".\n", byteStuff);
logImageClose(dpx);
- return 0;
+ return NULL;
}
/* endianness determination */
@@ -187,7 +187,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
if (verbose) printf("DPX: Bad magic number %lu in \"%s\".\n",
(uintptr_t)header.fileHeader.magic_num, byteStuff);
logImageClose(dpx);
- return 0;
+ return NULL;
}
dpx->srcFormat = format_DPX;
@@ -195,7 +195,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
if (dpx->numElements == 0) {
if (verbose) printf("DPX: Wrong number of elements: %d\n", dpx->numElements);
logImageClose(dpx);
- return 0;
+ return NULL;
}
dpx->width = swap_uint(header.imageHeader.pixels_per_line, dpx->isMSB);
@@ -204,7 +204,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
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;
+ return NULL;
}
dpx->depth = 0;
@@ -251,7 +251,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
if (dpx->depth == 0 || dpx->depth > 4) {
if (verbose) printf("DPX: Unsupported image depth: %d\n", dpx->depth);
logImageClose(dpx);
- return 0;
+ return NULL;
}
dpx->element[i].bitsPerSample = header.imageHeader.element[i].bits_per_sample;
@@ -261,7 +261,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
{
if (verbose) printf("DPX: Unsupported bitsPerSample for elements %d: %d\n", i, dpx->element[i].bitsPerSample);
logImageClose(dpx);
- return 0;
+ return NULL;
}
dpx->element[i].maxValue = powf(2, dpx->element[i].bitsPerSample) - 1.0f;
@@ -270,7 +270,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
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;
+ return NULL;
}
/* Sometimes, the offset is not set correctly in the header */
@@ -281,7 +281,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
if (dpx->element[i].dataOffset == 0) {
if (verbose) printf("DPX: Image header is corrupted.\n");
logImageClose(dpx);
- return 0;
+ return NULL;
}
dpx->element[i].transfer = header.imageHeader.element[i].transfer;
@@ -386,13 +386,13 @@ LogImageFile *dpxCreate(const char *filename, int width, int height, int bitsPer
const char *creator)
{
DpxMainHeader header;
- const char *shortFilename = 0;
+ const char *shortFilename = NULL;
unsigned char pad[6044];
LogImageFile *dpx = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
- if (dpx == 0) {
+ if (dpx == NULL) {
if (verbose) printf("DPX: Failed to malloc dpx file structure.\n");
- return 0;
+ return NULL;
}
dpx->width = width;
@@ -418,7 +418,7 @@ LogImageFile *dpxCreate(const char *filename, int width, int height, int bitsPer
default:
if (verbose) printf("DPX: bitsPerSample not supported: %d\n", bitsPerSample);
logImageClose(dpx);
- return 0;
+ return NULL;
}
if (hasAlpha == 0) {
@@ -463,17 +463,17 @@ LogImageFile *dpxCreate(const char *filename, int width, int height, int bitsPer
shortFilename = strrchr(filename, '/');
- if (shortFilename == 0)
+ if (shortFilename == NULL)
shortFilename = filename;
else
shortFilename++;
dpx->file = BLI_fopen(filename, "wb");
- if (dpx->file == 0) {
+ if (dpx->file == NULL) {
if (verbose) printf("DPX: Couldn't open file %s\n", filename);
logImageClose(dpx);
- return 0;
+ return NULL;
}
fillDpxMainHeader(dpx, &header, shortFilename, creator);
@@ -481,7 +481,7 @@ LogImageFile *dpxCreate(const char *filename, int width, int height, int bitsPer
if (fwrite(&header, sizeof(header), 1, dpx->file) == 0) {
if (verbose) printf("DPX: Couldn't write image header\n");
logImageClose(dpx);
- return 0;
+ return NULL;
}
/* Header should be rounded to next 8k block
@@ -490,7 +490,7 @@ LogImageFile *dpxCreate(const char *filename, int width, int height, int bitsPer
if (fwrite(&pad, 6044, 1, dpx->file) == 0) {
if (verbose) printf("DPX: Couldn't write image header\n");
logImageClose(dpx);
- return 0;
+ return NULL;
}
return dpx;
diff --git a/source/blender/imbuf/intern/cineon/logImageCore.c b/source/blender/imbuf/intern/cineon/logImageCore.c
index 332ad913d19..c10f201fb55 100644
--- a/source/blender/imbuf/intern/cineon/logImageCore.c
+++ b/source/blender/imbuf/intern/cineon/logImageCore.c
@@ -97,12 +97,12 @@ LogImageFile *logImageOpenFromFile(const char *filename, int cineon)
(void)cineon;
- if (f == 0)
- return 0;
+ if (f == NULL)
+ return NULL;
if (fread(&magicNum, sizeof(unsigned int), 1, f) != 1) {
fclose(f);
- return 0;
+ return NULL;
}
fclose(f);
@@ -112,7 +112,7 @@ LogImageFile *logImageOpenFromFile(const char *filename, int cineon)
else if (logImageIsCineon(&magicNum))
return cineonOpen((const unsigned char *)filename, 0, 0);
- return 0;
+ return NULL;
}
LogImageFile *logImageOpenFromMemory(const unsigned char *buffer, unsigned int size)
@@ -122,7 +122,7 @@ LogImageFile *logImageOpenFromMemory(const unsigned char *buffer, unsigned int s
else if (logImageIsCineon(buffer))
return cineonOpen(buffer, 1, size);
- return 0;
+ return NULL;
}
LogImageFile *logImageCreate(const char *filename, int cineon, int width, int height, int bitsPerSample,
@@ -136,15 +136,15 @@ LogImageFile *logImageCreate(const char *filename, int cineon, int width, int he
return dpxCreate(filename, width, height, bitsPerSample, isLogarithmic, hasAlpha,
referenceWhite, referenceBlack, gamma, creator);
- return 0;
+ return NULL;
}
void logImageClose(LogImageFile *logImage)
{
- if (logImage != 0) {
+ if (logImage != NULL) {
if (logImage->file) {
fclose(logImage->file);
- logImage->file = 0;
+ logImage->file = NULL;
}
MEM_freeN(logImage);
}
@@ -203,7 +203,7 @@ int logImageSetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
int returnValue;
elementData = (float *)MEM_mallocN(logImage->width * logImage->height * logImage->depth * sizeof(float), __func__);
- if (elementData == 0)
+ if (elementData == NULL)
return 1;
if (convertRGBAToLogElement(data, elementData, logImage, logImage->element[0], dataIsLinearRGB) != 0) {
@@ -244,7 +244,7 @@ static int logImageSetData8(LogImageFile *logImage, LogImageElement logElement,
int x, y;
row = (unsigned char *)MEM_mallocN(rowLength, __func__);
- if (row == 0) {
+ if (row == NULL) {
if (verbose) printf("DPX/Cineon: Cannot allocate row.\n");
return 1;
}
@@ -272,7 +272,7 @@ static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement,
int x, y, offset;
row = (unsigned int *)MEM_mallocN(rowLength, __func__);
- if (row == 0) {
+ if (row == NULL) {
if (verbose) printf("DPX/Cineon: Cannot allocate row.\n");
return 1;
}
@@ -313,7 +313,7 @@ static int logImageSetData12(LogImageFile *logImage, LogImageElement logElement,
int x, y;
row = (unsigned short *)MEM_mallocN(rowLength, __func__);
- if (row == 0) {
+ if (row == NULL) {
if (verbose) printf("DPX/Cineon: Cannot allocate row.\n");
return 1;
}
@@ -339,7 +339,7 @@ static int logImageSetData16(LogImageFile *logImage, LogImageElement logElement,
int x, y;
row = (unsigned short *)MEM_mallocN(rowLength, __func__);
- if (row == 0) {
+ if (row == NULL) {
if (verbose) printf("DPX/Cineon: Cannot allocate row.\n");
return 1;
}
@@ -383,10 +383,10 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
if (logImage->element[i].descriptor != descriptor_Depth && logImage->element[i].descriptor != descriptor_Composite) {
/* Allocate memory */
elementData[i] = (float *)MEM_mallocN(logImage->width * logImage->height * logImage->element[i].depth * sizeof(float), __func__);
- if (elementData[i] == 0) {
+ if (elementData[i] == NULL) {
if (verbose) printf("DPX/Cineon: Cannot allocate memory for elementData[%d]\n.", i);
for (j = 0; j < i; j++)
- if (elementData[j] != 0)
+ if (elementData[j] != NULL)
MEM_freeN(elementData[j]);
return 1;
}
@@ -396,7 +396,7 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
if (logImageElementGetData(logImage, logImage->element[i], elementData[i]) != 0) {
if (verbose) printf("DPX/Cineon: Cannot read elementData[%d]\n.", i);
for (j = 0; j < i; j++)
- if (elementData[j] != 0)
+ if (elementData[j] != NULL)
MEM_freeN(elementData[j]);
return 1;
}
@@ -531,10 +531,10 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
}
mergedData = (float *)MEM_mallocN(logImage->width * logImage->height * mergedElement.depth * sizeof(float), __func__);
- if (mergedData == 0) {
+ if (mergedData == NULL) {
if (verbose) printf("DPX/Cineon: Cannot allocate mergedData.\n");
for (i = 0; i < logImage->numElements; i++)
- if (elementData[i] != 0)
+ if (elementData[i] != NULL)
MEM_freeN(elementData[i]);
return 1;
}
@@ -548,7 +548,7 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
/* Done with elements data, clean-up */
for (i = 0; i < logImage->numElements; i++)
- if (elementData[i] != 0)
+ if (elementData[i] != NULL)
MEM_freeN(elementData[i]);
returnValue = convertLogElementToRGBA(mergedData, data, logImage, mergedElement, dataIsLinearRGB);
@@ -1383,7 +1383,7 @@ static int convertRGBAToLogElement(float *src, float *dst, LogImageFile *logImag
if (srcIsLinearRGB != 0) {
/* we need to convert src to sRGB */
srgbSrc = (float *)MEM_mallocN(4 * logImage->width * logImage->height * sizeof(float), __func__);
- if (srgbSrc == 0)
+ if (srgbSrc == NULL)
return 1;
memcpy(srgbSrc, src, 4 * logImage->width * logImage->height * sizeof(float));