From 021cb2c3870b9d0b2f2e03416702fc561f160c2b Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 25 Apr 2016 11:28:49 +0200 Subject: mp_image: allow passing NULL to mp_image_new_custom_ref() A minor simplification. Most callers don't need this, and there's no good reason why the caller should provide an "initializer" like this. (This function calls mp_image_new_dummy_ref(), which has no reason for an initializer either.) --- video/d3d11va.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'video/d3d11va.c') diff --git a/video/d3d11va.c b/video/d3d11va.c index a9be571e9c..e27d7952cd 100644 --- a/video/d3d11va.c +++ b/video/d3d11va.c @@ -69,8 +69,8 @@ struct mp_image *d3d11va_new_ref(ID3D11VideoDecoderOutputView *view, ID3D11VideoDecoderOutputView_GetResource( surface->surface, (ID3D11Resource **)&surface->texture); - struct mp_image *mpi = mp_image_new_custom_ref( - &(struct mp_image){0}, surface, d3d11va_release_img); + struct mp_image *mpi = + mp_image_new_custom_ref(NULL, surface, d3d11va_release_img); if (!mpi) abort(); -- cgit v1.2.3 From 3706918311ef4cc57b1241e87dcc43d699e960f9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 27 Apr 2016 13:49:47 +0200 Subject: vo_opengl: D3D11VA + ANGLE interop This uses ID3D11VideoProcessor to convert the video to a RGBA surface, which is then bound to ANGLE. Currently ANGLE does not provide any way to bind nv12 surfaces directly, so this will have to do. ID3D11VideoContext1 would give us slightly more control about the colorspace conversion, though it's still not good, and not available in MinGW headers yet. The video processor is created lazily, because we need to have the coded frame size, of which AVFrame and mp_image have no concept of. Doing the creation lazily is less of a pain than somehow hacking the coded frame size into mp_image. I'm not really sure how ID3D11VideoProcessorInputView is supposed to work. We recreate it on every frame, which is simple and hopefully doesn't affect performance. --- video/d3d11va.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'video/d3d11va.c') diff --git a/video/d3d11va.c b/video/d3d11va.c index e27d7952cd..e64c26191c 100644 --- a/video/d3d11va.c +++ b/video/d3d11va.c @@ -21,6 +21,7 @@ struct d3d11va_surface { HMODULE d3d11_dll; ID3D11Texture2D *texture; + int subindex; ID3D11VideoDecoderOutputView *surface; }; @@ -38,6 +39,14 @@ ID3D11Texture2D *d3d11_texture_in_mp_image(struct mp_image *mpi) return surface->texture; } +int d3d11_subindex_in_mp_image(struct mp_image *mpi) +{ + if (!mpi || mpi->imgfmt != IMGFMT_D3D11VA) + return -1; + struct d3d11va_surface *surface = (void *)mpi->planes[0]; + return surface->subindex; +} + static void d3d11va_release_img(void *arg) { struct d3d11va_surface *surface = arg; @@ -69,6 +78,10 @@ struct mp_image *d3d11va_new_ref(ID3D11VideoDecoderOutputView *view, ID3D11VideoDecoderOutputView_GetResource( surface->surface, (ID3D11Resource **)&surface->texture); + D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC surface_desc; + ID3D11VideoDecoderOutputView_GetDesc(surface->surface, &surface_desc); + surface->subindex = surface_desc.Texture2D.ArraySlice; + struct mp_image *mpi = mp_image_new_custom_ref(NULL, surface, d3d11va_release_img); if (!mpi) -- cgit v1.2.3 From dff33893f2ea91f425bceeec6596556d569e0370 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 27 Apr 2016 14:03:30 +0200 Subject: d3d11va: store texture/subindex in IMGFMT_D3D11VA plane pointers Basically this gets rid of the need for the accessors in d3d11va.h, and the code can be cleaned up a little bit. Note that libavcodec only defines a ID3D11VideoDecoderOutputView pointer in the last plane pointers, but it tolerates/passes through the other plane pointers we set. --- video/d3d11va.c | 99 --------------------------------------------------------- 1 file changed, 99 deletions(-) delete mode 100644 video/d3d11va.c (limited to 'video/d3d11va.c') diff --git a/video/d3d11va.c b/video/d3d11va.c deleted file mode 100644 index e64c26191c..0000000000 --- a/video/d3d11va.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of mpv. - * - * 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 . - */ - -#include "mp_image.h" -#include "d3d11va.h" - -struct d3d11va_surface { - HMODULE d3d11_dll; - ID3D11Texture2D *texture; - int subindex; - ID3D11VideoDecoderOutputView *surface; -}; - -ID3D11VideoDecoderOutputView *d3d11_surface_in_mp_image(struct mp_image *mpi) -{ - return mpi && mpi->imgfmt == IMGFMT_D3D11VA ? - (ID3D11VideoDecoderOutputView *)mpi->planes[3] : NULL; -} - -ID3D11Texture2D *d3d11_texture_in_mp_image(struct mp_image *mpi) -{ - if (!mpi || mpi->imgfmt != IMGFMT_D3D11VA) - return NULL; - struct d3d11va_surface *surface = (void *)mpi->planes[0]; - return surface->texture; -} - -int d3d11_subindex_in_mp_image(struct mp_image *mpi) -{ - if (!mpi || mpi->imgfmt != IMGFMT_D3D11VA) - return -1; - struct d3d11va_surface *surface = (void *)mpi->planes[0]; - return surface->subindex; -} - -static void d3d11va_release_img(void *arg) -{ - struct d3d11va_surface *surface = arg; - if (surface->surface) - ID3D11VideoDecoderOutputView_Release(surface->surface); - - if (surface->texture) - ID3D11Texture2D_Release(surface->texture); - - if (surface->d3d11_dll) - FreeLibrary(surface->d3d11_dll); - - talloc_free(surface); -} - -struct mp_image *d3d11va_new_ref(ID3D11VideoDecoderOutputView *view, - int w, int h) -{ - if (!view) - return NULL; - struct d3d11va_surface *surface = talloc_zero(NULL, struct d3d11va_surface); - - surface->d3d11_dll = LoadLibrary(L"d3d11.dll"); - if (!surface->d3d11_dll) - goto fail; - - surface->surface = view; - ID3D11VideoDecoderOutputView_AddRef(surface->surface); - ID3D11VideoDecoderOutputView_GetResource( - surface->surface, (ID3D11Resource **)&surface->texture); - - D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC surface_desc; - ID3D11VideoDecoderOutputView_GetDesc(surface->surface, &surface_desc); - surface->subindex = surface_desc.Texture2D.ArraySlice; - - struct mp_image *mpi = - mp_image_new_custom_ref(NULL, surface, d3d11va_release_img); - if (!mpi) - abort(); - - mp_image_setfmt(mpi, IMGFMT_D3D11VA); - mp_image_set_size(mpi, w, h); - mpi->planes[0] = (void *)surface; - mpi->planes[3] = (void *)surface->surface; - - return mpi; -fail: - d3d11va_release_img(surface); - return NULL; -} -- cgit v1.2.3