Commit Graph

1532 Commits

Author SHA1 Message Date
Kacper Michajłow eb16169b27 demux_playlist: add data:// to self-expanding protocols
Found by OSS-Fuzz.
2024-11-02 01:40:41 +01:00
Kacper Michajłow de42e11662 demux_edl: disallow nested edl to avoid infinite loop
Found by OSS-Fuzz.
2024-11-02 01:40:41 +01:00
llyyr c5561b8e09 demux_playlist: fix comparison for current file if it's in current dir
When the file is in the current working directory, stream->path points
the path user passed as arg, so it may or may not include './'.

Strip it from both to make the comparison work

Fixes: c201c4874d
2024-10-24 12:34:58 +02:00
nanahi dd23bf1555 demux_playlist: use STREAM_READ_FILE_FLAGS_DEFAULT 2024-10-22 03:16:51 +03:00
Kacper Michajłow c201c4874d demux_playlist: ensure the file is added to autocreated playlist
Even if it doesn't match extensions in filter mode.
2024-10-08 19:57:16 +02:00
Dudemanguy d54e8c3f40 demux_mkv: drop image probing down to 10000 blocks
It turns out that probing too many blocks is bad. I did not attempt to
go through all the logic but reading that many blocks causes the
demux_reader_state have some pretty funny values which then makes the
playloop think it needs to buffer for cache. It's probably fixable...
but seems hard admittedly so I'll be lazy. Just take out a magnitude off
the probing down to 10000. These seems to be more than sufficient. The
sample in #13975 where we had the opposite issue only needs somewhere
between 1700 and 1750 blocks to be properly detected. Crudely looking
at the demuxer values, 10000 here doesn't appear to alter anything
meaningfully so it does not have the "too many blocks problem".
Hopefully this is a perfect medium? Further improvements to the probe
can always be added later. Or maybe we decide this is all a giant
mistake and delete it. Fixes #14924.
2024-09-26 02:55:35 +00:00
Kacper Michajłow c9f3fa33a6 demux_mkv: add missing color repr init
Fixes: 66e451f4e6
2024-09-25 19:35:21 +02:00
llyyr d84a7c5112 stream: don't mark stdin as a filesystem file
Also rename the field to appropriately reflect what it is supposed to be
used for. The only other use of this was to search for ordered chapter
sources, and that makes no sense for mkv files from stdin.

This also fixes autocreate-playlist loading in the current directory
when the input file is stdin.
2024-09-14 16:17:44 +02:00
Kacper Michajłow b6f0599bfd demux_mkv: fix av_parser_codec leak 2024-08-22 18:13:53 +02:00
Kacper Michajłow 4e50da3ddc demux_playlist: use --directory-filter-types for --autocreate-playlist 2024-08-10 23:27:40 +02:00
Kacper Michajłow 73b58722e7 player/misc: add str_in_list() and use it 2024-08-10 23:27:40 +02:00
Kacper Michajłow b73445dcf3 demux_playlist: add only media files when opening directory 2024-08-10 23:27:40 +02:00
Kacper Michajłow 44a3a3293f options: add --{video,audio,image}-exts 2024-08-10 23:27:40 +02:00
Kacper Michajłow 4f1e9e34c3 demux_playlist: add --directory-filter-types 2024-08-10 23:27:40 +02:00
Kacper Michajłow c54ad6933b demux_playlist: add --autocreate-playlist-{video,audio,image}-exts 2024-08-10 23:27:40 +02:00
Kacper Michajłow bb9b862f0c demux: add --autocreate-playlist 2024-08-10 23:27:40 +02:00
Kacper Michajłow aa35f2e4bd demux_mf: disable glob for fuzzing 2024-08-04 21:33:36 +02:00
Kacper Michajłow 4764e41cac demux/ebml: bump ebml size limit to 512 MiB
While the code before 571f9b0f23 had a
typo and it was intended to be 100 MB, there are files that exceed this
limit, like 147 MiB. Increase the limit to 512 MiB which should be more
than enough for valid files.

