diff --git a/src/gallium/frontends/vdpau/surface.c b/src/gallium/frontends/vdpau/surface.c index 4f072809fc9..de092ecfe1b 100644 --- a/src/gallium/frontends/vdpau/surface.c +++ b/src/gallium/frontends/vdpau/surface.c @@ -82,14 +82,7 @@ vlVdpVideoSurfaceCreate(VdpDevice device, VdpChromaType chroma_type, mtx_lock(&dev->mutex); memset(&p_surf->templat, 0, sizeof(p_surf->templat)); - /* TODO: buffer_format should be selected to match chroma_type */ - p_surf->templat.buffer_format = pipe->screen->get_video_param - ( - pipe->screen, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_PREFERED_FORMAT - ); + p_surf->templat.buffer_format = ChromaToPipeFormat(chroma_type); p_surf->templat.width = width; p_surf->templat.height = height; p_surf->templat.interlaced = pipe->screen->get_video_param diff --git a/src/gallium/frontends/vdpau/vdpau_private.h b/src/gallium/frontends/vdpau/vdpau_private.h index 08f9b64a1d2..ffa8aa6f41b 100644 --- a/src/gallium/frontends/vdpau/vdpau_private.h +++ b/src/gallium/frontends/vdpau/vdpau_private.h @@ -162,6 +162,23 @@ FormatYCBCRToPipe(VdpYCbCrFormat vdpau_format) } +static inline enum pipe_format +ChromaToPipeFormat(VdpChromaType vdpau_type) +{ + switch (vdpau_type) { + case VDP_CHROMA_TYPE_420: + return PIPE_FORMAT_NV12; +#ifdef VDP_CHROMA_TYPE_420_16 + case VDP_CHROMA_TYPE_420_16: + return PIPE_FORMAT_P016; +#endif + default: + assert(0); + } + + return PIPE_FORMAT_NONE; +} + static inline VdpYCbCrFormat PipeToFormatYCBCR(enum pipe_format p_format) {