* Preamble
*****************************************************************************/
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
#include <vlc_interface.h>
#include <vlc_vout.h>
#include <vlc_keys.h>
#include <X11/extensions/Xvlib.h>
#include <X11/extensions/vldXvMC.h>
-#include "../../codec/xxmc/accel_xvmc.h"
+#include "../../codec/xvmc/accel_xvmc.h"
#include "xcommon.h"
#include "../../codec/spudec/spudec.h"
#include <unistd.h>
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
-extern int E_(Activate) ( vlc_object_t * );
-extern void E_(Deactivate) ( vlc_object_t * );
+extern int Activate ( vlc_object_t * );
+extern void Deactivate ( vlc_object_t * );
/*****************************************************************************
* Module descriptor
#define CROP_TEXT N_("Crop")
#define CROP_LONGTEXT N_("You can choose the crop style to apply.")
-vlc_module_begin();
- set_shortname( "XVMC" );
- add_string( "xvmc-display", NULL, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT, VLC_TRUE );
- add_integer( "xvmc-adaptor", -1, NULL, ADAPTOR_TEXT, ADAPTOR_LONGTEXT, VLC_TRUE );
- add_bool( "xvmc-altfullscreen", 0, NULL, ALT_FS_TEXT, ALT_FS_LONGTEXT, VLC_TRUE );
- add_string( "xvmc-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT, VLC_TRUE );
+vlc_module_begin ()
+ set_shortname( "XVMC" )
+ add_string( "xvmc-display", NULL, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT, true )
+ add_integer( "xvmc-adaptor", -1, NULL, ADAPTOR_TEXT, ADAPTOR_LONGTEXT, true )
+ add_bool( "xvmc-altfullscreen", 0, NULL, ALT_FS_TEXT, ALT_FS_LONGTEXT, true )
+ add_string( "xvmc-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT, true )
#ifdef HAVE_SYS_SHM_H
- add_bool( "xvmc-shm", 1, NULL, SHM_TEXT, SHM_LONGTEXT, VLC_TRUE );
+ add_bool( "xvmc-shm", 1, NULL, SHM_TEXT, SHM_LONGTEXT, true )
#endif
#ifdef HAVE_XINERAMA
- add_integer ( "xvmc-xineramascreen", 0, NULL, SCREEN_TEXT, SCREEN_LONGTEXT, VLC_TRUE );
+ add_integer ( "xvmc-xineramascreen", -1, NULL, SCREEN_TEXT, SCREEN_LONGTEXT, true )
#endif
- add_string( "xvmc-deinterlace-mode", "bob", NULL, MODE_TEXT, MODE_LONGTEXT, VLC_FALSE );
- add_string( "xvmc-crop-style", "eq", NULL, CROP_TEXT, CROP_LONGTEXT, VLC_FALSE );
+ add_string( "xvmc-deinterlace-mode", "bob", NULL, MODE_TEXT, MODE_LONGTEXT, false )
+ add_string( "xvmc-crop-style", "eq", NULL, CROP_TEXT, CROP_LONGTEXT, false )
- set_description( _("XVMC extension video output") );
- set_capability( "video output", 160 );
- set_callbacks( E_(Activate), E_(Deactivate) );
-vlc_module_end();
+ set_description( N_("XVMC extension video output") )
+ set_capability( "video output", 10 )
+ set_callbacks( Activate, Deactivate )
+vlc_module_end ()
/* following functions are local */
-static unsigned accel_priority[] = {
+static const unsigned accel_priority[] = {
VLC_XVMC_ACCEL_VLD,
};
unsigned num_xvmc_components, char *xvmc_components )
{
const clut_t *color = (const clut_t *) icolor;
- int i;
+ unsigned int i;
for (i=0; i<num_xvmc_components; ++i)
{
unsigned first_xx44_entry, unsigned num_xx44_entries,
unsigned num_xvmc_components, char *xvmc_components )
{
- int i;
+ unsigned int i;
const uint32_t *cluts = p->cluts + first_xx44_entry;
for( i=0; i<num_xx44_entries; ++i )
static int xx44_paletteIndex( xx44_palette_t *p, int color, uint32_t clut )
{
- int i;
+ unsigned int i;
uint32_t *cluts = p->cluts;
int tmp;
{
uint8_t masked_val = val & mask;
- if (size < 0)
- return;
+/* size_t is unsigned, therefore always positive
+ if (size < 0)
+ return;*/
while(size--)
{
int clip_right;
int i_len, i_color;
uint16_t *p_source = NULL;
- uint16_t i_colprecomp, i_destalpha;
-
+#if 0
if (!sub_img)
return;
y_off = sub_img->i_y;
alphamask = (ia44) ? 0x0F : 0xF0;
p_source = (uint16_t *)sub_img->p_sys->p_data;
- i_colprecomp, i_destalpha;
dst_y = dst_img + dst_pitch*y_off + x_off;
}
dst_y += dst_pitch;
}
+#endif
}
int xxmc_xvmc_surface_valid( vout_thread_t *p_vout, XvMCSurface *surf )
{
xvmc_surface_handler_t *handler = &p_vout->p_sys->xvmc_surf_handler;
- unsigned int index = surf - handler->surfaces;
+ unsigned long index = surf - handler->surfaces;
int ret;
- if (index >= XVMC_MAX_SURFACES)
+ if( index >= XVMC_MAX_SURFACES )
return 0;
pthread_mutex_lock(&handler->mutex);
ret = handler->surfValid[index];
return NULL;
}
XVMCUNLOCKDISPLAY( p_vout->p_sys->p_display );
- msg_Dbg( p_vout, "video_out_xxmc: created subpicture %d\n", i );
+ msg_Dbg( p_vout, "video_out_xxmc: created subpicture %d", i );
handler->subInUse[i] = 1;
handler->subValid[i] = 1;
pthread_mutex_unlock( &handler->mutex );
XFree(surfaceInfo);
/*
- * Try to create a direct rendering context. This will fail if we are not
- * on the displaying computer or an indirect context is not available.
- */
+ * Try to create a direct rendering context. This will fail if we are not
+ * on the displaying computer or an indirect context is not available.
+ */
XVMCUNLOCKDISPLAY( p_vout->p_sys->p_display );
curCap = p_vout->p_sys->xvmc_cap;
if( Success == XvMCCreateContext( p_vout->p_sys->p_display, i_xvport,
curCap->type_id,
curCap->max_width,
curCap->max_height,
- XVMC_DIRECT, &c) )
+ XVMC_DIRECT, &c ) )
{
- p_vout->p_sys->context_flags = XVMC_DIRECT;
+ msg_Dbg( p_vout, "using direct XVMC rendering context" );
+ p_vout->p_sys->context_flags = XVMC_DIRECT;
}
else if( Success == XvMCCreateContext( p_vout->p_sys->p_display, i_xvport,
curCap->type_id,
curCap->max_width,
curCap->max_height,
- 0, &c) )
+ 0, &c ) )
{
+ msg_Dbg( p_vout, "using default XVMC rendering context" );
p_vout->p_sys->context_flags = 0;
}
else
{
- if( p_vout->p_sys->xvmc_cap )
- free( p_vout->p_sys->xvmc_cap );
+ free( p_vout->p_sys->xvmc_cap );
p_vout->p_sys->xvmc_cap = NULL;
msg_Err( p_vout, "use of direct XvMC context on a remote display failed"
" falling back to XV." );
}
XVMCLOCKDISPLAY( p_vout->p_sys->p_display );
XvMCDestroyContext( p_vout->p_sys->p_display, &c );
- xxmc_xvmc_surface_handler_construct(p_vout );
+ xxmc_xvmc_surface_handler_construct( p_vout );
/* p_vout->p_sys->capabilities |= VO_CAP_XXMC; */
XVMCUNLOCKDISPLAY( p_vout->p_sys->p_display );
init_xx44_palette( &p_vout->p_sys->palette , 0 );
XLockDisplay( p_vout->p_sys->p_display );
msg_Dbg(p_vout, "xxmc_setup_subpictures");
#ifdef HAVE_SYS_SHM_H
- if( p_vout->p_sys->b_shm )
+ if( p_vout->p_sys->i_shm_opcode )
{
/* Create image using XShm extension */
p_vout->p_sys->subImage = CreateShmImage( p_vout,
sp = xxmc_xvmc_alloc_subpicture( p_vout, &p_vout->p_sys->context,
width, height,
curCap->subPicType.id );
- if( !sp == NULL )
- return VLC_EGENERIC;
-
- init_xx44_palette( &p_vout->p_sys->palette, sp->num_palette_entries );
- p_vout->p_sys->xvmc_palette = (char *) malloc( sp->num_palette_entries
- * sp->entry_bytes );
- xxmc_xvmc_free_subpicture( p_vout, sp);
- if( !p_vout->p_sys->xvmc_pallette )
- return VLC_EGENERIC;
- p_vout->p_sys->hwSubpictures = 1;
+ if( sp )
+ {
+ init_xx44_palette( &p_vout->p_sys->palette, sp->num_palette_entries );
+ p_vout->p_sys->xvmc_palette = (char *) malloc( sp->num_palette_entries
+ * sp->entry_bytes );
+ xxmc_xvmc_free_subpicture( p_vout, sp);
+ if( !p_vout->p_sys->xvmc_palette )
+ return VLC_EGENERIC;
+ p_vout->p_sys->hwSubpictures = 1;
+ }
}
return VLC_SUCCESS;
}
if( handler->surfValid[i] && !handler->surfInUse[i] )
{
handler->surfInUse[i] = 1;
+ msg_Dbg( p_vout, "reusing surface %d", i );
xxmc_xvmc_dump_surfaces( p_vout );
pthread_mutex_unlock( &handler->mutex );
return (handler->surfaces + i);
if( !handler->surfInUse[i] )
{
XVMCLOCKDISPLAY( p_vout->p_sys->p_display );
- if( Success != XvMCCreateSurface( p_vout->p_sys->p_display
+ if( Success != XvMCCreateSurface( p_vout->p_sys->p_display,
context,
handler->surfaces + i) )
{
}
msg_Dbg( p_vout, "freeing up XvMC surfaces and subpictures" );
- if( p_vout->p_sys->xvmc_palette )
- free( p_vout->p_sys->xvmc_palette );
+ free( p_vout->p_sys->xvmc_palette );
dispose_xx44_palette( &p_vout->p_sys->palette );
xxmc_xvmc_destroy_subpictures( p_vout );
xxmc_xvmc_destroy_surfaces( p_vout );
static int xxmc_find_context( vout_thread_t *p_vout, vlc_xxmc_t *xxmc,
unsigned int width, unsigned int height )
{
- int i, k;
- vlc_bool_t found = VLC_FALSE;
+ unsigned int i, k;
+ bool found = false;
xvmc_capabilities_t *curCap = NULL;
unsigned int request_mpeg_flags, request_accel_flags;
(width <= curCap->max_width) &&
(height <= curCap->max_height) )
{
- found = VLC_TRUE;
+ found = true;
break;
}
curCap++;
xvmc_context_reader_lock( &p_vout->p_sys->xvmc_lock );
- if( ! xxmc_xvmc_surface_valid( p_vout, picture->p_sys->xvmc_surf)) {
+ if( !xxmc_xvmc_surface_valid( p_vout, picture->p_sys->xvmc_surf ) )
+ {
msg_Dbg(p_vout, "xvmc_flushsync 1 : %d", picture->p_sys->xxmc_data.result );
picture->p_sys->xxmc_data.result = 128;
xvmc_context_reader_unlock( &p_vout->p_sys->xvmc_lock );
/* Wait a little till frame is being displayed */
while( status & XVMC_DISPLAYING )
{
- msleep(1);
+ /* msleep(1); */
XvMCGetSurfaceStatus( p_vout->p_sys->p_display,
picture->p_sys->xvmc_surf,
XvImage *myimage )
{
# ifdef HAVE_SYS_SHM_H
- if( p_vout->p_sys->b_shm )
+ if( p_vout->p_sys->i_shm_opcode )
{
XShmDetach( p_vout->p_sys->p_display, shminfo );
XFree( myimage );
void xvmc_vld_frame( picture_t *picture )
{
- vout_sys_t *p_sys = picture->p_sys;
+ picture_sys_t *p_sys = picture->p_sys;
vout_thread_t *p_vout = p_sys->p_vout;
- vlc_vld_frame_t *vft = &(p_sys->xxmc_data.vld_frame);
- picture_t *ff = (picture_t *) vft->forward_reference_picture;
- picture_t *bf = (picture_t *) vft->backward_reference_picture;
+ vlc_vld_frame_t *vft = &(p_sys->xxmc_data.vld_frame);
+ picture_t *ff = (picture_t *) vft->forward_reference_picture;
+ picture_t *bf = (picture_t *) vft->backward_reference_picture;
XvMCMpegControl ctl;
XvMCSurface *fs=0, *bs=0;
XvMCQMatrix qmx;
qmx.load_chroma_non_intra_quantiser_matrix = 0;
xvmc_context_reader_lock( &p_vout->p_sys->xvmc_lock );
- if( ! xxmc_xvmc_surface_valid( p_vout, picture->p_sys->xvmc_surf) )
+ if( !xxmc_xvmc_surface_valid( p_vout, picture->p_sys->xvmc_surf ) )
{
picture->p_sys->xxmc_data.result = 128;
xvmc_context_reader_unlock( &p_vout->p_sys->xvmc_lock );
void xvmc_vld_slice( picture_t *picture )
{
- vout_sys_t *p_sys = picture->p_sys;
+ picture_sys_t *p_sys = picture->p_sys;
vout_thread_t *p_vout = p_sys->p_vout;
xvmc_context_reader_lock( &p_vout->p_sys->xvmc_lock );
picture->p_sys->xxmc_data.result =
XvMCPutSlice2( p_vout->p_sys->p_display,
&p_vout->p_sys->context,
- picture->p_sys->xxmc_data.slice_data,
+ (char *)picture->p_sys->xxmc_data.slice_data,
picture->p_sys->xxmc_data.slice_data_size,
picture->p_sys->xxmc_data.slice_code );