Commit Graph

51988 Commits

Author SHA1 Message Date
Christoph Heinrich 0c8f3bc73c player/command: add term-size/[w,h] property
There was no way for scripts to know the current size of the terminal,
which is essintial if they want to provide a good user experience even
without a window.
2024-03-21 03:08:52 +01:00
Christoph Heinrich 0230a0c25a stats.lua: fix and unify scroll hint
The scroll hint on page 4 had baked in ass tags, which shouldn't be
there in the terminal. Also the scroll hint on page 0 was missing.

Refactor scroll hint generation into a function and use that for
pages 2, 4 and 0.
2024-03-21 03:08:52 +01:00
Christoph Heinrich c89b8340d5 stats.lua: use term_ellipsis for page 4
Page 4 might as well use the same line shortening function as the other
pages instead of rolling it's own.
2024-03-21 03:08:52 +01:00
Christoph Heinrich 777f69bee8 stats.lua: truncate long lines for the terminal
The terminal is assumed to be 80x24 in size, the new options
`term_width_limit` and `term_height_limit` can be used to overwrite
that.

Lines longer then the terminal width cause problems with scrolling
pages and need to be shortened.

The algorithm used for shortening can deal with tabs and escape
sequences, has rudimentary support for UTF-8 and runs in O(n).

avih helped in the creation of the term_ellipsis() function and split()
is also from him.
2024-03-21 03:08:52 +01:00
Christoph Heinrich 344ac5501d stats.lua: use scroll function for page 2 and 0
Pages 2 and 0 had their own scroll implementations, which worked fine
for ass, but didn't work well in the terminal.

Now they both use the same scroll function as page 4.

That scroll function requires each output line to be one entry
in the table. Page 0 did not adhere to that new requirement, instead
it generated two table entries for a single output line when a graph
is shown. To fulfill that requirement the generated graph now gets
directly appended to the same table entry that's used for the rest
of the line.
2024-03-21 03:08:52 +01:00
Christoph Heinrich 16a480375b stats.lua: refactor page 4 scrolling into function
This scrolling implementation will be used for other pages in future
commits.

The comment said it takes up 20 lines of the terminal, but in reality
it was 22 lines.
2024-03-21 03:08:52 +01:00
Kacper Michajłow 2a08440afb stats.lua: add more information in audio section
- current AO
- AO device
- AO volume
- audio delay
- output format
2024-03-21 02:40:00 +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
Dudemanguy 188155457d TOOLS: add an interface-changes generator script
Convenience script to automatically generate interface-changes.rst based
on the workflow introduced in the previous commit.
2024-03-20 22:38:56 +00:00
Dudemanguy 58363d209c DOCS: document the new way to handle interface changes
Manually editing interface-changes.rst is a giant maintenance pain that
causes merge conflicts all the time. Stop doing that nonsense and
instead have changes be written to files in DOCS/interface-changes. Also
remove that one sentence in changes.rst because it's just not true.
2024-03-20 22:38:56 +00:00
nanahi 8c1117b2cb meson: remove winmm dependency for win32 desktop target
Not needed anymore as timeBeginPeriod() is removed.
2024-03-19 20:23:25 +01:00
nanahi aff376e066 win32: increase hires timer resolution
timeBeginPeriod() only allows setting minimum timer resolution
to 1 ms. However, modern x86 platforms support a minimum timer
resolution of 0.5 ms. Use NtSetTimerResolution() instead for
the increased resolution, which can be set with MPV_HRT_RES.

Additionally, change the units of mp_start_hires_timers(),
mp_end_hires_timer(), MPV_HRT_RES, and MPV_HRT_MAX to nanoseconds,
in accordance with other functions used in timer.h.
2024-03-19 20:23:25 +01:00
Kacper Michajłow bfd016d101 win32: avoid multi byte string to wide conversion if not needed 2024-03-19 19:58:09 +01:00
Kacper Michajłow fc55f355fc win32: add puts/fputs wrappers 2024-03-19 19:58:09 +01:00
Kacper Michajłow 3372e17d51 win32: optimize mp_vfprintf a little
- remove redundant strlen/wcslen
- reuse allocated temporary buffers

