1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-25 04:38:01 +00:00
Commit Graph

46672 Commits

Author SHA1 Message Date
wm4
1e672f08f2 osd: another shitty pointless UB
The pointer could be NULL if the number of bytes to copy was 0. In a
sane world, this would be fine, but not the current world.
2018-10-19 11:06:56 +02:00
wm4
13c3270891 demux: remove a bogus unlock
Bug caused by a recent refactor. The function is not supposed to unlock
the mutex anymore, but the unlock was forgotten on an obscure code path.
This could sometimes lead to crashes, depending on libc behavior (when
an unlocked mutex was unlocked again, or it tries to unlock a mutex
locked by a different thread).

None of those fancy debug tools could tell me that. I found it by
switching to an error checking mutex and wrapping pthread calls into a
macro that checks their return values.
2018-10-19 11:06:47 +02:00
wm4
82078b1a6d demux: fix some theoretical UB with no impact
If the number of chapters is 0, the chapter list can be NULL. clang
complains that we pass NULL to qsort(). This is yet another pointless UB
that exists for no reason other than wasting your time.
2018-10-19 11:06:28 +02:00
wm4
91def93e12 x11: don't hide cursor if window isn't focused
I found this sort of annoying.

You could argue that the "frontend" should maybe contain this logic, but
who cares.
2018-10-11 06:38:57 +02:00
wm4
9c4dd8c24f stream: silence failed seek message on termination
Seems to happen often with ytdl pseudo-DASH streams, so whatever. I
couldn't reproduce it and check what triggers it, I just remember seeing
the error message and found it annoying.
2018-10-11 06:07:43 +02:00
wm4
4b1202a91a demux: make demuxer list static, remove ancient comment
I'd actually very much encourage demuxer implementations outside crappy
libavformat.
2018-10-11 05:46:28 +02:00
wm4
5868a08657 build: silence idiotic -Wformat-truncation
This warns about player/audio.c:253 with gcc 8.2.0. Although this
warning could be useful to check the worst case estimation, the compiler
doesn't explain how it gets its dumb, bogus result, so this is useless.
You'd just end up trying to make the compiler happy for no reason.
2018-10-11 05:45:47 +02:00
wm4
fc5a775f13 stream: something 2018-10-11 05:43:54 +02:00
wm4
098cf8be8f demux_lavf: increase max. probe size
For those shitty mp3s with extremely large ID3v2/APIC tags, and for
which libavformat insists on reading all data until after the ID3v2.
2018-10-02 19:59:22 +02:00
wm4
70e76eb80a stream: redo buffer handling and allow arbitrary size for stream_peek()
struct stream used to include the stream buffer, including peek buffer,
inline in the struct. It could not be resized, which means the maximum
peek size was set in stone. This meant demux_lavf.c could peek only so
much data.

Change it to use a dynamic buffer. Because it's possible, keep the
inline buffer for default buffer sizes (which are basically always used
outside of file opening). It's unknown whether it really helps with
anything. Probably not.

This is also the fallback plan in case we need something like the old
stream cache in order to deal with mp4 + unseekable http: the code can
now be easily changed to use any buffer size.
2018-10-02 19:59:22 +02:00
wm4
926a49e990 demux: another unused function 2018-10-01 23:36:11 +02:00
wm4
586386bed1 stats: show file format
Useful in particular with ytdl, where you never know what you get.
2018-09-22 11:35:32 +02:00
wm4
74dc7bcfb5 vo, vo_gpu, glx: correct GLX_OML_sync_control usage
I misunderstood how this extension works. If I understand it correctly
now, it's worse than I thought. They key thing is that the (ust, msc,
sbc) tripple is not for a single swap event. Instead, (ust, msc) run
independently from sbc. Assuming a CFR display/compositor, this means
you can at best know the vsync phase and frequency, but not the exact
time a sbc changed value.

There is GLX_INTEL_swap_event, which might work as expected, but it has
no EGL equivalent (while GLX_OML_sync_control does, in theory).

Redo the context_glx sync code. Now it's either more correct or less
correct. I wanted to add proper skip detection (if a vsync gets skipped
due to rendering taking too long and other problems), but it turned out
to be too complex, so only some unused fields in vo.h are left of it.
The "generic" skip detection has to do.

The vsync_duration field is also unused by vo.c.

Actually this seems to be an improvement. In cases where the flip call
timing is off, but the real driver-level timing apparently still works,
this will not report vsync skips or higher vsync jitter anymore. I could
observe this with screenshots and fullscreen switching. On the other
hand, maybe it just introduces an A/V offset or so.

