Commit Graph

432 Commits

Author SHA1 Message Date
Kacper Michajłow bc9d982330 encode_lavc: fix memory leak on --ofopts=help
Found by OSS-Fuzz.
2024-11-02 01:40:41 +01:00
Kacper Michajłow 201a39d7fa msg: skip formatting if there is only control char present
This doesn't change behaviour just skips some redundant code early.
2024-10-21 20:06:48 +02:00
Kacper Michajłow 3cf0f8309f msg: add newline conditionally
In idle mode, there is not status line and we sometimes want to have
output without last new line, which were always added after truncation.

Also, make sure we don't overwrite important chars with ellipsis, this
could happen when cut point is near the end.

Fixes: bf025cd289
2024-10-21 20:06:48 +02:00
Kacper Michajłow 6b695ac6e4 msg: use .. instead of … as ellipsis char
There were some concerns about the width of the … glyph, so avoid it and
use two dots.

Fixes: 6aa331289f
2024-10-18 19:57:53 +02:00
Kacper Michajłow 3e499ff3bc msg: fix width with ellipsis
Fixes: 6aa331289f
2024-10-18 00:25:10 +02:00
Kacper Michajłow b026fded7d msg: fix clipped output to non-tty
Not sure how it got lost.
2024-10-17 23:55:51 +02:00
Kacper Michajłow 6aa331289f msg: use … instead of ... dots 2024-10-17 23:55:51 +02:00
Kacper Michajłow 2df582b839 msg: don't format status line if not printing to terminal 2024-10-17 22:32:10 +02:00
Kacper Michajłow 39d3591bb2 msg: strip control char also when not printing to terminal 2024-10-12 01:26:43 +02:00
Kacper Michajłow bf025cd289 msg: allow to truncate the message to terminal width 2024-10-11 15:16:33 +02:00
Kacper Michajłow 95f0046309 misc/codepoint_width: add unicode width detection support
Add 4 stage trie to lookup unicode codepoint width and grapheme join
rules.

Generated by GraphemeTableGen from Microsoft Terminal (MIT Licence):
a7e47b711a/src/tools/GraphemeTableGen/Program.cs

With minor adjustment to use it in C codebase.
- Replaced constexpr with static
- Replaced auto with explicit types

Generated from Unicode 16.0.0:
ucd.nounihan.grouped.xml: sha256(b11c2d23673bae660fff8ddcd3c1de4d54bdf6c60188a07696b010282f515fcf)
2024-10-11 15:06:14 +02:00
Kacper Michajłow 4c19df1ded msg: print format string on format errors 2024-09-29 16:06:25 +02:00
Kacper Michajłow 4de6390d25 msg: don't use bold colors and instead use bright ones
Also avoid regular white/black, because it is often the terminal
background and invisible as foreground color.

Change debug messages to blue while at it to differentiate them from
trace ones.
2024-09-14 17:11:07 +02:00
llyyr 92f052c14e playlist: fix setting current item with autocreate-playlist
when the current directory isn't the playlist directory.
2024-08-23 00:56:17 +02:00
Kacper Michajłow e3f426aa4a common/playlist: add missing playlist_dir clear
Fixes: https://github.com/mpv-player/mpv/pull/14555#issuecomment-2282759582
2024-08-11 21:06:13 +02:00
Kacper Michajłow ff1f8baecd common/playlist: add playlist_set_current() 2024-08-10 23:27:40 +02:00
Kacper Michajłow 4f1e9e34c3 demux_playlist: add --directory-filter-types 2024-08-10 23:27:40 +02:00
Kacper Michajłow c54ad6933b demux_playlist: add --autocreate-playlist-{video,audio,image}-exts 2024-08-10 23:27:40 +02:00
Kacper Michajłow 7fb7e1dd73 various: add more format specifiers checks 2024-06-25 05:29:46 +02:00
Dudemanguy 0db6abadd4 playlist: let playlist-next go to first item if player is idle
Similar to the previous commit but the other way around. If you start
mpv as idle, load up a playlist without immediately hitting play and
then try to go to the next item, nothing happens. Naturally, you would
expect this to go to the first item. Fix this detecting if the playlist
has not started yet, the direction, and going to the first item in the
list.
2024-06-25 02:19:08 +00:00
Dudemanguy 0f76848e5f playlist: let playlist-prev go to last item in playlist
Previously, playlist-prev didn't work if you played a playlist to
completion using --idle and tried to go back. Naturally, one would
expect this to bring up the last item in the playlist, but nothing
happens. This is just because playlist_get_next is stupid and doesn't
take this into account since pl->current is NULL and thus returns NULL.
Fix this by considering the direction, checking if the playlist was
played to completion and grabbing the last entry in the index.
2024-06-25 02:19:08 +00:00
Kacper Michajłow 5534e0e1d9 common: validate parsed unicode codepoints value
Fixes UB when converting out of expected range values.

