style cleanup: use more const's in BLI_heap & dpx/cineon style cleanup
authorCampbell Barton <ideasman42@gmail.com>
Mon, 22 Oct 2012 13:00:02 +0000 (13:00 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 22 Oct 2012 13:00:02 +0000 (13:00 +0000)
12 files changed:
source/blender/blenlib/BLI_utildefines.h
source/blender/blenlib/intern/BLI_heap.c
source/blender/blenlib/intern/BLI_kdtree.c
source/blender/imbuf/intern/cineon/cineon_dpx.c
source/blender/imbuf/intern/cineon/cineonlib.c
source/blender/imbuf/intern/cineon/cineonlib.h
source/blender/imbuf/intern/cineon/dpxlib.c
source/blender/imbuf/intern/cineon/dpxlib.h
source/blender/imbuf/intern/cineon/logImageCore.c
source/blender/imbuf/intern/cineon/logImageCore.h
source/blender/imbuf/intern/cineon/logmemfile.c
source/blender/imbuf/intern/cineon/logmemfile.h

index 0dab51154ebf84ab04ee6fe8df37782e5319854f..801cff089d7bcfedea347f00f7ef24ebec3dccad 100644 (file)
 #define CHECK_TYPE_INLINE(val, type) \
        ((void)(((type *)0) != (val)))
 
-
-#ifndef SWAP
-#  define SWAP(type, a, b)  {  \
+#define SWAP(type, a, b)  {  \
        type sw_ap;                \
        CHECK_TYPE(a, type);       \
        CHECK_TYPE(b, type);       \
        (a) = (b);                 \
        (b) = sw_ap;               \
 } (void)0
-#endif
 
 /* swap with a temp value */
 #define SWAP_TVAL(tval, a, b)  {  \
