Commit Graph

48246 Commits

Author SHA1 Message Date
wm4 641d102101 msg: slightly improve --msg-time output
Cut the arbitrary offset, and document what unit/timesource it uses.
2020-02-14 16:12:37 +01:00
wm4 5793cb40c8 stream: early-out in stream_seek_skip() if nothing is skipped
stream_seek() might somewhat show up in the profiler, even if it's a
no-OP, because of the MP_TRACE() call. I find this annoying. Otherwise,
this should be of no consequence, and should not break or improve
anything.
2020-02-14 16:08:54 +01:00
wm4 c59ca06a0f stream_file: cache file size
Some cache logic in demux.c queries the raw byte stream size on every
packet read. This is because it reports the value to the user. (It has
to be polled like this because there is no change notification in most
underlying I/O APIs, and also the user can't just block on the demuxer
thread to update it explicitly.)

This causes a very high number of get_size calls with low packet sizes,
so cache the size, and update it on every read. Reads only happen
approximately all 64KB read with default settings, which is way less
frequent than every packet in such extreme cases.

In theory, this could in theory cause problems in some cases. Actually
this is whole commit complete non-sense, because why micro-optimize for
broken cases like patent troll codecs. I don't need to justify it
anyway.

As a minor detail, off_t is actually specified as signed, so the off_t
cast is never needed.
2020-02-14 16:07:13 +01:00
wm4 777c046b35 manpage: clarify --player-operation-mode
options.rst to clarify the option, some more text in mpv.rst to separate
out the compatibility stuff a little.

Fixes: #7461 (options.rst change only)
2020-02-14 12:58:45 +01:00
Dudemanguy 83efdb5a01 wayland: make resizing better
Resizing the window while preserving the aspect ratio actually kind of
sucked. The window size could make big dramatic changes which was pretty
unintuitive with respect to where the mouse was actually located.
Instead, let's just do some math to ensure that the window size is
always contained inside the width/height reported by
handle_toplevel_config while preserving the aspect ratio. Fixes #7426.
2020-02-13 20:28:59 +00:00
wm4 cc52a03401 audio: slightly simplify pull underrun message printing
A previous commit moved the underrun reporting to report_underruns(),
and called it from get_space(). One reason was that I worried about
printing a log message from a "realtime" callback, so I tried to move it
out of the way. (Though there's little justification other than a bad
feeling. While an older version of the pull code tried to avoid any
mutexes at all in the callback to accommodate "requirements" from APIs
like jackaudio, we gave up on that. Nobody has complained yet.)

Simplify this and move underrun reporting back to the callback. But
instead of printing the message from there, move the message into the
playloop. Change the message slightly, because ao->log is inaccessible,
and without the log prefix (e.g. "[ao/alsa]"), some context is missing.
2020-02-13 18:02:16 +01:00
Dudemanguy 374c6aff7b wayland: fix autofit and rotating issues
Fixes #7441. Just set screenrc to be equal to current_output's geometry.
Also remove some pointless/extra variables and print a warning/fallback
to screen 0 if a bad id is passed to --fs-screen.
2020-02-13 16:01:59 +00:00
wm4 5bf433b16f player: consider audio buffer if AO driver does not report underruns
AOs can report audio underruns, but only ao_alsa and ao_sdl (???)
currently do so. If the AO was marked as not reporting it, the cache
state was used to determine whether playback was interrupted due to slow
input.

This caused problems in some cases, such as video with very low video
frame rate: when a new frame is displayed, a new frame has to be
decoded, and since there it's so much further into the file (long frame
durations), the cache gets into an underrun state for a short moment,
even though both audio and video are playing fine. Enlarging the audio
buffer didn't help.

Fix this by making all AOs report underruns. If the AO driver does not
report underruns, fall back to using the buffer state.

pull.c behavior is slightly changed. Pull AOs are normally intended to
be used by pseudo-realtime audio APIs that fetch an audio buffer from
the API user via callback. I think it makes no sense to consider a
buffer underflow not an underrun in any situation, since we return
silence to the reader. (OK, maybe the reader could check the return
value? But let's not go there as long as there's no implementation.)
Remove the flag from ao_sdl.c, since it just worked via the generic
mechanism. Make the redundant underrun message verbose only.

push.c seems to log a redundant underflow message when resuming (because
somehow ao_play_data() is called when there's still no new data in the
buffer). But since ao_alsa does its own underrun reporting, and I only
use ao_alsa, I don't really care.

Also in all my tests, there seemed to be a rather high delay until the
underflow was logged (with audio only). I have no idea why this happened
and didn't try to debug this, but there's probably something wrong
somewhere.

