17ec681f3Smrg/************************************************************************** 27ec681f3Smrg * 37ec681f3Smrg * Copyright 2010 Younes Manton & Thomas Balling Sørensen. 47ec681f3Smrg * All Rights Reserved. 57ec681f3Smrg * 67ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 77ec681f3Smrg * copy of this software and associated documentation files (the 87ec681f3Smrg * "Software"), to deal in the Software without restriction, including 97ec681f3Smrg * without limitation the rights to use, copy, modify, merge, publish, 107ec681f3Smrg * distribute, sub license, and/or sell copies of the Software, and to 117ec681f3Smrg * permit persons to whom the Software is furnished to do so, subject to 127ec681f3Smrg * the following conditions: 137ec681f3Smrg * 147ec681f3Smrg * The above copyright notice and this permission notice (including the 157ec681f3Smrg * next paragraph) shall be included in all copies or substantial portions 167ec681f3Smrg * of the Software. 177ec681f3Smrg * 187ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 197ec681f3Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 207ec681f3Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 217ec681f3Smrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 227ec681f3Smrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 237ec681f3Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 247ec681f3Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 257ec681f3Smrg * 267ec681f3Smrg **************************************************************************/ 277ec681f3Smrg 287ec681f3Smrg#ifndef VDPAU_PRIVATE_H 297ec681f3Smrg#define VDPAU_PRIVATE_H 307ec681f3Smrg 317ec681f3Smrg#include <assert.h> 327ec681f3Smrg 337ec681f3Smrg#include <vdpau/vdpau.h> 347ec681f3Smrg#include <vdpau/vdpau_x11.h> 357ec681f3Smrg 367ec681f3Smrg#include "pipe/p_compiler.h" 377ec681f3Smrg#include "pipe/p_video_codec.h" 387ec681f3Smrg 397ec681f3Smrg#include "frontend/vdpau_interop.h" 407ec681f3Smrg#include "frontend/vdpau_dmabuf.h" 417ec681f3Smrg#include "frontend/vdpau_funcs.h" 427ec681f3Smrg 437ec681f3Smrg#include "util/u_debug.h" 447ec681f3Smrg#include "util/u_rect.h" 457ec681f3Smrg#include "os/os_thread.h" 467ec681f3Smrg 477ec681f3Smrg#include "vl/vl_video_buffer.h" 487ec681f3Smrg#include "vl/vl_bicubic_filter.h" 497ec681f3Smrg#include "vl/vl_compositor.h" 507ec681f3Smrg#include "vl/vl_csc.h" 517ec681f3Smrg#include "vl/vl_deint_filter.h" 527ec681f3Smrg#include "vl/vl_matrix_filter.h" 537ec681f3Smrg#include "vl/vl_median_filter.h" 547ec681f3Smrg#include "vl/vl_winsys.h" 557ec681f3Smrg 567ec681f3Smrg/* Full VDPAU API documentation available at : 577ec681f3Smrg * ftp://download.nvidia.com/XFree86/vdpau/doxygen/html/index.html */ 587ec681f3Smrg 597ec681f3Smrg#define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR 607ec681f3Smrg#define QUOTEME(x) #x 617ec681f3Smrg#define TOSTRING(x) QUOTEME(x) 627ec681f3Smrg#define INFORMATION_STRING TOSTRING(INFORMATION) 637ec681f3Smrg 647ec681f3Smrgstatic inline enum pipe_video_chroma_format 657ec681f3SmrgChromaToPipe(VdpChromaType vdpau_type) 667ec681f3Smrg{ 677ec681f3Smrg switch (vdpau_type) { 687ec681f3Smrg case VDP_CHROMA_TYPE_420: 697ec681f3Smrg return PIPE_VIDEO_CHROMA_FORMAT_420; 707ec681f3Smrg case VDP_CHROMA_TYPE_422: 717ec681f3Smrg return PIPE_VIDEO_CHROMA_FORMAT_422; 727ec681f3Smrg case VDP_CHROMA_TYPE_444: 737ec681f3Smrg return PIPE_VIDEO_CHROMA_FORMAT_444; 747ec681f3Smrg default: 757ec681f3Smrg assert(0); 767ec681f3Smrg } 777ec681f3Smrg 787ec681f3Smrg return -1; 797ec681f3Smrg} 807ec681f3Smrg 817ec681f3Smrgstatic inline VdpChromaType 827ec681f3SmrgPipeToChroma(enum pipe_video_chroma_format pipe_type) 837ec681f3Smrg{ 847ec681f3Smrg switch (pipe_type) { 857ec681f3Smrg case PIPE_VIDEO_CHROMA_FORMAT_420: 867ec681f3Smrg return VDP_CHROMA_TYPE_420; 877ec681f3Smrg case PIPE_VIDEO_CHROMA_FORMAT_422: 887ec681f3Smrg return VDP_CHROMA_TYPE_422; 897ec681f3Smrg case PIPE_VIDEO_CHROMA_FORMAT_444: 907ec681f3Smrg return VDP_CHROMA_TYPE_444; 917ec681f3Smrg default: 927ec681f3Smrg assert(0); 937ec681f3Smrg } 947ec681f3Smrg 957ec681f3Smrg return -1; 967ec681f3Smrg} 977ec681f3Smrg 987ec681f3Smrgstatic inline enum pipe_video_chroma_format 997ec681f3SmrgFormatYCBCRToPipeChroma(VdpYCbCrFormat vdpau_format) 1007ec681f3Smrg{ 1017ec681f3Smrg switch (vdpau_format) { 1027ec681f3Smrg case VDP_YCBCR_FORMAT_NV12: 1037ec681f3Smrg return PIPE_VIDEO_CHROMA_FORMAT_420; 1047ec681f3Smrg case VDP_YCBCR_FORMAT_YV12: 1057ec681f3Smrg return PIPE_VIDEO_CHROMA_FORMAT_420; 1067ec681f3Smrg case VDP_YCBCR_FORMAT_UYVY: 1077ec681f3Smrg return PIPE_VIDEO_CHROMA_FORMAT_422; 1087ec681f3Smrg case VDP_YCBCR_FORMAT_YUYV: 1097ec681f3Smrg return PIPE_VIDEO_CHROMA_FORMAT_422; 1107ec681f3Smrg case VDP_YCBCR_FORMAT_Y8U8V8A8: 1117ec681f3Smrg return PIPE_VIDEO_CHROMA_FORMAT_444; 1127ec681f3Smrg case VDP_YCBCR_FORMAT_V8U8Y8A8: 1137ec681f3Smrg return PIPE_VIDEO_CHROMA_FORMAT_444; 1147ec681f3Smrg default: 1157ec681f3Smrg assert(0); 1167ec681f3Smrg } 1177ec681f3Smrg 1187ec681f3Smrg return PIPE_VIDEO_CHROMA_FORMAT_NONE; 1197ec681f3Smrg} 1207ec681f3Smrg 1217ec681f3Smrgstatic inline enum pipe_format 1227ec681f3SmrgFormatYCBCRToPipe(VdpYCbCrFormat vdpau_format) 1237ec681f3Smrg{ 1247ec681f3Smrg switch (vdpau_format) { 1257ec681f3Smrg case VDP_YCBCR_FORMAT_NV12: 1267ec681f3Smrg return PIPE_FORMAT_NV12; 1277ec681f3Smrg case VDP_YCBCR_FORMAT_YV12: 1287ec681f3Smrg return PIPE_FORMAT_YV12; 1297ec681f3Smrg case VDP_YCBCR_FORMAT_UYVY: 1307ec681f3Smrg return PIPE_FORMAT_UYVY; 1317ec681f3Smrg case VDP_YCBCR_FORMAT_YUYV: 1327ec681f3Smrg return PIPE_FORMAT_YUYV; 1337ec681f3Smrg case VDP_YCBCR_FORMAT_Y8U8V8A8: 1347ec681f3Smrg return PIPE_FORMAT_R8G8B8A8_UNORM; 1357ec681f3Smrg case VDP_YCBCR_FORMAT_V8U8Y8A8: 1367ec681f3Smrg return PIPE_FORMAT_B8G8R8A8_UNORM; 1377ec681f3Smrg#ifdef VDP_YCBCR_FORMAT_P010 1387ec681f3Smrg case VDP_YCBCR_FORMAT_P010: 1397ec681f3Smrg return PIPE_FORMAT_P010; 1407ec681f3Smrg#endif 1417ec681f3Smrg#ifdef VDP_YCBCR_FORMAT_P016 1427ec681f3Smrg case VDP_YCBCR_FORMAT_P016: 1437ec681f3Smrg return PIPE_FORMAT_P016; 1447ec681f3Smrg#endif 1457ec681f3Smrg default: 1467ec681f3Smrg /* NOTE: Can't be "unreachable", as it's quite reachable. */ 1477ec681f3Smrg debug_assert(!"unexpected VdpYCbCrFormat"); 1487ec681f3Smrg#if defined(NDEBUG) || defined(DEBUG) 1497ec681f3Smrg FALLTHROUGH; 1507ec681f3Smrg#endif 1517ec681f3Smrg#ifdef VDP_YCBCR_FORMAT_Y_UV_444 1527ec681f3Smrg case VDP_YCBCR_FORMAT_Y_UV_444: 1537ec681f3Smrg#endif 1547ec681f3Smrg#ifdef VDP_YCBCR_FORMAT_Y_U_V_444 1557ec681f3Smrg case VDP_YCBCR_FORMAT_Y_U_V_444: 1567ec681f3Smrg#endif 1577ec681f3Smrg#ifdef VDP_YCBCR_FORMAT_Y_U_V_444_16 1587ec681f3Smrg case VDP_YCBCR_FORMAT_Y_U_V_444_16: 1597ec681f3Smrg#endif 1607ec681f3Smrg return PIPE_FORMAT_NONE; 1617ec681f3Smrg } 1627ec681f3Smrg 1637ec681f3Smrg} 1647ec681f3Smrg 1657ec681f3Smrgstatic inline VdpYCbCrFormat 1667ec681f3SmrgPipeToFormatYCBCR(enum pipe_format p_format) 1677ec681f3Smrg{ 1687ec681f3Smrg switch (p_format) { 1697ec681f3Smrg case PIPE_FORMAT_NV12: 1707ec681f3Smrg return VDP_YCBCR_FORMAT_NV12; 1717ec681f3Smrg case PIPE_FORMAT_YV12: 1727ec681f3Smrg return VDP_YCBCR_FORMAT_YV12; 1737ec681f3Smrg case PIPE_FORMAT_UYVY: 1747ec681f3Smrg return VDP_YCBCR_FORMAT_UYVY; 1757ec681f3Smrg case PIPE_FORMAT_YUYV: 1767ec681f3Smrg return VDP_YCBCR_FORMAT_YUYV; 1777ec681f3Smrg case PIPE_FORMAT_R8G8B8A8_UNORM: 1787ec681f3Smrg return VDP_YCBCR_FORMAT_Y8U8V8A8; 1797ec681f3Smrg case PIPE_FORMAT_B8G8R8A8_UNORM: 1807ec681f3Smrg return VDP_YCBCR_FORMAT_V8U8Y8A8; 1817ec681f3Smrg default: 1827ec681f3Smrg assert(0); 1837ec681f3Smrg } 1847ec681f3Smrg 1857ec681f3Smrg return -1; 1867ec681f3Smrg} 1877ec681f3Smrg 1887ec681f3Smrgstatic inline VdpRGBAFormat 1897ec681f3SmrgPipeToFormatRGBA(enum pipe_format p_format) 1907ec681f3Smrg{ 1917ec681f3Smrg switch (p_format) { 1927ec681f3Smrg case PIPE_FORMAT_A8_UNORM: 1937ec681f3Smrg return VDP_RGBA_FORMAT_A8; 1947ec681f3Smrg case PIPE_FORMAT_B10G10R10A2_UNORM: 1957ec681f3Smrg return VDP_RGBA_FORMAT_B10G10R10A2; 1967ec681f3Smrg case PIPE_FORMAT_B8G8R8A8_UNORM: 1977ec681f3Smrg return VDP_RGBA_FORMAT_B8G8R8A8; 1987ec681f3Smrg case PIPE_FORMAT_R10G10B10A2_UNORM: 1997ec681f3Smrg return VDP_RGBA_FORMAT_R10G10B10A2; 2007ec681f3Smrg case PIPE_FORMAT_R8G8B8A8_UNORM: 2017ec681f3Smrg return VDP_RGBA_FORMAT_R8G8B8A8; 2027ec681f3Smrg default: 2037ec681f3Smrg assert(0); 2047ec681f3Smrg } 2057ec681f3Smrg 2067ec681f3Smrg return -1; 2077ec681f3Smrg} 2087ec681f3Smrg 2097ec681f3Smrgstatic inline enum pipe_format 2107ec681f3SmrgFormatIndexedToPipe(VdpRGBAFormat vdpau_format) 2117ec681f3Smrg{ 2127ec681f3Smrg switch (vdpau_format) { 2137ec681f3Smrg case VDP_INDEXED_FORMAT_A4I4: 2147ec681f3Smrg return PIPE_FORMAT_R4A4_UNORM; 2157ec681f3Smrg case VDP_INDEXED_FORMAT_I4A4: 2167ec681f3Smrg return PIPE_FORMAT_A4R4_UNORM; 2177ec681f3Smrg case VDP_INDEXED_FORMAT_A8I8: 2187ec681f3Smrg return PIPE_FORMAT_A8R8_UNORM; 2197ec681f3Smrg case VDP_INDEXED_FORMAT_I8A8: 2207ec681f3Smrg return PIPE_FORMAT_R8A8_UNORM; 2217ec681f3Smrg default: 2227ec681f3Smrg assert(0); 2237ec681f3Smrg } 2247ec681f3Smrg 2257ec681f3Smrg return PIPE_FORMAT_NONE; 2267ec681f3Smrg} 2277ec681f3Smrg 2287ec681f3Smrgstatic inline enum pipe_format 2297ec681f3SmrgFormatColorTableToPipe(VdpColorTableFormat vdpau_format) 2307ec681f3Smrg{ 2317ec681f3Smrg switch(vdpau_format) { 2327ec681f3Smrg case VDP_COLOR_TABLE_FORMAT_B8G8R8X8: 2337ec681f3Smrg return PIPE_FORMAT_B8G8R8X8_UNORM; 2347ec681f3Smrg default: 2357ec681f3Smrg assert(0); 2367ec681f3Smrg } 2377ec681f3Smrg 2387ec681f3Smrg return PIPE_FORMAT_NONE; 2397ec681f3Smrg} 2407ec681f3Smrg 2417ec681f3Smrgstatic inline enum pipe_video_profile 2427ec681f3SmrgProfileToPipe(VdpDecoderProfile vdpau_profile) 2437ec681f3Smrg{ 2447ec681f3Smrg switch (vdpau_profile) { 2457ec681f3Smrg case VDP_DECODER_PROFILE_MPEG1: 2467ec681f3Smrg return PIPE_VIDEO_PROFILE_MPEG1; 2477ec681f3Smrg case VDP_DECODER_PROFILE_MPEG2_SIMPLE: 2487ec681f3Smrg return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE; 2497ec681f3Smrg case VDP_DECODER_PROFILE_MPEG2_MAIN: 2507ec681f3Smrg return PIPE_VIDEO_PROFILE_MPEG2_MAIN; 2517ec681f3Smrg case VDP_DECODER_PROFILE_H264_BASELINE: 2527ec681f3Smrg return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE; 2537ec681f3Smrg case VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE: 2547ec681f3Smrg return PIPE_VIDEO_PROFILE_MPEG4_AVC_CONSTRAINED_BASELINE; 2557ec681f3Smrg case VDP_DECODER_PROFILE_H264_MAIN: 2567ec681f3Smrg return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN; 2577ec681f3Smrg case VDP_DECODER_PROFILE_H264_HIGH: 2587ec681f3Smrg return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH; 2597ec681f3Smrg case VDP_DECODER_PROFILE_MPEG4_PART2_SP: 2607ec681f3Smrg return PIPE_VIDEO_PROFILE_MPEG4_SIMPLE; 2617ec681f3Smrg case VDP_DECODER_PROFILE_MPEG4_PART2_ASP: 2627ec681f3Smrg return PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE; 2637ec681f3Smrg case VDP_DECODER_PROFILE_VC1_SIMPLE: 2647ec681f3Smrg return PIPE_VIDEO_PROFILE_VC1_SIMPLE; 2657ec681f3Smrg case VDP_DECODER_PROFILE_VC1_MAIN: 2667ec681f3Smrg return PIPE_VIDEO_PROFILE_VC1_MAIN; 2677ec681f3Smrg case VDP_DECODER_PROFILE_VC1_ADVANCED: 2687ec681f3Smrg return PIPE_VIDEO_PROFILE_VC1_ADVANCED; 2697ec681f3Smrg case VDP_DECODER_PROFILE_HEVC_MAIN: 2707ec681f3Smrg return PIPE_VIDEO_PROFILE_HEVC_MAIN; 2717ec681f3Smrg case VDP_DECODER_PROFILE_HEVC_MAIN_10: 2727ec681f3Smrg return PIPE_VIDEO_PROFILE_HEVC_MAIN_10; 2737ec681f3Smrg case VDP_DECODER_PROFILE_HEVC_MAIN_STILL: 2747ec681f3Smrg return PIPE_VIDEO_PROFILE_HEVC_MAIN_STILL; 2757ec681f3Smrg case VDP_DECODER_PROFILE_HEVC_MAIN_12: 2767ec681f3Smrg return PIPE_VIDEO_PROFILE_HEVC_MAIN_12; 2777ec681f3Smrg case VDP_DECODER_PROFILE_HEVC_MAIN_444: 2787ec681f3Smrg return PIPE_VIDEO_PROFILE_HEVC_MAIN_444; 2797ec681f3Smrg default: 2807ec681f3Smrg return PIPE_VIDEO_PROFILE_UNKNOWN; 2817ec681f3Smrg } 2827ec681f3Smrg} 2837ec681f3Smrg 2847ec681f3Smrgstatic inline VdpDecoderProfile 2857ec681f3SmrgPipeToProfile(enum pipe_video_profile p_profile) 2867ec681f3Smrg{ 2877ec681f3Smrg switch (p_profile) { 2887ec681f3Smrg case PIPE_VIDEO_PROFILE_MPEG1: 2897ec681f3Smrg return VDP_DECODER_PROFILE_MPEG1; 2907ec681f3Smrg case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE: 2917ec681f3Smrg return VDP_DECODER_PROFILE_MPEG2_SIMPLE; 2927ec681f3Smrg case PIPE_VIDEO_PROFILE_MPEG2_MAIN: 2937ec681f3Smrg return VDP_DECODER_PROFILE_MPEG2_MAIN; 2947ec681f3Smrg case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE: 2957ec681f3Smrg return VDP_DECODER_PROFILE_H264_BASELINE; 2967ec681f3Smrg case PIPE_VIDEO_PROFILE_MPEG4_AVC_CONSTRAINED_BASELINE: 2977ec681f3Smrg return VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE; 2987ec681f3Smrg case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN: 2997ec681f3Smrg return VDP_DECODER_PROFILE_H264_MAIN; 3007ec681f3Smrg case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH: 3017ec681f3Smrg return VDP_DECODER_PROFILE_H264_HIGH; 3027ec681f3Smrg case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE: 3037ec681f3Smrg return VDP_DECODER_PROFILE_MPEG4_PART2_SP; 3047ec681f3Smrg case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE: 3057ec681f3Smrg return VDP_DECODER_PROFILE_MPEG4_PART2_ASP; 3067ec681f3Smrg case PIPE_VIDEO_PROFILE_VC1_SIMPLE: 3077ec681f3Smrg return VDP_DECODER_PROFILE_VC1_SIMPLE; 3087ec681f3Smrg case PIPE_VIDEO_PROFILE_VC1_MAIN: 3097ec681f3Smrg return VDP_DECODER_PROFILE_VC1_MAIN; 3107ec681f3Smrg case PIPE_VIDEO_PROFILE_VC1_ADVANCED: 3117ec681f3Smrg return VDP_DECODER_PROFILE_VC1_ADVANCED; 3127ec681f3Smrg case PIPE_VIDEO_PROFILE_HEVC_MAIN: 3137ec681f3Smrg return VDP_DECODER_PROFILE_HEVC_MAIN; 3147ec681f3Smrg case PIPE_VIDEO_PROFILE_HEVC_MAIN_10: 3157ec681f3Smrg return VDP_DECODER_PROFILE_HEVC_MAIN_10; 3167ec681f3Smrg case PIPE_VIDEO_PROFILE_HEVC_MAIN_STILL: 3177ec681f3Smrg return VDP_DECODER_PROFILE_HEVC_MAIN_STILL; 3187ec681f3Smrg case PIPE_VIDEO_PROFILE_HEVC_MAIN_12: 3197ec681f3Smrg return VDP_DECODER_PROFILE_HEVC_MAIN_12; 3207ec681f3Smrg case PIPE_VIDEO_PROFILE_HEVC_MAIN_444: 3217ec681f3Smrg return VDP_DECODER_PROFILE_HEVC_MAIN_444; 3227ec681f3Smrg default: 3237ec681f3Smrg assert(0); 3247ec681f3Smrg return -1; 3257ec681f3Smrg } 3267ec681f3Smrg} 3277ec681f3Smrg 3287ec681f3Smrgstatic inline struct u_rect * 3297ec681f3SmrgRectToPipe(const VdpRect *src, struct u_rect *dst) 3307ec681f3Smrg{ 3317ec681f3Smrg if (src) { 3327ec681f3Smrg dst->x0 = src->x0; 3337ec681f3Smrg dst->y0 = src->y0; 3347ec681f3Smrg dst->x1 = src->x1; 3357ec681f3Smrg dst->y1 = src->y1; 3367ec681f3Smrg return dst; 3377ec681f3Smrg } 3387ec681f3Smrg return NULL; 3397ec681f3Smrg} 3407ec681f3Smrg 3417ec681f3Smrgstatic inline struct pipe_box 3427ec681f3SmrgRectToPipeBox(const VdpRect *rect, struct pipe_resource *res) 3437ec681f3Smrg{ 3447ec681f3Smrg struct pipe_box box; 3457ec681f3Smrg 3467ec681f3Smrg box.x = 0; 3477ec681f3Smrg box.y = 0; 3487ec681f3Smrg box.z = 0; 3497ec681f3Smrg box.width = res->width0; 3507ec681f3Smrg box.height = res->height0; 3517ec681f3Smrg box.depth = 1; 3527ec681f3Smrg 3537ec681f3Smrg if (rect) { 3547ec681f3Smrg if (rect->x1 > rect->x0 && 3557ec681f3Smrg rect->y1 > rect->y0) { 3567ec681f3Smrg box.x = rect->x0; 3577ec681f3Smrg box.y = rect->y0; 3587ec681f3Smrg box.width = rect->x1 - box.x; 3597ec681f3Smrg box.height = rect->y1 - box.y; 3607ec681f3Smrg } else { 3617ec681f3Smrg box.width = 0; 3627ec681f3Smrg box.height = 0; 3637ec681f3Smrg } 3647ec681f3Smrg } 3657ec681f3Smrg 3667ec681f3Smrg return box; 3677ec681f3Smrg} 3687ec681f3Smrg 3697ec681f3Smrgstatic inline bool 3707ec681f3SmrgCheckSurfaceParams(struct pipe_screen *screen, 3717ec681f3Smrg const struct pipe_resource *templ) 3727ec681f3Smrg{ 3737ec681f3Smrg return screen->is_format_supported(screen, templ->format, templ->target, 3747ec681f3Smrg templ->nr_samples, 3757ec681f3Smrg templ->nr_storage_samples, templ->bind); 3767ec681f3Smrg} 3777ec681f3Smrg 3787ec681f3Smrgtypedef struct 3797ec681f3Smrg{ 3807ec681f3Smrg struct pipe_reference reference; 3817ec681f3Smrg struct vl_screen *vscreen; 3827ec681f3Smrg struct pipe_context *context; 3837ec681f3Smrg struct vl_compositor compositor; 3847ec681f3Smrg struct pipe_sampler_view *dummy_sv; 3857ec681f3Smrg mtx_t mutex; 3867ec681f3Smrg} vlVdpDevice; 3877ec681f3Smrg 3887ec681f3Smrgtypedef struct 3897ec681f3Smrg{ 3907ec681f3Smrg vlVdpDevice *device; 3917ec681f3Smrg struct vl_compositor_state cstate; 3927ec681f3Smrg 3937ec681f3Smrg struct { 3947ec681f3Smrg bool supported, enabled; 3957ec681f3Smrg float luma_min, luma_max; 3967ec681f3Smrg } luma_key; 3977ec681f3Smrg 3987ec681f3Smrg struct { 3997ec681f3Smrg bool supported, enabled, spatial; 4007ec681f3Smrg struct vl_deint_filter *filter; 4017ec681f3Smrg } deint; 4027ec681f3Smrg 4037ec681f3Smrg struct { 4047ec681f3Smrg bool supported, enabled; 4057ec681f3Smrg struct vl_bicubic_filter *filter; 4067ec681f3Smrg } bicubic; 4077ec681f3Smrg 4087ec681f3Smrg struct { 4097ec681f3Smrg bool supported, enabled; 4107ec681f3Smrg unsigned level; 4117ec681f3Smrg struct vl_median_filter *filter; 4127ec681f3Smrg } noise_reduction; 4137ec681f3Smrg 4147ec681f3Smrg struct { 4157ec681f3Smrg bool supported, enabled; 4167ec681f3Smrg float value; 4177ec681f3Smrg struct vl_matrix_filter *filter; 4187ec681f3Smrg } sharpness; 4197ec681f3Smrg 4207ec681f3Smrg unsigned video_width, video_height; 4217ec681f3Smrg enum pipe_video_chroma_format chroma_format; 4227ec681f3Smrg unsigned max_layers, skip_chroma_deint; 4237ec681f3Smrg 4247ec681f3Smrg bool custom_csc; 4257ec681f3Smrg vl_csc_matrix csc; 4267ec681f3Smrg} vlVdpVideoMixer; 4277ec681f3Smrg 4287ec681f3Smrgtypedef struct 4297ec681f3Smrg{ 4307ec681f3Smrg vlVdpDevice *device; 4317ec681f3Smrg struct pipe_video_buffer templat, *video_buffer; 4327ec681f3Smrg} vlVdpSurface; 4337ec681f3Smrg 4347ec681f3Smrgtypedef struct 4357ec681f3Smrg{ 4367ec681f3Smrg vlVdpDevice *device; 4377ec681f3Smrg struct pipe_sampler_view *sampler_view; 4387ec681f3Smrg} vlVdpBitmapSurface; 4397ec681f3Smrg 4407ec681f3Smrgtypedef uint64_t vlVdpTime; 4417ec681f3Smrg 4427ec681f3Smrgtypedef struct 4437ec681f3Smrg{ 4447ec681f3Smrg vlVdpDevice *device; 4457ec681f3Smrg struct pipe_surface *surface; 4467ec681f3Smrg struct pipe_sampler_view *sampler_view; 4477ec681f3Smrg struct pipe_fence_handle *fence; 4487ec681f3Smrg struct vl_compositor_state cstate; 4497ec681f3Smrg struct u_rect dirty_area; 4507ec681f3Smrg bool send_to_X; 4517ec681f3Smrg} vlVdpOutputSurface; 4527ec681f3Smrg 4537ec681f3Smrgtypedef struct 4547ec681f3Smrg{ 4557ec681f3Smrg vlVdpDevice *device; 4567ec681f3Smrg Drawable drawable; 4577ec681f3Smrg} vlVdpPresentationQueueTarget; 4587ec681f3Smrg 4597ec681f3Smrgtypedef struct 4607ec681f3Smrg{ 4617ec681f3Smrg vlVdpDevice *device; 4627ec681f3Smrg Drawable drawable; 4637ec681f3Smrg struct vl_compositor_state cstate; 4647ec681f3Smrg vlVdpOutputSurface *last_surf; 4657ec681f3Smrg} vlVdpPresentationQueue; 4667ec681f3Smrg 4677ec681f3Smrgtypedef struct 4687ec681f3Smrg{ 4697ec681f3Smrg vlVdpDevice *device; 4707ec681f3Smrg mtx_t mutex; 4717ec681f3Smrg struct pipe_video_codec *decoder; 4727ec681f3Smrg} vlVdpDecoder; 4737ec681f3Smrg 4747ec681f3Smrgtypedef uint32_t vlHandle; 4757ec681f3Smrg 4767ec681f3Smrgboolean vlCreateHTAB(void); 4777ec681f3Smrgvoid vlDestroyHTAB(void); 4787ec681f3SmrgvlHandle vlAddDataHTAB(void *data); 4797ec681f3Smrgvoid* vlGetDataHTAB(vlHandle handle); 4807ec681f3Smrgvoid vlRemoveDataHTAB(vlHandle handle); 4817ec681f3Smrg 4827ec681f3Smrgboolean vlGetFuncFTAB(VdpFuncId function_id, void **func); 4837ec681f3Smrg 4847ec681f3Smrg/* Public functions */ 4857ec681f3SmrgVdpDeviceCreateX11 vdp_imp_device_create_x11; 4867ec681f3Smrg 4877ec681f3Smrgvoid vlVdpDefaultSamplerViewTemplate(struct pipe_sampler_view *templ, struct pipe_resource *res); 4887ec681f3Smrg 4897ec681f3Smrg/* Internal function pointers */ 4907ec681f3SmrgVdpGetErrorString vlVdpGetErrorString; 4917ec681f3SmrgVdpDeviceDestroy vlVdpDeviceDestroy; 4927ec681f3Smrgvoid vlVdpDeviceFree(vlVdpDevice *dev); 4937ec681f3SmrgVdpGetProcAddress vlVdpGetProcAddress; 4947ec681f3SmrgVdpGetApiVersion vlVdpGetApiVersion; 4957ec681f3SmrgVdpGetInformationString vlVdpGetInformationString; 4967ec681f3SmrgVdpVideoSurfaceQueryCapabilities vlVdpVideoSurfaceQueryCapabilities; 4977ec681f3SmrgVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities; 4987ec681f3SmrgVdpDecoderQueryCapabilities vlVdpDecoderQueryCapabilities; 4997ec681f3SmrgVdpOutputSurfaceQueryCapabilities vlVdpOutputSurfaceQueryCapabilities; 5007ec681f3SmrgVdpOutputSurfaceQueryGetPutBitsNativeCapabilities vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities; 5017ec681f3SmrgVdpOutputSurfaceQueryPutBitsIndexedCapabilities vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities; 5027ec681f3SmrgVdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities; 5037ec681f3SmrgVdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities; 5047ec681f3SmrgVdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport; 5057ec681f3SmrgVdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport; 5067ec681f3SmrgVdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange; 5077ec681f3SmrgVdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport; 5087ec681f3SmrgVdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange; 5097ec681f3SmrgVdpVideoSurfaceCreate vlVdpVideoSurfaceCreate; 5107ec681f3SmrgVdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy; 5117ec681f3SmrgVdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters; 5127ec681f3SmrgVdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr; 5137ec681f3SmrgVdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr; 5147ec681f3Smrgvoid vlVdpVideoSurfaceClear(vlVdpSurface *vlsurf); 5157ec681f3SmrgVdpDecoderCreate vlVdpDecoderCreate; 5167ec681f3SmrgVdpDecoderDestroy vlVdpDecoderDestroy; 5177ec681f3SmrgVdpDecoderGetParameters vlVdpDecoderGetParameters; 5187ec681f3SmrgVdpDecoderRender vlVdpDecoderRender; 5197ec681f3SmrgVdpOutputSurfaceCreate vlVdpOutputSurfaceCreate; 5207ec681f3SmrgVdpOutputSurfaceDestroy vlVdpOutputSurfaceDestroy; 5217ec681f3SmrgVdpOutputSurfaceGetParameters vlVdpOutputSurfaceGetParameters; 5227ec681f3SmrgVdpOutputSurfaceGetBitsNative vlVdpOutputSurfaceGetBitsNative; 5237ec681f3SmrgVdpOutputSurfacePutBitsNative vlVdpOutputSurfacePutBitsNative; 5247ec681f3SmrgVdpOutputSurfacePutBitsIndexed vlVdpOutputSurfacePutBitsIndexed; 5257ec681f3SmrgVdpOutputSurfacePutBitsYCbCr vlVdpOutputSurfacePutBitsYCbCr; 5267ec681f3SmrgVdpOutputSurfaceRenderOutputSurface vlVdpOutputSurfaceRenderOutputSurface; 5277ec681f3SmrgVdpOutputSurfaceRenderBitmapSurface vlVdpOutputSurfaceRenderBitmapSurface; 5287ec681f3SmrgVdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate; 5297ec681f3SmrgVdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy; 5307ec681f3SmrgVdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters; 5317ec681f3SmrgVdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative; 5327ec681f3SmrgVdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy; 5337ec681f3SmrgVdpPresentationQueueCreate vlVdpPresentationQueueCreate; 5347ec681f3SmrgVdpPresentationQueueDestroy vlVdpPresentationQueueDestroy; 5357ec681f3SmrgVdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor; 5367ec681f3SmrgVdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor; 5377ec681f3SmrgVdpPresentationQueueGetTime vlVdpPresentationQueueGetTime; 5387ec681f3SmrgVdpPresentationQueueDisplay vlVdpPresentationQueueDisplay; 5397ec681f3SmrgVdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle; 5407ec681f3SmrgVdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus; 5417ec681f3SmrgVdpPreemptionCallback vlVdpPreemptionCallback; 5427ec681f3SmrgVdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister; 5437ec681f3SmrgVdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables; 5447ec681f3SmrgVdpVideoMixerCreate vlVdpVideoMixerCreate; 5457ec681f3SmrgVdpVideoMixerRender vlVdpVideoMixerRender; 5467ec681f3SmrgVdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues; 5477ec681f3SmrgVdpVideoMixerGetFeatureSupport vlVdpVideoMixerGetFeatureSupport; 5487ec681f3SmrgVdpVideoMixerGetFeatureEnables vlVdpVideoMixerGetFeatureEnables; 5497ec681f3SmrgVdpVideoMixerGetParameterValues vlVdpVideoMixerGetParameterValues; 5507ec681f3SmrgVdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues; 5517ec681f3SmrgVdpVideoMixerDestroy vlVdpVideoMixerDestroy; 5527ec681f3SmrgVdpGenerateCSCMatrix vlVdpGenerateCSCMatrix; 5537ec681f3Smrg/* Winsys specific internal function pointers */ 5547ec681f3SmrgVdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11; 5557ec681f3Smrg 5567ec681f3Smrg 5577ec681f3Smrg/* interop for GL gallium frontend */ 5587ec681f3SmrgVdpVideoSurfaceGallium vlVdpVideoSurfaceGallium; 5597ec681f3SmrgVdpOutputSurfaceGallium vlVdpOutputSurfaceGallium; 5607ec681f3SmrgVdpVideoSurfaceDMABuf vlVdpVideoSurfaceDMABuf; 5617ec681f3SmrgVdpOutputSurfaceDMABuf vlVdpOutputSurfaceDMABuf; 5627ec681f3Smrg 5637ec681f3Smrg#define VDPAU_OUT 0 5647ec681f3Smrg#define VDPAU_ERR 1 5657ec681f3Smrg#define VDPAU_WARN 2 5667ec681f3Smrg#define VDPAU_TRACE 3 5677ec681f3Smrg 5687ec681f3Smrgstatic inline void VDPAU_MSG(unsigned int level, const char *fmt, ...) 5697ec681f3Smrg{ 5707ec681f3Smrg static int debug_level = -1; 5717ec681f3Smrg 5727ec681f3Smrg if (debug_level == -1) { 5737ec681f3Smrg debug_level = MAX2(debug_get_num_option("VDPAU_DEBUG", 0), 0); 5747ec681f3Smrg } 5757ec681f3Smrg 5767ec681f3Smrg if (level <= debug_level) { 5777ec681f3Smrg va_list ap; 5787ec681f3Smrg va_start(ap, fmt); 5797ec681f3Smrg _debug_vprintf(fmt, ap); 5807ec681f3Smrg va_end(ap); 5817ec681f3Smrg } 5827ec681f3Smrg} 5837ec681f3Smrg 5847ec681f3Smrgstatic inline void 5857ec681f3SmrgDeviceReference(vlVdpDevice **ptr, vlVdpDevice *dev) 5867ec681f3Smrg{ 5877ec681f3Smrg vlVdpDevice *old_dev = *ptr; 5887ec681f3Smrg 5897ec681f3Smrg if (pipe_reference(&(*ptr)->reference, &dev->reference)) 5907ec681f3Smrg vlVdpDeviceFree(old_dev); 5917ec681f3Smrg *ptr = dev; 5927ec681f3Smrg} 5937ec681f3Smrg 5947ec681f3Smrg#endif /* VDPAU_PRIVATE_H */ 595