/*
* Copyright (c) 2008-2015 NVIDIA Corporation
*
* 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, sublicense, 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 NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <dlfcn.h>
#include <limits.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <vdpau/vdpau_x11.h>
#if DRI2
#include "mesa_dri2.h"
#include <X11/Xlib.h>
#endif
#include "util.h"
typedef void SetDllHandle(
void * driver_dll_handle
);
static void * _vdp_backend_dll;
static void * _vdp_trace_dll;
static void * _vdp_driver_dll;
static VdpDeviceCreateX11 * _vdp_imp_device_create_x11_proc;
#if defined(__GNUC__)
static void _vdp_close_driver(void) __attribute__((destructor));
#endif
#if DEBUG
static void _vdp_wrapper_error_breakpoint(char const * file, int line, char const * function)
{
fprintf(stderr, "VDPAU wrapper: Error detected at %s:%d %s()\n", file, line, function);
}
#define _VDP_ERROR_BREAKPOINT() _vdp_wrapper_error_breakpoint(__FILE__, __LINE__, __FUNCTION__)
#else
#define _VDP_ERROR_BREAKPOINT()
#endif
#define DRIVER_FALLBACK_LIB_FORMAT "libvdpau_%s.so"
#define DRIVER_LIB_FORMAT "%s/libvdpau_%s.so.1"
static char * _vdp_get_driver_name_from_dri2(
Display * display,
int screen
)
{
char * driver_name = NULL;
#if DRI2
Window root = RootWindow(display, screen);
int event_base, error_base;
int major, minor;
char * device_name;
if (!_vdp_DRI2QueryExtension(display, &event_base, &error_base)) {
return NULL;
}
if (!_vdp_DRI2QueryVersion(display, &major, &minor) ||
(major < 1 || (major == 1 && minor < 2))) {
_vdp_DRI2RemoveExtension(display);
return NULL;
}
if (!_vdp_DRI2Connect(display, root, &driver_name, &device_name)) {
_vdp_DRI2RemoveExtension(display);
return NULL;
}
XFree(device_name);
_vdp_DRI2RemoveExtension(display);
#else
(void) display; (void) screen;
#endif /* DRI2 */
return driver_name;
}
static VdpStatus _vdp_open_driver(
Display * display,
int screen)
{
char const * vdpau_driver;
char * vdpau_driver_dri2 = NULL;
const char * vdpau_driver_path = NULL;
char vdpau_driver_lib[PATH_MAX];
char const * vdpau_trace;
char const * func_name;
vdpau_driver = secure_getenv("VDPAU_DRIVER");
if (vdpau_driver) {
if (strchr(vdpau_driver, '/')) {
vdpau_driver = NULL;
}
}
if (!vdpau_driver) {
vdpau_driver = vdpau_driver_dri2 =
_vdp_get_driver_name_from_dri2(display, screen);
}
if (!vdpau_driver) {
vdpau_driver = "nvidia";
}
/* Don't allow setuid apps to use VDPAU_DRIVER_PATH */
vdpau_driver_path = secure_getenv("VDPAU_DRIVER_PATH");
if (vdpau_driver_path &&
snprintf(vdpau_driver_lib, sizeof(vdpau_driver_lib),
DRIVER_LIB_FORMAT, vdpau_driver_path, vdpau_driver) <
sizeof(vdpau_driver_lib)) {
_vdp_driver_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL);
}
/* Fallback to VDPAU_MODULEDIR when VDPAU_DRIVER_PATH is not set,
* or if we fail to create the driver path/dlopen the library. */
if (!_vdp_driver_dll) {
if (snprintf(vdpau_driver_lib, sizeof(vdpau_driver_lib),
DRIVER_LIB_FORMAT, VDPAU_MODULEDIR, vdpau_driver) >=
sizeof(vdpau_driver_lib)) {
fprintf(stderr, "Failed to construct driver path: path too long\n");
if (vdpau_driver_dri2) {
XFree(vdpau_driver_dri2);
vdpau_driver_dri2 = NULL;
}
_VDP_ERROR_BREAKPOINT();
return VDP_STATUS_NO_IMPLEMENTATION;
}
else {
_vdp_driver_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL);
}
}
if (!_vdp_driver_dll) {
/* Try again using the old path, which is guaranteed to fit in PATH_MAX
* if the complete path fit above. */
snprintf(vdpau_driver_lib, sizeof(vdpau_driver_lib),
DRIVER_FALLBACK_LIB_FORMAT, vdpau_driver);
_vdp_driver_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL);
}
if (vdpau_driver_dri2) {
XFree(vdpau_driver_dri2);
vdpau_driver_dri2 = NULL;
}
if (!_vdp_driver_dll) {
fprintf(stderr, "Failed to open VDPAU backend %s\n", dlerror());
_VDP_ERROR_BREAKPOINT();
return VDP_STATUS_NO_IMPLEMENTATION;
}
_vdp_backend_dll = _vdp_driver_dll;
vdpau_trace = secure_getenv("VDPAU_TRACE");
if (vdpau_trace && atoi(vdpau_trace)) {
SetDllHandle * set_dll_handle;
_vdp_trace_dll = dlopen(VDPAU_MODULEDIR "/libvdpau_trace.so.1",
RTLD_NOW | RTLD_GLOBAL);
if (!_vdp_trace_dll) {
fprintf(stderr, "Failed to open VDPAU trace library %s\n", dlerror());
_VDP_ERROR_BREAKPOINT();
return VDP_STATUS_NO_IMPLEMENTATION;
}
set_dll_handle = (SetDllHandle*)dlsym(
_vdp_trace_dll,
"vdp_trace_set_backend_handle"
);
if (!set_dll_handle) {
fprintf(stderr, "%s\n", dlerror());
_VDP_ERROR_BREAKPOINT();
return VDP_STATUS_NO_IMPLEMENTATION;
}
set_dll_handle(_vdp_backend_dll);
_vdp_backend_dll = _vdp_trace_dll;
func_name = "vdp_trace_device_create_x11";
}
else {
func_name = "vdp_imp_device_create_x11";
}
_vdp_imp_device_create_x11_proc = (VdpDeviceCreateX11*)dlsym(
_vdp_backend_dll,
func_name
);
if (!_vdp_imp_device_create_x11_proc) {
fprintf(stderr, "%s\n", dlerror());
_VDP_ERROR_BREAKPOINT();
return VDP_STATUS_NO_IMPLEMENTATION;
}
return VDP_STATUS_OK;
}
static void _vdp_close_driver(void)
{
if (_vdp_driver_dll) {
dlclose(_vdp_driver_dll);
_vdp_driver_dll = NULL;
}
if (_vdp_trace_dll) {
dlclose(_vdp_trace_dll);
_vdp_trace_dll = NULL;
}
_vdp_backend_dll = NULL;
_vdp_imp_device_create_x11_proc = NULL;
}
static VdpGetProcAddress * _imp_get_proc_address;
static VdpVideoSurfacePutBitsYCbCr * _imp_vid_put_bits_y_cb_cr;
static VdpPresentationQueueSetBackgroundColor * _imp_pq_set_bg_color;
static int _running_under_flash;
static int _enable_flash_uv_swap = 1;
static int _disable_flash_pq_bg_color = 1;
static VdpStatus vid_put_bits_y_cb_cr_swapped(
VdpVideoSurface surface,
VdpYCbCrFormat source_ycbcr_format,
void const * const * source_data,
uint32_t const * source_pitches
)
{
void const * data_reordered[3];
void const * const * data;
if (source_ycbcr_format == VDP_YCBCR_FORMAT_YV12) {
data_reordered[0] = source_data[0];
data_reordered[1] = source_data[2];
data_reordered[2] = sou
没有合适的资源?快使用搜索试试~ 我知道了~
libvdpau-1.1.1.tar.gz
需积分: 45 18 下载量 139 浏览量
2018-01-17
15:29:04
上传
评论
收藏 529KB GZ 举报
温馨提示
共42个文件
in:7个
am:5个
h:4个
linux系统离线安装CUDA所需依赖库,从vdpau官网下载的1.1.1版本libvdpau。
资源推荐
资源详情
资源评论
收起资源包目录
libvdpau-1.1.1.tar.gz (42个子文件)
libvdpau-1.1.1
acinclude.m4 2KB
test-driver 5KB
test
Makefile.am 150B
dlclose.c 2KB
Makefile.in 31KB
config.h.in 3KB
trace
vdpau_trace.cpp 152KB
Makefile.am 443B
Makefile.in 22KB
depcomp 23KB
include
vdpau
vdpau_x11.h 6KB
vdpau.h 172KB
aclocal.m4 371KB
autogen.sh 232B
compile 7KB
config.guess 42KB
vdpau.pc.in 276B
Makefile.am 209B
config.sub 35KB
src
util.h 2KB
mesa_dri2.c 6KB
Makefile.am 784B
Makefile.in 23KB
vdpau_wrapper.c 12KB
vdpau_wrapper.cfg 51B
mesa_dri2.h 2KB
README 0B
Makefile.in 28KB
INSTALL 0B
missing 7KB
install-sh 14KB
AUTHORS 129B
doc
Doxyfile 52KB
Makefile.am 616B
vdpau_data_flow.png 68KB
Makefile.in 13KB
configure 607KB
ltmain.sh 316KB
NEWS 0B
ChangeLog 40KB
COPYING 1KB
configure.ac 3KB
共 42 条
- 1
资源评论
unwannadie
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功