From: Philip Gladstone Date: Tue, 10 Jun 2003 01:47:41 +0000 (+0000) Subject: Get all the stride stuff right so that we actually get the colours X-Git-Tag: v0.5~16277 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=25a2ee7dd6c24bc9d5787f7f514cd3fb0b011540;p=platform%2Fupstream%2Flibav.git 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 --- diff --git a/vhook/fish.c b/vhook/fish.c index 7faae26..0a64188 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;