summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-05-24 15:07:45 +0200
committerwm4 <wm4@nowhere>2017-05-24 15:25:48 +0200
commit83a9b0bc4840c1bb203c23194c5f07f898999034 (patch)
tree0b7047c9623e8da03b31929c84febf69abe64bed /video/out
parent2426f95e0fc232b01228457e5116b592c56b1f7f (diff)
downloadmpv-83a9b0bc4840c1bb203c23194c5f07f898999034.tar.bz2
mpv-83a9b0bc4840c1bb203c23194c5f07f898999034.tar.xz
videotoolbox: support new libavcodec API
The new API has literally no advantages (other than that we can drop mp_vt_download_image and other things later), but it's sort-of uniform with the other hwaccels. "--videotoolbox-format=no" is not supported with the new API, because it doesn't "fit in". Probably could be added later again. The iOS code change is untested (no way to test).
Diffstat (limited to 'video/out')
-rw-r--r--video/out/opengl/hwdec_ios.m12
-rw-r--r--video/out/opengl/hwdec_osx.c12
2 files changed, 24 insertions, 0 deletions
diff --git a/video/out/opengl/hwdec_ios.m b/video/out/opengl/hwdec_ios.m
index 3ab532ed02..6cf1b803bd 100644
--- a/video/out/opengl/hwdec_ios.m
+++ b/video/out/opengl/hwdec_ios.m
@@ -23,6 +23,10 @@
#include <CoreVideo/CoreVideo.h>
#include <OpenGLES/EAGL.h>
+#include <libavutil/hwcontext.h>
+
+#include "config.h"
+
#include "video/mp_image_pool.h"
#include "video/vt.h"
#include "formats.h"
@@ -77,6 +81,12 @@ static int create_hwdec(struct gl_hwdec *hw)
.download_image = mp_vt_download_image,
.ctx = &p->hwctx,
};
+
+#if HAVE_VIDEOTOOLBOX_HWACCEL_NEW
+ av_hwdevice_ctx_create(&p->hwctx.av_device_ref, AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
+ NULL, NULL, 0);
+#endif
+
hwdec_devices_add(hw->devs, &p->hwctx);
return 0;
@@ -200,6 +210,8 @@ static void destroy(struct gl_hwdec *hw)
CFRelease(p->gl_texture_cache);
p->gl_texture_cache = NULL;
+ av_buffer_unref(&p->hwctx.av_device_ref);
+
hwdec_devices_remove(hw->devs, &p->hwctx);
}
diff --git a/video/out/opengl/hwdec_osx.c b/video/out/opengl/hwdec_osx.c
index 463f9c3f14..d4594e2dcc 100644
--- a/video/out/opengl/hwdec_osx.c
+++ b/video/out/opengl/hwdec_osx.c
@@ -24,6 +24,10 @@
#include <OpenGL/OpenGL.h>
#include <OpenGL/CGLIOSurface.h>
+#include <libavutil/hwcontext.h>
+
+#include "config.h"
+
#include "video/mp_image_pool.h"
#include "video/vt.h"
#include "formats.h"
@@ -68,6 +72,12 @@ static int create(struct gl_hwdec *hw)
.download_image = mp_vt_download_image,
.ctx = &p->hwctx,
};
+
+#if HAVE_VIDEOTOOLBOX_HWACCEL_NEW
+ av_hwdevice_ctx_create(&p->hwctx.av_device_ref, AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
+ NULL, NULL, 0);
+#endif
+
hwdec_devices_add(hw->devs, &p->hwctx);
return 0;
@@ -155,6 +165,8 @@ static void destroy(struct gl_hwdec *hw)
CVPixelBufferRelease(p->pbuf);
gl->DeleteTextures(MP_MAX_PLANES, p->gl_planes);
+ av_buffer_unref(&p->hwctx.av_device_ref);
+
hwdec_devices_remove(hw->devs, &p->hwctx);
}