From quick look ffmpeg limits to 1<<8 bytes, so we should be good with
our new limit.

In theory this limit could be removed, but it is better to play the
file, possibly with skipped some corrupted block of data, instead OOM.

Fixes: 571f9b0f23
2024-07-15 17:38:22 +02:00
Kacper Michajłow 024c79a53c demux_mf: don't run glob() on urls
Not intended to be run on urls. Fixes stack-overflow in glob() when
unexpected data is passed.

Found by OSS-Fuzz.
2024-07-12 22:38:18 +02:00
Guido Cella c2fc6503fb demux_mf: support URLs in @listfile and filemask
This allows playing arguments like
mf://https://foo.jpg,https://bar.jpg
and also URLs within @listfiles (files with 1 image per line).

URLs still don't work with globs and printf-formats.
2024-07-12 22:37:34 +02:00
Kacper Michajłow 9158653982 demux_mkv: ignore duplicated BlockAdditions to avoid memory leak
This can happen only on invalid files.

Found by OSS-Fuzz.
2024-07-11 03:48:25 +02:00
Kacper Michajłow 66fdec8a67 demux_edl: don't try to extract dirname from self-expanding protocols
Fixes infinite recursion. Trying to extract dirname from string of
memory://<data> is not really a good idea.

Found by OSS-Fuzz.
2024-07-11 03:48:25 +02:00
Kacper Michajłow 571f9b0f23 demux/ebml: fix ebml size check
There was one zero too many. Change the limit to 128 MiB with more
readable notation.
2024-07-09 20:58:39 +02:00
nanahi 33e414fa5d demux: avoid seeking video streams for refresh seek
940854c86f added this logic, but when the
demuxer contains a selected video stream, it causes a seek for the video
stream. This is unnecessary since the problems that commit fixed are only
relevant for external audio streams. For a demuxer with a video stream
selected, the synchronization is done by the demuxer implementation.
Add a check to prevent this.
2024-07-04 22:23:27 +00:00
nanahi c461ea6cd1 demux: don't log if track isn't refreshed
Also use demux_internal type for the refresh_track in style of other
internal functions.
2024-07-04 22:23:27 +00:00
Kacper Michajłow 2b1e9a6537 demux_playlist: don't add base path to self-expanding protocols
Adding base path make sense only if it is a real directory or url
location. In case of protocols like memory adding base path to playlist
entry in facts adds the whole playlist to that entry.

For example `mpv $'memory://#EXTM3U\na/b'` produces infinite loop,
expanding playlist, adding more to it.

open_file adds the dirname to support relative playlist enties, however,
the dirname is invalid when the name doesn't represent a path, such as
with memory://..., so avoid taking the dirname with such protocols.

Found by OSS-Fuzz.
2024-06-27 02:57:22 +02:00
Dudemanguy 6e3d90d72a options: remove some deprecated OPT_REPLACED option mapping
These were all deprecated in mpv 0.37.0 or earlier and are not
considered common enough options to warrant keeping the deprecated
mapping longer. Since demux_cue had only a single option in it, the
entire option substract is removed. This can be readded later if someone
wants to introduce a specific option to it again.
2024-06-25 02:18:58 +00:00
nanahi 940854c86f demux: allow refresh seek for non-video streams
Since d41f0a54b0, enabling a stream will
no longer perform a refresh seek, to fix issues with switching video
tracks. Additionally, 62e9a0c5f6 also
prevents refresh seek on track switching when it happens right after a
seek.

Unfortunately, when external audio files are loaded, preventing refresh
seeks can cause A-V sync issues. Since external tracks have separate demuxer
instances from the internal tracks, the demuxer instances from both
internal and external tracks are explicitly sought to the same pts when
seeking is performed. When enabling an external audio track for the first
time, the existing logic prevents refresh seek because no packets have ever
been read, so the track ends up not being sought. This means that switching
the track in the middle of playback results in a huge A-V desync.

