Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Diff of /src/video_out/video_out_xshm.c [5286f8] .. [7cc4e1] Maximize Restore

  Switch to side-by-side view

--- a/src/video_out/video_out_xshm.c
+++ b/src/video_out/video_out_xshm.c
@@ -1,13 +1,13 @@
 /*
  * Copyright (C) 2000-2003, 2008 the xine project
- * 
+ *
  * This file is part of xine, a free video player.
- * 
+ *
  * xine is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * xine is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -82,7 +82,7 @@
   int                flags;
 
   vo_scale_t         sc;
-    
+
   XImage            *image;
   XShmSegmentInfo    shminfo;
 
@@ -104,7 +104,7 @@
   int                depth, bpp, bytes_per_pixel, image_byte_order;
   int                use_shm;
   XColor             black;
-  
+
   int                yuv2rgb_brightness;
   int                yuv2rgb_contrast;
   int                yuv2rgb_saturation;
@@ -112,7 +112,7 @@
   yuv2rgb_factory_t *yuv2rgb_factory;
 
   vo_scale_t         sc;
-  
+
   xshm_frame_t      *cur_frame;
   x11osd            *xoverlay;
   int                ovl_changed;
@@ -168,11 +168,11 @@
 }
 
 /*
- * allocate an XImage, try XShm first but fall back to 
+ * allocate an XImage, try XShm first but fall back to
  * plain X11 if XShm should fail
  */
 /* called xlocked */
-static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo, 
+static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo,
 			      int width, int height) {
   XImage *myimage = NULL;
 
@@ -181,16 +181,16 @@
     /*
      * try shm
      */
-    
+
     gX11Fail = 0;
     x11_InstallXErrorHandler (this);
 
-    myimage = XShmCreateImage(this->display, 
+    myimage = XShmCreateImage(this->display,
 			      this->visual,
 			      this->depth,
 			      ZPixmap, NULL,
 			      shminfo,
-			      width, 
+			      width,
 			      height);
 
     if (myimage == NULL )  {
@@ -201,15 +201,15 @@
       this->use_shm = 0;
       goto finishShmTesting;
     }
-  
+
     this->bpp = myimage->bits_per_pixel;
     this->bytes_per_pixel = this->bpp / 8;
     this->image_byte_order = myimage->byte_order;
-    
+
     shminfo->shmid=shmget(IPC_PRIVATE,
-			  myimage->bytes_per_line * myimage->height, 
+			  myimage->bytes_per_line * myimage->height,
 			  IPC_CREAT | 0777);
-    
+
     if (shminfo->shmid < 0 ) {
       xprintf(this->xine, XINE_VERBOSITY_LOG,
 	      _("%s: %s: allocating image\n"), LOG_MODULE, strerror(errno));
@@ -218,9 +218,9 @@
       this->use_shm = 0;
       goto finishShmTesting;
     }
-  
+
     shminfo->shmaddr  = (char *) shmat(shminfo->shmid, 0, 0);
-  
+
     if (shminfo->shmaddr == ((char *) -1)) {
       xprintf(this->xine, XINE_VERBOSITY_LOG,
 	      _("%s: shared memory error (address error) when allocating image \n"), LOG_MODULE);
@@ -231,12 +231,12 @@
       this->use_shm = 0;
       goto finishShmTesting;
     }
-  
+
     shminfo->readOnly = False;
     myimage->data = shminfo->shmaddr;
-  
+
     XShmAttach(this->display, shminfo);
-  
+
     XSync(this->display, False);
 
     if (gX11Fail) {
@@ -251,10 +251,10 @@
       goto finishShmTesting;
     }
 
-    /* 
+    /*
      * Now that the Xserver has learned about and attached to the
      * shared memory segment,  delete it.  It's actually deleted by
-     * the kernel when all users of that segment have detached from 
+     * the kernel when all users of that segment have detached from
      * it.  Gives an automatic shared memory cleanup in case we crash.
      */
     shmctl (shminfo->shmid, IPC_RMID, 0);
@@ -276,7 +276,7 @@
 			    this->depth,
 			    ZPixmap, 0,
 			    NULL,
-			    width, 
+			    width,
 			    height,
 			    8, 0);
 
@@ -292,8 +292,8 @@
 }
 
 /* called xlocked */
