From 3697e0852467a29223a59d2ad6a31a00cfbde529 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Fri, 12 Oct 2007 06:37:20 +0000 Subject: == IMBuf fix == Fixed Campbell's patch for IMB_flipx: - header file declaration is corrected - reordered loops to make things faster (less cache misses and no tests for float-buffers on a _per pixel basis_!) (Campbell: it'd be nice, if you could check with me before patching the sequencer. Or at least pay attention to compiler warnings :) ) --- source/blender/imbuf/IMB_imbuf.h | 9 +-------- source/blender/imbuf/intern/rotate.c | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 16 deletions(-) (limited to 'source/blender/imbuf') diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 11cdebe70c3..2ca21e548c4 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -417,14 +417,6 @@ void bilinear_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float */ void IMB_convert_bgra_to_rgba(int size, unsigned int *rect); -/** - * Flip the image X/Y - * - * @attention Defined in imageprocess.c - */ -void IMB_xflip(struct ImBuf *ibuf); -void IMB_yflip(struct ImBuf *ibuf); - /** * * @attention defined in scaling.c @@ -532,6 +524,7 @@ extern float rgb_to_bw[4][4]; * * @attention Defined in rotate.c */ +void IMB_flipx(struct ImBuf *ibuf); void IMB_flipy(struct ImBuf * ibuf); /** diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c index 4654dd6aefa..42b30d6284f 100644 --- a/source/blender/imbuf/intern/rotate.c +++ b/source/blender/imbuf/intern/rotate.c @@ -94,17 +94,23 @@ void IMB_flipx(struct ImBuf * ibuf) float px_f[4]; if (ibuf == NULL) return; - if (ibuf->rect == NULL) return; x = ibuf->x; y = ibuf->y; - for(yi=y-1;yi>=0;yi--) { - for(xr=x-1, xl=0; xr>=xl; xr--, xl++) { - px = ibuf->rect[(x*yi)+xr]; - ibuf->rect[(x*yi)+xr] = ibuf->rect[(x*yi)+xl]; - ibuf->rect[(x*yi)+xl] = px; - - if (ibuf->rect_float) { + + if (ibuf->rect) { + for(yi=y-1;yi>=0;yi--) { + for(xr=x-1, xl=0; xr>=xl; xr--, xl++) { + px = ibuf->rect[(x*yi)+xr]; + ibuf->rect[(x*yi)+xr] = ibuf->rect[(x*yi)+xl]; + ibuf->rect[(x*yi)+xl] = px; + } + } + } + + 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)); -- cgit v1.2.3