index 42dca360f4cf07c9165ef612e61261e397b586b0..dcc028630e26b97b30e1e3d72f558865b13f5844 100644 (file)
@@ -84,10 +84,13 @@ BLI_INLINE void heap_swap(Heap *heap, const unsigned int i, const unsigned int j
 
 static void heap_down(Heap *heap, unsigned int i)
 {
+       /* size won't change in the loop */
+       const unsigned int size = heap->size;
+
        while (1) {
-               unsigned int size = heap->size,smallest ;
-               unsigned int l = HEAP_LEFT(i);
-               unsigned int r = HEAP_RIGHT(i);
+               const unsigned int l = HEAP_LEFT(i);
+               const unsigned int r = HEAP_RIGHT(i);
+               unsigned int smallest;
 
                smallest = ((l < size) && HEAP_COMPARE(heap->tree[l], heap->tree[i])) ? l : i;
 
@@ -105,7 +108,7 @@ static void heap_down(Heap *heap, unsigned int i)
 static void heap_up(Heap *heap, unsigned int i)
 {
        while (i > 0) {
-               unsigned int p = HEAP_PARENT(i);
+               const unsigned int p = HEAP_PARENT(i);
 
                if (HEAP_COMPARE(heap->tree[p], heap->tree[i]))
                        break;
@@ -139,9 +142,11 @@ void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp)
 {
        unsigned int i;
 
-       if (ptrfreefp)
-               for (i = 0; i < heap->size; i++)
+       if (ptrfreefp) {
+               for (i = 0; i < heap->size; i++) {
                        ptrfreefp(heap->tree[i]->ptr);
+               }
+       }
 
        MEM_freeN(heap->tree);
        BLI_memarena_free(heap->arena);
index 900580317f23d9fcf24a34d6b8f5b960e2d4047e..dd6c25ab6ad5887f07366268feca0eaa9700d5dc 100644 (file)
  *  \ingroup bli
  */
 
-
-
 #include "MEM_guardedalloc.h"
 
 #include "BLI_math.h"
 #include "BLI_kdtree.h"
+#include "BLI_utildefines.h"
 
-#ifndef SWAP
-#  define SWAP(type, a, b) { type sw_ap; sw_ap = (a); (a) = (b); (b) = sw_ap; } (void)0
-#endif
 
 typedef struct KDTreeNode {
        struct KDTreeNode *left, *right;
index 21f68e7913525b441662530ecaf75ae22217878d..d20c6dec9d35cb43b621323e55319e85f4c99288 100644 (file)
@@ -59,7 +59,7 @@ static struct ImBuf *imb_load_dpx_cineon(unsigned char *mem, size_t size, int us
 
        colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT);
 
-       logImageSetVerbose((G.f & G_DEBUG) ? 1:0);
+       logImageSetVerbose((G.f & G_DEBUG) ? 1 : 0);
 
        image = logImageOpenFromMemory(mem, size);
 
@@ -111,7 +111,7 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon
                return 0;
        }
        
-       logImageSetVerbose((G.f & G_DEBUG) ? 1:0);
+       logImageSetVerbose((G.f & G_DEBUG) ? 1 : 0);
 
        depth = (ibuf->planes + 7) >> 3;
        if (depth > 4 || depth < 3) {
@@ -142,11 +142,12 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon
                IMB_flipy(ibuf);
                rvalue = (logImageSetDataRGBA(logImage, ibuf->rect_float, 1) == 0);
                IMB_flipy(ibuf);
-       } else {
+       }
+       else {
                if (ibuf->rect == 0)
                        IMB_rect_from_float(ibuf);
 
-               fbuf = (float*)MEM_mallocN(ibuf->x * ibuf->y * 4 * sizeof(float), "fbuf in imb_save_dpx_cineon");
+               fbuf = (float *)MEM_mallocN(ibuf->x * ibuf->y * 4 * sizeof(float), "fbuf in imb_save_dpx_cineon");
                if (fbuf == 0) {
                        printf("DPX/Cineon: error allocating memory.\n");
                        logImageClose(logImage);
@@ -155,7 +156,7 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon
                for (y = 0; y < ibuf->y; y++) {
                        for (x = 0; x < ibuf->x; x++) {
                                fbuf_ptr = fbuf + 4 * ((ibuf->y - y - 1) * ibuf->x + x);
-                               rect_ptr = (unsigned char*)ibuf->rect + 4 * (y * ibuf->x + x);
+                               rect_ptr = (unsigned char *)ibuf->rect + 4 * (y * ibuf->x + x);
                                fbuf_ptr[0] = (float)rect_ptr[0] / 255.0f;
                                fbuf_ptr[1] = (float)rect_ptr[1] / 255.0f;
                                fbuf_ptr[2] = (float)rect_ptr[2] / 255.0f;
index 92a984378dbf53213fa78ad8a455fb7121ce70a4..9a90160125f6a5040835cdd9c4e40edca207dcdc 100644 (file)
@@ -132,8 +132,8 @@ static void fillCineonMainHeader(LogImageFile *cineon, CineonMainHeader *header,
 LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t bufferSize)
 {
        CineonMainHeader header;
-       LogImageFile *cineon = (LogImageFile*)MEM_mallocN(sizeof(LogImageFile), __func__);
-       char *filename = (char*)byteStuff;
+       LogImageFile *cineon = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
+       char *filename = (char *)byteStuff;
        int i;
        unsigned int dataOffset;
 
@@ -160,9 +160,10 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
                cineon->memBuffer = 0;
                cineon->memCursor = 0;
                cineon->memBufferSize = 0;
-       } else {
-               cineon->memBuffer = (unsigned char*)byteStuff;
-               cineon->memCursor = (unsigned char*)byteStuff;
+       }
+       else {
+               cineon->memBuffer = (unsigned char *)byteStuff;
+               cineon->memCursor = (unsigned char *)byteStuff;
                cineon->memBufferSize = bufferSize;
        }
 
@@ -176,12 +177,14 @@ LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t
        if (header.fileHeader.magic_num == swap_uint(CINEON_FILE_MAGIC, 1)) {
                cineon->isMSB = 1;
                if (verbose) printf("Cineon: File is MSB.\n");
-       } else if (header.fileHeader.magic_num == CINEON_FILE_MAGIC) {
+       }
+       else if (header.fileHeader.magic_num == CINEON_FILE_MAGIC) {
                cineon->isMSB = 0;
                if (verbose) printf("Cineon: File is LSB.\n");
-       } else {
+       }
+       else {
                if (verbose) printf("Cineon: Bad magic number %lu in \"%s\".\n",
-                                   (uintptr_t)header.fileHeader.magic_num, byteStuff);
+                                       (uintptr_t)header.fileHeader.magic_num, byteStuff);
                logImageClose(cineon);
                return 0;
        }
@@ -314,7 +317,7 @@ LogImageFile *cineonCreate(const char *filename, int width, int height, int bits
        const char *shortFilename = 0;
        /* unsigned char pad[6044]; */
 
-       LogImageFile *cineon = (LogImageFile*)MEM_mallocN(sizeof(LogImageFile), __func__);
+       LogImageFile *cineon = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
        if (cineon == 0) {
                if (verbose) printf("cineon: Failed to malloc cineon file structure.\n");
                return 0;
index 78403afe95514832ff7ae43f32793f9dfcdae412..9333743a1bf4ffdf2f78ecb7de7ff17c0d9fe17f 100644 (file)
@@ -36,25 +36,25 @@ extern "C" {
 
 #include "logImageCore.h"
 
-#define CINEON_FILE_MAGIC              0x802A5FD7
-#define CINEON_UNDEFINED_U8            0xFF
-#define CINEON_UNDEFINED_U16   0xFFFF
-#define CINEON_UNDEFINED_U32   0xFFFFFFFF
-#define CINEON_UNDEFINED_R32   0x7F800000
+#define CINEON_FILE_MAGIC       0x802A5FD7
+#define CINEON_UNDEFINED_U8     0xFF
+#define CINEON_UNDEFINED_U16    0xFFFF
+#define CINEON_UNDEFINED_U32    0xFFFFFFFF
+#define CINEON_UNDEFINED_R32    0x7F800000
 #define CINEON_UNDEFINED_CHAR   0
 
 typedef struct {
-       unsigned int    magic_num;
-       unsigned int    offset;
-       unsigned int    gen_hdr_size;
-       unsigned int    ind_hdr_size;
-       unsigned int    user_data_size;
-       unsigned int    file_size;
-       char                    version[8];
-       char                    file_name[100];
-       char                    creation_date[12];
-       char                    creation_time[12];
-       char                    reserved[36];
+       unsigned int    magic_num;
+       unsigned int    offset;
+       unsigned int    gen_hdr_size;
+       unsigned int    ind_hdr_size;
+       unsigned int    user_data_size;
+       unsigned int    file_size;
+       char            version[8];
+       char            file_name[100];
+       char            creation_date[12];
+       char            creation_time[12];
+       char            reserved[36];
 } CineonFileHeader;
 
 typedef struct {
@@ -62,51 +62,51 @@ typedef struct {
        unsigned char   descriptor2;
        unsigned char   bits_per_sample;
        unsigned char   filler;
-       unsigned int    pixels_per_line;
-       unsigned int    lines_per_image;
-       unsigned int    ref_low_data;
-       float                   ref_low_quantity;
-       unsigned int    ref_high_data;
-       float                   ref_high_quantity;
+       unsigned int    pixels_per_line;
+       unsigned int    lines_per_image;
+       unsigned int    ref_low_data;
+       float           ref_low_quantity;
+       unsigned int    ref_high_data;
+       float           ref_high_quantity;
 } CineonElementHeader;
 
 typedef struct {
-       unsigned char           orientation;
-       unsigned char           elements_per_image;
-       unsigned short          filler;
+       unsigned char       orientation;
+       unsigned char       elements_per_image;
+       unsigned short      filler;
        CineonElementHeader element[8];
-       float                           white_point_x;
-       float                           white_point_y;
-       float                           red_primary_x;
-       float                           red_primary_y;
-       float                           green_primary_x;
-       float                           green_primary_y;
-       float                           blue_primary_x;
-       float                           blue_primary_y;
-       char                            label[200];
-       char                            reserved[28];
-       unsigned char           interleave;
-       unsigned char           packing;
-       unsigned char           data_sign;
-       unsigned char           sense;
-       unsigned int            line_padding;
-       unsigned int            element_padding;
-       char                            reserved2[20];
+       float               white_point_x;
+       float               white_point_y;
+       float               red_primary_x;
+       float               red_primary_y;
+       float               green_primary_x;
+       float               green_primary_y;
+       float               blue_primary_x;
+       float               blue_primary_y;
+       char                label[200];
+       char                reserved[28];
+       unsigned char       interleave;
+       unsigned char       packing;
+       unsigned char       data_sign;
+       unsigned char       sense;
+       unsigned int        line_padding;
+       unsigned int        element_padding;
+       char                reserved2[20];
 } CineonImageHeader;
 
 typedef struct {
-       int             x_offset;
-       int             y_offset;
-       char    file_name[100];
-       char    creation_date[12];
-       char    creation_time[12];
-       char    input_device[64];
-       char    model_number[32];
-       char    input_serial_number[32];
+       int     x_offset;
+       int     y_offset;
+       char    file_name[100];
+       char    creation_date[12];
+       char    creation_time[12];
+       char    input_device[64];
+       char    model_number[32];
+       char    input_serial_number[32];
        float   x_input_samples_per_mm;
        float   y_input_samples_per_mm;
        float   input_device_gamma;
-       char    reserved[40];
+       char    reserved[40];
 } CineonOriginationHeader;
 
 typedef struct {
@@ -114,29 +114,29 @@ typedef struct {
        unsigned char   film_type;
        unsigned char   edge_code_perforation_offset;
        unsigned char   filler;
-       unsigned int    prefix;
-       unsigned int    count;
-       char                    format[32];
-       unsigned int    frame_position;
-       float                   frame_rate;
-       char                    attribute[32];
-       char                    slate[200];
-       char                    reserved[740];
+       unsigned int    prefix;
+       unsigned int    count;
+       char            format[32];
+       unsigned int    frame_position;
+       float           frame_rate;
+       char            attribute[32];
+       char            slate[200];
+       char            reserved[740];
 } CineonFilmHeader;
 
 typedef struct {
-       CineonFileHeader                fileHeader;
-       CineonImageHeader               imageHeader;
+       CineonFileHeader        fileHeader;
+       CineonImageHeader       imageHeader;
        CineonOriginationHeader originationHeader;
-       CineonFilmHeader                filmHeader;
+       CineonFilmHeader        filmHeader;
 } CineonMainHeader;
 
 void cineonSetVerbose(int);
-LogImageFile* cineonOpen(const unsigned char* byteStuff, int fromMemory, size_t bufferSize);
-LogImageFile* cineonCreate(const char* filename, int width, int height, int bitsPerSample, const char* creator);
+LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t bufferSize);
+LogImageFile *cineonCreate(const char *filename, int width, int height, int bitsPerSample, const char *creator);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif
+#endif  /* __CINEON_LIB_H__ */
index dc5f42ecaad8f741cc72f14d7b09c45d788f5ccc..d3158ea36f14dad8d082cb462f2d905bbf83b45a 100644 (file)
@@ -131,8 +131,8 @@ static void fillDpxMainHeader(LogImageFile *dpx, DpxMainHeader *header, const ch
 LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t bufferSize)
 {
        DpxMainHeader header;
-       LogImageFile *dpx = (LogImageFile*)MEM_mallocN(sizeof(LogImageFile), __func__);
-       char *filename = (char*)byteStuff;
+       LogImageFile *dpx = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
+       char *filename = (char *)byteStuff;
        int i;
 
        if (dpx == 0) {
@@ -158,9 +158,10 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
                dpx->memBuffer = 0;
                dpx->memCursor = 0;
                dpx->memBufferSize = 0;
-       } else {
-               dpx->memBuffer = (unsigned char*)byteStuff;
-               dpx->memCursor = (unsigned char*)byteStuff;
+       }
+       else {
+               dpx->memBuffer = (unsigned char *)byteStuff;
+               dpx->memCursor = (unsigned char *)byteStuff;
                dpx->memBufferSize = bufferSize;
        }
 
@@ -174,10 +175,12 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
        if (header.fileHeader.magic_num == swap_uint(DPX_FILE_MAGIC, 1)) {
                dpx->isMSB = 1;
                if (verbose) printf("DPX: File is MSB.\n");
-       } else if (header.fileHeader.magic_num == DPX_FILE_MAGIC) {
+       }
+       else if (header.fileHeader.magic_num == DPX_FILE_MAGIC) {
                dpx->isMSB = 0;
                if (verbose) printf("DPX: File is LSB.\n");
-       } else {
+       }
+       else {
                if (verbose) printf("DPX: Bad magic number %lu in \"%s\".\n",
                                    (uintptr_t)header.fileHeader.magic_num, byteStuff);
                logImageClose(dpx);
@@ -272,10 +275,10 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
                                if (dpx->element[i].refHighData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refHighData))
                                        dpx->element[i].refHighData = (unsigned int)dpx->element[i].maxValue;
 
-                               if(dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refLowQuantity))
+                               if (dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refLowQuantity))
                                        dpx->element[i].refLowQuantity = 0.0f;
 
-                               if(dpx->element[i].refHighQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refHighQuantity)) {
+                               if (dpx->element[i].refHighQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refHighQuantity)) {
                                        if (dpx->element[i].transfer == transfer_PrintingDensity || dpx->element[i].transfer == transfer_Logarithmic)
                                                dpx->element[i].refHighQuantity = 2.048f;
                                        else
@@ -296,10 +299,10 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
                                if (dpx->element[i].refHighData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refHighData))
                                        dpx->element[i].refHighData = 235.0f / 255.0f * dpx->element[i].maxValue;
 
-                               if(dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refLowQuantity))
+                               if (dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refLowQuantity))
                                        dpx->element[i].refLowQuantity = 0.0f;
 
-                               if(dpx->element[i].refHighQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refHighQuantity))
+                               if (dpx->element[i].refHighQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refHighQuantity))
                                        dpx->element[i].refHighQuantity = 0.7f;
 
                                break;
@@ -356,7 +359,7 @@ LogImageFile *dpxCreate(const char *filename, int width, int height, int bitsPer
        const char *shortFilename = 0;
        unsigned char pad[6044];
 
-       LogImageFile *dpx = (LogImageFile*)MEM_mallocN(sizeof(LogImageFile), __func__);
+       LogImageFile *dpx = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__);
        if (dpx == 0) {
                if (verbose) printf("DPX: Failed to malloc dpx file structure.\n");
                return 0;
index bd608b130577c2c8da1f7af7c151e148b22c8bab..e910aaa61e12be825231cd2622b39f282c78a645 100644 (file)
@@ -43,115 +43,115 @@ extern "C" {
 #define DPX_UNDEFINED_CHAR  0
 
 typedef struct {
-       unsigned int    magic_num;
-       unsigned int    offset;
-       char                    version[8];
-       unsigned int    file_size;
-       unsigned int    ditto_key;
-       unsigned int    gen_hdr_size;
-       unsigned int    ind_hdr_size;
-       unsigned int    user_data_size;
-       char                    file_name[100];
-       char                    creation_date[24];
-       char                    creator[100];
-       char                    project[200];
-       char                    copyright[200];
-       unsigned int    key;
-       char                    reserved[104];
+       unsigned int    magic_num;
+       unsigned int    offset;
+       char            version[8];
+       unsigned int    file_size;
+       unsigned int    ditto_key;
+       unsigned int    gen_hdr_size;
+       unsigned int    ind_hdr_size;
+       unsigned int    user_data_size;
+       char            file_name[100];
+       char            creation_date[24];
+       char            creator[100];
+       char            project[200];
+       char            copyright[200];
+       unsigned int    key;
+       char            reserved[104];
 } DpxFileHeader;
 
 typedef struct {
-       unsigned int    data_sign;
-       unsigned int    ref_low_data;
-       float                   ref_low_quantity;
-       unsigned int    ref_high_data;
-       float                   ref_high_quantity;
-       unsigned char   descriptor;
-       unsigned char   transfer;
-       unsigned char   colorimetric;
-       unsigned char   bits_per_sample;
-       unsigned short  packing;
-       unsigned short  encoding;
-       unsigned int    data_offset;
-       unsigned int    line_padding;
-       unsigned int    element_padding;
-       char                    description[32];
+       unsigned int    data_sign;
+       unsigned int    ref_low_data;
+       float           ref_low_quantity;
+       unsigned int    ref_high_data;
+       float           ref_high_quantity;
+       unsigned char   descriptor;
+       unsigned char   transfer;
+       unsigned char   colorimetric;
+       unsigned char   bits_per_sample;
+       unsigned short  packing;
+       unsigned short  encoding;
+       unsigned int    data_offset;
+       unsigned int    line_padding;
+       unsigned int    element_padding;
+       char            description[32];
 } DpxElementHeader;
 
 typedef struct {
-       unsigned short          orientation;
-       unsigned short          elements_per_image;
-       unsigned int            pixels_per_line;
-       unsigned int            lines_per_element;
-       DpxElementHeader        element[8];
-       char                            reserved[52];
+       unsigned short      orientation;
+       unsigned short      elements_per_image;
+       unsigned int        pixels_per_line;
+       unsigned int        lines_per_element;
+       DpxElementHeader    element[8];
+       char                reserved[52];
 } DpxImageHeader;
 
 typedef struct {
-       unsigned int    x_offset;
-       unsigned int    y_offset;
-       float                   x_center;
-       float                   y_center;
-       unsigned int    x_original_size;
-       unsigned int    y_original_size;
-       char                    file_name[100];
-       char                    creation_time[24];
-       char                    input_device[32];
-       char                    input_serial_number[32];
-       unsigned short  border_validity[4];
-       unsigned int    pixel_aspect_ratio[2];
-       char                    reserved[28];
+       unsigned int    x_offset;
+       unsigned int    y_offset;
+       float           x_center;
+       float           y_center;
+       unsigned int    x_original_size;
+       unsigned int    y_original_size;
+       char            file_name[100];
+       char            creation_time[24];
+       char            input_device[32];
+       char            input_serial_number[32];
+       unsigned short  border_validity[4];
+       unsigned int    pixel_aspect_ratio[2];
+       char            reserved[28];
 } DpxOrientationHeader;
 
 typedef struct {
-       char                    film_manufacturer_id[2];
-       char                    film_type[2];
-       char                    edge_code_perforation_offset[2];
-       char                    edge_code_prefix[6];
-       char                    edge_code_count[4];
-       char                    film_format[32];
-       unsigned int    frame_position;
-       unsigned int    sequence_length;
-       unsigned int    held_count;
-       float                   frame_rate;
-       float                   shutter_angle;
-       char                    frame_identification[32];
-       char                    slate_info[100];
-       char                    reserved[56];
+       char            film_manufacturer_id[2];
+       char            film_type[2];
+       char            edge_code_perforation_offset[2];
+       char            edge_code_prefix[6];
+       char            edge_code_count[4];
+       char            film_format[32];
+       unsigned int    frame_position;
+       unsigned int    sequence_length;
+       unsigned int    held_count;
+       float           frame_rate;
+       float           shutter_angle;
+       char            frame_identification[32];
+       char            slate_info[100];
+       char            reserved[56];
 } DpxFilmHeader;
 
 typedef struct {
-       unsigned int    time_code;
-       unsigned int    user_bits;
-       unsigned char   interlace;
-       unsigned char   field_number;
-       unsigned char   video_signal;
-       unsigned char   padding;
-       float                   horizontal_sample_rate;
-       float                   vertical_sample_rate;
-       float                   frame_rate;
-       float                   time_offset;
-       float                   gamma;
-       float                   black_level;
-       float                   black_gain;
-       float                   breakpoint;
-       float                   white_level;
-       float                   integration_times;
-       unsigned char   reserved[76];
+       unsigned int    time_code;
+       unsigned int    user_bits;
+       unsigned char   interlace;
+       unsigned char   field_number;
+       unsigned char   video_signal;
+       unsigned char   padding;
+       float           horizontal_sample_rate;
+       float           vertical_sample_rate;
+       float           frame_rate;
+       float           time_offset;
+       float           gamma;
+       float           black_level;
+       float           black_gain;
+       float           breakpoint;
+       float           white_level;
+       float           integration_times;
+       unsigned char   reserved[76];
 } DpxTelevisionHeader;
 
 
 typedef struct {
-       DpxFileHeader                   fileHeader;
-       DpxImageHeader                  imageHeader;
-       DpxOrientationHeader    orientationHeader;
-       DpxFilmHeader                   filmHeader;
-       DpxTelevisionHeader             televisionHeader;
+       DpxFileHeader           fileHeader;
+       DpxImageHeader          imageHeader;
+       DpxOrientationHeader    orientationHeader;
+       DpxFilmHeader           filmHeader;
+       DpxTelevisionHeader     televisionHeader;
 } DpxMainHeader;
 
 void dpxSetVerbose(int verbosity);
-LogImageFile* dpxOpen(const unsigned char* byteStuff, int fromMemory, size_t bufferSize);
-LogImageFile* dpxCreate(const char* filename, int width, int height, int bitsPerSample, int hasAlpha, int isLogarithmic, int referenceWhite, int referenceBlack, float gamma, const char* creator);
+LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t bufferSize);
+LogImageFile *dpxCreate(const char *filename, int width, int height, int bitsPerSample, int hasAlpha, int isLogarithmic, int referenceWhite, int referenceBlack, float gamma, const char *creator);
 
 #ifdef __cplusplus
 }
index 917554cb4fe07027b16ef4c00100dc4306489f46..6ee55ceb9d7ec6d238706df11facdf9e5951f971 100644 (file)
@@ -79,13 +79,13 @@ void logImageSetVerbose(int verbosity)
 
 int logImageIsDpx(const void *buffer)
 {
-       unsigned int magicNum = *(unsigned int*)buffer;
+       unsigned int magicNum = *(unsigned int *)buffer;
        return (magicNum == DPX_FILE_MAGIC || magicNum == swap_uint(DPX_FILE_MAGIC, 1));
 }
 
 int logImageIsCineon(const void *buffer)
 {
-       unsigned int magicNum = *(unsigned int*)buffer;
+       unsigned int magicNum = *(unsigned int *)buffer;
        return (magicNum == CINEON_FILE_MAGIC || magicNum == swap_uint(CINEON_FILE_MAGIC, 1));
 }
 
@@ -114,7 +114,7 @@ LogImageFile *logImageOpenFromFile(const char *filename, int cineon)
        return 0;
 }
 
-LogImageFile*logImageOpenFromMemory(const unsigned char *buffer, unsigned int size)
+LogImageFile *logImageOpenFromMemory(const unsigned char *buffer, unsigned int size)
 {
        if (logImageIsDpx(buffer))
                return dpxOpen(buffer, 1, size);
@@ -201,7 +201,7 @@ int logImageSetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
        float *elementData;
        int returnValue;
 
-       elementData = (float*)MEM_mallocN(logImage->width * logImage->height * logImage->depth * sizeof(float), __func__);
+       elementData = (float *)MEM_mallocN(logImage->width * logImage->height * logImage->depth * sizeof(float), __func__);
        if (elementData == 0)
                return 1;
 
@@ -242,7 +242,7 @@ static int logImageSetData8(LogImageFile *logImage, LogImageElement logElement,
        unsigned char *row;
        int x, y;
 
-       row = (unsigned char*)MEM_mallocN(rowLength, __func__);
+       row = (unsigned char *)MEM_mallocN(rowLength, __func__);
        if (row == 0) {
                if (verbose) printf("DPX/Cineon: Cannot allocate row.\n");
                return 1;
@@ -270,7 +270,7 @@ static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement,
        unsigned int *row;
        int x, y, offset;
 
-       row = (unsigned int*)MEM_mallocN(rowLength, __func__);
+       row = (unsigned int *)MEM_mallocN(rowLength, __func__);
        if (row == 0) {
                if (verbose) printf("DPX/Cineon: Cannot allocate row.\n");
                return 1;
@@ -311,7 +311,7 @@ static int logImageSetData12(LogImageFile *logImage, LogImageElement logElement,
        unsigned short *row;
        int x, y;
 
-       row = (unsigned short*)MEM_mallocN(rowLength, __func__);
+       row = (unsigned short *)MEM_mallocN(rowLength, __func__);
        if (row == 0) {
                if (verbose) printf("DPX/Cineon: Cannot allocate row.\n");
                return 1;
@@ -337,7 +337,7 @@ static int logImageSetData16(LogImageFile *logImage, LogImageElement logElement,
        unsigned short *row;
        int x, y;
 
-       row = (unsigned short*)MEM_mallocN(rowLength, __func__);
+       row = (unsigned short *)MEM_mallocN(rowLength, __func__);
        if (row == 0) {
                if (verbose) printf("DPX/Cineon: Cannot allocate row.\n");
                return 1;
@@ -374,14 +374,14 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
 
        /* 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. */
-       memset(&elementData, 0, 8 * sizeof(float*));
+       memset(&elementData, 0, 8 * sizeof(float *));
        hasAlpha = 0;
 
        for (i = 0; i < logImage->numElements; i++) {
                /* descriptor_Depth and descriptor_Composite are not supported */
                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__);
+                       elementData[i] = (float *)MEM_mallocN(logImage->width * logImage->height * logImage->element[i].depth * sizeof(float), __func__);
                        if (elementData[i] == 0) {
                                if (verbose) printf("DPX/Cineon: Cannot allocate memory for elementData[%d]\n.", i);
                                for (j = 0; j < i; j++)
@@ -409,7 +409,8 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
        if (logImage->numElements == 1) {
                returnValue = convertLogElementToRGBA(elementData[0], data, logImage, logImage->element[0], dataIsLinearRGB);
                MEM_freeN(elementData[0]);
-       } else {
+       }
+       else {
                /* The goal here is to merge every elements into only one
                 * to recreate a classic 16 bits RGB, RGBA or YCbCr element.
                 * Unsupported elements are skipped (depth, composite) */
@@ -421,7 +422,7 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
 
                /* Try to know how to assemble the elements */
                for (i = 0; i < logImage->numElements; i++) {
-                  switch(logImage->element[i].descriptor) {
+                       switch (logImage->element[i].descriptor) {
                                case descriptor_Red:
                                case descriptor_RGB:
                                        if (hasAlpha == 0)
@@ -528,7 +529,7 @@ int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB
                        }
                }
 
-               mergedData = (float*)MEM_mallocN(logImage->width * logImage->height * mergedElement.depth * sizeof(float), __func__);
+               mergedData = (float *)MEM_mallocN(logImage->width * logImage->height * mergedElement.depth * sizeof(float), __func__);
                if (mergedData == 0) {
                        if (verbose) printf("DPX/Cineon: Cannot allocate mergedData.\n");
                        for (i = 0; i < logImage->numElements; i++)
@@ -668,7 +669,8 @@ static int logImageElementGetData10(LogImageFile *logImage, LogImageElement logE
                                offset += 10;
                        }
                }
-       } else {
+       }
+       else {
                for (y = 0; y < logImage->height; y++) {
                        offset = -1;
                        for (x = 0; x < logImage->width * logElement.depth; x++) {
@@ -717,9 +719,11 @@ static int logImageElementGetData10Packed(LogImageFile *logImage, LogImageElemen
                                offset = 10 - offset2;
                                offset2 = 0;
                                oldPixel = 0;
-                       } else if (offset == 32) {
+                       }
+                       else if (offset == 32) {
                                offset = 0;
-                       } else if (offset + 10 > 32) {
+                       }
+                       else if (offset + 10 > 32) {
                                /* next pixel is on two different longs */
                                oldPixel = (pixel >> offset);
                                offset2 = 32 - offset;
@@ -794,9 +798,11 @@ static int logImageElementGetData12Packed(LogImageFile *logImage, LogImageElemen
                                offset = 12 - offset2;
                                offset2 = 0;
                                oldPixel = 0;
-                       } else if (offset == 32) {
+                       }
+                       else if (offset == 32) {
                                offset = 0;
-                       } else if (offset + 12 > 32) {
+                       }
+                       else if (offset + 12 > 32) {
                                /* next pixel is on two different longs */
                                oldPixel = (pixel >> offset);
                                offset2 = 32 - offset;
@@ -1005,9 +1011,9 @@ static int convertRGBA_RGB(float *src, float *dst, LogImageFile *logImage,
 
                case transfer_PrintingDensity:
                        if (elementIsSource == 1)
-                               getLogToLinLut((float*)&lut, logImage, logElement);
+                               getLogToLinLut((float *)&lut, logImage, logElement);
                        else
-                               getLinToLogLut((float*)&lut, logImage, logElement);
+                               getLinToLogLut((float *)&lut, logImage, logElement);
 
                        for (i = 0; i < logImage->width * logImage->height; i++) {
                                *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
@@ -1030,7 +1036,7 @@ static int convertRGB_RGBA(float *src, float *dst, LogImageFile *logImage,
        float *src_ptr = src;
        float *dst_ptr = dst;
 
-       switch(logElement.transfer) {
+       switch (logElement.transfer) {
                case transfer_UserDefined:
                case transfer_Linear:
                case transfer_Logarithmic:
@@ -1044,9 +1050,9 @@ static int convertRGB_RGBA(float *src, float *dst, LogImageFile *logImage,
 
                case transfer_PrintingDensity:
                        if (elementIsSource == 1)
-                               getLogToLinLut((float*)&lut, logImage, logElement);
+                               getLogToLinLut((float *)&lut, logImage, logElement);
                        else
-                               getLinToLogLut((float*)&lut, logImage, logElement);
+                               getLinToLogLut((float *)&lut, logImage, logElement);
 
                        for (i = 0; i < logImage->width * logImage->height; i++) {
                                *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
@@ -1078,9 +1084,9 @@ static int convertRGBA_RGBA(float *src, float *dst, LogImageFile *logImage,
 
                case transfer_PrintingDensity:
                        if (elementIsSource == 1)
-                               getLogToLinLut((float*)&lut, logImage, logElement);
+                               getLogToLinLut((float *)&lut, logImage, logElement);
                        else
-                               getLinToLogLut((float*)&lut, logImage, logElement);
+                               getLinToLogLut((float *)&lut, logImage, logElement);
 
                        for (i = 0; i < logImage->width * logImage->height; i++) {
                                *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
@@ -1119,9 +1125,9 @@ static int convertABGR_RGBA(float *src, float *dst, LogImageFile *logImage,
 
                case transfer_PrintingDensity:
                        if (elementIsSource == 1)
-                               getLogToLinLut((float*)&lut, logImage, logElement);
+                               getLogToLinLut((float *)&lut, logImage, logElement);
                        else
-                               getLinToLogLut((float*)&lut, logImage, logElement);
+                               getLinToLogLut((float *)&lut, logImage, logElement);
 
                        for (i = 0; i < logImage->width * logImage->height; i++) {
                                src_ptr += 4;
@@ -1145,7 +1151,7 @@ static int convertCbYCr_RGBA(float *src, float *dst, LogImageFile *logImage, Log
        float *src_ptr = src;
        float *dst_ptr = dst;
 
-       if (getYUVtoRGBMatrix((float*)&conversionMatrix, logElement) != 0)
+       if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
                return 1;
 
        refLowData = (float)logElement.refLowData / logElement.maxValue;
@@ -1170,7 +1176,7 @@ static int convertCbYCrA_RGBA(float *src, float *dst, LogImageFile *logImage, Lo
        float *src_ptr = src;
        float *dst_ptr = dst;
 
-       if (getYUVtoRGBMatrix((float*)&conversionMatrix, logElement) != 0)
+       if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
                return 1;
 
        refLowData = (float)logElement.refLowData / logElement.maxValue;
@@ -1196,7 +1202,7 @@ static int convertCbYCrY_RGBA(float *src, float *dst, LogImageFile *logImage, Lo
        float *src_ptr = src;
        float *dst_ptr = dst;
 
-       if (getYUVtoRGBMatrix((float*)&conversionMatrix, logElement) != 0)
+       if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
                return 1;
 
        refLowData = (float)logElement.refLowData / logElement.maxValue;
@@ -1226,7 +1232,7 @@ static int convertCbYACrYA_RGBA(float *src, float *dst, LogImageFile *logImage,
        float *src_ptr = src;
        float *dst_ptr = dst;
 
-       if (getYUVtoRGBMatrix((float*)&conversionMatrix, logElement) != 0)
+       if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
                return 1;
 
        refLowData = (float)logElement.refLowData / logElement.maxValue;
@@ -1258,7 +1264,7 @@ static int convertLuminance_RGBA(float *src, float *dst, LogImageFile *logImage,
        float *src_ptr = src;
        float *dst_ptr = dst;
 
-       if (getYUVtoRGBMatrix((float*)&conversionMatrix, logElement) != 0)
+       if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
                return 1;
 
        refLowData = (float)logElement.refLowData / logElement.maxValue;
@@ -1280,7 +1286,7 @@ static int convertYA_RGBA(float *src, float *dst, LogImageFile *logImage, LogIma
        float *src_ptr = src;
        float *dst_ptr = dst;
 
-       if (getYUVtoRGBMatrix((float*)&conversionMatrix, logElement) != 0)
+       if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0)
                return 1;
 
        refLowData = (float)logElement.refLowData / logElement.maxValue;
@@ -1350,7 +1356,7 @@ static int convertLogElementToRGBA(float *src, float *dst, LogImageFile *logImag
                return 1;
        else if (dstIsLinearRGB) {
                /* convert data from sRGB to Linear RGB via lut */
-               getSrgbToLinLut((float*)&lut, logElement);
+               getSrgbToLinLut((float *)&lut, logElement);
                src_ptr = dst; // no error here
                dst_ptr = dst;
                for (i = 0; i < logImage->width * logImage->height; i++) {
@@ -1375,7 +1381,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__);
+               srgbSrc = (float *)MEM_mallocN(4 * logImage->width * logImage->height * sizeof(float), __func__);
                if (srgbSrc == 0)
                        return 1;
 
@@ -1383,14 +1389,15 @@ static int convertRGBAToLogElement(float *src, float *dst, LogImageFile *logImag
                srgbSrc_ptr = srgbSrc;
 
                /* convert data from Linear RGB to sRGB via lut */
-               getLinToSrgbLut((float*)&lut, logElement);
+               getLinToSrgbLut((float *)&lut, logElement);
                for (i = 0; i < logImage->width * logImage->height; i++) {
                        *(srgbSrc_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
                        *(srgbSrc_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
                        *(srgbSrc_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)];
                        srgbSrc_ptr++; src_ptr++;
                }
-       } else
+       }
+       else
                srgbSrc = src;
 
        /* Convert linear RGBA data in src to format described by logElement in dst */
@@ -1437,7 +1444,7 @@ inline unsigned short swap_ushort(unsigned short x, int swap)
 inline unsigned int swap_uint(unsigned int x, int swap)
 {
        if (swap != 0)
-               return (x >> 24) | (( x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24);
+               return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24);
        else
                return x;
 }
@@ -1445,8 +1452,7 @@ inline unsigned int swap_uint(unsigned int x, int swap)
 inline float swap_float(float x, int swap)
 {
        if (swap != 0) {
-               union
-               {
+               union {
                        float f;
                        unsigned char b[4];
                } dat1, dat2;
@@ -1457,7 +1463,8 @@ inline float swap_float(float x, int swap)
                dat2.b[2] = dat1.b[1];
                dat2.b[3] = dat1.b[0];
                return dat2.f;
-       } else
+       }
+       else
                return x;
 }
 
index c1f4d2eae04fb339f277fdda4cb88c0d4c266f84..433cab27aefbc49ceefd162cb705b718914b01bf 100644 (file)
@@ -30,7 +30,6 @@
  *  \ingroup imbcineon
  */
 
-
 #ifndef __LOG_IMAGE_CORE_H__
 #define __LOG_IMAGE_CORE_H__
 
@@ -53,17 +52,17 @@ enum format {
 
 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
@@ -80,11 +79,11 @@ typedef struct LogImageFile
        float referenceWhite;
        float gamma;
 
-       /* io stuff */
-       FILEfile;
-       unsigned charmemBuffer;
+       /* io stuff */
+       FILE *file;
+       unsigned char *memBuffer;
        uintptr_t memBufferSize;
-       unsigned charmemCursor;
+       unsigned char *memCursor;
 
        /* is the file LSB or MSB ? */
        int isMSB;
@@ -95,23 +94,23 @@ typedef struct LogImageFile
 
 
 /* The SMPTE defines this code:
      *  0 - User-defined
      *  1 - Printing density
      *  2 - Linear
      *  3 - Logarithmic
      *  4 - Unspecified video
      *  5 - SMPTE 240M
      *  6 - CCIR 709-1
      *  7 - CCIR 601-2 system B or G
      *  8 - CCIR 601-2 system M
      *  9 - NTSC composite video
      *  10 - PAL composite video
      *  11 - Z linear
      *  12 - homogeneous
      *
      * Note that transfer_characteristics is U8, don't need
      * check the byte order.
      */
+ *  0 - User-defined
+ *  1 - Printing density
+ *  2 - Linear
+ *  3 - Logarithmic
+ *  4 - Unspecified video
+ *  5 - SMPTE 240M
+ *  6 - CCIR 709-1
+ *  7 - CCIR 601-2 system B or G
+ *  8 - CCIR 601-2 system M
+ *  9 - NTSC composite video
+ *  10 - PAL composite video
+ *  11 - Z linear
+ *  12 - homogeneous
+ *
+ * Note that transfer_characteristics is U8, don't need
+ * check the byte order.
+ */
 
 enum transfer {
        transfer_UserDefined,
@@ -130,30 +129,30 @@ enum transfer {
 };
 
 /* The SMPTE defines this code:
      * 0 - User-defined
      * 1 - Red
      * 2 - Green
      * 3 - Blue
      * 4 - Alpha
      * 6 - Luminance
      * 7 - Chrominance
      * 8 - Depth
      * 9 - Composite video
      * 50 - RGB
      * 51 - RGBA
      * 52 - ABGR
      * 100 - CbYCrY
      * 101 - CbYACrYA
      * 102 - CbYCr
      * 103 - CbYCrA
      * 150 - User-defined 2-component element
      * 151 - User-defined 3-component element
      * 152 - User-defined 4-component element
      * 153 - User-defined 5-component element
      * 154 - User-defined 6-component element
      * 155 - User-defined 7-component element
      * 156 - User-defined 8-component element
      */
+ * 0 - User-defined
+ * 1 - Red
+ * 2 - Green
+ * 3 - Blue
+ * 4 - Alpha
+ * 6 - Luminance
+ * 7 - Chrominance
+ * 8 - Depth
+ * 9 - Composite video
+ * 50 - RGB
+ * 51 - RGBA
+ * 52 - ABGR
+ * 100 - CbYCrY
+ * 101 - CbYACrYA
+ * 102 - CbYCr
+ * 103 - CbYCrA
+ * 150 - User-defined 2-component element
+ * 151 - User-defined 3-component element
+ * 152 - User-defined 4-component element
+ * 153 - User-defined 5-component element
+ * 154 - User-defined 6-component element
+ * 155 - User-defined 7-component element
+ * 156 - User-defined 8-component element
+ */
 
 enum descriptor {
        descriptor_UserDefined,
@@ -161,18 +160,18 @@ enum descriptor {
        descriptor_Green,
        descriptor_Blue,
        descriptor_Alpha,
-       descriptor_Luminance            = 6, /* don't ask me why there's no 5 */
+       descriptor_Luminance        = 6, /* don't ask me why there's no 5 */
        descriptor_Chrominance,
        descriptor_Depth,
        descriptor_Composite,
-       descriptor_RGB                          = 50,
+       descriptor_RGB              = 50,
        descriptor_RGBA,
        descriptor_ABGR,
-       descriptor_CbYCrY                       = 100,
+       descriptor_CbYCrY           = 100,
        descriptor_CbYACrYA,
        descriptor_CbYCr,
        descriptor_CbYCrA,
-       descriptor_UserDefined2Elt      = 150,
+       descriptor_UserDefined2Elt  = 150,
        descriptor_UserDefined3Elt,
        descriptor_UserDefined4Elt,
        descriptor_UserDefined5Elt,
@@ -186,18 +185,20 @@ enum descriptor {
 /* int functions return 0 for OK */
 
 void logImageSetVerbose(int verbosity);
-int logImageIsDpx(const voidbuffer);
-int logImageIsCineon(const voidbuffer);
-LogImageFilelogImageOpenFromMemory(const unsigned char *buffer, unsigned int size);
-LogImageFilelogImageOpenFromFile(const char *filename, int cineon);
+int logImageIsDpx(const void *buffer);
+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);
-void logImageClose(LogImageFile* logImage);
+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 */
 unsigned int getRowLength(int width, LogImageElement logElement);
-int logImageSetDataRGBA(LogImageFile *logImage,float *data, int dataIsLinearRGB);
-int logImageGetDataRGBA(LogImageFile *logImage, floatdata, int dataIsLinearRGB);
+int logImageSetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB);
+int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB);
 
 /* Endianness conversion */
 inline unsigned short swap_ushort(unsigned short x, int swap);
@@ -214,4 +215,4 @@ inline unsigned int float_uint(float value, unsigned int max);
 }
 #endif
 
-#endif
+#endif  /* __LOG_IMAGE_CORE_H__ */
index 54bc62276cf55157c75f1c1be463d840b0741a8d..3914f6dc6336fe6cde6fd838fc45380739f9ad8d 100644 (file)
@@ -42,11 +42,13 @@ int logimage_fseek(LogImageFile *logFile, intptr_t offset, int origin)
                        if (offset > logFile->memBufferSize)
                                return 1;
                        logFile->memCursor = logFile->memBuffer + offset;
-               } else if (origin == SEEK_END) {
+               }
+               else if (origin == SEEK_END) {
                        if (offset > logFile->memBufferSize)
                                return 1;
                        logFile->memCursor = (logFile->memBuffer + logFile->memBufferSize) - offset;
-               } else if (origin == SEEK_CUR) {
+               }
+               else if (origin == SEEK_CUR) {
                        uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
                        if (pos + offset > logFile->memBufferSize || pos < 0)
                                return 1;
@@ -57,12 +59,12 @@ int logimage_fseek(LogImageFile *logFile, intptr_t offset, int origin)
        return 0;
 }
 
-int logimage_fwrite(void *buffer, size_t size, unsigned int count, LogImageFilelogFile)
+int logimage_fwrite(void *buffer, size_t size, unsigned int count, LogImageFile *logFile)
 {
        if (logFile->file)
                return fwrite(buffer, size, count, logFile->file);
-       else { /*we're writing to memory*/
-               /*do nothing as this isn't supported yet*/
+       else { /* we're writing to memory */
+               /* do nothing as this isn't supported yet */
                return count;
        }
 }
@@ -73,7 +75,7 @@ int logimage_fread(void *buffer, size_t size, unsigned int count, LogImageFile *
                return fread(buffer, size, count, logFile->file);
        }
        else { /* we're reading from memory */
-               unsigned char *buf = (unsigned char*)buffer;
+               unsigned char *buf = (unsigned char *)buffer;
                uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer;
                size_t total_size = size * count;
                if (pos + total_size > logFile->memBufferSize) {
@@ -96,7 +98,7 @@ int logimage_read_uchar(unsigned char *x, LogImageFile *logFile)
        if (pos + sizeof(unsigned char) > logFile->memBufferSize)
                return 1;
 
-       *x = *(unsigned char*)logFile->memCursor;
+       *x = *(unsigned char *)logFile->memCursor;
        logFile->memCursor += sizeof(unsigned char);
        return 0;
 }
@@ -107,7 +109,7 @@ int logimage_read_ushort(unsigned short *x, LogImageFile *logFile)
        if (pos + sizeof(unsigned short) > logFile->memBufferSize)
                return 1;
 
-       *x = *(unsigned short*)logFile->memCursor;
+       *x = *(unsigned short *)logFile->memCursor;
        logFile->memCursor += sizeof(unsigned short);
        return 0;
 }
@@ -118,7 +120,7 @@ int logimage_read_uint(unsigned int *x, LogImageFile *logFile)
        if (pos + sizeof(unsigned int) > logFile->memBufferSize)
                return 1;
 
-       *x = *(unsigned int*)logFile->memCursor;
+       *x = *(unsigned int *)logFile->memCursor;
        logFile->memCursor += sizeof(unsigned int);
        return 0;
 }
index 55ad0a9467a7f4a9876e9c04b0b79902d83e3ac0..068a53e641b939909281ae560cdf4af4d26f65db 100644 (file)
 
 #include <stdlib.h>
 
-int logimage_fseek(LogImageFilelogFile, intptr_t offset, int origin);
-int logimage_fwrite(void* buffer, size_t size, unsigned int count, LogImageFile* logFile);
-int logimage_fread(void* buffer, size_t size, unsigned int count, LogImageFile* logFile);
-int logimage_read_uchar(unsigned char* x, LogImageFile* logFile);
-int logimage_read_ushort(unsigned short* x, LogImageFile* logFile);
-int logimage_read_uint(unsigned int* x, LogImageFile* logFile);
+int logimage_fseek(LogImageFile *logFile, intptr_t offset, int origin);
+int logimage_fwrite(void *buffer, size_t size, unsigned int count, LogImageFile *logFile);
+int logimage_fread(void *buffer, size_t size, unsigned int count, LogImageFile *logFile);
+int logimage_read_uchar(unsigned char *x, LogImageFile *logFile);
+int logimage_read_ushort(unsigned short *x, LogImageFile *logFile);
+int logimage_read_uint(unsigned int *x, LogImageFile *logFile);
 
 #endif  /* __LOGMEMFILE_H__ */