summaryrefslogtreecommitdiffstats
path: root/video/decode/dxva2.c
Commit message (Collapse)AuthorAgeFilesLines
* win32: build with -DINITGUIDJames Ross-Gowan2016-09-281-2/+0
| | | | | | | | | | | | We always want to use __declspec(selectany) to declare GUIDs, but manually including <initguid.h> in every file that used GUIDs was error-prone. Since all <initguid.h> does is define INITGUID and include <guiddef.h>, we can remove all references to <initguid.h> and just compile with -DINITGUID to get the same effect. Also, this partially reverts 622bcb0 by re-adding libuuid.a to the build, since apparently some GUIDs (such as GUID_NULL) are not declared in the source file, even when INITGUID is set.
* dxva2: remove dead code in failure caseJames Ross-Gowan2016-06-071-3/+0
| | | | | This was made unnecessary by a02d77b, since the only way the function could fail was by failing to add a reference to the DirectX DLLs.
* d3d: simplify DLL loadingwm42016-05-171-31/+7
| | | | | | | | | | | | | | | For some reason, the d3d9/dxva2/d3d11 DLLs are still optional. But we don't need to try so hard to keep exact references. In fact, there's no reason to unload them at all. So load them once in a central place. For simplicity, the d3d9/d3d11 backends both load all DLLs. (They will error out only if the required DLLs could not be loaded.) In theory, we could just call LoadLibrary multiple times (without calling FreeLibrary), but I'm slightly worried that this could be detected as a "bug", or that the reference count could even have a low static limit that could be hit soon.
* video: merge dxva2 source fileswm42016-05-171-2/+62
| | | | | | | video/dxva2.c exported only 2 functions, both used only by video/decode/dxva2.c. The same was already done for d3d11.
* video: add --hwdec=auto-copy modewm42016-05-111-0/+1
| | | | | | | | This uses the normal autoprobing rules like "auto", but rejects anything that isn't flagged as copying data back to system memory. The chunk in command.c was dead code, so remove it instead of updating it.
* video: refactor how VO exports hwdec device handleswm42016-05-091-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | The main change is with video/hwdec.h. mp_hwdec_info is made opaque (and renamed to mp_hwdec_devices). Its accessors are mainly thread-safe (or documented where not), which makes the whole thing saner and cleaner. In particular, thread-safety rules become less subtle and more obvious. The new internal API makes it easier to support multiple OpenGL interop backends. (Although this is not done yet, and it's not clear whether it ever will.) This also removes all the API-specific fields from mp_hwdec_ctx and replaces them with a "ctx" field. For d3d in particular, we drop the mp_d3d_ctx struct completely, and pass the interfaces directly. Remove the emulation checks from vaapi.c and vdpau.c; they are pointless, and the checks that matter are done on the VO layer. The d3d hardware decoders might slightly change behavior: dxva2-copy will not use the VO device anymore if the VO supports proper interop. This pretty much assumes that any in such cases the VO will not use any form of exclusive mode, which makes using the VO device in copy mode unnecessary. This is a big refactor. Some things may be untested and could be broken.
* win32: replace libuuid.a usage with initguid.hJames Ross-Gowan2016-05-011-0/+2
| | | | | | | | | | | | | | | Including initguid.h at the top of a file that uses references to GUIDs causes the GUIDs to be declared globally with __declspec(selectany). The 'selectany' attribute tells the linker to consolidate multiple definitions of each GUID, which would be great except that, in Cygwin and MinGW GCC 6.1, this method of linking makes the GUIDs conflict with the ones declared in libuuid.a. Since initguid.h obsoletes libuuid.a in modern compilers that support __declspec(selectany), add initguid.h to all files that use GUIDs and remove libuuid.a from the build. Fixes #3097
* d3d11va, dxva2: return the format struct directlywm42016-04-291-4/+4
| | | | Slight simplification, IMHO.
* d3d11va, dxva2: simplify decoder selectionwm42016-04-291-27/+15
| | | | | | | | In particular, this moves the depth test to common code. Should be functionally equivalent, except that for DXVA2, the IDirectXVideoDecoderService_GetDecoderRenderTargets API is called more often potentially.
* vo_opengl: D3D11VA + ANGLE interopwm42016-04-271-1/+2
| | | | | | | | | | | | | | | | | | | 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.
* dxva2: fix missing newline in error messageKevin Mitchell2016-04-181-1/+1
|
* d3dva: include selected decoder and format in verbose outputKevin Mitchell2016-04-171-0/+3
|
* vd_lavc: let hardware decoder request delaying frames explicitlywm42016-04-071-0/+1
| | | | | | | | | | Until now, the presence of the process_image() callback was used to set a delay queue with a hardcoded size. Change this to a vd_lavc_hwdec field instead, so the decoder can explicitly set this if it's really needed. Do this so process_image() can be used in the VideoToolbox glue code for something entirely unrelated.
* vd_lavc: fix codec vs. decoder confusionwm42016-04-071-2/+2
| | | | | | | | | | Some functions which expected a codec name (i.e. the name of the video format itself) were passed a decoder name. Most "native" libavcodec decoders have the same name as the codec, so this was never an issue. This should mean that e.g. using "--vd=lavc:h264_mmal --hwdec=mmal" should now actually enable native surface mode (instead of doing copy- back).
* dxva2: rewrite to use shared code with d3d11vaKevin Mitchell2016-03-301-494/+350
| | | | This is basically a full rewrite to make it look more like d3d11va.c
* dxva2: prevent outputting native surfaces with HWDEC_DXVA2_COPY (again)wm42016-03-171-1/+2
| | | | Not quite sure when/why exactly this was broken.
* dxva2: fix autoprobingwm42016-02-191-1/+6
| | | | | | | | | | | Doing --hwdec=auto ends up picking dxva2, creating a decoder, and then sending D3D frames down the video chain, which immediately fails and falls back to software. Consider dxva2 only if the VO provides a context. If this fails, autoprobing will proceed to try dxva2-copy as usual. Fixes #2844.
* dxva2: add interop (non-copyback) hwdec_typeKevin Mitchell2016-02-171-2/+14
| | | | | This always falls back to software decoding right now. VO support will be added in future commits.
* dxva2: avoid using AV_PIX_FMT_P010 directlywm42016-02-171-3/+4
| | | | | | | The new code is essentially equivalent, but compiles against older ffmpeg. Fixes #2832.
* dxva2: use mp_HESULT_to_str on FAILED(hr)Kevin Mitchell2016-02-161-11/+20
|
* dxva2: use mp_image_pool_get_no_alloc for decoder imagesKevin Mitchell2016-02-161-1/+2
| | | | | This makes it more explicit that the pool doesn't ever actually do any allocating itself.
* dxva2: another attempt at using mp_image poolKevin Mitchell2016-02-161-31/+34
| | | | | | | | | | Apparently, some drivers require you to allocate all of the decoder d3d surfaces at once. This commit changes the strategy from allocating surfaces as needed via mp_image_pool_set_allocator, to allocating all the surfaces in one call to IDirectXVideoDecoderService_CreateSurface and adding them to the pool with mp_image_pool_add. fixes #2822
* dxva2: support HEVC Main 10wm42016-02-151-8/+35
|
* dxva2: use mp_image pool for d3d surfacesKevin Mitchell2016-02-141-131/+65
| | | | | | | | | | | | | This is required so that the individual surfaces can pass beyond the dxva2 decoder and be passed to the vo. This also adds additional data to mp_image->planes[0] for IMGFMT_DXVA2, which is required for maintaining and releasing the surface even if the decoder code is uninited. The IDirectXVideoDecoder itself is encapsulated together with its surface pool and configuration in a dxva2_decoder structure whose creation and destruction is managed by talloc.
* dxva2: remove unused structure membersKevin Mitchell2016-02-141-5/+1
|
* dxva2: streamline number of surface calculationKevin Mitchell2016-02-141-9/+2
| | | | | use hwdec_get_max_refs and put the "4 base work surfaces" into ADDITIONAL_SURFACES macro.
* video/decode/dxva2.c: GUID_NULL conflictskwkam2016-02-061-1/+1
| | | | | | | GUID_NULL is defined in <ks.h> gcc 6.0 refuses to link the executable because of that Signed-off-by: wm4 <wm4@nowhere>
* vd_lavc: delay images before reading them backwm42016-01-251-1/+3
| | | | Facilitates hardware pipelining in particular with nvidia/dxva.
* dxva2: log more debug infoswm42016-01-111-11/+41
| | | | | Dump the complete list of decoders and image formats. If it's a decoder we know, add a stringified name.
* dxva2: reject 10 bit HEVCwm42015-11-231-0/+4
| | | | | | | | | 10 bit HEVC would require DXVA2_ModeHEVC_VLD_Main10, and most a different surface type (judging by lavfsplitter source code, both P010 and P016 would work). Since I'm unable to test this stuff, exclude 10 bit for now. See #2516.
* video: refactor GPU memcpy usagewm42015-09-251-57/+5
| | | | | | | | | | | | | | | | | Make the GPU memcpy from the dxva2 code generally useful to other parts of the player. We need to check at configure time whether SSE intrinsics work at all. (At least in this form, they won't work on clang, for example. It also won't work on non-x86.) Introduce a mp_image_copy_gpu(), and make the dxva2 code use it. Do some awkward stuff to share the existing code used by mp_image_copy(). I'm hoping that FFmpeg will sooner or later provide a function like this, so we can remove most of this again. (There is a patch, bit it's stuck in limbo since forever.) All this is used by the following commit.
* vd_lavc: remove unneeded hwdec parameterswm42015-08-191-5/+2
| | | | | | | All hwdec backends now use a single pixel format, and the format is always checked. Also, the init_decoder callback is now mandatory.
* win32: revert wchar_t changeswm42015-08-011-2/+2
| | | | | | | | | | | Revert "win32: more wchar_t -> WCHAR replacements" Revert "win32: replace wchar_t with WCHAR" Doing a "partial" port of this makes no sense anymore from my perspective. Revert the changes, as they're confusing without context, maintenance, and progress. These changes were a bit premature anyway, and might actually cause other issues (locale neutrality etc. as it was pointed out).
* win32: more wchar_t -> WCHAR replacementswm42015-07-301-2/+2
| | | | | | | | | | | | | This was essentially missing from commit 0b52ac8a. Since L"..." string literals have the type wchar_t[], we can't use them for UTF-16 strings. Use C11 u"..." string literals instead. These have the type char16_t[], but we simply assume char16_t is the same underlying type as WCHAR. In practice, they're both unsigned short. For this reason use -std=c11 on Windows. Since Windows is a "special" environment (we require either MinGW or Cygwin), we don't need to worry too much about compiler compatibility.
* dxva2: fix handling of cropped videowm42015-07-061-1/+5
| | | | | | Basically, we need to make sure to allocate enough data for the pretty dumb copy_nv12 function. (It could be avoided by making the function less dumb, but this fix is simpler.)
* client API, dxva2: add a workaround for OpenGL fullscreen issueswm42015-07-031-0/+1
| | | | | | | | | This is basically a hack for drivers which prevent the mpv DXVA2 decoder glue from working if OpenGL is in fullscreen mode. Since it doesn't add any "hard" new API to the client API, some of the code would be required for a true zero-copy hw decoding pipeline, and sine it isn't too much code after all, this is probably acceptable.
* vo_direct3d, dxva2: use the same D3D devicewm42015-07-031-0/+10
| | | | | Since we still read-back (and don't have hard plans on changing this), this doesn't have much of an advantage.
* dxva2: move device creation codewm42015-07-031-34/+50
| | | | Preparation for the following commit.
* dxva2: support HEVCwm42015-05-141-1/+8
| | | | | | | | | | | | This is pretty much copy&pasted from Libav commit a7e0380497306d9723dec8440a4c52e8bf0263cf. Note that if FFmpeg was not compiled with HEVC DXVA2 support or your video drivers do not support HEVC, the player will not fallback and just fail decoding any video. This is because libavcodec appears not to return an error in this case. The situation is made worse by the fact that MSYS2 is on an ancient MinGW-w64 release, which does not have the required headers for HEVC DXVA2 support.
* dxva2: fix broken build with gcc 5.1Avi Halachmi (:avih)2015-04-241-0/+5
| | | | | | gpu_mempcy should to be called from code which targets SSE Signed-off-by: wm4 <wm4@nowhere>
* win32: request UTF-16 API variants, Vista+ APIs, and COM C macroswm42015-01-071-7/+2
| | | | | Put the Vista+ (_WIN32_WINNT) and the COM C (COBJMACROS) defines into the build system, instead of defining them over and over in the code.
* dxva2: copy mp_image attributes to sw_imgJames Ross-Gowan2015-01-071-0/+1
|
* dxva2: use gpu_memcpy with unmatched stridesJames Ross-Gowan2014-10-271-8/+29
| | | | Like memcpy_pic, this checks if the strides match first.
* dxva2: fix copying surfaces with different strideJames Ross-Gowan2014-10-271-10/+18
|
* dxva2: fix crash on initialization failurewm42014-10-261-0/+2
| | | | If dxva2_init() fails, dxva2_uninit() will be called twice.
* dxva2: use optimized memcpyJames Ross-Gowan2014-10-261-11/+35
| | | | | | At least on my machine, reading back the frame with system memcpy is slower than just using software rendering. Use the optimized gpu_memcpy from LAV to speed things up.
* video: initial dxva2 supportwm42014-10-251-0/+606
Shamelessly stolen from ffmpeg. It probably doesn't work - you can debug it yourself.