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:
authorColin Basnett <cmbasnett@gmail.com>2022-09-17 03:50:37 +0300
committerColin Basnett <cmbasnett@gmail.com>2022-09-17 03:50:37 +0300
commit564bda241a973396da51d7c3ccd9efd97d51728a (patch)
tree4d9aa4cccd82e2e606b47774afa5e1015bf14768 /source/blender/imbuf/intern/cineon/logImageCore.c
parent0fff238150d076576053c25b646f653d6e3b0edb (diff)
parent48d7ff68f0df209c77bbb081ab46fbc109fd825a (diff)
Merge branch 'master' into feature-imformatfeature-imformat
Diffstat (limited to 'source/blender/imbuf/intern/cineon/logImageCore.c')
-rw-r--r--source/blender/imbuf/intern/cineon/logImageCore.c119
1 files changed, 58 insertions, 61 deletions
diff --git a/source/blender/imbuf/intern/cineon/logImageCore.c b/source/blender/imbuf/intern/cineon/logImageCore.c
index e693aa6f891..8188d0d04b9 100644
--- a/source/blender/imbuf/intern/cineon/logImageCore.c
+++ b/source/blender/imbuf/intern/cineon/logImageCore.c
@@ -81,29 +81,29 @@ void logImageSetVerbose(int verbosity)
* IO stuff
*/
-int logImageIsDpx(const void *buffer, const unsigned int size)
+int logImageIsDpx(const void *buffer, const uint size)
{
- unsigned int magicNum;
+ uint magicNum;
if (size < sizeof(magicNum)) {
return 0;
}
- magicNum = *(unsigned int *)buffer;
+ magicNum = *(uint *)buffer;
return (magicNum == DPX_FILE_MAGIC || magicNum == swap_uint(DPX_FILE_MAGIC, 1));
}
-int logImageIsCineon(const void *buffer, const unsigned int size)
+int logImageIsCineon(const void *buffer, const uint size)
{
- unsigned int magicNum;
+ uint magicNum;
if (size < sizeof(magicNum)) {
return 0;
}
- magicNum = *(unsigned int *)buffer;
+ magicNum = *(uint *)buffer;
return (magicNum == CINEON_FILE_MAGIC || magicNum == swap_uint(CINEON_FILE_MAGIC, 1));
}
LogImageFile *logImageOpenFromFile(const char *filepath, int cineon)
{
- unsigned int magicNum;
+ uint magicNum;
FILE *f = BLI_fopen(filepath, "rb");
(void)cineon;
@@ -120,16 +120,16 @@ LogImageFile *logImageOpenFromFile(const char *filepath, int cineon)
fclose(f);
if (logImageIsDpx(&magicNum, sizeof(magicNum))) {
- return dpxOpen((const unsigned char *)filepath, 0, 0);
+ return dpxOpen((const uchar *)filepath, 0, 0);
}
if (logImageIsCineon(&magicNum, sizeof(magicNum))) {
- return cineonOpen((const unsigned char *)filepath, 0, 0);
+ return cineonOpen((const uchar *)filepath, 0, 0);
}
return NULL;
}
-LogImageFile *logImageOpenFromMemory(const unsigned char *buffer, unsigned int size)
+LogImageFile *logImageOpenFromMemory(const uchar *buffer, uint size)
{
if (logImageIsDpx(buffer, size)) {
return dpxOpen(buffer, 1, size);
@@ -276,9 +276,9 @@ int logImageSetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
static int logImageSetData8(LogImageFile *logImage, LogImageElement logElement, float *data)
{
size_t rowLength = getRowLength(logImage->width, logElement);
- unsigned char *row;
+ uchar *row;
- row = (unsigned char *)MEM_mallocN(rowLength, __func__);
+ row = (uchar *)MEM_mallocN(rowLength, __func__);
if (row == NULL) {
if (verbose) {
printf("DPX/Cineon: Cannot allocate row.\n");
@@ -289,7 +289,7 @@ static int logImageSetData8(LogImageFile *logImage, LogImageElement logElement,
for (size_t y = 0; y < logImage->height; y++) {
for (size_t x = 0; x < logImage->width * logImage->depth; x++) {
- row[x] = (unsigned char)float_uint(data[y * logImage->width * logImage->depth + x], 255);
+ row[x] = (uchar)float_uint(data[y * logImage->width * logImage->depth + x], 255);
}
if (logimage_fwrite(row, rowLength, 1, logImage) == 0) {
@@ -307,10 +307,10 @@ static int logImageSetData8(LogImageFile *logImage, LogImageElement logElement,
static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement, float *data)
{
size_t rowLength = getRowLength(logImage->width, logElement);
- unsigned int pixel, index;
- unsigned int *row;
+ uint pixel, index;
+ uint *row;
- row = (unsigned int *)MEM_mallocN(rowLength, __func__);
+ row = (uint *)MEM_mallocN(rowLength, __func__);
if (row == NULL) {
if (verbose) {
printf("DPX/Cineon: Cannot allocate row.\n");
@@ -324,8 +324,7 @@ static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement,
pixel = 0;
for (size_t x = 0; x < logImage->width * logImage->depth; x++) {
- pixel |= (unsigned int)float_uint(data[y * logImage->width * logImage->depth + x], 1023)
- << offset;
+ pixel |= (uint)float_uint(data[y * logImage->width * logImage->depth + x], 1023) << offset;
offset -= 10;
if (offset < 0) {
row[index] = swap_uint(pixel, logImage->isMSB);
@@ -353,9 +352,9 @@ static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement,
static int logImageSetData12(LogImageFile *logImage, LogImageElement logElement, float *data)
{
size_t rowLength = getRowLength(logImage->width, logElement);
- unsigned short *row;
+ ushort *row;
- row = (unsigned short *)MEM_mallocN(rowLength, __func__);
+ row = (ushort *)MEM_mallocN(rowLength, __func__);
if (row == NULL) {
if (verbose) {
printf("DPX/Cineon: Cannot allocate row.\n");
@@ -366,7 +365,7 @@ static int logImageSetData12(LogImageFile *logImage, LogImageElement logElement,
for (size_t y = 0; y < logImage->height; y++) {
for (size_t x = 0; x < logImage->width * logImage->depth; x++) {
row[x] = swap_ushort(
- ((unsigned short)float_uint(data[y * logImage->width * logImage->depth + x], 4095)) << 4,
+ ((ushort)float_uint(data[y * logImage->width * logImage->depth + x], 4095)) << 4,
logImage->isMSB);
}
@@ -385,9 +384,9 @@ static int logImageSetData12(LogImageFile *logImage, LogImageElement logElement,
static int logImageSetData16(LogImageFile *logImage, LogImageElement logElement, float *data)
{
size_t rowLength = getRowLength(logImage->width, logElement);
- unsigned short *row;
+ ushort *row;
- row = (unsigned short *)MEM_mallocN(rowLength, __func__);
+ row = (ushort *)MEM_mallocN(rowLength, __func__);
if (row == NULL) {
if (verbose) {
printf("DPX/Cineon: Cannot allocate row.\n");
@@ -398,7 +397,7 @@ static int logImageSetData16(LogImageFile *logImage, LogImageElement logElement,
for (size_t y = 0; y < logImage->height; y++) {
for (size_t x = 0; x < logImage->width * logImage->depth; x++) {
row[x] = swap_ushort(
- (unsigned short)float_uint(data[y * logImage->width * logImage->depth + x], 65535),
+ (ushort)float_uint(data[y * logImage->width * logImage->depth + x], 65535),
logImage->isMSB);
}
@@ -425,11 +424,11 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
float *elementData[8];
float *elementData_ptr[8];
float *mergedData;
- unsigned int sampleIndex;
+ uint sampleIndex;
LogImageElement mergedElement;
/* Determine the depth of the picture and if there's a separate alpha element.
- * If the element is supported, load it into an unsigned ints array. */
+ * If the element is supported, load it into an `uint` array. */
memset(&elementData, 0, 8 * sizeof(float *));
hasAlpha = 0;
@@ -695,7 +694,7 @@ static int logImageElementGetData(LogImageFile *logImage, LogImageElement logEle
static int logImageElementGetData1(LogImageFile *logImage, LogImageElement logElement, float *data)
{
- unsigned int pixel;
+ uint pixel;
/* seek at the right place */
if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
@@ -727,7 +726,7 @@ static int logImageElementGetData1(LogImageFile *logImage, LogImageElement logEl
static int logImageElementGetData8(LogImageFile *logImage, LogImageElement logElement, float *data)
{
size_t rowLength = getRowLength(logImage->width, logElement);
- unsigned char pixel;
+ uchar pixel;
/* extract required pixels */
for (size_t y = 0; y < logImage->height; y++) {
@@ -756,7 +755,7 @@ static int logImageElementGetData10(LogImageFile *logImage,
LogImageElement logElement,
float *data)
{
- unsigned int pixel;
+ uint pixel;
/* seek to data */
if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
@@ -829,15 +828,14 @@ static int logImageElementGetData10Packed(LogImageFile *logImage,
float *data)
{
size_t rowLength = getRowLength(logImage->width, logElement);
- unsigned int pixel, oldPixel;
+ uint pixel, oldPixel;
/* converting bytes to pixels */
for (size_t y = 0; y < logImage->height; y++) {
/* seek to data */
if (logimage_fseek(logImage, y * rowLength + logElement.dataOffset, SEEK_SET) != 0) {
if (verbose) {
- printf("DPX/Cineon: Couldn't seek at %u\n",
- (unsigned int)(y * rowLength + logElement.dataOffset));
+ printf("DPX/Cineon: Couldn't seek at %u\n", (uint)(y * rowLength + logElement.dataOffset));
}
return 1;
}
@@ -884,9 +882,9 @@ static int logImageElementGetData12(LogImageFile *logImage,
LogImageElement logElement,
float *data)
{
- unsigned int sampleIndex;
- unsigned int numSamples = logImage->width * logImage->height * logElement.depth;
- unsigned short pixel;
+ uint sampleIndex;
+ uint numSamples = logImage->width * logImage->height * logElement.depth;
+ ushort pixel;
/* seek to data */
if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
@@ -923,15 +921,14 @@ static int logImageElementGetData12Packed(LogImageFile *logImage,
float *data)
{
size_t rowLength = getRowLength(logImage->width, logElement);
- unsigned int pixel, oldPixel;
+ uint pixel, oldPixel;
/* converting bytes to pixels */
for (size_t y = 0; y < logImage->height; y++) {
/* seek to data */
if (logimage_fseek(logImage, y * rowLength + logElement.dataOffset, SEEK_SET) != 0) {
if (verbose) {
- printf("DPX/Cineon: Couldn't seek at %u\n",
- (unsigned int)(y * rowLength + logElement.dataOffset));
+ printf("DPX/Cineon: Couldn't seek at %u\n", (uint)(y * rowLength + logElement.dataOffset));
}
return 1;
}
@@ -978,9 +975,9 @@ static int logImageElementGetData16(LogImageFile *logImage,
LogImageElement logElement,
float *data)
{
- unsigned int numSamples = logImage->width * logImage->height * logElement.depth;
- unsigned int sampleIndex;
- unsigned short pixel;
+ uint numSamples = logImage->width * logImage->height * logElement.depth;
+ uint sampleIndex;
+ ushort pixel;
/* seek to data */
if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) {
@@ -1076,8 +1073,8 @@ static float *getLinToLogLut(LogImageFile *logImage, LogImageElement logElement)
{
float *lut;
float gain, negativeFilmGamma, offset, step;
- unsigned int lutsize = (unsigned int)(logElement.maxValue + 1);
- unsigned int i;
+ uint lutsize = (uint)(logElement.maxValue + 1);
+ uint i;
lut = MEM_mallocN(sizeof(float) * lutsize, "getLinToLogLut");
@@ -1104,8 +1101,8 @@ static float *getLogToLinLut(LogImageFile *logImage, LogImageElement logElement)
float *lut;
float breakPoint, gain, kneeGain, kneeOffset, negativeFilmGamma, offset, step, softClip;
/* float filmGamma; unused */
- unsigned int lutsize = (unsigned int)(logElement.maxValue + 1);
- unsigned int i;
+ uint lutsize = (uint)(logElement.maxValue + 1);
+ uint i;
lut = MEM_mallocN(sizeof(float) * lutsize, "getLogToLinLut");
@@ -1154,8 +1151,8 @@ static float *getLogToLinLut(LogImageFile *logImage, LogImageElement logElement)
static float *getLinToSrgbLut(LogImageElement logElement)
{
float col, *lut;
- unsigned int lutsize = (unsigned int)(logElement.maxValue + 1);
- unsigned int i;
+ uint lutsize = (uint)(logElement.maxValue + 1);
+ uint i;
lut = MEM_mallocN(sizeof(float) * lutsize, "getLogToLinLut");
@@ -1175,8 +1172,8 @@ static float *getLinToSrgbLut(LogImageElement logElement)
static float *getSrgbToLinLut(LogImageElement logElement)
{
float col, *lut;
- unsigned int lutsize = (unsigned int)(logElement.maxValue + 1);
- unsigned int i;
+ uint lutsize = (uint)(logElement.maxValue + 1);
+ uint i;
lut = MEM_mallocN(sizeof(float) * lutsize, "getLogToLinLut");
@@ -1199,7 +1196,7 @@ static int convertRGBA_RGB(float *src,
LogImageElement logElement,
int elementIsSource)
{
- unsigned int i;
+ uint i;
float *src_ptr = src;
float *dst_ptr = dst;
@@ -1254,7 +1251,7 @@ static int convertRGB_RGBA(float *src,
LogImageElement logElement,
int elementIsSource)
{
- unsigned int i;
+ uint i;
float *src_ptr = src;
float *dst_ptr = dst;
@@ -1309,7 +1306,7 @@ static int convertRGBA_RGBA(float *src,
LogImageElement logElement,
int elementIsSource)
{
- unsigned int i;
+ uint i;
float *src_ptr = src;
float *dst_ptr = dst;
@@ -1354,7 +1351,7 @@ static int convertABGR_RGBA(float *src,
LogImageElement logElement,
int elementIsSource)
{
- unsigned int i;
+ uint i;
float *src_ptr = src;
float *dst_ptr = dst;
@@ -1407,7 +1404,7 @@ static int convertCbYCr_RGBA(float *src,
LogImageFile *logImage,
LogImageElement logElement)
{
- unsigned int i;
+ uint i;
float conversionMatrix[9], refLowData, y, cb, cr;
float *src_ptr = src;
float *dst_ptr = dst;
@@ -1439,7 +1436,7 @@ static int convertCbYCrA_RGBA(float *src,
LogImageFile *logImage,
LogImageElement logElement)
{
- unsigned int i;
+ uint i;
float conversionMatrix[9], refLowData, y, cb, cr, a;
float *src_ptr = src;
float *dst_ptr = dst;
@@ -1472,7 +1469,7 @@ static int convertCbYCrY_RGBA(float *src,
LogImageFile *logImage,
LogImageElement logElement)
{
- unsigned int i;
+ uint i;
float conversionMatrix[9], refLowData, y1, y2, cb, cr;
float *src_ptr = src;
float *dst_ptr = dst;
@@ -1524,7 +1521,7 @@ static int convertCbYACrYA_RGBA(float *src,
LogImageFile *logImage,
LogImageElement logElement)
{
- unsigned int i;
+ uint i;
float conversionMatrix[9], refLowData, y1, y2, cb, cr, a1, a2;
float *src_ptr = src;
float *dst_ptr = dst;
@@ -1578,7 +1575,7 @@ static int convertLuminance_RGBA(float *src,
LogImageFile *logImage,
LogImageElement logElement)
{
- unsigned int i;
+ uint i;
float conversionMatrix[9], value, refLowData;
float *src_ptr = src;
float *dst_ptr = dst;
@@ -1604,7 +1601,7 @@ static int convertYA_RGBA(float *src,
LogImageFile *logImage,
LogImageElement logElement)
{
- unsigned int i;
+ uint i;
float conversionMatrix[9], value, refLowData;
float *src_ptr = src;
float *dst_ptr = dst;
@@ -1629,7 +1626,7 @@ static int convertLogElementToRGBA(
float *src, float *dst, LogImageFile *logImage, LogImageElement logElement, int dstIsLinearRGB)
{
int rvalue;
- unsigned int i;
+ uint i;
float *src_ptr;
float *dst_ptr;
@@ -1698,7 +1695,7 @@ static int convertLogElementToRGBA(
static int convertRGBAToLogElement(
float *src, float *dst, LogImageFile *logImage, LogImageElement logElement, int srcIsLinearRGB)
{
- unsigned int i;
+ uint i;
int rvalue;
float *srgbSrc;
float *srgbSrc_ptr;