This commit may cause random regressions.

See: #7440
2020-02-13 01:32:58 +01:00
wm4 f3c498c7f1 ao: avoid unnecessary wakeups
If ao_add_events() is used, but all events flags are already set, then
we don't need to wakeup the core again.

Also, make the underrun message "exact" by avoiding the race condition
mentioned in the comment.

Avoiding redundant wakeups is not really worth the trouble, and it's
actually just a bonus in the change making the ao_underrun_event()
function return whether a new underrun was set, which is needed by the
following commit.
2020-02-13 01:28:14 +01:00
wm4 7e6ea02183 zimg: fix previous odd sizes commit
Obviously, we don't want to lose fractions, and the zimg active_region
fields in fact have the type double. The integer division was wrong.

Also, always set active_region.width/height. It appears zimg behavior
does not change if they're set to the normal integer values, so the
extra check to not set them in this case was worthless.
2020-02-13 01:26:51 +01:00
wm4 ffd89f5ff4 manpage: fix typo on sub-end
Fixes: #7455
2020-02-12 19:13:05 +01:00
wm4 c3f93f5fdd sws_utils: use zimg by default if available
This seems stable enough to use. Change the default, and remove it from
the sw-fast profile.
2020-02-12 18:06:53 +01:00
wm4 7c8b40c38a zimg: correct output to odd (chroma un-aligned) sizes
As suggested by the zimg author: active_region is not supported on
outputs (and the API returns an error), so instead scale to the "full"
surface, but adjust the source rectangle such that the cropped output
image happens to cover the correct region.

Does this even work? Since Balmer Peak doesn't work, I can't really say,
but it seems to look correct.
2020-02-12 18:01:22 +01:00
wm4 0848f3f832 zimg: fix typos in a comment
Also remove the "o" case, which was never implemented (probably was an
idea to output alpha formats, now obsoleted by zimg's full alpha
support).
2020-02-12 17:54:35 +01:00
wm4 5a45a4ca39 vo_drm, wo_wlshm: mention that it's software scaling
(But does anyone even read --vo=help output?)
2020-02-11 21:45:16 +01:00
wm4 2337e2861f vo_x11: don't call X11 "crap"
X11 is in fact beautiful and superior to Wayland. Instead, just state
what the problem is in most cases: software scaling. (We have
accelerated X11 rendering in vo_gpu and others.)
2020-02-11 21:43:53 +01:00
wm4 8c2179becf zimg: add pal8 unpacker
Some pngs are paletted, so this is vaguely interesting.
2020-02-10 19:01:21 +01:00
wm4 d699893dbd img_format: add alias for ffmpeg pal8 format
For the next commit.
2020-02-10 18:59:59 +01:00
wm4 a8404ed0a0 manpage: add some blabla about zimg speed vs. libswscale
Of course nobody will read this. I'm just putting it there so I can
blame users, who run into problems, for not having read it.
2020-02-10 18:59:34 +01:00
wm4 83f070dfb8 zimg: rename zplanes field
This was a confusing name, because 1. there's also a z_planes[] field,
and 2. it was not specific to zimg indexes.

Possibly there used to be an idea involved about supporting alpha to
non-alpha formats by discarding the alpha plane, but zimg does this now
(and zimg will correctly blend the alpha component too).
2020-02-10 17:59:13 +01:00
wm4 a9116ddd38 zimg: support gray/alpha conversion
The special thing about this format is

1. mpv assigns the component ID 4 to alpha, and component IDs 2 and 3
   are not present, which causes some messy details.
2. zimg always wants the alpha plane as plane 3, and plane 1 and 2 are
   not present, while FFmpeg/mpv put the alpha plane as plane 1.

In theory, 2. could be avoided, since FFmpeg actually doesn't have a any
2 plane formats (alpha is either packed, or plane 3). But having to skip
"empty" planes would break expectations.

zplanes is not equivalent to the mpv plane count (actually it was always
used this way), while zimg does not really have a plane count, but does,
in this case, only use plane 0 and 3, while 2 and 3 are unused and
unset. z_planes[] (not zplanes) is now always valid for all 4 array
entries (because it uses zimg indexes), but a -1 entry means it's an
unused plane.

I wonder if these conventions taken by mpv/zimg are not just causing
extra work. Maybe component IDs should just be indexes by the "natural"
order (e.g. R-G-B-A, Y-U-V-A, Y-A), and alpha should be represented as a
field that specifies the component ID for it, or just strictly assume
that 2/4 component formats always use the last component for alpha.
2020-02-10 17:57:01 +01:00
wm4 c31661466b zimg: fix some confusion about plane permutation
We reorder the planes between mpv and zimg conventions. It turns out the
code still confused when which convention was used.

