summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-10-31 15:18:57 +0100
committerwm4 <wm4@nowhere>2017-10-31 15:20:09 +0100
commit7fd1359fcf72f28eb7bc24392f50f1fdbd75b956 (patch)
tree9230dbb69afdaa531bedaa0b72bcd1e5db9bee3c
parente0f42bdc5d7208a7aebc4e0f75a4f4ba18ed49f2 (diff)
downloadmpv-7fd1359fcf72f28eb7bc24392f50f1fdbd75b956.tar.bz2
mpv-7fd1359fcf72f28eb7bc24392f50f1fdbd75b956.tar.xz
videotoolbox: use generic code for dummy hwdevice init
And move the remaining code (just 2 struct constant definitions) to vd_lavc.c.
-rw-r--r--video/decode/hw_videotoolbox.c73
-rw-r--r--video/decode/vd_lavc.c21
-rw-r--r--wscript_build.py1
3 files changed, 19 insertions, 76 deletions
diff --git a/video/decode/hw_videotoolbox.c b/video/decode/hw_videotoolbox.c
deleted file mode 100644
index 833b6fdead..0000000000
--- a/video/decode/hw_videotoolbox.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * This file is part of mpv.
- *
- * Copyright (c) 2015 Sebastien Zwickert
- *
- * mpv is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * mpv is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "config.h"
-
-#include <libavutil/hwcontext.h>
-
-#include "video/decode/lavc.h"
-
-static void vt_dummy_destroy(struct mp_hwdec_ctx *ctx)
-{
- av_buffer_unref(&ctx->av_device_ref);
- talloc_free(ctx);
-}
-
-static struct mp_hwdec_ctx *vt_create_dummy(struct mpv_global *global,
- struct mp_log *plog, bool probing)
-{
- struct mp_hwdec_ctx *ctx = talloc_ptrtype(NULL, ctx);
- *ctx = (struct mp_hwdec_ctx) {
- .type = HWDEC_VIDEOTOOLBOX_COPY,
- .ctx = "dummy",
- .destroy = vt_dummy_destroy,
- };
-
- if (av_hwdevice_ctx_create(&ctx->av_device_ref, AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
- NULL, NULL, 0) < 0)
- {
- vt_dummy_destroy(ctx);
- return NULL;
- }
-
- return ctx;
-}
-
-const struct vd_lavc_hwdec mp_vd_lavc_videotoolbox = {
- .type = HWDEC_VIDEOTOOLBOX,
- .image_format = IMGFMT_VIDEOTOOLBOX,
- .generic_hwaccel = true,
- .set_hwframes = true,
- .pixfmt_map = (const enum AVPixelFormat[][2]) {
- {AV_PIX_FMT_NONE}
- },
-};
-
-const struct vd_lavc_hwdec mp_vd_lavc_videotoolbox_copy = {
- .type = HWDEC_VIDEOTOOLBOX_COPY,
- .copying = true,
- .image_format = IMGFMT_VIDEOTOOLBOX,
- .generic_hwaccel = true,
- .create_dev = vt_create_dummy,
- .set_hwframes = true,
- .pixfmt_map = (const enum AVPixelFormat[][2]) {
- {AV_PIX_FMT_NONE}
- },
- .delay_queue = HWDEC_DELAY_QUEUE_COUNT,
-};
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index e3b5018d7c..3b22159f2b 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -126,8 +126,6 @@ const struct m_sub_options vd_lavc_conf = {
extern const struct vd_lavc_hwdec mp_vd_lavc_mediacodec;
extern const struct vd_lavc_hwdec mp_vd_lavc_mediacodec_copy;
-extern const struct vd_lavc_hwdec mp_vd_lavc_videotoolbox;
-extern const struct vd_lavc_hwdec mp_vd_lavc_videotoolbox_copy;
extern const struct vd_lavc_hwdec mp_vd_lavc_dxva2;
extern const struct vd_lavc_hwdec mp_vd_lavc_dxva2_copy;
extern const struct vd_lavc_hwdec mp_vd_lavc_d3d11va;
@@ -251,6 +249,25 @@ static const struct vd_lavc_hwdec mp_vd_lavc_vdpau_copy = {
};
#endif
+#if HAVE_VIDEOTOOLBOX_HWACCEL
+static const struct vd_lavc_hwdec mp_vd_lavc_videotoolbox = {
+ .type = HWDEC_VIDEOTOOLBOX,
+ .image_format = IMGFMT_VIDEOTOOLBOX,
+ .generic_hwaccel = true,
+ .set_hwframes = true,
+};
+static const struct vd_lavc_hwdec mp_vd_lavc_videotoolbox_copy = {
+ .type = HWDEC_VIDEOTOOLBOX_COPY,
+ .copying = true,
+ .image_format = IMGFMT_VIDEOTOOLBOX,
+ .generic_hwaccel = true,
+ .create_standalone_dev = true,
+ .create_standalone_dev_type = AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
+ .set_hwframes = true,
+ .delay_queue = HWDEC_DELAY_QUEUE_COUNT,
+};
+#endif
+
static const struct vd_lavc_hwdec *const hwdec_list[] = {
#if HAVE_RPI
&mp_vd_lavc_rpi,
diff --git a/wscript_build.py b/wscript_build.py
index affb8f30d4..dbf27171d7 100644
--- a/wscript_build.py
+++ b/wscript_build.py
@@ -370,7 +370,6 @@ def build(ctx):
( "video/decode/hw_dxva2.c", "d3d9-hwaccel" ),
( "video/decode/hw_d3d11va.c", "d3d-hwaccel" ),
( "video/decode/hw_mediacodec.c", "android" ),
- ( "video/decode/hw_videotoolbox.c", "videotoolbox-hwaccel" ),
( "video/decode/vd_lavc.c" ),
( "video/filter/refqueue.c" ),
( "video/filter/vf.c" ),