Commit Graph

45883 Commits

Author SHA1 Message Date
wm4 694157e024 m_option: pretty print mpv_node for OSD
Somewhat useful for debugging. Unfortunately libass (or something else)
strips leading whitespace, making it look slightly more ugly than
necessary. Still an improvement.
2017-10-30 15:32:24 +01:00
wm4 2d958dbf2b demux: refactor to export seek ranges
Even though only 1 seek range is supported at the time.

Other than preparation for possibly future features, the main gain is
actually that we finally separate the reporting for the buffering, and
the seek ranges. These can be subtly different, so it's good to have a
clear separation.

This commit also fixes that the ts_reader wasn't rebased to the start
time, which could make the player show "???" for buffered cache amount
in some .ts files and others (especially at the end, when ts_reader
could become higher than ts_max). It also fixes writing the cache-end
field in the demuxer-cache-state property: it checked ts_start against
NOPTS, which makes no sense.

ts_start was never used (except for the bug mentioned above), so get rid
of it completely. This also makes it convenient to move the segment
check for last_ts to the demux_add_packet() function.
2017-10-30 15:28:59 +01:00
wm4 d6ebb2df47 Get rid of deprecated AVFrame accessors
Fist we were required to use them for ABI compat. reasons (and other
BS), now they're deprecated and we're supposed to access them directly
again.
2017-10-30 13:36:44 +01:00
wm4 4f51326c28 manpage: fix/improve --msg-level description
Fixes #5055.
2017-10-30 12:58:55 +01:00
Ryo Munakata 046fe45950 hwdec_drmprime_drm: fix segv with --hwdec 2017-10-30 12:46:49 +01:00
Oleg Oshmyan 98986948e8 lavc_conv: make disable_styles faster
The current invocation of bstr_cut is as good as no cutting at all.
Almost the entire header is reread in every iteration of the loop.
I don't know how many styles libavcodec tends to generate, but if
(now or in the future) it generates many, then this loop is slow
for no good reason. If anything, the code would be more clear and
have the same performance if it didn't call bstr_cut at all.

The intention here (and the sensible thing regardless) seems to be
to skip the part of the string that bstr_find has already looked
through and found nothing. This commit additionally skips the whole
substring, because overlapping matches are impossible.
2017-10-30 12:44:11 +01:00
Daniel Kucera e9dc4ac86f demux_lavf: return AVERROR_EOF on file end
Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
Signed-off-by: wm4 <wm4@nowhere>

Uses different style and different logic from original PR.
2017-10-30 12:42:00 +01:00
wm4 6b745769b1 vd_lavc: add support for nvdec hwaccel
See manpage additions.

(In ffmpeg-mpv and Libav, this is still called "cuvid". Libav won't work
yet, because it has no frame params support yet, but this could get
fixed soon.)
2017-10-28 19:59:08 +02:00
wm4 3413fe4dfd demux_mkv: don't probe start time by default
It isn't all that reliable, and improving it would make startup slower
and require more complexity. There isn't even a good reason to do this
(other than semi-broken mkv files), so don't do it. Also see previous
commit.
2017-10-27 18:41:47 +02:00
wm4 c23c9e22ae lavc_conv: clamp timestamps to positive, fixes idiotic ffmpeg issue
In some cases, demux_mkv will detect a start time slightly above 0, but
there might still be a subtitle starting at exactly 0. When the player
rebases the timestamps to assumed start time, the subtitle will have a
slightly negative timestamp in the end. libavcodec's subtitle converter
turns this into a larger number due to underflow. Fix by clamping
subtitles always to 0, which may or may not be what you want.

At least it fixes #5047.
2017-10-27 18:40:33 +02:00
wm4 3c21694ff0 travis: correctly remove ffmpeg-stable from build matrix 2017-10-27 18:23:39 +02:00
wm4 47dca74f03 travis: adjust ffmpeg URL
No idea if this is correct.
2017-10-27 18:13:02 +02:00
wm4 4d47805a76 lavfi: fix warnings with newer libavfilter versions
Most likely will cause new warnings with avfilter_graph_alloc_filter()
on old libavfilter versions. Ingore that part.
2017-10-27 18:09:08 +02:00
wm4 83d44aca7d build: require our own ffmpeg repo
This is required now. Can't have FFmpeg upstream randomly break us and
then not fix it (like this recent EOF issue).