Why the fuck can't there be a proper API for retrieving these
statistics? I'm not even asking for much.
2018-09-21 15:51:52 +02:00
wm4
53f05d5a3b demux_lavf: hack-fix EDL mp4 DASH hack
I encountered a stream that fails with "Could not demux init fragment.".
It turns out this is a regression from the recent change to that code.
The assumption was that demux_lavf.c would treat this as concatenated
stream - which it does, but not for probing.

Doing this transparently is hard without doing it properly. Doing it
properly would mean creating some sort of stream_concat (reminiscent of
that FFmpeg security bug). I probably don't want to go there, and I
think libavformat should just support this directly, so whatever.
Hack-fix this with the knowledge that the init segment will always
contain the headers.
2018-09-15 23:41:55 +02:00
wm4
700b02a4f1 command: report unknown file size as unavailable, not -1 2018-09-15 19:09:53 +02:00
wm4
e495dc03e9 demux_mkv: simplify avi compat. codec_tags.c GUID lookup
The redundancy here always annoyed me. Back then I didn't change it
because it's hard to test and I just had fixed something. This doesn't
matter anymore, so simplify it, without testing and with the risk that
something breaks (why care).
2018-09-14 14:17:32 +02:00
wm4
7ce2430104 demux: autoselection is gone
Was used by DVD, I think.
2018-09-08 23:51:29 +02:00
wm4
73c6c6813e stats.lua: silence annoying fontconfig warnings
Apparently I don't have this font.
2018-09-08 23:13:35 +02:00
wm4
fe1451737e stream_libarchive: fix hangs when demuxer does out of bound seeks
This happened with a .flac file inside an archive. It tried to seek
beyond the end of the archive entry in a format where seeking isn't
supported. stream_libarchive handles these situations by skipping data.
But when the end of the archive is reached, archive_read_data() returns
0. While libarchive didn't bother to fucking document this, they do say
it's supposed to work like read(), so I guess a return value of 0 really
means EOF. So change the "< 0" to "<= 0". Also add some error logging.

The same file actually worked without out of bounds reads when
extracted, so there still might be something very wrong.
2018-09-08 16:17:36 +02:00
wm4
66e893ec5b demux: remove some more minor dead code
Also add clarifications.
2018-09-08 15:50:29 +02:00
wm4
07a4f2cab7 demux: fix crashing on edl
Evil shit due to a huge ownership/lifetime mess of various objects.
demux_close_stream() caused 1. the mp_cancel handle being lost (fix by
explicitly preserving it on the new dummy stream), and 2. passing a
dangling stream pointer to the timeline "demuxer" (use demuxer->stream,
which will never be a dangling pointer).

As one defensive programming measure, stop accessing the "stream"
variable in open_given_type(), even where it would still work. This
includes removing a redundant line of code, and removing the peak call,
which should not be needed anymore, as the remaining demuxers do this
mostly correctly.
2018-09-08 15:46:58 +02:00
wm4
1a94f7fc80 demux: remove some dead code
No idea what that shit is. Likely forgotten when timed metadata was
introduced, and some of the old mechanisms were replaced.
2018-09-08 15:25:53 +02:00
wm4
d3c7da53e8 demux: get rid of ->control callback
The only thing left is the notification for track switching. Just get
rid of that.

There's probably no real reason to get rid of control(), but why not. I
think I was actually trying to do some real work but fuck that.
2018-09-07 23:10:26 +02:00
wm4
c203deb80c demux: change hack for closing subtitle files early
Subtitles (and a few other file types, like playlists) are not streamed,
but fully read on opening. This means keeping the file handle or network
socket open is a waste of resources and could cause other weird
behavior. This is why there's a hack to close them after opening.

