Commit Graph

46320 Commits

Author SHA1 Message Date
wm4 ceca1602e9 f_lavfi: extend filter help output
Also print type and help string. Also print AV_OPT_TYPE_CONST, which are
like the mpv choice option type, except different. Print them as
separate lines because FFmpeg usually has help strings for them too.
2018-02-13 17:45:29 -08:00
wm4 223821d91c options: minor cleanup to --no-... handling
Most options starting with --no-<name> are automatically translated to
--<name>=no. Make the code slightly nicer by using a flag instead of
explicitly comparing option types. Also fix an issue that made the
option parser print nonsense error messages for if --no-... was used for
options which don't support it.
2018-02-13 17:45:29 -08:00
wm4 d7c38a0b23 options: prefix option with "--" in one case in help output 2018-02-13 17:45:29 -08:00
wm4 7b5a2588bd vo: make opengl-cb first in the autoprobing order
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.
2018-02-13 17:45:29 -08:00
wm4 706bb1d0c7 Fix recent FFmpeg deprecations
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.
2018-02-13 17:45:29 -08:00
wm4 3ffa70e2da filter: extend documentation comments
Add more explanations, and also fix some blatantly wrong things.
2018-02-13 17:45:29 -08:00
wm4 251f4e5d77 filter: simplify/fix external filter graph usage
There was the following problem: if a filter graph had asynchronous
filters, and the filter graph user did not call mp_filter_run() (and
only accessed the mp_pins), then filtering could stall, because using
mp_pin_out_request_data() only recursively invoked filtering if the
data_requested flag wasn't already set. The latter can happen if a
request was tried earlier but failed, and then an asynchronous filter
actually produced output that would satisfy the request. Obviously, it
has to invoke filtering again to get the requested frame.

Fix this by organizing the code differently, and making sure to invoke
mp_filter_run() on every request (if there's nothing to do, it doesn't
do anything anyway). Simplify it a bit by removing things which are not
needed, like connecting filter graphs with different root filters.
2018-02-13 17:45:29 -08:00
wm4 0ec0c147ed audio: don't touch spdif frames in mp_aframe_clip_timestamps()
It can't work for this type of format.
2018-02-13 17:45:29 -08:00
wm4 76947798ea f_lavfi: fix typo in comment 2018-02-13 17:45:29 -08:00
wm4 e167812406 demux: lower demuxer cache default sizes
Reduce backward/forward from 400MB/400MB to 50MB/150MB. Too many
complaints about high memory usage.

Note that external tracks (like ytdl DASH with external audio tracks)
will double the amounts, because an external track uses its own demuxer
and cache.
2018-02-13 17:45:29 -08:00
wm4 2cce782527 filter: adjust root log prefix
Avoids that the audio decoder shows up with a "[root/ad]" log prefix.

