Commit Graph

50761 Commits

Author SHA1 Message Date
Kacper Michajłow fe868988a1 DOCS: update notes about new profiles 2023-09-20 18:42:06 +02:00
Niklas Haas c172a650c4 vo_gpu: default to dscale=hermite
This new filter is slightly sharper, and significantly faster, than
mitchell. It also tends to preserve detail better. All in all, there is
no reason not to use it by default, especially from a performance PoV.
(In vo_gpu_next, hermite is implemented efficiently using hardware
accelerated bilinear interpolation)

See-Also: 75b3947b2c
2023-09-20 17:07:38 +02:00
Niklas Haas 87baed0b0f DOCS/options: document hermite scaler
Since I want to make it more prominent.
2023-09-20 17:07:38 +02:00
Niklas Haas 0cb4aa4ff7 DOCS/options: remove potentially offensive language
It can hurt people's feelings to refer to scalers as "high quality" and
"low quality", when it is so subjective.

I decided to preserve the lanczos sections at least because it's mostly
talking about the difference between EWA Lanczos and Lanczos, which is
less controversial than the difference between, say, Lanczos and
Catmull.
2023-09-20 17:07:38 +02:00
Niklas Haas c934391e07 DOCS/options: remove spline36 section
What a pointless section. We don't use it by default anymore so might as
well just remove it.
2023-09-20 17:07:38 +02:00
Alex Mitzsch 1ffe7aacca
DOCS/options: change wording to be less inflammatory
Change wording from "Disable idiotic nonsense" to just say "Disable
functions like."
2023-09-20 09:19:38 -04:00
ferreum 95157bb0a5 af_scaletempo2: fix missing variable init, remove redundant init 2023-09-20 14:36:23 +02:00
ferreum e05591ef59 af_scaletempo2: truncate final packet to expected length
Avoid generating too much audio after EOF.

Note: This often has no effect, because less audio is produced than
required.

Usually this comes to effect with the userspeed filter at high speed
(4x) and going back to 1x speed to remove the filter.
2023-09-20 14:36:23 +02:00
ferreum 8080d00d7f af_scaletempo2: fix processing of final packet
After the final input packet, the filter padded with silence to allow
one more iteration. That was not enough to process the final frames.

Continue padding the end of `input_buffer` with silence until the final
frames have been processed.

Implementation: Instead of padding when adding final samples, pad before
running WSOLA iteration. Count number of added silent frames and
remaining input frames for time keeping.
2023-09-20 14:36:23 +02:00
ferreum cf8b7ff0d6 af_scaletempo2: calculate latency by center of search block
This changes the emitted pts values from the start of the search block
to the center of the search block. Change initial `output_time`
accordingly. Initial `search_block_index` is irrelevant, because it's
overwritten before the first iteration.

Using the `output_time` removes the rounding of `search_block_index`,
which also fixes the <20 microsecond gaps in timestamps between output
packets.

Rationale:

The variance in audio position was in the range `0..search-interval`.

