Compare commits

...
584 Commits
Author SHA1 Message Date
sfan5 f4210f8490 Release 0.36.0 2023-07-23 19:10:36 +02:00
sfan5 5236003db5 Revert "vo_gpu_next: use pl_dispatch_info_move to avoid useless data copy"
We wanted to preserve the libplacebo v5.264.0 requirement for gpu_next
for this release, since this is the what most Linux distributions are shipping.
The VLC 3 <-> libplacebo v6 situation is an additional reason distros are not
likely to ship the newest libplacebo release soon.
This reverts commit b73d96776c.
2023-07-23 15:40:41 +02:00
Thomas Weißschuh 007019a303 ao_pipewire: for_each_sink: properly check termination condition
Doing a pw_thread_loop_wait() without checking conditions is invalid.
The thread loop could be signalled for other reasons and in this case
the wait needs to continue.

PipeWire added such additional signaling in
commit 33be898130f0 ("thread-loop: signal when started").

This meant that for_each_sink would return before the callbacks have
fired and session_has_sink() would incorrectly return "false", failing
the initialization of ao_pipewire.

Fixes #11995
2023-07-23 13:31:03 +02:00
Dudemanguy e8126e54e5 DOCS/vo: clarify dmabuf-wayland a bit
Make it clearer that you should be using --hwdec with this VO. Also make
some comments about the things that are required for this to work
correctly (i.e. working drivers/GPU and the right compositor).
2023-07-23 04:55:26 +00:00
Dudemanguy 783e2bf138 vo_dmabuf_wayland: correctly handle force-window
Since this works by mpctx giving us a dummy image, we can be reasonably
be confident that when we receive a matching imgfmt with no underlying
hw_subfmt that this is simply force window from the player. Just allow
this to go through the usual wayland logic and skip the hwdec checking.
When we get the real image later, it will still error out on the
compositors that don't have proper support.
2023-07-23 04:55:26 +00:00
Dudemanguy ca4192e2df player/video: check for forced eof
It's a bit of an edge case, but since we now allow the disabling of the
software fallback it's possible to have a situation where hwdec
completely fails and the mpv window is still lingering from the previous
item in the playlist. What needs to happen is simply that the vo_chain
should uninit itself and handle force_window if needed. In order to do
that, a new VDCTRL is added that checks vd_lavc if force_eof was set.
player/video will then start the uninit process if needed after getting
this.
2023-07-22 17:42:25 +00:00
Dudemanguy 61f0797557 vd_lavc: respect vd-lavc-software-fallback opt
There's an option that's supposed to stop mpv from falling back to
software decoding if hardware decoding fails. Except that it doesn't
work and can fallback to software decoding anyway. Correct this by
checking if all possible hwdec failed after the loop in
select_and_set_hwdec and that we have this option. If so, flag a bool to
force eof. In decode_frame afterwards, we then simply immediately return
an EOF.
2023-07-22 17:42:25 +00:00
Gusar321 bddf0efade vo_vaapi: restore hardware video decoding
Commit e50db42 changed how hwdec interop works. Adjust vo_vaapi accordingly by setting the appropriate image format.
2023-07-22 12:16:29 +02:00
Gusar321 800d9eaa42 vo_vaapi: fix segfault in draw_osd
When video width is not a multiple of slice size, the last slice will overflow. Fix this by adjusting the width of the last slice to fit within the video.

Fixes issue #10436
2023-07-22 12:16:29 +02:00
Thomas Weißschuh c9064b57c0 ao_pipewire: use native buffersize by default
Instead of trying to guess the correct number in mpv let the pipewire
server choose.

Fixes #9992
2023-07-22 12:16:21 +02:00
NRK 2dc8e70093 terminal-unix: fix not listening on input after being foregrounded
fixes regression caused by 2e7fcc5a2 where it wouldn't receive terminal
input if the process was foregrounded later on like this:

    $ mpv something.mp4 &
    $ fg

ref: https://github.com/mpv-player/mpv/issues/11795
2023-07-21 20:47:03 +02:00
llyyr 4198e6f35f osc: don't add margins to osc-deadzonesize
Currently, the osc will add a margin of (osc_height / 2) to the
deadzonesize for the window controls, the topbar and the bottombar,
i.e. when osc-deadzonesize=1, the osc will show up even if the cursor
is only hovering (osc_height / 2) pixels above or below it. This is not
what this option is supposed to do according to the manual, instead
osc-deadzonesize=1 should result in the osc only appearing when it is
directly hovered. The user can simply set osc-deadzonesize=0.9 or so if
such a margin is desired, instead make the option work as advertised by
removing this margin.

It should be noted that osc-layout=box does not share this behavior,
and it already works as advertised in the manual.
2023-07-21 20:24:18 +02:00
Dudemanguy 45b006b958 DOCS: clarify screenshot window and screenshot-sw 2023-07-21 20:23:11 +02:00
Dudemanguy 9a95cb9fd1 vo_drm: remove VOCTRL_SCREENSHOT_WIN
With the generic screenshot window implemented, this is no longer
needed since vo_drm already uses software scaling.
2023-07-21 20:23:11 +02:00
Dudemanguy d16c59096c screenshot: implement screenshot-window in sw for most VOs
mpv already has a bunch of software scaling utils. Instead of forcing
every VO to implement this, we can just grab the frame and scale it in
software in one central place. Fixes #11968.
2023-07-21 20:23:11 +02:00
Dudemanguy 97457a837e screenshot: clarify software screenshot logic
We should always be trying hardware screenshots (VOCTRL_SCREENSHOT and
VOCTRL_SCREENSHOT_WIN) before software ones. Rearrange all the logic
here to hopefully make this clearer. The mode is passed to add_osd
(renamed since it will also be used to add the osd) which will be used
more in the next commit.
2023-07-21 20:23:11 +02:00
NRK fd03d0038b image_writer: use proper specifier for int64_t 2023-07-20 20:38:06 +02:00
sfan5 15252e13d5 {zsh,bash}-completion: run mpv with --no-config
Reading the config when we're just interested in the option list
(not sure why mpv does that anyway) only has the potential to mess
this process up when it prints errors or the user has funny options
like msg-level or log-file set, so avoid doing so.
2023-07-19 13:01:08 +02:00
sfan5 5f664e2a1d bash-completion: do not complete removed options 2023-07-19 13:01:08 +02:00
sfan5 da9c94989a zsh-completion: do not complete removed options 2023-07-19 13:01:08 +02:00
sfan5 a0d8962be8 zimg: fix broken sig_peak handling
In sum there were three issues:
1. nominal_peak_luminance is an output parameter, not input
2. mpv internally uses MP_REF_WHITE which we need to scale by
3. the value should be left at its default for SDR

Together with the last change this means mpv can sucessfully
take HDR screenshots with --screenshot-sw without resulting
in a brightly colored mess. Though note that zimg does not
perform proper tonemapping.
2023-07-19 13:01:08 +02:00
sfan5 a960b75604 image_writer: move tag_csp check into image_writer_flexible_csp()
This ensures the sRGB fallback to happen in all situations involving
the image writer code, notably --screenshot-sw.

fixes: cbbe2e5221
2023-07-19 13:01:08 +02:00
sfan5 157ef77427 image_writer: replace sprintf usage
also fixes the buffer being cut off (?!)
2023-07-19 13:01:08 +02:00
sfan5 f95339c02a image_writer: share some code between write_lavc and write_avif
As a consequence:
- write_avif now respects tag-colorspace=no
- write_lavc additionally sets colorspace and chroma_location
  (of no consequence for png or jpeg)
2023-07-19 13:01:08 +02:00
sfan5 8f26d99fbd image_writer: error check avif-pixfmt option 2023-07-19 13:01:08 +02:00
sfan5 8aa8e21da9 image_writer: fix still-picture option for AVIF
Gets rid of validation warnings on the produced files.
2023-07-19 13:01:08 +02:00
sfan5 d7ef91fecd image_writer: remove duplicate packet writing code 2023-07-19 13:01:08 +02:00
sfan5 608b430b56 TOOLS: remove obsolete travisCI-related scripts 2023-07-19 13:01:08 +02:00
sfan5 d46a31317f wayland_common: remove questionable gcd impl and global state 2023-07-19 13:01:08 +02:00
Dudemanguy e399266400 wayland: don't treat tiled and maximized windows the same
mpv has historically always treated the various tiled states in
xdg-shell as maximized (probably because it was easier). Well it turns
out that there are some tiling compositors (hyprland) that allow tiled
windows to maximize themselves. This can lead to some scenarios where
mpv ends up doing a maximize on hyprland which actually works since it's
not a no-op like on sway. Fix this by separating out the tiled state
from maximize. It works mostly the same, but the main difference is that
there's no request to tile yourself like there is with maximize. Should
fix #11954.
2023-07-19 01:14:32 +00:00
Dudemanguy 949e1f0dcc wayland: add locked_size convenience shorthand
There's a lot of checks that are along the lines of !maximized &&
!minimized or vice versa. Make a locked_size boolean and store the
value of this in here to avoid writing long lines since the next commit
will add yet another condition to this.
2023-07-19 01:14:32 +00:00
Niklas Haas dbbcd9ec9c builtin.conf: add --hdr-contrast-recovery to gpu-hq
The first change to the gpu-hq profile in aeons.
2023-07-18 15:22:18 +02:00
Niklas Haas 02595011eb vo_gpu_next: add --hdr-contrast-recovery/smoothness
New upstream feature. Disabled by default.
2023-07-18 15:22:18 +02:00
rcombs ac725764ec builtin.conf: unset default languages in libmpv and encode profiles
The `auto` behavior doesn't really make sense in these contexts.
2023-07-18 00:42:56 -07:00
Philip Langdale fbd0be1cf4 vd_lavc: repeatedly attempt to fallback if hwdec fails in receive_frame
There is an additional failure path I didn't account for in my previous
work. While I ensured that a late hwdec failure in receive_frame can be
recovered from by trying the next hwdec, there is a specific
combination where if an hwdec fails in receive_frame, and the next
hwdec is a full decoder (eg: v4l2m2m), and that also fails, we are left
with no decoder and so the entire decoding process ends and playback is
stopped.

Basically, we must keep re-attempting the fallback in receive_frame
until we get a valid decoder (software or hardware). This edge case
will rarely be encountered as there are only a couple of decoder based
hwdecs.

Fixes #11947
2023-07-17 18:37:41 -07:00
Dudemanguy 1f8013ff3f wayland: handle modifier keys correctly
I don't know why we've been doing this wrong for so long or how I didn't
notice until now. Wayland specifically has an event for handling
modifiers. We even named it "keyboard_handle_modifiers" in the code.
What we should do is just get the modifier and save it after the xkb
state is updated. Then later if the user does something else (press
another key or clicks the mouse button), the saved modifier key is
applied. If you let go of the modifier at any point, the xkb will just
update its state again and we save a 0 again here (i.e. no modifier).

There is one bit of an edge case however. If a key is pressed BEFORE the
modifier, then we have to handle the mp_input_put_key in the modifier
event instead since the ordering is not guarenteed. What we do here is
keep track of the mpkey as well as the mpmod. However if we are unable
to find a matching mpkey and the key state is pressed down, assume it's
a modifery key that was pressed and don't update mpkey. That way
whenever the modifier event does happen, it can correctly handle this
and we know that the keys must be pressed down if we end up there in the
code path.

As another fun historical note, the xkb_keysym_to_utf8 line was actually
written by wm4 himself in 460ef9c7a4
nearly 10 years ago. As the commit shows, it was clearly intended to
handle modifiers (if lookupkey finds nothing, then try to find a mod
instead). Of course, this is extremely dated and wayland hasn't worked
like that in ages. This branch never actually did anything, and thus
we'll remove it here along with modifier lookup changes.

This solves bizarre issues with modifiers not working with random keys
while working fine with others (don't ask me why). Fixes #10286 and
fixes #11945.
2023-07-17 18:53:50 +00:00
Kacper Michajłow 347fbd6fa3 vo_gpu_next: add --target-contrast option
For better control over target display levels.
2023-07-17 18:50:34 +02:00
llyyr fbd392bcbb loadfile: make get_audio_lang function static
This fixes a build warning about missing prototypes
2023-07-17 18:02:07 +02:00
sfan5 8a6cabce35 DOCS/release-policy.md: add additional advice 2023-07-17 11:55:45 +02:00
rcombs 9e6c6c0897 loadfile: compute audio lang for sub selection when using lavfi-complex
When using lavfi-complex, no single track populates current_track for audio.
We work around this by iterating over the list of tracks and using the first
non-null language from a selected track. If multiple tracks are selected
(i.e. used by the filter) and have conflicting language tags, we'll ignore
them all and maintain the previous behavior (null).
2023-07-16 21:32:50 -07:00
Dudemanguy 9e9abb1a0f wayland: wrap resize requests in prepare_resize
828dd65ef8 started this and put it in the
most common place, but any resize mpv is doing should be accompanied by
that function call to correctly inform the compositor of the window
bounds. Since we also have to set VO_EVENT_RESIZE at the same time, it
makes sense to just put these in the same function. A slight thing to
note is that xdg_surface_set_window_geometry uses surface local
coordinates which means they are divided by the wl->scaling factor. If
possible, we should use surface local coordinates directly if available
(like in the toplevel config) to avoid potential rounding errors.
Otherwise, just calculate it out. The linked commit actually broke
some weston resizes in weird ways (window disappearing or completely
freezing). Don't ask me why and I didn't attempt to find out why either,
but with this it all appears to work normally again (the other
compositors don't appear to be any different, and they shouldn't be), so
we'll go with this since it fixes soemthing and it also is more
conceptually correct.
2023-07-16 21:20:50 -05:00
llyyr 580f36e436 sd_ass: fix converted subtitles having too-wide borders
Libass commit f08f8ea5 (between 0.16 and 0.17) changed how PlayResX
affects some aspects of rendering.

The libass change fixes a VSFilter compatibility issue which existed
for about two decades, and there are no libass plans to support the
previous behavior, so ultimately we have to adjust the mpv code, and
we can't guarantee to restore the old behavior in all cases.

Starting at this commit, vector drawing coords, font spacing, border
and shadow widths are all affected by PlayResX (specifically, by
the aspect), while previously they were unaffected by PlayResX.

This changed converted sub border and shadow widths in mpv, because
ffmpeg generates the ass with fixed PlayResX of 384 (aspect of 4:3),
and with libass 0.17, if this doesn't match the display aspect, then
borders and shadow were too wide - because most clips aspect is more
than 4:3.

The fact that ffmpeg uses fixed PlayResX of 384 could be considered
an issue, but for now we have no control over it, and ffmpeg doesn't
have the video resolution when it converts an srt source to ass.

So here we adjust PlayResX accordingly so that border/shadows are
now rendered with correct width.

However, regardless of that commit, changing PlayResX also affects
the margin value, so to compensate, we adjust sub-margins-x too.

According to libass devs, this should cover basic srt-to-ass
conversion by ffmpeg to work correctly with libass 0.17.

However, there could be srt extensions which use more complex ass,
and/or ffmpeg conversion of other sub formats (such as aribb24,
aribcaption and movtext), where more things need adjustments.
As of now we don't know what these are, and so we don't really know
what else might remain broken or get broken.
2023-07-16 21:02:54 +03:00
Dudemanguy cab544889a sd_ass: don't reconfigure ass on every frame
dbc5d7b7db seems to have originally
introduced this behavior. At the time, wm4 simply reconfigured ass on
every frame in order to accommodate runtime changes in sub options. This
certainly works, but these libass API calls are not free and there is at
least one known performance regression due to a change in libass*.
Regardless of whether or not the libass change is good/bad, there is no
need for mpv to constantly reconfigure this. When wm4 made that commit,
there was no notification mechanism for options changing that could
easily be used so he didn't really have any other choice. But it's
nearly 10 years later now and internally we have all the necessary
pieces to only configure ass again when we need to: on option changes or
resizes. So go ahead and implement that in this commit which simply uses
the already existing SD_CTRL_UPDATE_OPTS and compares osd_res sizes to
determine whether or not an ass configure is needed.

*: https://github.com/libass/libass/issues/698
2023-07-15 23:57:16 +00:00
m154k1 b077cf72df player: set default cache dir on macOS
Use ~/Library/Caches/io.mpv for caches instead of ~~home.
2023-07-15 23:56:57 +00:00
Dudemanguy 031e172cef DOCS/mpv: clarify the location of cache/state files 2023-07-15 15:10:41 +00:00
Dudemanguy d482bf6ef0 path-win: implement cache directories
4502522a7a implemented cache directories
but only on linux which meant other OSes continued to save this stuff in
their config directory. Since we turned on cache by default, people are
getting cache files in there which is understandably causing some
confusion. Let's go ahead and implement a separate cache directory for
windows since there seems to be some established conventions for this
already. For people using the portable_path, the cache is saved in a
subdirectory within the portable_path since the idea is for that to be
completely self contained.
2023-07-15 15:10:41 +00:00
Philip Langdale 93f95f61e9 DOCS/interface-changes: document change in ctrl+h behaviour
We now use `auto-safe` when turning on hardware decoding instead of
`auto`.
2023-07-15 18:58:28 +08:00
Philip Langdale e64ef6089f vd_lavc: map hwdec=yes to hwdec=auto-safe
To remain consistent with our belief that `auto-safe` should be the
recommended mode when turning on hw decoding, let's remap `yes` from
`auto` to `auto-safe`.
2023-07-14 20:41:24 -07:00
Philip Langdale 7fe2a76621 vd_lavc: add drm and drm-copy to the auto-safe list
We have supported `hwdec=drm` for some time now, and on devices where
this method is present, it is the preferred, and only, method
available. Combine that with the fact that software decoding on
embedded devices will not turn out well, and it's clear that we should
put `drm` and `drm-copy` on the `auto-safe` list to maximise usability
in simple configurations.
2023-07-14 20:41:24 -07:00
Philip Langdale 9f7f9c1614 input: update ctrl+h to toggle auto-safe rather than auto
It has been odd that ctrl+h toggles `auto` for hwdecs even though we
always recommend people start with `auto-safe`, and `auto` will attempt
various hwdecs that can fail so badly we can't fall back to software
decoding.

With the change to more exhaustively attempt to use hwdecs, it is now
easier to get into situations where these fragile hwdecs will get
attempted in basic scenarios, like pressing ctrl+h.

So it is high time to default to `auto-safe`.
2023-07-14 20:41:24 -07:00
Philip Langdale 4501e07996 vd_lavc: try other hwdecs when falling back after an hwdec failure
Today, if hwdec initialisation succeeds, we move on to attempting
decoding, and if decoding fails, we enter a fallback path that will
only do software decoding.

This is suboptimal because some hwdecs and codec combinations can
pass hwdec init, but then fail at hwaccel init, or even frame decoding.
In these situations, we will never attempt other hwdecs in the `auto`
or manually specified lists which might work.

One good example is someone tries to use `vulkan,auto` and tries to
play av1 content. The vulkan decoding will fail at hwaccel init time,
and then fallback to software instead of going through the auto list
which would allow vaapi, nvdec, etc to play the file.

Instead, let's not give up immediately, and try the next hwdec after
a failure, just like we do if hwdec init fails.

The key part of this change is to keep track of the hwdecs we have
tried, so that each time we run through hwdec selection, we don't try
the same one over and over again. If we really get through the whole
list with no success, we will then fall back to software decoding.

Fixes #11865
2023-07-14 20:41:24 -07:00
Dudemanguy 1f683401aa vo_dmabuf_wayland: error out if compositor doesn't support the format
This was never implemented so in cases where the compositor didn't have
support for the underlying format, the window would just be black and
quite unhelpful. Well it turns out that fixing this is actually really
easy because mpv has reconfig2 which returns the entire mp_image on
every reconfig. We can just use that mp_image to try and obtain the
format and modifier pair and then use that to check against what we know
the compositor supports. If there are any problems, error out
gracefully. Some code duplication with the vaapi/drmprime importers, but
it's probably better to keep these separate. Fixes #11198 and fixes #11664
2023-07-14 14:24:45 +00:00
Dudemanguy 2616b2b11e build: make dmabuf-wayland a build option and require drm
It makes more sense as an option at this point. Also libdrm is not
optional at all. You have to get a drm format and modifier for this to
even work (the VO will just fail without DRM). Just hard require it and
remove the guards. vaapi can remain optional.
2023-07-14 14:24:45 +00:00
Christoph Heinrich cf0373e15b console: sort the output from the help command
Closes #11927
2023-07-14 13:06:01 +00:00
Guido Cella fc43faa026 player: delete watch later redirect entries again
6a365b258a broke deleting redirect entries for resuming playback. If you
do mpv dir1 dir2, quit-watch-later on a file in dir1, then later
quit-watch-later on a file in dir2, mpv dir1 dir2 would not resume from
dir2 because the redirect entry for dir1 is never deleted.

Fix this by deleting watch later config files for directory/playlist
entries.
2023-07-14 13:05:40 +00:00
Dudemanguy 828dd65ef8 wayland: use xdg_surface_set_window_geometry
mpv has never used this because we never really seemed to need it, but
it actually has a purpose. This informs the compositor of the actual
dimensions of the mpv window and avoids errors with sizes not matching
(particularly with weston). It's a better way to fix the "maximizing
causing an error on weston" issue since it also works for dmabuf-wayland
(which always had this problem).
2023-07-13 12:12:37 +00:00
Dudemanguy 4ff27d5220 Revert "wayland_gl: wait until resize to create egl_window"
The original reason for this commit was to prevent a compositor error on
weston when going into the maximized state. The configured dimensions of
mpv didn't match its actual size and Weston is super strict about this
so it threw a compositor error which is fatal. It only happened in
opengl and this seemed like an OK workaround, so I went with this.
However, there's actually a far easier way to solve this problem and we
don't need this anymore. This has the benefit of avoiding a harmless
warning message that appears with gpu-next on opengl. The next commit is
the proper solution. Closes #10324.

This reverts commit 661b5542de.
2023-07-13 12:12:37 +00:00
Dudemanguy 33130741f4 vo_dmabuf_wayland: guard in destroy_osd_buffers
*sigh*
2023-07-12 22:20:20 -05:00
Dudemanguy 7409f4a6c9 vo_dmabuf_wayland: stop lazy loading hwdec
The implementation was copied from vo_gpu/vo_gpu_next but fundamentally
it doesn't make sense for this VO. Hardware decoding is not optional in
vo_dmabuf_wayland. We should be sure to request and load all supported
formats in the preinit and fail if there are any problems. There should
be no functional change from before, but it's more conceptually correct
this way.
2023-07-12 16:59:59 -05:00
Dudemanguy b57cf110c9 vo_dmabuf_wayland: don't try to get pts without frame->current
Fixes a segfault with --force-window=immediate.
2023-07-12 16:59:47 -05:00
Dudemanguy f3c1dcf7a1 draw_bmp: ensure last slice is less than total width (again)
Essentially the same as d1d2370d07 except
for clear_rgba_overlay. From some empirical testing, the s->x1 value is
either 0 or SLICE_W (256). In the case where it is 256 and s->x0 is 0,
then it writes memory. For most slices, this is fine. However for the
very last slice in the loop, it is possible for the width here to exceed
the total width of the line (p->w). If that occurs, the memset triggers
a buffer overflow. This last case needs to be guarded in the same way as
the previously mentioned commit (total width - SLICE_W * x) and with
MPMIN in case s->x1 is 0 here to preserve the old behavior. It's unknown
if anything other than dmabuf-wayland can possibly hit this, but it's
definitely a problem within mp_draw_sub_overlay itself.
2023-07-12 19:19:54 +00:00
Dudemanguy c958990833 vo_dmabuf_wayland: add osd support
This adds osd support via shm buffers using a similar approach that the
normal buffers do, but it differs in a few key areas. One thing to note
is that sway and weston actually handle this extremely differently which
required all the abstractions here. In particular, weston does not cope
well with destroying the wl_buffer from shm outside of the release
handler at all (i.e. it segfaults). The workaround here is to simply
attach a NULL to the osd surface and do a surface commit before we
destroy the buffers. This is reasonable enough and seems to work well
although it's pretty weird. Sway is more straightforward although it
actually releases the osd buffer when the window goes out of sight.
Also, I found that it doesn't always release every buffer before you
close it unlike weston seems to do which is part of the reason all this
bookkeeping is required. I don't know if there's any other compositor
out there that can possibly handle vo_dmabuf_wayland right now, but
suffering through these two is good enough for now I think.
2023-07-12 19:19:54 +00:00
Dudemanguy 180a3df1f1 vo_dmabuf_wayland: init wl_list at the top of preinit
Otherwise, we could fail and skip to uninit without initalizing this
which then will segfault because the list is null and accessed while
trying to destroy buffers.
2023-07-12 19:19:54 +00:00
Dudemanguy a890d7be2a vo_dmabuf_wayland: stop guarding viewport interfaces
It's entirely pointless. Not having viewport is already a fatal error
for this VO as it cannot possibly work without that protocol. Just drop
all these redundant if's.
2023-07-12 19:19:54 +00:00
NRK dc06dec1ee video/image_writer: check for write errors
make sure that fwrite is error checked. and if any data was still
remaining on the buffer, it will be flushed - and errors checked - via
the fclose() call below.
2023-07-11 19:55:28 +02:00
NRK 6b76000f0b video/image_writer: fix file leak in error path
regression from de7f4fb1e
2023-07-11 19:55:28 +02:00
Adam Sampson 6461fb9c44 wscript: add 1.32 protocols to sources
The patch that added these protocols didn't include them in the list of
sources, which caused build failure with wayland-protocols 1.32.
2023-07-11 17:33:59 +00:00
m154k1 cbb1af64d5 stats.lua: set sans-serif as default font
sans is deprecated and unsupported on some platforms.
2023-07-10 16:58:54 +02:00
llyyr a0f1bbddff wayland: add xdg_toplevel.wm_capabilities handler
Fixes crash when compositors advertise xdg_toplevel version >= 5
2023-07-10 13:37:23 +00:00
Dudemanguy 7beae9ac86 wayland: add support for suspended toplevel state
mpv already guesses when the window is hidden so plugging in a proper
event that actually tells us this is really trivial. Note that there's
some redundancy with setting wl->hidden in a few spots, but nothing can
really be done about that as long as the crappy hack is still in place.
2023-07-09 19:22:53 +00:00
Dudemanguy 589da09e5a wayland: add cursor-shape-v1 support
This protocol no longer requires us to draw a separate cursor surface
and all of that horrible stuff. We can just ask the compositor for the
default cursor instead since that's literally all mpv cares about.
2023-07-09 18:10:19 +00:00
Kacper Michajłow fc3e28f1e9 vd_lavc: fix delay_queue for videos with frames < max_delay_queue
In case there are no packets from demuxer we cannot send EAGAIN, because
we will not proceed and get stuck with one frame in queue and never
output it. Just respect avcodec_receive_frame ret code and act
accordingly. The only case to care about is EOF when we have to drain
already queued frames.

Fixes playback of 1-2 frame videos.
2023-07-09 11:59:32 +02:00
Kacper Michajłow bf77f1ae74 vd_lavc: prefer d3d11va-copy over dxva2-copy
There is no reason to prefer dxva2. I believe it was mistake from
initial commit that added the hwdec list that has been propagated
through years.
2023-07-09 11:59:32 +02:00
Dudemanguy ab3002851e vo_wlshm: bail out of resize if width/height is 0
It can happen during initialization and of course nothing good will
happen if we let this go through (i.e. segfault). Return and wait for
geometry to finish setting up in the wayland stuff before doing the
initial resize.
2023-07-08 20:47:35 -05:00
Dudemanguy 0242055564 wayland: fix memory leak with multiple monitors
Very dumb. I can't remember if it was always like this or if I broke it
at some point, but clearly each wl_output should just be freed in
remove_output. Freeing it if it happens to be wl->current_output only
works for that one monitor, so remove that whole line. This has to
happen before we close the wayland connection so reorder the uninit a
little bit.
2023-07-08 20:31:09 -05:00
Dudemanguy 6a365b258a player: delete watch_later file after successful load
Currently, mpv immediately deletes the watch_later file after an attempt
at playing the file is made. This is not really ideal because the file
may fail to load for a variety of reasons (including not even existing),
but the state is cleared anyway unconditionally. Instead, just wait
until after playback is successfully initialized before deleting it.
This way silly mistakes like forgetting to mount the drive doesn't
result in deleting your watch_later data. Fixes #3427.
2023-07-08 14:33:47 +00:00
cvzi f5eb7ea1a9 json: unify json_parse depth to MAX_JSON_DEPTH=50 2023-07-08 11:36:15 +02:00
NRK 2e7fcc5a2a terminal-unix: better error detection logic
the reason for checking `EBADF|EINVAL` specifically is unknown. but it's
clearly not working as intended since it can cause issues like #11795.

instead of checking for "bad errors" check for known "good errors" where
we might not want to break out. this includes:

* EINTR: which can happen if read() is interrupted by some signal.
* EAGAIN: which happens if a non-blocking fd would block. `tty_in` is
  _not_ non-blocking, so EAGAIN should never occur here. but it's added
  just in case that changes in the future.

Fixes: https://github.com/mpv-player/mpv/issues/11795
Closes: https://github.com/mpv-player/mpv/pull/11805
2023-07-08 09:03:06 +02:00
Dudemanguy 6ed521fd14 TOOLS/idet: fix some outdated cli syntax
d3cef97ad3 changed the way the command
line was parsed and syntax like "--foo value" stopped being considered
valid. This old script still was using the old syntax and thus was
broken. Update it to "--msg-level=ffmpeg=v" which is the recommended
syntax. Fixes #11892.
2023-07-06 22:40:51 -05:00
Christoph Heinrich 2da0c0b33f demux_playlist: sort files before directories 2023-07-06 18:17:45 +00:00
Christoph Heinrich f266eadf1e demux_playlist: add option to control recursive directory loading
Directories were always loaded recursively, which can be slow
(e.g. one of the subdirectories is a mounting point to a slow device)
and can unexpectedly expand into a massive playlist.

Due to the problems described in 503dada42f,
this defaults to recursive loading.

ref. https://github.com/mpv-player/mpv/issues/9652
2023-07-06 18:17:45 +00:00
llyyr 9ad14e0886 TOOLS/lua/autoload: allow extending ext sets from script-opts 2023-07-06 13:42:54 +00:00
Dudemanguy ee69d99bd4 various: correctly ignore cache files with --no-config
--no-config should prevent loading user files of any type: configs,
cache, etc. For cache files, this case wasn't properly handled and it
was assumed they would always get something. vo_gpu's shader cache
actually already handles this, so it was left untouched. In theory,
demuxer cache should never have this issue because saving it to disk is
disabled by default (and likely that will never change), but go ahead
and change it for consistency's sake. Fixes some segfaults with
--no-config and various combinations of settings (particularly
--vo=gpu-next).
2023-07-06 13:08:23 +00:00
Dudemanguy 48e0ee9979 vo_gpu/vo_gpu_next: enable gpu shader and icc cache by default
4502522a7a changed the way mpv handled and
saved cached files. In particular, it made a separate boolean option for
actually enabling cache and left the *-dir options as purely just a path
(i.e. having a dir set didn't mean you save cache). This technically
regressed people's configs, so let's just turn the cache on by default.
Linux users already expect random stuff in ~/.cache and well everyone
else can just live with some files possibly appearing in their config
directory.
2023-07-04 22:14:43 +00:00
Dudemanguy d6a6901090 vo_gpu: fix some cache related memory leaks
I goofed this up.
2023-07-04 22:14:43 +00:00
Dudemanguy dbc0fcea1b player: add --input-cursor-passthrough option
Add an option for allowing pointer events to pass through the mpv
window. This could be useful in cases where a user wants to display
transparent images/video with mpv and interact with applications beneath
the window. This commit implements this functionality for x11 and
wayland. Note that whether or not this actually works likely depends on
your window manager and/or compositor. E.g. sway ignores pointer events
but the entire window becomes draggable when you float it (nothing under
the mpv window receives events). Weston behaves as expected however so
that is a compositor bug. Excuse the couple of completely unrelated
style fixes (both were originally done by me).
2023-07-04 19:16:43 +00:00
Eva 3ba446d0b0 TOOLS/lua/autoload: avoid unnecessary playlist manipulation, performance
We used to sort the playlist with playlist-move after every loadfile.
Instead, append all files in order and call playlist-move once to move
the only entry we don't control the position of.
Don't fetch every playlist item separately, reuse native property.
We used to pick up on new files added to the directory, but only when
playing an entry at the edge of the playlist due to an early return.
New files are now added to the playlist on every file change.
This still works as expected and doesn't load duplicate files on
shuffled playlists or playlists with files manually added after autoload

33% faster on average for my test directory with 1371 files.
2023-07-03 02:41:58 +00:00
Dudemanguy c8a54a8c23 wscript: bump required libplacebo-next version to 5.266
Was forgotten in b73d96776c. Can't wait
until we finally remove the waf build.
2023-07-02 20:04:42 +03:00
Kacper Michajłow d2c28bc4df vo_gpu_next: remove synchronization from info_callback
VOCTRL is processed on VO thread.
2023-07-02 16:20:48 +02:00
Kacper Michajłow b73d96776c vo_gpu_next: use pl_dispatch_info_move to avoid useless data copy
Instead copy the data on-demand when VOCTRL_PERFORMANCE_DATA is
requested.
2023-07-02 16:20:48 +02:00
Kacper Michajłow c637beb522 ci/msys2: double down on running meson through python3.11
Run not only scripts inside build system, but also meson itself with
Python 3.11.

Fixes: eb4da3400a
2023-07-02 15:15:43 +02:00
NRK b616a6cef1 vo_x11: don't rely on XFree to free calloc-ed data 2023-07-02 12:47:31 +02:00
NRK fa7503989f vo_x11: check for calloc() failure 2023-07-02 12:47:31 +02:00
Dudemanguy f76c441ba2 win32: add support for drag-and-drop option 2023-07-01 02:06:02 +00:00
Dudemanguy 6625a94608 options: add no to drag-and-drop
Suggested by @sfan5. Naturally, "no" disables all drag and drop
behavior.
2023-07-01 02:06:02 +00:00
cloud11665 b45be3d6e9 test/meson: explicitly specify lavf dependency
Added stubs for mp_set_avdict().
2023-07-01 02:05:23 +00:00
cloud11665 695172f63e player/screenshot: add "screenshot" logger 2023-07-01 02:05:23 +00:00
cloud11665 de7f4fb1ee video/image_writer: add avif screenshot support
Notes:
- converts the (image) write() api to filenames, because using avio
with FILE* is a pain.
- adds more debug logs for screenshots.

build: rename av1 dependency to avif_muxer
wscript: unify lavf dependency with meson
2023-07-01 02:05:23 +00:00
NRK 0bfafd2451 options: drop unnecessary casts
the reason for these casts are unknown but they were presumably to
silence warnings 9 years ago. but it doesn't seem to be necessary
nowadays, so just drop the casts and also drop the `const` from the
compound literal type.

some small technical notes:

1. while string literals aren't `const` in C, writing to them is
   undefined (do not ask me why). and so compilers will typically put
   string literals into read only section anyways, regardless of
   weather `const` was used in the source or not. so this shouldn't make
   any difference codegen wise.
2. making the array of pointers `const` on the other hand might affect
   codegen, eg: `(char *const []){...}`. however, that'd trigger a lot
   of discarded qualifier warnings.
2023-06-30 10:22:15 +02:00
NRK 39957c251c options: use designated initializer
shorter and more robust this way instead of inserting at an index by
manually counting.

the surrounding code also uses `[STREAM_*] = ..` so it's more consistent
as well.
2023-06-30 10:22:15 +02:00
Philip Langdale 40a1b0066e vd_lavc: do inline string array initialisation for hwdec_api
I couldn't work out the correct syntax, but NRK0 pointed out an example
of where we'd done it elsewhere in the codebase.
2023-06-29 15:03:05 -07:00
Philip Langdale 9ff8c9e780 vd_lavc: let the user provide a priority list of hwdecs to consider
Today, the only way to make mpv consider multiple hwdecs and pick the
first one that works is to use one of the `auto` modes. But the list
that is considered in those cases is hard-coded. If the user wants to
provide their own list, they are out of luck.

And I think that there is now a significant reason to support this -
the new Vulkan hwdec is definitely not ready to be in the auto list,
but if you want to use it by default, it will not work with many codecs
that are normally hardware decodable (only h.264, hevc and av1 if you
are very lucky). Everything else will fall back to software decoding.

Instead, what you really want to say is: use Vulkan for whatever it
supports, and fall back to my old hwdec for everything else.

One side-effect of this implementation is that you can freely mix
hwdec names and special values like `auto` and `no`. The behaviour will
be correct, so I didn't try and prohibit any combinations. However,
some combinations will be silly - eg: sticking any further values after
`no` will result in them being ignored. On the other hand, a
combination like `vulkan,auto` could be very useful as that will use
Vulkan if possible, and if not, run the normal auto routine.

Fixes #11797
2023-06-29 11:58:51 -07:00
NRK a61b784d90 osdep: remove erroneous POLLERR emulation
first of all, POLLERR is supposed to be ignored in `.events` and only
returned in `.revents`.

secondly select()'s exceptfds does not have a 1:1 correspondence with
POLLERR. thankfully, the only caller of this function (in terminal-unix)
never set the POLLERR flag so the errorfds were unused anyways.

so go ahead and remove it entirely instead of pretending we can emulate
something that's not possible.
2023-06-29 13:17:56 +02:00
NRK 7ad7609541 wayland: remove erroneous POLLERR usage
POLLERR is only returned in `.revents` and is ignored in `.events`
2023-06-29 13:17:56 +02:00
sfan5 76589a5b34 image_writer: respect jpeg-quality when using ffmpeg for writing 2023-06-29 12:42:15 +02:00
sfan5 eac6a82e01 image_writer: remove unused struct fields 2023-06-29 11:33:19 +02:00
NRK d70b859084 mp_image: abort on av_buffer_ref() failure
this changes mp_image_new_ref() to handle allocation failure itself
instead of doing it at its many call-sites (some of which never checked
for failure at all).

also remove MP_HANDLE_OOM() from the call sites since this is not
necessary anymore.

not all the call-sites have been touched, since some of the caller might
be relying on `mp_image_new_ref(NULL)` returning NULL.

Fixes: https://github.com/mpv-player/mpv/issues/11840
2023-06-28 20:56:23 -07:00
NRK 2f220c6286 loadfile: fix leak due to setting NULL parent
in the first iteration, *out will be null and thus the steal and the
strdup both sets the parent to NULL - leaking the allocation later on
(caught via LeakSanitizer).

let append_lang() take care of setting the parent instead.
2023-06-28 14:45:13 -05:00
syphyr f8cb539e6f hwdec: fix undeclared identifier in mediacodec_embed
mediacodec_embed is a `vo` and not a `hwdec`.
2023-06-28 10:29:24 -07:00
NRK c3781b2d68 vo_drm: fix null dereference and using closed fd
when vo_drm_init() fails inside of preinit(), uninit() will be called as
part of cleanup with vo->drm being NULL and thus `drm->fd` would lead to
null dereference.

and since vo_drm_uninit() closes drm->fd, destroy_framebuffer() ends up
using a closed fd.

according to the drm-gem manpage [0]:

> If you close the DRM file-descriptor, all open dumb-buffers are
> automatically destroyed.

so remove the destroy_framebuffer() loop entirely, which fixes both the
issues.

[0]: https://www.systutorials.com/docs/linux/man/7-drm-gem/
2023-06-28 02:10:14 +00:00
Kacper Michajłow e7902eb83d github/workflows: do not copyback files from freebsd VM
It is unstable and fails quite often. Just disable it and remove log
printing of failure.
2023-06-27 09:33:30 +02:00
Kacper Michajłow a6a72f2c86 github/workflows: bump freebsd VM memory size to 8GB 2023-06-27 09:33:30 +02:00
Kacper Michajłow 4dfc2c50c1 hwdec: do not add hwdec device if it failed to create 2023-06-26 19:07:29 +02:00
Kacper Michajłow a5b9290261 vd_lavc: check if av_device_ref is available
Fixes crashes when hwdevice failed to create.

Fixes: #11769
2023-06-26 19:07:29 +02:00
Kacper Michajłow eb4da3400a ci/msys2: switch to Python 3.11 to fix crashes during build
There is a long-standing bug with random crashes of Python 3.10 on CI.

See:
https://github.com/python/cpython/issues/105400
https://github.com/msys2/MINGW-packages/issues/11864
https://github.com/msys2/MINGW-packages/issues/17415
2023-06-26 19:07:18 +02:00
Philip Langdale 9921785340 loadfile: insert missing parentheses
Impressively, gcc's parentheses warning has caught a situation where
the missing parentheses were really needed.
2023-06-26 09:26:27 -07:00
rcombs 945d7c1eda osc: add toggle for forced-only subs 2023-06-25 11:01:58 +02:00
rcombs d8bd1c35ef loadfile: expose auto-forced-only when printing stream info 2023-06-25 11:01:58 +02:00
rcombs 5c4852d173 command: add sub-forced-only-cur prop 2023-06-25 11:01:58 +02:00
rcombs c6cacea4de command: report auto-forced-only flag in track desc 2023-06-25 11:01:58 +02:00
rcombs ba7cc07106 sub: rewrite auto-forced-only support
- No longer has a fake "option" used only internally (which didn't always get propagated properly)
- Always overrideable during playback
2023-06-25 11:01:58 +02:00
rcombs 991a2f79ce player: add more precise sub fallback options 2023-06-25 11:01:58 +02:00
rcombs 5dfa3f7f08 options: default slang to auto 2023-06-25 11:01:58 +02:00
rcombs 5f146e742a loadfile: support "auto" as a language option
This uses the user's OS-level preferred set of languages
2023-06-25 11:01:58 +02:00
rcombs 76009bf7a6 loadfile: use mp_match_lang_single
This adds basic support for IETF language tags,
as well as matching 2-letter language codes against 3-letter ones (and vice versa).
2023-06-25 11:01:58 +02:00
rcombs eb14dbff3e loadfile: take a const char* in match_lang 2023-06-25 11:01:58 +02:00
rcombs be34f52f72 loadfile: short-circuit early on null stream language 2023-06-25 11:01:58 +02:00
rcombs 57dae8f42c osdep: add mp_get_user_langs 2023-06-25 11:01:58 +02:00
rcombs 0463096b3c osdep: move cfstr<->cstr conversions to a new apple_utils.c file 2023-06-25 11:01:58 +02:00
rcombs 8c8d97c26c misc: add language-matching utilities 2023-06-25 11:01:58 +02:00
rcombs 1669c4698d options: set subs-with-matching-audio to off by default
This means that subtitles won't be displayed unless the user asks for them
2023-06-25 11:01:58 +02:00
Philip Langdale 78285e98f1 vo: hwdec: prioritise drmprime over drmprime_overlay
I originally left `drmprime_overlay` as higher priority because
`drmprime` was new, and because I didn't have any hardware where both
worked (only one or the other) so I couldn't compare relative
performance, and if only one worked, the priority didn't matter.

But with time and more usage, we've reached a point where we can say we
would recommend using `drmprime` in situations where both work, and
we've also been able to identify hardware where both do indeed work and
it seems that `drmprime` is more reliable.

So, let's flip them.
2023-06-22 12:46:21 -07:00
NRK 32147956ca ad_lavc: check for allocation failure
Fixes: https://github.com/mpv-player/mpv/issues/11792
2023-06-22 18:13:11 +02:00
Niklas Haas 0af81b16d8 vo_gpu_next: add --corner-rounding option
For better or worse.
2023-06-21 23:52:35 +02:00
Niklas Haas f1600ea9cf vo_gpu_next: add missing --gamut-mapping-mode options
Adds the missing upstream values that were exposed by the new gamut
mapping API.
2023-06-21 23:52:35 +02:00
Thomas Weißschuh 594458838e ao_pipewire: bump dependency to 0.3.48
Now that Debian 12 is release bump the minium required version to what
is provided in Ubuntu Jammy (22.04).
The same as has been done for the wayland dependencies.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2023-06-21 17:33:31 +02:00
Kacper Michajłow 71c80826f1 ao_wasapi: use client name instead of hardcoded string 2023-06-21 17:31:59 +02:00
Kacper Michajłow 3dc661fe8e ao_wasapi: remove infinite loop hack in AOCONTROL_UPDATE_STREAM_TITLE
Instead of brute forcing the name until it is set, without any error
checking and expecting it would start to work, fallback to client name
if initial request fails.

Fixes player going into infinite loop with very long title names. The
API rejects unreasonably long names, which make sense.

As for alleged "weird race condition in the IAudioSessionControl itself"
I cannot comment. It works on my end and even if it fails, it is not a
critical error or even something that we should care about... and
obviously not hang the whole player for that.

Fixes: #11803
2023-06-21 17:31:59 +02:00
Leo Izen ee155d79fd demux/demux_lavf: avoid leaking AVFormatContext during demux_open_lavf
If demux_open_lavf fails between calling avformat_alloc_context() and
assigning the context to priv->avfc, it will never be properly freed.

Fixes #11793.
2023-06-18 09:54:52 -04:00
Dudemanguy 650c53df50 vo_dmabuf_wayland: drop linux-dmabuf-v2 (again)
It was done once before but later reverted for testing reasons. This
time it's permanent though since I can test this VO on ARM and with an
up to date system.
2023-06-16 14:46:59 +00:00
Dudemanguy ca08bf599f wayland: bump wayland-protocols to 1.25
1.27 would have been nicer but ubuntu 22.04 is on 1.25 so we'll just
compromise.
2023-06-16 14:46:59 +00:00
Dudemanguy 45e2ca5411 wayland: bump required version to 1.20
This lets us remove some ifdefs.
2023-06-16 14:46:59 +00:00
Leo Izen d16f971df5 DOCS: fix admonition typo
Fix missing second : in DOCS/man/options.rst after a .. admonition::
2023-06-15 12:28:18 -04:00
Dudemanguy f5e828ac25 vo_dmabuf_wayland: update the image of pending buffers
When using a display-* video-sync mode, it is possible for buffers with
a matching id to already have an image associated with them (i.e. the
compositor hasn't released it yet). Previously, it was thought that we
could just unref, return null, and make a new buffer but this eventually
leads to a fatal error that originates from libwayland itself which
stops playback. Admittedly, the reason for the error is a bit nebulous
but likely it seems to be some kind of mismatch between dmabuf params
and the associated image with the buffer.

However, we can simplify this process greatly. Instead when the
previously mentioned edge case happens, the old image can simply be
freed and we give the buffer the new image. This saves creating a new
buffer and also avoids that nasty libwayland error. A nice win-win all
around. Fixes #11773.
2023-06-14 12:21:10 -05:00
Dudemanguy 4d4837b84e vo_dmabuf_wayland: use a minimum of 15 buffers
vo_dmabuf_wayland has a pool of wl_buffers that it cycles through when
drawing frame. There needs to be at least some minimum number otherwise
a flickering artifact occurs where old frames are mistakenly repeated.
When using display-resample and other similar modes, it seems more
buffers are required (more drawing happens so it makes sense) and the
current minimum of 8 isn't good enough. Let's just bump this to 15. It's
also a random ad hoc number, but as far as I know there's not really a
way to predict how many buffers a random video may need. From testing,
it works fine and overall 15 is still a tiny amount of objects to create
considering the lifetime of a video, so we'll just go with this.
2023-06-14 12:00:23 -05:00
sfan5 f1c9daa169 ci: use a different mirror for freetype
GNU decided to break theirs
2023-06-13 10:01:05 +02:00
Dudemanguy 8ecf2d37eb player: add drag-and-drop option
Some platforms (wayland) apparently have a lot of trouble with drag and
drop. The default behavior is still the same which is basically obeying
what we get from the window manager/compositor, but the --drag-and-drop
option allows forcibly overriding the drag and drop behavior. i.e. you
can force it to always replace the playlist or append at the end. This
only implements this in X11 and Wayland but in theory windows and macos
could find this option useful (both hardcode the shift key for
appending). Patches welcome.
2023-06-12 20:50:08 +00:00
Dudemanguy 2f8d9322fd wayland: avoid misleading log messages on drag/drop
In data_offer_actions, it's possible to get the
WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE action which would set
wl->dnd_action to DND_APPEND (did nothing in practice) but also log a
message which is confusing and misleading. Instead, just ignore and
don't do anything when we get this case.
2023-06-12 20:50:08 +00:00
Kacper Michajłow 1c82d6ae7a ci/mingw: add dlltool to the meson crossfile 2023-06-08 19:52:10 -04:00
OlesyaGerasimenko 309a139e67 mpv.desktop: add Russian translation for GenericName
Added Russian translation for "GenericName", updated Russian
translation for "Comment".
2023-06-08 06:46:05 -04:00
Kacper Michajłow 6ff131add0 ci/mingw: remove cache
To avoid building against stale version of dependencies. In particular
libplacebo is moving target and as we can see the build has been broken
few times recently, so let the CI validate it for us.

The time to build everything is under 30 minutes, which is acceptable in
my opinion, not much longer than macos build.
2023-06-08 06:26:06 -04:00
Kacper Michajłow 8037320920 ci/mingw: update dependencies versions 2023-06-08 06:26:06 -04:00
Kacper Michajłow 5c7a9490cb ci/msys2: enable egl-angle-lib
Now that it has been fixed upstream we can enable and test if it links
correctly.
2023-06-08 06:25:23 -04:00
Leo Izen 6932a27781 github/workflows/build.yml: install ca-certificates package on msys2
Allows python to download waf correctly, fixing CI failure due to its
outdated built-in certificate pool.
2023-06-08 12:09:57 +02:00
Leo Izen 7fe727555d bootstrap.py: update waf to 2.0.25
Fixes some minor bugs in waf.
2023-06-08 12:09:57 +02:00
Guido Cella 1fbaf4602e DOCS/mpv: add an example for applying profiles to certain paths
It is worth adding this example because it has been asked multiple times
in the issue tracker and the IRC channel.

string.find() is used because it's 20 times faster than string.match().
2023-06-07 19:04:21 -04:00
Arthur Williams 46ee31b655 player: don't load unwanted files after 519e56f
519e56f caused an attempt to get the language even if the file name
didn't start with the movie title. However, detecting a language when
fuzz >= 1 or the language is known, caused prio to be non-zero which
caused the file to be included regardless of its name. This shouldn't be
the behavior when sub-auto != all.

Now all the prio updates that depend on lang will only happen if the
file in question starts with the movie name. Since language was never
detected before if this wasn't true, the behavior should be the same as
before 519e56f when sub-auto != all.

Closes: #11749
2023-06-07 10:17:28 +02:00
Philip Langdale effc68063b hwdec_cuda: bump required headers version for timeline semaphores
We're moving to using timeline semaphores for synchronisation between
cuda and vulkan. It's only required with libplacebo-next right now,
but eventually our baseline libplacebo requirement will increase, so we
will need new enough nvidia headers that include the necessary
declarations.
2023-06-04 13:25:43 -07:00
Philip Langdale 3a6738ed8c hwdec_cuda: clear vulkan semaphore fd after passing ownership to cuda
This is not technically necessary, because we never touch the fd again
after passing to cuda, but having it there could lead to future code
accidentally using it.
2023-06-04 13:24:52 -07:00
Philip Langdale 7918545caf hwdec_vulkan: respect probing flag when logging during init
All hwdecs should respect the probing flag and demote their lgoging to
verbose level, so that initialisation failures during probing do not
spam the user. I forgot to do this for the Vulkan hwdec.
2023-06-03 18:37:43 -07:00
Philip Langdale ba6af0fb15 vulkan: don't assume all ra_ctx implementations have a swapchain
The dmabuf-wayland vo has a stub ra implementation that doesn't
have a swapchain. That means that it's currently not safe to call
ra_vk_ctx_get on that ra_ctx, but it must be safe to call on all ra
implementations as this is how we discover if it is a vulkan ra.

This hasn't been an issue before because no Vulkan code paths would be
triggered when using dmabuf-wayland, but with the new vulkan hwdec, it
becomes possible to trigger when hwdecs are probed.
2023-06-03 18:37:43 -07:00
Philip Langdale c8790a9173 hwdec_cuda: remove usage of deprecated libplacebo sync API
The libplacebo sync abstraction is deprecated and we should be using
the more explicit Vulkan semaphore helpers instead. This means that
more of the book keeping moves to our side, but it's not too bad.

There are two main things going on here:

1. After a lot of back and forth, I decided to write the new code with
   timeline semaphores to streamline things, and that also means all
   the variables are separate - which makes the #ifdefs easier to read.
   Which is important because:

2. While pl_sync owned the exported fd/handle, pl_vulkan_sem does not,
   so we are responsible for managing them. That means reversing the
   previous logic - we now can pass an original fd to CUDA and never
   think about it again, while we have to clean up a Win32 Handle
   because CUDA will not take ownership.
2023-06-03 18:15:20 -07:00
sfan5 e18cf0b92a video/out/android: assert WinID value before use 2023-06-03 17:07:43 +02:00
Kacper Michajłow c1bef0f084 path: handle URLs consistently in mp_basename
Detect URLs and skip DOS path processing as it is likely to do
unexpected thing when ":" is found.
2023-06-01 22:47:48 +02:00
Christoph Heinrich 83acd93c6a lua: read_options: find script-opts prefix at index 1 exactly
Finding the prefix in the key is not enough, the key has to actually
start with the prefix. Otherwise a key like `uosc-font_scale` will not
only match the `uosc-` prefix, but also the `osc-` prefix, resulting
in a logged warning about `-font_scale` being an unknown key.
2023-06-01 15:11:55 +03:00
Kacper Michajłow f79458476b demux/demux_lavf: strip URL parameters before matching extension
Unfortunately Content-Type matching seems to be not enough as there are
mistagged streams. Try to match extension and pass-through URL.

Fixes #11700
2023-05-30 10:54:21 +02:00
Philip Langdale bc28dce303 hwdec_vulkan: enable AV1 support if available
AV1 support in Vulkan is extremely bleeding edge - to the point that
the extension is not present in official Khronos releases, but it has
a reserved identifier and we can look it up with a string literal for
now.

This will be skipped and ignored if the driver doesn't support it, so
it's safe if/when the name changes later (it'll just never be activated
in that case).
2023-05-29 14:46:42 -07:00
Philip Langdale 0f37d72360 hwdec_vulkan: check for the correct libplacebo version
It's 6.278, rather than 5.278.
2023-05-29 14:39:22 -07:00
sfan5 0d1b96c233 vo: hwdec_aimagereader: fix compile
forgotten in 085f3e31a0
2023-05-29 22:50:35 +02:00
Philip Langdale 0131ae4133 hwdec_vulkan: simplify requirement checks for Vulkan interop
I originally wrote this trying to avoid doing an explicit version check
on the headers, but it just makes things more confusing, and the
requirements harder to understand.

So, Vulkan interop now takes a dependency on the header release where
they finalised the video decode headers. VK_EXT_descriptor_buffer was
added in 1.3.235, so that's covered as well.

Along the way I fixed a bug in the waf build where it was depending
on libplacebo-next instead of libplacebo-decode.
2023-05-29 13:26:29 -07:00
Kacper Michajłow ba5370e82a vo/vulkan: do not define zero sized array
It is not needed at all.
2023-05-29 12:33:43 -07:00
Philip Langdale c40bd88872 hwdec_vulkan: account for vulkan frames now using presentation size
ffmpeg was previously allocating images for frames as the code size,
rather than the presentation one (1088 vs 1080 in the most common
example). Using the coded size when wrapping images for libplacebo
resulted in incorrect scaling from 1088 -> 1080, but even using the
presentation size wasn't perfect, as discussed in the original
commit.

However, ffmpeg has now been updated to use the presentation size for
the frame images, after discussions that concluded this must be done
because there is no way for a frame consumer to fix the dimensions
without copying the frame.

With that ffmpeg change, we can just use the normal layout information
like all the other hwdecs.
2023-05-29 10:16:29 -07:00
Philip Langdale 872b068cb7 f_hwtransfer: disable vulkan multiplane images when uploading from cuda
Although we can support vulkan multiplane images, cuda lacks any such
support, and so cannot natively import such images for interop. It's
possible that we can do separate exports for each plane in the image
and have it work, but for now, we can selectively disable multiplane
when we know that we'll be consuming cuda frames.

As a reminder, even though cuda is the frame source, interop is one way
so the vulkan images have to be imported to cuda before we copy the
frame contents over.

This logic here is slightly more complex than I'd like but you can't
just set the flag blindly, as it will cause hwframes ctx creation to
fail if the format is packed or if it's planar rgb. Oh well.
2023-05-28 15:46:05 -07:00
Philip Langdale 642dae1a6e hwdec_vulkan: use bwdif_vulkan as deinterlacing auto filter
This is currently the only vulkan deinterlacing filter in ffmpeg and
it's a very high quality algorithm.
2023-05-28 15:46:05 -07:00
Philip Langdale 45a2d8c670 vo: vulkan: request additional extensions and features for ffmpeg
Vulkan hwdec interop with the ffmpeg 6.1 vulkan code will require
additional features beyond those activated by libplacebo by default.

Enabling these features requires both requesting the features'
extensions and then explicitly turning on the features. libplacebo
handles detecting unsupported features and dropping them, to avoid
failing to create the vulkan device.

We then leave it to ffmpeg to decide if any missing features are
required for functionality, and error out if necessary.

As ffmpeg requires at least one bleeding edge extension (descriptor
buffers), all of this logic is gated on the presence of sufficiently
new Vulkan headers.
2023-05-28 15:46:05 -07:00
Philip Langdale 61e685594d hwdec_vulkan: add Vulkan HW Interop
Vulkan Video Decoding has finally become a reality, as it's now
showing up in shipping drivers, and the ffmpeg support has been
merged.

With that in mind, this change introduces HW interop support for
ffmpeg Vulkan frames. The implementation is functionally complete - it
can display frames produced by hardware decoding, and it can work with
ffmpeg vulkan filters. There are still various caveats due to gaps and
bugs in drivers, so YMMV, as always.

Primary testing has been done on Intel, AMD, and nvidia hardware on
Linux with basic Windows testing on nvidia.

Notable caveats:
* Due to driver bugs, video decoding on nvidia does not work right now,
  unless you use the Vulkan Beta driver. It can be worked around, but
  requires ffmpeg changes that are not considered acceptable to merge.
* Even if those work-arounds are applied, Vulkan filters will not work
  on video that was decoded by Vulkan, due to additional bugs in the
  nvidia drivers. The filters do work correctly on content decoded some
  other way, and then uploaded to Vulkan (eg: Decode with nvdec, upload
  with --vf=format=vulkan)
* Vulkan filters can only be used with drivers that support
  VK_EXT_descriptor_buffer which doesn't include Intel ANV as yet.
  There is an MR outstanding for this.
* When dealing with 1080p content, there may be some visual distortion
  in the bottom lines of frames due to chroma scaling incorporating the
  extra hidden lines at the bottom of the frame (1080p content is
  actually stored as 1088 lines), depending on the hardware/driver
  combination and the scaling algorithm. This cannot be easily
  addressed as the mechanical fix for it violates the Vulkan spec, and
  probably requires a spec change to resolve properly.

All of these caveats will be fixed in either drivers or ffmpeg, and so
will not require mpv changes (unless something unexpected happens)

If you want to run on nvidia with the non-beta drivers, you can this
ffmpeg tree with the work-around patches:

* https://github.com/philipl/FFmpeg/tree/vulkan-nvidia-workarounds
2023-05-28 15:46:05 -07:00
Philip Langdale 085f3e31a0 vo: hwdec: Pass the ra_ctx to hwdecs instead of just the ra
We will need the full ra_ctx to be able to look up all the state
required to initialise an ffmpeg vulkan hwcontext, so pass let's
pass the ra_ctx instead of just the ra.
2023-05-28 15:46:05 -07:00
Kacper Michajłow 959ef843d2 vo_gpu_next: fix to allow using dllimport
Address of variables can't be used for constant initialization in C
language modes.
2023-05-27 14:54:59 +02:00
Niklas Haas 7595ea7c7c vo_gpu_next: respect gl->flipped
This fixes flipped rendering on angle/dxinterop instances.
2023-05-27 11:37:48 +02:00
Niklas Haas b216c09ade opengl: move ra_gl_ctx_params.flipped to struct GL
This is motivated by a need to access it from vo_gpu_next's opengl
wrapping code, and justified by it being an inherent property of the GL
context itself,
2023-05-27 11:37:48 +02:00
Kacper Michajłow 9fd4ae9529 vo: make mp_frame_perf thread safe
It was unsafe to return pointer to memory that was freed on another
thread, just copy the string to caller owned sturcture.

Fixes crashes when displaying passes stats with gpu-next.
2023-05-25 16:25:33 +02:00
Kacper Michajłow 19c5cd92b2 vo_gpu_next: add size guard for pass->num_samples
This shouldn't happen as the array sizes are the same, but guard against
it in case libplacebo do something naughty.
2023-05-25 16:25:33 +02:00
Kacper Michajłow 3b89a58af7 vo_gpu_next: synchronize voctrl_performance_data access
info_callback is fired quite often and from different thread than any
accesses to this structure.
2023-05-25 16:25:33 +02:00
Kacper Michajłow 695b3c51d1 vo_gpu_next: fix off by one in info_callback
Fixes invalid memory writes.
2023-05-25 16:25:33 +02:00
Dudemanguy c1de4bb745 vo_dmabuf_wayland: rewrite around wl_list
vo_dmabuf_wayland worked by allocating entries to a pool and then having
a lot of complex logic dealing with releasing buffers, pending entries,
etc. along with some other not so nice things. Instead, we can rewrite
this logic so that the wl_buffers created by the imported dmabuf is
instead stored in a linked list, wl_list. We can simply append our
buffers to the list when needed and destroy everything at the end. On
every frame, we can check the ids of our surfaces and reuse existing
buffers, so in practice there will only ever be a handful at a time.
Some other small changes were made in an attempt to organize the
vaapi/drmprime code a little better as well.

An important change is to always enforce at least a minimum number of
buffers. Certain formats would not make enough unique buffers, and this
results in flickering/artifacts occuring. The old way to attempt to deal
with this was to clear out all the existing buffers and remake them, but
this gets complicated and also didn't always work. An easy solution to
this is just create more buffers which appears to solve this problem.
The actual number needed is not really based on anything solid, but 8
is a reasonable number to create for the lifetime of a file and it seems
to do the trick.

Additionally, seeking/loading new files can result in flicker artificts
due to buffers being reused when they shouldn't. When that happens, we
flip a bool so all the buffers get destroyed in draw_frame to avoid any
visual glitches.
2023-05-24 21:53:17 +00:00
Niklas Haas b9a5583f17 vo_gpu_next: fix build on older libplacebo
Introduced by, of all things, a rebase...

Fixes: a5da8b2c87
2023-05-24 22:06:03 +02:00
Niklas Haas a5da8b2c87 vo_gpu_next: update to new libplacebo gamut mapping API
This just replaces the API calls to get rid of deprecation warnings, it
doesn't yet expand the enum, nor replace them by the proper options.

The translation from tone map modes to hybrid mix parameters is taken
from the libplacebo source code.
2023-05-24 21:32:23 +02:00
Niklas Haas dc13d47c73 vo_gpu_next: remove --tone-mapping-crosstalk
Removed upstream, to be replaced by constant 0.04.
2023-05-24 21:32:00 +02:00
Matthew Lindner a1a2e27f84 context_drm_egl: check for non-existant drm in uninit
Previously, if vo_drm_init failed at the start of drm_egl_init it
caused a use-after-free in drm_egl_uninit when it tried to access the
non-existant drm context. At that point vo_drm_uninit had already been
called resulting in two different null pointer dereference. In this
situation the DRM private context had also not been allocated.
2023-05-22 21:47:24 -05:00
sfan5 2a2cb6a49e player: improve diagnostics around writing watch_later files 2023-05-21 20:11:24 +02:00
sfan5 576e86bfa1 path: let configdir also override "cache" and "state" paths
This matches the behaviour that libmpv API clients expect better and
prevents silent regressons with watch_later suddenly appearing in
an entirely different path (or none at all in case of weird platforms*).

Also added some comments for easier understanding.

* Android
2023-05-21 20:11:24 +02:00
sfan5 d8d0c853c0 path: simplify "cache" and "state" fallback
Instead of having more global state just do it on-the-fly.
2023-05-21 20:11:24 +02:00
Arthur Williams 519e56f80f player: always try to detect subtitle language from file name
Previously, we'd only attempt to call guess_lang_from_filename if the
external file name matched the video name ignoring the extensions. So if
they didn't match, we'd just report the language as "unknown". And since
the name will never match for urls, the language would always be treated
as unknown.

Now we'll always try to guess the language from the filename regardless
of its similarity to the video file name.

Closes #10348
2023-05-21 10:02:03 -04:00
Kacper Michajłow ec58670a0d ra_d3d11: change how messages are ignored during texture size lookup
Filtering globally D3D11_MESSAGE_ID_CREATETEXTURE2D_INVALIDDIMENSIONS is
suboptimal, because can also hide other invalid usages. In the same time
it is not enough, because not only this message is emitted, but also one
about E_INVALIDARG. Just flush queue before and clear messages after to
ignore this part of code.

As a side note, I don't believe this texture size lookup is in fact
useful, but since it is there and is relatively harmless, let's leave
it as is.
2023-05-18 21:56:54 +02:00
Dudemanguy f677f8a5a7 wayland: improve guessing when mpv is focused
The current implementation is order dependent and assumes that getting
keyboard input happens before the toplevel is activated. This isn't
necessarily the case and indeed mutter activates the toplevel first.
Improve this by simply spinning off the check to a function and calling
it in the three places where it would be needed: the toplevel
configuration event, keyboard entering, and keyboard leaving. This
fixes #11694.
2023-05-17 16:13:04 -05:00
Kacper Michajłow 1237bf0d73 demux/demux_lavf: pass-through mime_type
This fixes HLS playback. After FFmpeg@954d16f check is strict as per
RFC8216 requirement and demuxer need to have this information to work
properly.
2023-05-16 10:46:35 -04:00
Kacper Michajłow fe4f03f42c demux/demux_lavf: pass-through filename for HLS
Fixes local HLS playback.

After FFmpeg@6b1f68c commit HLS is only processed if file extension
matches RFC8216 requirement.
2023-05-16 10:46:35 -04:00
Kacper Michajłow 1a649df00a Revert "demux/demux_lavf: pass dummy filename when an HLS mimetype is detected"
This reverts commit acababec20.

Now it has been fixed upstream FFmpeg@6b1f68c.
2023-05-16 10:46:33 -04:00
Leo Izen acababec20 demux/demux_lavf: pass dummy filename when an HLS mimetype is detected
Pass "dummy.m3u8" filename to work around FFmpeg commit
6b1f68ccb04d791f0250e05687c346a99ff47ea1 which broke their HLS demuxer
and its ability to probe.

Since the above commit, libavformat will check the filename of the file
to be probed and reject it if it doesn't end with a valid HLS extension
i.e. m3u8,hls,m3u (never mind that .hls is not a valid HLS extension).
In addition to a bug with query strings, this also breaks mpv
functionality as mpv explicitly doesn't tell libavformat the filename
when probing, in order to properly detect the file based only on their
contents.

The [HLS specification](https://www.rfc-editor.org/rfc/rfc8216.txt) aka
RFC 8216, specifies in section 4 that "Each Playlist file MUST be
identifiable either by the path component of its URI or by HTTP
Content-Type." Notably, it does not require both, so this FFmpeg commit
is noncompliant. We work around this noncompliance by checking the MIME
type ourselves. If the mimetype matches one of the valid HLS mimetypes
(and also application/x-mpegurl, a legacy pre-standardization type),
then we pass "dummy.m3u8" to libavformat in order to work around its
overly strict checking of filenames.

Without this patch, we are unable to play many HLS streams, including a
few from the ytdl hook. This patch restores those ability to play those
streams when built against FFmpeg master. Do note that if the server
sends an invalid content-type header then we cannot implement this
workaround so those streams will still fail to play.
2023-05-14 16:28:29 -04:00
Kacper Michajłow 9e716d6303 vo_gpu_next: allow to use ICC profile luminance value
Also while at it respect target-peak option when ICC profile is used.

Fixes #11449
2023-05-13 17:08:37 +02:00
Philip Langdale 8343b3bded mp_image: use the ffmpeg interlaced frame flags where available
The old frame properties are deprecated and have been replaced by frame
flags.
2023-05-11 14:31:17 -07:00
rim 5afc0da530 ao_oss: return actual OSS playing state
fix: https://github.com/mpv-player/mpv/issues/10640
2023-05-11 01:53:55 +00:00
Dudemanguy 4502522a7a player: use XDG_CACHE_HOME by default
This adds cache as a possible path for mpv to internally pick
(~/.cache/mpv for non-darwin unix-like systems, the usual config
directory for everyone else). For gpu shader cache and icc cache,
controlling whether or not to write such files is done with the new
--gpu-shader-cache and --icc-cache options respectively. Additionally,
--cache-on-disk no longer requires explicitly setting the --cache-dir
option. The old options, --cache-dir, --gpu-shader-cache-dir, and
--icc-cache-dir simply set an override for the directory to save cache
files. If unset, then the cache is saved in XDG_CACHE_HOME.
2023-05-09 20:37:17 +00:00
Dudemanguy 7c4c9bc86f player: use XDG_STATE_HOME for watch_later
A pain point for some users is the fact that watch_later is stored in
the ~/.config directory when it's really not configuration data. Roughly
2 years ago, XDG_STATE_DIR was added to the XDG Base Directory
Specification[0] and its description, user-specific state data, actually
perfectly matches what watch_later data is for. Let's go ahead and use
this directory as the default for watch_later. This change only affects
non-darwin unix-like systems (i.e. Linux, BSDs, etc.). The directory
doesn't move for anyone else.

Internally, quite a few things change with regards to the path
selection. If the platform in question does not have a statedir concept,
then the path selection will simply return "home" instead (old
behavior). Fixes #9147.

[0]: https://gitlab.freedesktop.org/xdg/xdg-specs/-/commit/4f2884e16db35f2962d9b64312917c81be5cb54b
2023-05-09 20:37:17 +00:00
Dudemanguy 5158b85b21 path: expand internal path selection API to allow for additional types
Currently, nothing new is actually implemented but the idea is simply to
just pass a type string all the way up from mp_find_user_file down to
actually getting the platform path. This allows for selecting different
directories besides the user's native config directory. See the next
commit for an implementation.
2023-05-09 20:37:17 +00:00
Dudemanguy baa9d56481 osdep: separate out macos paths from path-unix.c
macOS really has completely different path conventions that mpv doesn't
take into account and it treats it just like any other old unix-like
system. This means mpv enforces certain conventions on it (like all the
XDG stuff) that doesn't really apply. Since we'd like to use more of
this but at the same time not distrupt mac users even more, let's just
copy and paste the current code to a new file, update the build and call
it a day. This way, the paths of these two platforms can more freely
diverge.
2023-05-09 20:37:17 +00:00
Nick Hanley a1580b6424 DOCS/options: document required parameter for --x11-name 2023-05-06 21:26:50 +00:00
Dudemanguy a3eb163303 meson: bump required version to 0.62
This lets us use meson's custom dl dependency as well as the version
method when checking rst2pdf's version.
2023-05-02 19:20:50 +00:00
Simon Ser 6234a70920 wayland: add support for wl_surface.preferred_buffer_scale
See [1] for the motivation. Very similar to the fractional scale,
except it's in core and integer-only.

[1]: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/220
2023-04-30 21:20:18 +00:00
Thomas Weißschuh 6d422b3edc options: read config file as stream
This aligns the possible sources of config files other loaded data.
For example `--input-conf`.
2023-04-29 22:34:54 +00:00
Kacper Michajłow 7668361685 ci: switch to lua51 for MSYS build
luajit is currently crashing on 32-bit build:
https://github.com/msys2/MINGW-packages/issues/17042
2023-04-29 19:07:45 +00:00
Kacper Michajłow e836b58050 ci: use auto detection for lua library version for MSYS 2023-04-29 19:07:45 +00:00
low-batt 6d208d38d2 charset_conv: fix memory corruption in mp_iconv_to_utf8
If mp_iconv_to_utf8 was given an empty string to convert in the buf
parameter it would corrupt memory when writing a null into outbuf
before returning it to the caller. This happened when streaming from a
URL that ends in a slash. For such a URL the method mp_basename returns
an empty string. The method append_dir_subtitles passes the result
returned from mp_basename to mp_iconv_to_utf8 which then corrupts
memory. This was detected using Guard Malloc. The fix changes
mp_iconv_to_utf8 check up front if buf is empty and if it is return
buf as the result in compliance with the documented behavior of the
method when no conversion is needed.

Fixes #11626
2023-04-29 01:37:41 +00:00
Lypheo e928bd5fdb sub: fix UPDATE_SUB_HARD for converted and external subtitles
Upon an option update with an UPDATE_SUB_HARD flag,
the ass_track that stores all the decoded
subtitle packets/events is destroyed and recreated, which means
the packets need to be read and decoded again to refill
the ass_track. This caused issues (no subs displayed) in 2 cases:
1. external sub files
  Previously, external sub files were read and decoded only
  once when loaded. Since this meant all decoded events were lost
  forever when recreating the ass_track, we need to change this
  and trigger a new preload during sub reinits.
2. converted subs (non-ASS text subs like srt)
  For converted subs, we maintain a list of previously
  seen packets to avoid decoding and adding duplicate events
  to the ass_track. Previously this list wasn’t synchronized with
  the corresponding ass_track, so the sub decoder would reject
  any previously seen sub packets, usually meaning only subs sometime
  after the current pts would be displayed after sub reinits.
  Fix this by resetting the list upon ass_track recreation.
2023-04-29 00:30:15 +00:00
Guido Cella c5211dbf4a console.lua: add a script-opt for the border size
Because I find the console log easier to read with a thicker border.
2023-04-26 16:30:01 +00:00
Kacper Michajłow 4fd0a39fc8 vo_gpu_next: fixes to allow using dllimport
Address of variables can't be used for constant initialization in C
language modes.

See https://github.com/llvm/llvm-project/commit/0c43d8077e605ab78d85180f0dcaa4df1ae37607
2023-04-24 13:16:55 +02:00
Thomas Weißschuh 71f9e97fc0 ao_pipewire: clarify --pipewire-buffer=native 2023-04-23 21:03:58 -07:00
Thomas Weißschuh 993553e138 ao_pulse: clarify --pulse-buffer=native 2023-04-23 21:03:58 -07:00
Thomas Weißschuh cb6b4af1d7 ao_pipewire: let sound server determine latency
Fixes #11467
2023-04-23 21:03:58 -07:00
Thomas Weißschuh eafd0e5fad ao_pipewire: give sound server more flexibility for buffers 2023-04-23 21:03:58 -07:00
EmperorPenguin18 c7a8e71578 hwdec_drmprime: support rpi4_8 and rpi4_10 formats
HEVC hardware decode with drm wasn't working on the RPi 4. Mpv would
report the image format (rpi4_8 for 8-bit and rpi4_10 for 10-bit) wasn't
supported. The change to hwdec_drmprime.c identifies these two formats
as NV12 because it functions exactly the same. The change to
dmabuf_interop_gl.c adds support for P030 which rpi4_10 uses. These
changes were tested on a Pi 4 with this fork of ffmpeg:
https://github.com/jc-kynesim/rpi-ffmpeg.

Signed-off-by: EmperorPenguin18 <60635017+EmperorPenguin18@users.noreply.github.com>
2023-04-20 14:37:15 -07:00
Arnold Stanovský c50f536bd1 ytdl_hook: fix clip start and end 2023-04-12 02:14:09 +00:00
Sam Van Den Berge b573a4967d libmpv: fix file name in documentation
render_cb.h doesn't exist but render.h does.
2023-04-11 20:06:42 +00:00
Dudemanguy 3c1686488b meson: use the new build_options method
This finally allows us to put any user defined options into the
CONFIGURATION variable like what waf does. The arbitrary hardcoded
fallback is left in place for old meson versions. Also update the
documentation in regards to the mpv-configuration variable to be
relevant to meson.
2023-04-11 20:05:36 +00:00
iczero d65e56216d wayland: correctly scale configure_bounds 2023-04-11 20:05:17 +00:00
Leo Izen cbbe2e5221 player/screenshot: avoid non-sRGB spaces with --screenshot-tag-csp=no
If --screenshot-tag-csp=no, then there won't be any color tags in the
output space, so PNG and JXL screenshots should be written as sRGB
rather than the native space of the input video.
2023-04-10 18:29:56 -04:00
Mika Kuoppala 95d7b05e71 video/out/gpu: Fix compilation warning of out of bound access
Make the index into the arrays in copy_image()
unsigned to make compiler trust that we dont access
out of bounds.
2023-04-10 10:48:16 -04:00
quietvoid 1808f264b3 mp_image: always add AV_FRAME_DATA_DOVI_METADATA when present
As the Dolby Vision metadata is only supported for vo_gpu_next, the check
whether to use the metadata is now handled by `mp_map_dovi_metadata_to_pl`.

It doesn't hurt to keep the metadata in `mp_image`, and might be useful to
library users.
2023-04-10 05:18:58 -04:00
sfan5 9a8b31707e ci: add a workflow that lints commit messages 2023-04-08 17:08:57 +02:00
Dudemanguy 7ae7fc0112 auto_profiles: try to distinguish invalid properties better
6e4a76db08 attemped to reject invalid
properties and print an error for users so they actually know that
something is going wrong. This worked by simply checking if the property
not found error is returned, but it is actually perfectly possible for a
property to not be found (different than being unavailable just to be
clear here) at first and then show up later. An example would be
user-data which can be created at any time. It's also possible with
subproperties of things like track-list where a new track could be added
later.

In light of this, let's soften the error checking logic here with a
simple trick. mpv already keeps track of all toplevel properties and it
can be easily retrieved with the "property-list" property, so just cache
that. When we get a property not found error, instead of rejecting it,
try to match it something in the property-list first. If we have a
match, then consider the property valid and allow the script to behavior
normally. If not, we reject it. This approach means property names that
are obviously wrong like "fake-property-here" will reliably get rejected
and something like "user-data/test" works as usual. The downside is that
errors in the subproperty level are not caught, so something like
"track-list/0/fake-property" would still be considered valid and the
user gets no warning that this won't work. We'll just accept the
compromise and hope this isn't too common.

Fixes #11550.
2023-04-07 01:48:55 +00:00
Guido Cella 41372c5e1f auto_profiles.lua: apply profiles when conditions are truthy
Instead of erroring when values returned by profile-cond expressions
aren't booleans, apply the relative profiles as long as the return
values are truthy. This allows shortening conditions like

profile-cond=path:match('foo') ~= nil

to

profile-cond=path:match('foo')
2023-04-05 18:32:18 +00:00
Christoph Heinrich b7ffe0d16e osc: skip rendering when osd_dimensions are 0
The idle logo could appear on the left side of the window for a split
second after starting.
That is because when osd dimensions can be reported as 0 at the very beginning.
Since the width gets calculated based on a fixed height and the aspect ratio,
which is 0, that results in a width of 0 until the next update.
2023-04-05 17:14:43 +00:00
Kacper Michajłow 9feeb324ed win32: follow Windows settings and update dark mode state
Microsoft documented how to enable dark mode for title bar:

https://learn.microsoft.com/windows/apps/desktop/modernize/apply-windows-themes
https://learn.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute

Documentation says to set the DWMWA_USE_IMMERSIVE_DARK_MODE attribute to
TRUE to honor dark mode for the window, FALSE to always use light mode.
While in fact setting it to TRUE causes dark mode to be always enabled,
regardless of the settings. Since it is quite unlikely that it will be
fixed, just use UxTheme API to check if dark mode should be applied and
while at it enable it fully. Ideally this function should only call the
DwmSetWindowAttribute(), but it just doesn't work as documented.

Fixes: #6901
2023-04-04 20:04:57 +02:00
Kacper Michajłow 68b3239b52 d3d11: retry device creation without debug, if SDK is not available
Fixes #11512
2023-04-02 21:43:53 +03:00
Kacper Michajłow 9d120a4411 build: add check for eglext_angle.h when checking for ANGLE
This better follows the actual required bits, and makes sure that
a file not part of standard EGL headers is available, as the
handle type is part of standard EGL extensions header.
2023-04-02 21:23:48 +03:00
Kacper Michajłow 911d742817 context_angle: include eglext_angle.h explicitly
Recent MSYS update switched to using vanilla EGL headers, which doesn't
include eglext_angle.h implicitly.
2023-03-30 22:00:38 +03:00
feltcat 0f13c38e72 DOCS/input: fix typo 2023-03-30 13:57:08 +00:00
Dudemanguy 6e4a76db08 auto_profiles: check for non-existent properties
Previously, it just silently didn't do anything which is not very
intuitive. Since the lua api returns an error string, check to see if
it matches the "property not found" case and print an error message.
Additionally, don't add the fake property to the internal
cached_properties list or try to observe it. This avoids redundant
evaluate calls which will never actually succeed. We do still mark it
under watched_properties however. This avoids having to call
mp.get_property_native multiple times.
2023-03-29 13:33:57 +00:00
Alexander Seiler bdf7b5c3b8 various: fix various typos in the code base
Signed-off-by: Alexander Seiler <seileralex@gmail.com>
2023-03-28 19:29:44 +00:00
Harri Nieminen 292a5868cb various: fix typos
Found by codespell
2023-03-28 19:29:44 +00:00
Philip Langdale 24bed9b949 demux_lavf: update to handle deprecation of io_close
`io_close2` was introduced as a superior replacement for `io_close` in
ffmpeg 5.0, and then deprecated in 6.0. The difference is that
`io_close2` can return errors. In our case, we're just calling through
to the original function anyway, so we don't need to do more than pass
the return value back.
2023-03-28 11:32:51 -07:00
Kacper Michajłow 6a62aa0330 ci: bump cache version to rebuild libplacebo
libplacebo-next version requirement was increased recently, need to
rebuild it to fix mingw CI builds.
2023-03-28 09:23:38 -07:00
Kacper Michajłow 21301dc12d ci/mingw: require libplacebo-next
libplacebo is build by us, so we can explicitly enable it.
2023-03-28 09:23:38 -07:00
Kacper Michajłow 10136e77a3 build: add an option to control gpu-next
Also simplify meson logic
2023-03-28 09:23:38 -07:00
Kacper Michajłow 1ea74f10a7 ci/mingw: update meson
libplacebo requires >= 0.63
2023-03-28 09:23:38 -07:00
Philip Langdale d1d0b1a8ee meson: fix libplacebo-next version comparison
Should just compare against '264'.
2023-03-26 22:01:06 -07:00
llyyr 685d9cbe5b vo_gpu_next: drop various PL_API_VER checks
We don't need these anymore now that we require PL_API_VER>=264 for
building libplacebo-next
2023-03-26 20:55:58 -07:00
llyyr 631b7d54dc wscript: bump libplacebo-next required version to 5.264
b77f88157e only bumped the version for
meson builds.
2023-03-26 20:55:58 -07:00
Philip Langdale b77f88157e meson: bump libplacebo-next required version to 5.264
This is the latest stable release, and what we should use for
libplacebo-next per haasn's recommendation.

The previous 202 version wasn't even a release.
2023-03-26 21:00:23 +02:00
cloud11665 664f197746 player/screenshot: add filename return field
DOCS/input: add screenshot return value description
2023-03-25 16:24:21 +00:00
Christoph Heinrich 34a04d0567 player: set playlist title to media title if not set already
The playlist title only got set when it was specified in the playlist
file.
If there is a title after opening a file, that should also be reflected
in the playlist.
2023-03-24 02:28:49 +00:00
Christoph Heinrich 5ddf6d479e Revert "player: set playlist title to media title if not set already"
As it turns out that approach was suboptimal.
The playlist title would only ever get set when media-title actually
gets read, which depending on the configuration and usage might never
happen.

The next commit reimplements that feature in a different way.

This reverts commit 048d4d8b75 except for
the input.rst change.
2023-03-24 02:28:49 +00:00
Thomas Weißschuh 4827fc2907 meson: rst2pdf handle dependency file 2023-03-24 02:18:39 +00:00
Thomas Weißschuh 707554324a TOOLS/docutils-wrapper: handle commands without depfile 2023-03-24 02:18:39 +00:00
Thomas Weißschuh 375e527620 TOOLS/docutils-wrapper: properly propagate failures 2023-03-24 02:18:39 +00:00
Thomas Weißschuh d6f70ef96b TOOLS/docutils-wrapper: gracefully remove non-existing files 2023-03-24 02:18:39 +00:00
Ameer Taweel 892ca9f5d9 DOCS/lua: fix typo 2023-03-21 15:49:42 +02:00
Oliver Freyermuth a45995f6b8 options: enable scripts related opts also with cplugins.
If an mpv build neither supports lua nor javascript,
but only cplugins, the scripts options are still usable
to select which cplugins to load.
2023-03-18 21:40:17 +02:00
Dudemanguy e1727553f1 test: update format refs to ffmpeg 6
Major release means new formats and failing tests so just add the new
stuff to the ref again and bump the minimum libavutil version. The last
ffmpeg commit that added a new format and is the minimum required
version for these subset of tests is referenced below.

https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/479747645f795b6f4f376578ea1556409f943c31
2023-03-15 00:25:11 +02:00
Dudemanguy c7395970df github/workflows: fix failure conditions
It turns out that you actually have to add failure() to each condition
otherwise a default status check of success() is applied (thanks
github). Looks redundant but whatever. Thanks to @kasper93 for actually
reading the documentation.
2023-03-15 00:25:11 +02:00
Jan Ekström 1313f287e5 common/av_common: clean up mp_lavc_set_extradata
It no longer has any users, as the last ones (subtitle decoders)
were switched to mp_set_avctx_codec_headers.
2023-03-14 23:59:47 +02:00
Jan Ekström 9f5d7d5932 sub/sd_lavc: properly fill avctx with codecpar values at init
Similar reasons as with the previous commit touching lavc_conv,
as well as this being the last location where mp_lavc_set_extradata
being utilized.
2023-03-14 23:59:47 +02:00
Jan Ekström e20b645611 sub/lavc_conv: properly fill avctx with codecpar values at init
This way we receive such minor details as the profile (necessary for
ARIB captions, among others) during init. This enables decoders
to switch between ARIB caption profile A and profile C streams.
2023-03-14 23:59:47 +02:00
Jan Ekström ef7b711bed common/av_common: constify mp_codec_params related getters
They should not be modifying the argument, so clearly marking it
as const makes sure we don't do it in the future as well as allows
for read-only optimizations.
2023-03-14 23:59:47 +02:00
rcombs 0da0acdae8 demux_mkv: support ARIB captions 2023-03-14 22:32:40 +02:00
rcombs 3eb2dfe2eb player/command: fix mem leak in user-data property; closes #11436 2023-03-13 22:49:51 -04:00
llyyr 3a2f8d42ab vo_gpu_next: compatibility with libplacebo v6.265
libplacebo v6.265.0 removed v4 deprecations. We already require
PL_API_VER >= 202, so we don't need to wrap
pl_tex_transfer_params.row_pitch around a conditional, which exists
since PL_API_VER >= 168. However, pl_source_frame.duration does not exist until
PL_API_VER >= 219, so we should use a conditional directive.
2023-03-13 20:09:06 +01:00
Dudemanguy 9880b06a37 wayland: make wayland-edge-pixels-pointer default to 16
10 is ludicrously small. How did no one on an CSD compositor complain
about this?
2023-03-08 14:06:22 +00:00
Dudemanguy b313a242c2 wayland: use correct x/y coordinates for the cursor
While adding fractional scale support, the coordinates for wayland
changed to always include the scaling parameter. The pointer stuff
actually did too. However, the check_for_resize function used the
unscaled, local surface coordinates. Likely, it was neccesary at the
time since wl->geometry used to report unscaled coordinates. In light of
that, we can just simply use mouse_x/y instead for this function to make
it work correctly with the right/bottom edges. mouse_unscaled becomes
completely unneccesary, so just drop it.

Some minor style changes included just because.
2023-03-08 14:06:22 +00:00
Christoph Heinrich 855b619cc9 screenshot: fix segfault when taking a screenshot without video
Also a style change to exit early when nothing can be done anymore.
2023-03-07 14:36:52 +00:00
Christoph Heinrich 31160ff941 wayland: fix client side resize
`xdg_toplevel_decoration` exists on SSD compositors independent of if
there is a border or not, so resizing didn't work on those.
Checking the border option makes more sense and also works on such
compositors.
2023-03-07 00:16:18 +00:00
Niklas Haas dcc9bc5dea vo_gpu_next: compatibility with PL_API_VER >= 254
This field was renamed/moved to a different params struct.
2023-03-06 21:35:10 +01:00
Leo Izen 4defd8bb27 vo_gpu_next: use inverse mapping functions to tag screenshots
Screenshots using the hardware renderer should now include color tags
that map directly from the libplacebo tags, so the if/else logic only
needs to be included once.
2023-03-05 22:37:05 -05:00
Leo Izen 8217b186f6 video/out/placebo/utils: add mappings from pl enums to mpv enums
mp_trc_to_pl, mp_prim_to_pl, and mp_levels_to_pl have forward but not
inverse mappings. This commit adds mp_trc_from_pl, mp_prim_from_pl, and
mp_levels_from_pl inverse mapping functions, which just map the enums
in the other direction.
2023-03-05 22:37:05 -05:00
Leo Izen 34ed2ac225 video: add missing libplacebo colorspace enums
Add some missing libplacebo primaries and transfer enums to mpv's enum
constant tables, and update the functions that convert between the two.
2023-03-05 22:37:05 -05:00
Kacper Michajłow 22e3264652 mp_image: assert if src and dst are different in copy_attributes
It doesn't make sense to call this function on same image and the code
is not safe to do so.
2023-03-05 22:36:56 +02:00
Kacper Michajłow 2a7122ac41 mp_image: copy side data in mp_image_copy_attributes
This fixes HDR10 and HDR10+ metadata usage in vo_gpu_next when hwdec
copy variant is used.
2023-03-05 22:36:56 +02:00
Thomas Weißschuh c0ca5f1a37 ao_pipewire: use realtime scheduling for data thread
By making the data thread realtime it is able to serve requests faster
and more reliable reducing crackling in certain situations.

As the mpv callbacks that are running on the data thread are all
non-blocking and very short this should be safe.

The same mechanism is also used by pw-cat and the alsa plugin shipped by
pipewire.
2023-03-05 11:23:01 -08:00
rcombs 291e05ec1a loadfile: strongly prefer that all streams are from the same program
In raw OTA MPEGTS, different programs can be entirely different virtual channels.
In web streams, different programs can be different variant bitrates,
so using streams from different programs can waste large amounts of bandwidth.
2023-03-03 23:54:46 -06:00
rcombs b2a021d891 command: expose hls-bitrate and program-id as track-list subproperties 2023-03-03 23:54:46 -06:00
rcombs 46199c02a0 loadfile: report hls_bitrate and program_id in struct track 2023-03-03 23:54:46 -06:00
rcombs ad60753bce demux: propagate hls_bitrate and program_id in generated caption tracks 2023-03-03 23:54:46 -06:00
rcombs c39e332e50 demux_lavf: report program_id
This can be useful in stream selection.
2023-03-03 23:54:46 -06:00
Christoph Heinrich 362256edbc ytdl_hook: only log error when no fallback url available
An error indicates that something doesn't work, but as long as a
safe url is available, playback is still expected to work.

Thus reduce logging level of MP4 DASH without fragments message and
add a new error message for when there is no safe url available either.

Also adds a missing space.
2023-03-03 23:02:13 +00:00
Christoph Heinrich 94c189dae7 ytdl_hook: init fragment requires other fragments
With dash the first fragment was always considered an init fragment if
there wasn't a duration. However that only makes sense when there are
also other fragments, so check if there are other fragments in addition
to the lack of a duration.
2023-03-03 23:02:13 +00:00
Dudemanguy 296d40dc6f vo: fix race condition with redraw requests
There is a very subtle race in vo that can manifest itself on pause
events. In the renderloop, render_frame, unsurprisingly, does the heavy
lifting of actually queuing up and flipping the frames. This is called
during normal playback. Sometimes various parts of the player can make a
redraw request which will latter trigger another render of the frame
later down in the loop (do_redraw). Because these requests can happen at
essentially anytime, sometimes the redraw request will happen *before*
do_redraw and it'll be caught in render_frame. When this happens,
the existing render_frame run works perfectly fine as a redraw so it
clears out the request which is sensible. Normally this is all locked of
course, but there's one catch. render_frame has to unlock itself when
propagating down into specific VOs/backends. That's what causes this
bug.

While render_frame is unlocked, other parts of the player can send
redraw requests which will cause in->request_redraw to become true. The
logic in the code always clears out this parameter after a successful
render, but this isn't correct. When in->request_become becomes true in
the middle of render_frame, there needs to be one more draw afterwards
to reflect whatever actually changed (usually the OSD). Instead, this
gets simply discarded. If you rapidly spam pause while rendering things
to the OSD at the same time, it's possible to for the last render to
be behind a frame and appear as if your osd event was ignored.

Once you realize what is happening, the fix is quite simple. Just store
the initial value of in->request_redraw before the unlock step. After we
do the render step and unlock again, only set in->request_redraw to
false if there was an initial redraw request. We just finished doing a
redraw, so it is safe to clear. Otherwise, leave in->request_redraw
alone. If it is initially false, then it will still be false and nothing
changes. However if it updated to true in the middle of the rendering,
this value is now preserved so we can go and call do_redraw later and
show what that last frame was meant to be when you pause. One
unfortunate thing about this design is that it is technically possible
for other internal things in vo to update during that unlocked period.
Hopefully, that doesn't actually happen and only redraw requests work
like this.

Fixes #8172 and #8350.
2023-03-02 22:09:10 +00:00
Dudemanguy e82d9045a4 ci: separate meson tests and reorganize build steps
Instead of running the test directly in the build script, we can make a
separate step in the workflow so it looks a little prettier. For running
the actual tests, we skip mingw since they will never be run (cross
compiled). Additionally, improve the github workflow logic a bit so that
way logs on failure are only shown when that specific step fails. The
freebsd job still has to be less elegant since it's in a weird vm
thingy.

Not really related but the location of various build directories
(particularly waf) are corrected as well (might as well).
2023-03-02 15:45:27 +00:00
Dudemanguy 9db818279a test: integrate unittests with meson
This reworks all of mpv's unit tests so they are compiled as separate
executables (optional) and run via meson test. Because most of the tests
are dependant on mpv's internals, existing compiled objects are
leveraged to create static libs and used when necessary. As an aside, a
function was moved into video/out/gpu/utils for sanity's sake (otherwise
most of vo would have been needed). As a plus, meson multithreads
running tests automatically and also the output no longer pollutes the
source directory. There are tests that can break due to ffmpeg changes,
so they require a specific minimum libavutil version to be built.
2023-03-02 15:45:27 +00:00
Dudemanguy 6153242157 ci: use the same arguments when running the built mpv binary
A couple of places didn't have -v --no-config so just use them
everywhere.
2023-03-02 15:45:27 +00:00
Dudemanguy 3535e326dc player: remove unittest option
Since meson has its own unit testing system, let's rework mpv's tests so
they integrate nicely with this. To prepare for this, start off by
dropping the unittest option. Of course, this means that tests will no
longer be supported in the waf build at all but it will be dropped
anyway. Note that the tests option is preserved for the meson build. We
will still make use of this in the future commits.
2023-03-02 15:45:27 +00:00
Dudemanguy 3eae9d6c0f test: update ffmpeg format refs
A few formats were added recently, some were removed, and some flags
were changed. Maybe this should be better, but just update for now so
the tests stop failing.
2023-03-02 15:45:27 +00:00
Kacper Michajłow a0340ffe2d zimg: fix MP_CSP_PRIM_CIE_1931 mapping
MP_CSP_PRIM_CIE_1931 are RGB primaries, not ZIMG_PRIMARIES_ST428 which
is XYZ.
2023-03-02 09:37:06 -05:00
Kacper Michajłow 752e76ced7 zimg: add ZIMG_TRANSFER_ST428 mapping 2023-03-02 09:37:06 -05:00
Kacper Michajłow 7ceadbb3c1 zimg: set correct primaries for XYZ 2023-03-02 09:37:06 -05:00
Kacper Michajłow 2101e77d1e sws_utils: hardcode output gamma and primaries for XYZ 2023-03-02 09:37:06 -05:00
Kacper Michajłow f2fab0d8e1 mp_image: fix XYZ gamma and primaries guess 2023-03-02 09:37:06 -05:00
Kacper Michajłow 9dc4154fec vo_gpu: improve XYZ conversion
Fixes #4925
2023-03-02 09:37:06 -05:00
Kacper Michajłow 40af0893a9 mp_image: be less agressive with clearing color information 2023-03-02 09:37:06 -05:00
Kacper Michajłow 507d817f19 f_swscale: do not reset color levels to default
There is no good reason to do so, both zimg and swscale supports full
range output. If downstream something expects limited range yuv always,
it needs to be comunicated in different way.
2023-03-02 09:37:06 -05:00
Kacper Michajłow cb9ba6cb26 csputils: add MP_CSP_TRC_ST428 as defined in ST 428-1 2023-03-02 09:37:06 -05:00
Dudemanguy c31e145e1f DOCS/options: mention default value of cursor-autohide
Closes #11358.
2023-03-01 23:17:33 -06:00
Dudemanguy 7bd528dbeb DOCS/options: clarify hidpi-window-scale description
It's enabled by default everywhere. The sentences about macOS is
misleading and may imply it's disabled by default on the other
platforms.
2023-03-01 23:13:57 -06:00
Dudemanguy c993d5c0ce player: add --auto-window-resize option
mpv's window resizing logic always automatically resized the window
whenever the video resolution changed (i.e. advancing forward in a
playlist). This simply introduces the option to make this behavior
configurable. Every windowing backend would need to implement this
behavior in their code since a reconfigure event must always be a
resize. The params of the frame changed so you either have to resize the
window to the new size of the params or make the params the same size as
the window. This commit implements it for wayland, win32, and x11.
2023-03-02 02:55:36 +00:00
Dudemanguy cd02b5ccf6 ra: assert when using params with dimensions
This came up in #9828. According to the header comments, creating a 1D
ra_tex requires height and depth to be set to 1. For a 2D texture, it
requires depth be set to 1. There were a couple of spots in mpv's code
where this wasn't being followed. Although there was no known bug from
this, the rest of the code works like this so it was a good idea to go
ahead and sync it up. As a followup, let's just add some simple asserts
to ra.c to enforce this so it doesn't go unnoticed in the future.
2023-03-02 02:08:39 +00:00
Frédéric Brière 779d4f99a7 sub: add --sub-fonts-dir and --osd-fonts-dir options
These options make it possible to specify the directory that will be
passed to ass_set_fonts_dir(), akin to VLC's `--ssa-fontsdir` and
FFmpeg's `fontsdir`.

Fixes #8338
2023-03-01 02:09:46 +00:00
Daniel van Vugt 022790a2b4 wayland: request frame callbacks on the topmost surface
Which is wl->video_surface for vo_dmabuf_wayland.

Listening on wl->surface results in freezes if it is occluded and
culled by the compositor. Which mutter does, and the wl_surface::frame
spec warns about:

> A server should avoid signaling the frame callbacks if the
> surface is not visible in any way, e.g. the surface is off-screen,
> or completely obscured by other opaque surfaces.
2023-02-28 15:07:14 +00:00
Daniel van Vugt 1f493b7671 wayland: deduplicate and cache detection of dmabuf-wayland 2023-02-28 15:07:14 +00:00
Ray Smith 8a43fc0e9a wayland: use bool type for alpha framebuffer tracking
ra_ctx_opts.want_alpha and vo_wayland_set_opaque_region's alpha
argument are only used as bool but both are ints. Particularly for the
function argument, passing a 0 or 1 is confusing - at first glance it
looks like you're specifying an alpha value of 0 or 1.

Since they're only used as bools, make them bools.
2023-02-28 14:53:32 +00:00
msoxzw 8006ff6cf6 vo_gpu: d3d11_helpers: prefer DXGI_SWAP_EFFECT_FLIP_DISCARD if possible
Similar to libplacebo[1], DXGI_SWAP_EFFECT_FLIP_DISCARD is used instead
of DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL starting with Windows 10.

[1]: https://github.com/haasn/libplacebo/blob/master/src/d3d11/swapchain.c
2023-02-28 14:41:33 +00:00
averne 3e351a41e2 vf_gpu: initialize depth=1 on target textures
According to internal documentation, 2D textures should have d=1.
This fixes the correctness of the API usage, not any bug.
2023-02-28 14:13:55 +00:00
averne 4fbc3ad399 video: initialize depth=1 on screenshot textures
According to internal documentation, 2D textures should have d=1.
This fixes the correctness of the API usage, not any bug.
2023-02-28 14:13:55 +00:00
Martin Eesmaa 0426f4b107 external_files: recognize jxl and avif files as cover art 2023-02-27 17:50:46 +00:00
Dudemanguy c5d1230517 {console,ytdl_hook}: use the platform property
The console.lua check is still kind of dumb since we check an
environment variable to distinguish between wayland and x11, but
otherwise it should be better in theory.
2023-02-27 17:13:21 +00:00
Dudemanguy 80feac62f1 command: add platform property
This returns the value of the target OS that mpv was built on as
reported by the build system. It is quite conceivable that script
writers and API users would need to make OS-dependent choices in some
cases. Such people end up writing boilerplate/hacks to guess what OS
they are on. Assuming you trust the build system (if you don't, we're in
really deep trouble), then mpv actually knows exactly what OS it was
built on. Simply take this information at configuration time, make it a
define, and let mp_property_platform return the value.

Note that mpv has two build systems (waf and meson), so the names of the
detected OSes may not be exactly the same. Since meson is the newer
build system, the value of this property follows meson's naming
conventions*. In the waf build, there is a small function to map known
naming deviations to match meson (i.e. changing "win32" to "windows").
waf's documentation is a nightmare to follow, but it seems to simply
take the output of sys.platform in python and strip away any trailing
numbers if they exist (exception being win32 and os2)*.

*: https://mesonbuild.com/Reference-tables.html#operating-system-names
*: https://waf.io/apidocs/Utils.html#waflib.Utils.unversioned_sys_platform
2023-02-27 17:13:21 +00:00
Christoph Heinrich 8ea7aa5471 ytdl_hook: don't overwrite force-media-title
ytdl_hook always set force-media-title, making users unable to force
a media-title via options.

To prevent that, check if force-media-title is already set to avoid
overwriting it.

A better solution would be to use tags like is already done for some
metadata, however that doesn't work when `all_formats=yes` is used.
See cbb8f534b0
A comment was added to hint at why it isn't done via tags.

ref.
https://github.com/mpv-player/mpv/pull/10453#issuecomment-1445277496
2023-02-27 17:07:38 +00:00
Guido Cella 42fd6f5f6f ytdl_hook.lua: make exec return a single value
This refactors exec to only return the result of the subprocess command,
and makes the rest of run_ytdl_hook use the fields of this result,
because specifying all those return values multiple times is unwieldy
now that exec is called several times, and this is easier to read
anyway.

I removed the line
err = string.format("%s returned '%d'", err, es)
altogether instead of updating the es variable, because there was no
chance of it being executed since it would only happen when
result.killed_by_us is true, but run_ytdl_hook returns early when it is.
2023-02-27 17:04:42 +00:00
Guido Cella 0772d0263c TOOLS/autocrop.lua: log a more accurate warning
This reorders some code and checks the image track-list sub-property
instead of the albumart one, so that when playing audio without enough
playtime-remaining and images, the "autocrop only works for videos."
warning is logged instead of the "Not enough time to detect crop." one.
It also avoids repeating this warning twice in the code.

As of e16d0dd15d current-tracks returns a video track even when
lavfi-complex is used, so the track-list loop in is_cropable can be
replaced with just checking current-tracks/video while still cropping
videos with lavfi-complex.
2023-02-27 17:03:38 +00:00
der richter ae6a22ddec audio: remove a duplicate clearing of a struct variable
Fixes #8301
2023-02-27 17:02:19 +00:00
Christoph Heinrich a194ddaa43 options: change parameter that was forgottin in property transition
17d91b9d4d changed the name,
but not the parameter type and cast
2023-02-27 11:21:49 +01:00
Christoph Heinrich c5265381b5 client API: reintroduce CONF_TYPE_FLAG for type conversion
Changing the CONF_TYPE_FLAG was a bad idea because mpv_node.u.flag
continues to be an int, leading to a mismatch in type sizes which can
lead to problems with memcpy().

ref. #11373

This partially reverts commit 17d91b9d4d.
2023-02-27 11:21:49 +01:00
Christoph Heinrich a265da9f25 Partially revert "options: remove OPT_FLAG"
The m_option_type_flag is still needed for the CONF_TYPE_FLAG
(next commit).

Add a comment that m_option_type_flag shouldn't be used.

ref. #11373

This partially reverts commit 07545657bf.
2023-02-27 11:21:49 +01:00
rcombs d941564d48 console: observe osc margins from user-data instead of shared-script-properties 2023-02-26 17:54:09 -06:00
rcombs 894f0c28eb osc: set values in user-data in addition to shared-script-properties 2023-02-26 17:54:09 -06:00
Christoph Heinrich 048d4d8b75 player: set playlist title to media title if not set already
The playlist title only got set when it was specified in the
playlist file.
If there is a title after opening a file, that should also be reflected
in the playlist.

ref. #4780
2023-02-26 22:39:54 +00:00
Thomas Weißschuh ed5426c351 various: fix warning -Wimplicit-const-int-float-conversion 2023-02-26 16:45:07 +01:00
Thomas Weißschuh 8d67e891ab vo_gpu_next: fix warning -Wunused-function 2023-02-26 16:45:07 +01:00
Thomas Weißschuh b4ae1551e4 vo_wayland: fix warning -Wvoid-pointer-to-enum-cast 2023-02-26 16:45:07 +01:00
sfan5 5a83745316 vd_lavc: sort hwdecs without hwdevices last for autoprobing
For hwdecs without devices we can't get instant feedback during probing
whether the hwdec can possibly work or not, so we definitely want to try them last.
Independently this would also have solved the issue addressed by the previous commit.
2023-02-26 16:40:59 +01:00
sfan5 1dda09b817 vd_lavc: prioritize mediacodec for hwdec autoprobe
This fixes an issue where mpv would try mediacodec (which may not
be available depending on Android version) and pick v4l2m2m next
which ends up failing even though mediacodec-copy would have been available.
2023-02-26 16:40:59 +01:00
Thomas Weißschuh 16f0cd546d video: make csp option definitions private 2023-02-24 13:55:29 +01:00
Thomas Weißschuh fb48722234 video: make csp equalizer params float
This allows more precise adjustments.

Fixes #11316
2023-02-24 13:55:29 +01:00
sfan5 0d991eba72 vo_gpu: fix newline in log message 2023-02-24 13:33:45 +01:00
sfan5 3e85df3b2d demux: constify a struct member
Fixes a segfault when an invalid demuxer is given due to
uninitialized use of `filename` after goto.
2023-02-24 13:22:03 +01:00
Kacper Michajłow 84f6d7a97e vo_gpu_next: fix color space hint with target peak override
Fixes: #11339
2023-02-23 10:14:53 +01:00
sfan5 985a253f84 DOCS: clarify that GLX is deprecated 2023-02-22 23:25:47 +01:00
Christoph Heinrich c0807e98fb options: remove explicit initialization of integers to 0 2023-02-21 17:15:17 +00:00
Christoph Heinrich 07545657bf options: remove OPT_FLAG 2023-02-21 17:15:17 +00:00
Christoph Heinrich 17d91b9d4d options: transition properties from flag to bool 2023-02-21 17:15:17 +00:00
Christoph Heinrich 4ebfe9851c options: transition commands from OPT_FLAG to OPT_BOOL 2023-02-21 17:15:17 +00:00
Christoph Heinrich 91cc0d8cf6 options: transition options from OPT_FLAG to OPT_BOOL
c784820454 introduced a bool option type
as a replacement for the flag type, but didn't actually transition and
remove the flag type because it would have been too much mundane work.
2023-02-21 17:15:17 +00:00
Christoph Heinrich b9850a6e8c input: remove unused struct member 2023-02-21 17:15:17 +00:00
llyyr d0eae60d67 DOCS/client-api-changes.rst: move mpv_del_property to 0.36.0
incorrectly placed under 0.35.0 by 2cfaa820e5
2023-02-21 17:07:57 +00:00
Thomas Weißschuh 9efce6d4ae various: drop unused #include "config.h"
Most sources don't need config.h.
The inclusion only leads to lots of unneeded recompilation if the
configuration is changed.
2023-02-20 14:21:18 +00:00
Thomas Weißschuh a90355660c ao_pipewire: drop unused #include "generated/version.h" 2023-02-20 14:21:18 +00:00
rcombs d1cf89b655 Vulkan: add configure check for VK_KHR_display extension
This allows building directly against ICDs that don't implement this extension.
2023-02-20 00:05:26 -06:00
Niklas Haas 9a752e8b26 vo_gpu_next: add --tone-mapping-visualize 2023-02-19 21:01:40 +01:00
quietvoid 41ad51bda2 vo_gpu_next: parse Dolby Vision metadata for dynamic scene brightness
Improves playback for Dolby Vision video files as the metadata can be
used instead of requiring `hdr-compute-peak=yes`.
2023-02-19 20:50:37 +01:00
quietvoid 0d82afbc7f mp_image: forward AV_FRAME_DATA_DOVI_RPU_BUFFER side data
When available, and ignored if `vf=format:dolbyvision=no`.
2023-02-19 20:50:37 +01:00
Leo Izen 2955a0759c DOCS: document JPEG XL default effort change
Document the change in 7607432127.
2023-02-18 06:16:21 -05:00
Dudemanguy e2cdc23af0 Revert "vo_dmabuf_wayland: drop support for linux-dmabuf-v2"
This was originally dropped because it was thought to be unneeded at the
time, but at least some devices (rockchip) apparently are still on old
compositors that use linux-dmabuf v2. It's not much code, and for
testing purposes it's good to have around since it's hard to test
drmprime otherwise. Some minor additions are here to support the newly
added vaapi-format mapping in v2 of the protocol.

This reverts commit a5b9d529ee.
2023-02-18 02:21:54 +00:00
Leo Izen 7607432127 video/image_writer: use effort=4 default for JXL screenshots
effort=4 has a significant increase in quality/bpp compared to effort=3
with a very minor increase in encoding time. It's worth the trade-off
as a default setting for lossy encoding.
2023-02-17 17:40:11 -05:00
Thomas Weißschuh c3f326bc13 ao_pipewire: fix removal of zeroed hooks on old pipewire
Older versions of pipewire segfault when calling spa_hook_remove() on
hooks that are zeroed.
Add a backfill for the logic added by pipewire 0.3.57.

Being able to remove zeroed hooks makes errorhandling much easier.

See #11309
2023-02-15 16:37:20 -08:00
Niklas Haas 16ef237da5 vo_gpu_next: allow native CSP screenshots
Useful for getting native screenshots of non-sRGB content, such as HDR
etc.
2023-02-13 21:53:41 +01:00
Niklas Haas c975888584 player/screenshot: pass on ability to output native CSP
Fixes: #10988
2023-02-13 21:53:41 +01:00
Niklas Haas ff26024496 screenshot: explicitly default VOCTRL_SCREENSHOT csp
This allows the logic in `convert_image` to fast-path if the image
params are equal. Without this check, the image params are basically
never equal, because that path goes through `mp_image_params_guess_csp`
while the `mp_image` itself does not.

Force it here for consistency across VOs.
2023-02-13 21:53:41 +01:00
Niklas Haas 6d9e72cd89 video/image_writer: force sRGB for unsupported formats
After commit c98e7353, we blindly pass the screenshot colorspace to the
image writer. But since we want to introduces the ability to save images
in HDR and other exotic formats, we should strip this for unsupported
formats.

See-Also: #10988
2023-02-13 21:53:41 +01:00
Niklas Haas 01351a6412 video/image_writer: add image_writer_flexible_csp
PNG only supports this since the introduction of cICP, so put a version
check on the next API version bump after the cICP writing patch got
merged.
2023-02-13 21:53:41 +01:00
Niklas Haas 862be6c237 vo_gpu_next: tag screenshots with correct colorspace
When taking window screenshots with a colorspace override, tag them
appropriately, based on the best-known colorspace info. Note that this
is imperfect, we should ideally also attach the output ICC profile if
one exists. But this is better than nothing.

Also force 1:1 PAR in this case. In all other cases, default to sRGB.
2023-02-13 21:53:41 +01:00
Niklas Haas 5078132b28 vo_gpu_next: only apply target options in window screenshot mode
When taking an unscaled screenshot, always render to an unspecified
SDR-like space. (Subject to change) Apply output-specific options (ICC
profile, color space overrides, custom LUT) only in window screenshot
mode.

I decided to split this off from subsequent refactors because it is IMO
a bug fix deserving of its own commit.
2023-02-13 21:53:41 +01:00
Niklas Haas 4f84d91df2 vo_gpu_next: be explicit about screenshot repr
Screenshots are currently always RGB. Subject to change, but needs to be
communicated clearly if changed. This commit is not a functional change,
it's merely for code clarity.
2023-02-13 21:53:41 +01:00
rcombs 2e0bdbfe9c m_property: avoid using a small stack buffer in m_property_do_bstr
This allows operations on properties with longer names (e.g. deeply-nested user-data sub-props).
2023-02-13 14:39:41 -06:00
Niklas Haas 2d4a243810 vo_gpu_next: expose --tone-mapping=st2094-40 and st2094-10 2023-02-13 17:52:35 +01:00
Niklas Haas 79b093f210 vo_gpu_next: support mapping HDR10+ dynamic metadata
Based on the new upstream helper function `pl_map_hdr_metadata` and the
existing AV_FRAME_DATA_DYNAMIC_HDR_PLUS. This allows us to use SMPTE
2094-40 dynamic HDR tonemapping in mpv, albeit with the limitation of
requiring `--tone-mapping=auto` in order to pick this curve upstream.
2023-02-13 17:52:35 +01:00
Thomas Weißschuh a40958cdf8 ao_pipewire: allow usage of global volume control
PipeWire supports a global volume control for streams that works on top
of the per-channel volumes.
As mpv only supports a single volume with ao-volume it can make sense to
use the single global volume from PipeWire for it.
This allows the user to also specify per-channel volumes and not have
mpv trample over them.

This mode is not the default as pulseaudio does not support this
global volume control and all tooling controlling PipeWire via
pipewire-pulse (like pavucontrol) will not be able to see this channel.
2023-02-11 10:00:46 -08:00
Christoph Heinrich 8f76673608 command: only avoid redrawing when old and new osd are both hidden
The `osd-overlay` command didn't trigger a redraw when the overlay was
set to hidden.
This is fine when the overlay was already hidden before that, but
transitioning from not hidden to hidden requires a redraw.
2023-02-11 14:51:14 +01:00
Dudemanguy 180b4faed0 DOCS/options: remove testing note in video-sync-max-factor
This option is a bit obscure, but some people do use it and it can be
useful. The actual code that implements this is very simple, so there's
really no need to have a scary note in the docs about it possibly
changing or being removed.
2023-02-11 00:50:11 +00:00
Dudemanguy 1126df0d80 vf_sub: undeprecate
3a9e661e92 officially made this video
filter deprecated roughly 6 years ago. Every other video filter in that
commit has actually been removed since then except for vf_sub. ffmpeg
does have its own subtitles filter, but it doesn't have the same control
over scale like vf_sub does. That's probably why wm4 never actually
removed it. Let's stop scaring users with a warning since this filter
probably won't ever get removed. Closes #9254.
2023-02-11 00:50:11 +00:00
Aaron Boxer 49fd6caa43 vo_dmabuf_wayland: reject hw formats not supported by compositor 2023-02-11 00:46:46 +00:00
Leo Izen 8ba7b8f0d2 video/image_writer: change screenshot-tag-colorspace default to yes
With significant improvements to the color tagging support in various
screenshot formats, e.g. cICP in FFmpeg, and JPEG XL's generally robust
color support, it's safe to default this to yes.
2023-02-09 21:03:28 +01:00
Aaron Boxer a3340645be vo_dmabuf_wayland: add purgatory list to buffer pool to avoid memory leaks 2023-02-05 23:27:08 +00:00
Aaron Boxer 6803903e0c vo_dmabuf_wayland: ensure buffer pool is cleaned at start of uninit 2023-02-05 23:27:08 +00:00
Aaron Boxer ce6efc782f vo_dmabuf_wayland: simplify buffer pool reset 2023-02-05 23:27:08 +00:00
Aaron Boxer f1f6eaa3de vo_dmabuf_wayland: only resize when a new frame is about to be drawn 2023-02-05 23:27:08 +00:00
Max Dunbar 5bd991f338 DOCS/input: remove experimental note from sub-text 2023-02-05 16:23:29 +00:00
Thomas Weißschuh e439ddc051 ao_pipewire: report linking errors from init() 2023-02-03 12:33:09 -08:00
Thomas Weißschuh 83681de3c1 ao_pipewire: add support for exclusive mode 2023-02-03 12:33:09 -08:00
Thomas Weißschuh c29692d81d ao_pipewire: move stream flags to dedicated variable 2023-02-03 12:33:09 -08:00
Thomas Weißschuh 888a7c963f ao_pipewire: adjust message level based on probing
Use the ao->probing property to upgrade the status message when the AO
is explicitly selected.

Suggested-by: uau on #mpv-devel
2023-02-03 12:32:45 -08:00
Thomas Weißschuh 771c8a165a f_hwtransfer: fix leak of framesconstraints 2023-02-03 09:23:09 -08:00
Thomas Weißschuh c7c92240a9 image_pool: properly free frames
av_frame_unref() only frees the buffers, not the frame data itself.
2023-02-03 09:23:09 -08:00
Thomas Weißschuh b0fb6999a4 ao_pipewire: remove unneeded goto 2023-02-03 09:18:37 -08:00
Thomas Weißschuh c8d9155c56 ao_pipewire: replace opencoded talloc() 2023-02-03 09:18:37 -08:00
Thomas Weißschuh 79795b8378 ao_pipewire: print stream states as string 2023-02-03 09:18:37 -08:00
Thomas Weißschuh 24504418fc ao_pipewire: remove unnecessary empty lines 2023-02-03 09:18:37 -08:00
Thomas Weißschuh 69fb378575 ao_pipewire: remove opencoded spa_zero() 2023-02-03 09:18:37 -08:00
Thomas Weißschuh af3c7f3d31 ao_pipewire: remove some unnecessary linebreaks 2023-02-03 09:18:37 -08:00
Thomas Weißschuh c2c36c0d57 ao_pipewire: reduce message level of unsuccessful connection
As ao_pipewire is probed first if a user does not have PipeWire running
they will see a scary warning message even if another AO afterwards is
probed fine.
Tone down the error message so as not to confuse users.
2023-02-03 09:18:37 -08:00
Thomas Weißschuh 469f7af210 ao_pipewire: remove unnecessary braces 2023-02-03 09:18:37 -08:00
Kacper Michajłow bc7a126237 sws_utils: add check for HAVE_ZIMG to suppress warnings 2023-02-02 14:23:02 +00:00
Kacper Michajłow 87fb254deb vo_gpu_next: add check for PL_HAVE_LCMS 2023-02-02 14:23:02 +00:00
Kacper Michajłow a97dd423c8 hwdec_cuda: fix enum type for semaphore 2023-02-02 14:23:02 +00:00
Kacper Michajłow 68c1338d56 vo_d3d11: do not call MAKEINTRESOURCEW twice 2023-02-02 14:23:02 +00:00
Kacper Michajłow 3a28dbb711 osdep/io: add void to mp_penviron 2023-02-02 14:23:02 +00:00
Kacper Michajłow ebf34ffad3 demux: remove unused code 2023-02-02 14:23:02 +00:00
Kacper Michajłow 2048125f0c ao_lavc: remove unused code 2023-02-02 14:23:02 +00:00
Kacper Michajłow 0a4b139ddf osdep: add MP_FALLTHROUGH 2023-02-02 14:23:02 +00:00
Kacper Michajłow 08cd7c1e29 libplacebo: fix enum type cast 2023-02-02 14:23:02 +00:00
dyphire 070287aebb stats.lua: display HDR peak in nits
The value of `sig-peak` is relative to the SDR peak. This is not
a problem when used inside the player, but the `HDR peak` in stats
should display human-readable information.
So change to return the actual nits value of HDR.
Closed https://github.com/mpv-player/mpv/issues/10127
2023-02-02 14:22:40 +00:00
Dudemanguy cc87a25f7d meson: move vector check inside of meson.build
It's three lines. There's no real reason to have this as a separate file
when we've removed every other compile check sourced from outside files.
2023-02-02 14:22:09 +00:00
Dudemanguy a9c5414b86 meson: check macos touchbar with has_header 2023-02-02 14:22:09 +00:00
Dudemanguy bf32281425 meson: check pthread provider with has_function
Previously, we did this doing code fragments, but we can be a bit more
clever and use has_function as well as the platform we're on.
2023-02-02 14:22:09 +00:00
Leo Izen 7990dd8f3f video/image_writer: avoid stripping colorspace info when writing image
Writing an image either with vo_image or with a screenshot will strip
the colorspace info because it allocates a new mp_image that contains
the same data as the old image after calling mp_image_params_guess_csp.
However, mp_image_params_guess_csp cannot always guess the appropriate
colorspace, so it picks a "sane default." Since this function also
changes parameters so the space always makes sense, this extra info
isn't harmful and allows screenshots and vo_image outs to be properly
tagged with the correct colorspace.

Fixes #10988.
2023-01-31 12:39:04 -05:00
Alby 88918411f3 stream: accept webdav:// and webdavs:// urls
Treat them as http:// and https:// respectively. This allows to play files
on webdav archives directly on KDE, avoiding the (extremely slow) local
copying performed by kio.
2023-01-31 12:03:41 -05:00
Kacper Michajłow e4e3a8fc0b ci: pack mingw64 meson build instead of waf 2023-01-31 14:50:26 +00:00
Kacper Michajłow 7151b5122a ci: separate meson/waf build dirs 2023-01-31 14:50:26 +00:00
Kacper Michajłow 08d11e8c5d ci: use meson compile instead of ninja directly 2023-01-31 14:50:26 +00:00
Kacper Michajłow 2868ecf2ac ci: do not print compile commands
It only shadows warnings/errors and makes log files bloated.
2023-01-31 14:50:26 +00:00
Dudemanguy 78d9b40ddc meson: replace check_header with has_header
It turns out that there's a has_header check, and we should actually be
using that instead. We only care here if the header actually exists so
the pre-processor check is all that is needed. check_header depends on
what arguments the user passes among other things. That makes it more
complicated than necessary for our purposes.
2023-01-31 14:50:02 +00:00
Dudemanguy 25f5333b4a meson: actually use -Werror=format-security
We tested for this flag, but never added -Wformat in addition to
-Werror=format-security. The latter was silently ignored and actually
did nothing.
2023-01-31 14:50:02 +00:00
Dudemanguy 9659555d45 hwdec/vaapi: zero-initialize VADRMPRIMESurfaceDescriptor
Otherwise, desc can contain garbage values and segfault trying to close
file descriptors that aren't actually there. Fixes #11239.
2023-01-30 10:41:32 -06:00
StratusFearMe21 3038e578af player/video.c: don't resync audio if video is an image 2023-01-30 14:52:00 +00:00
rcombs 4bcefa5be3 vo_lavc: set frame rate on encoder; fixes #11215
ffmpeg was internally defaulting to 24000fps, which resulted in encoders selecting inappropriate levels and making poor ratecontrol decisions.
2023-01-29 22:14:27 -06:00
Dudemanguy da81a6d532 wayland: add auto choice to wayland-configure-bounds
Previously, this defaulted to yes and configure-bounds from the
compositor would always apply. In the case where the user explicitly set
autofit or geometry, this could be confusing because configure-bounds
would take precedence over it. Instead, let's add an auto choice and
make that the default. If we detect that the option is on auto and that
there is autofit/geometry being set, then ignore the event. This should
be more intuitive since someone who bothers to explicitly set mpv's
geometry would naturally expect that geometry to actually apply.
2023-01-30 03:59:40 +00:00
Dudemanguy adc04dbba0 wayland: handle runtime hidpi-window-scale changes correctly
Semi-regression although this option never really did what the manual
said until recently. In the past, this option also controlled whether or
not mpv set the wayland buffer_scale to the value of the wl_output or
force it 1. This had varying effects depending on the exact compositor
configuration. That logic has now all been removed and this option now
only controls whether or not to scale the window with the hidpi scale
factor we get from the compositor. i.e. it actually does what the
manual says now.
2023-01-30 03:59:40 +00:00
Dudemanguy e6a42f7afc wayland: unbreak runtime geometry/autofit changes
Regressed from 879824a47f. The geometry
needs to be explictly recalculated now. Change up this function a little
bit also give it the ability to directly perform a resize after the
fact. This is a common workflow and we'll be using it in the next
commit.
2023-01-30 03:59:40 +00:00
Avi Halachmi (:avih) 86093fcae7 lua/js: remove user-data helpers
This reverts:
  3fb4140c lua/defaults: add user_data helpers
  68a20e7a javascript/defaults: add user_data helpers
  00510379 lua/js: fix user_data_del util function

As well as the lua/js parts of:
  3ec2a098 docs: document new user-data property

user-data and its sub-properties can be set/get/observed/deleted
via the standard properties interface, so there's no need for
additional helpers specific to user-data, which only added maintenance
burden.
2023-01-29 01:52:31 +02:00
rcombs 0051037957 lua/js: fix user_data_del util function 2023-01-28 15:21:15 -06:00
rcombs 0f3a041796 doc: correct spelling of user-data/user_data JS/lua helpers 2023-01-28 14:55:24 -06:00
rcombs 3ec2a0988a docs: document new user-data property 2023-01-28 14:37:24 -06:00
rcombs 68a20e7ae4 javascript/defaults: add user_data helpers 2023-01-28 14:37:24 -06:00
rcombs 3fb4140c38 lua/defaults: add user_data helpers 2023-01-28 14:37:21 -06:00
rcombs 0b4860248b player/command: add user-data property
This will replace shared-script-properties in new usage. It can be used for all the same things, but is much more versatile.
Clients can create arbitrary sub-objects, and text expansion can access them.
For instance, if a script sets `user-data/my-script/property1` to "test", that value will be available by expanding ${user-data/my-script/property1}.
2023-01-28 14:37:02 -06:00
rcombs 94e1659b6c javascript: add mp.del_property() 2023-01-28 14:20:20 -06:00
rcombs 51c6784df7 lua: add mp.del_property() 2023-01-28 14:20:20 -06:00
rcombs 2cfaa820e5 libmpv: add mpv_del_property() convenience function 2023-01-28 14:20:20 -06:00
rcombs 04241ab731 player/command: add "del" command 2023-01-28 14:20:20 -06:00
rcombs e1815789f7 m_property: add M_PROPERTY_DELETE 2023-01-28 14:20:20 -06:00
rcombs dc4fd24c6f player/client: support observing sub-properties
This notifies if either a descendent or ancestor of the requested path is modified.
2023-01-28 14:20:20 -06:00
rcombs 0b3c37bc43 options/m_option: support duplicating MPV_FORMAT_BYTE_ARRAY nodes 2023-01-28 14:20:20 -06:00
rcombs 3b2b47e32a misc/node: add bstr-based variants for map_get() and map_add() 2023-01-28 14:20:20 -06:00
rcombs fa7202d9f2 misc/json: don't wrap top-level pretty strings/infs in quotes
This makes pretty-printing nodes substantially more friendly.
2023-01-28 14:20:20 -06:00
Oxan van Leeuwen 91ba71b09f DOCS: Add missing 'not' 2023-01-28 11:59:59 -05:00
Aaron Boxer 588d66fb25 hwdec_vaapi: close file descriptors even if surface export fails
otherwise they can leak
2023-01-28 16:54:48 +01:00
Aaron Boxer 881f820fdf vo_dmabuf_wayland: close file handles when surface export fails
file handles may still be opened despite failure
2023-01-28 16:54:48 +01:00
Aaron Boxer e3618002e3 vo_dmabuf_wayland: plug leaking file descriptor from solid buffer pool 2023-01-28 16:54:48 +01:00
Kacper Michajłow 9d659ed847 DOCS/compile-windows.md: update MSYS2 packages 2023-01-28 01:03:12 +00:00
Kacper Michajłow b5f62050ec test/repack.c: skip tests that exceeded maximum allowed ZIMG dimension
Fixes tests on 32-bit platforms
2023-01-28 01:03:12 +00:00
Kacper Michajłow 5fd6789d90 meson: add missing library dep for egl_angle_lib check 2023-01-28 01:03:12 +00:00
Kacper Michajłow af537eff06 vo_opengl/angle_dynamic: simplify symbol renaming to make it more straightforward 2023-01-28 01:03:12 +00:00
Kacper Michajłow 75e41478cc waf: migrate to version.py
Fixes https://github.com/mpv-player/mpv-build/issues/204
2023-01-28 01:03:12 +00:00
Kacper Michajłow bc1af592db ci: migrate MSYS2 build to GitHub Actions 2023-01-28 01:03:12 +00:00
Kacper Michajłow c3149d9fc2 wscript: remove MSVC from compiler lookup
MSVC is not supported and waf doesn't respect CC environment value like
any sane buildsystem.
2023-01-28 01:03:12 +00:00
Thomas Weißschuh c25682f09e meson: reuse libmpv objects for cplayer
When building both cplayer and libmpv in the same build previously all
sources were built twice.
By reusing the objects from libmpv in cplayer we can thus save 50%
percent of the build steps.
2023-01-26 21:39:04 -08:00
Thomas Weißschuh fb137e8d88 ao_pipewire: align thread name with general conventions 2023-01-25 15:56:36 -08:00
Thomas Weißschuh 870512eb84 audio: simplify implementation of property ao-volume
ao-volume is represented in the code with a `struct ao_control_vol_t`
which contains volumes for two channels, left and right.

However the code implementing this property in command.c never treats
these values individually. They are always averaged together.
On the other hand the code in the AOs handling these values also has to
handle the case where *not* exactly two channels are handled.

So let's remove the `struct ao_control_vol_t` and replace it with a
simple float.
This makes the semantics clear to AO authors and allows us to drop some code from the AOs and command.c.
2023-01-25 15:49:21 -08:00
Dudemanguy 5510d9f663 stream/dvb: remove some unused variables
Missed in b6b8380518.
2023-01-24 21:21:02 -06:00
Sultan Alsawaf 0d44ae319d x11: remove PresentNotifyMSC from egl/glx/vulkan to fix xpresent timing
PresentNotifyMSC turns out to be not only redundant, but also harmful with
mesa-backed egl/glx/vulkan VOs because for all of them, mesa uses
PresentPixmap behind the scenes when DRI3 is available, which already
spawns a PresentCompleteNotify event when the buffer swap actually
finishes. This is important because without using the timing information
from these PresentCompleteKindPixmap events, there's no way for mpv to know
exactly when a frame becomes visible on the display.

By using PresentNotifyMSC in conjunction with DRI3-enabled mesa, two
problems are created:
1. mpv assumes that a vblank won't elapse (i.e., it assumes the current MSC
   won't change) between the time when mesa enqueues the buffer swap and
   the time when mpv calls PresentNotifyMSC to ask xorg for a notification
   at the next MSC, relative to the current MSC at the time that xorg reads
   it for the PresentNotifyMSC call. This means that mpv could get a
   notification one or more vblanks later than it expects, since the
   intention here is for mpv to get a notification at the MSC that the
   buffer swap completes.
2. mpv assumes that a buffer swap always takes one vblank to complete,
   which isn't always true. A buffer swap (i.e., a page flip) could take
   longer than that depending on hardware conditions (if the GPU is running
   slowly or needs to exit a low-power state), scheduling delays (under
   heavy system or GPU load), or unfortunate timing (if the raster scan
   line happens to be at one of the last few rows of pixels and a vblank
   elapses just before the buffer swap is enqueued).

This causes mpv to have a faulty assumption of when frames become visible.

Since mpv already receives the PresentCompleteNotify events generated by
mesa's buffer swaps under the hood, the PresentNotifyMSC usage is unneeded
and just throws a wrench in mpv's vsync timing when xpresent is enabled.

Simply removing the PresentNotifyMSC usage from the egl, glx, and vulkan
VOs fixes the xpresent vsync timing.
2023-01-25 03:13:23 +00:00
Dudemanguy 879824a47f wayland: add wp-fractional-scale-v1 support
This protocol is pretty important since it finally lets us solve the
longstanding issue of fractional scaling in wayland (no more mpv doing
rendering over the target resolution and then being scaled down). This
protocol also can completely replace the buffer_scale usage that we are
currently using for integer scaling so hopefully this can be removed
sometime in the future. Note that vo_dmabuf_wayland is omitted from the
fractional scale handling because we want the compositor to handle all
the scaling for that VO.

Fixes #9443.
2023-01-24 00:04:39 +00:00
Dudemanguy 006ec9ce43 wayland: rewrite geometry and scaling handling
This is in preparation for fractional scaling support. Basically, redo
all the coordinates in wayland so that wl->geometry is equal exactly to
what is being put out to the screen (no extra wl->scaling multiplication
required). The wl->vdparams variable is also eliminated for simplicity.
This changes mpv's behavior on wayland with hidpi scaling but that will
be addressed in more detail with the next commit.
2023-01-24 00:04:39 +00:00
9b59d39a3a vo_gpu: implement VO_DR_FLAG_HOST_CACHED
For OpenGL, this is based on simply comparing GL_VENDOR strings against
a list of allowed vendors.

Co-authored-by: Nicolas F. <ovdev@fratti.ch>
Co-authored-by: Niklas Haas <git@haasn.dev>
2023-01-23 14:13:34 +01:00
Niklas Haas 2531a89fcb vo_gpu_next: implement VO_DR_FLAG_HOST_CACHED
For sufficiently new versions of libplacebo.
2023-01-23 14:13:34 +01:00
c7ea0cd68f vd_lavc: add "auto" choice for vd-lavc-dr
--vd-lavc-dr defaulted to "yes", which caused issues on certain
hardware. Instead of disabling it, add a new "auto" value and
make it the default.

The "auto" choice will enable DR only when we can request host-cached
buffers (as signalled by the new VO_DR_FLAG_HOST_CACHED).

Co-authored-by: Nicolas F. <ovdev@fratti.ch>
Co-authored-by: Niklas Haas <git@haasn.dev>
2023-01-23 14:13:34 +01:00
Niklas Haas f8c17f55f9 vo: add int flags to the get_image signature
This is a huge disgusting mess to thread through everywhere. Maybe I'm
stupid for attempting to solve the problem this way.
2023-01-23 14:13:34 +01:00
Avi Halachmi (:avih) 8eb7a00fa1 msg: log-file set at mpv.conf: don't ignore early messages
Previously, if log-file was set not via a CLI option (e.g. set via
mpv.conf or other config file, or set from a script init phase),
then meaningful early log messages were thrown away because the log
file name was unknown initially.

Such early log messages include the command line arguments, any
options set from mpv.conf, and possibly more.

Now we store up to 5000 early messages before the log file name is
known, and flush them once/if it becomes known, or destroy this
buffer once mpv init is complete.

The implementation is similar and adjacent, but not identical, to an
existing early log system for mpv clients which request a log buffer.
2023-01-23 11:05:08 +02:00
Avi Halachmi (:avih) 17baa00e02 msg: log-file buffer size: don't use magic number (no-op) 2023-01-23 11:05:08 +02:00
Dudemanguy 92a6f2d687 drm: rewrite based around vo_drm_state
A longstanding pain point of the drm VOs is the relative lack of state
sharing. While drm_common does provide some sharing, it's far less than
other platforms like x11 or wayland. What we do here is essentially copy
them by creating a new vo_drm_state struct and using it in vo_drm and
context_drm_egl. Much of the functionality that was essentially
duplicated in both VOs/contexts is now reduced simple functions in
drm_common. The usage of the term 'kms' was also mostly eliminated since
this is libdrm nowadays from a userspace perspective.
2023-01-21 17:08:29 +00:00
Niklas Haas 8c617765fe mp_image: fix XYZ primaries default
This was incorrectly set to BT.2020, when it should be DCI-P3 for pretty
much all real-world XYZ content (which is digital cinema content).
2023-01-21 13:03:33 +01:00
Dudemanguy 25d02e88d3 meson: skip some unneeded macos-specific checks
A couple of programs were always unconditionally searched for, but we
don't have to do this if we're not on darwin.
2023-01-20 21:42:49 +01:00
Thomas Weißschuh 67dbe2a8f4 meson: drop feature plain-gl 2023-01-19 22:15:14 +00:00
Thomas Weißschuh 44179398b0 ci: run meson tests 2023-01-19 22:15:14 +00:00
Thomas Weißschuh e09bab90ce meson: limit vaapi checks 2023-01-19 22:15:14 +00:00
Thomas Weißschuh ede8d29408 meson: don't add libmpv and cplayer features to conf_data
Core code should not use these features as it would mean that a libmpv
build could change an mpv executable and vice-versa.
Also changing one of them should not force a full recompile of the other
one through a change to config.h.
2023-01-19 22:15:14 +00:00
Thomas Weißschuh 491aaacca6 meson: remove dependency from libmpv to plain-gl
The libmpv feature should not have any impact on the built core code.
Otherwise a mpv executable compiled in a build together with libmpv has
different features than one from a build without.

The gl feature doesn't hurt, so always enable it.
2023-01-19 22:15:14 +00:00
Thomas Weißschuh 2056bf1b4e meson: add simple test executable for libmpv
This can be used to make sure that the built libmpv is functional.
2023-01-19 22:15:14 +00:00
Thomas Weißschuh fd2f1a6f9a stream: remove trailing NULL element from stream list 2023-01-17 14:01:47 +01:00
Niklas Haas b091dfda71 hwdec_cuda: drop support for PL_HANDLE_WIN32_KMT
This handle type was only needed for backwards compatibility with
windows 7. Dropping it allows us to simplify the code: there is no
longer a need for runtime checks, as the handle type can now be
statically assigned based on the platform.

The motivating usecase here, apart from code simplification, is a
desired switch to timeline semaphores, which (in the CUDA API) only
supports the non-KMT win32 handles.

It's worth pointing out that we need no runtime check for
IsWindows8OrGreater(), because the `export_caps.sync` check will already
fail on versions of windows not supporting PL_HANDLE_WIN32.
2023-01-17 11:38:46 +01:00
Thomas Weißschuh f52cfdabca wayland: only warn when actually missing idle inhibit support 2023-01-16 19:26:09 +00:00
Thomas Weißschuh 2bbf880d96 vo: make driver list static 2023-01-16 19:25:54 +00:00
Thomas Weißschuh f66c5404f4 vo: remove trailing NULL element from driver array 2023-01-16 19:25:54 +00:00
Thomas Weißschuh 98c2fa095d ao: remove trailing NULL element from driver array 2023-01-16 19:25:54 +00:00
LaserEyess 50169e05d8 DOCS/compile-windows.md: update with meson instructions
No need to encourage waf here.

Note: minor edits by Dudemanguy to update some dead links and such.
2023-01-15 16:46:11 +00:00
Dudemanguy 3858a8102b build: officially deprecate waf
While the waf build has served us well for many years, it's time to
officially consider it deprecated. The meson build was added fully with
the intention to eventually replace waf and its current state is more
than good enough to do that. Let's start the deprecation period now to
give users a heads up to switch before we remove waf for good.
2023-01-15 16:46:11 +00:00
Christoph Heinrich 7b09bf7ffc TOOLS/lua/autoload: improve alphanumeric sorting
Currently filenames like `EP.1.v0.1080p.mp4` do not get sorted correctly
(e.g. episode 11 right after episode 1). That is caused by the `.` in
front of the episode number, making it get sorted as if it were
decimals.

The solution is to match the whole real number or integer instead of
matching the integer part and the fractional part separately.

This will regress sorting of numbers with multiple commas where the
length of the individual segments differs between filenames.
Since those are rather uncommon, that is unlikely to be a problem (for
anyone ever).
2023-01-15 16:45:24 +00:00
Dudemanguy 6cdce9e18e wayland: store presentation feedbacks in a pool
Officially, the most cursed part of the wayland code in mpv (third or
fourth try now?) This time, let's allocate a pool during init
(arbitrarily set to the maximum swapchain length mpv allows, 8; don't
even know if this actually works in wayland). Then we add/remove
feedbacks from the pool during the lifecycle of the VO, and clean it up
all at the end. Hopefully, this does the trick for good this time.
2023-01-13 22:24:11 -06:00
Dudemanguy f32c5586d6 Revert "wayland: dispatch and wait for compositor events in uninit"
This ended up being a bad idea. The problem is that it introduces
ordering when destroying events (something we weren't worried about
before) and Lynne pointed out a problem with the callback not also being
destroyed before the surface in IRC. Just undo this and go with a
different approach (next commit). P.S. the wayland_dispatch_events name
change is kept though because I like that better.

This reverts commit aa8ddfcdf3.
2023-01-13 22:23:49 -06:00
Dudemanguy 73581d8fe6 TOOLS/docutils-wrapper: make executable + alphabetize
I should have caught this during review but the feature was too cool and
I didn't really pay attention (sorry). For consistency with the rest of
the scripts here.
2023-01-13 10:13:39 -06:00
Dudemanguy 9a9039deb2 audio: fix crash during uninit on ao_lavc
The buffer state can be null when using --ao=lavc, so just check it
first. Fixes #10175.
2023-01-13 16:02:38 +00:00
Ionen Wolkens 95a76f0692 meson: also search for rst2html with .py extension
This allows using rst2html.py from docutils if present, this
was already done for rst2man.py (unneeded for rst2pdf).
2023-01-13 16:01:15 +00:00
sfan5 1201d59f0b various: replace abort() with MP_ASSERT_UNREACHABLE() where appropriate
In debug mode the macro causes an assertion failure.
In release mode it works differently and tells the compiler that it can
assume the codepath will never execute. For this reason I was conversative
in replacing it, e.g. in mpv-internal code that exhausts all valid values
of an enum or when a condition is clear from directly preceding code.
2023-01-12 22:02:07 +01:00
sfan5 7b03cd367d various: replace if + abort() with MP_HANDLE_OOM()
MP_HANDLE_OOM also aborts but calls assert() first, which
will result in an useful message if compiled in debug mode.
2023-01-12 22:02:07 +01:00
sfan5 b6b8380518 stream/dvb: drop support for DVB API before 5.8
There is really no reason to keep the #ifdef mess around given
that version is available since December 2012 (Linux 3.7).
2023-01-12 22:02:07 +01:00
sfan5 1e00e3119f ao_audiotrack: replace malloc with talloc 2023-01-12 22:02:07 +01:00
sfan5 d54f22f8b6 stream/cookies: use stream_read_file()
No need for this redundant implementation.
2023-01-12 22:02:07 +01:00
sfan5 833bff8738 {video,audio}: adjust unsafe strncpy usages 2023-01-12 22:02:07 +01:00
sfan5 f4280e5238 video/x11: replace sprintf usage 2023-01-12 22:02:07 +01:00
sfan5 2703a2c8ff video: replace sprintf usage 2023-01-12 22:02:07 +01:00
sfan5 57f00a0372 demux_mf: replace unsafe string functions 2023-01-12 22:02:07 +01:00
sfan5 356096b954 ra_d3d11: fix incorrect type
As it happens, `SIZE_T` and `size_t` are not the same length on 32-bit Windows
2023-01-12 22:02:07 +01:00
sfan5 9196abf111 DOCS: clarify wid casting on Windows
The situation here is that HWND is always a 32-bit value but the
win32 API also accepts sign-extended values as valid. The trouble
starts when the numeric value is negative, as mpv ignores those.
Apparently this only happens after a while (related to uptime
or number of handles created), which meant this problem was rare.

addresses #10189
2023-01-12 22:02:07 +01:00
Dudemanguy a5b9d529ee vo_dmabuf_wayland: drop support for linux-dmabuf-v2
The only real reason this was ever supported is because it was
dramatically simpler than v4, so it was put in as an initial
implementation. Later, v4 support was added and we left v2 for
compatibility, but let's just drop it. Compositors all use v4 nowadays,
and v2 is significantly limited (no modifier support for example). It's
better to just remove this dead code for simplicity.
2023-01-12 17:42:35 +00:00
Aaron Boxer 865a159244 vo_dmabuf_wayland: support panscan and panning 2023-01-11 18:10:40 +00:00
Max Dunbar 05bc366d18 ta/README: update link to talloc documentation 2023-01-10 17:06:38 +00:00
Dudemanguy 4beb1bcae7 vo_wlshm: properly support video panscan
Turns out it was already doing this under the hood the entire time. The
only catch is that the vo just needed a resize.
2023-01-09 19:30:26 -06:00
Dudemanguy 6471afecd0 player: don't force saving start in watch-later-options
The watch-later mechanism has always unconditionally wrote start to
files to save the playback position. When this was later expanded to
watch-later-options, this logic was kept in place. But we don't actually
have to unconditionally write this and can allow users to remove the
option from the list if they want to. The start value still requires
some special handling; it should always be written if possible
regardless of the value changing. However, we can just place it within
the default set of options for watch-later-options so it can be removed
like any other.
2023-01-09 16:37:14 +00:00
Christoph Heinrich c4ec47a65e player: add video-sync=display-tempo
So far there was no way to sync video to display and have audio sync to
video without changes in pitch.

With this option the audio does not get resampled (pitch change) and
instead the corrected audio speed is applied to audio filters.
2023-01-09 15:17:09 +00:00
Christoph Heinrich 67321b1440 player: choose speed of smallest acceptable factor for display sync
Instead of choosing based on smallest deviation from set speed,
use the speed change from the smallest factor that does not
exceed `video-sync-max-video-change`.
2023-01-09 15:03:30 +00:00
Christoph Heinrich de9f375a23 TOOLS/lua/autoload: optimize performance of natural sorting
Formatting the string on each comparison is wasteful.
Formatting strings beforehand and then comparing the already formatted
ones leads to a huge performance gain.
2023-01-09 15:01:17 +00:00
dyphire 444bcd43b7 TOOLS/lua/autoload: further optimize the natural sorting
Commits https://github.com/mpv-player/mpv/commit/257dbdf06feb366f9eb1f96ceb7026c9365dddaa uses a algorithm of splitting strings
into a table of number and string values to achieve natural sorting.
This approach works well in most cases, but it does not work well
in some specific scenarios.
Now let's implement natural sorting with a stronger algorithm.

Also fixes indentation.

Ref: https://github.com/jonniek/mpv-playlistmanager/commit/3cf323f3c419af77f4141119283c1ec2911491c5
Closes https://github.com/mpv-player/mpv/issues/8969
2023-01-09 15:01:17 +00:00
Dudemanguy 8439c084e1 wayland: make vo_wayland_reconfig a bool
This was already returning true/false but the type was int. Also
simplify a few places in the wayland contexts where we can just return
the value of this function instead of doing redundant checks.
2023-01-08 20:42:42 +00:00
Dudemanguy d73fc7912a wayland: cleanup on vo_wayland_init error
Instead of just returning true/false, it's better to have this function
cleanup itself. We can eliminate some redundant uninit calls elsewhere
in the code as well.
2023-01-08 20:42:42 +00:00
Dudemanguy e4e0e7dfcf vo: change vo_platform_init to bool
There's several functions that are used for initializing mpv on a
certain platform (x11, wayland, etc.). These currently are all int, but
they actually return 1 and 0 like a boolean. This gets a bit confusing
because actual vo preinit functions return 0 and -1 instead. Just make
these all bool instead and return true/false to make it clearer.
2023-01-08 20:42:42 +00:00
Dudemanguy e43393c4da vo_wlshm: cleanup on failure
If failure occurs during preinit, vo_wlshm should goto an error and
cleaup itself like the other VOs.
2023-01-08 12:39:50 -06:00
Dudemanguy c5af54eb35 vo_dmabuf_wayland: goto err instead of returning
Returning early is clearly wrong. It should use to goto to cleanup after
itself. Also renamed from error_out to err for purely comestic reasons.
2023-01-08 12:19:14 -06:00
Christoph Reiter 96773f39e1 vulkan: fix build error for 32bit builds with clang
vk->surface is a handle and not a pointer, so assign VK_NULL_HANDLE.
This fixes the following build error on 32bit Windows when using clang for example,
which errors out when assigning a 32bit pointer to a 64bit integer:

  ../mpv-0.35.0/video/out/vulkan/utils.c:37:21:
    error: incompatible pointer to integer conversion assigning to 'VkSurfaceKHR' (aka 'unsigned long long') from 'void *' [-Wint-conversion]
          vk->surface = NULL;
                      ^ ~~~~
2023-01-08 16:09:01 +01:00
Thomas Weißschuh 8a0fa62b58 meson: dynamically compute dependencies for manpage and html build
This allows us to rebuild the manpages and html documentation only when
necessary. It is not necessary to manually keep the list of dependencies
up to date.

Unfortunately rst2pdf does not yet support this feature, see
https://github.com/rst2pdf/rst2pdf/issues/1108
2023-01-08 01:55:40 +00:00
sfan5 c8a90001f2 TOOLS/umpv: support shell-quotes in $MPV 2023-01-07 13:16:03 +01:00
Philip Langdale 33e73f4efd demux: new packet should not point to source buffer when copying data
In `new_demux_packet_from`, we initialise a new packet and allocate a
buffer which we copy the source data into. But I was then assigning
the original source pointer as the packet's buffer, rather than keeping
the newly allocated one. Whoops.
2023-01-06 14:12:44 -08:00
Philip Langdale d628e6108e demux: actually initialise packet buffer when creating new packet
When I refactored the code here to stop using stack allocated
AVPackets, I forgot to assign `dp->buffer` after initialising the
AVPacket.

Fixes #11097
2023-01-06 14:03:36 -08:00
Dudemanguy 3a6ef81705 version.py/version.sh: bump copyright year 2023-01-04 08:29:07 -06:00
Simon Ruderich c153eb7d01 demux: boost read EBU R128 gain values to ReplayGain's reference level
Without this change the same track encoded as Opus - which requires R128
tagging - and e.g. Vorbis with ReplayGain tagging have different volumes.
This is caused by ReplayGain 2 having a higher reference level of -18 dB
LUFS, while EBU R128 has a lower reference level of -23 dB LUFS.

For the results of gain application to match, the read EBU R128
values need to be boosted according to the difference in reference
levels.

Patch inspired by mpd's source code.
2023-01-04 14:05:22 +02:00
Dudemanguy aa8ddfcdf3 wayland: dispatch and wait for compositor events in uninit
Similar to some other issues we've had with unprocessed compositor
events. When quitting mpv, there's two things we should be doing:
dispatching any last minute wayland events and then waiting for a
compositor reply. Luckily, there's already an internal helper for this
(renamed to wayland_dispatch_events for consistency) that we can use.
All of the special casing of wl->feedback becomes unneccesary and we can
remove this from vo_wayland_state with this method. Fixes #110022.
2023-01-03 20:45:39 +00:00
Dudemanguy 4bbb1ccfd7 wayland: initalize display_fd as -1
In the event of a failed wayland initalization, the display_fd is
actually 0 instead of -1 which would correctly indicate it doesn't
exist. Also move the fd check inside vo_wayland_dispatch_events since
that function shouldn't ever do anything if we don't actually have a
display fd.
2023-01-03 20:45:39 +00:00
Dudemanguy 24e2251b73 wayland: consistently employ use_present
We have a use_present bool that keeps track of whether or not to use
presentation time. However, the creation of the feedback listener
actually wasn't checking this and was instead checking for the existence
of wl->presentation. There's no point in always creating the
listener and feedback if mpv isn't actually going to use it. Just change
it to use_present instead.
2023-01-03 20:45:39 +00:00
Dudemanguy d1d2370d07 draw_bmp: ensure last slice width is less than total width
e97819f88e corrected a special case
condition that lead to an out of bounds access if the total width
happened to be an integer multiple of SLICE_W (256) which could cause a
crash in software VOs. However, it turns out that the functions in this
file evaluate quite differently when using encoding mode (and presumably
libmpv as well according to reports although I could not independently
verify it).

The logic here gets complicated but what ends up happening is that, in
blend_overlay_with_video, the value of x + w can be greater than p->w in
certain cases in encoding mode. The x is the positional value of the
slice which remained unchanged from before, but w can take the full
value of SLICE_W (256) which is not necessarily correct. The width of
the final slice here should be the total remaining width. We can handle
this in mark_rect by simply always adjusting x1 of the last slice to be
equal to total width - SLICE_W * x so it can never extend beyond where
it should be. In practice, this value should be the maximum allowed
here. I'm not sure if the existing x1 value can possibly already be
lower than SLICE_W, but just MPMIN it to be on the safe side.
Fixes #10908.
2023-01-03 01:08:46 +00:00
repojohnray fee6847aa7 vo: hwdec: fix drmGetDeviceNameFromFd2() related memory leak
This commit fixes a minor memory leak related to drmGetDeviceNameFromFd2().
This function returns a string allocated with strdup().
2023-01-02 16:48:24 -08:00
repojohnray 2e9c43f931 hwdec_drmprime: fix memory leak 2023-01-02 19:46:07 +01:00
Li Chang 39f7f83351 ao_coreaudio: use AudioUnitReset as ao_driver.reset to prevent long restart
[motivation]
Seeking on MacOS appears to be lagged when users connect
to wireless audio output (airpods for example).

This commit attempts to fix mpv-player/mpv#10270

[observation]
1. When using other media player (VLC to be exact) simultaneously,
the lagging on seek disappear. We could guess that the AudioDevice
is on some sort of "warm-up" state.

See mpv-player/mpv#9243 for detailed description.

2. `AudioOutputUnitStart` takes significant longer time after each seek
or pause/play when using wireless output devices compares to wired devices.

[rationale]
After investigate codes in ao_coreaudio.c, it appears that the the `stop`
function was used as `ao_driver.reset` function. Therefore every seek
and pause would call `AudioOutputUnitStop`.

It turns out that `ao_driver.reset` function is used in `ao_reset`.
And `ao_reset` function is used to clean up the state of current `ao`
so I think `AudioUnitReset` is more proper than `AudioOutputUnitStop`
under this semantics.

Since ao_coreaudio use pull base mechanism, audio playback behaviors
upon pause/seek could be handled by callback function
(streaming silence when paused) so there is no need to stop AudioUnit when resetting.
Therefore using `AudioUnitReset` as `ao_driver.reset` looks proper.

Additionally, after using proper reset, the AudioUnit that represents
hardware I/O devices doesn't need to be restart everytime seek/pause actions happen.
Restarting wireless devices simply takes longer in MacOS which is
the root cause of lagging observed by users when they seek or pause/play media.

[method]
Use `AudioUnitReset` for ao_driver.reset.
2023-01-02 19:45:54 +01:00
Kacper Michajłow ad65c8855b vo_opengl: do not blindly reject all Microsoft's OpenGL implementations
This change enables mpv to work in the WSL2 (WSLg) environment where
OpenGL is implemented on top of D3D12.

This reverts commit 149d98d244.

Mentioned OpenGL implementation (GDI Generic) in the original change
will be rejected by version check, so there is no need to handle it
manually.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2022-12-30 11:02:52 -05:00
Sultan Alsawaf eb29aa4839 demux: add --demuxer-hysteresis-secs option to save power with caching
Buffering ahead nonstop into the cache results in nonstop disk or network
activity to read stream data from wherever it may originate. Currently,
there's no way to configure the demuxer to back off once it's buffered
ahead enough data, since the cache limit will be perpetually not-reached as
a stream continues to play, until the entire stream is eventually buffered.

On a laptop with an i9-12900H with decoding performed by the iGPU,
watching a locally-saved 1080p video which hasn't been buffered into the
page cache consumes approximately 15 W even with caching enabled. When
configuring a hysteresis to make the demuxer back off, power consumption
drops to 9 W when watching the same video, resulting in a whopping 6 W of
power savings.

To make it possible to attain significant power savings via caching, add
a --demuxer-hysteresis-secs option to configure a hysteresis to make the
demuxer back off until there's only the configured number of seconds
remaining in the cache from the current playback position.

This feature is disabled by default.
2022-12-30 10:30:22 +01:00
Ron Shabi b6c9846112 external_files: recognize webp files as cover art
mpv currently only recognizes jpg and png files named "AlbumArt",
"Album", "cover", etc. which are in the same folder as the audio files
as album/cover art and displays it when playing such audios.

This feature adds support for webp files following the same naming
scheme to be displayed as cover art for albums who have them.

Webp variations are lower in priority compared to jpg or png files.

Resolves: #11006
2022-12-29 15:48:57 +01:00
Sultan Alsawaf 4a2aa36674 x11: add modesetting to the xpresent whitelist
Since the modesetting driver now has TearFree support with integration into
xpresent, it's important that xpresent is used with the modesetting driver
to get the correct vsync timing when a frame is delayed by one vblank
interval due to a pending page-flip enqueued by a different entity. The
modesetting driver ensures that the xpresent extension reports the correct
presentation timing when TearFree is used; mpv just needs to listen to it.

Add the modesetting driver to the xpresent whitelist so mpv can get the
correct presentation completion timing when modesetting TearFree is used.

This is also helpful for when xpresent performs page flips directly in the
modesetting driver and a natural delay in the display pipeline causes a
page flip to be delayed by one vblank interval or more.
2022-12-27 13:07:33 +01:00
sfan5 d8ae14653a build: add configure test for POSIX shm for the sake of vo_kitty
Android's POSIX coverage is pretty sketchy but not like we have a choice.
2022-12-26 15:08:07 +01:00
Philip Langdale cb15bc4324 demux: replace deprecated usage of stack allocated AVPackets
In the previous change, I replaced the callsites that used
`av_init_packet`, but there are a handful of places that use stack
allocated packets with no initialisation.

In one case, I just switched to heap allocation as it's only done once
per stream at most.

In the other case, I removed our usage of the AVPackets as a
convenience mechanism to transfer data into a heap allocated packet.
Instead, I inlined the data copying.
2022-12-24 09:55:37 -08:00
Thomas Weißschuh 657fd2804c audio: reset pull AO at end of file
When a pull AO reaches reaches EOF then ao_read_data() will set
p->playing = false.
Because the ao is marked as not playing ao_set_pause(true) will not
reset the AO.
This keeps the output stream unintentionally open.

Fixes #9835
2022-12-22 15:14:08 -08:00
Mia Herkt 874e28f4a4 vo_kitty: Introduce modern sixel alternative
See https://sw.kovidgoyal.net/kitty/graphics-protocol/

This makes no attempt at querying terminal features or handling
terminal errors, as it would require mpv to pass the response codes
from the terminal to the vo instead of interpreting them as
keystrokes made by the user and acting very unpredictably.

Tested with kitty and konsole.

Fixes #9605
2022-12-21 19:39:30 +01:00
Nicolas F 7614e68233 external_files: set log level for potential files to trace
We ask users to freely share log files with us, which is usually
okay, unless a user has some unrelated and potentially embarrassing
files in their working directory. These would show up in the debug
level message output that --log-file enables.

Change the listing of potential external files to trace log level,
to save the users and the developers the embarrassment.
2022-12-21 19:04:27 +01:00
chen70 3447463008 hwdec/d3d11va: fix a possible memory leak 2022-12-21 19:03:38 +01:00
garamond13 27dab30209 filter_kernels: fix kaiser
Seems to me that params[1] is set to NAN and here should be the same value as in params[0].
2022-12-20 13:53:25 +01:00
Mia Herkt d5c3b9d989 man/vo: Typo 2022-12-20 11:12:23 +01:00
Mia Herkt 383ca54fc5 man/vo: Correct --vo-sixel-buffered 2022-12-20 11:10:28 +01:00
Mia Herkt 56f0ba22f1 vo_sixel: Implement write() loop
Not all systems are Linux. Also update the comment to better reflect
POSIX documentation.
2022-12-20 10:45:36 +01:00
Mia Herkt 125fd4c2f9 vo_sixel: Rename draw-clear -> config-clear 2022-12-20 10:29:49 +01:00
Mia Herkt 08747c4965 osdep/terminal.h: Rename screen buffer controls
SAVE/RESTORE were a bit misleading.
2022-12-20 10:26:53 +01:00
Mia Herkt a4cac2ddc6 vo_sixel: Alias/deprecate exit-clear -> alt-screen
Also update documentation to reflect actual behavior.
2022-12-20 10:22:51 +01:00
Mia Herkt 12c3203e98 vo_sixel: Make buffering optional
It can be slower than unbuffered.
2022-12-20 10:06:49 +01:00
Mia Herkt aa3e9b706f man/vo: Fix rendering error due to non-printables 2022-12-20 06:57:12 +01:00
Mia Herkt 67bdda27f7 DOCS/interface-changes: Add --vo-sixel-draw-clear 2022-12-20 03:54:38 +01:00
Philip Langdale 405073b9ca Revert "ao_pipewire: deactivate stream at end of playback"
This reverts commit b5373079f2.
2022-12-19 15:54:42 -08:00
Mia Herkt fe21553637 vo_sixel: Buffer full output sequence
This allows the VO to write its output without interference from other
processes or threads.
2022-12-19 13:48:49 +01:00
Mia Herkt 3ca31b6cf4 vo_sixel: Use write(2) on POSIX platforms 2022-12-19 13:48:49 +01:00
Mia Herkt 0f721ab51c vo_tct: Use newer options API 2022-12-19 13:48:49 +01:00
Mia Herkt 85f1fa0715 vo_sixel: Move user options to struct 2022-12-19 13:48:49 +01:00
Mia Herkt 68ae603e75 vo_sixel: Add option to skip clear while drawing 2022-12-19 13:48:49 +01:00
Mia Herkt f1957ce911 osdep/terminal: Move common esc codes to terminal.h 2022-12-19 13:48:49 +01:00
Mia Herkt 4e1626a21c vo_sixel: Use the alternate buffer to restore term 2022-12-19 13:48:49 +01:00
Mia Herkt 1564e4f29f vo_tct: Use the alternate buffer to restore term 2022-12-19 13:48:49 +01:00
Thomas Weißschuh b5373079f2 ao_pipewire: deactivate stream at end of playback
By explictly shutting down the stream pipewire can deactivate the used
hardware, saving CPU and power.

Fixes #9835
2022-12-18 13:34:29 -08:00
Thomas Weißschuh f9d0b0c08a ao_pipewire: clean up when hotplug_init fails 2022-12-12 21:36:04 +01:00
Thomas Weißschuh f2ba5fdfd3 ao_pipewire: destroy context on connection failure 2022-12-12 21:36:04 +01:00
Thomas Weißschuh 64a7fd3a12 ao_pipewire: free properties on failure 2022-12-12 21:36:04 +01:00
Philip Langdale eeefa8aec0 vd_lavc: Set AV_HWACCEL_FLAG_UNSAFE_OUTPUT flag
This new hwaccel flag was added to allow us to request that an hwaccel
decode not implicitly copy output frames before passing them out. The
only hwaccel that would implicitly copy frames is nvdec due to how it
has a small output pool that cannot be grown very much. However, we
already copy frames as soon as we get our hands on them (in our hwdec)
so we're already safe from pool exhaustion, and the extra copy doesn't
help us.
2022-12-12 10:07:43 -08:00
EmperorPenguin18 cf349d68e3 hwdec_drmprime: support yuv420p format
H264 hardware decode with v4l2m2m wasn't working on the RPi 4. Mpv would
report the image format (yuv420p) wasn't supported. The change to
hwdec_drmprime.c is to explicitly say that the format now is supported.
The change to dmabuf_interop_gl.c is to specify the colour format of the
planes before generating egl images. These changes were tested on a Pi 4
with this fork of ffmpeg: https://github.com/jc-kynesim/rpi-ffmpeg.

Signed-off-by: EmperorPenguin18 <60635017+EmperorPenguin18@users.noreply.github.com>
2022-12-10 15:57:09 -08:00
rcombs 2fa1e7d0b4 ao_coreaudio: use device's nominal sample rate for latency properties
Fixes sync issues when using high-latency devices at non-native sample rates

Closes #10984
2022-12-10 18:15:46 +02:00
NRK 25b66256d7 player: add window-id property
currently only supported on x11.

one practical use-case of this is wanting to embed something (such as
dmenu) into the mpv window to use as a menu/selection. there might be
other use-cases as well (e.g doing some shenanigans with `xdotool` or
whatnot).

it's currently possible to:

* listen for 'current-window-scale' change (to check if the
  window has been created or not)
* call an external tool like `xdo` or `xdotool` and grab the xid
  from mpv's pid.

however it adds unnecessary dependency on external tools when mpv is
fully capable of easily providing this information.

closes: #10918
2022-12-05 02:03:25 +00:00
Philip Langdale 4574dd5dc6 ffmpeg: update to handle deprecation of av_init_packet
This has been a long standing annoyance - ffmpeg is removing
sizeof(AVPacket) from the API which means you cannot stack-allocate
AVPacket anymore. However, that is something we take advantage of
because we use short-lived AVPackets to bridge from native mpv packets
in our main decoding paths.

We don't think that switching these to `av_packet_alloc` is desirable,
given the cost of heap allocation, so this change takes a different
approach - allocating a single packet in the relevant context and
reusing it over and over.

That's fairly straight-forward, with the main caveat being that
re-initialising the packet is unintuitive. There is no function that
does exactly what we need (what `av_init_packet` did). The closest is
`av_packet_unref`, which additionally frees buffers and side-data.
However, we don't copy those things - we just assign them in from our
own packet, so we have to explicitly clear the pointers before calling
`av_packet_unref`. But at least we can make a wrapper function for
that.

The weirdest part of the change is the handling of the vtt subtitle
conversion. This requires two packets, so I had to pre-allocate two in
the context struct. That sounds excessive, but if allocating the
primary packet is too expensive, then allocating the secondary one for
vtt subtitles must also be too expensive.

This change is not conditional as heap allocated AVPackets were
available for years and years before the deprecation.
2022-12-03 14:44:18 -08:00
Philip Langdale 77e7f5de2c sws_utils: update to handle deprecation of avcodec_enum_to_chroma_pos
This has been replaced by `av_chroma_location_enum_to_pos`.
2022-12-01 10:45:47 -08:00
Philip Langdale 83257be693 vd_lavc: update to handle deprecation of pkt_duration
This has been replaced by `duration`.
2022-12-01 10:45:47 -08:00
Philip Langdale 70683b8916 ffmpeg: increase minimum required version to 4.4
Now that 0.35 has been released, we can consider increasing our minimum
required ffmpeg version. Currently, we think 4.4 is the most recent
version we can move to (from the current requirement of 4.0).

This allows us to remove a few conditionals. There are more that we
won't be able to remove unless we move further up to 5.1.
2022-12-01 10:45:47 -08:00
Dudemanguy 11229e7f71 wayland: check for resize/move in touch event first
8300830951 rearranged/simplified some of
the wayland touch code mainly because what was there before was
completely broken on my machine in those days (dragging was unreliable,
resizing was really buggy, etc.). However, one user said that touch
input no longer worked for him after that change. I could not ever
reproduce it, but it seems the issue was putting down the key before
testing for resize/move in the code. Now who knows why this actually
matters, but apparently it works for the user in question and I don't
observe any unexpected behavior on my end when swapping the order. Like
the mouse/pointer code, we also now do a test for dragging before
actually trying a resize/move which is a little more consistent than
before. Fixes #9771.
2022-12-01 11:14:03 -06:00
Dudemanguy bca516bd2c osc: don't spam window-controls bindings on every render
Not sure when this actually started happening, but it's probably been
like this for years. Currently, the logic for the window-controls works
by simply checking if the osc is visible and then either enabling or
disabling the associated keybindings. The problem is that this can just
constantly spam mp.enable_keybindings/disable_key_bindings on every
single render call if the user disables the border at any point in time.
This does a lot of pointless work and also results in the logs being
spammed with lines like "disable-section". Clearly, this should just
work like the code for checking the input keybindings just above it.
Keep track of an internal state variable and check when it doesn't match
the osc visibility. In that case, we can then either enable or disable
the key bindings and just update the variable.
2022-11-29 16:40:36 +00:00
Thomas Weißschuh 7eb8f81091 ao_pipewire: log sample queueing
This allows us to more easily see the datapath from mpv to pipewire.

We know how often the callbacks are triggered, how big the buffers are
and how much data mpv provides to pipewire.
2022-11-28 16:43:24 -08:00
SuperSamus 3624a9d3e6 TOOLS/umpv: prefer $XDG_RUNTIME_DIR 2022-11-28 21:08:55 +00:00
Niklas Haas e97e0e4d92 vo_gpu_next: don't flush cache on OSD update
Flushing the cache is a hammer-for-a-screw operation, because it nukes
*all* renderer state, including the HDR peak detection state. When
enabling e.g. --hdr-compute-peak, or any other future methods of dynamic
tone mapping, this would lead to bad results (e.g. brightness
fluctuations) whenever the OSD state is updated.

Instead of flushing the cache to force an OSD re-render, instead just
update the frame signature directly whenever its osd_sync value changes.
This accomplishes effectively the same thing but without touching the
HDR state.

This is slightly violating the libplacebo abstraction in a way that
isn't publicly documented. To be on the safe side we could make a carbon
copy of the array before modifying it, but given that this is unlikely
to change upstream I'll probably just end up explicitly documenting it
instead of forcing the copy in mpv.
2022-11-25 02:15:05 +01:00
Dudemanguy ead8469454 meson: fix stdatomic detection on bsd
BSDs use compiler-rt instead of libatomic for atomic types. In this
case, we can handle it similar to how dl is detected. Check for the
library (allowing for it to fail), and then check for a header symbol
while linking latomic. Fixes #10906.
2022-11-22 02:37:10 +00:00
Niklas Haas e1a04cd8ac lcms: fix validate_3dlut_size_opt
Not only was this function needlessly convoluted, it was also broken -
since it returned a bool value where an error code was expected.
2022-11-21 17:39:37 +01:00
Niklas Haas b9b3342369 lcms: always parse lcms2-related options
Currently, the lcms-related options are only defined when lcms2 is
enabled at build time. However, this causes issues (e.g. segfault) for
vo_gpu_next, which relies on the presence of these options (to forward
them to libplacebo).

(That libplacebo internally depends on lcms2 as well is an
implementation detail - compiling mpv *without* lcms against libplacebo
*with* lcms should be possible in principle)

Fixes: #10891
Closes: #10856
2022-11-21 17:39:37 +01:00
LaserEyess a62f71bfbe vo_dmabuf_wayland: use single-pixel-buffer-v1
The new single-pixel-buffer protocol is designed to optimize the case
for using a solid color as an underlay wl_surface. It works the same as
the wl_shm 1x1 pixel trick currently used, but it allows the compositor
to make optimizations with more certainty than the wl_shm trick.
2022-11-20 19:13:59 +00:00
LaserEyess 303178e645 wlbuf_pool.h: add headers for forward declarations
This was previously implicitly included by the order of headers in
vo_dmabuf_wayland.c, but it is better to make it an explicit and reorder
the headers properly.
2022-11-20 19:13:59 +00:00
Dudemanguy 04f765da6f meson: unbreak dl check on BSDs without libdl
Regression from 1835dfc05c. The actual
libdl dependency is not always required for the function symbol check.
Fixes #10901.
2022-11-20 12:04:04 -06:00
Dudemanguy f10b24e3c5 meson: prepend MPV_CONFDIR path with prefix
Meson uses the sysconfdir option for setting the global config
directory. This conveniently defaults to /etc if the prefix is set to
/usr which is nice for linux distros. BSDs tend to use /usr/local which
causes this value to become 'etc' by default which is not an absolute
path so you would need to set something like -Dsysconfdir=/usr/local/etc
as well in the configuration step. It turns out we can have our cake and
eat it too by just joining the paths of prefix and sysconfdir together.
In the case where -Dprefix=/usr, this still results in /etc/mpv as the
path since the path joining logic just drops the leading '/usr/'. For
the /usr/local case, it ends up as /usr/local/etc/mpv as expected. This
fixes #10882.
2022-11-19 13:10:24 -06:00
Niklas Haas 8327ac3e6d vo_gpu_next: fix undefined behavior on alpha-first formats
When the alpha channel is the first component, this code block gets
skipped by the continue, meaning the check for c==0 never passes.

Fix it by explicitly keeping track of whether bits have been set.
2022-11-19 14:12:24 +01:00
Dudemanguy d3a61cfe98 wayland: also log refresh rate on surface entrance
Never bothered to log this for some reason, but it's pretty convenient
when debugging.
2022-11-18 16:36:21 -06:00
LaserEyess ba20f60add drm: remove legacy API
The legacy DRM API adds some complexity to the DRM code. There
are only 4 drivers that do not support the DRM Atomic API:

1. radeon (early GCN amd cards)
2. gma500 (ancient intel GPUs)
3. ast (ASPEED SoCs)
4. nouveau

Going forward, new DRM drivers will be guaranteed to support the atomic
API so this is a safe removal.
2022-11-16 09:32:55 +01:00
Dudemanguy 6623efb142 wayland: add support for content-type protocol
The content-type protocol allows mpv to send compositor a hint about the
type of content being displayed on its surface so it could potentially
make some sort of optimization. Fundamentally, this is pretty simple but
since this requires a very new wayland-protocols version (1.27), we have
to mess with the build to add a new define and add a bunch of if's in
here. The protocol itself exposes 4 different types of content: none,
photo, video, and game.

To do that, let's add a new option (wayland-content-type) that lets
users control what hint to send to the compossitor. Since the previous
commit adds a VOCTRL that notifies us about the content being displayed,
we can also add an auto value to this option. As you'd expect, the
compositor hint would be set to photo if mpv's core detects an image,
video for other things, and it is set to none for the special case of
forcing a window when there is not a video track. For completion's sake,
game is also allowed as a value for this option, but in practice there
shouldn't be a reason to use that.
2022-11-15 23:18:55 +00:00
Dudemanguy bab85944df player/video: add VOCTRL_CONTENT_TYPE
mpv's core already keeps track of whether or not it thinks a track is an
image. Some VOs (i.e. wayland) would benefit from knowing if what is
currently being displayed is an image or not so add a new VOCTRL that
signals this anytime we load a new file with a VO. Additionally, let's
add a helper enum for signaling the kind of content that is being
displayed. There is now MP_CONTENT_NONE (strictly for force window being
used on a track with no image/video), MP_CONTENT_IMAGE, and
MP_CONTENT_VIDEO. See the next commit for the actual usage of this (with
wayland).
2022-11-15 23:18:55 +00:00
Jan Ekström 0f0520aeca player/main: log libplacebo version if built with it
As we start basing more and more functionality on it, it makes
sense to start logging it more visibly as part of --version.
2022-11-15 21:41:22 +02:00
Jan Ekström 8bbe39a858 common/av_log: move general FFmpeg version before library versions
This way another library can be logged before FFmpeg without it
looking weird.
2022-11-15 21:41:22 +02:00
Philip Langdale 25fa52d237 vo: hwdec: remove legacy_names
These were introduced for configuration compatibility in 0.35 but we
don't want to retain them past that point.
2022-11-15 16:33:12 +01:00
Dudemanguy 38a626650a player: add --force-render option
mpv has an internal optimization on a couple of platforms where it will
not render any frames if the window is minimized or hidden. There's at
least once possible use case for wanting to force a render anyway
(screensharing with pipeware) so let's just add a simple switch for
this that always forces mpv to render. Closes #10846.
2022-11-15 15:31:21 +00:00
Dudemanguy 295ceab382 wayland: error out if essential protocol support is missing
Related issue: #10868. While most protocols are in theory optional, a
small amount of them are absolutely essential and nothing will work
without them. We should make sure to error out in those cases and not
try to actually do anything. For wayland support in general,
wl_compositor support is obviously required. If there is no wl_surface,
you can't do anything. Additionally, vo_wlshm quite obviously requires
wl_shm so mark that one as well. vo_dmabuf_wayland needs linux_dmabuf,
viewporter, wl_shm, and wl_subcompositor. In practice, these are all
very standard protocols and shouldn't be missing but the linked issue
above is at least one example where a compositor was stuck on an ancient
version of a wayland interface.
2022-11-15 14:42:02 +00:00
Jakub Wilk 62af31cbca meson: fix capitalization of "OpenGL" 2022-11-14 14:14:55 +00:00
Thomas Weißschuh d8fbe3c79f ao_pipewire: log version information and metadata 2022-11-13 20:40:14 -08:00
sfan5 1e9a2cbebf DOCS: update release policy to match reality 2022-11-13 15:01:34 +01:00
sfan5 2f747341f9 Update VERSION 2022-11-12 14:54:19 +01:00
383 changed files with 11370 additions and 6381 deletions

No files matched your search

+2 -2
View File
@@ -2,7 +2,7 @@
name: 'Report a build Problem'
about: 'Create a report for a build related Issue'
title: ''
labels: 'core:waf'
labels: 'core:meson'
assignees: ''
---
@@ -24,7 +24,7 @@ differs from your own.
### Log file
Upload build/config.log or ./waf configure output to https://0x0.st/ or attach
Upload meson-logs/meson-log.txt or meson setup build output to https://0x0.st/ or attach
it to the github issue, and replace this text with a link to it.
The issue will be closed for ignoring the issue template.
+117 -26
View File
@@ -18,16 +18,11 @@ jobs:
steps:
- uses: actions/checkout@v3
# Increase -N suffix here to force full rebuild after changes
- uses: actions/cache@v3
with:
path: mingw_prefix/
key: "${{ matrix.target }}-6"
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y autoconf automake pkg-config g++-mingw-w64 gcc-multilib meson nasm
sudo apt-get install -y autoconf automake pkg-config g++-mingw-w64 gcc-multilib python3-pip ninja-build nasm
sudo python3 -m pip install meson
./bootstrap.py
- name: Build libraries
@@ -37,26 +32,28 @@ jobs:
TARGET: ${{ matrix.target }}
- name: Build with meson
id: build
run: |
./ci/build-mingw64.sh meson
./ci/build-mingw64.sh meson pack
env:
TARGET: ${{ matrix.target }}
- name: Print meson log
if: ${{ failure() }}
if: ${{ failure() && steps.build.outcome == 'failure' }}
run: |
cat ./build/meson-logs/meson-log.txt
- name: Build with waf
id: build_waf
run: |
./ci/build-mingw64.sh waf pack
./ci/build-mingw64.sh waf
env:
TARGET: ${{ matrix.target }}
- name: Print waf log
if: ${{ failure() }}
if: ${{ failure() && steps.build_waf.outcome == 'failure' }}
run: |
cat ./build/config.log
cat ./build_waf/config.log
- uses: actions/upload-artifact@v3
with:
@@ -86,6 +83,7 @@ jobs:
brew install autoconf automake pkg-config libtool python freetype fribidi little-cms2 lua@5.1 libass ffmpeg meson
- name: Build with meson
id: build
run: |
./ci/build-macos.sh meson
env:
@@ -93,11 +91,22 @@ jobs:
TRAVIS_OS_NAME: "${{ matrix.os }}"
- name: Print meson log
if: ${{ failure() }}
if: ${{ failure() && steps.build.outcome == 'failure' }}
run: |
cat ./build/meson-logs/meson-log.txt
- name: Run meson tests
id: tests
run: |
meson test -C build
- name: Print meson test log
if: ${{ failure() && steps.tests.outcome == 'failure' }}
run: |
cat ./build/meson-logs/testlog.txt
- name: Build with waf
id: build_waf
run: |
./ci/build-macos.sh waf
env:
@@ -105,9 +114,9 @@ jobs:
TRAVIS_OS_NAME: "${{ matrix.os }}"
- name: Print waf log
if: ${{ failure() }}
if: ${{ failure() && steps.build_waf.outcome == 'failure' }}
run: |
cat ./build/config.log
cat ./build_waf/config.log
linux:
runs-on: "ubuntu-22.04"
@@ -130,22 +139,34 @@ jobs:
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Build with meson
id: build
run: |
./ci/build-tumbleweed.sh meson
- name: Print meson log
if: ${{ failure() }}
if: ${{ failure() && steps.build.outcome == 'failure' }}
run: |
cat ./build/meson-logs/meson-log.txt
- name: Run meson tests
id: tests
run: |
meson test -C build
- name: Print meson test log
if: ${{ failure() && steps.tests.outcome == 'failure' }}
run: |
cat ./build/meson-logs/testlog.txt
- name: Build with waf
id: build_waf
run: |
./ci/build-tumbleweed.sh waf
- name: Print waf log
if: ${{ failure() }}
if: ${{ failure() && steps.build_waf.outcome == 'failure' }}
run: |
cat ./build/config.log
cat ./build_waf/config.log
freebsd:
runs-on: macos-12 # until https://github.com/actions/runner/issues/385
@@ -154,6 +175,8 @@ jobs:
- name: Test in FreeBSD VM
uses: vmactions/freebsd-vm@v0
with:
mem: 8192
copyback: false
usesh: true
prepare: |
# Requested in ci/build-freebsd.sh
@@ -195,13 +218,81 @@ jobs:
#
run: |
./ci/build-freebsd.sh
meson test -C build
- name: Print meson log
if: ${{ failure() }}
run: |
cat ./build/meson-logs/meson-log.txt
msys2:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
sys:
- clang32
- clang64
- mingw32
- mingw64
- ucrt64
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v3
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.sys }}
update: true
install: git
pacboy: >-
angleproject:p
ca-certificates:p
cc:p
diffutils:p
ffmpeg:p
lcms2:p
libarchive:p
libass:p
libcdio-paranoia:p
libdvdnav:p
libjpeg-turbo:p
libplacebo:p
lua51:p
ninja:p
pkgconf:p
python3.11:p
rst2pdf:p
rubberband:p
shaderc:p
spirv-cross:p
uchardet:p
vapoursynth:p
vulkan:p
- name: Print waf log
if: ${{ failure() }}
run: |
cat ./build/config.log
- name: Build with meson
id: build
run: |
./ci/build-msys2.sh meson
- name: Print meson log
if: ${{ failure() && steps.build.outcome == 'failure' }}
run: |
cat ./build/meson-logs/meson-log.txt
- name: Run meson tests
id: tests
run: |
source ./venv/bin/activate
meson test -C build
- name: Print meson test log
if: ${{ failure() && steps.tests.outcome == 'failure' }}
run: |
cat ./build/meson-logs/testlog.txt
- name: Build with waf
id: build_waf
run: |
./ci/build-msys2.sh waf
- name: Print waf log
if: ${{ failure() && steps.build_waf.outcome == 'failure' }}
run: |
cat ./build_waf/config.log
+22
View File
@@ -0,0 +1,22 @@
name: lint
on:
push:
branches:
- master
- ci
- 'release/**'
pull_request:
branches: [master]
jobs:
commit-msg:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50
- name: Lint
run: |
./ci/lint-commit-msg.py
+1
View File
@@ -27,6 +27,7 @@ that you get for free. In some cases, these overlapped with custom waf options.
supported in the meson build. Instead, pass the generic pkg-config values
such as ``lua52``, ``lua5.2``, etc.
* ``--lgpl`` was changed to ``gpl``. If ``gpl`` is false, the build is LGPL2.1+.
* ``--tests`` was removed since unit tests now explicitly require meson to run
### Boolean Options
+2
View File
@@ -32,6 +32,8 @@ API changes
::
--- mpv 0.36.0 ---
2.1 - add mpv_del_property()
--- mpv 0.35.0 ---
2.0 - remove headers/functions of the obsolete opengl_cb API
- remove mpv_opengl_init_params.extra_exts field
+34 -33
View File
@@ -4,28 +4,43 @@ Compiling for Windows
Compiling for Windows is supported with MinGW-w64. This can be used to produce
both 32-bit and 64-bit executables, and it works for building on Windows and
cross-compiling from Linux and Cygwin. MinGW-w64 is available from:
http://mingw-w64.sourceforge.net.
https://www.mingw-w64.org/
While building a complete MinGW-w64 toolchain yourself is possible, there are a
few build environments and scripts to help ease the process, such as MSYS2 and
MXE. Note that MinGW environments included in Linux distributions are often
broken, outdated and useless, and usually don't use MinGW-w64.
**Warning**: the original MinGW (http://www.mingw.org) is unsupported.
**Warning**: the original MinGW (https://osdn.net/projects/mingw/) is unsupported.
Cross-compilation
=================
When cross-compiling, you have to run mpv's configure with these arguments:
When cross-compiling, it is recommended to use a meson crossfile to setup
the cross compiling environment. A minimal example is included below:
```bash
DEST_OS=win32 TARGET=i686-w64-mingw32 ./waf configure
```ini
[binaries]
c = 'x86_64-w64-mingw32-gcc'
cpp = 'x86_64-w64-mingw32-g++'
ar = 'x86_64-w64-mingw32-ar'
strip = 'x86_64-w64-mingw32-strip'
exe_wrapper = 'wine64'
[host_machine]
system = 'windows'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'
```
See [meson's documentation](https://mesonbuild.com/Cross-compilation.html) for
more information.
[MXE](https://mxe.cc) makes it very easy to bootstrap a complete MingGW-w64
environment from a Linux machine. See a working example below.
Alternatively, you can try [mingw-w64-cmake](https://github.com/lachs0r/mingw-w64-cmake),
Alternatively, you can try [mpv-winbuild-cmake](https://github.com/shinchiro/mpv-winbuild-cmake),
which bootstraps a MinGW-w64 environment and builds mpv and dependencies.
Example with MXE
@@ -79,11 +94,8 @@ export PATH=/opt/mxe/usr/bin/:$PATH
cd ..
git clone https://github.com/mpv-player/mpv.git
cd mpv
python ./bootstrap.py
DEST_OS=win32 TARGET=i686-w64-mingw32.static ./waf configure
# Or, if 64 bit version,
# DEST_OS=win32 TARGET=x86_64-w64-mingw32.static ./waf configure
./waf build
meson setup build --crossfile crossfile
meson compile -C build
```
Native compilation with MSYS2
@@ -99,7 +111,7 @@ To build 64-bit mpv on Windows:
Installing MSYS2
----------------
1. Download an installer from https://msys2.github.io/
1. Download an installer from https://www.msys2.org/
Both the i686 and the x86_64 version of MSYS2 can build 32-bit and 64-bit
mpv binaries when running on a 64-bit version of Windows, but the x86_64
@@ -132,37 +144,30 @@ Installing mpv dependencies
```bash
# Install MSYS2 build dependencies and a MinGW-w64 compiler
pacman -S git python $MINGW_PACKAGE_PREFIX-{pkg-config,gcc}
pacman -S git $MINGW_PACKAGE_PREFIX-{python,pkgconf,gcc,meson}
# Install the most important MinGW-w64 dependencies. libass and lcms2 are also
# pulled in as dependencies of ffmpeg.
pacman -S $MINGW_PACKAGE_PREFIX-{ffmpeg,libjpeg-turbo,lua51}
pacman -S $MINGW_PACKAGE_PREFIX-{ffmpeg,libjpeg-turbo,luajit}
```
Building mpv
------------
Clone the latest mpv from git and install waf. **Note:** ``/usr/bin/python3``
is invoked directly here, since an MSYS2 version of Python is required.
```bash
git clone https://github.com/mpv-player/mpv.git && cd mpv
/usr/bin/python3 bootstrap.py
```
Finally, compile and install mpv. Binaries will be installed to
``/mingw64/bin`` or ``/mingw32/bin``.
```bash
/usr/bin/python3 waf configure CC=gcc.exe --check-c-compiler=gcc --prefix=$MSYSTEM_PREFIX
/usr/bin/python3 waf install
meson setup build --prefix=$MSYSTEM_PREFIX
meson compile -C build
```
Or, compile and install both libmpv and mpv:
```bash
/usr/bin/python3 waf configure CC=gcc.exe --check-c-compiler=gcc --enable-libmpv-shared --prefix=$MSYSTEM_PREFIX
/usr/bin/python3 waf install
meson setup build -Dlibmpv=true --prefix=$MSYSTEM_PREFIX
meson compile -C build
meson install -C build
```
Linking libmpv with MSVC programs
@@ -177,13 +182,11 @@ To do this, you need a Visual Studio which supports ``stdint.h`` (recent ones do
and you need to create a import library for the mpv DLL:
```bash
lib /def:mpv.def /name:mpv-1.dll /out:mpv.lib /MACHINE:X64
lib /name:mpv-1.dll /out:mpv.lib /MACHINE:X64
```
The string in the ``/name:`` parameter must match the filename of the DLL (this
is simply the filename the MSVC linker will use). The ``mpv.def`` can be
retrieved from the mpv build directory, or can be produced by MingGW's
gendef.exe helper from the mpv DLL.
is simply the filename the MSVC linker will use).
Static linking is not possible.
@@ -208,6 +211,4 @@ Use of the ANGLE OpenGL backend requires a copy of the D3D compiler DLL that
matches the version of the D3D SDK that ANGLE was built with
(``d3dcompiler_43.dll`` in case of MinGW-built ANGLE) in the path or in the
same folder as mpv. It must be of the same architecture (x86_64 / i686) as the
mpv you compiled. You can find copies here:
https://mpv.srsfckn.biz/d3dcompiler.7z
mpv you compiled.
+64
View File
@@ -26,6 +26,70 @@ Interface changes
::
--- mpv 0.36.0 ---
- add `--target-contrast`
- Target luminance value is now also applied when ICC profile is used.
`--icc-use-luma` has been added to use ICC profile luminance value.
If target luminance and ICC luminance is not used, old behavior apply,
defaulting to 203 nits. (Only applies for `--vo=gpu-next`)
- `playlist/N/title` gets set upon opening the file if it wasn't already set
and a title is available.
- add the `--vo=kitty` video output driver, as well as the options
`--vo-kitty-cols`, `--vo-kitty-rows`, `--vo-kitty-width`,
`--vo-kitty-height`, `--vo-kitty-left`, `--vo-kitty-top`,
`--vo-kitty-config-clear`, `--vo-kitty-alt-screen` and
`--vo-kitty-use-shm`
- add `--force-render`
- add `--vo-sixel-config-clear`, `--vo-sixel-alt-screen` and
`--vo-sixel-buffered`
- add `--wayland-content-type`
- deprecate `--vo-sixel-exit-clear` and alias it to
`--vo-sixel-alt-screen`
- deprecate `--drm-atomic`
- add `--demuxer-hysteresis-secs`
- add `--video-sync=display-tempo`
- the `start` option is no longer unconditionally written by
watch-later. It is still written by default but you may
need to explicitly add `start` depending on how you have
`--watch-later-options` configured.
- add `--vd-lavc-dr=auto` and make it the default
- add support for the fractional scale protocol in wayland
- in wayland, hidpi window scaling now scales the window by the compositor's
dpi scale factor by default (can be disabled with --no-hidpi-window-scale
if fractional scaling support exists).
- change --screenshot-tag-colorspace default value from `no` to `yes`
- undeprecate vf_sub
- add `--tone-mapping=st2094-40` and `--tone-mapping=st2094-10`
- change `--screenshot-jxl-effort` default from `3` to `4`.
- add `--tone-mapping-visualize`
- change type of `--brightness`, `--saturation`, `--contrast`, `--hue` and
`--gamma` to float.
- add `platform` property
- add `--auto-window-resize`
- `--save-position-on-quit` and its associated commands now store state files in
the XDG_STATE_HOME directory by default. This only has an effect on linux/bsd
systems.
- mpv now implictly saves cache files in XDG_CACHE_HOME by default. This only has
an effect if the user enables options that would lead to cache being stored and
only makes a difference on linux/bsd systems.
- `--cache-on-disk` no longer requires explictly setting the `--cache-dir` option
- add `--icc-cache` and `--gpu-shader-cache` options to control whether or not to
save cache files for these features; explictly setting `--icc-cache-dir` and
`--gpu-shader-cache` is no longer required
- remove the `--tone-mapping-crosstalk` option
- add `--gamut-mapping-mode=perceptual|relative|saturation|absolute|linear`
- add `--corner-rounding` option
- change `--subs-with-matching-audio` default from `yes` to `no`
- change `--slang` default from blank to `auto`
- add `--input-cursor-passthrough` option to allow pointer events to completely
passthrough the mpv window
- icc and gpu-shader cache are now saved by default (use --no-icc-shader-cache and
--no-gpu-shader-cache to disable)
- add `--directory-mode=recursive|lazy|ignore`
- `--hwdec=yes` is now mapped to `auto-safe` rather than `auto` (also used
by ctrl+h keybind)
- add `--hdr-contrast-recovery` and `--hdr-contrast-smoothness`
- include `--hdr-contrast-recovery` in the `gpu-hq` profile
--- mpv 0.35.0 ---
- add the `--vo=gpu-next` video output driver, as well as the options
`--allow-delayed-peak-detect`, `--builtin-scalers`,
+7 -2
View File
@@ -128,7 +128,7 @@ Available audio output drivers are:
Set the audio buffer size in milliseconds. A higher value buffers
more data, and has a lower probability of buffer underruns. A smaller
value makes the audio stream react faster, e.g. to playback speed
changes.
changes. "native" lets the sound server determine buffers.
``--pulse-latency-hacks=<yes|no>``
Enable hacks to workaround PulseAudio timing bugs (default: no). If
@@ -154,13 +154,18 @@ Available audio output drivers are:
Set the audio buffer size in milliseconds. A higher value buffers
more data, and has a lower probability of buffer underruns. A smaller
value makes the audio stream react faster, e.g. to playback speed
changes.
changes. "native" lets the sound server determine buffers.
``--pipewire-remote=<remote>``
Specify the PipeWire remote daemon name to connect to via local UNIX
sockets.
An empty <remote> string uses the default remote named ``pipewire-0``.
``--pipewire-volume-mode=<channel|global>``
Specify if the ``ao-volume`` property should apply to the channel
volumes or the global volume.
By default the channel volumes are used.
``sdl``
SDL 1.2+ audio output driver. Should work on any platform supported by SDL
1.2, but may require the ``SDL_AUDIODRIVER`` environment variable to be set
+5
View File
@@ -144,6 +144,11 @@ Configurable Options
Set the font size used for the REPL and the console. This will be
multiplied by "scale".
``border_size``
Default: 1
Set the font border size used for the REPL and the console.
``history_dedup``
Default: true
+55 -17
View File
@@ -186,7 +186,7 @@ character at the value.
Custom quotes also take the content literally, but are more flexible than single
quotes. They start with ````` (back-quote) followed by any ASCII character,
and end at the first occurance of the same pair in reverse order, e.g.
and end at the first occurrence of the same pair in reverse order, e.g.
```-foo-``` or ````bar````. The final pair sequence is not allowed at the
value - in these examples ``-``` and `````` respectively. In the second
example the last character of the value also can't be a back-quote.
@@ -334,6 +334,9 @@ Remember to quote string arguments in input.conf (see `Flat command syntax`_).
``set <name> <value>``
Set the given property or option to the given value.
``del <name>``
Delete the given property. Most properties cannot be deleted.
``add <name> [<value>]``
Add the given value to the property or option. On overflow or underflow,
clamp the property to the maximum. If ``<value>`` is omitted, assume ``1``.
@@ -366,8 +369,7 @@ Remember to quote string arguments in input.conf (see `Flat command syntax`_).
behavior depends on the selected video output.
<window>
Save the contents of the mpv window. Typically scaled, with OSD and
subtitles. The exact behavior depends on the selected video output, and
if no support is available, this will act like ``video``.
subtitles. The exact behavior depends on the selected video output.
<each-frame>
Take a screenshot each frame. Issue this command again to stop taking
screenshots. Note that you should disable frame-dropping when using
@@ -383,6 +385,9 @@ Remember to quote string arguments in input.conf (see `Flat command syntax`_).
``async`` flag to make encoding/writing the image file asynchronous. For
normal standalone commands, this is always asynchronous, and the flag has
no effect. (This behavior changed with mpv 0.29.0.)
On success, returns a ``mpv_node`` with a ``filename`` field set to the
saved screenshot location.
``screenshot-to-file <filename> <flags>``
Take a screenshot and save it to a given file. The format of the file will
@@ -1091,7 +1096,7 @@ Input Commands that are Possibly Subject to Change
Before mpv 0.18.1, you had to do manual "double buffering" when updating
an overlay by replacing it with a different memory buffer. Since mpv
0.18.1, the memory is simply copied and doesn't reference any of the
memory indicated by the command's arguments after the commend returns.
memory indicated by the command's arguments after the command returns.
If you want to use this command before mpv 0.18.1, reads the old docs
to see how to handle this correctly.
@@ -1383,7 +1388,7 @@ Input Commands that are Possibly Subject to Change
This was mostly created for network streams. For local files, there may
be much better methods to create excerpts and such. There are tons of
much more user-friendly Lua scripts, that will reencode parts of a file
much more user-friendly Lua scripts, that will re-encode parts of a file
by spawning a separate instance of ``ffmpeg``. With network streams,
this is not that easily possible, as the stream would have to be
downloaded again. Even if ``--stream-record`` is used to record the
@@ -1423,8 +1428,8 @@ IPC sees. Note that the C API has separate C-level declarations with
``mpv_event``, which may be slightly different.
Note that events are asynchronous: the player core continues running while
events are delivered to scripts and other clients. In some cases, you can hooks
to enforce synchronous execution.
events are delivered to scripts and other clients. In some cases, you can use
hooks to enforce synchronous execution.
All events can have the following fields:
@@ -2559,7 +2564,7 @@ Property list
is unavailable if no video is active.
When setting this property in the fullscreen or maximized state, the behavior
is the same as window-scale. In all ther cases, setting the value of this
is the same as window-scale. In all other cases, setting the value of this
property will always resize the window. This does not affect the value of
``window-scale``.
@@ -2652,6 +2657,10 @@ Property list
Any of these properties may be unavailable or set to dummy values if the
VO window is not created or visible.
``window-id``
Read-only - mpv's window id. May not always be available, i.e due to window
not being opened yet or not being supported by the VO.
``mouse-pos``
Read-only - last known mouse position, normalizd to OSD dimensions.
@@ -2671,8 +2680,6 @@ Property list
stripped. If the subtitle is not text-based (i.e. DVD/BD subtitles), an
empty string is returned.
This property is experimental and might be removed in the future.
``sub-text-ass``
Like ``sub-text``, but return the text in ASS format. Text subtitles in
other formats are converted. For native ASS subtitles, events that do
@@ -2684,8 +2691,6 @@ Property list
header and per-event metadata are not returned. You likely need to do
further filtering on the returned string to make it useful.
This property is experimental and might be removed in the future.
``secondary-sub-text``
Same as ``sub-text``, but for the secondary subtitles.
@@ -2706,6 +2711,9 @@ Property list
``secondary-sub-end``
Same as ``sub-end``, but for the secondary subtitles.
``sub-forced-only-cur``
Read-only - whether the current subtitle track is being shown in forced-only mode.
``playlist-pos`` (RW)
Current position on playlist. The first entry is on position 0. Writing to
this property may start playback at the new position.
@@ -2786,9 +2794,10 @@ Property list
entry, ``no``/false or unavailable otherwise.
``playlist/N/title``
Name of the Nth entry. Only available if the playlist file contains
such fields, and only if mpv's parser supports it for the given
playlist format.
Name of the Nth entry. Available if the playlist file contains
such fields and mpv's parser supports it for the given
playlist format, or if the playlist entry has been opened before and a
media-title other then then filename has been acquired.
``playlist/N/id``
Unique ID for this entry. This is an automatically assigned integer ID
@@ -2858,6 +2867,10 @@ Property list
``yes``/true if the track has the forced flag set in the file,
``no``/false or unavailable otherwise.
``track-list/N/auto-forced-only``
``yes``/true if the track was autoselected in forced-only mode,
``no``/false or unavailable otherwise.
``track-list/N/codec``
The codec name used by this track, for example ``h264``. Unavailable
in some rare cases.
@@ -3249,6 +3262,24 @@ Property list
(There is no way to ensure synchronization if two scripts try to update the
same key at the same time.)
``user-data`` (RW)
This is a recursive key/value map of arbitrary nodes shared between clients for
general use (i.e. scripts, IPC clients, host applications, etc).
The player itself does not use any data in it (although some builtin scripts may).
The property is not preserved across player restarts.
This is a more powerful replacement for ``shared-script-properties``.
Sub-paths can be accessed directly; e.g. ``user-data/my-script/state/a`` can be
read, written, or observed.
The top-level object itself cannot be written directly; write to sub-paths instead.
Converting this property or its sub-properties to strings will give a JSON
representation. If converting a leaf-level object (i.e. not a map or array)
and not using raw mode, the underlying content will be given (e.g. strings will be
printed directly, rather than quoted and JSON-escaped).
``working-directory``
The working directory of the mpv process. Can be useful for JSON IPC users,
because the command line player usually works with relative paths.
@@ -3304,8 +3335,9 @@ Property list
might contain either a release version, or just a git hash.
``mpv-configuration``
The configuration arguments which were passed to the build system
(typically the way ``./waf configure ...`` was invoked).
The configuration arguments that were passed to the build system. If the
meson version used to compile mpv is older than 1.1.0, then a hardcoded
string of a few, arbitrary options is displayed instead.
``ffmpeg-version``
The contents of the ``av_version_info()`` API call. This is a string which
@@ -3319,6 +3351,12 @@ Property list
somewhat weird form (apparently "hex BCD"), indicating the release version
of the libass library linked to mpv.
``platform``
Returns a string describing what target platform mpv was built for. The value
of this is dependent on what the underlying build system detects. Some of the
most common values are: ``windows``, ``darwin`` (macos or ios), ``linux``,
``android``, and ``freebsd``. Note that this is not a complete listing.
``options/<name>`` (RW)
The value of option ``--<name>``. Most options can be changed at runtime by
writing to this property. Note that many options require reloading the file
+2 -2
View File
@@ -193,8 +193,8 @@ And this is the completion:
{"request_id":123,"error":"success","data":null}
By design, you will not get a confirmation that the command was started. If a
command is long running, sending the message will lead to any reply until much
later when the command finishes.
command is long running, sending the message will not lead to any reply until
much later when the command finishes.
Some commands execute synchronously, but these will behave like asynchronous
commands that finished execution immediately.
+2
View File
@@ -95,6 +95,8 @@ success, ``error`` is empty string on success.
``mp.abort_async_command(id)``
``mp.del_property(name)`` (LE)
``mp.get_property(name [,def])`` (LE)
``mp.get_property_osd(name [,def])`` (LE)
+7 -1
View File
@@ -70,7 +70,7 @@ consists of multiple source files, or requires other files (you can use
``mp.get_script_directory()`` to get the location and e.g. load data files).
Making a script a git repository, basically a repository which contains a
``main.lua``` file in the root directory, makes scripts easily updateable
``main.lua`` file in the root directory, makes scripts easily updateable
(without the dangers of auto-updates). Another suggestion is to use git
submodules to share common files or libraries.
@@ -199,6 +199,12 @@ The ``mp`` module is preloaded, although it can be loaded manually with
Whether this works and how long it takes depends on the command and the
situation. The abort call itself is asynchronous. Does not return anything.
``mp.del_property(name [,def])``
Delete the given property. See ``mp.get_property`` and `Properties`_ for more
information about properties. Most properties cannot be deleted.
Returns true on success, or ``nil, error`` on error.
``mp.get_property(name [,def])``
Return the value of the given property as string. These are the same
properties as used in input.conf. See `Properties`_ for a list of
+64 -22
View File
@@ -461,6 +461,10 @@ Name Meaning
``~~desktop/`` the path to the desktop (win32, macOS)
``~~exe_dir/`` win32 only: the path to the directory containing the exe (for
config file purposes; ``$MPV_HOME`` overrides it)
``~~cache/`` the path to application cache data (``~/.cache/mpv/``)
On some platforms, this will be the same as ``~~home/``.
``~~state/`` the path to application state data (``~/.local/state/mpv/``)
On some platforms, this will be the same as ``~~home/``.
``~~old_home/`` do not use
================ ===============================================================
@@ -793,9 +797,10 @@ Conditional auto profiles
Profiles which have the ``profile-cond`` option set are applied automatically
if the associated condition matches (unless auto profiles are disabled). The
option takes a string, which is interpreted as Lua condition. If evaluating the
expression returns true, the profile is applied, if it returns false, it is
ignored. This Lua code execution is not sandboxed.
option takes a string, which is interpreted as Lua expression. If the
expression evaluates as truthy, the profile is applied. If the expression
errors or evaluates as falsy, the profile is not applied. This Lua code
execution is not sandboxed.
Any variables in condition expressions can reference properties. If an
identifier is not already defined by Lua or mpv, it is interpreted as property.
@@ -816,13 +821,13 @@ cause errors if used in expressions. These are logged in verbose mode, and the
expression is considered to be false.
Whenever a property referenced by a profile condition changes, the condition
is re-evaluated. If the return value of the condition changes from false or
error to true, the profile is applied.
is re-evaluated. If the return value of the condition changes from falsy or
error to truthy, the profile is applied.
This mechanism tries to "unapply" profiles once the condition changes from true
to false. If you want to use this, you need to set ``profile-restore`` for the
profile. Another possibility it to create another profile with an inverse
condition to undo the other profile.
This mechanism tries to "unapply" profiles once the condition changes from
truthy to falsy or error. If you want to use this, you need to set
``profile-restore`` for the profile. Another possibility it to create another
profile with an inverse condition to undo the other profile.
Recursive profiles can be used. But it is discouraged to reference other
conditional profiles in a conditional profile, since this can lead to tricky
@@ -839,6 +844,14 @@ and unintuitive behavior.
profile-cond=width >= 1280
hue=-50
Make only videos containing "youtube" or "youtu.be" in their path brighter:
::
[youtube]
profile-cond=path:find('youtu%.?be')
gamma=20
If you want the profile to be reverted if the condition goes to false again,
you can set ``profile-restore``:
@@ -1526,6 +1539,7 @@ input command can take an exit code: in this case, that exit code is returned.
FILES
=====
Note that this section assumes Linux/BSD. On other platforms the paths may be different.
For Windows-specifics, see `FILES ON WINDOWS`_ section.
``/usr/local/etc/mpv/mpv.conf``
@@ -1533,6 +1547,18 @@ For Windows-specifics, see `FILES ON WINDOWS`_ section.
in default configuration will use ``/usr/local/etc/mpv/`` as config
directory, while most Linux distributions will set it to ``/etc/mpv/``).
``~/.cache/mpv``
The standard cache directory. Certain options within mpv may cause it to write
cache files to disk. This can be overridden by environment variables, in
ascending order:
:1: If ``$XDG_CACHE_HOME`` is set, then the derived cache directory
will be ``$XDG_CACHE_HOME/mpv``.
:2: If ``$MPV_HOME`` is set, then the derived cache directory will be
``$MPV_HOME``.
If the directory does not exist, mpv will try to create it automatically.
``~/.config/mpv``
The standard configuration directory. This can be overridden by environment
variables, in ascending order:
@@ -1547,7 +1573,9 @@ For Windows-specifics, see `FILES ON WINDOWS`_ section.
``~/.mpv/``
The original (pre 0.5.0) configuration directory. It will continue to be
read if present.
read if present. If this directory is present and the standard configuration
directory is not present, then cache files and watch later config files will
also be written to this directory.
If both this directory and the standard configuration directory are
present, configuration will be read from both with the standard
@@ -1572,11 +1600,8 @@ For Windows-specifics, see `FILES ON WINDOWS`_ section.
fallback subtitle font
``~/.config/mpv/fonts/``
Font files in this directory are used by mpv/libass for subtitles. Useful
if you do not want to install fonts to your system. Note that files in this
directory are loaded into memory before being used by mpv. If you have a
lot of fonts, consider using fonts.conf (see above) to include additional
fonts, which is more memory-efficient.
Default location for ``--sub-fonts-dir`` (see `Subtitles`_) and
``--osd-fonts-dir`` (see `OSD`_).
``~/.config/mpv/scripts/``
All files in this directory are loaded as if they were passed to the
@@ -1586,11 +1611,18 @@ For Windows-specifics, see `FILES ON WINDOWS`_ section.
See `Script location`_ for details.
``~/.config/mpv/watch_later/``
``~/.local/state/mpv/watch_later/``
Contains temporary config files needed for resuming playback of files with
the watch later feature. See for example the ``Q`` key binding, or the
``quit-watch-later`` input command.
This can be overridden by environment variables, in ascending order:
:1: If ``$XDG_STATE_HOME`` is set, then the derived watch later directory
will be ``$XDG_STATE_HOME/mpv/watch_later``.
:2: If ``$MPV_HOME`` is set, then the derived watch later directory will be
``$MPV_HOME/watch_later``.
Each file is a small config file which is loaded if the corresponding media
file is loaded. It contains the playback position and some (not necessarily
all) settings that were changed during playback. The filenames are hashed
@@ -1621,16 +1653,18 @@ You can find the exact path by running ``echo %APPDATA%\mpv\mpv.conf`` in cmd.ex
Other config files (such as ``input.conf``) are in the same directory. See the
`FILES`_ section above.
The cache directory is located at ``%LOCALAPPDATA%/mpv``.
The environment variable ``$MPV_HOME`` completely overrides these, like on
UNIX.
If a directory named ``portable_config`` next to the mpv.exe exists, all
config will be loaded from this directory only. Watch later config files are
written to this directory as well. (This exists on Windows only and is redundant
with ``$MPV_HOME``. However, since Windows is very scripting unfriendly, a
wrapper script just setting ``$MPV_HOME``, like you could do it on other
systems, won't work. ``portable_config`` is provided for convenience to get
around this restriction.)
config will be loaded from this directory only. Watch later config files and
cache files are written to this directory as well. (This exists on Windows
only and is redundant with ``$MPV_HOME``. However, since Windows is very
scripting unfriendly, a wrapper script just setting ``$MPV_HOME``, like you
could do it on other systems, won't work. ``portable_config`` is provided for
convenience to get around this restriction.)
Config files located in the same directory as ``mpv.exe`` are loaded with
lower priority. Some config files are loaded only once, which means that
@@ -1644,3 +1678,11 @@ future.
Note that mpv likes to mix ``/`` and ``\`` path separators for simplicity.
kernel32.dll accepts this, but cmd.exe does not.
FILES ON MACOS
==============
On macOS the watch later directory is located at ``~/.config/mpv/watch_later/``
and the cache directory is set to ``~/Library/Caches/io.mpv/``. These directories
can't be overwritten by enviroment variables.
Everything else is the same as `FILES`_.
+310 -111
View File
@@ -5,10 +5,14 @@ Track Selection
---------------
``--alang=<languagecode[,languagecode,...]>``
Specify a priority list of audio languages to use. Different container
formats employ different language codes. DVDs use ISO 639-1 two-letter
language codes, Matroska, MPEG-TS and NUT use ISO 639-2 three-letter
language codes, while OGM uses a free-form identifier. See also ``--aid``.
Specify a priority list of audio languages to use, as IETF language tags.
Equivalent ISO 639-1 two-letter and ISO 639-2 three-letter codes are treated the same.
The first tag in the list whose language matches a track in the file will be used.
A track that matches more subtags will be preferred over one that matches fewer,
with preference given to earlier subtags over later ones. See also ``--aid``.
The special value "auto" can be included anywhere in the list,
and is equivalent to the user's OS-level list of preferred languages.
This is a string list option. See `List Options`_ for details.
@@ -20,10 +24,7 @@ Track Selection
audio.
``--slang=<languagecode[,languagecode,...]>``
Specify a priority list of subtitle languages to use. Different container
formats employ different language codes. DVDs use ISO 639-1 two letter
language codes, Matroska uses ISO 639-2 three letter language codes while
OGM uses a free-form identifier. See also ``--sid``.
Equivalent to ``--alang``, for subtitle tracks (default: auto).
This is a string list option. See `List Options`_ for details.
@@ -33,6 +34,8 @@ Track Selection
a DVD and falls back on English if Hungarian is not available.
- ``mpv --slang=jpn example.mkv`` plays a Matroska file with Japanese
subtitles.
- ``mpv --slang=pt-BR example.mkv`` plays a Matroska file with Brazilian
Portuguese subtitles if available, and otherwise any Portuguese subtitles.
``--vlang=<...>``
Equivalent to ``--alang`` and ``--slang``, for video tracks.
@@ -136,9 +139,17 @@ Track Selection
referenced tracks are always selected.
``--subs-with-matching-audio=<yes|no>``
When autoselecting a subtitle track, select a non-forced one even if the selected
audio stream matches your preferred subtitle language (default: yes). Disable this
if you'd like to only show subtitles for foreign audio or onscreen text.
When autoselecting a subtitle track, select a full/non-forced one even if the selected
audio stream matches your preferred subtitle language (default: no).
``--subs-fallback=<yes|default|no>``
When autoselecting a subtitle track, if no tracks match your preferred languages,
select a full track even if it doesn't match your preferred subtitle language (default: no).
Setting this to `default` means that only streams flagged as `default` will be selected.
``--subs-fallback-forced=<yes|no>``
When autoselecting a subtitle track, if no tracks match your preferred languages,
select a forced track that matches the language of the selected audio track (default: yes).
Playback Control
@@ -260,7 +271,7 @@ Playback Control
The way older versions of mpv played playlist files via ``--playlist``
was not safe against maliciously constructed files. Such files may
trigger harmful actions. This has been the case for all verions of
trigger harmful actions. This has been the case for all versions of
mpv prior to 0.31.0, and all MPlayer versions, but unfortunately this
fact was not well documented earlier, and some people have even
misguidedly recommended the use of ``--playlist`` with untrusted
@@ -708,9 +719,9 @@ Program Behavior
Print version string and exit.
``--no-config``
Do not load default configuration files. This prevents loading of both the
user-level and system-wide ``mpv.conf`` and ``input.conf`` files. Other
configuration files are blocked as well, such as resume playback files.
Do not load default configuration or any user files. This prevents loading of
both the user-level and system-wide ``mpv.conf`` and ``input.conf`` files. Other
user files are blocked as well, such as resume playback files and cache files.
.. note::
@@ -1015,8 +1026,9 @@ Watch Later
``--watch-later-directory=<path>``
The directory in which to store the "watch later" temporary files.
The default is a subdirectory named "watch_later" underneath the
config directory (usually ``~/.config/mpv/``).
If this option is unset, the files will be stored in a subdirectory
named "watch_later" underneath the local state directory
(usually ``~/.local/state/mpv/``).
``--no-resume-playback``
Do not restore playback position from the ``watch_later`` configuration
@@ -1032,8 +1044,8 @@ Watch Later
``--watch-later-options=option1,option2,...``
The options that are saved in "watch later" files if they have been changed
since when mpv started. These values will be restored the next time the
files are played. The playback position is always saved as ``start``, so
adding ``start`` to this list has no effect.
files are played. Note that the playback position is saved via the ``start``
option.
When removing options, existing watch later data won't be modified and will
still be applied fully, but new watch later data won't contain these
@@ -1049,8 +1061,7 @@ Watch Later
``--watch-later-options-remove=mute``
The volume and mute state won't be saved to watch later files.
- ``--watch-later-options-clr``
No option will be saved to watch later files except the starting
position.
No option will be saved to watch later files.
``--write-filename-in-watch-later-config``
Prepend the watch later config files with the name of the file they refer
@@ -1174,7 +1185,7 @@ Video
``--display-fps=<fps>``
Deprecated alias for ``--override-display-fps``.
``--hwdec=<api>``
``--hwdec=<api1,api2,...|no|auto|auto-safe|auto-copy>``
Specify the hardware video decoding API that should be used if possible.
Whether hardware decoding is actually done depends on the video codec. If
hardware decoding is not possible, mpv will fall back on software decoding.
@@ -1189,7 +1200,7 @@ Video
.. note::
Use the ``Ctrl+h`` shortcut to toggle hardware decoding at runtime. It
toggles this option between ``auto`` and ``no``.
toggles this option between ``auto-safe`` and ``no``.
If you decide you want to use hardware decoding by default, the general
recommendation is to try out decoding with the command line option, and
@@ -1233,14 +1244,21 @@ Video
- If you're a developer, or want to perform elaborate tests, you may
need any of the other possible option values.
``<api>`` can be one of the following:
This option accepts a comma delimited list of ``api`` types, along with certain
special values:
:no: always use software decoding (default)
:auto: forcibly enable any hw decoder found (see below)
:yes: exactly the same as ``auto``
:auto-safe: enable any whitelisted hw decoder (see below)
:auto: forcibly enable any hw decoder found (see below)
:yes: exactly the same as ``auto-safe``
:auto-copy: enable best hw decoder with copy-back (see below)
.. note::
Special values can be mixed with api names. eg: ``vaapi,auto`` will try
and use the ``vaapi`` hwdec, and if that fails, will run through the
normal ``auto`` logic.
Actively supported hwdecs:
:d3d11va: requires ``--vo=gpu`` with ``--gpu-context=d3d11`` or
@@ -1254,7 +1272,9 @@ Video
:nvdec: requires ``--vo=gpu`` (Any platform CUDA is available)
:nvdec-copy: copies video back to system RAM (Any platform CUDA is available)
:drm: requires ``--vo=gpu`` (Linux only)
:drm-copy: copies video back to system RAM (Linux ony)
:drm-copy: copies video back to system RAM (Linux only)
:vulkan: requires ``--vo=gpu-next`` (Any platform with Vulkan Video Decoding)
:vulkan-copy: copies video back to system RAM (Any platform with Vulkan Video Decoding)
Other hwdecs (only use if you know you have to):
@@ -1310,7 +1330,8 @@ Video
.. note::
Most non-copy methods only work with the OpenGL GPU backend. Currently,
only the ``vaapi``, ``nvdec`` and ``cuda`` methods work with Vulkan.
only the ``vaapi``, ``nvdec``, ``cuda`` and ``vulkan`` methods work with
Vulkan.
The ``vaapi`` mode, if used with ``--vo=gpu``, requires Mesa 11, and most
likely works with Intel and AMD GPUs only. It also requires the opengl EGL
@@ -1701,8 +1722,8 @@ Video
support this, then it will be treated as ``cpu``, regardless of the setting.
Currently, only ``gpu-next`` supports film grain application.
``--vd-lavc-dr=<yes|no>``
Enable direct rendering (default: yes). If this is set to ``yes``, the
``--vd-lavc-dr=<auto|yes|no>``
Enable direct rendering (default: auto). If this is set to ``yes``, the
video will be decoded directly to GPU video memory (or staging buffers).
This can speed up video upload, and may help with large resolutions or
slow hardware. This works only with the following VOs:
@@ -1710,6 +1731,10 @@ Video
- ``gpu``: requires at least OpenGL 4.4 or Vulkan.
- ``libmpv``: The libmpv render API has optional support.
The ``auto`` option will try to guess whether DR can improve performance
on your particular hardware. Currently this enables it on AMD or NVIDIA
if using OpenGL or unconditionally if using Vulkan.
Using video filters of any kind that write to the image data (or output
newly allocated frames) will silently disable the DR code path.
@@ -1843,10 +1868,10 @@ Audio
Enable exclusive output mode. In this mode, the system is usually locked
out, and only mpv will be able to output audio.
This only works for some audio outputs, such as ``wasapi`` and
``coreaudio``. Other audio outputs silently ignore this options. They either
have no concept of exclusive mode, or the mpv side of the implementation is
missing.
This only works for some audio outputs, such as ``wasapi``, ``coreaudio``
and ``pipewire``. Other audio outputs silently ignore this option.
They either have no concept of exclusive mode, or the mpv side of the
implementation is missing.
``--audio-fallback-to-null=<yes|no>``
If no audio device can be opened, behave as if ``--ao=null`` was given. This
@@ -2901,6 +2926,15 @@ Subtitles
name does not match, it may prefer not to render any text that uses the
missing font.)
``--sub-fonts-dir=<path>``
Font files in this directory are used by mpv/libass for subtitles. Useful
if you do not want to install fonts to your system. Note that files in this
directory are loaded into memory before being used by mpv. If you have a
lot of fonts, consider using fonts.conf (see `FILES`_ section) to include
additional mpv user settings.
If this option is not specified, ``~~/fonts`` will be used by default.
Window
------
@@ -3051,6 +3085,15 @@ Window
``--snap-window``
(Windows only) Snap the player window to screen edges.
``--drag-and-drop=<no|auto|replace|append>``
(X11, Wayland and Windows only)
Controls the default behavior of drag and drop on platforms that support this.
``auto`` will obey what the underlying os/platform gives mpv. Typically, holding
shift during the drag and drop will append the item to the playlist. Otherwise,
it will completely replace it. ``replace`` and ``append`` always force replacing
and appending to the playlist respectively. ``no`` disables all drag and drop
behavior.
``--ontop``
Makes the player window stay on top of other windows.
@@ -3064,7 +3107,7 @@ Window
:window: On top of all other windows.
:system: On top of system elements like Taskbar, Menubar and Dock.
:desktop: On top of the Dekstop behind windows and Desktop icons.
:desktop: On top of the Desktop behind windows and Desktop icons.
:level: A level as integer.
``--focus-on-open``, ``--no-focus-on-open``
@@ -3103,7 +3146,7 @@ Window
Generally only supported by GUI VOs. Ignored for encoding.
.. admonition: Note (macOS)
.. admonition:: Note (macOS)
On macOS, the origin of the screen coordinate system is located on the
bottom-left corner. For instance, ``0:0`` will place the window at the
@@ -3222,9 +3265,9 @@ Window
``--window-minimized`` for further remarks.
``--cursor-autohide=<number|no|always>``
Make mouse cursor automatically hide after given number of milliseconds.
``no`` will disable cursor autohide. ``always`` means the cursor will stay
hidden.
Make mouse cursor automatically hide after given number of milliseconds
(default: 1000 ms). ``no`` will disable cursor autohide. ``always``
means the cursor will stay hidden.
``--cursor-autohide-fs-only``
If this option is given, the cursor is always visible in windowed mode. In
@@ -3243,11 +3286,24 @@ Window
depending on GPU drivers and hardware. For other VOs, this just makes
rendering slower.
``--force-render``
Forces mpv to always render frames regardless of the visibility of the
window. Currently only affects X11 and Wayland VOs since they are the
only ones that have this optimization (i.e. everything else always renders
regardless of visibility).
``--force-window-position``
Forcefully move mpv's video output window to default location whenever
there is a change in video parameters, video stream or file. This used to
be the default behavior. Currently only affects X11 VOs.
``--auto-window-resize=<yes|no>``
(Wayland, Win32, and X11)
By default, mpv will automatically resize itself if the video's size changes
(i.e. advancing forward in a playlist). Setting this to ``no`` disables this
behavior so the window size never changes automatically. This option does
not have any impact on the ``--autofit`` or ``--geometry`` options.
``--no-keepaspect``, ``--keepaspect``
``--no-keepaspect`` will always stretch the video to window size, and will
disable the window manager hints that force the window aspect ratio.
@@ -3276,8 +3332,7 @@ Window
(macOS, Windows, X11, and Wayland only)
Scale the window size according to the backing scale factor (default: yes).
On regular HiDPI resolutions the window opens with double the size but appears
as having the same size as on non-HiDPI resolutions. This is enabled by
default on macOS.
as having the same size as on non-HiDPI resolutions.
``--native-fs``, ``--no-native-fs``
(macOS only)
@@ -3312,8 +3367,9 @@ Window
draw directly on the root window.
On win32, the ID is interpreted as ``HWND``. Pass it as value cast to
``intptr_t``. mpv will create its own window, and set the wid window as
parent, like with X11.
``uint32_t`` (all Windows handles are 32-bit), this is important as mpv will
not accept negative values. mpv will create its own window and set the
wid window as parent, like with X11.
On macOS/Cocoa, the ID is interpreted as ``NSView*``. Pass it as value cast
to ``intptr_t``. mpv will create its own sub-view. Because macOS does not
@@ -3328,7 +3384,7 @@ Window
``--no-window-dragging``
Don't move the window when clicking on it and moving the mouse pointer.
``--x11-name``
``--x11-name=<string>``
Set the window class name for X11-based video output methods.
``--x11-netwm=<yes|no|auto>``
@@ -3813,6 +3869,33 @@ Demuxer
(This value tends to be fuzzy, because many file formats don't store linear
timestamps.)
``--demuxer-hysteresis-secs=<seconds>``
Once the ``--demuxer-max-bytes`` limit is reached, this value can be used
to specify a hysteresis before the demuxer will buffer ahead again. This
specifies the maximum number of seconds from the current playback position
that needs to be remaining in the cache before the demuxer will continue
buffering ahead.
For example, with a value of 10 seconds specified, the demuxer will buffer
ahead up to ``--demuxer-max-bytes`` and won't start buffering ahead again
until there is only 10 seconds of content left in the cache. When the
demuxer starts buffering ahead again, it will buffer ahead up to
``--demuxer-max-bytes`` and stop until there's only 10 seconds of content
remaining in the cache, and so on.
This can provide significant power savings and reduce load by making the
demuxer only buffer ahead in chunks at a time rather than buffering ahead
nonstop to keep the cache filled.
If you want to save power and reduce load, configure this to a small number
that's much lower than ``--cache-secs`` or ``--demuxer-readahead-secs``.
If it takes a long time to buffer anything at all for a given stream (like
when reading from a very slow disk is involved), then the hysteresis value
should be larger to compensate.
The default value is 0 seconds, which disables the caching hysteresis. A
value of 10 seconds probably works well for most usecases.
``--prefetch-playlist=<yes|no>``
Prefetch next playlist entry while playback of the current entry is ending
(default: no).
@@ -3862,6 +3945,13 @@ Demuxer
libarchive opens all volumes anyway when playing the main file, even though
mpv iterated no archive entries yet.
``--directory-mode=<recursive|lazy|ignore>``
When opening a directory, open subdirectories recursively, lazily or not at
all (default: recursive).
Values other then ``recursive`` can lead to problems with resuming playlists
(`RESUMING PLAYBACK`_) and possibly other things.
Input
-----
@@ -3977,6 +4067,12 @@ Input
driver. Necessary to use the OSC, or to select the buttons in DVD menus.
Support depends on the VO in use.
``--input-cursor-passthrough``, ``--no-input-cursor-passthrough``
(X11 and Wayland only)
Tell the backend windowing system to allow pointer events to passthrough
the mpv window. This allows windows under mpv to instead receive pointer
events as if the mpv window was never there.
``--input-media-keys=<yes|no>``
On systems where mpv can choose between receiving media keys or letting
the system handle them - this option controls whether mpv should receive
@@ -4219,6 +4315,9 @@ OSD
See ``--sub-font-provider`` for details and accepted values. Note that
unlike subtitles, OSD never uses embedded fonts from media files.
``--osd-fonts-dir=<path>``
See ``--sub-fonts-dir`` for details. Defaults to ``~~/fonts``.
Screenshot
----------
@@ -4232,13 +4331,14 @@ Screenshot
:jpeg: JPEG (alias for jpg)
:webp: WebP
:jxl: JPEG XL
:avif: AVIF
``--screenshot-tag-colorspace=<yes|no>``
Tag screenshots with the appropriate colorspace.
Tag screenshots with the appropriate colorspace (default: yes).
Note that not all formats are supported.
Default: ``no``.
Note that not all formats support this. When it is unsupported, or when
this option is disabled, screenshots will be converted to sRGB before
being written.
``--screenshot-high-bit-depth=<yes|no>``
If possible, write screenshots with a bit depth similar to the source
@@ -4385,22 +4485,50 @@ Screenshot
``--screenshot-jxl-effort=<1-9>``
Set the JPEG XL compression effort. Higher effort (usually) means better
compression, but takes more CPU time. The default is 3.
compression, but takes more CPU time. The default is 4.
``--screenshot-avif-encoder=<encoder>``
Specify the AV1 encoder to be used by libavcodec for encoding avif
screenshots.
Default: ``libaom-av1``
``--screenshot-avif-pixfmt=<format>``
Specify the pixel format to the libavcodec encoder.
Default: ``yuv420p``
``--screenshot-avif-opts=key1=value1,key2=value2,...``
Specifies libavcodec options for selected encoder. For more information,
consult the FFmpeg documentation.
Default: ``usage=allintra,crf=32,cpu-used=8,tune=ssim``
Note: the default is only guaranteed to work with the libaom-av1 encoder.
Above options may not be valid and or optimal for other encoders.
This is a key/value list option. See `List Options`_ for details.
.. admonition:: Example
"``--screenshot-avif-opts=crf=32,aq-mode=complexity``"
sets the crf to 32 and quantization (aq-mode) to complexity based.
``--screenshot-sw=<yes|no>``
Whether to use software rendering for screenshots (default: no).
If set to no, the screenshot will be rendered by the current VO if possible
(only vo_gpu currently). The advantage is that this will (probably) always
If set to no, the screenshot will be rendered by the current VO (only vo_gpu
or vo_gpu_next currently). The advantage is that this will (probably) always
show up as in the video window, because the same code is used for rendering.
But since the renderer needs to be reinitialized, this can be slow and
interrupt playback. (Unless the ``window`` mode is used with the
``screenshot`` command.)
interrupt playback.
If set to yes, the software scaler is used to convert the video to RGB (or
whatever the target screenshot requires). In this case, conversion will
run in a separate thread and will probably not interrupt playback. The
software renderer may lack some capabilities, such as HDR rendering.
If ``window`` mode is used, the image will also be scaled in software
which may not accurately reflect the actual visible result.
Software Scaler
---------------
@@ -4715,8 +4843,6 @@ Cache
This makes sense only with ``--cache``. If the normal cache is disabled,
this option is ignored.
You need to set ``--cache-dir`` to use this.
The cache file is append-only. Even if the player appears to prune data, the
file space freed by it is not reused. The cache file is deleted when
playback is closed.
@@ -4739,7 +4865,8 @@ Cache
continue to use the cache file that was opened first.
``--cache-dir=<path>``
Directory where to create temporary files (default: none).
Directory where to create temporary files. Cache is stored in the system's
cache directory (usually ``~/.cache/mpv``) if this is unset.
Currently, this is used for ``--cache-on-disk`` only.
@@ -5573,13 +5700,19 @@ them.
``--wayland-app-id=<string>``
Set the client app id for Wayland-based video output methods (default: ``mpv``).
``--wayland-configure-bounds=<yes|no>``
``--wayland-configure-bounds=<auto|yes|no>``
Controls whether or not mpv opts into the configure bounds event if sent by the
compositor (default: yes). This restricts the initial size of the mpv window to
compositor (default: auto). This restricts the initial size of the mpv window to
a certain maximum size intended by the compositor. In most cases, this simply
just prevents the mpv window from being larger than the size of the monitor when
it first renders. This option will take precedence over any ``autofit`` or
``geometry`` type settings if the configure bounds are used.
it first renders. With the default value of ``auto``, configure-bounds will
silently be ignored if any ``autofit`` or ``geometry`` type option is also set.
``--wayland-content-type=<auto|none|photo|video|game>``
If supported by the compositor, mpv will send a hint using the content-type
protocol telling the compositor what type of content is being displayed. ``auto``
(default) will automatically switch between telling the compositor the content
is a photo, video or possibly none depending on internal heuristics.
``--wayland-disable-vsync=<yes|no>``
Disable mpv's internal vsync for Wayland-based video output (default: no).
@@ -5587,7 +5720,7 @@ them.
``video-sync=display-desync``, ``--no-audio``, and ``--untimed=yes``.
``--wayland-edge-pixels-pointer=<value>``
Defines the size of an edge border (default: 10) to initiate client side
Defines the size of an edge border (default: 16) to initiate client side
resize events in the wayland contexts with the mouse. This is only active if
there are no server side decorations from the compositor.
@@ -5895,6 +6028,12 @@ them.
remaining quantization artifacts. Higher numbers add more noise. (Default
48)
``--corner-rounding=<0..1>``
If set to a value above 0.0, the output will be rendered with rounded
corners, as if an alpha transparency mask had been applied. The value
indicates the relative fraction of the side length to round - a value of
1.0 rounds the corners as much as possible. (``--vo=gpu-next`` only)
``--sharpen=<value>``
If set to a value other than 0, enable an unsharp masking filter. Positive
values will sharpen the image (but add more ringing and aliasing). Negative
@@ -6042,7 +6181,7 @@ them.
``<material>`` can be one of the following:
:titlebar: The standard macOS titel bar material.
:titlebar: The standard macOS title bar material.
:selection: The standard macOS selection material.
:menu: The standard macOS menu material. (macOS 10.11+)
:popover: The standard macOS popover material. (macOS 10.11+)
@@ -6140,7 +6279,7 @@ them.
d3d11
Win32, with native Direct3D 11 rendering.
x11
X11/GLX
X11/GLX (deprecated/legacy, EGL is preferred these days)
x11vk
VK_KHR_xlib_surface
wayland
@@ -6349,6 +6488,15 @@ them.
In such a configuration, we highly recommend setting ``--tone-mapping``
to ``mobius`` or even ``clip``.
``--target-contrast=<auto|10-1000000|inf>``
Specifies the measured contrast of the output display. ``--target-contrast``
in conjunction with ``--target-peak`` value is used to calculate display
black point. Used in black point compensation during HDR tone-mapping.
``auto`` is the default and assumes 1000:1 contrast as a typical SDR display
would have or an infinite contrast when HDR ``--target-trc`` is used.
``inf`` contrast specifies display with perfect black level, in practice OLED.
(Only for ``--vo=gpu-next``)
``--target-lut=<file>``
Specifies a custom LUT file (in Adobe .cube format) to apply to the colors
before display on-screen. This LUT is fed values in normalized RGB, after
@@ -6399,6 +6547,15 @@ them.
HDR<->SDR mapping specified in ITU-R Report BT.2446, method A. This is
the recommended curve for well-mastered content. (``--vo=gpu-next``
only)
st2094-40
Dynamic HDR10+ tone-mapping method specified in SMPTE ST2094-40 Annex
B. In the absence of metadata, falls back to a fixed spline matched to
the input/output average brightness characteristics. (``--vo=gpu-next``
only)
st2094-10
Dynamic tone-mapping method specified in SMPTE ST2094-10 Annex B.2.
Conceptually simpler than ST2094-40, and generally produces worse
results.
``--tone-mapping-param=<value>``
Set tone mapping parameters. By default, this is set to the special string
@@ -6429,16 +6586,13 @@ them.
Specifies the scale factor to use while stretching. Defaults to 1.0.
spline
Specifies the knee point (in PQ space). Defaults to 0.30.
st2094-10
Specifies the contrast (slope) at the knee point. Defaults to 1.0.
``--inverse-tone-mapping``
If set, allows inverse tone mapping (expanding SDR to HDR). Not supported
by all tone mapping curves. Use with caution. (``--vo=gpu-next`` only)
``--tone-mapping-crosstalk=<0.0..0.30>``
If nonzero, apply an extra crosstalk matrix before tone mapping. Can help
improve the appearance of strongly saturated monochromatic highlights.
(Default: 0.04, only affects ``--vo=gpu-next``)
``--tone-mapping-max-boost=<1.0..10.0>``
Upper limit for how much the tone mapping algorithm is allowed to boost
the average brightness by over-exposing the image. The default value of 1.0
@@ -6470,6 +6624,16 @@ them.
reductions to account for brightness-related perceptual nonuniformity.
(``--vo=gpu-next`` only)
``--tone-mapping-visualize``
Display a (PQ-PQ) graph of the active tone-mapping LUT. Intended only for
debugging purposes. The X axis shows PQ input values, the Y axis shows PQ
output values. The tone-mapping curve is shown in green/yellow. Yellow
means the brightness has been boosted from the source, dark blue regions
show where the brightness has been reduced. The extra colored regions and
lines indicate various monitor limits, as well a reference diagonal
(neutral tone-mapping) and source scene average brightness information (if
available). (``--vo=gpu-next`` only)
``--gamut-mapping-mode``
Specifies the algorithm used for reducing the gamut of images for the
target display, after any tone mapping is done.
@@ -6477,16 +6641,36 @@ them.
auto
Choose the best mode automatically. (Default)
clip
Hard-clip to the gamut (per-channel).
warn
Simply highlight out-of-gamut pixels.
desaturate
Chromatically desaturate out-of-gamut colors towards white.
darken
Linearly darken the entire image, then clip to the color volume. Unlike
``clip``, this does not destroy detail in saturated regions, but comes
at the cost of sometimes significantly lowering output brightness.
Hard-clip to the gamut (per-channel). Very low quality, but free.
perceptual
Performs a perceptually balanced gamut mapping using a soft knee
function to roll-off clipped regions, and a hue shifting function to
preserve saturation. (``--vo=gpu-next`` only)
relative
Performs relative colorimetric clipping, while maintaining an
exponential relationship between brightness and chromaticity.
(``--vo=gpu-next`` only)
saturation
Performs simple RGB->RGB saturation mapping. The input R/G/B channels
are mapped directly onto the output R/G/B channels. Will never clip,
but will distort all hues and/or result in a faded look.
(``--vo=gpu-next`` only)
absolute
Performs absolute colorimetric clipping. Like ``relative``, but does
not adapt the white point. (``--vo=gpu-next`` only)
desaturate
Performs constant-luminance colorimetric clipping, desaturing colors
towards white until they're in-range.
darken
Uniformly darkens the input slightly to prevent clipping on blown-out
highlights, then clamps colorimetrically to the input gamut boundary,
biased slightly to preserve chromaticity over luminance.
(``--vo=gpu-next`` only)
warn
Performs no gamut mapping, but simply highlights out-of-gamut pixels.
linear
Linearly/uniformly desaturates the image in order to bring the entire
image into the target gamut. (``--vo=gpu-next`` only)
``--hdr-compute-peak=<auto|yes|no>``
Compute the HDR peak and frame average brightness per-frame instead of
@@ -6530,6 +6714,18 @@ them.
aggressive, up to the limit of the high threshold (at which point the
filter becomes instant).
``--hdr-contrast-recovery=<0.0..2.0>``, ``--hdr-contrast-smoothness=<1.0..100.0>``
Enables the HDR contrast recovery algorithm, which is to designed to
enhance contrast of HDR video after tone mapping. The strength (default:
0.0) indicates the degree of contrast recovery, with 0.0 being completely
disabled and 1.0 being 100% strength. Values higher than 1.0 are allowed,
but may result in excessive sharpening. The smoothness (default: 3.5)
indicates the degree to which the HDR source is low-passed in order to
obtain contrast information - a value of 2.0 corresponds to 2x downscaling.
Users on low DPI displays (<= 100) may want to lower this value, while
users on very high DPI displays ("retina") may want to increase it. (Only
for ``vo=gpu-next``)
``--use-embedded-icc-profile``
Load the embedded ICC profile contained in media files such as PNG images.
(Default: yes). Note that this option only works when also using a display
@@ -6551,15 +6747,20 @@ them.
Applications using libmpv with the render API need to provide the ICC
profile via ``MPV_RENDER_PARAM_ICC_PROFILE``.
``--icc-cache-dir=<dirname>``
Store and load the 3D LUTs created from the ICC profile in this directory.
This can be used to speed up loading, since LittleCMS 2 can take a while to
create a 3D LUT. Note that these files contain uncompressed LUTs. Their
size depends on the ``--icc-3dlut-size``, and can be very big.
``--icc-cache``
Store and load 3D LUTs created from the ICC profile on disk in the
cache directory (Default: ``yes``). This can be used to speed up loading,
since LittleCMS 2 can take a while to create a 3D LUT. Note that these
files contain uncompressed LUTs. Their size depends on the
``--icc-3dlut-size``, and can be very big.
NOTE: This is not cleaned automatically, so old, unused cache files may
stick around indefinitely.
``--icc-cache-dir``
The directory where icc cache is stored. Cache is stored in the system's
cache directory (usually ``~/.cache/mpv``) if this is unset.
``--icc-intent=<value>``
Specifies the ICC intent used for the color transformation (when using
``--icc-profile``).
@@ -6587,6 +6788,9 @@ them.
value ``inf`` causes the BT.1886 curve to be treated as a pure power gamma
2.4 function.
``--icc-use-luma``
Use ICC profile luminance value. (Only for ``--vo=gpu-next``)
``--lut=<file>``
Specifies a custom LUT (in Adobe .cube format) to apply to the colors
as part of color conversion. The exact interpretation depends on the value
@@ -6692,16 +6896,20 @@ them.
This option might be silently removed in the future.
``--gpu-shader-cache-dir=<dirname>``
Store and load compiled GLSL shaders in this directory. Normally, shader
compilation is very fast, so this is usually not needed. It mostly matters
for GPU APIs that require internally recompiling shaders to other languages,
for example anything based on ANGLE or Vulkan. Enabling this can improve
startup performance on these platforms.
``--gpu-shader-cache``
Store and load compiled GLSL shaders in the cache directory (Default: ``yes``).
Normally, shader compilation is very fast, so this is not usually needed.
It mostly matters for GPU APIs that require internally recompiling shaders to
other languages, for example anything based on ANGLE or Vulkan. Enabling this
can improve startup performance on these platforms.
NOTE: This is not cleaned automatically, so old, unused cache files may
stick around indefinitely.
``--gpu-shader-cache-dir``
The directory where gpu shader cache is stored. Cache is stored in the system's
cache directory (usually ``~/.cache/mpv``) if this is unset.
Miscellaneous
-------------
@@ -6806,6 +7014,15 @@ Miscellaneous
:display-resample-vdrop: Resample audio to match the video. Drop video
frames to compensate for drift.
:display-resample-desync: Like the previous mode, but no A/V compensation.
:display-tempo: Same as ``display-resample``, but apply audio speed
changes to audio filters instead of resampling to avoid
the change in pitch. Beware that some audio filters
don't do well with a speed close to 1. It is recommend
to use a conditional profile to automatically switch to
``display-resample`` when speed gets too close to 1 for
your filter setup. Use (speed * video_speed_correction)
to get the actual playback speed in the condition.
See `Conditional auto profiles`_ for details.
:display-vdrop: Drop or repeat video frames to compensate desyncing
video. (Although it should have the same effects as
``audio``, the implementation is very different.)
@@ -6829,9 +7046,6 @@ Miscellaneous
See ``--interpolation-threshold`` for how this option affects
interpolation.
This is mostly for testing, and the option may be randomly changed in the
future without notice.
``--video-sync-max-video-change=<value>``
Maximum speed difference in percent that is applied to video with
``--video-sync=display-...`` (default: 1). Display sync mode will be
@@ -6844,8 +7058,11 @@ Miscellaneous
25 fps. We consider the pitch change too extreme to allow this behavior
by default. Set this option to a value of ``5`` to enable it.
Note that in the ``--video-sync=display-resample`` mode, audio speed will
additionally be changed by a small amount if necessary for A/V sync. See
Note that ``--video-sync=display-tempo`` avoids this pitch change.
Also note that in the ``--video-sync=display-resample`` or
``--video-sync=display-tempo`` mode, audio speed will additionally be
changed by a small amount if necessary for A/V sync. See
``--video-sync-max-audio-change``.
``--video-sync-max-audio-change=<value>``
@@ -7075,21 +7292,3 @@ Miscellaneous
code is the same.)
Conversion is not applied to metadata that is updated at runtime.
Debugging
---------
``--unittest=<name>``
Run an internal unit test. There are multiple, and the name specifies which.
The special value ``all-simple`` runs all tests which do not need further
setup (other arguments and such). Some tests may need additional arguments
to do anything useful.
On success, the player binary exits with exit status 0, otherwise it returns
with an undefined non-0 exit status (it may crash or abort itself on test
failures).
This is only enabled if built with ``--enable-tests``, and should normally
be enabled and used by developers only.
+1 -1
View File
@@ -174,7 +174,7 @@ Configurable Options
``seekbarhandlesize``
Default: 0.6
Size ratio of the seek handle if ``seekbarstyle`` is set to ``dimaond``
Size ratio of the seek handle if ``seekbarstyle`` is set to ``diamond``
or ``knob``. This is relative to the full height of the seekbar.
``seekbarkeyframes``
+2 -9
View File
@@ -35,13 +35,6 @@ UP Scroll one line up
DOWN Scroll one line down
==== ==================
Font
~~~~
For optimal visual experience, a font with support for many font weights and
monospaced digits is recommended. By default, the open source font
`Source Sans Pro <https://github.com/adobe-fonts/source-sans-pro>`_ is used.
Configuration
-------------
@@ -110,13 +103,13 @@ Configurable Options
Clear data buffers used for drawing graphs when toggling.
``font``
Default: Source Sans Pro
Default: sans-serif
Font name. Should support as many font weights as possible for optimal
visual experience.
``font_mono``
Default: Source Sans Pro
Default: monospace
Font name for parts where monospaced characters are necessary to align
text. Currently, monospaced digits are sufficient.
+8
View File
@@ -141,6 +141,11 @@ Available mpv-only filters are:
For a list of available formats, use ``--vf=format=fmt=help``.
.. note::
Conversion between hardware formats is supported in some cases.
eg: ``cuda`` to ``vulkan``, or ``vaapi`` to ``vulkan``.
``<convert=yes|no>``
Force conversion of color parameters (default: no).
@@ -164,6 +169,9 @@ Available mpv-only filters are:
If input and output video parameters are the same, conversion is always
skipped.
When converting between hardware formats, this parameter has no effect,
and the only conversion that is done is the format conversion.
.. admonition:: Examples
``mpv test.mkv --vf=format:colormatrix=ycgco``
+67 -19
View File
@@ -291,9 +291,12 @@ Available video output drivers are:
or VA API hardware decoding. The driver is designed to avoid any GPU to CPU copies,
and to perform scaling and color space conversion using fixed-function hardware,
if available, rather than GPU shaders. This frees up GPU resources for other tasks.
Currently this driver is experimental and only works with the ``--hwdec=vaapi``
or ``hwdec=drm`` drivers;
OSD is also not supported. Supported compositors : Weston and Sway.
It is highly recommended to use this VO with the appropriate ``--hwdec`` option such
as ``auto-safe``. It can still work in some circumstances without ``--hwdec`` due to
mpv's internal conversion filters, but this is not recommended as it's a needless
extra step. Correct output depends on support from your GPU, drivers, and compositor.
Weston and wlroots-based compositors like Sway and Intel GPUs are known to generally
work.
``vaapi``
Intel VA API video output driver with support for hardware decoding. Note
@@ -383,13 +386,54 @@ Available video output drivers are:
``--vo-tct-256=<yes|no>`` (default: no)
Use 256 colors - for terminals which don't support true color.
``kitty``
Graphical output for the terminal, using the kitty graphics protocol.
Tested with kitty and Konsole.
You may need to use ``--profile=sw-fast`` to get decent performance.
Kitty size and alignment options:
``--vo-kitty-cols=<columns>``, ``--vo-kitty-rows=<rows>`` (default: 0)
Specify the terminal size in character cells, otherwise (0) read it
from the terminal, or fall back to 80x25.
``--vo-kitty-width=<width>``, ``--vo-kitty-height=<height>`` (default: 0)
Specify the available size in pixels, otherwise (0) read it from the
terminal, or fall back to 320x240.
``--vo-kitty-left=<col>``, ``--vo-kitty-top=<row>`` (default: 0)
Specify the position in character cells where the image starts (1 is
the first column or row). If 0 (default) then try to automatically
determine it according to the other values and the image aspect ratio
and zoom.
``--vo-kitty-config-clear=<yes|no>`` (default: yes)
Whether or not to clear the terminal whenever the output is
reconfigured (e.g. when video size changes).
``--vo-kitty-alt-screen=<yes|no>`` (default: yes)
Whether or not to use the alternate screen buffer and return the
terminal to its previous state on exit. When set to no, the last
kitty image stays on screen after quit, with the cursor following it.
``--vo-kitty-use-shm=<yes|no>`` (default: no)
Use shared memory objects to transfer image data to the terminal.
This is much faster than sending the data as escape codes, but is not
supported by as many terminals. It also only works on the local machine
and not via e.g. SSH connections.
This option is not implemented on Windows.
``sixel``
Graphical output for the terminal, using sixels. Tested with ``mlterm`` and
``xterm``.
Note: the Sixel image output is not synchronized with other terminal output
from mpv, which can lead to broken images. The option ``--really-quiet``
can help with that, and is recommended.
Note: the Sixel image output is not synchronized with other terminal
output from mpv, which can lead to broken images.
The option ``--really-quiet`` can help with that, and is recommended.
On some platforms, using the ``--vo-sixel-buffered`` option may work as
well.
You may need to use ``--profile=sw-fast`` to get decent performance.
@@ -433,10 +477,25 @@ Available video output drivers are:
to take into account padding at the report - this only works correctly
when the overall padding per axis is smaller than the number of cells.
``--vo-sixel-exit-clear=<yes|no>`` (default: yes)
Whether or not to clear the terminal on quit. When set to no - the last
``--vo-sixel-config-clear=<yes|no>`` (default: yes)
Whether or not to clear the terminal whenever the output is
reconfigured (e.g. when video size changes).
``--vo-sixel-alt-screen=<yes|no>`` (default: yes)
Whether or not to use the alternate screen buffer and return the
terminal to its previous state on exit. When set to no, the last
sixel image stays on screen after quit, with the cursor following it.
``--vo-sixel-exit-clear`` is a deprecated alias for this option and
may be removed in the future.
``--vo-sixel-buffered=<yes|no>`` (default: no)
Buffers the full output sequence before writing it to the terminal.
On POSIX platforms, this can help prevent interruption (including from
other applications) and thus broken images, but may come at a
performance cost with some terminals and is subject to implementation
details.
Sixel image quality options:
``--vo-sixel-dither=<algo>``
@@ -597,16 +656,6 @@ Available video output drivers are:
Use ``--drm-mode=help`` to get a list of available modes for all active
connectors.
``--drm-atomic=<no|auto>``
Toggle use of atomic modesetting. Mostly useful for debugging.
:no: Use legacy modesetting.
:auto: Use atomic modesetting, falling back to legacy modesetting if
not available. (default)
Note: Only affects ``gpu-context=drm``. ``vo=drm`` supports legacy
modesetting only.
``--drm-draw-plane=<primary|overlay|N>``
Select the DRM plane to which video and OSD is drawn to, under normal
circumstances. The plane can be specified as ``primary``, which will
@@ -653,7 +702,6 @@ Available video output drivers are:
just cause the video to get rendered at a different resolution and then
scaled to screen size.
Note: this option is only available with DRM atomic support.
(default: display resolution)
``--drm-vrr-enabled=<no|yes|auto>``
+41 -24
View File
@@ -1,13 +1,15 @@
Release Policy
==============
Once or twice a month, a new release is cut off of the master branch and is
Once or twice a year, a new release is cut off of the master branch and is
assigned a 0.X.Y version number, where X is incremented each time a release
contains breaking changes, such as changed options or added/removed features,
and Y is incremented if a release contains only bugfixes and other minor
changes.
Releases are tagged on the master branch and will not be maintained separately.
Patch releases may be made if the amount or severity of bugs justify it, or in
the event of security issues.
The goal of releases is to provide Linux distributions with something to
package. If you want the newest features, just use the master branch.
@@ -31,26 +33,31 @@ While on master:
- Create signed tag v0.X.Y.
- Add -UNKNOWN suffix to version in `VERSION` file.
- Commit changes, push release branch (`release/0.X`) and tag to GitHub.
- Push release branch (`release/0.X`) and tag to GitHub.
- Create a new GitHub release using the content of `RELEASE_NOTES` related to
the new version.
- Readd -UNKNOWN suffix to version in `VERSION` file.
If necessary (to e.g. exclude commits already on master), the release can
be done on a branch with different commit history. The release branch **must**
then be merged to master so `git describe` will pick up the tag.
This does not apply to patch releases, which are tagged directly on the
`release/0.X` branch. The master branch always remains at v0.X.0.
Release notes template
----------------------
Here is a template that can be used for writing the `RELEASE_NOTES` file.
Here is a template that can be used for writing the `RELEASE_NOTES` file:
```markdown
Release 0.X.Y
=============
This release requires FFmpeg <ver> or newer.
Features
--------
@@ -59,20 +66,18 @@ New
- List of new features
Changed
~~~~~~~
- List of changed features
Removed
~~~~~~~
- List of removed features
Deprecated
~~~~~~~~~~
- List of deprecated features
Behavior
--------
- List of user-visible changes in behavior
Options and Commands
--------------------
@@ -82,40 +87,52 @@ Added
- List of added options and commands
Changed
~~~~~~~
- List of changed options and commands
Renamed
~~~~~~~
- List of renamed options and commands
Deprecated
~~~~~~~~~~
- List of deprecated options and commands
Removed
~~~~~~~
- List of removed options and commands
Fixes and Minor Enhancements
----------------------------
- List of fixes and minor enhancements
This listing is not complete. There are many more bug fixes and changes. The
complete change log can be viewed by running `git log <start>..<end>` in
the git repository.
```
Note that the "Release 0.X.Y" title should be removed when creating a new GitHub
release.
This listing is not complete. Check DOCS/client-api-changes.rst for a history
of changes to the client API, and DOCS/interface-changes.rst for a history
of changes to other user-visible interfaces.
A complete changelog can be seen by running `git log <start>..<end>`
in the git repository.
```
When creating a new point release its changes should be added on top of the
`RELEASE_NOTES` file (with the appropriate title) so that all the changes in
the current 0.X branch will be included. This way the `RELEASE_NOTES` file
can be used by distributors as changelog for point releases too.
The changelog of lists all changes since the last release, including those
that have been backported to patch releases already.
Some additional advice:
- Especially for features, try to reword the messages so that the user-visible
change is clear to the reader. But don't simplify too much or be too verbose.
- It often makes sense to merge multiple related changes into one line
- Changes that have been made and reverted within the same release must not
appear in the changelog
- Limit the "Options and Commands" section to relevant changes
- When filling in the GitHub release, remove the "Release 0.X.Y" heading
+3
View File
@@ -80,6 +80,9 @@ can be obtained from your distro or PyPI. Waf can be downloaded by using the
with mpv. Some documentation about the differences between the build systems are
located in [build-system-differences][build-system-differences].
**Note**: Building with waf is considered *deprecated* and will be removed in the
future.
### Meson
After creating your build directory (e.g. `meson setup build`), you can view a list
+165 -101
View File
@@ -1,55 +1,57 @@
Release 0.35.0
Release 0.36.0
==============
This release requires FFmpeg 4.0 or newer.
This release requires FFmpeg 4.4 or newer.
For packagers: Note that mpv's build system is only supported on Python 3.
If you use the `bootstrap.py` script it will take care of this, otherwise you
need to explicitly invoke the build system using `python3 waf`.
This release adds the Meson build system as an alternative to waf.
It is supposed to be feature-complete but please report any issues you encounter.
This is the last release to contain the waf build system.
Meson is the primary and actively supported build system while waf is considered deprecated.
Features
--------
Added
~~~~~
New
~~~
- vo_gpu_next: add new libplacebo-based renderer
- build: add meson build support
- vo_gpu_next: forward Dolby Vision metadata to libplacebo
- ao_pipewire: add PipeWire audio backend
- ao_sndio: readd this audio output again
- vo_gpu_next: apply film grain if such metadata is present
- drm: context_drm_egl: add support for enabling VRR
- demux: add support for R128 replaygain tags
- x11: support X Present extension
- af_rubberband: add support for new engine in rubberband 3.0.0
- hwdec/drmprime: add drmprime hwdec-interop (commonly found on SoCs)
- various: support binding functions keys beyond F12
- audio: support hotplug events for multiple AOs
- sub: use Unicode linebreaking for non-ASS subs and OSD
- vo_gpu: hwdec: add Android hwdec utilizing AImageReader
- vo_dmabuf_wayland: add wayland VO displaying dmabuf buffers (vaapi or drm hwdec only)
- lua/console: add history deduplication
- player: add window-id property
- vo_kitty: introduce modern sixel alternative
- wayland: add wp-fractional-scale-v1 support
- player/command: add `user-data` property (replacement for `shared-script-properties`)
- vo_gpu_next: support mapping HDR10+ dynamic metadata
- vo_gpu_next: allow screenshots in native colorspace
- vo_gpu_next: parse Dolby Vision metadata for dynamic scene brightness
- video: allow csp equalizer adjustments with floating point precision
- command: add platform property
- demux_mkv: support ARIB captions
- hwdec_vulkan: add support for Vulkan-based hardware decoding
- player: better handling of forced-only subtitles and a toggle in the OSC
- vo_dmabuf_wayland: add osd support
Changed
~~~~~~~
- filters: re-add vavpp hardware deinterlacing auto-filter (for --deinterlace)
- swresample: don't forcibly clip audio on every conversion
- ytdl_hook: always set HTTP headers to fix yt-dlp on certain sites
- TOOLS/umpv: prefer $XDG_RUNTIME_DIR
- ffmpeg: increase minimum required version to 4.4
- player: choose speed of smallest acceptable factor for display sync
- player: don't force saving `start` in watch-later-options
- build: officially deprecate waf
- vf_sub: undeprecate
- player: set playlist title to media title if not set already
- player: use and respect XDG_STATE_HOME and XDG_CACHE_HOME by default
- wayland: bump required version to 1.20 and wayland-protocols to 1.25
- ao_pipewire: require at least libpipewire 0.3.48
- vo: hwdec: prioritise drmprime over drmprime_overlay
- vo_gpu/vo_gpu_next: enable gpu shader and icc cache by default
Removed
~~~~~~~
- libmpv: remove opengl_cb API and other deprecated symbols
- lua: remove deprecated mp.suspend(), resume() and resume_all()
- build: raise minimum libplacebo version requirement to v4.157.0
- drm: remove support for legacy (non-atomic) API
- stream/dvb: drop support for DVB API before Linux 3.7
- hwdec_cuda: drop support for PL_HANDLE_WIN32_KMT (Windows 7 only)
- vo_dmabuf_wayland: drop linux-dmabuf-v2 support
Options and Commands
@@ -58,98 +60,160 @@ Options and Commands
Added
~~~~~
- vo_gpu_next: add --target-colorspace-hint to facilitate HDR passthrough
- vo_gpu_next: new tone mapping options 'auto', 'spline', 'bt.2446a'
and add --tone-mapping-crosstalk, --inverse-tone-mapping
- vo_gpu: add --gamut-mapping-mode and --tone-mapping-mode
- options: add 'always' choice to --stop-screensaver
- options: add --osd-playing-msg-duration
- player: add --cover-art-whitelist option
- x11: add --x11-present option
- player: add --force-render option
- demux: add --demuxer-hysteresis-secs option to save power with caching
- ao_pipewire: allow usage of global volume control via --pipewire-volume-mode
- vo_gpu_next: add --tone-mapping-visualize
- sub: add --sub-fonts-dir and --osd-fonts-dir options
- player: add --auto-window-resize
- console.lua: add a script-opt for the border size
- player: add --drag-and-drop option
- vo_gpu_next: add --corner-rounding option
- player: add more precise sub fallback options --subs-fallback and --subs-fallback-forced
- player: add --input-cursor-passthrough option
- TOOLS/lua/autoload: allow extending ext sets from script-opts
- demux_playlist: add --directory-mode option to control recursive directory loading
- vo_gpu_next: add --target-contrast and --hdr-contrast-recovery/smoothness
Changed
~~~~~~~
- ao_openal: enable --openal-direct-channels by default
- options: only apply --sub-visibility to primary subtitles
- options: make --cover-art-auto=exact the default
- vo_gpu/hwdec: rename and introduce legacy names for some interops
- vd_lavc: add "auto" choice for --vd-lavc-dr and make it the default
(notably this change was also backported to v0.35.1)
- wayland: add auto choice to --wayland-configure-bounds
- image_writer: change --screenshot-tag-colorspace default to yes
- vo_gpu_next: expose --tone-mapping=st2094-40 and st2094-10
- wayland: make --wayland-edge-pixels-pointer default to 16
- options: enable scripts related opts also with cplugins
- player/screenshot: add filename return field
- options: set --subs-with-matching-audio to off by default
- options: default --slang to auto, which uses the settings of the user's OS
- vd_lavc: allow user to specify a priority list in --hwdec
- vd_lavc: map hwdec=yes to hwdec=auto-safe and change ctrl+h to use auto-safe
Deprecated
~~~~~~~~~~
- vo_gpu: deprecate --gamma-factor and --gamma-auto
- drm: deprecate `--drm-atomic` (now always enabled)
Removed
~~~~~~~
- vo_gpu: remove --gamut-clipping, --gamut-warning, --tone-mapping-desaturate and
--tone-mapping-desaturate-exponent (replacements available)
- vulkan: remove --vulkan-disable-events
- vo_gpu_next: remove --tone-mapping-crosstalk
Fixes and Minor Enhancements
----------------------------
- context_drm_egl: use gbm_surface_create_with_modifiers
- context_drm_egl: add support for BGR surface formats
- vo_gpu: vulkan: open DRM render fd when using VK_KHR_display
- client API: use symbol visibility attributes
- vo_gpu: hwdec_vaapi: add dma-buf modifiers support
- wayland: fix various issues that could lead to jitter
- osc: fix cache displaying 60s in some cases
- player: make --keep-open=always work with --loop-playlist
- opengl: support driver debug message under OpenGL ES
- vo_gpu: opengl: fixes for OpenGL ES version and extension handling
- f_decoder_wrapper: support frame rotation metadata (used by JPEG)
- wscript: switch shaderc checks to pkgconfig
- vd_lavc: enable hwdec for prores by default
- vo_gpu: add HOOKED_gather for custom shaders
- wayland, x11: sanitize window title for valid UTF-8
- win32: apply geometry position to content instead of window
- filter_kernels: add cosine window
- vo_gpu: hwdec_vaapi: don't probe formats for irrelevant endpoints
- vo_gpu: hwdec: load hwdec interops on-demand by default
- stats.lua: graphs: fix bad rendering due to division by 0
- hwdec: warn on unsupported --hwdec option value
- x11: fix --screen-name option
- x11: avoid wasteful rendering when possible
- video/image_writer: add JPEG XL support
- stream_lavf: enable ipfs, ipns and rist protocol support
- osc.lua: fix crash when calling osc-tracklist while idle
- player: add jxl, tiff, tif to list of image extensions
- various: switch to new AVChannelLayout structure
- lua: command_native_async: always run callback asynchronously (edge case)
- context_x11egl: remove supposed transparency workaround
- vo_gpu: fix 3DLUT precision
- drm: avoid drmModeAtomicCommit races by blocking
- drm_common: skip cards that don't support KMS for autodetection
- hwdec/dmabuf_interop_gl: support basic multi-plane formats
- misc/random: switch to internal xoshiro rng implementation
- ytdl_hook: improve track detection
- ad_lavc: strip non-normalized floats
- mpv.metainfo.xml: add XDG appstream metadata manifest
- mac: avoid unnecessary unsafe conversions; fixes crash in debug builds
- af_scaletempo2: fix crash when the number of channels increases
- wayland: correctly handle non-CLOCK_MONOTONIC clocks
- x11: fix --on-all-workspaces option
- sd_ass: improve handling of subtitles with unknown duration
- hwdec/vaapi: improve probing of supported sw formats
- demux_mf: enable support for QOI, PHM and HDR images
- demux_mkv: add AVS2 and AVS3 to tag list
- TOOLS/lua/autoload: fix incorrect duplicate file loading behavior
- demux/codec_tags: support more WAVEFORMATEXTENSIBLE tags
- sd_ass: never mangle colours on RGB video
- ao_pipewire: log version and other useful debug info
- wayland: error out if essential protocol support is missing
- wayland: add support for content-type protocol
- wayland: also log refresh rate on surface entrance
- vo_gpu_next: fix undefined behavior on alpha-first formats
- meson: prepend MPV_CONFDIR path with prefix
- meson: unbreak dl check on BSDs without libdl
- lcms: fix crash with lcms2-related options if lcms is disabled
- meson: fix stdatomic detection on bsd
- osc: don't spam window-controls bindings on every render
- wayland: check for resize/move in touch event first
- ao_coreaudio: use device's nominal sample rate for latency properties
- hwdec_drmprime: support yuv420p format
- ao_pipewire: properly clean up resources
- vo/{sixel,tct}: use the alternate buffer to restore terminal
- vo_sixel: add option to skip clear while drawing
- filter_kernels: fix kaiser
- hwdec/d3d11va: fix a possible memory leak
- external_files: set log level for potential files to trace
- external_files: recognize webp files as cover art
- vo_opengl: do not blindly reject all Microsoft's OpenGL implementations
- ao_coreaudio: use AudioUnitReset as ao_driver.reset to prevent long restart
- hwdec_drmprime: fix memory leak
- vo: hwdec: fix libdrm-related memory leak
- draw_bmp: ensure last slice width is less than total width
- demux: boost read EBU R128 gain values to ReplayGain's reference level
- version.py: bump copyright year
- TOOLS/umpv: support shell-quotes in $MPV
- vulkan: fix build error for 32bit builds with clang
- TOOLS/lua/autoload: improve and optimize the natural sorting
- vo_wlshm: properly support video panscan
- vo_dmabuf_wayland: support panscan and panning
- ra_d3d11: fix incorrect type
- meson: also search for rst2html with .py extension
- audio: fix crash during uninit with ao_lavc
- wayland: only warn about GNOME when actually missing idle inhibit support
- mp_image: fix XYZ primaries default
- msg: preserve early messages when log-file is set in mpv.conf
- x11: fix issue with xpresent timing feedback
- meson: reuse libmpv objects for cplayer to save 50% of compile steps
- player/client: support observing sub-properties
- m_property: implement new deletion operation on properties
- vo_lavc: set frame rate on encoder to fix non-conforming outputs
- player/video: don't resync audio if video is an image
- stream: accept webdav:// and webdavs:// urls
- video/image_writer: avoid stripping colorspace info when writing image
- stats.lua: display HDR peak in nits
- image_pool: fix memory leak with frames
- options: transition from OPT_FLAG to OPT_BOOL
- vd_lavc: sort hwdecs without hwdevices last for autoprobing
- ytdl_hook: don't overwrite force-media-title
- lua: use user-data for interop between osc.lua and console.lua
- vo: fix race condition with redraw requests
- various: more fixes to ensure correct playback of XYZ colorspace
- ytdl_hook: fix fragment-related issue that broke YouTube DASH playback
- command: expose hls-bitrate and program-id as track-list subproperties
- ao_pipewire: use realtime scheduling for data thread
- auto_profiles: check for non-existent properties
- d3d11: retry device creation without debug, if SDK is not available
- win32: follow Windows settings and update dark mode state
- ytdl_hook.lua: fix clip start and end
- hwdec_drmprime: support custom rpi4_8 and rpi4_10 formats
- sub: fix UPDATE_SUB_HARD for converted and external subtitles
- charset_conv: fix memory corruption in mp_iconv_to_utf8
- options: read config file as stream
- wayland: improve guessing when mpv is focused
- player: always try to detect subtitle language from file name
- vo: fix mp_frame_perf thread safety
- lua: read_options: find script-opts prefix at index 1 exactly
- path: handle URLs consistently in mp_basename
- ao_wasapi: remove infinite loop hack in AOCONTROL_UPDATE_STREAM_TITLE
- ao_wasapi: use client name instead of hardcoded string
- vd_lavc: fix crash if hwdec devices fail to create
- vo_drm: fix null dereference and using closed fd
- image_writer: respect jpeg-quality when using ffmpeg for writing
- image_writer: add support for AVIF
- TOOLS/lua/autoload: avoid unnecessary playlist manipulation, performance
- various: correctly ignore cache files with --no-config
- terminal-unix: better error detection logic
- json: raise parse depth to 50 for the sake of utils.parse_json()
- player: delete watch_later file only after successful load
- wayland: fix memory leak with multiple monitors
- vd_lavc: prefer d3d11va-copy over dxva2-copy
- vd_lavc: fix hwdec for videos with less than less than 3 frames
- wayland: add support for suspended toplevel state
- draw_bmp: ensure last slice is less than total width (again)
- console.lua: sort the output from the help command
- vd_lavc: try other hwdecs when falling back after an hwdec failure
- sd_ass: don't reconfigure ass on every frame (performance regression)
- sd_ass: fix converted subtitles having too-wide borders
- loadfile: compute audio language for sub selection when using lavfi-complex
- wayland: fix modifier keys in certain situations
- vd_lavc: corrections towards hwdec and swdec fallback
- zimg: fix broken sig_peak (HDR) handling
- screenshot: implement `screenshot window` in sw for most VOs
- osc: don't add margins to osc-deadzonesize
- vo_vaapi: fix segfault in draw_osd
- vo_dmabuf_wayland: correctly handle force-window
- ao_pipewire: fix error with pipewire 0.3.75 or later
This listing is not complete. Check DOCS/client-api-changes.rst for a history
of changes to the client API, and DOCS/interface-changes.rst for a history
of changes to other user-visible interfaces.
A complete changelog can be seen by running `git log v0.34.0..v0.35.0`
A complete changelog can be seen by running `git log v0.35.0..v0.36.0`
in the git repository or by visiting either
https://github.com/mpv-player/mpv/compare/v0.34.0...v0.35.0 or
https://git.srsfckn.biz/mpv/log/?qt=range&q=v0.34.0..v0.35.0
https://github.com/mpv-player/mpv/compare/v0.35.0...v0.36.0 or
https://git.srsfckn.biz/mpv/log/?qt=range&q=v0.35.0..v0.36.0
-24
View File
@@ -1,24 +0,0 @@
#!/usr/bin/bash
set -e
export DEST_OS=win32
export CC=gcc
export PKG_CONFIG=/usr/bin/pkg-config
export PERL=/usr/bin/perl
export PYTHON=/usr/bin/python3
"$PYTHON" bootstrap.py
"$PYTHON" waf configure \
--check-c-compiler=gcc \
--enable-spirv-cross \
--enable-d3d-hwaccel \
--enable-d3d11 \
--enable-jpeg \
--enable-lcms2 \
--enable-libarchive \
--enable-lua \
--enable-rubberband \
--enable-shaderc \
--enable-uchardet \
--enable-vulkan
"$PYTHON" waf build
-54
View File
@@ -1,54 +0,0 @@
#!/usr/bin/bash
set -e
export PYTHON=/usr/bin/python3
# Write an empty fonts.conf to speed up fc-cache
export FONTCONFIG_FILE=/dummy-fonts.conf
cat >"$FONTCONFIG_FILE" <<EOF
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig></fontconfig>
EOF
# Install build dependencies for mpv
pacman -S --noconfirm --needed \
$MINGW_PACKAGE_PREFIX-toolchain \
$MINGW_PACKAGE_PREFIX-cmake \
$MINGW_PACKAGE_PREFIX-lcms2 \
$MINGW_PACKAGE_PREFIX-libarchive \
$MINGW_PACKAGE_PREFIX-libass \
$MINGW_PACKAGE_PREFIX-libjpeg-turbo \
$MINGW_PACKAGE_PREFIX-libplacebo \
$MINGW_PACKAGE_PREFIX-lua51 \
$MINGW_PACKAGE_PREFIX-ninja \
$MINGW_PACKAGE_PREFIX-rubberband \
$MINGW_PACKAGE_PREFIX-shaderc \
$MINGW_PACKAGE_PREFIX-spirv-cross \
$MINGW_PACKAGE_PREFIX-uchardet \
$MINGW_PACKAGE_PREFIX-vulkan
# Delete unused packages to reduce space used in the Appveyor cache
pacman -Sc --noconfirm
# Compile ffmpeg
(
git clone --depth=1 https://github.com/FFmpeg/ffmpeg.git && cd ffmpeg
mkdir build && cd build
../configure \
--prefix=$MINGW_PREFIX \
--target-os=mingw32 \
--arch=$MSYSTEM_CARCH \
--disable-static \
--disable-doc \
--disable-asm \
--enable-gpl \
--enable-version3 \
--enable-shared \
--enable-pic \
--enable-d3d11va \
--enable-dxva2 \
--enable-schannel
make -j4 install
)
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env python3
"""
Wrapper around docutils rst2x commands,
converting their dependency files to a format understood by meson/ninja.
"""
#
# This file is part of mpv.
#
# mpv is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# mpv is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with mpv. If not, see <http://www.gnu.org/licenses/>.
#
import os
import subprocess
import sys
def convert_depfile(output, depfile):
with open(depfile, 'r') as f:
deps = f.readlines()
with open(depfile, 'w') as f:
f.write(os.path.abspath(output))
f.write(': \\\n')
for dep in deps:
dep = dep[:-1]
f.write('\t')
f.write(os.path.abspath(dep))
f.write(' \\\n')
def remove(path):
try:
os.remove(path)
except FileNotFoundError:
pass
argv = sys.argv[1:]
depfile = None
output = argv[-1]
for opt, optarg in zip(argv, argv[1:]):
if opt == '--record-dependencies':
depfile = optarg
try:
proc = subprocess.run(argv, check=True)
if depfile is not None:
convert_depfile(output, depfile)
except:
remove(output)
if depfile is not None:
remove(depfile)
sys.exit(1)
sys.exit(proc.returncode)
+1 -1
View File
@@ -22,7 +22,7 @@
testfun()
{
$ILDETECT_MPV "$@" \
--vf-add=lavfi="[idet]" --msg-level ffmpeg=v \
--vf-add=lavfi="[idet]" --msg-level=ffmpeg=v \
--o= --vo=null --no-audio --untimed \
$ILDETECT_MPVFLAGS \
| { if [ -n "$ILDETECT_QUIET" ]; then cat; else tee /dev/stderr; fi } \
+12 -18
View File
@@ -107,14 +107,18 @@ function is_enough_time(seconds)
return playtime_remaining and time_needed < playtime_remaining
end
function is_cropable()
for _, track in pairs(mp.get_property_native('track-list')) do
if track.type == 'video' and track.selected then
return not track.albumart
end
function is_cropable(time_needed)
if mp.get_property_native('current-tracks/video/image') ~= false then
mp.msg.warn("autocrop only works for videos.")
return false
end
return false
if not is_enough_time(time_needed) then
mp.msg.warn("Not enough time to detect crop.")
return false
end
return true
end
function remove_filter(label)
@@ -142,18 +146,9 @@ function cleanup()
end
function detect_crop()
-- If it's not cropable, exit.
if not is_cropable() then
mp.msg.warn("autocrop only works for videos.")
return
end
-- Verify if there is enough time to detect crop.
local time_needed = options.detect_seconds
if not is_enough_time(time_needed) then
mp.msg.warn("Not enough time to detect crop.")
if not is_cropable(time_needed) then
return
end
@@ -282,8 +277,7 @@ function on_start()
-- Verify if there is enough time for autocrop.
local time_needed = options.auto_delay + options.detect_seconds
if not is_enough_time(time_needed) then
mp.msg.warn("Not enough time for autocrop.")
if not is_cropable(time_needed) then
return
end
+64 -50
View File
@@ -16,6 +16,9 @@ disabled=no
images=no
videos=yes
audio=yes
additional_image_exts=list,of,ext
additional_video_exts=list,of,ext
additional_audio_exts=list,of,ext
ignore_hidden=yes
--]]
@@ -31,6 +34,9 @@ o = {
images = true,
videos = true,
audio = true,
additional_image_exts = "",
additional_video_exts = "",
additional_audio_exts = "",
ignore_hidden = true
}
options.read_options(o)
@@ -48,6 +54,12 @@ function SetUnion (a,b)
return res
end
function Split (s)
local set = {}
for v in string.gmatch(s, '([^,]+)') do set[v] = true end
return set
end
EXTENSIONS_VIDEO = Set {
'3g2', '3gp', 'avi', 'flv', 'm2ts', 'm4v', 'mj2', 'mkv', 'mov',
'mp4', 'mpeg', 'mpg', 'ogv', 'rmvb', 'webm', 'wmv', 'y4m'
@@ -63,17 +75,20 @@ EXTENSIONS_IMAGES = Set {
'svg', 'tga', 'tif', 'tiff', 'webp'
}
EXTENSIONS_VIDEO = SetUnion(EXTENSIONS_VIDEO, Split(o.additional_video_exts))
EXTENSIONS_AUDIO = SetUnion(EXTENSIONS_AUDIO, Split(o.additional_audio_exts))
EXTENSIONS_IMAGES = SetUnion(EXTENSIONS_IMAGES, Split(o.additional_image_exts))
EXTENSIONS = Set {}
if o.videos then EXTENSIONS = SetUnion(EXTENSIONS, EXTENSIONS_VIDEO) end
if o.audio then EXTENSIONS = SetUnion(EXTENSIONS, EXTENSIONS_AUDIO) end
if o.images then EXTENSIONS = SetUnion(EXTENSIONS, EXTENSIONS_IMAGES) end
function add_files_at(index, files)
index = index - 1
function add_files(files)
local oldcount = mp.get_property_number("playlist-count", 1)
for i = 1, #files do
mp.commandv("loadfile", files[i], "append")
mp.commandv("playlist-move", oldcount + i - 1, index + i - 1)
mp.commandv("loadfile", files[i][1], "append")
mp.commandv("playlist-move", oldcount + i - 1, files[i][2])
end
end
@@ -94,47 +109,35 @@ table.filter = function(t, iter)
end
end
-- splitbynum and alnumcomp from alphanum.lua (C) Andre Bogus
-- Released under the MIT License
-- http://www.davekoelle.com/files/alphanum.lua
-- alphanum sorting for humans in Lua
-- http://notebook.kulchenko.com/algorithms/alphanumeric-natural-sorting-for-humans-in-lua
-- split a string into a table of number and string values
function splitbynum(s)
local result = {}
for x, y in (s or ""):gmatch("(%d*)(%D*)") do
if x ~= "" then table.insert(result, tonumber(x)) end
if y ~= "" then table.insert(result, y) end
function alphanumsort(filenames)
local function padnum(n, d)
return #d > 0 and ("%03d%s%.12f"):format(#n, n, tonumber(d) / (10 ^ #d))
or ("%03d%s"):format(#n, n)
end
return result
end
function clean_key(k)
k = (' '..k..' '):gsub("%s+", " "):sub(2, -2):lower()
return splitbynum(k)
end
-- compare two strings
function alnumcomp(x, y)
local xt, yt = clean_key(x), clean_key(y)
for i = 1, math.min(#xt, #yt) do
local xe, ye = xt[i], yt[i]
if type(xe) == "string" then ye = tostring(ye)
elseif type(ye) == "string" then xe = tostring(xe) end
if xe ~= ye then return xe < ye end
local tuples = {}
for i, f in ipairs(filenames) do
tuples[i] = {f:lower():gsub("0*(%d+)%.?(%d*)", padnum), f}
end
return #xt < #yt
table.sort(tuples, function(a, b)
return a[1] == b[1] and #b[2] < #a[2] or a[1] < b[1]
end)
for i, tuple in ipairs(tuples) do filenames[i] = tuple[2] end
return filenames
end
local autoloaded = nil
function get_playlist_filenames()
local filenames = {}
for n = 0, pl_count - 1, 1 do
local filename = mp.get_property('playlist/'..n..'/filename')
local _, file = utils.split_path(filename)
filenames[file] = true
end
return filenames
function get_playlist_filenames(playlist)
local filenames = {}
for i = 1, #playlist do
local _, file = utils.split_path(playlist[i].filename)
filenames[file] = true
end
return filenames
end
function find_and_add_entries()
@@ -181,7 +184,7 @@ function find_and_add_entries()
end
return EXTENSIONS[string.lower(ext)]
end)
table.sort(files, alnumcomp)
alphanumsort(files)
if dir == "." then
dir = ""
@@ -201,32 +204,43 @@ function find_and_add_entries()
msg.trace("current file position in files: "..current)
local append = {[-1] = {}, [1] = {}}
local filenames = get_playlist_filenames()
local filenames = get_playlist_filenames(pl)
for direction = -1, 1, 2 do -- 2 iterations, with direction = -1 and +1
for i = 1, MAXENTRIES do
local file = files[current + i * direction]
local pos = current + i * direction
local file = files[pos]
if file == nil or file[1] == "." then
break
end
local filepath = dir .. file
-- skip files already in playlist
if filenames[file] then break end
if direction == -1 then
if pl_current == 1 then -- never add additional entries in the middle
if not filenames[file] then
if direction == -1 then
msg.info("Prepending " .. file)
table.insert(append[-1], 1, filepath)
table.insert(append[-1], 1, {filepath, pos - 1})
else
msg.info("Adding " .. file)
if pl_count > 1 then
table.insert(append[1], {filepath, pos - 1})
else
mp.commandv("loadfile", filepath, "append")
end
end
else
msg.info("Adding " .. file)
table.insert(append[1], filepath)
end
end
if pl_count == 1 and direction == -1 and #append[-1] > 0 then
for i = 1, #append[-1] do
mp.commandv("loadfile", append[-1][i][1], "append")
end
mp.commandv("playlist-move", 0, current)
end
end
add_files_at(pl_current + 1, append[1])
add_files_at(pl_current, append[-1])
if pl_count > 1 then
add_files(append[1])
add_files(append[-1])
end
end
mp.register_event("start-file", find_and_add_entries)
-139
View File
@@ -1,139 +0,0 @@
#!/usr/bin/ruby
class TravisDepsBuilder
def self.make(name)
instance = klass.new(name)
instance.fill_data
instance.deps
instance.build
end
def self.klass
Module.const_get([self.name, self.os.capitalize].join)
rescue NameError
self
end
def self.os
ENV['TRAVIS_OS_NAME']
end
attr_reader :name, :url, :action, :os
def initialize(name)
@name, @os = name, self.class.os
end
def fill_data
data = build_map.fetch(name)
@url, @action = data[:url], data[:action]
end
def build
send(action)
end
def deps; end
private
def package_manager_update
# yes class variable, you wanna update only once across all instances
@@updated ||= false
return if @@updated
sh({'linux' => 'sudo apt-get update -y', 'osx' => 'brew update'}[os])
@@updated = true
end
def package_install(*packages)
cmd = {
'linux' => 'sudo apt-get install %s -y',
'osx' => 'brew install %s'
}[os] % [packages.join(" ")]
sh cmd
end
def git
sh "git clone --depth=1 #{url} #{name}"
compile name
end
def stable
filename = File.basename(url)
sh "wget #{url}"
sh "tar -xzvf #{filename}"
dirname = File.basename(url, ".tar.gz" )
compile dirname
end
def package
package_install(url)
end
def compile(dirname)
sh "cd #{dirname} && #{configure} && make && sudo make install"
sh "cd $TRAVIS_BUILD_DIR"
end
def configure
"./configure"
end
def sh(command)
`#{command}`
end
end
class Libav < TravisDepsBuilder
def build_map
{
"libav-git" => {
:action => :git,
:url => "git://git.libav.org/libav.git"
},
"ffmpeg-git" => {
:action => :git,
:url => "https://github.com/FFmpeg/FFmpeg.git"
}
}
end
def configure
[super, "--cc=#{ENV['CC']} --disable-asm"].join(" ")
end
end
class LibavOsx < Libav
def build_map
{
"ffmpeg-git" => { :action => :package, :url => 'ffmpeg' },
}
end
end
class Libass < TravisDepsBuilder
def build_map
{
"libass-stable" => {
:action => :stable,
:url => 'https://github.com/libass/libass/releases/download/0.12.1/libass-0.12.1.tar.gz'
}
}
end
end
class Dependencies < TravisDepsBuilder
def deps
packages = {
'linux' => 'pkg-config fontconfig libfribidi-dev yasm libxinerama-dev libxrandr-dev',
'osx' => 'pkg-config fontconfig freetype fribidi yasm'
}
package_manager_update
package_install(packages.fetch(os))
end
end
Dependencies.new(:deps).deps
Libass.make(ARGV[0])
Libav.make(ARGV[1])
-29
View File
@@ -1,29 +0,0 @@
#!/bin/sh
if [ "$TRAVIS_OS_NAME" != "linux" ] || [ "$CC" != "clang" ]; then
# trigger build only on one of the matrix nodes
exit;
fi
if [ "x$TRAVIS_BRANCH" != "xmaster" ]; then
# only rebuild website with pushes to master
exit;
fi
TRAVIS_COMMIT_RANGE=${TRAVIS_COMMIT_RANGE:-HEAD^..}
if git diff --quiet --name-only --exit-code "$TRAVIS_COMMIT_RANGE" DOCS/ VERSION; then
exit;
fi
body='{
"request": {
"branch":"master"
}}'
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Travis-API-Version: 3" \
-H "Authorization: token $WEBSITE_TRAVIS_TOKEN" \
-d "$body" \
https://api.travis-ci.org/repo/mpv-player%2Fmpv.io/requests
+3 -2
View File
@@ -32,6 +32,7 @@ import socket
import errno
import subprocess
import string
import shlex
files = sys.argv[1:]
@@ -52,7 +53,7 @@ def make_abs(filename):
return filename
files = (make_abs(f) for f in files)
SOCK = os.path.join(os.getenv("HOME"), ".umpv_socket")
SOCK = os.path.join(os.getenv("XDG_RUNTIME_DIR", os.getenv("HOME")), ".umpv_socket")
sock = None
try:
@@ -78,7 +79,7 @@ if sock:
else:
# Let mpv recreate socket if it doesn't already exist.
opts = (os.getenv("MPV") or "mpv").split()
opts = shlex.split(os.getenv("MPV") or "mpv")
opts.extend(["--no-terminal", "--force-window", "--input-ipc-server=" + SOCK,
"--"])
opts.extend(files)
+1 -1
View File
@@ -1 +1 @@
0.35.0
0.36.0
-38
View File
@@ -1,38 +0,0 @@
image: Visual Studio 2019
branches:
only:
- master
- appveyor
- ci
environment:
global:
PATH: C:\msys64\usr\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
matrix:
- MSYSTEM: MINGW64
- MSYSTEM: MINGW32
shallow_clone: true
test: off
install:
# Disable checking disk space to speed up install time
- C:\msys64\usr\bin\sed -i 's/^CheckSpace/#CheckSpace/g' /etc/pacman.conf
# Update core packages
- C:\msys64\usr\bin\pacman -Syyuu --noconfirm --noprogressbar --ask=20
# Explicitly kill any remaining msys2 processes after core update
- taskkill /f /fi "MODULES eq msys-2.0.dll"
# Update non-core packages
- C:\msys64\usr\bin\pacman -Suu --noconfirm --noprogressbar --ask=20
# Install required MSYS2 packages
- C:\msys64\usr\bin\pacman -S --noconfirm --noprogressbar --needed base-devel perl python pkgconf
# Now MSYS2 is up to date, do the rest of the install from a bash script
- C:\msys64\usr\bin\bash -lc "cd && exec \"$APPVEYOR_BUILD_FOLDER\"/TOOLS/appveyor-install.sh"
build_script:
- C:\msys64\usr\bin\bash -lc "cd \"$APPVEYOR_BUILD_FOLDER\" && exec ./TOOLS/appveyor-build.sh"
on_failure:
- type "%APPVEYOR_BUILD_FOLDER%\build\config.log"
cache:
- C:\msys64\var\cache\pacman\pkg
+2 -4
View File
@@ -52,8 +52,7 @@ struct mp_aframe *mp_aframe_create(void)
{
struct mp_aframe *frame = talloc_zero(NULL, struct mp_aframe);
frame->av_frame = av_frame_alloc();
if (!frame->av_frame)
abort();
MP_HANDLE_OOM(frame->av_frame);
talloc_set_destructor(frame, free_frame);
mp_aframe_reset(frame);
return frame;
@@ -701,8 +700,7 @@ int mp_aframe_pool_allocate(struct mp_aframe_pool *pool, struct mp_aframe *frame
if (planes > AV_NUM_DATA_POINTERS) {
av_frame->extended_data =
av_calloc(planes, sizeof(av_frame->extended_data[0]));
if (!av_frame->extended_data)
abort();
MP_HANDLE_OOM(av_frame->extended_data);
} else {
av_frame->extended_data = av_frame->data;
}
+8 -6
View File
@@ -46,6 +46,7 @@
struct priv {
AVCodecContext *avctx;
AVFrame *avframe;
AVPacket *avpkt;
struct mp_chmap force_channel_map;
uint32_t skip_samples, trim_samples;
bool preroll_done;
@@ -59,7 +60,7 @@ struct priv {
#define OPT_BASE_STRUCT struct ad_lavc_params
struct ad_lavc_params {
float ac3drc;
int downmix;
bool downmix;
int threads;
char **avopts;
};
@@ -67,7 +68,7 @@ struct ad_lavc_params {
const struct m_sub_options ad_lavc_conf = {
.opts = (const m_option_t[]) {
{"ac3drc", OPT_FLOAT(ac3drc), M_RANGE(0, 6)},
{"downmix", OPT_FLAG(downmix)},
{"downmix", OPT_BOOL(downmix)},
{"threads", OPT_INT(threads), M_RANGE(0, 16)},
{"o", OPT_KEYVALUELIST(avopts)},
{0}
@@ -75,7 +76,6 @@ const struct m_sub_options ad_lavc_conf = {
.size = sizeof(struct ad_lavc_params),
.defaults = &(const struct ad_lavc_params){
.ac3drc = 0,
.downmix = 0,
.threads = 1,
},
};
@@ -104,6 +104,8 @@ static bool init(struct mp_filter *da, struct mp_codec_params *codec,
lavc_context = avcodec_alloc_context3(lavc_codec);
ctx->avctx = lavc_context;
ctx->avframe = av_frame_alloc();
ctx->avpkt = av_packet_alloc();
MP_HANDLE_OOM(ctx->avctx && ctx->avframe && ctx->avpkt);
lavc_context->codec_type = AVMEDIA_TYPE_AUDIO;
lavc_context->codec_id = lavc_codec->id;
lavc_context->pkt_timebase = ctx->codec_timebase;
@@ -160,6 +162,7 @@ static void destroy(struct mp_filter *da)
avcodec_free_context(&ctx->avctx);
av_frame_free(&ctx->avframe);
mp_free_av_packet(&ctx->avpkt);
}
static void reset(struct mp_filter *da)
@@ -185,10 +188,9 @@ static int send_packet(struct mp_filter *da, struct demux_packet *mpkt)
if (mpkt && priv->next_pts == MP_NOPTS_VALUE)
priv->next_pts = mpkt->pts;
AVPacket pkt;
mp_set_av_packet(&pkt, mpkt, &priv->codec_timebase);
mp_set_av_packet(priv->avpkt, mpkt, &priv->codec_timebase);
int ret = avcodec_send_packet(avctx, mpkt ? &pkt : NULL);
int ret = avcodec_send_packet(avctx, mpkt ? priv->avpkt : NULL);
if (ret < 0)
MP_ERR(da, "Error decoding audio.\n");
return ret;
+11 -7
View File
@@ -41,6 +41,7 @@ struct spdifContext {
struct mp_log *log;
enum AVCodecID codec_id;
AVFormatContext *lavf_ctx;
AVPacket *avpkt;
int out_buffer_len;
uint8_t out_buffer[OUTBUF_SIZE];
bool need_close;
@@ -82,6 +83,7 @@ static void destroy(struct mp_filter *da)
avformat_free_context(lavf_ctx);
spdif_ctx->lavf_ctx = NULL;
}
mp_free_av_packet(&spdif_ctx->avpkt);
}
static void determine_codec_params(struct mp_filter *da, AVPacket *pkt,
@@ -167,8 +169,7 @@ static int init_filter(struct mp_filter *da, AVPacket *pkt)
goto fail;
void *buffer = av_mallocz(OUTBUF_SIZE);
if (!buffer)
abort();
MP_HANDLE_OOM(buffer);
lavf_ctx->pb = avio_alloc_context(buffer, OUTBUF_SIZE, 1, spdif_ctx, NULL,
write_packet, NULL);
if (!lavf_ctx->pb) {
@@ -295,15 +296,14 @@ static void process(struct mp_filter *da)
struct mp_aframe *out = NULL;
double pts = mpkt->pts;
AVPacket pkt;
mp_set_av_packet(&pkt, mpkt, NULL);
pkt.pts = pkt.dts = 0;
mp_set_av_packet(spdif_ctx->avpkt, mpkt, NULL);
spdif_ctx->avpkt->pts = spdif_ctx->avpkt->dts = 0;
if (!spdif_ctx->lavf_ctx) {
if (init_filter(da, &pkt) < 0)
if (init_filter(da, spdif_ctx->avpkt) < 0)
goto done;
}
spdif_ctx->out_buffer_len = 0;
int ret = av_write_frame(spdif_ctx->lavf_ctx, &pkt);
int ret = av_write_frame(spdif_ctx->lavf_ctx, spdif_ctx->avpkt);
avio_flush(spdif_ctx->lavf_ctx->pb);
if (ret < 0) {
MP_ERR(da, "spdif mux error: '%s'\n", mp_strerror(AVUNERROR(ret)));
@@ -424,6 +424,10 @@ static struct mp_decoder *create(struct mp_filter *parent,
talloc_free(da);
return NULL;
}
spdif_ctx->avpkt = av_packet_alloc();
MP_HANDLE_OOM(spdif_ctx->avpkt);
return &spdif_ctx->public;
}
+2 -2
View File
@@ -30,7 +30,7 @@ struct f_opts {
int out_srate;
struct m_channels out_channels;
int fail;
bool fail;
};
struct priv {
@@ -135,7 +135,7 @@ const struct mp_user_filter_entry af_format = {
{"out-srate", OPT_INT(out_srate), M_RANGE(1000, 8*48000)},
{"out-channels", OPT_CHANNELS(out_channels),
.flags = M_OPT_CHANNELS_LIMITED},
{"fail", OPT_FLAG(fail)},
{"fail", OPT_BOOL(fail)},
{0}
},
},
+3 -3
View File
@@ -56,7 +56,7 @@ const static uint16_t ac3_bitrate_tab[19] = {
};
struct f_opts {
int add_iec61937_header;
bool add_iec61937_header;
int bit_rate;
int min_channel_num;
char *encoder;
@@ -418,13 +418,13 @@ const struct mp_user_filter_entry af_lavcac3enc = {
.name = "lavcac3enc",
.priv_size = sizeof(OPT_BASE_STRUCT),
.priv_defaults = &(const OPT_BASE_STRUCT) {
.add_iec61937_header = 1,
.add_iec61937_header = true,
.bit_rate = 640,
.min_channel_num = 3,
.encoder = "ac3",
},
.options = (const struct m_option[]) {
{"tospdif", OPT_FLAG(add_iec61937_header)},
{"tospdif", OPT_BOOL(add_iec61937_header)},
{"bitrate", OPT_CHOICE(bit_rate,
{"auto", 0}, {"default", 0}), M_RANGE(32, 640)},
{"minch", OPT_INT(min_channel_num), M_RANGE(2, 6)},
+4 -5
View File
@@ -102,12 +102,11 @@ static const struct ao_driver * const audio_out_drivers[] = {
#endif
&audio_out_pcm,
&audio_out_lavc,
NULL
};
static bool get_desc(struct m_obj_desc *dst, int index)
{
if (index >= MP_ARRAY_SIZE(audio_out_drivers) - 1)
if (index >= MP_ARRAY_SIZE(audio_out_drivers))
return false;
const struct ao_driver *ao = audio_out_drivers[index];
*dst = (struct m_obj_desc) {
@@ -313,7 +312,7 @@ struct ao *ao_init_best(struct mpv_global *global,
}
if (autoprobe) {
for (int n = 0; audio_out_drivers[n]; n++) {
for (int n = 0; n < MP_ARRAY_SIZE(audio_out_drivers); n++) {
const struct ao_driver *driver = audio_out_drivers[n];
if (driver == &audio_out_null)
break;
@@ -521,7 +520,7 @@ struct ao_device_list *ao_hotplug_get_device_list(struct ao_hotplug *hp,
}
}
for (int n = 0; audio_out_drivers[n]; n++) {
for (int n = 0; n < MP_ARRAY_SIZE(audio_out_drivers); n++) {
const struct ao_driver *d = audio_out_drivers[n];
if (d == &audio_out_null)
break; // don't add unsafe/special entries
@@ -702,7 +701,7 @@ static void convert_plane(int type, void *data, int num_samples)
break;
}
default:
abort();
MP_ASSERT_UNREACHABLE();
}
}
+1 -7
View File
@@ -26,8 +26,7 @@
#include "audio/chmap_sel.h"
enum aocontrol {
// _VOLUME commands take struct ao_control_vol pointer for input/output.
// If there's only one volume, SET should use average of left/right.
// _VOLUME commands take a pointer to float for input/output.
AOCONTROL_GET_VOLUME,
AOCONTROL_SET_VOLUME,
// _MUTE commands take a pointer to bool
@@ -61,11 +60,6 @@ enum {
AO_INIT_EXCLUSIVE = 1 << 3,
};
typedef struct ao_control_vol {
float left;
float right;
} ao_control_vol_t;
enum aocontrol_media_role {
AOCONTROL_MEDIA_ROLE_MUSIC,
AOCONTROL_MEDIA_ROLE_MOVIE,
+15 -18
View File
@@ -34,7 +34,6 @@
#include <math.h>
#include <string.h>
#include "config.h"
#include "options/options.h"
#include "options/m_config.h"
#include "options/m_option.h"
@@ -57,9 +56,9 @@ struct ao_alsa_opts {
char *mixer_device;
char *mixer_name;
int mixer_index;
int resample;
int ni;
int ignore_chmap;
bool resample;
bool ni;
bool ignore_chmap;
int buffer_time;
int frags;
};
@@ -67,12 +66,12 @@ struct ao_alsa_opts {
#define OPT_BASE_STRUCT struct ao_alsa_opts
static const struct m_sub_options ao_alsa_conf = {
.opts = (const struct m_option[]) {
{"alsa-resample", OPT_FLAG(resample)},
{"alsa-resample", OPT_BOOL(resample)},
{"alsa-mixer-device", OPT_STRING(mixer_device)},
{"alsa-mixer-name", OPT_STRING(mixer_name)},
{"alsa-mixer-index", OPT_INT(mixer_index), M_RANGE(0, 99)},
{"alsa-non-interleaved", OPT_FLAG(ni)},
{"alsa-ignore-chmap", OPT_FLAG(ignore_chmap)},
{"alsa-non-interleaved", OPT_BOOL(ni)},
{"alsa-ignore-chmap", OPT_BOOL(ignore_chmap)},
{"alsa-buffer-time", OPT_INT(buffer_time), M_RANGE(0, INT_MAX)},
{"alsa-periods", OPT_INT(frags), M_RANGE(0, INT_MAX)},
{0}
@@ -80,8 +79,6 @@ static const struct m_sub_options ao_alsa_conf = {
.defaults = &(const struct ao_alsa_opts) {
.mixer_device = "default",
.mixer_name = "Master",
.mixer_index = 0,
.ni = 0,
.buffer_time = 100000,
.frags = 4,
},
@@ -168,15 +165,13 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
switch (cmd) {
case AOCONTROL_SET_VOLUME: {
ao_control_vol_t *vol = arg;
set_vol = vol->left / f_multi + pmin + 0.5;
float *vol = arg;
set_vol = *vol / f_multi + pmin + 0.5;
err = snd_mixer_selem_set_playback_volume(elem, 0, set_vol);
CHECK_ALSA_ERROR("Error setting left channel");
MP_DBG(ao, "left=%li, ", set_vol);
set_vol = vol->right / f_multi + pmin + 0.5;
err = snd_mixer_selem_set_playback_volume(elem, 1, set_vol);
CHECK_ALSA_ERROR("Error setting right channel");
MP_DBG(ao, "right=%li, pmin=%li, pmax=%li, mult=%f\n",
@@ -184,12 +179,14 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
break;
}
case AOCONTROL_GET_VOLUME: {
ao_control_vol_t *vol = arg;
float *vol = arg;
float left, right;
snd_mixer_selem_get_playback_volume(elem, 0, &get_vol);
vol->left = (get_vol - pmin) * f_multi;
left = (get_vol - pmin) * f_multi;
snd_mixer_selem_get_playback_volume(elem, 1, &get_vol);
vol->right = (get_vol - pmin) * f_multi;
MP_DBG(ao, "left=%f, right=%f\n", vol->left, vol->right);
right = (get_vol - pmin) * f_multi;
*vol = (left + right) / 2.0;
MP_DBG(ao, "vol=%f\n", *vol);
break;
}
case AOCONTROL_SET_MUTE: {
@@ -563,7 +560,7 @@ static char *append_params(void *ta_parent, const char *device, const char *p)
/* a simple list of parameters: add it at the end of the list */
return talloc_asprintf(ta_parent, "%s,%s", device, p);
}
abort();
MP_ASSERT_UNREACHABLE();
}
static int try_open_device(struct ao *ao, const char *device, int mode)
+3 -8
View File
@@ -54,7 +54,7 @@ struct priv {
jfloatArray floatarray;
jobject bbuf;
int cfg_pcm_float;
bool cfg_pcm_float;
int cfg_session_id;
bool needs_timestamp_offset;
@@ -648,11 +648,6 @@ static void uninit(struct ao *ao)
p->timestamp = NULL;
}
if (p->chunk) {
free(p->chunk);
p->chunk = NULL;
}
pthread_cond_destroy(&p->wakeup);
pthread_mutex_destroy(&p->lock);
@@ -728,7 +723,7 @@ static int init(struct ao *ao)
ao->device_buffer = p->size / af_fmt_to_bytes(ao->format);
p->chunksize = p->size;
p->chunk = malloc(p->size);
p->chunk = talloc_size(ao, p->size);
jobject timestamp = MP_JNI_NEW(AudioTimestamp.clazz, AudioTimestamp.ctor);
if (!timestamp || MP_JNI_EXCEPTION_LOG(ao) < 0) {
@@ -823,7 +818,7 @@ const struct ao_driver audio_out_audiotrack = {
.start = start,
.priv_size = sizeof(struct priv),
.options = (const struct m_option[]) {
{"pcm-float", OPT_FLAG(cfg_pcm_float)},
{"pcm-float", OPT_BOOL(cfg_pcm_float)},
{"session-id", OPT_INT(cfg_session_id)},
{0}
},
-1
View File
@@ -15,7 +15,6 @@
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "ao.h"
#include "internal.h"
#include "audio/format.h"
+10 -11
View File
@@ -17,7 +17,6 @@
#include <CoreAudio/HostTime.h>
#include "config.h"
#include "ao.h"
#include "internal.h"
#include "audio/format.h"
@@ -37,7 +36,7 @@ struct priv {
AudioStreamBasicDescription original_asbd;
AudioStreamID original_asbd_stream;
int change_physical_format;
bool change_physical_format;
};
static int64_t ca_get_hardware_latency(struct ao *ao) {
@@ -83,7 +82,7 @@ static OSStatus render_cb_lpcm(void *ctx, AudioUnitRenderActionFlags *aflags,
return noErr;
}
static int get_volume(struct ao *ao, struct ao_control_vol *vol) {
static int get_volume(struct ao *ao, float *vol) {
struct priv *p = ao->priv;
float auvol;
OSStatus err =
@@ -91,15 +90,15 @@ static int get_volume(struct ao *ao, struct ao_control_vol *vol) {
kAudioUnitScope_Global, 0, &auvol);
CHECK_CA_ERROR("could not get HAL output volume");
vol->left = vol->right = auvol * 100.0;
*vol = auvol * 100.0;
return CONTROL_TRUE;
coreaudio_error:
return CONTROL_ERROR;
}
static int set_volume(struct ao *ao, struct ao_control_vol *vol) {
static int set_volume(struct ao *ao, float *vol) {
struct priv *p = ao->priv;
float auvol = (vol->left + vol->right) / 200.0;
float auvol = *vol / 100.0;
OSStatus err =
AudioUnitSetParameter(p->audio_unit, kHALOutputParam_Volume,
kAudioUnitScope_Global, 0, auvol, 0);
@@ -314,11 +313,11 @@ coreaudio_error:
return false;
}
static void stop(struct ao *ao)
static void reset(struct ao *ao)
{
struct priv *p = ao->priv;
OSStatus err = AudioOutputUnitStop(p->audio_unit);
CHECK_CA_WARN("can't stop audio unit");
OSStatus err = AudioUnitReset(p->audio_unit, kAudioUnitScope_Global, 0);
CHECK_CA_WARN("can't reset audio unit");
}
static void start(struct ao *ao)
@@ -415,14 +414,14 @@ const struct ao_driver audio_out_coreaudio = {
.uninit = uninit,
.init = init,
.control = control,
.reset = stop,
.reset = reset,
.start = start,
.hotplug_init = hotplug_init,
.hotplug_uninit = hotplug_uninit,
.list_devs = ca_get_device_list,
.priv_size = sizeof(struct priv),
.options = (const struct m_option[]){
{"change-physical-format", OPT_FLAG(change_physical_format)},
{"change-physical-format", OPT_BOOL(change_physical_format)},
{0}
},
.options_prefix = "coreaudio",
+2 -3
View File
@@ -39,7 +39,6 @@
#include <libavutil/intreadwrite.h>
#include <libavutil/intfloat.h>
#include "config.h"
#include "ao.h"
#include "internal.h"
#include "audio/format.h"
@@ -73,7 +72,7 @@ struct priv {
AudioStreamBasicDescription original_asbd;
// Output s16 physical format, float32 virtual format, ac3/dts mpv format
int spdif_hack;
bool spdif_hack;
bool changed_mixing;
@@ -465,7 +464,7 @@ const struct ao_driver audio_out_coreaudio_exclusive = {
.changed_mixing = false,
},
.options = (const struct m_option[]){
{"spdif-hack", OPT_FLAG(spdif_hack)},
{"spdif-hack", OPT_BOOL(spdif_hack)},
{0}
},
.options_prefix = "coreaudio",
+9 -16
View File
@@ -35,21 +35,6 @@
#include <mach/mach_time.h>
#endif
CFStringRef cfstr_from_cstr(char *str)
{
return CFStringCreateWithCString(NULL, str, CA_CFSTR_ENCODING);
}
char *cfstr_get_cstr(CFStringRef cfstr)
{
CFIndex size =
CFStringGetMaximumSizeForEncoding(
CFStringGetLength(cfstr), CA_CFSTR_ENCODING) + 1;
char *buffer = talloc_zero_size(NULL, size);
CFStringGetCString(cfstr, buffer, size, CA_CFSTR_ENCODING);
return buffer;
}
#if HAVE_COREAUDIO
static bool ca_is_output_device(struct ao *ao, AudioDeviceID dev)
{
@@ -456,7 +441,15 @@ int64_t ca_get_device_latency_us(struct ao *ao, AudioDeviceID device)
}
}
return ca_frames_to_us(ao, latency_frames);
double sample_rate = ao->samplerate;
OSStatus err = CA_GET_O(device, kAudioDevicePropertyNominalSampleRate,
&sample_rate);
CHECK_CA_WARN("cannot get device sample rate, falling back to AO sample rate!");
if (err == noErr) {
MP_VERBOSE(ao, "Device sample rate: %f\n", sample_rate);
}
return latency_frames / sample_rate * 1e6;
}
static OSStatus ca_change_format_listener(
+1 -5
View File
@@ -25,11 +25,7 @@
#include "common/msg.h"
#include "audio/out/ao.h"
#include "internal.h"
#define CA_CFSTR_ENCODING kCFStringEncodingUTF8
CFStringRef cfstr_from_cstr(char *str);
char *cfstr_get_cstr(CFStringRef cfstr);
#include "osdep/apple_utils.h"
bool check_ca_st(struct ao *ao, int level, OSStatus code, const char *message);
+5 -5
View File
@@ -47,8 +47,8 @@
struct jack_opts {
char *port;
char *client_name;
int connect;
int autostart;
bool connect;
bool autostart;
int stdlayout;
};
@@ -57,15 +57,15 @@ static const struct m_sub_options ao_jack_conf = {
.opts = (const struct m_option[]){
{"jack-port", OPT_STRING(port)},
{"jack-name", OPT_STRING(client_name)},
{"jack-autostart", OPT_FLAG(autostart)},
{"jack-connect", OPT_FLAG(connect)},
{"jack-autostart", OPT_BOOL(autostart)},
{"jack-connect", OPT_BOOL(connect)},
{"jack-std-channel-layout", OPT_CHOICE(stdlayout,
{"waveext", 0}, {"any", 1})},
{0}
},
.defaults = &(const struct jack_opts) {
.client_name = "mpv",
.connect = 1,
.connect = true,
},
.size = sizeof(struct jack_opts),
};
+1 -12
View File
@@ -182,18 +182,8 @@ fail:
static void uninit(struct ao *ao)
{
struct priv *ac = ao->priv;
struct encode_lavc_context *ectx = ao->encode_lavc_ctx;
if (!ac->shutdown) {
double outpts = ac->expected_next_pts;
pthread_mutex_lock(&ectx->lock);
if (!ac->enc->options->rawts)
outpts += ectx->discontinuity_pts_offset;
pthread_mutex_unlock(&ectx->lock);
outpts += encoder_get_offset(ac->enc);
if (!write_frame(ao, MP_EOF_FRAME))
MP_WARN(ao, "could not flush last frame\n");
encoder_encode(ac->enc, NULL);
@@ -210,8 +200,7 @@ static void encode(struct ao *ao, struct mp_aframe *af)
double outpts = mp_aframe_get_pts(af);
AVFrame *frame = mp_aframe_to_avframe(af);
if (!frame)
abort();
MP_HANDLE_OOM(frame);
frame->pts = rint(outpts * av_q2d(av_inv_q(encoder->time_base)));
+6 -7
View File
@@ -28,7 +28,6 @@
#include "mpv_talloc.h"
#include "config.h"
#include "osdep/timer.h"
#include "options/m_option.h"
#include "common/common.h"
@@ -44,13 +43,13 @@ struct priv {
int buffersize; // samples
bool playing;
int untimed;
bool untimed;
float bufferlen; // seconds
float speed; // multiplier
float latency_sec; // seconds
float latency; // samples
int broken_eof;
int broken_delay;
bool broken_eof;
bool broken_delay;
// Minimal unit of audio samples that can be written at once. If play() is
// called with sizes not aligned to this, a rounded size will be returned.
@@ -216,13 +215,13 @@ const struct ao_driver audio_out_null = {
.speed = 1,
},
.options = (const struct m_option[]) {
{"untimed", OPT_FLAG(untimed)},
{"untimed", OPT_BOOL(untimed)},
{"buffer", OPT_FLOAT(bufferlen), M_RANGE(0, 100)},
{"outburst", OPT_INT(outburst), M_RANGE(1, 100000)},
{"speed", OPT_FLOAT(speed), M_RANGE(0, 10000)},
{"latency", OPT_FLOAT(latency_sec), M_RANGE(0, 100)},
{"broken-eof", OPT_FLAG(broken_eof)},
{"broken-delay", OPT_FLAG(broken_delay)},
{"broken-eof", OPT_BOOL(broken_eof)},
{"broken-delay", OPT_BOOL(broken_delay)},
{"channel-layouts", OPT_CHANNELS(channel_layouts)},
{"format", OPT_AUDIOFORMAT(format)},
{0}
+6 -8
View File
@@ -19,8 +19,6 @@
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
@@ -58,7 +56,7 @@ struct priv {
ALenum al_format;
int num_buffers;
int num_samples;
int direct_channels;
bool direct_channels;
};
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
@@ -67,13 +65,13 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
case AOCONTROL_GET_VOLUME:
case AOCONTROL_SET_VOLUME: {
ALfloat volume;
ao_control_vol_t *vol = (ao_control_vol_t *)arg;
float *vol = arg;
if (cmd == AOCONTROL_SET_VOLUME) {
volume = (vol->left + vol->right) / 200.0;
volume = *vol / 100.0;
alListenerf(AL_GAIN, volume);
}
alGetListenerf(AL_GAIN, &volume);
vol->left = vol->right = volume * 100;
*vol = volume * 100;
return CONTROL_TRUE;
}
case AOCONTROL_GET_MUTE:
@@ -391,12 +389,12 @@ const struct ao_driver audio_out_openal = {
.priv_defaults = &(const struct priv) {
.num_buffers = 4,
.num_samples = 8192,
.direct_channels = 1,
.direct_channels = true,
},
.options = (const struct m_option[]) {
{"num-buffers", OPT_INT(num_buffers), M_RANGE(2, MAX_BUF)},
{"num-samples", OPT_INT(num_samples), M_RANGE(256, MAX_SAMPLES)},
{"direct-channels", OPT_FLAG(direct_channels)},
{"direct-channels", OPT_BOOL(direct_channels)},
{0}
},
.options_prefix = "openal",
+6 -17
View File
@@ -4,7 +4,7 @@
* Original author: A'rpi
* Support for >2 output channels added 2001-11-25
* - Steve Davies <steve@daviesfam.org>
* Rozhuk Ivan <rozhuk.im@gmail.com> 2020
* Rozhuk Ivan <rozhuk.im@gmail.com> 2020-2023
*
* This file is part of mpv.
*
@@ -35,7 +35,6 @@
#endif
#include <sys/types.h>
#include "config.h"
#include "audio/format.h"
#include "common/msg.h"
#include "options/options.h"
@@ -53,7 +52,6 @@
struct priv {
int dsp_fd;
bool playing;
double bps; /* Bytes per second. */
};
@@ -116,7 +114,7 @@ static void device_descr_get(size_t dev_idx, char *buf, size_t buf_size)
snprintf(dev_path, sizeof(dev_path), PATH_DEV_MIXER"%zu", dev_idx);
int fd = open(dev_path, O_RDONLY);
if (ioctl(fd, SOUND_MIXER_INFO, &mi) == 0) {
strncpy(buf, mi.name, buf_size);
strncpy(buf, mi.name, buf_size - 1);
tmp = (buf_size - 1);
}
close(fd);
@@ -241,7 +239,6 @@ static int init(struct ao *ao)
ao->samplerate = samplerate;
ao->channels = channels;
p->bps = (channels.num * samplerate * af_fmt_to_bytes(format));
p->playing = false;
return 0;
@@ -261,13 +258,12 @@ static void uninit(struct ao *ao)
ioctl(p->dsp_fd, SNDCTL_DSP_HALT, NULL);
close(p->dsp_fd);
p->dsp_fd = -1;
p->playing = false;
}
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
{
struct priv *p = ao->priv;
ao_control_vol_t *vol = (ao_control_vol_t *)arg;
float *vol = arg;
int v;
if (p->dsp_fd < 0)
@@ -279,11 +275,10 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
MP_WARN_IOCTL_ERR(ao);
return CONTROL_ERROR;
}
vol->right = ((v & 0xff00) >> 8);
vol->left = (v & 0x00ff);
*vol = ((v & 0x00ff) + ((v & 0xff00) >> 8)) / 2.0;
return CONTROL_OK;
case AOCONTROL_SET_VOLUME:
v = ((int)vol->right << 8) | (int)vol->left;
v = ((int)*vol << 8) | (int)*vol;
if (ioctl(p->dsp_fd, SNDCTL_DSP_SETPLAYVOL, &v) == -1) {
MP_WARN_IOCTL_ERR(ao);
return CONTROL_ERROR;
@@ -300,7 +295,6 @@ static void reset(struct ao *ao)
int trig = 0;
/* Clear buf and do not start playback after data written. */
p->playing = false;
if (ioctl(p->dsp_fd, SNDCTL_DSP_HALT, NULL) == -1 ||
ioctl(p->dsp_fd, SNDCTL_DSP_SETTRIGGER, &trig) == -1)
{
@@ -320,7 +314,6 @@ static void start(struct ao *ao)
MP_WARN_IOCTL_ERR(ao);
return;
}
p->playing = true;
}
static bool audio_write(struct ao *ao, void **data, int samples)
@@ -337,13 +330,11 @@ static bool audio_write(struct ao *ao, void **data, int samples)
continue;
MP_WARN(ao, "audio_write: write() fail, err = %i: %s.\n",
errno, strerror(errno));
p->playing = false;
return false;
}
if ((size_t)rc != size) {
MP_WARN(ao, "audio_write: unexpected partial write: required: %zu, written: %zu.\n",
size, (size_t)rc);
p->playing = false;
return false;
}
@@ -360,7 +351,6 @@ static void get_state(struct ao *ao, struct mp_pcm_state *state)
ioctl(p->dsp_fd, SNDCTL_DSP_GETODELAY, &odelay) == -1)
{
MP_WARN_IOCTL_ERR(ao);
p->playing = false;
memset(state, 0x00, sizeof(struct mp_pcm_state));
state->delay = 0.0;
return;
@@ -368,7 +358,7 @@ static void get_state(struct ao *ao, struct mp_pcm_state *state)
state->free_samples = (info.bytes / ao->sstride);
state->queued_samples = (ao->device_buffer - state->free_samples);
state->delay = (odelay / p->bps);
state->playing = p->playing;
state->playing = (state->queued_samples != 0);
}
static void list_devs(struct ao *ao, struct ao_device_list *list)
@@ -406,6 +396,5 @@ const struct ao_driver audio_out_oss = {
.priv_size = sizeof(struct priv),
.priv_defaults = &(const struct priv) {
.dsp_fd = -1,
.playing = false,
},
};
+5 -7
View File
@@ -19,8 +19,6 @@
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -44,8 +42,8 @@
struct priv {
char *outputfilename;
int waveheader;
int append;
bool waveheader;
bool append;
uint64_t data_length;
FILE *fp;
};
@@ -239,11 +237,11 @@ const struct ao_driver audio_out_pcm = {
.start = start,
.reset = reset,
.priv_size = sizeof(struct priv),
.priv_defaults = &(const struct priv) { .waveheader = 1 },
.priv_defaults = &(const struct priv) { .waveheader = true },
.options = (const struct m_option[]) {
{"file", OPT_STRING(outputfilename), .flags = M_OPT_FILE},
{"waveheader", OPT_FLAG(waveheader)},
{"append", OPT_FLAG(append)},
{"waveheader", OPT_BOOL(waveheader)},
{"append", OPT_BOOL(append)},
{0}
},
.options_prefix = "ao-pcm",
+156 -75
View File
@@ -32,42 +32,46 @@
#include "options/m_option.h"
#include "ao.h"
#include "audio/format.h"
#include "config.h"
#include "generated/version.h"
#include "internal.h"
#include "osdep/timer.h"
// Added in Pipewire 0.3.33
// remove the fallback when we require a newer version
#ifndef PW_KEY_NODE_RATE
#define PW_KEY_NODE_RATE "node.rate"
#endif
// Added in Pipewire 0.3.44
// remove the fallback when we require a newer version
#ifndef PW_KEY_TARGET_OBJECT
#define PW_KEY_TARGET_OBJECT "target.object"
#endif
#if !PW_CHECK_VERSION(0, 3, 50)
static inline int pw_stream_get_time_n(struct pw_stream *stream, struct pw_time *time, size_t size) {
return pw_stream_get_time(stream, time);
}
#endif
#if !PW_CHECK_VERSION(0, 3, 57)
// Earlier versions segfault on zeroed hooks
#define spa_hook_remove(hook) if ((hook)->link.prev) spa_hook_remove(hook)
#endif
enum init_state {
INIT_STATE_NONE,
INIT_STATE_SUCCESS,
INIT_STATE_ERROR,
};
enum {
VOLUME_MODE_CHANNEL,
VOLUME_MODE_GLOBAL,
};
struct priv {
struct pw_thread_loop *loop;
struct pw_stream *stream;
struct pw_core *core;
struct spa_hook stream_listener;
struct spa_hook core_listener;
enum init_state init_state;
bool muted;
float volume[2];
float volume;
struct {
int buffer_msec;
char *remote;
int volume_mode;
} options;
struct {
@@ -136,7 +140,6 @@ static enum spa_audio_channel mp_speaker_id_to_spa(struct ao *ao, enum mp_speake
};
}
static void on_process(void *userdata)
{
struct ao *ao = userdata;
@@ -183,6 +186,8 @@ static void on_process(void *userdata)
}
pw_stream_queue_buffer(p->stream, b);
MP_TRACE(ao, "queued %d of %d samples\n", samples, nframes);
}
static void on_param_changed(void *userdata, uint32_t id, const struct spa_pod *param)
@@ -193,6 +198,14 @@ static void on_param_changed(void *userdata, uint32_t id, const struct spa_pod *
uint8_t buffer[1024];
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
/* We want to know when our node is linked.
* As there is no proper callback for this we use the Latency param for this
*/
if (id == SPA_PARAM_Latency) {
p->init_state = INIT_STATE_SUCCESS;
pw_thread_loop_signal(p->loop, false);
}
if (param == NULL || id != SPA_PARAM_Format)
return;
@@ -201,7 +214,8 @@ static void on_param_changed(void *userdata, uint32_t id, const struct spa_pod *
params[0] = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(ao->num_planes),
SPA_PARAM_BUFFERS_size, SPA_POD_Int(buffer_size),
SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int(
buffer_size, 0, INT32_MAX),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(ao->sstride));
if (!params[0]) {
MP_ERR(ao, "Could not build parameter pod\n");
@@ -217,10 +231,14 @@ static void on_param_changed(void *userdata, uint32_t id, const struct spa_pod *
static void on_state_changed(void *userdata, enum pw_stream_state old, enum pw_stream_state state, const char *error)
{
struct ao *ao = userdata;
MP_DBG(ao, "Stream state changed: old_state=%d state=%d error=%s\n", old, state, error);
struct priv *p = ao->priv;
MP_DBG(ao, "Stream state changed: old_state=%s state=%s error=%s\n",
pw_stream_state_as_string(old), pw_stream_state_as_string(state), error);
if (state == PW_STREAM_STATE_ERROR) {
MP_WARN(ao, "Stream in error state, trying to reload...\n");
p->init_state = INIT_STATE_ERROR;
pw_thread_loop_signal(p->loop, false);
ao_request_reload(ao);
}
@@ -260,14 +278,16 @@ static void on_control_info(void *userdata, uint32_t id,
p->muted = control->values[0] >= 0.5;
break;
case SPA_PROP_channelVolumes:
if (control->n_values == 2) {
p->volume[0] = control->values[0];
p->volume[1] = control->values[1];
} else if (control->n_values > 0) {
float volume = volume_avg(control->values, control->n_values);
p->volume[0] = volume;
p->volume[1] = volume;
}
if (p->options.volume_mode != VOLUME_MODE_CHANNEL)
break;
if (control->n_values > 0)
p->volume = volume_avg(control->values, control->n_values);
break;
case SPA_PROP_volume:
if (p->options.volume_mode != VOLUME_MODE_GLOBAL)
break;
if (control->n_values > 0)
p->volume = control->values[0];
break;
}
}
@@ -290,9 +310,8 @@ static void uninit(struct ao *ao)
if (p->stream)
pw_stream_destroy(p->stream);
p->stream = NULL;
if (p->core) {
if (p->core)
pw_context_destroy(pw_core_get_context(p->core));
}
p->core = NULL;
if (p->loop)
pw_thread_loop_destroy(p->loop);
@@ -335,6 +354,11 @@ static void for_each_sink_registry_event_global(void *data, uint32_t id,
}
struct for_each_done_ctx {
struct pw_thread_loop *loop;
bool done;
};
static const struct pw_registry_events for_each_sink_registry_events = {
.version = PW_VERSION_REGISTRY_EVENTS,
.global = for_each_sink_registry_event_global,
@@ -342,8 +366,9 @@ static const struct pw_registry_events for_each_sink_registry_events = {
static void for_each_sink_done(void *data, uint32_t it, int seq)
{
struct pw_thread_loop *loop = data;
pw_thread_loop_signal(loop, false);
struct for_each_done_ctx *ctx = data;
ctx->done = true;
pw_thread_loop_signal(ctx->loop, false);
}
static const struct pw_core_events for_each_sink_core_events = {
@@ -357,12 +382,16 @@ static int for_each_sink(struct ao *ao, void (cb) (struct ao *ao, uint32_t id,
struct priv *priv = ao->priv;
struct pw_registry *registry;
struct spa_hook core_listener;
struct for_each_done_ctx done_ctx = {
.loop = priv->loop,
.done = false,
};
int ret = -1;
pw_thread_loop_lock(priv->loop);
spa_zero(core_listener);
if (pw_core_add_listener(priv->core, &core_listener, &for_each_sink_core_events, priv->loop) < 0)
if (pw_core_add_listener(priv->core, &core_listener, &for_each_sink_core_events, &done_ctx) < 0)
goto unlock_loop;
registry = pw_core_get_registry(priv->core, PW_VERSION_REGISTRY, 0);
@@ -381,7 +410,8 @@ static int for_each_sink(struct ao *ao, void (cb) (struct ao *ao, uint32_t id,
if (pw_registry_add_listener(registry, &registry_listener, &for_each_sink_registry_events, &revents_ctx) < 0)
goto destroy_registry;
pw_thread_loop_wait(priv->loop);
while (!done_ctx.done)
pw_thread_loop_wait(priv->loop);
spa_hook_remove(&registry_listener);
@@ -422,9 +452,20 @@ static void on_error(void *data, uint32_t id, int seq, int res, const char *mess
MP_WARN(ao, "Error during playback: %s, %s\n", spa_strerror(res), message);
}
static void on_core_info(void *data, const struct pw_core_info *info)
{
struct ao *ao = data;
MP_VERBOSE(ao, "Core user: %s\n", info->user_name);
MP_VERBOSE(ao, "Core host: %s\n", info->host_name);
MP_VERBOSE(ao, "Core version: %s\n", info->version);
MP_VERBOSE(ao, "Core name: %s\n", info->name);
}
static const struct pw_core_events core_events = {
.version = PW_VERSION_CORE_EVENTS,
.error = on_error,
.info = on_core_info,
};
static int pipewire_init_boilerplate(struct ao *ao)
@@ -434,8 +475,10 @@ static int pipewire_init_boilerplate(struct ao *ao)
pw_init(NULL, NULL);
MP_VERBOSE(ao, "Headers version: %s\n", pw_get_headers_version());
MP_VERBOSE(ao, "Library version: %s\n", pw_get_library_version());
p->loop = pw_thread_loop_new("ao-pipewire", NULL);
p->loop = pw_thread_loop_new("mpv/ao/pipewire", NULL);
if (p->loop == NULL)
return -1;
@@ -444,7 +487,10 @@ static int pipewire_init_boilerplate(struct ao *ao)
if (pw_thread_loop_start(p->loop) < 0)
goto error;
context = pw_context_new(pw_thread_loop_get_loop(p->loop), NULL, 0);
context = pw_context_new(
pw_thread_loop_get_loop(p->loop),
pw_properties_new(PW_KEY_CONFIG_NAME, "client-rt.conf", NULL),
0);
if (!context)
goto error;
@@ -453,8 +499,10 @@ static int pipewire_init_boilerplate(struct ao *ao)
pw_properties_new(PW_KEY_REMOTE_NAME, p->options.remote, NULL),
0);
if (!p->core) {
MP_WARN(ao, "Could not connect to context '%s': %s\n",
p->options.remote, strerror(errno));
MP_MSG(ao, ao->probing ? MSGL_V : MSGL_ERR,
"Could not connect to context '%s': %s\n",
p->options.remote, strerror(errno));
pw_context_destroy(context);
goto error;
}
@@ -475,6 +523,26 @@ error:
return -1;
}
static void wait_for_init_done(struct ao *ao)
{
struct priv *p = ao->priv;
struct timespec abstime;
int r;
r = pw_thread_loop_get_time(p->loop, &abstime, 50 * SPA_NSEC_PER_MSEC);
if (r < 0) {
MP_WARN(ao, "Could not get timeout for initialization: %s\n", spa_strerror(r));
return;
}
while (p->init_state == INIT_STATE_NONE) {
r = pw_thread_loop_timed_wait_full(p->loop, &abstime);
if (r < 0) {
MP_WARN(ao, "Could not wait for initialization: %s\n", spa_strerror(r));
return;
}
}
}
static int init(struct ao *ao)
{
@@ -496,11 +564,14 @@ static int init(struct ao *ao)
);
if (pipewire_init_boilerplate(ao) < 0)
goto error;
goto error_props;
ao->device_buffer = p->options.buffer_msec * ao->samplerate / 1000;
if (p->options.buffer_msec) {
ao->device_buffer = p->options.buffer_msec * ao->samplerate / 1000;
pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%d/%d", ao->device_buffer, ao->samplerate);
}
pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%d/%d", ao->device_buffer, ao->samplerate);
pw_properties_setf(props, PW_KEY_NODE_RATE, "1/%d", ao->samplerate);
enum spa_audio_format spa_format = af_fmt_to_pw(ao, ao->format);
@@ -520,7 +591,7 @@ static int init(struct ao *ao)
params[0] = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, &audio_info);
if (!params[0])
goto error;
goto error_props;
if (af_fmt_is_planar(ao->format)) {
ao->num_planes = ao->channels.num;
@@ -532,34 +603,39 @@ static int init(struct ao *ao)
pw_thread_loop_lock(p->loop);
p->stream = pw_stream_new(
p->core,
"audio-src",
props);
p->stream = pw_stream_new(p->core, "audio-src", props);
if (p->stream == NULL) {
pw_thread_loop_unlock(p->loop);
goto error;
}
pw_stream_add_listener(p->stream,
&p->stream_listener,
&stream_events, ao);
pw_stream_add_listener(p->stream, &p->stream_listener, &stream_events, ao);
enum pw_stream_flags flags = PW_STREAM_FLAG_AUTOCONNECT |
PW_STREAM_FLAG_INACTIVE |
PW_STREAM_FLAG_MAP_BUFFERS |
PW_STREAM_FLAG_RT_PROCESS;
if (ao->init_flags & AO_INIT_EXCLUSIVE)
flags |= PW_STREAM_FLAG_EXCLUSIVE;
if (pw_stream_connect(p->stream,
PW_DIRECTION_OUTPUT, PW_ID_ANY,
PW_STREAM_FLAG_AUTOCONNECT |
PW_STREAM_FLAG_INACTIVE |
PW_STREAM_FLAG_MAP_BUFFERS |
PW_STREAM_FLAG_RT_PROCESS,
params, 1) < 0) {
PW_DIRECTION_OUTPUT, PW_ID_ANY, flags, params, 1) < 0) {
pw_thread_loop_unlock(p->loop);
goto error;
}
wait_for_init_done(ao);
pw_thread_loop_unlock(p->loop);
if (p->init_state == INIT_STATE_ERROR)
goto error;
return 0;
error_props:
pw_properties_free(props);
error:
uninit(ao);
return -1;
@@ -590,9 +666,8 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
switch (cmd) {
case AOCONTROL_GET_VOLUME: {
struct ao_control_vol *vol = arg;
vol->left = spa_volume_to_mp_volume(p->volume[0]);
vol->right = spa_volume_to_mp_volume(p->volume[1]);
float *vol = arg;
*vol = spa_volume_to_mp_volume(p->volume);
return CONTROL_OK;
}
case AOCONTROL_GET_MUTE: {
@@ -609,19 +684,21 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
pw_thread_loop_lock(p->loop);
switch (cmd) {
case AOCONTROL_SET_VOLUME: {
struct ao_control_vol *vol = arg;
float *vol = arg;
uint8_t n = ao->channels.num;
float values[MP_NUM_CHANNELS] = {0};
if (n == 2) {
values[0] = mp_volume_to_spa_volume(vol->left);
values[1] = mp_volume_to_spa_volume(vol->right);
} else {
if (p->options.volume_mode == VOLUME_MODE_CHANNEL) {
float values[MP_NUM_CHANNELS] = {0};
for (int i = 0; i < n; i++)
values[i] = mp_volume_to_spa_volume(vol->left);
values[i] = mp_volume_to_spa_volume(*vol);
ret = CONTROL_RET(pw_stream_set_control(
p->stream, SPA_PROP_channelVolumes, n, values, 0));
} else {
float value = mp_volume_to_spa_volume(*vol);
ret = CONTROL_RET(pw_stream_set_control(
p->stream, SPA_PROP_volume, 1, &value, 0));
}
ret = CONTROL_RET(pw_stream_set_control(p->stream, SPA_PROP_channelVolumes, n, values, 0));
break;
}
}
case AOCONTROL_SET_MUTE: {
bool *muted = arg;
float value = *muted ? 1.f : 0.f;
@@ -690,7 +767,7 @@ static void hotplug_registry_global_cb(void *data, uint32_t id,
return;
pw_thread_loop_lock(priv->loop);
struct id_list *item = talloc_size(ao, sizeof(*item));
struct id_list *item = talloc(ao, struct id_list);
item->id = id;
spa_list_init(&item->node);
spa_list_append(&priv->hotplug.sinks, &item->node);
@@ -713,10 +790,10 @@ static void hotplug_registry_global_remove_cb(void *data, uint32_t id)
removed_sink = true;
spa_list_remove(&e->node);
talloc_free(e);
goto done;
break;
}
}
done:
pw_thread_loop_unlock(priv->loop);
if (removed_sink)
@@ -729,24 +806,22 @@ static const struct pw_registry_events hotplug_registry_events = {
.global_remove = hotplug_registry_global_remove_cb,
};
static int hotplug_init(struct ao *ao)
{
struct priv *priv = ao->priv;
int res = pipewire_init_boilerplate(ao);
if (res)
return res;
goto error_no_unlock;
pw_thread_loop_lock(priv->loop);
spa_memzero(&priv->hotplug, sizeof(priv->hotplug));
spa_zero(priv->hotplug);
spa_list_init(&priv->hotplug.sinks);
priv->hotplug.registry = pw_core_get_registry(priv->core, PW_VERSION_REGISTRY, 0);
if (!priv->hotplug.registry) {
if (!priv->hotplug.registry)
goto error;
}
if (pw_registry_add_listener(priv->hotplug.registry, &priv->hotplug.registry_listener, &hotplug_registry_events, ao) < 0) {
pw_proxy_destroy((struct pw_proxy *)priv->hotplug.registry);
@@ -759,6 +834,7 @@ static int hotplug_init(struct ao *ao)
error:
pw_thread_loop_unlock(priv->loop);
error_no_unlock:
uninit(ao);
return -1;
}
@@ -806,12 +882,17 @@ const struct ao_driver audio_out_pipewire = {
{
.loop = NULL,
.stream = NULL,
.options.buffer_msec = 20,
.init_state = INIT_STATE_NONE,
.options.buffer_msec = 0,
.options.volume_mode = VOLUME_MODE_CHANNEL,
},
.options_prefix = "pipewire",
.options = (const struct m_option[]) {
{"buffer", OPT_INT(options.buffer_msec), M_RANGE(1, 2000)},
{"buffer", OPT_CHOICE(options.buffer_msec, {"native", 0}),
M_RANGE(1, 2000)},
{"remote", OPT_STRING(options.remote) },
{"volume-mode", OPT_CHOICE(options.volume_mode,
{"channel", VOLUME_MODE_CHANNEL}, {"global", VOLUME_MODE_GLOBAL})},
{0}
},
};
+11 -22
View File
@@ -28,7 +28,6 @@
#include <pulse/pulseaudio.h>
#include "config.h"
#include "audio/format.h"
#include "common/msg.h"
#include "options/m_option.h"
@@ -57,8 +56,8 @@ struct priv {
char *cfg_host;
int cfg_buffer;
int cfg_latency_hacks;
int cfg_allow_suspended;
bool cfg_latency_hacks;
bool cfg_allow_suspended;
};
#define GENERIC_ERR_MSG(str) \
@@ -680,14 +679,8 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
// we naively copied the struct, without updating pointers etc.
// Pointers might point to invalid data, accessors might fail.
if (cmd == AOCONTROL_GET_VOLUME) {
ao_control_vol_t *vol = arg;
if (priv->pi.volume.channels != 2)
vol->left = vol->right =
VOL_PA2MP(pa_cvolume_avg(&priv->pi.volume));
else {
vol->left = VOL_PA2MP(priv->pi.volume.values[0]);
vol->right = VOL_PA2MP(priv->pi.volume.values[1]);
}
float *vol = arg;
*vol = VOL_PA2MP(pa_cvolume_avg(&priv->pi.volume));
} else if (cmd == AOCONTROL_GET_MUTE) {
bool *mute = arg;
*mute = priv->pi.mute;
@@ -701,16 +694,11 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
priv->retval = 0;
uint32_t stream_index = pa_stream_get_index(priv->stream);
if (cmd == AOCONTROL_SET_VOLUME) {
const ao_control_vol_t *vol = arg;
const float *vol = arg;
struct pa_cvolume volume;
pa_cvolume_reset(&volume, ao->channels.num);
if (volume.channels != 2)
pa_cvolume_set(&volume, volume.channels, VOL_MP2PA(vol->left));
else {
volume.values[0] = VOL_MP2PA(vol->left);
volume.values[1] = VOL_MP2PA(vol->right);
}
pa_cvolume_set(&volume, volume.channels, VOL_MP2PA(*vol));
if (!waitop(priv, pa_context_set_sink_input_volume(priv->context,
stream_index,
&volume,
@@ -729,8 +717,9 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
GENERIC_ERR_MSG("pa_context_set_sink_input_mute() failed");
return CONTROL_ERROR;
}
} else
abort();
} else {
MP_ASSERT_UNREACHABLE();
}
return CONTROL_OK;
}
@@ -821,8 +810,8 @@ const struct ao_driver audio_out_pulse = {
{"host", OPT_STRING(cfg_host)},
{"buffer", OPT_CHOICE(cfg_buffer, {"native", 0}),
M_RANGE(1, 2000)},
{"latency-hacks", OPT_FLAG(cfg_latency_hacks)},
{"allow-suspended", OPT_FLAG(cfg_allow_suspended)},
{"latency-hacks", OPT_BOOL(cfg_latency_hacks)},
{"allow-suspended", OPT_BOOL(cfg_allow_suspended)},
{0}
},
.options_prefix = "pulse",
-1
View File
@@ -18,7 +18,6 @@
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "audio/format.h"
#include "mpv_talloc.h"
#include "ao.h"
+3 -5
View File
@@ -17,8 +17,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "config.h"
#include <sys/types.h>
#include <poll.h>
#include <errno.h>
@@ -211,18 +209,18 @@ static void uninit(struct ao *ao)
static int control(struct ao *ao, enum aocontrol cmd, void *arg)
{
struct priv *p = ao->priv;
ao_control_vol_t *vol = arg;
float *vol = arg;
switch (cmd) {
case AOCONTROL_GET_VOLUME:
if (!p->havevol)
return CONTROL_FALSE;
vol->left = vol->right = p->vol * 100 / SIO_MAXVOL;
*vol = p->vol * 100 / SIO_MAXVOL;
break;
case AOCONTROL_SET_VOLUME:
if (!p->havevol)
return CONTROL_FALSE;
sio_setvol(p->hdl, vol->left * SIO_MAXVOL / 100);
sio_setvol(p->hdl, *vol * SIO_MAXVOL / 100);
break;
default:
return CONTROL_UNKNOWN;
+25 -23
View File
@@ -348,13 +348,10 @@ static int thread_control_exclusive(struct ao *ao, enum aocontrol cmd, void *arg
case AOCONTROL_GET_VOLUME:
IAudioEndpointVolume_GetMasterVolumeLevelScalar(
state->pEndpointVolume, &volume);
*(ao_control_vol_t *)arg = (ao_control_vol_t){
.left = 100.0f * volume,
.right = 100.0f * volume,
};
*(float *)arg = volume;
return CONTROL_OK;
case AOCONTROL_SET_VOLUME:
volume = ((ao_control_vol_t *)arg)->left / 100.f;
volume = (*(float *)arg) / 100.f;
IAudioEndpointVolume_SetMasterVolumeLevelScalar(
state->pEndpointVolume, volume, NULL);
return CONTROL_OK;
@@ -381,13 +378,10 @@ static int thread_control_shared(struct ao *ao, enum aocontrol cmd, void *arg)
switch(cmd) {
case AOCONTROL_GET_VOLUME:
ISimpleAudioVolume_GetMasterVolume(state->pAudioVolume, &volume);
*(ao_control_vol_t *)arg = (ao_control_vol_t){
.left = 100.0f * volume,
.right = 100.0f * volume,
};
*(float *)arg = volume;
return CONTROL_OK;
case AOCONTROL_SET_VOLUME:
volume = ((ao_control_vol_t *)arg)->left / 100.f;
volume = (*(float *)arg) / 100.f;
ISimpleAudioVolume_SetMasterVolume(state->pAudioVolume, volume, NULL);
return CONTROL_OK;
case AOCONTROL_GET_MUTE:
@@ -412,20 +406,28 @@ static int thread_control(struct ao *ao, enum aocontrol cmd, void *arg)
if (!state->pSessionControl)
return CONTROL_FALSE;
wchar_t *title = mp_from_utf8(NULL, (char*)arg);
wchar_t *tmp = NULL;
// There is a weird race condition in the IAudioSessionControl itself --
// it seems that *sometimes* the SetDisplayName does not take effect and
// it still shows the old title. Use this loop to insist until it works.
do {
IAudioSessionControl_SetDisplayName(state->pSessionControl, title, NULL);
SAFE_DESTROY(tmp, CoTaskMemFree(tmp));
IAudioSessionControl_GetDisplayName(state->pSessionControl, &tmp);
} while (wcscmp(title, tmp));
SAFE_DESTROY(tmp, CoTaskMemFree(tmp));
wchar_t *title = mp_from_utf8(NULL, (const char *)arg);
HRESULT hr = IAudioSessionControl_SetDisplayName(state->pSessionControl,
title,NULL);
talloc_free(title);
return CONTROL_OK;
if (SUCCEEDED(hr))
return CONTROL_OK;
MP_WARN(ao, "Error setting audio session name: %s\n",
mp_HRESULT_to_str(hr));
assert(ao->client_name);
if (!ao->client_name)
return CONTROL_ERROR;
// Fallback to client name
title = mp_from_utf8(NULL, ao->client_name);
IAudioSessionControl_SetDisplayName(state->pSessionControl,
title, NULL);
talloc_free(title);
return CONTROL_ERROR;
}
return state->share_mode == AUDCLNT_SHAREMODE_EXCLUSIVE ?
+11 -7
View File
@@ -31,8 +31,6 @@
#include "osdep/strnlen.h"
#include "ao_wasapi.h"
#define MIXER_DEFAULT_LABEL L"mpv - video player"
DEFINE_PROPERTYKEY(mp_PKEY_Device_FriendlyName,
0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20,
0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14);
@@ -545,7 +543,7 @@ exit_label:
return hr;
}
static void init_session_display(struct wasapi_state *state) {
static void init_session_display(struct wasapi_state *state, const char *name) {
HRESULT hr = IAudioClient_GetService(state->pAudioClient,
&IID_IAudioSessionControl,
(void **)&state->pSessionControl);
@@ -560,14 +558,20 @@ static void init_session_display(struct wasapi_state *state) {
mp_HRESULT_to_str(hr));
}
hr = IAudioSessionControl_SetDisplayName(state->pSessionControl,
MIXER_DEFAULT_LABEL, NULL);
assert(name);
if (!name)
return;
wchar_t *title = mp_from_utf8(NULL, name);
hr = IAudioSessionControl_SetDisplayName(state->pSessionControl, title, NULL);
talloc_free(title);
EXIT_ON_ERROR(hr);
return;
exit_label:
// if we got here then the session control is useless - release it
SAFE_RELEASE(state->pSessionControl);
MP_WARN(state, "Error setting audio session display name: %s\n",
MP_WARN(state, "Error setting audio session name: %s\n",
mp_HRESULT_to_str(hr));
return;
}
@@ -668,7 +672,7 @@ static HRESULT fix_format(struct ao *ao, bool align_hack)
hr = init_clock(state);
EXIT_ON_ERROR(hr);
init_session_display(state);
init_session_display(state, ao->client_name);
init_volume_control(state);
#if !HAVE_UWP
+13 -11
View File
@@ -357,7 +357,7 @@ void ao_set_paused(struct ao *ao, bool paused)
pthread_mutex_lock(&p->lock);
if (p->playing && !p->paused && paused) {
if ((p->playing || !ao->driver->write) && !p->paused && paused) {
if (p->streaming && !ao->stream_silence) {
if (ao->driver->write) {
if (!p->recover_pause)
@@ -459,7 +459,7 @@ void ao_uninit(struct ao *ao)
{
struct buffer_state *p = ao->buffer_state;
if (p->thread_valid) {
if (p && p->thread_valid) {
pthread_mutex_lock(&p->pt_lock);
p->terminate = true;
pthread_cond_broadcast(&p->pt_wakeup);
@@ -472,17 +472,19 @@ void ao_uninit(struct ao *ao)
if (ao->driver_initialized)
ao->driver->uninit(ao);
talloc_free(p->filter_root);
talloc_free(p->queue);
talloc_free(p->pending);
talloc_free(p->convert_buffer);
talloc_free(p->temp_buf);
if (p) {
talloc_free(p->filter_root);
talloc_free(p->queue);
talloc_free(p->pending);
talloc_free(p->convert_buffer);
talloc_free(p->temp_buf);
pthread_cond_destroy(&p->wakeup);
pthread_mutex_destroy(&p->lock);
pthread_cond_destroy(&p->wakeup);
pthread_mutex_destroy(&p->lock);
pthread_cond_destroy(&p->pt_wakeup);
pthread_mutex_destroy(&p->pt_lock);
pthread_cond_destroy(&p->pt_wakeup);
pthread_mutex_destroy(&p->pt_lock);
}
talloc_free(ao);
}
+2 -2
View File
@@ -5,10 +5,10 @@
import os, sys, stat, hashlib, subprocess
from urllib.request import urlopen, URLError
WAFRELEASE = "waf-2.0.24"
WAFRELEASE = "waf-2.0.25"
WAFURLS = ["https://waf.io/" + WAFRELEASE,
"https://www.freehackers.org/~tnagy/release/" + WAFRELEASE]
SHA256HASH = "93909bca823a675f9f40af7c65b24887c3a3c0efdf411ff1978ba827194bdeb0"
SHA256HASH = "21199cd220ccf60434133e1fd2ab8c8e5217c3799199c82722543970dc8e38d5"
if os.path.exists("waf"):
wafver = subprocess.check_output([sys.executable, './waf', '--version']).decode()
+4 -1
View File
@@ -12,6 +12,7 @@ meson setup build \
-Dopenal=enabled \
-Dsdl2=enabled \
-Dsndio=enabled \
-Dtests=true \
-Dvdpau=enabled \
-Dvulkan=enabled \
-Doss-audio=enabled \
@@ -22,13 +23,14 @@ meson setup build \
$NULL
meson compile -C build
./build/mpv
./build/mpv -v --no-config
if [ ! -e "./waf" ] ; then
python3 ./bootstrap.py
fi
python3 ./waf configure \
--out=build_waf \
--enable-libmpv-shared \
--enable-lua \
--enable-egl-drm \
@@ -45,3 +47,4 @@ python3 ./waf configure \
$NULL
python3 ./waf build
./build_waf/mpv -v --no-config
+4 -5
View File
@@ -14,14 +14,13 @@ if [[ $1 = "meson" ]]; then
PKG_CONFIG_PATH="${FFMPEG_SYSROOT}/lib/pkgconfig/" CC="${CC}" CXX="${CXX}" \
meson setup build \
-Dprefix="${MPV_INSTALL_PREFIX}" \
-Dlibmpv=true \
-D{libmpv,tests}=true \
-D{gl,iconv,lcms2,lua,jpeg,plain-gl,zlib}=enabled \
-D{cocoa,coreaudio,gl-cocoa,macos-cocoa-cb,macos-touchbar,videotoolbox-gl}=enabled
meson compile -C build -j4
meson install -C build
./build/mpv
./build/mpv -v --no-config
fi
if [[ $1 = "waf" ]]; then
@@ -31,6 +30,7 @@ if [[ $1 = "waf" ]]; then
PKG_CONFIG_PATH="${FFMPEG_SYSROOT}/lib/pkgconfig/" CC="${CC}" CXX="${CXX}" python3 \
./waf configure \
--out=build_waf \
--variant="${MPV_VARIANT}" \
--prefix="${MPV_INSTALL_PREFIX}" \
--enable-{gl,iconv,lcms2,libmpv-shared,lua,jpeg,plain-gl,zlib} \
@@ -38,7 +38,6 @@ if [[ $1 = "waf" ]]; then
--swift-flags="${CI_SWIFT_FLAGS}"
python3 ./waf build --variant="${MPV_VARIANT}" -j4
python3 ./waf install --variant="${MPV_VARIANT}"
./build/mpv
${MPV_INSTALL_PREFIX}/bin/mpv -v --no-config
fi
+13 -11
View File
@@ -35,6 +35,7 @@ ar = '${AR}'
strip = '${TARGET}-strip'
pkgconfig = 'pkg-config'
windres = '${TARGET}-windres'
dlltool = '${TARGET}-dlltool'
[host_machine]
system = 'windows'
cpu_family = '${fam}'
@@ -77,7 +78,7 @@ fi
## zlib
if [ ! -e "$prefix_dir/lib/libz.dll.a" ]; then
ver=1.2.12
ver=1.2.13
gettar "https://zlib.net/fossils/zlib-${ver}.tar.gz"
pushd zlib-${ver}
make -fwin32/Makefile.gcc clean
@@ -134,8 +135,8 @@ fi
## freetype2
if [ ! -e "$prefix_dir/lib/libfreetype.dll.a" ]; then
ver=2.12.1
gettar "https://download.savannah.gnu.org/releases/freetype/freetype-${ver}.tar.xz"
ver=2.13.0
gettar "https://mirror.netcologne.de/savannah/freetype/freetype-${ver}.tar.xz"
builddir freetype-${ver}
meson .. --cross-file "$prefix_dir/crossfile"
makeplusinstall
@@ -144,7 +145,7 @@ fi
## fribidi
if [ ! -e "$prefix_dir/lib/libfribidi.dll.a" ]; then
ver=1.0.12
ver=1.0.13
gettar "https://github.com/fribidi/fribidi/releases/download/v${ver}/fribidi-${ver}.tar.xz"
builddir fribidi-${ver}
meson .. --cross-file "$prefix_dir/crossfile" \
@@ -155,7 +156,7 @@ fi
## harfbuzz
if [ ! -e "$prefix_dir/lib/libharfbuzz.dll.a" ]; then
ver=5.3.0
ver=7.3.0
gettar "https://github.com/harfbuzz/harfbuzz/releases/download/${ver}/harfbuzz-${ver}.tar.xz"
builddir harfbuzz-${ver}
meson .. --cross-file "$prefix_dir/crossfile" \
@@ -200,22 +201,23 @@ rm -rf build
if [ "$1" = "meson" ]; then
meson setup build --cross-file "$prefix_dir/crossfile" \
--buildtype debugoptimized \
-D{libmpv,tests}=true -Dlua=luajit \
-D{shaderc,spirv-cross,d3d11,libplacebo}=enabled
-Dlibmpv=true -Dlua=luajit \
-D{shaderc,spirv-cross,d3d11,libplacebo,libplacebo-next}=enabled
ninja -C build --verbose
meson compile -C build
elif [ "$1" = "waf" ]; then
PKG_CONFIG=pkg-config ./waf configure \
--out=build_waf \
--enable-libmpv-shared --lua=luajit \
--enable-{shaderc,spirv-cross,d3d11,libplacebo,tests}
--enable-{shaderc,spirv-cross,d3d11,libplacebo,libplacebo-next}
./waf build --verbose
./waf build
fi
if [ "$2" = pack ]; then
mkdir -p artifact
echo "Copying:"
cp -pv build/mpv.{com,exe} "$prefix_dir/bin/"*.dll artifact/
cp -pv build/generated/mpv.com build/mpv.exe "$prefix_dir/bin/"*.dll artifact/
# ship everything and the kitchen sink
shopt -s nullglob
for file in /usr/lib/gcc/$TARGET/*-posix/*.dll /usr/$TARGET/lib/*.dll; do
+60
View File
@@ -0,0 +1,60 @@
#!/bin/sh -e
if [ "$1" = "meson" ]; then
python3.11 -m venv venv
source ./venv/bin/activate
python -m pip install meson
meson setup build \
-D cdda=enabled \
-D d3d-hwaccel=enabled \
-D d3d11=enabled \
-D dvdnav=enabled \
-D egl-angle-lib=enabled \
-D egl-angle-win32=enabled \
-D jpeg=enabled \
-D lcms2=enabled \
-D libarchive=enabled \
-D libbluray=enabled \
-D libmpv=true \
-D libplacebo=enabled \
-D lua=enabled \
-D pdf-build=enabled \
-D rubberband=enabled \
-D shaderc=enabled \
-D spirv-cross=enabled \
-D tests=true \
-D uchardet=enabled \
-D vapoursynth=enabled \
-D vulkan=enabled
meson compile -C build
cp ./build/generated/mpv.com ./build
./build/mpv.com -v --no-config
fi
if [ "$1" = "waf" ]; then
./bootstrap.py
./waf configure \
--out=build_waf \
--enable-cdda \
--enable-d3d-hwaccel \
--enable-d3d11 \
--enable-dvdnav \
--enable-egl-angle-lib \
--enable-egl-angle-win32 \
--enable-jpeg \
--enable-lcms2 \
--enable-libarchive \
--enable-libbluray \
--enable-libmpv-shared \
--enable-libplacebo \
--enable-pdf-build \
--enable-rubberband \
--enable-shaderc \
--enable-spirv-cross \
--enable-uchardet \
--enable-vapoursynth \
--enable-lua \
--enable-vulkan
./waf build
./build_waf/mpv.com -v --no-config
fi
+6 -6
View File
@@ -13,12 +13,13 @@ if [ "$1" = "meson" ]; then
-Dshaderc=enabled \
-Dtests=true \
-Dvulkan=enabled
meson compile -C build --verbose
./build/mpv --no-config -v --unittest=all-simple
meson compile -C build
./build/mpv -v --no-config
fi
if [ "$1" = "waf" ]; then
python3 ./waf configure \
python3 ./waf configure \
--out=build_waf \
--enable-cdda \
--enable-dvbin \
--enable-dvdnav \
@@ -27,8 +28,7 @@ if [ "$1" = "waf" ]; then
--enable-manpage-build \
--enable-pipewire \
--enable-shaderc \
--enable-tests \
--enable-vulkan
python3 ./waf build --verbose
./build/mpv -v --no-config -v --unittest=all-simple
python3 ./waf build
./build_waf/mpv -v --no-config
fi
+112
View File
@@ -0,0 +1,112 @@
#!/usr/bin/env python3
import os, sys, json, subprocess, re
def call(cmd) -> str:
sys.stdout.flush()
ret = subprocess.run(cmd, check=True, stdout=subprocess.PIPE, text=True)
return ret.stdout
lint_rules = {}
def lint_rule(description: str):
def f(func):
assert func.__name__ not in lint_rules.keys()
lint_rules[func.__name__] = (func, description)
return f
def get_commit_range() -> str:
if len(sys.argv) > 1:
return sys.argv[1]
# https://github.com/actions/runner/issues/342#issuecomment-590670059
event_name = os.environ["GITHUB_EVENT_NAME"]
with open(os.environ["GITHUB_EVENT_PATH"], "rb") as f:
event = json.load(f)
if event_name == "push":
if event["created"] or event["forced"]:
print("Skipping logic on branch creation or force-push")
return None
return event["before"] + "..." + event["after"]
elif event_name == "pull_request":
return event["pull_request"]["base"]["sha"] + ".." + event["pull_request"]["head"]["sha"]
def do_lint(commit_range: str) -> bool:
commits = call(["git", "log", "--pretty=format:%h %s", commit_range]).splitlines()
print(f"Linting {len(commits)} commit(s):")
any_failed = False
for commit in commits:
sha, _, _ = commit.partition(' ')
#print(commit)
body = call(["git", "show", "-s", "--format=%B", sha]).splitlines()
failed = []
if len(body) == 0:
failed.append("* Commit message must not be empty")
else:
for k, v in lint_rules.items():
if not v[0](body):
failed.append(f"* {v[1]} [{k}]")
if failed:
any_failed = True
print("-" * 40)
sys.stdout.flush()
subprocess.run(["git", "-P", "show", "-s", sha])
print("\nhas the following issues:")
print("\n".join(failed))
print("-" * 40)
return any_failed
################################################################################
NO_PREFIX_WHITELIST = r"^Revert \"(.*)\"|^Release [0-9]|^Update VERSION$"
@lint_rule("Subject line must contain a prefix identifying the sub system")
def subsystem_prefix(body):
if re.search(NO_PREFIX_WHITELIST, body[0]):
return True
m = re.search(r"^([^:]+):\s", body[0])
if not m:
return False
# a comma-separated list is okay
s = re.sub(r",\s+", "", m.group(1))
# but no spaces otherwise
return not " " in s
@lint_rule("First word after : must be lower case")
def description_lowercase(body):
if re.search(NO_PREFIX_WHITELIST, body[0]):
return True
return re.search(r":\s+[a-z0-9]", body[0])
@lint_rule("Subject line must not end with a full stop")
def no_dot(body):
return not body[0].rstrip().endswith('.')
@lint_rule("There must be an empty line between subject and extended description")
def empty_line(body):
return len(body) == 1 or body[1].strip() == ""
# been seeing this one all over github lately, must be the webshits
@lint_rule("Do not use 'conventional commits' style")
def no_cc(body):
return not re.search(r"(?i)^(feat|fix|chore|refactor)[!:(]", body[0])
@lint_rule("History must be linear, no merge commits")
def no_merge(body):
return not body[0].startswith("Merge ")
@lint_rule("Subject line should be shorter than 72 characters")
def line_too_long(body):
return len(body[0]) <= 72
@lint_rule("Prefix should not include C file extensions (use `vo_gpu: ...` not `vo_gpu.c: ...`)")
def no_file_exts(body):
return not re.search(r"[a-z0-9]\.[ch]:\s", body[0])
################################################################################
if __name__ == "__main__":
commit_range = get_commit_range()
if commit_range is None:
exit(0)
print("Commit range:", commit_range)
any_failed = do_lint(commit_range)
exit(1 if any_failed else 0)
+26 -18
View File
@@ -40,20 +40,6 @@
#include "av_common.h"
#include "codecs.h"
int mp_lavc_set_extradata(AVCodecContext *avctx, void *ptr, int size)
{
if (size) {
av_free(avctx->extradata);
avctx->extradata_size = 0;
avctx->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata)
return -1;
avctx->extradata_size = size;
memcpy(avctx->extradata, ptr, size);
}
return 0;
}
enum AVMediaType mp_to_av_stream_type(int type)
{
switch (type) {
@@ -64,7 +50,7 @@ enum AVMediaType mp_to_av_stream_type(int type)
}
}
AVCodecParameters *mp_codec_params_to_av(struct mp_codec_params *c)
AVCodecParameters *mp_codec_params_to_av(const struct mp_codec_params *c)
{
AVCodecParameters *avp = avcodec_parameters_alloc();
if (!avp)
@@ -125,7 +111,7 @@ error:
}
// Set avctx codec headers for decoding. Returns <0 on failure.
int mp_set_avctx_codec_headers(AVCodecContext *avctx, struct mp_codec_params *c)
int mp_set_avctx_codec_headers(AVCodecContext *avctx, const struct mp_codec_params *c)
{
enum AVMediaType codec_type = avctx->codec_type;
enum AVCodecID codec_id = avctx->codec_id;
@@ -145,7 +131,7 @@ int mp_set_avctx_codec_headers(AVCodecContext *avctx, struct mp_codec_params *c)
// Pick a "good" timebase, which will be used to convert double timestamps
// back to fractions for passing them through libavcodec.
AVRational mp_get_codec_timebase(struct mp_codec_params *c)
AVRational mp_get_codec_timebase(const struct mp_codec_params *c)
{
AVRational tb = {c->native_tb_num, c->native_tb_den};
if (tb.num < 1 || tb.den < 1) {
@@ -196,7 +182,11 @@ double mp_pts_from_av(int64_t av_pts, AVRational *tb)
// Set duration field only if tb is set.
void mp_set_av_packet(AVPacket *dst, struct demux_packet *mpkt, AVRational *tb)
{
av_init_packet(dst);
dst->side_data = NULL;
dst->side_data_elems = 0;
dst->buf = NULL;
av_packet_unref(dst);
dst->data = mpkt ? mpkt->buffer : NULL;
dst->size = mpkt ? mpkt->len : 0;
/* Some codecs (ZeroCodec, some cases of PNG) may want keyframe info
@@ -394,3 +384,21 @@ int mp_set_avopts_pos(struct mp_log *log, void *avobj, void *posargs, char **kv)
}
return success;
}
/**
* Must be used to free an AVPacket that was used with mp_set_av_packet().
*
* We have a particular pattern where we "borrow" buffers and set them
* into an AVPacket to pass data to ffmpeg without extra copies.
* This applies to buf and side_data, so this function clears them before
* freeing.
*/
void mp_free_av_packet(AVPacket **pkt)
{
if (*pkt) {
(*pkt)->side_data = NULL;
(*pkt)->side_data_elems = 0;
(*pkt)->buf = NULL;
}
av_packet_free(pkt);
}
+4 -4
View File
@@ -31,11 +31,10 @@ struct mp_codec_params;
struct AVDictionary;
struct mp_log;
int mp_lavc_set_extradata(AVCodecContext *avctx, void *ptr, int size);
enum AVMediaType mp_to_av_stream_type(int type);
AVCodecParameters *mp_codec_params_to_av(struct mp_codec_params *c);
int mp_set_avctx_codec_headers(AVCodecContext *avctx, struct mp_codec_params *c);
AVRational mp_get_codec_timebase(struct mp_codec_params *c);
AVCodecParameters *mp_codec_params_to_av(const struct mp_codec_params *c);
int mp_set_avctx_codec_headers(AVCodecContext *avctx, const struct mp_codec_params *c);
AVRational mp_get_codec_timebase(const struct mp_codec_params *c);
void mp_set_av_packet(AVPacket *dst, struct demux_packet *mpkt, AVRational *tb);
int64_t mp_pts_to_av(double mp_pts, AVRational *tb);
double mp_pts_from_av(int64_t av_pts, AVRational *tb);
@@ -50,5 +49,6 @@ void mp_set_avdict(struct AVDictionary **dict, char **kv);
void mp_avdict_print_unset(struct mp_log *log, int msgl, struct AVDictionary *d);
int mp_set_avopts(struct mp_log *log, void *avobj, char **kv);
int mp_set_avopts_pos(struct mp_log *log, void *avobj, void *posargs, char **kv);
void mp_free_av_packet(AVPacket **pkt);
#endif
+1 -2
View File
@@ -193,6 +193,7 @@ void check_library_versions(struct mp_log *log, int v)
{"libswresample", LIBSWRESAMPLE_VERSION_INT, swresample_version()},
};
mp_msg(log, v, "FFmpeg version: %s\n", av_version_info());
mp_msg(log, v, "FFmpeg library versions:\n");
for (int n = 0; n < MP_ARRAY_SIZE(libs); n++) {
@@ -209,8 +210,6 @@ void check_library_versions(struct mp_log *log, int v)
abort();
}
}
mp_msg(log, v, "FFmpeg version: %s\n", av_version_info());
}
#undef V
+2
View File
@@ -73,6 +73,7 @@ enum video_sync {
VS_DISP_RESAMPLE,
VS_DISP_RESAMPLE_VDROP,
VS_DISP_RESAMPLE_NONE,
VS_DISP_TEMPO,
VS_DISP_ADROP,
VS_DISP_VDROP,
VS_DISP_NONE,
@@ -82,6 +83,7 @@ enum video_sync {
#define VS_IS_DISP(x) ((x) == VS_DISP_RESAMPLE || \
(x) == VS_DISP_RESAMPLE_VDROP || \
(x) == VS_DISP_RESAMPLE_NONE || \
(x) == VS_DISP_TEMPO || \
(x) == VS_DISP_ADROP || \
(x) == VS_DISP_VDROP || \
(x) == VS_DISP_NONE)
+4 -4
View File
@@ -40,10 +40,10 @@ struct encode_opts {
char **aopts;
float voffset;
float aoffset;
int rawts;
int video_first;
int audio_first;
int copy_metadata;
bool rawts;
bool video_first;
bool audio_first;
bool copy_metadata;
char **set_metadata;
char **remove_metadata;
};
+5 -6
View File
@@ -23,7 +23,6 @@
#include <libavutil/avutil.h>
#include <libavutil/timestamp.h>
#include "config.h"
#include "encode_lavc.h"
#include "common/av_common.h"
#include "common/global.h"
@@ -88,12 +87,12 @@ const struct m_sub_options encode_config = {
.deprecation_message = "--audio-delay (once unbroken)"},
{"oaoffset", OPT_FLOAT(aoffset), M_RANGE(-1000000.0, 1000000.0),
.deprecation_message = "--audio-delay (once unbroken)"},
{"orawts", OPT_FLAG(rawts)},
{"ovfirst", OPT_FLAG(video_first),
{"orawts", OPT_BOOL(rawts)},
{"ovfirst", OPT_BOOL(video_first),
.deprecation_message = "no replacement"},
{"oafirst", OPT_FLAG(audio_first),
{"oafirst", OPT_BOOL(audio_first),
.deprecation_message = "no replacement"},
{"ocopy-metadata", OPT_FLAG(copy_metadata)},
{"ocopy-metadata", OPT_BOOL(copy_metadata)},
{"oset-metadata", OPT_KEYVALUELIST(set_metadata)},
{"oremove-metadata", OPT_STRINGLIST(remove_metadata)},
@@ -107,7 +106,7 @@ const struct m_sub_options encode_config = {
},
.size = sizeof(struct encode_opts),
.defaults = &(const struct encode_opts){
.copy_metadata = 1,
.copy_metadata = true,
},
};
+78 -11
View File
@@ -43,7 +43,15 @@
#include "msg.h"
#include "msg_control.h"
// log buffer size (lines) for terminal level and logfile level
#define TERM_BUF 100
#define FILE_BUF 100
// logfile lines to accumulate during init before we know the log file name.
// thousands of logfile lines during init can happen (especially with many
// scripts, big config, etc), so we set 5000. If it cycles and messages are
// overwritten, then the first (virtual) log line indicates how many were lost.
#define EARLY_FILE_BUF 5000
struct mp_log_root {
struct mpv_global *global;
@@ -64,6 +72,7 @@ struct mp_log_root {
struct mp_log_buffer **buffers;
int num_buffers;
struct mp_log_buffer *early_buffer;
struct mp_log_buffer *early_filebuffer;
FILE *stats_file;
bstr buffer;
// --- must be accessed atomically
@@ -350,7 +359,8 @@ static void write_msg_to_buffers(struct mp_log *log, int lev, char *text)
buffer_level = MPMAX(log->terminal_level, MSGL_DEBUG);
if (lev <= buffer_level && lev != MSGL_STATUS) {
if (buffer->level == MP_LOG_BUFFER_MSGL_LOGFILE) {
// If the buffer is full, block until we can write again.
// If the buffer is full, block until we can write again,
// unless there's no write thread (died, or early filebuffer)
bool dead = false;
while (buffer->num_entries == buffer->capacity && !dead) {
// Temporary unlock is OK; buffer->level is immutable, and
@@ -641,8 +651,33 @@ void mp_msg_update_msglevels(struct mpv_global *global, struct MPOpts *opts)
if (root->log_path) {
root->log_file = fopen(root->log_path, "wb");
if (root->log_file) {
// if a logfile is created and the early filebuf still exists,
// flush and destroy the early buffer
pthread_mutex_lock(&root->lock);
struct mp_log_buffer *earlybuf = root->early_filebuffer;
if (earlybuf)
root->early_filebuffer = NULL; // but it still logs msgs
pthread_mutex_unlock(&root->lock);
if (earlybuf) {
// flush, destroy before creating the normal logfile buf,
// as once the new one is created (specifically, its write
// thread), then MSGL_LOGFILE messages become blocking, but
// the early logfile buf is without dequeue - can deadlock.
// note: timestamp is unknown, we use 0.000 as indication.
// note: new messages while iterating are still flushed.
struct mp_log_buffer_entry *e;
while ((e = mp_msg_log_buffer_read(earlybuf))) {
fprintf(root->log_file, "[%8.3f][%c][%s] %s", 0.0,
mp_log_levels[e->level][0], e->prefix, e->text);
talloc_free(e);
}
mp_msg_log_buffer_destroy(earlybuf); // + remove from root
}
root->log_file_buffer =
mp_msg_log_buffer_new(global, 100, MP_LOG_BUFFER_MSGL_LOGFILE,
mp_msg_log_buffer_new(global, FILE_BUF, MP_LOG_BUFFER_MSGL_LOGFILE,
wakeup_log_file, root);
root->log_file_thread_active = true;
if (pthread_create(&root->log_file_thread, NULL, log_file_thread,
@@ -700,6 +735,7 @@ void mp_msg_uninit(struct mpv_global *global)
struct mp_log_root *root = global->log->root;
terminate_log_file_thread(root);
mp_msg_log_buffer_destroy(root->early_buffer);
mp_msg_log_buffer_destroy(root->early_filebuffer);
assert(root->num_buffers == 0);
if (root->stats_file)
fclose(root->stats_file);
@@ -713,23 +749,42 @@ void mp_msg_uninit(struct mpv_global *global)
global->log = NULL;
}
void mp_msg_set_early_logging(struct mpv_global *global, bool enable)
// early logging store log messages before they have a known destination.
// there are two early log buffers which are similar logically, and both cease
// function (if still exist, independently) once the log destination is known,
// or mpv init is complete (typically, after all clients/scripts init is done).
//
// - "normal" early_buffer, holds early terminal-level logs, and is handed over
// to the first client which requests such log buffer, so that it sees older
// messages too. further clients which request a log buffer get a new one
// which accumulates messages starting at this point in time.
//
// - early_filebuffer - early log-file messages until a log file name is known.
// main cases where meaningful messages are accumulated before the filename
// is known are when log-file is set at mpv.conf, or from script/client init.
// once a file name is known, the early buffer is flushed and destroyed.
// unlike the "proper" log-file buffer, the early filebuffer is not backed by
// a write thread, and hence non-blocking (can overwrite old messages).
// it's also bigger than the actual file buffer (early: 5000, actual: 100).
static void mp_msg_set_early_logging_raw(struct mpv_global *global, bool enable,
struct mp_log_buffer **root_logbuf,
int size, int level)
{
struct mp_log_root *root = global->log->root;
pthread_mutex_lock(&root->lock);
if (enable != !!root->early_buffer) {
if (enable != !!*root_logbuf) {
if (enable) {
pthread_mutex_unlock(&root->lock);
struct mp_log_buffer *buf =
mp_msg_log_buffer_new(global, TERM_BUF, MP_LOG_BUFFER_MSGL_TERM,
NULL, NULL);
mp_msg_log_buffer_new(global, size, level, NULL, NULL);
pthread_mutex_lock(&root->lock);
assert(!root->early_buffer); // no concurrent calls to this function
root->early_buffer = buf;
assert(!*root_logbuf); // no concurrent calls to this function
*root_logbuf = buf;
} else {
struct mp_log_buffer *buf = root->early_buffer;
root->early_buffer = NULL;
struct mp_log_buffer *buf = *root_logbuf;
*root_logbuf = NULL;
pthread_mutex_unlock(&root->lock);
mp_msg_log_buffer_destroy(buf);
return;
@@ -739,6 +794,18 @@ void mp_msg_set_early_logging(struct mpv_global *global, bool enable)
pthread_mutex_unlock(&root->lock);
}
void mp_msg_set_early_logging(struct mpv_global *global, bool enable)
{
struct mp_log_root *root = global->log->root;
mp_msg_set_early_logging_raw(global, enable, &root->early_buffer,
TERM_BUF, MP_LOG_BUFFER_MSGL_TERM);
// normally MSGL_LOGFILE buffer gets a write thread, but not the early buf
mp_msg_set_early_logging_raw(global, enable, &root->early_filebuffer,
EARLY_FILE_BUF, MP_LOG_BUFFER_MSGL_LOGFILE);
}
struct mp_log_buffer *mp_msg_log_buffer_new(struct mpv_global *global,
int size, int level,
void (*wakeup_cb)(void *ctx),
@@ -810,7 +877,7 @@ void mp_msg_log_buffer_destroy(struct mp_log_buffer *buffer)
}
}
abort();
MP_ASSERT_UNREACHABLE();
found:
-1
View File
@@ -16,7 +16,6 @@
*/
#include <assert.h>
#include "config.h"
#include "playlist.h"
#include "common/common.h"
#include "common/global.h"
+9 -7
View File
@@ -64,6 +64,7 @@ struct mp_recorder_sink {
struct mp_recorder *owner;
struct sh_stream *sh;
AVStream *av_stream;
AVPacket *avpkt;
double max_out_pts;
bool discont;
bool proper_eof;
@@ -82,10 +83,11 @@ static int add_stream(struct mp_recorder *priv, struct sh_stream *sh)
.owner = priv,
.sh = sh,
.av_stream = avformat_new_stream(priv->mux, NULL),
.avpkt = av_packet_alloc(),
.max_out_pts = MP_NOPTS_VALUE,
};
if (!rst->av_stream)
if (!rst->av_stream || !rst->avpkt)
return -1;
AVCodecParameters *avp = mp_codec_params_to_av(sh->codec);
@@ -237,15 +239,14 @@ static void mux_packet(struct mp_recorder_sink *rst,
rst->max_out_pts = MP_PTS_MAX(rst->max_out_pts, pkt->pts);
AVPacket avpkt;
mp_set_av_packet(&avpkt, &mpkt, &rst->av_stream->time_base);
mp_set_av_packet(rst->avpkt, &mpkt, &rst->av_stream->time_base);
avpkt.stream_index = rst->av_stream->index;
rst->avpkt->stream_index = rst->av_stream->index;
if (avpkt.duration < 0 && rst->sh->type != STREAM_SUB)
avpkt.duration = 0;
if (rst->avpkt->duration < 0 && rst->sh->type != STREAM_SUB)
rst->avpkt->duration = 0;
AVPacket *new_packet = av_packet_clone(&avpkt);
AVPacket *new_packet = av_packet_clone(rst->avpkt);
if (!new_packet) {
MP_ERR(priv, "Failed to allocate packet.\n");
return;
@@ -319,6 +320,7 @@ void mp_recorder_destroy(struct mp_recorder *priv)
for (int n = 0; n < priv->num_streams; n++) {
struct mp_recorder_sink *rst = priv->streams[n];
mux_packets(rst);
mp_free_av_packet(&rst->avpkt);
}
if (av_write_trailer(priv->mux) < 0)
+8 -3
View File
@@ -100,11 +100,16 @@ struct demux_cache *demux_cache_create(struct mpv_global *global,
cache->fd = -1;
char *cache_dir = cache->opts->cache_dir;
if (!(cache_dir && cache_dir[0])) {
MP_ERR(cache, "No cache data directory supplied.\n");
goto fail;
if (cache_dir && cache_dir[0]) {
cache_dir = mp_get_user_path(NULL, global, cache_dir);
} else {
cache_dir = mp_find_user_file(NULL, global, "cache", "");
}
if (!cache_dir || !cache_dir[0])
goto fail;
mp_mkdirp(cache_dir);
cache->filename = mp_path_join(cache, cache_dir, "mpv-cache-XXXXXX.dat");
cache->fd = mp_mkostemps(cache->filename, 4, O_CLOEXEC);
if (cache->fd < 0) {
+47 -34
View File
@@ -86,23 +86,24 @@ static const demuxer_desc_t *const demuxer_list[] = {
struct demux_opts {
int enable_cache;
int disk_cache;
bool disk_cache;
int64_t max_bytes;
int64_t max_bytes_bw;
int donate_fw;
bool donate_fw;
double min_secs;
int force_seekable;
double hyst_secs;
bool force_seekable;
double min_secs_cache;
int access_references;
bool access_references;
int seekable_cache;
int create_ccs;
bool create_ccs;
char *record_file;
int video_back_preroll;
int audio_back_preroll;
int back_batch[STREAM_TYPE_COUNT];
double back_seek_size;
char *meta_cp;
int force_retry_eof;
bool force_retry_eof;
};
#define OPT_BASE_STRUCT struct demux_opts
@@ -113,19 +114,20 @@ const struct m_sub_options demux_conf = {
.opts = (const struct m_option[]){
{"cache", OPT_CHOICE(enable_cache,
{"no", 0}, {"auto", -1}, {"yes", 1})},
{"cache-on-disk", OPT_FLAG(disk_cache)},
{"cache-on-disk", OPT_BOOL(disk_cache)},
{"demuxer-readahead-secs", OPT_DOUBLE(min_secs), M_RANGE(0, DBL_MAX)},
{"demuxer-hysteresis-secs", OPT_DOUBLE(hyst_secs), M_RANGE(0, DBL_MAX)},
{"demuxer-max-bytes", OPT_BYTE_SIZE(max_bytes),
M_RANGE(0, M_MAX_MEM_BYTES)},
{"demuxer-max-back-bytes", OPT_BYTE_SIZE(max_bytes_bw),
M_RANGE(0, M_MAX_MEM_BYTES)},
{"demuxer-donate-buffer", OPT_FLAG(donate_fw)},
{"force-seekable", OPT_FLAG(force_seekable)},
{"demuxer-donate-buffer", OPT_BOOL(donate_fw)},
{"force-seekable", OPT_BOOL(force_seekable)},
{"cache-secs", OPT_DOUBLE(min_secs_cache), M_RANGE(0, DBL_MAX)},
{"access-references", OPT_FLAG(access_references)},
{"access-references", OPT_BOOL(access_references)},
{"demuxer-seekable-cache", OPT_CHOICE(seekable_cache,
{"auto", -1}, {"no", 0}, {"yes", 1})},
{"sub-create-cc-track", OPT_FLAG(create_ccs)},
{"sub-create-cc-track", OPT_BOOL(create_ccs)},
{"stream-record", OPT_STRING(record_file)},
{"video-backward-overlap", OPT_CHOICE(video_back_preroll, {"auto", -1}),
M_RANGE(0, 1024)},
@@ -138,7 +140,7 @@ const struct m_sub_options demux_conf = {
{"demuxer-backward-playback-step", OPT_DOUBLE(back_seek_size),
M_RANGE(0, DBL_MAX)},
{"metadata-codepage", OPT_STRING(meta_cp)},
{"demuxer-force-retry-on-eof", OPT_FLAG(force_retry_eof),
{"demuxer-force-retry-on-eof", OPT_BOOL(force_retry_eof),
.deprecation_message = "temporary debug option, no replacement"},
{0}
},
@@ -147,11 +149,11 @@ const struct m_sub_options demux_conf = {
.enable_cache = -1, // auto
.max_bytes = 150 * 1024 * 1024,
.max_bytes_bw = 50 * 1024 * 1024,
.donate_fw = 1,
.donate_fw = true,
.min_secs = 1.0,
.min_secs_cache = 1000.0 * 60 * 60,
.seekable_cache = -1,
.access_references = 1,
.access_references = true,
.video_back_preroll = -1,
.audio_back_preroll = -1,
.back_seek_size = 60,
@@ -210,6 +212,8 @@ struct demux_internal {
bool warned_queue_overflow;
bool eof; // whether we're in EOF state
double min_secs;
double hyst_secs; // stop reading till there's hyst_secs remaining
bool hyst_active;
size_t max_bytes;
size_t max_bytes_bw;
bool seekable_cache;
@@ -467,7 +471,7 @@ static void prune_old_packets(struct demux_internal *in);
static void dumper_close(struct demux_internal *in);
static void demux_convert_tags_charset(struct demuxer *demuxer);
static uint64_t get_foward_buffered_bytes(struct demux_stream *ds)
static uint64_t get_forward_buffered_bytes(struct demux_stream *ds)
{
if (!ds->reader_head)
return 0;
@@ -537,7 +541,7 @@ static void check_queue_consistency(struct demux_internal *in)
// ...reader_head and others must be in the queue.
assert(is_forward == !!queue->ds->reader_head);
assert(kf_found == !!queue->keyframe_latest);
uint64_t fw_bytes2 = get_foward_buffered_bytes(queue->ds);
uint64_t fw_bytes2 = get_forward_buffered_bytes(queue->ds);
assert(fw_bytes == fw_bytes2);
}
@@ -974,6 +978,7 @@ struct sh_stream *demux_alloc_sh_stream(enum stream_type type)
.index = -1,
.ff_index = -1, // may be overwritten by demuxer
.demuxer_id = -1, // ... same
.program_id = -1, // ... same
.codec = talloc_zero(sh, struct mp_codec_params),
.tags = talloc_zero(sh, struct mp_tags),
};
@@ -1272,6 +1277,8 @@ static struct sh_stream *demuxer_get_cc_track_locked(struct sh_stream *stream)
return NULL;
sh->codec->codec = "eia_608";
sh->default_track = true;
sh->hls_bitrate = stream->hls_bitrate;
sh->program_id = stream->program_id;
stream->ds->cc = sh;
demux_add_sh_stream_locked(stream->ds->in, sh);
sh->ds->ignore_eof = true;
@@ -2117,7 +2124,7 @@ static void add_packet_locked(struct sh_stream *stream, demux_packet_t *dp)
ds->base_ts = queue->last_ts;
const char *num_pkts = queue->head == queue->tail ? "1" : ">1";
uint64_t fw_bytes = get_foward_buffered_bytes(ds);
uint64_t fw_bytes = get_forward_buffered_bytes(ds);
MP_TRACE(in, "append packet to %s: size=%zu pts=%f dts=%f pos=%"PRIi64" "
"[num=%s size=%zd]\n", stream_type_name(stream->type),
dp->len, dp->pts, dp->dts, dp->pos, num_pkts, (size_t)fw_bytes);
@@ -2205,17 +2212,23 @@ static bool read_packet(struct demux_internal *in)
if (ds->eager && ds->queue->last_ts != MP_NOPTS_VALUE &&
in->min_secs > 0 && ds->base_ts != MP_NOPTS_VALUE &&
ds->queue->last_ts >= ds->base_ts &&
!in->back_demuxing)
prefetch_more |= ds->queue->last_ts - ds->base_ts < in->min_secs;
total_fw_bytes += get_foward_buffered_bytes(ds);
!in->back_demuxing) {
if (ds->queue->last_ts - ds->base_ts <= in->hyst_secs)
in->hyst_active = false;
if (!in->hyst_active)
prefetch_more |= ds->queue->last_ts - ds->base_ts < in->min_secs;
}
total_fw_bytes += get_forward_buffered_bytes(ds);
}
MP_TRACE(in, "bytes=%zd, read_more=%d prefetch_more=%d, refresh_more=%d\n",
(size_t)total_fw_bytes, read_more, prefetch_more, refresh_more);
if (total_fw_bytes >= in->max_bytes) {
// if we hit the limit just by prefetching, simply stop prefetching
if (!read_more)
if (!read_more) {
in->hyst_active = !!in->hyst_secs;
return false;
}
if (!in->warned_queue_overflow) {
in->warned_queue_overflow = true;
MP_WARN(in, "Too many packets in the demuxer packet queues:\n");
@@ -2226,7 +2239,7 @@ static bool read_packet(struct demux_internal *in)
for (struct demux_packet *dp = ds->reader_head;
dp; dp = dp->next)
num_pkts++;
uint64_t fw_bytes = get_foward_buffered_bytes(ds);
uint64_t fw_bytes = get_forward_buffered_bytes(ds);
MP_WARN(in, " %s/%d: %zd packets, %zd bytes%s%s\n",
stream_type_name(ds->type), n,
num_pkts, (size_t)fw_bytes,
@@ -2307,7 +2320,7 @@ static void prune_old_packets(struct demux_internal *in)
uint64_t fw_bytes = 0;
for (int n = 0; n < in->num_streams; n++) {
struct demux_stream *ds = in->streams[n]->ds;
fw_bytes += get_foward_buffered_bytes(ds);
fw_bytes += get_forward_buffered_bytes(ds);
}
uint64_t max_avail = in->max_bytes_bw;
// Backward cache (if enabled at all) can use unused forward cache.
@@ -2415,10 +2428,6 @@ static void execute_trackswitch(struct demux_internal *in)
{
in->tracks_switched = false;
bool any_selected = false;
for (int n = 0; n < in->num_streams; n++)
any_selected |= in->streams[n]->ds->selected;
pthread_mutex_unlock(&in->lock);
if (in->d_thread->desc->switched_tracks)
@@ -2466,6 +2475,7 @@ static void update_opts(struct demux_internal *in)
struct demux_opts *opts = in->opts;
in->min_secs = opts->min_secs;
in->hyst_secs = opts->hyst_secs;
in->max_bytes = opts->max_bytes;
in->max_bytes_bw = opts->max_bytes_bw;
@@ -2647,8 +2657,7 @@ static int dequeue_packet(struct demux_stream *ds, double min_pts,
return -1;
ds->attached_picture_added = true;
struct demux_packet *pkt = demux_copy_packet(ds->sh->attached_picture);
if (!pkt)
abort();
MP_HANDLE_OOM(pkt);
pkt->stream = ds->sh->index;
*res = pkt;
return 1;
@@ -2858,7 +2867,7 @@ static const char *d_level(enum demux_check level)
case DEMUX_CHECK_REQUEST:return "request";
case DEMUX_CHECK_NORMAL: return "normal";
}
abort();
MP_ASSERT_UNREACHABLE();
}
static int decode_float(char *str, float *out)
@@ -2952,6 +2961,11 @@ static struct replaygain_data *decode_rgain(struct mp_log *log,
}
rg.track_gain /= 256.;
rg.album_gain /= 256.;
// Add 5dB to compensate for the different reference levels between
// our reference of ReplayGain 2 (-18 LUFS) and EBU R128 (-23 LUFS).
rg.track_gain += 5.;
rg.album_gain += 5.;
return talloc_dup(NULL, &rg);
}
@@ -3252,7 +3266,7 @@ struct parent_stream_info {
bool is_streaming;
int stream_origin;
struct mp_cancel *cancel;
char *filename;
const char *filename;
};
static struct demuxer *open_given_type(struct mpv_global *global,
@@ -3422,7 +3436,7 @@ static struct demuxer *demux_open(struct stream *stream,
.is_streaming = stream->streaming,
.stream_origin = stream->stream_origin,
.cancel = cancel,
.filename = talloc_strdup(NULL, stream->url),
.filename = stream->url,
};
// Test demuxers from first to last, one pass for each check_levels[] entry
@@ -3444,7 +3458,6 @@ static struct demuxer *demux_open(struct stream *stream,
}
done:
talloc_free(sinfo.filename);
talloc_free(log);
return demuxer;
}
@@ -4507,7 +4520,7 @@ void demux_get_reader_state(struct demuxer *demuxer, struct demux_reader_state *
r->ts_end = MP_PTS_MAX(r->ts_end, ds->queue->last_ts);
any_packets |= !!ds->reader_head;
}
r->fw_bytes += get_foward_buffered_bytes(ds);
r->fw_bytes += get_forward_buffered_bytes(ds);
}
r->idle = (!in->reading && !r->underrun) || r->eof;
r->underrun &= !r->idle && in->threading;
+66 -33
View File
@@ -36,9 +36,7 @@
#include <libavutil/display.h>
#include <libavutil/opt.h>
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(56, 43, 100)
#include <libavutil/dovi_meta.h>
#endif
#include "audio/chmap_avchannel.h"
@@ -78,14 +76,14 @@ struct demux_lavf_opts {
int probescore;
float analyzeduration;
int buffersize;
int allow_mimetype;
bool allow_mimetype;
char *format;
char **avopts;
int hacks;
bool hacks;
char *sub_cp;
int rtsp_transport;
int linearize_ts;
int propagate_opts;
bool propagate_opts;
};
const struct m_sub_options demux_lavf_conf = {
@@ -98,10 +96,10 @@ const struct m_sub_options demux_lavf_conf = {
M_RANGE(0, 3600)},
{"demuxer-lavf-buffersize", OPT_INT(buffersize),
M_RANGE(1, 10 * 1024 * 1024), OPTDEF_INT(BIO_BUFFER_SIZE)},
{"demuxer-lavf-allow-mimetype", OPT_FLAG(allow_mimetype)},
{"demuxer-lavf-allow-mimetype", OPT_BOOL(allow_mimetype)},
{"demuxer-lavf-probescore", OPT_INT(probescore),
M_RANGE(1, AVPROBE_SCORE_MAX)},
{"demuxer-lavf-hacks", OPT_FLAG(hacks)},
{"demuxer-lavf-hacks", OPT_BOOL(hacks)},
{"demuxer-lavf-o", OPT_KEYVALUELIST(avopts)},
{"sub-codepage", OPT_STRING(sub_cp)},
{"rtsp-transport", OPT_CHOICE(rtsp_transport,
@@ -112,14 +110,14 @@ const struct m_sub_options demux_lavf_conf = {
{"udp_multicast", 4})},
{"demuxer-lavf-linearize-timestamps", OPT_CHOICE(linearize_ts,
{"no", 0}, {"auto", -1}, {"yes", 1})},
{"demuxer-lavf-propagate-opts", OPT_FLAG(propagate_opts)},
{"demuxer-lavf-propagate-opts", OPT_BOOL(propagate_opts)},
{0}
},
.size = sizeof(struct demux_lavf_opts),
.defaults = &(const struct demux_lavf_opts){
.probeinfo = -1,
.allow_mimetype = 1,
.hacks = 1,
.allow_mimetype = true,
.hacks = true,
// AVPROBE_SCORE_MAX/4 + 1 is the "recommended" limit. Below that, the
// user is supposed to retry with larger probe sizes until a higher
// value is reached.
@@ -127,7 +125,7 @@ const struct m_sub_options demux_lavf_conf = {
.sub_cp = "auto",
.rtsp_transport = 2,
.linearize_ts = -1,
.propagate_opts = 1,
.propagate_opts = true,
},
};
@@ -225,6 +223,12 @@ struct stream_info {
double ts_offset;
};
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 10, 100)
#define HAVE_IO_CLOSE2 1
#else
#define HAVE_IO_CLOSE2 0
#endif
typedef struct lavf_priv {
struct stream *stream;
bool own_stream;
@@ -258,7 +262,11 @@ typedef struct lavf_priv {
int num_nested;
int (*default_io_open)(struct AVFormatContext *s, AVIOContext **pb,
const char *url, int flags, AVDictionary **options);
#if HAVE_IO_CLOSE2
int (*default_io_close2)(struct AVFormatContext *s, AVIOContext *pb);
#else
void (*default_io_close)(struct AVFormatContext *s, AVIOContext *pb);
#endif
} lavf_priv_t;
static void update_read_stats(struct demuxer *demuxer)
@@ -458,11 +466,16 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
}
}
// HLS streams seems to be not well tagged, so matching mime type is not
// enough. Strip URL parameters and match extension.
bstr ext = bstr_get_ext(bstr_split(bstr0(priv->filename), "?#", NULL));
AVProbeData avpd = {
// Disable file-extension matching with normal checks
.filename = check <= DEMUX_CHECK_REQUEST ? priv->filename : "",
// Disable file-extension matching with normal checks, except for HLS
.filename = !bstrcasecmp0(ext, "m3u8") || !bstrcasecmp0(ext, "m3u") ||
check <= DEMUX_CHECK_REQUEST ? priv->filename : "",
.buf_size = 0,
.buf = av_mallocz(PROBE_BUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE),
.mime_type = lavfdopts->allow_mimetype ? mime_type : NULL,
};
if (!avpd.buf)
return -1;
@@ -745,14 +758,12 @@ static void handle_new_stream(demuxer_t *demuxer, int i)
sh->codec->rotate = (((int)(-r) % 360) + 360) % 360;
}
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(56, 43, 100)
if ((sd = av_stream_get_side_data(st, AV_PKT_DATA_DOVI_CONF, NULL))) {
const AVDOVIDecoderConfigurationRecord *cfg = (void *) sd;
MP_VERBOSE(demuxer, "Found Dolby Vision config record: profile "
"%d level %d\n", cfg->dv_profile, cfg->dv_level);
av_format_inject_global_side_data(avfc);
}
#endif
// This also applies to vfw-muxed mkv, but we can't detect these easily.
sh->codec->avi_dts = matches_avinputformat_name(priv, "avi");
@@ -836,6 +847,9 @@ static void handle_new_stream(demuxer_t *demuxer, int i)
if (lang && lang->value && strcmp(lang->value, "und") != 0)
sh->lang = talloc_strdup(sh, lang->value);
sh->hls_bitrate = dict_get_decimal(st->metadata, "variant_bitrate", 0);
AVProgram *prog = av_find_program_from_stream(avfc, NULL, i);
if (prog)
sh->program_id = prog->id;
sh->missing_timestamps = !!(priv->avif_flags & AVFMT_NOTIMESTAMPS);
mp_tags_copy_from_av_dictionary(sh->tags, st->metadata);
demux_add_sh_stream(demuxer, sh);
@@ -930,7 +944,11 @@ static int nested_io_open(struct AVFormatContext *s, AVIOContext **pb,
return r;
}
#if HAVE_IO_CLOSE2
static int nested_io_close2(struct AVFormatContext *s, AVIOContext *pb)
#else
static void nested_io_close(struct AVFormatContext *s, AVIOContext *pb)
#endif
{
struct demuxer *demuxer = s->opaque;
lavf_priv_t *priv = demuxer->priv;
@@ -942,16 +960,21 @@ static void nested_io_close(struct AVFormatContext *s, AVIOContext *pb)
}
}
#if HAVE_IO_CLOSE2
return priv->default_io_close2(s, pb);
#else
priv->default_io_close(s, pb);
#endif
}
static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
{
AVFormatContext *avfc;
AVFormatContext *avfc = NULL;
AVDictionaryEntry *t = NULL;
float analyze_duration = 0;
lavf_priv_t *priv = talloc_zero(NULL, lavf_priv_t);
AVDictionary *dopts = NULL;
demuxer->priv = priv;
priv->stream = demuxer->stream;
@@ -965,11 +988,11 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
&priv->mf_fps);
if (lavf_check_file(demuxer, check) < 0)
return -1;
goto fail;
avfc = avformat_alloc_context();
if (!avfc)
return -1;
goto fail;
if (index_mode != 1)
avfc->flags |= AVFMT_FLAG_IGNIDX;
@@ -991,8 +1014,6 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
"analyzeduration to %f\n", analyze_duration);
}
AVDictionary *dopts = NULL;
if ((priv->avif_flags & AVFMT_NOFILE) || priv->format_hack.no_stream) {
mp_setup_av_network_options(&dopts, priv->avif->name,
demuxer->global, demuxer->log);
@@ -1001,12 +1022,12 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
} else {
void *buffer = av_malloc(lavfdopts->buffersize);
if (!buffer)
return -1;
goto fail;
priv->pb = avio_alloc_context(buffer, lavfdopts->buffersize, 0,
demuxer, mp_read, NULL, mp_seek);
if (!priv->pb) {
av_free(buffer);
return -1;
goto fail;
}
priv->pb->read_seek = mp_read_seek;
priv->pb->seekable = demuxer->seekable ? AVIO_SEEKABLE_NORMAL : 0;
@@ -1041,9 +1062,14 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
avfc->opaque = demuxer;
if (demuxer->access_references) {
priv->default_io_open = avfc->io_open;
priv->default_io_close = avfc->io_close;
avfc->io_open = nested_io_open;
#if HAVE_IO_CLOSE2
priv->default_io_close2 = avfc->io_close2;
avfc->io_close2 = nested_io_close2;
#else
priv->default_io_close = avfc->io_close;
avfc->io_close = nested_io_close;
#endif
} else {
avfc->io_open = block_io_open;
}
@@ -1051,8 +1077,8 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
mp_set_avdict(&dopts, lavfdopts->avopts);
if (av_dict_copy(&priv->av_opts, dopts, 0) < 0) {
av_dict_free(&dopts);
return -1;
MP_ERR(demuxer, "av_dict_copy() failed\n");
goto fail;
}
if (priv->format_hack.readall_on_no_streamseek && priv->pb &&
@@ -1071,8 +1097,7 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
if (avformat_open_input(&avfc, priv->filename, priv->avif, &dopts) < 0) {
MP_ERR(demuxer, "avformat_open_input() failed\n");
av_dict_free(&dopts);
return -1;
goto fail;
}
mp_avdict_print_unset(demuxer->log, MSGL_V, dopts);
@@ -1090,7 +1115,7 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
if (probeinfo) {
if (avformat_find_stream_info(avfc, NULL) < 0) {
MP_ERR(demuxer, "av_find_stream_info() failed\n");
return -1;
goto fail;
}
MP_VERBOSE(demuxer, "avformat_find_stream_info() finished after %"PRId64
@@ -1170,6 +1195,13 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
}
return 0;
fail:
if (!priv->avfc)
avformat_free_context(avfc);
av_dict_free(&dopts);
return -1;
}
static bool demux_lavf_read_packet(struct demuxer *demux,
@@ -1311,10 +1343,11 @@ static void demux_seek_lavf(demuxer_t *demuxer, double seek_pts, int flags)
if (priv->pcm_seek_hack && !priv->pcm_seek_hack_packet_size) {
// This might for example be the initial seek. Fuck it up like the
// bullshit it is.
AVPacket pkt = {0};
if (av_read_frame(priv->avfc, &pkt) >= 0)
priv->pcm_seek_hack_packet_size = pkt.size;
av_packet_unref(&pkt);
AVPacket *pkt = av_packet_alloc();
MP_HANDLE_OOM(pkt);
if (av_read_frame(priv->avfc, pkt) >= 0)
priv->pcm_seek_hack_packet_size = pkt->size;
av_packet_free(&pkt);
add_new_streams(demuxer);
}
if (priv->pcm_seek_hack && priv->pcm_seek_hack_packet_size &&
+2 -2
View File
@@ -28,7 +28,7 @@
#include "stream/stream_libarchive.h"
struct demux_libarchive_opts {
int rar_list_all_volumes;
bool rar_list_all_volumes;
};
static int cmp_filename(const void *a, const void *b)
@@ -112,7 +112,7 @@ const struct demuxer_desc demuxer_desc_libarchive = {
.open = open_file,
.options = &(const struct m_sub_options){
.opts = (const struct m_option[]) {
{"rar-list-all-volumes", OPT_FLAG(rar_list_all_volumes)},
{"rar-list-all-volumes", OPT_BOOL(rar_list_all_volumes)},
{0}
},
.size = sizeof(OPT_BASE_STRUCT),
+3 -4
View File
@@ -126,10 +126,9 @@ static mf_t *open_mf_pattern(void *talloc_ctx, struct demuxer *d, char *filename
#if HAVE_GLOB
if (!strchr(filename, '%')) {
strcpy(fname, filename);
if (!strchr(filename, '*'))
strcat(fname, "*");
// append * if none present
snprintf(fname, fname_avail, "%s%c", filename,
strchr(filename, '*') ? 0 : '*');
mp_info(log, "search expr: %s\n", fname);
glob_t gg;
+41 -3
View File
@@ -224,7 +224,7 @@ struct demux_mkv_opts {
double subtitle_preroll_secs;
double subtitle_preroll_secs_index;
int probe_duration;
int probe_start_time;
bool probe_start_time;
};
const struct m_sub_options demux_mkv_conf = {
@@ -237,7 +237,7 @@ const struct m_sub_options demux_mkv_conf = {
M_RANGE(0, DBL_MAX)},
{"probe-video-duration", OPT_CHOICE(probe_duration,
{"no", 0}, {"yes", 1}, {"full", 2})},
{"probe-start-time", OPT_FLAG(probe_start_time)},
{"probe-start-time", OPT_BOOL(probe_start_time)},
{0}
},
.size = sizeof(struct demux_mkv_opts),
@@ -245,7 +245,7 @@ const struct m_sub_options demux_mkv_conf = {
.subtitle_preroll = 2,
.subtitle_preroll_secs = 1.0,
.subtitle_preroll_secs_index = 10.0,
.probe_start_time = 1,
.probe_start_time = true,
},
};
@@ -1831,9 +1831,15 @@ static const char *const mkv_sub_tag[][2] = {
{ "D_WEBVTT/CAPTIONS", "webvtt-webm"},
{ "S_TEXT/WEBVTT", "webvtt"},
{ "S_DVBSUB", "dvb_subtitle"},
{ "S_ARIBSUB", "arib_caption"},
{0}
};
static void avcodec_par_destructor(void *p)
{
avcodec_parameters_free(p);
}
static int demux_mkv_open_sub(demuxer_t *demuxer, mkv_track_t *track)
{
const char *subtitle_type = NULL;
@@ -1862,6 +1868,38 @@ static int demux_mkv_open_sub(demuxer_t *demuxer, mkv_track_t *track)
sh->codec->extradata = track->private_data;
sh->codec->extradata_size = track->private_size;
if (!strcmp(sh->codec->codec, "arib_caption") && track->private_size >= 3) {
struct AVCodecParameters **lavp = talloc_ptrtype(track, lavp);
talloc_set_destructor(lavp, avcodec_par_destructor);
struct AVCodecParameters *lav = *lavp = sh->codec->lav_codecpar = avcodec_parameters_alloc();
MP_HANDLE_OOM(lav);
lav->codec_type = AVMEDIA_TYPE_SUBTITLE;
lav->codec_id = AV_CODEC_ID_ARIB_CAPTION;
int component_tag = track->private_data[0];
int data_component_id = AV_RB16(track->private_data + 1);
switch (data_component_id) {
case 0x0008:
// [0x30..0x37] are component tags utilized for
// non-mobile captioning service ("profile A").
if (component_tag >= 0x30 && component_tag <= 0x37)
lav->profile = FF_PROFILE_ARIB_PROFILE_A;
break;
case 0x0012:
// component tag 0x87 signifies a mobile/partial reception
// (1seg) captioning service ("profile C").
if (component_tag == 0x87)
lav->profile = FF_PROFILE_ARIB_PROFILE_C;
break;
}
if (lav->profile == FF_PROFILE_UNKNOWN)
MP_WARN(demuxer, "ARIB caption profile %02x / %04x not supported.\n",
component_tag, data_component_id);
}
demux_add_sh_stream(demuxer, sh);
if (!subtitle_type)
+81 -28
View File
@@ -22,9 +22,9 @@
#include <libavutil/common.h>
#include "config.h"
#include "common/common.h"
#include "options/options.h"
#include "options/m_config.h"
#include "common/msg.h"
#include "common/playlist.h"
#include "misc/thread_tools.h"
@@ -36,6 +36,31 @@
#define PROBE_SIZE (8 * 1024)
enum dir_mode {
DIR_RECURSIVE,
DIR_LAZY,
DIR_IGNORE,
};
#define OPT_BASE_STRUCT struct demux_playlist_opts
struct demux_playlist_opts {
int dir_mode;
};
struct m_sub_options demux_playlist_conf = {
.opts = (const struct m_option[]) {
{"directory-mode", OPT_CHOICE(dir_mode,
{"recursive", DIR_RECURSIVE},
{"lazy", DIR_LAZY},
{"ignore", DIR_IGNORE})},
{0}
},
.size = sizeof(struct demux_playlist_opts),
.defaults = &(const struct demux_playlist_opts){
.dir_mode = DIR_RECURSIVE,
},
};
static bool check_mimetype(struct stream *s, const char *const *list)
{
if (s->mime_type) {
@@ -60,6 +85,7 @@ struct pl_parser {
enum demux_check check_level;
struct stream *real_stream;
char *format;
struct demux_playlist_opts *opts;
};
@@ -310,10 +336,27 @@ static bool same_st(struct stat *st1, struct stat *st2)
return st1->st_dev == st2->st_dev && st1->st_ino == st2->st_ino;
}
struct pl_dir_entry {
char *path;
char *name;
struct stat st;
bool is_dir;
};
static int cmp_dir_entry(const void *a, const void *b)
{
struct pl_dir_entry *a_entry = (struct pl_dir_entry*) a;
struct pl_dir_entry *b_entry = (struct pl_dir_entry*) b;
if (a_entry->is_dir == b_entry->is_dir) {
return mp_natural_sort_cmp(a_entry->name, b_entry->name);
} else {
return a_entry->is_dir ? 1 : -1;
}
}
// Return true if this was a readable directory.
static bool scan_dir(struct pl_parser *p, char *path,
struct stat *dir_stack, int num_dir_stack,
char ***files, int *num_files)
struct stat *dir_stack, int num_dir_stack)
{
if (strlen(path) >= 8192 || num_dir_stack == MAX_DIR_STACK)
return false; // things like mount bind loops
@@ -324,6 +367,11 @@ static bool scan_dir(struct pl_parser *p, char *path,
return false;
}
struct pl_dir_entry *dir_entries = NULL;
int num_dir_entries = 0;
int path_len = strlen(path);
int dir_mode = p->opts->dir_mode;
struct dirent *ep;
while ((ep = readdir(dp))) {
if (ep->d_name[0] == '.')
@@ -336,29 +384,41 @@ static bool scan_dir(struct pl_parser *p, char *path,
struct stat st;
if (stat(file, &st) == 0 && S_ISDIR(st.st_mode)) {
for (int n = 0; n < num_dir_stack; n++) {
if (same_st(&dir_stack[n], &st)) {
MP_VERBOSE(p, "Skip recursive entry: %s\n", file);
goto skip;
if (dir_mode != DIR_IGNORE) {
for (int n = 0; n < num_dir_stack; n++) {
if (same_st(&dir_stack[n], &st)) {
MP_VERBOSE(p, "Skip recursive entry: %s\n", file);
goto skip;
}
}
}
dir_stack[num_dir_stack] = st;
scan_dir(p, file, dir_stack, num_dir_stack + 1, files, num_files);
struct pl_dir_entry d = {file, &file[path_len], st, true};
MP_TARRAY_APPEND(p, dir_entries, num_dir_entries, d);
}
} else {
MP_TARRAY_APPEND(p, *files, *num_files, file);
struct pl_dir_entry f = {file, &file[path_len], .is_dir = false};
MP_TARRAY_APPEND(p, dir_entries, num_dir_entries, f);
}
skip: ;
}
closedir(dp);
return true;
}
static int cmp_filename(const void *a, const void *b)
{
return mp_natural_sort_cmp(*(char **)a, *(char **)b);
if (dir_entries)
qsort(dir_entries, num_dir_entries, sizeof(dir_entries[0]), cmp_dir_entry);
for (int n = 0; n < num_dir_entries; n++) {
if (dir_mode == DIR_RECURSIVE && dir_entries[n].is_dir) {
dir_stack[num_dir_stack] = dir_entries[n].st;
char *file = dir_entries[n].path;
scan_dir(p, file, dir_stack, num_dir_stack + 1);
}
else {
playlist_add_file(p->pl, dir_entries[n].path);
}
}
return true;
}
static int parse_dir(struct pl_parser *p)
@@ -372,21 +432,13 @@ static int parse_dir(struct pl_parser *p)
if (!path)
return -1;
char **files = NULL;
int num_files = 0;
struct stat dir_stack[MAX_DIR_STACK];
scan_dir(p, path, dir_stack, 0, &files, &num_files);
if (files)
qsort(files, num_files, sizeof(files[0]), cmp_filename);
for (int n = 0; n < num_files; n++)
playlist_add_file(p->pl, files[n]);
scan_dir(p, path, dir_stack, 0);
p->add_base = false;
return num_files > 0 ? 0 : -1;
return p->pl->num_entries > 0 ? 0 : -1;
}
#define MIME_TYPES(...) \
@@ -459,6 +511,7 @@ static int open_file(struct demuxer *demuxer, enum demux_check check)
p->error = false;
p->s = demuxer->stream;
p->utf16 = stream_skip_bom(p->s);
p->opts = mp_get_config_group(demuxer, demuxer->global, &demux_playlist_conf);
bool ok = fmt->parse(p) >= 0 && !p->error;
if (p->add_base)
playlist_add_base_path(p->pl, mp_dirname(demuxer->filename));
@@ -472,7 +525,7 @@ static int open_file(struct demuxer *demuxer, enum demux_check check)
return ok ? 0 : -1;
}
const struct demuxer_desc demuxer_desc_playlist = {
const demuxer_desc_t demuxer_desc_playlist = {
.name = "playlist",
.desc = "Playlist file",
.open = open_file,
+1 -4
View File
@@ -15,8 +15,6 @@
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@@ -247,8 +245,7 @@ static int demux_rawvideo_open(demuxer_t *demuxer, enum demux_check check)
c->disp_h = height;
if (mp_imgfmt) {
c->lav_codecpar = avcodec_parameters_alloc();
if (!c->lav_codecpar)
abort();
MP_HANDLE_OOM(c->lav_codecpar);
c->lav_codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
c->lav_codecpar->codec_id = mp_codec_to_av_codec_id(decoder);
c->lav_codecpar->format = imgfmt2pixfmt(mp_imgfmt);
+2 -4
View File
@@ -20,8 +20,6 @@
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdlib.h>
#include <stdbool.h>
#include <inttypes.h>
@@ -429,7 +427,7 @@ static void ebml_parse_element(struct ebml_parse_ctx *ctx, void *target,
uint32_t, num_elems[i]);
break;
default:
abort();
MP_ASSERT_UNREACHABLE();
}
}
}
@@ -582,7 +580,7 @@ static void ebml_parse_element(struct ebml_parse_ctx *ctx, void *target,
MP_TRACE(ctx, "ebml_id %x\n", (unsigned)*idptr);
break;
default:
abort();
MP_ASSERT_UNREACHABLE();
}
*countptr += 1;
error:
+40 -22
View File
@@ -23,8 +23,6 @@
#include <libavcodec/avcodec.h>
#include <libavutil/intreadwrite.h>
#include "config.h"
#include "common/av_common.h"
#include "common/common.h"
#include "demux.h"
@@ -51,13 +49,8 @@ static void packet_destroy(void *ptr)
demux_packet_unref_contents(dp);
}
// This actually preserves only data and side data, not PTS/DTS/pos/etc.
// It also allows avpkt->data==NULL with avpkt->size!=0 - the libavcodec API
// does not allow it, but we do it to simplify new_demux_packet().
struct demux_packet *new_demux_packet_from_avpacket(struct AVPacket *avpkt)
static struct demux_packet *packet_create(void)
{
if (avpkt->size > 1000000000)
return NULL;
struct demux_packet *dp = talloc(NULL, struct demux_packet);
talloc_set_destructor(dp, packet_destroy);
*dp = (struct demux_packet) {
@@ -70,10 +63,20 @@ struct demux_packet *new_demux_packet_from_avpacket(struct AVPacket *avpkt)
.stream = -1,
.avpacket = av_packet_alloc(),
};
MP_HANDLE_OOM(dp->avpacket);
return dp;
}
// This actually preserves only data and side data, not PTS/DTS/pos/etc.
// It also allows avpkt->data==NULL with avpkt->size!=0 - the libavcodec API
// does not allow it, but we do it to simplify new_demux_packet().
struct demux_packet *new_demux_packet_from_avpacket(struct AVPacket *avpkt)
{
if (avpkt->size > 1000000000)
return NULL;
struct demux_packet *dp = packet_create();
int r = -1;
if (!dp->avpacket) {
// error
} else if (avpkt->data) {
if (avpkt->data) {
// We hope that this function won't need/access AVPacket input padding,
// because otherwise new_demux_packet_from() wouldn't work.
r = av_packet_ref(dp->avpacket, avpkt);
@@ -94,29 +97,44 @@ struct demux_packet *new_demux_packet_from_buf(struct AVBufferRef *buf)
{
if (!buf)
return NULL;
AVPacket pkt = {
.size = buf->size,
.data = buf->data,
.buf = buf,
};
return new_demux_packet_from_avpacket(&pkt);
if (buf->size > 1000000000)
return NULL;
struct demux_packet *dp = packet_create();
dp->avpacket->buf = av_buffer_ref(buf);
if (!dp->avpacket->buf) {
talloc_free(dp);
return NULL;
}
dp->avpacket->data = dp->buffer = buf->data;
dp->avpacket->size = dp->len = buf->size;
return dp;
}
// Input data doesn't need to be padded.
struct demux_packet *new_demux_packet_from(void *data, size_t len)
{
if (len > INT_MAX)
struct demux_packet *dp = new_demux_packet(len);
if (!dp)
return NULL;
AVPacket pkt = { .data = data, .size = len };
return new_demux_packet_from_avpacket(&pkt);
memcpy(dp->avpacket->data, data, len);
return dp;
}
struct demux_packet *new_demux_packet(size_t len)
{
if (len > INT_MAX)
return NULL;
AVPacket pkt = { .data = NULL, .size = len };
return new_demux_packet_from_avpacket(&pkt);
struct demux_packet *dp = packet_create();
int r = av_new_packet(dp->avpacket, len);
if (r < 0) {
talloc_free(dp);
return NULL;
}
dp->buffer = dp->avpacket->data;
dp->len = len;
return dp;
}
void demux_packet_shorten(struct demux_packet *dp, size_t len)
+1
View File
@@ -51,6 +51,7 @@ struct sh_stream {
bool image; // video stream is an image
bool still_image; // video stream contains still images
int hls_bitrate;
int program_id;
struct mp_tags *tags;
+5 -1
View File
@@ -42,7 +42,7 @@ function _mpv_generate_arguments {
local -a option_aliases=()
local list_options_line
for list_options_line in "${(@f)$($~words[1] --list-options)}"; do
for list_options_line in "${(@f)$($~words[1] --no-config --list-options)}"; do
[[ $list_options_line =~ $'^[ \t]+--([^ \t]+)[ \t]*(.*)' ]] || continue
@@ -77,6 +77,10 @@ function _mpv_generate_arguments {
# Save this for later; we might not have parsed the target option yet
option_aliases+="$name $match[2]"
elif [[ $desc =~ $'^removed ' ]]; then
# skip
else
# Option takes argument
+7
View File
@@ -28,6 +28,9 @@ input-default-bindings=no
input-vo-keyboard=no
# OSX/Cocoa global input hooks
input-media-keys=no
vlang=
alang=
slang=
[encoding]
vo=lavc
@@ -39,12 +42,16 @@ resume-playback=no
load-scripts=no
osc=no
framedrop=no
vlang=
alang=
slang=
[gpu-hq]
scale=spline36
cscale=spline36
dscale=mitchell
dither-depth=auto
hdr-contrast-recovery=0.30
correct-downscaling=yes
linear-downscaling=yes
sigmoid-upscaling=yes
+1 -1
View File
@@ -160,7 +160,7 @@
#L cycle-values loop-file "inf" "no" # toggle infinite looping
#ctrl+c quit 4
#DEL script-binding osc/visibility # cycle OSC visibility between never, auto (mouse-move) and always
#ctrl+h cycle-values hwdec "auto" "no" # toggle hardware decoding
#ctrl+h cycle-values hwdec "auto-safe" "no" # toggle hardware decoding
#F8 show-text ${playlist} # show the playlist
#F9 show-text ${track-list} # show the list of video, audio and sub tracks
+7 -4
View File
@@ -18,7 +18,7 @@
#
# Cache all the mpv options
_mpv_options=$(mpv --list-options)
_mpv_options=$(mpv --no-config --list-options)
_mpv_get_args()
{
@@ -73,9 +73,12 @@ _mpv_get_args()
}
# This regex detects special options where we don't want an '=' appended
_mpv_special_regex='Flag.*\[not in config files\]|Print'
_mpv_regular_options=($(echo "$_mpv_options" | grep -v -E "$_mpv_special_regex" |awk '{print "\\"$1;}' | grep '\--'))
_mpv_special_options=($(echo "$_mpv_options" | grep -E "$_mpv_special_regex" |awk '{print "\\"$1;}' | grep '\--'))
_mpv_special_regex='\s(Flag.*\[not in config files\]|Print)'
_mpv_skip_regex='\sremoved \[deprecated\]'
_mpv_regular_options=($(echo "$_mpv_options" | grep -vE "$_mpv_skip_regex" | \
grep -vE "$_mpv_special_regex" | awk '{print "\\"$1;}' | grep '\--'))
_mpv_special_options=($(echo "$_mpv_options" | grep -vE "$_mpv_skip_regex" | \
grep -E "$_mpv_special_regex" | awk '{print "\\"$1;}' | grep '\--'))
_mpv()
{
+3 -2
View File
@@ -16,6 +16,7 @@ GenericName[cs]=Multimediální přehrávač
GenericName[da]=Multimedieafspiller
GenericName[fr]=Lecteur multimédia
GenericName[ja]=マルチメディアプレイヤー
GenericName[ru]=Мультимедийный проигрыватель
GenericName[tr]=Çoklu ortam oynatıcı
GenericName[zh_CN]=多媒体播放器
GenericName[zh_TW]=多媒體播放器
@@ -29,7 +30,7 @@ Comment[fr]=Lire des vidéos et des musiques
Comment[ja]=映画や音楽を再生する
Comment[it]=Lettore multimediale
Comment[pl]=Odtwarzaj filmy i muzykę
Comment[ru]=Воспроизвести фильмы и музыку
Comment[ru]=Воспроизведение фильмов и музыки
Comment[tr]=Filmleri ve şarkıları oynatın
Comment[zh_CN]=播放电影和歌曲
Comment[zh_TW]=播放電影和歌曲
@@ -39,5 +40,5 @@ Exec=mpv --player-operation-mode=pseudo-gui -- %U
Terminal=false
Categories=AudioVideo;Audio;Video;Player;TV;
MimeType=application/ogg;application/x-ogg;application/mxf;application/sdp;application/smil;application/x-smil;application/streamingmedia;application/x-streamingmedia;application/vnd.rn-realmedia;application/vnd.rn-realmedia-vbr;audio/aac;audio/x-aac;audio/vnd.dolby.heaac.1;audio/vnd.dolby.heaac.2;audio/aiff;audio/x-aiff;audio/m4a;audio/x-m4a;application/x-extension-m4a;audio/mp1;audio/x-mp1;audio/mp2;audio/x-mp2;audio/mp3;audio/x-mp3;audio/mpeg;audio/mpeg2;audio/mpeg3;audio/mpegurl;audio/x-mpegurl;audio/mpg;audio/x-mpg;audio/rn-mpeg;audio/musepack;audio/x-musepack;audio/ogg;audio/scpls;audio/x-scpls;audio/vnd.rn-realaudio;audio/wav;audio/x-pn-wav;audio/x-pn-windows-pcm;audio/x-realaudio;audio/x-pn-realaudio;audio/x-ms-wma;audio/x-pls;audio/x-wav;video/mpeg;video/x-mpeg2;video/x-mpeg3;video/mp4v-es;video/x-m4v;video/mp4;application/x-extension-mp4;video/divx;video/vnd.divx;video/msvideo;video/x-msvideo;video/ogg;video/quicktime;video/vnd.rn-realvideo;video/x-ms-afs;video/x-ms-asf;audio/x-ms-asf;application/vnd.ms-asf;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvxvideo;video/x-avi;video/avi;video/x-flic;video/fli;video/x-flc;video/flv;video/x-flv;video/x-theora;video/x-theora+ogg;video/x-matroska;video/mkv;audio/x-matroska;application/x-matroska;video/webm;audio/webm;audio/vorbis;audio/x-vorbis;audio/x-vorbis+ogg;video/x-ogm;video/x-ogm+ogg;application/x-ogm;application/x-ogm-audio;application/x-ogm-video;application/x-shorten;audio/x-shorten;audio/x-ape;audio/x-wavpack;audio/x-tta;audio/AMR;audio/ac3;audio/eac3;audio/amr-wb;video/mp2t;audio/flac;audio/mp4;application/x-mpegurl;video/vnd.mpegurl;application/vnd.apple.mpegurl;audio/x-pn-au;video/3gp;video/3gpp;video/3gpp2;audio/3gpp;audio/3gpp2;video/dv;audio/dv;audio/opus;audio/vnd.dts;audio/vnd.dts.hd;audio/x-adpcm;application/x-cue;audio/m3u;
X-KDE-Protocols=ftp,http,https,mms,rtmp,rtsp,sftp,smb,srt,rist
X-KDE-Protocols=ftp,http,https,mms,rtmp,rtsp,sftp,smb,srt,rist,webdav,webdavs
StartupWMClass=mpv
+6
View File
@@ -82,6 +82,12 @@ static void deint_process(struct mp_filter *f)
char *args[] = {"mode", "send_field", NULL};
p->sub.filter =
mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "yadif_cuda", args);
#if HAVE_VULKAN_INTEROP
} else if (img->imgfmt == IMGFMT_VULKAN) {
char *args[] = {"mode", "send_field", NULL};
p->sub.filter =
mp_create_user_filter(f, MP_OUTPUT_CHAIN_VIDEO, "bwdif_vulkan", args);
#endif
} else if (img->imgfmt == IMGFMT_VAAPI) {
char *args[] = {"deint", "motion-adaptive",
"interlaced-only", "yes", NULL};
-2
View File
@@ -1,5 +1,3 @@
#include "config.h"
#include "audio/aframe.h"
#include "audio/chmap_sel.h"
#include "audio/format.h"
+5 -8
View File
@@ -27,7 +27,6 @@
#include <libavutil/common.h>
#include <libavutil/rational.h>
#include "config.h"
#include "options/options.h"
#include "common/msg.h"
#include "options/m_config.h"
@@ -54,7 +53,7 @@
#include "filter_internal.h"
struct dec_queue_opts {
int use_queue;
bool use_queue;
int64_t max_bytes;
int64_t max_samples;
double max_duration;
@@ -63,7 +62,7 @@ struct dec_queue_opts {
#define OPT_BASE_STRUCT struct dec_queue_opts
static const struct m_option dec_queue_opts_list[] = {
{"enable", OPT_FLAG(use_queue)},
{"enable", OPT_BOOL(use_queue)},
{"max-secs", OPT_DOUBLE(max_duration), M_RANGE(0, DBL_MAX)},
{"max-bytes", OPT_BYTE_SIZE(max_bytes), M_RANGE(0, M_MAX_MEM_BYTES)},
{"max-samples", OPT_INT64(max_samples), M_RANGE(0, DBL_MAX)},
@@ -74,7 +73,6 @@ static const struct m_sub_options vdec_queue_conf = {
.opts = dec_queue_opts_list,
.size = sizeof(struct dec_queue_opts),
.defaults = &(const struct dec_queue_opts){
.use_queue = 0,
.max_bytes = 512 * 1024 * 1024,
.max_samples = 50,
.max_duration = 2,
@@ -85,7 +83,6 @@ static const struct m_sub_options adec_queue_conf = {
.opts = dec_queue_opts_list,
.size = sizeof(struct dec_queue_opts),
.defaults = &(const struct dec_queue_opts){
.use_queue = 0,
.max_bytes = 1 * 1024 * 1024,
.max_samples = 48000,
.max_duration = 1,
@@ -99,7 +96,7 @@ struct dec_wrapper_opts {
float movie_aspect;
int aspect_method;
double force_fps;
int correct_pts;
bool correct_pts;
int video_rotate;
char *audio_decoders;
char *video_decoders;
@@ -115,7 +112,7 @@ static int decoder_list_help(struct mp_log *log, const m_option_t *opt,
const struct m_sub_options dec_wrapper_conf = {
.opts = (const struct m_option[]){
{"correct-pts", OPT_FLAG(correct_pts)},
{"correct-pts", OPT_BOOL(correct_pts)},
{"fps", OPT_DOUBLE(force_fps), M_RANGE(0, DBL_MAX)},
{"ad", OPT_STRING(audio_decoders),
.help = decoder_list_help},
@@ -140,7 +137,7 @@ const struct m_sub_options dec_wrapper_conf = {
},
.size = sizeof(struct dec_wrapper_opts),
.defaults = &(const struct dec_wrapper_opts){
.correct_pts = 1,
.correct_pts = true,
.movie_aspect = -1.,
.aspect_method = 2,
.video_reverse_size = 1 * 1024 * 1024 * 1024,
+1
View File
@@ -77,6 +77,7 @@ enum dec_ctrl {
VDCTRL_GET_BFRAMES,
// framedrop mode: 0=none, 1=standard, 2=hrseek
VDCTRL_SET_FRAMEDROP,
VDCTRL_CHECK_FORCED_EOF,
};
int mp_decoder_wrapper_control(struct mp_decoder_wrapper *d,
+11 -3
View File
@@ -50,6 +50,12 @@ struct hwmap_pairs {
// We cannot discover which pairs of hardware formats need to use hwmap to
// convert between the formats, so we need a lookup table.
static const struct hwmap_pairs hwmap_pairs[] = {
#if HAVE_VULKAN_INTEROP
{
.first_fmt = IMGFMT_VAAPI,
.second_fmt = IMGFMT_VULKAN,
},
#endif
{
.first_fmt = IMGFMT_DRMPRIME,
.second_fmt = IMGFMT_VAAPI,
@@ -124,7 +130,7 @@ int mp_hwupload_find_upload_format(struct mp_hwupload *u, int imgfmt)
select_format(p, imgfmt, &sw, &up);
// In th case where the imgfmt is not natively supported, it must be
// converted, either before or during upload. If the imgfmt is supported as
// an hw input format, then prefer that, and if the upload has to do implict
// an hw input format, then prefer that, and if the upload has to do implicit
// conversion, that's fine. On the other hand, if the imgfmt is not a
// supported input format, then pick the output format as the conversion
// target to avoid doing two conversions (one before upload, and one during
@@ -192,7 +198,8 @@ static void process(struct mp_filter *f)
}
if (!mp_update_av_hw_frames_pool(&p->hw_pool, p->av_device_ctx, p->hw_imgfmt,
p->last_hw_output_fmt, src->w, src->h))
p->last_hw_output_fmt, src->w, src->h,
src->imgfmt == IMGFMT_CUDA))
{
MP_ERR(f, "failed to create frame pool\n");
goto error;
@@ -347,7 +354,7 @@ static bool probe_formats(struct mp_hwupload *u, int hw_imgfmt)
// Creates an AVHWFramesContexts with the given parameters.
AVBufferRef *frames = NULL;
if (!mp_update_av_hw_frames_pool(&frames, ctx->av_device_ref,
hw_imgfmt, imgfmt, 128, 128))
hw_imgfmt, imgfmt, 128, 128, false))
{
MP_WARN(u->f, "failed to allocate pool\n");
continue;
@@ -385,6 +392,7 @@ static bool probe_formats(struct mp_hwupload *u, int hw_imgfmt)
av_buffer_unref(&frames);
}
av_hwframe_constraints_free(&cstr);
p->av_device_ctx = av_buffer_ref(ctx->av_device_ref);
if (!p->av_device_ctx)
return false;
+4 -6
View File
@@ -260,8 +260,7 @@ static void precreate_graph(struct lavfi *c, bool first_init)
c->failed = false;
c->graph = avfilter_graph_alloc();
if (!c->graph)
abort();
MP_HANDLE_OOM(c->graph);
if (mp_set_avopts(c->log, c->graph, c->graph_opts) < 0)
goto error;
@@ -852,8 +851,7 @@ static struct lavfi *lavfi_alloc(struct mp_filter *parent)
c->log = f->log;
c->public.f = f;
c->tmp_frame = av_frame_alloc();
if (!c->tmp_frame)
abort();
MP_HANDLE_OOM(c->tmp_frame);
return c;
}
@@ -948,7 +946,7 @@ struct lavfi_user_opts {
char *filter_name;
char **filter_opts;
int fix_pts;
bool fix_pts;
char *hwdec_interop;
};
@@ -1121,7 +1119,7 @@ const struct mp_user_filter_entry af_lavfi = {
.priv_size = sizeof(OPT_BASE_STRUCT),
.options = (const m_option_t[]){
{"graph", OPT_STRING(graph)},
{"fix-pts", OPT_FLAG(fix_pts)},
{"fix-pts", OPT_BOOL(fix_pts)},
{"o", OPT_KEYVALUELIST(avopts)},
{"hwdec_interop",
OPT_STRING_VALIDATE(hwdec_interop,
+2 -4
View File
@@ -22,8 +22,6 @@
#include <libavutil/mathematics.h>
#include <libswresample/swresample.h>
#include "config.h"
#include "audio/aframe.h"
#include "audio/fmt-conversion.h"
#include "audio/format.h"
@@ -73,9 +71,9 @@ const struct m_sub_options resample_conf = {
.opts = (const m_option_t[]) {
{"audio-resample-filter-size", OPT_INT(filter_size), M_RANGE(0, 32)},
{"audio-resample-phase-shift", OPT_INT(phase_shift), M_RANGE(0, 30)},
{"audio-resample-linear", OPT_FLAG(linear)},
{"audio-resample-linear", OPT_BOOL(linear)},
{"audio-resample-cutoff", OPT_DOUBLE(cutoff), M_RANGE(0, 1)},
{"audio-normalize-downmix", OPT_FLAG(normalize)},
{"audio-normalize-downmix", OPT_BOOL(normalize)},
{"audio-resample-max-output-size", OPT_DOUBLE(max_output_frame_size)},
{"audio-swresample-o", OPT_KEYVALUELIST(avopts)},
{0}
+2 -2
View File
@@ -19,9 +19,9 @@ struct mp_swresample {
struct mp_resample_opts {
int filter_size;
int phase_shift;
int linear;
bool linear;
double cutoff;
int normalize;
bool normalize;
int allow_passthrough;
double max_output_frame_size;
char **avopts;
Loaded 100 of 383 files, more files were not shown because too many files have changed in this diff. Show more