diff options
Diffstat (limited to 'src/video_out/video_out_xvmc.c')
| -rw-r--r-- | src/video_out/video_out_xvmc.c | 260 | 
1 files changed, 75 insertions, 185 deletions
| diff --git a/src/video_out/video_out_xvmc.c b/src/video_out/video_out_xvmc.c index a17e4d6a0..7f282ee53 100644 --- a/src/video_out/video_out_xvmc.c +++ b/src/video_out/video_out_xvmc.c @@ -1,5 +1,5 @@  /* - * Copyright (C) 2000-2004 the xine project + * Copyright (C) 2000-2004, 2008 the xine project   *   * This file is part of xine, a free video player.   * @@ -66,15 +66,13 @@  */  #include "xine.h" -#include "video_out.h" -#include "xine_internal.h" +#include <xine/video_out.h> +#include <xine/xine_internal.h>  #include "accel_xvmc.h" -/* TODO - delete these? */ -#include "deinterlace.h" - -#include "xineutils.h" -#include "vo_scale.h" +#include <xine/xineutils.h> +#include <xine/vo_scale.h> +#include "xv_common.h"  /* #define LOG1 */  /* #define DLOG */ @@ -196,11 +194,6 @@ struct xvmc_driver_s {    double               ratio_factor;         /* output frame must fullfill:  						height = width * ratio_factor  */ -   -  xvmc_frame_t         deinterlace_frame; -  int                  deinterlace_method; -  int                  deinterlace_enabled; -    /* gui callback */    void               (*frame_output_cb) (void *user_data, @@ -225,8 +218,6 @@ typedef struct {    Display             *display;    config_values_t     *config;    XvPortID             xv_port; -  XvAdaptorInfo       *adaptor_info; -  unsigned int         adaptor_num;    int                  surface_type_id;    unsigned int         max_surface_width; @@ -487,9 +478,9 @@ static void xvmc_render_macro_blocks(vo_frame_t *current_image,  				     int second_field,  				     xvmc_macroblocks_t *macroblocks) {    xvmc_driver_t *this           = (xvmc_driver_t *) current_image->driver; -  xvmc_frame_t  *current_frame  = (xvmc_frame_t *)  current_image; -  xvmc_frame_t  *forward_frame  = (xvmc_frame_t *)  forward_ref_image; -  xvmc_frame_t  *backward_frame = (xvmc_frame_t *)  backward_ref_image; +  xvmc_frame_t  *current_frame  = XVMC_FRAME(current_image); +  xvmc_frame_t  *forward_frame  = XVMC_FRAME(forward_ref_image); +  xvmc_frame_t  *backward_frame = XVMC_FRAME(backward_ref_image);    int           flags;    lprintf ("xvmc_render_macro_blocks\n"); @@ -562,6 +553,7 @@ static vo_frame_t *xvmc_alloc_frame (vo_driver_t *this_gen) {      return NULL;    frame->vo_frame.accel_data = &frame->xvmc_data; +  frame->xvmc_data.vo_frame = &frame->vo_frame;    /* keep track of frames and how many frames alocated. */    this->frames[this->num_frame_buffers++] = frame; @@ -971,24 +963,13 @@ static void xvmc_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) {    /* Make sure the surface has finished rendering before we display */      XvMCSyncSurface(this->display, &this->cur_frame->surface); -  if (this->deinterlace_enabled && -      (this->deinterlace_method == DEINTERLACE_ONEFIELD)) { -    XvMCPutSurface(this->display, &this->cur_frame->surface, -		   this->drawable, -		   this->sc.displayed_xoffset, this->sc.displayed_yoffset, -		   this->sc.displayed_width, this->sc.displayed_height, -		   this->sc.output_xoffset, this->sc.output_yoffset, -		   this->sc.output_width, this->sc.output_height, -		   XVMC_TOP_FIELD); -  } else { /* WEAVE */ -    XvMCPutSurface(this->display, &this->cur_frame->surface, -		   this->drawable, -		   this->sc.displayed_xoffset, this->sc.displayed_yoffset, -		   this->sc.displayed_width, this->sc.displayed_height, -		   this->sc.output_xoffset, this->sc.output_yoffset, -		   this->sc.output_width, this->sc.output_height, -		   XVMC_FRAME_PICTURE); -  } +  XvMCPutSurface(this->display, &this->cur_frame->surface, +		 this->drawable, +		 this->sc.displayed_xoffset, this->sc.displayed_yoffset, +		 this->sc.displayed_width, this->sc.displayed_height, +		 this->sc.output_xoffset, this->sc.output_yoffset, +		 this->sc.output_width, this->sc.output_height, +		 XVMC_FRAME_PICTURE);    XUnlockDisplay (this->display); @@ -1064,16 +1045,6 @@ static int xvmc_set_property (vo_driver_t *this_gen,    }     else {      switch (property) { -    case VO_PROP_INTERLACED: -      this->props[property].value = value; -      lprintf("VO_PROP_INTERLACED(%d)\n", this->props[property].value); -      this->deinterlace_enabled = value; - -      if (this->deinterlace_method == DEINTERLACE_ONEFIELDXV) { -	xvmc_compute_ideal_size (this); -      } -      break; -      case VO_PROP_ASPECT_RATIO:        if (value>=XINE_VO_ASPECT_NUM_RATIOS)  	value = XINE_VO_ASPECT_AUTO; @@ -1252,13 +1223,13 @@ static void xvmc_dispose (vo_driver_t *this_gen) {  /* called xlocked */  static void xvmc_check_capability (xvmc_driver_t *this, -				   int property, XvAttribute attr, -				   int base_id, char *str_prop, -				   char *config_name, -				   char *config_desc, -				   char *config_help) { +				   int property, XvAttribute attr, int base_id, +				   const char *config_name, +				   const char *config_desc, +				   const char *config_help) {    int          int_default;    cfg_entry_t *entry; +  const char  *str_prop = attr.name;    /*     * some Xv drivers (Gatos ATI) report some ~0 as max values, this is confusing. @@ -1281,13 +1252,13 @@ static void xvmc_check_capability (xvmc_driver_t *this,      if ((attr.min_value == 0) && (attr.max_value == 1)) {        this->config->register_bool (this->config, config_name, int_default,  				   config_desc, -				   NULL, 20, xvmc_property_callback, &this->props[property]); +				   config_help, 20, xvmc_property_callback, &this->props[property]);      } else {        this->config->register_range (this->config, config_name, int_default,  				    this->props[property].min, this->props[property].max,  				    config_desc, -				    NULL, 20, xvmc_property_callback, &this->props[property]); +				    config_help, 20, xvmc_property_callback, &this->props[property]);      }      entry = this->config->lookup_entry (this->config, config_name); @@ -1305,14 +1276,6 @@ static void xvmc_check_capability (xvmc_driver_t *this,      this->props[property].value  = int_default;  } -static void xvmc_update_deinterlace(void *this_gen, xine_cfg_entry_t *entry) { -  xvmc_driver_t *this = (xvmc_driver_t *) this_gen; - -  lprintf ("xvmc_update_deinterlace method = %d\n",entry->num_value); -   -  this->deinterlace_method = entry->num_value; -} -  static void xvmc_update_XV_DOUBLE_BUFFER(void *this_gen, xine_cfg_entry_t *entry)  {    xvmc_driver_t *this = (xvmc_driver_t *) this_gen; @@ -1333,7 +1296,6 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi    xvmc_class_t         *class   = (xvmc_class_t *) class_gen;    config_values_t      *config  = class->config;    xvmc_driver_t        *this    = NULL; -  Display              *display = NULL;    unsigned int          i, formats;    XvPortID              xv_port = class->xv_port;    XvAttribute          *attr; @@ -1341,13 +1303,12 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi    int                   nattr;    x11_visual_t         *visual  = (x11_visual_t *) visual_gen;    XColor                dummy; +  XvAdaptorInfo        *adaptor_info; +  unsigned int          adaptor_num;    /* XvImage              *myimage; */    lprintf ("open_plugin\n"); -  display = visual->display; -   -  /* TODO ???  */    this = (xvmc_driver_t *) xine_xmalloc (sizeof (xvmc_driver_t));    if (!this) @@ -1371,7 +1332,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi    XLockDisplay(this->display);    this->gc                 = XCreateGC(this->display, this->drawable, 0, NULL);    XUnlockDisplay(this->display); -  this->capabilities       = VO_CAP_XVMC_MOCOMP | VO_CAP_CROP; +  this->capabilities       = VO_CAP_XVMC_MOCOMP | VO_CAP_CROP | VO_CAP_ZOOM_X | VO_CAP_ZOOM_Y;    this->surface_type_id    = class->surface_type_id;    this->max_surface_width  = class->max_surface_width; @@ -1383,7 +1344,6 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi    /* TODO CLEAN UP THIS */    this->user_data          = visual->user_data; -  this->deinterlace_method = 0;    this->use_colorkey       = 0;    this->colorkey           = 0; @@ -1430,56 +1390,53 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi      this->capabilities |= VO_CAP_XVMC_IDCT;    XLockDisplay(this->display); -  attr = XvQueryPortAttributes(display, xv_port, &nattr); +  attr = XvQueryPortAttributes(this->display, xv_port, &nattr);    if(attr && nattr) {      int k;      for(k = 0; k < nattr; k++) {        if((attr[k].flags & XvSettable) && (attr[k].flags & XvGettable)) { -	if(!strcmp(attr[k].name, "XV_HUE")) { -	  xvmc_check_capability (this, VO_PROP_HUE, attr[k], -				 class->adaptor_info[class->adaptor_num].base_id, "XV_HUE", -				 NULL, NULL, NULL); - -	} else if(!strcmp(attr[k].name, "XV_SATURATION")) { +	const char *const name = attr[k].name; +	if(!strcmp(name, "XV_HUE")) { +	  if (!strncmp(adaptor_info[adaptor_num].name, "NV", 2)) { +            xprintf (this->xine, XINE_VERBOSITY_NONE, LOG_MODULE ": ignoring broken XV_HUE settings on NVidia cards\n"); +	  } else { +	    this->capabilities |= VO_CAP_HUE; +	    xvmc_check_capability (this, VO_PROP_HUE, attr[k], +				   adaptor_info[adaptor_num].base_id, +				   NULL, NULL, NULL); +	  } +	} else if(!strcmp(name, "XV_SATURATION")) { +	  this->capabilities |= VO_CAP_SATURATION;  	  xvmc_check_capability (this, VO_PROP_SATURATION, attr[k], -				 class->adaptor_info[class->adaptor_num].base_id, "XV_SATURATION", +				 adaptor_info[adaptor_num].base_id,  				 NULL, NULL, NULL); -  	} else if(!strcmp(attr[k].name, "XV_BRIGHTNESS")) { +	  this->capabilities |= VO_CAP_BRIGHTNESS;  	  xvmc_check_capability (this, VO_PROP_BRIGHTNESS, attr[k], -				 class->adaptor_info[class->adaptor_num].base_id, "XV_BRIGHTNESS", +				 adaptor_info[adaptor_num].base_id,  				 NULL, NULL, NULL); - -	} else if(!strcmp(attr[k].name, "XV_CONTRAST")) { +	} else if(!strcmp(name, "XV_CONTRAST")) { +	  this->capabilities |= VO_CAP_CONTRAST;  	  xvmc_check_capability (this, VO_PROP_CONTRAST, attr[k], -				 class->adaptor_info[class->adaptor_num].base_id, "XV_CONTRAST", +				 adaptor_info[adaptor_num].base_id,  				 NULL, NULL, NULL); - -	} else if(!strcmp(attr[k].name, "XV_COLORKEY")) { +	} else if(!strcmp(name, "XV_COLORKEY")) { +	  this->capabilities |= VO_CAP_COLORKEY;  	  xvmc_check_capability (this, VO_PROP_COLORKEY, attr[k], -				 class->adaptor_info[class->adaptor_num].base_id, "XV_COLORKEY", +				 adaptor_info[adaptor_num].base_id,  				 "video.device.xv_colorkey", -				 _("video overlay colour key"), -			         _("The colour key is used to tell the graphics card where to " -				   "overlay the video image. Try different values, if you experience " -				   "windows becoming transparent.")); - -	} else if(!strcmp(attr[k].name, "XV_AUTOPAINT_COLORKEY")) { +				 VIDEO_DEVICE_XV_COLORKEY_HELP); +	} else if(!strcmp(name, "XV_AUTOPAINT_COLORKEY")) { +	  this->capabilities |= VO_CAP_AUTOPAINT_COLORKEY;  	  xvmc_check_capability (this, VO_PROP_AUTOPAINT_COLORKEY, attr[k], -				 class->adaptor_info[class->adaptor_num].base_id, "XV_AUTOPAINT_COLORKEY", +				 adaptor_info[adaptor_num].base_id,  				 "video.device.xv_autopaint_colorkey", -				 _("autopaint colour key"), -				 _("Make Xv autopaint its colour key.")); - -	} else if(!strcmp(attr[k].name, "XV_DOUBLE_BUFFER")) { -	  int xvmc_double_buffer; -	  xvmc_double_buffer = config->register_bool (config, "video.device.xv_double_buffer", 1, -	    _("enable double buffering"), -	    _("Double buffering will synchronize the update of the video image to the " -	      "repainting of the entire screen (\"vertical retrace\"). This eliminates " -	      "flickering and tearing artifacts, but will use more graphics memory."), -	    20, xvmc_update_XV_DOUBLE_BUFFER, this); +				 VIDEO_DEVICE_XV_AUTOPAINT_COLORKEY_HELP); +	} else if(!strcmp(name, "XV_DOUBLE_BUFFER")) { +	  int xvmc_double_buffer = config->register_bool (config, "video.device.xv_double_buffer", 1, +				   VIDEO_DEVICE_XV_DOUBLE_BUFFER_HELP, +				   20, xvmc_update_XV_DOUBLE_BUFFER, this);  	  config->update_num(config,"video.device.xv_double_buffer",xvmc_double_buffer);  	}        } @@ -1494,7 +1451,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi    /*     * check supported image formats     */ -  fo = XvListImageFormats(display, this->xv_port, (int*)&formats); +  fo = XvListImageFormats(this->display, this->xv_port, (int*)&formats);    XUnlockDisplay(this->display);    this->xvmc_format_yv12 = 0; @@ -1505,15 +1462,21 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi  	     fo[i].id, (char*)&fo[i].id,  	     (fo[i].format == XvPacked) ? "packed" : "planar"); -    if (fo[i].id == XINE_IMGFMT_YV12)  { +    switch (fo[i].id) { +    case XINE_IMGFMT_YV12:        this->xvmc_format_yv12 = fo[i].id; -      this->capabilities     |= VO_CAP_YV12; -      lprintf("this adaptor supports the yv12 format.\n"); -    } -    else if (fo[i].id == XINE_IMGFMT_YUY2) { +      this->capabilities |= VO_CAP_YV12; +      xprintf(this->xine, XINE_VERBOSITY_LOG, +	      _("%s: this adaptor supports the %s format.\n"), LOG_MODULE, "YV12"); +      break; +    case XINE_IMGFMT_YUY2:        this->xvmc_format_yuy2 = fo[i].id; -      this->capabilities     |= VO_CAP_YUY2; -      lprintf("this adaptor supports the yuy2 format.\n"); +      this->capabilities |= VO_CAP_YUY2; +      xprintf(this->xine, XINE_VERBOSITY_LOG,  +	      _("%s: this adaptor supports the %s format.\n"), LOG_MODULE, "YUY2"); +      break; +    default: +      break;      }    } @@ -1534,65 +1497,6 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi      dispose_ximage (this, &myshminfo, myimage);      XUnLockDisplay(this->display);    */ -   -  this->deinterlace_method = -    config->register_enum (config, "video.output.xv_deinterlace_method", 4, -			   deinterlace_methods,  -			   _("deinterlace method (deprecated)"), -			   _("This config setting is deprecated. You should use the new deinterlacing " -			     "post processing settings instead.\n\n" -			     "From the old days of analog television, where the even and odd numbered " -			     "lines of a video frame would be displayed at different times comes the " -			     "idea to increase motion smoothness by also recording the lines at " -			     "different times. This is called \"interlacing\". But unfortunately, " -			     "todays displays show the even and odd numbered lines as one complete frame " -			     "all at the same time (called \"progressive display\"), which results in " -			     "ugly frame errors known as comb artifacts. Software deinterlacing is an " -			     "approach to reduce these artifacts. The individual values are:\n\n" -			     "none\n" -			     "Disables software deinterlacing.\n\n" -			     "bob\n" -			     "Interpolates between the lines for moving parts of the image.\n\n" -			     "weave\n" -			     "Similar to bob, but with a tendency to preserve the full resolution, " -			     "better for high detail in low movement scenes.\n\n" -			     "greedy\n" -			     "Very good adaptive deinterlacer, but needs a lot of CPU power.\n\n" -			     "onefield\n" -			     "Always interpolates and reduces vertical resolution.\n\n" -			     "onefieldxv\n" -			     "Same as onefield, but does the interpolation in hardware.\n\n" -			     "linearblend\n" -			     "Applies a slight vertical blur to remove the comb artifacts. Good results " -			     "with medium CPU usage."), -			   10, xvmc_update_deinterlace, this); - -  this->deinterlace_enabled = 1;  /* default is enabled */ -  lprintf("deinterlace_methods %d ",this->deinterlace_method); - -  switch(this->deinterlace_method) { -  case DEINTERLACE_NONE:  -    lprintf("NONE\n");  -    break; -  case DEINTERLACE_BOB:  -    lprintf("BOB\n");  -    break; -  case DEINTERLACE_WEAVE:  -    lprintf("WEAVE\n"); -    break; -  case DEINTERLACE_GREEDY:  -    lprintf("GREEDY\n"); -    break; -  case DEINTERLACE_ONEFIELD:  -    lprintf("ONEFIELD\n"); -    break; -  case DEINTERLACE_ONEFIELDXV:  -    lprintf("ONEFIELDXV\n"); -    break; -  case DEINTERLACE_LINEARBLEND:  -    lprintf("LINEARBLEND\n");  -    break; -  }    lprintf("initialization of plugin successful\n");    return &this->vo_driver; @@ -1602,21 +1506,9 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi   * class functions   */ -static char* get_identifier (video_driver_class_t *this_gen) { -  return "XvMC"; -} - -static char* get_description (video_driver_class_t *this_gen) { -  return _("xine video output plugin using the XvMC X video extension"); -} -  static void dispose_class (video_driver_class_t *this_gen) {    xvmc_class_t        *this = (xvmc_class_t *) this_gen; -  XLockDisplay(this->display); -  XvFreeAdaptorInfo (this->adaptor_info); -  XUnlockDisplay(this->display); -      free (this);  } @@ -1782,15 +1674,13 @@ static void *init_class (xine_t *xine, void *visual_gen) {      return NULL;    this->driver_class.open_plugin     = open_plugin; -  this->driver_class.get_identifier  = get_identifier; -  this->driver_class.get_description = get_description; +  this->driver_class.identifier      = "XvMC"; +  this->driver_class.description     = N_("xine video output plugin using the XvMC X video extension");    this->driver_class.dispose         = dispose_class;    this->display                      = display;    this->config                       = xine->config;    this->xv_port                      = xv_port; -  this->adaptor_info                 = adaptor_info; -  this->adaptor_num                  = adaptor_num;    this->surface_type_id              = surface_type;    this->max_surface_width            = max_width;    this->max_surface_height           = max_height; @@ -1815,7 +1705,7 @@ static const vo_info_t vo_info_xvmc = {  const plugin_info_t xine_plugin_info[] EXPORTED = {    /* type, API, "name", version, special_info, init_function */ -  { PLUGIN_VIDEO_OUT, 21, "xvmc", XINE_VERSION_CODE, &vo_info_xvmc, init_class }, +  { PLUGIN_VIDEO_OUT, 22, "xvmc", XINE_VERSION_CODE, &vo_info_xvmc, init_class },    { PLUGIN_NONE, 0, "", 0, NULL, NULL }  }; | 
