diff options
Diffstat (limited to 'source/blender/imbuf/intern/cineon/logImageCore.h')
-rw-r--r-- | source/blender/imbuf/intern/cineon/logImageCore.h | 248 |
1 files changed, 127 insertions, 121 deletions
diff --git a/source/blender/imbuf/intern/cineon/logImageCore.h b/source/blender/imbuf/intern/cineon/logImageCore.h index 07fe6e22d40..e01c2e0f117 100644 --- a/source/blender/imbuf/intern/cineon/logImageCore.h +++ b/source/blender/imbuf/intern/cineon/logImageCore.h @@ -45,51 +45,50 @@ extern "C" { /* There are some differences between DPX and Cineon so we need to know from what type of file the datas come from */ enum format { - format_DPX, - format_Cineon, + format_DPX, + format_Cineon, }; typedef struct LogImageElement { - int depth; - int bitsPerSample; - int dataOffset; - int packing; - int transfer; - int descriptor; - unsigned int refLowData; - unsigned int refHighData; - float refLowQuantity; - float refHighQuantity; - float maxValue; /* = 2^bitsPerSample - 1 (used internally, doesn't come from the file header) */ + int depth; + int bitsPerSample; + int dataOffset; + int packing; + int transfer; + int descriptor; + unsigned int refLowData; + unsigned int refHighData; + float refLowQuantity; + float refHighQuantity; + float maxValue; /* = 2^bitsPerSample - 1 (used internally, doesn't come from the file header) */ } LogImageElement; typedef struct LogImageFile { - /* specified in header */ - int width; - int height; - int numElements; - int depth; - LogImageElement element[8]; - - /* used for log <-> lin conversion */ - float referenceBlack; - float referenceWhite; - float gamma; - - /* io stuff */ - FILE *file; - unsigned char *memBuffer; - uintptr_t memBufferSize; - unsigned char *memCursor; - - /* is the file LSB or MSB ? */ - int isMSB; - - /* DPX or Cineon ? */ - int srcFormat; + /* specified in header */ + int width; + int height; + int numElements; + int depth; + LogImageElement element[8]; + + /* used for log <-> lin conversion */ + float referenceBlack; + float referenceWhite; + float gamma; + + /* io stuff */ + FILE *file; + unsigned char *memBuffer; + uintptr_t memBufferSize; + unsigned char *memCursor; + + /* is the file LSB or MSB ? */ + int isMSB; + + /* DPX or Cineon ? */ + int srcFormat; } LogImageFile; - /* The SMPTE defines this code: * 0 - User-defined * 1 - Printing density @@ -110,19 +109,19 @@ typedef struct LogImageFile { */ enum transfer { - transfer_UserDefined, - transfer_PrintingDensity, - transfer_Linear, - transfer_Logarithmic, - transfer_Unspecified, - transfer_Smpte240M, - transfer_Ccir7091, - transfer_Ccir6012BG, - transfer_Ccir6012M, - transfer_NTSC, - transfer_PAL, - transfer_ZLinear, - transfer_Homogeneous, + transfer_UserDefined, + transfer_PrintingDensity, + transfer_Linear, + transfer_Logarithmic, + transfer_Unspecified, + transfer_Smpte240M, + transfer_Ccir7091, + transfer_Ccir6012BG, + transfer_Ccir6012M, + transfer_NTSC, + transfer_PAL, + transfer_ZLinear, + transfer_Homogeneous, }; /* The SMPTE defines this code: @@ -152,31 +151,31 @@ enum transfer { */ enum descriptor { - descriptor_UserDefined, - descriptor_Red, - descriptor_Green, - descriptor_Blue, - descriptor_Alpha, - descriptor_Luminance = 6, /* don't ask me why there's no 5 */ - descriptor_Chrominance, - descriptor_Depth, - descriptor_Composite, - descriptor_RGB = 50, - descriptor_RGBA, - descriptor_ABGR, - descriptor_CbYCrY = 100, - descriptor_CbYACrYA, - descriptor_CbYCr, - descriptor_CbYCrA, - descriptor_UserDefined2Elt = 150, - descriptor_UserDefined3Elt, - descriptor_UserDefined4Elt, - descriptor_UserDefined5Elt, - descriptor_UserDefined6Elt, - descriptor_UserDefined7Elt, - descriptor_UserDefined8Elt, - /* following descriptors are for internal use only */ - descriptor_YA, + descriptor_UserDefined, + descriptor_Red, + descriptor_Green, + descriptor_Blue, + descriptor_Alpha, + descriptor_Luminance = 6, /* don't ask me why there's no 5 */ + descriptor_Chrominance, + descriptor_Depth, + descriptor_Composite, + descriptor_RGB = 50, + descriptor_RGBA, + descriptor_ABGR, + descriptor_CbYCrY = 100, + descriptor_CbYACrYA, + descriptor_CbYCr, + descriptor_CbYCrA, + descriptor_UserDefined2Elt = 150, + descriptor_UserDefined3Elt, + descriptor_UserDefined4Elt, + descriptor_UserDefined5Elt, + descriptor_UserDefined6Elt, + descriptor_UserDefined7Elt, + descriptor_UserDefined8Elt, + /* following descriptors are for internal use only */ + descriptor_YA, }; /* int functions return 0 for OK */ @@ -187,9 +186,17 @@ int logImageIsCineon(const void *buffer); LogImageFile *logImageOpenFromMemory(const unsigned char *buffer, unsigned int size); LogImageFile *logImageOpenFromFile(const char *filename, int cineon); void logImageGetSize(LogImageFile *logImage, int *width, int *height, int *depth); -LogImageFile *logImageCreate(const char *filename, int cineon, int width, int height, int bitsPerSample, - int isLogarithmic, int hasAlpha, int referenceWhite, int referenceBlack, - float gamma, const char *creator); +LogImageFile *logImageCreate(const char *filename, + int cineon, + int width, + int height, + int bitsPerSample, + int isLogarithmic, + int hasAlpha, + int referenceWhite, + int referenceBlack, + float gamma, + const char *creator); void logImageClose(LogImageFile *logImage); /* Data handling */ @@ -205,74 +212,73 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB BLI_INLINE unsigned short swap_ushort(unsigned short x, int swap) { - if (swap != 0) - return (x >> 8) | (x << 8); - else - return x; + if (swap != 0) + return (x >> 8) | (x << 8); + else + return x; } BLI_INLINE unsigned int swap_uint(unsigned int x, int swap) { - if (swap != 0) - return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24); - else - return x; + if (swap != 0) + return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24); + else + return x; } BLI_INLINE float swap_float(float x, int swap) { - if (swap != 0) { - union { - float f; - unsigned char b[4]; - } dat1, dat2; - - dat1.f = x; - dat2.b[0] = dat1.b[3]; - dat2.b[1] = dat1.b[2]; - dat2.b[2] = dat1.b[1]; - dat2.b[3] = dat1.b[0]; - return dat2.f; - } - else - return x; + if (swap != 0) { + union { + float f; + unsigned char b[4]; + } dat1, dat2; + + dat1.f = x; + dat2.b[0] = dat1.b[3]; + dat2.b[1] = dat1.b[2]; + dat2.b[2] = dat1.b[1]; + dat2.b[3] = dat1.b[0]; + return dat2.f; + } + else + return x; } /* Other */ BLI_INLINE unsigned int clamp_uint(unsigned int x, unsigned int low, unsigned int high) { - if (x > high) - return high; - else if (x < low) - return low; - else - return x; + if (x > high) + return high; + else if (x < low) + return low; + else + return x; } BLI_INLINE float clamp_float(float x, float low, float high) { - if (x > high) - return high; - else if (x < low) - return low; - else - return x; + if (x > high) + return high; + else if (x < low) + return low; + else + return x; } BLI_INLINE unsigned int float_uint(float value, unsigned int max) { - if (value < 0.0f) - return 0; - else if (value > (1.0f - 0.5f / (float)max)) - return max; - else - return (unsigned int)(((float)max * value) + 0.5f); + if (value < 0.0f) + return 0; + else if (value > (1.0f - 0.5f / (float)max)) + return max; + else + return (unsigned int)(((float)max * value) + 0.5f); } - #ifdef __cplusplus } #endif -#endif /* __LOGIMAGECORE_H__ */ +#endif /* __LOGIMAGECORE_H__ */ |