summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAman Gupta <aman@tmm1.net>2017-12-18 17:20:41 -0800
committerJames Ross-Gowan <rossy@jrg.systems>2017-12-20 15:45:55 +1100
commit7e2252688b786eb51fb234141b264eaa7889ff90 (patch)
treee3f62073901ccee71bce14d6972d78ec2b22b79d
parenteb619d0f5757e011df43c2a1279fd06449ee885c (diff)
downloadmpv-7e2252688b786eb51fb234141b264eaa7889ff90.tar.bz2
mpv-7e2252688b786eb51fb234141b264eaa7889ff90.tar.xz
vo_mediacodec_embed: implement hwcontext
Fixes vo_mediacodec_embed, which was broken in 80359c6615658f2784
-rw-r--r--DOCS/man/options.rst1
-rw-r--r--video/out/vo_mediacodec_embed.c30
-rw-r--r--wscript2
3 files changed, 31 insertions, 2 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 39c143b228..77b402590d 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -2540,7 +2540,6 @@ Window
value cast to ``intptr_t``. Use with ``--vo=mediacodec_embed`` and
``--hwdec=mediacodec`` for direct rendering using MediaCodec, or with
``--vo=gpu --gpu-context=android`` (with or without ``--hwdec=mediacodec-copy``).
- This is currently broken.
``--no-window-dragging``
Don't move the window when clicking on it and moving the mouse pointer.
diff --git a/video/out/vo_mediacodec_embed.c b/video/out/vo_mediacodec_embed.c
index ff1e687f89..63975e9408 100644
--- a/video/out/vo_mediacodec_embed.c
+++ b/video/out/vo_mediacodec_embed.c
@@ -16,17 +16,44 @@
*/
#include <libavcodec/mediacodec.h>
+#include <libavutil/hwcontext.h>
+#include <libavutil/hwcontext_mediacodec.h>
#include "common/common.h"
#include "vo.h"
#include "video/mp_image.h"
+#include "video/hwdec.h"
struct priv {
struct mp_image *next_image;
+ struct mp_hwdec_ctx hwctx;
};
+static AVBufferRef *create_mediacodec_device_ref(struct vo *vo)
+{
+ AVBufferRef *device_ref = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_MEDIACODEC);
+ if (!device_ref)
+ return NULL;
+
+ AVHWDeviceContext *ctx = (void *)device_ref->data;
+ AVMediaCodecDeviceContext *hwctx = ctx->hwctx;
+ hwctx->surface = (void *)(intptr_t)(vo->opts->WinID);
+
+ if (av_hwdevice_ctx_init(device_ref) < 0)
+ av_buffer_unref(&device_ref);
+
+ return device_ref;
+}
+
static int preinit(struct vo *vo)
{
+ struct priv *p = vo->priv;
+ vo->hwdec_devs = hwdec_devices_create();
+ p->hwctx = (struct mp_hwdec_ctx){
+ .driver_name = "mediacodec_embed",
+ .av_device_ref = create_mediacodec_device_ref(vo),
+ };
+ hwdec_devices_add(vo->hwdec_devs, &p->hwctx);
return 0;
}
@@ -72,6 +99,9 @@ static void uninit(struct vo *vo)
{
struct priv *p = vo->priv;
mp_image_unrefp(&p->next_image);
+
+ hwdec_devices_remove(vo->hwdec_devs, &p->hwctx);
+ av_buffer_unref(&p->hwctx.av_device_ref);
}
const struct vo_driver video_out_mediacodec_embed = {
diff --git a/wscript b/wscript
index a79e0df282..4a1959b2a6 100644
--- a/wscript
+++ b/wscript
@@ -412,7 +412,7 @@ iconv support use --disable-iconv.",
]
ffmpeg_pkg_config_checks = [
- 'libavutil', '>= 56.0.100',
+ 'libavutil', '>= 56.6.100',
'libavcodec', '>= 58.7.100',
'libavformat', '>= 58.0.102',
'libswscale', '>= 5.0.101',