[Libva] [PATCH v3 intel-driver 4/8] config: fix vaGetConfigAttributes() to validate profile/entrypoint.

Gwenole Beauchesne gb.devel at gmail.com
Thu May 15 03:07:54 PDT 2014


Factor out code to validate profile/entrypoint per the underlying
hardware capabilities. Also fix vaGetConfigAttributes() to really
validate the profile/entrypoint pair.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
---
 src/i965_drv_video.c | 145 +++++++++++++++++++++++++++------------------------
 1 file changed, 78 insertions(+), 67 deletions(-)

diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index 4f473ee..34c96e7 100755
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -512,6 +512,78 @@ i965_QueryConfigEntrypoints(VADriverContextP ctx,
     return n > 0 ? VA_STATUS_SUCCESS : VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
 }
 
+static VAStatus
+i965_validate_config(VADriverContextP ctx, VAProfile profile,
+    VAEntrypoint entrypoint)
+{
+    struct i965_driver_data * const i965 = i965_driver_data(ctx);
+    VAStatus va_status;
+
+    /* Validate profile & entrypoint */
+    switch (profile) {
+    case VAProfileMPEG2Simple:
+    case VAProfileMPEG2Main:
+        if ((HAS_MPEG2_DECODING(i965) && entrypoint == VAEntrypointVLD) ||
+            (HAS_MPEG2_ENCODING(i965) && entrypoint == VAEntrypointEncSlice)) {
+            va_status = VA_STATUS_SUCCESS;
+        } else {
+            va_status = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
+        }
+        break;
+
+    case VAProfileH264ConstrainedBaseline:
+    case VAProfileH264Main:
+    case VAProfileH264High:
+        if ((HAS_H264_DECODING(i965) && entrypoint == VAEntrypointVLD) ||
+            (HAS_H264_ENCODING(i965) && entrypoint == VAEntrypointEncSlice)) {
+            va_status = VA_STATUS_SUCCESS;
+        } else {
+            va_status = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
+        }
+        break;
+
+    case VAProfileVC1Simple:
+    case VAProfileVC1Main:
+    case VAProfileVC1Advanced:
+        if (HAS_VC1_DECODING(i965) && entrypoint == VAEntrypointVLD) {
+            va_status = VA_STATUS_SUCCESS;
+        } else {
+            va_status = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
+        }
+        break;
+
+    case VAProfileNone:
+        if (HAS_VPP(i965) && VAEntrypointVideoProc == entrypoint) {
+            va_status = VA_STATUS_SUCCESS;
+        } else {
+            va_status = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
+        }
+        break;
+
+    case VAProfileJPEGBaseline:
+        if (HAS_JPEG_DECODING(i965) && entrypoint == VAEntrypointVLD) {
+            va_status = VA_STATUS_SUCCESS;
+        } else {
+            va_status = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
+        }
+        break;
+
+    case VAProfileVP8Version0_3:
+        if ((HAS_VP8_DECODING(i965) && entrypoint == VAEntrypointVLD) ||
+            (HAS_VP8_ENCODING(i965) && entrypoint == VAEntrypointEncSlice)) {
+            va_status = VA_STATUS_SUCCESS;
+        } else {
+            va_status = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
+        }
+        break;
+
+    default:
+        va_status = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
+        break;
+    }
+    return va_status;
+}
+
 VAStatus 
 i965_GetConfigAttributes(VADriverContextP ctx,
                          VAProfile profile,
@@ -519,8 +591,13 @@ i965_GetConfigAttributes(VADriverContextP ctx,
                          VAConfigAttrib *attrib_list,  /* in/out */
                          int num_attribs)
 {
+    VAStatus va_status;
     int i;
 
+    va_status = i965_validate_config(ctx, profile, entrypoint);
+    if (va_status != VA_STATUS_SUCCESS)
+        return va_status;
+
     /* Other attributes don't seem to be defined */
     /* What to do if we don't know the attribute? */
     for (i = 0; i < num_attribs; i++) {
@@ -606,73 +683,7 @@ i965_CreateConfig(VADriverContextP ctx,
     int i;
     VAStatus vaStatus;
 
-    /* Validate profile & entrypoint */
-    switch (profile) {
-    case VAProfileMPEG2Simple:
-    case VAProfileMPEG2Main:
-        if ((HAS_MPEG2_DECODING(i965) && VAEntrypointVLD == entrypoint) ||
-            (HAS_MPEG2_ENCODING(i965) && VAEntrypointEncSlice == entrypoint)) {
-            vaStatus = VA_STATUS_SUCCESS;
-        } else {
-            vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
-        }
-        break;
-
-    case VAProfileH264ConstrainedBaseline:
-    case VAProfileH264Main:
-    case VAProfileH264High:
-        if ((HAS_H264_DECODING(i965) && VAEntrypointVLD == entrypoint) ||
-            (HAS_H264_ENCODING(i965) && VAEntrypointEncSlice == entrypoint)) {
-            vaStatus = VA_STATUS_SUCCESS;
-        } else {
-            vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
-        }
-
-        break;
-
-    case VAProfileVC1Simple:
-    case VAProfileVC1Main:
-    case VAProfileVC1Advanced:
-        if (HAS_VC1_DECODING(i965) && VAEntrypointVLD == entrypoint) {
-            vaStatus = VA_STATUS_SUCCESS;
-        } else {
-            vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
-        }
-
-        break;
-
-    case VAProfileNone:
-        if (HAS_VPP(i965) && VAEntrypointVideoProc == entrypoint) {
-            vaStatus = VA_STATUS_SUCCESS;
-        } else {
-            vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
-        }
-
-        break;
-
-    case VAProfileJPEGBaseline:
-        if (HAS_JPEG_DECODING(i965) && VAEntrypointVLD == entrypoint) {
-            vaStatus = VA_STATUS_SUCCESS;
-        } else {
-            vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
-        }
-
-        break;
-
-    case VAProfileVP8Version0_3:
-        if ((HAS_VP8_DECODING(i965) && VAEntrypointVLD == entrypoint) ||
-            (HAS_VP8_ENCODING(i965) && VAEntrypointEncSlice == entrypoint))
-            vaStatus = VA_STATUS_SUCCESS;
-        else
-            vaStatus = VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT;
-
-        break;
-
-    default:
-        vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
-        break;
-    }
-
+    vaStatus = i965_validate_config(ctx, profile, entrypoint);
     if (VA_STATUS_SUCCESS != vaStatus) {
         return vaStatus;
     }
-- 
1.9.1



More information about the Libva mailing list