To make it worse, unlike one demuxer instance with multiple tracks,
tracks from multiple demuxer instances are not synced in any meaningful
way beyond the separate explicit seeking. The only thing which keeps these
tracks synced is the generic A-V sync logic, which is unfit for such large
desync above. This means the audio is at the start position after the track
is switched, behind the video, so the audio is not considered ready, and
audio is continuously filtered sequentially until it is synced to the video.
While this is happening, the audio filtering exhausts all CPU resources.

There is also a case with cache enabled: if a seek causes some new data to
be cached, the demuxer is sought to the end of joined cache range.
If track is switched after this, the existing logic prevents a refresh seek,
so the demuxer is at a wrong position after the track is switched.

Fix this by allowing refresh seek for non-video streams, even when no packets
have been read yet or immediately after a seek.
2024-06-22 18:21:28 +00:00
Kacper Michajłow 687eb4c875 various: remove no longer needed availability checks
image_writer: remove jpegxl availability check

meson: remove check for lavu vulkan support

image_writer: remove avif availability check

ad_spdif: remove no longer needed definitions

demux_lavf: remove side data extraction compatibility code

demux/packet: remove ITU T.35 availability check

filters/f_lavfi: remove avfilter_filter_pad_count availability check

image_writer: remove PNG cICP support check

mp_image: remove AV_FRAME_DATA_DOVI_METADATA availability check

mp_image: remove AV_FRAME_FLAG_INTERLACED availability check

vd_lavc: remove ctx->pic->duration availability check

sws_utils: remove av_chroma_location_enum_to_pos availability check

vd_lavc: remove AV_CODEC_EXPORT_DATA_FILM_GRAIN availability check

demux_lavf: always use io_close2
2024-06-22 16:12:14 +02:00
Kacper Michajłow 3c5a79300c various: remove av channel layout check 2024-06-22 16:12:14 +02:00
Kacper Michajłow c194f2dc32 demux_edl: fix infinite loop on empty EDL files
"file" is implicit key, it is always available, so we have to check if
it is not empty.

Found by OSS-Fuzz.

Fixes: 96ef62161a
2024-06-18 03:11:14 +02:00
Kacper Michajłow 6c908363cd demux_lavf: fix null derefence of stream variable
demux_stream_is_selected() already checks if stream is valid, so move
the image format hack check after that.

Fixes: 4ef7931266
2024-06-15 18:08:16 +02:00
nanahi 3fa09458da demux_lavf: add format hack entry for jpeg metadata frames 2024-06-14 17:16:19 +00:00
nanahi daa3264d3f demux_lavf: fix null derefence in io_open callback
The options parameter here can be NULL. It's NULL checked a few lines down,
but not for the propagate_opts loop. This results in null derefence with
--demuxer-lavf-format=image2.

Fixes: b6413f82b2
2024-06-14 17:16:19 +00:00
Dudemanguy 4ef7931266 demux_lavf: drop jpeg frames that are at a nonzero pos
There are jpg files out there that have extra embedded metadata
(pictures from smartphones commonly have an embedded gain map). ffmpeg
doesn't currently support this, so mpv currently sees the extra metadata
as essentially another frame. This results in weird video-like behavior.
Until ffmpeg support this more properly, we can work around this by
simply discarding extra packets and not sending the new frame to the
internal playloop. If demux_lavf detects that the stream is a
single-frame jpg, then we only accepts the packet at pos 0. Anything
else is discarded. Ref #13192.
2024-06-13 19:12:29 +00:00
Dudemanguy a900d41b1e Revert "demux_lavf: pass jpg filenames to ffmpeg for probing"
Passing jpg filenames to ffmpeg is actually quite bad. This causes all
jpg images (at least in my testing) to be probed as image2 which is
blacklisted in demux_lavf since it's completely broken (see commit
74e62ed2d1 for some details). What happens
in practice is that the lavf demxuer fails and the it opens in the mf
demuxer instead. This is OK for simple viewing, but because that demuxer
is limited, many specific file properities and other things are
completely unavailable which breaks any script that may depend on them
(e.g. width, height, etc.) For the small subset of files that this
commit appeared to "fix" (in reality, it just fell back to the mf
demuxer) is not worth breaking property usage in the vast majority of
normal proper files. Ideally ffmpeg should fix this but some other
workaround on our end can be used instead.