-static void dispose_ximage (xshm_driver_t *this, 
-			    XShmSegmentInfo *shminfo, 
+static void dispose_ximage (xshm_driver_t *this,
+			    XShmSegmentInfo *shminfo,
 			    XImage *myimage) {
 
   if (this->use_shm) {
@@ -306,7 +306,7 @@
       shminfo->shmid = -1;
     }
 
-  } 
+  }
   else
     XDestroyImage (myimage);
 }
@@ -329,10 +329,10 @@
 static void xshm_frame_proc_slice (vo_frame_t *vo_img, uint8_t **src) {
   xshm_frame_t  *frame = (xshm_frame_t *) vo_img ;
   /*xshm_driver_t *this = (xshm_driver_t *) vo_img->driver; */
-  
-  vo_img->proc_called = 1;                                    
-  
-  if( frame->vo_frame.crop_left || frame->vo_frame.crop_top || 
+
+  vo_img->proc_called = 1;
+
+  if( frame->vo_frame.crop_left || frame->vo_frame.crop_top ||
       frame->vo_frame.crop_right || frame->vo_frame.crop_bottom )
   {
     /* we don't support crop, so don't even waste cpu cycles.
@@ -340,7 +340,7 @@
      */
     return;
   }
-  
+
   lprintf ("copy... (format %d)\n", frame->format);
 
   if (frame->format == XINE_IMGFMT_YV12)
@@ -349,7 +349,7 @@
   else
     frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst,
 				  src[0]);
-  
+
   lprintf ("copy...done\n");
 }
 
@@ -406,10 +406,10 @@
   /*
    * supply required functions/fields
    */
-  
+
   frame->vo_frame.proc_slice = xshm_frame_proc_slice;
   frame->vo_frame.proc_frame = NULL;
-  frame->vo_frame.field      = xshm_frame_field; 
+  frame->vo_frame.field      = xshm_frame_field;
   frame->vo_frame.dispose    = xshm_frame_dispose;
   frame->vo_frame.driver     = this_gen;
 
@@ -469,7 +469,7 @@
                           frame->sc.video_pixel_aspect,
                           &gui_width, &gui_height,
                           &gui_pixel_aspect);
-                          
+
   /* find out if we need to adapt this frame */
   do_adapt = 0;
 
@@ -494,7 +494,7 @@
     frame->sc.user_ratio         = this->sc.user_ratio;
 
     xshm_compute_ideal_size (this, frame);
-  
+
     /* now we have updated video_aspect_pixel we use the callback   */
     /* again to obtain the correct gui_width and gui_height values. */
     frame->sc.dest_size_cb (frame->sc.user_data, width, height,
@@ -502,20 +502,20 @@
                             &gui_width, &gui_height,
                             &gui_pixel_aspect);
   }
-  
+
   if ((frame->sc.gui_width != gui_width) ||
       (frame->sc.gui_height != gui_height) ||
       do_adapt) {
-    
+
     do_adapt = 1;
     frame->sc.gui_width  = gui_width;
     frame->sc.gui_height = gui_height;
-    
+
     xshm_compute_rgb_size (this, frame);
-    
+
     lprintf ("gui_size has changed => adapt\n");
   }
-  
+
 
   /* ok, now do what we have to do */
 
@@ -561,7 +561,7 @@
     lprintf ("stripe out_ht=%i, deliv_ht=%i\n",
 	    frame->sc.output_height, frame->sc.delivered_height);
 
-    /* 
+    /*
      * set up colorspace converter
      */
 
@@ -617,7 +617,7 @@
   }
 }
 
-static void xshm_overlay_begin (vo_driver_t *this_gen, 
+static void xshm_overlay_begin (vo_driver_t *this_gen,
 			      vo_frame_t *frame_gen, int changed) {
   xshm_driver_t  *this  = (xshm_driver_t *) this_gen;
 
@@ -625,10 +625,10 @@
 
   if( this->ovl_changed && this->xoverlay ) {
     LOCK_DISPLAY(this);
-    x11osd_clear(this->xoverlay); 
+    x11osd_clear(this->xoverlay);
     UNLOCK_DISPLAY(this);
   }
-  
+
   this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x;
   this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y;
 }
@@ -645,7 +645,7 @@
   this->ovl_changed = 0;
 }
 
