st/va: Add support for P010, used for 10-bit videos
authorThong Thai <thong.thai@amd.com>
Wed, 18 Dec 2019 16:31:28 +0000 (11:31 -0500)
committerMarge Bot <eric+marge@anholt.net>
Fri, 3 Jan 2020 16:30:22 +0000 (16:30 +0000)
Signed-off-by: Thong Thai <thong.thai@amd.com>
Reviewed-by: Leo Liu <leo.liu@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3153>

src/gallium/state_trackers/va/image.c
src/gallium/state_trackers/va/picture.c
src/gallium/state_trackers/va/postproc.c
src/gallium/state_trackers/va/surface.c

index 1a0712c9761946bdf7859d07f326d5a312895c18..0a54a90cb4cfba5c73e94f28a2ea3c2206364c76 100644 (file)
@@ -279,6 +279,9 @@ vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image)
       img->pitches[0] = stride > 0 ? stride : w * 4;
       assert(img->pitches[0] >= (w * 4));
       break;
+
+   case VA_FOURCC('P','0','1','0'):
+   case VA_FOURCC('P','0','1','6'):
    case VA_FOURCC('N','V','1','2'):
       if (surf->buffer->interlaced) {
          struct pipe_video_buffer *new_buffer;
@@ -449,13 +452,20 @@ vlVaGetImage(VADriverContextP ctx, VASurfaceID surface, int x, int y,
       return VA_STATUS_ERROR_OPERATION_FAILED;
    }
 
+
    if (format != surf->buffer->buffer_format) {
       /* support NV12 to YV12 and IYUV conversion now only */
       if ((format == PIPE_FORMAT_YV12 &&
-          surf->buffer->buffer_format == PIPE_FORMAT_NV12) ||
-          (format == PIPE_FORMAT_IYUV &&
-          surf->buffer->buffer_format == PIPE_FORMAT_NV12))
+         surf->buffer->buffer_format == PIPE_FORMAT_NV12) ||
+         (format == PIPE_FORMAT_IYUV &&
+         surf->buffer->buffer_format == PIPE_FORMAT_NV12))
          convert = true;
+      else if (format == PIPE_FORMAT_NV12 &&
+         (surf->buffer->buffer_format == PIPE_FORMAT_P010 ||
+          surf->buffer->buffer_format == PIPE_FORMAT_P016)) {
+         mtx_unlock(&drv->mutex);
+         return VA_STATUS_ERROR_OPERATION_FAILED;
+      }
       else {
          mtx_unlock(&drv->mutex);
          return VA_STATUS_ERROR_OPERATION_FAILED;
index 04d2da0afeb732e4e4b9bee1b59b4d022732fe23..d292594590c6750351219a55c07930b772551a65 100644 (file)
@@ -81,6 +81,7 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID rende
           context->target->buffer_format != PIPE_FORMAT_B8G8R8X8_UNORM &&
           context->target->buffer_format != PIPE_FORMAT_R8G8B8X8_UNORM &&
           context->target->buffer_format != PIPE_FORMAT_NV12 &&
+          context->target->buffer_format != PIPE_FORMAT_P010 &&
           context->target->buffer_format != PIPE_FORMAT_P016)
          return VA_STATUS_ERROR_UNIMPLEMENTED;
 
index 3431b1b48c77786b38b6d17a7807d1571afad486..661e3bf941471139cc255f079dc210ef2f55085b 100644 (file)
@@ -353,6 +353,7 @@ vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver *drv, vlVaContext *contex
    dst_region = vlVaRegionDefault(param->output_region, dst_surface, &def_dst_region);
 
    if (context->target->buffer_format != PIPE_FORMAT_NV12 &&
+       context->target->buffer_format != PIPE_FORMAT_P010 &&
        context->target->buffer_format != PIPE_FORMAT_P016)
       return vlVaPostProcCompositor(drv, context, src_region, dst_region,
                                     src, context->target, deinterlace);
index 391eab65e69c806e8a76382686b9bfe4f7914e7c..47c6f9b06c90774647367a41d558623ae816cbc7 100644 (file)
@@ -754,18 +754,28 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format,
 
    memset(&templat, 0, sizeof(templat));
 
-   templat.buffer_format = pscreen->get_video_param(
-      pscreen,
-      PIPE_VIDEO_PROFILE_UNKNOWN,
-      PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
-      PIPE_VIDEO_CAP_PREFERED_FORMAT
-   );
-   templat.interlaced = pscreen->get_video_param(
-      pscreen,
-      PIPE_VIDEO_PROFILE_UNKNOWN,
-      PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
-      PIPE_VIDEO_CAP_PREFERS_INTERLACED
-   );
+   if (format == VA_RT_FORMAT_YUV420_10BPP)
+   {
+      templat.buffer_format = PIPE_FORMAT_P010;
+      templat.interlaced = false;
+   }
+   else
+   {
+      templat.buffer_format = pscreen->get_video_param(
+         pscreen,
+         PIPE_VIDEO_PROFILE_UNKNOWN,
+         PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
+         PIPE_VIDEO_CAP_PREFERED_FORMAT
+      );
+      templat.interlaced = pscreen->get_video_param(
+         pscreen,
+         PIPE_VIDEO_PROFILE_UNKNOWN,
+         PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
+         PIPE_VIDEO_CAP_PREFERS_INTERLACED
+      );
+   }
+   
+
 
    if (expected_fourcc) {
       enum pipe_format expected_format = VaFourccToPipeFormat(expected_fourcc);