151ef96e76
- Add mpv-vaapi2.patch: Fix build iwth vaapi 2.0. The patch is a backport of the commits 93c52b, f35126 and 2ecf24. - Conditionalize use of %desktop_database_post/postun and icon_theme_cache_post/postun to suse_version < 1330. The functionality has since been replaced by file triggers and the macros expand to %nil. OBS-URL: https://build.opensuse.org/request/show/542474 OBS-URL: https://build.opensuse.org/package/show/multimedia:apps/mpv?expand=0&rev=125
146 lines
5.1 KiB
Diff
146 lines
5.1 KiB
Diff
From 6265a2d7793c52b16f48f6f8db5d8833d350abc5 Mon Sep 17 00:00:00 2001
|
|
From: wm4 <wm4@nowhere>
|
|
Date: Fri, 29 Sep 2017 16:51:30 +0200
|
|
Subject: [PATCH] vaapi: minor changes
|
|
|
|
This is for relicensing. Some of this code is loosely based on
|
|
vo_vaapi.c from the original MPlayer-vaapi patches. Most of the code has
|
|
changed, and only the initialization code and check_status() look
|
|
remotely similar. The initialization code is changed to be like Libav's
|
|
(hwcontext_vaapi.c). check_va_status() is just a C idiom, but to play it
|
|
safe, we'll either drop it from LGPL code (or recreate it).
|
|
|
|
vaapi.c still contains plenty of code from the original patches, but the
|
|
next commits will move them out of the LGPL code paths.
|
|
---
|
|
video/vaapi.c | 14 +++++++-------
|
|
1 file changed, 7 insertions(+), 7 deletions(-)
|
|
|
|
Index: mpv-0.27.0/video/vaapi.c
|
|
===================================================================
|
|
--- mpv-0.27.0.orig/video/vaapi.c
|
|
+++ mpv-0.27.0/video/vaapi.c
|
|
@@ -30,15 +30,6 @@
|
|
#include <libavutil/hwcontext.h>
|
|
#include <libavutil/hwcontext_vaapi.h>
|
|
|
|
-bool check_va_status(struct mp_log *log, VAStatus status, const char *msg)
|
|
-{
|
|
- if (status != VA_STATUS_SUCCESS) {
|
|
- mp_err(log, "%s: %s\n", msg, vaErrorStr(status));
|
|
- return false;
|
|
- }
|
|
- return true;
|
|
-}
|
|
-
|
|
int va_get_colorspace_flag(enum mp_csp csp)
|
|
{
|
|
switch (csp) {
|
|
@@ -112,9 +103,27 @@ static void va_get_formats(struct mp_vaa
|
|
ctx->image_formats = formats;
|
|
}
|
|
|
|
-// VA message callbacks are global and do not have a context parameter, so it's
|
|
-// impossible to know from which VADisplay they originate. Try to route them
|
|
-// to existing mpv/libmpv instances within this process.
|
|
+#if VA_CHECK_VERSION(1, 0, 0)
|
|
+static void va_message_callback(void *context, const char *msg, int mp_level)
|
|
+{
|
|
+ struct mp_vaapi_ctx *res = context;
|
|
+ mp_msg(res->log, mp_level, "libva: %s", msg);
|
|
+}
|
|
+
|
|
+static void va_error_callback(void *context, const char *msg)
|
|
+{
|
|
+ va_message_callback(context, msg, MSGL_ERR);
|
|
+}
|
|
+
|
|
+static void va_info_callback(void *context, const char *msg)
|
|
+{
|
|
+ va_message_callback(context, msg, MSGL_V);
|
|
+}
|
|
+#else
|
|
+// Pre-libva2 VA message callbacks are global and do not have a context
|
|
+// parameter, so it's impossible to know from which VADisplay they
|
|
+// originate. Try to route them to existing mpv/libmpv instances within
|
|
+// this process.
|
|
static pthread_mutex_t va_log_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
static struct mp_vaapi_ctx **va_mpv_clients;
|
|
static int num_va_mpv_clients;
|
|
@@ -149,6 +158,7 @@ static void va_info_callback(const char
|
|
{
|
|
va_message_callback(msg, MSGL_V);
|
|
}
|
|
+#endif
|
|
|
|
static void open_lavu_vaapi_device(struct mp_vaapi_ctx *ctx)
|
|
{
|
|
@@ -181,6 +191,10 @@ struct mp_vaapi_ctx *va_initialize(VADis
|
|
},
|
|
};
|
|
|
|
+#if VA_CHECK_VERSION(1, 0, 0)
|
|
+ vaSetErrorCallback(display, va_error_callback, res);
|
|
+ vaSetInfoCallback(display, va_info_callback, res);
|
|
+#else
|
|
pthread_mutex_lock(&va_log_mutex);
|
|
MP_TARRAY_APPEND(NULL, va_mpv_clients, num_va_mpv_clients, res);
|
|
pthread_mutex_unlock(&va_log_mutex);
|
|
@@ -191,15 +205,16 @@ struct mp_vaapi_ctx *va_initialize(VADis
|
|
vaSetErrorCallback(va_error_callback);
|
|
vaSetInfoCallback(va_info_callback);
|
|
#endif
|
|
+#endif
|
|
|
|
- int major_version, minor_version;
|
|
- int status = vaInitialize(display, &major_version, &minor_version);
|
|
- if (status != VA_STATUS_SUCCESS && probing)
|
|
- goto error;
|
|
- if (!check_va_status(res->log, status, "vaInitialize()"))
|
|
+ int major, minor;
|
|
+ int status = vaInitialize(display, &major, &minor);
|
|
+ if (status != VA_STATUS_SUCCESS) {
|
|
+ if (!probing)
|
|
+ MP_ERR(res, "Failed to initialize VAAPI: %s\n", vaErrorStr(status));
|
|
goto error;
|
|
-
|
|
- MP_VERBOSE(res, "VA API version %d.%d\n", major_version, minor_version);
|
|
+ }
|
|
+ MP_VERBOSE(res, "Initialized VAAPI: version %d.%d\n", major, minor);
|
|
|
|
va_get_formats(res);
|
|
if (!res->image_formats)
|
|
@@ -231,6 +246,7 @@ void va_destroy(struct mp_vaapi_ctx *ctx
|
|
if (ctx->destroy_native_ctx)
|
|
ctx->destroy_native_ctx(ctx->native_ctx);
|
|
|
|
+#if !VA_CHECK_VERSION(1, 0, 0)
|
|
pthread_mutex_lock(&va_log_mutex);
|
|
for (int n = 0; n < num_va_mpv_clients; n++) {
|
|
if (va_mpv_clients[n] == ctx) {
|
|
@@ -241,6 +257,7 @@ void va_destroy(struct mp_vaapi_ctx *ctx
|
|
if (num_va_mpv_clients == 0)
|
|
TA_FREEP(&va_mpv_clients); // avoid triggering leak detectors
|
|
pthread_mutex_unlock(&va_log_mutex);
|
|
+#endif
|
|
|
|
talloc_free(ctx);
|
|
}
|
|
Index: mpv-0.27.0/video/vaapi.h
|
|
===================================================================
|
|
--- mpv-0.27.0.orig/video/vaapi.h
|
|
+++ mpv-0.27.0/video/vaapi.h
|
|
@@ -41,9 +41,9 @@ struct mp_vaapi_ctx {
|
|
void (*destroy_native_ctx)(void *native_ctx);
|
|
};
|
|
|
|
-bool check_va_status(struct mp_log *log, VAStatus status, const char *msg);
|
|
-
|
|
-#define CHECK_VA_STATUS(ctx, msg) check_va_status((ctx)->log, status, msg)
|
|
+#define CHECK_VA_STATUS(ctx, msg) \
|
|
+ (status == VA_STATUS_SUCCESS ? true \
|
|
+ : (MP_ERR(ctx, "%s failed (%s)\n", msg, vaErrorStr(status)), false))
|
|
|
|
int va_get_colorspace_flag(enum mp_csp csp);
|
|
|