]> git.sesse.net Git - vlc/blobdiff - modules/video_output/x11/xvmc.c
Replace vlc_bool_t by bool, VLC_TRUE by true and VLC_FALSE by false.
[vlc] / modules / video_output / x11 / xvmc.c
index 153de41716812599ed4417972ddef4467c29d867..2bdcfd7225cfafb67bdf936d2a3bc46013f6bcfa 100644 (file)
  * Preamble
  *****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
 #include <vlc_interface.h>
 #include <vlc_vout.h>
@@ -64,7 +68,7 @@
 #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>
@@ -130,21 +134,21 @@ extern void E_(Deactivate) ( vlc_object_t * );
 
 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 );
+    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", 0, 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_capability( "video output", 10 );
     set_callbacks( E_(Activate), E_(Deactivate) );
 vlc_module_end();
 
@@ -238,7 +242,7 @@ static void colorToPalette( const uint32_t *icolor, unsigned char *palette_p,
                             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)
     {
@@ -258,7 +262,7 @@ void xx44_to_xvmc_palette( const xx44_palette_t *p,unsigned char *xvmc_palette,
                            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 )
@@ -274,7 +278,7 @@ void xx44_to_xvmc_palette( const xx44_palette_t *p,unsigned char *xvmc_palette,
 
 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;
 
@@ -306,8 +310,9 @@ static void memblend_xx44( uint8_t *mem, uint8_t val,
 {
     uint8_t masked_val = val & mask;
 
-    if (size < 0)
-        return;
+/* size_t is unsigned, therefore always positive
+   if (size < 0)
+        return;*/
 
     while(size--)
     {
@@ -334,8 +339,7 @@ void blend_xx44( uint8_t *dst_img, subpicture_t *sub_img,
     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;
 
@@ -345,7 +349,6 @@ void blend_xx44( uint8_t *dst_img, subpicture_t *sub_img,
     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;
 
@@ -465,15 +468,16 @@ void blend_xx44( uint8_t *dst_img, subpicture_t *sub_img,
         }
         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];
@@ -741,25 +745,27 @@ int checkXvMCCap( vout_thread_t *p_vout )
     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
@@ -774,7 +780,7 @@ int checkXvMCCap( vout_thread_t *p_vout )
     }
     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 );
@@ -806,7 +812,7 @@ static int xxmc_setup_subpictures( vout_thread_t *p_vout,
             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,
@@ -830,16 +836,16 @@ static int xxmc_setup_subpictures( vout_thread_t *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;
 }
@@ -956,6 +962,7 @@ static XvMCSurface *xxmc_xvmc_alloc_surface( vout_thread_t *p_vout,
         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);
@@ -966,7 +973,7 @@ static XvMCSurface *xxmc_xvmc_alloc_surface( vout_thread_t *p_vout,
         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) )
             {
@@ -1032,8 +1039,8 @@ void xxmc_dispose_context( vout_thread_t *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;
 
@@ -1059,7 +1066,7 @@ static int xxmc_find_context( vout_thread_t *p_vout, vlc_xxmc_t *xxmc,
                   (width <= curCap->max_width) &&
                   (height <= curCap->max_height) )
             {
-                found = VLC_TRUE;
+                found = true;
                 break;
             }
             curCap++;
@@ -1113,7 +1120,8 @@ static void xvmc_flushsync(picture_t *picture)
 
     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 );
@@ -1313,7 +1321,7 @@ static void dispose_ximage( vout_thread_t *p_vout, XShmSegmentInfo *shminfo,
                 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 );
@@ -1336,11 +1344,11 @@ static void dispose_ximage( vout_thread_t *p_vout, XShmSegmentInfo *shminfo,
 
 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;
@@ -1392,7 +1400,7 @@ void xvmc_vld_frame( picture_t *picture )
     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 );
@@ -1414,7 +1422,7 @@ void xvmc_vld_frame( picture_t *picture )
 
 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 );
@@ -1430,7 +1438,7 @@ void xvmc_vld_slice( picture_t *picture )
     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 );