This is an annoying consequence of mp_log_new(): if a log parent doesn't
have a prefix with "!", it'll add the prefix to all mp_logs created from
it. This should probably be fixed in the mp_log code itself, but doing
so would be a big deal as we'd have to make sure all the other log
prefixes are what we want. So work it around for now.
2018-02-13 17:45:29 -08:00
wm4 4107a8be6c vf_vavpp: select best quality deinterlacing algorithm by default
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.
2018-02-13 17:45:29 -08:00
wm4 6b2b2b75b9 manpage: remove mention of --vf=eq
This doesn't work anymore.
2018-02-13 17:45:29 -08:00
wm4 d6890c19dd input: add a keybinding to toggle hardware decoding
We sure as hell won't enable hardware decoding by default, but we can
make it more accessible with a key binding.
2018-02-13 17:45:29 -08:00
wm4 830f0aed97 video: make --deinterlace and HW deinterlace filters always deinterlace
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.
2018-02-13 17:45:29 -08:00
wm4 1dcf511376 build: drop support for SDL1
For some reason it was supported for ao_sdl because we've only used SDL1
API.
2018-02-13 17:45:29 -08:00
wm4 02f9087de9 audio: move back PTS jump detection to before filter chain
The recent changes to player/audio.c moved PTS jump detection to after
audio filtering. This was mostly done for convenience, because dataflow
between decoder and filters was made "automatic", and jump detection
would have to be done as filter. Now move it back to after decoders,
again out of convenience. The future direction is to make the dataflow
between filters and AO automatic, so this is a bit in the way. Another
reason is that speed changes tend to cause jumps - these are legitimate,
but get annoying quickly.
2018-02-13 17:45:29 -08:00
wm4 562f563ff1 DOCS/interface-changes.rst: fix typo 2018-02-13 17:45:29 -08:00
James Ross-Gowan 1b80e124db vo_gpu: d3d11: implement tex_download()
This allows the new GPU screenshot functionality introduced in
9f595f3a80 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.
2018-02-13 21:25:15 +11:00
James Ross-Gowan 7d2228c673 vo_gpu: use a variable for the RA_CAP_FRAGCOORD flag
This is just a cosmetic change. Now the RA_CAP_FRAGCOORD check looks
like all the others.
2018-02-13 00:21:26 +02:00
James Ross-Gowan 44dc79dcb0 vo_gpu: check for HDR peak detection in dumb mode too
Similar spirit to edb4970ca8. 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.
2018-02-13 00:21:26 +02:00
Akemi 8762818dd2 build: fix swift detection on major swift versions
the swift version string on major versions only has two components,
major and minor, the third one is missing.
2018-02-12 08:29:22 -08:00
Akemi c82fed85b9 build: fix swift detection with python3
python3 returns bytes instead of str, unlike python2. explicitly decode
the output.
2018-02-12 08:29:22 -08:00
Akemi 3f73520897 build: fix configure on windows
configure failed because of a wrong check. fix the check and also only
check for swift on macOS.
2018-02-12 08:29:22 -08:00
Akemi c5e4538bc4 cocoa-cb: initial implementation via opengl-cb API
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
2018-02-12 04:49:15 -08:00
Akemi 235eb60671 build: fix linking to dev SDK on macOS
on macOS mpv was linked to the system SDK which didn't cause any
problems as long as the system SDK was the same as the dev SDK. though
it started to cause linking warnings when a new xcode version with the
SDK for the next macOS was installed. in the worst case it could also
cause linking errors. to fix this we explicitly set the SDK path to the
SDK that is used for building instead.
2018-02-12 04:49:15 -08:00
Akemi abf2efb107 osx: always deactivate the early opengl flush on macOS
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.
2018-02-12 04:49:15 -08:00
Ricardo Constantino f670c64e59
ytdl_hook: add ytdl:// prefix again for non-youtube playlists
Only youtube playlists return ID-only urls. Other extractors may
return "<extractor>:<ID>" so those still need the ytdl:// prefix.

Reproduced with
http://www.cbc.ca/burdenoftruth/videos/trailers-promos/burden-of-truth-returns
2018-02-11 23:27:37 -08:00
Ricardo Constantino 57228b6581
ytdl_hook: add script opt for using manifest URLs
Disable by default.
This feature was added in 7eb342757, which allowed stream selection
in runtime. Problem with this atm is that FFmpeg will try to demux
every first packet of every track leading to noticeable delay opening
the URL.

This option can be changed to enabled by default or removed when
HLS/DASH demuxers are improved upstream.
2018-02-11 23:27:37 -08:00
Ricardo Constantino 664e8fe66a
ytdl_hook: parse youtube playlist urls to set start index
Still needs `--ytdl-raw-option=yes-playlist=` because this only
works for youtube.

This was requested in a few issues:
https://github.com/mpv-player/mpv/issues/1400
https://github.com/mpv-player/mpv/issues/2592
https://github.com/mpv-player/mpv/issues/3024