This reverts commit d0aeca5918.
2024-06-13 19:12:29 +00:00
Dudemanguy fa89082f2e sub: avoid unneeded calls to is_animated
4e5d996c3a added this as part of a series
of patches written to avoid wasteful sub redraws when playing a still
image with subs. The is_animated special case was specifically for ASS
subtitles that have animations/effects and would need repeated redraws
in the still image case. This check was done unconditionally for all ASS
subtitles, but for very big ASS subtitles, this text parsing can get a
bit expensive.

Because this function call is only ever needed for the weird edge case
of ASS subtitles over a still image, some additional logic can be added
to avoid calling is_animated in the vast majority of cases. The animated
field in demux_packet can be changed to a tristate instead where -1
indicates "unknown" (the default state). In update_subtitle, we can look
at the current state of the video tracks and decide whether or not it is
neccesary to perform is_animated and pass that knowledge to sd_ass
before any subtitle packets are decoded and thus save us from doing this
potentially expensive call.
2024-06-04 12:29:13 +00:00
sfan5 54c755b08d various: add missing checks for directory streams
All of this code opens a stream and expects to read stuff from a file.
But streams can also be directories and that has to be handled.
2024-05-15 22:45:18 +02:00
Kacper Michajłow aa3cf6d57b command: add dolby-vision-profile and dolby-vision-level to track-list 2024-05-10 01:26:30 +02:00
Kacper Michajłow c83c273400 demux_mkv: inject AV_PKT_DATA_DOVI_CONF to demuxed packets 2024-05-10 01:26:30 +02:00
Kacper Michajłow a094971ce8 demux_mkv: demux Block Additional Mappings
Parse Dolby Vision configuration.
2024-05-10 01:26:30 +02:00
Kacper Michajłow d6803c4518 demux_edl: make protocol comparison case insensitive
Else nested edl protocol causes infinite recursion, when loading.

Found by OSS-Fuzz.
2024-05-08 18:52:40 +02:00
Kacper Michajłow b647201795 osdep/dirent: add implementation for Windows SDK build 2024-05-06 22:01:17 +02:00
Kacper Michajłow fffe723fc4 various: move strings.h inclusion to common.h 2024-05-06 22:01:17 +02:00
Kacper Michajłow 18ef834ef4 various: move unistd.h inclusion to common.h 2024-05-06 22:01:17 +02:00
Kacper Michajłow 22ed5d0d3a demux_mkv: fix image detection
If blocks were already demuxed we would skip them and ask for new ones.
For files with few blocks it would return EOF without actually checking
the content.

Also make demux limit higher. In practice it doesn't matter, because if
it is image, video track will have only 1 block. And if it is not image
it will break on 2nd video block.

Fixes: #13975
2024-05-05 14:28:02 +02:00
Aman Karmani abe8f3f9df demux: keep track of ts information per stream type
Signed-off-by: Aman Karmani <aman@tmm1.net>
2024-05-05 14:11:47 +02:00
Kacper Michajłow e42e0f2e2a demux_mkv: make V_QUICKTIME codec detection generic
This allows playing files with any fourcc that is supported by mpv.
2024-05-05 13:53:43 +02:00
Kacper Michajłow b68c742b27 demux/packet: add support for ITU T.35 metadata in Matroska 2024-04-29 01:37:02 +02:00
MartinEesmaa 4f828676fd demux: support VVC Matroska demux
This allows to demux Versatile Video Codec with Matroska container to play.
2024-04-29 01:35:31 +02:00