Upstream FFmpeg is of course still supported, but you will need to edit
the build scripts. Official support is only with the master branch of
our own repo.
2017-10-27 18:08:40 +02:00
wm4 f36d152eb7 vd_lavc: use avcodec_fill_hw_frames_parameters() API
This removes the need for codec- and API-specific knowledge in the
libavcodec hardware acceleration API user. For mpv, this removes the
need for vd_lavc_hwdec.pixfmt_map and a few other things. (For now, we
still keep the "old" parts for the sake of supporting older Libav, and
FFgarbage.)
2017-10-27 18:08:20 +02:00
Niklas Haas 4701c5ba4f vo_gpu: fix ra_tex_upload_pbo for 2D textures
params->rc was ignored in the calculation for the buffer size. I fucking
hate this stupid ra_tex_upload signature where *rc is randomly relevant
or not.
2017-10-27 16:56:23 +02:00
wm4 d6f33e0b0d vo_gpu: osd: simplify some code
Coverity complains about this, but it's probably a false positive.
Anyway, rewrite it in a slightly more readable way. Now it's more
obvious that it is correct.
2017-10-27 14:19:57 +02:00
wm4 6a9f457102 audio/out: initialize an array to avoid confusing static analyzer
I _think_ this confuses Coverity and it thinks there is uninitialized
data to be read. Initialize the array to change/remove the warning, or
if there's a real problem, to make it easier to detect. (Basically apply
defensive coding.)
2017-10-27 14:11:33 +02:00
wm4 c54673b86f af_lavfi: fix small memory leak
Plus restructure the error path to make this simpler.
2017-10-27 13:54:40 +02:00
wm4 41beaa653a audio: fix small memory leak
Most commonly happened with --end, in which case that field tends to be
set.
2017-10-27 13:54:08 +02:00
wm4 f08ec22567 command: change demuxer-cache-state property to return multiple ranges
Even if the demuxer cache does not multiple ranges yet. This is to
reduce the pain should caching of multiple ranges ever be implemented.

Also change it from the sub properties stuff to return a mpv_node
directly, which is less roundabout. Sub-property access won't work
anymore, though.

Remove the seekable-start/-end fields as well, as they're redundant with
the ranges.

All this would normally be considered an API change, but since it's been
only a few days with no known users, change it immediately.

This adds some node.c helpers as well, as the code would be too damn
fugly otherwise.
2017-10-26 22:31:04 +02:00
wm4 22fa498bf9 vd_lavc: more aggressive frame dropping for intra only codecs
Should speed up seeks.

(Unfortunately it's useless for backstepping. Backstepping is like
precise seeking, except we're unable to drop frames, as we can't know
the previous frame if we drop it.)
2017-10-26 19:44:26 +02:00
wm4 ae8b531207 demux_timeline: don't use segments for DASH
Recent regression. Crashes because it sets the segmented flag, without
actually setting the fields required for segmentation.
2017-10-26 00:38:20 +02:00
Niklas Haas c2d4fd0ef4 vo_gpu: change --tone-mapping-desaturate algorithm
Comparing mpv's implementation against the ACES ODR reference samples
and algorithms, it seems like they're happy desaturating highlights
_way_ more aggressively than mpv currently does. And indeed, looking at
some example clips like The Redwoods (which is actually well-mastered),
the current desaturation produces unnatural-looking brightness fringes
where the sky meets the treeline.

Adjust the algorithm to make it apply to a much larger, more gradual
brightness region; and change the interpretation of the parameter. As a
bonus, the new parameter is actually sanely scaled (higher values = more
desaturation). Also, make it scale based on the signal level instead of
the luminance, to avoid under-desaturating bright blues.
2017-10-25 17:24:27 +02:00
wm4 ec8cad40f2 demux: better computation of seek start target
Avoids that cache seeking is not possible with files that have audio
frames with no timestamps (such as avi, sometimes mkv sub-packets from
lacing). These would set back_pts (first seekable PTS) to NOPTS, and
thus disable cache seeking completely. Instead, prune such packets until
we find one with timestamps.

One corner case is that the new next good packet might be in the forward
cache. In this case we defer dropping until the next time this code is
run, and the reader position has possibly moved past the drop point.
2017-10-25 16:39:33 +02:00
wm4 d235380cd3 demux: reject cache seeks if parts of the range are unset
In theory, start/ts_min could be set to NOPTS, in which case
"pts < start" for a valid pts would always evaluate to false.

