Commit Graph

49015 Commits

Author SHA1 Message Date
Niklas Haas a74b6619f2 csputils: add MP_CHROMA_TOPLEFT
This is commonly used by UHD/HDR sources, and mpv hilariously ignores it
up until now, just blindly mapping it to MP_CHROMA_AUTO without even so
much as a warning message.

It would be justified to add all the other chroma locations as well, but
I'm lazy and just wanted to quickly fix this bug.
2020-12-02 01:36:29 +01:00
der richter f16c6472a1 travis: use newer 10.15 VM with newer xcode 2020-11-29 16:02:45 +01:00
der richter b9a682edcf travis: fix macOS 10.13 build
homebrew is removing 10.13 support and some of the dependencies start
building rom source now. we will just pin the last working homebrew
version, similar to the 10.12 build
2020-11-29 16:02:45 +01:00
Avi Halachmi (:avih) aba77c64ff vo_sixel: don't leak the frame reference
The reference is allocated at reconfig and happens at least once (and
leaked at least once), but can also be called more, e.g. on zoom or
pan-and-scan changes.
2020-11-29 14:15:51 +02:00
Avi Halachmi (:avih) 824e569fb5 vo_tct: don't leak the frame reference
The reference is allocated at reconfig (and leaked at least once), but
could theoretically be called more than once by mpv, or in the future
when the tct code is enhanced to hande e.g. pan-and-scan changes.
2020-11-29 14:15:51 +02:00
Avi Halachmi (:avih) d4233021c7 vo_tct: remove unused variable 2020-11-29 14:15:51 +02:00
sfan5 6ebac1f794 player: allow vo to be switched at runtime 2020-11-27 17:28:59 +01:00
sfan5 10fbd305c8 demux: add function to refresh a track without (de-)selecting it 2020-11-27 17:28:59 +01:00
Shreesh Adiga 4d80314c5c vo_sixel: use draw_frame instead of draw_image
draw_image is deprecated, and draw_frame allows better
behavior, like rendering the osd without image.
e.g. `mpv --vo=sixel --idle --force-window`.
2020-11-27 15:31:24 +02:00
Shreesh Adiga 4dd5fdc087 vo_sixel: skip testdither init in fixed palette
testdither was being created irrespective of whether
opt_fixedpal is set or not. In case of opt_fixedpal=1,
testdither is not used in the `prepare_static_palette`
code. Hence only initialize it when opt_fixedpal is 0.
2020-11-27 15:31:24 +02:00
Shreesh Adiga 24525e4ef9 vo_sixel: Update libsixel constant values
In sixel_dither_initialize, replace 3 with the libsixel
SIXEL_PIXELFORMAT_RGB888. Also in sixel_encode, the 4th
parameter is supposed to be depth, which also happens
to be the value of PIXELFORMAT_RGB888, so replacing that
constant with the depth value.
2020-11-27 15:31:24 +02:00
LaserEyess 8886f017a1 matroska.py: remove python2 support
Since 0.33.0 mpv does not support python2. This commit removes
python2 support from the file completely with the following
changes:

 - __future__ import of print_function is python2 only
 - unicode literals are legacy in python3
 - 'sys.version_info.major < 3' check is redundant
2020-11-27 11:17:29 +01:00
LaserEyess d7e80dee26 bootstrap.py: remove all python2 support
In 0.33.0 python2 support has been removed from mpv's build system. This
commit removes python2 compatibility code from bootstrap.py with the
following changes:

 - __future__ import for print_function is not needed
 - urllib2 is python2 only
2020-11-27 11:17:29 +01:00
Avi Halachmi (:avih) 62fb374349 vo_sixel: change default dither to "auto"
For two reasons:
1. It was counter intuitive that there's an "auto" value (which is
   actually a libsixel value and not an mpv one), but it's not the
   default value - our default was Atkinson.
2. "auto" provides better dithering than Atkinson with libsixel, which
   is especially noticeable with smooth gradients - where Atkinson has
   visible banding.

In libsixel 1.8.2 the "auto" value maps to Atkinson if the output
palette has up to 16 colors, or to Floyd-Steinberg otherwise (e.g.
using fixed palette with 256 colors chooses Floyd-Steinberg).
2020-11-27 00:25:32 +02:00
Avi Halachmi (:avih) 59c32a04b0 vo_sixel: fix the image corruption with mlterm
The issue was that we only uploaded the palette to the terminal when it
changed (once on init with fixed palette, every frame with dynamic
palette with trheshold=-1, only on scene change with threshold >= 0).

Now we upload it on every frame, and it seems to fix the mlterm image
corruption both with fixed palette and also with dynamic palette with
threshold (i.e. at frames which did not upload a palette).

It's not entirely clear why it's required with mlterm.

