[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11490] trunk/blender/source/blender: == Sequencer ==
Peter Schlaile
peter at schlaile.de
Sun Aug 5 20:22:46 CEST 2007
Revision: 11490
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11490
Author: schlaile
Date: 2007-08-05 20:22:45 +0200 (Sun, 05 Aug 2007)
Log Message:
-----------
== Sequencer ==
This adds "[#6766] Transform Sequencer effect" by damiles.
* Configurable interpolation: no, linear, bicubic
* Makes it possible to specify coordinates in units of pixels or by percent
of the picture size
It makes the code a lot more clean, since new imbuf functions are used.
This patch also fixes
[#6829] Limit on VSE Transform Effect
Modified Paths:
--------------
trunk/blender/source/blender/makesdna/DNA_sequence_types.h
trunk/blender/source/blender/src/drawseq.c
trunk/blender/source/blender/src/seqeffects.c
Modified: trunk/blender/source/blender/makesdna/DNA_sequence_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_sequence_types.h 2007-08-05 17:44:32 UTC (rev 11489)
+++ trunk/blender/source/blender/makesdna/DNA_sequence_types.h 2007-08-05 18:22:45 UTC (rev 11490)
@@ -170,6 +170,8 @@
float yFin;
float rotIni;
float rotFin;
+ int percent;
+ int interpolation;
} TransformVars;
typedef struct SolidColorVars {
Modified: trunk/blender/source/blender/src/drawseq.c
===================================================================
--- trunk/blender/source/blender/src/drawseq.c 2007-08-05 17:44:32 UTC (rev 11489)
+++ trunk/blender/source/blender/src/drawseq.c 2007-08-05 18:22:45 UTC (rev 11490)
@@ -1192,14 +1192,29 @@
uiDefButF(block, NUM, SEQ_BUT_EFFECT, "yScale Start:", 10,50,150,19, &transform->ScaleyIni, 0.0, 10.0, 0, 0, "Y Scale Start");
uiDefButF(block, NUM, SEQ_BUT_EFFECT, "yScale End:", 160,50,150,19, &transform->ScaleyFin, 0.0, 10.0, 0, 0, "Y Scale End");
- uiDefButF(block, NUM, SEQ_BUT_EFFECT, "x Start:", 10,30,150,19, &transform->xIni, -1000.0, 1000.0, 0, 0, "X Position Start");
- uiDefButF(block, NUM, SEQ_BUT_EFFECT, "x End:", 160,30,150,19, &transform->xFin, -1000.0, 1000.0, 0, 0, "X Position End");
+ uiDefButI(block, ROW, SEQ_BUT_EFFECT, "Percent", 10, 30, 150, 19, &transform->percent, 0.0, 1.0, 0.0, 0.0, "Percent Translate");
+ uiDefButI(block, ROW, SEQ_BUT_EFFECT, "Pixels", 160, 30, 150, 19, &transform->percent, 0.0, 0.0, 0.0, 0.0, "Pixels Translate");
+ if(transform->percent==1){
+ uiDefButF(block, NUM, SEQ_BUT_EFFECT, "x Start:", 10,10,150,19, &transform->xIni, -100.0, 100.0, 0, 0, "X Position Start");
+ uiDefButF(block, NUM, SEQ_BUT_EFFECT, "x End:", 160,10,150,19, &transform->xFin, -100.0, 100.0, 0, 0, "X Position End");
+ uiDefButF(block, NUM, SEQ_BUT_EFFECT, "y Start:", 10,-10,150,19, &transform->yIni, -100.0, 100.0, 0, 0, "Y Position Start");
+ uiDefButF(block, NUM, SEQ_BUT_EFFECT, "y End:", 160,-10,150,19, &transform->yFin, -100.0, 100.0, 0, 0, "Y Position End");
+ }else{
+ uiDefButF(block, NUM, SEQ_BUT_EFFECT, "x Start:", 10,10,150,19, &transform->xIni, -10000.0, 10000.0, 0, 0, "X Position Start");
+ uiDefButF(block, NUM, SEQ_BUT_EFFECT, "x End:", 160,10,150,19, &transform->xFin, -10000.0, 10000.0, 0, 0, "X Position End");
+ uiDefButF(block, NUM, SEQ_BUT_EFFECT, "y Start:", 10,-10,150,19, &transform->yIni, -10000.0, 10000.0, 0, 0, "Y Position Start");
+ uiDefButF(block, NUM, SEQ_BUT_EFFECT, "y End:", 160,-10,150,19, &transform->yFin, -10000.0, 10000.0, 0, 0, "Y Position End");
- uiDefButF(block, NUM, SEQ_BUT_EFFECT, "y Start:", 10,10,150,19, &transform->yIni, -1000.0, 1000.0, 0, 0, "Y Position Start");
- uiDefButF(block, NUM, SEQ_BUT_EFFECT, "y End:", 160,10,150,19, &transform->yFin, -1000.0, 1000.0, 0, 0, "Y Position End");
+ }
+
- uiDefButF(block, NUM, SEQ_BUT_EFFECT, "rot Start:",10,-10,150,19, &transform->rotIni, 0.0, 360.0, 0, 0, "Rotation Start");
- uiDefButF(block, NUM, SEQ_BUT_EFFECT, "rot End:",160,-10,150,19, &transform->rotFin, 0.0, 360.0, 0, 0, "Rotation End");
+
+ uiDefButF(block, NUM, SEQ_BUT_EFFECT, "rot Start:",10,-30,150,19, &transform->rotIni, 0.0, 360.0, 0, 0, "Rotation Start");
+ uiDefButF(block, NUM, SEQ_BUT_EFFECT, "rot End:",160,-30,150,19, &transform->rotFin, 0.0, 360.0, 0, 0, "Rotation End");
+
+ uiDefButI(block, ROW, SEQ_BUT_EFFECT, "No Interpolat", 10, -50, 100, 19, &transform->interpolation, 0.0, 0.0, 0.0, 0.0, "No interpolation");
+ uiDefButI(block, ROW, SEQ_BUT_EFFECT, "Bilinear", 101, -50, 100, 19, &transform->interpolation, 0.0, 1.0, 0.0, 0.0, "Bilinear interpolation");
+ uiDefButI(block, ROW, SEQ_BUT_EFFECT, "Bicubic", 202, -50, 100, 19, &transform->interpolation, 0.0, 2.0, 0.0, 0.0, "Bicubic interpolation");
} else if(last_seq->type==SEQ_COLOR) {
SolidColorVars *colvars = (SolidColorVars *)last_seq->effectdata;
uiDefButF(block, COL, SEQ_BUT_RELOAD, "",10,90,150,19, colvars->col, 0, 0, 0, 0, "");
Modified: trunk/blender/source/blender/src/seqeffects.c
===================================================================
--- trunk/blender/source/blender/src/seqeffects.c 2007-08-05 17:44:32 UTC (rev 11489)
+++ trunk/blender/source/blender/src/seqeffects.c 2007-08-05 18:22:45 UTC (rev 11490)
@@ -1926,6 +1926,8 @@
scale->rotIni=0;
scale->rotFin=0;
+ scale->interpolation=1;
+ scale->percent=1;
}
static int num_inputs_transform()
@@ -1944,50 +1946,9 @@
dst->effectdata = MEM_dupallocN(src->effectdata);
}
-/* function assumes out to be zero'ed, only does RGBA */
-static void bilinear_interpolation_transform_float(ImBuf *in, float *out, float u, float v)
+static void do_transform(Sequence * seq,float facf0, int x, int y,
+ struct ImBuf *ibuf1,struct ImBuf *out)
{
- float *row1, *row2, *row3, *row4, a, b;
- float a_b, ma_b, a_mb, ma_mb;
- float empty[4]= {0.0f, 0.0f, 0.0f, 0.0f};
- int y1, y2, x1, x2;
-
- x1= (int)floor(u);
- x2= (int)ceil(u);
- y1= (int)floor(v);
- y2= (int)ceil(v);
-
- /* sample area entirely outside image? */
- if(x2<0 || x1>in->x-1 || y2<0 || y1>in->y-1)
- return;
-
- /* sample including outside of edges of image */
- if(x1<0 || y1<0) row1= empty;
- else row1= in->rect_float + in->x * y1 * 4 + 4*x1;
-
- if(x1<0 || y2>in->y-1) row2= empty;
- else row2= in->rect_float + in->x * y2 * 4 + 4*x1;
-
- if(x2>in->x-1 || y1<0) row3= empty;
- else row3= in->rect_float + in->x * y1 * 4 + 4*x2;
-
- if(x2>in->x-1 || y2>in->y-1) row4= empty;
- else row4= in->rect_float + in->x * y2 * 4 + 4*x2;
-
- a= u-floor(u);
- b= v-floor(v);
- a_b= a*b; ma_b= (1.0f-a)*b; a_mb= a*(1.0f-b); ma_mb= (1.0f-a)*(1.0f-b);
-
- out[0]= ma_mb*row1[0] + a_mb*row3[0] + ma_b*row2[0]+ a_b*row4[0];
- out[1]= ma_mb*row1[1] + a_mb*row3[1] + ma_b*row2[1]+ a_b*row4[1];
- out[2]= ma_mb*row1[2] + a_mb*row3[2] + ma_b*row2[2]+ a_b*row4[2];
- out[3]= ma_mb*row1[3] + a_mb*row3[3] + ma_b*row2[3]+ a_b*row4[3];
-}
-
-
-static void do_transform_effect_float(Sequence * seq,float facf0, int x, int y,
- struct ImBuf *ibuf1,float *out)
-{
int xo, yo, xi, yi;
float xs,ys,factxScale,factyScale,tx,ty,rad,s,c,xaux,yaux,factRot,px,py;
TransformVars *scale;
@@ -1996,151 +1957,20 @@
xo = x;
yo = y;
- /*factor scale*/
+ //factor scale
factxScale = scale->ScalexIni + (scale->ScalexFin - scale->ScalexIni) * facf0;
factyScale = scale->ScaleyIni + (scale->ScaleyFin - scale->ScaleyIni) * facf0;
- /*Factor translate*/
- tx = scale->xIni+(xo / 2.0f) + (scale->xFin-(xo / 2.0f) - scale->xIni+(xo / 2.0f)) * facf0;
- ty = scale->yIni+(yo / 2.0f) + (scale->yFin-(yo / 2.0f) - scale->yIni+(yo / 2.0f)) * facf0;
-
- /*factor Rotate*/
- factRot = scale->rotIni + (scale->rotFin - scale->rotIni) * facf0;
- rad = (M_PI * factRot) / 180.0f;
- s= sin(rad);
- c= cos(rad);
-
- for (yi = 0; yi < yo; yi++) {
- for (xi = 0; xi < xo; xi++) {
- /*tranlate point*/
- px = xi-tx;
- py = yi-ty;
-
- /*rotate point with center ref*/
- xaux = c*px + py*s ;
- yaux = -s*px + c*py;
-
- /*scale point with center ref*/
- xs = xaux / factxScale;
- ys = yaux / factyScale;
-
- /*undo reference center point */
- xs += (xo / 2.0f);
- ys += (yo / 2.0f);
-
- /*interpolate*/
- bilinear_interpolation_transform_float(ibuf1,out, xs,ys);
-
- out+=4;
- }
- }
-
-}
-
-/* function assumes out to be zero'ed, only does RGBA */
-static void bilinear_interpolation_transform_byte(unsigned char *in, unsigned char *out, float u, float v,int x,int y)
-{
- float a, b;
- float a_b, ma_b, a_mb, ma_mb;
- int y1, y2, x1, x2;
-
- int row1R,row1G,row1B,row1A;
- int row2R,row2G,row2B,row2A;
- int row3R,row3G,row3B,row3A;
- int row4R,row4G,row4B,row4A;
-
- x1= (int)floor(u);
- x2= (int)ceil(u);
- y1= (int)floor(v);
- y2= (int)ceil(v);
-
- /* sample area entirely outside image? */
- if(x2<0 || x1>x-1 || y2<0 || y1>y-1)
- return;
-
- /* sample including outside of edges of image */
- if(x1<0 || y1<0){
- row1R = 0;
- row1G = 0;
- row1B = 0;
- row1A = 0;
+ //Factor translate
+ if(!scale->percent){
+ tx = scale->xIni+(xo / 2.0f) + (scale->xFin-(xo / 2.0f) - scale->xIni+(xo / 2.0f)) * facf0;
+ ty = scale->yIni+(yo / 2.0f) + (scale->yFin-(yo / 2.0f) - scale->yIni+(yo / 2.0f)) * facf0;
+ }else{
+ tx = xo*(scale->xIni/100.0)+(xo / 2.0f) + (xo*(scale->xFin/100.0)-(xo / 2.0f) - xo*(scale->xIni/100.0)+(xo / 2.0f)) * facf0;
+ ty = yo*(scale->yIni/100.0)+(yo / 2.0f) + (yo*(scale->yFin/100.0)-(yo / 2.0f) - yo*(scale->yIni/100.0)+(yo / 2.0f)) * facf0;
}
- else{
- row1R= in[x * y1 * 4 + 4 * x1];
- row1G= in[x * y1 * 4 + 4 * x1 + 1];
- row1B= in[x * y1 * 4 + 4 * x1 + 2];
- row1A= in[x * y1 * 4 + 4 * x1 + 3];
- }
-
- if(x1<0 || y2>y-1){
- row2R = 0;
- row2G = 0;
- row2B = 0;
- row2A = 0;
- }
- else{
- row2R= in[x * y2 * 4 + 4 * x1];
- row2G= in[x * y2 * 4 + 4 * x1 + 1];
- row2B= in[x * y2 * 4 + 4 * x1 + 2];
- row2A= in[x * y2 * 4 + 4 * x1 + 3];
- }
-
- if(x2>x-1 || y1<0){
- row3R = 0;
- row3G = 0;
- row3B = 0;
- row3A = 0;
- }
- else{
- row3R= in[x * y1 * 4 + 4 * x2];
- row3G= in[x * y1 * 4 + 4 * x2 + 1];
- row3B= in[x * y1 * 4 + 4 * x2 + 2];
- row3A= in[x * y1 * 4 + 4 * x2 + 3];
- }
-
- if(x2>x-1 || y2>y-1){
- row4R = 0;
- row4G = 0;
- row4B = 0;
- row4A = 0;
- }
- else{
- row4R= in[x * y2 * 4 + 4 * x2];
- row4G= in[x * y2 * 4 + 4 * x2 + 1];
- row4B= in[x * y2 * 4 + 4 * x2 + 2];
- row4A= in[x * y2 * 4 + 4 * x2 + 3];
- }
-
- a= u-floor(u);
- b= v-floor(v);
- a_b= a*b; ma_b= (1-a)*b; a_mb= a*(1-b); ma_mb= (1-a)*(1-b);
-
- out[0]= (int)(ma_mb*row1R + a_mb*row3R + ma_b*row2R + a_b*row4R);
- out[1]= (int)(ma_mb*row1G + a_mb*row3G + ma_b*row2G + a_b*row4G);
- out[2]= (int)(ma_mb*row1B + a_mb*row3B + ma_b*row2B + a_b*row4B);
- out[3]= (int)(ma_mb*row1A + a_mb*row3A + ma_b*row2A + a_b*row4A);
-}
-static void do_transform_effect_byte(Sequence * seq,float facf0, int x, int y,
- unsigned char *ibuf1,unsigned char *out)
-{
- int xo, yo, xi, yi;
- float xs,ys,factxScale,factyScale,tx,ty,rad,s,c,xaux,yaux,factRot,px,py;
- TransformVars *scale;
-
- scale = (TransformVars *)seq->effectdata;
- xo = x;
- yo = y;
-
- /*factor scale*/
- factxScale = scale->ScalexIni + (scale->ScalexFin - scale->ScalexIni) * facf0;
- factyScale = scale->ScaleyIni + (scale->ScaleyFin - scale->ScaleyIni) * facf0;
-
- /*Factor translate*/
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list