aboutsummaryrefslogtreecommitdiffstats
path: root/vhook/fish.c
diff options
context:
space:
mode:
authorPhilip Gladstone <philipjsg@users.sourceforge.net>2003-05-21 02:15:11 +0000
committerPhilip Gladstone <philipjsg@users.sourceforge.net>2003-05-21 02:15:11 +0000
commitd9974a4867de0bd913c258822f4a47fb36dec111 (patch)
treeef3289d012be7285cc3c27e71bb0326463345477 /vhook/fish.c
parent31d8cb134d2f12925edb51f479e9891217822d54 (diff)
downloadffmpeg-d9974a4867de0bd913c258822f4a47fb36dec111.tar.gz
Made it work again -- it now detects fish! (This involved clearing out
some accumulated bit rot) Originally committed as revision 1895 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'vhook/fish.c')
-rw-r--r--vhook/fish.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/vhook/fish.c b/vhook/fish.c
index 15486d79a9..7faae26f7e 100644
--- a/vhook/fish.c
+++ b/vhook/fish.c
@@ -99,7 +99,7 @@ int Configure(void **ctxp, int argc, char *argv[])
optind = 0;
ci->dir = "/tmp";
- ci->threshold = 1000;
+ ci->threshold = 100;
ci->file_limit = 100;
ci->min_interval = 1000000;
ci->inset = 10; /* Percent */
@@ -126,6 +126,10 @@ int Configure(void **ctxp, int argc, char *argv[])
break;
case 't':
ci->threshold = atof(optarg) * 1000;
+ if (ci->threshold > 1000 || ci->threshold < 0) {
+ fprintf(stderr, "Invalid threshold value '%s' (range is 0-1)\n", optarg);
+ return -1;
+ }
break;
case 'w':
ci->min_width = atoi(optarg);
@@ -199,6 +203,11 @@ void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width,
uint8_t *cm = cropTbl + MAX_NEG_CROP;
int rowsize = picture->linesize[0];
+#if 0
+ printf("pix_fmt = %d, width = %d, pts = %lld, ci->next_pts = %lld\n",
+ pix_fmt, width, pts, ci->next_pts);
+#endif
+
if (pts < ci->next_pts)
return;
@@ -224,9 +233,9 @@ 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];
- u = picture->data[1];
- v = picture->data[2];
+ 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;
for (h = h_start; h > h_end; h -= 2) {
int w;
@@ -265,11 +274,14 @@ void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width,
v++;
}
- y += picture->linesize[0] * 2 - width;
- u += picture->linesize[1] - width2;
- v += picture->linesize[2] - width2;
+ y += picture->linesize[0] * 2 - (w_start - w_end) * 2;
+ u += picture->linesize[1] - (w_start - w_end);
+ v += picture->linesize[2] - (w_start - w_end);
}
+ if (ci->debug)
+ fprintf(stderr, "Fish: Inrange=%d of %d = %d threshold\n", inrange, pixcnt, 1000 * inrange / pixcnt);
+
if (inrange * 1000 / pixcnt >= ci->threshold) {
/* Save to file */
int size;
@@ -278,9 +290,6 @@ void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width,
static int frame_counter;
static int foundfile;
- if (ci->debug)
- fprintf(stderr, "Fish: Inrange=%d of %d = %d threshold\n", inrange, pixcnt, 1000 * inrange / pixcnt);
-
if ((frame_counter++ % 20) == 0) {
/* Check how many files we have */
DIR *d;