1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-25 16:33:02 +00:00

Move xv_port,xv_colorkey,xv_ck_info to x11 struct

This commit is contained in:
Uoti Urpala 2008-04-21 03:43:03 +03:00
parent 40f02f64fd
commit e66e17adc1
3 changed files with 71 additions and 73 deletions

View File

@ -266,9 +266,9 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
XMatchVisualInfo(x11->display, mScreen, depth, TrueColor, &vinfo);
xswa.background_pixel = 0;
if (xv_ck_info.method == CK_METHOD_BACKGROUND)
if (x11->xv_ck_info.method == CK_METHOD_BACKGROUND)
{
xswa.background_pixel = xv_colorkey;
xswa.background_pixel = x11->xv_colorkey;
}
xswa.border_pixel = 0;
xswamask = CWBackPixel | CWBorderPixel;
@ -324,7 +324,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
}
mp_msg(MSGT_VO, MSGL_V, "using Xvideo port %d for hw scaling\n",
xv_port);
x11->xv_port);
switch (ctx->xv_format)
{
@ -401,7 +401,7 @@ static void allocate_xvimage(struct vo *vo, int foo)
if (ctx->Shmem_Flag)
{
ctx->xvimage[foo] =
(XvImage *) XvShmCreateImage(x11->display, xv_port, ctx->xv_format,
(XvImage *) XvShmCreateImage(x11->display, x11->xv_port, ctx->xv_format,
NULL, ctx->image_width, ctx->image_height,
&ctx->Shminfo[foo]);
@ -418,7 +418,7 @@ static void allocate_xvimage(struct vo *vo, int foo)
#endif
{
ctx->xvimage[foo] =
(XvImage *) XvCreateImage(x11->display, xv_port, ctx->xv_format, NULL,
(XvImage *) XvCreateImage(x11->display, x11->xv_port, ctx->xv_format, NULL,
ctx->image_width, ctx->image_height);
ctx->xvimage[foo]->data = malloc(ctx->xvimage[foo]->data_size);
XSync(x11->display, False);
@ -453,7 +453,7 @@ static inline void put_xvimage(struct vo *vo, XvImage *xvi)
#ifdef HAVE_SHM
if (ctx->Shmem_Flag)
{
XvShmPutImage(x11->display, xv_port, x11->window, vo_gc,
XvShmPutImage(x11->display, x11->xv_port, x11->window, vo_gc,
xvi, 0, 0, ctx->image_width,
ctx->image_height, ctx->drwX - (vo_panscan_x >> 1),
ctx->drwY - (vo_panscan_y >> 1), vo->dwidth + vo_panscan_x,
@ -462,7 +462,7 @@ static inline void put_xvimage(struct vo *vo, XvImage *xvi)
} else
#endif
{
XvPutImage(x11->display, xv_port, x11->window, vo_gc,
XvPutImage(x11->display, x11->xv_port, x11->window, vo_gc,
xvi, 0, 0, ctx->image_width, ctx->image_height,
ctx->drwX - (vo_panscan_x >> 1), ctx->drwY - (vo_panscan_y >> 1),
vo->dwidth + vo_panscan_x,
@ -740,7 +740,7 @@ static int preinit(struct vo *vo, const char *arg)
{ NULL }
};
xv_port = 0;
x11->xv_port = 0;
/* parse suboptions */
if ( subopt_parse( arg, subopts ) != 0 )
@ -749,7 +749,7 @@ static int preinit(struct vo *vo, const char *arg)
}
/* modify colorkey settings according to the given options */
xv_setup_colorkeyhandling( ck_method_arg.str, ck_src_arg.str );
xv_setup_colorkeyhandling(vo, ck_method_arg.str, ck_src_arg.str);
if (!vo_init(vo))
return -1;
@ -773,7 +773,7 @@ static int preinit(struct vo *vo, const char *arg)
}
/* check adaptors */
if (xv_port)
if (x11->xv_port)
{
int port_found;
@ -784,7 +784,7 @@ static int preinit(struct vo *vo, const char *arg)
for (xv_p = ctx->ai[i].base_id;
xv_p < ctx->ai[i].base_id + ctx->ai[i].num_ports; ++xv_p)
{
if (xv_p == xv_port)
if (xv_p == x11->xv_port)
{
port_found = 1;
break;
@ -794,17 +794,17 @@ static int preinit(struct vo *vo, const char *arg)
}
if (port_found)
{
if (XvGrabPort(x11->display, xv_port, CurrentTime))
xv_port = 0;
if (XvGrabPort(x11->display, x11->xv_port, CurrentTime))
x11->xv_port = 0;
} else
{
mp_msg(MSGT_VO, MSGL_WARN,
MSGTR_LIBVO_XV_InvalidPortParameter);
xv_port = 0;
x11->xv_port = 0;
}
}
for (i = 0; i < ctx->adaptors && xv_port == 0; i++)
for (i = 0; i < ctx->adaptors && x11->xv_port == 0; i++)
{
if ((ctx->ai[i].type & XvInputMask) && (ctx->ai[i].type & XvImageMask))
{
@ -812,7 +812,7 @@ static int preinit(struct vo *vo, const char *arg)
xv_p < ctx->ai[i].base_id + ctx->ai[i].num_ports; ++xv_p)
if (!XvGrabPort(x11->display, xv_p, CurrentTime))
{
xv_port = xv_p;
x11->xv_port = xv_p;
break;
} else
{
@ -822,7 +822,7 @@ static int preinit(struct vo *vo, const char *arg)
}
}
}
if (!xv_port)
if (!x11->xv_port)
{
if (busy_ports)
mp_msg(MSGT_VO, MSGL_ERR,
@ -839,7 +839,7 @@ static int preinit(struct vo *vo, const char *arg)
vo_xv_enable_vsync(vo);
vo_xv_get_max_img_dim(vo, &ctx->max_width, &ctx->max_height);
ctx->fo = XvListImageFormats(x11->display, xv_port, (int *) &ctx->formats);
ctx->fo = XvListImageFormats(x11->display, x11->xv_port, (int *) &ctx->formats);
mp_input_add_event_fd(ConnectionNumber(x11->display), x11_fd_callback, vo);
ctx->event_fd_registered = 1;
@ -900,12 +900,12 @@ static int control(struct vo *vo, uint32_t request, void *data)
case VOCTRL_SET_EQUALIZER:
{
struct voctrl_set_equalizer_args *args = data;
return vo_xv_set_eq(vo, xv_port, args->name, args->value);
return vo_xv_set_eq(vo, x11->xv_port, args->name, args->value);
}
case VOCTRL_GET_EQUALIZER:
{
struct voctrl_get_equalizer_args *args = data;
return vo_xv_get_eq(vo, xv_port, args->name, args->valueptr);
return vo_xv_get_eq(vo, x11->xv_port, args->name, args->valueptr);
}
case VOCTRL_ONTOP:
vo_x11_ontop(vo);

View File

@ -107,7 +107,9 @@ static void saver_on(Display *);
void vo_x11_init_state(struct vo_x11_state *s)
{
*s = (struct vo_x11_state){};
*s = (struct vo_x11_state){
.xv_ck_info = { CK_METHOD_MANUALFILL, CK_SRC_CUR },
};
}
/*
@ -2183,11 +2185,6 @@ int vo_xv_get_eq(struct vo *vo, uint32_t xv_port, char *name, int *value)
return (VO_FALSE);
}
/** \brief contains flags changing the execution of the colorkeying code */
xv_ck_info_t xv_ck_info = { CK_METHOD_MANUALFILL, CK_SRC_CUR };
unsigned long xv_colorkey; ///< The color used for manual colorkeying.
unsigned int xv_port; ///< The selected Xv port.
/**
* \brief Interns the requested atom if it is available.
*
@ -2203,7 +2200,7 @@ static Atom xv_intern_atom_if_exists(struct vo_x11_state *x11,
int attrib_count,i;
Atom xv_atom = None;
attributes = XvQueryPortAttributes(x11->display, xv_port, &attrib_count );
attributes = XvQueryPortAttributes(x11->display, x11->xv_port, &attrib_count );
if( attributes!=NULL )
{
for ( i = 0; i < attrib_count; ++i )
@ -2230,7 +2227,7 @@ int vo_xv_enable_vsync(struct vo *vo)
Atom xv_atom = xv_intern_atom_if_exists(x11, "XV_SYNC_TO_VBLANK");
if (xv_atom == None)
return -1;
return XvSetPortAttribute(x11->display, xv_port, xv_atom, 1) == Success;
return XvSetPortAttribute(x11->display, x11->xv_port, xv_atom, 1) == Success;
}
/**
@ -2246,11 +2243,12 @@ int vo_xv_enable_vsync(struct vo *vo)
*/
void vo_xv_get_max_img_dim(struct vo *vo, uint32_t * width, uint32_t * height)
{
struct vo_x11_state *x11 = vo->x11;
XvEncodingInfo * encodings;
//unsigned long num_encodings, idx; to int or too long?!
unsigned int num_encodings, idx;
XvQueryEncodings(vo->x11->display, xv_port, &num_encodings, &encodings);
XvQueryEncodings(x11->display, x11->xv_port, &num_encodings, &encodings);
if ( encodings )
{
@ -2281,11 +2279,11 @@ void vo_xv_get_max_img_dim(struct vo *vo, uint32_t * width, uint32_t * height)
* Outputs the content of |ck_handling| as a readable message.
*
*/
void vo_xv_print_ck_info(void)
static void vo_xv_print_ck_info(struct vo_x11_state *x11)
{
mp_msg( MSGT_VO, MSGL_V, "[xv common] " );
switch ( xv_ck_info.method )
switch ( x11->xv_ck_info.method )
{
case CK_METHOD_NONE:
mp_msg( MSGT_VO, MSGL_V, "Drawing no colorkey.\n" ); return;
@ -2299,32 +2297,32 @@ void vo_xv_print_ck_info(void)
mp_msg( MSGT_VO, MSGL_V, "\n[xv common] " );
switch ( xv_ck_info.source )
switch ( x11->xv_ck_info.source )
{
case CK_SRC_CUR:
mp_msg( MSGT_VO, MSGL_V, "Using colorkey from Xv (0x%06lx).\n",
xv_colorkey );
x11->xv_colorkey );
break;
case CK_SRC_USE:
if ( xv_ck_info.method == CK_METHOD_AUTOPAINT )
if ( x11->xv_ck_info.method == CK_METHOD_AUTOPAINT )
{
mp_msg( MSGT_VO, MSGL_V,
"Ignoring colorkey from MPlayer (0x%06lx).\n",
xv_colorkey );
x11->xv_colorkey );
}
else
{
mp_msg( MSGT_VO, MSGL_V,
"Using colorkey from MPlayer (0x%06lx)."
" Use -colorkey to change.\n",
xv_colorkey );
x11->xv_colorkey );
}
break;
case CK_SRC_SET:
mp_msg( MSGT_VO, MSGL_V,
"Setting and using colorkey from MPlayer (0x%06lx)."
" Use -colorkey to change.\n",
xv_colorkey );
x11->xv_colorkey );
break;
}
}
@ -2362,16 +2360,16 @@ int vo_xv_init_colorkey(struct vo *vo)
if( xv_atom != None && !(vo_colorkey & 0xFF000000) )
{
/* check if we should use the colorkey specified in vo_colorkey */
if ( xv_ck_info.source != CK_SRC_CUR )
if ( x11->xv_ck_info.source != CK_SRC_CUR )
{
xv_colorkey = vo_colorkey;
x11->xv_colorkey = vo_colorkey;
/* check if we have to set the colorkey too */
if ( xv_ck_info.source == CK_SRC_SET )
if ( x11->xv_ck_info.source == CK_SRC_SET )
{
xv_atom = XInternAtom(x11->display, "XV_COLORKEY",False);
rez = XvSetPortAttribute(x11->display, xv_port, xv_atom, vo_colorkey);
rez = XvSetPortAttribute(x11->display, x11->xv_port, xv_atom, vo_colorkey);
if ( rez != Success )
{
mp_msg( MSGT_VO, MSGL_FATAL,
@ -2384,10 +2382,10 @@ int vo_xv_init_colorkey(struct vo *vo)
{
int colorkey_ret;
rez=XvGetPortAttribute(x11->display,xv_port, xv_atom, &colorkey_ret);
rez=XvGetPortAttribute(x11->display,x11->xv_port, xv_atom, &colorkey_ret);
if ( rez == Success )
{
xv_colorkey = colorkey_ret;
x11->xv_colorkey = colorkey_ret;
}
else
{
@ -2401,36 +2399,36 @@ int vo_xv_init_colorkey(struct vo *vo)
xv_atom = xv_intern_atom_if_exists(vo->x11, "XV_AUTOPAINT_COLORKEY");
/* should we draw the colorkey ourselves or activate autopainting? */
if ( xv_ck_info.method == CK_METHOD_AUTOPAINT )
if ( x11->xv_ck_info.method == CK_METHOD_AUTOPAINT )
{
rez = !Success; // reset rez to something different than Success
if ( xv_atom != None ) // autopaint is supported
{
rez = XvSetPortAttribute(x11->display, xv_port, xv_atom, 1);
rez = XvSetPortAttribute(x11->display, x11->xv_port, xv_atom, 1);
}
if ( rez != Success )
{
// fallback to manual colorkey drawing
xv_ck_info.method = CK_METHOD_MANUALFILL;
x11->xv_ck_info.method = CK_METHOD_MANUALFILL;
}
}
else // disable colorkey autopainting if supported
{
if ( xv_atom != None ) // we have autopaint attribute
{
XvSetPortAttribute(x11->display, xv_port, xv_atom, 0);
XvSetPortAttribute(x11->display, x11->xv_port, xv_atom, 0);
}
}
}
else // do no colorkey drawing at all
{
xv_ck_info.method = CK_METHOD_NONE;
x11->xv_ck_info.method = CK_METHOD_NONE;
} /* end: should we draw colorkey */
/* output information about the current colorkey settings */
vo_xv_print_ck_info();
vo_xv_print_ck_info(x11);
return 1; // success
}
@ -2450,10 +2448,10 @@ void vo_xv_draw_colorkey(struct vo *vo, int32_t x, int32_t y,
{
struct MPOpts *opts = vo->opts;
struct vo_x11_state *x11 = vo->x11;
if( xv_ck_info.method == CK_METHOD_MANUALFILL ||
xv_ck_info.method == CK_METHOD_BACKGROUND )//less tearing than XClearWindow()
if( x11->xv_ck_info.method == CK_METHOD_MANUALFILL ||
x11->xv_ck_info.method == CK_METHOD_BACKGROUND )//less tearing than XClearWindow()
{
XSetForeground(x11->display, vo_gc, xv_colorkey );
XSetForeground(x11->display, vo_gc, x11->xv_colorkey );
XFillRectangle(x11->display, x11->window, vo_gc,
x, y,
w, h );
@ -2525,19 +2523,20 @@ int xv_test_ckm( void * arg )
* \param str Pointer to the string or NULL
*
*/
void xv_setup_colorkeyhandling( char const * ck_method_str,
char const * ck_str )
void xv_setup_colorkeyhandling(struct vo *vo, const char *ck_method_str,
const char *ck_str)
{
struct vo_x11_state *x11 = vo->x11;
/* check if a valid pointer to the string was passed */
if ( ck_str )
{
if ( strncmp( ck_str, "use", 3 ) == 0 )
{
xv_ck_info.source = CK_SRC_USE;
x11->xv_ck_info.source = CK_SRC_USE;
}
else if ( strncmp( ck_str, "set", 3 ) == 0 )
{
xv_ck_info.source = CK_SRC_SET;
x11->xv_ck_info.source = CK_SRC_SET;
}
}
/* check if a valid pointer to the string was passed */
@ -2545,15 +2544,15 @@ void xv_setup_colorkeyhandling( char const * ck_method_str,
{
if ( strncmp( ck_method_str, "bg", 2 ) == 0 )
{
xv_ck_info.method = CK_METHOD_BACKGROUND;
x11->xv_ck_info.method = CK_METHOD_BACKGROUND;
}
else if ( strncmp( ck_method_str, "man", 3 ) == 0 )
{
xv_ck_info.method = CK_METHOD_MANUALFILL;
x11->xv_ck_info.method = CK_METHOD_MANUALFILL;
}
else if ( strncmp( ck_method_str, "auto", 4 ) == 0 )
{
xv_ck_info.method = CK_METHOD_AUTOPAINT;
x11->xv_ck_info.method = CK_METHOD_AUTOPAINT;
}
}
}

View File

@ -10,6 +10,14 @@ struct vo_x11_state {
Display *display;
Window window;
int depthonscreen;
struct xv_ck_info_s {
int method; ///< CK_METHOD_* constants
int source; ///< CK_SRC_* constants
} xv_ck_info;
unsigned long xv_colorkey;
unsigned int xv_port;
Atom XA_NET_SUPPORTED;
Atom XA_NET_WM_STATE;
Atom XA_NET_WM_STATE_FULLSCREEN;
@ -83,10 +91,6 @@ void vo_x11_ewmh_fullscreen(struct vo_x11_state *x11, int action);
extern GC vo_gc;
extern XSizeHints vo_hint;
#ifdef HAVE_XV
//XvPortID xv_port;
extern unsigned int xv_port;
int vo_xv_set_eq(struct vo *vo, uint32_t xv_port, char * name, int value);
int vo_xv_get_eq(struct vo *vo, uint32_t xv_port, char * name, int *value);
@ -95,11 +99,6 @@ int vo_xv_enable_vsync(struct vo *vo);
void vo_xv_get_max_img_dim(struct vo *vo, uint32_t * width, uint32_t * height);
/*** colorkey handling ***/
typedef struct xv_ck_info_s
{
int method; ///< CK_METHOD_* constants
int source; ///< CK_SRC_* constants
} xv_ck_info_t;
#define CK_METHOD_NONE 0 ///< no colorkey drawing
#define CK_METHOD_BACKGROUND 1 ///< set colorkey as window background
@ -109,17 +108,13 @@ typedef struct xv_ck_info_s
#define CK_SRC_SET 1 ///< use and set specified / default colorkey
#define CK_SRC_CUR 2 ///< use current colorkey ( get it from xv )
extern xv_ck_info_t xv_ck_info;
extern unsigned long xv_colorkey;
int vo_xv_init_colorkey(struct vo *vo);
void vo_xv_draw_colorkey(struct vo *vo, int32_t x, int32_t y, int32_t w, int32_t h);
extern void xv_setup_colorkeyhandling(char const * ck_method_str, char const * ck_str);
void xv_setup_colorkeyhandling(struct vo *vo, const char *ck_method_str, const char *ck_str);
/*** test functions for common suboptions ***/
int xv_test_ck( void * arg );
int xv_test_ckm( void * arg );
#endif
extern void vo_x11_putkey(int key);
@ -158,10 +153,14 @@ int vo_find_depth_from_visuals(Display *dpy, int screen, Visual **visual_return)
#define vo_x11_clearwindow(display, window) vo_x11_clearwindow(global_vo, window)
#define vo_x11_classhint(display, window, name) vo_x11_classhint(global_vo, window, name)
#define vo_x11_setlayer(display, window, layer) vo_x11_setlayer(global_vo, window, layer)
#define xv_setup_colorkeyhandling(a, b) xv_setup_colorkeyhandling(global_vo, a, b)
#define mDisplay global_vo->x11->display
#define vo_depthonscreen global_vo->x11->depthonscreen
#define vo_window global_vo->x11->window
#define xv_ck_info global_vo->x11->xv_ck_info
#define xv_colorkey global_vo->x11->xv_colorkey
#define xv_port global_vo->x11->xv_port
#endif
#endif /* MPLAYER_X11_COMMON_H */