[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51496] trunk/blender/source/blender: style cleanup: use more const's in BLI_heap & dpx/cineon style cleanup
Campbell Barton
ideasman42 at gmail.com
Mon Oct 22 15:00:02 CEST 2012
Revision: 51496
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51496
Author: campbellbarton
Date: 2012-10-22 13:00:02 +0000 (Mon, 22 Oct 2012)
Log Message:
-----------
style cleanup: use more const's in BLI_heap & dpx/cineon style cleanup
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/BLI_utildefines.h
trunk/blender/source/blender/blenlib/intern/BLI_heap.c
trunk/blender/source/blender/blenlib/intern/BLI_kdtree.c
trunk/blender/source/blender/imbuf/intern/cineon/cineon_dpx.c
trunk/blender/source/blender/imbuf/intern/cineon/cineonlib.c
trunk/blender/source/blender/imbuf/intern/cineon/cineonlib.h
trunk/blender/source/blender/imbuf/intern/cineon/dpxlib.c
trunk/blender/source/blender/imbuf/intern/cineon/dpxlib.h
trunk/blender/source/blender/imbuf/intern/cineon/logImageCore.c
trunk/blender/source/blender/imbuf/intern/cineon/logImageCore.h
trunk/blender/source/blender/imbuf/intern/cineon/logmemfile.c
trunk/blender/source/blender/imbuf/intern/cineon/logmemfile.h
Modified: trunk/blender/source/blender/blenlib/BLI_utildefines.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_utildefines.h 2012-10-22 12:49:00 UTC (rev 51495)
+++ trunk/blender/source/blender/blenlib/BLI_utildefines.h 2012-10-22 13:00:02 UTC (rev 51496)
@@ -109,9 +109,7 @@
#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); \
@@ -119,7 +117,6 @@
(a) = (b); \
(b) = sw_ap; \
} (void)0
-#endif
/* swap with a temp value */
#define SWAP_TVAL(tval, a, b) { \
Modified: trunk/blender/source/blender/blenlib/intern/BLI_heap.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/BLI_heap.c 2012-10-22 12:49:00 UTC (rev 51495)
+++ trunk/blender/source/blender/blenlib/intern/BLI_heap.c 2012-10-22 13:00:02 UTC (rev 51496)
@@ -84,10 +84,13 @@
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_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 @@
{
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);
Modified: trunk/blender/source/blender/blenlib/intern/BLI_kdtree.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/BLI_kdtree.c 2012-10-22 12:49:00 UTC (rev 51495)
+++ trunk/blender/source/blender/blenlib/intern/BLI_kdtree.c 2012-10-22 13:00:02 UTC (rev 51496)
@@ -30,16 +30,12 @@
* \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;
Modified: trunk/blender/source/blender/imbuf/intern/cineon/cineon_dpx.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/cineon/cineon_dpx.c 2012-10-22 12:49:00 UTC (rev 51495)
+++ trunk/blender/source/blender/imbuf/intern/cineon/cineon_dpx.c 2012-10-22 13:00:02 UTC (rev 51496)
@@ -59,7 +59,7 @@
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 @@
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 @@
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 @@
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;
Modified: trunk/blender/source/blender/imbuf/intern/cineon/cineonlib.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/cineon/cineonlib.c 2012-10-22 12:49:00 UTC (rev 51495)
+++ trunk/blender/source/blender/imbuf/intern/cineon/cineonlib.c 2012-10-22 13:00:02 UTC (rev 51496)
@@ -132,8 +132,8 @@
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 @@
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 @@
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 @@
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;
Modified: trunk/blender/source/blender/imbuf/intern/cineon/cineonlib.h
===================================================================
--- trunk/blender/source/blender/imbuf/intern/cineon/cineonlib.h 2012-10-22 12:49:00 UTC (rev 51495)
+++ trunk/blender/source/blender/imbuf/intern/cineon/cineonlib.h 2012-10-22 13:00:02 UTC (rev 51496)
@@ -36,25 +36,25 @@
#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 @@
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;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list