Update to 0.5

Cleanup spec file
This commit is contained in:
Nicolas Chauvet 2012-09-05 23:11:21 +02:00
parent 858bb2be0a
commit ab435e554f
3 changed files with 6 additions and 449 deletions

View File

@ -1,254 +0,0 @@
From 0cef65f53d836e8cfdb01e58d0df58743badba71 Mon Sep 17 00:00:00 2001
From: Stephen Warren <swarren@wwwdotorg.org>
Date: Wed, 02 May 2012 03:27:24 +0000
Subject: Implement workarounds for Adobe Flash bugs
Implement two workarounds:
1) Swap U and V planes to VdpVideoSurfacePutBitsYCbCr to fix blue-tinged
videos.
2) Disable VdpPresentationQueueSetBackgroundColor, so that Flash doesn't
set the background to pure black or pure white, which would cause the
VDPAU image to bleed through to other parts of the desktop with those
very common colors.
These workarounds are only enabled when running under Flash player, and
may be individually controlled via /etc/vdpau_wrapper.cfg, should they
ever need to be disabled.
Note that this code stores the VDPAU backend function pointers as global
variables, which is technically incorrect. However, the likelihood of
any known VDPAU implementation ever returning different values for these
pointers within a single process is zero. If this becomes a problem, a
has table of VdpDevice to the stored pointers should be implemented.
Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 48e69a7..9162ffb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,7 @@
AM_CFLAGS = \
-I$(top_srcdir)/include \
-DVDPAU_MODULEDIR="\"$(moduledir)\"" \
+ -DVDPAU_SYSCONFDIR="\"$(sysconfdir)\"" \
$(X11_CFLAGS) \
$(XEXT_CFLAGS)
@@ -26,3 +27,6 @@ libvdpauincludedir = $(includedir)/vdpau
libvdpauinclude_HEADERS = \
$(top_srcdir)/include/vdpau/vdpau.h \
$(top_srcdir)/include/vdpau/vdpau_x11.h
+
+libvdpausysconfdir=$(sysconfdir)
+libvdpausysconf_DATA = vdpau_wrapper.cfg
diff --git a/src/vdpau_wrapper.c b/src/vdpau_wrapper.c
index 23de3d4..c955745 100644
--- a/src/vdpau_wrapper.c
+++ b/src/vdpau_wrapper.c
@@ -210,6 +210,163 @@ static void _vdp_close_driver(void)
_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 _inited_fixes;
+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] = source_data[1];
+ /*
+ * source_pitches[1] and source_pitches[2] should be equal,
+ * so no need to re-order.
+ */
+ data = data_reordered;
+ }
+ else {
+ data = source_data;
+ }
+
+ return _imp_vid_put_bits_y_cb_cr(
+ surface,
+ source_ycbcr_format,
+ data,
+ source_pitches
+ );
+}
+
+static VdpStatus pq_set_bg_color_noop(
+ VdpPresentationQueue presentation_queue,
+ VdpColor * const background_color
+)
+{
+ return VDP_STATUS_OK;
+}
+
+static VdpStatus vdp_wrapper_get_proc_address(
+ VdpDevice device,
+ VdpFuncId function_id,
+ /* output parameters follow */
+ void * * function_pointer
+)
+{
+ VdpStatus status;
+
+ status = _imp_get_proc_address(device, function_id, function_pointer);
+ if (status != VDP_STATUS_OK) {
+ return status;
+ }
+
+ if (_running_under_flash) {
+ switch (function_id) {
+ case VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR:
+ if (_enable_flash_uv_swap) {
+ _imp_vid_put_bits_y_cb_cr = *function_pointer;
+ *function_pointer = vid_put_bits_y_cb_cr_swapped;
+ }
+ break;
+ case VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR:
+ if (_disable_flash_pq_bg_color) {
+ _imp_pq_set_bg_color = *function_pointer;
+ *function_pointer = pq_set_bg_color_noop;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ return VDP_STATUS_OK;
+}
+
+static void init_running_under_flash(void)
+{
+ FILE *fp;
+ char buffer[1024];
+ int ret, i;
+
+ fp = fopen("/proc/self/cmdline", "r");
+ if (!fp) {
+ return;
+ }
+ ret = fread(buffer, 1, sizeof(buffer) - 1, fp);
+ fclose(fp);
+ if (ret < 0) {
+ return;
+ }
+ /*
+ * Sometimes the file contains null between arguments. Wipe these out so
+ * strstr doesn't stop early.
+ */
+ for (i = 0; i < ret; i++) {
+ if (buffer[i] == '\0') {
+ buffer[i] = 'x';
+ }
+ }
+ buffer[ret] = '\0';
+
+ if (strstr(buffer, "libflashplayer") != NULL) {
+ _running_under_flash = 1;
+ }
+}
+
+void init_config(void)
+{
+ FILE *fp;
+ char buffer[1024];
+ int ret;
+
+ fp = fopen(VDPAU_SYSCONFDIR "/vdpau_wrapper.cfg", "r");
+ if (!fp) {
+ return;
+ }
+
+ while (fgets(buffer, sizeof(buffer), fp) != NULL) {
+ char * equals = strchr(buffer, '=');
+ char * param;
+
+ if (equals == NULL) {
+ continue;
+ }
+
+ *equals = '\0';
+ param = equals + 1;
+
+ if (!strcmp(buffer, "enable_flash_uv_swap")) {
+ _enable_flash_uv_swap = atoi(param);
+ }
+ else if (!strcmp(buffer, "disable_flash_pq_bg_color")) {
+ _disable_flash_pq_bg_color = atoi(param);
+ }
+ }
+}
+
+void init_fixes(void)
+{
+ if (_inited_fixes) {
+ return;
+ }
+ _inited_fixes = 1;
+
+ init_running_under_flash();
+ init_config();
+}
+
VdpStatus vdp_device_create_x11(
Display * display,
int screen,
@@ -220,6 +377,8 @@ VdpStatus vdp_device_create_x11(
{
VdpStatus status;
+ init_fixes();
+
if (!_vdp_imp_device_create_x11_proc) {
status = _vdp_open_driver(display, screen);
if (status != VDP_STATUS_OK) {
@@ -228,10 +387,17 @@ VdpStatus vdp_device_create_x11(
}
}
- return _vdp_imp_device_create_x11_proc(
+ status = _vdp_imp_device_create_x11_proc(
display,
screen,
device,
- get_proc_address
+ &_imp_get_proc_address
);
+ if (status != VDP_STATUS_OK) {
+ return status;
+ }
+
+ *get_proc_address = vdp_wrapper_get_proc_address;
+
+ return VDP_STATUS_OK;
}
diff --git a/src/vdpau_wrapper.cfg b/src/vdpau_wrapper.cfg
new file mode 100644
index 0000000..21d5b8c
--- a/dev/null
+++ b/src/vdpau_wrapper.cfg
@@ -0,0 +1,2 @@
+enable_flash_uv_swap=1
+disable_flash_pq_bg_color=1
--
cgit v0.9.0.2-2-gbebe

View File

@ -1,179 +0,0 @@
From 4262513e67c3572ed19bd796ec6180cdde7ccb7e Mon Sep 17 00:00:00 2001
From: Kiran Pawar <kpawar@nvidia.com>
Date: Fri, 05 Aug 2011 06:15:18 +0000
Subject: vdpau_wrapper.c: Track dynamic library handles and free them on exit using __attribute__((destructor))
Signed-off-by: Kiran Pawar <kpawar@nvidia.com>
Tested-by: Aaron Plattner <aplattner@nvidia.com>
Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
---
diff --git a/src/vdpau_wrapper.c b/src/vdpau_wrapper.c
index f504775..23de3d4 100644
--- a/src/vdpau_wrapper.c
+++ b/src/vdpau_wrapper.c
@@ -40,6 +40,17 @@ 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)
@@ -87,23 +98,16 @@ static char * _vdp_get_driver_name_from_dri2(
return driver_name;
}
-VdpStatus vdp_device_create_x11(
+static VdpStatus _vdp_open_driver(
Display * display,
- int screen,
- /* output parameters follow */
- VdpDevice * device,
- VdpGetProcAddress * * get_proc_address
-)
+ int screen)
{
char const * vdpau_driver;
char * vdpau_driver_dri2 = NULL;
char vdpau_driver_lib[PATH_MAX];
- void * backend_dll;
char const * vdpau_trace;
char const * func_name;
- VdpDeviceCreateX11 * vdp_imp_device_create_x11;
-
vdpau_driver = getenv("VDPAU_DRIVER");
if (!vdpau_driver) {
vdpau_driver = vdpau_driver_dri2 =
@@ -125,13 +129,13 @@ VdpStatus vdp_device_create_x11(
return VDP_STATUS_NO_IMPLEMENTATION;
}
- backend_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL);
- if (!backend_dll) {
+ _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_LIB_FORMAT,
"", vdpau_driver, "");
- backend_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL);
+ _vdp_driver_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL);
}
if (vdpau_driver_dri2) {
@@ -139,26 +143,28 @@ VdpStatus vdp_device_create_x11(
vdpau_driver_dri2 = NULL;
}
- if (!backend_dll) {
+ 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 = getenv("VDPAU_TRACE");
if (vdpau_trace && atoi(vdpau_trace)) {
- void * trace_dll;
SetDllHandle * set_dll_handle;
- trace_dll = dlopen(VDPAU_MODULEDIR "/libvdpau_trace.so.1", RTLD_NOW | RTLD_GLOBAL);
- if (!trace_dll) {
+ _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(
- trace_dll,
+ _vdp_trace_dll,
"vdp_trace_set_backend_handle"
);
if (!set_dll_handle) {
@@ -167,9 +173,9 @@ VdpStatus vdp_device_create_x11(
return VDP_STATUS_NO_IMPLEMENTATION;
}
- set_dll_handle(backend_dll);
+ set_dll_handle(_vdp_backend_dll);
- backend_dll = trace_dll;
+ _vdp_backend_dll = _vdp_trace_dll;
func_name = "vdp_trace_device_create_x11";
}
@@ -177,17 +183,52 @@ VdpStatus vdp_device_create_x11(
func_name = "vdp_imp_device_create_x11";
}
- vdp_imp_device_create_x11 = (VdpDeviceCreateX11*)dlsym(
- backend_dll,
+ _vdp_imp_device_create_x11_proc = (VdpDeviceCreateX11*)dlsym(
+ _vdp_backend_dll,
func_name
);
- if (!vdp_imp_device_create_x11) {
+ if (!_vdp_imp_device_create_x11_proc) {
fprintf(stderr, "%s\n", dlerror());
_VDP_ERROR_BREAKPOINT();
return VDP_STATUS_NO_IMPLEMENTATION;
}
- return vdp_imp_device_create_x11(
+ 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;
+}
+
+VdpStatus vdp_device_create_x11(
+ Display * display,
+ int screen,
+ /* output parameters follow */
+ VdpDevice * device,
+ VdpGetProcAddress * * get_proc_address
+)
+{
+ VdpStatus status;
+
+ if (!_vdp_imp_device_create_x11_proc) {
+ status = _vdp_open_driver(display, screen);
+ if (status != VDP_STATUS_OK) {
+ _vdp_close_driver();
+ return status;
+ }
+ }
+
+ return _vdp_imp_device_create_x11_proc(
display,
screen,
device,
--
cgit v0.9.0.2-2-gbebe

View File

@ -1,15 +1,12 @@
Name: libvdpau
Version: 0.4.1
Release: 9%{?dist}
Version: 0.5
Release: 1%{?dist}
Summary: Wrapper library for the Video Decode and Presentation API
Group: System Environment/Libraries
License: MIT
URL: http://freedesktop.org/wiki/Software/VDPAU
Source0: http://people.freedesktop.org/~aplattner/vdpau/libvdpau-%{version}.tar.bz2
Patch0: libvdpau-backport.patch
Patch1: flash-workarounds.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Source0: http://cgit.freedesktop.org/~aplattner/libvdpau/snapshot/libvdpau-%{version}.tar.gz
BuildRequires: libtool
@ -52,8 +49,6 @@ developing applications that use %{name}.
%prep
%setup -q
%patch0 -p1
%patch1 -p1 -b .flash-workarounds
autoreconf -vif
@ -65,23 +60,17 @@ make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT INSTALL="install -p"
find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
%clean
rm -rf $RPM_BUILD_ROOT
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(-,root,root,-)
%doc AUTHORS COPYING
%config(noreplace) %{_sysconfdir}/vdpau_wrapper.cfg
%{_libdir}/*.so.*
@ -90,18 +79,19 @@ rm -rf $RPM_BUILD_ROOT
%{?!_without_docs:
%files docs
%defattr(-,root,root,-)
%doc %{_docdir}/%{name}
}
%files devel
%defattr(-,root,root,-)
%{_includedir}/vdpau/
%{_libdir}/libvdpau.so
%{_libdir}/pkgconfig/vdpau.pc
%changelog
* Wed Sep 05 2012 Nicolas Chauvet <kwizart@gmail.com> - 0.5-1
- Update to 0.5
* Sun Aug 19 2012 Julian Sikorski <belegdol@fedoraproject.org> - 0.4.1-9
- Added flash workarounds