For #1400 to be completely implemented would need ytdl_hook to
re-request the same playlist with the last video's ID for the mix to
continue indefinitely which would probably too hackish to work reliably.
2018-02-11 23:27:36 -08:00
Ricardo Constantino 976daf1942
ytdl_hook: exit early, save an indentation level 2018-02-11 23:27:36 -08:00
Ricardo Constantino bf3549839e
ytdl_hook: various nit
Remove obsolete comment about FFmpeg ignoring non-http proxies
which was repeated in ytdl_hook before the feature was added.

Remove unnecessary conditions for not nil. Lua tables will always
return nil for non-existent keys.
2018-02-11 23:27:36 -08:00
Ricardo Constantino 3e71eb8676
ytdl_hook: whitelist subtitle URLs as well
This was overlooked when doing the whitelisting for video and audio to
fix #5456.
2018-02-11 23:25:56 -08:00
Ricardo Constantino 268431c858
ytdl_hook: use fallback if there's no demuxer-lavf-list prop
This is important if backporting by grabbing the latest version of
the script without backporting the commit that added the property:

828bd2963c
2018-02-11 23:25:05 -08:00
Kevin Mitchell 40f29a33df
appveyor: trigger build on pushing to 'ci'
This way, both travis and appveyor can be manually triggered
simultaneously.
2018-02-11 18:13:12 -08:00
Marco Migliori 7916201401 vo_drm: support --monitorpixelaspect
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.
2018-02-11 17:51:15 -08:00
Marco Migliori 733bcc03f6 vo_drm: reset last input image on reconfig
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.
2018-02-11 17:51:15 -08:00
Marco Migliori 3a2bc158bb vo_drm: make the osd as large as the screen
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.
2018-02-11 17:51:15 -08:00
wm4 9f595f3a80 vo_gpu: make screenshots use the GL renderer
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.
2018-02-11 17:45:51 -08:00
wm4 7b1e73139f vo_gpu: add internal ability to skip osd/subs for rendering
Needed for the following commit.
2018-02-11 17:45:51 -08:00
wm4 bff8cfe3f0 vo_gpu: use blit() only if target ra_tex supports it
Even if RA_CAP_BLIT is set, this might just not be enabled for the
target ra_tex.
2018-02-11 17:45:51 -08:00
Niklas Haas ff08df5bb1 vo_gpu: add memory barrier on the HDR peak detection
This can cause the peak detection state to be inconsistent in rare
cases, which might explain the issues when taking screenshots in #5499.
2018-02-11 16:45:20 -08:00
Niklas Haas 4e7f4f10ce vo_gpu: correctly infer HDR peak detection support
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.
2018-02-11 16:45:20 -08:00
Niklas Haas 4c2edecd7d vo_gpu: refactor HDR peak detection algorithm
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)
2018-02-11 16:45:20 -08:00
Ricardo Constantino 20df21746a
appveyor: use undocumented --ask to force yes for all questions
Also, remove progressbar, just spammy for reason.
2018-02-11 14:16:50 +00:00
Zehua Chen 000a0e2775
player: correctly set track information on adding external files
Before this commit, auto_loaded and lang were only set for the first
track in auto-loaded external files. Likewise, for the title and
lang arguments to the sub-add and audio-add commands.

Fixes #5432
2018-02-10 06:50:32 -08:00
Rostislav Pehlivanov 6161cfd781 wayland_common: fix idle_inhibitor protocol segfault
The pointer is used as a state and wasn't zeroed after seeks.
2018-02-09 21:16:14 +02:00
LongChair b01623e0d2 drmprime interop : Add frames triple buffering
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
2018-02-07 22:40:30 -08:00
wm4 9282a34fbf vd_lavc: fix stall with some uses of --hwdec=copy
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.
2018-02-05 23:34:42 -08:00
Niklas Haas e3d93fde2f vo_gpu: port HDR tone mapping algorithm from libplacebo
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.
2018-02-05 23:11:18 -08:00