/* * EffecTV - Realtime Digital Video Effector * Copyright (C) 2001-2003 FUKUCHI Kentaro * * ChameleonTV - Vanishing into the wall!! * Copyright (C) 2003 FUKUCHI Kentaro * */ #include #include #include "EffecTV.h" #include "utils.h" #define PLANES_DEPTH 6 #define PLANES (1<name = effectname; entry->start = start; entry->stop = stop; entry->draw = draw; return entry; } static int start() { timebuffer = (unsigned char *)malloc(video_area * PLANES); if(timebuffer == NULL) return -1; memset(timebuffer, 0, video_area * PLANES); memset(sum, 0, video_area * sizeof(unsigned int)); bgIsSet = 0; plane = 0; state = 1; return 0; } static int stop() { if(state) { if(timebuffer) { free(timebuffer); timebuffer = NULL; } state = 0; } return 0; } static int draw(RGB32 *src, RGB32 *dest) { if(!bgIsSet) { setBackground(src); } if(mode == 0) { drawDisappearing(src, dest); } else { drawAppearing(src, dest); } return 0; } static void drawDisappearing(RGB32 *src, RGB32 *dest) { int i; unsigned int Y; int r, g, b; int R, G, B; unsigned char *p; RGB32 *q; unsigned int *s; p = timebuffer + plane * video_area; q = bgimage; s = sum; for(i=0; i>16) & 0xff; g = (Y>>8) & 0xff; b = Y & 0xff; R = (*q>>16) & 0xff; G = (*q>>8) & 0xff; B = *q & 0xff; Y = (r + g * 2 + b) >> 2; *s -= *p; *s += Y; *p = Y; Y = (abs(((int)Y<>PLANES_DEPTH; if(Y>255) Y = 255; R += ((r - R) * Y) >> 8; G += ((g - G) * Y) >> 8; B += ((b - B) * Y) >> 8; *dest++ = (R<<16)|(G<<8)|B; p++; q++; s++; } plane++; plane = plane & (PLANES-1); } static void drawAppearing(RGB32 *src, RGB32 *dest) { int i; unsigned int Y; int r, g, b; int R, G, B; unsigned char *p; RGB32 *q; unsigned int *s; p = timebuffer + plane * video_area; q = bgimage; s = sum; for(i=0; i>16) & 0xff; g = (Y>>8) & 0xff; b = Y & 0xff; R = (*q>>16) & 0xff; G = (*q>>8) & 0xff; B = *q & 0xff; Y = (r + g * 2 + b) >> 2; *s -= *p; *s += Y; *p = Y; Y = (abs(((int)Y<>PLANES_DEPTH; if(Y>255) Y = 255; r += ((R - r) * Y) >> 8; g += ((G - g) * Y) >> 8; b += ((B - b) * Y) >> 8; *dest++ = (r<<16)|(g<<8)|b; p++; q++; s++; } plane++; plane = plane & (PLANES-1); } static void setBackground(RGB32 *src) { memcpy(bgimage, src, video_area * PIXEL_SIZE); bgIsSet = 1; }