Also remove the redundant "in-cache seek is possible.." message, as
there's always another message when cache seeks are done.
2017-10-25 16:39:33 +02:00
wm4 03a0e8336a demux: fall back to DTS when determining seek target
Fixes AVI in particular, which abuses DTS for reordered PTS. (It's not
really DTS...)
2017-10-25 16:39:33 +02:00
wm4 e6348504b3 demux: disallow seeking if there are streams with no timestamps
The seek range computation ignored streams with no timestamps. For
things like buffer estimation this is OK and wanted, but the seek range
needs to be conservative.
2017-10-25 16:39:33 +02:00
wm4 3d71651523 demux: fix tracking of forward/backward cache size
Which parts of the queue are considered forward or backward cache
depends on ds->reader_header. The packet at ds->reader_head, as well as
all packets following it (via the ->next field) are considered forward.
The fw_packs/fw_bytes/bw_bytes must be updated accordingly.

This broke in demux_add_packet(), when ds->reader_head was _not_ set on
the first packet (or before). This could happen since commit
05ae571241, which can require skipping packets (so they immediately end
up in the backbuffer).
2017-10-25 16:39:33 +02:00
wm4 56d9dafbbb demux: respect timeline boundaries for cache seeks
With the timeline code, a packet at the start or end of a segment can
refer to an invisible frame. So it doesn't extend the seek range, and
the timestamp should be clipped to the actual segment range.

Also restructure recompute_keyframe_target_pts() to be hopefully less
confusing.
2017-10-25 16:39:33 +02:00
wm4 8bf399e02e demux: don't report unknown queue state if no packets were added
Restores some behavior from before the demuxer cache changes, though
affects mostly just OSD display. The unknown queue state is reserved for
streams with missing or messed up timestamps.
2017-10-25 16:39:33 +02:00
wm4 374e3bd83c demux_timeline: trust attached picture flag
Fully fixes behavior of the files mentioned in the previous commit. Will
probably lead to worse behavior if someone tries to fix real video and
cover art tracks, but that's a broken fringe case anyway.
2017-10-25 16:39:33 +02:00
wm4 3d32cb1649 demux: set correct stream index for attached pictures
This fixes .cue files with audio files that contain attached pictures to
some degree. demux_timeline.c just discarded packets with unset index,
so the picture was never fed to the decoder.
2017-10-25 16:39:33 +02:00
James Ross-Gowan 257a2b9646 win32: add more-POSIXy versions of open() and fstat()
Directory-opening never worked on Windows because MSVCRT's open()
doesn't open directories and its fstat() doesn't recognise directory
handles. These are just MSVCRT restrictions, and the Windows API itself
has no problem with opening directories as file objects, so reimplement
mpv's mp_open and mp_stat to use the Windows API directly. This should
fix directory playback.

This also populates the st_dev and st_ino fields of struct stat, so
filesystem loop checking in demux_playlist.c should now work on Windows.

Fixes #4711
2017-10-25 22:37:20 +11:00
wm4 a5b51f75dc demux: get rid of demux_packet.new_segment field
The new_segment field was used to track the decoder data flow handler of
timeline boundaries, which are used for ordered chapters etc. (anything
that sets demuxer_desc.load_timeline). This broke seeking with the
demuxer cache enabled. The demuxer is expected to set the new_segment
field after every seek or segment boundary switch, so the cached packets
basically contained incorrect values for this, and the decoders were not
initialized correctly.

Fix this by getting rid of the flag completely. Let the decoders instead
compare the segment information by content, which is hopefully enough.
(In theory, two segments with same information could perhaps appear in
broken-ish corner cases, or in an attempt to simulate looping, and such.
I preferred the simple solution over others, such as generating unique
and stable segment IDs.)

We still add a "segmented" field to make it explicit whether segments
are used, instead of doing something silly like testing arbitrary other
segment fields for validity.

Cached seeking with timeline stuff is still slightly broken even with
this commit: the seek logic is not aware of the overlap that segments
can have, and the timestamp clamping that needs to be performed in
theory to account for the fact that a packet might contain a frame that
is always clipped off by segment handling. This can be fixed later.
2017-10-24 19:35:55 +02:00
wm4 bb9679d9a3 demux_timeline: change virtual_stream array to array of pointers
Needed for a failed thing, leaving it anyway because it causes no harm
and might be less awkward if struct virtual_stream is possibly extended
anyway in the future.
2017-10-24 19:24:20 +02:00
wm4 4593002222 manpage: add --hwdec=rkmpp entry 2017-10-23 21:12:45 +02:00
wm4 2c00687641 client API: minor bump + change entry for DRM related opengl-cb changes
Commit cfcee4cfe7 forgot those.
2017-10-23 21:11:44 +02:00
Lionel CHAZALLON 1992bb5151 video : Move drm options to substruct.
This allows to group them and most of all query the group config when
needed and when we don't have the access to vo.
2017-10-23 21:08:20 +02:00
Lionel CHAZALLON cfcee4cfe7 Add DRM_PRIME Format Handling and Display for RockChip MPP decoders
This commit allows to use the AV_PIX_FMT_DRM_PRIME newly introduced
format in ffmpeg that allows decoders to provide an AVDRMFrameDescriptor
struct.

