From owner-freebsd-multimedia Wed May 6 17:49:55 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id RAA00597 for freebsd-multimedia-outgoing; Wed, 6 May 1998 17:49:55 -0700 (PDT) (envelope-from owner-freebsd-multimedia@FreeBSD.ORG) Received: from whqvax.picker.com (whqvax.picker.com [144.54.1.1]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id RAA00557 for ; Wed, 6 May 1998 17:49:49 -0700 (PDT) (envelope-from rhh@ct.picker.com) Received: from ct.picker.com by whqvax.picker.com with SMTP; Wed, 6 May 1998 20:49:18 -0400 (EDT) Received: from elmer.ct.picker.com by ct.picker.com (4.1/SMI-4.1) id AA07135; Wed, 6 May 98 20:49:19 EDT Received: by elmer.ct.picker.com (SMI-8.6/SMI-SVR4) id UAA00721; Wed, 6 May 1998 20:49:02 -0400 Message-Id: <19980506204902.A615@ct.picker.com> Date: Wed, 6 May 1998 20:49:02 -0400 From: Randall Hopper To: Tomi.Vainio@Sun.COM Cc: multimedia@FreeBSD.ORG Subject: Fxtv 0.46 XImages FIX (Re: problem capturing video with BT848/Hauppauge Win/TV) Mail-Followup-To: Tomi.Vainio@Sun.COM, multimedia@freebsd.org References: <13647.31488.492948.498930@ultrahot> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=rwEMma7ioTxnRzrJ X-Mailer: Mutt 0.91.1i In-Reply-To: <13647.31488.492948.498930@ultrahot>; from Tomi Vainio - Sun Finland - on Tue, May 05, 1998 at 11:48:00PM +0300 Sender: owner-freebsd-multimedia@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org --rwEMma7ioTxnRzrJ Content-Type: text/plain; charset=us-ascii Ok Tomi, I "think" I've got it :-) (at least for your XImages core dump) In summary: PROBLEM #1 SYMPTOMS: - Core dump building/processing an XImage - Only occurs in -bpp 32 - Core dump appears to happen with either Standard or Shared (Shm) XImages There was a bug in the allocation of standard XImages that could result in underallocation of the image buffer leading to a core dump. Please try: 1. Apply the 1st attached patch (*TST*.patch) to unmodified Fxtv 0.46 source, build, and then do this: > gdb ./fxtv (gdb) run -synchronous -disableDirectV (gdb) where Play with it, maximize it, move it around, try to core dump it. If you can't, skip the "where" command. If it core dumps though I'd appreciate you mailing the stack printout as well as the program output. 2. If it dumps, try: > gdb ./fxtv (gdb) run -synchronous -disableDirectV -xrm "*Bpp32bit: 4" -xrm "*Bpp24bit: 4" (gdb) where Again, try to core dump it. If this works for you as I suspect it will, here's the "real" fix: 3. Apply 2nd attached patch (*FIX*.patch) to unmodified Fxtv 0.46 source, build, and give the fxtv binary a whirl. This is the same thing minus the printfs and the gratuitous quadrupling of the image buffer size in the *TST*.patch patch. :-) Let me know how it goes. Randall --rwEMma7ioTxnRzrJ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="fxtv-0.46-stdximgTST.patch" --- ORIG/Makefile Wed Nov 5 01:14:25 1997 +++ Makefile Wed May 6 20:36:19 1998 @@ -7,10 +7,10 @@ override CF_VERS = -DVERS_STR=\"0.46\" override INC = -I$(X11BASE)/include -I/usr/local/include override LD_INC = -L$(X11BASE)/lib -L/usr/local/lib -override CFLAGS = -O2 -m486 $(INC) $(CF_VERS) -#override CFLAGS = -g $(INC) $(CF_VERS) -override LDFLAGS = $(LD_INC) -#override LDFLAGS = -g $(LD_INC) +#override CFLAGS = -O2 -m486 $(INC) $(CF_VERS) +override CFLAGS = -g $(INC) $(CF_VERS) +#override LDFLAGS = $(LD_INC) +override LDFLAGS = -g $(LD_INC) override LIBS = -ltiff -lXaw3d -lXmu -lXt -lXpm -lXxf86dga \ -lXxf86vm -lSM -lICE -lXext -lX11 @@ -30,7 +30,7 @@ $(EXEC) : $(CSRCOBJ) $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) - strip $(EXEC) +# strip $(EXEC) tv.o : tv.c app_rsrc.h --- ORIG/tvscreen.c Wed Nov 5 01:01:57 1997 +++ tvscreen.c Wed May 6 20:37:00 1998 @@ -2308,6 +2308,8 @@ d->ximage_use_for_expose = FALSE; + printf( "---\n" ); + /* Free the old */ if ( image->ximg ) if ( image->is_shm ) { @@ -2338,15 +2340,22 @@ if ( c->xfer_mode == TV_TRANSFER_SHMEM_IMAGE ) { /* FIXME: Clean up shared mem segments on exit and on */ /* next run. */ - image->ximg = XShmCreateImage( TVDISPLAY, v->visual, v->depth, + printf( "SHM: WxH, Depth = %dx%d, %d\n", g->w, g->h, v->depth ); + image->ximg = XShmCreateImage( TVDISPLAY, v->visual, v->depth, ZPixmap, NULL, &image->shm_info, g->w, g->h ); if ( image->ximg == NULL ) { fprintf( stderr, "XShmCreateImage() failed\n" ); exit(1); } + printf( "SHM: Bytes/line, Height = %d, %d\n", + image->ximg->bytes_per_line, image->ximg->height ); image->shm_info.shmid = shmget( IPC_PRIVATE, +#ifdef OLD image->ximg->bytes_per_line * image->ximg->height, +#else + 4 * image->ximg->bytes_per_line * image->ximg->height, +#endif IPC_CREAT | 0777 ); if ( image->shm_info.shmid < 0 ) { fprintf( stderr, "shmget() failed: %s\n", strerror(errno)); @@ -2372,14 +2381,31 @@ if ( bpp_adj == 24 ) bpp_adj = 32; + printf( "STD: WxH, Depth = %dx%d, %d\n", g->w, g->h, v->depth ); image->ximg = XCreateImage( TVDISPLAY, v->visual, v->depth, ZPixmap, 0, NULL, g->w, g->h, +#ifdef OLD bpp_adj, 0 ); +#else + BitmapPad(TVDISPLAY), 0 ); +#endif if ( image->ximg == NULL ) { fprintf( stderr, "XCreateImage() failed\n" ); exit(1); } + printf( "STD: WxH, Bpp = %dx%d, %d\n", + g->w, g->h, bpp_adj/8 ); + printf( "STD: Bytes/line, Height = %d, %d\n", + image->ximg->bytes_per_line, image->ximg->height ); +#ifdef OLD image->ximg->data = malloc( g->w * g->h * (bpp_adj / 8) ); +#elif defined(CORRECT) + image->ximg->data = malloc( image->ximg->bytes_per_line * + image->ximg->height ); +#else + image->ximg->data = malloc( 4 * image->ximg->bytes_per_line * + image->ximg->height ); +#endif if ( image->ximg->data == NULL ) TVUTILOutOfMemory(); image->is_shm = False; --rwEMma7ioTxnRzrJ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="fxtv-0.46-stdximgFIX.patch" --- ORIG/Makefile Wed Nov 5 01:14:25 1997 +++ Makefile Wed May 6 20:36:19 1998 @@ -7,10 +7,10 @@ override CF_VERS = -DVERS_STR=\"0.46\" override INC = -I$(X11BASE)/include -I/usr/local/include override LD_INC = -L$(X11BASE)/lib -L/usr/local/lib -override CFLAGS = -O2 -m486 $(INC) $(CF_VERS) -#override CFLAGS = -g $(INC) $(CF_VERS) -override LDFLAGS = $(LD_INC) -#override LDFLAGS = -g $(LD_INC) +#override CFLAGS = -O2 -m486 $(INC) $(CF_VERS) +override CFLAGS = -g $(INC) $(CF_VERS) +#override LDFLAGS = $(LD_INC) +override LDFLAGS = -g $(LD_INC) override LIBS = -ltiff -lXaw3d -lXmu -lXt -lXpm -lXxf86dga \ -lXxf86vm -lSM -lICE -lXext -lX11 @@ -30,7 +30,7 @@ $(EXEC) : $(CSRCOBJ) $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) - strip $(EXEC) +# strip $(EXEC) tv.o : tv.c app_rsrc.h --- ORIG/tvscreen.c Wed Nov 5 01:01:57 1997 +++ tvscreen.c Wed May 6 20:34:22 1998 @@ -2366,20 +2366,15 @@ image->is_shm = True; } else if ( c->xfer_mode == TV_TRANSFER_STD_IMAGE ) { - /* FIXME: Handle 3Bpp 24bpp */ - int bpp_adj = (v->depth+7)/8*8; - - if ( bpp_adj == 24 ) - bpp_adj = 32; - image->ximg = XCreateImage( TVDISPLAY, v->visual, v->depth, ZPixmap, 0, NULL, g->w, g->h, - bpp_adj, 0 ); + BitmapPad(TVDISPLAY), 0 ); if ( image->ximg == NULL ) { fprintf( stderr, "XCreateImage() failed\n" ); exit(1); } - image->ximg->data = malloc( g->w * g->h * (bpp_adj / 8) ); + image->ximg->data = malloc( image->ximg->bytes_per_line * + image->ximg->height ); if ( image->ximg->data == NULL ) TVUTILOutOfMemory(); image->is_shm = False; --rwEMma7ioTxnRzrJ-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-multimedia" in the body of the message