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>2012-05-14 02:05:51 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-05-14 02:05:51 +0400
commit4f2c83f573472c69f7f72762a34e1158433a06b6 (patch)
treee5fe9dcd6d151adf2b906603b15ee20fb4ba9067
parente5963aae1de14c4aaf2953b1cb91b4119415c565 (diff)
style cleanup: imbuf & icons
-rw-r--r--GNUmakefile2
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c2
-rw-r--r--source/blender/blenkernel/intern/icons.c76
-rw-r--r--source/blender/editors/space_api/spacetypes.c44
-rw-r--r--source/blender/imbuf/intern/allocimbuf.c122
-rw-r--r--source/blender/imbuf/intern/divers.c284
-rw-r--r--source/blender/imbuf/intern/filter.c341
-rw-r--r--source/blender/imbuf/intern/imageprocess.c336
-rw-r--r--source/blender/imbuf/intern/rotate.c54
-rw-r--r--source/blender/imbuf/intern/writeimage.c4
10 files changed, 632 insertions, 633 deletions
diff --git a/GNUmakefile b/GNUmakefile
index ebd2db60e0a..f2ac0285407 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -216,7 +216,7 @@ test_deprecated:
test_style:
# run our own checks on C/C++ style
- PYTHONIOENCODING=utf_8 python3.2 $(BLENDER_DIR)/source/tools/check_style_c.py $(BLENDER_DIR)/source/blender $(BLENDER_DIR)/source/creator
+ PYTHONIOENCODING=utf_8 python3.2 $(BLENDER_DIR)/source/tools/check_style_c.py $(BLENDER_DIR)/source/blender $(BLENDER_DIR)/source/creator --no-length-check
# -----------------------------------------------------------------------------
# Project Files
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index 9bdb575bd49..abbd4bf64bc 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -2406,7 +2406,7 @@ static void ccgSubSurf__allFaces(CCGSubSurf *ss, CCGFace ***faces, int *numFaces
CCGFace **array;
int i, num;
- if (!*faces) {
+ if (*faces == NULL) {
array = MEM_mallocN(sizeof(*array) * ss->fMap->numEntries, "CCGSubsurf allFaces");
num = 0;
for (i = 0; i < ss->fMap->curSize; i++) {
diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c
index edde21ed7c8..5990e92798e 100644
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.c
@@ -51,11 +51,9 @@
#include "BLO_sys_types.h" // for intptr_t support
-#define GS(a) (*((short *)(a)))
-
/* GLOBALS */
-static GHash* gIcons = NULL;
+static GHash *gIcons = NULL;
static int gNextIconId = 1;
@@ -64,7 +62,7 @@ static int gFirstIconId = 1;
static void icon_free(void *val)
{
- Icon* icon = val;
+ Icon *icon = val;
if (icon) {
if (icon->drawinfo_free) {
@@ -84,15 +82,15 @@ static int get_next_free_id(void)
int startId = gFirstIconId;
/* if we haven't used up the int number range, we just return the next int */
- if (gNextIconId>=gFirstIconId)
+ if (gNextIconId >= gFirstIconId)
return gNextIconId++;
/* now we try to find the smallest icon id not stored in the gIcons hash */
- while (BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(startId)) && startId>=gFirstIconId)
+ while (BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(startId)) && startId >= gFirstIconId)
startId++;
/* if we found a suitable one that isn't used yet, return it */
- if (startId>=gFirstIconId)
+ if (startId >= gFirstIconId)
return startId;
/* fail */
@@ -115,14 +113,14 @@ void BKE_icons_free(void)
gIcons = NULL;
}
-struct PreviewImage* BKE_previewimg_create(void)
+PreviewImage *BKE_previewimg_create(void)
{
- PreviewImage* prv_img = NULL;
+ PreviewImage *prv_img = NULL;
int i;
prv_img = MEM_callocN(sizeof(PreviewImage), "img_prv");
- for (i=0; i<NUM_ICON_SIZES; ++i) {
+ for (i = 0; i < NUM_ICON_SIZES; ++i) {
prv_img->changed[i] = 1;
prv_img->changed_timestamp[i] = 0;
}
@@ -135,7 +133,7 @@ void BKE_previewimg_freefunc(void *link)
if (prv) {
int i;
- for (i=0; i<NUM_ICON_SIZES;++i) {
+ for (i = 0; i < NUM_ICON_SIZES; ++i) {
if (prv->rect[i]) {
MEM_freeN(prv->rect[i]);
prv->rect[i] = NULL;
@@ -153,14 +151,14 @@ void BKE_previewimg_free(PreviewImage **prv)
}
}
-struct PreviewImage* BKE_previewimg_copy(PreviewImage *prv)
+PreviewImage *BKE_previewimg_copy(PreviewImage *prv)
{
- PreviewImage* prv_img = NULL;
+ PreviewImage *prv_img = NULL;
int i;
if (prv) {
prv_img = MEM_dupallocN(prv);
- for (i=0; i < NUM_ICON_SIZES; ++i) {
+ for (i = 0; i < NUM_ICON_SIZES; ++i) {
if (prv->rect[i]) {
prv_img->rect[i] = MEM_dupallocN(prv->rect[i]);
}
@@ -175,62 +173,62 @@ struct PreviewImage* BKE_previewimg_copy(PreviewImage *prv)
void BKE_previewimg_free_id(ID *id)
{
if (GS(id->name) == ID_MA) {
- Material *mat = (Material*)id;
+ Material *mat = (Material *)id;
BKE_previewimg_free(&mat->preview);
}
else if (GS(id->name) == ID_TE) {
- Tex *tex = (Tex*)id;
+ Tex *tex = (Tex *)id;
BKE_previewimg_free(&tex->preview);
}
else if (GS(id->name) == ID_WO) {
- World *wo = (World*)id;
+ World *wo = (World *)id;
BKE_previewimg_free(&wo->preview);
}
else if (GS(id->name) == ID_LA) {
- Lamp *la = (Lamp*)id;
+ Lamp *la = (Lamp *)id;
BKE_previewimg_free(&la->preview);
}
else if (GS(id->name) == ID_IM) {
- Image *img = (Image*)id;
+ Image *img = (Image *)id;
BKE_previewimg_free(&img->preview);
}
else if (GS(id->name) == ID_BR) {
- Brush *br = (Brush*)id;
+ Brush *br = (Brush *)id;
BKE_previewimg_free(&br->preview);
}
}
-PreviewImage* BKE_previewimg_get(ID *id)
+PreviewImage *BKE_previewimg_get(ID *id)
{
- PreviewImage* prv_img = NULL;
+ PreviewImage *prv_img = NULL;
if (GS(id->name) == ID_MA) {
- Material *mat = (Material*)id;
+ Material *mat = (Material *)id;
if (!mat->preview) mat->preview = BKE_previewimg_create();
prv_img = mat->preview;
}
else if (GS(id->name) == ID_TE) {
- Tex *tex = (Tex*)id;
+ Tex *tex = (Tex *)id;
if (!tex->preview) tex->preview = BKE_previewimg_create();
prv_img = tex->preview;
}
else if (GS(id->name) == ID_WO) {
- World *wo = (World*)id;
+ World *wo = (World *)id;
if (!wo->preview) wo->preview = BKE_previewimg_create();
prv_img = wo->preview;
}
else if (GS(id->name) == ID_LA) {
- Lamp *la = (Lamp*)id;
+ Lamp *la = (Lamp *)id;
if (!la->preview) la->preview = BKE_previewimg_create();
prv_img = la->preview;
}
else if (GS(id->name) == ID_IM) {
- Image *img = (Image*)id;
+ Image *img = (Image *)id;
if (!img->preview) img->preview = BKE_previewimg_create();
prv_img = img->preview;
}
else if (GS(id->name) == ID_BR) {
- Brush *br = (Brush*)id;
+ Brush *br = (Brush *)id;
if (!br->preview) br->preview = BKE_previewimg_create();
prv_img = br->preview;
}
@@ -240,19 +238,19 @@ PreviewImage* BKE_previewimg_get(ID *id)
void BKE_icon_changed(int id)
{
- Icon* icon = NULL;
+ Icon *icon = NULL;
if (!id || G.background) return;
icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(id));
if (icon) {
- PreviewImage *prv = BKE_previewimg_get((ID*)icon->obj);
+ PreviewImage *prv = BKE_previewimg_get((ID *)icon->obj);
/* all previews changed */
if (prv) {
int i;
- for (i=0; i<NUM_ICON_SIZES; ++i) {
+ for (i = 0; i < NUM_ICON_SIZES; ++i) {
prv->changed[i] = 1;
prv->changed_timestamp[i]++;
}
@@ -260,9 +258,9 @@ void BKE_icon_changed(int id)
}
}
-int BKE_icon_getid(struct ID* id)
+int BKE_icon_getid(struct ID *id)
{
- Icon* new_icon = NULL;
+ Icon *new_icon = NULL;
if (!id || G.background)
return 0;
@@ -291,9 +289,9 @@ int BKE_icon_getid(struct ID* id)
return id->icon_id;
}
-Icon* BKE_icon_get(int icon_id)
+Icon *BKE_icon_get(int icon_id)
{
- Icon* icon = NULL;
+ Icon *icon = NULL;
icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id));
@@ -305,9 +303,9 @@ Icon* BKE_icon_get(int icon_id)
return icon;
}
-void BKE_icon_set(int icon_id, struct Icon* icon)
+void BKE_icon_set(int icon_id, struct Icon *icon)
{
- Icon* old_icon = NULL;
+ Icon *old_icon = NULL;
old_icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id));
@@ -319,10 +317,10 @@ void BKE_icon_set(int icon_id, struct Icon* icon)
BLI_ghash_insert(gIcons, SET_INT_IN_POINTER(icon_id), icon);
}
-void BKE_icon_delete(struct ID* id)
+void BKE_icon_delete(struct ID *id)
{
- if (!id->icon_id) return; /* no icon defined for library object */
+ if (!id->icon_id) return; /* no icon defined for library object */
BLI_ghash_remove(gIcons, SET_INT_IN_POINTER(id->icon_id), NULL, icon_free);
id->icon_id = 0;
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 31243184961..956aee84fd3 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -70,7 +70,7 @@ void ED_spacetypes_init(void)
SpaceType *type;
/* UI_UNIT_X is now a variable, is used in some spacetype inits? */
- U.widget_unit= 20;
+ U.widget_unit = 20;
/* create space types */
ED_spacetype_outliner();
@@ -117,7 +117,7 @@ void ED_spacetypes_init(void)
/* register operators */
spacetypes = BKE_spacetypes_list();
- for (type=spacetypes->first; type; type=type->next) {
+ for (type = spacetypes->first; type; type = type->next) {
if (type->operatortypes)
type->operatortypes();
}
@@ -136,7 +136,7 @@ void ED_spacetypes_init(void)
/* register dropboxes (can use macros) */
spacetypes = BKE_spacetypes_list();
- for (type=spacetypes->first; type; type=type->next) {
+ for (type = spacetypes->first; type; type = type->next) {
if (type->dropboxes)
type->dropboxes();
}
@@ -169,10 +169,10 @@ void ED_spacetypes_keymap(wmKeyConfig *keyconf)
UI_view2d_keymap(keyconf);
spacetypes = BKE_spacetypes_list();
- for (stype=spacetypes->first; stype; stype=stype->next) {
+ for (stype = spacetypes->first; stype; stype = stype->next) {
if (stype->keymap)
stype->keymap(keyconf);
- for (atype=stype->regiontypes.first; atype; atype=atype->next) {
+ for (atype = stype->regiontypes.first; atype; atype = atype->next) {
if (atype->keymap)
atype->keymap(keyconf);
}
@@ -192,15 +192,15 @@ typedef struct RegionDrawCB {
} RegionDrawCB;
void *ED_region_draw_cb_activate(ARegionType *art,
- void (*draw)(const struct bContext *, struct ARegion *, void *),
- void *customdata, int type)
+ void (*draw)(const struct bContext *, struct ARegion *, void *),
+ void *customdata, int type)
{
- RegionDrawCB *rdc= MEM_callocN(sizeof(RegionDrawCB), "RegionDrawCB");
+ RegionDrawCB *rdc = MEM_callocN(sizeof(RegionDrawCB), "RegionDrawCB");
BLI_addtail(&art->drawcalls, rdc);
- rdc->draw= draw;
- rdc->customdata= customdata;
- rdc->type= type;
+ rdc->draw = draw;
+ rdc->customdata = customdata;
+ rdc->type = type;
return rdc;
}
@@ -209,8 +209,8 @@ void ED_region_draw_cb_exit(ARegionType *art, void *handle)
{
RegionDrawCB *rdc;
- for (rdc= art->drawcalls.first; rdc; rdc= rdc->next) {
- if (rdc==(RegionDrawCB *)handle) {
+ for (rdc = art->drawcalls.first; rdc; rdc = rdc->next) {
+ if (rdc == (RegionDrawCB *)handle) {
BLI_remlink(&art->drawcalls, rdc);
MEM_freeN(rdc);
return;
@@ -227,8 +227,8 @@ void ED_region_draw_cb_draw(const bContext *C, ARegion *ar, int type)
{
RegionDrawCB *rdc;
- for (rdc= ar->type->drawcalls.first; rdc; rdc= rdc->next) {
- if (rdc->type==type)
+ for (rdc = ar->type->drawcalls.first; rdc; rdc = rdc->next) {
+ if (rdc->type == type)
rdc->draw(C, ar, rdc->customdata);
}
}
@@ -283,14 +283,14 @@ void ED_spacetype_xxx(void)
{
static SpaceType st;
- st.spaceid= SPACE_VIEW3D;
+ st.spaceid = SPACE_VIEW3D;
- st.new= xxx_new;
- st.free= xxx_free;
- st.init= xxx_init;
- st.duplicate= xxx_duplicate;
- st.operatortypes= xxx_operatortypes;
- st.keymap= xxx_keymap;
+ st.new = xxx_new;
+ st.free = xxx_free;
+ st.init = xxx_init;
+ st.duplicate = xxx_duplicate;
+ st.operatortypes = xxx_operatortypes;
+ st.keymap = xxx_keymap;
BKE_spacetype_register(&st);
}
diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c
index 2cfdd7bc324..319e3f27bd8 100644
--- a/source/blender/imbuf/intern/allocimbuf.c
+++ b/source/blender/imbuf/intern/allocimbuf.c
@@ -51,39 +51,39 @@ void imb_freemipmapImBuf(ImBuf *ibuf)
{
int a;
- for (a=1; a<ibuf->miptot; a++) {
- if (ibuf->mipmap[a-1])
- IMB_freeImBuf(ibuf->mipmap[a-1]);
- ibuf->mipmap[a-1]= NULL;
+ for (a = 1; a < ibuf->miptot; a++) {
+ if (ibuf->mipmap[a - 1])
+ IMB_freeImBuf(ibuf->mipmap[a - 1]);
+ ibuf->mipmap[a - 1] = NULL;
}
- ibuf->miptot= 0;
+ ibuf->miptot = 0;
}
/* any free rect frees mipmaps to be sure, creation is in render on first request */
void imb_freerectfloatImBuf(ImBuf *ibuf)
{
- if (ibuf==NULL) return;
+ if (ibuf == NULL) return;
if (ibuf->rect_float && (ibuf->mall & IB_rectfloat)) {
MEM_freeN(ibuf->rect_float);
- ibuf->rect_float=NULL;
+ ibuf->rect_float = NULL;
}
imb_freemipmapImBuf(ibuf);
- ibuf->rect_float= NULL;
+ ibuf->rect_float = NULL;
ibuf->mall &= ~IB_rectfloat;
}
/* any free rect frees mipmaps to be sure, creation is in render on first request */
void imb_freerectImBuf(ImBuf *ibuf)
{
- if (ibuf==NULL) return;
+ if (ibuf == NULL) return;
if (ibuf->rect && (ibuf->mall & IB_rect))
MEM_freeN(ibuf->rect);
- ibuf->rect= NULL;
+ ibuf->rect = NULL;
imb_freemipmapImBuf(ibuf);
@@ -94,14 +94,14 @@ void imb_freetilesImBuf(ImBuf *ibuf)
{
int tx, ty;
- if (ibuf==NULL) return;
+ if (ibuf == NULL) return;
if (ibuf->tiles && (ibuf->mall & IB_tiles)) {
- for (ty=0; ty<ibuf->ytiles; ty++) {
- for (tx=0; tx<ibuf->xtiles; tx++) {
- if (ibuf->tiles[ibuf->xtiles*ty + tx]) {
+ for (ty = 0; ty < ibuf->ytiles; ty++) {
+ for (tx = 0; tx < ibuf->xtiles; tx++) {
+ if (ibuf->tiles[ibuf->xtiles * ty + tx]) {
imb_tile_cache_tile_free(ibuf, tx, ty);
- MEM_freeN(ibuf->tiles[ibuf->xtiles*ty + tx]);
+ MEM_freeN(ibuf->tiles[ibuf->xtiles * ty + tx]);
}
}
}
@@ -109,13 +109,13 @@ void imb_freetilesImBuf(ImBuf *ibuf)
MEM_freeN(ibuf->tiles);
}
- ibuf->tiles= NULL;
+ ibuf->tiles = NULL;
ibuf->mall &= ~IB_tiles;
}
static void freeencodedbufferImBuf(ImBuf *ibuf)
{
- if (ibuf==NULL) return;
+ if (ibuf == NULL) return;
if (ibuf->encodedbuffer && (ibuf->mall & IB_mem))
MEM_freeN(ibuf->encodedbuffer);
@@ -128,23 +128,23 @@ static void freeencodedbufferImBuf(ImBuf *ibuf)
void IMB_freezbufImBuf(ImBuf *ibuf)
{
- if (ibuf==NULL) return;
+ if (ibuf == NULL) return;
if (ibuf->zbuf && (ibuf->mall & IB_zbuf))
MEM_freeN(ibuf->zbuf);
- ibuf->zbuf= NULL;
+ ibuf->zbuf = NULL;
ibuf->mall &= ~IB_zbuf;
}
void IMB_freezbuffloatImBuf(ImBuf *ibuf)
{
- if (ibuf==NULL) return;
+ if (ibuf == NULL) return;
if (ibuf->zbuf_float && (ibuf->mall & IB_zbuffloat))
MEM_freeN(ibuf->zbuf_float);
- ibuf->zbuf_float= NULL;
+ ibuf->zbuf_float = NULL;
ibuf->mall &= ~IB_zbuffloat;
}
@@ -172,9 +172,9 @@ void IMB_refImBuf(ImBuf *ibuf)
ibuf->refcounter++;
}
-ImBuf * IMB_makeSingleUser(ImBuf *ibuf)
+ImBuf *IMB_makeSingleUser(ImBuf *ibuf)
{
- ImBuf * rval;
+ ImBuf *rval;
if (!ibuf || ibuf->refcounter == 0) { return ibuf; }
@@ -189,11 +189,11 @@ short addzbufImBuf(ImBuf *ibuf)
{
int size;
- if (ibuf==NULL) return FALSE;
+ if (ibuf == NULL) return FALSE;
IMB_freezbufImBuf(ibuf);
- size = ibuf->x *ibuf->y *sizeof(unsigned int);
+ size = ibuf->x * ibuf->y * sizeof(unsigned int);
if ((ibuf->zbuf = MEM_mapallocN(size, "addzbufImBuf"))) {
ibuf->mall |= IB_zbuf;
ibuf->flags |= IB_zbuf;
@@ -207,11 +207,11 @@ short addzbuffloatImBuf(ImBuf *ibuf)
{
int size;
- if (ibuf==NULL) return FALSE;
+ if (ibuf == NULL) return FALSE;
IMB_freezbuffloatImBuf(ibuf);
- size = ibuf->x *ibuf->y *sizeof(float);
+ size = ibuf->x * ibuf->y * sizeof(float);
if ((ibuf->zbuf_float = MEM_mapallocN(size, "addzbuffloatImBuf"))) {
ibuf->mall |= IB_zbuffloat;
ibuf->flags |= IB_zbuffloat;
@@ -224,7 +224,7 @@ short addzbuffloatImBuf(ImBuf *ibuf)
short imb_addencodedbufferImBuf(ImBuf *ibuf)
{
- if (ibuf==NULL) return FALSE;
+ if (ibuf == NULL) return FALSE;
freeencodedbufferImBuf(ibuf);
@@ -248,14 +248,14 @@ short imb_enlargeencodedbufferImBuf(ImBuf *ibuf)
unsigned int newsize, encodedsize;
void *newbuffer;
- if (ibuf==NULL) return FALSE;
+ if (ibuf == NULL) return FALSE;
if (ibuf->encodedbuffersize < ibuf->encodedsize) {
printf("imb_enlargeencodedbufferImBuf: error in parameters\n");
return FALSE;
}
- newsize = 2 *ibuf->encodedbuffersize;
+ newsize = 2 * ibuf->encodedbuffersize;
if (newsize < 10000) newsize = 10000;
newbuffer = MEM_mallocN(newsize, "enlargeencodedbufferImBuf");
@@ -285,14 +285,14 @@ short imb_addrectfloatImBuf(ImBuf *ibuf)
{
int size;
- if (ibuf==NULL) return FALSE;
+ if (ibuf == NULL) return FALSE;
if (ibuf->rect_float)
- imb_freerectfloatImBuf(ibuf); /* frees mipmap too, hrm */
+ imb_freerectfloatImBuf(ibuf); /* frees mipmap too, hrm */
- size = ibuf->x *ibuf->y;
- size = size *4 *sizeof(float);
- ibuf->channels= 4;
+ size = ibuf->x * ibuf->y;
+ size = size * 4 * sizeof(float);
+ ibuf->channels = 4;
if ((ibuf->rect_float = MEM_mapallocN(size, "imb_addrectfloatImBuf"))) {
ibuf->mall |= IB_rectfloat;
@@ -308,15 +308,15 @@ short imb_addrectImBuf(ImBuf *ibuf)
{
int size;
- if (ibuf==NULL) return FALSE;
+ if (ibuf == NULL) return FALSE;
/* don't call imb_freerectImBuf, it frees mipmaps, this call is used only too give float buffers display */
if (ibuf->rect && (ibuf->mall & IB_rect))
MEM_freeN(ibuf->rect);
- ibuf->rect= NULL;
+ ibuf->rect = NULL;
- size = ibuf->x*ibuf->y;
- size = size*sizeof(unsigned int);
+ size = ibuf->x * ibuf->y;
+ size = size * sizeof(unsigned int);
if ((ibuf->rect = MEM_mapallocN(size, "imb_addrectImBuf"))) {
ibuf->mall |= IB_rect;
@@ -330,10 +330,10 @@ short imb_addrectImBuf(ImBuf *ibuf)
short imb_addtilesImBuf(ImBuf *ibuf)
{
- if (ibuf==NULL) return FALSE;
+ if (ibuf == NULL) return FALSE;
if (!ibuf->tiles)
- if ((ibuf->tiles = MEM_callocN(sizeof(unsigned int*)*ibuf->xtiles*ibuf->ytiles, "imb_tiles")))
+ if ((ibuf->tiles = MEM_callocN(sizeof(unsigned int *) * ibuf->xtiles * ibuf->ytiles, "imb_tiles")))
ibuf->mall |= IB_tiles;
return (ibuf->tiles != NULL);
@@ -346,36 +346,36 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int
ibuf = MEM_callocN(sizeof(ImBuf), "ImBuf_struct");
if (ibuf) {
- ibuf->x= x;
- ibuf->y= y;
- ibuf->planes= planes;
- ibuf->ftype= TGA;
- ibuf->channels= 4; /* float option, is set to other values when buffers get assigned */
- ibuf->ppm[0]= ibuf->ppm[1]= 150.0 / 0.0254; /* 150dpi -> pixels-per-meter */
+ ibuf->x = x;
+ ibuf->y = y;
+ ibuf->planes = planes;
+ ibuf->ftype = TGA;
+ ibuf->channels = 4; /* float option, is set to other values when buffers get assigned */
+ ibuf->ppm[0] = ibuf->ppm[1] = 150.0 / 0.0254; /* 150dpi -> pixels-per-meter */
if (flags & IB_rect) {
- if (imb_addrectImBuf(ibuf)==FALSE) {
+ if (imb_addrectImBuf(ibuf) == FALSE) {
IMB_freeImBuf(ibuf);
return NULL;
}
}
if (flags & IB_rectfloat) {
- if (imb_addrectfloatImBuf(ibuf)==FALSE) {
+ if (imb_addrectfloatImBuf(ibuf) == FALSE) {
IMB_freeImBuf(ibuf);
return NULL;
}
}
if (flags & IB_zbuf) {
- if (addzbufImBuf(ibuf)==FALSE) {
+ if (addzbufImBuf(ibuf) == FALSE) {
IMB_freeImBuf(ibuf);
return NULL;
}
}
if (flags & IB_zbuffloat) {
- if (addzbuffloatImBuf(ibuf)==FALSE) {
+ if (addzbuffloatImBuf(ibuf) == FALSE) {
IMB_freeImBuf(ibuf);
return NULL;
}
@@ -404,10 +404,10 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1)
if (ibuf2 == NULL) return NULL;
if (flags & IB_rect)
- memcpy(ibuf2->rect, ibuf1->rect, x *y *sizeof(int));
+ memcpy(ibuf2->rect, ibuf1->rect, x * y * sizeof(int));
if (flags & IB_rectfloat)
- memcpy(ibuf2->rect_float, ibuf1->rect_float, ibuf1->channels *x *y *sizeof(float));
+ memcpy(ibuf2->rect_float, ibuf1->rect_float, ibuf1->channels * x * y * sizeof(float));
if (ibuf1->encodedbuffer) {
ibuf2->encodedbuffersize = ibuf1->encodedbuffersize;
@@ -423,16 +423,16 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1)
tbuf = *ibuf1;
// fix pointers
- tbuf.rect = ibuf2->rect;
- tbuf.rect_float = ibuf2->rect_float;
+ tbuf.rect = ibuf2->rect;
+ tbuf.rect_float = ibuf2->rect_float;
tbuf.encodedbuffer = ibuf2->encodedbuffer;
- tbuf.zbuf= NULL;
- tbuf.zbuf_float= NULL;
- for (a=0; a<IB_MIPMAP_LEVELS; a++)
- tbuf.mipmap[a]= NULL;
+ tbuf.zbuf = NULL;
+ tbuf.zbuf_float = NULL;
+ for (a = 0; a < IB_MIPMAP_LEVELS; a++)
+ tbuf.mipmap[a] = NULL;
// set malloc flag
- tbuf.mall = ibuf2->mall;
+ tbuf.mall = ibuf2->mall;
tbuf.c_handle = NULL;
tbuf.refcounter = 0;
@@ -449,7 +449,7 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1)
static void imbuf_cache_destructor(void *data)
{
- ImBuf *ibuf = (ImBuf*) data;
+ ImBuf *ibuf = (ImBuf *) data;
imb_freerectImBuf(ibuf);
imb_freerectfloatImBuf(ibuf);
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index 8f8c6311b30..062c7a9368d 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -48,7 +48,7 @@
void IMB_de_interlace(ImBuf *ibuf)
{
- ImBuf * tbuf1, * tbuf2;
+ ImBuf *tbuf1, *tbuf2;
if (ibuf == NULL) return;
if (ibuf->flags & IB_fields) return;
@@ -75,7 +75,7 @@ void IMB_de_interlace(ImBuf *ibuf)
void IMB_interlace(ImBuf *ibuf)
{
- ImBuf * tbuf1, * tbuf2;
+ ImBuf *tbuf1, *tbuf2;
if (ibuf == NULL) return;
ibuf->flags &= ~IB_fields;
@@ -113,13 +113,13 @@ DitherContext *create_dither_context(int w, float factor)
DitherContext *di;
int i;
- di= MEM_callocN(sizeof(DitherContext), "dithering context");
- di->f= factor / 16.0f;
- di->error_buf= MEM_callocN(4*(w+1)*sizeof(int), "dithering error");
- di->e= di->error_buf;
+ di = MEM_callocN(sizeof(DitherContext), "dithering context");
+ di->f = factor / 16.0f;
+ di->error_buf = MEM_callocN(4 * (w + 1) * sizeof(int), "dithering error");
+ di->e = di->error_buf;
- for (i=0; i<4; ++i)
- di->v[i]= di->v0[i]= di->v1[i]= 1024.0f*(BLI_frand()-0.5f);
+ for (i = 0; i < 4; ++i)
+ di->v[i] = di->v0[i] = di->v1[i] = 1024.0f * (BLI_frand() - 0.5f);
return di;
}
@@ -134,10 +134,10 @@ static void dither_finish_row(DitherContext *di)
{
int i;
- for (i=0; i<4; i++)
- di->v[i]= di->v0[i]= di->v1[i] = 0;
+ for (i = 0; i < 4; i++)
+ di->v[i] = di->v0[i] = di->v1[i] = 0;
- di->e= di->error_buf;
+ di->e = di->error_buf;
}
MINLINE unsigned char dither_value(unsigned short v_in, DitherContext *di, int i)
@@ -145,12 +145,12 @@ MINLINE unsigned char dither_value(unsigned short v_in, DitherContext *di, int i
int dv, d2;
unsigned char v_out;
- di->v[i] = v_in + (2*di->v[i] + di->e[4]) * di->f;
+ di->v[i] = v_in + (2 * di->v[i] + di->e[4]) * di->f;
CLAMP(di->v[i], 0, 0xFF00);
v_out = USHORTTOUCHAR(di->v[i]);
- di->v[i] -= v_out<<8;
+ di->v[i] -= v_out << 8;
dv = di->v[i];
- d2 = di->v[i]<<1;
+ d2 = di->v[i] << 1;
di->v[i] += d2;
*(di->e++) = di->v[i] + di->v0[i];
di->v[i] += d2;
@@ -166,18 +166,18 @@ MINLINE unsigned char dither_value(unsigned short v_in, DitherContext *di, int i
MINLINE void ushort_to_byte_v4(uchar b[4], const unsigned short us[4])
{
- b[0]= USHORTTOUCHAR(us[0]);
- b[1]= USHORTTOUCHAR(us[1]);
- b[2]= USHORTTOUCHAR(us[2]);
- b[3]= USHORTTOUCHAR(us[3]);
+ b[0] = USHORTTOUCHAR(us[0]);
+ b[1] = USHORTTOUCHAR(us[1]);
+ b[2] = USHORTTOUCHAR(us[2]);
+ b[3] = USHORTTOUCHAR(us[3]);
}
MINLINE void ushort_to_byte_dither_v4(uchar b[4], const unsigned short us[4], DitherContext *di)
{
- b[0]= dither_value(us[0], di, 0);
- b[1]= dither_value(us[1], di, 1);
- b[2]= dither_value(us[2], di, 2);
- b[3]= dither_value(us[3], di, 3);
+ b[0] = dither_value(us[0], di, 0);
+ b[1] = dither_value(us[1], di, 1);
+ b[2] = dither_value(us[2], di, 2);
+ b[3] = dither_value(us[3], di, 3);
}
MINLINE void float_to_byte_dither_v4(uchar b[4], const float f[4], DitherContext *di)
@@ -188,8 +188,8 @@ MINLINE void float_to_byte_dither_v4(uchar b[4], const float f[4], DitherContext
/* float to byte pixels, output 4-channel RGBA */
void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
- int channels_from, float dither, int profile_to, int profile_from, int predivide,
- int width, int height, int stride_to, int stride_from)
+ int channels_from, float dither, int profile_to, int profile_from, int predivide,
+ int width, int height, int stride_to, int stride_from)
{
float tmp[4];
int x, y;
@@ -201,32 +201,32 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
BLI_init_srgb_conversion();
if (dither)
- di= create_dither_context(width, dither);
+ di = create_dither_context(width, dither);
for (y = 0; y < height; y++) {
if (channels_from == 1) {
- /* single channel input */
- const float *from = rect_from + stride_from*y;
- uchar *to = rect_to + stride_to*y*4;
+ /* single channel input */
+ const float *from = rect_from + stride_from * y;
+ uchar *to = rect_to + stride_to * y * 4;
- for (x = 0; x < width; x++, from++, to+=4)
+ for (x = 0; x < width; x++, from++, to += 4)
to[0] = to[1] = to[2] = to[3] = FTOCHAR(from[0]);
}
else if (channels_from == 3) {
- /* RGB input */
- const float *from = rect_from + stride_from*y*3;
- uchar *to = rect_to + stride_to*y*4;
+ /* RGB input */
+ const float *from = rect_from + stride_from * y * 3;
+ uchar *to = rect_to + stride_to * y * 4;
if (profile_to == profile_from) {
/* no color space conversion */
- for (x = 0; x < width; x++, from+=3, to+=4) {
+ for (x = 0; x < width; x++, from += 3, to += 4) {
rgb_float_to_uchar(to, from);
to[3] = 255;
}
}
else if (profile_to == IB_PROFILE_SRGB) {
/* convert from linear to sRGB */
- for (x = 0; x < width; x++, from+=3, to+=4) {
+ for (x = 0; x < width; x++, from += 3, to += 4) {
linearrgb_to_srgb_v3_v3(tmp, from);
rgb_float_to_uchar(to, tmp);
to[3] = 255;
@@ -234,7 +234,7 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
}
else if (profile_to == IB_PROFILE_LINEAR_RGB) {
/* convert from sRGB to linear */
- for (x = 0; x < width; x++, from+=3, to+=4) {
+ for (x = 0; x < width; x++, from += 3, to += 4) {
srgb_to_linearrgb_v3_v3(tmp, from);
rgb_float_to_uchar(to, tmp);
to[3] = 255;
@@ -242,18 +242,18 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
}
}
else if (channels_from == 4) {
- /* RGBA input */
- const float *from = rect_from + stride_from*y*4;
- uchar *to = rect_to + stride_to*y*4;
+ /* RGBA input */
+ const float *from = rect_from + stride_from * y * 4;
+ uchar *to = rect_to + stride_to * y * 4;
if (profile_to == profile_from) {
/* no color space conversion */
if (dither) {
- for (x = 0; x < width; x++, from+=4, to+=4)
+ for (x = 0; x < width; x++, from += 4, to += 4)
float_to_byte_dither_v4(to, from, di);
}
else {
- for (x = 0; x < width; x++, from+=4, to+=4)
+ for (x = 0; x < width; x++, from += 4, to += 4)
rgba_float_to_uchar(to, from);
}
}
@@ -262,25 +262,25 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
unsigned short us[4];
if (dither && predivide) {
- for (x = 0; x < width; x++, from+=4, to+=4) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
linearrgb_to_srgb_ushort4_predivide(us, from);
ushort_to_byte_dither_v4(to, us, di);
}
}
else if (dither) {
- for (x = 0; x < width; x++, from+=4, to+=4) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
linearrgb_to_srgb_ushort4(us, from);
ushort_to_byte_dither_v4(to, us, di);
}
}
else if (predivide) {
- for (x = 0; x < width; x++, from+=4, to+=4) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
linearrgb_to_srgb_ushort4_predivide(us, from);
ushort_to_byte_v4(to, us);
}
}
else {
- for (x = 0; x < width; x++, from+=4, to+=4) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
linearrgb_to_srgb_ushort4(us, from);
ushort_to_byte_v4(to, us);
}
@@ -289,25 +289,25 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
else if (profile_to == IB_PROFILE_LINEAR_RGB) {
/* convert from sRGB to linear */
if (dither && predivide) {
- for (x = 0; x < width; x++, from+=4, to+=4) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
srgb_to_linearrgb_predivide_v4(tmp, from);
float_to_byte_dither_v4(to, tmp, di);
}
}
else if (dither) {
- for (x = 0; x < width; x++, from+=4, to+=4) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
srgb_to_linearrgb_v4(tmp, from);
float_to_byte_dither_v4(to, tmp, di);
}
}
else if (predivide) {
- for (x = 0; x < width; x++, from+=4, to+=4) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
srgb_to_linearrgb_predivide_v4(tmp, from);
rgba_float_to_uchar(to, tmp);
}
}
else {
- for (x = 0; x < width; x++, from+=4, to+=4) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
srgb_to_linearrgb_v4(tmp, from);
rgba_float_to_uchar(to, tmp);
}
@@ -325,8 +325,8 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from,
/* byte to float pixels, input and output 4-channel RGBA */
void IMB_buffer_float_from_byte(float *rect_to, const uchar *rect_from,
- int profile_to, int profile_from, int predivide,
- int width, int height, int stride_to, int stride_from)
+ int profile_to, int profile_from, int predivide,
+ int width, int height, int stride_to, int stride_from)
{
float tmp[4];
int x, y;
@@ -339,23 +339,23 @@ void IMB_buffer_float_from_byte(float *rect_to, const uchar *rect_from,
/* RGBA input */
for (y = 0; y < height; y++) {
- const uchar *from = rect_from + stride_from*y*4;
- float *to = rect_to + stride_to*y*4;
+ const uchar *from = rect_from + stride_from * y * 4;
+ float *to = rect_to + stride_to * y * 4;
if (profile_to == profile_from) {
/* no color space conversion */
- for (x = 0; x < width; x++, from+=4, to+=4)
+ for (x = 0; x < width; x++, from += 4, to += 4)
rgba_uchar_to_float(to, from);
}
else if (profile_to == IB_PROFILE_LINEAR_RGB) {
/* convert sRGB to linear */
if (predivide) {
- for (x = 0; x < width; x++, from+=4, to+=4) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
srgb_to_linearrgb_uchar4_predivide(to, from);
}
}
else {
- for (x = 0; x < width; x++, from+=4, to+=4) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
srgb_to_linearrgb_uchar4(to, from);
}
}
@@ -363,13 +363,13 @@ void IMB_buffer_float_from_byte(float *rect_to, const uchar *rect_from,
else if (profile_to == IB_PROFILE_SRGB) {
/* convert linear to sRGB */
if (predivide) {
- for (x = 0; x < width; x++, from+=4, to+=4) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
rgba_uchar_to_float(tmp, from);
linearrgb_to_srgb_predivide_v4(to, tmp);
}
}
else {
- for (x = 0; x < width; x++, from+=4, to+=4) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
rgba_uchar_to_float(tmp, from);
linearrgb_to_srgb_v4(to, tmp);
}
@@ -380,8 +380,8 @@ void IMB_buffer_float_from_byte(float *rect_to, const uchar *rect_from,
/* float to float pixels, output 4-channel RGBA */
void IMB_buffer_float_from_float(float *rect_to, const float *rect_from,
- int channels_from, int profile_to, int profile_from, int predivide,
- int width, int height, int stride_to, int stride_from)
+ int channels_from, int profile_to, int profile_from, int predivide,
+ int width, int height, int stride_to, int stride_from)
{
int x, y;
@@ -389,39 +389,39 @@ void IMB_buffer_float_from_float(float *rect_to, const float *rect_from,
BLI_assert(profile_to != IB_PROFILE_NONE);
BLI_assert(profile_from != IB_PROFILE_NONE);
- if (channels_from==1) {
+ if (channels_from == 1) {
/* single channel input */
for (y = 0; y < height; y++) {
- const float *from = rect_from + stride_from*y;
- float *to = rect_to + stride_to*y*4;
+ const float *from = rect_from + stride_from * y;
+ float *to = rect_to + stride_to * y * 4;
- for (x = 0; x < width; x++, from++, to+=4)
+ for (x = 0; x < width; x++, from++, to += 4)
to[0] = to[1] = to[2] = to[3] = from[0];
}
}
else if (channels_from == 3) {
/* RGB input */
for (y = 0; y < height; y++) {
- const float *from = rect_from + stride_from*y*3;
- float *to = rect_to + stride_to*y*4;
+ const float *from = rect_from + stride_from * y * 3;
+ float *to = rect_to + stride_to * y * 4;
if (profile_to == profile_from) {
/* no color space conversion */
- for (x = 0; x < width; x++, from+=3, to+=4) {
+ for (x = 0; x < width; x++, from += 3, to += 4) {
copy_v3_v3(to, from);
to[3] = 1.0f;
}
}
else if (profile_to == IB_PROFILE_LINEAR_RGB) {
/* convert from sRGB to linear */
- for (x = 0; x < width; x++, from+=3, to+=4) {
+ for (x = 0; x < width; x++, from += 3, to += 4) {
srgb_to_linearrgb_v3_v3(to, from);
to[3] = 1.0f;
}
}
else if (profile_to == IB_PROFILE_SRGB) {
/* convert from linear to sRGB */
- for (x = 0; x < width; x++, from+=3, to+=4) {
+ for (x = 0; x < width; x++, from += 3, to += 4) {
linearrgb_to_srgb_v3_v3(to, from);
to[3] = 1.0f;
}
@@ -431,32 +431,32 @@ void IMB_buffer_float_from_float(float *rect_to, const float *rect_from,
else if (channels_from == 4) {
/* RGBA input */
for (y = 0; y < height; y++) {
- const float *from = rect_from + stride_from*y*4;
- float *to = rect_to + stride_to*y*4;
+ const float *from = rect_from + stride_from * y * 4;
+ float *to = rect_to + stride_to * y * 4;
if (profile_to == profile_from) {
/* same profile, copy */
- memcpy(to, from, sizeof(float)*4*width);
+ memcpy(to, from, sizeof(float) * 4 * width);
}
else if (profile_to == IB_PROFILE_LINEAR_RGB) {
/* convert to sRGB to linear */
if (predivide) {
- for (x = 0; x < width; x++, from+=4, to+=4)
+ for (x = 0; x < width; x++, from += 4, to += 4)
srgb_to_linearrgb_predivide_v4(to, from);
}
else {
- for (x = 0; x < width; x++, from+=4, to+=4)
+ for (x = 0; x < width; x++, from += 4, to += 4)
srgb_to_linearrgb_v4(to, from);
}
}
else if (profile_to == IB_PROFILE_SRGB) {
/* convert from linear to sRGB */
if (predivide) {
- for (x = 0; x < width; x++, from+=4, to+=4)
+ for (x = 0; x < width; x++, from += 4, to += 4)
linearrgb_to_srgb_predivide_v4(to, from);
}
else {
- for (x = 0; x < width; x++, from+=4, to+=4)
+ for (x = 0; x < width; x++, from += 4, to += 4)
linearrgb_to_srgb_v4(to, from);
}
}
@@ -466,8 +466,8 @@ void IMB_buffer_float_from_float(float *rect_to, const float *rect_from,
/* byte to byte pixels, input and output 4-channel RGBA */
void IMB_buffer_byte_from_byte(uchar *rect_to, const uchar *rect_from,
- int profile_to, int profile_from, int predivide,
- int width, int height, int stride_to, int stride_from)
+ int profile_to, int profile_from, int predivide,
+ int width, int height, int stride_to, int stride_from)
{
float tmp[4];
int x, y;
@@ -478,24 +478,24 @@ void IMB_buffer_byte_from_byte(uchar *rect_to, const uchar *rect_from,
/* always RGBA input */
for (y = 0; y < height; y++) {
- const uchar *from = rect_from + stride_from*y*4;
- uchar *to = rect_to + stride_to*y*4;
+ const uchar *from = rect_from + stride_from * y * 4;
+ uchar *to = rect_to + stride_to * y * 4;
if (profile_to == profile_from) {
/* same profile, copy */
- memcpy(to, from, sizeof(uchar)*4*width);
+ memcpy(to, from, sizeof(uchar) * 4 * width);
}
else if (profile_to == IB_PROFILE_LINEAR_RGB) {
/* convert to sRGB to linear */
if (predivide) {
- for (x = 0; x < width; x++, from+=4, to+=4) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
rgba_uchar_to_float(tmp, from);
srgb_to_linearrgb_predivide_v4(tmp, tmp);
rgba_float_to_uchar(to, tmp);
}
}
else {
- for (x = 0; x < width; x++, from+=4, to+=4) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
rgba_uchar_to_float(tmp, from);
srgb_to_linearrgb_v4(tmp, tmp);
rgba_float_to_uchar(to, tmp);
@@ -505,14 +505,14 @@ void IMB_buffer_byte_from_byte(uchar *rect_to, const uchar *rect_from,
else if (profile_to == IB_PROFILE_SRGB) {
/* convert from linear to sRGB */
if (predivide) {
- for (x = 0; x < width; x++, from+=4, to+=4) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
rgba_uchar_to_float(tmp, from);
linearrgb_to_srgb_predivide_v4(tmp, tmp);
rgba_float_to_uchar(to, tmp);
}
}
else {
- for (x = 0; x < width; x++, from+=4, to+=4) {
+ for (x = 0; x < width; x++, from += 4, to += 4) {
rgba_uchar_to_float(tmp, from);
linearrgb_to_srgb_v4(tmp, tmp);
rgba_float_to_uchar(to, tmp);
@@ -526,15 +526,15 @@ void IMB_buffer_byte_from_byte(uchar *rect_to, const uchar *rect_from,
void IMB_rect_from_float(ImBuf *ibuf)
{
- int predivide= (ibuf->flags & IB_cm_predivide);
+ int predivide = (ibuf->flags & IB_cm_predivide);
int profile_from;
/* verify we have a float buffer */
- if (ibuf->rect_float==NULL)
+ if (ibuf->rect_float == NULL)
return;
/* create byte rect if it didn't exist yet */
- if (ibuf->rect==NULL)
+ if (ibuf->rect == NULL)
imb_addrectImBuf(ibuf);
/* determine profiles */
@@ -546,9 +546,9 @@ void IMB_rect_from_float(ImBuf *ibuf)
BLI_assert(0);
/* do conversion */
- IMB_buffer_byte_from_float((uchar*)ibuf->rect, ibuf->rect_float,
- ibuf->channels, ibuf->dither, IB_PROFILE_SRGB, profile_from, predivide,
- ibuf->x, ibuf->y, ibuf->x, ibuf->x);
+ IMB_buffer_byte_from_float((uchar *)ibuf->rect, ibuf->rect_float,
+ ibuf->channels, ibuf->dither, IB_PROFILE_SRGB, profile_from, predivide,
+ ibuf->x, ibuf->y, ibuf->x, ibuf->x);
/* ensure user flag is reset */
ibuf->userflags &= ~IB_RECT_INVALID;
@@ -559,15 +559,15 @@ void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w
{
float *rect_float;
uchar *rect_byte;
- int predivide= (ibuf->flags & IB_cm_predivide);
+ int predivide = (ibuf->flags & IB_cm_predivide);
int profile_from;
/* verify we have a float buffer */
- if (ibuf->rect_float==NULL || buffer==NULL)
+ if (ibuf->rect_float == NULL || buffer == NULL)
return;
/* create byte rect if it didn't exist yet */
- if (ibuf->rect==NULL)
+ if (ibuf->rect == NULL)
imb_addrectImBuf(ibuf);
/* determine profiles */
@@ -579,16 +579,16 @@ void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w
BLI_assert(0);
/* do conversion */
- rect_float= ibuf->rect_float + (x + y*ibuf->x)*ibuf->channels;
- rect_byte= (uchar*)ibuf->rect + (x + y*ibuf->x)*4;
+ rect_float = ibuf->rect_float + (x + y * ibuf->x) * ibuf->channels;
+ rect_byte = (uchar *)ibuf->rect + (x + y * ibuf->x) * 4;
IMB_buffer_float_from_float(buffer, rect_float,
- ibuf->channels, IB_PROFILE_SRGB, profile_from, predivide,
- w, h, w, ibuf->x);
+ ibuf->channels, IB_PROFILE_SRGB, profile_from, predivide,
+ w, h, w, ibuf->x);
IMB_buffer_byte_from_float(rect_byte, buffer,
- 4, ibuf->dither, IB_PROFILE_SRGB, IB_PROFILE_SRGB, 0,
- w, h, ibuf->x, w);
+ 4, ibuf->dither, IB_PROFILE_SRGB, IB_PROFILE_SRGB, 0,
+ w, h, ibuf->x, w);
/* ensure user flag is reset */
ibuf->userflags &= ~IB_RECT_INVALID;
@@ -596,14 +596,14 @@ void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w
void IMB_float_from_rect(ImBuf *ibuf)
{
- int predivide= (ibuf->flags & IB_cm_predivide);
+ int predivide = (ibuf->flags & IB_cm_predivide);
int profile_from;
/* verify if we byte and float buffers */
- if (ibuf->rect==NULL)
+ if (ibuf->rect == NULL)
return;
- if (ibuf->rect_float==NULL)
+ if (ibuf->rect_float == NULL)
if (imb_addrectfloatImBuf(ibuf) == 0)
return;
@@ -614,27 +614,27 @@ void IMB_float_from_rect(ImBuf *ibuf)
profile_from = IB_PROFILE_SRGB;
/* do conversion */
- IMB_buffer_float_from_byte(ibuf->rect_float, (uchar*)ibuf->rect,
- IB_PROFILE_LINEAR_RGB, profile_from, predivide,
- ibuf->x, ibuf->y, ibuf->x, ibuf->x);
+ IMB_buffer_float_from_byte(ibuf->rect_float, (uchar *)ibuf->rect,
+ IB_PROFILE_LINEAR_RGB, profile_from, predivide,
+ ibuf->x, ibuf->y, ibuf->x, ibuf->x);
}
/* no profile conversion */
void IMB_float_from_rect_simple(ImBuf *ibuf)
{
- int predivide= (ibuf->flags & IB_cm_predivide);
+ int predivide = (ibuf->flags & IB_cm_predivide);
- if (ibuf->rect_float==NULL)
+ if (ibuf->rect_float == NULL)
imb_addrectfloatImBuf(ibuf);
- IMB_buffer_float_from_byte(ibuf->rect_float, (uchar*)ibuf->rect,
- IB_PROFILE_SRGB, IB_PROFILE_SRGB, predivide,
- ibuf->x, ibuf->y, ibuf->x, ibuf->x);
+ IMB_buffer_float_from_byte(ibuf->rect_float, (uchar *)ibuf->rect,
+ IB_PROFILE_SRGB, IB_PROFILE_SRGB, predivide,
+ ibuf->x, ibuf->y, ibuf->x, ibuf->x);
}
void IMB_convert_profile(ImBuf *ibuf, int profile)
{
- int predivide= (ibuf->flags & IB_cm_predivide);
+ int predivide = (ibuf->flags & IB_cm_predivide);
int profile_from, profile_to;
if (ibuf->profile == profile)
@@ -662,25 +662,25 @@ void IMB_convert_profile(ImBuf *ibuf, int profile)
/* do conversion */
if (ibuf->rect_float) {
IMB_buffer_float_from_float(ibuf->rect_float, ibuf->rect_float,
- 4, profile_to, profile_from, predivide,
- ibuf->x, ibuf->y, ibuf->x, ibuf->x);
+ 4, profile_to, profile_from, predivide,
+ ibuf->x, ibuf->y, ibuf->x, ibuf->x);
}
if (ibuf->rect) {
- IMB_buffer_byte_from_byte((uchar*)ibuf->rect, (uchar*)ibuf->rect,
- profile_to, profile_from, predivide,
- ibuf->x, ibuf->y, ibuf->x, ibuf->x);
+ IMB_buffer_byte_from_byte((uchar *)ibuf->rect, (uchar *)ibuf->rect,
+ profile_to, profile_from, predivide,
+ ibuf->x, ibuf->y, ibuf->x, ibuf->x);
}
/* set new profile */
- ibuf->profile= profile;
+ ibuf->profile = profile;
}
/* use when you need to get a buffer with a certain profile
* if the return */
float *IMB_float_profile_ensure(ImBuf *ibuf, int profile, int *alloc)
{
- int predivide= (ibuf->flags & IB_cm_predivide);
+ int predivide = (ibuf->flags & IB_cm_predivide);
int profile_from, profile_to;
/* determine profiles */
@@ -696,7 +696,7 @@ float *IMB_float_profile_ensure(ImBuf *ibuf, int profile, int *alloc)
if (profile_from == profile_to) {
/* simple case, just allocate the buffer and return */
- *alloc= 0;
+ *alloc = 0;
if (ibuf->rect_float == NULL)
IMB_float_from_rect(ibuf);
@@ -705,18 +705,18 @@ float *IMB_float_profile_ensure(ImBuf *ibuf, int profile, int *alloc)
}
else {
/* conversion is needed, first check */
- float *fbuf= MEM_mallocN(ibuf->x * ibuf->y * sizeof(float) * 4, "IMB_float_profile_ensure");
- *alloc= 1;
+ float *fbuf = MEM_mallocN(ibuf->x * ibuf->y * sizeof(float) * 4, "IMB_float_profile_ensure");
+ *alloc = 1;
if (ibuf->rect_float == NULL) {
- IMB_buffer_float_from_byte(fbuf, (uchar*)ibuf->rect,
- profile_to, profile_from, predivide,
- ibuf->x, ibuf->y, ibuf->x, ibuf->x);
+ IMB_buffer_float_from_byte(fbuf, (uchar *)ibuf->rect,
+ profile_to, profile_from, predivide,
+ ibuf->x, ibuf->y, ibuf->x, ibuf->x);
}
else {
IMB_buffer_float_from_float(fbuf, ibuf->rect_float,
- 4, profile_to, profile_from, predivide,
- ibuf->x, ibuf->y, ibuf->x, ibuf->x);
+ 4, profile_to, profile_from, predivide,
+ ibuf->x, ibuf->y, ibuf->x, ibuf->x);
}
return fbuf;
@@ -728,24 +728,24 @@ float *IMB_float_profile_ensure(ImBuf *ibuf, int profile, int *alloc)
/* no profile conversion */
void IMB_color_to_bw(ImBuf *ibuf)
{
- float *rctf= ibuf->rect_float;
- uchar *rct= (uchar*)ibuf->rect;
+ float *rctf = ibuf->rect_float;
+ uchar *rct = (uchar *)ibuf->rect;
int i;
if (rctf) {
- for (i = ibuf->x * ibuf->y; i > 0; i--, rctf+=4)
- rctf[0]= rctf[1]= rctf[2]= rgb_to_grayscale(rctf);
+ for (i = ibuf->x * ibuf->y; i > 0; i--, rctf += 4)
+ rctf[0] = rctf[1] = rctf[2] = rgb_to_grayscale(rctf);
}
if (rct) {
- for (i = ibuf->x * ibuf->y; i > 0; i--, rct+=4)
- rct[0]= rct[1]= rct[2]= rgb_to_grayscale_byte(rct);
+ for (i = ibuf->x * ibuf->y; i > 0; i--, rct += 4)
+ rct[0] = rct[1] = rct[2] = rgb_to_grayscale_byte(rct);
}
}
void IMB_buffer_float_clamp(float *buf, int width, int height)
{
- int i, total = width*height*4;
+ int i, total = width * height * 4;
for (i = 0; i < total; i++) {
buf[i] = MIN2(1.0, buf[i]);
}
@@ -753,27 +753,27 @@ void IMB_buffer_float_clamp(float *buf, int width, int height)
/**************************** alter saturation *****************************/
-void IMB_saturation(ImBuf * ibuf, float sat)
+void IMB_saturation(ImBuf *ibuf, float sat)
{
int i;
- unsigned char *rct= (unsigned char *)ibuf->rect;
- float *rctf= ibuf->rect_float;
+ unsigned char *rct = (unsigned char *)ibuf->rect;
+ float *rctf = ibuf->rect_float;
float hsv[3];
if (rct) {
float rgb[3];
- for (i = ibuf->x * ibuf->y; i > 0; i--, rct+=4) {
+ for (i = ibuf->x * ibuf->y; i > 0; i--, rct += 4) {
rgb_uchar_to_float(rgb, rct);
- rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
- hsv_to_rgb(hsv[0], hsv[1] * sat, hsv[2], rgb, rgb+1, rgb+2);
+ rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
+ hsv_to_rgb(hsv[0], hsv[1] * sat, hsv[2], rgb, rgb + 1, rgb + 2);
rgb_float_to_uchar(rct, rgb);
}
}
if (rctf) {
- for (i = ibuf->x * ibuf->y; i > 0; i--, rctf+=4) {
- rgb_to_hsv(rctf[0], rctf[1], rctf[2], hsv, hsv+1, hsv+2);
- hsv_to_rgb(hsv[0], hsv[1] * sat, hsv[2], rctf, rctf+1, rctf+2);
+ for (i = ibuf->x * ibuf->y; i > 0; i--, rctf += 4) {
+ rgb_to_hsv(rctf[0], rctf[1], rctf[2], hsv, hsv + 1, hsv + 2);
+ hsv_to_rgb(hsv[0], hsv[1] * sat, hsv[2], rctf, rctf + 1, rctf + 2);
}
}
}
diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c
index bc5e85a3c55..e744851a9b6 100644
--- a/source/blender/imbuf/intern/filter.c
+++ b/source/blender/imbuf/intern/filter.c
@@ -49,19 +49,19 @@ static void filtrow(unsigned char *point, int x)
{
unsigned int c1, c2, c3, error;
- if (x>1) {
+ if (x > 1) {
c1 = c2 = *point;
error = 2;
- for (x--;x>0;x--) {
+ for (x--; x > 0; x--) {
c3 = point[4];
- c1 += (c2<<1) + c3 + error;
+ c1 += (c2 << 1) + c3 + error;
error = c1 & 3;
*point = c1 >> 2;
point += 4;
- c1=c2;
- c2=c3;
+ c1 = c2;
+ c2 = c3;
}
- *point = (c1 + (c2<<1) + c2 + error) >> 2;
+ *point = (c1 + (c2 << 1) + c2 + error) >> 2;
}
}
@@ -69,17 +69,17 @@ static void filtrowf(float *point, int x)
{
float c1, c2, c3;
- if (x>1) {
+ if (x > 1) {
c1 = c2 = *point;
- for (x--;x>0;x--) {
+ for (x--; x > 0; x--) {
c3 = point[4];
c1 += (c2 * 2) + c3;
- *point = 0.25f*c1;
+ *point = 0.25f * c1;
point += 4;
- c1=c2;
- c2=c3;
+ c1 = c2;
+ c2 = c3;
}
- *point = 0.25f*(c1 + (c2 * 2) + c2);
+ *point = 0.25f * (c1 + (c2 * 2) + c2);
}
}
@@ -90,21 +90,21 @@ static void filtcolum(unsigned char *point, int y, int skip)
unsigned int c1, c2, c3, error;
unsigned char *point2;
- if (y>1) {
+ if (y > 1) {
c1 = c2 = *point;
point2 = point;
error = 2;
- for (y--;y>0;y--) {
+ for (y--; y > 0; y--) {
point2 += skip;
c3 = *point2;
- c1 += (c2<<1) + c3 +error;
+ c1 += (c2 << 1) + c3 + error;
error = c1 & 3;
*point = c1 >> 2;
- point=point2;
- c1=c2;
- c2=c3;
+ point = point2;
+ c1 = c2;
+ c2 = c3;
}
- *point = (c1 + (c2<<1) + c2 + error) >> 2;
+ *point = (c1 + (c2 << 1) + c2 + error) >> 2;
}
}
@@ -112,19 +112,19 @@ static void filtcolumf(float *point, int y, int skip)
{
float c1, c2, c3, *point2;
- if (y>1) {
+ if (y > 1) {
c1 = c2 = *point;
point2 = point;
- for (y--;y>0;y--) {
+ for (y--; y > 0; y--) {
point2 += skip;
c3 = *point2;
c1 += (c2 * 2) + c3;
- *point = 0.25f*c1;
- point=point2;
- c1=c2;
- c2=c3;
+ *point = 0.25f * c1;
+ point = point2;
+ c1 = c2;
+ c2 = c3;
}
- *point = 0.25f*(c1 + (c2 * 2) + c2);
+ *point = 0.25f * (c1 + (c2 * 2) + c2);
}
}
@@ -139,9 +139,9 @@ void IMB_filtery(struct ImBuf *ibuf)
x = ibuf->x;
y = ibuf->y;
- skip = x<<2;
+ skip = x << 2;
- for (;x>0;x--) {
+ for (; x > 0; x--) {
if (point) {
if (ibuf->planes > 24) filtcolum(point, y, skip);
point++;
@@ -177,9 +177,9 @@ void imb_filterx(struct ImBuf *ibuf)
x = ibuf->x;
y = ibuf->y;
- skip = (x<<2) - 3;
+ skip = (x << 2) - 3;
- for (;y>0;y--) {
+ for (; y > 0; y--) {
if (point) {
if (ibuf->planes > 24) filtrow(point, x);
point++;
@@ -188,7 +188,7 @@ void imb_filterx(struct ImBuf *ibuf)
filtrow(point, x);
point++;
filtrow(point, x);
- point+=skip;
+ point += skip;
}
if (pointf) {
if (ibuf->planes > 24) filtrowf(pointf, x);
@@ -198,7 +198,7 @@ void imb_filterx(struct ImBuf *ibuf)
filtrowf(pointf, x);
pointf++;
filtrowf(pointf, x);
- pointf+=skip;
+ pointf += skip;
}
}
}
@@ -209,44 +209,44 @@ void IMB_filterN(ImBuf *out, ImBuf *in)
register char *cp, *r11, *r13, *r21, *r23, *r31, *r33;
int rowlen, x, y;
- rowlen= in->x;
+ rowlen = in->x;
- for (y=0; y<in->y; y++) {
+ for (y = 0; y < in->y; y++) {
/* setup rows */
- row2= (char*)(in->rect + y*rowlen);
- row1= (y == 0)? row2: row2 - 4*rowlen;
- row3= (y == in->y-1)? row2: row2 + 4*rowlen;
+ row2 = (char *)(in->rect + y * rowlen);
+ row1 = (y == 0) ? row2 : row2 - 4 * rowlen;
+ row3 = (y == in->y - 1) ? row2 : row2 + 4 * rowlen;
- cp= (char *)(out->rect + y*rowlen);
+ cp = (char *)(out->rect + y * rowlen);
- for (x=0; x<rowlen; x++) {
+ for (x = 0; x < rowlen; x++) {
if (x == 0) {
r11 = row1;
r21 = row1;
r31 = row1;
}
else {
- r11 = row1-4;
- r21 = row1-4;
- r31 = row1-4;
+ r11 = row1 - 4;
+ r21 = row1 - 4;
+ r31 = row1 - 4;
}
- if (x == rowlen-1) {
+ if (x == rowlen - 1) {
r13 = row1;
r23 = row1;
r33 = row1;
}
else {
- r13 = row1+4;
- r23 = row1+4;
- r33 = row1+4;
+ r13 = row1 + 4;
+ r23 = row1 + 4;
+ r33 = row1 + 4;
}
- cp[0]= (r11[0] + 2*row1[0] + r13[0] + 2*r21[0] + 4*row2[0] + 2*r23[0] + r31[0] + 2*row3[0] + r33[0])>>4;
- cp[1]= (r11[1] + 2*row1[1] + r13[1] + 2*r21[1] + 4*row2[1] + 2*r23[1] + r31[1] + 2*row3[1] + r33[1])>>4;
- cp[2]= (r11[2] + 2*row1[2] + r13[2] + 2*r21[2] + 4*row2[2] + 2*r23[2] + r31[2] + 2*row3[2] + r33[2])>>4;
- cp[3]= (r11[3] + 2*row1[3] + r13[3] + 2*r21[3] + 4*row2[3] + 2*r23[3] + r31[3] + 2*row3[3] + r33[3])>>4;
- cp+=4; row1+=4; row2+=4; row3+=4;
+ cp[0] = (r11[0] + 2 * row1[0] + r13[0] + 2 * r21[0] + 4 * row2[0] + 2 * r23[0] + r31[0] + 2 * row3[0] + r33[0]) >> 4;
+ cp[1] = (r11[1] + 2 * row1[1] + r13[1] + 2 * r21[1] + 4 * row2[1] + 2 * r23[1] + r31[1] + 2 * row3[1] + r33[1]) >> 4;
+ cp[2] = (r11[2] + 2 * row1[2] + r13[2] + 2 * r21[2] + 4 * row2[2] + 2 * r23[2] + r31[2] + 2 * row3[2] + r33[2]) >> 4;
+ cp[3] = (r11[3] + 2 * row1[3] + r13[3] + 2 * r21[3] + 4 * row2[3] + 2 * r23[3] + r31[3] + 2 * row3[3] + r33[3]) >> 4;
+ cp += 4; row1 += 4; row2 += 4; row3 += 4;
}
}
}
@@ -263,32 +263,32 @@ void IMB_mask_filter_extend(char *mask, int width, int height)
int rowlen, x, y;
char *temprect;
- rowlen= width;
+ rowlen = width;
/* make a copy, to prevent flooding */
- temprect= MEM_dupallocN(mask);
+ temprect = MEM_dupallocN(mask);
- for (y=1; y<=height; y++) {
+ for (y = 1; y <= height; y++) {
/* setup rows */
- row1= (char *)(temprect + (y-2)*rowlen);
- row2= row1 + rowlen;
- row3= row2 + rowlen;
- if (y==1)
- row1= row2;
- else if (y==height)
- row3= row2;
-
- for (x=0; x<rowlen; x++) {
- if (mask[((y-1)*rowlen)+x]==0) {
- if (*row1 || *row2 || *row3 || *(row1+1) || *(row3+1) ) {
- mask[((y-1)*rowlen)+x] = FILTER_MASK_MARGIN;
+ row1 = (char *)(temprect + (y - 2) * rowlen);
+ row2 = row1 + rowlen;
+ row3 = row2 + rowlen;
+ if (y == 1)
+ row1 = row2;
+ else if (y == height)
+ row3 = row2;
+
+ for (x = 0; x < rowlen; x++) {
+ if (mask[((y - 1) * rowlen) + x] == 0) {
+ if (*row1 || *row2 || *row3 || *(row1 + 1) || *(row3 + 1) ) {
+ mask[((y - 1) * rowlen) + x] = FILTER_MASK_MARGIN;
}
- else if ((x!=rowlen-1) && (*(row1+2) || *(row2+2) || *(row3+2)) ) {
- mask[((y-1)*rowlen)+x] = FILTER_MASK_MARGIN;
+ else if ((x != rowlen - 1) && (*(row1 + 2) || *(row2 + 2) || *(row3 + 2)) ) {
+ mask[((y - 1) * rowlen) + x] = FILTER_MASK_MARGIN;
}
}
- if (x!=0) {
+ if (x != 0) {
row1++; row2++; row3++;
}
}
@@ -301,10 +301,10 @@ void IMB_mask_clear(ImBuf *ibuf, char *mask, int val)
{
int x, y;
if (ibuf->rect_float) {
- for (x=0; x<ibuf->x; x++) {
- for (y=0; y<ibuf->y; y++) {
- if (mask[ibuf->x*y + x] == val) {
- float *col= ibuf->rect_float + 4*(ibuf->x*y + x);
+ for (x = 0; x < ibuf->x; x++) {
+ for (y = 0; y < ibuf->y; y++) {
+ if (mask[ibuf->x * y + x] == val) {
+ float *col = ibuf->rect_float + 4 * (ibuf->x * y + x);
col[0] = col[1] = col[2] = col[3] = 0.0f;
}
}
@@ -312,10 +312,10 @@ void IMB_mask_clear(ImBuf *ibuf, char *mask, int val)
}
else {
/* char buffer */
- for (x=0; x<ibuf->x; x++) {
- for (y=0; y<ibuf->y; y++) {
- if (mask[ibuf->x*y + x] == val) {
- char *col= (char *)(ibuf->rect + ibuf->x*y + x);
+ for (x = 0; x < ibuf->x; x++) {
+ for (y = 0; y < ibuf->y; y++) {
+ if (mask[ibuf->x * y + x] == val) {
+ char *col = (char *)(ibuf->rect + ibuf->x * y + x);
col[0] = col[1] = col[2] = col[3] = 0;
}
}
@@ -325,23 +325,23 @@ void IMB_mask_clear(ImBuf *ibuf, char *mask, int val)
static int filter_make_index(const int x, const int y, const int w, const int h)
{
- if (x<0 || x>=w || y<0 || y>=h) return -1; /* return bad index */
- else return y*w+x;
+ if (x < 0 || x >= w || y < 0 || y >= h) return -1; /* return bad index */
+ else return y * w + x;
}
static int check_pixel_assigned(const void *buffer, const char *mask, const int index, const int depth, const int is_float)
{
int res = 0;
- if (index>=0) {
- const int alpha_index = depth*index+(depth-1);
+ if (index >= 0) {
+ const int alpha_index = depth * index + (depth - 1);
- if (mask!=NULL) {
- res = mask[index]!=0 ? 1 : 0;
+ if (mask != NULL) {
+ res = mask[index] != 0 ? 1 : 0;
}
- else if ( (is_float && ((const float *) buffer)[alpha_index]!=0.0f) ||
- (!is_float && ((const unsigned char *) buffer)[alpha_index]!=0) ) {
- res=1;
+ else if ( (is_float && ((const float *) buffer)[alpha_index] != 0.0f) ||
+ (!is_float && ((const unsigned char *) buffer)[alpha_index] != 0) ) {
+ res = 1;
}
}
@@ -354,93 +354,94 @@ static int check_pixel_assigned(const void *buffer, const char *mask, const int
* */
void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter)
{
- const int width= ibuf->x;
- const int height= ibuf->y;
- const int depth= 4; /* always 4 channels */
- const int chsize= ibuf->rect_float ? sizeof(float) : sizeof(unsigned char);
- const int bsize= width*height*depth*chsize;
- const int is_float= ibuf->rect_float!=NULL;
- void *dstbuf= (void *) MEM_dupallocN(ibuf->rect_float ? (void *) ibuf->rect_float : (void *) ibuf->rect);
- char *dstmask= mask==NULL ? NULL : (char *) MEM_dupallocN(mask);
- void *srcbuf= ibuf->rect_float ? (void *) ibuf->rect_float : (void *) ibuf->rect;
- char *srcmask= mask;
- int cannot_early_out= 1, r, n, k, i, j, c;
+ const int width = ibuf->x;
+ const int height = ibuf->y;
+ const int depth = 4; /* always 4 channels */
+ const int chsize = ibuf->rect_float ? sizeof(float) : sizeof(unsigned char);
+ const int bsize = width * height * depth * chsize;
+ const int is_float = ibuf->rect_float != NULL;
+ void *dstbuf = (void *) MEM_dupallocN(ibuf->rect_float ? (void *) ibuf->rect_float : (void *) ibuf->rect);
+ char *dstmask = mask == NULL ? NULL : (char *) MEM_dupallocN(mask);
+ void *srcbuf = ibuf->rect_float ? (void *) ibuf->rect_float : (void *) ibuf->rect;
+ char *srcmask = mask;
+ int cannot_early_out = 1, r, n, k, i, j, c;
float weight[25];
/* build a weights buffer */
- n= 1;
+ n = 1;
#if 0
- k= 0;
+ k = 0;
for (i = -n; i <= n; i++)
for (j = -n; j <= n; j++)
weight[k++] = sqrt((float) i * i + j * j);
#endif
- weight[0]=1; weight[1]=2; weight[2]=1;
- weight[3]=2; weight[4]=0; weight[5]=2;
- weight[6]=1; weight[7]=2; weight[8]=1;
+ weight[0] = 1; weight[1] = 2; weight[2] = 1;
+ weight[3] = 2; weight[4] = 0; weight[5] = 2;
+ weight[6] = 1; weight[7] = 2; weight[8] = 1;
/* run passes */
for (r = 0; cannot_early_out == 1 && r < filter; r++) {
int x, y;
cannot_early_out = 0;
- for (y= 0; y<height; y++) {
- for (x= 0; x<width; x++) {
- const int index= filter_make_index(x, y, width, height);
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ const int index = filter_make_index(x, y, width, height);
/* only update unassigned pixels */
if (!check_pixel_assigned(srcbuf, srcmask, index, depth, is_float)) {
float tmp[4];
- float wsum=0;
- float acc[4]={0, 0, 0, 0};
+ float wsum = 0;
+ float acc[4] = {0, 0, 0, 0};
k = 0;
- if (check_pixel_assigned(srcbuf, srcmask, filter_make_index(x-1, y, width, height), depth, is_float) ||
- check_pixel_assigned(srcbuf, srcmask, filter_make_index(x+1, y, width, height), depth, is_float) ||
- check_pixel_assigned(srcbuf, srcmask, filter_make_index(x, y-1, width, height), depth, is_float) ||
- check_pixel_assigned(srcbuf, srcmask, filter_make_index(x, y+1, width, height), depth, is_float)) {
- for (i= -n; i<=n; i++) {
- for (j=-n; j<=n; j++) {
+ if (check_pixel_assigned(srcbuf, srcmask, filter_make_index(x - 1, y, width, height), depth, is_float) ||
+ check_pixel_assigned(srcbuf, srcmask, filter_make_index(x + 1, y, width, height), depth, is_float) ||
+ check_pixel_assigned(srcbuf, srcmask, filter_make_index(x, y - 1, width, height), depth, is_float) ||
+ check_pixel_assigned(srcbuf, srcmask, filter_make_index(x, y + 1, width, height), depth, is_float))
+ {
+ for (i = -n; i <= n; i++) {
+ for (j = -n; j <= n; j++) {
if (i != 0 || j != 0) {
- const int tmpindex= filter_make_index(x+i, y+j, width, height);
+ const int tmpindex = filter_make_index(x + i, y + j, width, height);
- if (check_pixel_assigned(srcbuf, srcmask, tmpindex, depth, is_float)) {
+ if (check_pixel_assigned(srcbuf, srcmask, tmpindex, depth, is_float)) {
if (is_float) {
- for (c=0; c<depth; c++)
- tmp[c] = ((const float *) srcbuf)[depth*tmpindex+c];
+ for (c = 0; c < depth; c++)
+ tmp[c] = ((const float *) srcbuf)[depth * tmpindex + c];
}
else {
- for (c=0; c<depth; c++)
- tmp[c] = (float) ((const unsigned char *) srcbuf)[depth*tmpindex+c];
+ for (c = 0; c < depth; c++)
+ tmp[c] = (float) ((const unsigned char *) srcbuf)[depth * tmpindex + c];
}
- wsum+= weight[k];
+ wsum += weight[k];
- for (c=0; c<depth; c++)
- acc[c]+= weight[k] * tmp[c];
+ for (c = 0; c < depth; c++)
+ acc[c] += weight[k] * tmp[c];
}
}
k++;
}
}
- if (wsum!=0) {
- for (c=0; c<depth; c++)
- acc[c]/= wsum;
+ if (wsum != 0) {
+ for (c = 0; c < depth; c++)
+ acc[c] /= wsum;
if (is_float) {
- for (c=0; c<depth; c++)
- ((float *) dstbuf)[depth*index+c] = acc[c];
+ for (c = 0; c < depth; c++)
+ ((float *) dstbuf)[depth * index + c] = acc[c];
}
else {
- for (c=0; c<depth; c++) {
- ((unsigned char *) dstbuf)[depth*index+c]= acc[c] > 255 ? 255 : (acc[c] < 0 ? 0 : ((unsigned char) (acc[c]+0.5f)));
+ for (c = 0; c < depth; c++) {
+ ((unsigned char *) dstbuf)[depth * index + c] = acc[c] > 255 ? 255 : (acc[c] < 0 ? 0 : ((unsigned char) (acc[c] + 0.5f)));
}
}
- if (dstmask!=NULL) dstmask[index]=FILTER_MASK_MARGIN; /* assigned */
+ if (dstmask != NULL) dstmask[index] = FILTER_MASK_MARGIN; /* assigned */
cannot_early_out = 1;
}
}
@@ -450,12 +451,12 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter)
/* keep the original buffer up to date. */
memcpy(srcbuf, dstbuf, bsize);
- if (dstmask!=NULL) memcpy(srcmask, dstmask, width*height);
+ if (dstmask != NULL) memcpy(srcmask, dstmask, width * height);
}
/* free memory */
MEM_freeN(dstbuf);
- if (dstmask!=NULL) MEM_freeN(dstmask);
+ if (dstmask != NULL) MEM_freeN(dstmask);
}
/* threadsafe version, only recreates existing maps */
@@ -464,14 +465,14 @@ void IMB_remakemipmap(ImBuf *ibuf, int use_filter)
ImBuf *hbuf = ibuf;
int curmap = 0;
- ibuf->miptot= 1;
+ ibuf->miptot = 1;
while (curmap < IB_MIPMAP_LEVELS) {
if (ibuf->mipmap[curmap]) {
if (use_filter) {
- ImBuf *nbuf= IMB_allocImBuf(hbuf->x, hbuf->y, 32, IB_rect);
+ ImBuf *nbuf = IMB_allocImBuf(hbuf->x, hbuf->y, 32, IB_rect);
IMB_filterN(nbuf, hbuf);
imb_onehalf_no_alloc(ibuf->mipmap[curmap], nbuf);
IMB_freeImBuf(nbuf);
@@ -480,10 +481,10 @@ void IMB_remakemipmap(ImBuf *ibuf, int use_filter)
imb_onehalf_no_alloc(ibuf->mipmap[curmap], hbuf);
}
- ibuf->miptot= curmap+2;
- hbuf= ibuf->mipmap[curmap];
+ ibuf->miptot = curmap + 2;
+ hbuf = ibuf->mipmap[curmap];
if (hbuf)
- hbuf->miplevel= curmap+1;
+ hbuf->miplevel = curmap + 1;
if (!hbuf || (hbuf->x <= 2 && hbuf->y <= 2))
break;
@@ -500,11 +501,11 @@ void IMB_makemipmap(ImBuf *ibuf, int use_filter)
imb_freemipmapImBuf(ibuf);
- ibuf->miptot= 1;
+ ibuf->miptot = 1;
while (curmap < IB_MIPMAP_LEVELS) {
if (use_filter) {
- ImBuf *nbuf= IMB_allocImBuf(hbuf->x, hbuf->y, 32, IB_rect);
+ ImBuf *nbuf = IMB_allocImBuf(hbuf->x, hbuf->y, 32, IB_rect);
IMB_filterN(nbuf, hbuf);
ibuf->mipmap[curmap] = IMB_onehalf(nbuf);
IMB_freeImBuf(nbuf);
@@ -512,9 +513,9 @@ void IMB_makemipmap(ImBuf *ibuf, int use_filter)
else
ibuf->mipmap[curmap] = IMB_onehalf(hbuf);
- ibuf->miptot= curmap+2;
- hbuf= ibuf->mipmap[curmap];
- hbuf->miplevel= curmap+1;
+ ibuf->miptot = curmap + 2;
+ hbuf = ibuf->mipmap[curmap];
+ hbuf->miplevel = curmap + 1;
if (hbuf->x <= 2 && hbuf->y <= 2)
break;
@@ -525,8 +526,8 @@ void IMB_makemipmap(ImBuf *ibuf, int use_filter)
ImBuf *IMB_getmipmap(ImBuf *ibuf, int level)
{
- CLAMP(level, 0, ibuf->miptot-1);
- return (level == 0)? ibuf: ibuf->mipmap[level-1];
+ CLAMP(level, 0, ibuf->miptot - 1);
+ return (level == 0) ? ibuf : ibuf->mipmap[level - 1];
}
void IMB_premultiply_rect(unsigned int *rect, char planes, int w, int h)
@@ -534,22 +535,22 @@ void IMB_premultiply_rect(unsigned int *rect, char planes, int w, int h)
char *cp;
int x, y, val;
- if (planes == 24) { /* put alpha at 255 */
- cp= (char *)(rect);
+ if (planes == 24) { /* put alpha at 255 */
+ cp = (char *)(rect);
- for (y=0; y<h; y++)
- for (x=0; x<w; x++, cp+=4)
- cp[3]= 255;
+ for (y = 0; y < h; y++)
+ for (x = 0; x < w; x++, cp += 4)
+ cp[3] = 255;
}
else {
- cp= (char *)(rect);
-
- for (y=0; y<h; y++) {
- for (x=0; x<w; x++, cp+=4) {
- val= cp[3];
- cp[0]= (cp[0]*val)>>8;
- cp[1]= (cp[1]*val)>>8;
- cp[2]= (cp[2]*val)>>8;
+ cp = (char *)(rect);
+
+ for (y = 0; y < h; y++) {
+ for (x = 0; x < w; x++, cp += 4) {
+ val = cp[3];
+ cp[0] = (cp[0] * val) >> 8;
+ cp[1] = (cp[1] * val) >> 8;
+ cp[2] = (cp[2] * val) >> 8;
}
}
}
@@ -560,21 +561,21 @@ void IMB_premultiply_rect_float(float *rect_float, char planes, int w, int h)
float val, *cp;
int x, y;
- if (planes==24) { /* put alpha at 1.0 */
- cp= rect_float;
+ if (planes == 24) { /* put alpha at 1.0 */
+ cp = rect_float;
- for (y=0; y<h; y++)
- for (x=0; x<w; x++, cp+=4)
- cp[3]= 1.0;
+ for (y = 0; y < h; y++)
+ for (x = 0; x < w; x++, cp += 4)
+ cp[3] = 1.0;
}
else {
- cp= rect_float;
- for (y=0; y<h; y++) {
- for (x=0; x<w; x++, cp+=4) {
- val= cp[3];
- cp[0]= cp[0]*val;
- cp[1]= cp[1]*val;
- cp[2]= cp[2]*val;
+ cp = rect_float;
+ for (y = 0; y < h; y++) {
+ for (x = 0; x < w; x++, cp += 4) {
+ val = cp[3];
+ cp[0] = cp[0] * val;
+ cp[1] = cp[1] * val;
+ cp[2] = cp[2] * val;
}
}
}
@@ -583,7 +584,7 @@ void IMB_premultiply_rect_float(float *rect_float, char planes, int w, int h)
void IMB_premultiply_alpha(ImBuf *ibuf)
{
- if (ibuf==NULL)
+ if (ibuf == NULL)
return;
if (ibuf->rect)
diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c
index 9717670cfa6..40f6f36e06b 100644
--- a/source/blender/imbuf/intern/imageprocess.c
+++ b/source/blender/imbuf/intern/imageprocess.c
@@ -61,13 +61,13 @@ void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf)
size = ibuf->x * ibuf->y;
while (size-- > 0) {
- rt= cp[0];
- cp[0]= cp[3];
- cp[3]= rt;
- rt= cp[1];
- cp[1]= cp[2];
- cp[2]= rt;
- cp+= 4;
+ rt = cp[0];
+ cp[0] = cp[3];
+ cp[3] = rt;
+ rt = cp[1];
+ cp[1] = cp[2];
+ cp[2] = rt;
+ cp += 4;
}
}
@@ -75,26 +75,26 @@ void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf)
size = ibuf->x * ibuf->y;
while (size-- > 0) {
- rtf= cpf[0];
- cpf[0]= cpf[3];
- cpf[3]= rtf;
- rtf= cpf[1];
- cpf[1]= cpf[2];
- cpf[2]= rtf;
- cpf+= 4;
+ rtf = cpf[0];
+ cpf[0] = cpf[3];
+ cpf[3] = rtf;
+ rtf = cpf[1];
+ cpf[1] = cpf[2];
+ cpf[2] = rtf;
+ cpf += 4;
}
}
}
static void pixel_from_buffer(struct ImBuf *ibuf, unsigned char **outI, float **outF, int x, int y)
{
- int offset = ibuf->x * y * 4 + 4*x;
+ int offset = ibuf->x * y * 4 + 4 * x;
if (ibuf->rect)
- *outI= (unsigned char *)ibuf->rect + offset;
+ *outI = (unsigned char *)ibuf->rect + offset;
if (ibuf->rect_float)
- *outF= (float *)ibuf->rect_float + offset;
+ *outF = (float *)ibuf->rect_float + offset;
}
/**************************************************************************
@@ -111,11 +111,11 @@ static void pixel_from_buffer(struct ImBuf *ibuf, unsigned char **outI, float **
static float P(float k)
{
float p1, p2, p3, p4;
- p1 = MAX2(k+2.0f, 0);
- p2 = MAX2(k+1.0f, 0);
+ p1 = MAX2(k + 2.0f, 0);
+ p2 = MAX2(k + 1.0f, 0);
p3 = MAX2(k, 0);
- p4 = MAX2(k-1.0f, 0);
- return (float)(1.0f/6.0f)*( p1*p1*p1 - 4.0f * p2*p2*p2 + 6.0f * p3*p3*p3 - 4.0f * p4*p4*p4);
+ p4 = MAX2(k - 1.0f, 0);
+ return (float)(1.0f / 6.0f) * (p1 * p1 * p1 - 4.0f * p2 * p2 * p2 + 6.0f * p3 * p3 * p3 - 4.0f * p4 * p4 * p4);
}
@@ -123,7 +123,7 @@ static float P(float k)
/* older, slower function, works the same as above */
static float P(float k)
{
- return (float)(1.0f/6.0f)*( pow( MAX2(k+2.0f, 0), 3.0f ) - 4.0f * pow( MAX2(k+1.0f, 0), 3.0f ) + 6.0f * pow( MAX2(k, 0), 3.0f ) - 4.0f * pow( MAX2(k-1.0f, 0), 3.0f));
+ return (float)(1.0f / 6.0f) * (pow(MAX2(k + 2.0f, 0), 3.0f) - 4.0f * pow(MAX2(k + 1.0f, 0), 3.0f) + 6.0f * pow(MAX2(k, 0), 3.0f) - 4.0f * pow(MAX2(k - 1.0f, 0), 3.0f));
}
#endif
@@ -134,51 +134,51 @@ void bicubic_interpolation_color(struct ImBuf *in, unsigned char *outI, float *o
float a, b, w, wx, wy[4], outR, outG, outB, outA, *dataF;
/* sample area entirely outside image? */
- if (ceil(u)<0 || floor(u)>in->x-1 || ceil(v)<0 || floor(v)>in->y-1)
+ if (ceil(u) < 0 || floor(u) > in->x - 1 || ceil(v) < 0 || floor(v) > in->y - 1)
return;
/* ImBuf in must have a valid rect or rect_float, assume this is already checked */
- i= (int)floor(u);
- j= (int)floor(v);
- a= u - i;
- b= v - j;
+ i = (int)floor(u);
+ j = (int)floor(v);
+ a = u - i;
+ b = v - j;
outR = outG = outB = outA = 0.0f;
/* Optimized and not so easy to read */
/* avoid calling multiple times */
- wy[0] = P(b-(-1));
- wy[1] = P(b- 0);
- wy[2] = P(b- 1);
- wy[3] = P(b- 2);
-
- for (n= -1; n<= 2; n++) {
- x1= i+n;
- CLAMP(x1, 0, in->x-1);
- wx = P(n-a);
- for (m= -1; m<= 2; m++) {
- y1= j+m;
- CLAMP(y1, 0, in->y-1);
+ wy[0] = P(b - (-1));
+ wy[1] = P(b - 0);
+ wy[2] = P(b - 1);
+ wy[3] = P(b - 2);
+
+ for (n = -1; n <= 2; n++) {
+ x1 = i + n;
+ CLAMP(x1, 0, in->x - 1);
+ wx = P(n - a);
+ for (m = -1; m <= 2; m++) {
+ y1 = j + m;
+ CLAMP(y1, 0, in->y - 1);
/* normally we could do this */
/* w = P(n-a) * P(b-m); */
/* except that would call P() 16 times per pixel therefor pow() 64 times, better precalc these */
- w = wx * wy[m+1];
+ w = wx * wy[m + 1];
if (outF) {
- dataF= in->rect_float + in->x * y1 * 4 + 4*x1;
- outR+= dataF[0] * w;
- outG+= dataF[1] * w;
- outB+= dataF[2] * w;
- outA+= dataF[3] * w;
+ dataF = in->rect_float + in->x * y1 * 4 + 4 * x1;
+ outR += dataF[0] * w;
+ outG += dataF[1] * w;
+ outB += dataF[2] * w;
+ outA += dataF[3] * w;
}
if (outI) {
- dataI= (unsigned char*)in->rect + in->x * y1 * 4 + 4*x1;
- outR+= dataI[0] * w;
- outG+= dataI[1] * w;
- outB+= dataI[2] * w;
- outA+= dataI[3] * w;
+ dataI = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x1;
+ outR += dataI[0] * w;
+ outG += dataI[1] * w;
+ outB += dataI[2] * w;
+ outA += dataI[3] * w;
}
}
}
@@ -187,24 +187,24 @@ void bicubic_interpolation_color(struct ImBuf *in, unsigned char *outI, float *o
#if 0
/* older, slower function, works the same as above */
- for (n= -1; n<= 2; n++) {
- for (m= -1; m<= 2; m++) {
- x1= i+n;
- y1= j+m;
- if (x1>0 && x1 < in->x && y1>0 && y1<in->y) {
+ for (n = -1; n <= 2; n++) {
+ for (m = -1; m <= 2; m++) {
+ x1 = i + n;
+ y1 = j + m;
+ if (x1 > 0 && x1 < in->x && y1 > 0 && y1 < in->y) {
if (do_float) {
- dataF= in->rect_float + in->x * y1 * 4 + 4*x1;
- outR+= dataF[0] * P(n-a) * P(b-m);
- outG+= dataF[1] * P(n-a) * P(b-m);
- outB+= dataF[2] * P(n-a) * P(b-m);
- outA+= dataF[3] * P(n-a) * P(b-m);
+ dataF = in->rect_float + in->x * y1 * 4 + 4 * x1;
+ outR += dataF[0] * P(n - a) * P(b - m);
+ outG += dataF[1] * P(n - a) * P(b - m);
+ outB += dataF[2] * P(n - a) * P(b - m);
+ outA += dataF[3] * P(n - a) * P(b - m);
}
if (do_rect) {
- dataI= (unsigned char*)in->rect + in->x * y1 * 4 + 4*x1;
- outR+= dataI[0] * P(n-a) * P(b-m);
- outG+= dataI[1] * P(n-a) * P(b-m);
- outB+= dataI[2] * P(n-a) * P(b-m);
- outA+= dataI[3] * P(n-a) * P(b-m);
+ dataI = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x1;
+ outR += dataI[0] * P(n - a) * P(b - m);
+ outG += dataI[1] * P(n - a) * P(b - m);
+ outB += dataI[2] * P(n - a) * P(b - m);
+ outA += dataI[3] * P(n - a) * P(b - m);
}
}
}
@@ -212,16 +212,16 @@ void bicubic_interpolation_color(struct ImBuf *in, unsigned char *outI, float *o
#endif
if (outI) {
- outI[0]= (int)outR;
- outI[1]= (int)outG;
- outI[2]= (int)outB;
- outI[3]= (int)outA;
+ outI[0] = (int)outR;
+ outI[1] = (int)outG;
+ outI[2] = (int)outB;
+ outI[3] = (int)outA;
}
if (outF) {
- outF[0]= outR;
- outF[1]= outG;
- outF[2]= outB;
- outF[3]= outA;
+ outF[0] = outR;
+ outF[1] = outG;
+ outF[2] = outB;
+ outF[3] = outA;
}
}
@@ -246,68 +246,68 @@ void bilinear_interpolation_color(struct ImBuf *in, unsigned char *outI, float *
float *row1, *row2, *row3, *row4, a, b;
unsigned char *row1I, *row2I, *row3I, *row4I;
float a_b, ma_b, a_mb, ma_mb;
- float empty[4]= {0.0f, 0.0f, 0.0f, 0.0f};
- unsigned char emptyI[4]= {0, 0, 0, 0};
+ float empty[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ unsigned char emptyI[4] = {0, 0, 0, 0};
int y1, y2, x1, x2;
/* ImBuf in must have a valid rect or rect_float, assume this is already checked */
- x1= (int)floor(u);
- x2= (int)ceil(u);
- y1= (int)floor(v);
- y2= (int)ceil(v);
+ x1 = (int)floor(u);
+ x2 = (int)ceil(u);
+ y1 = (int)floor(v);
+ y2 = (int)ceil(v);
// sample area entirely outside image?
- if (x2<0 || x1>in->x-1 || y2<0 || y1>in->y-1) return;
+ if (x2 < 0 || x1 > in->x - 1 || y2 < 0 || y1 > in->y - 1) return;
if (outF) {
// sample including outside of edges of image
- if (x1<0 || y1<0) row1= empty;
- else row1= (float *)in->rect_float + in->x * y1 * 4 + 4*x1;
-
- if (x1<0 || y2>in->y-1) row2= empty;
- else row2= (float *)in->rect_float + in->x * y2 * 4 + 4*x1;
+ if (x1 < 0 || y1 < 0) row1 = empty;
+ else row1 = (float *)in->rect_float + in->x * y1 * 4 + 4 * x1;
- if (x2>in->x-1 || y1<0) row3= empty;
- else row3= (float *)in->rect_float + in->x * y1 * 4 + 4*x2;
+ if (x1 < 0 || y2 > in->y - 1) row2 = empty;
+ else row2 = (float *)in->rect_float + in->x * y2 * 4 + 4 * x1;
- if (x2>in->x-1 || y2>in->y-1) row4= empty;
- else row4= (float *)in->rect_float + in->x * y2 * 4 + 4*x2;
+ if (x2 > in->x - 1 || y1 < 0) row3 = empty;
+ else row3 = (float *)in->rect_float + in->x * y1 * 4 + 4 * x2;
- a= u-floorf(u);
- b= v-floorf(v);
- a_b= a*b; ma_b= (1.0f-a)*b; a_mb= a*(1.0f-b); ma_mb= (1.0f-a)*(1.0f-b);
-
- outF[0]= ma_mb*row1[0] + a_mb*row3[0] + ma_b*row2[0]+ a_b*row4[0];
- outF[1]= ma_mb*row1[1] + a_mb*row3[1] + ma_b*row2[1]+ a_b*row4[1];
- outF[2]= ma_mb*row1[2] + a_mb*row3[2] + ma_b*row2[2]+ a_b*row4[2];
- outF[3]= ma_mb*row1[3] + a_mb*row3[3] + ma_b*row2[3]+ a_b*row4[3];
+ if (x2 > in->x - 1 || y2 > in->y - 1) row4 = empty;
+ else row4 = (float *)in->rect_float + in->x * y2 * 4 + 4 * x2;
+
+ a = u - floorf(u);
+ b = v - floorf(v);
+ a_b = a * b; ma_b = (1.0f - a) * b; a_mb = a * (1.0f - b); ma_mb = (1.0f - a) * (1.0f - b);
+
+ outF[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0];
+ outF[1] = ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1];
+ outF[2] = ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2];
+ outF[3] = ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3];
}
if (outI) {
// sample including outside of edges of image
- if (x1<0 || y1<0) row1I= emptyI;
- else row1I= (unsigned char *)in->rect + in->x * y1 * 4 + 4*x1;
+ if (x1 < 0 || y1 < 0) row1I = emptyI;
+ else row1I = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x1;
- if (x1<0 || y2>in->y-1) row2I= emptyI;
- else row2I= (unsigned char *)in->rect + in->x * y2 * 4 + 4*x1;
+ if (x1 < 0 || y2 > in->y - 1) row2I = emptyI;
+ else row2I = (unsigned char *)in->rect + in->x * y2 * 4 + 4 * x1;
- if (x2>in->x-1 || y1<0) row3I= emptyI;
- else row3I= (unsigned char *)in->rect + in->x * y1 * 4 + 4*x2;
+ if (x2 > in->x - 1 || y1 < 0) row3I = emptyI;
+ else row3I = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x2;
- if (x2>in->x-1 || y2>in->y-1) row4I= emptyI;
- else row4I= (unsigned char *)in->rect + in->x * y2 * 4 + 4*x2;
+ if (x2 > in->x - 1 || y2 > in->y - 1) row4I = emptyI;
+ else row4I = (unsigned char *)in->rect + in->x * y2 * 4 + 4 * x2;
- a= u-floorf(u);
- b= v-floorf(v);
- a_b= a*b; ma_b= (1.0f-a)*b; a_mb= a*(1.0f-b); ma_mb= (1.0f-a)*(1.0f-b);
+ a = u - floorf(u);
+ b = v - floorf(v);
+ a_b = a * b; ma_b = (1.0f - a) * b; a_mb = a * (1.0f - b); ma_mb = (1.0f - a) * (1.0f - b);
/* need to add 0.5 to avoid rounding down (causes darken with the smear brush)
* tested with white images and this should not wrap back to zero */
- outI[0]= (ma_mb*row1I[0] + a_mb*row3I[0] + ma_b*row2I[0]+ a_b*row4I[0]) + 0.5f;
- outI[1]= (ma_mb*row1I[1] + a_mb*row3I[1] + ma_b*row2I[1]+ a_b*row4I[1]) + 0.5f;
- outI[2]= (ma_mb*row1I[2] + a_mb*row3I[2] + ma_b*row2I[2]+ a_b*row4I[2]) + 0.5f;
- outI[3]= (ma_mb*row1I[3] + a_mb*row3I[3] + ma_b*row2I[3]+ a_b*row4I[3]) + 0.5f;
+ outI[0] = (ma_mb * row1I[0] + a_mb * row3I[0] + ma_b * row2I[0] + a_b * row4I[0]) + 0.5f;
+ outI[1] = (ma_mb * row1I[1] + a_mb * row3I[1] + ma_b * row2I[1] + a_b * row4I[1]) + 0.5f;
+ outI[2] = (ma_mb * row1I[2] + a_mb * row3I[2] + ma_b * row2I[2] + a_b * row4I[2]) + 0.5f;
+ outI[3] = (ma_mb * row1I[3] + a_mb * row3I[3] + ma_b * row2I[3] + a_b * row4I[3]) + 0.5f;
}
}
@@ -327,54 +327,54 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *outI, fl
/* ImBuf in must have a valid rect or rect_float, assume this is already checked */
- x1= (int)floor(u);
- x2= (int)ceil(u);
- y1= (int)floor(v);
- y2= (int)ceil(v);
+ x1 = (int)floor(u);
+ x2 = (int)ceil(u);
+ y1 = (int)floor(v);
+ y2 = (int)ceil(v);
// sample area entirely outside image?
- if (x2<0 || x1>in->x-1 || y2<0 || y1>in->y-1) return;
+ if (x2 < 0 || x1 > in->x - 1 || y2 < 0 || y1 > in->y - 1) return;
/* wrap interpolation pixels - main difference from bilinear_interpolation_color */
- if (x1<0)x1= in->x+x1;
- if (y1<0)y1= in->y+y1;
+ if (x1 < 0) x1 = in->x + x1;
+ if (y1 < 0) y1 = in->y + y1;
- if (x2>=in->x)x2= x2-in->x;
- if (y2>=in->y)y2= y2-in->y;
+ if (x2 >= in->x) x2 = x2 - in->x;
+ if (y2 >= in->y) y2 = y2 - in->y;
if (outF) {
// sample including outside of edges of image
- row1= (float *)in->rect_float + in->x * y1 * 4 + 4*x1;
- row2= (float *)in->rect_float + in->x * y2 * 4 + 4*x1;
- row3= (float *)in->rect_float + in->x * y1 * 4 + 4*x2;
- row4= (float *)in->rect_float + in->x * y2 * 4 + 4*x2;
-
- a= u-floorf(u);
- b= v-floorf(v);
- a_b= a*b; ma_b= (1.0f-a)*b; a_mb= a*(1.0f-b); ma_mb= (1.0f-a)*(1.0f-b);
-
- outF[0]= ma_mb*row1[0] + a_mb*row3[0] + ma_b*row2[0]+ a_b*row4[0];
- outF[1]= ma_mb*row1[1] + a_mb*row3[1] + ma_b*row2[1]+ a_b*row4[1];
- outF[2]= ma_mb*row1[2] + a_mb*row3[2] + ma_b*row2[2]+ a_b*row4[2];
- outF[3]= ma_mb*row1[3] + a_mb*row3[3] + ma_b*row2[3]+ a_b*row4[3];
+ row1 = (float *)in->rect_float + in->x * y1 * 4 + 4 * x1;
+ row2 = (float *)in->rect_float + in->x * y2 * 4 + 4 * x1;
+ row3 = (float *)in->rect_float + in->x * y1 * 4 + 4 * x2;
+ row4 = (float *)in->rect_float + in->x * y2 * 4 + 4 * x2;
+
+ a = u - floorf(u);
+ b = v - floorf(v);
+ a_b = a * b; ma_b = (1.0f - a) * b; a_mb = a * (1.0f - b); ma_mb = (1.0f - a) * (1.0f - b);
+
+ outF[0] = ma_mb * row1[0] + a_mb * row3[0] + ma_b * row2[0] + a_b * row4[0];
+ outF[1] = ma_mb * row1[1] + a_mb * row3[1] + ma_b * row2[1] + a_b * row4[1];
+ outF[2] = ma_mb * row1[2] + a_mb * row3[2] + ma_b * row2[2] + a_b * row4[2];
+ outF[3] = ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3];
}
if (outI) {
// sample including outside of edges of image
- row1I= (unsigned char *)in->rect + in->x * y1 * 4 + 4*x1;
- row2I= (unsigned char *)in->rect + in->x * y2 * 4 + 4*x1;
- row3I= (unsigned char *)in->rect + in->x * y1 * 4 + 4*x2;
- row4I= (unsigned char *)in->rect + in->x * y2 * 4 + 4*x2;
-
- a= u-floorf(u);
- b= v-floorf(v);
- a_b= a*b; ma_b= (1.0f-a)*b; a_mb= a*(1.0f-b); ma_mb= (1.0f-a)*(1.0f-b);
+ row1I = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x1;
+ row2I = (unsigned char *)in->rect + in->x * y2 * 4 + 4 * x1;
+ row3I = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x2;
+ row4I = (unsigned char *)in->rect + in->x * y2 * 4 + 4 * x2;
+
+ a = u - floorf(u);
+ b = v - floorf(v);
+ a_b = a * b; ma_b = (1.0f - a) * b; a_mb = a * (1.0f - b); ma_mb = (1.0f - a) * (1.0f - b);
/* need to add 0.5 to avoid rounding down (causes darken with the smear brush)
* tested with white images and this should not wrap back to zero */
- outI[0]= (ma_mb*row1I[0] + a_mb*row3I[0] + ma_b*row2I[0]+ a_b*row4I[0]) + 0.5f;
- outI[1]= (ma_mb*row1I[1] + a_mb*row3I[1] + ma_b*row2I[1]+ a_b*row4I[1]) + 0.5f;
- outI[2]= (ma_mb*row1I[2] + a_mb*row3I[2] + ma_b*row2I[2]+ a_b*row4I[2]) + 0.5f;
- outI[3]= (ma_mb*row1I[3] + a_mb*row3I[3] + ma_b*row2I[3]+ a_b*row4I[3]) + 0.5f;
+ outI[0] = (ma_mb * row1I[0] + a_mb * row3I[0] + ma_b * row2I[0] + a_b * row4I[0]) + 0.5f;
+ outI[1] = (ma_mb * row1I[1] + a_mb * row3I[1] + ma_b * row2I[1] + a_b * row4I[1]) + 0.5f;
+ outI[2] = (ma_mb * row1I[2] + a_mb * row3I[2] + ma_b * row2I[2] + a_b * row4I[2]) + 0.5f;
+ outI[3] = (ma_mb * row1I[3] + a_mb * row3I[3] + ma_b * row2I[3] + a_b * row4I[3]) + 0.5f;
}
}
@@ -401,41 +401,41 @@ void neareast_interpolation_color(struct ImBuf *in, unsigned char *outI, float *
/* ImBuf in must have a valid rect or rect_float, assume this is already checked */
- x1= (int)(u);
- y1= (int)(v);
+ x1 = (int)(u);
+ y1 = (int)(v);
// sample area entirely outside image?
- if (x1<0 || x1>in->x-1 || y1<0 || y1>in->y-1) return;
+ if (x1 < 0 || x1 > in->x - 1 || y1 < 0 || y1 > in->y - 1) return;
// sample including outside of edges of image
- if (x1<0 || y1<0) {
+ if (x1 < 0 || y1 < 0) {
if (outI) {
- outI[0]= 0;
- outI[1]= 0;
- outI[2]= 0;
- outI[3]= 0;
+ outI[0] = 0;
+ outI[1] = 0;
+ outI[2] = 0;
+ outI[3] = 0;
}
if (outF) {
- outF[0]= 0.0f;
- outF[1]= 0.0f;
- outF[2]= 0.0f;
- outF[3]= 0.0f;
+ outF[0] = 0.0f;
+ outF[1] = 0.0f;
+ outF[2] = 0.0f;
+ outF[3] = 0.0f;
}
}
else {
- dataI= (unsigned char *)in->rect + in->x * y1 * 4 + 4*x1;
+ dataI = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x1;
if (outI) {
- outI[0]= dataI[0];
- outI[1]= dataI[1];
- outI[2]= dataI[2];
- outI[3]= dataI[3];
+ outI[0] = dataI[0];
+ outI[1] = dataI[1];
+ outI[2] = dataI[2];
+ outI[3] = dataI[3];
}
- dataF= in->rect_float + in->x * y1 * 4 + 4*x1;
+ dataF = in->rect_float + in->x * y1 * 4 + 4 * x1;
if (outF) {
- outF[0]= dataF[0];
- outF[1]= dataF[1];
- outF[2]= dataF[2];
- outF[3]= dataF[3];
+ outF[0] = dataF[0];
+ outF[1] = dataF[1];
+ outF[2] = dataF[2];
+ outF[3] = dataF[3];
}
}
}
diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c
index 8914d4ee64d..b3fe363a266 100644
--- a/source/blender/imbuf/intern/rotate.c
+++ b/source/blender/imbuf/intern/rotate.c
@@ -44,7 +44,7 @@
#include "IMB_allocimbuf.h"
-void IMB_flipy(struct ImBuf * ibuf)
+void IMB_flipy(struct ImBuf *ibuf)
{
int x, y;
@@ -57,47 +57,47 @@ void IMB_flipy(struct ImBuf * ibuf)
y = ibuf->y;
top = ibuf->rect;
- bottom = top + ((y-1) * x);
- line= MEM_mallocN(x*sizeof(int), "linebuf");
+ bottom = top + ((y - 1) * x);
+ line = MEM_mallocN(x * sizeof(int), "linebuf");
y >>= 1;
- for (;y>0;y--) {
- memcpy(line, top, x*sizeof(int));
- memcpy(top, bottom, x*sizeof(int));
- memcpy(bottom, line, x*sizeof(int));
+ for (; y > 0; y--) {
+ memcpy(line, top, x * sizeof(int));
+ memcpy(top, bottom, x * sizeof(int));
+ memcpy(bottom, line, x * sizeof(int));
bottom -= x;
- top+= x;
+ top += x;
}
MEM_freeN(line);
}
if (ibuf->rect_float) {
- float *topf=NULL, *bottomf=NULL, *linef=NULL;
+ float *topf = NULL, *bottomf = NULL, *linef = NULL;
x = ibuf->x;
y = ibuf->y;
- topf= ibuf->rect_float;
- bottomf = topf + 4*((y-1) * x);
- linef= MEM_mallocN(4*x*sizeof(float), "linebuff");
+ topf = ibuf->rect_float;
+ bottomf = topf + 4 * ((y - 1) * x);
+ linef = MEM_mallocN(4 * x * sizeof(float), "linebuff");
y >>= 1;
- for (;y>0;y--) {
- memcpy(linef, topf, 4*x*sizeof(float));
- memcpy(topf, bottomf, 4*x*sizeof(float));
- memcpy(bottomf, linef, 4*x*sizeof(float));
- bottomf -= 4*x;
- topf+= 4*x;
+ for (; y > 0; y--) {
+ memcpy(linef, topf, 4 * x * sizeof(float));
+ memcpy(topf, bottomf, 4 * x * sizeof(float));
+ memcpy(bottomf, linef, 4 * x * sizeof(float));
+ bottomf -= 4 * x;
+ topf += 4 * x;
}
MEM_freeN(linef);
}
}
-void IMB_flipx(struct ImBuf * ibuf)
+void IMB_flipx(struct ImBuf *ibuf)
{
int x, y, xr, xl, yi;
float px_f[4];
@@ -108,19 +108,19 @@ void IMB_flipx(struct ImBuf * ibuf)
y = ibuf->y;
if (ibuf->rect) {
- for (yi=y-1;yi>=0;yi--) {
- for (xr=x-1, xl=0; xr>=xl; xr--, xl++) {
- SWAP(unsigned int, ibuf->rect[(x*yi)+xr], ibuf->rect[(x*yi)+xl]);
+ for (yi = y - 1; yi >= 0; yi--) {
+ for (xr = x - 1, xl = 0; xr >= xl; xr--, xl++) {
+ SWAP(unsigned int, ibuf->rect[(x * yi) + xr], ibuf->rect[(x * yi) + xl]);
}
}
}
if (ibuf->rect_float) {
- for (yi=y-1;yi>=0;yi--) {
- for (xr=x-1, xl=0; xr>=xl; xr--, xl++) {
- memcpy(&px_f, &ibuf->rect_float[((x*yi)+xr)*4], 4*sizeof(float));
- memcpy(&ibuf->rect_float[((x*yi)+xr)*4], &ibuf->rect_float[((x*yi)+xl)*4], 4*sizeof(float));
- memcpy(&ibuf->rect_float[((x*yi)+xl)*4], &px_f, 4*sizeof(float));
+ for (yi = y - 1; yi >= 0; yi--) {
+ for (xr = x - 1, xl = 0; xr >= xl; xr--, xl++) {
+ memcpy(&px_f, &ibuf->rect_float[((x * yi) + xr) * 4], 4 * sizeof(float));
+ memcpy(&ibuf->rect_float[((x * yi) + xr) * 4], &ibuf->rect_float[((x * yi) + xl) * 4], 4 * sizeof(float));
+ memcpy(&ibuf->rect_float[((x * yi) + xl) * 4], &px_f, 4 * sizeof(float));
}
}
}
diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c
index 60fc7db6465..1c182e9784e 100644
--- a/source/blender/imbuf/intern/writeimage.c
+++ b/source/blender/imbuf/intern/writeimage.c
@@ -47,10 +47,10 @@ short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags)
if (ibuf == NULL) return (FALSE);
ibuf->flags = flags;
- for (type=IMB_FILE_TYPES; type->is_a; type++) {
+ for (type = IMB_FILE_TYPES; type->is_a; type++) {
if (type->save && type->ftype(type, ibuf)) {
if (!(type->flag & IM_FTYPE_FLOAT)) {
- if (ibuf->rect==NULL && ibuf->rect_float)
+ if (ibuf->rect == NULL && ibuf->rect_float)
IMB_rect_from_float(ibuf);
}
return type->save(ibuf, name, flags);