-static void xshm_overlay_blend (vo_driver_t *this_gen, 
+static void xshm_overlay_blend (vo_driver_t *this_gen,
 				vo_frame_t *frame_gen, vo_overlay_t *overlay) {
   xshm_driver_t  *this  = (xshm_driver_t *) this_gen;
   xshm_frame_t   *frame = (xshm_frame_t *) frame_gen;
@@ -655,13 +655,13 @@
     if( overlay->unscaled ) {
       if( this->ovl_changed && this->xoverlay ) {
         LOCK_DISPLAY(this);
-        x11osd_blend(this->xoverlay, overlay); 
+        x11osd_blend(this->xoverlay, overlay);
         UNLOCK_DISPLAY(this);
       }
     } else {
       if (!overlay->rgb_clut || !overlay->hili_rgb_clut)
         xshm_overlay_clut_yuv2rgb (this, overlay, frame);
- 
+
       switch (this->bpp) {
         case 16:
          _x_blend_rgb16 ((uint8_t *)frame->image->data, overlay,
@@ -682,7 +682,7 @@
                       &this->alphablend_extra_data);
          break;
         default:
-	  xprintf(this->xine, XINE_VERBOSITY_DEBUG, 
+	  xprintf(this->xine, XINE_VERBOSITY_DEBUG,
 		  "xine-lib:video_out_xshm:xshm_overlay_blend: Cannot blend bpp:%i\n", this->bpp);
 	/* it should never get here, unless a user tries to play in bpp:8 */
 	break;
@@ -693,12 +693,12 @@
 
 static void clean_output_area (xshm_driver_t *this, xshm_frame_t *frame) {
   int i;
-  
+
   memcpy( this->sc.border, frame->sc.border, sizeof(this->sc.border) );
-  
+
   LOCK_DISPLAY(this);
   XSetForeground (this->display, this->gc, this->black.pixel);
-  
+
   for( i = 0; i < 4; i++ ) {
     if( this->sc.border[i].w && this->sc.border[i].h )
       XFillRectangle(this->display, this->drawable, this->gc,
@@ -709,7 +709,7 @@
     x11osd_resize (this->xoverlay, this->sc.gui_width, this->sc.gui_height);
     this->ovl_changed = 1;
   }
-  
+
   UNLOCK_DISPLAY(this);
 }
 
@@ -721,15 +721,15 @@
     this->sc.delivered_height   = this->cur_frame->sc.delivered_height;
     this->sc.delivered_width    = this->cur_frame->sc.delivered_width;
     this->sc.video_pixel_aspect = this->cur_frame->sc.video_pixel_aspect;
-    if( _x_vo_scale_redraw_needed( &this->sc ) ) {  
+    if( _x_vo_scale_redraw_needed( &this->sc ) ) {
 
       clean_output_area (this, this->cur_frame);
       ret = 1;
     }
-  } 
+  }
   else
     ret = 1;
-      
+
   return ret;
 }
 
@@ -742,22 +742,22 @@
 	   frame->vo_frame.id,
 	   frame->sc.output_width, frame->sc.output_height);
 
-  /* 
+  /*
    * tell gui that we are about to display a frame,
    * ask for offset
    */
-    
+
   this->sc.delivered_height   = frame->sc.delivered_height;
   this->sc.delivered_width    = frame->sc.delivered_width;
   this->sc.video_pixel_aspect = frame->sc.video_pixel_aspect;
-  if( _x_vo_scale_redraw_needed( &this->sc ) ) {  
+  if( _x_vo_scale_redraw_needed( &this->sc ) ) {
 
     clean_output_area (this, frame);
   }
-    
+
   if (this->cur_frame) {
 
-    if ( (this->cur_frame->sc.output_width != frame->sc.output_width) 
+    if ( (this->cur_frame->sc.output_width != frame->sc.output_width)
          || (this->cur_frame->sc.output_height != frame->sc.output_height)
          || (this->cur_frame->sc.output_xoffset != frame->sc.output_xoffset)
          || (this->cur_frame->sc.output_yoffset != frame->sc.output_yoffset) )
@@ -767,10 +767,10 @@
   }
 
   this->cur_frame = frame;
-    
+
   LOCK_DISPLAY(this);
   lprintf ("display locked...\n");
-  
+
   if (this->use_shm) {
 
     lprintf ("put image (shm)\n");
@@ -821,14 +821,14 @@
   case VO_PROP_OUTPUT_YOFFSET:
     return this->cur_frame->sc.output_yoffset;
   default:
-    xprintf(this->xine, XINE_VERBOSITY_DEBUG, 
+    xprintf(this->xine, XINE_VERBOSITY_DEBUG,
 	    LOG_MODULE ": tried to get unsupported property %d\n", property);
   }
 
   return 0;
 }
 
-static int xshm_set_property (vo_driver_t *this_gen, 
+static int xshm_set_property (vo_driver_t *this_gen,
 			      int property, int value) {
   xshm_driver_t *this = (xshm_driver_t *) this_gen;
 
@@ -837,7 +837,7 @@
     if (value>=XINE_VO_ASPECT_NUM_RATIOS)
       value = XINE_VO_ASPECT_AUTO;
     this->sc.user_ratio = value;
-    xprintf(this->xine, XINE_VERBOSITY_DEBUG, 
+    xprintf(this->xine, XINE_VERBOSITY_DEBUG,
 	    LOG_MODULE ": aspect ratio changed to %s\n", _x_vo_scale_aspect_ratio_name_table[value]);
     break;
 
@@ -869,7 +869,7 @@
     break;
 
   default:
-    xprintf (this->xine, XINE_VERBOSITY_DEBUG, 
+    xprintf (this->xine, XINE_VERBOSITY_DEBUG,
 	     LOG_MODULE ": tried to set unsupported property %d\n", property);
   }
 
@@ -895,7 +895,7 @@
   }
 }
 
-static int xshm_gui_data_exchange (vo_driver_t *this_gen, 
+static int xshm_gui_data_exchange (vo_driver_t *this_gen,
 				   int data_type, void *data) {
   xshm_driver_t   *this = (xshm_driver_t *) this_gen;
 
@@ -906,15 +906,15 @@
 #endif
 
   case XINE_GUI_SEND_EXPOSE_EVENT:
-    
+
     lprintf ("expose event\n");
 
     if (this->cur_frame) {
       XExposeEvent * xev = (XExposeEvent *) data;
-      
+
       if (xev && xev->count == 0) {
 	int i;
-	
+
 	LOCK_DISPLAY(this);
 	if (this->use_shm) {
 	  XShmPutImage(this->display,
@@ -924,7 +924,7 @@
 		       False);
 	}
 	else {
-	  XPutImage(this->display, 
+	  XPutImage(this->display,
 		    this->drawable, this->gc, this->cur_frame->image,
 		    0, 0, this->cur_frame->sc.output_xoffset, this->cur_frame->sc.output_yoffset,
 		    this->cur_frame->sc.output_width, this->cur_frame->sc.output_height);
@@ -947,7 +947,7 @@
       }
     }
   break;
-  
+
   case XINE_GUI_SEND_DRAWABLE_CHANGED:
     this->drawable = (Drawable) data;
 
@@ -965,7 +965,7 @@
     if (this->cur_frame) {
       x11_rectangle_t *rect = data;
       int              x1, y1, x2, y2;
-      
+
       _x_vo_scale_translate_gui2video(&this->cur_frame->sc,
 			       rect->x, rect->y,
 			       &x1, &y1);
@@ -988,16 +988,16 @@
 
 static void xshm_dispose (vo_driver_t *this_gen) {
   xshm_driver_t *this = (xshm_driver_t *) this_gen;
-  
+
   if (this->cur_frame)
     this->cur_frame->vo_frame.dispose (&this->cur_frame->vo_frame);
 
   this->yuv2rgb_factory->dispose (this->yuv2rgb_factory);
-  
+
   LOCK_DISPLAY(this);
   XFreeGC(this->display, this->gc);
   UNLOCK_DISPLAY(this);
-  
+
   if( this->xoverlay ) {
     LOCK_DISPLAY(this);
     x11osd_destroy (this->xoverlay);
@@ -1005,7 +1005,7 @@
   }
 
   _x_alphablend_free(&this->alphablend_extra_data);
-  
+
   free (this);
 }
 
@@ -1017,7 +1017,7 @@
   int                 format_ret;
   long                length;
   Atom                to_get;
-  
+
   retval = NULL;
   length = 0x7fffffff;
   to_get = XInternAtom(this->display, "_IMLIB_COLORMAP", False);
@@ -1029,7 +1029,7 @@
     if (format_ret == 8) {
       unsigned int i;
       unsigned long j;
-	  
+
       j = 1 + retval[0]*4;
       this->yuv2rgb_cmap = malloc(sizeof(uint8_t) * 32 * 32 * 32);
       for (i = 0; i < 32 * 32 * 32 && j < num_ret; i++)
@@ -1077,14 +1077,14 @@
   int			swapped;
   int			cpu_byte_order;
   XColor                dummy;
-  
+
   this = (xshm_driver_t *) calloc(1, sizeof(xshm_driver_t));
 
   if (!this)
     return NULL;
 
   _x_alphablend_init(&this->alphablend_extra_data, class->xine);
-  
+
   this->display		    = visual->display;
   this->screen		    = visual->screen;
 
@@ -1097,9 +1097,9 @@
   this->sc.frame_output_cb  = visual->frame_output_cb;
   this->sc.dest_size_cb     = visual->dest_size_cb;
   this->sc.user_data        = visual->user_data;
-  
+
   this->sc.user_ratio       = XINE_VO_ASPECT_AUTO;
-  
+
   this->drawable	    = visual->d;
   this->cur_frame           = NULL;
   LOCK_DISPLAY(this);
@@ -1107,7 +1107,7 @@
   UNLOCK_DISPLAY(this);
   this->xoverlay                = NULL;
   this->ovl_changed             = 0;
- 
+
   this->x11_old_error_handler = NULL;
   this->xine                  = class->xine;
 
@@ -1124,7 +1124,7 @@
   this->vo_driver.gui_data_exchange    = xshm_gui_data_exchange;
   this->vo_driver.dispose              = xshm_dispose;
   this->vo_driver.redraw_needed        = xshm_redraw_needed;
-  
+
   LOCK_DISPLAY(this);
   XAllocNamedColor (this->display,
 		    DefaultColormap (this->display, this->screen),
@@ -1146,7 +1146,7 @@
   UNLOCK_DISPLAY(this);
   this->visual = attribs.visual;
   this->depth  = attribs.depth;
-  
+
   if (this->depth>16)
     xprintf(this->xine, XINE_VERBOSITY_LOG,
 	    _("\n\nWARNING: current display depth is %d. For better performance\n"
@@ -1159,7 +1159,7 @@
   LOCK_DISPLAY(this);
   if (XShmQueryExtension(this->display)) {
     this->use_shm = 1;
-  } 
+  }
   else {
     xprintf(this->xine, XINE_VERBOSITY_LOG,
 	    _("%s: MIT shared memory extension not present on display.\n"), LOG_MODULE);
@@ -1181,7 +1181,7 @@
    */
   cpu_byte_order = htonl(1) == 1 ? MSBFirst : LSBFirst;
   swapped = cpu_byte_order != this->image_byte_order;
-  
+
   xprintf(this->xine, XINE_VERBOSITY_DEBUG,
 	  LOG_MODULE ": video mode depth is %d (%d bpp), %s, %sswapped,\n"
 	  LOG_MODULE ": red: %08lx, green: %08lx, blue: %08lx\n",
@@ -1245,16 +1245,16 @@
   }
 
   if (!mode) {
-    xprintf (this->xine, XINE_VERBOSITY_LOG, 
+    xprintf (this->xine, XINE_VERBOSITY_LOG,
 	     _("%s: your video mode was not recognized, sorry :-(\n"), LOG_MODULE);
     return NULL;
   }
-  
+
   this->yuv2rgb_brightness = 0;
   this->yuv2rgb_contrast   = 128;
   this->yuv2rgb_saturation = 128;
-  
-  this->yuv2rgb_factory = yuv2rgb_factory_init (mode, swapped, 
+
+  this->yuv2rgb_factory = yuv2rgb_factory_init (mode, swapped,
 						this->yuv2rgb_cmap);
   this->yuv2rgb_factory->set_csc_levels (this->yuv2rgb_factory,
 					 this->yuv2rgb_brightness,
@@ -1282,7 +1282,7 @@
   visual.frame_output_cb = old_visual->frame_output_cb;
   visual.lock_display    = NULL;
   visual.unlock_display  = NULL;
-  
+
   return xshm_open_plugin_2(class_gen, (void *)&visual);
 }
 
@@ -1327,7 +1327,7 @@
  */
 
 const plugin_info_t xine_plugin_info[] EXPORTED = {
-  /* type, API, "name", version, special_info, init_function */  
+  /* type, API, "name", version, special_info, init_function */
   { PLUGIN_VIDEO_OUT, 22, "xshm", XINE_VERSION_CODE, &vo_info_xshm, xshm_init_class },
   { PLUGIN_VIDEO_OUT, 22, "xshm", XINE_VERSION_CODE, &vo_info_xshm_2, xshm_init_class_2 },
   { PLUGIN_NONE, 0, "", 0, NULL, NULL }