summaryrefslogtreecommitdiffstats
path: root/video/decode
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-05-10 20:37:03 +0200
committerwm4 <wm4@nowhere>2016-05-10 21:06:34 +0200
commita3d416c3d3f578e9359fcc145989b26ccf58d190 (patch)
tree3bfc4a1fc51e9fc82b74bd5b81b3f45a15d16799 /video/decode
parent4b3faf9dc1487d3a84ecc605e88452b30bc65d13 (diff)
downloadmpv-a3d416c3d3f578e9359fcc145989b26ccf58d190.tar.bz2
mpv-a3d416c3d3f578e9359fcc145989b26ccf58d190.tar.xz
vo_opengl: d3d11egl: native NV12 sampling support
This uses EGL_ANGLE_stream_producer_d3d_texture_nv12 and related extensions to map the D3D textures coming from the hardware decoder directly in GL. In theory this would be trivial to achieve, but unfortunately ANGLE does not have a mechanism to "import" D3D textures as GL textures. Instead, an awkward mechanism via EGL_KHR_stream was implemented, which involves at least 5 extensions and a lot of glue code. (Even worse than VAAPI EGL interop, and very far from the simplicity you get on OSX.) The ANGLE mechanism so far supports only the NV12 texture format, which means 10 bit won't work. It also does not work in ES3 mode yet. For these reasons, the "old" ID3D11VideoProcessor code is kept and used as a fallback.
Diffstat (limited to 'video/decode')
-rw-r--r--video/decode/d3d11va.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/video/decode/d3d11va.c b/video/decode/d3d11va.c
index 1626626767..9e300b1620 100644
--- a/video/decode/d3d11va.c
+++ b/video/decode/d3d11va.c
@@ -187,6 +187,29 @@ static const struct d3d_decoded_format d3d11_formats[] = {
};
#undef DFMT
+// Update hw_subfmt to the underlying format. Needed because AVFrame does not
+// have such an attribute, so it can't be passed through, and is updated here
+// instead. (But in the future, AVHWFramesContext could be used.)
+static struct mp_image *d3d11va_update_image_attribs(struct lavc_ctx *s,
+ struct mp_image *img)
+{
+ ID3D11Texture2D *texture = (void *)img->planes[1];
+
+ if (!texture)
+ return img;
+
+ D3D11_TEXTURE2D_DESC texture_desc;
+ ID3D11Texture2D_GetDesc(texture, &texture_desc);
+ for (int n = 0; n < MP_ARRAY_SIZE(d3d11_formats); n++) {
+ if (d3d11_formats[n].dxfmt == texture_desc.Format) {
+ img->params.hw_subfmt = d3d11_formats[n].mpfmt;
+ break;
+ }
+ }
+
+ return img;
+}
+
static bool d3d11_format_supported(struct lavc_ctx *s, const GUID *guid,
const struct d3d_decoded_format *format)
{
@@ -274,7 +297,7 @@ static int d3d11va_init_decoder(struct lavc_ctx *s, int w, int h)
.MiscFlags = 0,
.ArraySize = n_surfaces,
.Usage = D3D11_USAGE_DEFAULT,
- .BindFlags = D3D11_BIND_DECODER,
+ .BindFlags = D3D11_BIND_DECODER | D3D11_BIND_SHADER_RESOURCE,
.CPUAccessFlags = 0,
};
hr = ID3D11Device_CreateTexture2D(p->device, &tex_desc, NULL, &texture);
@@ -555,6 +578,7 @@ const struct vd_lavc_hwdec mp_vd_lavc_d3d11va = {
.uninit = d3d11va_uninit,
.init_decoder = d3d11va_init_decoder,
.allocate_image = d3d11va_allocate_image,
+ .process_image = d3d11va_update_image_attribs,
};
const struct vd_lavc_hwdec mp_vd_lavc_d3d11va_copy = {