Found by OSS-Fuzz.
2024-06-23 02:33:04 +02:00
Kacper Michajłow e5d85704a3 av_log: sort library version print and add missing libavdevice
Incidentally sorted list put more important libs to the top.
2024-06-22 16:12:14 +02:00
Kacper Michajłow 3c5a79300c various: remove av channel layout check 2024-06-22 16:12:14 +02:00
Kacper Michajłow 00cfe1e1fd common: clang supports __builtin_clz also in non-GNU modes 2024-06-05 19:16:35 +02:00
Dudemanguy f921b64ed7 stream: implement get_protocols method for stream_lavf
Previously, all stream protocols were a static list in mpv. This is okay
for own builtin stuff, but for protocols that depend on ffmpeg it's not
so great. Support for certain protocols may or may not be enabled in a
user's ffmpeg and the protocol list that mpv generates should ideally
match this. Fix this by implementing a get_protocols method for
stream_lavf that will have different results depending on the ffmpeg mpv
is built against. We keep the safe and unsafe protocols separation. The
former is essentially a whitelist. Any protocol that is found in ffmpeg
but is not in the safe whitelist is considered unsafe. In the stream
list, ffmpeg is moved to the bottom so any possible protocols that are
added in the future don't automatically take precedence over any builtin
mpv ones.
2024-05-22 20:10:52 +00:00
Dudemanguy 406301f23d av_common: parent mp_get_lavf_demuxer contents to the list
The only usage of this function is freed in mpv's generic property code,
so no other changes are needed.
2024-05-22 20:10:52 +00:00
Kacper Michajłow a16f653eb5 msg: clear status line only if needed 2024-05-19 19:10:58 +02:00
Kacper Michajłow 895dd9e4e2 msg: split mp_msg_flush_status_line into private and public variant 2024-05-19 19:10:58 +02:00
Kacper Michajłow 243c1d6d91 msg: check target stream before printing
After f18ce7eca0 status is not always
printed to stderr.
2024-05-19 19:10:58 +02:00
Kacper Michajłow 1f7c223749 av_common: fix integer overflow when adjusting timebase
Found by OSS-Fuzz.
2024-05-15 01:25:18 +02:00
Kacper Michajłow f18ce7eca0 msg: print all messages to one stream
This reverts commit 4939570e17 and makes
it more strict about the output stream. Status message is also on the
same stream now.
2024-05-06 22:21:46 +02:00
Kacper Michajłow 414c47d1d8 player/main: select msg output stream early
This avoids printing any stray messages in encode output stream.

