style cleanup: seqeffects

This commit is contained in:
Campbell Barton
2012-05-08 09:31:25 +00:00
parent 670916dbff
commit 7a4ad3aaae

View File

@@ -58,27 +58,27 @@
#include "RNA_access.h"
/* **** XXX **** */
static void error(const char *UNUSED(error), ...) {}
static void error(const char *UNUSED(error), ...) {
}
#define INT 96
#define FLO 128
#define INT 96
#define FLO 128
/* **** XXX **** */
/* Glow effect */
enum {
GlowR=0,
GlowG=1,
GlowB=2,
GlowA=3
GlowR = 0,
GlowG = 1,
GlowB = 2,
GlowA = 3
};
static struct ImBuf * prepare_effect_imbufs(
SeqRenderData context,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
{
struct ImBuf * out;
static struct ImBuf *prepare_effect_imbufs(
SeqRenderData context,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3){
struct ImBuf *out;
int x = context.rectx;
int y = context.recty;
@@ -87,8 +87,9 @@ static struct ImBuf * prepare_effect_imbufs(
out = IMB_allocImBuf((short)x, (short)y, 32, IB_rect);
}
else if ((ibuf1 && ibuf1->rect_float) ||
(ibuf2 && ibuf2->rect_float) ||
(ibuf3 && ibuf3->rect_float)) {
(ibuf2 && ibuf2->rect_float) ||
(ibuf3 && ibuf3->rect_float))
{
/* if any inputs are rectfloat, output is float too */
out = IMB_allocImBuf((short)x, (short)y, 32, IB_rectfloat);
@@ -127,15 +128,15 @@ static struct ImBuf * prepare_effect_imbufs(
static void open_plugin_seq(PluginSeq *pis, const char *seqname)
{
int (*version)(void);
void* (*alloc_private)(void);
void * (*alloc_private)(void);
char *cp;
/* to be sure: (is tested for) */
pis->doit= NULL;
pis->pname= NULL;
pis->varstr= NULL;
pis->cfra= NULL;
pis->version= 0;
pis->doit = NULL;
pis->pname = NULL;
pis->varstr = NULL;
pis->cfra = NULL;
pis->version = 0;
pis->instance_private_data = NULL;
/* clear the error list */
@@ -145,55 +146,54 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname)
/* pis->handle= 0; */
/* open the needed object */
pis->handle= BLI_dynlib_open(pis->name);
pis->handle = BLI_dynlib_open(pis->name);
if (test_dlerr(pis->name, pis->name)) return;
if (pis->handle != NULL) {
/* find the address of the version function */
version= (int (*)(void))BLI_dynlib_find_symbol(pis->handle, "plugin_seq_getversion");
version = (int (*)(void))BLI_dynlib_find_symbol(pis->handle, "plugin_seq_getversion");
if (test_dlerr(pis->name, "plugin_seq_getversion")) return;
if (version != NULL) {
pis->version= version();
pis->version = version();
if (pis->version >= 2 && pis->version <= 6) {
int (*info_func)(PluginInfo *);
PluginInfo *info= (PluginInfo*) MEM_mallocN(sizeof(PluginInfo), "plugin_info");
PluginInfo *info = (PluginInfo *) MEM_mallocN(sizeof(PluginInfo), "plugin_info");
info_func= (int (*)(PluginInfo *))BLI_dynlib_find_symbol(pis->handle, "plugin_getinfo");
info_func = (int (*)(PluginInfo *))BLI_dynlib_find_symbol(pis->handle, "plugin_getinfo");
if (info_func == NULL) error("No info func");
else {
info_func(info);
pis->pname= info->name;
pis->vars= info->nvars;
pis->cfra= info->cfra;
pis->pname = info->name;
pis->vars = info->nvars;
pis->cfra = info->cfra;
pis->varstr= info->varstr;
pis->varstr = info->varstr;
pis->doit= (void(*)(void))info->seq_doit;
pis->doit = (void (*)(void))info->seq_doit;
if (info->init)
info->init();
}
MEM_freeN(info);
cp= BLI_dynlib_find_symbol(pis->handle, "seqname");
cp = BLI_dynlib_find_symbol(pis->handle, "seqname");
if (cp) BLI_strncpy(cp, seqname, SEQ_NAME_MAXSTR);
}
else {
printf ("Plugin returned unrecognized version number\n");
printf("Plugin returned unrecognized version number\n");
return;
}
}
alloc_private = (void* (*)(void))BLI_dynlib_find_symbol(
pis->handle, "plugin_seq_alloc_private_data");
alloc_private = (void * (*)(void))BLI_dynlib_find_symbol(
pis->handle, "plugin_seq_alloc_private_data");
if (alloc_private) {
pis->instance_private_data = alloc_private();
}
pis->current_private_data = (void**)
BLI_dynlib_find_symbol(
pis->handle, "plugin_private_data");
pis->current_private_data = (void **)
BLI_dynlib_find_symbol(pis->handle, "plugin_private_data");
}
}
@@ -203,25 +203,25 @@ static PluginSeq *add_plugin_seq(const char *str, const char *seqname)
VarStruct *varstr;
int a;
pis= MEM_callocN(sizeof(PluginSeq), "PluginSeq");
pis = MEM_callocN(sizeof(PluginSeq), "PluginSeq");
BLI_strncpy(pis->name, str, FILE_MAX);
open_plugin_seq(pis, seqname);
if (pis->doit==NULL) {
if (pis->handle==NULL) error("no plugin: %s", str);
if (pis->doit == NULL) {
if (pis->handle == NULL) error("no plugin: %s", str);
else error("in plugin: %s", str);
MEM_freeN(pis);
return NULL;
}
/* default values */
varstr= pis->varstr;
for (a=0; a<pis->vars; a++, varstr++) {
if ( (varstr->type & FLO)==FLO)
pis->data[a]= varstr->def;
else if ( (varstr->type & INT)==INT)
*((int *)(pis->data+a))= (int) varstr->def;
varstr = pis->varstr;
for (a = 0; a < pis->vars; a++, varstr++) {
if ( (varstr->type & FLO) == FLO)
pis->data[a] = varstr->def;
else if ( (varstr->type & INT) == INT)
*((int *)(pis->data + a)) = (int) varstr->def;
}
return pis;
@@ -229,7 +229,7 @@ static PluginSeq *add_plugin_seq(const char *str, const char *seqname)
static void free_plugin_seq(PluginSeq *pis)
{
if (pis==NULL) return;
if (pis == NULL) return;
/* no BLI_dynlib_close: same plugin can be opened multiple times with 1 handle */
@@ -237,7 +237,7 @@ static void free_plugin_seq(PluginSeq *pis)
void (*free_private)(void *);
free_private = (void (*)(void *))BLI_dynlib_find_symbol(
pis->handle, "plugin_seq_free_private_data");
pis->handle, "plugin_seq_free_private_data");
if (free_private) {
free_private(pis->instance_private_data);
}
@@ -246,9 +246,9 @@ static void free_plugin_seq(PluginSeq *pis)
MEM_freeN(pis);
}
static void init_plugin(Sequence * seq, const char * fname)
static void init_plugin(Sequence *seq, const char *fname)
{
seq->plugin= (PluginSeq *)add_plugin_seq(fname, seq->name+2);
seq->plugin = (PluginSeq *)add_plugin_seq(fname, seq->name + 2);
}
/*
@@ -259,34 +259,34 @@ static int num_inputs_plugin(void)
return 1;
}
static void load_plugin(Sequence * seq)
static void load_plugin(Sequence *seq)
{
if (seq) {
open_plugin_seq(seq->plugin, seq->name+2);
open_plugin_seq(seq->plugin, seq->name + 2);
}
}
static void copy_plugin(Sequence * dst, Sequence * src)
static void copy_plugin(Sequence *dst, Sequence *src)
{
if (src->plugin) {
dst->plugin= MEM_dupallocN(src->plugin);
open_plugin_seq(dst->plugin, dst->name+2);
dst->plugin = MEM_dupallocN(src->plugin);
open_plugin_seq(dst->plugin, dst->name + 2);
}
}
static ImBuf * IMB_cast_away_list(ImBuf * i)
static ImBuf *IMB_cast_away_list(ImBuf *i)
{
if (!i) {
return NULL;
}
return (ImBuf*) (((void**) i) + 2);
return (ImBuf *) (((void **) i) + 2);
}
static struct ImBuf * do_plugin_effect(
SeqRenderData context, Sequence *seq, float cfra,
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
static struct ImBuf *do_plugin_effect(
SeqRenderData context, Sequence *seq, float cfra,
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
{
char *cp;
int float_rendering;
@@ -294,31 +294,31 @@ static struct ImBuf * do_plugin_effect(
* old plugins) do very bad stuff
* with imbuf-internals */
struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
int x = context.rectx;
int y = context.recty;
if (seq->plugin && seq->plugin->doit) {
if (seq->plugin->cfra)
*(seq->plugin->cfra)= cfra;
*(seq->plugin->cfra) = cfra;
cp = BLI_dynlib_find_symbol(
seq->plugin->handle, "seqname");
seq->plugin->handle, "seqname");
/* XXX: it's crappy to limit copying buffer by it's lemgth,
* but assuming plugin stuff is using correct buffer size
* it should be fine */
if (cp) strncpy(cp, seq->name+2, sizeof(seq->name)-2);
if (cp) strncpy(cp, seq->name + 2, sizeof(seq->name) - 2);
if (seq->plugin->current_private_data) {
*seq->plugin->current_private_data
= seq->plugin->instance_private_data;
= seq->plugin->instance_private_data;
}
float_rendering = (out->rect_float != NULL);
if (seq->plugin->version<=3 && float_rendering) {
if (seq->plugin->version <= 3 && float_rendering) {
use_temp_bufs = 1;
if (ibuf1) {
@@ -344,27 +344,27 @@ static struct ImBuf * do_plugin_effect(
out->flags &= ~IB_rectfloat;
}
if (seq->plugin->version<=2) {
if (seq->plugin->version <= 2) {
if (ibuf1) IMB_convert_rgba_to_abgr(ibuf1);
if (ibuf2) IMB_convert_rgba_to_abgr(ibuf2);
if (ibuf3) IMB_convert_rgba_to_abgr(ibuf3);
}
if (seq->plugin->version<=4) {
if (seq->plugin->version <= 4) {
((SeqDoit)seq->plugin->doit)(
seq->plugin->data, facf0, facf1, x, y,
IMB_cast_away_list(ibuf1),
IMB_cast_away_list(ibuf2),
IMB_cast_away_list(out),
IMB_cast_away_list(ibuf3));
seq->plugin->data, facf0, facf1, x, y,
IMB_cast_away_list(ibuf1),
IMB_cast_away_list(ibuf2),
IMB_cast_away_list(out),
IMB_cast_away_list(ibuf3));
}
else {
((SeqDoit)seq->plugin->doit)(
seq->plugin->data, facf0, facf1, x, y,
ibuf1, ibuf2, out, ibuf3);
seq->plugin->data, facf0, facf1, x, y,
ibuf1, ibuf2, out, ibuf3);
}
if (seq->plugin->version<=2) {
if (seq->plugin->version <= 2) {
if (!use_temp_bufs) {
if (ibuf1) IMB_convert_rgba_to_abgr(ibuf1);
if (ibuf2) IMB_convert_rgba_to_abgr(ibuf2);
@@ -372,7 +372,7 @@ static struct ImBuf * do_plugin_effect(
}
IMB_convert_rgba_to_abgr(out);
}
if (seq->plugin->version<=3 && float_rendering) {
if (seq->plugin->version <= 3 && float_rendering) {
IMB_float_from_rect_simple(out);
}
@@ -386,12 +386,12 @@ static struct ImBuf * do_plugin_effect(
}
static int do_plugin_early_out(struct Sequence *UNUSED(seq),
float UNUSED(facf0), float UNUSED(facf1))
float UNUSED(facf0), float UNUSED(facf1))
{
return 0;
}
static void free_plugin(struct Sequence * seq)
static void free_plugin(struct Sequence *seq)
{
free_plugin_seq(seq->plugin);
seq->plugin = NULL;
@@ -401,129 +401,129 @@ static void free_plugin(struct Sequence * seq)
* ALPHA OVER
* ********************************************************************** */
static void init_alpha_over_or_under(Sequence * seq)
static void init_alpha_over_or_under(Sequence *seq)
{
Sequence * seq1 = seq->seq1;
Sequence * seq2 = seq->seq2;
Sequence *seq1 = seq->seq1;
Sequence *seq2 = seq->seq2;
seq->seq2= seq1;
seq->seq1= seq2;
seq->seq2 = seq1;
seq->seq1 = seq2;
}
static void do_alphaover_effect_byte(float facf0, float facf1, int x, int y,
char * rect1, char *rect2, char *out)
char *rect1, char *rect2, char *out)
{
int fac2, mfac, fac, fac4;
int xo, tempc;
char *rt1, *rt2, *rt;
xo= x;
rt1= (char *)rect1;
rt2= (char *)rect2;
rt= (char *)out;
xo = x;
rt1 = (char *)rect1;
rt2 = (char *)rect2;
rt = (char *)out;
fac2= (int)(256.0f*facf0);
fac4= (int)(256.0f*facf1);
fac2 = (int)(256.0f * facf0);
fac4 = (int)(256.0f * facf1);
while (y--) {
x= xo;
x = xo;
while (x--) {
/* rt = rt1 over rt2 (alpha from rt1) */
fac= fac2;
mfac= 256 - ( (fac2*rt1[3])>>8 );
fac = fac2;
mfac = 256 - ( (fac2 * rt1[3]) >> 8);
if (fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
else if (mfac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt1);
if (fac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
else if (mfac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt1);
else {
tempc= ( fac*rt1[0] + mfac*rt2[0])>>8;
if (tempc>255) rt[0]= 255; else rt[0]= tempc;
tempc= ( fac*rt1[1] + mfac*rt2[1])>>8;
if (tempc>255) rt[1]= 255; else rt[1]= tempc;
tempc= ( fac*rt1[2] + mfac*rt2[2])>>8;
if (tempc>255) rt[2]= 255; else rt[2]= tempc;
tempc= ( fac*rt1[3] + mfac*rt2[3])>>8;
if (tempc>255) rt[3]= 255; else rt[3]= tempc;
tempc = (fac * rt1[0] + mfac * rt2[0]) >> 8;
if (tempc > 255) rt[0] = 255; else rt[0] = tempc;
tempc = (fac * rt1[1] + mfac * rt2[1]) >> 8;
if (tempc > 255) rt[1] = 255; else rt[1] = tempc;
tempc = (fac * rt1[2] + mfac * rt2[2]) >> 8;
if (tempc > 255) rt[2] = 255; else rt[2] = tempc;
tempc = (fac * rt1[3] + mfac * rt2[3]) >> 8;
if (tempc > 255) rt[3] = 255; else rt[3] = tempc;
}
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
if (y==0) break;
if (y == 0) break;
y--;
x= xo;
x = xo;
while (x--) {
fac= fac4;
mfac= 256 - ( (fac4*rt1[3])>>8 );
fac = fac4;
mfac = 256 - ( (fac4 * rt1[3]) >> 8);
if (fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
else if (mfac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt1);
if (fac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
else if (mfac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt1);
else {
tempc= ( fac*rt1[0] + mfac*rt2[0])>>8;
if (tempc>255) rt[0]= 255; else rt[0]= tempc;
tempc= ( fac*rt1[1] + mfac*rt2[1])>>8;
if (tempc>255) rt[1]= 255; else rt[1]= tempc;
tempc= ( fac*rt1[2] + mfac*rt2[2])>>8;
if (tempc>255) rt[2]= 255; else rt[2]= tempc;
tempc= ( fac*rt1[3] + mfac*rt2[3])>>8;
if (tempc>255) rt[3]= 255; else rt[3]= tempc;
tempc = (fac * rt1[0] + mfac * rt2[0]) >> 8;
if (tempc > 255) rt[0] = 255; else rt[0] = tempc;
tempc = (fac * rt1[1] + mfac * rt2[1]) >> 8;
if (tempc > 255) rt[1] = 255; else rt[1] = tempc;
tempc = (fac * rt1[2] + mfac * rt2[2]) >> 8;
if (tempc > 255) rt[2] = 255; else rt[2] = tempc;
tempc = (fac * rt1[3] + mfac * rt2[3]) >> 8;
if (tempc > 255) rt[3] = 255; else rt[3] = tempc;
}
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
}
}
static void do_alphaover_effect_float(float facf0, float facf1, int x, int y,
float * rect1, float *rect2, float *out)
float *rect1, float *rect2, float *out)
{
float fac2, mfac, fac, fac4;
int xo;
float *rt1, *rt2, *rt;
xo= x;
rt1= rect1;
rt2= rect2;
rt= out;
xo = x;
rt1 = rect1;
rt2 = rect2;
rt = out;
fac2= facf0;
fac4= facf1;
fac2 = facf0;
fac4 = facf1;
while (y--) {
x= xo;
x = xo;
while (x--) {
/* rt = rt1 over rt2 (alpha from rt1) */
fac= fac2;
mfac= 1.0f - (fac2 * rt1[3]);
fac = fac2;
mfac = 1.0f - (fac2 * rt1[3]);
if (fac <= 0.0f) {
memcpy(rt, rt2, 4 * sizeof(float));
}
else if (mfac <=0) {
else if (mfac <= 0) {
memcpy(rt, rt1, 4 * sizeof(float));
}
else {
rt[0] = fac*rt1[0] + mfac*rt2[0];
rt[1] = fac*rt1[1] + mfac*rt2[1];
rt[2] = fac*rt1[2] + mfac*rt2[2];
rt[3] = fac*rt1[3] + mfac*rt2[3];
rt[0] = fac * rt1[0] + mfac * rt2[0];
rt[1] = fac * rt1[1] + mfac * rt2[1];
rt[2] = fac * rt1[2] + mfac * rt2[2];
rt[3] = fac * rt1[3] + mfac * rt2[3];
}
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
if (y==0) break;
if (y == 0) break;
y--;
x= xo;
x = xo;
while (x--) {
fac= fac4;
mfac= 1.0f - (fac4*rt1[3]);
fac = fac4;
mfac = 1.0f - (fac4 * rt1[3]);
if (fac <= 0.0f) {
memcpy(rt, rt2, 4 * sizeof(float));
@@ -532,35 +532,35 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y,
memcpy(rt, rt1, 4 * sizeof(float));
}
else {
rt[0] = fac*rt1[0] + mfac*rt2[0];
rt[1] = fac*rt1[1] + mfac*rt2[1];
rt[2] = fac*rt1[2] + mfac*rt2[2];
rt[3] = fac*rt1[3] + mfac*rt2[3];
rt[0] = fac * rt1[0] + mfac * rt2[0];
rt[1] = fac * rt1[1] + mfac * rt2[1];
rt[2] = fac * rt1[2] + mfac * rt2[2];
rt[3] = fac * rt1[3] + mfac * rt2[3];
}
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
}
}
static struct ImBuf * do_alphaover_effect(
SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
static struct ImBuf *do_alphaover_effect(
SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
{
struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
if (out->rect_float) {
do_alphaover_effect_float(
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
}
else {
do_alphaover_effect_byte(
facf0, facf1, context.rectx, context.recty,
(char*) ibuf1->rect, (char*) ibuf2->rect,
(char*) out->rect);
facf0, facf1, context.rectx, context.recty,
(char *) ibuf1->rect, (char *) ibuf2->rect,
(char *) out->rect);
}
return out;
}
@@ -571,24 +571,24 @@ static struct ImBuf * do_alphaover_effect(
* ********************************************************************** */
static void do_alphaunder_effect_byte(
float facf0, float facf1, int x, int y, char *rect1,
char *rect2, char *out)
float facf0, float facf1, int x, int y, char *rect1,
char *rect2, char *out)
{
int fac2, mfac, fac, fac4;
int xo;
char *rt1, *rt2, *rt;
xo= x;
rt1= rect1;
rt2= rect2;
rt= out;
xo = x;
rt1 = rect1;
rt2 = rect2;
rt = out;
fac2= (int)(256.0f*facf0);
fac4= (int)(256.0f*facf1);
fac2 = (int)(256.0f * facf0);
fac4 = (int)(256.0f * facf1);
while (y--) {
x= xo;
x = xo;
while (x--) {
/* rt = rt1 under rt2 (alpha from rt2) */
@@ -596,68 +596,68 @@ static void do_alphaunder_effect_byte(
/* this complex optimalisation is because the
* 'skybuf' can be crossed in
*/
if (rt2[3]==0 && fac2==256) *( (unsigned int *)rt) = *( (unsigned int *)rt1);
else if (rt2[3]==255) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
if (rt2[3] == 0 && fac2 == 256) *( (unsigned int *)rt) = *( (unsigned int *)rt1);
else if (rt2[3] == 255) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
else {
mfac= rt2[3];
fac= (fac2*(256-mfac))>>8;
mfac = rt2[3];
fac = (fac2 * (256 - mfac)) >> 8;
if (fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
if (fac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
else {
rt[0]= ( fac*rt1[0] + mfac*rt2[0])>>8;
rt[1]= ( fac*rt1[1] + mfac*rt2[1])>>8;
rt[2]= ( fac*rt1[2] + mfac*rt2[2])>>8;
rt[3]= ( fac*rt1[3] + mfac*rt2[3])>>8;
rt[0] = (fac * rt1[0] + mfac * rt2[0]) >> 8;
rt[1] = (fac * rt1[1] + mfac * rt2[1]) >> 8;
rt[2] = (fac * rt1[2] + mfac * rt2[2]) >> 8;
rt[3] = (fac * rt1[3] + mfac * rt2[3]) >> 8;
}
}
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
if (y==0) break;
if (y == 0) break;
y--;
x= xo;
x = xo;
while (x--) {
if (rt2[3]==0 && fac4==256) *( (unsigned int *)rt) = *( (unsigned int *)rt1);
else if (rt2[3]==255) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
if (rt2[3] == 0 && fac4 == 256) *( (unsigned int *)rt) = *( (unsigned int *)rt1);
else if (rt2[3] == 255) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
else {
mfac= rt2[3];
fac= (fac4*(256-mfac))>>8;
mfac = rt2[3];
fac = (fac4 * (256 - mfac)) >> 8;
if (fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
if (fac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt2);
else {
rt[0]= ( fac*rt1[0] + mfac*rt2[0])>>8;
rt[1]= ( fac*rt1[1] + mfac*rt2[1])>>8;
rt[2]= ( fac*rt1[2] + mfac*rt2[2])>>8;
rt[3]= ( fac*rt1[3] + mfac*rt2[3])>>8;
rt[0] = (fac * rt1[0] + mfac * rt2[0]) >> 8;
rt[1] = (fac * rt1[1] + mfac * rt2[1]) >> 8;
rt[2] = (fac * rt1[2] + mfac * rt2[2]) >> 8;
rt[3] = (fac * rt1[3] + mfac * rt2[3]) >> 8;
}
}
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
}
}
static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y,
float *rect1, float *rect2,
float *out)
float *rect1, float *rect2,
float *out)
{
float fac2, mfac, fac, fac4;
int xo;
float *rt1, *rt2, *rt;
xo= x;
rt1= rect1;
rt2= rect2;
rt= out;
xo = x;
rt1 = rect1;
rt2 = rect2;
rt = out;
fac2= facf0;
fac4= facf1;
fac2 = facf0;
fac4 = facf1;
while (y--) {
x= xo;
x = xo;
while (x--) {
/* rt = rt1 under rt2 (alpha from rt2) */
@@ -665,7 +665,7 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y,
/* this complex optimalisation is because the
* 'skybuf' can be crossed in
*/
if ( rt2[3]<=0 && fac2 >= 1.0f) {
if (rt2[3] <= 0 && fac2 >= 1.0f) {
memcpy(rt, rt1, 4 * sizeof(float));
}
else if (rt2[3] >= 1.0f) {
@@ -679,67 +679,67 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y,
memcpy(rt, rt2, 4 * sizeof(float));
}
else {
rt[0]= fac*rt1[0] + mfac*rt2[0];
rt[1]= fac*rt1[1] + mfac*rt2[1];
rt[2]= fac*rt1[2] + mfac*rt2[2];
rt[3]= fac*rt1[3] + mfac*rt2[3];
rt[0] = fac * rt1[0] + mfac * rt2[0];
rt[1] = fac * rt1[1] + mfac * rt2[1];
rt[2] = fac * rt1[2] + mfac * rt2[2];
rt[3] = fac * rt1[3] + mfac * rt2[3];
}
}
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
if (y==0) break;
if (y == 0) break;
y--;
x= xo;
x = xo;
while (x--) {
if (rt2[3]<=0 && fac4 >= 1.0f) {
if (rt2[3] <= 0 && fac4 >= 1.0f) {
memcpy(rt, rt1, 4 * sizeof(float));
}
else if (rt2[3]>=1.0f) {
else if (rt2[3] >= 1.0f) {
memcpy(rt, rt2, 4 * sizeof(float));
}
else {
mfac= rt2[3];
fac= fac4*(1.0f-mfac);
mfac = rt2[3];
fac = fac4 * (1.0f - mfac);
if (fac == 0) {
memcpy(rt, rt2, 4 * sizeof(float));
}
else {
rt[0]= fac * rt1[0] + mfac * rt2[0];
rt[1]= fac * rt1[1] + mfac * rt2[1];
rt[2]= fac * rt1[2] + mfac * rt2[2];
rt[3]= fac * rt1[3] + mfac * rt2[3];
rt[0] = fac * rt1[0] + mfac * rt2[0];
rt[1] = fac * rt1[1] + mfac * rt2[1];
rt[2] = fac * rt1[2] + mfac * rt2[2];
rt[3] = fac * rt1[3] + mfac * rt2[3];
}
}
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
}
}
static struct ImBuf* do_alphaunder_effect(
SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
static struct ImBuf *do_alphaunder_effect(
SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
{
struct ImBuf * out = prepare_effect_imbufs(
context, ibuf1, ibuf2, ibuf3);
struct ImBuf *out = prepare_effect_imbufs(
context, ibuf1, ibuf2, ibuf3);
if (out->rect_float) {
do_alphaunder_effect_float(
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
}
else {
do_alphaunder_effect_byte(
facf0, facf1, context.rectx, context.recty,
(char*) ibuf1->rect, (char*) ibuf2->rect,
(char*) out->rect);
facf0, facf1, context.rectx, context.recty,
(char *) ibuf1->rect, (char *) ibuf2->rect,
(char *) out->rect);
}
return out;
}
@@ -750,95 +750,95 @@ static struct ImBuf* do_alphaunder_effect(
* ********************************************************************** */
static void do_cross_effect_byte(float facf0, float facf1, int x, int y,
char *rect1, char *rect2,
char *out)
char *rect1, char *rect2,
char *out)
{
int fac1, fac2, fac3, fac4;
int xo;
char *rt1, *rt2, *rt;
xo= x;
rt1= rect1;
rt2= rect2;
rt= out;
xo = x;
rt1 = rect1;
rt2 = rect2;
rt = out;
fac2= (int)(256.0f*facf0);
fac1= 256-fac2;
fac4= (int)(256.0f*facf1);
fac3= 256-fac4;
fac2 = (int)(256.0f * facf0);
fac1 = 256 - fac2;
fac4 = (int)(256.0f * facf1);
fac3 = 256 - fac4;
while (y--) {
x= xo;
x = xo;
while (x--) {
rt[0]= (fac1*rt1[0] + fac2*rt2[0])>>8;
rt[1]= (fac1*rt1[1] + fac2*rt2[1])>>8;
rt[2]= (fac1*rt1[2] + fac2*rt2[2])>>8;
rt[3]= (fac1*rt1[3] + fac2*rt2[3])>>8;
rt[0] = (fac1 * rt1[0] + fac2 * rt2[0]) >> 8;
rt[1] = (fac1 * rt1[1] + fac2 * rt2[1]) >> 8;
rt[2] = (fac1 * rt1[2] + fac2 * rt2[2]) >> 8;
rt[3] = (fac1 * rt1[3] + fac2 * rt2[3]) >> 8;
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
if (y==0) break;
if (y == 0) break;
y--;
x= xo;
x = xo;
while (x--) {
rt[0]= (fac3*rt1[0] + fac4*rt2[0])>>8;
rt[1]= (fac3*rt1[1] + fac4*rt2[1])>>8;
rt[2]= (fac3*rt1[2] + fac4*rt2[2])>>8;
rt[3]= (fac3*rt1[3] + fac4*rt2[3])>>8;
rt[0] = (fac3 * rt1[0] + fac4 * rt2[0]) >> 8;
rt[1] = (fac3 * rt1[1] + fac4 * rt2[1]) >> 8;
rt[2] = (fac3 * rt1[2] + fac4 * rt2[2]) >> 8;
rt[3] = (fac3 * rt1[3] + fac4 * rt2[3]) >> 8;
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
}
}
static void do_cross_effect_float(float facf0, float facf1, int x, int y,
float *rect1, float *rect2, float *out)
float *rect1, float *rect2, float *out)
{
float fac1, fac2, fac3, fac4;
int xo;
float *rt1, *rt2, *rt;
xo= x;
rt1= rect1;
rt2= rect2;
rt= out;
xo = x;
rt1 = rect1;
rt2 = rect2;
rt = out;
fac2= facf0;
fac1= 1.0f - fac2;
fac4= facf1;
fac3= 1.0f - fac4;
fac2 = facf0;
fac1 = 1.0f - fac2;
fac4 = facf1;
fac3 = 1.0f - fac4;
while (y--) {
x= xo;
x = xo;
while (x--) {
rt[0]= fac1*rt1[0] + fac2*rt2[0];
rt[1]= fac1*rt1[1] + fac2*rt2[1];
rt[2]= fac1*rt1[2] + fac2*rt2[2];
rt[3]= fac1*rt1[3] + fac2*rt2[3];
rt[0] = fac1 * rt1[0] + fac2 * rt2[0];
rt[1] = fac1 * rt1[1] + fac2 * rt2[1];
rt[2] = fac1 * rt1[2] + fac2 * rt2[2];
rt[3] = fac1 * rt1[3] + fac2 * rt2[3];
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
if (y==0) break;
if (y == 0) break;
y--;
x= xo;
x = xo;
while (x--) {
rt[0]= fac3*rt1[0] + fac4*rt2[0];
rt[1]= fac3*rt1[1] + fac4*rt2[1];
rt[2]= fac3*rt1[2] + fac4*rt2[2];
rt[3]= fac3*rt1[3] + fac4*rt2[3];
rt[0] = fac3 * rt1[0] + fac4 * rt2[0];
rt[1] = fac3 * rt1[1] + fac4 * rt2[1];
rt[2] = fac3 * rt1[2] + fac4 * rt2[2];
rt[3] = fac3 * rt1[3] + fac4 * rt2[3];
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
}
@@ -846,26 +846,26 @@ static void do_cross_effect_float(float facf0, float facf1, int x, int y,
/* careful: also used by speed effect! */
static struct ImBuf* do_cross_effect(
SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
static struct ImBuf *do_cross_effect(
SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
{
struct ImBuf * out = prepare_effect_imbufs(
context, ibuf1, ibuf2, ibuf3);
struct ImBuf *out = prepare_effect_imbufs(
context, ibuf1, ibuf2, ibuf3);
if (out->rect_float) {
do_cross_effect_float(
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
}
else {
do_cross_effect_byte(
facf0, facf1, context.rectx, context.recty,
(char*) ibuf1->rect, (char*) ibuf2->rect,
(char*) out->rect);
facf0, facf1, context.rectx, context.recty,
(char *) ibuf1->rect, (char *) ibuf2->rect,
(char *) out->rect);
}
return out;
}
@@ -906,9 +906,9 @@ static void makeGammaTables(float gamma)
for (i = 0; i < RE_GAMMA_TABLE_SIZE; i++) {
color_domain_table[i] = i * color_step;
gamma_range_table[i] = pow(color_domain_table[i],
valid_gamma);
valid_gamma);
inv_gamma_range_table[i] = pow(color_domain_table[i],
valid_inv_gamma);
valid_inv_gamma);
}
/* The end of the table should match 1.0 carefully. In order to avoid */
@@ -921,11 +921,11 @@ static void makeGammaTables(float gamma)
/* To speed up calculations, we make these calc factor tables. They are */
/* multiplication factors used in scaling the interpolation. */
for (i = 0; i < RE_GAMMA_TABLE_SIZE; i++ ) {
gamfactor_table[i] = inv_color_step
* (gamma_range_table[i + 1] - gamma_range_table[i]);
inv_gamfactor_table[i] = inv_color_step
* (inv_gamma_range_table[i + 1] - inv_gamma_range_table[i]);
for (i = 0; i < RE_GAMMA_TABLE_SIZE; i++) {
gamfactor_table[i] = inv_color_step *
(gamma_range_table[i + 1] - gamma_range_table[i]);
inv_gamfactor_table[i] = inv_color_step *
(inv_gamma_range_table[i + 1] - inv_gamma_range_table[i]);
}
} /* end of void makeGammaTables(float gamma) */
@@ -942,9 +942,9 @@ static float gammaCorrect(float c)
/* may help solve that, by exchanging LUT size for the interpolation. */
/* Negative colors are explicitly handled. */
if (i < 0) res = -pow(abs(c), valid_gamma);
else if (i >= RE_GAMMA_TABLE_SIZE ) res = pow(c, valid_gamma);
else if (i >= RE_GAMMA_TABLE_SIZE) res = pow(c, valid_gamma);
else res = gamma_range_table[i] +
( (c - color_domain_table[i]) * gamfactor_table[i]);
( (c - color_domain_table[i]) * gamfactor_table[i]);
return res;
} /* end of float gammaCorrect(float col) */
@@ -956,12 +956,12 @@ static float invGammaCorrect(float col)
int i;
float res = 0.0;
i = floor(col*inv_color_step);
i = floor(col * inv_color_step);
/* Negative colors are explicitly handled. */
if (i < 0) res = -pow(abs(col), valid_inv_gamma);
else if (i >= RE_GAMMA_TABLE_SIZE) res = pow(col, valid_inv_gamma);
else res = inv_gamma_range_table[i] +
( (col - color_domain_table[i]) * inv_gamfactor_table[i]);
( (col - color_domain_table[i]) * inv_gamfactor_table[i]);
return res;
} /* end of float invGammaCorrect(float col) */
@@ -969,26 +969,26 @@ static float invGammaCorrect(float col)
static void gamtabs(float gamma)
{
float val, igamma= 1.0f/gamma;
float val, igamma = 1.0f / gamma;
int a;
/* gamtab: in short, out short */
for (a=0; a<65536; a++) {
val= a;
val/= 65535.0f;
for (a = 0; a < 65536; a++) {
val = a;
val /= 65535.0f;
if (gamma==2.0f) val= sqrt(val);
else if (gamma!=1.0f) val= pow(val, igamma);
if (gamma == 2.0f) val = sqrt(val);
else if (gamma != 1.0f) val = pow(val, igamma);
gamtab[a]= (65535.99f*val);
gamtab[a] = (65535.99f * val);
}
/* inverse gamtab1 : in byte, out short */
for (a=1; a<=256; a++) {
if (gamma==2.0f) igamtab1[a-1]= a*a-1;
else if (gamma==1.0f) igamtab1[a-1]= 256*a-1;
for (a = 1; a <= 256; a++) {
if (gamma == 2.0f) igamtab1[a - 1] = a * a - 1;
else if (gamma == 1.0f) igamtab1[a - 1] = 256 * a - 1;
else {
val= a/256.0f;
igamtab1[a - 1]= (65535.0 * pow(val, gamma)) - 1;
val = a / 256.0f;
igamtab1[a - 1] = (65535.0 * pow(val, gamma)) - 1;
}
}
@@ -1003,139 +1003,139 @@ static void build_gammatabs(void)
}
}
static void init_gammacross(Sequence * UNUSED(seq))
static void init_gammacross(Sequence *UNUSED(seq))
{
}
static void load_gammacross(Sequence * UNUSED(seq))
static void load_gammacross(Sequence *UNUSED(seq))
{
}
static void free_gammacross(Sequence * UNUSED(seq))
static void free_gammacross(Sequence *UNUSED(seq))
{
}
static void do_gammacross_effect_byte(float facf0, float UNUSED(facf1),
int x, int y,
unsigned char *rect1,
unsigned char *rect2,
unsigned char *out)
int x, int y,
unsigned char *rect1,
unsigned char *rect2,
unsigned char *out)
{
int fac1, fac2, col;
int xo;
unsigned char *rt1, *rt2, *rt;
xo= x;
rt1= (unsigned char *)rect1;
rt2= (unsigned char *)rect2;
rt= (unsigned char *)out;
xo = x;
rt1 = (unsigned char *)rect1;
rt2 = (unsigned char *)rect2;
rt = (unsigned char *)out;
fac2= (int)(256.0f*facf0);
fac1= 256-fac2;
fac2 = (int)(256.0f * facf0);
fac1 = 256 - fac2;
while (y--) {
x= xo;
x = xo;
while (x--) {
col= (fac1*igamtab1[rt1[0]] + fac2*igamtab1[rt2[0]])>>8;
if (col>65535) rt[0]= 255; else rt[0]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
col=(fac1*igamtab1[rt1[1]] + fac2*igamtab1[rt2[1]])>>8;
if (col>65535) rt[1]= 255; else rt[1]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
col= (fac1*igamtab1[rt1[2]] + fac2*igamtab1[rt2[2]])>>8;
if (col>65535) rt[2]= 255; else rt[2]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
col= (fac1*igamtab1[rt1[3]] + fac2*igamtab1[rt2[3]])>>8;
if (col>65535) rt[3]= 255; else rt[3]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
col = (fac1 * igamtab1[rt1[0]] + fac2 * igamtab1[rt2[0]]) >> 8;
if (col > 65535) rt[0] = 255; else rt[0] = ( (char *)(gamtab + col))[MOST_SIG_BYTE];
col = (fac1 * igamtab1[rt1[1]] + fac2 * igamtab1[rt2[1]]) >> 8;
if (col > 65535) rt[1] = 255; else rt[1] = ( (char *)(gamtab + col))[MOST_SIG_BYTE];
col = (fac1 * igamtab1[rt1[2]] + fac2 * igamtab1[rt2[2]]) >> 8;
if (col > 65535) rt[2] = 255; else rt[2] = ( (char *)(gamtab + col))[MOST_SIG_BYTE];
col = (fac1 * igamtab1[rt1[3]] + fac2 * igamtab1[rt2[3]]) >> 8;
if (col > 65535) rt[3] = 255; else rt[3] = ( (char *)(gamtab + col))[MOST_SIG_BYTE];
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
if (y==0) break;
if (y == 0) break;
y--;
x= xo;
x = xo;
while (x--) {
col= (fac1*igamtab1[rt1[0]] + fac2*igamtab1[rt2[0]])>>8;
if (col>65535) rt[0]= 255; else rt[0]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
col= (fac1*igamtab1[rt1[1]] + fac2*igamtab1[rt2[1]])>>8;
if (col>65535) rt[1]= 255; else rt[1]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
col= (fac1*igamtab1[rt1[2]] + fac2*igamtab1[rt2[2]])>>8;
if (col>65535) rt[2]= 255; else rt[2]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
col= (fac1*igamtab1[rt1[3]] + fac2*igamtab1[rt2[3]])>>8;
if (col>65535) rt[3]= 255; else rt[3]= ( (char *)(gamtab+col))[MOST_SIG_BYTE];
col = (fac1 * igamtab1[rt1[0]] + fac2 * igamtab1[rt2[0]]) >> 8;
if (col > 65535) rt[0] = 255; else rt[0] = ( (char *)(gamtab + col))[MOST_SIG_BYTE];
col = (fac1 * igamtab1[rt1[1]] + fac2 * igamtab1[rt2[1]]) >> 8;
if (col > 65535) rt[1] = 255; else rt[1] = ( (char *)(gamtab + col))[MOST_SIG_BYTE];
col = (fac1 * igamtab1[rt1[2]] + fac2 * igamtab1[rt2[2]]) >> 8;
if (col > 65535) rt[2] = 255; else rt[2] = ( (char *)(gamtab + col))[MOST_SIG_BYTE];
col = (fac1 * igamtab1[rt1[3]] + fac2 * igamtab1[rt2[3]]) >> 8;
if (col > 65535) rt[3] = 255; else rt[3] = ( (char *)(gamtab + col))[MOST_SIG_BYTE];
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
}
}
static void do_gammacross_effect_float(float facf0, float UNUSED(facf1),
int x, int y,
float *rect1, float *rect2,
float *out)
int x, int y,
float *rect1, float *rect2,
float *out)
{
float fac1, fac2;
int xo;
float *rt1, *rt2, *rt;
xo= x;
rt1= rect1;
rt2= rect2;
rt= out;
xo = x;
rt1 = rect1;
rt2 = rect2;
rt = out;
fac2= facf0;
fac1= 1.0f - fac2;
fac2 = facf0;
fac1 = 1.0f - fac2;
while (y--) {
x= xo * 4;
x = xo * 4;
while (x--) {
*rt= gammaCorrect(
fac1 * invGammaCorrect(*rt1)
+ fac2 * invGammaCorrect(*rt2));
*rt = gammaCorrect(
fac1 * invGammaCorrect(*rt1)
+ fac2 * invGammaCorrect(*rt2));
rt1++; rt2++; rt++;
}
if (y==0) break;
if (y == 0) break;
y--;
x= xo * 4;
x = xo * 4;
while (x--) {
*rt= gammaCorrect(
fac1*invGammaCorrect(*rt1)
+ fac2*invGammaCorrect(*rt2));
*rt = gammaCorrect(
fac1 * invGammaCorrect(*rt1)
+ fac2 * invGammaCorrect(*rt2));
rt1++; rt2++; rt++;
}
}
}
static struct ImBuf * do_gammacross_effect(
SeqRenderData context,
Sequence *UNUSED(seq), float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
static struct ImBuf *do_gammacross_effect(
SeqRenderData context,
Sequence *UNUSED(seq), float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
{
struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
build_gammatabs();
if (out->rect_float) {
do_gammacross_effect_float(
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
}
else {
do_gammacross_effect_byte(
facf0, facf1, context.rectx, context.recty,
(unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect,
(unsigned char*) out->rect);
facf0, facf1, context.rectx, context.recty,
(unsigned char *) ibuf1->rect, (unsigned char *) ibuf2->rect,
(unsigned char *) out->rect);
}
return out;
}
@@ -1146,86 +1146,86 @@ static struct ImBuf * do_gammacross_effect(
* ********************************************************************** */
static void do_add_effect_byte(float facf0, float facf1, int x, int y,
unsigned char *rect1, unsigned char *rect2,
unsigned char *out)
unsigned char *rect1, unsigned char *rect2,
unsigned char *out)
{
int col, xo, fac1, fac3;
char *rt1, *rt2, *rt;
xo= x;
rt1= (char *)rect1;
rt2= (char *)rect2;
rt= (char *)out;
xo = x;
rt1 = (char *)rect1;
rt2 = (char *)rect2;
rt = (char *)out;
fac1= (int)(256.0f*facf0);
fac3= (int)(256.0f*facf1);
fac1 = (int)(256.0f * facf0);
fac3 = (int)(256.0f * facf1);
while (y--) {
x= xo;
x = xo;
while (x--) {
col= rt1[0]+ ((fac1*rt2[0])>>8);
if (col>255) rt[0]= 255; else rt[0]= col;
col= rt1[1]+ ((fac1*rt2[1])>>8);
if (col>255) rt[1]= 255; else rt[1]= col;
col= rt1[2]+ ((fac1*rt2[2])>>8);
if (col>255) rt[2]= 255; else rt[2]= col;
col= rt1[3]+ ((fac1*rt2[3])>>8);
if (col>255) rt[3]= 255; else rt[3]= col;
col = rt1[0] + ((fac1 * rt2[0]) >> 8);
if (col > 255) rt[0] = 255; else rt[0] = col;
col = rt1[1] + ((fac1 * rt2[1]) >> 8);
if (col > 255) rt[1] = 255; else rt[1] = col;
col = rt1[2] + ((fac1 * rt2[2]) >> 8);
if (col > 255) rt[2] = 255; else rt[2] = col;
col = rt1[3] + ((fac1 * rt2[3]) >> 8);
if (col > 255) rt[3] = 255; else rt[3] = col;
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
if (y==0) break;
if (y == 0) break;
y--;
x= xo;
x = xo;
while (x--) {
col= rt1[0]+ ((fac3*rt2[0])>>8);
if (col>255) rt[0]= 255; else rt[0]= col;
col= rt1[1]+ ((fac3*rt2[1])>>8);
if (col>255) rt[1]= 255; else rt[1]= col;
col= rt1[2]+ ((fac3*rt2[2])>>8);
if (col>255) rt[2]= 255; else rt[2]= col;
col= rt1[3]+ ((fac3*rt2[3])>>8);
if (col>255) rt[3]= 255; else rt[3]= col;
col = rt1[0] + ((fac3 * rt2[0]) >> 8);
if (col > 255) rt[0] = 255; else rt[0] = col;
col = rt1[1] + ((fac3 * rt2[1]) >> 8);
if (col > 255) rt[1] = 255; else rt[1] = col;
col = rt1[2] + ((fac3 * rt2[2]) >> 8);
if (col > 255) rt[2] = 255; else rt[2] = col;
col = rt1[3] + ((fac3 * rt2[3]) >> 8);
if (col > 255) rt[3] = 255; else rt[3] = col;
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
}
}
static void do_add_effect_float(float facf0, float facf1, int x, int y,
float *rect1, float *rect2,
float *out)
float *rect1, float *rect2,
float *out)
{
int xo;
float fac1, fac3;
float *rt1, *rt2, *rt;
xo= x;
rt1= rect1;
rt2= rect2;
rt= out;
xo = x;
rt1 = rect1;
rt2 = rect2;
rt = out;
fac1= facf0;
fac3= facf1;
fac1 = facf0;
fac3 = facf1;
while (y--) {
x= xo * 4;
x = xo * 4;
while (x--) {
*rt = *rt1 + fac1 * (*rt2);
rt1++; rt2++; rt++;
}
if (y==0) break;
if (y == 0) break;
y--;
x= xo * 4;
x = xo * 4;
while (x--) {
*rt = *rt1 + fac3 * (*rt2);
@@ -1234,25 +1234,24 @@ static void do_add_effect_float(float facf0, float facf1, int x, int y,
}
}
static struct ImBuf * do_add_effect(SeqRenderData context,
Sequence *UNUSED(seq), float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
{
struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
static struct ImBuf *do_add_effect(SeqRenderData context,
Sequence *UNUSED(seq), float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3){
struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
if (out->rect_float) {
do_add_effect_float(
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
}
else {
do_add_effect_byte(
facf0, facf1, context.rectx, context.recty,
(unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect,
(unsigned char*) out->rect);
facf0, facf1, context.rectx, context.recty,
(unsigned char *) ibuf1->rect, (unsigned char *) ibuf2->rect,
(unsigned char *) out->rect);
}
return out;
}
@@ -1263,86 +1262,86 @@ static struct ImBuf * do_add_effect(SeqRenderData context,
* ********************************************************************** */
static void do_sub_effect_byte(float facf0, float facf1,
int x, int y,
char *rect1, char *rect2, char *out)
int x, int y,
char *rect1, char *rect2, char *out)
{
int col, xo, fac1, fac3;
char *rt1, *rt2, *rt;
xo= x;
rt1= (char *)rect1;
rt2= (char *)rect2;
rt= (char *)out;
xo = x;
rt1 = (char *)rect1;
rt2 = (char *)rect2;
rt = (char *)out;
fac1= (int)(256.0f*facf0);
fac3= (int)(256.0f*facf1);
fac1 = (int)(256.0f * facf0);
fac3 = (int)(256.0f * facf1);
while (y--) {
x= xo;
x = xo;
while (x--) {
col= rt1[0]- ((fac1*rt2[0])>>8);
if (col<0) rt[0]= 0; else rt[0]= col;
col= rt1[1]- ((fac1*rt2[1])>>8);
if (col<0) rt[1]= 0; else rt[1]= col;
col= rt1[2]- ((fac1*rt2[2])>>8);
if (col<0) rt[2]= 0; else rt[2]= col;
col= rt1[3]- ((fac1*rt2[3])>>8);
if (col<0) rt[3]= 0; else rt[3]= col;
col = rt1[0] - ((fac1 * rt2[0]) >> 8);
if (col < 0) rt[0] = 0; else rt[0] = col;
col = rt1[1] - ((fac1 * rt2[1]) >> 8);
if (col < 0) rt[1] = 0; else rt[1] = col;
col = rt1[2] - ((fac1 * rt2[2]) >> 8);
if (col < 0) rt[2] = 0; else rt[2] = col;
col = rt1[3] - ((fac1 * rt2[3]) >> 8);
if (col < 0) rt[3] = 0; else rt[3] = col;
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
if (y==0) break;
if (y == 0) break;
y--;
x= xo;
x = xo;
while (x--) {
col= rt1[0]- ((fac3*rt2[0])>>8);
if (col<0) rt[0]= 0; else rt[0]= col;
col= rt1[1]- ((fac3*rt2[1])>>8);
if (col<0) rt[1]= 0; else rt[1]= col;
col= rt1[2]- ((fac3*rt2[2])>>8);
if (col<0) rt[2]= 0; else rt[2]= col;
col= rt1[3]- ((fac3*rt2[3])>>8);
if (col<0) rt[3]= 0; else rt[3]= col;
col = rt1[0] - ((fac3 * rt2[0]) >> 8);
if (col < 0) rt[0] = 0; else rt[0] = col;
col = rt1[1] - ((fac3 * rt2[1]) >> 8);
if (col < 0) rt[1] = 0; else rt[1] = col;
col = rt1[2] - ((fac3 * rt2[2]) >> 8);
if (col < 0) rt[2] = 0; else rt[2] = col;
col = rt1[3] - ((fac3 * rt2[3]) >> 8);
if (col < 0) rt[3] = 0; else rt[3] = col;
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
}
}
static void do_sub_effect_float(float facf0, float facf1, int x, int y,
float *rect1, float *rect2,
float *out)
float *rect1, float *rect2,
float *out)
{
int xo;
float fac1, fac3;
float *rt1, *rt2, *rt;
xo= x;
rt1= rect1;
rt2= rect2;
rt= out;
xo = x;
rt1 = rect1;
rt2 = rect2;
rt = out;
fac1= facf0;
fac3= facf1;
fac1 = facf0;
fac3 = facf1;
while (y--) {
x= xo * 4;
x = xo * 4;
while (x--) {
*rt = *rt1 - fac1 * (*rt2);
rt1++; rt2++; rt++;
}
if (y==0) break;
if (y == 0) break;
y--;
x= xo * 4;
x = xo * 4;
while (x--) {
*rt = *rt1 - fac3 * (*rt2);
@@ -1351,25 +1350,24 @@ static void do_sub_effect_float(float facf0, float facf1, int x, int y,
}
}
static struct ImBuf * do_sub_effect(
SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
{
struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
static struct ImBuf *do_sub_effect(
SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3){
struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
if (out->rect_float) {
do_sub_effect_float(
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
}
else {
do_sub_effect_byte(
facf0, facf1, context.rectx, context.recty,
(char*) ibuf1->rect, (char*) ibuf2->rect,
(char*) out->rect);
facf0, facf1, context.rectx, context.recty,
(char *) ibuf1->rect, (char *) ibuf2->rect,
(char *) out->rect);
}
return out;
}
@@ -1379,88 +1377,88 @@ static struct ImBuf * do_sub_effect(
* ********************************************************************** */
/* Must be > 0 or add precopy, etc to the function */
#define XOFF 8
#define YOFF 8
#define XOFF 8
#define YOFF 8
static void do_drop_effect_byte(float facf0, float facf1, int x, int y,
char *rect2i, char *rect1i,
char *outi)
char *rect2i, char *rect1i,
char *outi)
{
int height, width, temp, fac, fac1, fac2;
char *rt1, *rt2, *out;
int field= 1;
int field = 1;
width= x;
height= y;
width = x;
height = y;
fac1= (int)(70.0f*facf0);
fac2= (int)(70.0f*facf1);
fac1 = (int)(70.0f * facf0);
fac2 = (int)(70.0f * facf1);
rt2= (char*) (rect2i + YOFF*width);
rt1= (char*) rect1i;
out= (char*) outi;
for (y=0; y<height-YOFF; y++) {
if (field) fac= fac1;
else fac= fac2;
field= !field;
rt2 = (char *) (rect2i + YOFF * width);
rt1 = (char *) rect1i;
out = (char *) outi;
for (y = 0; y < height - YOFF; y++) {
if (field) fac = fac1;
else fac = fac2;
field = !field;
memcpy(out, rt1, sizeof(int)*XOFF);
rt1+= XOFF*4;
out+= XOFF*4;
memcpy(out, rt1, sizeof(int) * XOFF);
rt1 += XOFF * 4;
out += XOFF * 4;
for (x=XOFF; x<width; x++) {
temp= ((fac*rt2[3])>>8);
for (x = XOFF; x < width; x++) {
temp = ((fac * rt2[3]) >> 8);
*(out++)= MAX2(0, *rt1 - temp); rt1++;
*(out++)= MAX2(0, *rt1 - temp); rt1++;
*(out++)= MAX2(0, *rt1 - temp); rt1++;
*(out++)= MAX2(0, *rt1 - temp); rt1++;
rt2+=4;
*(out++) = MAX2(0, *rt1 - temp); rt1++;
*(out++) = MAX2(0, *rt1 - temp); rt1++;
*(out++) = MAX2(0, *rt1 - temp); rt1++;
*(out++) = MAX2(0, *rt1 - temp); rt1++;
rt2 += 4;
}
rt2+=XOFF*4;
rt2 += XOFF * 4;
}
memcpy(out, rt1, sizeof(int)*YOFF*width);
memcpy(out, rt1, sizeof(int) * YOFF * width);
}
static void do_drop_effect_float(float facf0, float facf1, int x, int y,
float *rect2i, float *rect1i,
float *outi)
float *rect2i, float *rect1i,
float *outi)
{
int height, width;
float temp, fac, fac1, fac2;
float *rt1, *rt2, *out;
int field= 1;
int field = 1;
width= x;
height= y;
width = x;
height = y;
fac1= 70.0f*facf0;
fac2= 70.0f*facf1;
fac1 = 70.0f * facf0;
fac2 = 70.0f * facf1;
rt2= (rect2i + YOFF*width);
rt1= rect1i;
out= outi;
for (y=0; y<height-YOFF; y++) {
if (field) fac= fac1;
else fac= fac2;
field= !field;
rt2 = (rect2i + YOFF * width);
rt1 = rect1i;
out = outi;
for (y = 0; y < height - YOFF; y++) {
if (field) fac = fac1;
else fac = fac2;
field = !field;
memcpy(out, rt1, 4 * sizeof(float)*XOFF);
rt1+= XOFF*4;
out+= XOFF*4;
memcpy(out, rt1, 4 * sizeof(float) * XOFF);
rt1 += XOFF * 4;
out += XOFF * 4;
for (x=XOFF; x<width; x++) {
temp= fac * rt2[3];
for (x = XOFF; x < width; x++) {
temp = fac * rt2[3];
*(out++)= MAX2(0.0f, *rt1 - temp); rt1++;
*(out++)= MAX2(0.0f, *rt1 - temp); rt1++;
*(out++)= MAX2(0.0f, *rt1 - temp); rt1++;
*(out++)= MAX2(0.0f, *rt1 - temp); rt1++;
rt2+=4;
*(out++) = MAX2(0.0f, *rt1 - temp); rt1++;
*(out++) = MAX2(0.0f, *rt1 - temp); rt1++;
*(out++) = MAX2(0.0f, *rt1 - temp); rt1++;
*(out++) = MAX2(0.0f, *rt1 - temp); rt1++;
rt2 += 4;
}
rt2+=XOFF*4;
rt2 += XOFF * 4;
}
memcpy(out, rt1, 4 * sizeof(float)*YOFF*width);
memcpy(out, rt1, 4 * sizeof(float) * YOFF * width);
}
/* **********************************************************************
@@ -1468,19 +1466,19 @@ static void do_drop_effect_float(float facf0, float facf1, int x, int y,
* ********************************************************************** */
static void do_mul_effect_byte(float facf0, float facf1, int x, int y,
unsigned char *rect1, unsigned char *rect2,
unsigned char *out)
unsigned char *rect1, unsigned char *rect2,
unsigned char *out)
{
int xo, fac1, fac3;
char *rt1, *rt2, *rt;
xo= x;
rt1= (char *)rect1;
rt2= (char *)rect2;
rt= (char *)out;
xo = x;
rt1 = (char *)rect1;
rt2 = (char *)rect2;
rt = (char *)out;
fac1= (int)(256.0f*facf0);
fac3= (int)(256.0f*facf1);
fac1 = (int)(256.0f * facf0);
fac3 = (int)(256.0f * facf1);
/* formula:
* fac*(a*b) + (1-fac)*a => fac*a*(b-1)+axaux= c*px + py*s ;//+centx
@@ -1489,48 +1487,48 @@ static void do_mul_effect_byte(float facf0, float facf1, int x, int y,
while (y--) {
x= xo;
x = xo;
while (x--) {
rt[0]= rt1[0] + ((fac1*rt1[0]*(rt2[0]-256))>>16);
rt[1]= rt1[1] + ((fac1*rt1[1]*(rt2[1]-256))>>16);
rt[2]= rt1[2] + ((fac1*rt1[2]*(rt2[2]-256))>>16);
rt[3]= rt1[3] + ((fac1*rt1[3]*(rt2[3]-256))>>16);
rt[0] = rt1[0] + ((fac1 * rt1[0] * (rt2[0] - 256)) >> 16);
rt[1] = rt1[1] + ((fac1 * rt1[1] * (rt2[1] - 256)) >> 16);
rt[2] = rt1[2] + ((fac1 * rt1[2] * (rt2[2] - 256)) >> 16);
rt[3] = rt1[3] + ((fac1 * rt1[3] * (rt2[3] - 256)) >> 16);
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
if (y==0) break;
if (y == 0) break;
y--;
x= xo;
x = xo;
while (x--) {
rt[0]= rt1[0] + ((fac3*rt1[0]*(rt2[0]-256))>>16);
rt[1]= rt1[1] + ((fac3*rt1[1]*(rt2[1]-256))>>16);
rt[2]= rt1[2] + ((fac3*rt1[2]*(rt2[2]-256))>>16);
rt[3]= rt1[3] + ((fac3*rt1[3]*(rt2[3]-256))>>16);
rt[0] = rt1[0] + ((fac3 * rt1[0] * (rt2[0] - 256)) >> 16);
rt[1] = rt1[1] + ((fac3 * rt1[1] * (rt2[1] - 256)) >> 16);
rt[2] = rt1[2] + ((fac3 * rt1[2] * (rt2[2] - 256)) >> 16);
rt[3] = rt1[3] + ((fac3 * rt1[3] * (rt2[3] - 256)) >> 16);
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
}
}
static void do_mul_effect_float(float facf0, float facf1, int x, int y,
float *rect1, float *rect2,
float *out)
float *rect1, float *rect2,
float *out)
{
int xo;
float fac1, fac3;
float *rt1, *rt2, *rt;
xo= x;
rt1= rect1;
rt2= rect2;
rt= out;
xo = x;
rt1 = rect1;
rt2 = rect2;
rt = out;
fac1= facf0;
fac3= facf1;
fac1 = facf0;
fac3 = facf1;
/* formula:
* fac*(a*b) + (1-fac)*a => fac*a*(b-1)+a
@@ -1538,52 +1536,52 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y,
while (y--) {
x= xo;
x = xo;
while (x--) {
rt[0]= rt1[0] + fac1*rt1[0]*(rt2[0]-1.0f);
rt[1]= rt1[1] + fac1*rt1[1]*(rt2[1]-1.0f);
rt[2]= rt1[2] + fac1*rt1[2]*(rt2[2]-1.0f);
rt[3]= rt1[3] + fac1*rt1[3]*(rt2[3]-1.0f);
rt[0] = rt1[0] + fac1 * rt1[0] * (rt2[0] - 1.0f);
rt[1] = rt1[1] + fac1 * rt1[1] * (rt2[1] - 1.0f);
rt[2] = rt1[2] + fac1 * rt1[2] * (rt2[2] - 1.0f);
rt[3] = rt1[3] + fac1 * rt1[3] * (rt2[3] - 1.0f);
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
if (y==0) break;
if (y == 0) break;
y--;
x= xo;
x = xo;
while (x--) {
rt[0]= rt1[0] + fac3*rt1[0]*(rt2[0]-1.0f);
rt[1]= rt1[1] + fac3*rt1[1]*(rt2[1]-1.0f);
rt[2]= rt1[2] + fac3*rt1[2]*(rt2[2]-1.0f);
rt[3]= rt1[3] + fac3*rt1[3]*(rt2[3]-1.0f);
rt[0] = rt1[0] + fac3 * rt1[0] * (rt2[0] - 1.0f);
rt[1] = rt1[1] + fac3 * rt1[1] * (rt2[1] - 1.0f);
rt[2] = rt1[2] + fac3 * rt1[2] * (rt2[2] - 1.0f);
rt[3] = rt1[3] + fac3 * rt1[3] * (rt2[3] - 1.0f);
rt1+= 4; rt2+= 4; rt+= 4;
rt1 += 4; rt2 += 4; rt += 4;
}
}
}
static struct ImBuf * do_mul_effect(
SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
static struct ImBuf *do_mul_effect(
SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
{
struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
if (out->rect_float) {
do_mul_effect_float(
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
}
else {
do_mul_effect_byte(
facf0, facf1, context.rectx, context.recty,
(unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect,
(unsigned char*) out->rect);
facf0, facf1, context.rectx, context.recty,
(unsigned char *) ibuf1->rect, (unsigned char *) ibuf2->rect,
(unsigned char *) out->rect);
}
return out;
@@ -1607,8 +1605,8 @@ static void precalc_wipe_zone(WipeZone *wipezone, WipeVars *wipe, int xo, int yo
wipezone->angle = tanf(DEG2RADF(fabsf(wipe->angle)));
wipezone->xo = xo;
wipezone->yo = yo;
wipezone->width = (int)(wipe->edgeWidth*((xo+yo)/2.0f));
wipezone->pythangle = 1.0f/sqrtf(wipezone->angle*wipezone->angle + 1.0f);
wipezone->width = (int)(wipe->edgeWidth * ((xo + yo) / 2.0f));
wipezone->pythangle = 1.0f / sqrtf(wipezone->angle * wipezone->angle + 1.0f);
}
// This function calculates the blur band for the wipe effects
@@ -1623,18 +1621,18 @@ static float in_band(float width, float dist, int side, int dir)
return (float)side;
if (side == 1)
alpha = (dist+0.5f*width) / (width);
alpha = (dist + 0.5f * width) / (width);
else
alpha = (0.5f*width-dist) / (width);
alpha = (0.5f * width - dist) / (width);
if (dir == 0)
alpha = 1-alpha;
alpha = 1 - alpha;
return alpha;
}
static float check_zone(WipeZone *wipezone, int x, int y,
Sequence *seq, float facf0)
Sequence *seq, float facf0)
{
float posx, posy, hyp, hyp2, angle, hwidth, b1, b2, b3, pointdist;
/* some future stuff */
@@ -1642,9 +1640,9 @@ static float check_zone(WipeZone *wipezone, int x, int y,
float temp1, temp2, temp3, temp4; //some placeholder variables
int xo = wipezone->xo;
int yo = wipezone->yo;
float halfx = xo*0.5f;
float halfy = yo*0.5f;
float widthf, output=0;
float halfx = xo * 0.5f;
float halfy = yo * 0.5f;
float widthf, output = 0;
WipeVars *wipe = (WipeVars *)seq->effectdata;
int width;
@@ -1670,9 +1668,9 @@ static float check_zone(WipeZone *wipezone, int x, int y,
hyp = fabs(y - posy);
}
else {
b1 = posy - (-angle)*posx;
b2 = y - (-angle)*x;
hyp = fabsf(angle*x+y+(-posy-angle*posx))*wipezone->pythangle;
b1 = posy - (-angle) * posx;
b2 = y - (-angle) * x;
hyp = fabsf(angle * x + y + (-posy - angle * posx)) * wipezone->pythangle;
}
if (angle < 0) {
@@ -1693,49 +1691,49 @@ static float check_zone(WipeZone *wipezone, int x, int y,
else
output = in_band(width, hyp, 1, 1);
}
break;
break;
case DO_DOUBLE_WIPE:
if (!wipe->forward)
facf0 = 1.0f-facf0; // Go the other direction
facf0 = 1.0f - facf0; // Go the other direction
width = wipezone->width; // calculate the blur width
hwidth = width*0.5f;
hwidth = width * 0.5f;
if (angle == 0) {
b1 = posy*0.5f;
b3 = yo-posy*0.5f;
b1 = posy * 0.5f;
b3 = yo - posy * 0.5f;
b2 = y;
hyp = abs(y - posy*0.5f);
hyp2 = abs(y - (yo-posy*0.5f));
hyp = abs(y - posy * 0.5f);
hyp2 = abs(y - (yo - posy * 0.5f));
}
else {
b1 = posy*0.5f - (-angle)*posx*0.5f;
b3 = (yo-posy*0.5f) - (-angle)*(xo-posx*0.5f);
b2 = y - (-angle)*x;
b1 = posy * 0.5f - (-angle) * posx * 0.5f;
b3 = (yo - posy * 0.5f) - (-angle) * (xo - posx * 0.5f);
b2 = y - (-angle) * x;
hyp = fabsf(angle*x+y+(-posy*0.5f-angle*posx*0.5f))*wipezone->pythangle;
hyp2 = fabsf(angle*x+y+(-(yo-posy*0.5f)-angle*(xo-posx*0.5f)))*wipezone->pythangle;
hyp = fabsf(angle * x + y + (-posy * 0.5f - angle * posx * 0.5f)) * wipezone->pythangle;
hyp2 = fabsf(angle * x + y + (-(yo - posy * 0.5f) - angle * (xo - posx * 0.5f))) * wipezone->pythangle;
}
hwidth = minf(hwidth, fabsf(b3-b1)/2.0f);
hwidth = minf(hwidth, fabsf(b3 - b1) / 2.0f);
if (b2 < b1 && b2 < b3 ) {
if (b2 < b1 && b2 < b3) {
output = in_band(hwidth, hyp, 0, 1);
}
else if (b2 > b1 && b2 > b3 ) {
else if (b2 > b1 && b2 > b3) {
output = in_band(hwidth, hyp2, 0, 1);
}
else {
if ( hyp < hwidth && hyp2 > hwidth )
if (hyp < hwidth && hyp2 > hwidth)
output = in_band(hwidth, hyp, 1, 1);
else if ( hyp > hwidth && hyp2 < hwidth )
output = in_band(hwidth, hyp2, 1, 1);
else if (hyp > hwidth && hyp2 < hwidth)
output = in_band(hwidth, hyp2, 1, 1);
else
output = in_band(hwidth, hyp2, 1, 1) * in_band(hwidth, hyp, 1, 1);
output = in_band(hwidth, hyp2, 1, 1) * in_band(hwidth, hyp, 1, 1);
}
if (!wipe->forward)output = 1-output;
break;
if (!wipe->forward) output = 1 - output;
break;
case DO_CLOCK_WIPE:
/*
* temp1: angle of effect center in rads
@@ -1744,125 +1742,125 @@ static float check_zone(WipeZone *wipezone, int x, int y,
* temp4: angle of high side of blur
*/
output = 1.0f - facf0;
widthf = wipe->edgeWidth*2.0f*(float)M_PI;
widthf = wipe->edgeWidth * 2.0f * (float)M_PI;
temp1 = 2.0f * (float)M_PI * facf0;
if (wipe->forward) {
temp1 = 2.0f*(float)M_PI - temp1;
temp1 = 2.0f * (float)M_PI - temp1;
}
x = x - halfx;
y = y - halfy;
temp2 = asin(abs(y)/sqrt(x*x + y*y));
temp2 = asin(abs(y) / sqrt(x * x + y * y));
if (x <= 0 && y >= 0) temp2 = (float)M_PI - temp2;
else if (x<=0 && y <= 0) temp2 += (float)M_PI;
else if (x >= 0 && y <= 0) temp2 = 2.0f*(float)M_PI - temp2;
else if (x <= 0 && y <= 0) temp2 += (float)M_PI;
else if (x >= 0 && y <= 0) temp2 = 2.0f * (float)M_PI - temp2;
if (wipe->forward) {
temp3 = temp1-(widthf*0.5f)*facf0;
temp4 = temp1+(widthf*0.5f)*(1-facf0);
temp3 = temp1 - (widthf * 0.5f) * facf0;
temp4 = temp1 + (widthf * 0.5f) * (1 - facf0);
}
else {
temp3 = temp1-(widthf*0.5f)*(1-facf0);
temp4 = temp1+(widthf*0.5f)*facf0;
temp3 = temp1 - (widthf * 0.5f) * (1 - facf0);
temp4 = temp1 + (widthf * 0.5f) * facf0;
}
if (temp3 < 0) temp3 = 0;
if (temp4 > 2.0f*(float)M_PI) temp4 = 2.0f*(float)M_PI;
if (temp4 > 2.0f * (float)M_PI) temp4 = 2.0f * (float)M_PI;
if (temp2 < temp3) output = 0;
else if (temp2 > temp4) output = 1;
else output = (temp2-temp3)/(temp4-temp3);
else output = (temp2 - temp3) / (temp4 - temp3);
if (x == 0 && y == 0) output = 1;
if (output != output) output = 1;
if (wipe->forward) output = 1 - output;
break;
/* BOX WIPE IS NOT WORKING YET */
/* case DO_CROSS_WIPE: */
/* BOX WIPE IS NOT WORKING YET */
break;
/* BOX WIPE IS NOT WORKING YET */
/* case DO_CROSS_WIPE: */
/* BOX WIPE IS NOT WORKING YET */
#if 0
case DO_BOX_WIPE:
if (invert)facf0 = 1-facf0;
if (invert) facf0 = 1 - facf0;
width = (int)(wipe->edgeWidth*((xo+yo)/2.0));
hwidth = (float)width/2.0;
if (angle == 0)angle = 0.000001;
b1 = posy/2 - (-angle)*posx/2;
b3 = (yo-posy/2) - (-angle)*(xo-posx/2);
b2 = y - (-angle)*x;
width = (int)(wipe->edgeWidth * ((xo + yo) / 2.0));
hwidth = (float)width / 2.0;
if (angle == 0) angle = 0.000001;
b1 = posy / 2 - (-angle) * posx / 2;
b3 = (yo - posy / 2) - (-angle) * (xo - posx / 2);
b2 = y - (-angle) * x;
hyp = abs(angle*x+y+(-posy/2-angle*posx/2))*wipezone->pythangle;
hyp2 = abs(angle*x+y+(-(yo-posy/2)-angle*(xo-posx/2)))*wipezone->pythangle;
hyp = abs(angle * x + y + (-posy / 2 - angle * posx / 2)) * wipezone->pythangle;
hyp2 = abs(angle * x + y + (-(yo - posy / 2) - angle * (xo - posx / 2))) * wipezone->pythangle;
temp1 = xo*(1-facf0/2)-xo*facf0/2;
temp2 = yo*(1-facf0/2)-yo*facf0/2;
pointdist = sqrt(temp1*temp1 + temp2*temp2);
temp1 = xo * (1 - facf0 / 2) - xo * facf0 / 2;
temp2 = yo * (1 - facf0 / 2) - yo * facf0 / 2;
pointdist = sqrt(temp1 * temp1 + temp2 * temp2);
if (b2 < b1 && b2 < b3 ) {
if (b2 < b1 && b2 < b3) {
if (hwidth < pointdist)
output = in_band(wipezone, hwidth, hyp, facf0, 0, 1);
}
else if (b2 > b1 && b2 > b3 ) {
}
else if (b2 > b1 && b2 > b3) {
if (hwidth < pointdist)
output = in_band(wipezone, hwidth, hyp2, facf0, 0, 1);
}
else {
if ( hyp < hwidth && hyp2 > hwidth )
}
else {
if (hyp < hwidth && hyp2 > hwidth)
output = in_band(wipezone, hwidth, hyp, facf0, 1, 1);
else if ( hyp > hwidth && hyp2 < hwidth )
output = in_band(wipezone, hwidth, hyp2, facf0, 1, 1);
else if (hyp > hwidth && hyp2 < hwidth)
output = in_band(wipezone, hwidth, hyp2, facf0, 1, 1);
else
output = in_band(wipezone, hwidth, hyp2, facf0, 1, 1) * in_band(wipezone, hwidth, hyp, facf0, 1, 1);
output = in_band(wipezone, hwidth, hyp2, facf0, 1, 1) * in_band(wipezone, hwidth, hyp, facf0, 1, 1);
}
if (invert)facf0 = 1-facf0;
angle = -1/angle;
b1 = posy/2 - (-angle)*posx/2;
b3 = (yo-posy/2) - (-angle)*(xo-posx/2);
b2 = y - (-angle)*x;
if (invert) facf0 = 1 - facf0;
angle = -1 / angle;
b1 = posy / 2 - (-angle) * posx / 2;
b3 = (yo - posy / 2) - (-angle) * (xo - posx / 2);
b2 = y - (-angle) * x;
hyp = abs(angle*x+y+(-posy/2-angle*posx/2))*wipezone->pythangle;
hyp2 = abs(angle*x+y+(-(yo-posy/2)-angle*(xo-posx/2)))*wipezone->pythangle;
hyp = abs(angle * x + y + (-posy / 2 - angle * posx / 2)) * wipezone->pythangle;
hyp2 = abs(angle * x + y + (-(yo - posy / 2) - angle * (xo - posx / 2))) * wipezone->pythangle;
if (b2 < b1 && b2 < b3 ) {
if (b2 < b1 && b2 < b3) {
if (hwidth < pointdist)
output *= in_band(wipezone, hwidth, hyp, facf0, 0, 1);
}
else if (b2 > b1 && b2 > b3 ) {
}
else if (b2 > b1 && b2 > b3) {
if (hwidth < pointdist)
output *= in_band(wipezone, hwidth, hyp2, facf0, 0, 1);
}
else {
if ( hyp < hwidth && hyp2 > hwidth )
}
else {
if (hyp < hwidth && hyp2 > hwidth)
output *= in_band(wipezone, hwidth, hyp, facf0, 1, 1);
else if ( hyp > hwidth && hyp2 < hwidth )
else if (hyp > hwidth && hyp2 < hwidth)
output *= in_band(wipezone, hwidth, hyp2, facf0, 1, 1);
else
output *= in_band(wipezone, hwidth, hyp2, facf0, 1, 1) * in_band(wipezone, hwidth, hyp, facf0, 1, 1);
}
break;
break;
#endif
case DO_IRIS_WIPE:
if (xo > yo) yo = xo;
else xo = yo;
if (!wipe->forward) facf0 = 1-facf0;
if (!wipe->forward) facf0 = 1 - facf0;
width = wipezone->width;
hwidth = width*0.5f;
hwidth = width * 0.5f;
temp1 = (halfx-(halfx)*facf0);
pointdist = sqrt(temp1*temp1 + temp1*temp1);
temp1 = (halfx - (halfx) * facf0);
pointdist = sqrt(temp1 * temp1 + temp1 * temp1);
temp2 = sqrt((halfx-x)*(halfx-x) + (halfy-y)*(halfy-y));
if (temp2 > pointdist) output = in_band(hwidth, fabs(temp2-pointdist), 0, 1);
else output = in_band(hwidth, fabs(temp2-pointdist), 1, 1);
temp2 = sqrt((halfx - x) * (halfx - x) + (halfy - y) * (halfy - y));
if (temp2 > pointdist) output = in_band(hwidth, fabs(temp2 - pointdist), 0, 1);
else output = in_band(hwidth, fabs(temp2 - pointdist), 1, 1);
if (!wipe->forward) output = 1-output;
if (!wipe->forward) output = 1 - output;
break;
break;
}
if (output < 0) output = 0;
else if (output > 1) output = 1;
@@ -1871,7 +1869,7 @@ static float check_zone(WipeZone *wipezone, int x, int y,
static void init_wipe_effect(Sequence *seq)
{
if (seq->effectdata)MEM_freeN(seq->effectdata);
if (seq->effectdata) MEM_freeN(seq->effectdata);
seq->effectdata = MEM_callocN(sizeof(struct WipeVars), "wipevars");
}
@@ -1882,7 +1880,7 @@ static int num_inputs_wipe(void)
static void free_wipe_effect(Sequence *seq)
{
if (seq->effectdata)MEM_freeN(seq->effectdata);
if (seq->effectdata) MEM_freeN(seq->effectdata);
seq->effectdata = NULL;
}
@@ -1892,9 +1890,9 @@ static void copy_wipe_effect(Sequence *dst, Sequence *src)
}
static void do_wipe_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1),
int x, int y,
unsigned char *rect1,
unsigned char *rect2, unsigned char *out)
int x, int y,
unsigned char *rect1,
unsigned char *rect2, unsigned char *out)
{
WipeZone wipezone;
WipeVars *wipe = (WipeVars *)seq->effectdata;
@@ -1909,15 +1907,15 @@ static void do_wipe_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1),
xo = x;
yo = y;
for (y=0;y<yo;y++) {
for (x=0;x<xo;x++) {
for (y = 0; y < yo; y++) {
for (x = 0; x < xo; x++) {
float check = check_zone(&wipezone, x, y, seq, facf0);
if (check) {
if (rt1) {
rt[0] = (int)(rt1[0]*check)+ (int)(rt2[0]*(1-check));
rt[1] = (int)(rt1[1]*check)+ (int)(rt2[1]*(1-check));
rt[2] = (int)(rt1[2]*check)+ (int)(rt2[2]*(1-check));
rt[3] = (int)(rt1[3]*check)+ (int)(rt2[3]*(1-check));
rt[0] = (int)(rt1[0] * check) + (int)(rt2[0] * (1 - check));
rt[1] = (int)(rt1[1] * check) + (int)(rt2[1] * (1 - check));
rt[2] = (int)(rt1[2] * check) + (int)(rt2[2] * (1 - check));
rt[3] = (int)(rt1[3] * check) + (int)(rt2[3] * (1 - check));
}
else {
rt[0] = 0;
@@ -1941,21 +1939,21 @@ static void do_wipe_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1),
}
}
rt+=4;
if (rt1 !=NULL) {
rt1+=4;
rt += 4;
if (rt1 != NULL) {
rt1 += 4;
}
if (rt2 !=NULL) {
rt2+=4;
if (rt2 != NULL) {
rt2 += 4;
}
}
}
}
static void do_wipe_effect_float(Sequence *seq, float facf0, float UNUSED(facf1),
int x, int y,
float *rect1,
float *rect2, float *out)
int x, int y,
float *rect1,
float *rect2, float *out)
{
WipeZone wipezone;
WipeVars *wipe = (WipeVars *)seq->effectdata;
@@ -1970,15 +1968,15 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float UNUSED(facf1)
xo = x;
yo = y;
for (y=0;y<yo;y++) {
for (x=0;x<xo;x++) {
for (y = 0; y < yo; y++) {
for (x = 0; x < xo; x++) {
float check = check_zone(&wipezone, x, y, seq, facf0);
if (check) {
if (rt1) {
rt[0] = rt1[0]*check+ rt2[0]*(1-check);
rt[1] = rt1[1]*check+ rt2[1]*(1-check);
rt[2] = rt1[2]*check+ rt2[2]*(1-check);
rt[3] = rt1[3]*check+ rt2[3]*(1-check);
rt[0] = rt1[0] * check + rt2[0] * (1 - check);
rt[1] = rt1[1] * check + rt2[1] * (1 - check);
rt[2] = rt1[2] * check + rt2[2] * (1 - check);
rt[3] = rt1[3] * check + rt2[3] * (1 - check);
}
else {
rt[0] = 0;
@@ -2002,36 +2000,35 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float UNUSED(facf1)
}
}
rt+=4;
if (rt1 !=NULL) {
rt1+=4;
rt += 4;
if (rt1 != NULL) {
rt1 += 4;
}
if (rt2 !=NULL) {
rt2+=4;
if (rt2 != NULL) {
rt2 += 4;
}
}
}
}
static struct ImBuf * do_wipe_effect(
SeqRenderData context, Sequence *seq, float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
{
struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
static struct ImBuf *do_wipe_effect(
SeqRenderData context, Sequence *seq, float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3){
struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
if (out->rect_float) {
do_wipe_effect_float(seq,
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
facf0, facf1, context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
}
else {
do_wipe_effect_byte(seq,
facf0, facf1, context.rectx, context.recty,
(unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect,
(unsigned char*) out->rect);
facf0, facf1, context.rectx, context.recty,
(unsigned char *) ibuf1->rect, (unsigned char *) ibuf2->rect,
(unsigned char *) out->rect);
}
return out;
@@ -2043,7 +2040,7 @@ static void init_transform_effect(Sequence *seq)
{
TransformVars *transform;
if (seq->effectdata)MEM_freeN(seq->effectdata);
if (seq->effectdata) MEM_freeN(seq->effectdata);
seq->effectdata = MEM_callocN(sizeof(struct TransformVars), "transformvars");
transform = (TransformVars *)seq->effectdata;
@@ -2051,14 +2048,14 @@ static void init_transform_effect(Sequence *seq)
transform->ScalexIni = 1.0f;
transform->ScaleyIni = 1.0f;
transform->xIni=0.0f;
transform->yIni=0.0f;
transform->xIni = 0.0f;
transform->yIni = 0.0f;
transform->rotIni=0.0f;
transform->rotIni = 0.0f;
transform->interpolation=1;
transform->percent=1;
transform->uniform_scale=0;
transform->interpolation = 1;
transform->percent = 1;
transform->uniform_scale = 0;
}
static int num_inputs_transform(void)
@@ -2068,7 +2065,7 @@ static int num_inputs_transform(void)
static void free_transform_effect(Sequence *seq)
{
if (seq->effectdata)MEM_freeN(seq->effectdata);
if (seq->effectdata) MEM_freeN(seq->effectdata);
seq->effectdata = NULL;
}
@@ -2078,8 +2075,8 @@ static void copy_transform_effect(Sequence *dst, Sequence *src)
}
static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out,
float scale_x, float scale_y, float translate_x, float translate_y,
float rotate, int interpolation)
float scale_x, float scale_y, float translate_x, float translate_y,
float rotate, int interpolation)
{
int xo, yo, xi, yi;
float xt, yt, xr, yr;
@@ -2089,19 +2086,19 @@ static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out
yo = y;
// Rotate
s= sin(rotate);
c= cos(rotate);
s = sin(rotate);
c = cos(rotate);
for (yi = 0; yi < yo; yi++) {
for (xi = 0; xi < xo; xi++) {
//translate point
xt = xi-translate_x;
yt = yi-translate_y;
xt = xi - translate_x;
yt = yi - translate_y;
//rotate point with center ref
xr = c*xt + s*yt;
yr = -s*xt + c*yt;
xr = c * xt + s * yt;
yr = -s * xt + c * yt;
//scale point with center ref
xt = xr / scale_x;
@@ -2113,22 +2110,22 @@ static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out
//interpolate
switch (interpolation) {
case 0:
neareast_interpolation(ibuf1, out, xt, yt, xi, yi);
break;
case 1:
bilinear_interpolation(ibuf1, out, xt, yt, xi, yi);
break;
case 2:
bicubic_interpolation(ibuf1, out, xt, yt, xi, yi);
break;
case 0:
neareast_interpolation(ibuf1, out, xt, yt, xi, yi);
break;
case 1:
bilinear_interpolation(ibuf1, out, xt, yt, xi, yi);
break;
case 2:
bicubic_interpolation(ibuf1, out, xt, yt, xi, yi);
break;
}
}
}
}
static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x, int y,
struct ImBuf *ibuf1, struct ImBuf *out)
struct ImBuf *ibuf1, struct ImBuf *out)
{
TransformVars *transform = (TransformVars *)seq->effectdata;
float scale_x, scale_y, translate_x, translate_y, rotate_radians;
@@ -2144,14 +2141,14 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x
// Translate
if (!transform->percent) {
float rd_s = (scene->r.size/100.0f);
float rd_s = (scene->r.size / 100.0f);
translate_x = transform->xIni*rd_s+(x/2.0f);
translate_y = transform->yIni*rd_s+(y/2.0f);
translate_x = transform->xIni * rd_s + (x / 2.0f);
translate_y = transform->yIni * rd_s + (y / 2.0f);
}
else {
translate_x = x*(transform->xIni/100.0f)+(x/2.0f);
translate_y = y*(transform->yIni/100.0f)+(y/2.0f);
translate_x = x * (transform->xIni / 100.0f) + (x / 2.0f);
translate_y = y * (transform->yIni / 100.0f) + (y / 2.0f);
}
// Rotate
@@ -2161,13 +2158,12 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x
}
static struct ImBuf * do_transform_effect(
SeqRenderData context, Sequence *seq, float UNUSED(cfra),
float facf0, float UNUSED(facf1),
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
{
struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
static struct ImBuf *do_transform_effect(
SeqRenderData context, Sequence *seq, float UNUSED(cfra),
float facf0, float UNUSED(facf1),
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3){
struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
do_transform(context.scene, seq, facf0,
context.rectx, context.recty, ibuf1, out);
@@ -2180,7 +2176,7 @@ static struct ImBuf * do_transform_effect(
* GLOW
* ********************************************************************** */
static void RVBlurBitmap2_byte(unsigned char* map, int width, int height,
static void RVBlurBitmap2_byte(unsigned char *map, int width, int height,
float blur,
int quality)
/* MUUUCCH better than the previous blur. */
@@ -2192,26 +2188,26 @@ static void RVBlurBitmap2_byte(unsigned char* map, int width, int height,
/* a small bitmap. Avoid avoid avoid. */
/*=============================== */
{
unsigned char* temp=NULL, *swap;
float *filter=NULL;
int x, y, i, fx, fy;
int index, ix, halfWidth;
float fval, k, curColor[3], curColor2[3], weight=0;
unsigned char *temp = NULL, *swap;
float *filter = NULL;
int x, y, i, fx, fy;
int index, ix, halfWidth;
float fval, k, curColor[3], curColor2[3], weight = 0;
/* If we're not really blurring, bail out */
if (blur<=0)
if (blur <= 0)
return;
/* Allocate memory for the tempmap and the blur filter matrix */
temp= MEM_mallocN((width*height*4), "blurbitmaptemp");
temp = MEM_mallocN((width * height * 4), "blurbitmaptemp");
if (!temp)
return;
/* Allocate memory for the filter elements */
halfWidth = ((quality+1)*blur);
filter = (float *)MEM_mallocN(sizeof(float)*halfWidth*2, "blurbitmapfilter");
halfWidth = ((quality + 1) * blur);
filter = (float *)MEM_mallocN(sizeof(float) * halfWidth * 2, "blurbitmapfilter");
if (!filter) {
MEM_freeN (temp);
MEM_freeN(temp);
return;
}
@@ -2221,137 +2217,137 @@ static void RVBlurBitmap2_byte(unsigned char* map, int width, int height,
/* posted to comp.graphics.algorithms by */
/* Blancmange (bmange@airdmhor.gen.nz) */
k = -1.0f/(2.0f*(float)M_PI*blur*blur);
for (ix = 0;ix< halfWidth;ix++) {
weight = (float)exp(k*(ix*ix));
k = -1.0f / (2.0f * (float)M_PI * blur * blur);
for (ix = 0; ix < halfWidth; ix++) {
weight = (float)exp(k * (ix * ix));
filter[halfWidth - ix] = weight;
filter[halfWidth + ix] = weight;
}
filter[0] = weight;
/* Normalize the array */
fval=0;
for (ix = 0;ix< halfWidth*2;ix++)
fval+=filter[ix];
fval = 0;
for (ix = 0; ix < halfWidth * 2; ix++)
fval += filter[ix];
for (ix = 0;ix< halfWidth*2;ix++)
filter[ix]/=fval;
for (ix = 0; ix < halfWidth * 2; ix++)
filter[ix] /= fval;
/* Blur the rows */
for (y=0;y<height;y++) {
for (y = 0; y < height; y++) {
/* Do the left & right strips */
for (x=0;x<halfWidth;x++) {
index=(x+y*width)*4;
fx=0;
for (x = 0; x < halfWidth; x++) {
index = (x + y * width) * 4;
fx = 0;
zero_v3(curColor);
zero_v3(curColor2);
for (i=x-halfWidth;i<x+halfWidth;i++) {
if ((i>=0)&&(i<width)) {
curColor[0]+=map[(i+y*width)*4+GlowR]*filter[fx];
curColor[1]+=map[(i+y*width)*4+GlowG]*filter[fx];
curColor[2]+=map[(i+y*width)*4+GlowB]*filter[fx];
for (i = x - halfWidth; i < x + halfWidth; i++) {
if ((i >= 0) && (i < width)) {
curColor[0] += map[(i + y * width) * 4 + GlowR] * filter[fx];
curColor[1] += map[(i + y * width) * 4 + GlowG] * filter[fx];
curColor[2] += map[(i + y * width) * 4 + GlowB] * filter[fx];
curColor2[0]+=map[(width-1-i+y*width)*4+GlowR] *
filter[fx];
curColor2[1]+=map[(width-1-i+y*width)*4+GlowG] *
filter[fx];
curColor2[2]+=map[(width-1-i+y*width)*4+GlowB] *
filter[fx];
curColor2[0] += map[(width - 1 - i + y * width) * 4 + GlowR] *
filter[fx];
curColor2[1] += map[(width - 1 - i + y * width) * 4 + GlowG] *
filter[fx];
curColor2[2] += map[(width - 1 - i + y * width) * 4 + GlowB] *
filter[fx];
}
fx++;
}
temp[index+GlowR]=curColor[0];
temp[index+GlowG]=curColor[1];
temp[index+GlowB]=curColor[2];
temp[index + GlowR] = curColor[0];
temp[index + GlowG] = curColor[1];
temp[index + GlowB] = curColor[2];
temp[((width-1-x+y*width)*4)+GlowR]=curColor2[0];
temp[((width-1-x+y*width)*4)+GlowG]=curColor2[1];
temp[((width-1-x+y*width)*4)+GlowB]=curColor2[2];
temp[((width - 1 - x + y * width) * 4) + GlowR] = curColor2[0];
temp[((width - 1 - x + y * width) * 4) + GlowG] = curColor2[1];
temp[((width - 1 - x + y * width) * 4) + GlowB] = curColor2[2];
}
/* Do the main body */
for (x=halfWidth;x<width-halfWidth;x++) {
index=(x+y*width)*4;
fx=0;
for (x = halfWidth; x < width - halfWidth; x++) {
index = (x + y * width) * 4;
fx = 0;
zero_v3(curColor);
for (i=x-halfWidth;i<x+halfWidth;i++) {
curColor[0]+=map[(i+y*width)*4+GlowR]*filter[fx];
curColor[1]+=map[(i+y*width)*4+GlowG]*filter[fx];
curColor[2]+=map[(i+y*width)*4+GlowB]*filter[fx];
for (i = x - halfWidth; i < x + halfWidth; i++) {
curColor[0] += map[(i + y * width) * 4 + GlowR] * filter[fx];
curColor[1] += map[(i + y * width) * 4 + GlowG] * filter[fx];
curColor[2] += map[(i + y * width) * 4 + GlowB] * filter[fx];
fx++;
}
temp[index+GlowR]=curColor[0];
temp[index+GlowG]=curColor[1];
temp[index+GlowB]=curColor[2];
temp[index + GlowR] = curColor[0];
temp[index + GlowG] = curColor[1];
temp[index + GlowB] = curColor[2];
}
}
/* Swap buffers */
swap=temp;temp=map;map=swap;
swap = temp; temp = map; map = swap;
/* Blur the columns */
for (x=0;x<width;x++) {
for (x = 0; x < width; x++) {
/* Do the top & bottom strips */
for (y=0;y<halfWidth;y++) {
index=(x+y*width)*4;
fy=0;
for (y = 0; y < halfWidth; y++) {
index = (x + y * width) * 4;
fy = 0;
zero_v3(curColor);
zero_v3(curColor2);
for (i=y-halfWidth;i<y+halfWidth;i++) {
if ((i>=0)&&(i<height)) {
for (i = y - halfWidth; i < y + halfWidth; i++) {
if ((i >= 0) && (i < height)) {
/* Bottom */
curColor[0]+=map[(x+i*width)*4+GlowR]*filter[fy];
curColor[1]+=map[(x+i*width)*4+GlowG]*filter[fy];
curColor[2]+=map[(x+i*width)*4+GlowB]*filter[fy];
curColor[0] += map[(x + i * width) * 4 + GlowR] * filter[fy];
curColor[1] += map[(x + i * width) * 4 + GlowG] * filter[fy];
curColor[2] += map[(x + i * width) * 4 + GlowB] * filter[fy];
/* Top */
curColor2[0]+=map[(x+(height-1-i)*width) *
4+GlowR]*filter[fy];
curColor2[1]+=map[(x+(height-1-i)*width) *
4+GlowG]*filter[fy];
curColor2[2]+=map[(x+(height-1-i)*width) *
4+GlowB]*filter[fy];
curColor2[0] += map[(x + (height - 1 - i) * width) *
4 + GlowR] * filter[fy];
curColor2[1] += map[(x + (height - 1 - i) * width) *
4 + GlowG] * filter[fy];
curColor2[2] += map[(x + (height - 1 - i) * width) *
4 + GlowB] * filter[fy];
}
fy++;
}
temp[index+GlowR]=curColor[0];
temp[index+GlowG]=curColor[1];
temp[index+GlowB]=curColor[2];
temp[((x+(height-1-y)*width)*4)+GlowR]=curColor2[0];
temp[((x+(height-1-y)*width)*4)+GlowG]=curColor2[1];
temp[((x+(height-1-y)*width)*4)+GlowB]=curColor2[2];
temp[index + GlowR] = curColor[0];
temp[index + GlowG] = curColor[1];
temp[index + GlowB] = curColor[2];
temp[((x + (height - 1 - y) * width) * 4) + GlowR] = curColor2[0];
temp[((x + (height - 1 - y) * width) * 4) + GlowG] = curColor2[1];
temp[((x + (height - 1 - y) * width) * 4) + GlowB] = curColor2[2];
}
/* Do the main body */
for (y=halfWidth;y<height-halfWidth;y++) {
index=(x+y*width)*4;
fy=0;
for (y = halfWidth; y < height - halfWidth; y++) {
index = (x + y * width) * 4;
fy = 0;
zero_v3(curColor);
for (i=y-halfWidth;i<y+halfWidth;i++) {
curColor[0]+=map[(x+i*width)*4+GlowR]*filter[fy];
curColor[1]+=map[(x+i*width)*4+GlowG]*filter[fy];
curColor[2]+=map[(x+i*width)*4+GlowB]*filter[fy];
for (i = y - halfWidth; i < y + halfWidth; i++) {
curColor[0] += map[(x + i * width) * 4 + GlowR] * filter[fy];
curColor[1] += map[(x + i * width) * 4 + GlowG] * filter[fy];
curColor[2] += map[(x + i * width) * 4 + GlowB] * filter[fy];
fy++;
}
temp[index+GlowR]=curColor[0];
temp[index+GlowG]=curColor[1];
temp[index+GlowB]=curColor[2];
temp[index + GlowR] = curColor[0];
temp[index + GlowG] = curColor[1];
temp[index + GlowB] = curColor[2];
}
}
/* Swap buffers */
swap=temp;temp=map; /* map=swap; */ /* UNUSED */
swap = temp; temp = map; /* map=swap; */ /* UNUSED */
/* Tidy up */
MEM_freeN (filter);
MEM_freeN (temp);
MEM_freeN(filter);
MEM_freeN(temp);
}
static void RVBlurBitmap2_float ( float* map, int width, int height,
float blur,
int quality)
static void RVBlurBitmap2_float(float *map, int width, int height,
float blur,
int quality)
/* MUUUCCH better than the previous blur. */
/* We do the blurring in two passes which is a whole lot faster. */
/* I changed the math arount to implement an actual Gaussian */
@@ -2361,26 +2357,26 @@ static void RVBlurBitmap2_float ( float* map, int width, int height,
/* a small bitmap. Avoid avoid avoid. */
/*=============================== */
{
float* temp=NULL, *swap;
float *filter=NULL;
int x, y, i, fx, fy;
int index, ix, halfWidth;
float fval, k, curColor[3], curColor2[3], weight=0;
float *temp = NULL, *swap;
float *filter = NULL;
int x, y, i, fx, fy;
int index, ix, halfWidth;
float fval, k, curColor[3], curColor2[3], weight = 0;
/* If we're not really blurring, bail out */
if (blur<=0)
if (blur <= 0)
return;
/* Allocate memory for the tempmap and the blur filter matrix */
temp= MEM_mallocN((width*height*4*sizeof(float)), "blurbitmaptemp");
temp = MEM_mallocN((width * height * 4 * sizeof(float)), "blurbitmaptemp");
if (!temp)
return;
/* Allocate memory for the filter elements */
halfWidth = ((quality+1)*blur);
filter = (float *)MEM_mallocN(sizeof(float)*halfWidth*2, "blurbitmapfilter");
halfWidth = ((quality + 1) * blur);
filter = (float *)MEM_mallocN(sizeof(float) * halfWidth * 2, "blurbitmapfilter");
if (!filter) {
MEM_freeN (temp);
MEM_freeN(temp);
return;
}
@@ -2390,133 +2386,133 @@ static void RVBlurBitmap2_float ( float* map, int width, int height,
/* posted to comp.graphics.algorithms by */
/* Blancmange (bmange@airdmhor.gen.nz) */
k = -1.0f/(2.0f*(float)M_PI*blur*blur);
k = -1.0f / (2.0f * (float)M_PI * blur * blur);
for (ix = 0;ix< halfWidth;ix++) {
weight = (float)exp(k*(ix*ix));
for (ix = 0; ix < halfWidth; ix++) {
weight = (float)exp(k * (ix * ix));
filter[halfWidth - ix] = weight;
filter[halfWidth + ix] = weight;
}
filter[0] = weight;
/* Normalize the array */
fval=0;
for (ix = 0;ix< halfWidth*2;ix++)
fval+=filter[ix];
fval = 0;
for (ix = 0; ix < halfWidth * 2; ix++)
fval += filter[ix];
for (ix = 0;ix< halfWidth*2;ix++)
filter[ix]/=fval;
for (ix = 0; ix < halfWidth * 2; ix++)
filter[ix] /= fval;
/* Blur the rows */
for (y=0;y<height;y++) {
for (y = 0; y < height; y++) {
/* Do the left & right strips */
for (x=0;x<halfWidth;x++) {
index=(x+y*width)*4;
fx=0;
curColor[0]=curColor[1]=curColor[2]=0.0f;
curColor2[0]=curColor2[1]=curColor2[2]=0.0f;
for (x = 0; x < halfWidth; x++) {
index = (x + y * width) * 4;
fx = 0;
curColor[0] = curColor[1] = curColor[2] = 0.0f;
curColor2[0] = curColor2[1] = curColor2[2] = 0.0f;
for (i=x-halfWidth;i<x+halfWidth;i++) {
if ((i>=0)&&(i<width)) {
curColor[0]+=map[(i+y*width)*4+GlowR]*filter[fx];
curColor[1]+=map[(i+y*width)*4+GlowG]*filter[fx];
curColor[2]+=map[(i+y*width)*4+GlowB]*filter[fx];
for (i = x - halfWidth; i < x + halfWidth; i++) {
if ((i >= 0) && (i < width)) {
curColor[0] += map[(i + y * width) * 4 + GlowR] * filter[fx];
curColor[1] += map[(i + y * width) * 4 + GlowG] * filter[fx];
curColor[2] += map[(i + y * width) * 4 + GlowB] * filter[fx];
curColor2[0]+=map[(width-1-i+y*width)*4+GlowR] *
filter[fx];
curColor2[1]+=map[(width-1-i+y*width)*4+GlowG] *
filter[fx];
curColor2[2]+=map[(width-1-i+y*width)*4+GlowB] *
filter[fx];
curColor2[0] += map[(width - 1 - i + y * width) * 4 + GlowR] *
filter[fx];
curColor2[1] += map[(width - 1 - i + y * width) * 4 + GlowG] *
filter[fx];
curColor2[2] += map[(width - 1 - i + y * width) * 4 + GlowB] *
filter[fx];
}
fx++;
}
temp[index+GlowR]=curColor[0];
temp[index+GlowG]=curColor[1];
temp[index+GlowB]=curColor[2];
temp[index + GlowR] = curColor[0];
temp[index + GlowG] = curColor[1];
temp[index + GlowB] = curColor[2];
temp[((width-1-x+y*width)*4)+GlowR]=curColor2[0];
temp[((width-1-x+y*width)*4)+GlowG]=curColor2[1];
temp[((width-1-x+y*width)*4)+GlowB]=curColor2[2];
temp[((width - 1 - x + y * width) * 4) + GlowR] = curColor2[0];
temp[((width - 1 - x + y * width) * 4) + GlowG] = curColor2[1];
temp[((width - 1 - x + y * width) * 4) + GlowB] = curColor2[2];
}
/* Do the main body */
for (x=halfWidth;x<width-halfWidth;x++) {
index=(x+y*width)*4;
fx=0;
for (x = halfWidth; x < width - halfWidth; x++) {
index = (x + y * width) * 4;
fx = 0;
zero_v3(curColor);
for (i=x-halfWidth;i<x+halfWidth;i++) {
curColor[0]+=map[(i+y*width)*4+GlowR]*filter[fx];
curColor[1]+=map[(i+y*width)*4+GlowG]*filter[fx];
curColor[2]+=map[(i+y*width)*4+GlowB]*filter[fx];
for (i = x - halfWidth; i < x + halfWidth; i++) {
curColor[0] += map[(i + y * width) * 4 + GlowR] * filter[fx];
curColor[1] += map[(i + y * width) * 4 + GlowG] * filter[fx];
curColor[2] += map[(i + y * width) * 4 + GlowB] * filter[fx];
fx++;
}
temp[index+GlowR]=curColor[0];
temp[index+GlowG]=curColor[1];
temp[index+GlowB]=curColor[2];
temp[index + GlowR] = curColor[0];
temp[index + GlowG] = curColor[1];
temp[index + GlowB] = curColor[2];
}
}
/* Swap buffers */
swap=temp;temp=map;map=swap;
swap = temp; temp = map; map = swap;
/* Blur the columns */
for (x=0;x<width;x++) {
for (x = 0; x < width; x++) {
/* Do the top & bottom strips */
for (y=0;y<halfWidth;y++) {
index=(x+y*width)*4;
fy=0;
for (y = 0; y < halfWidth; y++) {
index = (x + y * width) * 4;
fy = 0;
zero_v3(curColor);
zero_v3(curColor2);
for (i=y-halfWidth;i<y+halfWidth;i++) {
if ((i>=0)&&(i<height)) {
for (i = y - halfWidth; i < y + halfWidth; i++) {
if ((i >= 0) && (i < height)) {
/* Bottom */
curColor[0]+=map[(x+i*width)*4+GlowR]*filter[fy];
curColor[1]+=map[(x+i*width)*4+GlowG]*filter[fy];
curColor[2]+=map[(x+i*width)*4+GlowB]*filter[fy];
curColor[0] += map[(x + i * width) * 4 + GlowR] * filter[fy];
curColor[1] += map[(x + i * width) * 4 + GlowG] * filter[fy];
curColor[2] += map[(x + i * width) * 4 + GlowB] * filter[fy];
/* Top */
curColor2[0]+=map[(x+(height-1-i)*width) *
4+GlowR]*filter[fy];
curColor2[1]+=map[(x+(height-1-i)*width) *
4+GlowG]*filter[fy];
curColor2[2]+=map[(x+(height-1-i)*width) *
4+GlowB]*filter[fy];
curColor2[0] += map[(x + (height - 1 - i) * width) *
4 + GlowR] * filter[fy];
curColor2[1] += map[(x + (height - 1 - i) * width) *
4 + GlowG] * filter[fy];
curColor2[2] += map[(x + (height - 1 - i) * width) *
4 + GlowB] * filter[fy];
}
fy++;
}
temp[index+GlowR]=curColor[0];
temp[index+GlowG]=curColor[1];
temp[index+GlowB]=curColor[2];
temp[((x+(height-1-y)*width)*4)+GlowR]=curColor2[0];
temp[((x+(height-1-y)*width)*4)+GlowG]=curColor2[1];
temp[((x+(height-1-y)*width)*4)+GlowB]=curColor2[2];
temp[index + GlowR] = curColor[0];
temp[index + GlowG] = curColor[1];
temp[index + GlowB] = curColor[2];
temp[((x + (height - 1 - y) * width) * 4) + GlowR] = curColor2[0];
temp[((x + (height - 1 - y) * width) * 4) + GlowG] = curColor2[1];
temp[((x + (height - 1 - y) * width) * 4) + GlowB] = curColor2[2];
}
/* Do the main body */
for (y=halfWidth;y<height-halfWidth;y++) {
index=(x+y*width)*4;
fy=0;
for (y = halfWidth; y < height - halfWidth; y++) {
index = (x + y * width) * 4;
fy = 0;
zero_v3(curColor);
for (i=y-halfWidth;i<y+halfWidth;i++) {
curColor[0]+=map[(x+i*width)*4+GlowR]*filter[fy];
curColor[1]+=map[(x+i*width)*4+GlowG]*filter[fy];
curColor[2]+=map[(x+i*width)*4+GlowB]*filter[fy];
for (i = y - halfWidth; i < y + halfWidth; i++) {
curColor[0] += map[(x + i * width) * 4 + GlowR] * filter[fy];
curColor[1] += map[(x + i * width) * 4 + GlowG] * filter[fy];
curColor[2] += map[(x + i * width) * 4 + GlowB] * filter[fy];
fy++;
}
temp[index+GlowR]=curColor[0];
temp[index+GlowG]=curColor[1];
temp[index+GlowB]=curColor[2];
temp[index + GlowR] = curColor[0];
temp[index + GlowG] = curColor[1];
temp[index + GlowB] = curColor[2];
}
}
/* Swap buffers */
swap=temp;temp=map; /* map=swap; */ /* UNUSED */
swap = temp; temp = map; /* map=swap; */ /* UNUSED */
/* Tidy up */
MEM_freeN (filter);
MEM_freeN (temp);
MEM_freeN(filter);
MEM_freeN(temp);
}
@@ -2524,94 +2520,94 @@ static void RVBlurBitmap2_float ( float* map, int width, int height,
/* C must have been previously allocated but it may be A or B. */
/* We clamp values to 255 to prevent weirdness */
/*=============================== */
static void RVAddBitmaps_byte (unsigned char* a, unsigned char* b, unsigned char* c, int width, int height)
static void RVAddBitmaps_byte(unsigned char *a, unsigned char *b, unsigned char *c, int width, int height)
{
int x, y, index;
int x, y, index;
for (y=0;y<height;y++) {
for (x=0;x<width;x++) {
index=(x+y*width)*4;
c[index+GlowR]=MIN2(255, a[index+GlowR]+b[index+GlowR]);
c[index+GlowG]=MIN2(255, a[index+GlowG]+b[index+GlowG]);
c[index+GlowB]=MIN2(255, a[index+GlowB]+b[index+GlowB]);
c[index+GlowA]=MIN2(255, a[index+GlowA]+b[index+GlowA]);
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
index = (x + y * width) * 4;
c[index + GlowR] = MIN2(255, a[index + GlowR] + b[index + GlowR]);
c[index + GlowG] = MIN2(255, a[index + GlowG] + b[index + GlowG]);
c[index + GlowB] = MIN2(255, a[index + GlowB] + b[index + GlowB]);
c[index + GlowA] = MIN2(255, a[index + GlowA] + b[index + GlowA]);
}
}
}
static void RVAddBitmaps_float (float* a, float* b, float* c,
int width, int height)
static void RVAddBitmaps_float(float *a, float *b, float *c,
int width, int height)
{
int x, y, index;
int x, y, index;
for (y=0;y<height;y++) {
for (x=0;x<width;x++) {
index=(x+y*width)*4;
c[index+GlowR]= MIN2(1.0f, a[index+GlowR]+b[index+GlowR]);
c[index+GlowG]= MIN2(1.0f, a[index+GlowG]+b[index+GlowG]);
c[index+GlowB]= MIN2(1.0f, a[index+GlowB]+b[index+GlowB]);
c[index+GlowA]= MIN2(1.0f, a[index+GlowA]+b[index+GlowA]);
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
index = (x + y * width) * 4;
c[index + GlowR] = MIN2(1.0f, a[index + GlowR] + b[index + GlowR]);
c[index + GlowG] = MIN2(1.0f, a[index + GlowG] + b[index + GlowG]);
c[index + GlowB] = MIN2(1.0f, a[index + GlowB] + b[index + GlowB]);
c[index + GlowA] = MIN2(1.0f, a[index + GlowA] + b[index + GlowA]);
}
}
}
/* For each pixel whose total luminance exceeds the threshold, */
/* Multiply it's value by BOOST and add it to the output map */
static void RVIsolateHighlights_byte (unsigned char* in, unsigned char* out,
int width, int height, int threshold,
float boost, float clamp)
static void RVIsolateHighlights_byte(unsigned char *in, unsigned char *out,
int width, int height, int threshold,
float boost, float clamp)
{
int x, y, index;
int intensity;
int intensity;
for (y=0;y< height;y++) {
for (x=0;x< width;x++) {
index= (x+y*width)*4;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
index = (x + y * width) * 4;
/* Isolate the intensity */
intensity=(in[index+GlowR]+in[index+GlowG]+in[index+GlowB]-threshold);
if (intensity>0) {
out[index+GlowR]=MIN2(255*clamp, (in[index+GlowR]*boost*intensity)/255);
out[index+GlowG]=MIN2(255*clamp, (in[index+GlowG]*boost*intensity)/255);
out[index+GlowB]=MIN2(255*clamp, (in[index+GlowB]*boost*intensity)/255);
out[index+GlowA]=MIN2(255*clamp, (in[index+GlowA]*boost*intensity)/255);
intensity = (in[index + GlowR] + in[index + GlowG] + in[index + GlowB] - threshold);
if (intensity > 0) {
out[index + GlowR] = MIN2(255 * clamp, (in[index + GlowR] * boost * intensity) / 255);
out[index + GlowG] = MIN2(255 * clamp, (in[index + GlowG] * boost * intensity) / 255);
out[index + GlowB] = MIN2(255 * clamp, (in[index + GlowB] * boost * intensity) / 255);
out[index + GlowA] = MIN2(255 * clamp, (in[index + GlowA] * boost * intensity) / 255);
}
else {
out[index+GlowR]=0;
out[index+GlowG]=0;
out[index+GlowB]=0;
out[index+GlowA]=0;
out[index + GlowR] = 0;
out[index + GlowG] = 0;
out[index + GlowB] = 0;
out[index + GlowA] = 0;
}
}
}
}
static void RVIsolateHighlights_float (float* in, float* out,
int width, int height, float threshold,
float boost, float clamp)
static void RVIsolateHighlights_float(float *in, float *out,
int width, int height, float threshold,
float boost, float clamp)
{
int x, y, index;
float intensity;
float intensity;
for (y=0;y< height;y++) {
for (x=0;x< width;x++) {
index= (x+y*width)*4;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
index = (x + y * width) * 4;
/* Isolate the intensity */
intensity=(in[index+GlowR]+in[index+GlowG]+in[index+GlowB]-threshold);
if (intensity>0) {
out[index+GlowR]=MIN2(clamp, (in[index+GlowR]*boost*intensity));
out[index+GlowG]=MIN2(clamp, (in[index+GlowG]*boost*intensity));
out[index+GlowB]=MIN2(clamp, (in[index+GlowB]*boost*intensity));
out[index+GlowA]=MIN2(clamp, (in[index+GlowA]*boost*intensity));
intensity = (in[index + GlowR] + in[index + GlowG] + in[index + GlowB] - threshold);
if (intensity > 0) {
out[index + GlowR] = MIN2(clamp, (in[index + GlowR] * boost * intensity));
out[index + GlowG] = MIN2(clamp, (in[index + GlowG] * boost * intensity));
out[index + GlowB] = MIN2(clamp, (in[index + GlowB] * boost * intensity));
out[index + GlowA] = MIN2(clamp, (in[index + GlowA] * boost * intensity));
}
else {
out[index+GlowR]=0;
out[index+GlowG]=0;
out[index+GlowB]=0;
out[index+GlowA]=0;
out[index + GlowR] = 0;
out[index + GlowG] = 0;
out[index + GlowB] = 0;
out[index + GlowA] = 0;
}
}
}
@@ -2621,7 +2617,7 @@ static void init_glow_effect(Sequence *seq)
{
GlowVars *glow;
if (seq->effectdata)MEM_freeN(seq->effectdata);
if (seq->effectdata) MEM_freeN(seq->effectdata);
seq->effectdata = MEM_callocN(sizeof(struct GlowVars), "glowvars");
glow = (GlowVars *)seq->effectdata;
@@ -2640,7 +2636,7 @@ static int num_inputs_glow(void)
static void free_glow_effect(Sequence *seq)
{
if (seq->effectdata)MEM_freeN(seq->effectdata);
if (seq->effectdata) MEM_freeN(seq->effectdata);
seq->effectdata = NULL;
}
@@ -2651,56 +2647,56 @@ static void copy_glow_effect(Sequence *dst, Sequence *src)
//void do_glow_effect(Cast *cast, float facf0, float facf1, int xo, int yo, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *outbuf, ImBuf *use)
static void do_glow_effect_byte(Sequence *seq, int render_size, float facf0, float UNUSED(facf1),
int x, int y, char *rect1,
char *UNUSED(rect2), char *out)
int x, int y, char *rect1,
char *UNUSED(rect2), char *out)
{
unsigned char *outbuf=(unsigned char *)out;
unsigned char *inbuf=(unsigned char *)rect1;
unsigned char *outbuf = (unsigned char *)out;
unsigned char *inbuf = (unsigned char *)rect1;
GlowVars *glow = (GlowVars *)seq->effectdata;
RVIsolateHighlights_byte(inbuf, outbuf, x, y, glow->fMini*765, glow->fBoost * facf0, glow->fClamp);
RVBlurBitmap2_byte (outbuf, x, y, glow->dDist * (render_size / 100.0f), glow->dQuality);
RVIsolateHighlights_byte(inbuf, outbuf, x, y, glow->fMini * 765, glow->fBoost * facf0, glow->fClamp);
RVBlurBitmap2_byte(outbuf, x, y, glow->dDist * (render_size / 100.0f), glow->dQuality);
if (!glow->bNoComp)
RVAddBitmaps_byte (inbuf, outbuf, outbuf, x, y);
RVAddBitmaps_byte(inbuf, outbuf, outbuf, x, y);
}
static void do_glow_effect_float(Sequence *seq, int render_size, float facf0, float UNUSED(facf1),
int x, int y,
float *rect1, float *UNUSED(rect2), float *out)
int x, int y,
float *rect1, float *UNUSED(rect2), float *out)
{
float *outbuf = out;
float *inbuf = rect1;
GlowVars *glow = (GlowVars *)seq->effectdata;
RVIsolateHighlights_float(inbuf, outbuf, x, y, glow->fMini*3.0f, glow->fBoost * facf0, glow->fClamp);
RVBlurBitmap2_float (outbuf, x, y, glow->dDist * (render_size / 100.0f), glow->dQuality);
RVIsolateHighlights_float(inbuf, outbuf, x, y, glow->fMini * 3.0f, glow->fBoost * facf0, glow->fClamp);
RVBlurBitmap2_float(outbuf, x, y, glow->dDist * (render_size / 100.0f), glow->dQuality);
if (!glow->bNoComp)
RVAddBitmaps_float (inbuf, outbuf, outbuf, x, y);
RVAddBitmaps_float(inbuf, outbuf, outbuf, x, y);
}
static struct ImBuf * do_glow_effect(
SeqRenderData context, Sequence *seq, float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
static struct ImBuf *do_glow_effect(
SeqRenderData context, Sequence *seq, float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
{
struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
int render_size = 100*context.rectx/context.scene->r.xsch;
int render_size = 100 * context.rectx / context.scene->r.xsch;
if (out->rect_float) {
do_glow_effect_float(seq, render_size,
facf0, facf1,
context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
facf0, facf1,
context.rectx, context.recty,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
}
else {
do_glow_effect_byte(seq, render_size,
facf0, facf1,
context.rectx, context.recty,
(char*) ibuf1->rect, (char*) ibuf2->rect,
(char*) out->rect);
facf0, facf1,
context.rectx, context.recty,
(char *) ibuf1->rect, (char *) ibuf2->rect,
(char *) out->rect);
}
return out;
@@ -2714,7 +2710,7 @@ static void init_solid_color(Sequence *seq)
{
SolidColorVars *cv;
if (seq->effectdata)MEM_freeN(seq->effectdata);
if (seq->effectdata) MEM_freeN(seq->effectdata);
seq->effectdata = MEM_callocN(sizeof(struct SolidColorVars), "solidcolor");
cv = (SolidColorVars *)seq->effectdata;
@@ -2728,7 +2724,7 @@ static int num_inputs_color(void)
static void free_solid_color(Sequence *seq)
{
if (seq->effectdata)MEM_freeN(seq->effectdata);
if (seq->effectdata) MEM_freeN(seq->effectdata);
seq->effectdata = NULL;
}
@@ -2738,18 +2734,17 @@ static void copy_solid_color(Sequence *dst, Sequence *src)
}
static int early_out_color(struct Sequence *UNUSED(seq),
float UNUSED(facf0), float UNUSED(facf1))
float UNUSED(facf0), float UNUSED(facf1))
{
return -1;
}
static struct ImBuf * do_solid_color(
SeqRenderData context, Sequence *seq, float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3)
{
struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
static struct ImBuf *do_solid_color(
SeqRenderData context, Sequence *seq, float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3){
struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
SolidColorVars *cv = (SolidColorVars *)seq->effectdata;
@@ -2772,20 +2767,20 @@ static struct ImBuf * do_solid_color(
rect = (unsigned char *)out->rect;
for (y=0; y<out->y; y++) {
for (x=0; x<out->x; x++, rect+=4) {
rect[0]= col0[0];
rect[1]= col0[1];
rect[2]= col0[2];
rect[3]= 255;
for (y = 0; y < out->y; y++) {
for (x = 0; x < out->x; x++, rect += 4) {
rect[0] = col0[0];
rect[1] = col0[1];
rect[2] = col0[2];
rect[3] = 255;
}
y++;
if (y<out->y) {
for (x=0; x<out->x; x++, rect+=4) {
rect[0]= col1[0];
rect[1]= col1[1];
rect[2]= col1[2];
rect[3]= 255;
if (y < out->y) {
for (x = 0; x < out->x; x++, rect += 4) {
rect[0] = col1[0];
rect[1] = col1[1];
rect[2] = col1[2];
rect[3] = 255;
}
}
}
@@ -2805,20 +2800,20 @@ static struct ImBuf * do_solid_color(
rect_float = out->rect_float;
for (y=0; y<out->y; y++) {
for (x=0; x<out->x; x++, rect_float+=4) {
rect_float[0]= col0[0];
rect_float[1]= col0[1];
rect_float[2]= col0[2];
rect_float[3]= 1.0;
for (y = 0; y < out->y; y++) {
for (x = 0; x < out->x; x++, rect_float += 4) {
rect_float[0] = col0[0];
rect_float[1] = col0[1];
rect_float[2] = col0[2];
rect_float[3] = 1.0;
}
y++;
if (y<out->y) {
for (x=0; x<out->x; x++, rect_float+=4) {
rect_float[0]= col1[0];
rect_float[1]= col1[1];
rect_float[2]= col1[2];
rect_float[3]= 1.0;
if (y < out->y) {
for (x = 0; x < out->x; x++, rect_float += 4) {
rect_float[0] = col1[0];
rect_float[1] = col1[1];
rect_float[2] = col1[2];
rect_float[3] = 1.0;
}
}
}
@@ -2841,16 +2836,15 @@ static int early_out_multicam(struct Sequence *UNUSED(seq), float UNUSED(facf0),
return -1;
}
static struct ImBuf * do_multicam(
SeqRenderData context, Sequence *seq, float cfra,
float UNUSED(facf0), float UNUSED(facf1),
struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2),
struct ImBuf *UNUSED(ibuf3))
{
struct ImBuf * i;
struct ImBuf * out;
Editing * ed;
ListBase * seqbasep;
static struct ImBuf *do_multicam(
SeqRenderData context, Sequence *seq, float cfra,
float UNUSED(facf0), float UNUSED(facf1),
struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2),
struct ImBuf *UNUSED(ibuf3)){
struct ImBuf *i;
struct ImBuf *out;
Editing *ed;
ListBase *seqbasep;
if (seq->multicam_source == 0 || seq->multicam_source >= seq->machine) {
return NULL;
@@ -2896,12 +2890,11 @@ static int early_out_adjustment(struct Sequence *UNUSED(seq), float UNUSED(facf0
return -1;
}
static struct ImBuf * do_adjustment_impl(SeqRenderData context, Sequence * seq,
float cfra)
{
Editing * ed;
ListBase * seqbasep;
struct ImBuf * i= NULL;
static struct ImBuf *do_adjustment_impl(SeqRenderData context, Sequence *seq,
float cfra){
Editing *ed;
ListBase *seqbasep;
struct ImBuf *i = NULL;
ed = context.scene->ed;
@@ -2909,7 +2902,7 @@ static struct ImBuf * do_adjustment_impl(SeqRenderData context, Sequence * seq,
if (seq->machine > 0) {
i = give_ibuf_seqbase(context, cfra,
seq->machine - 1, seqbasep);
seq->machine - 1, seqbasep);
}
/* found nothing? so let's work the way up the metastrip stack, so
@@ -2918,7 +2911,7 @@ static struct ImBuf * do_adjustment_impl(SeqRenderData context, Sequence * seq,
*/
if (!i) {
Sequence * meta;
Sequence *meta;
meta = seq_metastrip(&ed->seqbase, NULL, seq);
@@ -2930,15 +2923,14 @@ static struct ImBuf * do_adjustment_impl(SeqRenderData context, Sequence * seq,
return i;
}
static struct ImBuf * do_adjustment(
SeqRenderData context, Sequence *seq, float cfra,
float UNUSED(facf0), float UNUSED(facf1),
struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2),
struct ImBuf *UNUSED(ibuf3))
{
struct ImBuf * i = NULL;
struct ImBuf * out;
Editing * ed;
static struct ImBuf *do_adjustment(
SeqRenderData context, Sequence *seq, float cfra,
float UNUSED(facf0), float UNUSED(facf1),
struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2),
struct ImBuf *UNUSED(ibuf3)){
struct ImBuf *i = NULL;
struct ImBuf *out;
Editing *ed;
ed = context.scene->ed;
@@ -2964,11 +2956,11 @@ static struct ImBuf * do_adjustment(
* ********************************************************************** */
static void init_speed_effect(Sequence *seq)
{
SpeedControlVars * v;
SpeedControlVars *v;
if (seq->effectdata) MEM_freeN(seq->effectdata);
seq->effectdata = MEM_callocN(sizeof(struct SpeedControlVars),
"speedcontrolvars");
"speedcontrolvars");
v = (SpeedControlVars *)seq->effectdata;
v->globalSpeed = 1.0;
@@ -2977,9 +2969,9 @@ static void init_speed_effect(Sequence *seq)
v->length = 0;
}
static void load_speed_effect(Sequence * seq)
static void load_speed_effect(Sequence *seq)
{
SpeedControlVars * v = (SpeedControlVars *)seq->effectdata;
SpeedControlVars *v = (SpeedControlVars *)seq->effectdata;
v->frameMap = NULL;
v->length = 0;
@@ -2992,7 +2984,7 @@ static int num_inputs_speed(void)
static void free_speed_effect(Sequence *seq)
{
SpeedControlVars * v = (SpeedControlVars *)seq->effectdata;
SpeedControlVars *v = (SpeedControlVars *)seq->effectdata;
if (v->frameMap) MEM_freeN(v->frameMap);
if (seq->effectdata) MEM_freeN(seq->effectdata);
seq->effectdata = NULL;
@@ -3000,7 +2992,7 @@ static void free_speed_effect(Sequence *seq)
static void copy_speed_effect(Sequence *dst, Sequence *src)
{
SpeedControlVars * v;
SpeedControlVars *v;
dst->effectdata = MEM_dupallocN(src->effectdata);
v = (SpeedControlVars *)dst->effectdata;
v->frameMap = NULL;
@@ -3008,15 +3000,15 @@ static void copy_speed_effect(Sequence *dst, Sequence *src)
}
static int early_out_speed(struct Sequence *UNUSED(seq),
float UNUSED(facf0), float UNUSED(facf1))
float UNUSED(facf0), float UNUSED(facf1))
{
return 1;
}
static void store_icu_yrange_speed(struct Sequence * seq,
short UNUSED(adrcode), float * ymin, float * ymax)
static void store_icu_yrange_speed(struct Sequence *seq,
short UNUSED(adrcode), float *ymin, float *ymax)
{
SpeedControlVars * v = (SpeedControlVars *)seq->effectdata;
SpeedControlVars *v = (SpeedControlVars *)seq->effectdata;
/* if not already done, load / initialize data */
get_sequence_effect(seq);
@@ -3036,32 +3028,31 @@ static void store_icu_yrange_speed(struct Sequence * seq,
}
}
}
void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
void sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, int force)
{
int cfra;
float fallback_fac = 1.0f;
SpeedControlVars * v = (SpeedControlVars *)seq->effectdata;
FCurve *fcu= NULL;
SpeedControlVars *v = (SpeedControlVars *)seq->effectdata;
FCurve *fcu = NULL;
int flags = v->flags;
/* if not already done, load / initialize data */
get_sequence_effect(seq);
if ( (force == FALSE) &&
(seq->len == v->length) &&
(v->frameMap != NULL)
) {
if ((force == FALSE) &&
(seq->len == v->length) &&
(v->frameMap != NULL))
{
return;
}
if ( (seq->seq1 == NULL) ||
(seq->len < 1)
) { /* make coverity happy and check for (CID 598) input strip ... */
if ((seq->seq1 == NULL) || (seq->len < 1)) {
/* make coverity happy and check for (CID 598) input strip ... */
return;
}
/* XXX - new in 2.5x. should we use the animation system this way?
* The fcurve is needed because many frames need evaluating at once - campbell */
fcu= id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "speed_factor", 0, NULL);
fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "speed_factor", 0, NULL);
if (!v->frameMap || v->length != seq->len) {
@@ -3070,7 +3061,7 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
v->length = seq->len;
v->frameMap = MEM_callocN(sizeof(float) * v->length,
"speedcontrol frameMap");
"speedcontrol frameMap");
}
fallback_fac = 1.0;
@@ -3080,7 +3071,7 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
(seq->seq1->len != 0))
{
fallback_fac = (float) seq->seq1->len /
(float) (seq->seq1->enddisp - seq->seq1->start);
(float) (seq->seq1->enddisp - seq->seq1->start);
flags = SEQ_SPEED_INTEGRATE;
fcu = NULL;
}
@@ -3179,13 +3170,13 @@ static int num_inputs_default(void)
}
static int early_out_noop(struct Sequence *UNUSED(seq),
float UNUSED(facf0), float UNUSED(facf1))
float UNUSED(facf0), float UNUSED(facf1))
{
return 0;
}
static int early_out_fade(struct Sequence *UNUSED(seq),
float facf0, float facf1)
float facf0, float facf1)
{
if (facf0 == 0.0f && facf1 == 0.0f) {
return 1;
@@ -3197,7 +3188,7 @@ static int early_out_fade(struct Sequence *UNUSED(seq),
}
static int early_out_mul_input2(struct Sequence *UNUSED(seq),
float facf0, float facf1)
float facf0, float facf1)
{
if (facf0 == 0.0f && facf1 == 0.0f) {
return 1;
@@ -3205,20 +3196,20 @@ static int early_out_mul_input2(struct Sequence *UNUSED(seq),
return 0;
}
static void store_icu_yrange_noop(struct Sequence * UNUSED(seq),
short UNUSED(adrcode), float *UNUSED(ymin), float *UNUSED(ymax))
static void store_icu_yrange_noop(struct Sequence *UNUSED(seq),
short UNUSED(adrcode), float *UNUSED(ymin), float *UNUSED(ymax))
{
/* defaults are fine */
}
static void get_default_fac_noop(struct Sequence *UNUSED(seq), float UNUSED(cfra),
float * facf0, float * facf1)
float *facf0, float *facf1)
{
*facf0 = *facf1 = 1.0;
}
static void get_default_fac_fade(struct Sequence *seq, float cfra,
float * facf0, float * facf1)
float *facf0, float *facf1)
{
*facf0 = (float)(cfra - seq->startdisp);
*facf1 = (float)(*facf0 + 0.5f);
@@ -3226,45 +3217,43 @@ static void get_default_fac_fade(struct Sequence *seq, float cfra,
*facf1 /= seq->len;
}
static struct ImBuf * do_overdrop_effect(SeqRenderData context,
Sequence *UNUSED(seq),
float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf * ibuf1,
struct ImBuf * ibuf2,
struct ImBuf * ibuf3)
{
struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
static struct ImBuf *do_overdrop_effect(SeqRenderData context,
Sequence *UNUSED(seq),
float UNUSED(cfra),
float facf0, float facf1,
struct ImBuf *ibuf1,
struct ImBuf *ibuf2,
struct ImBuf *ibuf3){
struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3);
int x = context.rectx;
int y = context.recty;
if (out->rect_float) {
do_drop_effect_float(
facf0, facf1, x, y,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
facf0, facf1, x, y,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
do_alphaover_effect_float(
facf0, facf1, x, y,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
facf0, facf1, x, y,
ibuf1->rect_float, ibuf2->rect_float,
out->rect_float);
}
else {
do_drop_effect_byte(
facf0, facf1, x, y,
(char*) ibuf1->rect,
(char*) ibuf2->rect,
(char*) out->rect);
facf0, facf1, x, y,
(char *) ibuf1->rect,
(char *) ibuf2->rect,
(char *) out->rect);
do_alphaover_effect_byte(
facf0, facf1, x, y,
(char*) ibuf1->rect, (char*) ibuf2->rect,
(char*) out->rect);
facf0, facf1, x, y,
(char *) ibuf1->rect, (char *) ibuf2->rect,
(char *) out->rect);
}
return out;
}
static struct SeqEffectHandle get_sequence_effect_impl(int seq_type)
{
static struct SeqEffectHandle get_sequence_effect_impl(int seq_type){
struct SeqEffectHandle rval;
int sequence_type = seq_type;
@@ -3280,112 +3269,112 @@ static struct SeqEffectHandle get_sequence_effect_impl(int seq_type)
rval.copy = NULL;
switch (sequence_type) {
case SEQ_CROSS:
rval.execute = do_cross_effect;
rval.early_out = early_out_fade;
rval.get_default_fac = get_default_fac_fade;
break;
case SEQ_GAMCROSS:
rval.init = init_gammacross;
rval.load = load_gammacross;
rval.free = free_gammacross;
rval.early_out = early_out_fade;
rval.get_default_fac = get_default_fac_fade;
rval.execute = do_gammacross_effect;
break;
case SEQ_ADD:
rval.execute = do_add_effect;
rval.early_out = early_out_mul_input2;
break;
case SEQ_SUB:
rval.execute = do_sub_effect;
rval.early_out = early_out_mul_input2;
break;
case SEQ_MUL:
rval.execute = do_mul_effect;
rval.early_out = early_out_mul_input2;
break;
case SEQ_ALPHAOVER:
rval.init = init_alpha_over_or_under;
rval.execute = do_alphaover_effect;
break;
case SEQ_OVERDROP:
rval.execute = do_overdrop_effect;
break;
case SEQ_ALPHAUNDER:
rval.init = init_alpha_over_or_under;
rval.execute = do_alphaunder_effect;
break;
case SEQ_WIPE:
rval.init = init_wipe_effect;
rval.num_inputs = num_inputs_wipe;
rval.free = free_wipe_effect;
rval.copy = copy_wipe_effect;
rval.early_out = early_out_fade;
rval.get_default_fac = get_default_fac_fade;
rval.execute = do_wipe_effect;
break;
case SEQ_GLOW:
rval.init = init_glow_effect;
rval.num_inputs = num_inputs_glow;
rval.free = free_glow_effect;
rval.copy = copy_glow_effect;
rval.execute = do_glow_effect;
break;
case SEQ_TRANSFORM:
rval.init = init_transform_effect;
rval.num_inputs = num_inputs_transform;
rval.free = free_transform_effect;
rval.copy = copy_transform_effect;
rval.execute = do_transform_effect;
break;
case SEQ_SPEED:
rval.init = init_speed_effect;
rval.num_inputs = num_inputs_speed;
rval.load = load_speed_effect;
rval.free = free_speed_effect;
rval.copy = copy_speed_effect;
rval.execute = do_cross_effect;
rval.early_out = early_out_speed;
rval.store_icu_yrange = store_icu_yrange_speed;
break;
case SEQ_COLOR:
rval.init = init_solid_color;
rval.num_inputs = num_inputs_color;
rval.early_out = early_out_color;
rval.free = free_solid_color;
rval.copy = copy_solid_color;
rval.execute = do_solid_color;
break;
case SEQ_PLUGIN:
rval.init_plugin = init_plugin;
rval.num_inputs = num_inputs_plugin;
rval.load = load_plugin;
rval.free = free_plugin;
rval.copy = copy_plugin;
rval.execute = do_plugin_effect;
rval.early_out = do_plugin_early_out;
rval.get_default_fac = get_default_fac_fade;
break;
case SEQ_MULTICAM:
rval.num_inputs = num_inputs_multicam;
rval.early_out = early_out_multicam;
rval.execute = do_multicam;
break;
case SEQ_ADJUSTMENT:
rval.num_inputs = num_inputs_adjustment;
rval.early_out = early_out_adjustment;
rval.execute = do_adjustment;
break;
case SEQ_CROSS:
rval.execute = do_cross_effect;
rval.early_out = early_out_fade;
rval.get_default_fac = get_default_fac_fade;
break;
case SEQ_GAMCROSS:
rval.init = init_gammacross;
rval.load = load_gammacross;
rval.free = free_gammacross;
rval.early_out = early_out_fade;
rval.get_default_fac = get_default_fac_fade;
rval.execute = do_gammacross_effect;
break;
case SEQ_ADD:
rval.execute = do_add_effect;
rval.early_out = early_out_mul_input2;
break;
case SEQ_SUB:
rval.execute = do_sub_effect;
rval.early_out = early_out_mul_input2;
break;
case SEQ_MUL:
rval.execute = do_mul_effect;
rval.early_out = early_out_mul_input2;
break;
case SEQ_ALPHAOVER:
rval.init = init_alpha_over_or_under;
rval.execute = do_alphaover_effect;
break;
case SEQ_OVERDROP:
rval.execute = do_overdrop_effect;
break;
case SEQ_ALPHAUNDER:
rval.init = init_alpha_over_or_under;
rval.execute = do_alphaunder_effect;
break;
case SEQ_WIPE:
rval.init = init_wipe_effect;
rval.num_inputs = num_inputs_wipe;
rval.free = free_wipe_effect;
rval.copy = copy_wipe_effect;
rval.early_out = early_out_fade;
rval.get_default_fac = get_default_fac_fade;
rval.execute = do_wipe_effect;
break;
case SEQ_GLOW:
rval.init = init_glow_effect;
rval.num_inputs = num_inputs_glow;
rval.free = free_glow_effect;
rval.copy = copy_glow_effect;
rval.execute = do_glow_effect;
break;
case SEQ_TRANSFORM:
rval.init = init_transform_effect;
rval.num_inputs = num_inputs_transform;
rval.free = free_transform_effect;
rval.copy = copy_transform_effect;
rval.execute = do_transform_effect;
break;
case SEQ_SPEED:
rval.init = init_speed_effect;
rval.num_inputs = num_inputs_speed;
rval.load = load_speed_effect;
rval.free = free_speed_effect;
rval.copy = copy_speed_effect;
rval.execute = do_cross_effect;
rval.early_out = early_out_speed;
rval.store_icu_yrange = store_icu_yrange_speed;
break;
case SEQ_COLOR:
rval.init = init_solid_color;
rval.num_inputs = num_inputs_color;
rval.early_out = early_out_color;
rval.free = free_solid_color;
rval.copy = copy_solid_color;
rval.execute = do_solid_color;
break;
case SEQ_PLUGIN:
rval.init_plugin = init_plugin;
rval.num_inputs = num_inputs_plugin;
rval.load = load_plugin;
rval.free = free_plugin;
rval.copy = copy_plugin;
rval.execute = do_plugin_effect;
rval.early_out = do_plugin_early_out;
rval.get_default_fac = get_default_fac_fade;
break;
case SEQ_MULTICAM:
rval.num_inputs = num_inputs_multicam;
rval.early_out = early_out_multicam;
rval.execute = do_multicam;
break;
case SEQ_ADJUSTMENT:
rval.num_inputs = num_inputs_adjustment;
rval.early_out = early_out_adjustment;
rval.execute = do_adjustment;
break;
}
return rval;
}
struct SeqEffectHandle get_sequence_effect(Sequence * seq)
struct SeqEffectHandle get_sequence_effect(Sequence *seq)
{
struct SeqEffectHandle rval= {NULL};
struct SeqEffectHandle rval = {NULL};
if (seq->type & SEQ_EFFECT) {
rval = get_sequence_effect_impl(seq->type);
@@ -3398,9 +3387,9 @@ struct SeqEffectHandle get_sequence_effect(Sequence * seq)
return rval;
}
struct SeqEffectHandle get_sequence_blend(Sequence * seq)
struct SeqEffectHandle get_sequence_blend(Sequence *seq)
{
struct SeqEffectHandle rval= {NULL};
struct SeqEffectHandle rval = {NULL};
if (seq->blend_mode != 0) {
rval = get_sequence_effect_impl(seq->blend_mode);