st/va: add config support for 10bit decoding v2
authorChristian König <christian.koenig@amd.com>
Mon, 6 Mar 2017 16:36:29 +0000 (17:36 +0100)
committerChristian König <christian.koenig@amd.com>
Mon, 13 Mar 2017 07:51:44 +0000 (08:51 +0100)
Advertise 10bpp support if the driver supports decoding to a P016 surface.

v2: Advertise 10bpp for the decoder as well.

Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Mark Thompson <sw@jkqxz.net>
src/gallium/state_trackers/va/config.c
src/gallium/state_trackers/va/va_private.h

index 15beb6cd00f957a2a3abe5b72112eb58dbacb6da..05f97a01eeb0ac447234becbd0cfe6cb75bb58eb 100644 (file)
@@ -108,17 +108,24 @@ VAStatus
 vlVaGetConfigAttributes(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint,
                         VAConfigAttrib *attrib_list, int num_attribs)
 {
+   struct pipe_screen *pscreen;
    int i;
 
    if (!ctx)
       return VA_STATUS_ERROR_INVALID_CONTEXT;
 
+   pscreen = VL_VA_PSCREEN(ctx);
+
    for (i = 0; i < num_attribs; ++i) {
       unsigned int value;
       if (entrypoint == VAEntrypointVLD) {
          switch (attrib_list[i].type) {
          case VAConfigAttribRTFormat:
             value = VA_RT_FORMAT_YUV420;
+           if (pscreen->is_video_format_supported(pscreen, PIPE_FORMAT_P016,
+                                                   ProfileToPipe(profile),
+                                                   PIPE_VIDEO_ENTRYPOINT_BITSTREAM))
+               value |= VA_RT_FORMAT_YUV420_10BPP;
             break;
          default:
             value = VA_ATTRIB_NOT_SUPPORTED;
@@ -146,6 +153,7 @@ vlVaGetConfigAttributes(VADriverContextP ctx, VAProfile profile, VAEntrypoint en
          switch (attrib_list[i].type) {
          case VAConfigAttribRTFormat:
             value = (VA_RT_FORMAT_YUV420 |
+                     VA_RT_FORMAT_YUV420_10BPP |
                      VA_RT_FORMAT_RGB32);
             break;
          default:
@@ -169,6 +177,7 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin
    vlVaConfig *config;
    struct pipe_screen *pscreen;
    enum pipe_video_profile p;
+   unsigned int supported_rt_formats;
 
    if (!ctx)
       return VA_STATUS_ERROR_INVALID_CONTEXT;
@@ -185,9 +194,12 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin
    if (profile == VAProfileNone && entrypoint == VAEntrypointVideoProc) {
       config->entrypoint = VAEntrypointVideoProc;
       config->profile = PIPE_VIDEO_PROFILE_UNKNOWN;
+      supported_rt_formats = VA_RT_FORMAT_YUV420 |
+                             VA_RT_FORMAT_YUV420_10BPP |
+                             VA_RT_FORMAT_RGB32;
       for (int i = 0; i < num_attribs; i++) {
          if (attrib_list[i].type == VAConfigAttribRTFormat) {
-            if (attrib_list[i].value & (VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_RGB32)) {
+            if (attrib_list[i].value & supported_rt_formats) {
                config->rt_format = attrib_list[i].value;
             } else {
                FREE(config);
@@ -198,7 +210,7 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin
 
       /* Default value if not specified in the input attributes. */
       if (!config->rt_format)
-         config->rt_format = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_RGB32;
+         config->rt_format = supported_rt_formats;
 
       mtx_lock(&drv->mutex);
       *config_id = handle_table_add(drv->htab, config);
@@ -241,6 +253,10 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin
    }
 
    config->profile = p;
+   supported_rt_formats = VA_RT_FORMAT_YUV420;
+   if (pscreen->is_video_format_supported(pscreen, PIPE_FORMAT_P016, p,
+                                         config->entrypoint))
+      supported_rt_formats |= VA_RT_FORMAT_YUV420_10BPP;
 
    for (int i = 0; i <num_attribs ; i++) {
       if (attrib_list[i].type == VAConfigAttribRateControl) {
@@ -252,7 +268,7 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin
             config->rc = PIPE_H264_ENC_RATE_CONTROL_METHOD_DISABLE;
       }
       if (attrib_list[i].type == VAConfigAttribRTFormat) {
-         if (attrib_list[i].value == VA_RT_FORMAT_YUV420) {
+         if (attrib_list[i].value & supported_rt_formats) {
             config->rt_format = attrib_list[i].value;
          } else {
             FREE(config);
@@ -263,7 +279,7 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin
 
    /* Default value if not specified in the input attributes. */
    if (!config->rt_format)
-      config->rt_format = VA_RT_FORMAT_YUV420;
+      config->rt_format = supported_rt_formats;
 
    mtx_lock(&drv->mutex);
    *config_id = handle_table_add(drv->htab, config);
index 7216aba4379dfb34599d2b2b35b6bc9047113b44..9c32c084ea92de3371e3332634db13194ba5ffc3 100644 (file)
@@ -57,6 +57,7 @@ ChromaToPipe(int format)
 {
    switch (format) {
    case VA_RT_FORMAT_YUV420:
+   case VA_RT_FORMAT_YUV420_10BPP:
       return PIPE_VIDEO_CHROMA_FORMAT_420;
    case VA_RT_FORMAT_YUV422:
       return PIPE_VIDEO_CHROMA_FORMAT_422;