diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-12-28 17:29:33 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-12-28 17:29:33 +0400 |
commit | b9ff5840a617ec836f2d09bb0f04d60e5c3b8f67 (patch) | |
tree | 8a196777f4ee32e3ee089c12b667caa2c82dec75 /source/blender/render/intern | |
parent | 1f02209957fc8afde957b48f1be41fc399a725b0 (diff) |
Code refactoring: add unified image buffer functions for doing float => byte,
byte => float, float => float, byte => byte conversions with profile, dither
and predivide. Previously code for this was spread out too much.
There should be no functional changes, this is so the predivide/table/dither
patches can work correctly.
Diffstat (limited to 'source/blender/render/intern')
-rw-r--r-- | source/blender/render/intern/source/pipeline.c | 55 |
1 files changed, 17 insertions, 38 deletions
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index d82cff16496..0a481629ee8 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1149,32 +1149,17 @@ void RE_ResultGet32(Render *re, unsigned int *rect) RE_AcquireResultImage(re, &rres); - if(rres.rect32) + if(rres.rect32) { memcpy(rect, rres.rect32, sizeof(int)*rres.rectx*rres.recty); + } else if(rres.rectf) { - float *fp= rres.rectf; - int tot= rres.rectx*rres.recty; - char *cp= (char *)rect; - - if (re->r.color_mgt_flag & R_COLOR_MANAGEMENT) { - /* Finally convert back to sRGB rendered image */ - for(;tot>0; tot--, cp+=4, fp+=4) { - cp[0] = FTOCHAR(linearrgb_to_srgb(fp[0])); - cp[1] = FTOCHAR(linearrgb_to_srgb(fp[1])); - cp[2] = FTOCHAR(linearrgb_to_srgb(fp[2])); - cp[3] = FTOCHAR(fp[3]); - } - } - else { - /* Color management is off : no conversion necessary */ - for(;tot>0; tot--, cp+=4, fp+=4) { - cp[0] = FTOCHAR(fp[0]); - cp[1] = FTOCHAR(fp[1]); - cp[2] = FTOCHAR(fp[2]); - cp[3] = FTOCHAR(fp[3]); - } - } + int profile_from= (re->r.color_mgt_flag & R_COLOR_MANAGEMENT)? IB_PROFILE_LINEAR_RGB: IB_PROFILE_SRGB; + int predivide= 0; + int dither= 0; + IMB_buffer_byte_from_float((unsigned char*)rect, rres.rectf, + 4, dither, IB_PROFILE_SRGB, profile_from, predivide, + rres.rectx, rres.recty, rres.rectx, rres.rectx); } else /* else fill with black */ @@ -2567,24 +2552,18 @@ static void do_render_seq(Render * re) if(ibuf) { if(ibuf->rect_float) { + /* color management: when off ensure rectf is non-lin, since thats what the internal + * render engine delivers */ + int profile_to= (re->r.color_mgt_flag & R_COLOR_MANAGEMENT)? IB_PROFILE_LINEAR_RGB: IB_PROFILE_SRGB; + int profile_from= (ibuf->profile == IB_PROFILE_LINEAR_RGB)? IB_PROFILE_LINEAR_RGB: IB_PROFILE_SRGB; + int predivide= 0; + if (!rr->rectf) rr->rectf= MEM_mallocN(4*sizeof(float)*rr->rectx*rr->recty, "render_seq rectf"); - /* color management: when off ensure rectf is non-lin, since thats what the internal - * render engine delivers */ - if(re->r.color_mgt_flag & R_COLOR_MANAGEMENT) { - if(ibuf->profile == IB_PROFILE_LINEAR_RGB) - memcpy(rr->rectf, ibuf->rect_float, 4*sizeof(float)*rr->rectx*rr->recty); - else - srgb_to_linearrgb_rgba_rgba_buf(rr->rectf, ibuf->rect_float, rr->rectx*rr->recty); - - } - else { - if(ibuf->profile != IB_PROFILE_LINEAR_RGB) - memcpy(rr->rectf, ibuf->rect_float, 4*sizeof(float)*rr->rectx*rr->recty); - else - linearrgb_to_srgb_rgba_rgba_buf(rr->rectf, ibuf->rect_float, rr->rectx*rr->recty); - } + IMB_buffer_float_from_float(rr->rectf, ibuf->rect_float, + 4, profile_to, profile_from, predivide, + rr->rectx, rr->recty, rr->rectx, rr->rectx); /* TSK! Since sequence render doesn't free the *rr render result, the old rect32 can hang around when sequence render has rendered a 32 bits one before */ |