summaryrefslogtreecommitdiffstats
path: root/video
Commit message (Collapse)AuthorAgeFilesLines
...
* w32_common: handle media keysJames Ross-Gowan2017-08-051-0/+15
| | | | | | | | | | | | | | | | | This was attempted before in fc9695e63b5b, but it was reverted in 1b7ce759b1f4 because it caused conflicts with other software watching the same keys (See #2041.) It seems like some PCs ship with OEM software that watches the volume keys without consuming key events and this causes them to be handled twice, once by mpv and once by the other software. In order to prevent conflicts like this, use the WM_APPCOMMAND message to handle media keys. Returning TRUE from the WM_APPCOMMAND handler should indicate to the operating system that we consumed the key event and it should not be propogated to the shell. Also, we now only listen for keys that are directly related to multimedia playback (eg. the APPCOMMAND_MEDIA_* keys.) Keys like APPCOMMAND_VOLUME_* are ignored, so they can be handled by the shell, or by other mixer software.
* vo_opengl: always print when getting embedded ICC profile dataRostislav Pehlivanov2017-08-041-1/+2
| | | | | | The printout in get_vid_profile() gets skipped if icc caching has been enabled, so always print if an embedded ICC profile has been provided.
* vo_opengl: support embedded ICC profilesNiklas Haas2017-08-033-13/+70
| | | | | | | | | | | | | | | | This currently only works when using lcms-based color management (--icc-profile-*). In principle, we could also support using lcms even when the user has not specified an ICC profile, by generating the profile against a fixed reference (--target-prim/--target-trc) instead. I still might do that some day, simply because 3dlut provides a higher quality conversion than our simple gamut mapping does for stuff like BT.2020, and also because it's now needed to enable embedded ICC profiles. But that would be a separate change, so preserve the status quo for now. (Besides, my opinion is still that you should be using an ICC profile if you care about colors being accurate _at all_)
* vd_lavc: decode embedded ICC profilesNiklas Haas2017-08-033-0/+22
| | | | | | | | | 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.
* vo_opengl: use GL_CLIENT_STORAGE_BIT for DRNiklas Haas2017-08-031-1/+1
| | | | | | | | | mesa won't pick client storage unless this bit is set, and we *absolutely* want to be using client storage for our DR PBOs. Performance is shit on AMD otherwise. (Nvidia always uses client storage for persistent coherent buffers whether you tell it it or not, probably because it's way faster and nvidia doesn't trust users to figure that out on their own)
* vo_opengl: remove unused ra_mapped_buffer.preferred_align fieldwm42017-08-032-2/+0
| | | | | | | | | | | It makes no sense to have this on an already created buffer. If anything, the ra backend would have to export this as a global value (e.g. struct ra field), so that whatever allocates the buffer can account for the required alignment. Since this code is in vo_opengl.c in the first place, and since GL doesn't dictate any special alignment here, it doesn't make sense in the first place to export this. (Maybe something like this will be required later.)
* vo_opengl: don't hardcode texmap0 for polar computeNiklas Haas2017-08-031-1/+3
| | | | | This was an oversight. The ID shouldn't be hard-coded here, so add it to sampler_prelude instead.
* vo_opengl: don't precompute texcoord in global scopeNiklas Haas2017-08-031-1/+1
| | | | | | | | | | | Breaks on mesa for whatever reason... even though it doesn't generate a GLSL shader compiler error Shouldn't make a performance difference for us because we cache `pos` anyway, and most compute shaders will probably cache all of their samples to shmem. Might have to re-visit this when we have an actual use case for repeated sampling inside CS though. (RAVU + anti-ringing is a possible candidate for that)
* vo_opengl: make compute shaders more flexibleNiklas Haas2017-08-035-32/+52
| | | | | | This allows users to do their own custom sample writing, mainly meant to address use cases such as RAVU. Also clean up the compute shader code a bit.
* vo_opengl: add legend for texture format debug dumpwm42017-08-031-0/+4
|
* vo_opengl: give special Apple name a more appropriate namewm42017-08-031-1/+1
| | | | | | | | Or less appropriate, as some would argue. The new name is short for "Apple YUV packed". (This format is needed only for hardware decoding on rather old Apple hardware, and a very annoying special case.)
* vo_opengl: simplify/fix user shader textureswm42017-08-033-69/+50
| | | | | | | | | | | | | | | | | | | | This broke float textures, which were actually used by some shaders. There were probably some other bugs as well. Lots of code can be avoided by using ra_tex_params directly, so do that. The main change is that COMPONENT/FORMAT are replaced by a single FORMAT directive, which takes different parameters now. Due to the mess with 16/32 bit float textures, and because we want to support other APIs than just GL in the future, it's not really clear how this should be handled, and the nice component/type separation makes things actually harder. So just jump the gun and use the ra_format.name names, which were originally meant mostly for debugging. (This is probably something that will be regretted later.) Still only superficially tested, but seems to work. Fixes #4708.
* vo_opengl: fix constexprs on ANGLENiklas Haas2017-08-031-6/+6
| | | | I hate GLES
* vo_opengl: fix HLG OOTF inverseNiklas Haas2017-08-031-1/+1
| | | | Got the "sign" of the second multiplication wrong.
* vo_opengl: generalize HDR tone mapping to gamut mappingNiklas Haas2017-08-033-17/+23
| | | | | | | | | | | | | | | | | | | | | | Since this code was already written for HDR, and is now per-channel (because it works better for HDR as well), we can actually reuse this to get very high quality gamut mapping without clipping. The only required change is to move the tone mapping from before the gamut map to after the gamut map. Additonally, we need to also account for changes in the signal range as a result of applying the CMS when we compute ref_peak, which is fortunately pretty easy because we only need to consider the case of primaries mapping to themselves. Since `HDR` no longer really makes sense as a label, rename it to `--tone-mapping` in general. Also fits better with `--tone-mapping-desat` etc. Arguably we could also rename `--hdr-compute-peak`, but that option is basically only useful for HDR content anyway because we don't need information about the signal range for gamut mapping. This (finally!) gives us reasonably high quality gamut mapping even in the absence of an ICC profile / 3DLUT.
* vo_opengl: implement HLG OOTF inverseNiklas Haas2017-08-031-8/+3
| | | | | | | Huge thanks to @rusxg for finding this solution, which was previously believed not to exist. Of course, we still don't actually need it, but I don't want to leave this half-implemented in case somebody does in the future.
* 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).
* cocoa: fix the support of multiple renderers (GPU switch)Alex Notes2017-07-311-6/+15
| | | | | | | | | | | | So far, switching between integrated and discrete GPU would cause the kernel to kill mpv due to an indecipherable buffer error. The technical note TN2229 from Apple recommends to enable OpenGL Offline Renderers for every Mac with more GPUs than displays to handle the switch between GPU. By ordering the array from the least commonly rejected to the most, we can sequentially remove PixelFormat attributes to fit the host. Fixes #2371
* cocoa: remove usage of FFABS and the dependency on libavutil/common.hAkemi2017-07-311-4/+2
|
* cocoa: distinguish between horizontal and vertical scrollAkemi2017-07-311-2/+12
| | | | | | | | | | we need to switch the x and y deltas when Shift is being held because macOS switches them around. otherwise we would get a horizontal scroll on a vertical one and vice versa. additional we switch from deltaX/Y to scrollingDeltaX/Y since the Apple docs suggest it's the preferred way now. in my tests both reported the same values on imprecise scrolls though.
* vo_opengl: manage user shader textures with rawm42017-07-303-51/+28
| | | | | Drops some features I guess, no idea if those were needed. Untested due to lack of test cases.
* vo_opengl: fix dither texture filterwm42017-07-301-1/+0
| | | | Should be GL_NEAREST, not GL_LINEAR.
* vo_opengl: manage ICC LUT texture via rawm42017-07-291-28/+25
| | | | | Also move the capability check to gl_video_get_lut3d(), because it seems more convenient (ra won't have a _CAP_EXT16).
* vo_opengl: manage scaler LUT textures via rawm42017-07-294-41/+23
| | | | Also fix the RA_CAP_ bitmask nonsense.
* vo_opengl: manage dither texture via rawm42017-07-296-34/+66
| | | | | | | | | Also add some more helpers. Fix the broken math.h include statement. utils.c uses ra_gl.h internals, which it shouldn't, and which will be removed again as soon as this code gets converted to ra fully.
* vo_opengl: do not use GL format conversion on texture uploadwm42017-07-291-16/+16
| | | | | | | | | | | | | | | | | | The dither texture data is created as a float array, but uploaded to a texture with GL_R16 as internal format. We relied on GL to do the conversion from float to uint16_t. Not all GL variants even support this: GLES does not provide this conversion (one of the reasons why this code has a float16 code path). Also, ra is not going to do this. So just convert on the fly. Still keep the float16 texture format fallback, because not all GLES implementations provide GL_R16. There is some possibility that we'll need to provide some kind of upload conversion anyway for float->float16. We still rely on GL doing this implicitly, and all GL variants support it, but with RA there might be the need for explicit conversion. Even then, it might be best to reduce the number of conversion cases. I'll worry about this later.
* vo_opengl: use ra_* for format negotiation toowm42017-07-293-29/+22
| | | | | | | | | | | | | Format handling via ra_* was added earlier, but the format negotiation part was forgotten. Actually move some aspects of it to ra_get_imgfmt_desc(). Also make sure the unorm and float formats selected by the common format lookup functions are linear filterable. (For OpenGL, this is implicitly guaranteed, so it wasn't done before.) Whether these assumptions should be checked/enforced in the ra code at all is a bit fuzzy, but with ra being helper code only for the actual video renderer, it's probably justified.
* vo_opengl: support loading custom user texturesNiklas Haas2017-07-273-77/+328
| | | | | | | | | | | Parsing the texture data as raw strings makes the textures the most portable and self-contained. In order to facilitate different types of shaders, the parse_user_shader interaction has been changed to instead have it loop through blocks and call the passed functions for each valid block parsed. This is more modular and also cleaner, with better code separation. Closes #4586.
* vo_opengl: slightly refactor user_shaders codeNiklas Haas2017-07-273-73/+53
| | | | | | | | | | | | | | - Each struct tex_hook now stores multiple hooks, this allows us to avoid the awkward way of the current code has to add the same pass multiple times. - As a consequence, SHADER_MAX_HOOKS was split up into SHADER_MAX_PASSES (number of tex_hooks) and SHADER_MAX_HOOKS (number of hooked textures per tex_hook), and both numbers decreased correspondingly. - Instead of having a weird free() callback, we can just leverage talloc's recursive free behavior. The only user is the user shaders code anyway.
* vo_opengl: tone map on the maximum signal componentNiklas Haas2017-07-271-19/+25
| | | | | | | | | | This actually makes sure we don't decolor due to clipping even when the signal itself exceeds the luma by a significant factor, which was pretty common for saturated blues (and to a lesser degree, reds) - most noticeable in skies etc. This prevents the turn-the-sky-cyan effect of mobius tone mapping, and should also improve the other tone mapping modes in quality.
* vo_opengl: fix mpgl_caps bit checkNiklas Haas2017-07-271-1/+1
| | | | | As pointed out by @bjin, this would match if _any_ of the reqs are set. Need to test for explicit equality.
* vo_opengl: start work on rendering API abstractionwm42017-07-267-175/+836
| | | | | | | | | | | | | | | | | | | | | | This starts work on moving OpenGL-specific code out of the general renderer code, so that we can support other other GPU APIs. This is in a very early stage and it's only a proof of concept. It's unknown whether this will succeed or result in other backends. For now, the GL rendering API ("ra") and its only provider (ra_gl) does texture creation/upload/destruction only. And it's used for the main video texture only. All other code is still hardcoded to GL. There is some duplication with ra_format and gl_format handling. In the end, only the ra variants will be needed (plus the gl_format table of course). For now, this is simpler, because for some reason lots of hwdec code still requires the GL variants, and would have to be updated to use the ra ones. Currently, the video.c code accesses private ra_gl fields. In the end, it should not do that of course, and it would not include ra_gl.h. Probably adds bugs, but you can keep them.
* vo_opengl: describe the texture uploading modeNiklas Haas2017-07-261-1/+2
| | | | | Be a bit more transparent here, which is especially helpful when people are sending me screenshots of stats pages.
* vo_opengl: check against shmem limitsNiklas Haas2017-07-266-26/+54
| | | | | | The radius check was not strict enough, especially not for all platforms. To fix this, actually check the hardware capabilities instead of relying on a hard-coded maximum radius.
* vo_opengl: fix image uniforms for older OpenGLJames Ross-Gowan2017-07-261-0/+2
| | | | | This explicitly enables the GL_ARB_shader_image_load_store extension, which seems to fix compute shaders for Intel/GL 3.0.
* vo_opengl: cosmetic changeNiklas Haas2017-07-251-8/+6
|
* vo_opengl: add PRINTF_ATTRIBUTE to gl_sc_ssboNiklas Haas2017-07-251-1/+1
| | | | | Doesn't uncover any bugs, but apparently we're getting in the habit of this anyway.
* vo_opengl: kill off FBOTEX_COMPUTE againNiklas Haas2017-07-253-26/+16
| | | | | | | | | | | The textures not having an FBO actually caused regressions when trying to render the subtitles on top of this texture (--blend-subtitles), which still relied on an FBO. So just kill off the logic entirely. Why worry about a single FBO wasted when we're allocating like 10 anyway. Fixes #4657.
* vo_opengl: fix incoherent SSBO usageNiklas Haas2017-07-251-0/+1
| | | | | | | According to the OpenGL spec, atomic access to SSBO variables is *not* guaranteed to be coherent, even when reusing the same SSBO attached to the same shader across different frames. So we actually need a glMemoryBarrier here, at least in theory.
* vo_opengl: cosmetic fixNiklas Haas2017-07-251-2/+2
|
* vo_opengl: fix incoherent texture usageNiklas Haas2017-07-252-0/+5
| | | | | | | | | This bug slipped past my attention because nvidia ignores memory barriers, but this is not necessarily always the case. Since image_load_store is incoherent (specifically, writing to images from compute shaders is incoherent) we need to insert a memory barrier to make it coherent again. Since we only care about texture fetches, that's the only barrier we need.
* vo_opengl: adjust the rules for linearizationNiklas Haas2017-07-241-20/+41
| | | | | | | | | | | | | | | | | | Two changes, compounded into one since they affect the same logic: 1. Never use linearization for HDR downscaling 2. Always use linearization for interpolation Instead of fixing p->use_linear at the beginning of pass_render_frame, we flip it on "dynamically" as needed. I plan on killing this p->use_linear frame (along with other per-pass metadata) and moving them into their own struct for tracking the "current" state of the video, but that's a separate/upcoming refactor. As a small bonus, reduce some code duplication in the interpolation logic. Fixes #4631
* vo_opengl: enable compute shader for mesaBin Jin2017-07-255-4/+26
| | | | | | | | | Mesa 17.1 supports compute shader but not full specs of OpenGL 4.3. Change the code to detect OpenGL extension "GL_ARB_compute_shader" rather than OpenGL version 4.3. HDR peak detection requires SSBO, and polar scaler requires 2D array extension. Add these extensions as requirement as well.
* vo_opengl: support user compute shadersNiklas Haas2017-07-243-0/+12
| | | | | These are identical to regular fragment shader hooks, but with extra metadata indicating the preferred block size.
* vo_opengl: implement compute shader based EWA kernelNiklas Haas2017-07-243-7/+81
| | | | | | | | | | | This performs almost 50% faster on my machine (!!), from 4650μs down to about 3176μs for ewa_lanczossharp. It's possible we could use a similar approach to speed up the separable scalers, although with vastly simpler code. For separable scalers we'd also have the additional huge benefit of only needing padding in one direction, so we could potentially use a big 256x1 kernel or something to essentially compute an entire row at once.
* vo_opengl: support HDR peak detectionNiklas Haas2017-07-249-22/+193
| | | | | | | | | | | | | | This is done via compute shaders. As a consequence, the tone mapping algorithms had to be rewritten to compute their known constants in GLSL (ahead of time), instead of doing it once. Didn't affect performance. Using shmem/SSBO atomics in this way is extremely fast on nvidia, but it might be slow on other platforms. Needs testing. Unfortunately, setting up the SSBO still requires OpenGL calls, which means I can't have it in video_shaders.c, where it belongs. But I'll defer worrying about that until the backend refactor, since then I'll be breaking up the video/video_shaders structure anyway.
* vo_opengl: support compute shadersNiklas Haas2017-07-247-100/+317
| | | | | | | | These can either be invoked as dispatch_compute to do a single computation, or finish_pass_fbo (after setting compute_size_minimum) to render to a new texture using a compute shader. To make this stuff all work transparently, we try really, really hard to make compute shaders as identical to fragment shaders as possible in their behavior.
* vo_opengl: cut down on FBOTEX_FUZZY abuseNiklas Haas2017-07-241-4/+2
| | | | | | | | Don't use FBOTEX_FUZZY where the FBO is sized according to p->texture_w/h, since this changes infrequently (and when it does, we need to reset everything anyway). No real reason to make this change other than that it possibly prevents nasty surprises in the future, so I feel more comfortable about it.
* common, vo_opengl: add/use helper for formatted strings on the stackwm42017-07-242-10/+5
| | | | | | | | | | | Seems like I really like this C99 idiom. No reason not to generalize it do snprintf(). Introduce mp_tprintf(), which basically this idiom to snprintf(). This macro looks like it returns a string that was allocated with alloca() on the caller site, except it's portable C99/C11. (And unlike alloca(), the result is valid only within block scope.) Use it in 2 places in the vo_opengl code. But it has the potential to make a whole bunch of weird looking code look slightly nicer.
* vo_opengl: check format on some printf-like callswm42017-07-242-3/+5
| | | | Fix 1 incorrect use.
* vo_opengl: add direct rendering supportwm42017-07-2412-4/+430
| | | | | | | | | | | | | | | | | | | | 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).
* mp_image: expose some image allocation code as helpers, refactorwm42017-07-232-20/+129
| | | | | | | Refactor the image allocation code, and expose part of it as helper code. This aims towards allowing callers to easily allocate mp_image references from custom-allocated linear buffers. This is exposing only as much as what should be actually required.
* mp_image_pool: disallow adding read only frameswm42017-07-231-2/+6
| | | | | | Remove the feature of adding read-only frames to mp_image_pool_add(). This makes no sense, because an image pool is an allocator, and must always return writable images. Also check these assumptions earlier.
* vo_opengl: osd: remove stale declarationwm42017-07-231-1/+0
| | | | Was missed in the previous changes.
* vo_opengl: add printf format checking to pass_describe()wm42017-07-221-0/+1
|
* vo_opengl: make VAO helper private, remove old VAO mechanismwm42017-07-222-44/+17
| | | | The struct describing vertex attributes is still public, of course.
* vo_opengl: osd: use new VAO mechanismwm42017-07-223-49/+43
| | | | | | | In addition to using the new VAO mechanism introduced in the previous commit, this tries to keep the OSD code self-contained. This doesn't work all too well