Compare commits

...

3 Commits

Author SHA1 Message Date
71205d4ab0 v4l2 heisenbug, krkrkr 2020-12-26 19:04:22 +01:00
14ded65303 V4L2 : heisenbug spotted around VIDIOC_DQBUF, infinite loop 2020-12-26 18:37:04 +01:00
ce96b51ca4 oups... 2020-12-26 10:39:50 +01:00
3 changed files with 38 additions and 27 deletions

View File

@ -100,7 +100,7 @@ int random_blocks(FloatImg *picture, int percent)
{
int x, y;
if ( (picture->width%16) || (picture->height%8) )
if ( (picture->width%16) || (picture->height%16) )
{
fprintf(stderr, "%s: %d%d bad dims\n", __func__,
picture->width, picture->height);
@ -173,9 +173,7 @@ h = picz->height; w = picz->width;
for (y=BB; y<h-BB; y++) {
dy = (float)y * omega; /* normalize vertical position */
x = xpos + x_delta(dy, phi); /* add sinus deviation */
/* compute bounding box */
if ( (x>BB) && (x<w-BB) ) {
/* an make the glitch */
@ -184,7 +182,6 @@ for (y=BB; y<h-BB; y++) {
if (rand() & 8)
fimg_plot_rgb(picz, x-1, y, fv, fv, fv);
if (rand() & 8)
// XXX else
fimg_plot_rgb(picz, x+1, y, fv, fv, fv);
}
}

View File

@ -33,7 +33,6 @@
/* compilation control */
#define SAVE_AS_CUMUL 1
#define SAVE_AS_PNM 0
#define SAVE_AS_FIMG 0
/* --------------------------------------------------------------------- */
@ -190,6 +189,8 @@ if ((fmt.fmt.pix.width != width) || (fmt.fmt.pix.height != height)) {
fmt.fmt.pix.width, fmt.fmt.pix.height);
}
fprintf(stderr,"--- Ok 1\n");
CLEAR(req);
req.count = 2;
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@ -242,19 +243,20 @@ else {
fimg_clear(&cumul);
cumul.fval = 255.0; /* must be read from camera XXX */
cumul.count = 0;
to_save = &cumul;
#endif
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
xioctl(fd, VIDIOC_STREAMON, &type);
#if 0
if (verbosity) fprintf(stderr,"pid %d grabbing %d picz...\n",
#if 1
if (verbosity) fprintf(stderr,"pid %d is going to grab %d picz...\n",
getpid(), nbre_capt);
#endif
/*
* START ON THE GRABBING LOOP
*/
for (i = 0; i < nbre_capt; i++) {
do {
FD_ZERO(&fds);
@ -269,35 +271,22 @@ for (i = 0; i < nbre_capt; i++) {
if (r == -1) {
perror("select");
return errno;
return errno; /* WTF ? a rogue return
from the main() ? */
}
if(verbosity > 1) {
printf("%6d / %6d %9.3f\r", i, nbre_capt,
fprintf(stderr, "%6d / %6d %9.3f\n", i, nbre_capt,
fimg_timer_get(0));
fflush(stderr);
}
CLEAR(buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
xioctl(fd, VIDIOC_DQBUF, &buf);
#if SAVE_AS_PNM
/* at this time,we'v got a picture in-memory,
so we can blast in on storage */
sprintf(out_name, "%s/%05d.ppm", dest_dir, i);
if (verbosity > 1) fprintf(stderr, "--> %s\n", out_name);
fout = fopen(out_name, "w");
if (!fout) {
perror("Cannot open image");
exit(EXIT_FAILURE);
}
fprintf(fout, "P6\n%d %d 255\n",
fmt.fmt.pix.width, fmt.fmt.pix.height);
fwrite(buffers[buf.index].start, buf.bytesused, 1, fout);
fclose(fout);
#endif
fprintf(stderr, "xioctl VIDIOC_DQBUF done\n"); fflush(stderr);
#if SAVE_AS_CUMUL
if (upscaling) {

25
v4l2/notes.txt Normal file
View File

@ -0,0 +1,25 @@
Heisenbug dans la capture d'image
=================================
Contexte : Debian 10 32 bits sur Sony Vaio,
webcam Logitech classique.
Mon soft 'grabvidseq' part _parfois_ en torche oo, à la louche une
fois sur cent. Mais toujours au même endroit, au début de la boucle
de capture des images, précisément dans cet appel système :
CLEAR(buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
xioctl(fd, VIDIOC_DQBUF, &buf);
Quand le programme semble figé, un strace -p <pi> sort le même
message en rafale _très_ féroce :
ioctl(3, VIDIOC_DQBUF, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE}) = -1 EAGAIN (Resource temporarily unavailable)
ioctl(3, VIDIOC_DQBUF, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE}) = -1 EAGAIN (Resource temporarily unavailable)
ioctl(3, VIDIOC_DQBUF, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE^Cstrace: Process 11181 detached
WTF ?