This is taking me longer than I wanted.
All of these I think still need work but they at least do not coredump. Basically they need some troubleshooting. I'm heading home now so will work on it again tomorrow hopefully. If anyone is bored feel free to take a look at them and see if you can find the problems. (dnr.c also needs to be converted to float aware) Kent
This commit is contained in:
parent
4e03e83a53
commit
783a2900a6
@ -138,8 +138,13 @@ void blurbuf(struct ImBuf *ibuf, int nr, Cast *cast)
|
|||||||
if(cast->gamma != 1.0) gamwarp(tbuf, 1.0 / cast->gamma);
|
if(cast->gamma != 1.0) gamwarp(tbuf, 1.0 / cast->gamma);
|
||||||
|
|
||||||
/* Very bad code warning! This fails badly with float-buffers!!! */
|
/* Very bad code warning! This fails badly with float-buffers!!! */
|
||||||
freeN(ibuf->rect);
|
if (ibuf->rect_float) {
|
||||||
ibuf->rect= tbuf->rect;
|
freeN(ibuf->rect_float);
|
||||||
|
ibuf->rect_float= tbuf->rect_float;
|
||||||
|
} else {
|
||||||
|
freeN(ibuf->rect);
|
||||||
|
ibuf->rect= tbuf->rect;
|
||||||
|
}
|
||||||
freeN(tbuf);
|
freeN(tbuf);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -153,6 +158,7 @@ void doblur(struct ImBuf *mbuf, float fac, Cast *cast)
|
|||||||
float ifac, pfac;
|
float ifac, pfac;
|
||||||
int n, b1, b2;
|
int n, b1, b2;
|
||||||
char *irect, *prect, *mrect;
|
char *irect, *prect, *mrect;
|
||||||
|
float *irectf, *prectf, *mrectf;
|
||||||
|
|
||||||
/* wich buffers ? */
|
/* wich buffers ? */
|
||||||
|
|
||||||
@ -178,30 +184,55 @@ void doblur(struct ImBuf *mbuf, float fac, Cast *cast)
|
|||||||
blurbuf(ibuf, n, cast);
|
blurbuf(ibuf, n, cast);
|
||||||
blurbuf(ibuf, n, cast);
|
blurbuf(ibuf, n, cast);
|
||||||
|
|
||||||
fac= 255.0*(fac-pfac)/(ifac-pfac);
|
fac = (fac-pfac)/(ifac-pfac);
|
||||||
b1= fac;
|
b1= 255.0*fac;
|
||||||
if(b1>255) b1= 255;
|
if(b1>255) b1= 255;
|
||||||
b2= 255-b1;
|
b2= 255-b1;
|
||||||
|
|
||||||
if(b1==255) {
|
if(b1==255) {
|
||||||
memcpy(mbuf->rect, ibuf->rect, 4*ibuf->x*ibuf->y);
|
if (mbuf->rect_float)
|
||||||
|
memcpy(mbuf->rect_float, ibuf->rect_float, 4*ibuf->x*ibuf->y * sizeof(float));
|
||||||
|
else
|
||||||
|
memcpy(mbuf->rect_float, ibuf->rect_float, 4*ibuf->x*ibuf->y);
|
||||||
}
|
}
|
||||||
else if(b1==0) {
|
else if(b1==0) {
|
||||||
memcpy(mbuf->rect, pbuf->rect, 4*pbuf->x*pbuf->y);
|
if (mbuf->rect_float)
|
||||||
|
memcpy(mbuf->rect_float, pbuf->rect_float, 4*pbuf->x*pbuf->y * sizeof(float));
|
||||||
|
else
|
||||||
|
memcpy(mbuf->rect, pbuf->rect, 4*pbuf->x*pbuf->y);
|
||||||
}
|
}
|
||||||
else { /* interpolate */
|
else { /* interpolate */
|
||||||
n= ibuf->x*ibuf->y;
|
n= ibuf->x*ibuf->y;
|
||||||
irect= (char *)ibuf->rect;
|
if (mbuf->rect_float) {
|
||||||
prect= (char *)pbuf->rect;
|
irectf= ibuf->rect_float;
|
||||||
mrect= (char *)mbuf->rect;
|
prectf= pbuf->rect_float;
|
||||||
while(n--) {
|
mrectf= mbuf->rect_float;
|
||||||
mrect[0]= (irect[0]*b1+ prect[0]*b2)>>8;
|
while(n--) {
|
||||||
mrect[1]= (irect[1]*b1+ prect[1]*b2)>>8;
|
mrectf[0]= (irectf[0]*fac+ prectf[0]*(1-fac))/2;
|
||||||
mrect[2]= (irect[2]*b1+ prect[2]*b2)>>8;
|
mrectf[1]= (irectf[1]*fac+ prectf[1]*(1-fac))/2;
|
||||||
mrect[3]= (irect[3]*b1+ prect[3]*b2)>>8;
|
mrectf[2]= (irectf[2]*fac+ prectf[2]*(1-fac))/2;
|
||||||
mrect+= 4;
|
mrectf[3]= (irectf[3]*fac+ prectf[3]*(1-fac))/2;
|
||||||
irect+= 4;
|
mrectf[0]= 1;
|
||||||
prect+= 4;
|
mrectf[1]= 1;
|
||||||
|
mrectf[2]= 1;
|
||||||
|
mrectf[3]= 1;
|
||||||
|
mrectf+= 4;
|
||||||
|
irectf+= 4;
|
||||||
|
prectf+= 4;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
irect= (char *)ibuf->rect;
|
||||||
|
prect= (char *)pbuf->rect;
|
||||||
|
mrect= (char *)mbuf->rect;
|
||||||
|
while(n--) {
|
||||||
|
mrect[0]= (irect[0]*b1+ prect[0]*b2)>>8;
|
||||||
|
mrect[1]= (irect[1]*b1+ prect[1]*b2)>>8;
|
||||||
|
mrect[2]= (irect[2]*b1+ prect[2]*b2)>>8;
|
||||||
|
mrect[3]= (irect[3]*b1+ prect[3]*b2)>>8;
|
||||||
|
mrect+= 4;
|
||||||
|
irect+= 4;
|
||||||
|
prect+= 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
freeImBuf(ibuf);
|
freeImBuf(ibuf);
|
||||||
@ -221,7 +252,8 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int x, int y, ImBuf *
|
|||||||
bfacf1 = (facf1 * 6.0) + 1.0;
|
bfacf1 = (facf1 * 6.0) + 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(out->rect, ibuf1->rect, 4*out->x*out->y);
|
if (out->rect_float) memcpy(out->rect_float, ibuf1->rect_float, 4*out->x*out->y * sizeof(float));
|
||||||
|
else memcpy(out->rect, ibuf1->rect, 4*out->x*out->y);
|
||||||
|
|
||||||
/* it blurs interlaced, only tested with even fields */
|
/* it blurs interlaced, only tested with even fields */
|
||||||
de_interlace(out);
|
de_interlace(out);
|
||||||
@ -231,11 +263,14 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int x, int y, ImBuf *
|
|||||||
|
|
||||||
doblur(out, bfacf0, cast); /*fieldA*/
|
doblur(out, bfacf0, cast); /*fieldA*/
|
||||||
|
|
||||||
out->rect += out->x * out->y;
|
if (out->rect_float) out->rect_float += out->x * out->y;
|
||||||
|
else out->rect += out->x * out->y;
|
||||||
|
|
||||||
doblur(out, bfacf1, cast); /*fieldB*/
|
doblur(out, bfacf1, cast); /*fieldB*/
|
||||||
|
|
||||||
out->rect -= out->x * out->y;
|
if (out->rect_float) out->rect_float -= out->x * out->y;
|
||||||
|
else out->rect -= out->x * out->y;
|
||||||
|
|
||||||
out->flags |= IB_fields;
|
out->flags |= IB_fields;
|
||||||
|
|
||||||
interlace(out);
|
interlace(out);
|
||||||
|
@ -182,10 +182,12 @@ static void rgb_to_hsv (double r, double g, double b,
|
|||||||
|
|
||||||
void plugin_seq_doit(Cast *cast, float facf0, float facf1, int width,
|
void plugin_seq_doit(Cast *cast, float facf0, float facf1, int width,
|
||||||
int height, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *out, ImBuf *use) {
|
int height, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *out, ImBuf *use) {
|
||||||
char *dest, *src1, *src2;
|
char *dest, *src1;
|
||||||
int x, y, c;
|
int x, y, c;
|
||||||
double gamma_table[256];
|
double gamma_table[256];
|
||||||
double uv_table[256];
|
double uv_table[256];
|
||||||
|
float *destf = out->rect_float;
|
||||||
|
float *src1f = ibuf1->rect_float;
|
||||||
|
|
||||||
if (!ibuf1) return;
|
if (!ibuf1) return;
|
||||||
|
|
||||||
@ -224,7 +226,9 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int width,
|
|||||||
double h,s,v,r,g,b;
|
double h,s,v,r,g,b;
|
||||||
double fac;
|
double fac;
|
||||||
|
|
||||||
rgb_to_hsv((double) src1[0]/255.0,
|
if (ibuf1->rect_float) rgb_to_hsv(src1f[0], src1f[1],
|
||||||
|
src1f[2],&h,&s,&v);
|
||||||
|
else rgb_to_hsv((double) src1[0]/255.0,
|
||||||
(double) src1[1]/255.0,
|
(double) src1[1]/255.0,
|
||||||
(double) src1[2]/255.0,
|
(double) src1[2]/255.0,
|
||||||
&h, &s, &v);
|
&h, &s, &v);
|
||||||
@ -238,10 +242,18 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int width,
|
|||||||
}
|
}
|
||||||
hsv_to_rgb(h,s,v, &r, &g, &b);
|
hsv_to_rgb(h,s,v, &r, &g, &b);
|
||||||
|
|
||||||
*dest++ = r*255.0;
|
if (out->rect_float) {
|
||||||
*dest++ = g*255.0;
|
destf[0] = r;
|
||||||
*dest++ = b*255.0;
|
destf[1] = g;
|
||||||
dest++;
|
destf[2] = b;
|
||||||
|
destf = destf + 4;
|
||||||
|
src1f +=4;
|
||||||
|
} else {
|
||||||
|
dest[0] = r*255.0;
|
||||||
|
dest[1] = g*255.0;
|
||||||
|
dest[2] = b*255.0;
|
||||||
|
dest += 4;
|
||||||
|
}
|
||||||
|
|
||||||
src1 += 4;
|
src1 += 4;
|
||||||
}
|
}
|
||||||
|
@ -119,6 +119,8 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int width,
|
|||||||
float yuv[3];
|
float yuv[3];
|
||||||
float gamma_table[256];
|
float gamma_table[256];
|
||||||
float uv_table[256];
|
float uv_table[256];
|
||||||
|
float *destf = out->rect_float;
|
||||||
|
float *src1f = ibuf1->rect_float;
|
||||||
|
|
||||||
if (!ibuf1) return;
|
if (!ibuf1) return;
|
||||||
|
|
||||||
@ -155,9 +157,15 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int width,
|
|||||||
for (y = 0; y < height; y++) {
|
for (y = 0; y < height; y++) {
|
||||||
for (x = 0; x < width; x++) {
|
for (x = 0; x < width; x++) {
|
||||||
float fac;
|
float fac;
|
||||||
rgb[0]= (float)src1[0]/255.0;
|
if (out->rect_float) {
|
||||||
rgb[1]= (float)src1[1]/255.0;
|
rgb[0]= (float)src1f[0]/255.0;
|
||||||
rgb[2]= (float)src1[2]/255.0;
|
rgb[1]= (float)src1f[1]/255.0;
|
||||||
|
rgb[2]= (float)src1f[2]/255.0;
|
||||||
|
} else {
|
||||||
|
rgb[0]= (float)src1[0]/255.0;
|
||||||
|
rgb[1]= (float)src1[1]/255.0;
|
||||||
|
rgb[2]= (float)src1[2]/255.0;
|
||||||
|
}
|
||||||
rgb_to_yuv(rgb, yuv);
|
rgb_to_yuv(rgb, yuv);
|
||||||
|
|
||||||
yuv[0] = gamma_table[(int) (yuv[0] * 255.0)] / 255.0;
|
yuv[0] = gamma_table[(int) (yuv[0] * 255.0)] / 255.0;
|
||||||
@ -179,12 +187,19 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int width,
|
|||||||
}
|
}
|
||||||
yuv_to_rgb(yuv, rgb);
|
yuv_to_rgb(yuv, rgb);
|
||||||
|
|
||||||
*dest++ = rgb[0]*255.0;
|
if (out->rect_float) {
|
||||||
*dest++ = rgb[1]*255.0;
|
*destf++ = rgb[0];
|
||||||
*dest++ = rgb[2]*255.0;
|
*destf++ = rgb[1];
|
||||||
dest++;
|
*destf++ = rgb[2];
|
||||||
|
destf++;
|
||||||
src1 += 4;
|
src1f += 4;
|
||||||
|
} else {
|
||||||
|
*dest++ = rgb[0]*255.0;
|
||||||
|
*dest++ = rgb[1]*255.0;
|
||||||
|
*dest++ = rgb[2]*255.0;
|
||||||
|
dest++;
|
||||||
|
src1 += 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,20 +99,17 @@ void plugin_getinfo(PluginInfo *info)
|
|||||||
/* ************************************************************
|
/* ************************************************************
|
||||||
Scatter
|
Scatter
|
||||||
|
|
||||||
with usage of ImBuf rect operation.
|
|
||||||
|
|
||||||
************************************************************ */
|
************************************************************ */
|
||||||
|
|
||||||
static void ibufrectop(ImBuf *dbuf, ImBuf *sbuf,
|
static void rectcpy(ImBuf *dbuf, ImBuf *sbuf,
|
||||||
int destx, int desty,
|
int destx, int desty,
|
||||||
int srcx, int srcy, int width, int height,
|
int srcx, int srcy, int width, int height)
|
||||||
void (*operation)(),
|
|
||||||
int value)
|
|
||||||
{
|
{
|
||||||
uint *drect,*srect;
|
uint *drect,*srect;
|
||||||
|
float *dfrect, *sfrect;
|
||||||
|
int tmp;
|
||||||
|
|
||||||
if (dbuf == 0) return;
|
if (dbuf == 0) return;
|
||||||
if (operation == 0) return;
|
|
||||||
|
|
||||||
if (destx < 0){
|
if (destx < 0){
|
||||||
srcx -= destx ;
|
srcx -= destx ;
|
||||||
@ -140,41 +137,71 @@ static void ibufrectop(ImBuf *dbuf, ImBuf *sbuf,
|
|||||||
if (sbuf){
|
if (sbuf){
|
||||||
if (width > sbuf->x - srcx) width = sbuf->x - srcx;
|
if (width > sbuf->x - srcx) width = sbuf->x - srcx;
|
||||||
if (height > sbuf->y - srcy) height = sbuf->y - srcy;
|
if (height > sbuf->y - srcy) height = sbuf->y - srcy;
|
||||||
|
srect = sbuf->rect;
|
||||||
|
sfrect = sbuf->rect_float;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width <= 0) return;
|
if (width <= 0) return;
|
||||||
if (height <= 0) return;
|
if (height <= 0) return;
|
||||||
|
|
||||||
drect = dbuf->rect;
|
drect = dbuf->rect;
|
||||||
if (sbuf) srect = sbuf->rect;
|
dfrect = dbuf->rect_float;
|
||||||
|
|
||||||
|
tmp = desty * dbuf->x + destx;
|
||||||
|
|
||||||
|
if (dbuf->rect_float) dfrect += tmp;
|
||||||
|
else drect += tmp;
|
||||||
|
|
||||||
drect += desty * dbuf->x;
|
|
||||||
drect += destx;
|
|
||||||
destx = dbuf->x;
|
destx = dbuf->x;
|
||||||
|
|
||||||
if (sbuf) {
|
if (sbuf) {
|
||||||
srect += srcy * sbuf->x;
|
tmp = srcy * sbuf->x + srcx;
|
||||||
srect += srcx;
|
if (dbuf->rect_float) sfrect += tmp;
|
||||||
|
else srect += tmp;
|
||||||
srcx = sbuf->x;
|
srcx = sbuf->x;
|
||||||
} else{
|
} else{
|
||||||
srect = drect;
|
if (dbuf->rect_float) sfrect = dfrect;
|
||||||
|
else srect = drect;
|
||||||
srcx = destx;
|
srcx = destx;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;height > 0; height--){
|
for (;height > 0; height--){
|
||||||
operation(drect, srect, width, value);
|
if (dbuf->rect_float) {
|
||||||
drect += destx;
|
memcpy(dfrect,sfrect, srcx * sizeof(float));
|
||||||
srect += srcx;
|
dfrect += destx;
|
||||||
|
sfrect += srcx;
|
||||||
|
} else {
|
||||||
|
memcpy(drect,srect, srcx * sizeof(int));
|
||||||
|
drect += destx;
|
||||||
|
srect += srcx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rectcpy(uint *drect, uint *srect, int x) {
|
static void fill_out(ImBuf *out, float r, float g, float b, float a)
|
||||||
memcpy(drect,srect, x * sizeof(int));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void rectfill(uint *drect, uint *srect, int x, int value)
|
|
||||||
{
|
{
|
||||||
for (;x > 0; x--) *drect++ = value;
|
int tot,x;
|
||||||
|
float *rectf = out->rect_float;
|
||||||
|
unsigned char *rect = (unsigned char *)out->rect;
|
||||||
|
|
||||||
|
tot = out->x * out->y;
|
||||||
|
if (out->rect_float) {
|
||||||
|
for (x = 0;x < tot; x++) {
|
||||||
|
rectf[0] = r;
|
||||||
|
rectf[1] = g;
|
||||||
|
rectf[2] = b;
|
||||||
|
rectf[3] = a;
|
||||||
|
rectf = rectf + 4;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (x=0;x < tot;x++) {
|
||||||
|
rect[0] = (int)(r * 255);
|
||||||
|
rect[1] = (int)(g * 255);
|
||||||
|
rect[2] = (int)(b * 255);
|
||||||
|
rect[3] = (int)(a * 255);
|
||||||
|
rect += 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -184,7 +211,7 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int sx, int sy, ImBuf
|
|||||||
int x, y, lr;
|
int x, y, lr;
|
||||||
|
|
||||||
/* fill imbuf 'out' with black */
|
/* fill imbuf 'out' with black */
|
||||||
ibufrectop(out, ibuf1,0,0,0,0,32767,32767,rectfill, 0);
|
fill_out(out, 0,0,0,0);
|
||||||
|
|
||||||
switch (cast->type) {
|
switch (cast->type) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -223,12 +250,12 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int sx, int sy, ImBuf
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ibufrectop(out, ibuf1, 0, y, x, y, 32767, 1, rectcpy, 0);
|
rectcpy(out, ibuf1, 0, y, x, y, 32767, 1);
|
||||||
if (cast->wrap) {
|
if (cast->wrap) {
|
||||||
ibufrectop(out, ibuf1, 0, y, x + sx, y, 32767, 1, rectcpy, 0);
|
rectcpy(out, ibuf1, 0, y, x + sx, y, 32767, 1);
|
||||||
ibufrectop(out, ibuf1, 0, y, x + sx + sx, y, 32767, 1, rectcpy, 0);
|
rectcpy(out, ibuf1, 0, y, x + sx + sx, y, 32767, 1);
|
||||||
ibufrectop(out, ibuf1, 0, y, x - sx, y, 32767, 1, rectcpy, 0);
|
rectcpy(out, ibuf1, 0, y, x - sx, y, 32767, 1);
|
||||||
ibufrectop(out, ibuf1, 0, y, x - sx - sx, y, 32767, 1, rectcpy, 0);
|
rectcpy(out, ibuf1, 0, y, x - sx - sx, y, 32767, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user