From 4b54277d2e9420e37cdce98b3a09e6cecf87300d Mon Sep 17 00:00:00 2001 From: David Rosca Date: Thu, 7 Aug 2025 11:08:43 +0200 Subject: [PATCH] Remove VDPAU MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VDPAU only supports X11 and GL interop. There is no Wayland or Vulkan interop support. The API has limitations that makes it impossible to correctly decode certain streams. Application support is also very limited, and VAAPI is always a better choice over VDPAU. Acked-by: Mike Blumenkrantz Acked-by: Adam Jackson Reviewed-by: Marek Olšák Part-of: --- docs/gallium/screen.rst | 2 +- docs/index.rst | 3 +- docs/relnotes/new_features.txt | 1 + docs/sourcetree.rst | 1 - docs/systems.rst | 3 +- meson.build | 36 +- meson.options | 16 +- src/compiler/nir/meson.build | 1 - src/gallium/auxiliary/meson.build | 2 +- src/gallium/frontends/vdpau/bitmap.c | 210 ---- src/gallium/frontends/vdpau/decode.c | 1145 ------------------ src/gallium/frontends/vdpau/device.c | 333 ----- src/gallium/frontends/vdpau/ftab.c | 139 --- src/gallium/frontends/vdpau/htab.c | 90 -- src/gallium/frontends/vdpau/meson.build | 22 - src/gallium/frontends/vdpau/mixer.c | 1032 ---------------- src/gallium/frontends/vdpau/output.c | 829 ------------- src/gallium/frontends/vdpau/preemption.c | 48 - src/gallium/frontends/vdpau/presentation.c | 382 ------ src/gallium/frontends/vdpau/query.c | 630 ---------- src/gallium/frontends/vdpau/surface.c | 551 --------- src/gallium/frontends/vdpau/vdpau_private.h | 618 ---------- src/gallium/include/frontend/vdpau_dmabuf.h | 94 -- src/gallium/include/frontend/vdpau_funcs.h | 65 - src/gallium/include/frontend/vdpau_interop.h | 54 - src/gallium/meson.build | 9 +- src/gallium/targets/dri/dri.sym.in | 1 - src/gallium/targets/dri/meson.build | 26 +- src/gallium/targets/vdpau/meson.build | 70 -- src/gallium/targets/vdpau/vdpau.sym.in | 10 - src/gallium/targets/vdpau/vdpau_target.c | 2 - 31 files changed, 13 insertions(+), 6412 deletions(-) delete mode 100644 src/gallium/frontends/vdpau/bitmap.c delete mode 100644 src/gallium/frontends/vdpau/decode.c delete mode 100644 src/gallium/frontends/vdpau/device.c delete mode 100644 src/gallium/frontends/vdpau/ftab.c delete mode 100644 src/gallium/frontends/vdpau/htab.c delete mode 100644 src/gallium/frontends/vdpau/meson.build delete mode 100644 src/gallium/frontends/vdpau/mixer.c delete mode 100644 src/gallium/frontends/vdpau/output.c delete mode 100644 src/gallium/frontends/vdpau/preemption.c delete mode 100644 src/gallium/frontends/vdpau/presentation.c delete mode 100644 src/gallium/frontends/vdpau/query.c delete mode 100644 src/gallium/frontends/vdpau/surface.c delete mode 100644 src/gallium/frontends/vdpau/vdpau_private.h delete mode 100644 src/gallium/include/frontend/vdpau_dmabuf.h delete mode 100644 src/gallium/include/frontend/vdpau_funcs.h delete mode 100644 src/gallium/include/frontend/vdpau_interop.h delete mode 100644 src/gallium/targets/vdpau/meson.build delete mode 100644 src/gallium/targets/vdpau/vdpau.sym.in delete mode 100644 src/gallium/targets/vdpau/vdpau_target.c diff --git a/docs/gallium/screen.rst b/docs/gallium/screen.rst index 1c80e31e205..c7c2b3b2b75 100644 --- a/docs/gallium/screen.rst +++ b/docs/gallium/screen.rst @@ -557,7 +557,7 @@ Capability about the features and limits of the driver/GPU. * ``pipe_caps.cl_gl_sharing``: True if driver supports everything required by a frontend implementing the CL extension, and also supports importing/exporting all of pipe_texture_target via dma buffers. -* ``pipe_caps.prefer_compute_for_multimedia``: Whether VDPAU and VAAPI +* ``pipe_caps.prefer_compute_for_multimedia``: Whether VAAPI should use a compute-based blit instead of pipe_context::blit and compute pipeline for compositing images. * ``pipe_caps.fragment_shader_interlock``: True if fragment shader interlock functionality is supported. diff --git a/docs/index.rst b/docs/index.rst index 6e8dea6d989..2ee58324878 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -5,7 +5,7 @@ The Mesa project began as an open-source implementation of the `OpenGL`_ specification - a system for rendering interactive 3D graphics. Over the years the project has grown to implement more graphics APIs, -including `OpenGL ES`_, `OpenCL`_, `VDPAU`_, `VA-API`_, +including `OpenGL ES`_, `OpenCL`_, `VA-API`_, `Vulkan`_ and `EGL`_. A variety of device drivers allows the Mesa libraries to be used in many @@ -19,7 +19,6 @@ Linux, FreeBSD, and other operating systems. .. _OpenGL: https://www.opengl.org/ .. _OpenGL ES: https://www.khronos.org/opengles/ .. _OpenCL: https://www.khronos.org/opencl/ -.. _VDPAU: https://en.wikipedia.org/wiki/VDPAU .. _VA-API: https://en.wikipedia.org/wiki/Video_Acceleration_API .. _Vulkan: https://www.vulkan.org/ .. _EGL: https://www.khronos.org/egl/ diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt index 8df9d33a074..deef9876814 100644 --- a/docs/relnotes/new_features.txt +++ b/docs/relnotes/new_features.txt @@ -20,3 +20,4 @@ VK_KHR_maintenance8 on panvk/v10+ VK_KHR_maintenance9 on panvk VK_AMD_buffer_marker on NVK VK_EXT_ycbcr_2plane_444_formats on radv +Removed VDPAU frontend diff --git a/docs/sourcetree.rst b/docs/sourcetree.rst index d395e700d86..9eeaed453bf 100644 --- a/docs/sourcetree.rst +++ b/docs/sourcetree.rst @@ -135,7 +135,6 @@ each directory. - **hgl** - Haiku OpenGL - **lavapipe** - Vulkan frontend, software Vulkan rasterizer using LLVMpipe. - **va** - VA-API frontend - - **vdpau** - VDPAU frontend - **wgl** - Windows WGL frontend - **winsys** - The device drivers are platform-independent, the diff --git a/docs/systems.rst b/docs/systems.rst index bdd3da3583d..63f780c9f89 100644 --- a/docs/systems.rst +++ b/docs/systems.rst @@ -7,7 +7,7 @@ Haiku. We're actively developing and maintaining several hardware and software drivers. The primary API is OpenGL but there's also support for OpenGL ES, Vulkan, -EGL, OpenCL, VDPAU and VA-API. +EGL, OpenCL and VA-API. Hardware drivers include: @@ -75,3 +75,4 @@ the Git repo. The list includes: - Silicon Integrated Systems - swrast - VIA Unichrome +- VDPAU diff --git a/meson.build b/meson.build index 293ee16dae1..93351bbe09d 100644 --- a/meson.build +++ b/meson.build @@ -628,30 +628,6 @@ if with_gallium_d3d12 and not _with_gallium_d3d12_video.disabled() pre_args += '-DHAVE_GALLIUM_D3D12_VIDEO' endif -_vdpau_drivers = [ - with_gallium_d3d12_video, - with_gallium_nouveau, - with_gallium_r600, - with_gallium_radeonsi, - with_gallium_virgl, -] - -vdpau = get_option('gallium-vdpau') \ - .require(system_has_kms_drm, error_message : 'VDPAU state tracker can only be build on unix-like OSes.') \ - .require(with_platform_x11, error_message : 'VDPAU state tracker requires X11 support.') \ - .require(_vdpau_drivers.contains(true), error_message : 'VDPAU state tracker requires at least one of the following gallium drivers: r600, radeonsi, nouveau, d3d12 (with option gallium-d3d12-video, virgl).') - -dep_vdpau = dependency('vdpau', version : '>= 1.5', required : vdpau) -if dep_vdpau.found() - dep_vdpau = dep_vdpau.partial_dependency(compile_args : true) -endif -with_gallium_vdpau = dep_vdpau.found() - -vdpau_drivers_path = get_option('vdpau-libs-path') -if vdpau_drivers_path == '' - vdpau_drivers_path = join_paths(get_option('libdir'), 'vdpau') -endif - # GLSL has interesting version output and Meson doesn't parse it correctly as of # Meson 1.4.0 prog_glslang = find_program( @@ -2091,8 +2067,7 @@ if with_platform_x11 # needed for GL sharing extension dep_x11 = dependency('x11', version : dep_xlib_version) endif - if (with_any_vk or with_glx == 'dri' or with_egl or - (with_gallium_vdpau or with_gallium_va)) + if (with_any_vk or with_glx == 'dri' or with_egl or with_gallium_va) dep_xcb = dependency('xcb') dep_xcb_keysyms = dependency('xcb-keysyms', required : false) with_xcb_keysyms = dep_xcb_keysyms.found() @@ -2128,8 +2103,7 @@ if with_platform_x11 endif if (with_egl or with_dri or - with_any_vk or - with_gallium_vdpau) + with_any_vk) dep_xcb_xfixes = dependency('xcb-xfixes') endif if with_any_vk @@ -2363,9 +2337,6 @@ summary(vulkan_summary, section: 'Vulkan', bool_yn: true, list_sep: ' ') video_summary = {'Codecs': _codecs.length() != 0 ? _codecs : false} video_apis = [] -if with_gallium_vdpau - video_apis += 'vdpau' -endif if with_gallium_va video_apis += 'va' endif @@ -2390,9 +2361,6 @@ if with_gallium gallium_summary += {'Platforms': _platforms} gallium_frontends = ['mesa'] - if with_gallium_vdpau - gallium_frontends += 'vdpau' - endif if with_gallium_va gallium_frontends += 'va' endif diff --git a/meson.options b/meson.options index ac92e414d1d..48362ca693b 100644 --- a/meson.options +++ b/meson.options @@ -102,20 +102,6 @@ option( description : 'Enable HUD block/NIC I/O HUD status support', ) -option( - 'gallium-vdpau', - type : 'feature', - deprecated: {'true': 'enabled', 'false': 'disabled'}, - description : 'enable gallium vdpau frontend.', -) - -option( - 'vdpau-libs-path', - type : 'string', - value : '', - description : 'path to put vdpau libraries. defaults to $libdir/vdpau.' -) - option( 'gallium-va', type : 'feature', @@ -717,7 +703,7 @@ option( description : 'List of codecs to build support for. ' + 'Distros might want to consult their legal department before ' + 'enabling these. This is used for all video APIs (vaapi, ' + - 'vdpau, vulkan). Non-patent encumbered codecs will be ' + + 'vulkan). Non-patent encumbered codecs will be ' + 'enabled by default with the all_free default value.' ) diff --git a/src/compiler/nir/meson.build b/src/compiler/nir/meson.build index 73b24b9fe5c..c12b33912a2 100644 --- a/src/compiler/nir/meson.build +++ b/src/compiler/nir/meson.build @@ -80,7 +80,6 @@ with_nir_headers_only = ( gallium_drivers == ['d3d12'] and get_option('gallium-d3d12-graphics').disabled() and not [ - with_gallium_vdpau, with_gallium_va, with_any_vk, with_gallium_st_d3d10umd, diff --git a/src/gallium/auxiliary/meson.build b/src/gallium/auxiliary/meson.build index d6e0d65f356..28101bf2ca5 100644 --- a/src/gallium/auxiliary/meson.build +++ b/src/gallium/auxiliary/meson.build @@ -562,7 +562,7 @@ libgalliumvl = static_library( # some drivers export their screen creation function globally, so all frontends have to contain the # full libgalliumvl. So we'll handle this here globally for everybody. -if (with_gallium_mediafoundation or with_gallium_va or with_gallium_vdpau or with_dri or with_gallium_radeonsi) +if (with_gallium_mediafoundation or with_gallium_va or with_dri or with_gallium_radeonsi) libgalliumvl_stub = libgalliumvl else libgalliumvl_stub = _libgalliumvl_stub diff --git a/src/gallium/frontends/vdpau/bitmap.c b/src/gallium/frontends/vdpau/bitmap.c deleted file mode 100644 index 66e3852be8d..00000000000 --- a/src/gallium/frontends/vdpau/bitmap.c +++ /dev/null @@ -1,210 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Thomas Balling Sørensen. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include - -#include "util/u_memory.h" -#include "util/u_sampler.h" - -#include "vdpau_private.h" - -/** - * Create a VdpBitmapSurface. - */ -VdpStatus -vlVdpBitmapSurfaceCreate(VdpDevice device, - VdpRGBAFormat rgba_format, - uint32_t width, uint32_t height, - VdpBool frequently_accessed, - VdpBitmapSurface *surface) -{ - struct pipe_context *pipe; - struct pipe_resource res_tmpl, *res; - struct pipe_sampler_view sv_templ; - VdpStatus ret; - - vlVdpBitmapSurface *vlsurface = NULL; - - if (!(width && height)) - return VDP_STATUS_INVALID_SIZE; - - vlVdpDevice *dev = vlGetDataHTAB(device); - if (!dev) - return VDP_STATUS_INVALID_HANDLE; - - pipe = dev->context; - if (!pipe) - return VDP_STATUS_INVALID_HANDLE; - - if (!surface) - return VDP_STATUS_INVALID_POINTER; - - vlsurface = CALLOC(1, sizeof(vlVdpBitmapSurface)); - if (!vlsurface) - return VDP_STATUS_RESOURCES; - - DeviceReference(&vlsurface->device, dev); - - memset(&res_tmpl, 0, sizeof(res_tmpl)); - res_tmpl.target = PIPE_TEXTURE_2D; - res_tmpl.format = VdpFormatRGBAToPipe(rgba_format); - res_tmpl.width0 = width; - res_tmpl.height0 = height; - res_tmpl.depth0 = 1; - res_tmpl.array_size = 1; - res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; - res_tmpl.usage = frequently_accessed ? PIPE_USAGE_DYNAMIC : PIPE_USAGE_DEFAULT; - - mtx_lock(&dev->mutex); - - if (!CheckSurfaceParams(pipe->screen, &res_tmpl)) { - ret = VDP_STATUS_RESOURCES; - goto err_unlock; - } - - res = pipe->screen->resource_create(pipe->screen, &res_tmpl); - if (!res) { - ret = VDP_STATUS_RESOURCES; - goto err_unlock; - } - - vlVdpDefaultSamplerViewTemplate(&sv_templ, res); - vlsurface->sampler_view = pipe->create_sampler_view(pipe, res, &sv_templ); - - pipe_resource_reference(&res, NULL); - - if (!vlsurface->sampler_view) { - ret = VDP_STATUS_RESOURCES; - goto err_unlock; - } - - mtx_unlock(&dev->mutex); - - *surface = vlAddDataHTAB(vlsurface); - if (*surface == 0) { - mtx_lock(&dev->mutex); - ret = VDP_STATUS_ERROR; - goto err_sampler; - } - - return VDP_STATUS_OK; - -err_sampler: - pipe->sampler_view_release(pipe, vlsurface->sampler_view); -err_unlock: - mtx_unlock(&dev->mutex); - DeviceReference(&vlsurface->device, NULL); - FREE(vlsurface); - return ret; -} - -/** - * Destroy a VdpBitmapSurface. - */ -VdpStatus -vlVdpBitmapSurfaceDestroy(VdpBitmapSurface surface) -{ - vlVdpBitmapSurface *vlsurface; - - vlsurface = vlGetDataHTAB(surface); - if (!vlsurface) - return VDP_STATUS_INVALID_HANDLE; - - struct pipe_context *pipe = vlsurface->sampler_view->context; - mtx_lock(&vlsurface->device->mutex); - pipe->sampler_view_release(pipe, vlsurface->sampler_view); - mtx_unlock(&vlsurface->device->mutex); - - vlRemoveDataHTAB(surface); - DeviceReference(&vlsurface->device, NULL); - FREE(vlsurface); - - return VDP_STATUS_OK; -} - -/** - * Retrieve the parameters used to create a VdpBitmapSurface. - */ -VdpStatus -vlVdpBitmapSurfaceGetParameters(VdpBitmapSurface surface, - VdpRGBAFormat *rgba_format, - uint32_t *width, uint32_t *height, - VdpBool *frequently_accessed) -{ - vlVdpBitmapSurface *vlsurface; - struct pipe_resource *res; - - vlsurface = vlGetDataHTAB(surface); - if (!vlsurface) - return VDP_STATUS_INVALID_HANDLE; - - if (!(rgba_format && width && height && frequently_accessed)) - return VDP_STATUS_INVALID_POINTER; - - res = vlsurface->sampler_view->texture; - *rgba_format = PipeToFormatRGBA(res->format); - *width = res->width0; - *height = res->height0; - *frequently_accessed = res->usage == PIPE_USAGE_DYNAMIC; - - return VDP_STATUS_OK; -} - -/** - * Copy image data from application memory in the surface's native format to - * a VdpBitmapSurface. - */ -VdpStatus -vlVdpBitmapSurfacePutBitsNative(VdpBitmapSurface surface, - void const *const *source_data, - uint32_t const *source_pitches, - VdpRect const *destination_rect) -{ - vlVdpBitmapSurface *vlsurface; - struct pipe_box dst_box; - struct pipe_context *pipe; - - vlsurface = vlGetDataHTAB(surface); - if (!vlsurface) - return VDP_STATUS_INVALID_HANDLE; - - if (!(source_data && source_pitches)) - return VDP_STATUS_INVALID_POINTER; - - pipe = vlsurface->device->context; - - mtx_lock(&vlsurface->device->mutex); - - dst_box = RectToPipeBox(destination_rect, vlsurface->sampler_view->texture); - pipe->texture_subdata(pipe, vlsurface->sampler_view->texture, 0, - PIPE_MAP_WRITE, &dst_box, *source_data, - *source_pitches, 0); - - mtx_unlock(&vlsurface->device->mutex); - - return VDP_STATUS_OK; -} diff --git a/src/gallium/frontends/vdpau/decode.c b/src/gallium/frontends/vdpau/decode.c deleted file mode 100644 index 8c975b2789b..00000000000 --- a/src/gallium/frontends/vdpau/decode.c +++ /dev/null @@ -1,1145 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Thomas Balling Sørensen. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "util/u_memory.h" -#include "util/u_math.h" -#include "util/u_debug.h" -#include "util/u_video.h" - -#include "util/vl_vlc.h" - -#include "vl/vl_codec.h" -#include "vdpau_private.h" - -#define AV1_KEY_FRAME 0 -#define AV1_REFS_PER_FRAME 7 -#define AV1_NUM_REF_FRAMES 8 -#define AV1_PRIMARY_REF_NONE AV1_REFS_PER_FRAME -#define AV1_SUPERRES_DENOM_MIN 9 -#define AV1_SUPERRES_NUM 8 -#define H264_CHROMA_FORMAT_IDC_420 1 - -/** - * Create a VdpDecoder. - */ -VdpStatus -vlVdpDecoderCreate(VdpDevice device, - VdpDecoderProfile profile, - uint32_t width, uint32_t height, - uint32_t max_references, - VdpDecoder *decoder) -{ - struct pipe_video_codec templat = {}; - struct pipe_context *pipe; - struct pipe_screen *screen; - vlVdpDevice *dev; - vlVdpDecoder *vldecoder; - VdpStatus ret; - bool supported; - uint32_t maxwidth, maxheight; - - if (!decoder) - return VDP_STATUS_INVALID_POINTER; - *decoder = 0; - - if (!(width && height)) - return VDP_STATUS_INVALID_VALUE; - - templat.profile = ProfileToPipe(profile); - if (templat.profile == PIPE_VIDEO_PROFILE_UNKNOWN) - return VDP_STATUS_INVALID_DECODER_PROFILE; - - dev = vlGetDataHTAB(device); - if (!dev) - return VDP_STATUS_INVALID_HANDLE; - - pipe = dev->context; - screen = dev->vscreen->pscreen; - - mtx_lock(&dev->mutex); - - supported = vl_codec_supported(screen, templat.profile, false); - if (!supported) { - mtx_unlock(&dev->mutex); - return VDP_STATUS_INVALID_DECODER_PROFILE; - } - - maxwidth = screen->get_video_param - ( - screen, - templat.profile, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_MAX_WIDTH - ); - maxheight = screen->get_video_param - ( - screen, - templat.profile, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_MAX_HEIGHT - ); - if (width > maxwidth || height > maxheight) { - mtx_unlock(&dev->mutex); - return VDP_STATUS_INVALID_SIZE; - } - - vldecoder = CALLOC(1,sizeof(vlVdpDecoder)); - if (!vldecoder) { - mtx_unlock(&dev->mutex); - return VDP_STATUS_RESOURCES; - } - - DeviceReference(&vldecoder->device, dev); - - templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM; - templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420; - templat.width = width; - templat.height = height; - templat.max_references = max_references; - - if (u_reduce_video_profile(templat.profile) == - PIPE_VIDEO_FORMAT_MPEG4_AVC) - templat.level = u_get_h264_level(templat.width, templat.height, - &templat.max_references); - - vldecoder->decoder = pipe->create_video_codec(pipe, &templat); - - if (!vldecoder->decoder) { - ret = VDP_STATUS_ERROR; - goto error_decoder; - } - - *decoder = vlAddDataHTAB(vldecoder); - if (*decoder == 0) { - ret = VDP_STATUS_ERROR; - goto error_handle; - } - - (void) mtx_init(&vldecoder->mutex, mtx_plain); - mtx_unlock(&dev->mutex); - - return VDP_STATUS_OK; - -error_handle: - vldecoder->decoder->destroy(vldecoder->decoder); - -error_decoder: - mtx_unlock(&dev->mutex); - DeviceReference(&vldecoder->device, NULL); - FREE(vldecoder); - return ret; -} - -/** - * Destroy a VdpDecoder. - */ -VdpStatus -vlVdpDecoderDestroy(VdpDecoder decoder) -{ - vlVdpDecoder *vldecoder; - - vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder); - if (!vldecoder) - return VDP_STATUS_INVALID_HANDLE; - - mtx_lock(&vldecoder->mutex); - vldecoder->decoder->destroy(vldecoder->decoder); - mtx_unlock(&vldecoder->mutex); - mtx_destroy(&vldecoder->mutex); - - vlRemoveDataHTAB(decoder); - DeviceReference(&vldecoder->device, NULL); - FREE(vldecoder); - - return VDP_STATUS_OK; -} - -/** - * Retrieve the parameters used to create a VdpDecoder. - */ -VdpStatus -vlVdpDecoderGetParameters(VdpDecoder decoder, - VdpDecoderProfile *profile, - uint32_t *width, - uint32_t *height) -{ - vlVdpDecoder *vldecoder; - - vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder); - if (!vldecoder) - return VDP_STATUS_INVALID_HANDLE; - - *profile = PipeToProfile(vldecoder->decoder->profile); - *width = vldecoder->decoder->width; - *height = vldecoder->decoder->height; - - return VDP_STATUS_OK; -} - -static VdpStatus -vlVdpGetReferenceFrame(VdpVideoSurface handle, struct pipe_video_buffer **ref_frame) -{ - vlVdpSurface *surface; - - /* if surfaces equals VDP_STATUS_INVALID_HANDLE, they are not used */ - if (handle == VDP_INVALID_HANDLE) { - *ref_frame = NULL; - return VDP_STATUS_OK; - } - - surface = vlGetDataHTAB(handle); - if (!surface) - return VDP_STATUS_INVALID_HANDLE; - - *ref_frame = surface->ref_buffer ? surface->ref_buffer : surface->video_buffer; - if (!*ref_frame) - return VDP_STATUS_INVALID_HANDLE; - - return VDP_STATUS_OK; -} - -/** - * Decode a mpeg 1/2 video. - */ -static VdpStatus -vlVdpDecoderRenderMpeg12(struct pipe_mpeg12_picture_desc *picture, - const VdpPictureInfoMPEG1Or2 *picture_info) -{ - VdpStatus r; - - VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding MPEG12\n"); - - r = vlVdpGetReferenceFrame(picture_info->forward_reference, &picture->ref[0]); - if (r != VDP_STATUS_OK) - return r; - - r = vlVdpGetReferenceFrame(picture_info->backward_reference, &picture->ref[1]); - if (r != VDP_STATUS_OK) - return r; - - picture->picture_coding_type = picture_info->picture_coding_type; - picture->picture_structure = picture_info->picture_structure; - picture->frame_pred_frame_dct = picture_info->frame_pred_frame_dct; - picture->q_scale_type = picture_info->q_scale_type; - picture->alternate_scan = picture_info->alternate_scan; - picture->intra_vlc_format = picture_info->intra_vlc_format; - picture->concealment_motion_vectors = picture_info->concealment_motion_vectors; - picture->intra_dc_precision = picture_info->intra_dc_precision; - picture->f_code[0][0] = picture_info->f_code[0][0] - 1; - picture->f_code[0][1] = picture_info->f_code[0][1] - 1; - picture->f_code[1][0] = picture_info->f_code[1][0] - 1; - picture->f_code[1][1] = picture_info->f_code[1][1] - 1; - picture->num_slices = picture_info->slice_count; - picture->top_field_first = picture_info->top_field_first; - picture->full_pel_forward_vector = picture_info->full_pel_forward_vector; - picture->full_pel_backward_vector = picture_info->full_pel_backward_vector; - picture->intra_matrix = picture_info->intra_quantizer_matrix; - picture->non_intra_matrix = picture_info->non_intra_quantizer_matrix; - - return VDP_STATUS_OK; -} - -/** - * Decode a mpeg 4 video. - */ -static VdpStatus -vlVdpDecoderRenderMpeg4(struct pipe_mpeg4_picture_desc *picture, - const VdpPictureInfoMPEG4Part2 *picture_info) -{ - VdpStatus r; - unsigned i; - - VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding MPEG4\n"); - - r = vlVdpGetReferenceFrame(picture_info->forward_reference, &picture->ref[0]); - if (r != VDP_STATUS_OK) - return r; - - r = vlVdpGetReferenceFrame(picture_info->backward_reference, &picture->ref[1]); - if (r != VDP_STATUS_OK) - return r; - - for (i = 0; i < 2; ++i) { - picture->trd[i] = picture_info->trd[i]; - picture->trb[i] = picture_info->trb[i]; - } - picture->vop_time_increment_resolution = picture_info->vop_time_increment_resolution; - picture->vop_coding_type = picture_info->vop_coding_type; - picture->vop_fcode_forward = picture_info->vop_fcode_forward; - picture->vop_fcode_backward = picture_info->vop_fcode_backward; - picture->resync_marker_disable = picture_info->resync_marker_disable; - picture->interlaced = picture_info->interlaced; - picture->quant_type = picture_info->quant_type; - picture->quarter_sample = picture_info->quarter_sample; - picture->short_video_header = picture_info->short_video_header; - picture->rounding_control = picture_info->rounding_control; - picture->alternate_vertical_scan_flag = picture_info->alternate_vertical_scan_flag; - picture->top_field_first = picture_info->top_field_first; - picture->intra_matrix = picture_info->intra_quantizer_matrix; - picture->non_intra_matrix = picture_info->non_intra_quantizer_matrix; - - return VDP_STATUS_OK; -} - -static VdpStatus -vlVdpDecoderRenderVC1(struct pipe_vc1_picture_desc *picture, - const VdpPictureInfoVC1 *picture_info) -{ - VdpStatus r; - - VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding VC-1\n"); - - r = vlVdpGetReferenceFrame(picture_info->forward_reference, &picture->ref[0]); - if (r != VDP_STATUS_OK) - return r; - - r = vlVdpGetReferenceFrame(picture_info->backward_reference, &picture->ref[1]); - if (r != VDP_STATUS_OK) - return r; - - picture->slice_count = picture_info->slice_count; - picture->picture_type = picture_info->picture_type; - picture->frame_coding_mode = picture_info->frame_coding_mode; - picture->postprocflag = picture_info->postprocflag; - picture->pulldown = picture_info->pulldown; - picture->interlace = picture_info->interlace; - picture->tfcntrflag = picture_info->tfcntrflag; - picture->finterpflag = picture_info->finterpflag; - picture->psf = picture_info->psf; - picture->dquant = picture_info->dquant; - picture->panscan_flag = picture_info->panscan_flag; - picture->refdist_flag = picture_info->refdist_flag; - picture->quantizer = picture_info->quantizer; - picture->extended_mv = picture_info->extended_mv; - picture->extended_dmv = picture_info->extended_dmv; - picture->overlap = picture_info->overlap; - picture->vstransform = picture_info->vstransform; - picture->loopfilter = picture_info->loopfilter; - picture->fastuvmc = picture_info->fastuvmc; - picture->range_mapy_flag = picture_info->range_mapy_flag; - picture->range_mapy = picture_info->range_mapy; - picture->range_mapuv_flag = picture_info->range_mapuv_flag; - picture->range_mapuv = picture_info->range_mapuv; - picture->multires = picture_info->multires; - picture->syncmarker = picture_info->syncmarker; - picture->rangered = picture_info->rangered; - picture->maxbframes = picture_info->maxbframes; - picture->deblockEnable = picture_info->deblockEnable; - picture->pquant = picture_info->pquant; - - return VDP_STATUS_OK; -} - -static VdpStatus -vlVdpDecoderRenderH264(struct pipe_h264_picture_desc *picture, - const VdpPictureInfoH264 *picture_info, - unsigned level_idc) -{ - unsigned i; - - VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Decoding H264\n"); - - picture->pps->sps->chroma_format_idc = H264_CHROMA_FORMAT_IDC_420; - picture->pps->sps->mb_adaptive_frame_field_flag = picture_info->mb_adaptive_frame_field_flag; - picture->pps->sps->frame_mbs_only_flag = picture_info->frame_mbs_only_flag; - picture->pps->sps->log2_max_frame_num_minus4 = picture_info->log2_max_frame_num_minus4; - picture->pps->sps->pic_order_cnt_type = picture_info->pic_order_cnt_type; - picture->pps->sps->log2_max_pic_order_cnt_lsb_minus4 = picture_info->log2_max_pic_order_cnt_lsb_minus4; - picture->pps->sps->delta_pic_order_always_zero_flag = picture_info->delta_pic_order_always_zero_flag; - picture->pps->sps->direct_8x8_inference_flag = picture_info->direct_8x8_inference_flag; - picture->pps->sps->level_idc = level_idc; - picture->pps->sps->MinLumaBiPredSize8x8 = (level_idc >= 31); /* See section A.3.3.2 of H264 spec */; - - picture->pps->transform_8x8_mode_flag = picture_info->transform_8x8_mode_flag; - picture->pps->chroma_qp_index_offset = picture_info->chroma_qp_index_offset; - picture->pps->second_chroma_qp_index_offset = picture_info->second_chroma_qp_index_offset; - picture->pps->pic_init_qp_minus26 = picture_info->pic_init_qp_minus26; - /*picture->pps-> pic_init_qs_minus26 not passed in VdpPictureInfoH264*/ - picture->pps->entropy_coding_mode_flag = picture_info->entropy_coding_mode_flag; - picture->pps->deblocking_filter_control_present_flag = picture_info->deblocking_filter_control_present_flag; - picture->pps->redundant_pic_cnt_present_flag = picture_info->redundant_pic_cnt_present_flag; - picture->pps->constrained_intra_pred_flag = picture_info->constrained_intra_pred_flag; - picture->pps->weighted_pred_flag = picture_info->weighted_pred_flag; - picture->pps->weighted_bipred_idc = picture_info->weighted_bipred_idc; - picture->pps->bottom_field_pic_order_in_frame_present_flag = picture_info->pic_order_present_flag; - memcpy(picture->pps->ScalingList4x4, picture_info->scaling_lists_4x4, 6*16); - memcpy(picture->pps->ScalingList8x8, picture_info->scaling_lists_8x8, 2*64); - - picture->slice_count = picture_info->slice_count; - picture->field_order_cnt[0] = picture_info->field_order_cnt[0]; - picture->field_order_cnt[1] = picture_info->field_order_cnt[1]; - picture->is_reference = picture_info->is_reference; - picture->frame_num = picture_info->frame_num; - picture->field_pic_flag = picture_info->field_pic_flag; - picture->bottom_field_flag = picture_info->bottom_field_flag; - picture->num_ref_frames = picture_info->num_ref_frames; - - picture->num_ref_idx_l0_active_minus1 = picture_info->num_ref_idx_l0_active_minus1; - picture->num_ref_idx_l1_active_minus1 = picture_info->num_ref_idx_l1_active_minus1; - - for (i = 0; i < 16; ++i) { - VdpStatus ret = vlVdpGetReferenceFrame - ( - picture_info->referenceFrames[i].surface, - &picture->ref[i] - ); - if (ret != VDP_STATUS_OK) - return ret; - - picture->is_long_term[i] = picture_info->referenceFrames[i].is_long_term; - picture->top_is_reference[i] = picture_info->referenceFrames[i].top_is_reference; - picture->bottom_is_reference[i] = picture_info->referenceFrames[i].bottom_is_reference; - picture->field_order_cnt_list[i][0] = picture_info->referenceFrames[i].field_order_cnt[0]; - picture->field_order_cnt_list[i][1] = picture_info->referenceFrames[i].field_order_cnt[1]; - picture->frame_num_list[i] = picture_info->referenceFrames[i].frame_idx; - } - - return VDP_STATUS_OK; -} - -static VdpStatus -vlVdpDecoderRenderH265(struct pipe_h265_picture_desc *picture, - const VdpPictureInfoHEVC *picture_info) -{ - unsigned i; - - picture->pps->sps->chroma_format_idc = picture_info->chroma_format_idc; - picture->pps->sps->separate_colour_plane_flag = picture_info->separate_colour_plane_flag; - picture->pps->sps->pic_width_in_luma_samples = picture_info->pic_width_in_luma_samples; - picture->pps->sps->pic_height_in_luma_samples = picture_info->pic_height_in_luma_samples; - picture->pps->sps->bit_depth_luma_minus8 = picture_info->bit_depth_luma_minus8; - picture->pps->sps->bit_depth_chroma_minus8 = picture_info->bit_depth_chroma_minus8; - picture->pps->sps->log2_max_pic_order_cnt_lsb_minus4 = picture_info->log2_max_pic_order_cnt_lsb_minus4; - picture->pps->sps->sps_max_dec_pic_buffering_minus1 = picture_info->sps_max_dec_pic_buffering_minus1; - picture->pps->sps->log2_min_luma_coding_block_size_minus3 = picture_info->log2_min_luma_coding_block_size_minus3; - picture->pps->sps->log2_diff_max_min_luma_coding_block_size = picture_info->log2_diff_max_min_luma_coding_block_size; - picture->pps->sps->log2_min_transform_block_size_minus2 = picture_info->log2_min_transform_block_size_minus2; - picture->pps->sps->log2_diff_max_min_transform_block_size = picture_info->log2_diff_max_min_transform_block_size; - picture->pps->sps->max_transform_hierarchy_depth_inter = picture_info->max_transform_hierarchy_depth_inter; - picture->pps->sps->max_transform_hierarchy_depth_intra = picture_info->max_transform_hierarchy_depth_intra; - picture->pps->sps->scaling_list_enabled_flag = picture_info->scaling_list_enabled_flag; - memcpy(picture->pps->sps->ScalingList4x4, picture_info->ScalingList4x4, 6*16); - memcpy(picture->pps->sps->ScalingList8x8, picture_info->ScalingList8x8, 6*64); - memcpy(picture->pps->sps->ScalingList16x16, picture_info->ScalingList16x16, 6*64); - memcpy(picture->pps->sps->ScalingList32x32, picture_info->ScalingList32x32, 2*64); - memcpy(picture->pps->sps->ScalingListDCCoeff16x16, picture_info->ScalingListDCCoeff16x16, 6); - memcpy(picture->pps->sps->ScalingListDCCoeff32x32, picture_info->ScalingListDCCoeff32x32, 2); - picture->pps->sps->amp_enabled_flag = picture_info->amp_enabled_flag; - picture->pps->sps->sample_adaptive_offset_enabled_flag = picture_info->sample_adaptive_offset_enabled_flag; - picture->pps->sps->pcm_enabled_flag = picture_info->pcm_enabled_flag; - picture->pps->sps->pcm_sample_bit_depth_luma_minus1 = picture_info->pcm_sample_bit_depth_luma_minus1; - picture->pps->sps->pcm_sample_bit_depth_chroma_minus1 = picture_info->pcm_sample_bit_depth_chroma_minus1; - picture->pps->sps->log2_min_pcm_luma_coding_block_size_minus3 = picture_info->log2_min_pcm_luma_coding_block_size_minus3; - picture->pps->sps->log2_diff_max_min_pcm_luma_coding_block_size = picture_info->log2_diff_max_min_pcm_luma_coding_block_size; - picture->pps->sps->pcm_loop_filter_disabled_flag = picture_info->pcm_loop_filter_disabled_flag; - picture->pps->sps->num_short_term_ref_pic_sets = picture_info->num_short_term_ref_pic_sets; - picture->pps->sps->long_term_ref_pics_present_flag = picture_info->long_term_ref_pics_present_flag; - picture->pps->sps->num_long_term_ref_pics_sps = picture_info->num_long_term_ref_pics_sps; - picture->pps->sps->sps_temporal_mvp_enabled_flag = picture_info->sps_temporal_mvp_enabled_flag; - picture->pps->sps->strong_intra_smoothing_enabled_flag = picture_info->strong_intra_smoothing_enabled_flag; - - picture->pps->dependent_slice_segments_enabled_flag = picture_info->dependent_slice_segments_enabled_flag; - picture->pps->output_flag_present_flag = picture_info->output_flag_present_flag; - picture->pps->num_extra_slice_header_bits = picture_info->num_extra_slice_header_bits; - picture->pps->sign_data_hiding_enabled_flag = picture_info->sign_data_hiding_enabled_flag; - picture->pps->cabac_init_present_flag = picture_info->cabac_init_present_flag; - picture->pps->num_ref_idx_l0_default_active_minus1 = picture_info->num_ref_idx_l0_default_active_minus1; - picture->pps->num_ref_idx_l1_default_active_minus1 = picture_info->num_ref_idx_l1_default_active_minus1; - picture->pps->init_qp_minus26 = picture_info->init_qp_minus26; - picture->pps->constrained_intra_pred_flag = picture_info->constrained_intra_pred_flag; - picture->pps->transform_skip_enabled_flag = picture_info->transform_skip_enabled_flag; - picture->pps->cu_qp_delta_enabled_flag = picture_info->cu_qp_delta_enabled_flag; - picture->pps->diff_cu_qp_delta_depth = picture_info->diff_cu_qp_delta_depth; - picture->pps->pps_cb_qp_offset = picture_info->pps_cb_qp_offset; - picture->pps->pps_cr_qp_offset = picture_info->pps_cr_qp_offset; - picture->pps->pps_slice_chroma_qp_offsets_present_flag = picture_info->pps_slice_chroma_qp_offsets_present_flag; - picture->pps->weighted_pred_flag = picture_info->weighted_pred_flag; - picture->pps->weighted_bipred_flag = picture_info->weighted_bipred_flag; - picture->pps->transquant_bypass_enabled_flag = picture_info->transquant_bypass_enabled_flag; - picture->pps->tiles_enabled_flag = picture_info->tiles_enabled_flag; - picture->pps->entropy_coding_sync_enabled_flag = picture_info->entropy_coding_sync_enabled_flag; - picture->pps->num_tile_columns_minus1 = picture_info->num_tile_columns_minus1; - picture->pps->num_tile_rows_minus1 = picture_info->num_tile_rows_minus1; - picture->pps->uniform_spacing_flag = picture_info->uniform_spacing_flag; - memcpy(picture->pps->column_width_minus1, picture_info->column_width_minus1, 20 * 2); - memcpy(picture->pps->row_height_minus1, picture_info->row_height_minus1, 22 * 2); - picture->pps->loop_filter_across_tiles_enabled_flag = picture_info->loop_filter_across_tiles_enabled_flag; - picture->pps->pps_loop_filter_across_slices_enabled_flag = picture_info->pps_loop_filter_across_slices_enabled_flag; - picture->pps->deblocking_filter_control_present_flag = picture_info->deblocking_filter_control_present_flag; - picture->pps->deblocking_filter_override_enabled_flag = picture_info->deblocking_filter_override_enabled_flag; - picture->pps->pps_deblocking_filter_disabled_flag = picture_info->pps_deblocking_filter_disabled_flag; - picture->pps->pps_beta_offset_div2 = picture_info->pps_beta_offset_div2; - picture->pps->pps_tc_offset_div2 = picture_info->pps_tc_offset_div2; - picture->pps->lists_modification_present_flag = picture_info->lists_modification_present_flag; - picture->pps->log2_parallel_merge_level_minus2 = picture_info->log2_parallel_merge_level_minus2; - picture->pps->slice_segment_header_extension_present_flag = picture_info->slice_segment_header_extension_present_flag; - - picture->IDRPicFlag = picture_info->IDRPicFlag; - picture->RAPPicFlag = picture_info->RAPPicFlag; - picture->IntraPicFlag = picture_info->RAPPicFlag; - picture->CurrRpsIdx = picture_info->CurrRpsIdx; - picture->NumPocTotalCurr = picture_info->NumPocTotalCurr; - picture->NumDeltaPocsOfRefRpsIdx = picture_info->NumDeltaPocsOfRefRpsIdx; - picture->NumShortTermPictureSliceHeaderBits = picture_info->NumShortTermPictureSliceHeaderBits; - picture->NumLongTermPictureSliceHeaderBits = picture_info->NumLongTermPictureSliceHeaderBits; - picture->CurrPicOrderCntVal = picture_info->CurrPicOrderCntVal; - - for (i = 0; i < 16; ++i) { - VdpStatus ret = vlVdpGetReferenceFrame - ( - picture_info->RefPics[i], - &picture->ref[i] - ); - if (ret != VDP_STATUS_OK) - return ret; - - picture->PicOrderCntVal[i] = picture_info->PicOrderCntVal[i]; - picture->IsLongTerm[i] = picture_info->IsLongTerm[i]; - } - - picture->NumPocStCurrBefore = picture_info->NumPocStCurrBefore; - picture->NumPocStCurrAfter = picture_info->NumPocStCurrAfter; - picture->NumPocLtCurr = picture_info->NumPocLtCurr; - memcpy(picture->RefPicSetStCurrBefore, picture_info->RefPicSetStCurrBefore, 8); - memcpy(picture->RefPicSetStCurrAfter, picture_info->RefPicSetStCurrAfter, 8); - memcpy(picture->RefPicSetLtCurr, picture_info->RefPicSetLtCurr, 8); - - return VDP_STATUS_OK; -} - -static void -copyArrayInt8FromShort(int8_t *dest, const short *src, unsigned count) { - unsigned i; - - for (i = 0; i < count; ++i) { - *dest = *src; - ++dest; - ++src; - } -} - -static void -copyAV1ScalingPoints(uint8_t *value, uint8_t *scaling, const unsigned char point[][2], unsigned count) { - unsigned i; - - for (i = 0; i < count; ++i) { - *value = (*point)[0]; - ++value; - *scaling = (*point)[1]; - ++scaling; - ++point; - } -} - -static uint8_t -indexOfAV1RefFrame(uint32_t frame, const unsigned int *ref_frame_map) { - uint8_t i; - - for (i = 0; i < AV1_NUM_REF_FRAMES; ++i) { - if (frame == *ref_frame_map) { - break; - } - ++ref_frame_map; - } - - return i; -} - -static void -copyAV1TileInfo(struct pipe_av1_picture_desc *picture, - const VdpPictureInfoAV1 *picture_info) -{ - uint32_t sbCols, sbRows; - uint32_t startSb, i; - int32_t width_sb, height_sb; - uint32_t MiCols = ((picture_info->width + 7) >> 3) << 1; - uint32_t MiRows = ((picture_info->height + 7) >> 3) << 1; - - if (picture_info->use_superres) { - const uint32_t superres_scale_denominator = picture_info->coded_denom + AV1_SUPERRES_DENOM_MIN; - const uint32_t width = ((picture_info->width * 8) + (superres_scale_denominator / 2)) - / superres_scale_denominator; - MiCols = (((width - 1) + 8) >> 3) << 1; - } - - sbCols = picture_info->use_128x128_superblock ? ((MiCols + 31) >> 5) : ((MiCols + 15) >> 4); - sbRows = picture_info->use_128x128_superblock ? ((MiRows + 31) >> 5) : ((MiRows + 15) >> 4); - - width_sb = sbCols; - height_sb = sbRows; - - startSb = 0; - for (i = 0; startSb < sbCols; ++i) { - const uint32_t tile_width = picture_info->tile_widths[i]; - picture->picture_parameter.width_in_sbs[i] = tile_width; - - picture->picture_parameter.tile_col_start_sb[i] = startSb; - startSb += tile_width; - width_sb -= tile_width; - } - picture->picture_parameter.tile_col_start_sb[i] = startSb + width_sb; - - startSb = 0; - for (i = 0; startSb < sbRows; ++i) { - const uint32_t tile_height = picture_info->tile_heights[i]; - picture->picture_parameter.height_in_sbs[i] = tile_height; - - picture->picture_parameter.tile_row_start_sb[i] = startSb; - startSb += tile_height; - height_sb -= tile_height; - } - picture->picture_parameter.tile_row_start_sb[i] = startSb + height_sb; -} - -static VdpStatus -vlVdpDecoderRenderAV1(struct pipe_av1_picture_desc *picture, - const VdpPictureInfoAV1 *picture_info) -{ - unsigned i, j; - - picture->picture_parameter.profile = picture_info->profile; - picture->picture_parameter.order_hint_bits_minus_1 = picture_info->order_hint_bits_minus1; - picture->picture_parameter.bit_depth_idx = picture_info->bit_depth_minus8 >> 1; - - picture->picture_parameter.seq_info_fields.use_128x128_superblock = - picture_info->use_128x128_superblock; - picture->picture_parameter.seq_info_fields.enable_filter_intra = - picture_info->enable_filter_intra; - picture->picture_parameter.seq_info_fields.enable_intra_edge_filter = - picture_info->enable_intra_edge_filter; - picture->picture_parameter.seq_info_fields.enable_interintra_compound = - picture_info->enable_interintra_compound; - picture->picture_parameter.seq_info_fields.enable_masked_compound = - picture_info->enable_masked_compound; - - picture->picture_parameter.seq_info_fields.enable_dual_filter = - picture_info->enable_dual_filter; - picture->picture_parameter.seq_info_fields.enable_order_hint = - picture_info->enable_order_hint; - picture->picture_parameter.seq_info_fields.enable_jnt_comp = - picture_info->enable_jnt_comp; - picture->picture_parameter.seq_info_fields.enable_cdef = - picture_info->enable_cdef; - picture->picture_parameter.seq_info_fields.mono_chrome = - picture_info->mono_chrome; - picture->picture_parameter.seq_info_fields.ref_frame_mvs = - picture_info->enable_order_hint; - picture->picture_parameter.seq_info_fields.film_grain_params_present = - picture_info->enable_fgs; - picture->picture_parameter.seq_info_fields.subsampling_x = - picture_info->subsampling_x; - picture->picture_parameter.seq_info_fields.subsampling_y = - picture_info->subsampling_y; - - picture->picture_parameter.frame_width = picture_info->width; - picture->picture_parameter.frame_height = picture_info->height; - - for (i = 0; i < AV1_NUM_REF_FRAMES; ++i) { - if (picture_info->frame_type == AV1_KEY_FRAME && picture_info->show_frame) { - picture->ref[i] = NULL; - } else { - VdpStatus ret = vlVdpGetReferenceFrame(picture_info->ref_frame_map[i], &picture->ref[i]); - if (ret != VDP_STATUS_OK) { - return ret; - } - } - } - - for (i = 0; i < AV1_REFS_PER_FRAME; ++i) { - const uint8_t idx = indexOfAV1RefFrame(picture_info->ref_frame[i].index, - picture_info->ref_frame_map); - if (idx == AV1_NUM_REF_FRAMES) { - return VDP_STATUS_ERROR; - } - picture->picture_parameter.ref_frame_idx[i] = idx; - } - - if (picture_info->primary_ref_frame == VDP_INVALID_HANDLE) { - picture->picture_parameter.primary_ref_frame = AV1_PRIMARY_REF_NONE; - } else { - const uint8_t *ref_index = picture->picture_parameter.ref_frame_idx; - const uint8_t idx = indexOfAV1RefFrame(picture_info->primary_ref_frame, - picture_info->ref_frame_map); - if (idx == AV1_NUM_REF_FRAMES) { - return VDP_STATUS_ERROR; - } - - for (i = 0; i < AV1_REFS_PER_FRAME; ++i) { - if (idx == *ref_index) { - break; - } - ++ref_index; - } - picture->picture_parameter.primary_ref_frame = i; - } - - picture->picture_parameter.refresh_frame_flags = 0x01; - picture->picture_parameter.order_hint = picture_info->frame_offset; - - // Segment Info - picture->picture_parameter.seg_info.segment_info_fields.enabled = - picture_info->segmentation_enabled; - picture->picture_parameter.seg_info.segment_info_fields.update_map = - picture_info->segmentation_update_map; - picture->picture_parameter.seg_info.segment_info_fields.update_data = - picture_info->segmentation_update_data; - picture->picture_parameter.seg_info.segment_info_fields.temporal_update = - picture_info->segmentation_temporal_update; - memcpy(picture->picture_parameter.seg_info.feature_data, - picture_info->segmentation_feature_data, - sizeof(picture->picture_parameter.seg_info.feature_data)); - memcpy(picture->picture_parameter.seg_info.feature_mask, - picture_info->segmentation_feature_mask, - sizeof(picture->picture_parameter.seg_info.feature_mask)); - - // Film Grain Info - if (picture_info->enable_fgs) { - picture->picture_parameter.film_grain_info.film_grain_info_fields.apply_grain = - picture_info->apply_grain; - picture->picture_parameter.film_grain_info.film_grain_info_fields.chroma_scaling_from_luma = - picture_info->chroma_scaling_from_luma; - picture->picture_parameter.film_grain_info.film_grain_info_fields.grain_scaling_minus_8 = - picture_info->scaling_shift_minus8; - picture->picture_parameter.film_grain_info.film_grain_info_fields.ar_coeff_lag = - picture_info->ar_coeff_lag; - picture->picture_parameter.film_grain_info.film_grain_info_fields.ar_coeff_shift_minus_6 = - picture_info->ar_coeff_shift_minus6; - picture->picture_parameter.film_grain_info.film_grain_info_fields.grain_scale_shift = - picture_info->grain_scale_shift; - picture->picture_parameter.film_grain_info.film_grain_info_fields.overlap_flag = - picture_info->overlap_flag; - picture->picture_parameter.film_grain_info.film_grain_info_fields.clip_to_restricted_range = - picture_info->clip_to_restricted_range; - - picture->picture_parameter.film_grain_info.grain_seed = - picture_info->random_seed; - picture->picture_parameter.film_grain_info.num_y_points = - picture_info->num_y_points; - picture->picture_parameter.film_grain_info.num_cb_points = - picture_info->num_cb_points; - picture->picture_parameter.film_grain_info.num_cr_points = - picture_info->num_cr_points; - picture->picture_parameter.film_grain_info.cb_mult = - picture_info->cb_mult; - picture->picture_parameter.film_grain_info.cb_luma_mult = - picture_info->cb_luma_mult; - picture->picture_parameter.film_grain_info.cb_offset = - picture_info->cb_offset; - picture->picture_parameter.film_grain_info.cr_mult = - picture_info->cr_mult; - picture->picture_parameter.film_grain_info.cr_luma_mult = - picture_info->cr_luma_mult; - picture->picture_parameter.film_grain_info.cr_offset = - picture_info->cr_offset; - - copyAV1ScalingPoints( - picture->picture_parameter.film_grain_info.point_y_value, - picture->picture_parameter.film_grain_info.point_y_scaling, - picture_info->scaling_points_y, - ARRAY_SIZE(picture->picture_parameter.film_grain_info.point_y_value)); - copyAV1ScalingPoints( - picture->picture_parameter.film_grain_info.point_cb_value, - picture->picture_parameter.film_grain_info.point_cb_scaling, - picture_info->scaling_points_cb, - ARRAY_SIZE(picture->picture_parameter.film_grain_info.point_cb_value)); - copyAV1ScalingPoints( - picture->picture_parameter.film_grain_info.point_cr_value, - picture->picture_parameter.film_grain_info.point_cr_scaling, - picture_info->scaling_points_cr, - ARRAY_SIZE(picture->picture_parameter.film_grain_info.point_cr_value)); - - copyArrayInt8FromShort( - picture->picture_parameter.film_grain_info.ar_coeffs_y, - picture_info->ar_coeffs_y, - ARRAY_SIZE(picture->picture_parameter.film_grain_info.ar_coeffs_y)); - copyArrayInt8FromShort( - picture->picture_parameter.film_grain_info.ar_coeffs_cb, - picture_info->ar_coeffs_cb, - ARRAY_SIZE(picture->picture_parameter.film_grain_info.ar_coeffs_cb)); - copyArrayInt8FromShort( - picture->picture_parameter.film_grain_info.ar_coeffs_cr, - picture_info->ar_coeffs_cr, - ARRAY_SIZE(picture->picture_parameter.film_grain_info.ar_coeffs_cr)); - } - - // Picture Info - picture->picture_parameter.pic_info_fields.frame_type = - picture_info->frame_type; - picture->picture_parameter.pic_info_fields.show_frame = - picture_info->show_frame; - picture->picture_parameter.pic_info_fields.showable_frame = 1; - picture->picture_parameter.pic_info_fields.error_resilient_mode = 1; - picture->picture_parameter.pic_info_fields.disable_cdf_update = - picture_info->disable_cdf_update; - picture->picture_parameter.pic_info_fields.allow_screen_content_tools = - picture_info->allow_screen_content_tools; - picture->picture_parameter.pic_info_fields.force_integer_mv = - picture_info->force_integer_mv; - picture->picture_parameter.pic_info_fields.allow_intrabc = - picture_info->allow_intrabc; - picture->picture_parameter.pic_info_fields.use_superres = - picture_info->use_superres; - picture->picture_parameter.pic_info_fields.allow_high_precision_mv = - picture_info->allow_high_precision_mv; - picture->picture_parameter.pic_info_fields.is_motion_mode_switchable = - picture_info->switchable_motion_mode; - picture->picture_parameter.pic_info_fields.use_ref_frame_mvs = - picture_info->use_ref_frame_mvs; - picture->picture_parameter.pic_info_fields.disable_frame_end_update_cdf = - picture_info->disable_frame_end_update_cdf; - picture->picture_parameter.pic_info_fields.uniform_tile_spacing_flag = 0; - picture->picture_parameter.pic_info_fields.allow_warped_motion = - picture_info->allow_warped_motion; - picture->picture_parameter.pic_info_fields.large_scale_tile = 0; - - picture->picture_parameter.superres_scale_denominator = - picture_info->use_superres ? picture_info->coded_denom + AV1_SUPERRES_DENOM_MIN : AV1_SUPERRES_NUM; - - // Loop Filter - picture->picture_parameter.interp_filter = picture_info->interp_filter; - memcpy(picture->picture_parameter.filter_level, - picture_info->loop_filter_level, - sizeof(picture->picture_parameter.filter_level)); - picture->picture_parameter.filter_level_u = - picture_info->loop_filter_level_u; - picture->picture_parameter.filter_level_v = - picture_info->loop_filter_level_v; - picture->picture_parameter.loop_filter_info_fields.sharpness_level = - picture_info->loop_filter_sharpness; - picture->picture_parameter.loop_filter_info_fields.mode_ref_delta_enabled = - picture_info->loop_filter_delta_enabled; - picture->picture_parameter.loop_filter_info_fields.mode_ref_delta_update = - picture_info->loop_filter_delta_update; - memcpy(picture->picture_parameter.ref_deltas, - picture_info->loop_filter_ref_deltas, - sizeof(picture->picture_parameter.ref_deltas)); - memcpy(picture->picture_parameter.mode_deltas, - picture_info->loop_filter_mode_deltas, - sizeof(picture->picture_parameter.mode_deltas)); - - // Tile Info - picture->picture_parameter.tile_cols = picture_info->num_tile_cols; - picture->picture_parameter.tile_rows = picture_info->num_tile_rows; - picture->picture_parameter.context_update_tile_id = - picture_info->context_update_tile_id; - copyAV1TileInfo(picture, picture_info); - - // Quantization Parameters - picture->picture_parameter.base_qindex = picture_info->base_qindex; - picture->picture_parameter.y_dc_delta_q = picture_info->qp_y_dc_delta_q; - picture->picture_parameter.u_dc_delta_q = picture_info->qp_u_dc_delta_q; - picture->picture_parameter.u_ac_delta_q = picture_info->qp_u_ac_delta_q; - picture->picture_parameter.v_dc_delta_q = picture_info->qp_v_dc_delta_q; - picture->picture_parameter.v_ac_delta_q = picture_info->qp_v_ac_delta_q; - - // QMatrix - picture->picture_parameter.qmatrix_fields.using_qmatrix = - picture_info->using_qmatrix; - if (picture_info->using_qmatrix) { - picture->picture_parameter.qmatrix_fields.qm_y = picture_info->qm_y; - picture->picture_parameter.qmatrix_fields.qm_u = picture_info->qm_u; - picture->picture_parameter.qmatrix_fields.qm_v = picture_info->qm_v; - } else { - picture->picture_parameter.qmatrix_fields.qm_y = 0x0f; - picture->picture_parameter.qmatrix_fields.qm_u = 0x0f; - picture->picture_parameter.qmatrix_fields.qm_v = 0x0f; - } - - // Mode Control Fields - picture->picture_parameter.mode_control_fields.delta_q_present_flag = - picture_info->delta_q_present; - picture->picture_parameter.mode_control_fields.log2_delta_q_res = - picture_info->delta_q_res; - picture->picture_parameter.mode_control_fields.delta_lf_present_flag = - picture_info->delta_lf_present; - picture->picture_parameter.mode_control_fields.log2_delta_lf_res = - picture_info->delta_lf_res; - picture->picture_parameter.mode_control_fields.delta_lf_multi = - picture_info->delta_lf_multi; - picture->picture_parameter.mode_control_fields.tx_mode = - picture_info->tx_mode; - picture->picture_parameter.mode_control_fields.reference_select = - picture_info->reference_mode; - picture->picture_parameter.mode_control_fields.reduced_tx_set_used = - picture_info->reduced_tx_set; - picture->picture_parameter.mode_control_fields.skip_mode_present = - picture_info->skip_mode; - - // CDEF - picture->picture_parameter.cdef_damping_minus_3 = - picture_info->cdef_damping_minus_3; - picture->picture_parameter.cdef_bits = picture_info->cdef_bits; - for (i = 0; i < ARRAY_SIZE(picture->picture_parameter.cdef_y_strengths); ++i) { - picture->picture_parameter.cdef_y_strengths[i] = - ((picture_info->cdef_y_strength[i] & 0xf) << 2) + - (picture_info->cdef_y_strength[i] >> 4); - picture->picture_parameter.cdef_uv_strengths[i] = - ((picture_info->cdef_uv_strength[i] & 0xf) << 2) + - (picture_info->cdef_uv_strength[i] >> 4); - } - - // Loop Restoration - picture->picture_parameter.loop_restoration_fields.yframe_restoration_type = - picture_info->lr_type[0]; - picture->picture_parameter.loop_restoration_fields.cbframe_restoration_type = - picture_info->lr_type[1]; - picture->picture_parameter.loop_restoration_fields.crframe_restoration_type = - picture_info->lr_type[2]; - picture->picture_parameter.loop_restoration_fields.lr_unit_shift = - picture_info->lr_unit_size[0] - 1; - picture->picture_parameter.loop_restoration_fields.lr_uv_shift = - picture_info->lr_unit_size[0] - picture_info->lr_unit_size[1]; - - if (picture_info->lr_type[0] || picture_info->lr_type[1] || picture_info->lr_type[2]) { - const uint8_t unit_shift = 6 + picture->picture_parameter.loop_restoration_fields.lr_unit_shift; - - picture->picture_parameter.lr_unit_size[0] = (1 << unit_shift); - picture->picture_parameter.lr_unit_size[1] = - 1 << (unit_shift - picture->picture_parameter.loop_restoration_fields.lr_uv_shift); - picture->picture_parameter.lr_unit_size[2] = - picture->picture_parameter.lr_unit_size[1]; - } else { - for (i = 0; i < ARRAY_SIZE(picture->picture_parameter.lr_unit_size); ++i) { - picture->picture_parameter.lr_unit_size[i] = (1 << 8); - } - } - - // Global Motion - for (i = 0; i < AV1_REFS_PER_FRAME; ++i) { - picture->picture_parameter.wm[i].invalid = picture_info->global_motion[i].invalid; - picture->picture_parameter.wm[i].wmtype = picture_info->global_motion[i].wmtype; - - // VDPAU only has 6 wmmat[] elements, whereas Gallium provides 8. - for (j = 0; j < ARRAY_SIZE(picture_info->global_motion[0].wmmat); ++j) { - picture->picture_parameter.wm[i].wmmat[j] = picture_info->global_motion[i].wmmat[j]; - } - } - - picture->picture_parameter.matrix_coefficients = 0; - - // Tile Information - picture->slice_parameter.slice_count = - picture_info->num_tile_rows * picture_info->num_tile_cols; - for (i = 0; i < picture->slice_parameter.slice_count; ++i) { - const uint32_t start_offset = picture_info->tile_info[i * 2]; - - picture->slice_parameter.slice_data_offset[i] = start_offset; - picture->slice_parameter.slice_data_size[i] = - picture_info->tile_info[i * 2 + 1] - start_offset; - } - - return VDP_STATUS_OK; -} - -static void -vlVdpDecoderFixVC1Startcode(uint32_t *num_buffers, const void *buffers[], unsigned sizes[]) -{ - static const uint8_t vc1_startcode[] = { 0x00, 0x00, 0x01, 0x0D }; - struct vl_vlc vlc = {}; - unsigned i; - - /* search the first 64 bytes for a startcode */ - vl_vlc_init(&vlc, *num_buffers, buffers, sizes); - while (vl_vlc_search_byte(&vlc, 64*8, 0x00) && vl_vlc_bits_left(&vlc) >= 32) { - uint32_t value = vl_vlc_peekbits(&vlc, 32); - if (value == 0x0000010D || - value == 0x0000010C || - value == 0x0000010B) - return; - vl_vlc_eatbits(&vlc, 8); - } - - /* none found, ok add one manually */ - VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Manually adding VC-1 startcode\n"); - for (i = *num_buffers; i > 0; --i) { - buffers[i] = buffers[i - 1]; - sizes[i] = sizes[i - 1]; - } - ++(*num_buffers); - buffers[0] = vc1_startcode; - sizes[0] = 4; -} - -/** - * Decode a compressed field/frame and render the result into a VdpVideoSurface. - */ -VdpStatus -vlVdpDecoderRender(VdpDecoder decoder, - VdpVideoSurface target, - VdpPictureInfo const *picture_info, - uint32_t bitstream_buffer_count, - VdpBitstreamBuffer const *bitstream_buffers) -{ - const void * buffers[bitstream_buffer_count + 1]; - unsigned sizes[bitstream_buffer_count + 1]; - vlVdpDecoder *vldecoder; - vlVdpSurface *vlsurf; - VdpStatus ret; - struct pipe_screen *screen; - struct pipe_video_codec *dec; - bool buffer_support[2]; - unsigned i; - struct pipe_h264_sps sps_h264 = {}; - struct pipe_h264_pps pps_h264 = { &sps_h264 }; - struct pipe_h265_sps sps_h265 = {}; - struct pipe_h265_pps pps_h265 = { &sps_h265 }; - union { - struct pipe_picture_desc base; - struct pipe_mpeg12_picture_desc mpeg12; - struct pipe_mpeg4_picture_desc mpeg4; - struct pipe_vc1_picture_desc vc1; - struct pipe_h264_picture_desc h264; - struct pipe_h265_picture_desc h265; - struct pipe_av1_picture_desc av1; - } desc; - struct pipe_video_buffer *target_buf; - - if (!(picture_info && bitstream_buffers)) - return VDP_STATUS_INVALID_POINTER; - - vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder); - if (!vldecoder) - return VDP_STATUS_INVALID_HANDLE; - dec = vldecoder->decoder; - screen = dec->context->screen; - - vlsurf = (vlVdpSurface *)vlGetDataHTAB(target); - if (!vlsurf) - return VDP_STATUS_INVALID_HANDLE; - - if (vlsurf->device != vldecoder->device) - return VDP_STATUS_HANDLE_DEVICE_MISMATCH; - - if (vlsurf->video_buffer != NULL && - pipe_format_to_chroma_format(vlsurf->video_buffer->buffer_format) != dec->chroma_format) - // TODO: Recreate decoder with correct chroma - return VDP_STATUS_INVALID_CHROMA_TYPE; - - buffer_support[0] = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE); - buffer_support[1] = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_SUPPORTS_INTERLACED); - - if (vlsurf->video_buffer == NULL || - !screen->is_video_format_supported(screen, vlsurf->video_buffer->buffer_format, - dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM) || - !buffer_support[vlsurf->video_buffer->interlaced]) { - - mtx_lock(&vlsurf->device->mutex); - - /* destroy the old one */ - if (vlsurf->video_buffer) - vlsurf->video_buffer->destroy(vlsurf->video_buffer); - - /* set the buffer format to the prefered one */ - vlsurf->templat.buffer_format = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_PREFERRED_FORMAT); - - /* also set interlacing to decoders preferences */ - vlsurf->templat.interlaced = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_PREFERS_INTERLACED); - - /* and recreate the video buffer */ - vlsurf->video_buffer = dec->context->create_video_buffer(dec->context, &vlsurf->templat); - - /* still no luck? get me out of here... */ - if (!vlsurf->video_buffer) { - mtx_unlock(&vlsurf->device->mutex); - return VDP_STATUS_NO_IMPLEMENTATION; - } - vlVdpVideoSurfaceClear(vlsurf); - mtx_unlock(&vlsurf->device->mutex); - } - - for (i = 0; i < bitstream_buffer_count; ++i) { - buffers[i] = bitstream_buffers[i].bitstream; - sizes[i] = bitstream_buffers[i].bitstream_bytes; - } - - memset(&desc, 0, sizeof(desc)); - desc.base.profile = dec->profile; - switch (u_reduce_video_profile(dec->profile)) { - case PIPE_VIDEO_FORMAT_MPEG12: - ret = vlVdpDecoderRenderMpeg12(&desc.mpeg12, (VdpPictureInfoMPEG1Or2 *)picture_info); - break; - case PIPE_VIDEO_FORMAT_MPEG4: - ret = vlVdpDecoderRenderMpeg4(&desc.mpeg4, (VdpPictureInfoMPEG4Part2 *)picture_info); - break; - case PIPE_VIDEO_FORMAT_VC1: - if (dec->profile == PIPE_VIDEO_PROFILE_VC1_ADVANCED) - vlVdpDecoderFixVC1Startcode(&bitstream_buffer_count, buffers, sizes); - ret = vlVdpDecoderRenderVC1(&desc.vc1, (VdpPictureInfoVC1 *)picture_info); - break; - case PIPE_VIDEO_FORMAT_MPEG4_AVC: - desc.h264.pps = &pps_h264; - ret = vlVdpDecoderRenderH264(&desc.h264, (VdpPictureInfoH264 *)picture_info, dec->level); - break; - case PIPE_VIDEO_FORMAT_HEVC: - desc.h265.pps = &pps_h265; - ret = vlVdpDecoderRenderH265(&desc.h265, (VdpPictureInfoHEVC *)picture_info); - break; - case PIPE_VIDEO_FORMAT_AV1: - ret = vlVdpDecoderRenderAV1(&desc.av1, (VdpPictureInfoAV1 *)picture_info); - break; - default: - return VDP_STATUS_INVALID_DECODER_PROFILE; - } - - if (ret != VDP_STATUS_OK) - return ret; - - target_buf = vlsurf->video_buffer; - - if (u_reduce_video_profile(dec->profile) == PIPE_VIDEO_FORMAT_AV1) { - desc.av1.film_grain_target = NULL; - if (desc.av1.picture_parameter.film_grain_info.film_grain_info_fields.apply_grain) { - if (!vlsurf->ref_buffer) { - mtx_lock(&vlsurf->device->mutex); - vlsurf->ref_buffer = dec->context->create_video_buffer(dec->context, &vlsurf->templat); - mtx_unlock(&vlsurf->device->mutex); - if (!vlsurf->ref_buffer) - return VDP_STATUS_RESOURCES; - } - desc.av1.film_grain_target = target_buf; - target_buf = vlsurf->ref_buffer; - } else if (vlsurf->ref_buffer) { - mtx_lock(&vlsurf->device->mutex); - vlsurf->ref_buffer->destroy(vlsurf->ref_buffer); - vlsurf->ref_buffer = NULL; - mtx_unlock(&vlsurf->device->mutex); - } - desc.av1.picture_parameter.max_width = vlsurf->templat.width; - desc.av1.picture_parameter.max_height = vlsurf->templat.height; - } - - mtx_lock(&vldecoder->mutex); - dec->begin_frame(dec, target_buf, &desc.base); - dec->decode_bitstream(dec, target_buf, &desc.base, bitstream_buffer_count, buffers, sizes); - dec->end_frame(dec, target_buf, &desc.base); - mtx_unlock(&vldecoder->mutex); - return ret; -} diff --git a/src/gallium/frontends/vdpau/device.c b/src/gallium/frontends/vdpau/device.c deleted file mode 100644 index b35f5a90ded..00000000000 --- a/src/gallium/frontends/vdpau/device.c +++ /dev/null @@ -1,333 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Younes Manton og Thomas Balling Sørensen. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "util/compiler.h" - -#include "util/u_memory.h" -#include "util/u_debug.h" -#include "util/format/u_format.h" -#include "util/u_sampler.h" - -#include "vdpau_private.h" - -/** - * Create a VdpDevice object for use with X11. - */ -PUBLIC VdpStatus -vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, - VdpGetProcAddress **get_proc_address) -{ - struct pipe_screen *pscreen; - struct pipe_resource *res, res_tmpl; - struct pipe_sampler_view sv_tmpl; - vlVdpDevice *dev = NULL; - VdpStatus ret; - - if (!(display && device && get_proc_address)) - return VDP_STATUS_INVALID_POINTER; - - if (!vlCreateHTAB()) { - ret = VDP_STATUS_RESOURCES; - goto no_htab; - } - - dev = CALLOC(1, sizeof(vlVdpDevice)); - if (!dev) { - ret = VDP_STATUS_RESOURCES; - goto no_dev; - } - - pipe_reference_init(&dev->reference, 1); - - dev->vscreen = vl_dri3_screen_create(display, screen); - if (!dev->vscreen) - dev->vscreen = vl_xlib_swrast_screen_create(display, screen); - if (!dev->vscreen) { - ret = VDP_STATUS_RESOURCES; - goto no_vscreen; - } - - pscreen = dev->vscreen->pscreen; - /* video cannot work if these are not supported */ - if (!pscreen->get_video_param || !pscreen->is_video_format_supported) { - ret = VDP_STATUS_RESOURCES; - goto no_vscreen; - } - - dev->context = pipe_create_multimedia_context(pscreen, false); - if (!dev->context) { - ret = VDP_STATUS_RESOURCES; - goto no_context; - } - - if (!pscreen->caps.npot_textures) { - ret = VDP_STATUS_NO_IMPLEMENTATION; - goto no_context; - } - - memset(&res_tmpl, 0, sizeof(res_tmpl)); - - res_tmpl.target = PIPE_TEXTURE_2D; - res_tmpl.format = PIPE_FORMAT_R8G8B8A8_UNORM; - res_tmpl.width0 = 1; - res_tmpl.height0 = 1; - res_tmpl.depth0 = 1; - res_tmpl.array_size = 1; - res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW; - res_tmpl.usage = PIPE_USAGE_DEFAULT; - - if (!CheckSurfaceParams(pscreen, &res_tmpl)) { - ret = VDP_STATUS_NO_IMPLEMENTATION; - goto no_resource; - } - - res = pscreen->resource_create(pscreen, &res_tmpl); - if (!res) { - ret = VDP_STATUS_RESOURCES; - goto no_resource; - } - - memset(&sv_tmpl, 0, sizeof(sv_tmpl)); - u_sampler_view_default_template(&sv_tmpl, res, res->format); - - sv_tmpl.swizzle_r = PIPE_SWIZZLE_1; - sv_tmpl.swizzle_g = PIPE_SWIZZLE_1; - sv_tmpl.swizzle_b = PIPE_SWIZZLE_1; - sv_tmpl.swizzle_a = PIPE_SWIZZLE_1; - - dev->dummy_sv = dev->context->create_sampler_view(dev->context, res, &sv_tmpl); - pipe_resource_reference(&res, NULL); - if (!dev->dummy_sv) { - ret = VDP_STATUS_RESOURCES; - goto no_resource; - } - - *device = vlAddDataHTAB(dev); - if (*device == 0) { - ret = VDP_STATUS_ERROR; - goto no_handle; - } - - if (!vl_compositor_init(&dev->compositor, dev->context, false)) { - ret = VDP_STATUS_ERROR; - goto no_compositor; - } - - (void) mtx_init(&dev->mutex, mtx_plain); - - *get_proc_address = &vlVdpGetProcAddress; - - return VDP_STATUS_OK; - -no_compositor: - vlRemoveDataHTAB(*device); -no_handle: - dev->context->sampler_view_release(dev->context, dev->dummy_sv); -no_resource: - dev->context->destroy(dev->context); -no_context: - dev->vscreen->destroy(dev->vscreen); -no_vscreen: - FREE(dev); -no_dev: - vlDestroyHTAB(); -no_htab: - return ret; -} - -/** - * Create a VdpPresentationQueueTarget for use with X11. - */ -VdpStatus -vlVdpPresentationQueueTargetCreateX11(VdpDevice device, Drawable drawable, - VdpPresentationQueueTarget *target) -{ - vlVdpPresentationQueueTarget *pqt; - VdpStatus ret; - - if (!drawable) - return VDP_STATUS_INVALID_HANDLE; - - vlVdpDevice *dev = vlGetDataHTAB(device); - if (!dev) - return VDP_STATUS_INVALID_HANDLE; - - pqt = CALLOC(1, sizeof(vlVdpPresentationQueueTarget)); - if (!pqt) - return VDP_STATUS_RESOURCES; - - DeviceReference(&pqt->device, dev); - pqt->drawable = drawable; - - *target = vlAddDataHTAB(pqt); - if (*target == 0) { - ret = VDP_STATUS_ERROR; - goto no_handle; - } - - return VDP_STATUS_OK; - -no_handle: - FREE(pqt); - return ret; -} - -/** - * Destroy a VdpPresentationQueueTarget. - */ -VdpStatus -vlVdpPresentationQueueTargetDestroy(VdpPresentationQueueTarget presentation_queue_target) -{ - vlVdpPresentationQueueTarget *pqt; - - pqt = vlGetDataHTAB(presentation_queue_target); - if (!pqt) - return VDP_STATUS_INVALID_HANDLE; - - vlRemoveDataHTAB(presentation_queue_target); - DeviceReference(&pqt->device, NULL); - FREE(pqt); - - return VDP_STATUS_OK; -} - -/** - * Destroy a VdpDevice. - */ -VdpStatus -vlVdpDeviceDestroy(VdpDevice device) -{ - vlVdpDevice *dev = vlGetDataHTAB(device); - if (!dev) - return VDP_STATUS_INVALID_HANDLE; - - vlRemoveDataHTAB(device); - DeviceReference(&dev, NULL); - - return VDP_STATUS_OK; -} - -/** - * Free a VdpDevice. - */ -void -vlVdpDeviceFree(vlVdpDevice *dev) -{ - mtx_destroy(&dev->mutex); - vl_compositor_cleanup(&dev->compositor); - dev->context->sampler_view_release(dev->context, dev->dummy_sv); - dev->context->destroy(dev->context); - dev->vscreen->destroy(dev->vscreen); - FREE(dev); - vlDestroyHTAB(); -} - -/** - * Retrieve a VDPAU function pointer. - */ -VdpStatus -vlVdpGetProcAddress(VdpDevice device, VdpFuncId function_id, void **function_pointer) -{ - vlVdpDevice *dev = vlGetDataHTAB(device); - if (!dev) - return VDP_STATUS_INVALID_HANDLE; - - if (!function_pointer) - return VDP_STATUS_INVALID_POINTER; - - if (!vlGetFuncFTAB(function_id, function_pointer)) - return VDP_STATUS_INVALID_FUNC_ID; - - VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Got proc address %p for id %d\n", *function_pointer, function_id); - - return VDP_STATUS_OK; -} - -#define _ERROR_TYPE(TYPE,STRING) case TYPE: return STRING; - -/** - * Retrieve a string describing an error code. - */ -char const * -vlVdpGetErrorString (VdpStatus status) -{ - switch (status) { - _ERROR_TYPE(VDP_STATUS_OK,"The operation completed successfully; no error."); - _ERROR_TYPE(VDP_STATUS_NO_IMPLEMENTATION,"No backend implementation could be loaded."); - _ERROR_TYPE(VDP_STATUS_DISPLAY_PREEMPTED,"The display was preempted, or a fatal error occurred. The application must re-initialize VDPAU."); - _ERROR_TYPE(VDP_STATUS_INVALID_HANDLE,"An invalid handle value was provided. Either the handle does not exist at all, or refers to an object of an incorrect type."); - _ERROR_TYPE(VDP_STATUS_INVALID_POINTER,"An invalid pointer was provided. Typically, this means that a NULL pointer was provided for an 'output' parameter."); - _ERROR_TYPE(VDP_STATUS_INVALID_CHROMA_TYPE,"An invalid/unsupported VdpChromaType value was supplied."); - _ERROR_TYPE(VDP_STATUS_INVALID_Y_CB_CR_FORMAT,"An invalid/unsupported VdpYCbCrFormat value was supplied."); - _ERROR_TYPE(VDP_STATUS_INVALID_RGBA_FORMAT,"An invalid/unsupported VdpRGBAFormat value was supplied."); - _ERROR_TYPE(VDP_STATUS_INVALID_INDEXED_FORMAT,"An invalid/unsupported VdpIndexedFormat value was supplied."); - _ERROR_TYPE(VDP_STATUS_INVALID_COLOR_STANDARD,"An invalid/unsupported VdpColorStandard value was supplied."); - _ERROR_TYPE(VDP_STATUS_INVALID_COLOR_TABLE_FORMAT,"An invalid/unsupported VdpColorTableFormat value was supplied."); - _ERROR_TYPE(VDP_STATUS_INVALID_BLEND_FACTOR,"An invalid/unsupported VdpOutputSurfaceRenderBlendFactor value was supplied."); - _ERROR_TYPE(VDP_STATUS_INVALID_BLEND_EQUATION,"An invalid/unsupported VdpOutputSurfaceRenderBlendEquation value was supplied."); - _ERROR_TYPE(VDP_STATUS_INVALID_FLAG,"An invalid/unsupported flag value/combination was supplied."); - _ERROR_TYPE(VDP_STATUS_INVALID_DECODER_PROFILE,"An invalid/unsupported VdpDecoderProfile value was supplied."); - _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE,"An invalid/unsupported VdpVideoMixerFeature value was supplied."); - _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_PARAMETER,"An invalid/unsupported VdpVideoMixerParameter value was supplied."); - _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE,"An invalid/unsupported VdpVideoMixerAttribute value was supplied."); - _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_PICTURE_STRUCTURE,"An invalid/unsupported VdpVideoMixerPictureStructure value was supplied."); - _ERROR_TYPE(VDP_STATUS_INVALID_FUNC_ID,"An invalid/unsupported VdpFuncId value was supplied."); - _ERROR_TYPE(VDP_STATUS_INVALID_SIZE,"The size of a supplied object does not match the object it is being used with.\ - For example, a VdpVideoMixer is configured to process VdpVideoSurface objects of a specific size.\ - If presented with a VdpVideoSurface of a different size, this error will be raised."); - _ERROR_TYPE(VDP_STATUS_INVALID_VALUE,"An invalid/unsupported value was supplied.\ - This is a catch-all error code for values of type other than those with a specific error code."); - _ERROR_TYPE(VDP_STATUS_INVALID_STRUCT_VERSION,"An invalid/unsupported structure version was specified in a versioned structure. \ - This implies that the implementation is older than the header file the application was built against."); - _ERROR_TYPE(VDP_STATUS_RESOURCES,"The system does not have enough resources to complete the requested operation at this time."); - _ERROR_TYPE(VDP_STATUS_HANDLE_DEVICE_MISMATCH,"The set of handles supplied are not all related to the same VdpDevice.When performing operations \ - that operate on multiple surfaces, such as VdpOutputSurfaceRenderOutputSurface or VdpVideoMixerRender, \ - all supplied surfaces must have been created within the context of the same VdpDevice object. \ - This error is raised if they were not."); - _ERROR_TYPE(VDP_STATUS_ERROR,"A catch-all error, used when no other error code applies."); - default: return "Unknown Error"; - } -} - -void -vlVdpDefaultSamplerViewTemplate(struct pipe_sampler_view *templ, struct pipe_resource *res) -{ - const struct util_format_description *desc; - - memset(templ, 0, sizeof(*templ)); - u_sampler_view_default_template(templ, res, res->format); - - desc = util_format_description(res->format); - if (desc->swizzle[0] == PIPE_SWIZZLE_0) - templ->swizzle_r = PIPE_SWIZZLE_1; - if (desc->swizzle[1] == PIPE_SWIZZLE_0) - templ->swizzle_g = PIPE_SWIZZLE_1; - if (desc->swizzle[2] == PIPE_SWIZZLE_0) - templ->swizzle_b = PIPE_SWIZZLE_1; - if (desc->swizzle[3] == PIPE_SWIZZLE_0) - templ->swizzle_a = PIPE_SWIZZLE_1; -} diff --git a/src/gallium/frontends/vdpau/ftab.c b/src/gallium/frontends/vdpau/ftab.c deleted file mode 100644 index a4e234594a0..00000000000 --- a/src/gallium/frontends/vdpau/ftab.c +++ /dev/null @@ -1,139 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Younes Manton & Thomas Balling Sørensen. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include - -#include "util/u_memory.h" - -#include "vdpau_private.h" - -static void* ftab[67] = -{ - &vlVdpGetErrorString, /* VDP_FUNC_ID_GET_ERROR_STRING */ - &vlVdpGetProcAddress, /* VDP_FUNC_ID_GET_PROC_ADDRESS */ - &vlVdpGetApiVersion, /* VDP_FUNC_ID_GET_API_VERSION */ - NULL, /* DUMMY */ - &vlVdpGetInformationString, /* VDP_FUNC_ID_GET_INFORMATION_STRING */ - &vlVdpDeviceDestroy, /* VDP_FUNC_ID_DEVICE_DESTROY */ - &vlVdpGenerateCSCMatrix, /* VDP_FUNC_ID_GENERATE_CSC_MATRIX */ - &vlVdpVideoSurfaceQueryCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES */ - &vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES */ - &vlVdpVideoSurfaceCreate, /* VDP_FUNC_ID_VIDEO_SURFACE_CREATE */ - &vlVdpVideoSurfaceDestroy, /* VDP_FUNC_ID_VIDEO_SURFACE_DESTROY */ - &vlVdpVideoSurfaceGetParameters, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS */ - &vlVdpVideoSurfaceGetBitsYCbCr, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR */ - &vlVdpVideoSurfacePutBitsYCbCr, /* VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR */ - &vlVdpOutputSurfaceQueryCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_CAPABILITIES */ - &vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_GET_PUT_BITS_NATIVE_CAPABILITIES */ - &vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_INDEXED_CAPABILITIES */ - &vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_Y_CB_CR_CAPABILITIES */ - &vlVdpOutputSurfaceCreate, /* VDP_FUNC_ID_OUTPUT_SURFACE_CREATE */ - &vlVdpOutputSurfaceDestroy, /* VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY */ - &vlVdpOutputSurfaceGetParameters, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_PARAMETERS */ - &vlVdpOutputSurfaceGetBitsNative, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE */ - &vlVdpOutputSurfacePutBitsNative, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE */ - &vlVdpOutputSurfacePutBitsIndexed, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED */ - &vlVdpOutputSurfacePutBitsYCbCr, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR */ - &vlVdpBitmapSurfaceQueryCapabilities, /* VDP_FUNC_ID_BITMAP_SURFACE_QUERY_CAPABILITIES */ - &vlVdpBitmapSurfaceCreate, /* VDP_FUNC_ID_BITMAP_SURFACE_CREATE */ - &vlVdpBitmapSurfaceDestroy, /* VDP_FUNC_ID_BITMAP_SURFACE_DESTROY */ - &vlVdpBitmapSurfaceGetParameters, /* VDP_FUNC_ID_BITMAP_SURFACE_GET_PARAMETERS */ - &vlVdpBitmapSurfacePutBitsNative, /* VDP_FUNC_ID_BITMAP_SURFACE_PUT_BITS_NATIVE */ - NULL, /* DUMMY */ - NULL, /* DUMMY */ - NULL, /* DUMMY */ - &vlVdpOutputSurfaceRenderOutputSurface, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE */ - &vlVdpOutputSurfaceRenderBitmapSurface, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE */ - NULL, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_VIDEO_SURFACE_LUMA */ - &vlVdpDecoderQueryCapabilities, /* VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES */ - &vlVdpDecoderCreate, /* VDP_FUNC_ID_DECODER_CREATE */ - &vlVdpDecoderDestroy, /* VDP_FUNC_ID_DECODER_DESTROY */ - &vlVdpDecoderGetParameters, /* VDP_FUNC_ID_DECODER_GET_PARAMETERS */ - &vlVdpDecoderRender, /* VDP_FUNC_ID_DECODER_RENDER */ - &vlVdpVideoMixerQueryFeatureSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT */ - &vlVdpVideoMixerQueryParameterSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT */ - &vlVdpVideoMixerQueryAttributeSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_SUPPORT */ - &vlVdpVideoMixerQueryParameterValueRange, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_VALUE_RANGE */ - &vlVdpVideoMixerQueryAttributeValueRange, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_VALUE_RANGE */ - &vlVdpVideoMixerCreate, /* VDP_FUNC_ID_VIDEO_MIXER_CREATE */ - &vlVdpVideoMixerSetFeatureEnables, /* VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES */ - &vlVdpVideoMixerSetAttributeValues, /* VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES */ - &vlVdpVideoMixerGetFeatureSupport, /* VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_SUPPORT */ - &vlVdpVideoMixerGetFeatureEnables, /* VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_ENABLES */ - &vlVdpVideoMixerGetParameterValues, /* VDP_FUNC_ID_VIDEO_MIXER_GET_PARAMETER_VALUES */ - &vlVdpVideoMixerGetAttributeValues, /* VDP_FUNC_ID_VIDEO_MIXER_GET_ATTRIBUTE_VALUES */ - &vlVdpVideoMixerDestroy, /* VDP_FUNC_ID_VIDEO_MIXER_DESTROY */ - &vlVdpVideoMixerRender, /* VDP_FUNC_ID_VIDEO_MIXER_RENDER */ - &vlVdpPresentationQueueTargetDestroy, /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY */ - &vlVdpPresentationQueueCreate, /* VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE */ - &vlVdpPresentationQueueDestroy, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY */ - &vlVdpPresentationQueueSetBackgroundColor, /* VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR */ - &vlVdpPresentationQueueGetBackgroundColor, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_BACKGROUND_COLOR */ - NULL, /* DUMMY */ - NULL, /* DUMMY */ - &vlVdpPresentationQueueGetTime, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME */ - &vlVdpPresentationQueueDisplay, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY */ - &vlVdpPresentationQueueBlockUntilSurfaceIdle, /* VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE */ - &vlVdpPresentationQueueQuerySurfaceStatus, /* VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS */ - &vlVdpPreemptionCallbackRegister /* VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER */ -}; - -static void* ftab_winsys[1] = -{ - &vlVdpPresentationQueueTargetCreateX11 /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 */ -}; - -static void* ftab_driver[4] = -{ - &vlVdpVideoSurfaceGallium, /* VDP_FUNC_ID_SURFACE_GALLIUM */ - &vlVdpOutputSurfaceGallium, /* VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM */ - &vlVdpVideoSurfaceDMABuf, /* VDP_FUNC_ID_VIDEO_SURFACE_DMA_BUF */ - &vlVdpOutputSurfaceDMABuf /* VDP_FUNC_ID_OUTPUT_SURFACE_DMA_BUF */ -}; - -bool vlGetFuncFTAB(VdpFuncId function_id, void **func) -{ - assert(func); - *func = NULL; - - if (function_id < VDP_FUNC_ID_BASE_WINSYS) { - if (function_id < ARRAY_SIZE(ftab)) - *func = ftab[function_id]; - - } else if (function_id < VDP_FUNC_ID_BASE_DRIVER) { - function_id -= VDP_FUNC_ID_BASE_WINSYS; - if (function_id < ARRAY_SIZE(ftab_winsys)) - *func = ftab_winsys[function_id]; - - } else { - function_id -= VDP_FUNC_ID_BASE_DRIVER; - if (function_id < ARRAY_SIZE(ftab_driver)) - *func = ftab_driver[function_id]; - } - - return *func != NULL; -} diff --git a/src/gallium/frontends/vdpau/htab.c b/src/gallium/frontends/vdpau/htab.c deleted file mode 100644 index 9bd27912bfa..00000000000 --- a/src/gallium/frontends/vdpau/htab.c +++ /dev/null @@ -1,90 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Younes Manton. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "util/simple_mtx.h" -#include "util/u_handle_table.h" -#include "util/u_thread.h" -#include "vdpau_private.h" - -static struct handle_table *htab = NULL; -static simple_mtx_t htab_lock = SIMPLE_MTX_INITIALIZER; - -bool vlCreateHTAB(void) -{ - bool ret; - - /* Make sure handle table handles match VDPAU handles. */ - assert(sizeof(unsigned) <= sizeof(vlHandle)); - simple_mtx_lock(&htab_lock); - if (!htab) - htab = handle_table_create(); - ret = htab != NULL; - simple_mtx_unlock(&htab_lock); - return ret; -} - -void vlDestroyHTAB(void) -{ - simple_mtx_lock(&htab_lock); - if (htab && !handle_table_get_first_handle(htab)) { - handle_table_destroy(htab); - htab = NULL; - } - simple_mtx_unlock(&htab_lock); -} - -vlHandle vlAddDataHTAB(void *data) -{ - vlHandle handle = 0; - - assert(data); - simple_mtx_lock(&htab_lock); - if (htab) - handle = handle_table_add(htab, data); - simple_mtx_unlock(&htab_lock); - return handle; -} - -void* vlGetDataHTAB(vlHandle handle) -{ - void *data = NULL; - - assert(handle); - simple_mtx_lock(&htab_lock); - if (htab) - data = handle_table_get(htab, handle); - simple_mtx_unlock(&htab_lock); - return data; -} - -void vlRemoveDataHTAB(vlHandle handle) -{ - simple_mtx_lock(&htab_lock); - if (htab) - handle_table_remove(htab, handle); - simple_mtx_unlock(&htab_lock); -} diff --git a/src/gallium/frontends/vdpau/meson.build b/src/gallium/frontends/vdpau/meson.build deleted file mode 100644 index ca334a8ca43..00000000000 --- a/src/gallium/frontends/vdpau/meson.build +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright © 2017, 2019 Intel Corproration -# SPDX-License-Identifier: MIT - -VDPAU_MAJOR = 1 -VDPAU_MINOR = 0 - -libvdpau_st = static_library( - 'vdpau_st', - files( - 'bitmap.c', 'decode.c', 'device.c', 'ftab.c', 'htab.c', 'mixer.c', - 'output.c', 'preemption.c', 'presentation.c', 'query.c', 'surface.c', - ), - c_args : [ - '-DVER_MAJOR=@0@'.format(VDPAU_MAJOR), - '-DVER_MINOR=@0@'.format(VDPAU_MINOR), - ], - gnu_symbol_visibility : 'hidden', - include_directories : [ - inc_include, inc_src, inc_util, inc_gallium, inc_gallium_aux, - ], - dependencies : [dep_vdpau, dep_xcb, dep_x11_xcb, dep_libdrm, idep_mesautil], -) diff --git a/src/gallium/frontends/vdpau/mixer.c b/src/gallium/frontends/vdpau/mixer.c deleted file mode 100644 index 6fbf42813ca..00000000000 --- a/src/gallium/frontends/vdpau/mixer.c +++ /dev/null @@ -1,1032 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Thomas Balling Sørensen. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include - -#include "util/u_memory.h" -#include "util/u_debug.h" - -#include "vl/vl_csc.h" - -#include "vdpau_private.h" - -/** - * Create a VdpVideoMixer. - */ -VdpStatus -vlVdpVideoMixerCreate(VdpDevice device, - uint32_t feature_count, - VdpVideoMixerFeature const *features, - uint32_t parameter_count, - VdpVideoMixerParameter const *parameters, - void const *const *parameter_values, - VdpVideoMixer *mixer) -{ - vlVdpVideoMixer *vmixer = NULL; - VdpStatus ret; - struct pipe_screen *screen; - unsigned max_size, i; - - vlVdpDevice *dev = vlGetDataHTAB(device); - if (!dev) - return VDP_STATUS_INVALID_HANDLE; - screen = dev->vscreen->pscreen; - - vmixer = CALLOC(1, sizeof(vlVdpVideoMixer)); - if (!vmixer) - return VDP_STATUS_RESOURCES; - - DeviceReference(&vmixer->device, dev); - - mtx_lock(&dev->mutex); - - if (!vl_compositor_init_state(&vmixer->cstate, dev->context)) { - ret = VDP_STATUS_ERROR; - goto no_compositor_state; - } - - vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, true, &vmixer->csc); - if (!debug_get_bool_option("G3DVL_NO_CSC", false)) { - if (!vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc, 1.0f, 0.0f)) { - ret = VDP_STATUS_ERROR; - goto err_csc_matrix; - } - } - - *mixer = vlAddDataHTAB(vmixer); - if (*mixer == 0) { - ret = VDP_STATUS_ERROR; - goto no_handle; - } - - ret = VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE; - for (i = 0; i < feature_count; ++i) { - switch (features[i]) { - /* they are valid, but we doesn't support them */ - case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9: - case VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE: - break; - - case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL: - vmixer->deint.supported = true; - break; - - case VDP_VIDEO_MIXER_FEATURE_SHARPNESS: - vmixer->sharpness.supported = true; - break; - - case VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION: - vmixer->noise_reduction.supported = true; - break; - - case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY: - vmixer->luma_key.supported = true; - break; - - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1: - vmixer->bicubic.supported = true; - break; - default: goto no_params; - } - } - - vmixer->chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420; - ret = VDP_STATUS_INVALID_VIDEO_MIXER_PARAMETER; - for (i = 0; i < parameter_count; ++i) { - switch (parameters[i]) { - case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH: - vmixer->video_width = *(uint32_t*)parameter_values[i]; - break; - case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT: - vmixer->video_height = *(uint32_t*)parameter_values[i]; - break; - case VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE: - vmixer->chroma_format = ChromaToPipe(*(VdpChromaType*)parameter_values[i]); - break; - case VDP_VIDEO_MIXER_PARAMETER_LAYERS: - vmixer->max_layers = *(uint32_t*)parameter_values[i]; - break; - default: goto no_params; - } - } - ret = VDP_STATUS_INVALID_VALUE; - if (vmixer->max_layers > 4) { - VDPAU_MSG(VDPAU_WARN, "[VDPAU] Max layers %u > 4 not supported\n", vmixer->max_layers); - goto no_params; - } - - max_size = screen->caps.max_texture_2d_size; - if (vmixer->video_width < 48 || vmixer->video_width > max_size) { - VDPAU_MSG(VDPAU_WARN, "[VDPAU] 48 < %u < %u not valid for width\n", - vmixer->video_width, max_size); - goto no_params; - } - if (vmixer->video_height < 48 || vmixer->video_height > max_size) { - VDPAU_MSG(VDPAU_WARN, "[VDPAU] 48 < %u < %u not valid for height\n", - vmixer->video_height, max_size); - goto no_params; - } - vmixer->luma_key.luma_min = 1.0f; - vmixer->luma_key.luma_max = 0.0f; - mtx_unlock(&dev->mutex); - - return VDP_STATUS_OK; - -no_params: - vlRemoveDataHTAB(*mixer); - -no_handle: -err_csc_matrix: - vl_compositor_cleanup_state(&vmixer->cstate); -no_compositor_state: - mtx_unlock(&dev->mutex); - DeviceReference(&vmixer->device, NULL); - FREE(vmixer); - return ret; -} - -/** - * Destroy a VdpVideoMixer. - */ -VdpStatus -vlVdpVideoMixerDestroy(VdpVideoMixer mixer) -{ - vlVdpVideoMixer *vmixer; - - vmixer = vlGetDataHTAB(mixer); - if (!vmixer) - return VDP_STATUS_INVALID_HANDLE; - - mtx_lock(&vmixer->device->mutex); - - vlRemoveDataHTAB(mixer); - - vl_compositor_cleanup_state(&vmixer->cstate); - - if (vmixer->deint.filter) { - vl_deint_filter_cleanup(vmixer->deint.filter); - FREE(vmixer->deint.filter); - } - - if (vmixer->noise_reduction.filter) { - vl_median_filter_cleanup(vmixer->noise_reduction.filter); - FREE(vmixer->noise_reduction.filter); - } - - if (vmixer->sharpness.filter) { - vl_matrix_filter_cleanup(vmixer->sharpness.filter); - FREE(vmixer->sharpness.filter); - } - - if (vmixer->bicubic.filter) { - vl_bicubic_filter_cleanup(vmixer->bicubic.filter); - FREE(vmixer->bicubic.filter); - } - mtx_unlock(&vmixer->device->mutex); - DeviceReference(&vmixer->device, NULL); - - FREE(vmixer); - - return VDP_STATUS_OK; -} - -/** - * Perform a video post-processing and compositing operation. - */ -VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer, - VdpOutputSurface background_surface, - VdpRect const *background_source_rect, - VdpVideoMixerPictureStructure current_picture_structure, - uint32_t video_surface_past_count, - VdpVideoSurface const *video_surface_past, - VdpVideoSurface video_surface_current, - uint32_t video_surface_future_count, - VdpVideoSurface const *video_surface_future, - VdpRect const *video_source_rect, - VdpOutputSurface destination_surface, - VdpRect const *destination_rect, - VdpRect const *destination_video_rect, - uint32_t layer_count, - VdpLayer const *layers) -{ - enum vl_compositor_deinterlace deinterlace; - struct u_rect rect, clip, *prect, dirty_area; - unsigned i, layer = 0; - struct pipe_video_buffer *video_buffer; - struct pipe_sampler_view *sampler_view, sv_templ; - struct pipe_surface surface, surf_templ; - struct pipe_context *pipe = NULL; - struct pipe_resource res_tmpl, *res = NULL; - - vlVdpVideoMixer *vmixer; - vlVdpSurface *surf; - vlVdpOutputSurface *dst, *bg = NULL; - - struct vl_compositor *compositor; - - vmixer = vlGetDataHTAB(mixer); - if (!vmixer) - return VDP_STATUS_INVALID_HANDLE; - - compositor = &vmixer->device->compositor; - - surf = vlGetDataHTAB(video_surface_current); - if (!surf) - return VDP_STATUS_INVALID_HANDLE; - video_buffer = surf->video_buffer; - - if (surf->device != vmixer->device) - return VDP_STATUS_HANDLE_DEVICE_MISMATCH; - - if (vmixer->video_width > video_buffer->width || - vmixer->video_height > video_buffer->height || - vmixer->chroma_format != pipe_format_to_chroma_format(video_buffer->buffer_format)) - return VDP_STATUS_INVALID_SIZE; - - if (layer_count > vmixer->max_layers) - return VDP_STATUS_INVALID_VALUE; - - dst = vlGetDataHTAB(destination_surface); - if (!dst) - return VDP_STATUS_INVALID_HANDLE; - - if (background_surface != VDP_INVALID_HANDLE) { - bg = vlGetDataHTAB(background_surface); - if (!bg) - return VDP_STATUS_INVALID_HANDLE; - } - - mtx_lock(&vmixer->device->mutex); - - vl_compositor_clear_layers(&vmixer->cstate); - - if (bg) - vl_compositor_set_rgba_layer(&vmixer->cstate, compositor, layer++, bg->sampler_view, - RectToPipe(background_source_rect, &rect), NULL, NULL); - - switch (current_picture_structure) { - case VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD: - deinterlace = VL_COMPOSITOR_BOB_TOP; - break; - - case VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD: - deinterlace = VL_COMPOSITOR_BOB_BOTTOM; - break; - - case VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME: - deinterlace = VL_COMPOSITOR_WEAVE; - break; - - default: - mtx_unlock(&vmixer->device->mutex); - return VDP_STATUS_INVALID_VIDEO_MIXER_PICTURE_STRUCTURE; - } - - if (deinterlace != VL_COMPOSITOR_WEAVE && vmixer->deint.enabled && - video_surface_past_count > 1 && video_surface_future_count > 0) { - vlVdpSurface *prevprev = vlGetDataHTAB(video_surface_past[1]); - vlVdpSurface *prev = vlGetDataHTAB(video_surface_past[0]); - vlVdpSurface *next = vlGetDataHTAB(video_surface_future[0]); - if (prevprev && prev && next && - vl_deint_filter_check_buffers(vmixer->deint.filter, - prevprev->video_buffer, prev->video_buffer, surf->video_buffer, next->video_buffer)) { - vl_deint_filter_render(vmixer->deint.filter, prevprev->video_buffer, - prev->video_buffer, surf->video_buffer, - next->video_buffer, - deinterlace == VL_COMPOSITOR_BOB_BOTTOM); - deinterlace = VL_COMPOSITOR_WEAVE; - video_buffer = vmixer->deint.filter->video_buffer; - } - } - - if (!destination_video_rect) - destination_video_rect = video_source_rect; - - prect = RectToPipe(video_source_rect, &rect); - if (!prect) { - rect.x0 = 0; - rect.y0 = 0; - rect.x1 = surf->templat.width; - rect.y1 = surf->templat.height; - prect = ▭ - } - vl_compositor_set_buffer_layer(&vmixer->cstate, compositor, layer, video_buffer, prect, NULL, deinterlace); - - if (vmixer->bicubic.filter || vmixer->sharpness.filter || vmixer->noise_reduction.filter) { - pipe = vmixer->device->context; - memset(&res_tmpl, 0, sizeof(res_tmpl)); - - res_tmpl.target = PIPE_TEXTURE_2D; - res_tmpl.format = dst->sampler_view->format; - res_tmpl.depth0 = 1; - res_tmpl.array_size = 1; - res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; - res_tmpl.usage = PIPE_USAGE_DEFAULT; - - if (!vmixer->bicubic.filter) { - res_tmpl.width0 = pipe_surface_width(&dst->surface); - res_tmpl.height0 = pipe_surface_height(&dst->surface); - } else { - res_tmpl.width0 = surf->templat.width; - res_tmpl.height0 = surf->templat.height; - } - - res = pipe->screen->resource_create(pipe->screen, &res_tmpl); - - vlVdpDefaultSamplerViewTemplate(&sv_templ, res); - sampler_view = pipe->create_sampler_view(pipe, res, &sv_templ); - - memset(&surf_templ, 0, sizeof(surf_templ)); - u_surface_default_template(&surf_templ, res); - surface = surf_templ; - - vl_compositor_reset_dirty_area(&dirty_area); - pipe_resource_reference(&res, NULL); - } else { - surface = dst->surface; - sampler_view = dst->sampler_view; - dirty_area = dst->dirty_area; - } - - if (!vmixer->bicubic.filter) { - vl_compositor_set_layer_dst_area(&vmixer->cstate, layer++, RectToPipe(destination_video_rect, &rect)); - vl_compositor_set_dst_clip(&vmixer->cstate, RectToPipe(destination_rect, &clip)); - } - - for (i = 0; i < layer_count; ++i) { - vlVdpOutputSurface *src = vlGetDataHTAB(layers->source_surface); - if (!src) { - mtx_unlock(&vmixer->device->mutex); - return VDP_STATUS_INVALID_HANDLE; - } - - assert(layers->struct_version == VDP_LAYER_VERSION); - - vl_compositor_set_rgba_layer(&vmixer->cstate, compositor, layer, src->sampler_view, - RectToPipe(layers->source_rect, &rect), NULL, NULL); - vl_compositor_set_layer_dst_area(&vmixer->cstate, layer++, RectToPipe(layers->destination_rect, &rect)); - - ++layers; - } - - vl_compositor_render(&vmixer->cstate, compositor, &surface, &dirty_area, true); - - if (vmixer->noise_reduction.filter) { - if (!vmixer->sharpness.filter && !vmixer->bicubic.filter) { - vl_median_filter_render(vmixer->noise_reduction.filter, - sampler_view, &dst->surface); - } else { - pipe_resource_reference(&res, NULL); - res = pipe->screen->resource_create(pipe->screen, &res_tmpl); - struct pipe_sampler_view *sampler_view_temp = pipe->create_sampler_view(pipe, res, &sv_templ); - surface.texture = res; - - vl_median_filter_render(vmixer->noise_reduction.filter, - sampler_view, &surface); - - pipe->sampler_view_release(pipe, sampler_view); - - sampler_view = sampler_view_temp; - } - } - - if (vmixer->sharpness.filter) { - if (!vmixer->bicubic.filter) { - vl_matrix_filter_render(vmixer->sharpness.filter, - sampler_view, &dst->surface); - } else { - pipe_resource_reference(&res, NULL); - res = pipe->screen->resource_create(pipe->screen, &res_tmpl); - struct pipe_sampler_view *sampler_view_temp = pipe->create_sampler_view(pipe, res, &sv_templ); - surface.texture = res; - - vl_matrix_filter_render(vmixer->sharpness.filter, - sampler_view, &surface); - - pipe->sampler_view_release(pipe, sampler_view); - - sampler_view = sampler_view_temp; - } - } - - if (vmixer->bicubic.filter) - vl_bicubic_filter_render(vmixer->bicubic.filter, - sampler_view, &dst->surface, - RectToPipe(destination_video_rect, &rect), - RectToPipe(destination_rect, &clip)); - - if(surface.texture != dst->surface.texture) { - pipe->sampler_view_release(pipe, sampler_view); - } - pipe_resource_reference(&res, NULL); - mtx_unlock(&vmixer->device->mutex); - - return VDP_STATUS_OK; -} - -static void -vlVdpVideoMixerUpdateDeinterlaceFilter(vlVdpVideoMixer *vmixer) -{ - struct pipe_context *pipe = vmixer->device->context; - assert(vmixer); - - /* remove existing filter */ - if (vmixer->deint.filter) { - vl_deint_filter_cleanup(vmixer->deint.filter); - FREE(vmixer->deint.filter); - vmixer->deint.filter = NULL; - } - - /* create a new filter if requested */ - if (vmixer->deint.enabled && vmixer->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) { - bool interlaced = pipe->screen->get_video_param(pipe->screen, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_PREFERS_INTERLACED); - vmixer->deint.filter = MALLOC(sizeof(struct vl_deint_filter)); - vmixer->deint.enabled = vl_deint_filter_init(vmixer->deint.filter, pipe, - vmixer->video_width, vmixer->video_height, - vmixer->skip_chroma_deint, vmixer->deint.spatial, !interlaced); - if (!vmixer->deint.enabled) { - FREE(vmixer->deint.filter); - vmixer->deint.filter = NULL; - } - } -} - -/** - * Update the noise reduction setting - */ -static void -vlVdpVideoMixerUpdateNoiseReductionFilter(vlVdpVideoMixer *vmixer) -{ - assert(vmixer); - - /* if present remove the old filter first */ - if (vmixer->noise_reduction.filter) { - vl_median_filter_cleanup(vmixer->noise_reduction.filter); - FREE(vmixer->noise_reduction.filter); - vmixer->noise_reduction.filter = NULL; - } - - /* and create a new filter as needed */ - if (vmixer->noise_reduction. enabled && vmixer->noise_reduction.level > 0) { - vmixer->noise_reduction.filter = MALLOC(sizeof(struct vl_median_filter)); - vl_median_filter_init(vmixer->noise_reduction.filter, vmixer->device->context, - vmixer->video_width, vmixer->video_height, - vmixer->noise_reduction.level + 1, - VL_MEDIAN_FILTER_CROSS); - } -} - -static void -vlVdpVideoMixerUpdateSharpnessFilter(vlVdpVideoMixer *vmixer) -{ - assert(vmixer); - - /* if present remove the old filter first */ - if (vmixer->sharpness.filter) { - vl_matrix_filter_cleanup(vmixer->sharpness.filter); - FREE(vmixer->sharpness.filter); - vmixer->sharpness.filter = NULL; - } - - /* and create a new filter as needed */ - if (vmixer->sharpness.enabled && vmixer->sharpness.value != 0.0f) { - float matrix[9]; - unsigned i; - - if (vmixer->sharpness.value > 0.0f) { - matrix[0] = -1.0f; matrix[1] = -1.0f; matrix[2] = -1.0f; - matrix[3] = -1.0f; matrix[4] = 8.0f; matrix[5] = -1.0f; - matrix[6] = -1.0f; matrix[7] = -1.0f; matrix[8] = -1.0f; - - for (i = 0; i < 9; ++i) - matrix[i] *= vmixer->sharpness.value; - - matrix[4] += 1.0f; - - } else { - matrix[0] = 1.0f; matrix[1] = 2.0f; matrix[2] = 1.0f; - matrix[3] = 2.0f; matrix[4] = 4.0f; matrix[5] = 2.0f; - matrix[6] = 1.0f; matrix[7] = 2.0f; matrix[8] = 1.0f; - - for (i = 0; i < 9; ++i) - matrix[i] *= fabsf(vmixer->sharpness.value) / 16.0f; - - matrix[4] += 1.0f - fabsf(vmixer->sharpness.value); - } - - vmixer->sharpness.filter = MALLOC(sizeof(struct vl_matrix_filter)); - vl_matrix_filter_init(vmixer->sharpness.filter, vmixer->device->context, - vmixer->video_width, vmixer->video_height, - 3, 3, matrix); - } -} - -/** - * Update the bicubic filter - */ -static void -vlVdpVideoMixerUpdateBicubicFilter(vlVdpVideoMixer *vmixer) -{ - assert(vmixer); - - /* if present remove the old filter first */ - if (vmixer->bicubic.filter) { - vl_bicubic_filter_cleanup(vmixer->bicubic.filter); - FREE(vmixer->bicubic.filter); - vmixer->bicubic.filter = NULL; - } - /* and create a new filter as needed */ - if (vmixer->bicubic.enabled) { - vmixer->bicubic.filter = MALLOC(sizeof(struct vl_bicubic_filter)); - vl_bicubic_filter_init(vmixer->bicubic.filter, vmixer->device->context, - vmixer->video_width, vmixer->video_height); - } -} - -/** - * Retrieve whether features were requested at creation time. - */ -VdpStatus -vlVdpVideoMixerGetFeatureSupport(VdpVideoMixer mixer, - uint32_t feature_count, - VdpVideoMixerFeature const *features, - VdpBool *feature_supports) -{ - vlVdpVideoMixer *vmixer; - unsigned i; - - if (!(features && feature_supports)) - return VDP_STATUS_INVALID_POINTER; - - vmixer = vlGetDataHTAB(mixer); - if (!vmixer) - return VDP_STATUS_INVALID_HANDLE; - - for (i = 0; i < feature_count; ++i) { - switch (features[i]) { - /* they are valid, but we doesn't support them */ - case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9: - case VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE: - feature_supports[i] = false; - break; - - case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL: - feature_supports[i] = vmixer->deint.supported; - break; - - case VDP_VIDEO_MIXER_FEATURE_SHARPNESS: - feature_supports[i] = vmixer->sharpness.supported; - break; - - case VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION: - feature_supports[i] = vmixer->noise_reduction.supported; - break; - - case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY: - feature_supports[i] = vmixer->luma_key.supported; - break; - - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1: - feature_supports[i] = vmixer->bicubic.supported; - break; - - default: - return VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE; - } - } - - return VDP_STATUS_OK; -} - -/** - * Enable or disable features. - */ -VdpStatus -vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer, - uint32_t feature_count, - VdpVideoMixerFeature const *features, - VdpBool const *feature_enables) -{ - vlVdpVideoMixer *vmixer; - unsigned i; - - if (!(features && feature_enables)) - return VDP_STATUS_INVALID_POINTER; - - vmixer = vlGetDataHTAB(mixer); - if (!vmixer) - return VDP_STATUS_INVALID_HANDLE; - - mtx_lock(&vmixer->device->mutex); - for (i = 0; i < feature_count; ++i) { - switch (features[i]) { - /* they are valid, but we doesn't support them */ - case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9: - case VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE: - break; - - case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL: - vmixer->deint.enabled = feature_enables[i]; - vlVdpVideoMixerUpdateDeinterlaceFilter(vmixer); - break; - - case VDP_VIDEO_MIXER_FEATURE_SHARPNESS: - vmixer->sharpness.enabled = feature_enables[i]; - vlVdpVideoMixerUpdateSharpnessFilter(vmixer); - break; - - case VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION: - vmixer->noise_reduction.enabled = feature_enables[i]; - vlVdpVideoMixerUpdateNoiseReductionFilter(vmixer); - break; - - case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY: - vmixer->luma_key.enabled = feature_enables[i]; - if (!debug_get_bool_option("G3DVL_NO_CSC", false)) - if (!vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc, - vmixer->luma_key.luma_min, vmixer->luma_key.luma_max)) { - mtx_unlock(&vmixer->device->mutex); - return VDP_STATUS_ERROR; - } - break; - - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1: - vmixer->bicubic.enabled = feature_enables[i]; - vlVdpVideoMixerUpdateBicubicFilter(vmixer); - break; - - default: - mtx_unlock(&vmixer->device->mutex); - return VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE; - } - } - mtx_unlock(&vmixer->device->mutex); - - return VDP_STATUS_OK; -} - -/** - * Retrieve whether features are enabled. - */ -VdpStatus -vlVdpVideoMixerGetFeatureEnables(VdpVideoMixer mixer, - uint32_t feature_count, - VdpVideoMixerFeature const *features, - VdpBool *feature_enables) -{ - vlVdpVideoMixer *vmixer; - unsigned i; - - if (!(features && feature_enables)) - return VDP_STATUS_INVALID_POINTER; - - vmixer = vlGetDataHTAB(mixer); - if (!vmixer) - return VDP_STATUS_INVALID_HANDLE; - - for (i = 0; i < feature_count; ++i) { - switch (features[i]) { - /* they are valid, but we doesn't support them */ - case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL: - case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9: - case VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE: - break; - - case VDP_VIDEO_MIXER_FEATURE_SHARPNESS: - feature_enables[i] = vmixer->sharpness.enabled; - break; - - case VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION: - feature_enables[i] = vmixer->noise_reduction.enabled; - break; - - case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY: - feature_enables[i] = vmixer->luma_key.enabled; - break; - - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1: - feature_enables[i] = vmixer->bicubic.enabled; - break; - - default: - return VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE; - } - } - - return VDP_STATUS_OK; -} - -/** - * Set attribute values. - */ -VdpStatus -vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer, - uint32_t attribute_count, - VdpVideoMixerAttribute const *attributes, - void const *const *attribute_values) -{ - const VdpColor *background_color; - union pipe_color_union color; - const float *vdp_csc; - float val; - unsigned i; - VdpStatus ret; - - if (!(attributes && attribute_values)) - return VDP_STATUS_INVALID_POINTER; - - vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer); - if (!vmixer) - return VDP_STATUS_INVALID_HANDLE; - - mtx_lock(&vmixer->device->mutex); - for (i = 0; i < attribute_count; ++i) { - switch (attributes[i]) { - case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR: - background_color = attribute_values[i]; - color.f[0] = background_color->red; - color.f[1] = background_color->green; - color.f[2] = background_color->blue; - color.f[3] = background_color->alpha; - vl_compositor_set_clear_color(&vmixer->cstate, &color); - break; - case VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX: - vdp_csc = attribute_values[i]; - vmixer->custom_csc = !!vdp_csc; - if (!vdp_csc) - vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, 1, &vmixer->csc); - else - memcpy(vmixer->csc, vdp_csc, sizeof(vl_csc_matrix)); - if (!debug_get_bool_option("G3DVL_NO_CSC", false)) - if (!vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc, - vmixer->luma_key.luma_min, vmixer->luma_key.luma_max)) { - ret = VDP_STATUS_ERROR; - goto fail; - } - break; - - case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL: - - val = *(float*)attribute_values[i]; - if (val < 0.0f || val > 1.0f) { - ret = VDP_STATUS_INVALID_VALUE; - goto fail; - } - - vmixer->noise_reduction.level = val * 10; - vlVdpVideoMixerUpdateNoiseReductionFilter(vmixer); - break; - - case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA: - val = *(float*)attribute_values[i]; - if (val < 0.0f || val > 1.0f) { - ret = VDP_STATUS_INVALID_VALUE; - goto fail; - } - vmixer->luma_key.luma_min = val; - if (!debug_get_bool_option("G3DVL_NO_CSC", false)) - if (!vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc, - vmixer->luma_key.luma_min, vmixer->luma_key.luma_max)) { - ret = VDP_STATUS_ERROR; - goto fail; - } - break; - - case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MAX_LUMA: - val = *(float*)attribute_values[i]; - if (val < 0.0f || val > 1.0f) { - ret = VDP_STATUS_INVALID_VALUE; - goto fail; - } - vmixer->luma_key.luma_max = val; - if (!debug_get_bool_option("G3DVL_NO_CSC", false)) - if (!vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc, - vmixer->luma_key.luma_min, vmixer->luma_key.luma_max)) { - ret = VDP_STATUS_ERROR; - goto fail; - } - break; - - case VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL: - - val = *(float*)attribute_values[i]; - if (val < -1.0f || val > 1.0f) { - ret = VDP_STATUS_INVALID_VALUE; - goto fail; - } - - vmixer->sharpness.value = val; - vlVdpVideoMixerUpdateSharpnessFilter(vmixer); - break; - - case VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE: - if (*(uint8_t*)attribute_values[i] > 1) { - ret = VDP_STATUS_INVALID_VALUE; - goto fail; - } - vmixer->skip_chroma_deint = *(uint8_t*)attribute_values[i]; - vlVdpVideoMixerUpdateDeinterlaceFilter(vmixer); - break; - default: - ret = VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE; - goto fail; - } - } - mtx_unlock(&vmixer->device->mutex); - - return VDP_STATUS_OK; -fail: - mtx_unlock(&vmixer->device->mutex); - return ret; -} - -/** - * Retrieve parameter values given at creation time. - */ -VdpStatus -vlVdpVideoMixerGetParameterValues(VdpVideoMixer mixer, - uint32_t parameter_count, - VdpVideoMixerParameter const *parameters, - void *const *parameter_values) -{ - vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer); - unsigned i; - if (!vmixer) - return VDP_STATUS_INVALID_HANDLE; - - if (!parameter_count) - return VDP_STATUS_OK; - if (!(parameters && parameter_values)) - return VDP_STATUS_INVALID_POINTER; - for (i = 0; i < parameter_count; ++i) { - switch (parameters[i]) { - case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH: - *(uint32_t*)parameter_values[i] = vmixer->video_width; - break; - case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT: - *(uint32_t*)parameter_values[i] = vmixer->video_height; - break; - case VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE: - *(VdpChromaType*)parameter_values[i] = PipeToChroma(vmixer->chroma_format); - break; - case VDP_VIDEO_MIXER_PARAMETER_LAYERS: - *(uint32_t*)parameter_values[i] = vmixer->max_layers; - break; - default: - return VDP_STATUS_INVALID_VIDEO_MIXER_PARAMETER; - } - } - return VDP_STATUS_OK; -} - -/** - * Retrieve current attribute values. - */ -VdpStatus -vlVdpVideoMixerGetAttributeValues(VdpVideoMixer mixer, - uint32_t attribute_count, - VdpVideoMixerAttribute const *attributes, - void *const *attribute_values) -{ - unsigned i; - VdpCSCMatrix **vdp_csc; - - if (!(attributes && attribute_values)) - return VDP_STATUS_INVALID_POINTER; - - vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer); - if (!vmixer) - return VDP_STATUS_INVALID_HANDLE; - - mtx_lock(&vmixer->device->mutex); - for (i = 0; i < attribute_count; ++i) { - switch (attributes[i]) { - case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR: - vl_compositor_get_clear_color(&vmixer->cstate, attribute_values[i]); - break; - case VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX: - vdp_csc = attribute_values[i]; - if (!vmixer->custom_csc) { - *vdp_csc = NULL; - break; - } - memcpy(*vdp_csc, vmixer->csc, sizeof(float)*12); - break; - - case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL: - *(float*)attribute_values[i] = (float)vmixer->noise_reduction.level / 10.0f; - break; - - case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA: - *(float*)attribute_values[i] = vmixer->luma_key.luma_min; - break; - case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MAX_LUMA: - *(float*)attribute_values[i] = vmixer->luma_key.luma_max; - break; - case VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL: - *(float*)attribute_values[i] = vmixer->sharpness.value; - break; - case VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE: - *(uint8_t*)attribute_values[i] = vmixer->skip_chroma_deint; - break; - default: - mtx_unlock(&vmixer->device->mutex); - return VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE; - } - } - mtx_unlock(&vmixer->device->mutex); - return VDP_STATUS_OK; -} - -/** - * Generate a color space conversion matrix. - */ -VdpStatus -vlVdpGenerateCSCMatrix(VdpProcamp *procamp, - VdpColorStandard standard, - VdpCSCMatrix *csc_matrix) -{ - enum VL_CSC_COLOR_STANDARD vl_std; - struct vl_procamp camp; - - if (!csc_matrix) - return VDP_STATUS_INVALID_POINTER; - - switch (standard) { - case VDP_COLOR_STANDARD_ITUR_BT_601: vl_std = VL_CSC_COLOR_STANDARD_BT_601; break; - case VDP_COLOR_STANDARD_ITUR_BT_709: vl_std = VL_CSC_COLOR_STANDARD_BT_709; break; - case VDP_COLOR_STANDARD_SMPTE_240M: vl_std = VL_CSC_COLOR_STANDARD_SMPTE_240M; break; - default: return VDP_STATUS_INVALID_COLOR_STANDARD; - } - - if (procamp) { - if (procamp->struct_version > VDP_PROCAMP_VERSION) - return VDP_STATUS_INVALID_STRUCT_VERSION; - camp.brightness = procamp->brightness; - camp.contrast = procamp->contrast; - camp.saturation = procamp->saturation; - camp.hue = procamp->hue; - } - - vl_csc_get_matrix(vl_std, procamp ? &camp : NULL, true, csc_matrix); - return VDP_STATUS_OK; -} diff --git a/src/gallium/frontends/vdpau/output.c b/src/gallium/frontends/vdpau/output.c deleted file mode 100644 index 21c9418647e..00000000000 --- a/src/gallium/frontends/vdpau/output.c +++ /dev/null @@ -1,829 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Thomas Balling Sørensen. - * Copyright 2011 Christian König. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include - -#include "util/u_debug.h" -#include "util/u_memory.h" -#include "util/u_sampler.h" -#include "util/format/u_format.h" -#include "util/u_surface.h" - -#include "vl/vl_csc.h" - -#include "frontend/drm_driver.h" - -#include "vdpau_private.h" - -/** - * Create a VdpOutputSurface. - */ -VdpStatus -vlVdpOutputSurfaceCreate(VdpDevice device, - VdpRGBAFormat rgba_format, - uint32_t width, uint32_t height, - VdpOutputSurface *surface) -{ - struct pipe_context *pipe; - struct pipe_resource res_tmpl, *res; - struct pipe_sampler_view sv_templ; - struct pipe_surface surf_templ; - - vlVdpOutputSurface *vlsurface = NULL; - - if (!(width && height)) - return VDP_STATUS_INVALID_SIZE; - - vlVdpDevice *dev = vlGetDataHTAB(device); - if (!dev) - return VDP_STATUS_INVALID_HANDLE; - - pipe = dev->context; - if (!pipe) - return VDP_STATUS_INVALID_HANDLE; - - vlsurface = CALLOC(1, sizeof(vlVdpOutputSurface)); - if (!vlsurface) - return VDP_STATUS_RESOURCES; - - DeviceReference(&vlsurface->device, dev); - - memset(&res_tmpl, 0, sizeof(res_tmpl)); - - /* - * The output won't look correctly when this buffer is send to X, - * if the VDPAU RGB component order doesn't match the X11 one so - * we only allow the X11 format - */ - vlsurface->send_to_X = dev->vscreen->color_depth == 24 && - rgba_format == VDP_RGBA_FORMAT_B8G8R8A8; - - res_tmpl.target = PIPE_TEXTURE_2D; - res_tmpl.format = VdpFormatRGBAToPipe(rgba_format); - res_tmpl.width0 = width; - res_tmpl.height0 = height; - res_tmpl.depth0 = 1; - res_tmpl.array_size = 1; - res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET | - PIPE_BIND_SHARED | PIPE_BIND_SCANOUT; - res_tmpl.usage = PIPE_USAGE_DEFAULT; - - mtx_lock(&dev->mutex); - - if (!CheckSurfaceParams(pipe->screen, &res_tmpl)) - goto err_unlock; - - res = pipe->screen->resource_create(pipe->screen, &res_tmpl); - if (!res) - goto err_unlock; - - vlVdpDefaultSamplerViewTemplate(&sv_templ, res); - vlsurface->sampler_view = pipe->create_sampler_view(pipe, res, &sv_templ); - if (!vlsurface->sampler_view) - goto err_resource; - - memset(&surf_templ, 0, sizeof(surf_templ)); - u_surface_default_template(&surf_templ, res); - vlsurface->surface = surf_templ; - - *surface = vlAddDataHTAB(vlsurface); - if (*surface == 0) - goto err_resource; - - pipe_resource_reference(&res, NULL); - - if (!vl_compositor_init_state(&vlsurface->cstate, pipe)) - goto err_resource; - - vl_compositor_reset_dirty_area(&vlsurface->dirty_area); - mtx_unlock(&dev->mutex); - - return VDP_STATUS_OK; - -err_resource: - pipe->sampler_view_release(pipe, vlsurface->sampler_view); - pipe_resource_reference(&res, NULL); -err_unlock: - mtx_unlock(&dev->mutex); - DeviceReference(&vlsurface->device, NULL); - FREE(vlsurface); - return VDP_STATUS_ERROR; -} - -/** - * Destroy a VdpOutputSurface. - */ -VdpStatus -vlVdpOutputSurfaceDestroy(VdpOutputSurface surface) -{ - vlVdpOutputSurface *vlsurface; - struct pipe_context *pipe; - - vlsurface = vlGetDataHTAB(surface); - if (!vlsurface) - return VDP_STATUS_INVALID_HANDLE; - - pipe = vlsurface->device->context; - - mtx_lock(&vlsurface->device->mutex); - - pipe->sampler_view_release(pipe, vlsurface->sampler_view); - pipe->screen->fence_reference(pipe->screen, &vlsurface->fence, NULL); - vl_compositor_cleanup_state(&vlsurface->cstate); - mtx_unlock(&vlsurface->device->mutex); - - vlRemoveDataHTAB(surface); - DeviceReference(&vlsurface->device, NULL); - FREE(vlsurface); - - return VDP_STATUS_OK; -} - -/** - * Retrieve the parameters used to create a VdpOutputSurface. - */ -VdpStatus -vlVdpOutputSurfaceGetParameters(VdpOutputSurface surface, - VdpRGBAFormat *rgba_format, - uint32_t *width, uint32_t *height) -{ - vlVdpOutputSurface *vlsurface; - - vlsurface = vlGetDataHTAB(surface); - if (!vlsurface) - return VDP_STATUS_INVALID_HANDLE; - - *rgba_format = PipeToFormatRGBA(vlsurface->sampler_view->texture->format); - *width = vlsurface->sampler_view->texture->width0; - *height = vlsurface->sampler_view->texture->height0; - - return VDP_STATUS_OK; -} - -/** - * Copy image data from a VdpOutputSurface to application memory in the - * surface's native format. - */ -VdpStatus -vlVdpOutputSurfaceGetBitsNative(VdpOutputSurface surface, - VdpRect const *source_rect, - void *const *destination_data, - uint32_t const *destination_pitches) -{ - vlVdpOutputSurface *vlsurface; - struct pipe_context *pipe; - struct pipe_resource *res; - struct pipe_box box; - struct pipe_transfer *transfer; - uint8_t *map; - - vlsurface = vlGetDataHTAB(surface); - if (!vlsurface) - return VDP_STATUS_INVALID_HANDLE; - - pipe = vlsurface->device->context; - if (!pipe) - return VDP_STATUS_INVALID_HANDLE; - - if (!destination_data || !destination_pitches) - return VDP_STATUS_INVALID_POINTER; - - mtx_lock(&vlsurface->device->mutex); - - res = vlsurface->sampler_view->texture; - box = RectToPipeBox(source_rect, res); - map = pipe->texture_map(pipe, res, 0, PIPE_MAP_READ, &box, &transfer); - if (!map) { - mtx_unlock(&vlsurface->device->mutex); - return VDP_STATUS_RESOURCES; - } - - util_copy_rect(*destination_data, res->format, *destination_pitches, 0, 0, - box.width, box.height, map, transfer->stride, 0, 0); - - pipe_texture_unmap(pipe, transfer); - mtx_unlock(&vlsurface->device->mutex); - - return VDP_STATUS_OK; -} - -/** - * Copy image data from application memory in the surface's native format to - * a VdpOutputSurface. - */ -VdpStatus -vlVdpOutputSurfacePutBitsNative(VdpOutputSurface surface, - void const *const *source_data, - uint32_t const *source_pitches, - VdpRect const *destination_rect) -{ - vlVdpOutputSurface *vlsurface; - struct pipe_box dst_box; - struct pipe_context *pipe; - - vlsurface = vlGetDataHTAB(surface); - if (!vlsurface) - return VDP_STATUS_INVALID_HANDLE; - - pipe = vlsurface->device->context; - if (!pipe) - return VDP_STATUS_INVALID_HANDLE; - - if (!source_data || !source_pitches) - return VDP_STATUS_INVALID_POINTER; - - mtx_lock(&vlsurface->device->mutex); - - dst_box = RectToPipeBox(destination_rect, vlsurface->sampler_view->texture); - - /* Check for a no-op. (application bug?) */ - if (!dst_box.width || !dst_box.height) { - mtx_unlock(&vlsurface->device->mutex); - return VDP_STATUS_OK; - } - - pipe->texture_subdata(pipe, vlsurface->sampler_view->texture, 0, - PIPE_MAP_WRITE, &dst_box, *source_data, - *source_pitches, 0); - mtx_unlock(&vlsurface->device->mutex); - - return VDP_STATUS_OK; -} - -/** - * Copy image data from application memory in a specific indexed format to - * a VdpOutputSurface. - */ -VdpStatus -vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface, - VdpIndexedFormat source_indexed_format, - void const *const *source_data, - uint32_t const *source_pitch, - VdpRect const *destination_rect, - VdpColorTableFormat color_table_format, - void const *color_table) -{ - vlVdpOutputSurface *vlsurface; - struct pipe_context *context; - struct vl_compositor *compositor; - struct vl_compositor_state *cstate; - - enum pipe_format index_format; - enum pipe_format colortbl_format; - - struct pipe_resource *res, res_tmpl; - struct pipe_sampler_view sv_tmpl; - struct pipe_sampler_view *sv_idx = NULL, *sv_tbl = NULL; - - struct pipe_box box; - struct u_rect dst_rect; - - vlsurface = vlGetDataHTAB(surface); - if (!vlsurface) - return VDP_STATUS_INVALID_HANDLE; - - context = vlsurface->device->context; - compositor = &vlsurface->device->compositor; - cstate = &vlsurface->cstate; - - index_format = FormatIndexedToPipe(source_indexed_format); - if (index_format == PIPE_FORMAT_NONE) - return VDP_STATUS_INVALID_INDEXED_FORMAT; - - if (!source_data || !source_pitch) - return VDP_STATUS_INVALID_POINTER; - - colortbl_format = FormatColorTableToPipe(color_table_format); - if (colortbl_format == PIPE_FORMAT_NONE) - return VDP_STATUS_INVALID_COLOR_TABLE_FORMAT; - - if (!color_table) - return VDP_STATUS_INVALID_POINTER; - - memset(&res_tmpl, 0, sizeof(res_tmpl)); - res_tmpl.target = PIPE_TEXTURE_2D; - res_tmpl.format = index_format; - - if (destination_rect) { - if (destination_rect->x1 > destination_rect->x0 && - destination_rect->y1 > destination_rect->y0) { - res_tmpl.width0 = destination_rect->x1 - destination_rect->x0; - res_tmpl.height0 = destination_rect->y1 - destination_rect->y0; - } - } else { - res_tmpl.width0 = vlsurface->surface.texture->width0; - res_tmpl.height0 = vlsurface->surface.texture->height0; - } - res_tmpl.depth0 = 1; - res_tmpl.array_size = 1; - res_tmpl.usage = PIPE_USAGE_STAGING; - res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW; - - mtx_lock(&vlsurface->device->mutex); - - if (!CheckSurfaceParams(context->screen, &res_tmpl)) - goto error_resource; - - res = context->screen->resource_create(context->screen, &res_tmpl); - if (!res) - goto error_resource; - - box.x = box.y = box.z = 0; - box.width = res->width0; - box.height = res->height0; - box.depth = res->depth0; - - context->texture_subdata(context, res, 0, PIPE_MAP_WRITE, &box, - source_data[0], source_pitch[0], - source_pitch[0] * res->height0); - - memset(&sv_tmpl, 0, sizeof(sv_tmpl)); - u_sampler_view_default_template(&sv_tmpl, res, res->format); - - sv_idx = context->create_sampler_view(context, res, &sv_tmpl); - pipe_resource_reference(&res, NULL); - - if (!sv_idx) - goto error_resource; - - memset(&res_tmpl, 0, sizeof(res_tmpl)); - res_tmpl.target = PIPE_TEXTURE_1D; - res_tmpl.format = colortbl_format; - res_tmpl.width0 = 1 << util_format_get_component_bits( - index_format, UTIL_FORMAT_COLORSPACE_RGB, 0); - res_tmpl.height0 = 1; - res_tmpl.depth0 = 1; - res_tmpl.array_size = 1; - res_tmpl.usage = PIPE_USAGE_STAGING; - res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW; - - res = context->screen->resource_create(context->screen, &res_tmpl); - if (!res) - goto error_resource; - - box.x = box.y = box.z = 0; - box.width = res->width0; - box.height = res->height0; - box.depth = res->depth0; - - context->texture_subdata(context, res, 0, PIPE_MAP_WRITE, &box, color_table, - util_format_get_stride(colortbl_format, res->width0), 0); - - memset(&sv_tmpl, 0, sizeof(sv_tmpl)); - u_sampler_view_default_template(&sv_tmpl, res, res->format); - - sv_tbl = context->create_sampler_view(context, res, &sv_tmpl); - pipe_resource_reference(&res, NULL); - - if (!sv_tbl) - goto error_resource; - - vl_compositor_clear_layers(cstate); - vl_compositor_set_palette_layer(cstate, compositor, 0, sv_idx, sv_tbl, NULL, NULL, false); - vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect)); - vl_compositor_render(cstate, compositor, &vlsurface->surface, &vlsurface->dirty_area, false); - - context->sampler_view_release(context, sv_idx); - context->sampler_view_release(context, sv_tbl); - mtx_unlock(&vlsurface->device->mutex); - - return VDP_STATUS_OK; - -error_resource: - context->sampler_view_release(context, sv_idx); - context->sampler_view_release(context, sv_tbl); - mtx_unlock(&vlsurface->device->mutex); - return VDP_STATUS_RESOURCES; -} - -/** - * Copy image data from application memory in a specific YCbCr format to - * a VdpOutputSurface. - */ -VdpStatus -vlVdpOutputSurfacePutBitsYCbCr(VdpOutputSurface surface, - VdpYCbCrFormat source_ycbcr_format, - void const *const *source_data, - uint32_t const *source_pitches, - VdpRect const *destination_rect, - VdpCSCMatrix const *csc_matrix) -{ - vlVdpOutputSurface *vlsurface; - struct vl_compositor *compositor; - struct vl_compositor_state *cstate; - - struct pipe_context *pipe; - enum pipe_format format; - struct pipe_video_buffer vtmpl, *vbuffer; - struct u_rect dst_rect; - struct pipe_sampler_view **sampler_views; - - unsigned i; - - vlsurface = vlGetDataHTAB(surface); - if (!vlsurface) - return VDP_STATUS_INVALID_HANDLE; - - - pipe = vlsurface->device->context; - compositor = &vlsurface->device->compositor; - cstate = &vlsurface->cstate; - - format = FormatYCBCRToPipe(source_ycbcr_format); - if (format == PIPE_FORMAT_NONE) - return VDP_STATUS_INVALID_Y_CB_CR_FORMAT; - - if (!source_data || !source_pitches) - return VDP_STATUS_INVALID_POINTER; - - mtx_lock(&vlsurface->device->mutex); - memset(&vtmpl, 0, sizeof(vtmpl)); - vtmpl.buffer_format = format; - - if (destination_rect) { - if (destination_rect->x1 > destination_rect->x0 && - destination_rect->y1 > destination_rect->y0) { - vtmpl.width = destination_rect->x1 - destination_rect->x0; - vtmpl.height = destination_rect->y1 - destination_rect->y0; - } - } else { - vtmpl.width = vlsurface->surface.texture->width0; - vtmpl.height = vlsurface->surface.texture->height0; - } - - vbuffer = pipe->create_video_buffer(pipe, &vtmpl); - if (!vbuffer) { - mtx_unlock(&vlsurface->device->mutex); - return VDP_STATUS_RESOURCES; - } - - sampler_views = vbuffer->get_sampler_view_planes(vbuffer); - if (!sampler_views) { - vbuffer->destroy(vbuffer); - mtx_unlock(&vlsurface->device->mutex); - return VDP_STATUS_RESOURCES; - } - - for (i = 0; i < 3; ++i) { - struct pipe_sampler_view *sv = sampler_views[i]; - if (!sv) continue; - - struct pipe_box dst_box; - u_box_3d(0, 0, 0, - sv->texture->width0, sv->texture->height0, 1, &dst_box); - - pipe->texture_subdata(pipe, sv->texture, 0, PIPE_MAP_WRITE, &dst_box, - source_data[i], source_pitches[i], 0); - } - - if (!csc_matrix) { - vl_csc_matrix csc; - vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, 1, &csc); - if (!vl_compositor_set_csc_matrix(cstate, (const vl_csc_matrix*)&csc, 1.0f, 0.0f)) - goto err_csc_matrix; - } else { - if (!vl_compositor_set_csc_matrix(cstate, csc_matrix, 1.0f, 0.0f)) - goto err_csc_matrix; - } - - vl_compositor_clear_layers(cstate); - vl_compositor_set_buffer_layer(cstate, compositor, 0, vbuffer, NULL, NULL, VL_COMPOSITOR_WEAVE); - vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect)); - vl_compositor_render(cstate, compositor, &vlsurface->surface, &vlsurface->dirty_area, false); - - vbuffer->destroy(vbuffer); - mtx_unlock(&vlsurface->device->mutex); - - return VDP_STATUS_OK; -err_csc_matrix: - vbuffer->destroy(vbuffer); - mtx_unlock(&vlsurface->device->mutex); - return VDP_STATUS_ERROR; -} - -static unsigned -BlendFactorToPipe(VdpOutputSurfaceRenderBlendFactor factor) -{ - switch (factor) { - case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ZERO: - return PIPE_BLENDFACTOR_ZERO; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE: - return PIPE_BLENDFACTOR_ONE; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_SRC_COLOR: - return PIPE_BLENDFACTOR_SRC_COLOR; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_SRC_COLOR: - return PIPE_BLENDFACTOR_INV_SRC_COLOR; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_SRC_ALPHA: - return PIPE_BLENDFACTOR_SRC_ALPHA; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA: - return PIPE_BLENDFACTOR_INV_SRC_ALPHA; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_DST_ALPHA: - return PIPE_BLENDFACTOR_DST_ALPHA; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_DST_ALPHA: - return PIPE_BLENDFACTOR_INV_DST_ALPHA; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_DST_COLOR: - return PIPE_BLENDFACTOR_DST_COLOR; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_DST_COLOR: - return PIPE_BLENDFACTOR_INV_DST_COLOR; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_SRC_ALPHA_SATURATE: - return PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_CONSTANT_COLOR: - return PIPE_BLENDFACTOR_CONST_COLOR; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR: - return PIPE_BLENDFACTOR_INV_CONST_COLOR; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_CONSTANT_ALPHA: - return PIPE_BLENDFACTOR_CONST_ALPHA; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA: - return PIPE_BLENDFACTOR_INV_CONST_ALPHA; - default: - assert(0); - return PIPE_BLENDFACTOR_ONE; - } -} - -static unsigned -BlendEquationToPipe(VdpOutputSurfaceRenderBlendEquation equation) -{ - switch (equation) { - case VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_SUBTRACT: - return PIPE_BLEND_SUBTRACT; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_REVERSE_SUBTRACT: - return PIPE_BLEND_REVERSE_SUBTRACT; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD: - return PIPE_BLEND_ADD; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_MIN: - return PIPE_BLEND_MIN; - case VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_MAX: - return PIPE_BLEND_MAX; - default: - assert(0); - return PIPE_BLEND_ADD; - } -} - -static void * -BlenderToPipe(struct pipe_context *context, - VdpOutputSurfaceRenderBlendState const *blend_state) -{ - struct pipe_blend_state blend; - - memset(&blend, 0, sizeof blend); - blend.independent_blend_enable = 0; - - if (blend_state) { - blend.rt[0].blend_enable = 1; - blend.rt[0].rgb_src_factor = BlendFactorToPipe(blend_state->blend_factor_source_color); - blend.rt[0].rgb_dst_factor = BlendFactorToPipe(blend_state->blend_factor_destination_color); - blend.rt[0].alpha_src_factor = BlendFactorToPipe(blend_state->blend_factor_source_alpha); - blend.rt[0].alpha_dst_factor = BlendFactorToPipe(blend_state->blend_factor_destination_alpha); - blend.rt[0].rgb_func = BlendEquationToPipe(blend_state->blend_equation_color); - blend.rt[0].alpha_func = BlendEquationToPipe(blend_state->blend_equation_alpha); - } else { - blend.rt[0].blend_enable = 0; - } - - blend.logicop_enable = 0; - blend.logicop_func = PIPE_LOGICOP_CLEAR; - blend.rt[0].colormask = PIPE_MASK_RGBA; - blend.dither = 0; - - return context->create_blend_state(context, &blend); -} - -static struct vertex4f * -ColorsToPipe(VdpColor const *colors, uint32_t flags, struct vertex4f result[4]) -{ - unsigned i; - struct vertex4f *dst = result; - - if (!colors) - return NULL; - - for (i = 0; i < 4; ++i) { - dst->x = colors->red; - dst->y = colors->green; - dst->z = colors->blue; - dst->w = colors->alpha; - - ++dst; - if (flags & VDP_OUTPUT_SURFACE_RENDER_COLOR_PER_VERTEX) - ++colors; - } - return result; -} - -/** - * Composite a sub-rectangle of a VdpOutputSurface into a sub-rectangle of - * another VdpOutputSurface; Output Surface object VdpOutputSurface. - */ -VdpStatus -vlVdpOutputSurfaceRenderOutputSurface(VdpOutputSurface destination_surface, - VdpRect const *destination_rect, - VdpOutputSurface source_surface, - VdpRect const *source_rect, - VdpColor const *colors, - VdpOutputSurfaceRenderBlendState const *blend_state, - uint32_t flags) -{ - vlVdpOutputSurface *dst_vlsurface; - - struct pipe_context *context; - struct pipe_sampler_view *src_sv; - struct vl_compositor *compositor; - struct vl_compositor_state *cstate; - - struct u_rect src_rect, dst_rect; - - struct vertex4f vlcolors[4]; - void *blend; - - dst_vlsurface = vlGetDataHTAB(destination_surface); - if (!dst_vlsurface) - return VDP_STATUS_INVALID_HANDLE; - - if (source_surface == VDP_INVALID_HANDLE) { - src_sv = dst_vlsurface->device->dummy_sv; - - } else { - vlVdpOutputSurface *src_vlsurface = vlGetDataHTAB(source_surface); - if (!src_vlsurface) - return VDP_STATUS_INVALID_HANDLE; - - if (dst_vlsurface->device != src_vlsurface->device) - return VDP_STATUS_HANDLE_DEVICE_MISMATCH; - - src_sv = src_vlsurface->sampler_view; - } - - mtx_lock(&dst_vlsurface->device->mutex); - - context = dst_vlsurface->device->context; - compositor = &dst_vlsurface->device->compositor; - cstate = &dst_vlsurface->cstate; - - blend = BlenderToPipe(context, blend_state); - - vl_compositor_clear_layers(cstate); - vl_compositor_set_layer_blend(cstate, 0, blend, false); - vl_compositor_set_rgba_layer(cstate, compositor, 0, src_sv, - RectToPipe(source_rect, &src_rect), NULL, - ColorsToPipe(colors, flags, vlcolors)); - STATIC_ASSERT(VL_COMPOSITOR_ROTATE_0 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_0); - STATIC_ASSERT(VL_COMPOSITOR_ROTATE_90 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_90); - STATIC_ASSERT(VL_COMPOSITOR_ROTATE_180 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_180); - STATIC_ASSERT(VL_COMPOSITOR_ROTATE_270 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_270); - vl_compositor_set_layer_rotation(cstate, 0, flags & 3); - vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect)); - vl_compositor_render(cstate, compositor, &dst_vlsurface->surface, &dst_vlsurface->dirty_area, false); - - context->delete_blend_state(context, blend); - mtx_unlock(&dst_vlsurface->device->mutex); - - return VDP_STATUS_OK; -} - -/** - * Composite a sub-rectangle of a VdpBitmapSurface into a sub-rectangle of - * a VdpOutputSurface; Output Surface object VdpOutputSurface. - */ -VdpStatus -vlVdpOutputSurfaceRenderBitmapSurface(VdpOutputSurface destination_surface, - VdpRect const *destination_rect, - VdpBitmapSurface source_surface, - VdpRect const *source_rect, - VdpColor const *colors, - VdpOutputSurfaceRenderBlendState const *blend_state, - uint32_t flags) -{ - vlVdpOutputSurface *dst_vlsurface; - - struct pipe_context *context; - struct pipe_sampler_view *src_sv; - struct vl_compositor *compositor; - struct vl_compositor_state *cstate; - - struct u_rect src_rect, dst_rect; - - struct vertex4f vlcolors[4]; - void *blend; - - dst_vlsurface = vlGetDataHTAB(destination_surface); - if (!dst_vlsurface) - return VDP_STATUS_INVALID_HANDLE; - - if (source_surface == VDP_INVALID_HANDLE) { - src_sv = dst_vlsurface->device->dummy_sv; - - } else { - vlVdpBitmapSurface *src_vlsurface = vlGetDataHTAB(source_surface); - if (!src_vlsurface) - return VDP_STATUS_INVALID_HANDLE; - - if (dst_vlsurface->device != src_vlsurface->device) - return VDP_STATUS_HANDLE_DEVICE_MISMATCH; - - src_sv = src_vlsurface->sampler_view; - } - - context = dst_vlsurface->device->context; - compositor = &dst_vlsurface->device->compositor; - cstate = &dst_vlsurface->cstate; - - mtx_lock(&dst_vlsurface->device->mutex); - - blend = BlenderToPipe(context, blend_state); - - vl_compositor_clear_layers(cstate); - vl_compositor_set_layer_blend(cstate, 0, blend, false); - vl_compositor_set_rgba_layer(cstate, compositor, 0, src_sv, - RectToPipe(source_rect, &src_rect), NULL, - ColorsToPipe(colors, flags, vlcolors)); - vl_compositor_set_layer_rotation(cstate, 0, flags & 3); - vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect)); - vl_compositor_render(cstate, compositor, &dst_vlsurface->surface, &dst_vlsurface->dirty_area, false); - - context->delete_blend_state(context, blend); - mtx_unlock(&dst_vlsurface->device->mutex); - - return VDP_STATUS_OK; -} - -struct pipe_resource *vlVdpOutputSurfaceGallium(VdpOutputSurface surface) -{ - vlVdpOutputSurface *vlsurface; - - vlsurface = vlGetDataHTAB(surface); - if (!vlsurface || !vlsurface->surface.texture) - return NULL; - - mtx_lock(&vlsurface->device->mutex); - vlsurface->device->context->flush(vlsurface->device->context, NULL, 0); - mtx_unlock(&vlsurface->device->mutex); - - return vlsurface->surface.texture; -} - -VdpStatus vlVdpOutputSurfaceDMABuf(VdpOutputSurface surface, - struct VdpSurfaceDMABufDesc *result) -{ - vlVdpOutputSurface *vlsurface; - struct pipe_screen *pscreen; - struct winsys_handle whandle; - - memset(result, 0, sizeof(*result)); - result->handle = -1; - - vlsurface = vlGetDataHTAB(surface); - if (!vlsurface || !vlsurface->surface.texture) - return VDP_STATUS_INVALID_HANDLE; - - mtx_lock(&vlsurface->device->mutex); - vlsurface->device->context->flush(vlsurface->device->context, NULL, 0); - - memset(&whandle, 0, sizeof(struct winsys_handle)); - whandle.type = WINSYS_HANDLE_TYPE_FD; - - pscreen = vlsurface->surface.texture->screen; - if (!pscreen->resource_get_handle(pscreen, vlsurface->device->context, - vlsurface->surface.texture, &whandle, - PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE)) { - mtx_unlock(&vlsurface->device->mutex); - return VDP_STATUS_NO_IMPLEMENTATION; - } - - mtx_unlock(&vlsurface->device->mutex); - - result->handle = whandle.handle; - result->width = pipe_surface_width(&vlsurface->surface); - result->height = pipe_surface_height(&vlsurface->surface); - result->offset = whandle.offset; - result->stride = whandle.stride; - result->format = PipeToFormatRGBA(vlsurface->surface.format); - - return VDP_STATUS_OK; -} diff --git a/src/gallium/frontends/vdpau/preemption.c b/src/gallium/frontends/vdpau/preemption.c deleted file mode 100644 index 6d376acd339..00000000000 --- a/src/gallium/frontends/vdpau/preemption.c +++ /dev/null @@ -1,48 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Thomas Balling Sørensen. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include -#include "vdpau_private.h" - -/** - * A callback to notify the client application that a device's display has - * been preempted. - */ -void vlVdpPreemptionCallback(VdpDevice device, void *context) -{ - /* TODO: Implement preemption */ -} - -/** - * Configure the display preemption callback. - */ -VdpStatus vlVdpPreemptionCallbackRegister(VdpDevice device, - VdpPreemptionCallback callback, - void *context) -{ - return VDP_STATUS_OK; -} diff --git a/src/gallium/frontends/vdpau/presentation.c b/src/gallium/frontends/vdpau/presentation.c deleted file mode 100644 index 5b995d91fe2..00000000000 --- a/src/gallium/frontends/vdpau/presentation.c +++ /dev/null @@ -1,382 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Thomas Balling Sørensen. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include -#include - -#include "util/u_debug.h" -#include "util/u_memory.h" - -#include "vdpau_private.h" - -/** - * Create a VdpPresentationQueue. - */ -VdpStatus -vlVdpPresentationQueueCreate(VdpDevice device, - VdpPresentationQueueTarget presentation_queue_target, - VdpPresentationQueue *presentation_queue) -{ - vlVdpPresentationQueue *pq = NULL; - VdpStatus ret; - - if (!presentation_queue) - return VDP_STATUS_INVALID_POINTER; - - vlVdpDevice *dev = vlGetDataHTAB(device); - if (!dev) - return VDP_STATUS_INVALID_HANDLE; - - vlVdpPresentationQueueTarget *pqt = vlGetDataHTAB(presentation_queue_target); - if (!pqt) - return VDP_STATUS_INVALID_HANDLE; - - if (dev != pqt->device) - return VDP_STATUS_HANDLE_DEVICE_MISMATCH; - - pq = CALLOC(1, sizeof(vlVdpPresentationQueue)); - if (!pq) - return VDP_STATUS_RESOURCES; - - DeviceReference(&pq->device, dev); - pq->drawable = pqt->drawable; - - mtx_lock(&dev->mutex); - if (!vl_compositor_init_state(&pq->cstate, dev->context)) { - mtx_unlock(&dev->mutex); - ret = VDP_STATUS_ERROR; - goto no_compositor; - } - mtx_unlock(&dev->mutex); - - *presentation_queue = vlAddDataHTAB(pq); - if (*presentation_queue == 0) { - ret = VDP_STATUS_ERROR; - goto no_handle; - } - - return VDP_STATUS_OK; - -no_handle: -no_compositor: - DeviceReference(&pq->device, NULL); - FREE(pq); - return ret; -} - -/** - * Destroy a VdpPresentationQueue. - */ -VdpStatus -vlVdpPresentationQueueDestroy(VdpPresentationQueue presentation_queue) -{ - vlVdpPresentationQueue *pq; - - pq = vlGetDataHTAB(presentation_queue); - if (!pq) - return VDP_STATUS_INVALID_HANDLE; - - mtx_lock(&pq->device->mutex); - vl_compositor_cleanup_state(&pq->cstate); - mtx_unlock(&pq->device->mutex); - - vlRemoveDataHTAB(presentation_queue); - DeviceReference(&pq->device, NULL); - FREE(pq); - - return VDP_STATUS_OK; -} - -/** - * Configure the background color setting. - */ -VdpStatus -vlVdpPresentationQueueSetBackgroundColor(VdpPresentationQueue presentation_queue, - VdpColor *const background_color) -{ - vlVdpPresentationQueue *pq; - union pipe_color_union color; - - if (!background_color) - return VDP_STATUS_INVALID_POINTER; - - pq = vlGetDataHTAB(presentation_queue); - if (!pq) - return VDP_STATUS_INVALID_HANDLE; - - color.f[0] = background_color->red; - color.f[1] = background_color->green; - color.f[2] = background_color->blue; - color.f[3] = background_color->alpha; - - mtx_lock(&pq->device->mutex); - vl_compositor_set_clear_color(&pq->cstate, &color); - mtx_unlock(&pq->device->mutex); - - return VDP_STATUS_OK; -} - -/** - * Retrieve the current background color setting. - */ -VdpStatus -vlVdpPresentationQueueGetBackgroundColor(VdpPresentationQueue presentation_queue, - VdpColor *const background_color) -{ - vlVdpPresentationQueue *pq; - union pipe_color_union color; - - if (!background_color) - return VDP_STATUS_INVALID_POINTER; - - pq = vlGetDataHTAB(presentation_queue); - if (!pq) - return VDP_STATUS_INVALID_HANDLE; - - mtx_lock(&pq->device->mutex); - vl_compositor_get_clear_color(&pq->cstate, &color); - mtx_unlock(&pq->device->mutex); - - background_color->red = color.f[0]; - background_color->green = color.f[1]; - background_color->blue = color.f[2]; - background_color->alpha = color.f[3]; - - return VDP_STATUS_OK; -} - -/** - * Retrieve the presentation queue's "current" time. - */ -VdpStatus -vlVdpPresentationQueueGetTime(VdpPresentationQueue presentation_queue, - VdpTime *current_time) -{ - vlVdpPresentationQueue *pq; - - if (!current_time) - return VDP_STATUS_INVALID_POINTER; - - pq = vlGetDataHTAB(presentation_queue); - if (!pq) - return VDP_STATUS_INVALID_HANDLE; - - mtx_lock(&pq->device->mutex); - *current_time = pq->device->vscreen->get_timestamp(pq->device->vscreen, - (void *)pq->drawable); - mtx_unlock(&pq->device->mutex); - - return VDP_STATUS_OK; -} - -/** - * Enter a surface into the presentation queue. - */ -VdpStatus -vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue, - VdpOutputSurface surface, - uint32_t clip_width, - uint32_t clip_height, - VdpTime earliest_presentation_time) -{ - static int dump_window = -1; - - vlVdpPresentationQueue *pq; - vlVdpOutputSurface *surf; - - struct pipe_context *pipe; - struct pipe_resource *tex; - struct pipe_surface surf_templ; - struct u_rect src_rect, dst_clip, *dirty_area; - - struct vl_compositor *compositor; - struct vl_compositor_state *cstate; - struct vl_screen *vscreen; - - pq = vlGetDataHTAB(presentation_queue); - if (!pq) - return VDP_STATUS_INVALID_HANDLE; - - surf = vlGetDataHTAB(surface); - if (!surf) - return VDP_STATUS_INVALID_HANDLE; - - pipe = pq->device->context; - compositor = &pq->device->compositor; - cstate = &pq->cstate; - vscreen = pq->device->vscreen; - - mtx_lock(&pq->device->mutex); - if (vscreen->set_back_texture_from_output && surf->send_to_X) - vscreen->set_back_texture_from_output(vscreen, surf->surface.texture, clip_width, clip_height); - tex = vscreen->texture_from_drawable(vscreen, (void *)pq->drawable); - if (!tex) { - mtx_unlock(&pq->device->mutex); - return VDP_STATUS_INVALID_HANDLE; - } - - if (!vscreen->set_back_texture_from_output || !surf->send_to_X) { - dirty_area = vscreen->get_dirty_area(vscreen); - - memset(&surf_templ, 0, sizeof(surf_templ)); - u_surface_default_template(&surf_templ, tex); - - dst_clip.x0 = 0; - dst_clip.y0 = 0; - dst_clip.x1 = clip_width ? clip_width : pipe_surface_width(&surf_templ); - dst_clip.y1 = clip_height ? clip_height : pipe_surface_height(&surf_templ); - - src_rect.x0 = 0; - src_rect.y0 = 0; - src_rect.x1 = pipe_surface_width(&surf_templ); - src_rect.y1 = pipe_surface_height(&surf_templ); - - vl_compositor_clear_layers(cstate); - vl_compositor_set_rgba_layer(cstate, compositor, 0, surf->sampler_view, &src_rect, NULL, NULL); - vl_compositor_set_dst_clip(cstate, &dst_clip); - vl_compositor_render(cstate, compositor, &surf_templ, dirty_area, true); - } - - vscreen->set_next_timestamp(vscreen, earliest_presentation_time); - - // flush before calling flush_frontbuffer so that rendering is flushed - // to back buffer so the texture can be copied in flush_frontbuffer - pipe->screen->fence_reference(pipe->screen, &surf->fence, NULL); - pipe->flush(pipe, &surf->fence, 0); - pipe->screen->flush_frontbuffer(pipe->screen, pipe, tex, 0, 0, - vscreen->get_private(vscreen), 0, NULL); - - pq->last_surf = surf; - - if (dump_window == -1) { - dump_window = debug_get_num_option("VDPAU_DUMP", 0); - } - - if (dump_window) { - static unsigned int framenum = 0; - char cmd[256]; - - if (framenum) { - sprintf(cmd, "xwd -id %d -silent -out vdpau_frame_%08d.xwd", (int)pq->drawable, framenum); - if (system(cmd) != 0) - VDPAU_MSG(VDPAU_ERR, "[VDPAU] Dumping surface %d failed.\n", surface); - } - framenum++; - } - - if (!vscreen->set_back_texture_from_output || !surf->send_to_X) { - pipe_resource_reference(&tex, NULL); - } - mtx_unlock(&pq->device->mutex); - - return VDP_STATUS_OK; -} - -/** - * Wait for a surface to finish being displayed. - */ -VdpStatus -vlVdpPresentationQueueBlockUntilSurfaceIdle(VdpPresentationQueue presentation_queue, - VdpOutputSurface surface, - VdpTime *first_presentation_time) -{ - vlVdpPresentationQueue *pq; - vlVdpOutputSurface *surf; - struct pipe_screen *screen; - - if (!first_presentation_time) - return VDP_STATUS_INVALID_POINTER; - - pq = vlGetDataHTAB(presentation_queue); - if (!pq) - return VDP_STATUS_INVALID_HANDLE; - - surf = vlGetDataHTAB(surface); - if (!surf) - return VDP_STATUS_INVALID_HANDLE; - - mtx_lock(&pq->device->mutex); - if (surf->fence) { - screen = pq->device->vscreen->pscreen; - screen->fence_finish(screen, NULL, surf->fence, OS_TIMEOUT_INFINITE); - screen->fence_reference(screen, &surf->fence, NULL); - } - mtx_unlock(&pq->device->mutex); - - return vlVdpPresentationQueueGetTime(presentation_queue, first_presentation_time); -} - -/** - * Poll the current queue status of a surface. - */ -VdpStatus -vlVdpPresentationQueueQuerySurfaceStatus(VdpPresentationQueue presentation_queue, - VdpOutputSurface surface, - VdpPresentationQueueStatus *status, - VdpTime *first_presentation_time) -{ - vlVdpPresentationQueue *pq; - vlVdpOutputSurface *surf; - struct pipe_screen *screen; - - if (!(status && first_presentation_time)) - return VDP_STATUS_INVALID_POINTER; - - pq = vlGetDataHTAB(presentation_queue); - if (!pq) - return VDP_STATUS_INVALID_HANDLE; - - surf = vlGetDataHTAB(surface); - if (!surf) - return VDP_STATUS_INVALID_HANDLE; - - *first_presentation_time = 0; - - if (!surf->fence) { - if (pq->last_surf == surf) - *status = VDP_PRESENTATION_QUEUE_STATUS_VISIBLE; - else - *status = VDP_PRESENTATION_QUEUE_STATUS_IDLE; - } else { - mtx_lock(&pq->device->mutex); - screen = pq->device->vscreen->pscreen; - if (screen->fence_finish(screen, NULL, surf->fence, 0)) { - screen->fence_reference(screen, &surf->fence, NULL); - *status = VDP_PRESENTATION_QUEUE_STATUS_VISIBLE; - mtx_unlock(&pq->device->mutex); - - // We actually need to query the timestamp of the last VSYNC event from the hardware - vlVdpPresentationQueueGetTime(presentation_queue, first_presentation_time); - *first_presentation_time += 1; - } else { - *status = VDP_PRESENTATION_QUEUE_STATUS_QUEUED; - mtx_unlock(&pq->device->mutex); - } - } - - return VDP_STATUS_OK; -} diff --git a/src/gallium/frontends/vdpau/query.c b/src/gallium/frontends/vdpau/query.c deleted file mode 100644 index 2358279c285..00000000000 --- a/src/gallium/frontends/vdpau/query.c +++ /dev/null @@ -1,630 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Younes Manton. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include -#include - -#include "vdpau_private.h" -#include "pipe/p_screen.h" -#include "pipe/p_defines.h" -#include "util/u_debug.h" - -#include "vl/vl_codec.h" - -/** - * Retrieve the VDPAU version implemented by the backend. - */ -VdpStatus -vlVdpGetApiVersion(uint32_t *api_version) -{ - if (!api_version) - return VDP_STATUS_INVALID_POINTER; - - *api_version = 1; - return VDP_STATUS_OK; -} - -/** - * Retrieve an implementation-specific string description of the implementation. - * This typically includes detailed version information. - */ -VdpStatus -vlVdpGetInformationString(char const **information_string) -{ - if (!information_string) - return VDP_STATUS_INVALID_POINTER; - - *information_string = INFORMATION_STRING; - return VDP_STATUS_OK; -} - -/** - * Query the implementation's VdpVideoSurface capabilities. - */ -VdpStatus -vlVdpVideoSurfaceQueryCapabilities(VdpDevice device, VdpChromaType surface_chroma_type, - VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height) -{ - vlVdpDevice *dev; - struct pipe_screen *pscreen; - uint32_t max_2d_texture_size; - - if (!(is_supported && max_width && max_height)) - return VDP_STATUS_INVALID_POINTER; - - dev = vlGetDataHTAB(device); - if (!dev) - return VDP_STATUS_INVALID_HANDLE; - - pscreen = dev->vscreen->pscreen; - if (!pscreen) - return VDP_STATUS_RESOURCES; - - mtx_lock(&dev->mutex); - - /* XXX: Current limits */ - *is_supported = true; - max_2d_texture_size = pscreen->caps.max_texture_2d_size; - mtx_unlock(&dev->mutex); - if (!max_2d_texture_size) - return VDP_STATUS_RESOURCES; - - *max_width = *max_height = max_2d_texture_size; - - return VDP_STATUS_OK; -} - -/** - * Query the implementation's VdpVideoSurface GetBits/PutBits capabilities. - */ -VdpStatus -vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaType surface_chroma_type, - VdpYCbCrFormat bits_ycbcr_format, - VdpBool *is_supported) -{ - vlVdpDevice *dev; - struct pipe_screen *pscreen; - VdpYCbCrFormat ycbcrFormat; - bool supported; - - if (!is_supported) - return VDP_STATUS_INVALID_POINTER; - - dev = vlGetDataHTAB(device); - if (!dev) - return VDP_STATUS_INVALID_HANDLE; - - pscreen = dev->vscreen->pscreen; - if (!pscreen) - return VDP_STATUS_RESOURCES; - - mtx_lock(&dev->mutex); - - ycbcrFormat = bits_ycbcr_format; - switch(bits_ycbcr_format) { - case VDP_YCBCR_FORMAT_NV12: - supported = surface_chroma_type == VDP_CHROMA_TYPE_420; - break; - - case VDP_YCBCR_FORMAT_YV12: - supported = surface_chroma_type == VDP_CHROMA_TYPE_420; - - /* We can convert YV12 to NV12 on the fly! */ - ycbcrFormat = VDP_YCBCR_FORMAT_NV12; - break; - - case VDP_YCBCR_FORMAT_UYVY: - case VDP_YCBCR_FORMAT_YUYV: - supported = surface_chroma_type == VDP_CHROMA_TYPE_422; - break; - - case VDP_YCBCR_FORMAT_Y8U8V8A8: - case VDP_YCBCR_FORMAT_V8U8Y8A8: - supported = surface_chroma_type == VDP_CHROMA_TYPE_444; - break; - - case VDP_YCBCR_FORMAT_P010: - case VDP_YCBCR_FORMAT_P016: - /* Do any other profiles imply support for this chroma type? */ - supported = (surface_chroma_type == VDP_CHROMA_TYPE_420_16) - && vl_codec_supported(pscreen, PIPE_VIDEO_PROFILE_HEVC_MAIN_10, false); - break; - - default: - supported = false; - break; - } - - if (supported && - !pscreen->is_video_format_supported(pscreen, - FormatYCBCRToPipe(ycbcrFormat), - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM)) { - supported = false; - } - *is_supported = supported; - - mtx_unlock(&dev->mutex); - - return VDP_STATUS_OK; -} - -/** - * Query the implementation's VdpDecoder capabilities. - */ -VdpStatus -vlVdpDecoderQueryCapabilities(VdpDevice device, VdpDecoderProfile profile, - VdpBool *is_supported, uint32_t *max_level, uint32_t *max_macroblocks, - uint32_t *max_width, uint32_t *max_height) -{ - vlVdpDevice *dev; - struct pipe_screen *pscreen; - enum pipe_video_profile p_profile; - - if (!(is_supported && max_level && max_macroblocks && max_width && max_height)) - return VDP_STATUS_INVALID_POINTER; - - dev = vlGetDataHTAB(device); - if (!dev) - return VDP_STATUS_INVALID_HANDLE; - - pscreen = dev->vscreen->pscreen; - if (!pscreen) - return VDP_STATUS_RESOURCES; - - p_profile = ProfileToPipe(profile); - if (p_profile == PIPE_VIDEO_PROFILE_UNKNOWN) { - *is_supported = false; - return VDP_STATUS_OK; - } - - mtx_lock(&dev->mutex); - *is_supported = vl_codec_supported(pscreen, p_profile, false); - if (*is_supported) { - *max_width = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_MAX_WIDTH); - *max_height = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_MAX_HEIGHT); - *max_level = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_MAX_LEVEL); - *max_macroblocks = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_MAX_MACROBLOCKS); - if (*max_macroblocks == 0) { - *max_macroblocks = (*max_width/16)*(*max_height/16); - } - } else { - *max_width = 0; - *max_height = 0; - *max_level = 0; - *max_macroblocks = 0; - } - mtx_unlock(&dev->mutex); - - return VDP_STATUS_OK; -} - -/** - * Query the implementation's VdpOutputSurface capabilities. - */ -VdpStatus -vlVdpOutputSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format, - VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height) -{ - vlVdpDevice *dev; - struct pipe_screen *pscreen; - enum pipe_format format; - - dev = vlGetDataHTAB(device); - if (!dev) - return VDP_STATUS_INVALID_HANDLE; - - pscreen = dev->vscreen->pscreen; - if (!pscreen) - return VDP_STATUS_RESOURCES; - - format = VdpFormatRGBAToPipe(surface_rgba_format); - if (format == PIPE_FORMAT_NONE || format == PIPE_FORMAT_A8_UNORM) - return VDP_STATUS_INVALID_RGBA_FORMAT; - - if (!(is_supported && max_width && max_height)) - return VDP_STATUS_INVALID_POINTER; - - mtx_lock(&dev->mutex); - *is_supported = pscreen->is_format_supported - ( - pscreen, format, PIPE_TEXTURE_2D, 1, 1, - PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET - ); - if (*is_supported) { - uint32_t max_2d_texture_size = pscreen->caps.max_texture_2d_size; - - if (!max_2d_texture_size) { - mtx_unlock(&dev->mutex); - return VDP_STATUS_ERROR; - } - - *max_width = *max_height = max_2d_texture_size; - } else { - *max_width = 0; - *max_height = 0; - } - mtx_unlock(&dev->mutex); - - return VDP_STATUS_OK; -} - -/** - * Query the implementation's capability to perform a PutBits operation using - * application data matching the surface's format. - */ -VdpStatus -vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format, - VdpBool *is_supported) -{ - vlVdpDevice *dev; - struct pipe_screen *pscreen; - enum pipe_format format; - - dev = vlGetDataHTAB(device); - if (!dev) - return VDP_STATUS_INVALID_HANDLE; - - pscreen = dev->vscreen->pscreen; - if (!pscreen) - return VDP_STATUS_ERROR; - - format = VdpFormatRGBAToPipe(surface_rgba_format); - if (format == PIPE_FORMAT_NONE || format == PIPE_FORMAT_A8_UNORM) - return VDP_STATUS_INVALID_RGBA_FORMAT; - - if (!is_supported) - return VDP_STATUS_INVALID_POINTER; - - mtx_lock(&dev->mutex); - *is_supported = pscreen->is_format_supported - ( - pscreen, format, PIPE_TEXTURE_2D, 1, 1, - PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET - ); - mtx_unlock(&dev->mutex); - - return VDP_STATUS_OK; -} - -/** - * Query the implementation's capability to perform a PutBits operation using - * application data in a specific indexed format. - */ -VdpStatus -vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities(VdpDevice device, - VdpRGBAFormat surface_rgba_format, - VdpIndexedFormat bits_indexed_format, - VdpColorTableFormat color_table_format, - VdpBool *is_supported) -{ - vlVdpDevice *dev; - struct pipe_screen *pscreen; - enum pipe_format rgba_format, index_format, colortbl_format; - - dev = vlGetDataHTAB(device); - if (!dev) - return VDP_STATUS_INVALID_HANDLE; - - pscreen = dev->vscreen->pscreen; - if (!pscreen) - return VDP_STATUS_ERROR; - - rgba_format = VdpFormatRGBAToPipe(surface_rgba_format); - if (rgba_format == PIPE_FORMAT_NONE || rgba_format == PIPE_FORMAT_A8_UNORM) - return VDP_STATUS_INVALID_RGBA_FORMAT; - - index_format = FormatIndexedToPipe(bits_indexed_format); - if (index_format == PIPE_FORMAT_NONE) - return VDP_STATUS_INVALID_INDEXED_FORMAT; - - colortbl_format = FormatColorTableToPipe(color_table_format); - if (colortbl_format == PIPE_FORMAT_NONE) - return VDP_STATUS_INVALID_COLOR_TABLE_FORMAT; - - if (!is_supported) - return VDP_STATUS_INVALID_POINTER; - - mtx_lock(&dev->mutex); - *is_supported = pscreen->is_format_supported - ( - pscreen, rgba_format, PIPE_TEXTURE_2D, 1, 1, - PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET - ); - - *is_supported &= pscreen->is_format_supported - ( - pscreen, index_format, PIPE_TEXTURE_2D, 1, 1, - PIPE_BIND_SAMPLER_VIEW - ); - - *is_supported &= pscreen->is_format_supported - ( - pscreen, colortbl_format, PIPE_TEXTURE_1D, 1, 1, - PIPE_BIND_SAMPLER_VIEW - ); - mtx_unlock(&dev->mutex); - - return VDP_STATUS_OK; -} - -/** - * Query the implementation's capability to perform a PutBits operation using - * application data in a specific YCbCr/YUB format. - */ -VdpStatus -vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format, - VdpYCbCrFormat bits_ycbcr_format, - VdpBool *is_supported) -{ - vlVdpDevice *dev; - struct pipe_screen *pscreen; - enum pipe_format rgba_format, ycbcr_format; - - dev = vlGetDataHTAB(device); - if (!dev) - return VDP_STATUS_INVALID_HANDLE; - - pscreen = dev->vscreen->pscreen; - if (!pscreen) - return VDP_STATUS_ERROR; - - rgba_format = VdpFormatRGBAToPipe(surface_rgba_format); - if (rgba_format == PIPE_FORMAT_NONE || rgba_format == PIPE_FORMAT_A8_UNORM) - return VDP_STATUS_INVALID_RGBA_FORMAT; - - ycbcr_format = FormatYCBCRToPipe(bits_ycbcr_format); - if (ycbcr_format == PIPE_FORMAT_NONE) - return VDP_STATUS_INVALID_INDEXED_FORMAT; - - if (!is_supported) - return VDP_STATUS_INVALID_POINTER; - - mtx_lock(&dev->mutex); - *is_supported = pscreen->is_format_supported - ( - pscreen, rgba_format, PIPE_TEXTURE_2D, 1, 1, - PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET - ); - - *is_supported &= pscreen->is_video_format_supported - ( - pscreen, ycbcr_format, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM - ); - mtx_unlock(&dev->mutex); - - return VDP_STATUS_OK; -} - -/** - * Query the implementation's VdpBitmapSurface capabilities. - */ -VdpStatus -vlVdpBitmapSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format, - VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height) -{ - vlVdpDevice *dev; - struct pipe_screen *pscreen; - enum pipe_format format; - - dev = vlGetDataHTAB(device); - if (!dev) - return VDP_STATUS_INVALID_HANDLE; - - pscreen = dev->vscreen->pscreen; - if (!pscreen) - return VDP_STATUS_RESOURCES; - - format = VdpFormatRGBAToPipe(surface_rgba_format); - if (format == PIPE_FORMAT_NONE) - return VDP_STATUS_INVALID_RGBA_FORMAT; - - if (!(is_supported && max_width && max_height)) - return VDP_STATUS_INVALID_POINTER; - - mtx_lock(&dev->mutex); - *is_supported = pscreen->is_format_supported - ( - pscreen, format, PIPE_TEXTURE_2D, 1, 1, - PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET - ); - if (*is_supported) { - uint32_t max_2d_texture_size = pscreen->caps.max_texture_2d_size; - - if (!max_2d_texture_size) { - mtx_unlock(&dev->mutex); - return VDP_STATUS_ERROR; - } - - *max_width = *max_height = max_2d_texture_size; - } else { - *max_width = 0; - *max_height = 0; - } - mtx_unlock(&dev->mutex); - - return VDP_STATUS_OK; -} - -/** - * Query the implementation's support for a specific feature. - */ -VdpStatus -vlVdpVideoMixerQueryFeatureSupport(VdpDevice device, VdpVideoMixerFeature feature, - VdpBool *is_supported) -{ - if (!is_supported) - return VDP_STATUS_INVALID_POINTER; - - switch (feature) { - case VDP_VIDEO_MIXER_FEATURE_SHARPNESS: - case VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION: - case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL: - case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY: - case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1: - *is_supported = VDP_TRUE; - break; - default: - *is_supported = VDP_FALSE; - break; - } - return VDP_STATUS_OK; -} - -/** - * Query the implementation's support for a specific parameter. - */ -VdpStatus -vlVdpVideoMixerQueryParameterSupport(VdpDevice device, VdpVideoMixerParameter parameter, - VdpBool *is_supported) -{ - if (!is_supported) - return VDP_STATUS_INVALID_POINTER; - - switch (parameter) { - case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH: - case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT: - case VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE: - case VDP_VIDEO_MIXER_PARAMETER_LAYERS: - *is_supported = VDP_TRUE; - break; - default: - *is_supported = VDP_FALSE; - break; - } - return VDP_STATUS_OK; -} - -/** - * Query the implementation's supported for a specific parameter. - */ -VdpStatus -vlVdpVideoMixerQueryParameterValueRange(VdpDevice device, VdpVideoMixerParameter parameter, - void *min_value, void *max_value) -{ - vlVdpDevice *dev = vlGetDataHTAB(device); - struct pipe_screen *screen; - - if (!dev) - return VDP_STATUS_INVALID_HANDLE; - if (!(min_value && max_value)) - return VDP_STATUS_INVALID_POINTER; - - mtx_lock(&dev->mutex); - screen = dev->vscreen->pscreen; - switch (parameter) { - case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH: - *(uint32_t*)min_value = 48; - *(uint32_t*)max_value = screen->get_video_param(screen, PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_MAX_WIDTH); - break; - case VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT: - *(uint32_t*)min_value = 48; - *(uint32_t*)max_value = screen->get_video_param(screen, PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_MAX_HEIGHT); - break; - - case VDP_VIDEO_MIXER_PARAMETER_LAYERS: - *(uint32_t*)min_value = 0; - *(uint32_t*)max_value = 4; - break; - - case VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE: - default: - mtx_unlock(&dev->mutex); - return VDP_STATUS_INVALID_VIDEO_MIXER_PARAMETER; - } - mtx_unlock(&dev->mutex); - return VDP_STATUS_OK; -} - -/** - * Query the implementation's support for a specific attribute. - */ -VdpStatus -vlVdpVideoMixerQueryAttributeSupport(VdpDevice device, VdpVideoMixerAttribute attribute, - VdpBool *is_supported) -{ - if (!is_supported) - return VDP_STATUS_INVALID_POINTER; - - switch (attribute) { - case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR: - case VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX: - case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL: - case VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL: - case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA: - case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MAX_LUMA: - case VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE: - *is_supported = VDP_TRUE; - break; - default: - *is_supported = VDP_FALSE; - } - return VDP_STATUS_OK; -} - -/** - * Query the implementation's supported for a specific attribute. - */ -VdpStatus -vlVdpVideoMixerQueryAttributeValueRange(VdpDevice device, VdpVideoMixerAttribute attribute, - void *min_value, void *max_value) -{ - if (!(min_value && max_value)) - return VDP_STATUS_INVALID_POINTER; - - switch (attribute) { - case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL: - case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA: - case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MAX_LUMA: - *(float*)min_value = 0.0f; - *(float*)max_value = 1.0f; - break; - case VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL: - *(float*)min_value = -1.0f; - *(float*)max_value = 1.0f; - break; - case VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE: - *(uint8_t*)min_value = 0; - *(uint8_t*)max_value = 1; - break; - case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR: - case VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX: - default: - return VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE; - } - return VDP_STATUS_OK; -} diff --git a/src/gallium/frontends/vdpau/surface.c b/src/gallium/frontends/vdpau/surface.c deleted file mode 100644 index fd99438cab8..00000000000 --- a/src/gallium/frontends/vdpau/surface.c +++ /dev/null @@ -1,551 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Thomas Balling Sørensen. - * Copyright 2011 Christian König. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include - -#include "pipe/p_state.h" - -#include "util/u_memory.h" -#include "util/u_debug.h" -#include "util/u_rect.h" -#include "util/u_surface.h" -#include "util/u_video.h" -#include "vl/vl_defines.h" - -#include "frontend/drm_driver.h" - -#include "vdpau_private.h" - -enum getbits_conversion { - CONVERSION_NONE, - CONVERSION_NV12_TO_YV12, - CONVERSION_YV12_TO_NV12, - CONVERSION_SWAP_YUYV_UYVY, -}; - -/** - * Create a VdpVideoSurface. - */ -VdpStatus -vlVdpVideoSurfaceCreate(VdpDevice device, VdpChromaType chroma_type, - uint32_t width, uint32_t height, - VdpVideoSurface *surface) -{ - struct pipe_context *pipe; - vlVdpSurface *p_surf; - VdpStatus ret; - - if (!(width && height)) { - ret = VDP_STATUS_INVALID_SIZE; - goto inv_size; - } - - p_surf = CALLOC(1, sizeof(vlVdpSurface)); - if (!p_surf) { - ret = VDP_STATUS_RESOURCES; - goto no_res; - } - - vlVdpDevice *dev = vlGetDataHTAB(device); - if (!dev) { - ret = VDP_STATUS_INVALID_HANDLE; - goto inv_device; - } - - DeviceReference(&p_surf->device, dev); - pipe = dev->context; - - mtx_lock(&dev->mutex); - memset(&p_surf->templat, 0, sizeof(p_surf->templat)); - 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 - ( - pipe->screen, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_PREFERS_INTERLACED - ); - if (p_surf->templat.buffer_format != PIPE_FORMAT_NONE) - p_surf->video_buffer = pipe->create_video_buffer(pipe, &p_surf->templat); - /* do not mandate early allocation of a video buffer */ - - if (!pipe->screen->get_video_param(pipe->screen, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_UNKNOWN, - PIPE_VIDEO_CAP_SKIP_CLEAR_SURFACE)) - vlVdpVideoSurfaceClear(p_surf); - - mtx_unlock(&dev->mutex); - - *surface = vlAddDataHTAB(p_surf); - if (*surface == 0) { - ret = VDP_STATUS_ERROR; - goto no_handle; - } - - return VDP_STATUS_OK; - -no_handle: - p_surf->video_buffer->destroy(p_surf->video_buffer); - -inv_device: - DeviceReference(&p_surf->device, NULL); - FREE(p_surf); - -no_res: -inv_size: - return ret; -} - -/** - * Destroy a VdpVideoSurface. - */ -VdpStatus -vlVdpVideoSurfaceDestroy(VdpVideoSurface surface) -{ - vlVdpSurface *p_surf; - - p_surf = (vlVdpSurface *)vlGetDataHTAB((vlHandle)surface); - if (!p_surf) - return VDP_STATUS_INVALID_HANDLE; - - mtx_lock(&p_surf->device->mutex); - if (p_surf->video_buffer) - p_surf->video_buffer->destroy(p_surf->video_buffer); - if (p_surf->ref_buffer) - p_surf->ref_buffer->destroy(p_surf->ref_buffer); - mtx_unlock(&p_surf->device->mutex); - - vlRemoveDataHTAB(surface); - DeviceReference(&p_surf->device, NULL); - FREE(p_surf); - - return VDP_STATUS_OK; -} - -/** - * Retrieve the parameters used to create a VdpVideoSurface. - */ -VdpStatus -vlVdpVideoSurfaceGetParameters(VdpVideoSurface surface, - VdpChromaType *chroma_type, - uint32_t *width, uint32_t *height) -{ - if (!(width && height && chroma_type)) - return VDP_STATUS_INVALID_POINTER; - - vlVdpSurface *p_surf = vlGetDataHTAB(surface); - if (!p_surf) - return VDP_STATUS_INVALID_HANDLE; - - if (p_surf->video_buffer) { - *width = p_surf->video_buffer->width; - *height = p_surf->video_buffer->height; - *chroma_type = PipeToChroma(pipe_format_to_chroma_format(p_surf->video_buffer->buffer_format)); - } else { - *width = p_surf->templat.width; - *height = p_surf->templat.height; - *chroma_type = PipeToChroma(pipe_format_to_chroma_format(p_surf->templat.buffer_format)); - } - - return VDP_STATUS_OK; -} - -static void -vlVdpVideoSurfaceSize(vlVdpSurface *p_surf, int component, - unsigned *width, unsigned *height) -{ - *width = p_surf->templat.width; - *height = p_surf->templat.height; - - vl_video_buffer_adjust_size(width, height, component, - pipe_format_to_chroma_format(p_surf->templat.buffer_format), - p_surf->templat.interlaced); -} - -/** - * Copy image data from a VdpVideoSurface to application memory in a specified - * YCbCr format. - */ -VdpStatus -vlVdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface, - VdpYCbCrFormat destination_ycbcr_format, - void *const *destination_data, - uint32_t const *destination_pitches) -{ - vlVdpSurface *vlsurface; - struct pipe_context *pipe; - enum pipe_format format, buffer_format; - struct pipe_sampler_view **sampler_views; - enum getbits_conversion conversion = CONVERSION_NONE; - unsigned i, j; - - vlsurface = vlGetDataHTAB(surface); - if (!vlsurface) - return VDP_STATUS_INVALID_HANDLE; - - pipe = vlsurface->device->context; - if (!pipe) - return VDP_STATUS_INVALID_HANDLE; - - if (!destination_data || !destination_pitches) - return VDP_STATUS_INVALID_POINTER; - - format = FormatYCBCRToPipe(destination_ycbcr_format); - if (format == PIPE_FORMAT_NONE) - return VDP_STATUS_INVALID_Y_CB_CR_FORMAT; - - if (vlsurface->video_buffer == NULL) - return VDP_STATUS_INVALID_VALUE; - - buffer_format = vlsurface->video_buffer->buffer_format; - if (format != buffer_format) { - if (format == PIPE_FORMAT_YV12 && buffer_format == PIPE_FORMAT_NV12) - conversion = CONVERSION_NV12_TO_YV12; - else if (format == PIPE_FORMAT_NV12 && buffer_format == PIPE_FORMAT_YV12) - conversion = CONVERSION_YV12_TO_NV12; - else if ((format == PIPE_FORMAT_YUYV && buffer_format == PIPE_FORMAT_UYVY) || - (format == PIPE_FORMAT_UYVY && buffer_format == PIPE_FORMAT_YUYV)) - conversion = CONVERSION_SWAP_YUYV_UYVY; - else - return VDP_STATUS_NO_IMPLEMENTATION; - } - - mtx_lock(&vlsurface->device->mutex); - sampler_views = vlsurface->video_buffer->get_sampler_view_planes(vlsurface->video_buffer); - if (!sampler_views) { - mtx_unlock(&vlsurface->device->mutex); - return VDP_STATUS_RESOURCES; - } - - for (i = 0; i < 3; ++i) { - unsigned width, height; - struct pipe_sampler_view *sv = sampler_views[i]; - if (!sv) continue; - - vlVdpVideoSurfaceSize(vlsurface, i, &width, &height); - - for (j = 0; j < sv->texture->array_size; ++j) { - struct pipe_box box; - u_box_3d(0, 0, j, width, height, 1, &box); - struct pipe_transfer *transfer; - uint8_t *map; - - map = pipe->texture_map(pipe, sv->texture, 0, - PIPE_MAP_READ, &box, &transfer); - if (!map) { - mtx_unlock(&vlsurface->device->mutex); - return VDP_STATUS_RESOURCES; - } - - if (conversion == CONVERSION_NV12_TO_YV12 && i == 1) { - u_copy_nv12_to_yv12(destination_data, destination_pitches, - i, j, transfer->stride, sv->texture->array_size, - map, box.width, box.height); - } else if (conversion == CONVERSION_YV12_TO_NV12 && i > 0) { - u_copy_yv12_to_nv12(destination_data, destination_pitches, - i, j, transfer->stride, sv->texture->array_size, - map, box.width, box.height); - } else if (conversion == CONVERSION_SWAP_YUYV_UYVY) { - u_copy_swap422_packed(destination_data, destination_pitches, - i, j, transfer->stride, sv->texture->array_size, - map, box.width, box.height); - } else { - util_copy_rect(destination_data[i] + destination_pitches[i] * j, sv->texture->format, - destination_pitches[i] * sv->texture->array_size, 0, 0, - box.width, box.height, map, transfer->stride, 0, 0); - } - - pipe_texture_unmap(pipe, transfer); - } - } - mtx_unlock(&vlsurface->device->mutex); - - return VDP_STATUS_OK; -} - -/** - * Copy image data from application memory in a specific YCbCr format to - * a VdpVideoSurface. - */ -VdpStatus -vlVdpVideoSurfacePutBitsYCbCr(VdpVideoSurface surface, - VdpYCbCrFormat source_ycbcr_format, - void const *const *source_data, - uint32_t const *source_pitches) -{ - enum pipe_format pformat = FormatYCBCRToPipe(source_ycbcr_format); - enum getbits_conversion conversion = CONVERSION_NONE; - struct pipe_context *pipe; - struct pipe_sampler_view **sampler_views; - unsigned i, j; - unsigned usage = PIPE_MAP_WRITE; - - vlVdpSurface *p_surf = vlGetDataHTAB(surface); - if (!p_surf) - return VDP_STATUS_INVALID_HANDLE; - - pipe = p_surf->device->context; - if (!pipe) - return VDP_STATUS_INVALID_HANDLE; - - if (!source_data || !source_pitches) - return VDP_STATUS_INVALID_POINTER; - - mtx_lock(&p_surf->device->mutex); - - if (p_surf->video_buffer == NULL || - ((pformat != p_surf->video_buffer->buffer_format))) { - enum pipe_format nformat = pformat; - struct pipe_screen *screen = pipe->screen; - - /* Determine the most suitable format for the new surface */ - if (!screen->is_video_format_supported(screen, nformat, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM)) { - nformat = screen->get_video_param(screen, - PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_PREFERRED_FORMAT); - if (nformat == PIPE_FORMAT_NONE) { - mtx_unlock(&p_surf->device->mutex); - return VDP_STATUS_NO_IMPLEMENTATION; - } - } - - if (p_surf->video_buffer == NULL || - nformat != p_surf->video_buffer->buffer_format) { - /* destroy the old one */ - if (p_surf->video_buffer) - p_surf->video_buffer->destroy(p_surf->video_buffer); - - /* adjust the template parameters */ - p_surf->templat.buffer_format = nformat; - if (nformat == PIPE_FORMAT_YUYV || nformat == PIPE_FORMAT_UYVY) - p_surf->templat.interlaced = false; - - /* and try to create the video buffer with the new format */ - p_surf->video_buffer = pipe->create_video_buffer(pipe, &p_surf->templat); - - /* stil no luck? ok forget it we don't support it */ - if (!p_surf->video_buffer) { - mtx_unlock(&p_surf->device->mutex); - return VDP_STATUS_NO_IMPLEMENTATION; - } - vlVdpVideoSurfaceClear(p_surf); - } - } - - if (pformat != p_surf->video_buffer->buffer_format) { - if (pformat == PIPE_FORMAT_YV12 && - p_surf->video_buffer->buffer_format == PIPE_FORMAT_NV12) - conversion = CONVERSION_YV12_TO_NV12; - else { - mtx_unlock(&p_surf->device->mutex); - return VDP_STATUS_NO_IMPLEMENTATION; - } - } - - sampler_views = p_surf->video_buffer->get_sampler_view_planes(p_surf->video_buffer); - if (!sampler_views) { - mtx_unlock(&p_surf->device->mutex); - return VDP_STATUS_RESOURCES; - } - - for (i = 0; i < 3; ++i) { - unsigned width, height; - struct pipe_sampler_view *sv = sampler_views[i]; - struct pipe_resource *tex; - if (!sv || !source_pitches[i]) continue; - - tex = sv->texture; - vlVdpVideoSurfaceSize(p_surf, i, &width, &height); - - for (j = 0; j < tex->array_size; ++j) { - struct pipe_box dst_box; - u_box_3d(0, 0, j, width, height, 1, &dst_box); - - if (conversion == CONVERSION_YV12_TO_NV12 && i == 1) { - struct pipe_transfer *transfer; - uint8_t *map; - - map = pipe->texture_map(pipe, tex, 0, usage, - &dst_box, &transfer); - if (!map) { - mtx_unlock(&p_surf->device->mutex); - return VDP_STATUS_RESOURCES; - } - - u_copy_nv12_from_yv12(source_data, source_pitches, - i, j, transfer->stride, tex->array_size, - map, dst_box.width, dst_box.height); - - pipe_texture_unmap(pipe, transfer); - } else { - pipe->texture_subdata(pipe, tex, 0, - PIPE_MAP_WRITE, &dst_box, - source_data[i] + source_pitches[i] * j, - source_pitches[i] * tex->array_size, - 0); - } - /* - * This surface has already been synced - * by the first map. - */ - usage |= PIPE_MAP_UNSYNCHRONIZED; - } - } - mtx_unlock(&p_surf->device->mutex); - - return VDP_STATUS_OK; -} - -/** - * Helper function to initially clear the VideoSurface after (re-)creation - */ -void -vlVdpVideoSurfaceClear(vlVdpSurface *vlsurf) -{ - struct pipe_context *pipe = vlsurf->device->context; - struct pipe_surface *surfaces; - unsigned i; - - if (!vlsurf->video_buffer) - return; - - surfaces = vlsurf->video_buffer->get_surfaces(vlsurf->video_buffer); - for (i = 0; i < VL_MAX_SURFACES; ++i) { - union pipe_color_union c = {}; - - if (!surfaces[i].texture) - continue; - - if (i > !!vlsurf->templat.interlaced) - c.f[0] = c.f[1] = c.f[2] = c.f[3] = 0.5f; - - uint16_t width, height; - pipe_surface_size(&surfaces[i], &width, &height); - pipe->clear_render_target(pipe, &surfaces[i], &c, 0, 0, - width, height, false); - } - pipe->flush(pipe, NULL, 0); -} - -/** - * Interop for the GL gallium frontend - */ -struct pipe_video_buffer *vlVdpVideoSurfaceGallium(VdpVideoSurface surface) -{ - vlVdpSurface *p_surf = vlGetDataHTAB(surface); - if (!p_surf) - return NULL; - - mtx_lock(&p_surf->device->mutex); - if (p_surf->video_buffer == NULL) { - struct pipe_context *pipe = p_surf->device->context; - - /* try to create a video buffer if we don't already have one */ - p_surf->video_buffer = pipe->create_video_buffer(pipe, &p_surf->templat); - } - mtx_unlock(&p_surf->device->mutex); - - return p_surf->video_buffer; -} - -VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface, - VdpVideoSurfacePlane plane, - struct VdpSurfaceDMABufDesc *result) -{ - vlVdpSurface *p_surf = vlGetDataHTAB(surface); - - struct pipe_screen *pscreen; - struct winsys_handle whandle; - - struct pipe_surface *surf; - - if (!p_surf) - return VDP_STATUS_INVALID_HANDLE; - - if (plane > 3) - return VDP_STATUS_INVALID_VALUE; - - if (!result) - return VDP_STATUS_INVALID_POINTER; - - memset(result, 0, sizeof(*result)); - result->handle = -1; - - mtx_lock(&p_surf->device->mutex); - if (p_surf->video_buffer == NULL) { - struct pipe_context *pipe = p_surf->device->context; - - /* try to create a video buffer if we don't already have one */ - p_surf->video_buffer = pipe->create_video_buffer(pipe, &p_surf->templat); - } - - /* Check if surface match interop requirements */ - if (p_surf->video_buffer == NULL || !p_surf->video_buffer->interlaced || - p_surf->video_buffer->buffer_format != PIPE_FORMAT_NV12) { - mtx_unlock(&p_surf->device->mutex); - return VDP_STATUS_NO_IMPLEMENTATION; - } - - surf = &p_surf->video_buffer->get_surfaces(p_surf->video_buffer)[plane]; - if (!surf) { - mtx_unlock(&p_surf->device->mutex); - return VDP_STATUS_RESOURCES; - } - - memset(&whandle, 0, sizeof(struct winsys_handle)); - whandle.type = WINSYS_HANDLE_TYPE_FD; - whandle.layer = surf->first_layer; - - pscreen = surf->texture->screen; - if (!pscreen->resource_get_handle(pscreen, p_surf->device->context, - surf->texture, &whandle, - PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE)) { - mtx_unlock(&p_surf->device->mutex); - return VDP_STATUS_NO_IMPLEMENTATION; - } - - mtx_unlock(&p_surf->device->mutex); - result->handle = whandle.handle; - result->width = pipe_surface_width(surf); - result->height = pipe_surface_height(surf); - result->offset = whandle.offset; - result->stride = whandle.stride; - - if (surf->format == PIPE_FORMAT_R8_UNORM) - result->format = VDP_RGBA_FORMAT_R8; - else - result->format = VDP_RGBA_FORMAT_R8G8; - - return VDP_STATUS_OK; -} diff --git a/src/gallium/frontends/vdpau/vdpau_private.h b/src/gallium/frontends/vdpau/vdpau_private.h deleted file mode 100644 index 6d19741afb1..00000000000 --- a/src/gallium/frontends/vdpau/vdpau_private.h +++ /dev/null @@ -1,618 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 Younes Manton & Thomas Balling Sørensen. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#ifndef VDPAU_PRIVATE_H -#define VDPAU_PRIVATE_H - -#include - -#include -#include - -#include "util/compiler.h" -#include "pipe/p_video_codec.h" - -#include "frontend/vdpau_interop.h" -#include "frontend/vdpau_dmabuf.h" -#include "frontend/vdpau_funcs.h" - -#include "util/u_debug.h" -#include "util/u_rect.h" -#include "util/u_surface.h" -#include "util/u_thread.h" - -#include "vl/vl_video_buffer.h" -#include "vl/vl_bicubic_filter.h" -#include "vl/vl_compositor.h" -#include "vl/vl_csc.h" -#include "vl/vl_deint_filter.h" -#include "vl/vl_matrix_filter.h" -#include "vl/vl_median_filter.h" -#include "vl/vl_winsys.h" - -/* Full VDPAU API documentation available at : - * ftp://download.nvidia.com/XFree86/vdpau/doxygen/html/index.html */ - -#define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR -#define QUOTEME(x) #x -#define TOSTRING(x) QUOTEME(x) -#define INFORMATION_STRING TOSTRING(INFORMATION) - -static inline enum pipe_video_chroma_format -ChromaToPipe(VdpChromaType vdpau_type) -{ - switch (vdpau_type) { - case VDP_CHROMA_TYPE_420: - return PIPE_VIDEO_CHROMA_FORMAT_420; - case VDP_CHROMA_TYPE_422: - return PIPE_VIDEO_CHROMA_FORMAT_422; - case VDP_CHROMA_TYPE_444: - return PIPE_VIDEO_CHROMA_FORMAT_444; - default: - assert(0); - } - - return -1; -} - -static inline VdpChromaType -PipeToChroma(enum pipe_video_chroma_format pipe_type) -{ - switch (pipe_type) { - case PIPE_VIDEO_CHROMA_FORMAT_420: - return VDP_CHROMA_TYPE_420; - case PIPE_VIDEO_CHROMA_FORMAT_422: - return VDP_CHROMA_TYPE_422; - case PIPE_VIDEO_CHROMA_FORMAT_444: - return VDP_CHROMA_TYPE_444; - default: - assert(0); - } - - return -1; -} - -static inline enum pipe_video_chroma_format -FormatYCBCRToPipeChroma(VdpYCbCrFormat vdpau_format) -{ - switch (vdpau_format) { - case VDP_YCBCR_FORMAT_NV12: - return PIPE_VIDEO_CHROMA_FORMAT_420; - case VDP_YCBCR_FORMAT_YV12: - return PIPE_VIDEO_CHROMA_FORMAT_420; - case VDP_YCBCR_FORMAT_UYVY: - return PIPE_VIDEO_CHROMA_FORMAT_422; - case VDP_YCBCR_FORMAT_YUYV: - return PIPE_VIDEO_CHROMA_FORMAT_422; - case VDP_YCBCR_FORMAT_Y8U8V8A8: - return PIPE_VIDEO_CHROMA_FORMAT_444; - case VDP_YCBCR_FORMAT_V8U8Y8A8: - return PIPE_VIDEO_CHROMA_FORMAT_444; - default: - assert(0); - } - - return PIPE_VIDEO_CHROMA_FORMAT_NONE; -} - -static inline enum pipe_format -FormatYCBCRToPipe(VdpYCbCrFormat vdpau_format) -{ - switch (vdpau_format) { - case VDP_YCBCR_FORMAT_NV12: - return PIPE_FORMAT_NV12; - case VDP_YCBCR_FORMAT_YV12: - return PIPE_FORMAT_YV12; - case VDP_YCBCR_FORMAT_UYVY: - return PIPE_FORMAT_UYVY; - case VDP_YCBCR_FORMAT_YUYV: - return PIPE_FORMAT_YUYV; - case VDP_YCBCR_FORMAT_Y8U8V8A8: - return PIPE_FORMAT_R8G8B8A8_UNORM; - case VDP_YCBCR_FORMAT_V8U8Y8A8: - return PIPE_FORMAT_B8G8R8A8_UNORM; -#ifdef VDP_YCBCR_FORMAT_P010 - case VDP_YCBCR_FORMAT_P010: - return PIPE_FORMAT_P010; -#endif -#ifdef VDP_YCBCR_FORMAT_P016 - case VDP_YCBCR_FORMAT_P016: - return PIPE_FORMAT_P016; -#endif - default: - /* NOTE: Can't be "unreachable", as it's quite reachable. */ - assert(!"unexpected VdpYCbCrFormat"); - return PIPE_FORMAT_NONE; -#ifdef VDP_YCBCR_FORMAT_Y_UV_444 - case VDP_YCBCR_FORMAT_Y_UV_444: - return PIPE_FORMAT_NONE; -#endif -#ifdef VDP_YCBCR_FORMAT_Y_U_V_444 - case VDP_YCBCR_FORMAT_Y_U_V_444: - return PIPE_FORMAT_NONE; -#endif -#ifdef VDP_YCBCR_FORMAT_Y_U_V_444_16 - case VDP_YCBCR_FORMAT_Y_U_V_444_16: - return PIPE_FORMAT_NONE; -#endif - } - -} - -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 - case VDP_CHROMA_TYPE_422: - return PIPE_FORMAT_UYVY; - default: - assert(0); - } - - return PIPE_FORMAT_NONE; -} - -static inline VdpYCbCrFormat -PipeToFormatYCBCR(enum pipe_format p_format) -{ - switch (p_format) { - case PIPE_FORMAT_NV12: - return VDP_YCBCR_FORMAT_NV12; - case PIPE_FORMAT_YV12: - return VDP_YCBCR_FORMAT_YV12; - case PIPE_FORMAT_UYVY: - return VDP_YCBCR_FORMAT_UYVY; - case PIPE_FORMAT_YUYV: - return VDP_YCBCR_FORMAT_YUYV; - case PIPE_FORMAT_R8G8B8A8_UNORM: - return VDP_YCBCR_FORMAT_Y8U8V8A8; - case PIPE_FORMAT_B8G8R8A8_UNORM: - return VDP_YCBCR_FORMAT_V8U8Y8A8; - default: - assert(0); - } - - return -1; -} - -static inline VdpRGBAFormat -PipeToFormatRGBA(enum pipe_format p_format) -{ - switch (p_format) { - case PIPE_FORMAT_A8_UNORM: - return VDP_RGBA_FORMAT_A8; - case PIPE_FORMAT_B10G10R10A2_UNORM: - return VDP_RGBA_FORMAT_B10G10R10A2; - case PIPE_FORMAT_B8G8R8A8_UNORM: - return VDP_RGBA_FORMAT_B8G8R8A8; - case PIPE_FORMAT_R10G10B10A2_UNORM: - return VDP_RGBA_FORMAT_R10G10B10A2; - case PIPE_FORMAT_R8G8B8A8_UNORM: - return VDP_RGBA_FORMAT_R8G8B8A8; - default: - assert(0); - } - - return -1; -} - -static inline enum pipe_format -FormatIndexedToPipe(VdpRGBAFormat vdpau_format) -{ - switch (vdpau_format) { - case VDP_INDEXED_FORMAT_A4I4: - return PIPE_FORMAT_R4A4_UNORM; - case VDP_INDEXED_FORMAT_I4A4: - return PIPE_FORMAT_A4R4_UNORM; - case VDP_INDEXED_FORMAT_A8I8: - return PIPE_FORMAT_A8R8_UNORM; - case VDP_INDEXED_FORMAT_I8A8: - return PIPE_FORMAT_R8A8_UNORM; - default: - assert(0); - } - - return PIPE_FORMAT_NONE; -} - -static inline enum pipe_format -FormatColorTableToPipe(VdpColorTableFormat vdpau_format) -{ - switch(vdpau_format) { - case VDP_COLOR_TABLE_FORMAT_B8G8R8X8: - return PIPE_FORMAT_B8G8R8X8_UNORM; - default: - assert(0); - } - - return PIPE_FORMAT_NONE; -} - -static inline enum pipe_video_profile -ProfileToPipe(VdpDecoderProfile vdpau_profile) -{ - switch (vdpau_profile) { - case VDP_DECODER_PROFILE_MPEG1: - return PIPE_VIDEO_PROFILE_MPEG1; - case VDP_DECODER_PROFILE_MPEG2_SIMPLE: - return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE; - case VDP_DECODER_PROFILE_MPEG2_MAIN: - return PIPE_VIDEO_PROFILE_MPEG2_MAIN; - case VDP_DECODER_PROFILE_H264_BASELINE: - return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE; - case VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE: - return PIPE_VIDEO_PROFILE_MPEG4_AVC_CONSTRAINED_BASELINE; - case VDP_DECODER_PROFILE_H264_MAIN: - return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN; - case VDP_DECODER_PROFILE_H264_HIGH: - return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH; - case VDP_DECODER_PROFILE_MPEG4_PART2_SP: - return PIPE_VIDEO_PROFILE_MPEG4_SIMPLE; - case VDP_DECODER_PROFILE_MPEG4_PART2_ASP: - return PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE; - case VDP_DECODER_PROFILE_VC1_SIMPLE: - return PIPE_VIDEO_PROFILE_VC1_SIMPLE; - case VDP_DECODER_PROFILE_VC1_MAIN: - return PIPE_VIDEO_PROFILE_VC1_MAIN; - case VDP_DECODER_PROFILE_VC1_ADVANCED: - return PIPE_VIDEO_PROFILE_VC1_ADVANCED; - case VDP_DECODER_PROFILE_HEVC_MAIN: - return PIPE_VIDEO_PROFILE_HEVC_MAIN; - case VDP_DECODER_PROFILE_HEVC_MAIN_10: - return PIPE_VIDEO_PROFILE_HEVC_MAIN_10; - case VDP_DECODER_PROFILE_HEVC_MAIN_STILL: - return PIPE_VIDEO_PROFILE_HEVC_MAIN_STILL; - case VDP_DECODER_PROFILE_HEVC_MAIN_12: - return PIPE_VIDEO_PROFILE_HEVC_MAIN_12; - case VDP_DECODER_PROFILE_HEVC_MAIN_444: - return PIPE_VIDEO_PROFILE_HEVC_MAIN_444; - case VDP_DECODER_PROFILE_AV1_MAIN: - return PIPE_VIDEO_PROFILE_AV1_MAIN; - default: - return PIPE_VIDEO_PROFILE_UNKNOWN; - } -} - -static inline VdpDecoderProfile -PipeToProfile(enum pipe_video_profile p_profile) -{ - switch (p_profile) { - case PIPE_VIDEO_PROFILE_MPEG1: - return VDP_DECODER_PROFILE_MPEG1; - case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE: - return VDP_DECODER_PROFILE_MPEG2_SIMPLE; - case PIPE_VIDEO_PROFILE_MPEG2_MAIN: - return VDP_DECODER_PROFILE_MPEG2_MAIN; - case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE: - return VDP_DECODER_PROFILE_H264_BASELINE; - case PIPE_VIDEO_PROFILE_MPEG4_AVC_CONSTRAINED_BASELINE: - return VDP_DECODER_PROFILE_H264_CONSTRAINED_BASELINE; - case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN: - return VDP_DECODER_PROFILE_H264_MAIN; - case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH: - return VDP_DECODER_PROFILE_H264_HIGH; - case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE: - return VDP_DECODER_PROFILE_MPEG4_PART2_SP; - case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE: - return VDP_DECODER_PROFILE_MPEG4_PART2_ASP; - case PIPE_VIDEO_PROFILE_VC1_SIMPLE: - return VDP_DECODER_PROFILE_VC1_SIMPLE; - case PIPE_VIDEO_PROFILE_VC1_MAIN: - return VDP_DECODER_PROFILE_VC1_MAIN; - case PIPE_VIDEO_PROFILE_VC1_ADVANCED: - return VDP_DECODER_PROFILE_VC1_ADVANCED; - case PIPE_VIDEO_PROFILE_HEVC_MAIN: - return VDP_DECODER_PROFILE_HEVC_MAIN; - case PIPE_VIDEO_PROFILE_HEVC_MAIN_10: - return VDP_DECODER_PROFILE_HEVC_MAIN_10; - case PIPE_VIDEO_PROFILE_HEVC_MAIN_STILL: - return VDP_DECODER_PROFILE_HEVC_MAIN_STILL; - case PIPE_VIDEO_PROFILE_HEVC_MAIN_12: - return VDP_DECODER_PROFILE_HEVC_MAIN_12; - case PIPE_VIDEO_PROFILE_HEVC_MAIN_444: - return VDP_DECODER_PROFILE_HEVC_MAIN_444; - case PIPE_VIDEO_PROFILE_AV1_MAIN: - return VDP_DECODER_PROFILE_AV1_MAIN; - default: - assert(0); - return -1; - } -} - -static inline struct u_rect * -RectToPipe(const VdpRect *src, struct u_rect *dst) -{ - if (src) { - dst->x0 = src->x0; - dst->y0 = src->y0; - dst->x1 = src->x1; - dst->y1 = src->y1; - return dst; - } - return NULL; -} - -static inline struct pipe_box -RectToPipeBox(const VdpRect *rect, struct pipe_resource *res) -{ - struct pipe_box box; - - box.x = 0; - box.y = 0; - box.z = 0; - box.width = res->width0; - box.height = res->height0; - box.depth = 1; - - if (rect) { - if (rect->x1 > rect->x0 && - rect->y1 > rect->y0) { - box.x = rect->x0; - box.y = rect->y0; - box.width = rect->x1 - box.x; - box.height = rect->y1 - box.y; - } else { - box.width = 0; - box.height = 0; - } - } - - return box; -} - -static inline bool -CheckSurfaceParams(struct pipe_screen *screen, - const struct pipe_resource *templ) -{ - return screen->is_format_supported(screen, templ->format, templ->target, - templ->nr_samples, - templ->nr_storage_samples, templ->bind); -} - -typedef struct -{ - struct pipe_reference reference; - struct vl_screen *vscreen; - struct pipe_context *context; - struct vl_compositor compositor; - struct pipe_sampler_view *dummy_sv; - mtx_t mutex; -} vlVdpDevice; - -typedef struct -{ - vlVdpDevice *device; - struct vl_compositor_state cstate; - - struct { - bool supported, enabled; - float luma_min, luma_max; - } luma_key; - - struct { - bool supported, enabled, spatial; - struct vl_deint_filter *filter; - } deint; - - struct { - bool supported, enabled; - struct vl_bicubic_filter *filter; - } bicubic; - - struct { - bool supported, enabled; - unsigned level; - struct vl_median_filter *filter; - } noise_reduction; - - struct { - bool supported, enabled; - float value; - struct vl_matrix_filter *filter; - } sharpness; - - unsigned video_width, video_height; - enum pipe_video_chroma_format chroma_format; - unsigned max_layers, skip_chroma_deint; - - bool custom_csc; - vl_csc_matrix csc; -} vlVdpVideoMixer; - -typedef struct -{ - vlVdpDevice *device; - struct pipe_video_buffer templat, *video_buffer, *ref_buffer; -} vlVdpSurface; - -typedef struct -{ - vlVdpDevice *device; - struct pipe_sampler_view *sampler_view; -} vlVdpBitmapSurface; - -typedef uint64_t vlVdpTime; - -typedef struct -{ - vlVdpDevice *device; - struct pipe_surface surface; - struct pipe_sampler_view *sampler_view; - struct pipe_fence_handle *fence; - struct vl_compositor_state cstate; - struct u_rect dirty_area; - bool send_to_X; -} vlVdpOutputSurface; - -typedef struct -{ - vlVdpDevice *device; - Drawable drawable; -} vlVdpPresentationQueueTarget; - -typedef struct -{ - vlVdpDevice *device; - Drawable drawable; - struct vl_compositor_state cstate; - vlVdpOutputSurface *last_surf; -} vlVdpPresentationQueue; - -typedef struct -{ - vlVdpDevice *device; - mtx_t mutex; - struct pipe_video_codec *decoder; -} vlVdpDecoder; - -typedef uint32_t vlHandle; - -bool vlCreateHTAB(void); -void vlDestroyHTAB(void); -vlHandle vlAddDataHTAB(void *data); -void* vlGetDataHTAB(vlHandle handle); -void vlRemoveDataHTAB(vlHandle handle); - -bool vlGetFuncFTAB(VdpFuncId function_id, void **func); - -/* Public functions */ -VdpDeviceCreateX11 vdp_imp_device_create_x11; - -void vlVdpDefaultSamplerViewTemplate(struct pipe_sampler_view *templ, struct pipe_resource *res); - -/* Internal function pointers */ -VdpGetErrorString vlVdpGetErrorString; -VdpDeviceDestroy vlVdpDeviceDestroy; -void vlVdpDeviceFree(vlVdpDevice *dev); -VdpGetProcAddress vlVdpGetProcAddress; -VdpGetApiVersion vlVdpGetApiVersion; -VdpGetInformationString vlVdpGetInformationString; -VdpVideoSurfaceQueryCapabilities vlVdpVideoSurfaceQueryCapabilities; -VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities; -VdpDecoderQueryCapabilities vlVdpDecoderQueryCapabilities; -VdpOutputSurfaceQueryCapabilities vlVdpOutputSurfaceQueryCapabilities; -VdpOutputSurfaceQueryGetPutBitsNativeCapabilities vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities; -VdpOutputSurfaceQueryPutBitsIndexedCapabilities vlVdpOutputSurfaceQueryPutBitsIndexedCapabilities; -VdpOutputSurfaceQueryPutBitsYCbCrCapabilities vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities; -VdpBitmapSurfaceQueryCapabilities vlVdpBitmapSurfaceQueryCapabilities; -VdpVideoMixerQueryFeatureSupport vlVdpVideoMixerQueryFeatureSupport; -VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport; -VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange; -VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport; -VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange; -VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate; -VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy; -VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters; -VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr; -VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr; -void vlVdpVideoSurfaceClear(vlVdpSurface *vlsurf); -VdpDecoderCreate vlVdpDecoderCreate; -VdpDecoderDestroy vlVdpDecoderDestroy; -VdpDecoderGetParameters vlVdpDecoderGetParameters; -VdpDecoderRender vlVdpDecoderRender; -VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate; -VdpOutputSurfaceDestroy vlVdpOutputSurfaceDestroy; -VdpOutputSurfaceGetParameters vlVdpOutputSurfaceGetParameters; -VdpOutputSurfaceGetBitsNative vlVdpOutputSurfaceGetBitsNative; -VdpOutputSurfacePutBitsNative vlVdpOutputSurfacePutBitsNative; -VdpOutputSurfacePutBitsIndexed vlVdpOutputSurfacePutBitsIndexed; -VdpOutputSurfacePutBitsYCbCr vlVdpOutputSurfacePutBitsYCbCr; -VdpOutputSurfaceRenderOutputSurface vlVdpOutputSurfaceRenderOutputSurface; -VdpOutputSurfaceRenderBitmapSurface vlVdpOutputSurfaceRenderBitmapSurface; -VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate; -VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy; -VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters; -VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative; -VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy; -VdpPresentationQueueCreate vlVdpPresentationQueueCreate; -VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy; -VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor; -VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor; -VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime; -VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay; -VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle; -VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus; -VdpPreemptionCallback vlVdpPreemptionCallback; -VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister; -VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables; -VdpVideoMixerCreate vlVdpVideoMixerCreate; -VdpVideoMixerRender vlVdpVideoMixerRender; -VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues; -VdpVideoMixerGetFeatureSupport vlVdpVideoMixerGetFeatureSupport; -VdpVideoMixerGetFeatureEnables vlVdpVideoMixerGetFeatureEnables; -VdpVideoMixerGetParameterValues vlVdpVideoMixerGetParameterValues; -VdpVideoMixerGetAttributeValues vlVdpVideoMixerGetAttributeValues; -VdpVideoMixerDestroy vlVdpVideoMixerDestroy; -VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix; -/* Winsys specific internal function pointers */ -VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11; - - -/* interop for GL gallium frontend */ -VdpVideoSurfaceGallium vlVdpVideoSurfaceGallium; -VdpOutputSurfaceGallium vlVdpOutputSurfaceGallium; -VdpVideoSurfaceDMABuf vlVdpVideoSurfaceDMABuf; -VdpOutputSurfaceDMABuf vlVdpOutputSurfaceDMABuf; - -#define VDPAU_OUT 0 -#define VDPAU_ERR 1 -#define VDPAU_WARN 2 -#define VDPAU_TRACE 3 - -static inline void VDPAU_MSG(unsigned int level, const char *fmt, ...) -{ - static int debug_level = -1; - - if (debug_level == -1) { - debug_level = MAX2(debug_get_num_option("VDPAU_DEBUG", 0), 0); - } - - if (level <= debug_level) { - va_list ap; - va_start(ap, fmt); - _debug_vprintf(fmt, ap); - va_end(ap); - } -} - -static inline void -DeviceReference(vlVdpDevice **ptr, vlVdpDevice *dev) -{ - vlVdpDevice *old_dev = *ptr; - - if (pipe_reference(&(*ptr)->reference, &dev->reference)) - vlVdpDeviceFree(old_dev); - *ptr = dev; -} - -#endif /* VDPAU_PRIVATE_H */ diff --git a/src/gallium/include/frontend/vdpau_dmabuf.h b/src/gallium/include/frontend/vdpau_dmabuf.h deleted file mode 100644 index f838c925f30..00000000000 --- a/src/gallium/include/frontend/vdpau_dmabuf.h +++ /dev/null @@ -1,94 +0,0 @@ -/************************************************************************** - * - * Copyright 2016 Advanced Micro Devices, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -/* - * Authors: - * Christian König - * - */ - -#ifndef _VDPAU_DMABUF_H_ -#define _VDPAU_DMABUF_H_ - -#include - -/* driver specific functions for NV_vdpau_interop */ -#ifndef VDP_FUNC_ID_BASE_DRIVER -#define VDP_FUNC_ID_BASE_DRIVER 0x2000 -#endif - -/* New DMA-buf based implementation */ -#define VDP_FUNC_ID_VIDEO_SURFACE_DMA_BUF (VDP_FUNC_ID_BASE_DRIVER + 2) -#define VDP_FUNC_ID_OUTPUT_SURFACE_DMA_BUF (VDP_FUNC_ID_BASE_DRIVER + 3) - -/* Define some more internal RGBA formats for more - * robust handling of Video Surfaces - */ -#define VDP_RGBA_FORMAT_R8 (-1) -#define VDP_RGBA_FORMAT_R8G8 (-2) - -struct VdpSurfaceDMABufDesc { - /* DMA-buf file descriptor */ - uint32_t handle; - /* Width in pixel */ - uint32_t width; - /* Height in pixel */ - uint32_t height; - /* Offset in bytes */ - uint32_t offset; - /* Stride in bytes */ - uint32_t stride; - /* VDP_RGBA_FORMAT_* as defined in the VDPAU spec and above. */ - uint32_t format; -}; - -/** - * \brief Video surface planes - */ -typedef uint32_t VdpVideoSurfacePlane; - -/** \hideinitializer \brief Luma top field */ -#define VDP_VIDEO_SURFACE_PLANE_LUMA_TOP ((VdpVideoSurfacePlane)0) -/** \hideinitializer \brief Luma bottom field */ -#define VDP_VIDEO_SURFACE_PLANE_LUMA_BOTTOM ((VdpVideoSurfacePlane)1) -/** \hideinitializer \brief Chroma top field */ -#define VDP_VIDEO_SURFACE_PLANE_CHROMA_TOP ((VdpVideoSurfacePlane)2) -/** \hideinitializer \brief Chroma bottom field */ -#define VDP_VIDEO_SURFACE_PLANE_CHROMA_BOTTOM ((VdpVideoSurfacePlane)3) - -typedef VdpStatus VdpVideoSurfaceDMABuf( - VdpVideoSurface surface, - VdpVideoSurfacePlane plane, - struct VdpSurfaceDMABufDesc * result -); - -typedef VdpStatus VdpOutputSurfaceDMABuf( - VdpOutputSurface surface, - struct VdpSurfaceDMABufDesc * result -); - -#endif /* _VDPAU_DMABUF_H_ */ diff --git a/src/gallium/include/frontend/vdpau_funcs.h b/src/gallium/include/frontend/vdpau_funcs.h deleted file mode 100644 index 66e3c23ede4..00000000000 --- a/src/gallium/include/frontend/vdpau_funcs.h +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************** - * - * Copyright 2016 Advanced Micro Devices, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -/* - * Authors: - * Christian König - * - */ - -#ifndef _VDPAU_FUNCS_H_ -#define _VDPAU_FUNCS_H_ - -#include "vdpau_dmabuf.h" - -/* Used for implementing NV_vdpau_interop */ -static inline enum pipe_format -VdpFormatRGBAToPipe(uint32_t vdpau_format) -{ - switch (vdpau_format) { - case VDP_RGBA_FORMAT_R8: - return PIPE_FORMAT_R8_UNORM; - case VDP_RGBA_FORMAT_R8G8: - return PIPE_FORMAT_R8G8_UNORM; - case VDP_RGBA_FORMAT_A8: - return PIPE_FORMAT_A8_UNORM; - case VDP_RGBA_FORMAT_B10G10R10A2: - return PIPE_FORMAT_B10G10R10A2_UNORM; - case VDP_RGBA_FORMAT_B8G8R8A8: - return PIPE_FORMAT_B8G8R8A8_UNORM; - case VDP_RGBA_FORMAT_R10G10B10A2: - return PIPE_FORMAT_R10G10B10A2_UNORM; - case VDP_RGBA_FORMAT_R8G8B8A8: - return PIPE_FORMAT_R8G8B8A8_UNORM; - default: - assert(0); - } - - return PIPE_FORMAT_NONE; -} - -#endif /* _VDPAU_FUNCS_H_ */ diff --git a/src/gallium/include/frontend/vdpau_interop.h b/src/gallium/include/frontend/vdpau_interop.h deleted file mode 100644 index 04d455a370a..00000000000 --- a/src/gallium/include/frontend/vdpau_interop.h +++ /dev/null @@ -1,54 +0,0 @@ -/************************************************************************** - * - * Copyright 2013 Advanced Micro Devices, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -/* - * Authors: - * Christian König - * - */ - -#ifndef _VDPAU_INTEROP_H_ -#define _VDPAU_INTEROP_H_ - -/* driver specific functions for NV_vdpau_interop */ -#ifndef VDP_FUNC_ID_BASE_DRIVER -#define VDP_FUNC_ID_BASE_DRIVER 0x2000 -#endif - -/* Older implementation relying on passing pipe_video_buffer and - * pipe_resources around. Deprecated and shouldn't be used for new things. - */ -#define VDP_FUNC_ID_VIDEO_SURFACE_GALLIUM (VDP_FUNC_ID_BASE_DRIVER + 0) -#define VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM (VDP_FUNC_ID_BASE_DRIVER + 1) - -struct pipe_resource; -struct pipe_video_buffer; - -typedef struct pipe_video_buffer *VdpVideoSurfaceGallium(uint32_t surface); -typedef struct pipe_resource *VdpOutputSurfaceGallium(uint32_t surface); - -#endif /* _VDPAU_INTEROP_H_ */ diff --git a/src/gallium/meson.build b/src/gallium/meson.build index 6ba60851984..fbbceb2d45f 100644 --- a/src/gallium/meson.build +++ b/src/gallium/meson.build @@ -8,8 +8,7 @@ foreach d : [[with_gallium_r300 or with_gallium_radeonsi or with_gallium_r600, ' [with_gallium_radeonsi, 'amdgpu_winsys_create'], [with_gallium_nouveau, 'nouveau_drm_screen_create'], [with_gallium_freedreno, 'fd_drm_screen_create_renderonly'], - [amd_with_llvm and with_gallium_radeonsi, 'ac_init_shared_llvm_once'], - [with_gallium_vdpau, 'vdp_imp_device_create_x11']] + [amd_with_llvm and with_gallium_radeonsi, 'ac_init_shared_llvm_once']] if d[0] sym_config.set(d[1], d[1] + ';') else @@ -216,12 +215,6 @@ if with_gallium_va subdir('targets/va') endif endif -if with_gallium_vdpau - subdir('frontends/vdpau') - if not with_dri - subdir('targets/vdpau') - endif -endif if with_gallium_mediafoundation subdir('frontends/mediafoundation') subdir('targets/mediafoundation') diff --git a/src/gallium/targets/dri/dri.sym.in b/src/gallium/targets/dri/dri.sym.in index e06673488ea..d987668e4f5 100644 --- a/src/gallium/targets/dri/dri.sym.in +++ b/src/gallium/targets/dri/dri.sym.in @@ -78,7 +78,6 @@ @fd_drm_screen_create_renderonly@ @ac_init_shared_llvm_once@ @va_driver_init@ - @vdp_imp_device_create_x11@ local: *; }; diff --git a/src/gallium/targets/dri/meson.build b/src/gallium/targets/dri/meson.build index 6a2c6e94b90..97f641c4e98 100644 --- a/src/gallium/targets/dri/meson.build +++ b/src/gallium/targets/dri/meson.build @@ -13,14 +13,11 @@ gallium_dri_drivers = [] gallium_dri_link_with = [] gallium_dri_link_whole = [] -if with_gallium_va or with_gallium_vdpau +if with_gallium_va gallium_dri_link_with += [libgalliumvlwinsys] if with_gallium_va gallium_dri_link_whole += [libva_st] endif - if with_gallium_vdpau - gallium_dri_link_whole += [libvdpau_st] - endif endif dri_sym = configure_file(input : 'dri.sym.in', output : 'dri.sym', configuration : sym_config) @@ -70,21 +67,15 @@ libgallium_dri = shared_library( shared_glapi_lib = libgallium_dri -if with_gallium_va or with_gallium_vdpau +if with_gallium_va va_drivers = [] - vdpau_drivers = [] foreach d : [[with_gallium_r600, 'r600'], [with_gallium_radeonsi, 'radeonsi'], [with_gallium_nouveau, 'nouveau'], [with_gallium_virgl, 'virtio_gpu'], [with_gallium_d3d12_video, 'd3d12']] if d[0] - if with_gallium_va - va_drivers += '@0@_drv_video.so'.format(d[1]) - endif - if with_gallium_vdpau - vdpau_drivers += 'libvdpau_@0@.so.@1@.@2@.0'.format(d[1], VDPAU_MAJOR, VDPAU_MINOR) - endif + va_drivers += '@0@_drv_video.so'.format(d[1]) endif endforeach @@ -98,15 +89,4 @@ if with_gallium_va or with_gallium_vdpau install_tag : 'runtime', ) endif - - if vdpau_drivers.length() > 0 - meson.add_install_script( - install_megadrivers, - libgallium_dri.full_path(), - vdpau_drivers_path, - vdpau_drivers, - '--megadriver-libdir', get_option('libdir'), - install_tag : 'runtime', - ) - endif endif diff --git a/src/gallium/targets/vdpau/meson.build b/src/gallium/targets/vdpau/meson.build deleted file mode 100644 index 0f355e3ca33..00000000000 --- a/src/gallium/targets/vdpau/meson.build +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright © 2017-2018 Intel Corporation -# SPDX-License-Identifier: MIT - -# TODO: support non-static targets -# Static targets are always enabled in autotools (unless you modify -# configure.ac) - -vdpau_link_args = [] -vdpau_link_depends = [] -vdpau_drivers = [] - -vdpau_sym = configure_file(input : 'vdpau.sym.in', output : 'vdpau.sym', configuration : sym_config) - -if with_ld_version_script - vdpau_link_args += ['-Wl,--version-script', join_paths(meson.current_build_dir(), 'vdpau.sym')] - vdpau_link_depends += vdpau_sym -endif -if with_ld_dynamic_list - vdpau_link_args += ['-Wl,--dynamic-list', join_paths(meson.current_source_dir(), '../dri.dyn')] - vdpau_link_depends += files('../dri.dyn') -endif - -link_with_libvdpau_gallium = [ - libgalliumvlwinsys, libgalliumvl, libgallium, - libpipe_loader_static, libws_null, libwsw, libswdri, libswkmsdri, -] - -if with_glx == 'xlib' - link_with_libvdpau_gallium += [libws_xlib] -endif - -libvdpau_gallium = shared_library( - 'vdpau_gallium', - 'vdpau_target.c', - gnu_symbol_visibility : 'hidden', - link_args : [vdpau_link_args, ld_args_gc_sections], - include_directories : [ - inc_include, inc_src, inc_gallium, inc_gallium_aux, inc_util, inc_gallium_winsys, inc_gallium_drivers, - ], - link_whole : [libvdpau_st], - link_with : link_with_libvdpau_gallium, - dependencies : [ - idep_mesautil, - driver_r600, driver_radeonsi, driver_nouveau, driver_d3d12, driver_virgl, - ], - link_depends : vdpau_link_depends, - soversion : '@0@.@1@.0'.format(VDPAU_MAJOR, VDPAU_MINOR), - install : true, - install_dir : vdpau_drivers_path, - name_suffix : libname_suffix, -) -foreach d : [[with_gallium_r600, 'r600'], - [with_gallium_radeonsi, 'radeonsi'], - [with_gallium_nouveau, 'nouveau'], - [with_gallium_virgl, 'virtio_gpu'], - [with_gallium_d3d12_video, 'd3d12']] - if d[0] - vdpau_drivers += 'libvdpau_@0@.so.@1@.@2@.0'.format(d[1], VDPAU_MAJOR, VDPAU_MINOR) - endif -endforeach - -if vdpau_drivers.length() > 0 - meson.add_install_script( - install_megadrivers, - libvdpau_gallium.full_path(), - vdpau_drivers_path, - vdpau_drivers, - install_tag : 'runtime', - ) -endif diff --git a/src/gallium/targets/vdpau/vdpau.sym.in b/src/gallium/targets/vdpau/vdpau.sym.in deleted file mode 100644 index d37e44b98f9..00000000000 --- a/src/gallium/targets/vdpau/vdpau.sym.in +++ /dev/null @@ -1,10 +0,0 @@ -{ - global: - vdp_imp_device_create_x11; - @nouveau_drm_screen_create@ - @radeon_drm_winsys_create@ - @amdgpu_winsys_create@ - @ac_init_shared_llvm_once@ - local: - *; -}; diff --git a/src/gallium/targets/vdpau/vdpau_target.c b/src/gallium/targets/vdpau/vdpau_target.c deleted file mode 100644 index 308e23bb4a0..00000000000 --- a/src/gallium/targets/vdpau/vdpau_target.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "target-helpers/drm_helper.h" -#include "target-helpers/sw_helper.h"