The difference is not big, but it satisfies me to remove those
redundancies.
2024-03-19 19:58:09 +01:00
Kacper Michajłow 2ee0db4c5d misc/bstr: add bstr_to_wchar for win32
Convenience to avoid strlen above other things.
2024-03-19 19:58:09 +01:00
Kacper Michajłow c1282d4d43 player/main: move terminal_uninit to the end
It is strange to do terminal_uninit() and still use terminal after. Even
tho it has no side-effects.
2024-03-19 19:58:09 +01:00
Kacper Michajłow 8ee25db71f win32: cache GetConsoleMode state for stdout/stderr
GetConsoleMode() can be quite slow and in mpv the mode never changes, so
we can just check it once.

Fixes performance when writing lots of logs to terminal.
2024-03-19 19:58:09 +01:00
Kacper Michajłow 7bdd673a72 win32: don't touch buffering options 2024-03-19 19:56:25 +01:00
Kacper Michajłow fe29152d06 win32-console-wrapper: fix printf specifiers
%s is evaluated as wchar_t only in "Windows classic" semantic. It is not
C standard compliant.

%ls is compatible with both and means the same wchar_t format.

This commit fixes error output from mpv.com.

See: https://devblogs.microsoft.com/oldnewthing/?p=102823
2024-03-19 19:56:25 +01:00
Kacper Michajłow c3843d79de win32: don't pass std handles if they are attached to console
This is default behavior to attach to existing console, passing custom
handles is useful if we want to replace them, but in case they are
already attached to console we want to attach to console directly.

In theory, it should work out of the box because "console-like" handles
should be managed by Windows internally, which works for INPUT and
OUTPUT, but in certain cases, not for ERROR. This allows using VT
features in those cases for stderr too.
2024-03-19 19:56:25 +01:00
llyyr dd88701aac DOCS/options: improve wording of dither-depth 2024-03-19 19:43:08 +01:00
mistraid121 574f269d32 af_lavcac3enc: fix memory leak on 2ch audio
If processing is not required, the frame would be leaked as it is not used.
2024-03-19 19:32:55 +01:00
nanahi 5fea0f9a47 various: use thread safe mp_strerror() 2024-03-19 19:30:27 +01:00
nanahi df01ebaafc image_writer: refactor screenshot write functions
When 3cb9119984 introduced AVIF screenshot
support, FILE * in write functions were replaced by filenames. This
resulted in unnecessary duplication of FILE * handling code and the usage
of avio_open API made it hard to use exclusive open with it.

To unify file handling, use avio_open_dyn_buf instead which writes to
memory instead. This way FILE * can be used for the write functions
and file handling code can be deduplicated. Since we now control
the file opening, exclusive open can now be used for AVIF screenshots.
2024-03-19 19:30:27 +01:00
nanahi 9a861c930b image_writer: fix TOCTOU in screenshot filename generation
The screenshot command is documented to not overwrite existing files.
However, there is a race window between the filename is generated with
gen_fname and when the file is open to write. Specifically, the
convert_image function in this window can be very time consuming
depending on video and screenshot image format and size. This results
in existing file being overwritten because the file writing functions
don't check for the existance of file.

Fix this be opening the file in exclusive mode. Add overwrite parameter to
write_image for other operations that are documented to overwrite existing
files, like screenshot-to-file. Note that for write_avif, checking
existance is used instead because avio_open does not support exclusive
open mode.
2024-03-19 19:30:27 +01:00
nanahi aa08e304c4 Revert "osdep/io: ignore 'x' mode for mp_fopen"
This flag is a GNU extension in C99, but was standardrized in C11,
so mpv should be able to use it. fopen is wrapped on win32 so
non-compliant MSVCRT.dll isn't a concern.
Since the upcoming commit uses this feature it can be brought back.