It would seem that the palette which libsixel uses with fixed palette
matches the built in default palette in xterm, but not in mlterm.
With dynamic palette we can guess that mlterm resets the palette after a
sixel image, but that's not confirmed.

Uploading the palette on every frame doesn't seem to slow down xterm
when using fixed palette - not clear yet why uploading a different
palette (when using fixedpalette=no) slows it down while same palette
on every frame doesn't.

In mlterm there's no slowdown either way - and now also no corruption.
2020-11-27 00:25:32 +02:00
Avi Halachmi (:avih) 1bb2665e3d vo_sixel: support --vo-sixel-exit-clear[=yes]
By default we still clear the screen, but now it's possible to leave the
last sixel image on screen.

Allows mpv to be used as img2sixel of sorts, but with our auto-fit and
various mpv scaling/filters etc.
2020-11-27 00:25:32 +02:00
Guido Cella 9867f21830 terminal: process input when foregrounded
When mpv is in the background because it was started with
`mpv foo.mp3 &`, or the user did ctrl+z bg, and is then brought to the
foreground with fg, it buffers input until you press enter. This makes
it accept input almost immediately. Having a short interval isn't
important, since input is buffered until the next loop iteration.

Closes #8120.
2020-11-26 23:55:59 +02:00
sfan5 fa7afc3e19 Update VERSION 2020-11-22 18:48:20 +01:00
sfan5 0728b51498
Release 0.33.0 2020-11-22 18:46:28 +01:00
sfan5 6bb73040dd file2string: remove question mark from safe chars
Trigraphs such as "??=" (which are enabled by default with -std=c11)
can mess up strings, so avoid them entirely by escaping question marks.

This also drops Python 2 compatibility from file2string, making the
change to the waf rule necessary. The input file is now opened in
binary mode which is also more correct versus the old text mode
which just happened to work even on binary files.
2020-11-22 17:16:57 +01:00
rcombs 4dcaf70b96 Revert "options: disable vsfilter blur compat by default"
This reverts commit 3d17e19c2c.

