Commit Graph

50162 Commits

Author SHA1 Message Date
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