--o is already pre-parse cli option which is designed to be parsed
before anything else is printed to output. So we can use that to force
stderr output if needed for encode mode.
2024-05-06 22:21:46 +02:00
Kacper Michajłow 9fc2343512 osdep/mpv.rc: fix encoding of MPVCOPYRIGHT
llvm-rc doesn't allow multi-byte codes in narrow utf-8.
2024-05-06 22:01:17 +02:00
Kacper Michajłow ed7fe505b4 common: define some bits for Windows SDK 2024-05-06 22:01:17 +02:00
Kacper Michajłow fffe723fc4 various: move strings.h inclusion to common.h 2024-05-06 22:01:17 +02:00
Kacper Michajłow 18ef834ef4 various: move unistd.h inclusion to common.h 2024-05-06 22:01:17 +02:00
Kacper Michajłow a569c3ce0c player/command: add track-list/N/decoder 2024-04-18 01:20:32 +02:00
Kacper Michajłow e720159f72 player/command: add video-codec-info and audio-codec-info
Adds support for extracting codec profile. Old properties are redirected
to new one and removed from docs. Likely will stay like that forever as
there is no reason to remove them.

As a effect of unification of properties between audio and video,
video-codec will now print codec (format) descriptive name, not decoder
long name as it were before. In practice this change fixes what docs
says. If you really need decoder name, use the `track-list/N/decoder-desc`.
2024-04-15 19:34:40 +02:00
Kacper Michajłow 9030e6a7ad msg: use fwrite
No need to recalc string length.
2024-04-13 18:23:16 +02:00
Kacper Michajłow f53e941ba0 msg: use defines for hide/restore cursor code 2024-04-13 18:23:16 +02:00
Kacper Michajłow 247ef82a76 msg: don't keep status line in partial
Noticed while looking at this code, we shouldn't append status line to
partial when !print_term.
2024-04-13 13:37:21 +02:00
Kacper Michajłow 8708f4dc91 m_property: add `>` for fixed precision floating-point expansion
This enhancement makes it easier to create constant width property
expansions, useful for the `--term-status-msg`. Additionally, it changes
to `%f` printing with manual zero trimming, which is easier to control
than `%g`. With this method, we can directly specify precision, not just
significant numbers. This approach also avoids overly high precision for
values less than 1, which is not necessary for a generic floating-point
print function.

A new print helper function is added, which can be used with adjusted
precision for specific cases where a different default is needed. This
also unifies the code slightly.
2024-03-21 03:50:11 +01:00
Kacper Michajłow 0deefd80bf msg: clear buffered status_line on flush
It shouldn't be used after flush anymore.
2024-03-21 01:47:15 +01:00
Kacper Michajłow 17a0756ed3 msg: simplify the line_skip calculation
Make it more straightforward by always calculating top offset first
instead of having two branches, that tries to calc it directly.

This also fixes missing negative check before `\033[%dA` which was in
practice only problem on macOS which was handling negative values, while
in fact it shouldn't.

Fixes: #13484
2024-03-21 01:47:15 +01:00
nanahi 18bd03d31a common/msg: fix warning: void function should not return void expression 2024-03-19 08:58:18 +01:00
nanahi 98ab8d87a1 common/msg: fix warning: use of non-standard escape character '\e' 2024-03-19 08:58:18 +01:00
David Vaughan c678033c1d input/player: add loadfile/loadlist insert-at command 2024-02-26 02:03:21 +00:00
David Vaughan da753196af player: change insert_next to insert_at
Change the `playlist_insert_next` function to `playlist_insert_at` (ie,
insert at the location of an entry, rather than after it, and rename to
be clearer that it doesn't have anything to do with the
currently-playing entry).

Also, replace calls to `playlist_add` with calls to
`playlist_insert_at`, since the former has become redundant.
2024-02-26 02:03:21 +00:00
David Vaughan 9e162d2604 player: add loadfile insert-next commands
This commit adds two new commands (`insert-next` and `insert-next-play`)
which mirror the existing commands, `append` and `append-play` in
functionality, with the difference that they insert directly after the
current playlist entry, rather than at the end of the playlist.

This change gives MPV a piece of functionality already found in (for
example) Spotify's media player: "play next". Additionally, using the
new `insert-next` command, users can trivially write a script to play a
new piece of media immediately without otherwise clearing or altering
the remainder of the playlist.
2024-02-26 02:03:21 +00:00