Change this hack to make the demuxer itself do this, which is less
weird. (Until recently, demuxer->stream ownership was more complex,
which is why it was done this way.)
2018-09-07 23:02:36 +02:00
wm4
edecfe2a30 demux: make demux_open() private
I always wanted to get rid of this, because it makes the ownership rules
for the stream pointer really awkward. demux_edl.c was the only
remaining user of this. Replace it with a semi-clever idea: the init
segment shit can be used to pass the "file" contents as memory block,
and "memory://" itself provides an empty stream. I have no idea if this
actually works, because I didn't immediately find a test stream (would
have to be some youtube DASH shit).
2018-09-07 22:40:12 +02:00
wm4
4b2cbefc0d demux: simplify API for returning cache status
Instead of going through those weird DEMUXER_CTRLs, query this
information directly. I'm not sure which kind of brain damage made me
use CTRLs for these. Since there are no other DEMUXER_CTRLs that make
sense for the frontend, remove the remaining infrastructure for them
too.
2018-09-07 22:26:48 +02:00
wm4
5282b5ea12 demux: return stream file size differently, rip out stream ctrls
The stream size return was the only thing that still required doing
STREAM_CTRLs from frontend through the demuxer layer. This can be done
much easier, so rip it out. Also rip out the now unused infrastructure
for STREAM_CTRLs via demuxer layer.
2018-09-07 21:58:46 +02:00
wm4
4d24ba4f2b stream_libarchive: remove base filename stuff
Apparently this was so that when playing a video file from a .rar file,
it would load external subtitles with the same name (instead of looking
for mpv's rar:// mangled URL). This was requested on github almost 5
years ago. Seems like a shit feature, and why should I give a fuck? Drop
it, because it complicates some in progress change.
2018-09-07 21:41:52 +02:00
wm4
283362f5c4 demux_timeline: fix off by one error, rearrange weird code
This code set pkt->stream to a value which I'm not sure whether it's
correct. A recent commit overwrote it with a value that is definitely
correct.

There appears to be an off by one error. No fucking clue whether this
was somehow correct, but applying an apparent fix does not seem to break
anything, so whatever.
2018-09-07 21:32:01 +02:00
wm4
59e78cb028 demux: return packets directly from demuxer instead of using sh_stream
Preparation for other potential changes to separate demuxer cache/thread
and actual demuxers.

Most things are untested, but it seems to work somewhat.
2018-09-07 15:20:32 +02:00
wm4
0d40788299 Remove any pretense for big endian support
I wouldn't have to care, but fuck big endian.
2018-09-07 13:41:07 +02:00
wm4
14eb300c78 demux: add another stream recording feature
--record-file is nice, but only sometimes. If you watch some sort of
livestream which you want to record, it's actually much nicer not to
record what you're currently "seeing", but anything you're receiving.
2018-09-01 16:06:41 +02:00
wm4
8446eb2322 demux_lavf: to get effective HLS bitrate
In theory, this could be easily done with custom I/O. In practice, all
the halfassed garbage in FFmpeg shits itself and fucks up like there's
no tomorrow. There are several problems:

1. FFmpeg pretends you can do custom I/O, but in reality there's a lot
that custom I/O can do. hls.c even contains explicit checks to disable
important things if custom I/O is used! In particular, you can't use the
HTTP keepalive functionality (needed for somewhat decent HLS
performance), because some cranky asshole in the cursed FFmpeg dev.
community blocked it.

2. The implementation of nested I/O callbacks (io_open/io_close) is
bogus and halfassed (like everything in FFmpeg, really). It will call
io_open on some URLs without ever calling io_close. Instead, it'll call
avio_close() on the context directly. From what I can tell, avio_close()
is incompable to custom I/O anyway (overwhelmed by their own garbage,
the fFmpeg devs created the io_close callback for this reason, because
they couldn't fix their own fucking garbage). This commit adds some
shitty workaround for this (technically triggers UB, but with that
garbage heap of a library we depend on it's not like it matters).

3. Even then, you can't proxy I/O contexts (see 1.), but we can just
keep track of the opened nested I/O contexts. The bytes_read is
documented as not public, but reading it is literally the only way to
get what we want.

A more reasonable approach would probably be using curl. It could
transparently handle the keep-alive thing, as well as propagating
cookies etc. (which doesn't work with the FFmpeg approach if you use
custom I/O). Of course even better if there were an independent HLS
implementation anywhere. FFmpeg's HLS support is so embarrassing
pathetic and just goes to show that they belong into the past
(multimedia from 2000-2010) and should either modernize or fuck off.
With FFmpeg's shit-crusted structures, todic communities, and retarded
assholes denying progress, probably the latter. Did I already mention
that FFmpeg is a shit fucked steaming pile of garbage shit?

And all just to get some basic I/O stats, that any proper HLS consumer
requires in order to implement adaptive streaming correctly (i.e.
browser based players, and nothing FFmshit based).
2018-09-01 15:28:40 +02:00
wm4
8feb512dd4 demux, stream: readd cache-speed in some other form
it's more like an input speed rather than a cache speed, but who cares.
2018-09-01 13:04:45 +02:00
wm4
6073e99c09 stream: remove DVD/CDDA sector size alignment 2018-09-01 11:56:28 +02:00
wm4
65a1c90b33 stream: remove some more optical disc leftovers 2018-09-01 11:54:28 +02:00
wm4
7ec597628f vo: use a struct for vsync feedback stuff
So new useless stuff can be easily added.
2018-08-31 20:08:52 +02:00
wm4
d73a8a93ce vo_gpu: glx: use GLX_OML_sync_control for better vsync reporting
Use the extension to compute the (hopefully correct) video delay and
vsync phase.

This is very fuzzy, because the latency will suddenly be applied after
some frames have already been shown. This means there _will_ be "jumps"
in the time accounting, which can lead to strange effects at start of
playback (such as making initial "dropped" etc. frames worse). The only
reasonable way to fix this would be running a few dummy frame swaps at
start of playback until the latency is known. The same happens when
unpausing.

This only affects display-sync mode.

Correct function was not confirmed. It only "looks right". I don't have
the equipment to make scientifically correct measurements.

A potentially bad thing is that we trust the timestamps we're receiving.
Out of bounds timestamps could wreak havoc. On the other hand, this will
probably cause the higher level code to panic and just disable DS.

As a further caveat, this makes a bunch of assumptions about UST
timestamps. If there are delayed frames (i.e. we skipped one or more
vsyncs), the latency logic is mostly reset. There is no attempt to make
the vo.c skipped vsync logic to use this. Also, the latency computation
determines a vsync duration, and there's no effort to reconcile or share
the vo.c logic for determining vsync duration.
2018-08-31 16:36:33 +02:00
wm4
8f4844b35c demux, stream: remove unneeded crap (esp. optical discs and Linux TV)
I don't ever use them, so kill them.

Linux TV is excessively complex, and whenever I attempted to use it, it
didn't work well or would have required some major work to update it.
(For example, when I tried to use a webcam-type device with tv://, it
worked badly; even the libavdevice garbage worked better.)

The "program" property was rather complex and rather obscure. I didn't
ever use it. Should there ever be a proper use for it (maybe HLS stream
selection?), it should be rewritten anyway.
2018-08-31 13:53:43 +02:00
wm4
559a400ac3 demux, stream: rip out the classic stream cache
The demuxer cache is the only cache now. Might need another change to
combat seeking failures in mp4 etc. The only bad thing is the loss of
cache-speed, which was sort of nice to have.
2018-08-31 12:55:22 +02:00
wm4
5f83b6a5f5 rendezvous: fix a typo 2018-08-31 11:40:33 +02:00
wm4
120dcdf5cc demux: allow cache sizes > 2GB
There was no reason to limit this. Only some int fields had to be
changed to size_t.
2018-08-24 12:56:41 +02:00
wm4
9467e90c5b demux_lavf: v4l streams are not seekable
FFmpeg is retarded enough not to give us any indication whether it is
(unless we query fields not in the ABI/API). I bet FFmpeg developers
love it when library users have to litter their code with duplicated
information.
2018-08-24 12:55:10 +02:00
wm4
cdc05c33b3 player: don't print status line again when quitting
Quitting is slightly asynchronous, so the status line can be updated
again. Normally, that's fine, but if quitting comes with a message (such
as with quit_watch_later), it will print the status line again after the
message, which looks annoying. So flush and clear the status message if
it's updated during quitting.
2018-08-11 22:45:03 +02:00
wm4
bf05697653 HACK: prefetch subtitles on track switch a bit more
To get overlapping shit etc.
2018-06-30 17:55:21 +02:00
wm4
99afa8d51b player: don't cache subtitles across deselection
This means reselection triggers full reinit. This is better if you have
options that "edit" subtitles or whatever.
2018-06-30 17:15:29 +02:00
wm4
4d6d3a3455 player: fix coding style
I'm also not sure whether this condition doesn't subtly break a lot of
things.
2018-05-24 20:00:13 +02:00
wm4
8527102121 m_config: remove a redundant condition
Always true, because a few lines above it checks for the same thing.
2018-05-24 19:56:39 +02:00
wm4
982416266c demux_lavf: drop obscure genpts option
This code shouldn't even exist in libavformat. If you still need it, you
can enable it via --demuxer-lavf-o.
2018-05-24 19:56:35 +02:00
wm4
b406f679b1 vo: remove bogus #if
If anyone happened to build with GL disabled, this could lead to option
changes not always refreshing the screen. Since vo_gpu is always enabled
now (just not necessarily any backend for it), we can drop the #if
completely.

(The way this works is a bit idiotic - the option cache exists only to
grab the change notification, which will trigger a redraw and make
vo_gpu update its own second copy of them. But at least it avoids some
layering issues for now.)
2018-05-24 19:56:35 +02:00