Fixes reading EMBL sizes in some files and makes this function readable
while at it.
Would be good to inline mp_log2(), but should be good enough.
Fixes: #15691
Like 565e7d906c did for avif, consider 1-frame HEVC as images, as HEVC
videos have nb_frames 0 or > 1.
Specifically, in the FATE suite:
nb_frames = 0 and are images:
cbf_cr_cb_TUDepth_4_circle.h265 food.hevc hdr10_plus_h265_sample.hevc
hdr_vivid_h265_sample.hevc hevc-monochrome.hevc
nb_frames = 0 and are videos:
mv_nuh_layer_id.bit paired_fields.hevc
paramchange_yuv420p_yuv420p10.hevc pir.hevc
nb_frames > 0:
dv84.mov extradata-reload-multi-stsd.mov multiview.mov
two_first_slice.mp4
As with other video codecs, the hevc images with nb_frames = 0 which are
really frames cut from a video are not detected as images, but you will
only find these files in FATE.
* Early exit if there is no useful data in the AVReplayGain
structure (FFmpeg does check that gain of at least one thing is
not INT32_MIN, but leaves the peak unchecked so it can be zero).
* Less depth in the if structure.
This simplifies the code, not requiring a loop.
Moves the getter definition somewhat upwards to allow
for its usage in a function that was defined before it.
This allows to select DVD/Blu-Ray title easily. Titles are listed as
editions with their duration and number.
I wanted to include Angles also in this selection, but currently Angles
are not that well supported, so let's stick with titles and leave the
rest for the future changes.
We might migrate to lavf demuxer for DVD/Blu-Ray in the future, the mpv
implementation is rotted anyway.
Fixes#14586
The first AVPacket method has been deprecated in FFmpeg, and only
the HEVC decoder would read this information from there. The native
AV1 decoder as well as the libdav1d wrapper only support the newer
propagation method via codec context's side data. {ad,sd,vd}_lavc
call mp_set_avctx_codec_headers which copies the side data from
codecpar to codec context, so no changes are required on the
receiving end.
This process has been deprecated since avformat 60.15.100 and
since avcodec 60.30.101 AV_PKT_DATA_DOVI_CONF has been read from
AVCodecContext's coded_side_data. Additionally, the HEVC decoder
is the only one which currently reads this side data from packets,
the native AV1 decoder as well as the libdav1d wrapper instead only
support the newer propagation method via codec context's side data.
How this currently is supposed to propagate is:
* demux_lavf copies the codec parameters into sh_stream's lav_codecpar.
* {ad,sd,vd}_lavc call mp_set_avctx_codec_headers that calls
avcodec_parameters_to_context, which then sets global side data
to the codec context.
As this logic is already in place, so no additional changes are required
for things to work and the deprecated function call can just be
cleaned up.
Ref: FFmpeg/FFmpeg@5432d2aaca
Ref: FFmpeg/FFmpeg@804be7f9e3
Ref: FFmpeg/FFmpeg@12e5116872
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
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.
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.
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
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.
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.
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.
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.
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.