[vlc-commits] vaapi: fix profiles detection.

Francois Cartegnie git at videolan.org
Tue Dec 6 16:48:50 CET 2011


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Dec  6 16:38:07 2011 +0100| [b1ae79cc89d54aa36556d46f71bd1becab6c1645] | committer: Jean-Paul Saman

vaapi: fix profiles detection.

The selected profile wasn't checked against card's ones.
(ex: resulting in sending MPEG2 to a VC1/h264 only card)

Signed-off-by: Jean-Paul Saman <jpsaman at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b1ae79cc89d54aa36556d46f71bd1becab6c1645
---

 modules/codec/avcodec/vaapi.c |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
index 710fddd..2ab53de 100644
--- a/modules/codec/avcodec/vaapi.c
+++ b/modules/codec/avcodec/vaapi.c
@@ -95,7 +95,9 @@ static vlc_va_vaapi_t *vlc_va_vaapi_Get( void *p_va )
 /* */
 static int Open( vlc_va_vaapi_t *p_va, int i_codec_id )
 {
-    VAProfile i_profile;
+    VAProfile i_profile, *p_profiles_list;
+    bool b_supported_profile = false;
+    int i_profiles_nb = 0;
     int i_surface_count;
 
     /* */
@@ -144,6 +146,28 @@ static int Open( vlc_va_vaapi_t *p_va, int i_codec_id )
     if( vaInitialize( p_va->p_display, &p_va->i_version_major, &p_va->i_version_minor ) )
         goto error;
 
+    /* Check if the selected profile is supported */
+    i_profiles_nb = vaMaxNumProfiles( p_va->p_display );
+    p_profiles_list = calloc( i_profiles_nb, sizeof( VAProfile ) );
+    if ( !p_profiles_list )
+        goto error;
+
+    VAStatus i_status = vaQueryConfigProfiles( p_va->p_display, p_profiles_list, &i_profiles_nb );
+    if ( i_status == VA_STATUS_SUCCESS )
+    {
+        for( int i = 0; i < i_profiles_nb; i++ )
+        {
+            if ( p_profiles_list[i] == i_profile )
+            {
+                b_supported_profile = true;
+                break;
+            }
+        }
+    }
+    free( p_profiles_list );
+    if ( !b_supported_profile )
+        goto error;
+
     /* Create a VA configuration */
     VAConfigAttrib attrib;
     memset( &attrib, 0, sizeof(attrib) );



More information about the vlc-commits mailing list