summaryrefslogtreecommitdiffstats
path: root/video/decode
Commit message (Collapse)AuthorAgeFilesLines
* hwdec: add mediacodec hardware decoder for IMGFMT_MEDIACODEC framesAman Gupta2017-10-092-0/+49
|
* hwdec: rename mediacodec to mediacodec-copyAman Gupta2017-10-092-9/+26
|
* build: switch preliminary LGPL mode from v3 to v2.1wm42017-10-051-9/+1
| | | | | | | | | | | iive agreed to relicense things that are still in mpv to LGPLv2.1. So change the licenses of the affected files, and rename the configure switch for LGPL mode to --enable-preliminary-lgpl2. (The "preliminary" part will probably be removed from the configure switch soon as well.) Also player/main.c hasn't had GPL parts since a few commits ago.
* vd_lavc: cuda requires setting hw_device_ctxwm42017-09-261-1/+1
| | | | | | This restores cuda/cuvid under Windows. Cuvid is relatively useless under Windows, but this was requested.
* video: remove old videotoolbox supportwm42017-09-262-179/+1
| | | | | Like as in previous commits, you need a very recent FFmpeg (probably git master).
* video: drop old D3D11/DXVA2 supportwm42017-09-264-1458/+8
| | | | | | | | | Now you need FFmpeg git, or something. This also gets rid of the last real use of gpu_memcpy(). libavutil does that itself. (vaapi.c still used it, but it was essentially unused, because the code path isn't really in use anymore. It wasn't even included due to the d3d-hwaccel dependency in wscript.)
* video: drop old cuda/cuvid hwaccelwm42017-09-263-122/+1
| | | | Just use FFmpeg 3.3 (or whatever it was) to get Cuvid support.
* vd_lavc: revert accidental vaapi changes revertwm42017-09-221-7/+5
| | | | | | | Commit bfa9b628589068 accidentally reverted these (because my editor did not reload the file correctly). Fixes #4904.
* build: add preliminary LGPL modewm42017-09-213-32/+28
| | | | | | | See "Copyright" file for caveats. This changes the remaining "almost LGPL" files to LGPL, because we think that the conditions the author set for these was finally fulfilled.
* Revert "vd_lavc: change auto-probe order to prefer cuda over vdpau-copy"wm42017-09-191-7/+5
| | | | | | | | | | | This reverts commit 96462040ec79b353457b64949f96fad30bd6e988. I guess the autoprobing is still too primitive to handle this well. What it really should be trying is initializing the wrapper decoder, and if that doesn't work, try another method. This is complicated by hwaccels initializing in a delayed way, so there is no easy solution yet. Probably fixes #4865.
* vd_lavc: change auto-probe order to prefer cuda over vdpau-copywm42017-08-301-5/+7
| | | | | This aims at making --opengl-hwdec-interop=cuda --hwdec=yes select the correct decoding mode: cuda instead of vdpau-copy.
* vd_lavc: work around some more idiotic FFmpeg nonsensewm42017-08-241-0/+4
| | | | | | Like in commit bd356333c713, but for the other hwaccels as well. Fixes #4794.
* vd_lavc: fix mid-stream hwdec fallbackwm42017-08-231-0/+3
| | | | | | Not resetting hwdec_request_reinit caused it to flush on every packet, which not only caused it to fail triggering the actual fallback, and let it never decode a new frame, but also to get stuck on EOF.
* video: add metadata handling for spherical videowm42017-08-211-0/+4
| | | | | | | | | | | | | | This adds handling of spherical video metadata: retrieving it from demux_lavf and demux_mkv, passing it through filters, and adjusting it with vf_format. This does not include support for rendering this type of video. We don't expect we need/want to support the other projection types like cube maps, so we don't include that for now. They can be added later as needed. Also raise the maximum sizes of stringified image params, since they can get really long.
* vd_lavc: fix device leak with copy-mode hwaccelswm42017-08-092-2/+4
| | | | | | | | | | | | Apparently this was broken by the "ctx->hwdec" check in the if condition guarding the destroy call, and "ctx->hwdec = NULL;" was moved up earlier, making this always dead code. This should probably be refcounted or so, although that could make it worse as well. For now, add a flag whether the device should be destroyed. Fixes #4735.
* vd_lavc: decode embedded ICC profilesNiklas Haas2017-08-031-0/+6
| | | | | | | | | Since these need to be refcounted, we throw them directly into struct mp_image instead of being part of mp_colorspace. Even though they would semantically make more sense in mp_colorspace, having them there is really awkward because mp_colorspace is passed around and stored a lot, and this way their lifetime is exactly tied to the lifetime of the mp_image associated with it.
* options: --priority can be LGPLwm42017-08-031-2/+0
| | | | | | | Original author has agreed now. Also fix the notice in dec_video.c - all GPL-only code is gone (unrelated to --priority/its author).
* vo_opengl: add direct rendering supportwm42017-07-243-0/+106
| | | | | | | | | | | | | | | | | | | | Can be enabled via --vd-lavc-dr=yes. See manpage additions for what it does. This reminds of the MPlayer -dr flag, but the implementation is completely different. It's the same basic concept: letting the decoder render into a GPU buffer to avoid a copy. Unlike MPlayer, this doesn't try to go through filters (libavfilter doesn't support this anyway). Unless a filter can work in-place, DR will be silently disabled. MPlayer had very complex semantics about buffer types and management (which apparently nobody ever understood) and weird restrictions that mostly limited it to mpeg2 style codecs. The mpv code does not do any of this, and just lets the decoder allocate an arbitrary number of untyped images. (No MPlayer code was used.) Parts of the code based on work by atomnuker (starting point for the generic code) and haasn (some GL definitions, some basic PBO code, and correct fencing).
* options: drop --video-aspect-method=hybridwm42017-07-212-29/+3
| | | | | | | | | Remove this code because it could be argued that it contains GPL-only code (see commit 642e963c860 for details). The remaining aspect methods appear to work just as well, are potentially more compatible to other players, and the code becomes much simpler.
* options: kill --field-dominancewm42017-07-211-9/+0
| | | | GPL-only author, no chance of relicensing.
* vd_lavc: fix crashes with old hwaccelswm42017-07-101-7/+5
| | | | | | | | | | | | | | Commit d5702d3b95 messed up the order of destruction of the elements: it destroyed the avctx before the hwaccel uninit, even though the hwaccel uninit could access avctx. This could happen with some old hwaccels only, such as D3D ones before the new libavcodec hwaccel API. Fix this by making use of the fact that avcodec_flush_buffers() will uninit the underlying hwaccel. Thus we can be sure avctx is not using any hwaccel objects anymore, and it's safe to uninit the hwaccel. Move the hwdec_dev dstruction code with it, because otherwise we would in theory potentially create some dangling pointers in avctx.
* ad_lavc, vd_lavc, sd_lavc: consistently use avcodec_free_context()wm42017-07-061-5/+1
| | | | | Instead of various ad-hoc ways to achieve the same thing. (The API was added only later.)
* vd_lavc: fix build with old FFmpeg/Libav versionswm42017-07-041-1/+1
| | | | | Seems like AV_HWACCEL_FLAG_IGNORE_LEVEL was introduced much earlier than AVCodecContext.hwaccel_flags.
* vd_lavc: remove unused hwaccel support codewm42017-07-042-43/+1
| | | | Was used by old hwaccel implementations.
* vd_lavc: make --vd-lavc-check-hw-profile=no work for generic hwaccelswm42017-07-041-1/+5
| | | | | | | This sets AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH, which some hwaccels using the new generic API respect. These do profile selection in libavcodec, so it can be controlled only with an external flag, instead of in mpv code like it used to be done.
* d3d: fix behavior with deprecated FFmpeg J pixel formatswm42017-07-042-0/+4
| | | | | | | | They have been deprecated for a decade, yet you're forced to explicitly deal with them at every step, or they will break your shit. FFmpeg insists on keeping them, because libavfilter is too stupid to deal with color ranges properly. Ridiculous.
* d3d: UWP support for D3D11VAwm42017-06-303-12/+19
| | | | | | | For some braindead reason, Microsoft decided to prevent you from dynamically loading system libraries. This makes portability harder. And we're talking about portability between Microsoft OSes!
* d3d: make DXVA2 support optionalwm42017-06-302-1/+9
| | | | | | | | | | | | This partially reverts the change from a longer time ago to always build DXVA2 and D3D11VA together. To make it simpler, we change the following: - building with ANGLE headers is now required to build D3D hwaccels - if DXVA2 is enabled, D3D11VA is still forcibly built - the CLI vo_opengl ANGLE backend is now under --egl-angle-win32 This is done to reduce the dependency mess slightly.
* vd: use ST.2086 / HDR10 MaxCLL in addition to mastering metadataNiklas Haas2017-06-183-18/+36
| | | | | | | | | | | | | MaxCLL is the more authoritative source for the metadata we are interested in. The use of mastering metadata is sort of a hack anyway, since there's no clearly-defined relationship between the mastering peak brightness and the actual content. (Unlike MaxCLL, which is an explicit relationship) Also move the parameter fixing to `fix_image_params` I don't know if the avutil check is strictly necessary but I've included it anyway to be on the safe side.
* video: refactor HDR implementationNiklas Haas2017-06-181-1/+1
| | | | | | | | | | | | | | | List of changes: 1. Kill nom_peak, since it's a pointless non-field that stores nothing of value and is _always_ derived from ref_white anyway. 2. Kill ref_white/--target-brightness, because the only case it really existed for (PQ) actually doesn't need to be this general: According to ITU-R BT.2100, PQ *always* assumes a reference monitor with a white point of 100 cd/m². 3. Improve documentation and comments surrounding this stuff. 4. Clean up some of the code in general. Move stuff where it belongs.
* dec_video: change license to LGPL (almost)wm42017-06-182-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "Almost" because this might contain copyright by michael, who agreed with LGPL, but only once the core is LGPL. This is preparation for that to happen. Apart from that, the usual remarks apply. In particular, dec_video.c started out quite chaotic with no modularization, but was later basically gutted, and in general rewritten a bunch of times. Not going to give a history lesson. Special attention needs to be given to 3 patches by cehosos, who did not agree to the relicensing: 240b743ebdf: --field-dominance e32cbbf7dc3: reinit VO if aspect ratio changes 306f6243fdf: use container aspect if codec aspect unset (?) The first patch is pretty clearly still in the current code, and needs to be disabled for LGPL. The functionality of the second patch is still active, but implemented completely different, and as part of general frame parameter changes (at the time of the patch, MPlayer already reinitialized the VO on frame size and pixel format changes - all this was merged into a single check for changing image parameters). The third patch makes me a bit more uncomfortable. It appears the code was moved to dec_video.c in de68b8f23c8c, and further changed in 82f0d373, 0a0bb905, and bf13bd0d. You could claim that cehoyos' copyright still sticks. Fortunately, we implement alternative aspect detection, which is simpler and probably preferable, and which arguably contains none of the original code and logic, and thus should be fully safe. While I don't know if cehoyos' copyright actually still applies, I'm more comfortable with making the code GPL-only for now. Also change the default to use the (in future) plain LGPL code, and deprecate the one associated with the GPL code, so we can eventually remove the GPL code. But it's also possible we decide that the copyright doesn't apply, and undo the deprecation and GPL guards. I expect that users won't notice anything. If you ask me, the old aspect method was probably an accidental bug instead of intentional behavior. Although, the new aspect method was broken too, so I had to fix it.
* vd, vd_lavc: change license to LGPL (almost)wm42017-06-152-8/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | iive agreed only to LGPL 3.0+ only. All of his relevant changes are for XvMC, for which mpv completely dropped support back in mplayer2 times. But you could claim that the get_format code represents some residual copyright (everything else added by iive was removed, only get_format still is around in some form). While I doubt that this is relly copyright-relevant, consider it is for now. michael is the original author of vd_lavc.c, so this file can become LGPL only after the core becomes LGPL. cehoyos did not agree with the LGPL relicensing, but all of his code is gone. Some others could not be reached, but their code is gone as well. In particular, vdpau support, which was originally done by Nvidia, had larger impact on vd_lavc.c, but vdpau support was first refactored a few times (for the purpose of modularization) and moved to different files, and then decoding was completely moved to libavcodec. Lastly, assigning the "opaque" field was moved by Gwenole Beauchesne in commit 8e5edec13eab. Agreement is pending (due to copyright apparently owned by the author's employer). So just undo the change, so we don't have to think about whether the change is copyrightable.
* d3d: add support for new libavcodec hwaccel APIwm42017-06-086-13/+381
| | | | | | Unfortunately quite a mess, in particular due to the need to have some compatibility with the old API. (The old API will be supported only in short term.)
* videotoolbox: support new libavcodec APIwm42017-05-242-0/+64
| | | | | | | | | | | 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).
* vd_lavc: check for missing device_ctx refwm42017-05-241-0/+5
| | | | | | It's not really guaranteed that other components always set this (e.g. on subtle errors), so check it explicitly. Although I'm not aware of a failing case.
* demux_raw: drop "mp-rawvideo" usewm42017-05-201-5/+0
| | | | | | This is an old pseudo codec to pass through the pixel format. Setup a suitable AVCodecParameter directly instead, so the "rawvideo" codec can be used.
* vdpau: crappy hack to allow initializing hw decoding after preemptionwm42017-05-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If vo_opengl is used, and vo_opengl already created the vdpau interop (for whatever reasons), and then preemption happens, and then you try to enable hw decoding, it failed. The reason was that preemption recovery is not run at any point before libavcodec accesses the vdpau device. The actual impact was that with libmpv + opengl-cb use, hardware decoding was permanently broken after display mode switching (something that caused the display to get preempted at least with older drivers). With mpv CLI, you can for example enable hw decoding during playback, then disable it, VT switch to console, switch back to X, and try to enable hw decoding again. This is mostly because libav* does not deal with preemption, and NVIDIA driver preemption behavior being horrible garbage. In addition to being misdesigned API, the preemption callback is not called before you try to access vdpau API, and then only with _some_ accesses. In summary, the preemption callback was never called, neither before nor after libavcodec tried to init the decoder. So we have to get mp_vdpau_handle_preemption() called before libavcodec accesses it. This in turn will do a dummy API access which usually triggers the preemption callback immediately (with NVIDIA's drivers). In addition, we have to update the AVHWDeviceContext's device. In theory it could change (in practice it usually seems to use handle "0"). Creating a new device would cause chaos, as we don't have a concept of switching the device context on the fly. So we simply update it directly. I'm fairly sure this violates the libav* API, but it's the best we can do.
* cuda: add new way to set cuda context on cuvid codecswm42017-05-053-3/+27
| | | | See FFmpeg commit c0f17a905f3588bf61ba6d86a83c6835d431ed3d.
* d3d: fix build with Libavwm42017-05-042-0/+2
| | | | Apparently it has been broken since forever?
* d3d11: change mp_image plane pointer semanticswm42017-05-042-8/+8
| | | | | | | | Until now, the texture pointer was stored in plane 1, and the texture array index was in plane 2. Move this down to plane 0 and plane 1. This is to align it to the new WIP D3D11 decoding API in Libav, where we decided that there is no reason to avoid setting plane 0, and that it would be less weird to start at plane 0.
* vd_lavc: fix build with FFmpeg 3.2wm42017-05-041-1/+6
| | | | | | | | Sigh... The functionality is not actually needed for vdpau, but if the vdpau hwaccel is present, the FFmpeg version is new enough that it includes the field.
* vd_lavc: add support for decoders which use AVCodecContext.hw_device_ctxwm42017-05-032-7/+18
| | | | | | | | | | | | These decoders can select the decoding device with hw_device_ctx, but don't use hw_frames_ctx (at least not in a meaningful way). Currently unused, but intended to be used for cuvid, as soon as it hits ffmpeg git master. Also make the vdpau and vaapi hwaccel definition structs static, as we have removed the old code which would have had clashing external declarations.
* video: drop vaapi/vdpau hw decoding support with FFmpeg 3.2wm42017-04-233-597/+3
| | | | | | | | | | This drops support for the old libavcodec APIs. Now FFmpeg 3.3 or FFmpeg git is required. Libav has no release with the new APIs yet, so for Libav git as of a few weeks or months ago or so is required if you want to use Libav. Not much actually changes in hwdec_vaegl.c - some code is removed, but the reindentation inflates the diff.
* vd_lavc: fix return value in receive_frame()wm42017-04-071-1/+1
| | | | | Pointed out by uau. Not sure why gcc doesn't warn (it uses ((void*)0) for NULL).
* vd_lavc: fix potential build failure with vaapiwm42017-03-231-1/+1
| | | | | | | If vaapi was found, but neither the old or new libavcodec vaapi hwaccel API, then HAVE_VAAPI_HWACCEL will be defined, but not _OLD or _NEW. The HAVE_VAAPI_HWACCEL define pretty much exists only for acrobatics with our own waf dependency checker helper code.
* vdpau: support new vdpau libavcodec decode APIwm42017-03-231-3/+41
| | | | | | | | | | | | | | | | | | | The new API works like the new vaapi API, using generic hwaccel support. One minor detail is the error message that will be printed if using non-4:2:0 surfaces (which as far as I can tell is completely broken in the nVidia drivers and thus not supported by mpv). The HEVC warning (which is completely broken in the nVidia drivers but should work with Mesa) had to be added to the generic hwaccel code. This also trashes display preemption recovery. Fuck that. It never really worked. If someone complains, I might attempt to add it back somehow. This is the 4th iteration of the libavcodec vdpau API (after the separate decoder API, the manual hwaccel API, and the automatic vdpau hwaccel API). Fortunately, further iterations will be generic, and not require much vdpau-specific changes (if any at all).
* vdpau: warn on HEVC due to completely broken nVidia driverswm42017-03-141-4/+7
| | | | | | I guess that's the full extent I still care about nVidia's broken garbage. In theory, we could always force the video mixer (which is the only method getting the video data that works), but why bother.
* vd_lavc: disable videotoolbox hack with newer ffmpeg versionswm42017-03-071-2/+5
| | | | | The hack becomes unnecessary with newer versions, but it's still needed for older ones.
* hw_videotoolbox: allow using native decoder output formatwm42017-03-021-2/+8
| | | | | | | Depends on FFmpeg commit ade7c1a2326e2bb9b. It has yet to show whether it actually does what it should. Probably doesn't.
* vd_lavc: log pixel format requested from decoderwm42017-03-011-8/+18
| | | | | | I find it slightly helpful in some situations. Also change the code to have a single exit path to make this easier.
* decode: fix extra surface countwm42017-02-274-5/+4
| | | | | | | | | | | | FFmpeg could crash with vaapi (new) and --vo=opengl + interpolation. It seems the actual surface count the old vaapi code uses (and which usually never exceeded the preallocated amount) was higher than what was used for the new vaapi code, so just correct that. The d3d helpers also had weird code that bumped the real pool size, fix them as well. Why this would result in an assertion failure instead of a proper error, who knows.
* dec_video, dec_audio: remove redundant NULL-checkswm42017-02-201-2/+1
| | | | OK, they're redundant. Now stop wasting my time, coverity.
* Fix two typoswm42017-02-201-1/+1
| | | | They're unrelated. Sue me.
* vd_lavc: increase verbosity if requested hwaccel is not compiledwm42017-02-201-1/+2
| | | | | Well, not like we can detect whether it's missing from libavcodec, but it's still slightly better.
* vd_lavc, vaapi: move hw device creation to generic codewm42017-02-204-155/+84
| | | | | | | | hw_vaapi.c didn't do much interesting anymore. Other than the function to create a device for decoding with vaapi-copy, everything can be done by generic code. Other libavcodec hwaccels are planned to provide the same API as vaapi. It will be possible to drop the other hw_ files in the future. They will use this generic code instead.
* videotoolbox: remove weird format-negotiation between VO and decoderwm4