diff options
author | Peter Schlaile <peter@schlaile.de> | 2007-10-12 10:37:20 +0400 |
---|---|---|
committer | Peter Schlaile <peter@schlaile.de> | 2007-10-12 10:37:20 +0400 |
commit | 3697e0852467a29223a59d2ad6a31a00cfbde529 (patch) | |
tree | 8c86485c60cd49e2080d90d1d904e2000f5e7d72 /source/blender/imbuf/intern/rotate.c | |
parent | 4f961081377ce262823fd4a037ce969fc5088474 (diff) |
== 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 :) )
Diffstat (limited to 'source/blender/imbuf/intern/rotate.c')
-rw-r--r-- | source/blender/imbuf/intern/rotate.c | 22 |
1 files changed, 14 insertions, 8 deletions
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)); |