diff options
author | Thomas Dinges <blender@dingto.org> | 2012-05-29 14:21:07 +0400 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2012-05-29 14:21:07 +0400 |
commit | 16117143d8f12dac65caa8368f56a7e8af8f0db2 (patch) | |
tree | 365d68a11bc4a898a863bf8c229d8cda629d9dc7 /release/plugins/sequence | |
parent | df8880a81f5ba212c49c357294774119c16fd13e (diff) |
Massive Code cleanup:
* Remove all code for Texture and Sequencer plugin system, this never worked in 2.5x / 2.6x and is therefore not needed anymore.
* DNA structures are kept, all read/writefile code is gone.
Diffstat (limited to 'release/plugins/sequence')
-rw-r--r-- | release/plugins/sequence/Makefile | 32 | ||||
-rw-r--r-- | release/plugins/sequence/blur.c | 284 | ||||
-rw-r--r-- | release/plugins/sequence/color-correction-hsv.c | 299 | ||||
-rw-r--r-- | release/plugins/sequence/color-correction-yuv.c | 239 | ||||
-rw-r--r-- | release/plugins/sequence/dnr.c | 151 | ||||
-rw-r--r-- | release/plugins/sequence/gamma.c | 183 | ||||
-rw-r--r-- | release/plugins/sequence/scatter.c | 263 |
7 files changed, 0 insertions, 1451 deletions
diff --git a/release/plugins/sequence/Makefile b/release/plugins/sequence/Makefile deleted file mode 100644 index 2b12e62d24a..00000000000 --- a/release/plugins/sequence/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): none yet. -# -# ***** END GPL LICENSE BLOCK ***** - -all: plugins - -plugins: - @/bin/sh -c 'for i in *.c; do ../bmake $$i; done;' - -clean: - rm -rf *.o *.so diff --git a/release/plugins/sequence/blur.c b/release/plugins/sequence/blur.c deleted file mode 100644 index d33feb0bb68..00000000000 --- a/release/plugins/sequence/blur.c +++ /dev/null @@ -1,284 +0,0 @@ -/** - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include <stdio.h> -#include "plugin.h" - -/* ******************** GLOBAL VARIABLES ***************** */ - - -char name[24] = "Blur"; - -/* structure for buttons, - * butcode name default min max 0 - */ - -VarStruct varstr[] = { - LABEL, "Input: 1 strip", 0.0, 0.0, 0.0, "", - NUMSLI | FLO, "Blur", 0.5, 0.0, 10.0, "Maximum filtersize", - NUMSLI | FLO, "Gamma", 1.0, 0.4, 2.0, "Gamma correction", - TOG | INT, "Animated", 0.0, 0.0, 1.0, "For (Ipo) animated blur", - NUM | INT, "debug", 0.0, 0.0, 2.0, - "0:off 1: show primary blur buffer 2: show 2nd blur buffer", - -}; - -/* The cast struct is for input in the main doit function - Varstr and Cast must have the same variables in the same order */ - -typedef struct Cast { - int dummy; /* because of the 'label' button */ - float blur; - float gamma; - float use_ipo; - int show; -} Cast; - - -/* cfra: the current frame */ - -float cfra; - -void plugin_seq_doit(Cast *, float, float, int, int, ImBuf *, ImBuf *, ImBuf *, ImBuf *); - -/* ******************** Fixed functions ***************** */ - -int plugin_seq_getversion(void) -{ - return B_PLUGIN_VERSION; -} - -void plugin_but_changed(int but) -{ -} - -void plugin_init(void) -{ -} - -void plugin_getinfo(PluginInfo *info) -{ - info->name = name; - info->nvars = sizeof(varstr) / sizeof(VarStruct); - info->cfra = &cfra; - - info->varstr = varstr; - - info->init = plugin_init; - info->seq_doit = (SeqDoit) plugin_seq_doit; - info->callback = plugin_but_changed; -} - - -void blurbuf(struct ImBuf *ibuf, int nr, Cast *cast) -{ - /* nr = number of blurs */ - /* the ibuf->rect is replaced */ - struct ImBuf *tbuf, *ttbuf; - int i, x4; - - tbuf = dupImBuf(ibuf); - x4 = ibuf->x / 4; - - /* This doesn't seem to work... paprmh */ - if (cast->gamma != 1.0) gamwarp(tbuf, cast->gamma); - - /* reduce */ - for (i = 0; i < nr; i++) { - ttbuf = onehalf(tbuf); - if (ttbuf) { - freeImBuf(tbuf); - tbuf = ttbuf; - } - if (tbuf->x < 4 || tbuf->y < 4) break; - } - - /* enlarge */ - for (i = 0; i < nr; i++) { - ttbuf = double_x(tbuf); - if (ttbuf) { - freeImBuf(tbuf); - tbuf = ttbuf; - } - ttbuf = double_y(tbuf); - if (ttbuf) { - freeImBuf(tbuf); - tbuf = ttbuf; - } - if (tbuf->x > x4) { - scaleImBuf(tbuf, ibuf->x, ibuf->y); - break; - } - } - - /* this doesn't seem to work...paprmh*/ - if (cast->gamma != 1.0) gamwarp(tbuf, 1.0 / cast->gamma); - - if (ibuf->rect) memcpy(ibuf->rect, tbuf->rect, 4 * ibuf->x * ibuf->y); - - if (ibuf->rect_float) - memcpy(ibuf->rect_float, tbuf->rect_float, 4 * ibuf->x * ibuf->y * sizeof(float)); - - freeImBuf(tbuf); - -} - -void doblur(struct ImBuf *mbuf, float fac, Cast *cast) -{ - /* make two filtered images, like a mipmap structure - * fac is filtersize in pixels - */ - struct ImBuf *ibuf, *pbuf; - float ifac, pfac, infac; - int n, b1, b2; - char *irect, *prect, *mrect; - float *irectf, *prectf, *mrectf; - - /* which buffers ? */ - - if (fac > 7.0) fac = 7.0; - if (fac <= 1.0) return; - - pfac = 2.0; - pbuf = dupImBuf(mbuf); - n = 1; - while (pfac < fac) { - blurbuf(pbuf, n, cast); - blurbuf(pbuf, n, cast); - - n++; - pfac += 1.0; - } - - ifac = pfac; - pfac -= 1.0; - - ibuf = dupImBuf(pbuf); - blurbuf(ibuf, n, cast); - blurbuf(ibuf, n, cast); - - fac = (fac - pfac) / (ifac - pfac); - n = mbuf->x * mbuf->y; - - if (cast->show) fac = cast->show - 1; - - if (mbuf->rect_float) { - if (fac >= 1) { - memcpy(mbuf->rect_float, ibuf->rect_float, 4 * n * sizeof(float)); - } - else if (fac <= 0) { - memcpy(mbuf->rect_float, pbuf->rect_float, 4 * n * sizeof(float)); - } - else { /* interpolate */ - infac = 1 - fac; - - irectf = (float *)ibuf->rect_float; - prectf = (float *)pbuf->rect_float; - mrectf = (float *)mbuf->rect_float; - while (n--) { - mrectf[0] = irectf[0] * fac + prectf[0] * infac; - mrectf[1] = irectf[1] * fac + prectf[1] * infac; - mrectf[2] = irectf[2] * fac + prectf[2] * infac; - mrectf[3] = irectf[3] * fac + prectf[3] * infac; - mrectf += 4; - irectf += 4; - prectf += 4; - } - } - } - else if (mbuf->rect) { - b1 = (int)fac * 255.0; - if (b1 > 255) b1 = 255; - b2 = 255 - b1; - - if (b1 == 255) { - memcpy(mbuf->rect, ibuf->rect, 4 * n); - } - else if (b1 == 0) { - memcpy(mbuf->rect, pbuf->rect, 4 * n); - } - else { /* interpolate */ - irect = (char *)ibuf->rect; - prect = (char *)pbuf->rect; - mrect = (char *)mbuf->rect; - while (n--) { - mrect[0] = (irect[0] * b1 + prect[0] * b2) >> 8; - mrect[1] = (irect[1] * b1 + prect[1] * b2) >> 8; - mrect[2] = (irect[2] * b1 + prect[2] * b2) >> 8; - mrect[3] = (irect[3] * b1 + prect[3] * b2) >> 8; - mrect += 4; - irect += 4; - prect += 4; - } - } - } - - freeImBuf(ibuf); - freeImBuf(pbuf); -} - - -void plugin_seq_doit(Cast *cast, float facf0, float facf1, int x, int y, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *out, ImBuf *use) -{ - float bfacf0, bfacf1; - - if (cast->use_ipo == 0) { - bfacf0 = bfacf1 = cast->blur + 1.0; - } - else { - bfacf0 = (facf0 * 6.0) + 1.0; - bfacf1 = (facf1 * 6.0) + 1.0; - } - - if (out->rect) memcpy(out->rect, ibuf1->rect, 4 * out->x * out->y); - if (out->rect_float) memcpy(out->rect_float, ibuf1->rect_float, 4 * out->x * out->y * sizeof(float)); - -/****************I can't get this field code to work... works ok without...paprmh****************/ - - - /* it blurs interlaced, only tested with even fields */ - -/* de_interlace(out);*/ - /* otherwise scaling goes wrong */ -/* out->flags &= ~IB_fields;*/ - - doblur(out, bfacf0, cast); /*fieldA*/ - -/* if (out->rect)out->rect += out->x * out->y; - if (out->rect_float)out->rect_float += out->x * out->y; - - doblur(out, bfacf1, cast);*/ /*fieldB*/ - -/* if (out->rect)out->rect -= out->x * out->y; - if (out->rect_float)out->rect_float -= out->x * out->y; - out->flags |= IB_fields; - - interlace(out);*/ - -} - diff --git a/release/plugins/sequence/color-correction-hsv.c b/release/plugins/sequence/color-correction-hsv.c deleted file mode 100644 index f77acd2ce93..00000000000 --- a/release/plugins/sequence/color-correction-hsv.c +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Color Correction Plugin (YUV Version) 0.01 - * - * Copyright (c) 2005 Peter Schlaile - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include <math.h> -#include "plugin.h" -#include <stdio.h> - -char name[] = "Color Correction"; - -VarStruct varstr[] = { - { NUMSLI | FLO, "St Y:", 0.0, -1.0, 1.0, "Setup Y"}, - { NUMSLI | FLO, "Gn Y:", 1.0, 0.0, 10.0, "Gain Y"}, - { NUMSLI | FLO, "Ga Y:", 1.0, 0.0, 10.0, "Gamma Y"}, - - { NUMSLI | FLO, "Lo S:", 1.0, 0.0, 10.0, "Saturation Shadows"}, - { NUMSLI | FLO, "Md S:", 1.0, 0.0, 10.0, "Saturation Midtones"}, - { NUMSLI | FLO, "Hi S:", 1.0, 0.0, 10.0, "Saturation Highlights"}, - - { NUMSLI | FLO, "MA S:", 1.0, 0.0, 10.0, "Master Saturation"}, - - { NUMSLI | FLO, "Lo T:", 0.25, 0.0, 1.0, - "Saturation Shadow Thres"}, - { NUMSLI | FLO, "Hi T:", 0.75, 0.0, 1.0, - "Saturation Highlights Thres"}, - { TOG | INT, "Debug", 0.0, 0.0, 1.0, - "Show curves as overlay"}, -}; - -typedef struct Cast { - float setup_y; - float gain_y; - float gamma_y; - float sat_shadows; - float sat_midtones; - float sat_highlights; - - float master_sat; - float lo_thres; - float hi_thres; - int debug; -} Cast; - -float cfra; - -void plugin_seq_doit(Cast *, float, float, int, int, ImBuf *, ImBuf *, ImBuf *, ImBuf *); - -int plugin_seq_getversion(void) -{ - return B_PLUGIN_VERSION; -} -void plugin_but_changed(int but) {} -void plugin_init() {} - -void plugin_getinfo(PluginInfo *info) -{ - info->name = name; - info->nvars = sizeof(varstr) / sizeof(VarStruct); - info->cfra = &cfra; - - info->varstr = varstr; - - info->init = plugin_init; - info->seq_doit = (SeqDoit) plugin_seq_doit; - info->callback = plugin_but_changed; -} - -static void hsv_to_rgb(double h, double s, double v, - double *r, double *g, double *b) -{ - int i; - double f, w, q, t; - - if (s == 0.0) - s = 0.000001; - - if (h == -1.0) - { - *r = v; - *g = v; - *b = v; - } - else { - if (h == 360.0) - h = 0.0; - h = h / 60.0; - i = (int) h; - f = h - i; - w = v * (1.0 - s); - q = v * (1.0 - (s * f)); - t = v * (1.0 - (s * (1.0 - f))); - - switch (i) - { - case 0: - *r = v; - *g = t; - *b = w; - break; - case 1: - *r = q; - *g = v; - *b = w; - break; - case 2: - *r = w; - *g = v; - *b = t; - break; - case 3: - *r = w; - *g = q; - *b = v; - break; - case 4: - *r = t; - *g = w; - *b = v; - break; - case 5: - *r = v; - *g = w; - *b = q; - break; - } - } -} - -static void rgb_to_hsv(double r, double g, double b, - double *h, double *s, double *v) -{ - double max, min, delta; - - max = r; - if (g > max) - max = g; - if (b > max) - max = b; - - min = r; - if (g < min) - min = g; - if (b < min) - min = b; - - *v = max; - - if (max != 0.0) - *s = (max - min) / max; - else - *s = 0.0; - - if (*s == 0.0) - *h = -1.0; - else { - delta = max - min; - - if (r == max) - *h = (g - b) / delta; - else if (g == max) - *h = 2.0 + (b - r) / delta; - else if (b == max) - *h = 4.0 + (r - g) / delta; - - *h = *h * 60.0; - - if (*h < 0.0) - *h = *h + 360; - } -} - -void plugin_seq_doit(Cast *cast, float facf0, float facf1, int width, - int height, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *out, ImBuf *use) -{ - char *dest, *src1; - int x, y, c; - double gamma_table[256]; - double uv_table[256]; - float *destf = out->rect_float; - float *src1f; - - if (!ibuf1) return; - - dest = (char *) out->rect; - src1 = (char *) ibuf1->rect; - src1f = ibuf1->rect_float; - - for (y = 0; y < 256; y++) { - float v = 1.0 * y / 255; - v += cast->setup_y; - v *= cast->gain_y; - v = pow(v, cast->gamma_y); - if (v > 1.0) { - v = 1.0; - } - else if (v < 0.0) { - v = 0.0; - } - gamma_table[y] = v * 255; - } - - for (y = 0; y < 256; y++) { - float v = 1.0; - v *= cast->master_sat; - if (y < cast->lo_thres * 255) { - v *= cast->sat_shadows; - } - else if (y > cast->hi_thres * 255) { - v *= cast->sat_highlights; - } - else { - v *= cast->sat_midtones; - } - uv_table[y] = v; - } - - - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) { - double h, s, v, r, g, b; - double fac; - - if (ibuf1->rect_float) rgb_to_hsv(src1f[0], src1f[1], - src1f[2], &h, &s, &v); - else rgb_to_hsv((double) src1[0] / 255.0, - (double) src1[1] / 255.0, - (double) src1[2] / 255.0, - &h, &s, &v); - v = gamma_table[(int) (v * 255.0)] / 255.0; - - fac = uv_table[(int) (255.0 * v)]; - - s *= fac; - if (s >= 1.0) { - s = 1.0; - } - hsv_to_rgb(h, s, v, &r, &g, &b); - - if (out->rect_float) { - destf[0] = r; - destf[1] = g; - destf[2] = b; - destf = destf + 4; - src1f += 4; - } - else { - dest[0] = r * 255.0; - dest[1] = g * 255.0; - dest[2] = b * 255.0; - dest += 4; - } - - src1 += 4; - } - } - - if (cast->debug) { - dest = (char *) out->rect; - for (c = 0; c < 10; c++) { - x = 0; - for (y = 0; y < 256; y++) { - char val = gamma_table[y]; - while (x < y * width / 255) { - *dest++ = val; - *dest++ = val; - *dest++ = val; - dest++; - x++; - } - } - } - for (c = 0; c < 10; c++) { - x = 0; - for (y = 0; y < 256; y++) { - char val = uv_table[y] * 255.0 / 10.0; - while (x < y * width / 255) { - *dest++ = val; - *dest++ = val; - *dest++ = val; - dest++; - x++; - } - } - } - } -} diff --git a/release/plugins/sequence/color-correction-yuv.c b/release/plugins/sequence/color-correction-yuv.c deleted file mode 100644 index c0c5d048b8f..00000000000 --- a/release/plugins/sequence/color-correction-yuv.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Color Correction Plugin (YUV Version) 0.01 - * - * Copyright (c) 2005 Peter Schlaile - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include <math.h> -#include "plugin.h" -#include <stdio.h> - -char name[]= "Color Correction"; - -VarStruct varstr[]= { - { NUMSLI|FLO, "St Y:", 0.0, -1.0, 1.0, "Setup Y"}, - { NUMSLI|FLO, "Gn Y:", 1.0, 0.0, 10.0,"Gain Y"}, - { NUMSLI|FLO, "Ga Y:", 1.0, 0.0, 10.0, "Gamma Y"}, - - { NUMSLI|FLO, "Lo S:", 1.0, 0.0, 10.0,"Saturation Shadows"}, - { NUMSLI|FLO, "Md S:", 1.0, 0.0, 10.0,"Saturation Midtones"}, - { NUMSLI|FLO, "Hi S:", 1.0, 0.0, 10.0,"Saturation Highlights"}, - - { NUMSLI|FLO, "MA S:", 1.0, 0.0, 10.0,"Master Saturation"}, - { NUMSLI|FLO, "Lo T:", 0.25, 0.0, 1.0, - "Saturation Shadow Thres"}, - { NUMSLI|FLO, "Hi T:", 0.75, 0.0, 1.0, - "Saturation Highlights Thres"}, - { TOG|INT, "Debug", 0.0, 0.0, 1.0, - "Show curves as overlay"}, -}; - -typedef struct Cast { - float setup_y; - float gain_y; - float gamma_y; - - float sat_shadows; - float sat_midtones; - float sat_highlights; - - float master_sat; - float lo_thres; - float hi_thres; - int debug; -} Cast; - -float cfra; - -void plugin_seq_doit(Cast *, float, float, int, int, ImBuf *, ImBuf *, ImBuf *, ImBuf *); - -int plugin_seq_getversion(void) { return B_PLUGIN_VERSION;} -void plugin_but_changed(int but) {} -void plugin_init() {} - -void plugin_getinfo(PluginInfo *info) -{ - info->name= name; - info->nvars= sizeof(varstr)/sizeof(VarStruct); - info->cfra= &cfra; - - info->varstr= varstr; - - info->init= plugin_init; - info->seq_doit= (SeqDoit) plugin_seq_doit; - info->callback= plugin_but_changed; -} - -static void rgb_to_yuv(float rgb[3], float yuv[3]) -{ - yuv[0]= 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2]; - yuv[1]= 0.492*(rgb[2] - yuv[0]); - yuv[2]= 0.877*(rgb[0] - yuv[0]); - - /* Normalize */ - yuv[1] /= 0.436; - yuv[2] /= 0.615; -} - -static void yuv_to_rgb(float yuv[3], float rgb[3]) -{ - yuv[1] *= 0.436; - yuv[2] *= 0.615; - - rgb[0] = yuv[2]/0.877 + yuv[0]; - rgb[2] = yuv[1]/0.492 + yuv[0]; - rgb[1] = (yuv[0] - 0.299*rgb[0] - 0.114*rgb[2]) / 0.587; - if (rgb[0] > 1.0) { - rgb[0] = 1.0; - } - if (rgb[0] < 0.0) { - rgb[0] = 0.0; - } - if (rgb[1] > 1.0) { - rgb[1] = 1.0; - } - if (rgb[1] < 0.0) { - rgb[1] = 0.0; - } - if (rgb[2] > 1.0) { - rgb[2] = 1.0; - } - if (rgb[2] < 0.0) { - rgb[2] = 0.0; - } -} - -void plugin_seq_doit(Cast *cast, float facf0, float facf1, int width, - int height, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *out, ImBuf *use) { - char *dest, *src1, *src2; - int x, y, c; - float rgb[3]; - float yuv[3]; - float gamma_table[256]; - float uv_table[256]; - float *destf = out->rect_float; - float *src1f; - - if (!ibuf1) return; - - dest= (char *) out->rect; - src1= (char *) ibuf1->rect; - src1f= ibuf1->rect_float; - - for (y = 0; y < 256; y++) { - float v = 1.0 * y / 255; - v += cast->setup_y; - v *= cast->gain_y; - v = pow(v, cast->gamma_y); - if ( v > 1.0) { - v = 1.0; - } else if (v < 0.0) { - v = 0.0; - } - gamma_table[y] = v * 255; - } - - for (y = 0; y < 256; y++) { - float v = 1.0; - v *= cast->master_sat; - if (y < cast->lo_thres * 255) { - v *= cast->sat_shadows; - } else if (y > cast->hi_thres * 255) { - v *= cast->sat_highlights; - } else { - v *= cast->sat_midtones; - } - uv_table[y] = v; - } - - - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) { - float fac; - if (out->rect_float) { - rgb[0]= (float)src1f[0]/255.0; - rgb[1]= (float)src1f[1]/255.0; - rgb[2]= (float)src1f[2]/255.0; - } else { - rgb[0]= (float)src1[0]/255.0; - rgb[1]= (float)src1[1]/255.0; - rgb[2]= (float)src1[2]/255.0; - } - rgb_to_yuv(rgb, yuv); - - yuv[0] = gamma_table[(int) (yuv[0] * 255.0)] / 255.0; - fac = uv_table[(int) (255.0 * yuv[0])]; - - yuv[1] = yuv[1] * fac; - yuv[2] = yuv[2] * fac; - if (yuv[1] > 1.0) { - yuv[1] = 1.0; - } - if (yuv[1] < -1.0) { - yuv[1] = -1.0; - } - if (yuv[2] > 1.0) { - yuv[2] = 1.0; - } - if (yuv[2] < -1.0) { - yuv[2] = -1.0; - } - yuv_to_rgb(yuv, rgb); - - if (out->rect_float) { - *destf++ = rgb[0]; - *destf++ = rgb[1]; - *destf++ = rgb[2]; - destf++; - src1f += 4; - } else { - *dest++ = rgb[0]*255.0; - *dest++ = rgb[1]*255.0; - *dest++ = rgb[2]*255.0; - dest++; - src1 += 4; - } - } - } - - if (cast->debug) { - dest= (char *) out->rect; - for (c = 0; c < 10; c++) { - x = 0; - for (y = 0; y < 256; y++) { - char val = gamma_table[y]; - while (x < y * width / 255) { - *dest++ = val; - *dest++ = val; - *dest++ = val; - dest++; - x++; - } - } - } - for (c = 0; c < 10; c++) { - x = 0; - for (y = 0; y < 256; y++) { - char val = uv_table[y] * 255.0/10.0; - while (x < y * width / 255) { - *dest++ = val; - *dest++ = val; - *dest++ = val; - dest++; - x++; - } - } - } - } -} diff --git a/release/plugins/sequence/dnr.c b/release/plugins/sequence/dnr.c deleted file mode 100644 index d374c40633c..00000000000 --- a/release/plugins/sequence/dnr.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Dynamic Noise Reduction (based on the VirtualDub filter by Steven Don) - * - * Copyright (c) 2005 Peter Schlaile - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include <math.h> -#include "plugin.h" -#include <stdio.h> - -char name[]= "Dynamic Noise Reduction"; - -VarStruct varstr[]= { - { NUMSLI|INT, "Level:", 10.0, 0.0, 15.0, "Level"}, -}; - -typedef struct Cast { - int level; -} Cast; - -float cfra; -void * plugin_private_data; - -struct my_data { - unsigned char lookup_table[65536]; - int last_level; - float last_cfra; - int last_width; - int last_height; - unsigned char * last_frame; -}; - -void plugin_seq_doit(Cast *, float, float, int, int, - ImBuf *, ImBuf *, ImBuf *, ImBuf *); - -int plugin_seq_getversion(void) { return B_PLUGIN_VERSION;} - -static void precalculate(unsigned char * table, int level) -{ - int ap_, bp; - - for (ap_ = 0; ap_ < 256; ap_++) { - for (bp = 0; bp < 256; bp++) { - int ap = ap_; - int diff = ap - bp; - if (diff < 0) { - diff = -diff; - } - if (diff < level) { - if (diff > (level >> 1)) { - ap = (ap + ap + bp)/3; - } else { - ap = bp; - } - } - - *table++ = ap; - } - } -} - -void plugin_but_changed(int but) { } -void plugin_init() { } - -void * plugin_seq_alloc_private_data() -{ - struct my_data * result = (struct my_data*) calloc( - sizeof(struct my_data), 1); - result->last_cfra = -1; - return result; -} - -void plugin_seq_free_private_data(void * data) -{ - struct my_data * d = (struct my_data*) data; - if (d->last_frame) { - free(d->last_frame); - } - free(d); -} - -void plugin_getinfo(PluginInfo *info) -{ - info->name= name; - info->nvars= sizeof(varstr)/sizeof(VarStruct); - info->cfra= &cfra; - - info->varstr= varstr; - - info->init= plugin_init; - info->seq_doit= (SeqDoit) plugin_seq_doit; - info->callback= plugin_but_changed; -} - -static void doit(unsigned char * src_, unsigned char * dst_, - unsigned char * table, int width, int height) -{ - int count = width * height; - unsigned char * src = src_; - unsigned char * dst = dst_; - - while (count--) { - *dst = table[(*src++ << 8) | *dst]; dst++; - *dst = table[(*src++ << 8) | *dst]; dst++; - *dst = table[(*src++ << 8) | *dst]; dst++; - *dst++ = *src++; - } - - memcpy(src_, dst_, width * height * 4); -} - -void plugin_seq_doit(Cast *cast, float facf0, float facf1, int width, - int height, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *out, ImBuf *use) { - - struct my_data * d = (struct my_data*) plugin_private_data; - - if (!ibuf1) return; - - if (cast->level != d->last_level) { - precalculate(d->lookup_table, cast->level); - d->last_level = cast->level; - } - - if (width != d->last_width || height != d->last_height || - cfra != d->last_cfra + 1) - { - free(d->last_frame); - d->last_frame = (unsigned char*) calloc(width * height, 4); - - d->last_width = width; - d->last_height = height; - } - - memcpy(out->rect, ibuf1->rect, width * height * 4); - - doit((unsigned char*) out->rect, - d->last_frame, d->lookup_table, width, height); - - d->last_cfra = cfra; -} diff --git a/release/plugins/sequence/gamma.c b/release/plugins/sequence/gamma.c deleted file mode 100644 index db04902413d..00000000000 --- a/release/plugins/sequence/gamma.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Gamma Correction Plugin (RGB Version) 0.01 - * - * Copyright (c) 2005 Peter Schlaile - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include <math.h> -#include "plugin.h" -#include "util.h" -#include <stdio.h> - -#define alpha_epsilon 0.0001f -char name[]= "Gamma Correction"; - -VarStruct varstr[]= { - { NUMSLI|FLO, "St M:", 0.0, -1.0, 1.0, "Setup Main"}, - { NUMSLI|FLO, "Gn M:", 1.0, 0.0, 10.0,"Gain Main"}, - { NUMSLI|FLO, "Ga M:", 1.0, 0.0, 10.0, "Gamma Main"}, - - { NUMSLI|FLO, "St R:", 0.0, -1.0, 1.0, "Setup Red"}, - { NUMSLI|FLO, "Gn R:", 1.0, 0.0, 10.0,"Gain Red"}, - { NUMSLI|FLO, "Ga R:", 1.0, 0.0, 10.0, "Gamma Red"}, - - { NUMSLI|FLO, "St G:", 0.0, -1.0, 1.0, "Setup Green"}, - { NUMSLI|FLO, "Gn G:", 1.0, 0.0, 10.0,"Gain Green"}, - { NUMSLI|FLO, "Ga G:", 1.0, 0.0, 10.0, "Gamma Green"}, - - { NUMSLI|FLO, "St B:", 0.0, -1.0, 1.0, "Setup Blue"}, - { NUMSLI|FLO, "Gn B:", 1.0, 0.0, 10.0,"Gain Blue"}, - { NUMSLI|FLO, "Ga B:", 1.0, 0.0, 10.0, "Gamma Blue"}, -}; - -typedef struct Cast { - float setup_m; - float gain_m; - float gamma_m; - - float setup_r; - float gain_r; - float gamma_r; - - float setup_g; - float gain_g; - float gamma_g; - - float setup_b; - float gain_b; - float gamma_b; -} Cast; - -float cfra; - -void plugin_seq_doit(Cast *, float, float, int, int, ImBuf *, ImBuf *, ImBuf *, ImBuf *); - -int plugin_seq_getversion(void) { return B_PLUGIN_VERSION; } -void plugin_but_changed(int but) {} -void plugin_init() {} - -void plugin_getinfo(PluginInfo *info) -{ - info->name= name; - info->nvars= sizeof(varstr)/sizeof(VarStruct); - info->cfra= &cfra; - - info->varstr= varstr; - - info->init= plugin_init; - info->seq_doit= (SeqDoit) plugin_seq_doit; - info->callback= plugin_but_changed; -} - -static void make_gamma_table(float setup, float gain, float gamma, - unsigned char * table) -{ - int y; - - for (y = 0; y < 256; y++) { - float v = 1.0 * y / 255; - v += setup; - v *= gain; - v = pow(v, gamma); - if ( v > 1.0) { - v = 1.0; - } else if (v < 0.0) { - v = 0.0; - } - table[y] = v * 255; - } - -} - - -void plugin_seq_doit(Cast *cast, float facf0, float facf1, int width, - int height, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *out, ImBuf *use) { - if (!out->rect_float) - { - unsigned char *dest, *src1, *src2; - int x, y, c; - unsigned char gamma_table_m[256]; - unsigned char gamma_table_r[256]; - unsigned char gamma_table_g[256]; - unsigned char gamma_table_b[256]; - - if (!ibuf1) return; - - dest= (unsigned char *) out->rect; - src1= (unsigned char *) ibuf1->rect; - - make_gamma_table(cast->setup_m, cast->gain_m, cast->gamma_m, - gamma_table_m); - make_gamma_table(cast->setup_r, cast->gain_r, cast->gamma_r, - gamma_table_r); - make_gamma_table(cast->setup_g, cast->gain_g, cast->gamma_g, - gamma_table_g); - make_gamma_table(cast->setup_b, cast->gain_b, cast->gamma_b, - gamma_table_b); - - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) { - *dest++ = gamma_table_r[gamma_table_m[*src1++]]; - *dest++ = gamma_table_g[gamma_table_m[*src1++]]; - *dest++ = gamma_table_b[gamma_table_m[*src1++]]; - dest++; src1++; - } - } - } - else - { - float *i=ibuf1->rect_float; - float *o=out->rect_float; - unsigned int size=width*height; - unsigned int k; - float val_r[3]={cast->setup_r,cast->gain_r,cast->gamma_r}; - float val_g[3]={cast->setup_g,cast->gain_g,cast->gamma_g}; - float val_b[3]={cast->setup_b,cast->gain_b,cast->gamma_b}; - float *vals[3]={val_r,val_g,val_b}; - for (k=0;k<size;++k) - { - if (cast->gamma_m!=1.f || cast->setup_m!=0.f || cast->gain_m!=1.f) - { - float alpha=CLAMP(i[3],0.f,1.f); - if (alpha>alpha_epsilon) { - int l; - for (l=0;l<3;++l) - { - float *val=vals[l]; - o[l]=i[l]/alpha; - o[l]=pow((o[l]+cast->setup_m)*cast->gain_m,cast->gamma_m); - if (val[2]!=1.f || val[0]!=0.f || val[1]!=1.f) - { - o[l]=pow((o[l]+val[0])*val[1],val[2]); - } - o[l]*=alpha; - o[l]=CLAMP(o[l],0.f,1.f); - } - } else { - o[0]=o[1]=o[2]=0.0; - } - o[3]=1.0; - } - else - { - int l; - for (l=0;l<3;++l) - o[l]=CLAMP(i[l],0.f,1.f); - o[3]=1.0; - } - i += 4; - o += 4; - } - } -} diff --git a/release/plugins/sequence/scatter.c b/release/plugins/sequence/scatter.c deleted file mode 100644 index a480f194bea..00000000000 --- a/release/plugins/sequence/scatter.c +++ /dev/null @@ -1,263 +0,0 @@ -/** - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "plugin.h" - -/* ******************** GLOBAL VARIABLES ***************** */ - - -char name[24] = "scatter"; - -/* structure for buttons, - * butcode name default min max 0 - */ - -VarStruct varstr[] = { - LABEL, "Input: 1 strip", 0.0, 0.0, 0.0, "", - NUM | INT, "seed: ", 1.0, 0.0, 10.0, "Offset in random table", - NUMSLI | FLO, "swing: ", 1.0, 0.0, 3.0, "The amplitude, width of the effect", - TOG | INT, "wrap", 0.0, 0.0, 1.0, "Cyclic wrap around the left/right edges", - NUM | INT, "type: ", 1.0, 0.0, 1.0, "Type 1 is random for each frame", -}; - -/* The cast struct is for input in the main doit function - Varstr and Cast must have the same variables in the same order */ - -typedef struct Cast { - int dummy; /* because of the 'label' button */ - int seed; - float swing; - int wrap; - int type; -} Cast; - -/* cfra: the current frame */ - -float cfra; - -void plugin_seq_doit(Cast *, float, float, int, int, ImBuf *, ImBuf *, ImBuf *, ImBuf *); - - -/* ******************** Fixed functions ***************** */ - -int plugin_seq_getversion(void) -{ - return B_PLUGIN_VERSION; -} - -void plugin_but_changed(int but) -{ -} - -void plugin_init() -{ -} - -void plugin_getinfo(PluginInfo *info) -{ - info->name = name; - info->nvars = sizeof(varstr) / sizeof(VarStruct); - info->cfra = &cfra; - - info->varstr = varstr; - - info->init = plugin_init; - info->seq_doit = (SeqDoit) plugin_seq_doit; - info->callback = plugin_but_changed; -} - - -/* ************************************************************ - Scatter - -************************************************************ */ - -static void rectcpy(ImBuf *dbuf, ImBuf *sbuf, - int destx, int desty, - int srcx, int srcy, int width, int height) -{ - uint *drect, *srect; - float *dfrect, *sfrect; - int tmp; - - if (dbuf == 0) return; - - if (destx < 0) { - srcx -= destx; - width += destx; - destx = 0; - } - if (srcx < 0) { - destx -= srcx; - width += destx; - srcx = 0; - } - if (desty < 0) { - srcy -= desty; - height += desty; - desty = 0; - } - if (srcy < 0) { - desty -= srcy; - height += desty; - srcy = 0; - } - - if (width > dbuf->x - destx) width = dbuf->x - destx; - if (height > dbuf->y - desty) height = dbuf->y - desty; - if (sbuf) { - if (width > sbuf->x - srcx) width = sbuf->x - srcx; - if (height > sbuf->y - srcy) height = sbuf->y - srcy; - srect = sbuf->rect; - sfrect = sbuf->rect_float; - } - - if (width <= 0) return; - if (height <= 0) return; - - drect = dbuf->rect; - dfrect = dbuf->rect_float; - - tmp = (desty * dbuf->x + destx); - - if (dbuf->rect_float) dfrect += 4 * tmp; - else drect += tmp; - - destx = dbuf->x; - - if (sbuf) { - tmp = (srcy * sbuf->x + srcx); - if (dbuf->rect_float) sfrect += 4 * tmp; - else srect += tmp; - srcx = sbuf->x; - } - else { - if (dbuf->rect_float) sfrect = dfrect; - else srect = drect; - srcx = destx; - } - - for (; height > 0; height--) { - if (dbuf->rect_float) { - memcpy(dfrect, sfrect, 4 * width * sizeof(float)); - dfrect += destx; - sfrect += srcx; - } - else { - memcpy(drect, srect, width * sizeof(int)); - drect += destx; - srect += srcx; - } - } -} - -static void fill_out(ImBuf *out, float r, float g, float b, float a) -{ - int tot, x; - float *rectf = out->rect_float; - unsigned char *rect = (unsigned char *)out->rect; - - tot = out->x * out->y; - if (out->rect_float) { - for (x = 0; x < tot; x++) { - rectf[0] = r; - rectf[1] = g; - rectf[2] = b; - rectf[3] = a; - rectf += 4; - } - } - else { - for (x = 0; x < tot; x++) { - rect[0] = (int)(r * 255); - rect[1] = (int)(g * 255); - rect[2] = (int)(b * 255); - rect[3] = (int)(a * 255); - rect += 4; - } - } -} - - -void plugin_seq_doit(Cast *cast, float facf0, float facf1, int sx, int sy, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *out, ImBuf *use) -{ - float f1, f2, t1, t2, t3; - int x, y, lr; - - /* fill imbuf 'out' with black */ - fill_out(out, 0, 0, 0, 0); - - - switch (cast->type) { - case 0: - srand48(cast->seed); - break; - case 1: - srand48(cast->seed + facf0 * 1000); - break; - } - - for (y = 0; y < sy; y++) { - switch (cast->type) { - case 0: - if ((y & 1) == 0) { - f1 = drand48() - 0.5; - f2 = drand48() - 0.5; - f1 = cast->swing * f1; - f2 = cast->swing * f2; - if (cast->wrap) f2 += 1.0; - lr = drand48() > 0.5; - t1 = facf0; - } - else t1 = facf1; - - t2 = 1.0 - t1; - t3 = 3.0 * (f1 * t1 * t1 * t2 + f2 * t1 * t2 * t2); - if (cast->wrap) t3 += t2 * t2 * t2; - x = sx * t3; - if (lr) x = -x; - break; - case 1: - f1 = drand48() - 0.5; - f1 = f1 * cast->swing; - if ((y & 1) == 0) f1 *= facf0; - else f1 *= facf1; - x = f1 * sx; - break; - } - - rectcpy(out, ibuf1, 0, y, x, y, 32767, 1); - if (cast->wrap) { - rectcpy(out, ibuf1, 0, y, x + sx, y, 32767, 1); - rectcpy(out, ibuf1, 0, y, x + sx + sx, y, 32767, 1); - rectcpy(out, ibuf1, 0, y, x - sx, y, 32767, 1); - rectcpy(out, ibuf1, 0, y, x - sx - sx, y, 32767, 1); - } - } -} - |