[vlc-devel] [PATCH 2/3] New video output for direct rendering of VAAPI decoded images.

Etienne Membrives etienne at membrives.fr
Wed Aug 5 13:17:06 CEST 2009


These three patches create a new picture type (fourcc 'VAAP'), a new video output and a chroma converter that use the Video Acceleration API (VAAPI) hardware acceleration to decode, display or help transcoding compressed videos. Due to the lack of implementation of subpicture blending in current VAAPI drivers, no OSD is available for the new video output.
---
 modules/codec/avcodec/chroma.c      |    4 +
 modules/codec/avcodec/vaapi.c       |   92 ++-----------------
 modules/codec/avcodec/vaapi.h       |   45 +++++++++-
 modules/codec/avcodec/video.c       |   20 ++++-
 modules/video_output/x11/Modules.am |    6 +
 modules/video_output/x11/vaapi.c    |  173 +++++++++++++++++++++++++++++++++++
 modules/video_output/x11/xcommon.c  |   56 ++++++++++--
 modules/video_output/x11/xcommon.h  |    7 ++
 8 files changed, 303 insertions(+), 100 deletions(-)
 create mode 100644 modules/video_output/x11/vaapi.c

diff --git a/modules/codec/avcodec/chroma.c b/modules/codec/avcodec/chroma.c
index 6e13170..9c3e733 100644
--- a/modules/codec/avcodec/chroma.c
+++ b/modules/codec/avcodec/chroma.c
@@ -74,6 +74,10 @@ static const struct
     {VLC_CODEC_J440, PIX_FMT_YUVJ440P, 0, 0, 0 },
 #endif
 
+#if HAVE_AVCODEC_VAAPI
+    {VLC_CODEC_VAAPI, PIX_FMT_VAAPI_VLD, 0, 0, 0 },
+#endif
+
     {VLC_CODEC_I422, PIX_FMT_YUV422P, 0, 0, 0 },
     {VLC_CODEC_J422, PIX_FMT_YUVJ422P, 0, 0, 0 },
 
diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index a9d4c6f..9cea964 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -46,44 +46,8 @@
 #ifdef HAVE_AVCODEC_VAAPI
 
 #include <X11/Xlib.h>
-#include <va/va_x11.h>
 
 
-typedef struct
-{
-    VASurfaceID  i_id;
-    int          i_refcount;
-    unsigned int i_order;
-
-} vlc_va_surface_t;
-
-struct vlc_va_t
-{
-    /* */
-    Display      *p_display_x11;
-    VADisplay     p_display;
-
-    VAConfigID    i_config_id;
-    VAContextID   i_context_id;
-
-    struct vaapi_context hw_ctx;
-
-    /* */
-    int i_version_major;
-    int i_version_minor;
-
-    /* */
-    int          i_surface_count;
-    unsigned int i_surface_order;
-    int          i_surface_width;
-    int          i_surface_height;
-    vlc_fourcc_t i_surface_chroma;
-
-    vlc_va_surface_t *p_surface;
-
-    VAImage      image;
-
-};
 
 static int VaOpen( vlc_va_t *p_va, int i_codec_id );
 static void VaClose( vlc_va_t *p_va );
@@ -200,6 +164,8 @@ static int VaOpen( vlc_va_t *p_va, int i_codec_id )
 
     p_va->i_surface_count = i_surface_count;
 
+    p_va->b_destroyed=false;
+
     return VLC_SUCCESS;
 
 error:
@@ -207,13 +173,17 @@ error:
 }
 static void VaClose( vlc_va_t *p_va )
 {
+    p_va->b_destroyed=true;
+
     if( p_va->i_surface_width || p_va->i_surface_height )
         VaDestroySurfaces( p_va );
 
     if( p_va->i_config_id )
         vaDestroyConfig( p_va->p_display, p_va->i_config_id );
+
     if( p_va->p_display )
         vaTerminate( p_va->p_display );
+
     if( p_va->p_display_x11 )
         XCloseDisplay( p_va->p_display_x11 );
 }