That struct holds dmabuf fds and information allowing zerocopy rendering
using KMS / DRM Atomic.

This has been tested on RockChip ROCK64 device.
2017-10-23 21:07:24 +02:00
Lionel CHAZALLON 762b8cc300 video : allow drm primary plane to be transparent for egl context
We want primary plane to be one top of overlay (video), so we need it to
be 32 bits.
2017-10-23 21:06:53 +02:00
wm4 05ae571241 demux: fix cached SEEK_FORWARD seeks into end of cached regions/EOF
Although seeking past the cached range will trigger a low level seek, a
seek into the region between cache end and last video key frame would
simply seek to the video key frame. This meant that you could get
"stuck" at the end of the file instead of terminating playback when
trying to seek past the end.

One change is that we fix this by _actually_ allowing SEEK_FORWARD to
seek past the last video keyframe in find_seek_target().

In that case, or otherwise seeking to cache buffer end, it could happen
that we set ds->reader_head=NULL if the seek target is after the current
packet. We allow this, because the end of the cached region is defined
by the existence of "any" packet, not necessarily a key frame. Seeking
there still makes sense, because we know that there is going to be more
packets (or EOF) that satisfy the seek target.

The problem is that just resuming demuxing with reader_head==NULL will
simply return any packets that come its way, even non-keyframe ones.
Some decoders will produce ugly soup in this case. (In practice, this
was not a problem, because seeking at the end of the cached region was
rare before this commit, and also some decoders like h264 will skip
broken frames by default anyway.)

So the other change of this commit is to enable key frame skipping.

As a nasty implementation detail, we use a separate flag, instead of
setting reader_head to the first key frame encounted (reader_head being
NULL can happen after a normal seek or on playback start, and then we
want to mirror the underlying demuxer behavior, for better or worse).

This change is relatively untested, so you get to keep the pieces for
yourself.
2017-10-23 20:55:11 +02:00
wm4 512509705e demux: report buffered duration of 0 during seeking instead of unknown
Looks ugly on the status line and could upset the buffering logic.
2017-10-23 19:36:20 +02:00
wm4 dbd22f43be demux: drop redundant SEEK_BACKWARD flag
Seems like most code dealing with this was for setting it in redundant
cases. Now SEEK_BACKWARD is redundant, and SEEK_FORWARD is the odd one
out.

Also fix that SEEK_FORWARD was not correctly unset in try_seek_cache().

In demux_mkv_seek(), make the arbitrary decision that a video stream is
not required for the subtitle prefetch logic to be active. We might want
subtitles with long duration even with audio only playback, or if the
file is used as external subtitle.
2017-10-23 19:05:39 +02:00
Mark Thompson 26b46950a1 vo_opengl: hwdec_vaegl: Disable vaExportSurfaceHandle()
libva 2.0 (VAAPI 1.0.0) was released without it, but it is scheduled to
be included in libva 2.1.
2017-10-23 11:58:13 +02:00
wm4 34676fc94d demux: fix crash with cue/ordered chapter files
If a packet uses segmentation, the codec field must be set. Copying the
codec field was forgotten as an oversight, which is why this just
crashes. This showed up only now, because demux_copy_packet() was not
used before in the main demux path until recently.

Fixes #5027.
2017-10-23 11:31:45 +02:00
Nicolas F 0358cca39e video: fix typo in log message 2017-10-22 16:51:09 +11:00
Rostislav Pehlivanov f8aeda0da9 wayland_common: check monitor scale
Since we divide by it in a couple of places and compositors can be crazy,
its better to be safe than sorry.
Also checks cursor spawn durinig init (pointless since it does again on
cursor entry but its more correct).
2017-10-22 06:49:35 +01:00
Rostislav Pehlivanov 78ef7fb766 wayland_common: improve cursor code and scale cursor properly
It seems the cursor hadn't had its position properly adjusted when scaled.
Hence, bring back correct buffer scaling to make the cursor look fine.
Also the cursor surface now gets created sooner so that's better.
2017-10-22 05:53:20 +01:00
wm4 60df01512c command: read the diff if you want to know 2017-10-21 21:13:53 +02:00