So the way it actually works is that the _only_ place where zimg order
is used is the zimg_image_buffer.plane[] array. plane_aligned[] and
zmask[] were accessed incorrectly, although I guess it rarely had a
reason to fail (plane reordering is mostly for RGB, which has planes of
all the same size).

Adjust some comments accordingly too.
2020-02-10 17:45:20 +01:00
wm4 a841fe9484 img_format: add gray/alpha planar formats
The zimg wrapper "needs" these formats as intermediary when repacking
the normal gray/alpha packed format. The packed format is used by the
png decoder and encoder, and is thus interesting.

Unfortunately, mpv-only formats are a mess right now, because all the
existing code is focused around using the FFmpeg metadata for pixel
formats. This should be improved, but not now, so make the mess worse.

This commit doesn't add support for it to the zimg wrapper yet.
2020-02-10 17:38:54 +01:00
wm4 cca02e51ef zimg: add alpha support
libzimg recently added direct alpha support and new API for it. (The API
change is rather minimal, and it turns out we can easily support old and
new zimg versions.)

This does not support _all_ alpha formats. For example, gray + alpha is
not supported yet, because my stupid design in the zimg wrapper would
require a planar gray + alpha format, while ffmpeg provides only a
packed one.
2020-02-09 19:16:54 +01:00
wm4 c9963c1368 vo: fix typo in comment 2020-02-09 18:32:28 +01:00
wm4 ee4a8f0d57 vf_format: add w, h parameters
Yes, this thing became vf_scale through the back door.
2020-02-09 18:23:22 +01:00
Dan Oscarsson eb1d50ba20 sub: enhance SDH filtering
It is not uncommon with a speaker label with [xxxx] inside.
They should also be filtered out.
2020-02-09 16:18:34 +01:00
der richter a8553578eb github: fix a typo in the contact links info 2020-02-09 13:25:29 +01:00
der richter c3298ad416 github: ask users to first reproduce the issue with --no-config 2020-02-09 13:25:29 +01:00
der richter 1881698543 mac: always include the macOS config when cocoa is available
the macOS config was only used in cocoa-cb before and only included when
it was available. since this config is meant for general macOS options
and backend independent options we include it when cocoa is available.
one of the options is already used in the old cocoa backend, which broke
using it when build without swift or cocoa-cb support.

Fixes #7449
2020-02-09 11:45:55 +01:00
Philip Langdale 6799f8e0e9 bash completion: complete ao/af/vo/vf options
I didn't handle these originally, but it turns out that they can be
handled with the samel logic as Choice options.
2020-02-08 09:50:58 -08:00
Philip Langdale 8676f4616c bash completion: Cache the options list
The bash completion seems to be working decently at this point, so I
feel comfortable caching the options output to improve the performance
of the completion.
2020-02-08 09:50:58 -08:00
Dan Oscarsson 18070f7405 sub: fix SDH filtering after change
The change, in an earlier commit, in format for ass to handle results
in a different number of fields to skip. Correct that so SDH filtering
works.

Should fix issue #7188
2020-02-08 18:10:04 +01:00
wm4 e9fc53a10b player: add ab-loop-count option/property
As requested I guess. It behaves quite similar to the --loop* options.

Not quite happy with the idea that 1) the option is mutated on each
operation (but at least it's consistent with --loop* and doesn't require
more properties), and 2) the ab-loop command will do nothing once all
loop iterations are done. As a concession, the OSD shows something about
"disabled".

Fixes: #7360
2020-02-08 15:01:33 +01:00
wm4 3fb0cc203b DOCS/interface-changes.rst: mention it's for incompatible changes
This is not really a changelog, but rather a list of potentially
breaking changes API- and normal users should be aware of, and to help
with migration from older mpv releases.
2020-02-08 14:44:53 +01:00
wm4 27d84de2f4 DOCS/interface-changes.rst: mention OSX bundle logging 2020-02-08 14:43:01 +01:00
der richter 5d7f0edfeb cocoa-cb: fix auto-selection of title bar style with older SDKs
returning a nil value only works when build with a +10.14 SDK otherwise
we need to fallback to the old mechanism.
2020-02-08 11:00:55 +01:00
der richter 3ad9c32a5f cocoa-cb: simplify cursor hiding and make it less greedy
for reasons unknown to me the NSCursor (un)hide functions can be
completely unreliable and the cursor can have an unknown state. this
only happens on some system and wasn't able to reproduce this. it's
probably some dumb race condition that might be possible to work around,
though because of the lack of reproducibility on my end it's hard to
test.