@@ -289,6 +259,7 @@ static int VaCreateSurfaces( vlc_va_t *p_va, void **pp_hw_ctx, vlc_fourcc_t *pi_
     if( !i_chroma )
         goto error;
     *pi_chroma = i_chroma;
+    //*pi_chroma =  VLC_FOURCC( 'V', 'A', 'A', 'P' ); /* We want to have a specific chroma */
 
     /* Create an image for surface extraction */
     if( vaCreateImage(  p_va->p_display, &fmt, i_width, i_height, &p_va->image ) )
@@ -340,55 +311,6 @@ static void VaDestroySurfaces( vlc_va_t *p_va )
     p_va->i_surface_height = 0;
 }
 
-int VaExtract( vlc_va_t *p_va, picture_t *p_picture, AVFrame *p_ff )
-{
-    VASurfaceID i_surface_id = (VASurfaceID)(uintptr_t)p_ff->data[3];
-
-    if( vaSyncSurface( p_va->p_display, p_va->i_context_id, i_surface_id ) )
-        return VLC_EGENERIC;
-
-    /* XXX vaDeriveImage may be better but it is not supported by
-     * my setup.
-     */
-
-    if( vaGetImage( p_va->p_display, i_surface_id,
-                    0, 0, p_va->i_surface_width, p_va->i_surface_height,
-                    p_va->image.image_id) )
-        return VLC_EGENERIC;
-
-    void *p_base;
-    if( vaMapBuffer( p_va->p_display, p_va->image.buf, &p_base ) )
-        return VLC_EGENERIC;
-
-    for( int i_plane = 0; i_plane < p_picture->i_planes; i_plane++ )
-    {
-        const int i_src_plane = ((p_va->image.format.fourcc == VA_FOURCC('Y','V','1','2' )) && i_plane != 0) ?  (3 - i_plane) : i_plane;
-        const uint8_t *p_src = (uint8_t*)p_base + p_va->image.offsets[i_src_plane];
-        const int i_src_stride = p_va->image.pitches[i_src_plane];
-
-        uint8_t *p_dst = p_picture->p[i_plane].p_pixels;
-        const int i_dst_stride = p_picture->p[i_plane].i_pitch;
-
-        if( i_src_stride != i_dst_stride )
-        {
-            for( int i = 0; i < p_picture->p[i_plane].i_visible_lines; i++ )
-            {
-                vlc_memcpy( p_dst, p_src, __MIN( i_src_stride, i_dst_stride ) );
-                p_src += i_src_stride;
-                p_dst += i_dst_stride;
-            }
-        }
-        else
-        {
-            vlc_memcpy( p_dst, p_src, p_picture->p[i_plane].i_visible_lines * i_src_stride );
-        }
-    }
-
-    if( vaUnmapBuffer( p_va->p_display, p_va->image.buf ) )
-        return VLC_EGENERIC;
-
-    return VLC_SUCCESS;
-}
 int VaGrabSurface( vlc_va_t *p_va, AVFrame *p_ff )
 {
     int i_old;
diff --git a/modules/codec/avcodec/vaapi.h b/modules/codec/avcodec/vaapi.h
index b8c6985..4c3c755 100644
--- a/modules/codec/avcodec/vaapi.h
+++ b/modules/codec/avcodec/vaapi.h
@@ -24,7 +24,48 @@
 #ifndef _VLC_VAAPI_H
 #define _VLC_VAAPI_H 1
 
-typedef struct vlc_va_t vlc_va_t;
+#include <va/va.h>
+#include <va/va_x11.h>
+#include <libavcodec/vaapi.h>
+#include <libavcodec/avcodec.h>
+
+typedef struct
+{
+    VASurfaceID  i_id;
+    int          i_refcount;
+    unsigned int i_order;
+
+} vlc_va_surface_t;
+
+typedef struct
+{
+    /* */
+    Display      *p_display_x11;
+    VADisplay     p_display;
+
+    VAConfigID    i_config_id;
+    VAContextID   i_context_id;
+
+    struct vaapi_context hw_ctx;
+
+    /* */
+    int i_version_major;
+    int i_version_minor;
+
+    /* */
+    int          i_surface_count;
+    unsigned int i_surface_order;
+    int          i_surface_width;
+    int          i_surface_height;
+    vlc_fourcc_t i_surface_chroma;
+
+    vlc_va_surface_t *p_surface;
+
+    VAImage      image;
+
+    /* */
+    bool b_destroyed;
+} vlc_va_t;
 
 vlc_va_t *VaNew( int i_codec_id );
 void VaDelete( vlc_va_t *p_va );
@@ -34,8 +75,6 @@ void VaVersion( vlc_va_t *p_va, char *psz_version, size_t i_version );
 int VaSetup( vlc_va_t *p_va, void **pp_hw_ctx, vlc_fourcc_t *pi_chroma,
              int i_width, int i_height );
 
-int VaExtract( vlc_va_t *p_va, picture_t *p_picture, AVFrame *p_ff );
-
 int VaGrabSurface( vlc_va_t *p_va, AVFrame *p_ff );
 
 void VaUngrabSurface( vlc_va_t *p_va, AVFrame *p_ff );
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index af268e0..1f9a2e2 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -144,6 +144,13 @@ static inline picture_t *ffmpeg_NewPictBuf( decoder_t *p_dec,
          * FIXME does it make sense here ? */
         p_dec->fmt_out.video.i_chroma = VLC_CODEC_I420;
     }
+
+    if (p_sys->p_va)
+    {
+        /* We want to output a specific chroma for "direct rendering"
+         */
+        p_dec->fmt_out.video.i_chroma = VLC_CODEC_VAAPI;
+    }
     p_dec->fmt_out.i_codec = p_dec->fmt_out.video.i_chroma;
 
     /* If an aspect-ratio was specified in the input format then force it */
@@ -358,8 +365,11 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
     p_dec->fmt_out.i_cat = VIDEO_ES;
     if( GetVlcChroma( &p_dec->fmt_out.video, p_context->pix_fmt ) != VLC_SUCCESS )
     {
-        /* we are doomed. but not really, because most codecs set their pix_fmt later on */
-        p_dec->fmt_out.i_codec = VLC_CODEC_I420;
+        if( p_sys->p_va )
+            p_dec->fmt_out.i_codec = VLC_CODEC_VAAPI;
+        else
+            /* we are doomed. but not really, because most codecs set their pix_fmt later on */
+            p_dec->fmt_out.i_codec = VLC_CODEC_I420;
     }
     p_dec->fmt_out.i_codec = p_dec->fmt_out.video.i_chroma;
 
@@ -750,6 +760,7 @@ picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
  *****************************************************************************/
 void EndVideoDec( decoder_t *p_dec )
 {
+    msg_Dbg( p_dec, "EndVideoDec called" );
     decoder_sys_t *p_sys = p_dec->p_sys;
 
     avcodec_flush_buffers( p_sys->p_context );
@@ -882,7 +893,10 @@ static void ffmpeg_CopyPicture( decoder_t *p_dec,
 
     if( p_sys->p_va )
     {
-        VaExtract( p_sys->p_va, p_pic, p_ff_pic );
+        VASurfaceID surface_id = (VASurfaceID)(uintptr_t)p_ff_pic->data[3];
+
+        memcpy(p_pic->p_data,&(p_sys->p_va),sizeof(vlc_va_t*));
+        memcpy(p_pic->p_data+sizeof(vlc_va_t*),&surface_id,sizeof(VASurfaceID));
     }
     else if( TestFfmpegChroma( p_sys->p_context->pix_fmt, -1 ) == VLC_SUCCESS )
     {
diff --git a/modules/video_output/x11/Modules.am b/modules/video_output/x11/Modules.am
index d00f375..d05e060 100644
--- a/modules/video_output/x11/Modules.am
+++ b/modules/video_output/x11/Modules.am
@@ -22,3 +22,9 @@ SOURCES_xvmc = \
         xcommon.h \
         $(NULL)
 
+SOURCES_vaapi = \
+        vaapi.c \
+        xcommon.c \
+        xcommon.h \
+        $(NULL)
+
diff --git a/modules/video_output/x11/vaapi.c b/modules/video_output/x11/vaapi.c
new file mode 100644
index 0000000..59f5217
--- /dev/null
+++ b/modules/video_output/x11/vaapi.c
@@ -0,0 +1,173 @@
+/*****************************************************************************
+ * vaapi.c : VAAPI plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 1998-2009 the VideoLAN team
+ *
+ * Authors: Etienne Membrives <etienne at membrives.fr>
+ *
+ * This program 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.
+ *
+ * This program 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
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_vout.h>
+#include <vlc_interface.h>
+#include <vlc_playlist.h>
+#include <vlc_keys.h>
+
+#ifdef HAVE_SYS_SHM_H
+#   include <sys/shm.h>                                /* shmget(), shmctl() */
+#endif
+
+#include <va/va_x11.h>
+#include <va/va.h>
+#include "../../codec/avcodec/vaapi.h"
+
+#include <X11/Xlib.h>
+#include <X11/Xproto.h>
+#include <X11/Xmd.h>
+#include <X11/Xutil.h>
+#include <X11/keysym.h>
+#include <X11/XF86keysym.h>
+#ifdef HAVE_SYS_SHM_H
+#   include <X11/extensions/XShm.h>
+#endif
+
+#include "xcommon.h"
+
+/*****************************************************************************
+ * Exported prototypes
+ *****************************************************************************/
+extern int  Activate   ( vlc_object_t * );
+extern void Deactivate ( vlc_object_t * );
+
+/*****************************************************************************
+ * Module descriptor
+ *****************************************************************************/
+#define ADAPTOR_TEXT N_("VA-API adaptor number")
+#define ADAPTOR_LONGTEXT N_( \
+    "If your graphics card provides several adaptors, you need to choose " \
+    "which one will be used (you shouldn't have to change this).")
+
+#define ALT_FS_TEXT N_("Alternate fullscreen method")
+#define ALT_FS_LONGTEXT N_( \
+    "There are two ways to make a fullscreen window, unfortunately each one " \
+    "has its drawbacks.\n" \
+    "1) Let the window manager handle your fullscreen window (default), but " \
+    "things like taskbars will likely show on top of the video.\n" \
+    "2) Completely bypass the window manager, but then nothing will be able " \
+    "to show on top of the video.")
+
+#define DISPLAY_TEXT N_("X11 display")
+#define DISPLAY_LONGTEXT N_( \
+    "X11 hardware display to use. By default VLC will " \
+    "use the value of the DISPLAY environment variable.")
+
+#define SHM_TEXT N_("Use shared memory")
+#define SHM_LONGTEXT N_( \
+    "Use shared memory to communicate between VLC and the X server.")
+
+#define SCREEN_TEXT N_("Screen for fullscreen mode.")
+#define SCREEN_LONGTEXT N_( \
+    "Screen to use in fullscreen mode. For instance " \
+    "set it to 0 for first screen, 1 for the second.")
+
+vlc_module_begin ()
+    set_shortname( "VAAPI" )
+    set_category( CAT_VIDEO )
+    set_subcategory( SUBCAT_VIDEO_VOUT )
+    add_string( "vaapi-display", NULL, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT, true )
+    add_integer( "vaapi-adaptor", -1, NULL, ADAPTOR_TEXT, ADAPTOR_LONGTEXT, true )
+    add_bool( "vaapi-altfullscreen", 0, NULL, ALT_FS_TEXT, ALT_FS_LONGTEXT, true )
+#ifdef HAVE_SYS_SHM_H
+    add_bool( "vaapi-shm", 1, NULL, SHM_TEXT, SHM_LONGTEXT, true )
+#endif
+#ifdef HAVE_XINERAMA
+    add_integer ( "vaapi-xineramascreen", -1, NULL, SCREEN_TEXT, SCREEN_LONGTEXT, true )
+#endif
+
+    set_description( N_("VAAPI extension video output") )
+    set_capability( "video output", 300 )
+    set_callbacks( Activate, Deactivate )
+vlc_module_end ()
+
+/* following functions are local */
+
+int StatusCheck( vout_thread_t* p_vout, VAStatus status, const char *msg )
+{
+    if ( status != VA_STATUS_SUCCESS )
+    {
+        msg_Err( p_vout, "[video_output x11_vaapi] %s: %s\n", msg, vaErrorStr( status ) );
+        return VLC_SUCCESS;
+    }
+    return VLC_EGENERIC;
+}
+
+
+/*****************************************************************************
+ * VAPutSurface
+ *****************************************************************************
+ * Puts a surface to display
+ *****************************************************************************/
+
+int VAPutSurface( vout_thread_t* p_vout, picture_t * p_pic, int i_x, int i_y, int i_width, int i_height )
+{
+    vlc_va_t* p_va;
+    VASurfaceID surface;
+    VAStatus status;
+
+    p_va=*((vlc_va_t **)p_pic->p_data);
+    memcpy(&surface,p_pic->p_data+sizeof(vlc_va_t*),sizeof(VASurfaceID));
+
+    if ( p_va==NULL )
+    {
+        msg_Err( p_vout, "No data to display" );
+        return VLC_EGENERIC;
+    }
+
+    if ( surface == 0 || p_va->b_destroyed == true ) {
+	msg_Err( p_vout, "No surface" );
+        goto error;
+    }
+
+    status = vaPutSurface( p_va->p_display,
+                           surface,
+                           p_vout->p_sys->p_win->video_window,
+                           0, 0, p_vout->output.i_width,
+			   p_vout->output.i_height,
+                           0,
+                           0,
+                           i_width,
+                           i_height,
+                           NULL, 0,
+                           VA_FRAME_PICTURE );
+
+    if ( StatusCheck( p_vout, status, "vaPutSurface()" ) )
+        goto error;
+
+    return VLC_SUCCESS;
+
+error:
+    return VLC_EGENERIC;
+}
+
diff --git a/modules/video_output/x11/xcommon.c b/modules/video_output/x11/xcommon.c
index 0391683..34a1d65 100644
--- a/modules/video_output/x11/xcommon.c
+++ b/modules/video_output/x11/xcommon.c
@@ -1,13 +1,14 @@
 /*****************************************************************************
  * xcommon.c: Functions common to the X11 and XVideo plugins
  *****************************************************************************
- * Copyright (C) 1998-2006 the VideoLAN team
+ * Copyright (C) 1998-2009 the VideoLAN team
  * $Id$
  *
  * Authors: Vincent Seguin <seguin at via.ecp.fr>
  *          Sam Hocevar <sam at zoy.org>
  *          David Kennedy <dkennedy at tinytoad.com>
  *          Gildas Bazin <gbazin at videolan.org>
+ *          Etienne Membrives <etienne at membrives.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -94,6 +95,12 @@
 #   include "../../codec/xvmc/accel_xvmc.h"
 #endif
 
+#ifdef MODULE_NAME_IS_vaapi
+#   include <va/va_x11.h>
+#   include <va/va.h>
+#   include "../../codec/avcodec/vaapi.h"
+#endif
+
 #include "xcommon.h"
 
 /*****************************************************************************
@@ -177,7 +184,7 @@ int Activate ( vlc_object_t *p_this )
 #if defined(MODULE_NAME_IS_xvmc)
     char *psz_value;
 #endif
-#if defined(MODULE_NAME_IS_xvideo) || defined(MODULE_NAME_IS_xvmc)
+#if defined(MODULE_NAME_IS_xvideo) || defined(MODULE_NAME_IS_xvmc) || defined(MODULE_NAME_IS_vaapi)
     char *       psz_chroma;
     vlc_fourcc_t i_chroma = 0;
     bool   b_chroma = 0;
@@ -285,7 +292,14 @@ int Activate ( vlc_object_t *p_this )
             }
         }
     }
+
     p_vout->output.i_chroma = vlc_fourcc_GetCodec( VIDEO_ES, X112VLC_FOURCC(p_vout->output.i_chroma) );
+#elif defined(MODULE_NAME_IS_vaapi)
+    p_vout->output.i_chroma = VLC_CODEC_VAAPI;
+
+    if ( p_vout->fmt_in.i_chroma != VLC_CODEC_VAAPI )
+        return VLC_EGENERIC;
+
 #elif defined(MODULE_NAME_IS_glx)
     {
         int i_opcode, i_evt, i_err = 0;
@@ -897,6 +911,15 @@ static int InitVideo( vout_thread_t *p_vout )
              p_vout->fmt_out.i_visible_height );
 #endif
 
+#ifdef MODULE_NAME_IS_vaapi
+    p_vout->output.i_width  = p_vout->render.i_width;
+    p_vout->output.i_height = p_vout->render.i_height;
+    p_vout->output.i_aspect = p_vout->render.i_aspect;
+
+    p_vout->fmt_out = p_vout->fmt_in;
+    p_vout->fmt_out.i_chroma = p_vout->output.i_chroma = VLC_CODEC_VAAPI;
+#endif
+
     /* Try to initialize up to MAX_DIRECTBUFFERS direct buffers */
     while( I_OUTPUTPICTURES < MAX_DIRECTBUFFERS )
     {
@@ -905,7 +928,7 @@ static int InitVideo( vout_thread_t *p_vout )
         /* Find an empty picture slot */
         for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
         {
-          if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
+            if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
             {
                 p_pic = p_vout->p_picture + i_index;
                 break;
@@ -951,6 +974,11 @@ static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
                        p_vout->p_sys->p_win->i_height,
                        &i_x, &i_y, &i_width, &i_height );
 
+#ifdef MODULE_NAME_IS_vaapi
+    VAPutSurface(p_vout, p_pic, i_x, i_y, i_width, i_height);
+    return;
+#endif
+
 #ifdef MODULE_NAME_IS_xvmc
     xvmc_context_reader_lock( &p_vout->p_sys->xvmc_lock );
 
@@ -1878,6 +1906,8 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
                        p_vout->output.i_aspect ) )
         return -1;
 