The effect of turning off this setting is that mpv doesn't tell libass what
the video stream's resolution is. This happens to result in some files having
their transforms scaled in ways that give higher performance (as described
in #7435) because libass happened to guess a video resolution that resulted
in transforms yielding smaller bitmaps, but it's just as easy for the opposite
to happen depending on the resolutions and effects involved.

The option's name is also somewhat misleading: setting the storage size affects
blur, but it also affects stroke (which is far more important for the vast
majority of scripts) and 3D transforms (which look very screwy when done wrong).
2020-11-22 17:37:43 +02:00
Uoti Urpala 2409300d40 build: always run waf with python3
Upstream waf still ships with the default interpreter being "python",
though the script works with both Python 2 and Python 3 (they're not
changing the default choice during 2.0.x releases for compatibility
reasons apparently). Add code to bootstrap.py to change the
interpreter from "python" to "python3" when downloading the "waf"
file.

Running any mpv code under Python 2 should be considered unsupported
in the future (and any code added need not work under Python 2).
2020-11-22 13:59:26 +01:00
der richter 5ae6f04d6b build: fix macOS arm builds
remove the hardcoded swift target version and move the version
restriction to configure. this was a bad idea anyway and could lead to
mismatched object files between obj-c and swift. fix travis 10.12 legacy
build.

also update the SDK version parser to handle the new macOS 11 scheme.

Fixes #8281
2020-11-22 13:44:16 +02:00
Shreesh Adiga 959097c880 vo_sixel: draw osd on the output frame 2020-11-22 13:34:25 +02:00
Shreesh Adiga 8a278c2ddd vo_sixel: return -1 instead of SIXELSTATUS on failure
Currently in mpv functions sixel failures return the
value status which is of type SIXELSTATUS. So changing
it to -1 which is explicit and compatible with mpv.
Also log the errors using MP_ERR/MP_LOG with the
error string returned by libsixel to have more info.
2020-11-22 13:34:25 +02:00
Shreesh Adiga b48e0b11d9 vo_sixel: set --vo-sixel-fixedpalette=yes by default
fixedpalette seems to be slightly faster than dynamic
palette, and also in mlterm it avoids corruption of
too bright values overflowing to black. Hence setting
it to be default choice instead of dynamic palette.
2020-11-22 13:34:25 +02:00
Shreesh Adiga 6ad3e2bfbd vo_sixel: Add aspect ratio based output centering
Resize the image based on the dimensions reported by
vo_get_src_dst_rects to correctly handle aspect ratio
that might be set/ignored.

Added pad-x and pad-y options for padding.
These options will be used to remove the extra padding.
Some terminals report the padding of 2px in the ioctl
dimensions which can't be used for displaying sixel
output. These options can be used for fine tuning
the output video resolution.

Now all the terminal size detection and calculation logic
is done in a single function at resize. Also top and left
values are computed from the dst_rect parameters to simplify
the logic for the aspect ratio based centering.

Additionally vo-sixel-rows and vo-sixel-cols options
have been added to enable the user to override the values
in case of failures with get_terminal_size2.

This commit also adds ability to handle video zoom correctly.
Whenever video-zoom is triggered, the src and dst rects
will be updated. Scaling seems to work well now.
2020-11-22 13:34:25 +02:00
Shreesh Adiga c615e51051 vo_sixel: rename all user options with opt_ prefix
This has no changes to mpv sixel playback behaviour.
This is required because currently the offset values
and the resolutions are being overwritten and not
remembered.
2020-11-22 13:34:25 +02:00
Shreesh Adiga 71b21b9339 vo_sixel: set output resolution based on terminal_get_size2 2020-11-22 13:34:25 +02:00
Shreesh Adiga 670f23f169 osdep/terminal: Add function to get terminal pixel dimensions 2020-11-22 13:34:25 +02:00
Emanuele Torre 38275338ee doc: split BNF definitions of <command> and <argument> in separate lines
Having them in the same line made it hard to read them in the man page
since they are formatted in the same way and they look as though they
are only one definition.
2020-11-22 01:23:42 +02:00
Leo Izen 9b5672ebed manpage: document improved --playlist security
Recent versions of mpv have applied security checks to --playlist
that previously only existed if playlist files were played as an
input directly. This commit documents this change and how to work
around it, in the event that playlist files are trusted.
2020-11-18 17:30:07 -05:00
Avi Halachmi (:avih) 24d6961833 command: mouse: generate MOUSE_{ENTER,LEAVE} if required
Previously the mouse command never ended up in enter/leave keypresses
for the default section even when logically required, because input.c
does not know the area of the default section and relies on something
feeding it ENTER/LEAVE presses - which the VO typically does but the
mouse command didn't.

Now the mouse command feeds it ENTER/LEAVE if required.

It's possible to handle it differently and more consistently by:
1. reverting this commit.
2. Updating the default section area whenever the osd dimensions change.
3. Always ignore MOUSE_ENTER keys because the position is not known yet
   (but MOSE_MOVE typically follows right away).
4. On mouse move: first generate ENTER/LEAVE if required.

That would guarantee consistency between mouse position and enter/leave
events but could be more sensitive to manage (the default section has
"infinite" area which is used to capture any event outside of specific
section areas), while this commit keeps consistency same as before and
depending on correct external feeding - which we now do better, even if
still not optimally (like before, it's still technically possible that
a script recieves MOUSE_ENTER and then reads the position before it got
updated after the ENTER).
2020-11-16 20:29:58 +02:00
Avi Halachmi (:avih) 3710c154d4 docs/input.rst: document the mouse-pos property 2020-11-16 20:29:58 +02:00
Avi Halachmi (:avih) 58004ea2ef command: mouse-pos property: add field "hover"
Add a third field: "hover", which is updated from input.c after input
keys MP_KEY_MOUSE_LEAVE and MP_KEY_MOUSE_ENTER - which are typically
sent by the VO.

It's part of mouse-pos and not a new property because it's highly tied
to mouse-pos - it makes x/y invalid while the cursor doesn't hover the
window.

Unike mouse-move, no dummy command was generated, so we add dummy
command in order for observer notification to work even while nothing
is bound.

Like mouse-pos, clients could not detect whether the mouse pointer
hovers the window because the OSC force-binds the MOUSE_LEAVE key, and
now they can using the hover field.

The lua mp.get_mouse_pos() wrapper still returns only x, y because
that's what osc.lua needs. Other clients can simply read the property.
2020-11-16 20:29:58 +02:00
Avi Halachmi (:avih) 0d5055fe93 lua/js: mp.get_mouse_pos: use the mouse-pos property
mp.get_mouse_pos() is undocumented and is no longer required - the
property can be used officially by any client now, however, osc.lua
uses it, and also some user scripts learnt to rely on it, so we keep
it - as a trivial wrapper around the new mouse-pos property.
2020-11-16 20:29:58 +02:00
Avi Halachmi (:avih) a768667956 command: new property: mouse-pos
This is a read-only MPV_NODE value with integer fields: x, y.
The values are unmodified from mp_input_get_mouse_pos(...).

Observer notification of this property is tied to the INPUT_PROCESSED
event, which fires after mouse move even if no command is bound
(dummy commands are generated if nothing is bound to ensure that
mp_input_get_mouse_pos returns the latest values - see ac927e39 ).

This allows clients such as JSON IPC to observe mouse position even
while the OSC is enabled - the OSC force-binds mouse move for most
of the window area, making it impossible for other clients to bind
mouse move without breaking the OSC.
2020-11-16 20:29:58 +02:00
Avi Halachmi (:avih) 799d3d4557 command: add internal INPUT_PROCESSED event
Fires after a non-empty input queue was processed.

Currently yet unused, but the next commit will use it.
2020-11-16 20:29:58 +02:00
wm4 26fc70dbfd path: do not use old_home for win32 exe dir
Apparently mpv supports loading config files from the same directory as
the mpv.exe. This is a fallback of some sort. It used the old_home
mechanism.

I want to add a warning if old_home exists, but that would always show
the warning on win32. Obviously we don't want that.

Add a separate exe_dir entry to deal with that.

Untested, but probably works.

Mistakenly reverted as part of the default configuration directory
location switch-back in aa18a8e1cd.

Separation of the mpv executable directory from old_path is a
good change now that we warn about the old_config directory also
existing.

Fixes #8232
Fixes #8244
Fixes #8262
2020-11-16 00:44:40 +02:00
Avi Halachmi (:avih) 932c1ada0f js: report scripts CPU/memory usage statistics
This can be viewed at page 4 of the internal stats display (i or I).

CPU time report is the same as at lua.c, but untested - doesn't seem
to work on windows - also not for lua.

TL;DR: Set env MPV_LEAK_REPORT=1 to enable js memory reporting stats.
       This also almost doubles the memory usage by js scripts.

For memory reporting, we don't have enough info by default, because
even when using a custom allocator, mujs doesn't report the old size
(on free or realloc) because it doesn't track this value, and as
a result we can't track the overall size.

Our option are either to track the size of each allocation on our own,
or use talloc which tracks this value.

However, using talloc for mujs allocations adds a considerable
overhead, and almost doubles(!) the overall memory used, because each
individual allocation includes a considerable talloc header, and mujs
does many small allocations.

So our solution is that by default we behave like previously - not
using a custom allocator with mujs, and stats does not display memory
usage for js scripts.

However, if the env var MPV_LEAK_REPORT is set to 1, then we use
a custom allocator with talloc and track/report memory usage.

We can't switch allocator at runtime, so an mpv instance either tracks
or doesn't track js scripts memory usage, according to the env var.
(we could use a property and apply it whenever a new script starts,
so that it could change for newly launched scripts, but we don't).
2020-11-15 20:36:04 +02:00
sfan5 cc25137eae ci: fix mingw build by adding harfbuzz 2020-11-15 17:32:03 +01:00
Ben Kerman f85de9e6d6 command: make subtitle time properties observable 2020-11-11 18:21:54 +00:00
Guido Cella 34f2143e8f manpage: properties fixes
- Explain which properties are writeable.
- Mark edition-list/N/id as writable.
- Remove (R) from some read-only properties since none of the others
have it.
- Add osd-dimension/ to its subproperties.
- options/<name> isn't read-only.
- focused works on macOS because of 82eda2e. Though it shouldn't be
possible to observe it without raising VO_EVENT_FOCUS.
2020-11-11 18:20:33 +00:00
Guido Cella 0ed4d66290 manpage: document the property-change event 2020-11-11 18:20:33 +00:00
Guido Cella fb819f069f manpage: document video-frame-info sub-properties
The picture type is explained in /usr/include/libavutil/avutil.h
Other subproperties in /usr/include/libavutil/frame.h
And there is a more detailed explanation for repeat_pict in
/usr/include/libavcodec/avcodec.h
2020-11-11 18:20:33 +00:00
Guido Cella 39ca957874 manpage: remove redundant "Return(s) "
...from the property descriptions that include it, and reformat the
paragraphs.
And say "Returns" in idle-active.
2020-11-11 18:20:33 +00:00
Guido Cella 5da326a8bb manpage: document demuxer-cache-state better 2020-11-11 18:20:33 +00:00
Guido Cella 81dfaa4962 manpage: be consistent with booleans
When possible, refer to booleans with "Whether..." since it can refer to
both yes (using input.conf and mp.get_property) and true (using the JSON
IPC or mp.get_property_native/bool), else explicitly say yes/true.
Say "true" for subprocess and osd-overlay named arguments since you
can't use them in input.conf and you will typically use them with the
boolean true in the named arguments, like the subprocess example in the
manpage does (though the string "yes" also works).
Subproperties that can't be accessed with the / syntax like
demuxer-cache-state's bof-cached and eof-cached always return true,
never yes.
2020-11-11 18:20:33 +00:00
Shreesh Adiga fd48f0bcb2 vo_sixel: Add fallback terminal width and height
In case terminal_get_size function fails, the
default height of 25 rows and 80 columns will be assumed
2020-11-09 19:44:07 +02:00
Shreesh Adiga baf45b3bc9 vo_sixel: Add checks to prevent null pointer dereferencing. 2020-11-09 19:44:07 +02:00