[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30229] trunk/blender/source/blender: sequencer float conversion was only using rgb -> float conversion inconsistantly, some places used colorspace conversion, some not.
Campbell Barton
ideasman42 at gmail.com
Mon Jul 12 16:57:24 CEST 2010
Revision: 30229
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30229
Author: campbellbarton
Date: 2010-07-12 16:57:24 +0200 (Mon, 12 Jul 2010)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/displist.c
trunk/blender/source/blender/blenkernel/intern/seqeffects.c
trunk/blender/source/blender/blenkernel/intern/sequencer.c
trunk/blender/source/blender/imbuf/IMB_imbuf.h
trunk/blender/source/blender/imbuf/intern/divers.c
Modified: trunk/blender/source/blender/blenkernel/intern/displist.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/displist.c 2010-07-12 14:54:05 UTC (rev 30228)
+++ trunk/blender/source/blender/blenkernel/intern/displist.c 2010-07-12 14:57:24 UTC (rev 30229)
@@ -575,9 +575,9 @@
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 @@
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 @@
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 @@
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];
Modified: trunk/blender/source/blender/blenkernel/intern/seqeffects.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/seqeffects.c 2010-07-12 14:54:05 UTC (rev 30228)
+++ trunk/blender/source/blender/blenkernel/intern/seqeffects.c 2010-07-12 14:57:24 UTC (rev 30229)
@@ -312,7 +312,7 @@
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 @@
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));
}
}
Modified: trunk/blender/source/blender/blenkernel/intern/sequencer.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/sequencer.c 2010-07-12 14:54:05 UTC (rev 30228)
+++ trunk/blender/source/blender/blenkernel/intern/sequencer.c 2010-07-12 14:57:24 UTC (rev 30229)
@@ -1022,13 +1022,13 @@
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 @@
}
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,15 +2077,15 @@
}
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 @@
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 &&
Modified: trunk/blender/source/blender/imbuf/IMB_imbuf.h
===================================================================
--- trunk/blender/source/blender/imbuf/IMB_imbuf.h 2010-07-12 14:54:05 UTC (rev 30228)
+++ trunk/blender/source/blender/imbuf/IMB_imbuf.h 2010-07-12 14:57:24 UTC (rev 30229)
@@ -319,6 +319,9 @@
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
Modified: trunk/blender/source/blender/imbuf/intern/divers.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/divers.c 2010-07-12 14:54:05 UTC (rev 30228)
+++ trunk/blender/source/blender/imbuf/intern/divers.c 2010-07-12 14:57:24 UTC (rev 30229)
@@ -222,3 +222,74 @@
}
}
+/* 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;
+}
More information about the Bf-blender-cvs
mailing list