+
+#ifndef MODULE_NAME_IS_vaapi
 #ifdef HAVE_SYS_SHM_H
     if( p_vout->p_sys->i_shm_opcode )
     {
@@ -1926,6 +1956,9 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
         free( p_pic->p_sys );
         return -1;
     }
+#else
+    vout_AllocatePicture( p_vout, p_pic, VLC_CODEC_VAAPI, p_vout->output.i_width, p_vout->output.i_height, p_vout->output.i_aspect);
+#endif
 
     switch( p_vout->output.i_chroma )
     {
@@ -1939,7 +1972,6 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
         case VLC_CODEC_RGB16:
         case VLC_CODEC_RGB24: /* Fixme: pixel pitch == 4 ? */
         case VLC_CODEC_RGB32:
-
             for( i_plane = 0; i_plane < p_pic->p_sys->p_image->num_planes;
                  i_plane++ )
             {
@@ -1966,7 +1998,6 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
         case VLC_CODEC_RGB15:
         case VLC_CODEC_RGB24:
         case VLC_CODEC_RGB32:
-
             p_pic->p->i_lines = p_pic->p_sys->p_image->height;
             p_pic->p->i_visible_lines = p_pic->p_sys->p_image->height;
             p_pic->p->p_pixels = (uint8_t*)p_pic->p_sys->p_image->data
@@ -1979,7 +2010,12 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
                                          * p_pic->p_sys->p_image->width;
             break;
 #endif
-
+#ifdef MODULE_NAME_IS_vaapi
+        case VLC_CODEC_VAAPI:
+            p_pic->p->p_pixels = p_pic->p_data;
+            p_pic->p->i_visible_pitch = p_pic->p->i_pixel_pitch * p_pic->format.i_width;
+            break;
+#endif
         default:
             /* Unknown chroma, tell the guy to get lost */
             IMAGE_FREE( p_pic->p_sys->p_image );
@@ -2008,6 +2044,7 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
  *****************************************************************************/
 static void FreePicture( vout_thread_t *p_vout, picture_t *p_pic )
 {
+#ifndef MODULE_NAME_IS_vaapi
     /* The order of operations is correct */
 #ifdef HAVE_SYS_SHM_H
     if( p_vout->p_sys->i_shm_opcode )
@@ -2034,6 +2071,7 @@ static void FreePicture( vout_thread_t *p_vout, picture_t *p_pic )
         p_pic->p_sys->xvmc_surf = NULL;
     }
 #endif
+#endif
 
     /* Do NOT use XFlush here ! */
     XSync( p_vout->p_sys->p_display, False );
@@ -2989,13 +3027,13 @@ static IMAGE_TYPE * CreateImage( vout_thread_t *p_vout,
 {
     uint8_t *    p_data;                          /* image data storage zone */
     IMAGE_TYPE *p_image;
-#ifdef MODULE_NAME_IS_x11
+#if defined(MODULE_NAME_IS_x11)
     int         i_quantum;                     /* XImage quantum (see below) */
     int         i_bytes_per_line;
 #endif
 
     /* Allocate memory for image */
-#ifdef MODULE_NAME_IS_xvideo
+#if defined(MODULE_NAME_IS_xvideo)
     p_data = malloc( i_width * i_height * i_bits_per_pixel / 8 );
 #elif defined(MODULE_NAME_IS_x11)
     i_bytes_per_line = i_width * i_bytes_per_pixel;
@@ -3004,7 +3042,7 @@ static IMAGE_TYPE * CreateImage( vout_thread_t *p_vout,
     if( !p_data )
         return NULL;
 
-#ifdef MODULE_NAME_IS_x11
+#if defined(MODULE_NAME_IS_x11)
     /* Optimize the quantum of a scanline regarding its size - the quantum is
        a diviser of the number of bits between the start of two scanlines. */
     if( i_bytes_per_line & 0xf )
diff --git a/modules/video_output/x11/xcommon.h b/modules/video_output/x11/xcommon.h
index 736cfdf..8d0d2d4 100644
--- a/modules/video_output/x11/xcommon.h
+++ b/modules/video_output/x11/xcommon.h
@@ -402,5 +402,12 @@ static IMAGE_TYPE *CreateImage    ( vout_thread_t *,
 IMAGE_TYPE *CreateShmImage ( vout_thread_t *,
                                     Display *, EXTRA_ARGS_SHM, int, int );
 #endif
+
+/*****************************************************************************
+ * VAAPI defines
+ *****************************************************************************/
+#ifdef MODULE_NAME_IS_vaapi
+int VAPutSurface( vout_thread_t* p_vout, picture_t * p_pic, int i_x, int i_y, int i_width, int i_height );
+#endif
 #endif
 
-- 
1.6.3.3




More information about the vlc-devel mailing list