summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-04-20 19:28:38 +0200
committerJan Ekström <jeebjp@gmail.com>2018-04-29 02:21:32 +0300
commit9825bbb8cf5090bbc9bd652687f2f196de54e7f7 (patch)
tree706c0a709de67b1593ab7e7f803e8d0c3d8cb570
parent67689ff6b42173b72bffecf23de3507e3ab605b0 (diff)
downloadmpv-9825bbb8cf5090bbc9bd652687f2f196de54e7f7.tar.bz2
mpv-9825bbb8cf5090bbc9bd652687f2f196de54e7f7.tar.xz
vo_libmpv: add support for DR
With all the preparation work done, this only has to do the annoying dance of passing it through all the damn layers.
-rw-r--r--video/out/gpu/libmpv_gpu.c9
-rw-r--r--video/out/libmpv.h3
-rw-r--r--video/out/vo_libmpv.c26
3 files changed, 38 insertions, 0 deletions
diff --git a/video/out/gpu/libmpv_gpu.c b/video/out/gpu/libmpv_gpu.c
index d08b3a56b9..3674d678c7 100644
--- a/video/out/gpu/libmpv_gpu.c
+++ b/video/out/gpu/libmpv_gpu.c
@@ -182,6 +182,14 @@ static int render(struct render_backend *ctx, mpv_render_param *params,
return 0;
}
+static struct mp_image *get_image(struct render_backend *ctx, int imgfmt,
+ int w, int h, int stride_align)
+{
+ struct priv *p = ctx->priv;
+
+ return gl_video_get_image(p->renderer, imgfmt, w, h, stride_align);
+}
+
static void destroy(struct render_backend *ctx)
{
struct priv *p = ctx->priv;
@@ -208,5 +216,6 @@ const struct render_backend_fns render_backend_gpu = {
.resize = resize,
.get_target_size = get_target_size,
.render = render,
+ .get_image = get_image,
.destroy = destroy,
};
diff --git a/video/out/libmpv.h b/video/out/libmpv.h
index ae154bbd24..4544a278db 100644
--- a/video/out/libmpv.h
+++ b/video/out/libmpv.h
@@ -52,6 +52,9 @@ struct render_backend_fns {
void (*reconfig)(struct render_backend *ctx, struct mp_image_params *params);
// Like VOCTRL_RESET.
void (*reset)(struct render_backend *ctx);
+ // Like vo_driver.get_image().
+ struct mp_image *(*get_image)(struct render_backend *ctx, int imgfmt,
+ int w, int h, int stride_align);
// This has two purposes: 1. set queue attributes on VO, 2. update the
// renderer's OSD pointer. Keep in mind that as soon as the caller releases
// the renderer lock, the VO pointer can become invalid. The OSD pointer
diff --git a/video/out/vo_libmpv.c b/video/out/vo_libmpv.c
index 75ac514595..838c6ac86d 100644
--- a/video/out/vo_libmpv.c
+++ b/video/out/vo_libmpv.c
@@ -17,6 +17,7 @@
#include "options/m_config.h"
#include "options/options.h"
#include "aspect.h"
+#include "dr_helper.h"
#include "vo.h"
#include "video/mp_image.h"
#include "sub/osd.h"
@@ -60,6 +61,7 @@ struct mpv_render_context {
// --- Immutable after init
bool advanced_control;
struct mp_dispatch_queue *dispatch; // NULL if advanced_control disabled
+ struct dr_helper *dr; // NULL if advanced_control disabled
pthread_mutex_t control_lock;
// --- Protected by control_lock
@@ -137,6 +139,14 @@ static void dispatch_wakeup(void *ptr)
update(ctx);
}
+static struct mp_image *render_get_image(void *ptr, int imgfmt, int w, int h,
+ int stride_align)
+{
+ struct mpv_render_context *ctx = ptr;
+
+ return ctx->renderer->fns->get_image(ctx->renderer, imgfmt, w, h, stride_align);
+}
+
int mpv_render_context_create(mpv_render_context **res, mpv_handle *mpv,
mpv_render_param *params)
{
@@ -190,6 +200,9 @@ int mpv_render_context_create(mpv_render_context **res, mpv_handle *mpv,
ctx->renderer->fns->check_format(ctx->renderer, n);
}
+ if (ctx->renderer->fns->get_image && ctx->dispatch)
+ ctx->dr = dr_helper_create(ctx->dispatch, render_get_image, ctx);
+
if (!mp_set_main_render_context(ctx->client_api, ctx, true)) {
MP_ERR(ctx, "There is already a mpv_render_context set.\n");
mpv_render_context_free(ctx);
@@ -277,6 +290,7 @@ void mpv_render_context_free(mpv_render_context *ctx)
ctx->renderer->fns->destroy(ctx->renderer);
talloc_free(ctx->renderer->priv);
talloc_free(ctx->renderer);
+ talloc_free(ctx->dr);
talloc_free(ctx->dispatch);
pthread_cond_destroy(&ctx->update_cond);
@@ -548,6 +562,17 @@ static int control(struct vo *vo, uint32_t request, void *data)
return r;
}
+static struct mp_image *get_image(struct vo *vo, int imgfmt, int w, int h,
+ int stride_align)
+{
+ struct vo_priv *p = vo->priv;
+
+ if (p->ctx->dr)
+ return dr_helper_get_image(p->ctx->dr, imgfmt, w, h, stride_align);
+
+ return NULL;
+}
+
static int reconfig(struct vo *vo, struct mp_image_params *params)
{
struct vo_priv *p = vo->priv;
@@ -619,6 +644,7 @@ const struct vo_driver video_out_libmpv = {
.query_format = query_format,
.reconfig = reconfig,
.control = control,
+ .get_image_ts = get_image,
.draw_frame = draw_frame,
.flip_page = flip_page,
.uninit = uninit,