[vlc-commits] contribs: use libplacebo on Windows
Thomas Guillem
git at videolan.org
Tue Nov 14 13:37:10 CET 2017
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Nov 13 15:16:16 2017 +0100| [421b81db864a3026cdbd7b62fefcde11339f7fd2] | committer: Thomas Guillem
contribs: use libplacebo on Windows
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=421b81db864a3026cdbd7b62fefcde11339f7fd2
---
.../src/libplacebo/0001-build-use-a-Makefile.patch | 6 +-
.../libplacebo/0002-build-fix-win32-build.patch | 161 +++++++++++++++++++++
contrib/src/libplacebo/rules.mak | 11 +-
3 files changed, 172 insertions(+), 6 deletions(-)
diff --git a/contrib/src/libplacebo/0001-build-use-a-Makefile.patch b/contrib/src/libplacebo/0001-build-use-a-Makefile.patch
index be48d72a5c..42b08c8c7a 100644
--- a/contrib/src/libplacebo/0001-build-use-a-Makefile.patch
+++ b/contrib/src/libplacebo/0001-build-use-a-Makefile.patch
@@ -1,7 +1,7 @@
-From 185f0ee9dc6ca6b46a43c669d98b5b63020a04e5 Mon Sep 17 00:00:00 2001
+From 2f3ec424ca2dcfdd1abe5f1774c35aea1c9b0088 Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas at gllm.fr>
Date: Mon, 30 Oct 2017 14:32:03 +0100
-Subject: [PATCH] build: use a Makefile
+Subject: [PATCH 1/2] build: use a Makefile
Only needed for VLC 3.0
---
@@ -13,7 +13,7 @@ Only needed for VLC 3.0
diff --git a/Makefile b/Makefile
new file mode 100644
-index 0000000..36e7f26
+index 0000000..13f661b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,38 @@
diff --git a/contrib/src/libplacebo/0002-build-fix-win32-build.patch b/contrib/src/libplacebo/0002-build-fix-win32-build.patch
new file mode 100644
index 0000000000..b05111202b
--- /dev/null
+++ b/contrib/src/libplacebo/0002-build-fix-win32-build.patch
@@ -0,0 +1,161 @@
+From 5fa4c39b3d5d93e7a5eaf16a813d8af80f59f254 Mon Sep 17 00:00:00 2001
+From: Thomas Guillem <thomas at gllm.fr>
+Date: Mon, 13 Nov 2017 15:00:04 +0100
+Subject: [PATCH 2/2] build: fix win32 build
+
+ - Remove pthread (disable TA_MEMORY_DEBUGGING and always init/deinit).
+
+ - Remove msvcr100.dll dependency. This dell is not avaible on old Windows
+ versions. Don't set locale on Windows, this doesn't seem to have any
+ consequences with VLC on windows (tested with US/FR locales).
+---
+ Makefile | 9 ++++++++-
+ src/context.c | 12 ++++++++++++
+ src/osdep/printf_useloc_win.c | 18 ++++++------------
+ src/ta/ta.c | 4 ++++
+ 4 files changed, 30 insertions(+), 13 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 13f661b..0d29744 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,6 +1,13 @@
+ SRCS := colorspace.c common.c context.c dispatch.c filters.c ra.c shaders.c \
+ shaders/colorspace.c shaders/sampling.c spirv.c bstr/bstr.c siphash.c \
+- ta/ta.c ta/ta_utils.c ta/talloc.c osdep/printf_useloc_posix.c
++ ta/ta.c ta/ta_utils.c ta/talloc.c
++
++ifdef HAVE_WIN32
++SRCS += osdep/printf_useloc_win.c
++else
++SRCS += osdep/printf_useloc_posix.c
++lpthread_libs = $(shell $(LD) -lpthread && echo "-lpthread" || echo "")
++endif
+
+ OBJS = $(patsubst %.c, $(OBJDIR)src/%.o, $(SRCS))
+
+diff --git a/src/context.c b/src/context.c
+index a325fb8..caaed3f 100644
+--- a/src/context.c
++++ b/src/context.c
+@@ -17,13 +17,17 @@
+
+ #include <stdio.h>
+ #include <locale.h>
++#ifdef _WIN32
+ #include <pthread.h>
++#endif
+
+ #include "common.h"
+ #include "context.h"
+
++#ifndef _WIN32
+ static pthread_mutex_t pl_ctx_mutex = PTHREAD_MUTEX_INITIALIZER;
+ static int pl_ctx_refcount;
++#endif
+
+ static void global_init(void)
+ {
+@@ -59,11 +63,15 @@ struct pl_context *pl_context_create(int api_ver,
+ abort();
+ }
+
++#ifdef _WIN32
++ global_init();
++#else
+ // Do global initialization only when refcount is 0
+ pthread_mutex_lock(&pl_ctx_mutex);
+ if (pl_ctx_refcount++ == 0)
+ global_init();
+ pthread_mutex_unlock(&pl_ctx_mutex);
++#endif
+
+ struct pl_context *ctx = talloc_zero(NULL, struct pl_context);
+ ctx->params = *PL_DEF(params, &pl_context_default_params);
+@@ -77,10 +85,14 @@ void pl_context_destroy(struct pl_context **ctx)
+ TA_FREEP(ctx);
+
+ // Do global uninitialization only when refcount reaches 0
++#ifdef _WIN32
++ global_uninit();
++#else
+ pthread_mutex_lock(&pl_ctx_mutex);
+ if (--pl_ctx_refcount == 0)
+ global_uninit();
+ pthread_mutex_unlock(&pl_ctx_mutex);
++#endif
+ }
+
+ static FILE *default_stream(void *stream, enum pl_log_level level)
+diff --git a/src/osdep/printf_useloc_win.c b/src/osdep/printf_useloc_win.c
+index 0c4c3be..fc56f90 100644
+--- a/src/osdep/printf_useloc_win.c
++++ b/src/osdep/printf_useloc_win.c
+@@ -16,43 +16,37 @@
+ */
+
+ #include <stdlib.h>
+-#include <locale.h>
+
+ #include "osdep/printf.h"
+-
+-static _locale_t cloc;
++#include <locale.h>
++#include <windows.h>
+
+ void printf_c_init()
+ {
+- cloc = _create_locale(LC_ALL, "C");
+- if (!cloc)
+- abort();
+ }
+
+ void printf_c_uninit()
+ {
+- _free_locale(cloc);
+- cloc = (_locale_t) 0;
+ }
+
+ int vprintf_c(const char *format, va_list ap)
+ {
+- return _vprintf_l(format, cloc, ap);
++ return vprintf(format, ap);
+ }
+
+ int vfprintf_c(FILE *stream, const char *format, va_list ap)
+ {
+- return _vfprintf_l(stream, format, cloc, ap);
++ return vfprintf(stream, format, ap);
+ }
+
+ int vsprintf_c(char *str, const char *format, va_list ap)
+ {
+- return _vsprintf_l(str, format, cloc, ap);
++ return vsprintf(str, format, ap);
+ }
+
+ int vsnprintf_c(char *str, size_t size, const char *format, va_list ap)
+ {
+- return _vsnprintf_l(str, size, format, cloc, ap);
++ return vsnprintf(str, size, format, ap);
+ }
+
+ #define WRAP(fn, ...) \
+diff --git a/src/ta/ta.c b/src/ta/ta.c
+index c6f8116..dec9cb7 100644
+--- a/src/ta/ta.c
++++ b/src/ta/ta.c
+@@ -29,6 +29,10 @@
+ #define TA_MEMORY_DEBUGGING
+ #endif
+
++#ifdef _WIN32
++#undef TA_MEMORY_DEBUGGING
++#endif
++
+ struct ta_header {
+ size_t size; // size of the user allocation
+ struct ta_header *prev; // ring list containing siblings
+--
+2.11.0
+
diff --git a/contrib/src/libplacebo/rules.mak b/contrib/src/libplacebo/rules.mak
index 3f36f283c0..89fe4728fd 100644
--- a/contrib/src/libplacebo/rules.mak
+++ b/contrib/src/libplacebo/rules.mak
@@ -4,12 +4,14 @@ PLACEBO_VERSION := 0.1.2
PLACEBO_URL := https://github.com/haasn/libplacebo/archive/v$(PLACEBO_VERSION).tar.gz
PLACEBO_ARCHIVE = libplacebo-$(PLACEBO_VERSION).tar.gz
-ifndef HAVE_WIN32
+ifdef HAVE_WIN32
+LIBPLACEBO_WIN32 = HAVE_WIN32=1
+endif
+
PKGS += libplacebo
ifeq ($(call need_pkg,"libplacebo"),)
PKGS_FOUND += libplacebo
endif
-endif
PLACEBOCONF := --prefix="$(PREFIX)" \
--libdir lib \
@@ -23,6 +25,9 @@ $(TARBALLS)/$(PLACEBO_ARCHIVE):
libplacebo: $(PLACEBO_ARCHIVE) .sum-libplacebo
$(UNPACK)
$(APPLY) $(SRC)/libplacebo/0001-build-use-a-Makefile.patch
+ifdef HAVE_WIN32
+ $(APPLY) $(SRC)/libplacebo/0002-build-fix-win32-build.patch
+endif
$(MOVE)
.libplacebo: libplacebo
@@ -30,5 +35,5 @@ libplacebo: $(PLACEBO_ARCHIVE) .sum-libplacebo
# we don't want to depend on meson/ninja for VLC 3.0
#cd $< && $(HOSTVARS) meson $(PLACEBOCONF) build
#cd $< && cd build && ninja install
- cd $< && $(HOSTVARS_PIC) PREFIX=$(PREFIX) make install
+ cd $< && $(HOSTVARS_PIC) PREFIX=$(PREFIX) $(LIBPLACEBO_WIN32) make install
touch $@
More information about the vlc-commits
mailing list