From 25a2ee7dd6c24bc9d5787f7f514cd3fb0b011540 Mon Sep 17 00:00:00 2001 From: Philip Gladstone Date: Tue, 10 Jun 2003 01:47:41 +0000 Subject: Get all the stride stuff right so that we actually get the colours right. Originally committed as revision 1944 to svn://svn.ffmpeg.org/ffmpeg/trunk --- vhook/fish.c | 54 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 20 deletions(-) (limited to 'vhook') diff --git a/vhook/fish.c b/vhook/fish.c index 7faae26f7e..0a6418834c 100644 --- a/vhook/fish.c +++ b/vhook/fish.c @@ -45,14 +45,30 @@ #include "framehook.h" #include "dsputil.h" -#define SCALE_BITS 10 - -#define C_Y (76309 >> (16 - SCALE_BITS)) -#define C_RV (117504 >> (16 - SCALE_BITS)) -#define C_BU (138453 >> (16 - SCALE_BITS)) -#define C_GU (13954 >> (16 - SCALE_BITS)) -#define C_GV (34903 >> (16 - SCALE_BITS)) +#define SCALEBITS 10 +#define ONE_HALF (1 << (SCALEBITS - 1)) +#define FIX(x) ((int) ((x) * (1<> SCALEBITS];\ + g = cm[(yt + g_add) >> SCALEBITS];\ + b = cm[(yt + b_add) >> SCALEBITS];\ +} + + typedef struct { int h; /* 0 .. 360 */ @@ -154,6 +170,8 @@ int Configure(void **ctxp, int argc, char *argv[]) ci->bright.h, ci->bright.s, ci->bright.v); + fprintf(stderr, " Threshold is %d%% pixels\n", ci->threshold / 10); + return 0; } @@ -234,25 +252,19 @@ void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width, pixcnt = ((h_start - h_end) >> 1) * (w_start - w_end); y = picture->data[0] + h_end * picture->linesize[0] + w_end * 2; - u = picture->data[1] + h_end * picture->linesize[1] + w_end; - v = picture->data[2] + h_end * picture->linesize[2] + w_end; + u = picture->data[1] + h_end * picture->linesize[1] / 2 + w_end; + v = picture->data[2] + h_end * picture->linesize[2] / 2 + w_end; for (h = h_start; h > h_end; h -= 2) { int w; for (w = w_start; w > w_end; w--) { - int r,g,b; - int Y, U, V; + unsigned int r,g,b; HSV hsv; + int cb, cr, yt, r_add, g_add, b_add; - U = u[0] - 128; - V = v[0] - 128; - - Y = (y[0] - 16) * C_Y; - - r = cm[(Y + C_RV * V + (1 << (SCALE_BITS - 1))) >> SCALE_BITS]; - g = cm[(Y + - C_GU * U - C_GV * V + (1 << (SCALE_BITS - 1))) >> SCALE_BITS]; - b = cm[(Y + C_BU * U + (1 << (SCALE_BITS - 1))) >> SCALE_BITS]; + YUV_TO_RGB1_CCIR(u[0], v[0]); + YUV_TO_RGB2_CCIR(r, g, b, y[0]); get_hsv(&hsv, r, g, b); @@ -266,7 +278,9 @@ void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width, hsv.v >= ci->dark.v && hsv.v <= ci->bright.v) { inrange++; } else if (ci->zapping) { - y[0] = y[1] = y[rowsize] = y[rowsize + 1] = 0; + y[0] = y[1] = y[rowsize] = y[rowsize + 1] = 16; + u[0] = 128; + v[0] = 128; } y+= 2; -- cgit v1.2.3