With this change, the range is

    (- search-interval / 2)..(search-interval / 2)`

which ensures lower maximum offset.
2023-09-20 14:36:23 +02:00
ferreum c0728249a1 af_scaletempo2: restore exact audio sync on return to 1x speed
Target block can be anywhere in the previous search-block, varying by
`search-interval` while the filter is active. This resulted in constant
audio offset when returning to 1x playback speed.

- Move the search block to the target block to sync up exactly.
- Drop old frames to minimize input_buffer usage.
2023-09-20 14:36:23 +02:00
ferreum f52cf90fed af_scaletempo2: fix speed change latency and pts spikes
The internal time update function involved multiple problems:

- Time was updated after WSOLA iteration. The means speed was updated
  one iteration later than it could be.
- The update functions caused spikes of too many or too few samples
  advanced, leading to audio glitches on speed changes.
- The inconsistent updates made it very difficult to produce gapless
  audio packets.
- The `output_time` update function involved complicated feedback:
  `search_block_index` influenced how many frames from `input_buffer`
  are retained, which influenced how much `output_time` is changed,
  which influenced `search_block_index`.

With these changes:

- Time is updated before WSOLA iterations. Speed changes are effective
  instantly.
- There are no spikes in playback speed during speed changes.
- No significant gaps are introduced in output packets.
- The time update function becomes (function calls omitted for brevity)

    output_time += ola_hop_size * playback_rate

Functions received a `playback_rate` parameter to check how many samples
are needed before iteration. Internal state is only updated when the
iteration is actually run, so the speed is allowed to change until
enough data is received.
2023-09-20 14:36:23 +02:00
ferreum 33d6d0f311 af_scaletempo2: fix audio artifact on initial WSOLA iteration
The first WSOLA iteration overlapped audio with whatever was in the
`wsola_output` buffer. This was either silence (if not run before), or
old frames (if switching to 1x and back to a different speed).

Track the state of the output buffer and memcpy the whole window for the
first iteration instead.
2023-09-20 14:36:23 +02:00
ferreum c3bceb3243 af_scaletempo2: fix audio offset when playing back at 1x speed
`read_input_buffer` needs to respect the `target_block_index`, otherwise
the audio resumes at the wrong position.
2023-09-20 14:36:23 +02:00
ferreum de09ec9ea4 af_scaletempo2: fix inconsistent search block position after init
`output_time` is used to set the center of the search block. Init of
both `search_block_index` and `output_time` with 0 caused inconsistent
search block movement for the first iterations.

Initialize with `search_block_center_offset` for consistency with initial
`search_block_index`.
2023-09-20 14:36:23 +02:00
ferreum 87cc7ed955 af_scaletempo2: move latency calculation to internal function 2023-09-20 14:36:23 +02:00
ferreum 0d64f795c7 af_scaletempo2: fix missing dereference when processing final packet
Missing dereference was not noticed because assigning 0 to pointer is
allowed.
2023-09-20 14:36:23 +02:00
ferreum 05395205dd af_scaletempo2: fix audio-video de-sync caused by speed changes
Fixes #12028

There was an additional issue that audio was always delayed by half the
configured search-interval. This was caused by the `out` buffer length
not being included in the delay calculation.

Notes:
- Every WSOLA iteration advances the input buffer by _some amount_, and
  produces data in the output buffer always of size `ola_hop_size`.
- `mp_scaletempo2_fill_buffer` is always called with `ola_hop_size`
- Thus, the rendered frames are always cleared immediately after
  processing, and `num_complete_frames` is 0 in the delay calculation.
- The factors contributing to delay are:
  - the pending samples in the input buffer according to the search
    block position, and
  - the pending rendered samples in the output buffer (always empty in
    practice).

The frame_delay code looked like that of the rubberband filter, which
might not work for scaletempo2. Sometimes a different amount of input
audio was consumed by scaletempo2 than expected. It may have been caused
by speed changes being a more dynamic process in scaletempo2. This can
be seen by where `playback_rate` is used in `run_one_wsola_iteration`:
`playback_rate` is only referenced after the iteration, when updating
the time and removing old data from buffers.

In scaletempo2, the playback speed is applied by changing the amount the
search block is moved. That apparently averages out correctly at
constant playback speed, but when the speed changes, the error in this
assumption probably spikes. This error accumulated across all speed
changes because of the persistent `frame_delay` value.

With the removal of the persistent `frame_delay`, there should be no way
for the audio to drift off. By deriving the delay from filter buffer
positions, and the buffers are filled only as much as needed, the delay
always stays within buffer bounds.
2023-09-20 14:36:23 +02:00
Dudemanguy 94a985d887 DOCS/vo: remove some dated deprecation warnings about --vo=rpi
Very amusingly, the manual previously said "The rpi VO will be removed
in mpv 0.23.0." Obviously, this didn't happen. It looks like wm4 changed
his mind on this with 51fd8f6fe1, but
never updated the docs. What was the problem? Who knows but allegedly
there are people that use --vo=rpi (it's supposed to work at least).
Actually context_rpi is probably broken since wm4 changed fullscreen
handling in 59cdfe50b2 and no one ever
bothered to fix it after that commit. In fact, that's the last commit
that touched that particular file. Someone did actually fix vo_rpi after
that so that one probably works at least. Anyways, I wouldn't mind just
deleting all rpi stuff, but there's probably some people out there that
use it so whatever. Remove the outdated deprecated language in the
documentation and just accept that we support this unfortunately.
2023-09-19 21:29:47 -05:00
Kacper Michajłow ec4683baa0 meson: enable cplugins on Windows
Fixes: #12185
2023-09-20 02:16:45 +00:00
Kacper Michajłow eab3842d8b cplugin: allow loading mpv_* symbols dynamically
Defining MPV_CPLUGIN_DYNAMIC_SYM during plugin compilation will replace mpv_*
functions with function pointers. Those pointer will be initialized when
loading the plugin.

It is recommended to use this symbol table when targeting Windows. The loader
does not have notion of global symbols. Loading cplugin into mpv process will
not allow this plugin to call any of the symbols that may be available in
other modules. Instead cplugin has to link explicitly to specific PE binary,
libmpv-2.dll/mpv.exe or any other binary that may have linked mpv statically.
This limits portability of cplugin as it would need to be compiled separately
for each of target PE binary that includes mpv's symbols. Which in practice
is unrealictis, as we want one cplugin to be loaded without those restrictions.

Instead of linking to any PE binary, we create function pointer for all mpv's
exported symbols. For convinience names of entrypoints are redefined to those
pointer so no changes are required in cplugin source code, except defining
MPV_CPLUGIN_DYNAMIC_SYM. Those function pointer are exported to make them
available for mpv to init with correct values during runtime, before calling
`mpv_open_cplugin`.

Note that those pointer are decorated with `selectany` attribute, so no need
to worry about multiple definitions, linker will keep only single instance.

This fixes cplugin usability on Windows. Without any API changes, only
recompilation with -DMPV_CPLUGIN_DYNAMIC_SYM is needed.
2023-09-20 02:16:45 +00:00
Kacper Michajłow 4435b1a0d5 libmpv: remove not used mpv.pc.in
waf leftover
2023-09-20 02:16:45 +00:00
chuck- adb118290b osdep/io: provide dlopen, etc. abstraction wrappers for windows 2023-09-20 02:16:45 +00:00
chuck- 0084854f8f scripting: dll cplugins 2023-09-20 02:16:45 +00:00
Kacper Michajłow 703f158880 builtin.conf: modernize internal profiles
The goal is to provide simple to understand quality/performance level
profiles for the users.

Instead of default and gpu-hq profile. There main profiles were added:
    - fast: can run on any hardware
    - default: balanced profile between quality and performance
    - high-quality: out of the box high quality experience. Intended
      mostly for dGPU.

Summary of three profiles, including default one:

[fast]
scale=bilinear
cscale=bilinear (implicit)
dscale=bilinear
dither=no
correct-downscaling=no
linear-downscaling=no
sigmoid-upscaling=no
hdr-compute-peak=no

[default] (implicit mpv defaults)
scale=lanczos
cscale=lanczos
dscale=mitchell
dither-depth=auto
correct-downscaling=yes
linear-downscaling=yes
sigmoid-upscaling=yes
hdr-compute-peak=yes

[high-quality] (inherits default options)
scale=ewa_lanczossharp
cscale=ewa_lanczossharp (implicit)
hdr-peak-percentile=99.995
hdr-contrast-recovery=0.30
allow-delayed-peak-detect=no
deband=yes
scaler-lut-size=8
2023-09-19 22:26:56 +02:00
Kacper Michajłow 7e692ee490 vo: change tscale to oversample by default
Keep it sharp, let users opt-in more blurry result.
2023-09-19 22:26:56 +02:00
Kacper Michajłow 4bedcd36f6 vo: make cscale follow scale by default 2023-09-19 22:26:56 +02:00
Kacper Michajłow 8121d41245 vo: enable correct-downscaling, linear-downscaling, sigmoid-upscaling 2023-09-19 22:26:56 +02:00
Dudemanguy 27a78276eb vo: avoid unnecessary redraws when the OSD shows
296d40dc6f changed how the vo handled
redraw requests in order to fix a race condition that can occur with
pausing. However, there was a slight oversight because a redraw request
that occurred while the core was unlocked and the video was still
playing would still be kept true (previously, this was always cleared).
That redraw is essential if mpv is paused otherwise the old issue comes
back, but if the video is playing it's unnecessary since the next loop
around will simply draw whatever we needed. The extra redraw could cause
a frame drop for some people in certain instances, so the solution is to
simply always clear redraw requests if !in->paused. This eliminates the
extra redraw but still keeps it when pausing.

Fixes #12426 and fixes #11579.
2023-09-19 13:11:30 -05:00
Dudemanguy 7a76cf4d65 demux: prepend some cache options with demuxer
--cache-dir is an awful name that leads to confusion (see #12418).
Change the name to --demuxer-cache-dir and --demuxer-cache-unlink-files
instead.
2023-09-18 17:13:15 +00:00
llyyr 1c09ee44c3 filter_kernels: remove bcspline filter
After fixing the B and C params for bcspline, it ended up being the same
thing as bicubic. There's no reason to have two names for the same
filter, so remove bcspline and keep bicubic to match libplacebo.
2023-09-18 17:44:18 +02:00
llyyr 816de3f064 filter_kernels: fix bcspline params
bcspline is defined as B=1, C=0 in ImageMagick (as CubicFilter) and
libplacebo, so we should match that.
2023-09-18 17:44:18 +02:00
llyyr faf5a4bc8d filter_kernels: add hermite filter
Matches HermiteFilter from Imagemagick (B=C=0, R=1)
2023-09-18 17:44:18 +02:00
llyyr 5efc04006b vo_gpu_next: fix blur and taper values being zero
This would always apply the config blur and taper values to the kernel,
even if it was zero because the user didn't specify any.
2023-09-18 17:42:28 +02:00
Dudemanguy ed5c744aa9 vo_dmabuf_wayland: support 90 degree rotations
All we have to do is set VO_CAP_ROTATE90 and then use buffer transform.
Maybe ideally we would rotate with vavpp instead if possible, but this
would be a convoluted mess that I'm not really interested in dealing
with right now.
2023-09-17 19:29:59 -05:00
Dudemanguy c6cef1bad3 DOCS/vo: remove outdated reference to --vo-vaapi-deinit-mode
This option was removed in db2268d5b1, but
the manual was never updated to reflect that.
2023-09-17 15:24:55 -05:00
Kacper Michajłow a4bf0bd695 demux_mkv: support ProjectionPoseRoll element 2023-09-17 16:48:42 +00:00
Kacper Michajłow 338f31e0b6 demux_mkv: support PixelCrop* elements
Fixes #6017
2023-09-17 16:48:42 +00:00
Kacper Michajłow 008e7db843 TOOLS/matroska.py: add PixelCrop* elements 2023-09-17 16:48:42 +00:00
Kacper Michajłow c40b064e38 demux: add crop to mp_codec_params 2023-09-17 16:48:42 +00:00
Kacper Michajłow 63ca12d7bc win32: remove noisy debug log
It is quite unnecessary to log every window move.
2023-09-17 17:14:34 +02:00
llyyr 181eddc80e osc: add scrolling to audio/sub buttons
Consistent with other osc buttons now
2023-09-17 00:03:45 +02:00
Niklas Haas bc35180933 vo_gpu: remove --scale-wblur etc
No need for this since it's entirely redundant with just changing the
filter radius directly. In fact, that's the whole *point* of the filter
radius - it does not modify the filter, it modifies the scaling of the
window.

Of course, this does not work for non-resizable kernels. But, really,
who cares?
2023-09-16 14:33:45 +02:00
Niklas Haas a24aa6b8f7 filter_kernels: add ewa_lanczos4sharpest
Mainly for vo_gpu_next.
2023-09-16 14:33:45 +02:00
Niklas Haas 93ff7554ac filter_kernels: refine ewa_lanczossharp/soft constants
Replaced by mathematically and numerically precise constants, the result
of exact computation. Also updates the description to provide more
explanation and motivation.
2023-09-16 14:33:45 +02:00
Niklas Haas 2ec79f8bb7 filter_kernels: use true jinc radius
For all filters. For consistency between vo_gpu and vo_gpu_next. Also
makes ewa_lanczossharp less special.
2023-09-16 14:33:45 +02:00
Niklas Haas aef62063f7 filter_kernels: replace magic jinc radius by constant (cosmetic) 2023-09-16 14:33:45 +02:00
Niklas Haas 06e65778be filter_kernels: properly sharpen/blur filter radius
We currently always scaled the window to the size of the configured
radius. However, this is wrong - we should instead be scaling it to the
size of the sharpened/blurred kernel. Since the window is always
stretched to the configured size of the filter, we can accomplish this
easily by just multiplying the blur value into the filter radius
directly, and then using that adjusted radius in place of `f.radius`
everywhere.

On a side note, this gives a very minor performance boost to
ewa_lanczossharp for no downside.
2023-09-16 14:33:45 +02:00
Niklas Haas 87162f0722 vo_gpu: slight bump to hard-coded option size limits
ewa_lanczos4sharpest, for example, overflows this buffer.
2023-09-16 14:33:45 +02:00
Niklas Haas 818ef158e8 vo_gpu_next: remove ewa_lanczossharp nag
Upstream finally caved in to peer pressure and added this filter. Of
course, this also removes the fallback for people on older versions of
libplacebo, but people using mpv git master are probably using
libplacebo git master anyway. It's time to debloat this code.
2023-09-16 14:33:45 +02:00