Basically a simple way to perform any command/property action from the
command line. This takes the exact same syntax as input.conf but not
including the key naturally. Potentially useful for weird properties
that don't map well to options (like ao-volume). Fixes#12353.
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.
Escape all messages in osc.lua, because other than the title they
weren't being escaped at all. If for example you did mpv foo.mp4
'{\fs50}bar.mp4' and script-message osc-playlist, it would just render
the second entry as bar.mp4 in big text.
The title was escaped partially, now the escaping is complete because:
- It escapes \. Backslashes at the end of the title are escaped instead
of being stripped, and \n, \N and \h are now printed verbatim. In
particular, "\\n" is no longer converted to space and is printed
verbatim instead which is more correct.
- Newlines ("\n", not the "\\n" escape sequence) are converted to spaces
instead of rendering them and messing up the text positioning within
the OSC.
- Spaces at the start are preserved.
Fixes#11209, fixes#11275.
This adds a command to escape ASS tags to remove code duplication
between sub/osd_libass.c, console.lua, osc.lua, stats.lua and any user
script that calls mp.create_osd_overlay().
A command is used instead of scripting functions so that all clients can
use this and not just use Lua and JS ones.
osd_mangle_ass() also interprets osd-sym-cc and osd-ass-cc/{0,1}, but
since they use invalid UTF-8 characters there is no risk of escape-ass
users using them by accident, like with any OSD message.
Always replacing \n with \\N in mangle_ass() even when it is not called
by escape-ass doesn't seem to cause any issue, but I made it conditional
anyway to avoid changing how all OSD messages are treated unnecessarily.
585d8c6856 increased max active
section limit from 5 to 50 but this obviously doesn't properly fix
the problem. Input still breaks if more than 25 scripts are loaded,
or if some scripts define lots of input sections.
Remove the limit completely by using a dynamic array for active sections.
Fixes: https://github.com/mpv-player/mpv/issues/13707
The terminal output was static in size with no way of automatically
adjusting it to the current terminal size.
The new term-size property makes truly automatic adjustment possible.
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.
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.
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.
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.
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.
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
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.
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.
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.
%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
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.
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.
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.
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.
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>
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.
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.