i decided to rework the cursor hiding code yet again and make it a lot
less greedy. the cursor will now always unhide when moved and there
will never be a situation again the cursor can't be unhidden again.
on the other hand there might be edge cases now where the cursor won't
hide immediately and you have to move it slightly to make it disappear
again. this should be an acceptable tradeoff.

Fixes #6886
2020-02-08 10:56:11 +01:00
der richter 2607a2b892 mac: activate logging when started from the bundle
this creates a default log for the last mpv run when started from the
bundle. that way one can get a log of what happened even after an issue
occurred. also add a menu entry under Help to show the current log, but
only when the bundle is used.

Fixes #7396
Fixes #2547
2020-02-08 10:55:07 +01:00
der richter b7b8a772f2 mac: remove stdout and stderr redirect for logging
this was kinda useless anyway since the bundle was started with
terminal=no and no logging was done anyway.

Fixes #1590
2020-02-08 10:55:07 +01:00
Dudemanguy af021a2891 wayland: adjust vo_wayland_wait_frame logic
Wayland uses vo_wayland_wait_frame plus some polling with a timeout for
blocking on vsync. Here are a couple of changes that seem to be
improvements. First, the poll time is always rounded up instead of
truncated. When rendering frames longer than the standard 16.666 ms
timeout, it seems that truncating the poll time slightly early may cause
some vsync jitter spikes. Waiting longer, even if it's too long, appears
to behave better.

The second change is to use wl_display_roundtrip instead of
wl_display_dispatch_pending. wl_display_dispatch_pending dispatches all
events immediately. This is good to avoid blocking, but it's not
guaranteed to wait long enough for all events to be processed on the
display fd. The preceding wl_display_read_events routine ensures that
all events on the display fd are queued. We just need a semi-blocking
routine to dispatch them for the most reliable vsync.

wl_display_roundtrip will dispatch any events for us, but also wait for
a reply from the display server. This makes it ideal for this role. If
the compositor doesn't reply to the client something else is probably
horribly broken and wrong anyway. It's also not a permanently blocking
call like wl_display_dispatch. If there's no frame callback (i.e. the
window is hidden), then it does not dispatch any events and returns
immediately.
2020-02-07 18:33:32 +00:00
Avi Halachmi (:avih) c4570be3b8 DOCS: js: minor update for require 2020-02-07 19:24:00 +02:00
Avi Halachmi (:avih) 756960bf3c js: require: directory-scripts: first look at <dir>/modules/
Also, add the function mp.get_script_directory() to let scripts know if
they're loaded as a directory and where.
2020-02-07 18:22:12 +02:00
Avi Halachmi (:avih) 68a1b47d4d js: require: don't use ~~/scripts/modules.js/
Directories inside ~~/scripts/ are now loaded as scripts, so don't use
it also for modules. Now there are no default module paths.

To compensate, we now try to run ~~/.init.js right after defaults.js,
so the user may extend the js init procedure via this script, e.g. for
adding default paths to mp.module_paths .
2020-02-07 18:20:33 +02:00
wm4 10a97f7cc3 osc: use cache state cache-duration field
Avoids an additional property access; see previous commit.
2020-02-07 16:16:18 +01:00
wm4 11d223228c command: add cache-duration to cache state property
Convenience; see following commit.
2020-02-07 16:15:55 +01:00
wm4 27d5d32020 demux: add option to disable "sharing" between back and forward buffers
As requested. I guess option name and manpage text could be better and
clearer.

Closes: #7442
2020-02-07 15:58:13 +01:00
wm4 c48fd48f1e console: fix typo in previous commit
Now keypad enter actually works.
2020-02-07 14:05:04 +01:00
wm4 f659cfd6e3 console: manually map numeric keypad (KP*) bindings
While mpv normally uses the text a key produces (as opposed to physical
key mappings), this is different with the keypad. This is for the sake
of making it possible to distinguish between these keys and the normal
number keys on the left side of a full size keyboard.

There were complaints that the keypad doesn't interact with console.lua,
so manually map them. This ignores numlock (behaves as if it's always
on), and maps KP_DEC to "." (even though it's mapped to "," on some
keyboards). The /*-+ keys produce ASCII on mpv (at least with X11) as an
inexplicable inconsistency, so there are no mappings for these.

Fixes: #7431
2020-02-07 13:51:25 +01:00
wm4 c33bbc8694 screenshot: fix typo in comment
It was not meant to imply that screenshots are male. Female (and other)
screenshots are also welcome to this project.
2020-02-07 13:42:42 +01:00