This reverts commit c36e051470.
2024-03-19 19:30:27 +01:00
Kacper Michajłow 374470d471 repack: add restrict qualifier to src/dst pointers
Allows compiler to do its job and optimize this code. We don't really
want to repack in-place.
2024-03-19 13:04:05 +01:00
nanahi e0b517985b win32: resolve dropped shell links (Windows shortcuts)
When a shell link is dropped onto the mpv window, the file name will be
replaced by the file name of its target so that the linked file is played.
2024-03-19 11:34:00 +01:00
nanahi d2bbd7a531 win32: implement shell link target resolving
Adds a function to resolve the target of a shell link (Windows shortcut)
for use by other parts of mpv.
2024-03-19 11:34:00 +01:00
Leo Izen 3e7d36c295 video/image_writer: attach MDVC metadata and CLLI metadata
This commit allows image_writer to attach HDR metadata to AVFrames via
the corresponding AVFrameSideData attachments, if present. It does this
by calling pl_avframe_set_color, already used by mp_image_to_avframe.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2024-03-19 09:49:04 +01:00
Kacper Michajłow 227916d5ed builtin.conf: remove debanding from the high-quality profile
Debanding is an inherently destructive process. It is not needed for
most high-quality sources and only produces an adverse smoothing effect
when applied to fine-detailed content, removing detail. It should only
be applied when necessary, either manually with the `b` keybind or with
an automatic profile.

Additionally, it is quite computationally heavy with no real benefit for
high-quality content.

By default, and especially in the high-quality profile, mpv should
preserve source detail and quality as much as possible. Additional
processing should be opt-in.
2024-03-19 09:18:49 +01:00
Kacper Michajłow 212b3863c6 input.conf: add `b` to toggle debanding 2024-03-19 09:18:49 +01:00
llyyr f914947dda vo_gpu_next: make `dither-depth=auto` mean 8 bpc for non-d3d11 SDR
Fixes the issue described in https://github.com/mpv-player/mpv/issues/11862
for SDR files for non-d3d11 gpu-api. We currently don't have a smarter
way to get the real on-the-wire bpc for other APIs, so this is the best
that can be done.
2024-03-19 09:06:01 +01:00
llyyr 16ae76948d vulkan: remove color_depth stub
Needed for the next commit
2024-03-19 09:06:01 +01:00
nanahi 465f405703 osdep/main-fn-win: fix implicit conversion warning 2024-03-19 08:58:18 +01:00
nanahi fbea9607be osdep/threads: fix warning: initializer element is not constant 2024-03-19 08:58:18 +01:00
nanahi e9f966595c ao_lavc: fix warning: ISO C forbids forward references to 'enum' types 2024-03-19 08:58:18 +01:00
nanahi a6f8d1d961 vo_gpu_next: fix -Wembedded-directive warning
warning: embedding a directive within macro arguments has undefined behavior
2024-03-19 08:58:18 +01:00
nanahi 59f23f5c29 video/out/gpu/spirv: fix warning: zero size arrays are an extension 2024-03-19 08:58:18 +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
nanahi 302ccf18ef options/m_config: fix no newline at end of file 2024-03-19 08:58:18 +01:00
nanahi 82a186567e various: fix -Wold-style-declaration warning
warning: `static' is not at beginning of declaration
2024-03-19 08:58:18 +01:00
nanahi 4f381f2137 video/out/placebo/utils: fix -Wignored-qualifiers warning
warning: type qualifiers ignored on function return type
2024-03-19 08:58:18 +01:00
nanahi a3489c8a0f demux/cache: fix -Wtype-limits warnings
warning: comparison of unsigned expression >= 0 is always true
warning: comparison is always false due to limited range of data type
2024-03-19 08:58:18 +01:00
nanahi b2c1e55e5d meson: bump warning level to 2
Ignore a few noisy warnings for now.
2024-03-19 08:58:18 +01:00
Kacper Michajłow cbe30f614d vo_gpu_next: don't render ASS subtitles at HDR colorspace
Upstream ASS specification says that all subtitles should be rendered
with color primaries and transfer matching their associated video. But
as expected after further discussion the decision has been made to
fallback to SDR mode in case of HDR video.

See-Also: 649a7c2e1f/libass/ass_types.h (L233-L237)
See-Also: libass/libass#297
See-Also: mpv-player#13381
Fixes: mpv-player#13673
2024-03-18 21:24:06 +01:00
der richter bf1c8acdac mac/touchbar: simplify item and view creation 2024-03-18 20:29:27 +01:00