summaryrefslogtreecommitdiffstats
path: root/video
Commit message (Collapse)AuthorAgeFilesLines
* vo_opengl: styleNiklas Haas2017-07-161-1/+1
| | | | Use uintptr_t instead of size_t. Shouldn't matter, but is cleaner.
* vo_opengl: use MP_ALIGN_UP instead of FFALIGNNiklas Haas2017-07-161-1/+1
| | | | Consistency/style
* vo_opengl: use glBufferSubData instead of glMapBufferRangeNiklas Haas2017-07-163-24/+10
| | | | | | | | | | | | | | | | | | | | Performance seems pretty much unchanged but I no longer get nasty spikes on NUMA systems, probably because glBufferSubData runs in the driver or something. As a simplification of the code, we also just size the PBO to always have the full size, even for cropped textures. This seems slower but not by relevant amounts, and only affects e.g. --vf=crop. It also slightly increases VRAM usage for textures with big strides. This new code path is especially nice because it no longer depends on GL_ARB_map_buffer_range, and no longer uses any functions that can possibly fail, thus simplifying control flow and seemingly deprecating the manpage's claim about possible image corruption. In theory we could also reduce NUM_PBO_BUFFERS since it doesn't seem like we're streaming uploads anyway, but leave it in there just in case some drivers disagree...
* Replace remaining avcodec_close() callswm42017-07-161-3/+1
| | | | | | | | This API isn't deprecated (yet?), but it's still inferior and harder to use than avcodec_free_context(). Leave the call only in 1 case in af_lavcac3enc.c, where we apparently seriously close and reopen the encoder for whatever reason.
* vo_opengl: update BufferData usage hintsNiklas Haas2017-07-151-2/+11
| | | | | | | | | | | | | | | STREAM is better than DYNAMIC because we're only using it once per frame. As for COPY vs DRAW, that was pretty much incorrect to begin with - but surprisngly, COPY is actually faster (sometimes significantly so, e.g. on my NUMA system). After testing, the best I can gather is that it has to do with the fact that COPY requires fewer redundant memcpy()s, and also 3x reduce RAM bandwidth (in theory). Anyway, that bit shouldn't introduce any regressions, it's just a documentation update. Maybe I'll change my mind about the comment again the future, it's really hard to tell. Vulkan, please save us!
* vo_opengl: coalesce intra-plane PBOsNiklas Haas2017-07-152-14/+17
| | | | | | | | | | | | | | Instead of allocating three PBOs and cycling through them, we allocate one PBO that's three times as large, and cycle through the subregion offsets. This results in arguably simpler code and faster initialization performance. Especially for 4K textures, initializing PBOs can take quite some time (e.g. 180ms -> 110ms). For 1080p, it's more like 66ms -> 52ms for me. The alignment to 4096 is completely unnecessary by spec, but we do it anyway just for peace of mind.
* img_format: fix a commentwm42017-07-151-3/+2
| | | | | This was changed a while ago. Part of it might still apply to the old D3D hwaccel glue code, though.
* vo_opengl: generalize --scale-clamp etc.Niklas Haas2017-07-124-5/+5
| | | | | This can help fight ringing without completely killing it, thus providing a middle-ground between ringing and aliasing.
* vo_opengl: remove redundant gl_video_setup_hooks callNiklas Haas2017-07-121-1/+0
| | | | | | | | This is unnecessary to call from gl_video_resize, because the hooks only (possibly) change when the actual vo_opengl options change. This used to be required back when mpv still had prescaling built in, but since that was all moved to user shaders and the code removed, this is a left-over artifact.
* vo_opengl: fix type of glsl variable frameAman Gupta2017-07-111-1/+1
|
* vo_opengl: don't make assumptions about plane orderwm42017-07-101-9/+30
| | | | | | | | | | | | | | | | | | | The renderer code doesn't list a fixed set of supported formats, but supports anything that is described by AVPixFmtDescriptor and follows a number of constraints. Plane order is not included in those constraints. This means the planes could be in random order, rather than what the vo_opengl renderer happens to assume. For example, it assumes that the 4th plane is alpha, even though alpha could be on any plane. Likewise it assumes that plane 0 was always luma, and planes 2/3 chroma. (In earlier iterations of format support, this was guaranteed by MP_IMGFLAG_YUV_P, but this is not used anymore.) Explicitly set the plane semantics (enum plane_type) by the component descriptors and the used colorspace. The behavior should mostly not change, but it's less likely to break when FFmpeg adds new pixel formats.
* vo_opengl: hwdec_dxva2egl: probe whether ANGLE mapping workswm42017-07-101-0/+12
| | | | | | | With some newer ANGLE builds, mapping can fail with "Failed to create EGL surface" during playback. The reason is unknown, and it might just be an ANGLE bug. Probe whether it works at init time to avoid the problem.
* 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.
* vo_opengl: fix dumb_mode chroma transformation fixupNiklas Haas2017-07-101-2/+2
| | | | | | | | In commit 6eb0bbe this was changed from xs[n] to use gl_format.chroma_w indiscriminately, which broke chroma rendering when zooming/cropping. The solution is to only use chroma_w for chroma planes. Fixes #4592.
* vo_opengl: describe the remainder passes after user shadersNiklas Haas2017-07-091-0/+1
| | | | | | | | | | | | On optional hook points, we store to a temp FBO and then read from it again to complete any operations that may still be left (e.g. sigmoidization after MAIN/LINEAR). In theory this mechanism should be reworked to avoid the temporary FBO until the next time we actually need one - and also skip redundant passes if we the next thing we need *is* a FBO - but both are those are tricky. Anyway, in the meantime, at least we can label the (semi-)redundant passes that get generated when using user shaders.
* vo_opengl: support tone-mapping-param for `clip`Niklas Haas2017-07-071-1/+1
| | | | | | | This just indicates a fixed linear coefficient to multiply into the signal, similar to the old option --target-brightness (but the inverse thereof). Good for testing purposes, which is why I added it. (This also corresponds somewhat to what zimg does)
* vo_opengl: rework --opengl-dumb-modeNiklas Haas2017-07-071-4/+9
| | | | | | | It's now possible to request non-dumb mode as a user, even when not using any non-dumb features. This change is mostly intended for testing, so I can easily switch between dumb and non-dumb mode on default settings. The default behavior is unaffected.
* vo_opengl: correct off-by-one in scale=oversampleNiklas Haas2017-07-071-1/+1
| | | | This caused a single pixel shift to the top-left, introduced in e3e03d0f3.
* vo_opengl: do not use vaapi-over-GLXwm42017-07-073-5/+4
| | | | | | | | | | | | | | | This backend is selected if vaapi is available, but vaapi-over-EGL is not. This causes various issues around the forced RGB conversion, which is done with fixed, usually incorrect parameters. It seems the existing auto probing check is too weak, and doesn't really prevent it from getting loaded. Fix this by adding a flag to not ever load this during auto probing. I'm still not deleting it, because it's useful for testing on nvidia machines. See #4555.
* vo_opengl: prevent desat from blowing up for negativeNiklas Haas2017-07-071-1/+1
| | | | | | | The current algorithm blew up when the color was negative, such as the case when downscaling with dscale=mitchell or other algorithms that introduce negative ringing. The simplest solution is to just slightly change the calculation to force both parameters to be in-range.
* 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.)
* vo_opengl: also expose NAME_mul for user shadersNiklas Haas2017-07-061-2/+3
| | | | | | | | | This is exposed so that bjin/mpv-prescalers can use textureGatherOffset for performance. Since there are now quite a lot of parameters where it isn't quite clear why they're all defined, add a paragraph to the man page that explains them a bit.
* vo_opengl: prevent division by zero in shaderNiklas Haas2017-07-061-1/+1
| | | | | In theory the max() should clamp it away anyway but I believe division by zero is UB so just avoid it altogether.
* vo_opengl: add --tone-mapping-desaturateNiklas Haas2017-07-064-6/+19
| | | | | | | This helps prevent unnaturally, weirdly colorized blown out highlights for direct images of the sunlit sky and other way-too-bright HDR content. I was debating whether to set the default at 1.0 or 2.0, but went with the more conservative option that preserves more detail/color.
* vo_opengl: get rid of weird double-bind in pass_read_fboNiklas Haas2017-07-051-4/+2
| | | | | | | | This logic doesn't really make sense. copy_img_tex already binds the texture, so why would we bind it a second time? Furthermore, nothing actually uses this return value. Must have been some left-over artifact of a previous iteration of this function. Anyway, it's harmless, just nonsensical. So remove it.
* vo_opengl: remove redundant left-over lineNiklas Haas2017-07-051-1/+0
| | | | The pass_read_fbo immediately below replaces it
* vo_opengl: use textureGatherOffset for polar filtersNiklas Haas2017-07-055-44/+90
| | | | | | | | | | | | | | | | | | This is more efficient on my machine (nvidia), but only when applied to groups of exactly 4 texels. So we switch to the more efficient textureGather for groups of 4. Some notes: - textureGatherOffset seems to be faster than textureGather by a non-negligible amount, but for some reason, textureOffset is still slower than a straight-up texture - textureGather* requires GLSL 400; and at least on nvidia, this requires actually allocating a GL 4.0 context. - the code in opengl/common.c that clamped the GLSL version to 330 is deprecated, because the old user shader style has been removed completely in the meantime - To combat the growing complexity of the polar sampling code, we drop the antiringing functionality from EWA shaders completely, since it never really worked well for EWA to begin with. (Horrific artifacting)
* 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.
* w32_common: use sent messages to wake up the Win32 threadJames Ross-Gowan2017-07-041-5/+12
| | | | | | | | | | | | | | | | | Instead of PostMessage, use SendNotifyMessage from the SendMessage family of functions to wake up the Win32 thread from the VO thread. When a message is sent rather than posted between threads, it ends up in a different queue which is processed before posted messages and can be processed in more places. This prevents a playback glitch when clicking on the titlebar, but not moving the window. With PostMessage-based wakeups, VOCTRLs could be delayed for up to 500ms after the user clicks on the titlebar, but with SendNotifyMessage, they still complete in under a millisecond. Also, instead of handling WM_USER, process the dispatch queue before every message. This ensures the dispatch queue is processed as soon as possible. WM_NULL is used to wake up the window procedure in case there are no other messages being processed.
* 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.
* vo_opengl: make the pass info mechanism more robustNiklas Haas2017-07-031-17/+26
| | | | | | | | | | - change asserts to silent exits - check all pointers before use - move the p->pass initialization code to the right place This should hopefully cut down on the amount of crashing by making the code fundamentally more robust, while also fixing a concrete issue where opengl-cb failed to initialize p->pass.
* w32_common: use SWP_NOSENDCHANGING when resizing childJames Ross-Gowan2017-07-031-1/+1
| | | | | | This seems to reduce glitches when resizing a --wid program (or it could be a placebo.) Since we don't need the WM_WINDOWPOSCHANGING handler in --wid mode, it should be fine.
* filter_kernels: add radius cutoff functionalityNiklas Haas2017-07-035-9/+24
| | | | | | | | This allows filter functions to be prematurely cut off once their contributions start becoming insignificant. This effectively prevents wasted GPU time sampling from parts of the function that are essentially reduced to zero by the window function, providing anywhere from a 10% to 20% speedup. (5700μs -> 4700μs for me)
* options: change everything againwm42017-07-022-7/+2
| | | | Fucking bullshit.
* x11: add 128x128 sized icon supportXu Zhao2017-07-021-0/+5
|
* x11: load icon differentlywm42017-07-014-83/+97
| | | | | | | | Now it's sourced from the etc/ PNG files directly, instead of preprocessing them with imagemagick. Add some ad-hoc code to decode PNG files with libavcodec. At least we can drop the zlib code in exchange.
* sws_utils: switch back to GPLwm42017-07-011-7/+9
| | | | | | Actually contains some code fragments by Michael Niedermayer (command line stuff, video equalizer), thus it can be LGPL only once the formal requirement of mpv's core being LGPL is fulfilled.
* vo_opengl: describe vdpau reinterleaving passNiklas Haas2017-07-011-0/+1
| | | | This shows up as (unknown pass) otherwise.
* vo_opengl: fix some more pass_info_reset issuesNiklas Haas2017-07-011-1/+10
| | | | | | | | | | | | 2f41c4e8 exposed some other edge cases as well. Globally resetting the pass info was not the right way to go about it, because we don't know in advance what the frame type is going to be - at least not with the current code structure. (In principle, we could separately indicate the frame type and the pass type and then only reset it on the first actual pass_describe call, but that's annoying as well) Also fixes a latent issue where p->pass was never initialized, which broke the MP_DBG debugging code in some cases.
* vo_opengl: call pass_info_reset earlierNiklas Haas2017-07-011-1/+1
| | | | | Omitting this call resulted in a crash when has_frame was false. But we can just call it way earlier, because there's really no reason not to.
* vo_opengl: merge uploading and renderingNiklas Haas2017-07-011-14/+14
| | | | | | Since all existing code does gl_video_upload immediately followed by pass_render_frame, we can just move the upload into pass_render_frame itself, which arguably makes more sense anyway.
* vo_opengl: refactor vo performance subsystemNiklas Haas2017-07-019-100/+206
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This replaces `vo-performance` by `vo-passes`, bringing with it a number of changes and improvements: 1. mpv users can now introspect the vo_opengl passes, which is something that has been requested multiple times. 2. performance data is now measured per-pass, which helps both development and debugging. 3. since adding more passes is cheap, we can now report information for more passes (e.g. the blit pass, and the osd pass). Note: we also switch to nanosecond scale, to be able to measure these passes better. 4. `--user-shaders` authors can now describe their own passes, helping users both identify which user shaders are active at any given time as well as helping shader authors identify performance issues. 5. the timing data per pass is now exported as a full list of samples, so projects like Argon-/mpv-stats can immediately read out all of the samples and render a graph without having to manually poll this option constantly. Due to gl_timer's design being complicated (directly reading performance data would block, so we delay the actual read-back until the next _start command), it's vital not to conflate different passes that might be doing different things from one frame to another. To accomplish this, the actual timers are stored as part of the gl_shader_cache's sc_entry, which makes them unique for that exact shader. Starting and stopping the time measurement is easy to unify with the gl_sc architecture, because the existing API already relies on a "generate, render, reset" flow, so we can just put timer_start and timer_stop in sc_generate and sc_reset, respectively. The ugliest thing about this code is that due to the need to keep pass information relatively stable in between frames, we need to distinguish between "new" and "redrawn" frames, which bloats the code somewhat and also feels hacky and vo_opengl-specific. (But then again, this entire thing is vo_opengl-specific)
* d3d: UWP support for D3D11VAwm42017-06-304-21/+23
| | | | | | | 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-304-5/+13
| | | | | | | | | | | | 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.
* img_format: drop some unused thingswm42017-06-302-16/+2
|
* mp_image: use new code for determining RGB/XYZ exceptionswm42017-06-301-3/+5
| | | | | | Slightly cleaner, possibly slightly more correct. (The last case should be dead code now. In general, we can't know the implied colorspace from a AV_PIX_FMT, at least not if FFmpeg adds a new one.)
* vo_direct3d: remove non-working nv12 shader supportwm42017-06-304-139/+0
| | | | | | | | | It never worked. It relied on some obscure texture format to provide the equivalent of GL_RG or GL_LUMINANCE_ALPHA, but no hardware seemed to report support for it ever. No idea what's the correct way to do this. On D3D11 it exists, of course. (Actually I'd like to remove the whole VO.)
* video: get rid of swapped packed YUVwm42017-06-309-20/+3
| | | | | | Another legacy annoyance. The only place where packed YUV is still important is slightly older Apple hardware or drivers, which require it for efficient hardware decoding.
* vo_opengl: remove mp_imgfmt_desc and IMGFLAG_ usagewm42017-06-303-35/+48
| | | | | These were weird due to their past, and often undefined or ill-defined. Time to get rid of them.
* vo_opengl: restructure format setupwm42017-06-307-131/+105
| | | | | | | | | | | | Instead of setting up a weird swizzle (which is linked to how the internal renderer code works, rather than the generic format code), add per-component mapping to gl_imgfmt_desc. The renderer still computes the weird swizzle, but at least it's confined to itself. Also, it appears the hwdec backends don't need this anymore. It's really nice that the messy init_format() goes away too.
* options: change path list options, and document list optionswm42017-06-302-1/+7
| | | | | | | | | | | | | | | | | | | | | | | The changes to path list options is basically getting rid of the need to pass multiple paths to a single option. Instead, you can use the option multiple times. The old behavior can be used by using the -set suffix with the option. Change some options to path lists. For example --script is now append by default, and if you use --script-set, you need to use ":"/";" as separator instead of ",". --sub-paths/--audio-file-paths is a deprecated alias now, and will break if the user tries to pass multiple paths to it. I'm assuming that if these are used, most users will pass only 1 path anyway. --opengl-shaders has more compatibility handling, since it's probably rather common that users pass multiple options to it. Also document all that in the manpage. I'll probably regret this later, as it somewhat increases the complexity of the option parser, rather than increasing it.
* vo_direct3d: fix buildwm42017-06-291-1/+0
| | | | That format is worthless anyway.
* video: drop some more IMGFMT aliaseswm42017-06-294-67/+52
| | | | | | | | | | | For vo_opengl and vo_direct3d, these are supported in a generic way. For vf_vapoursynth, we could probably map its VSFormat struct in a generic way, but for now do some bullshit. vf_eq.c actually loses support for these formats. We could add generic support too (anything that has 8 bit planes will work), but why bother. The filter is deprecated anyway.
* video: drop some unused IMGFMT aliaseswm42017-06-293-25/+1
| | | | | | These formats are supported in a generic way. To get rid of IMGFMT_NV21, remove support from vo_direct3d.c completely.
* vo_opengl: rely on FFmpeg pixdesc a bit morewm42017-06-293-80/+231
| | | | | | | |