summaryrefslogtreecommitdiffstats
path: root/video
Commit message (Collapse)AuthorAgeFilesLines
* vo_mediacodec_embed: fix forgotten VO_CAP_NOREDRAW→VO_CAP_NORETAINJan Ekström2018-02-201-1/+1
| | | | Fixes compilation of this module.
* cocoa-cb: fix hwdec when drawing off-screenAkemi2018-02-171-0/+1
| | | | | | | | | drawing off-screen failed because we didn't have a valid context. the problem is we force off-screen drawing because the CAOpenGLLayer refuses to draw anything while being off-screen. set the current context before starting to draw anything off-screen. Fixes #5530
* video: rename VO_CAP_NOREDRAW to VO_CAP_NORETAINAman Gupta2018-02-172-4/+4
|
* vo_gpu: hwdec_drmprime_drm: cosmetic simplificationwm42018-02-161-6/+3
| | | | | | Coverity complained about the redundant init of hratio etc. - just remove that and merge declaration/init of these variables. Also the first double cast in each expression is unnecessary.
* cocoa-cb: fix drawing on macOS 10.11Akemi2018-02-161-3/+19
| | | | | | | | | the CVDisplayLinkSetOutputHandler function introduced with 10.11 is broken on the very same version of the OS, which caused our render loop never to start. fallback to the old display link callback on 10.11. for reference the radar http://www.openradar.me/26640780 Fixes #5527
* vo_gpu: remove old window screenshot glue code and GL implementationwm42018-02-134-42/+0
| | | | | | | | | | | There is now a better way. Reading the font framebuffer was always a hack. The new code via VOCTRL_SCREENSHOT renders it into a FBO, which does not come with the disadvantages of reading the front buffer (like not being supported by GLES, possibly black regions due to overlapping windows on some systems). For now keep VOCTRL_SCREENSHOT_WIN on the VO level, because there are still some lesser VOs and backends that use it.
* vo: make opengl-cb first in the autoprobing orderwm42018-02-132-4/+5
| | | | | | | This should be helpful for the new OSX Cocoa backend, which uses opengl-cb internally. Since it comes with a behavior change that could possibly interfere with libmpv/opengl_cb users, we mark it as explicit API change.
* Fix recent FFmpeg deprecationswm42018-02-131-2/+3
| | | | | | | | | This includes codec/muxer/demuxer iteration (different iteration function, registration functions deprecated), and the renaming of AVFormatContext.filename to url (plus making it a malloced string). Libav doesn't have the new API yet, so it will break. I hope they will add the new APIs too.
* vf_vavpp: select best quality deinterlacing algorithm by defaultwm42018-02-131-5/+22
| | | | | | | | This switches the default away from "bob" to the best algorithm reported as supported by the driver. This is convenient for users, and there is no reason to use something worse by default. Untested.
* video: make --deinterlace and HW deinterlace filters always deinterlacewm42018-02-133-3/+3
| | | | | | | | | | | | | | | | Before this, we made deinterlacing dependent on the video codec metadata (AVFrame.interlaced_frame for libavcodec). So even if --deinterlace=yes was set, we skipped deinterlacing if the flag wasn't set. This is very unreliable and there are many streams with flags incorrectly set. The potential problem is that this might upset people who alwase enabled deinterlace and hoped it worked. But it's likely these people were screwed by this setting anyway. The new behavior is less tricky and easier to understand, and this preferable. Maybe one day we could introduce a --deinterlace=auto, which does the right thing, but of course this would be hard to implement (esecially with hwdec). Fixes #5219.
* vo_gpu: d3d11: implement tex_download()James Ross-Gowan2018-02-135-102/+57
| | | | | | | This allows the new GPU screenshot functionality introduced in 9f595f3a80ee to work with the D3D11 backend. It replaces the old window screenshot functionality, which was shared between D3D11 and ANGLE. The old code can be removed, since it's not needed by ANGLE anymore either.
* vo_gpu: use a variable for the RA_CAP_FRAGCOORD flagJames Ross-Gowan2018-02-131-4/+3
| | | | | This is just a cosmetic change. Now the RA_CAP_FRAGCOORD check looks like all the others.
* vo_gpu: check for HDR peak detection in dumb mode tooJames Ross-Gowan2018-02-131-7/+8
| | | | | | | | Similar spirit to edb4970ca8b9. check_gl_features() has a confusing early-return. This also adds compute_hdr_peak to the list of options that is copied to the dumb-mode options struct, since it seems to make a difference. Otherwise it would be impossible to disable HDR peak detection in dumb mode.
* cocoa-cb: initial implementation via opengl-cb APIAkemi2018-02-127-20/+1492
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this is meant to replace the old and not properly working vo_gpu/opengl cocoa backend in the future. the problems are various shortcomings of Apple's opengl implementation and buggy behaviour in certain circumstances that couldn't be properly worked around. there are also certain regressions on newer macOS versions from 10.11 onwards. - awful opengl performance with a none layer backed context - huge amount of dropped frames with an early context flush - flickering of system elements like the dock or volume indicator - double buffering not properly working with a none layer backed context - bad performance in fullscreen because of system optimisations all the problems were caused by using a normal opengl context, that seems somewhat abandoned by apple, and are fixed by using a layer backed opengl context instead. problems that couldn't be fixed could be properly worked around. this has all features our old backend has sans the wid embedding, the possibility to disable the automatic GPU switching and taking screenshots of the window content. the first was deemed unnecessary by me for now, since i just use the libmpv API that others can use anyway. second is technically not possible atm because we have to pre-allocate our opengl context at a time the config isn't read yet, so we can't get the needed property. third one is a bit tricky because of deadlocking and it needed to be in sync, hopefully i can work around that in the future. this also has at least one additional feature or eye-candy. a properly working fullscreen animation with the native fs. also since this is a direct port of the old backend of the parts that could be used, though with adaptions and improvements, this looks a lot cleaner and easier to understand. some credit goes to @pigoz for the initial swift build support which i could improve upon. Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739, #2392, #2217
* osx: always deactivate the early opengl flush on macOSAkemi2018-02-121-2/+6
| | | | | | | | | | | early flushing only caused problems on macOS, which includes: - performance problems and huge amount of dropped frames - problems with playing back video files with fps close to the display refresh rate - rendering at twice the rate of the video fps - not properly detected display refresh rate we always deactivate any early flush for macOS to fix these problems.
* vo_drm: support --monitorpixelaspectMarco Migliori2018-02-111-0/+2
| | | | | | | | | | This commit allows for video to be shown with the right aspect even when pixels are not square in the selected drm mode. For example, if drm mode 5 is "640x400", the right aspect on a 4:3 monitor is obtained by mpv --vo=drm --drm-mode=5 --monitorpixelaspect=5:6 ... Other vo's seem to make this parameter change the size of the window, but in the drm vo this is fixed, being as large as the screen.
* vo_drm: reset last input image on reconfigMarco Migliori2018-02-111-0/+3
| | | | | | | | | | | | | | | | | | The last image is stored in vo->priv->last_input to be used when redrawing a frame is necessary (control: VOCTRL_REDRAW_FRAME). At the beginning it is NULL, so a redraw request has no effect since draw_image ignores calls with image=NULL. When using --force-window the size of the image may change without the vo structure being re-created. Before this commit, the size of vo->priv->last_input could become inconsistent with the cropping rectangle vo->priv->src_rc, which could trigger an assert in mp_image_crop_rc(). Even if it did not, the last image of a video remained on the screen when the next file in the playlist had no video (e.g., it was an mp3 without an embedded cover). This commit deallocates and resets to NULL the image vo->priv->last_input when reconfiguring video.
* vo_drm: make the osd as large as the screenMarco Migliori2018-02-111-18/+18
| | | | | | | | | | | | | | | | | | | | Before this commit, the drm vo drew the osd over the scaled image, and then copied the result onto the framebuffer, shifted. This made the frame centered, but forced the osd to be only as large as the image. This was inconsistent with other vo's, covered the image with the progress indicator even when a black band was at the top of the screen, made the progress indicator wrap on narrow videos, etc. The change is to always use an image as large as the screen. The frame is copied scaled and shifted to it, and the osd drawn over it. The result is finally copied to the framebuffer without any shift, since it is already as large as it. Technically, cur_frame is an image as large as the screen and cur_frame_cropped is a dummy reference to it, cropped to the size of the scaled video. This way, copying the scaled image to cur_frame_cropped positions the image in the right place in cur_frame, which can then have the osd added to it and copied to the framebuffer.
* vo_gpu: make screenshots use the GL rendererwm42018-02-1114-25/+193
| | | | | | | | | | | | | | | | | | | | | | | | | | Using the GL renderer for color conversion will make sure screenshots will use the same conversion as normal video rendering. It can do this for all types of screenshots. The logic when to write 16 bit PNGs changes. To approximate the old behavior, we decide by looking whether the source video format has more than 8 bits per component. We apply this logic even for window screenshots. Also, 16 bit PNGs now always include an unused alpha channel. The reason is that FFmpeg has RGB48 and RGBA64 formats, but no RGB064. RGB48 is 3 bytes and usually not supported by GPUs for rendering, so we have to use RGBA64, which forces an alpha channel. Will break for users who use --target-trc and similar options. I considered creating a new gl_video context, but it could double GPU memory use, so I didn't. This uses FBOs instead of glGetTexImage(), because that increases the chance it could work on GLES (e.g. ANGLE). Untested. No support for the Vulkan and D3D11 backends yet. Fixes #5498. Also fixes #5240, because the code for reading back is not used with the new code path.
* vo_gpu: add internal ability to skip osd/subs for renderingwm42018-02-115-18/+40
| | | | Needed for the following commit.
* vo_gpu: use blit() only if target ra_tex supports itwm42018-02-111-2/+3
| | | | | Even if RA_CAP_BLIT is set, this might just not be enabled for the target ra_tex.
* vo_gpu: add memory barrier on the HDR peak detectionNiklas Haas2018-02-111-0/+1
| | | | | This can cause the peak detection state to be inconsistent in rare cases, which might explain the issues when taking screenshots in #5499.
* vo_gpu: correctly infer HDR peak detection supportNiklas Haas2018-02-111-1/+4
| | | | | | The re-ordering of commits e3d93fd and 0870859 ended up swallowing the change which made the HDR tone mapping algorithm actually check for RA_CAP_NUM_GROUPS support.
* vo_gpu: refactor HDR peak detection algorithmNiklas Haas2018-02-113-16/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The major changes are as follows: 1. Use `uint32_t` instead of `unsigned int` for the SSBO size calculation. This doesn't really matter, since a too-big buffer will still work just fine, but since `uint` is a 32-bit integer by definition this is the correct way to do it. 2. Pre-divide the frame_sum by the num_wg immediately at the end of a frame. This change was made to prevent overflow. At 4K screen size, this code is currently already very at risk of overflow, especially once I started playing with longer averaging sizes. Pre-dividing this out makes it just about fit into 32-bit even for worst-case PQ content. (It's technically also faster and easier this way, so I should have done it to begin with). Rename `frame_sum` to `frame_avg` to clearly signal the change in semantics. 3. Implement a scene transition detection algorithm. This basically compares the current frame's average brightness against the (averaged) value of the past frames. If it exceeds a threshold, which I experimentally configured, we reset the peak detection SSBO's state immediately - so that it just contains the current frame. This prevents annoying "eye adaptation"-like effects on scene transitions. 4. As a result of the previous change, we can now use a much larger buffer size by default, which results in a more stable and less flickery result. I experimented with values between 20 and 256 and settled on the new value of 64. (I also switched to a power-of-2 array size, because I like powers of two)
* wayland_common: fix idle_inhibitor protocol segfaultRostislav Pehlivanov2018-02-091-0/+1
| | | | The pointer is used as a state and wasn't zeroed after seeks.
* drmprime interop : Add frames triple bufferingLongChair2018-02-071-3/+8
| | | | | | | | | | | | | | | | | Currently using the drmprime interop with external mpv intgration can lead to rendering issues because the current frame is being released too early. Typically using this with Qt results in one frame shift because Qt will do waitforvsync and swap, rather than swap and waitforvsync. This leads to tearing as the frambuffer is released while being displayed on screen. In order to avoid releasing the framebuffer that is displayed, We keep the framebuffer alive for one more frame with triple buffering to make sure that whatever rendering process is used, the framebuffer will not be released when it's still on screen. This was tested on RockChip Rock64
* vd_lavc: fix stall with some uses of --hwdec=copywm42018-02-051-3/+6
| | | | | | | | | | | Also a regression of the filter change. The new code is more picky about EOF states, and it turns out the weird delay queue (used with some hwdec copy back modes only) accidentally dropped an EOF event. It reset the avctx before the delay queue was drained, which meant it never returned the expected AVERROR_EOF status code. Also don't signal EOF when copy back fails. It should just try to continue until fallback is performed.
* vo_gpu: port HDR tone mapping algorithm from libplaceboNiklas Haas2018-02-053-70/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current peak detection algorithm was very bugged (which contributed to the excessive cross-frame flicker without long normalization) and also didn't take into account the frame average brightness level. The new algorithm both takes into account frame average brightness (in addition to peak brightness), and also computes the values in a more stable/correct way. (The old path was basically undefined behavior) In addition to improving the algorithm, we also switch to hable tone mapping by default, and try to enable peak computation automatically whever possible (compute shaders + SSBOs supported). We also make the desaturation milder, after extensive testing during libplacebo development. I also had to compensate a bit for the representational differences between mpv and libplacebo (libplacebo treats 1.0 as the reference peak, but mpv treats it as the nominal peak), but it shouldn't have caused any problems. This is still not quite the same as libplacebo, since libplacebo also allows tagging the desired scene average brightness on the output, and it also supports reading the scene average brightness from static metadata (MaxFALL) where available. But those changes are a bit more involved. It's possible we could also read this from metadata in the future, but we have problems communicating with AVFrames as it is and I don't want to touch the mpv colorimetry structs for the time being.
* vo_gpu: add RA_CAP for gl_NumWorkGroupsNiklas Haas2018-02-053-1/+3
| | | | | SPIRV-Cross doesn't support this for the time being. It's possible this could go away again at a later date.
* vo_gpu: vulkan: correctly enable textureGatherOffsetNiklas Haas2018-02-052-2/+3
| | | | This also requires a vulkan feature / SPIR-V capability to function
* vo_gpu: vulkan: don't issue queries for unused timersNiklas Haas2018-02-051-5/+13
| | | | | | | The vulkan validation layers warn you if you try requesting a query result from a timer that hasn't even been started yet, so we have to do some extra bit of work to keep track of which indices we've seen so far, and avoid the queries on them.
* vo_gpu: vulkan: try enabling required featuresNiklas Haas2018-02-052-0/+10
| | | | | | | Instead of enabling every feature under the sun, make an effort to just whitelist the ones we actually might use. Turns out the extended storage format support is needed for some of the storage formats we use, in particular rgba16.
* vo_gpu: vulkan: add missing buffer barrier fieldsNiklas Haas2018-02-051-0/+2
| | | | These were accidentally omitted.
* vd_lavc: fix recently broken hardware decode fallbackwm42018-02-041-7/+16
| | | | | | | | | This is a dataflow issue caused by the filters change. When the fallback happens, vd_lavc does not return a frame, but also does not accept a new packet, which confuses lavc_process(). Fix this by immediately retrying to feed the buffered packet and decode a frame on fallback. Fixes #5489.
* vf_vapoursynth: always keep input frame array filledwm42018-02-031-1/+3
| | | | | | | | In theory (and practice), this is not needed, because the VS filter get frame callback will cause the process function to be called again if there's not enough data. But it's still a bit weird to just add one more frame on each iteration, so make it cleaner and make it request frames until the input array is full.
* vf_vapoursynth: fix lockingwm42018-02-031-1/+2
| | | | | | | | This was obviously nonsense, and a previous "fix" to this code was nonsense too. What is really needed here is temporarily dropping the lock while calling destroy_vs()/reinit_vs(). Fixes #5470.
* vf_vapoursynth: fix obscure/impossible leakwm42018-02-031-0/+1
| | | | | | | Unknown frames were not freed properly. Although this doesn't really happen anyway, because we're never going to feed audio frames to a video filter chain. Since it's theoretically possible, and all other filters handle this consistently, fix it anyway.
* vf_vapoursynth: fix output colorspace flags and other attributeswm42018-02-031-0/+2
| | | | | | | Properly initialize the output frame parameters other than image format and size. This includes colorspace hints. (We're still not reading them back from VapourSynth if it sets them, though. Usually it doesn't anyway.)
* vf_vapoursynth: fix potential deadlock on init failurewm42018-02-031-1/+1
| | | | | When VS initialization failed, it could hang due to forgetting to release the mutex.
* vf_vapoursynth: initialize start timestamp properlywm42018-02-031-1/+1
| | | | | | | | | VapourSynth can't pass through timestamps, only frame durations. So we need to remember the timestamp of the very first frame passed to it. This was accidentally set to 0 instead of NOPTS on init, so inserting the filter during playback could show strange behavior. Might be part of #5470.
* video: make decoder wrapper a filterwm42018-01-304-776/+125
| | | | | | | | | | | | | | | | | | | | | | | | | Move dec_video.c to filters/f_decoder_wrapper.c. It essentially becomes a source filter. vd.h mostly disappears, because mp_filter takes care of the dataflow, but its remains are in struct mp_decoder_fns. One goal is to simplify dataflow by letting the filter framework handle it (or more accurately, using its conventions). One result is that the decode calls disappear from video.c, because we simply connect the decoder wrapper and the filter chain with mp_pin_connect(). Another goal is to eventually remove the code duplication between the audio and video paths for this. This commit prepares for this by trying to make f_decoder_wrapper.c extensible, so it can be used for audio as well later. Decoder framedropping changes a bit. It doesn't seem to be worse than before, and it's an obscure feature, so I'm content with its new state. Some special code that was apparently meant to avoid dropping too many frames in a row is removed, though. I'm not sure how the source code tree should be organized. For one, video/decode/vd_lavc.c is the only file in its directory, which is a bit annoying.
* mp_image: preserve AVFrame closed captions datawm42018-01-302-0/+8
| | | | | | | | | | This is preparation for a change in vd_lavc.c: it should not have to access the demuxer (to pass along closed captions), so the idea is to make them part of mp_image, and to let the layer above vd_lavc propagate the buffer. Don't bother with preserving them for mp_image->AVFrame, because we don't need this.
* mp_image: factor buffer referencingwm42018-01-301-17/+15
| | | | | | | | | | | Reduce the trivial but still annoying code duplication in mp_image_new_ref(), which has to create new buffer references and deal with possible failure of creating them. The tricky part is that if creating a reference fails, we must set the target to NULL, so that unreferencing the failed new mp_image reference does not release the buffer references of the original mp_image. For the same reason, the code can't jump to error handling when it can't create a new reference, and has to set a flag instead.
* video: rewrite filtering glue codewm42018-01-3021-2616/+1078
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Get rid of the old vf.c code. Replace it with a generic filtering framework, which can potentially handle more than just --vf. At least reimplementing --af with this code is planned. This changes some --vf semantics (including runtime behavior and the "vf" command). The most important ones are listed in interface-changes. vf_convert.c is renamed to f_swscale.c. It is now an internal filter that can not be inserted by the user manually. f_lavfi.c is a refactor of player/lavfi.c. The latter will be removed once --lavfi-complex is reimplemented on top of f_lavfi.c. (which is conceptually easy, but a big mess due to the data flow changes). The existing filters are all changed heavily. The data flow of the new filter framework is different. Especially EOF handling changes - EOF is now a "frame" rather than a state, and must be passed through exactly once. Another major thing is that all filters must support dynamic format changes. The filter reconfig() function goes away. (This sounds complex, but since all filters need to handle EOF draining anyway, they can use the same code, and it removes the mess with reconfig() having to predict the output format, which completely breaks with libavfilter anyway.) In addition, there is no automatic format negotiation or conversion. libavfilter's primitive and insufficient API simply doesn't allow us to do this in a reasonable way. Instead, filters can use f_autoconvert as sub-filter, and tell it which formats they support. This filter will in turn add actual conversion filters, such as f_swscale, to perform necessary format changes. vf_vapoursynth.c uses the same basic principle of operation as before, but with worryingly different details in data flow. Still appears to work. The hardware deint filters (vf_vavpp.c, vf_d3d11vpp.c, vf_vdpaupp.c) are heavily changed. Fortunately, they all used refqueue.c, which is for sharing the data flow logic (especially for managing future/past surfaces and such). It turns out it can be used to factor out most of the data flow. Some of these filters accepted software input. Instead of having ad-hoc upload code in each filter, surface upload is now delegated to f_autoconvert, which can use f_hwupload to perform this. Exporting VO capabilities is still a big mess (mp_stream_info stuff). The D3D11 code drops the redundant image formats, and all code uses the hw_subfmt (sw_format in FFmpeg) instead. Although that too seems to be a big mess for now. f_async_queue is unused.
* vo_gpu: check for RA_CAP_FRAGCOORD in dumb mode tooJames Ross-Gowan2018-01-301-13/+14
| | | | | | | The RA_CAP_FRAGCOORD checks apply to dumb mode as well, but they were after the check for dumb mode, which returns early, so they never ran. Fixes #5436
* video: fix crash with vdpau when reinitializing renderingwm42018-01-271-3/+3
| | | | | | | | | | Using vdpau will allocate additional textures for the reinterleaving step, which uninit_rendering() will free. This is a problem because the hwdec image remains mapped when reinitializing, so the reinterleaving textures are turned into dangling pointers. Fix this by freeing the reinterleave textures on full uninit instead. Fixes #5447.
* hwdec: detach d3d and d3d9 hwaccel from anglemyfreeer2018-01-251-1/+3
|