diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-07-12 18:57:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-07-12 18:57:24 +0400 |
commit | a470640f2e88c0997b12600b9de652da6aac7444 (patch) | |
tree | 37d6fb2b66755ac8b753f064e7d66f9e4c029da5 /source | |
parent | 731824c464e03b133ea9698c2d74dbb8e7f890be (diff) |
sequencer float conversion was only using rgb -> float conversion inconsistantly, some places used colorspace conversion, some not.
Added IMB_float_from_rect_simple() for the sequencer to use.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/displist.c | 15 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/seqeffects.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 34 | ||||
-rw-r--r-- | source/blender/imbuf/IMB_imbuf.h | 3 | ||||
-rw-r--r-- | source/blender/imbuf/intern/divers.c | 71 |
5 files changed, 95 insertions, 32 deletions
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 716d3110bc3..bb020c936a6 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -575,9 +575,9 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un char *col1= (char*)&col1base[j*4]; char *col2= (char*)(col2base?&col2base[j*4]:NULL); float *vn = (mf->flag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1; - - VECCOPY(vec, mv->co); - mul_m4_v3(mat, vec); + + mul_v3_m4v3(vec, mat, mv->co); + vec[0]+= 0.001*vn[0]; vec[1]+= 0.001*vn[1]; vec[2]+= 0.001*vn[2]; @@ -688,8 +688,7 @@ void shadeDispList(Scene *scene, Base *base) a= dl->nr; while(a--) { - VECCOPY(vec, fp); - mul_m4_v3(mat, vec); + mul_v3_m4v3(vec, mat, fp); fastshade(vec, n1, fp, ma, (char *)col1, NULL); @@ -704,8 +703,7 @@ void shadeDispList(Scene *scene, Base *base) nor= dl->nors; while(a--) { - VECCOPY(vec, fp); - mul_m4_v3(mat, vec); + mul_v3_m4v3(vec, mat, fp); n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; @@ -742,8 +740,7 @@ void shadeDispList(Scene *scene, Base *base) a= dl->nr; while(a--) { - VECCOPY(vec, fp); - mul_m4_v3(mat, vec); + mul_v3_m4v3(vec, mat, fp); /* transpose ! */ n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 56a8edcc4fc..73c19772c69 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -312,7 +312,7 @@ static void do_plugin_effect(Scene *scene, Sequence *seq, int cfra, IMB_convert_rgba_to_abgr(out); } if (seq->plugin->version<=3 && float_rendering) { - IMB_float_from_rect(out); + IMB_float_from_rect_simple(out); } if (use_temp_bufs) { @@ -2783,7 +2783,7 @@ static void do_multicam(Scene *scene, Sequence *seq, int cfra, IMB_rect_from_float(i); memcpy(out->rect, i->rect, out->x * out->y * 4); } else if (out->rect_float && i->rect) { - IMB_float_from_rect(i); + IMB_float_from_rect_simple(i); memcpy(out->rect_float, i->rect_float, out->x * out->y *4*sizeof(float)); } } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 6e48a71cec4..fd3e56a418c 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1022,13 +1022,13 @@ static void do_effect(Scene *scene, int cfra, Sequence *seq, TStripElem * se, y= se2->ibuf->y; if (!se1->ibuf->rect_float && se->ibuf->rect_float) { - IMB_float_from_rect(se1->ibuf); + IMB_float_from_rect_simple(se1->ibuf); } if (!se2->ibuf->rect_float && se->ibuf->rect_float) { - IMB_float_from_rect(se2->ibuf); + IMB_float_from_rect_simple(se2->ibuf); } if (!se3->ibuf->rect_float && se->ibuf->rect_float) { - IMB_float_from_rect(se3->ibuf); + IMB_float_from_rect_simple(se3->ibuf); } if (!se1->ibuf->rect && !se->ibuf->rect_float) { @@ -1784,17 +1784,9 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf } if(seq->flag & SEQ_MAKE_FLOAT) { - if (!se->ibuf->rect_float) { - int profile = IB_PROFILE_NONE; - - /* no color management: - * don't disturb the existing profiles */ - SWAP(int, se->ibuf->profile, profile); + if (!se->ibuf->rect_float) + IMB_float_from_rect_simple(se->ibuf); - IMB_float_from_rect(se->ibuf); - - SWAP(int, se->ibuf->profile, profile); - } if (se->ibuf->rect) { imb_freerectImBuf(se->ibuf); } @@ -2085,14 +2077,14 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int } copy_from_ibuf_still(seq, se); - if (!se->ibuf) { - se->ibuf= IMB_loadiffname( - name, IB_rect); + if (se->ibuf==NULL && (se->ibuf= IMB_loadiffname(name, IB_rect))) { /* we don't need both (speed reasons)! */ - if (se->ibuf && - se->ibuf->rect_float && se->ibuf->rect) { + if (se->ibuf->rect_float && se->ibuf->rect) imb_freerectImBuf(se->ibuf); - } + + /* all sequencer color is done in SRGB space, linear gives odd crossfades */ + if(se->ibuf->profile == IB_PROFILE_LINEAR_RGB) + IMB_convert_profile(se->ibuf, IB_PROFILE_NONE); copy_to_ibuf_still(seq, se); } @@ -2707,11 +2699,11 @@ static TStripElem* do_build_seq_array_recursively( if (!se1->ibuf_comp->rect_float && se2->ibuf_comp->rect_float) { - IMB_float_from_rect(se1->ibuf_comp); + IMB_float_from_rect_simple(se1->ibuf_comp); } if (!se2->ibuf->rect_float && se2->ibuf_comp->rect_float) { - IMB_float_from_rect(se2->ibuf); + IMB_float_from_rect_simple(se2->ibuf); } if (!se1->ibuf_comp->rect && diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 37399c9d68a..07b99dddfa5 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -319,6 +319,9 @@ void IMB_de_interlace(struct ImBuf *ibuf); void IMB_interlace(struct ImBuf *ibuf); void IMB_rect_from_float(struct ImBuf *ibuf); void IMB_float_from_rect(struct ImBuf *ibuf); +void IMB_float_from_rect_simple(struct ImBuf *ibuf); /* no profile conversion */ +/* note, check that the conversion exists, only some are supported */ +void IMB_convert_profile(struct ImBuf *ibuf, int profile); /** * Change the ordering of the color bytes pointed to by rect from diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index 0cc4346041f..7b3a07f10ad 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -222,3 +222,74 @@ void IMB_float_from_rect(struct ImBuf *ibuf) } } +/* no profile conversion */ +void IMB_float_from_rect_simple(struct ImBuf *ibuf) +{ + int profile = IB_PROFILE_NONE; + + /* no color management: + * don't disturb the existing profiles */ + SWAP(int, ibuf->profile, profile); + + IMB_float_from_rect(ibuf); + + SWAP(int, ibuf->profile, profile); +} + +void IMB_convert_profile(struct ImBuf *ibuf, int profile) +{ + int ok= FALSE; + int i; + + unsigned char *rct= (unsigned char *)ibuf->rect; + float *rctf= ibuf->rect_float; + + if(ibuf->profile == profile) + return; + + if(ELEM(ibuf->profile, IB_PROFILE_NONE, IB_PROFILE_SRGB)) { /* from */ + if(profile == IB_PROFILE_LINEAR_RGB) { /* to */ + if(ibuf->rect_float) { + for (i = ibuf->x * ibuf->y; i > 0; i--, rctf+=4) { + rctf[0]= srgb_to_linearrgb(rctf[0]); + rctf[1]= srgb_to_linearrgb(rctf[1]); + rctf[2]= srgb_to_linearrgb(rctf[2]); + } + } + if(ibuf->rect) { + for (i = ibuf->x * ibuf->y; i > 0; i--, rct+=4) { + rctf[0]= (unsigned char)((srgb_to_linearrgb((float)rctf[0]/255.0f) * 255.0f) + 0.5f); + rctf[1]= (unsigned char)((srgb_to_linearrgb((float)rctf[1]/255.0f) * 255.0f) + 0.5f); + rctf[2]= (unsigned char)((srgb_to_linearrgb((float)rctf[2]/255.0f) * 255.0f) + 0.5f); + } + } + ok= TRUE; + } + } + else if (ibuf->profile == IB_PROFILE_LINEAR_RGB) { /* from */ + if(ELEM(profile, IB_PROFILE_NONE, IB_PROFILE_SRGB)) { /* to */ + if(ibuf->rect_float) { + for (i = ibuf->x * ibuf->y; i > 0; i--, rctf+=4) { + rctf[0]= linearrgb_to_srgb(rctf[0]); + rctf[1]= linearrgb_to_srgb(rctf[1]); + rctf[2]= linearrgb_to_srgb(rctf[2]); + } + } + if(ibuf->rect) { + for (i = ibuf->x * ibuf->y; i > 0; i--, rct+=4) { + rctf[0]= (unsigned char)((linearrgb_to_srgb((float)rctf[0]/255.0f) * 255.0f) + 0.5f); + rctf[1]= (unsigned char)((linearrgb_to_srgb((float)rctf[1]/255.0f) * 255.0f) + 0.5f); + rctf[2]= (unsigned char)((linearrgb_to_srgb((float)rctf[2]/255.0f) * 255.0f) + 0.5f); + } + } + ok= TRUE; + } + } + + if(ok==FALSE){ + printf("IMB_convert_profile: failed profile conversion %d -> %d\n", ibuf->profile, profile); + return; + } + + ibuf->profile= profile; +} |