Commit Graph

42512 Commits

Author SHA1 Message Date
wm4 d32c4c75ef player: refactor display-sync frame duration calculations
Get rid of get_past_frame_durations(), which was a bit too messy. Add
a past_frames array, which contains the same information in a more
reasonable way. This also means that we can get the exact current and
past frame durations without going through awful stuff. (The main
problem is that vo_pts_history contains future frames as well, which is
needed for frame backstepping etc., but gets in the way here.)

Also disable the automatic disabling of display-sync if the frame
duration changes, and extend the frame durations allowed for display
sync. To allow arbitrarily high durations, vo.c needs to be changed
to pause and potentially redraw OSD while showing a single frame, so
they're still limited.

In an attempt to deal with VFR, calculate the overall speed using the
average FPS. The frame scheduling itself does not use the average FPS,
but the duration of the current frame. This does not work too well,
but provides a good base for further improvements.

Where this commit actually helps a lot is dealing with rounded
timestamps, e.g. if the container framerate is wrong or unknown, or
if the muxer wrote incorrectly rounded timestamps. While the rounding
errors apparently can't be get rid of completely in the general case,
this is still much better than e.g. disabling display-sync completely
just because some frame durations go out of bounds.
2015-11-13 22:45:40 +01:00
wm4 624c9e46ce player: always require a future frame with display-sync enabled
We need a frame duration even on start, because the number of vsyncs
the frame is shown is predetermined. (vo_opengl actually makes use of
this property in certain cases.)
2015-11-13 22:42:42 +01:00
wm4 f0feea5591 command: rename vo-missed-frame-count property
"Missed" implies the frame was dropped, but what really happens is that
the following frame will be shown later than intended (due to the
current frame skipping a vsync).

(As of this commit, this property is still inactive and always
returns 0. See git blame for details.)
2015-11-13 22:41:41 +01:00
Martin Herkt def87f1e5f
win32: avoid detection as exclusive fullscreen window
Apparently Windows treats windows that use OpenGL, cover an entire
screen and have the WS_POPUP style set or are topmost windows as
exclusive fullscreen windows that bypass DWM and cannot be covered
by other windows.
This means we can’t use dwmflush in fullscreen mode, and it also
means that no other window can cover mpv, and it makes the screen
flicker when switching to fullscreen mode.

This can be avoided by not setting the WS_POPUP flag.
Users can still access the old behavior by enabling stay-on-top
(which IMO at least makes sense—now we just need to get dwmflush
autodetection right to avoid nasty surprises).

fixes #2177
2015-11-13 12:41:59 +01:00
wm4 b726fefe5d vo_opengl_cb: do not block on flipping when redrawing
Gives slightly better behavior when used with Qt. (Which tends not to
flip buffers when the window is not visible.)
2015-11-12 22:44:05 +01:00
wm4 49a41bf4df build: make vaapi-wayland depend on gl-wayland
Wayland without GL isn't enough. Specifically, we need to make sure the
EGL libs are included. (That's one tricky dependency tree.)

Fixes #2476.
2015-11-12 11:38:03 +01:00
wm4 384b13c5fd demux_libass: remove this demuxer
This loaded external .ass files via libass. libavformat's .ass reader is
now good enough, so use that instead.

Apparently libavformat still doesn't support fonts embedded into text
.ass files, but support for this has been accidentally broken in mpv for
a while anyway. (And only 1 person complained.)
2015-11-11 21:28:20 +01:00
wm4 977869a804 demux_lavf: mark ASS tracks as always UTF-8
Stops mpv from trying to run a subtitle charset detector on .ass files
loaded by libavformat.
2015-11-11 21:25:08 +01:00
wm4 7c4fe02d01 player: less naive rounding 2015-11-11 19:52:35 +01:00
rr- b7398cbdd8 drm: fix setting up connectors
Fixes regression from 67caea357c.
2015-11-11 19:40:13 +01:00
wm4 9774be0d15 af_lavrresample: simplify set_compensation usage
Just set the ratio directly by working around the intended semantics of
the API function. The silly rounding stuff we had isn't needed anymore
(and not entirely correct anyway).

Note that since the compensation is virtually active forever, we need to
reset if it's not needed. So always run this code to be sure to reset
it.

Also note that libswresample itself had a precision issue, until it
was fixed in FFmpeg commit 351e625d.
2015-11-11 19:28:37 +01:00
wm4 fee45c0170 player: silence sporadic error messages on audio init
When the audio format is not known yet and the audio chain is still
initializing, filter reinit will fail. Normally, attempts to
reinitialize filters at this stage should be rare (e.g. user commands
editing the filter chain). But it sometimes happened with track
switching in combination with the video code calling
update_playback_speed() at arbitrary times.

Get rid of the message by not trying to change the filters for the sake
of playback speed update while decoding is still being initialized.
2015-11-10 17:53:05 +01:00
wm4 9a6ec9de2f vd_lavc: be more careful with flushing the decoder
Until now, we've relied on the following things:

- you can send flush packets to the decoder even if it's fully flushed,
- you can send new packets to a flushed decoder,
- you can send new packers to a partially flushed decoder.

("flushing" refers to sending flush packets to the decoder until the
decoder does not return new pictures, not avcodec_flush_buffers().)

All of these are questionable. The libavcodec API probably doesn't
guarantee that these work well or at all, even though most decoders have
no issue with these. But especially with hardware decoding wrappers
(like MMAL), real problems can be expected. Isolate us from these corner
cases by handling them explicitly.
2015-11-10 16:06:42 +01:00
wm4 4682b0147e vo_opengl: move the glFlush() call to the renderer 2015-11-10 14:36:23 +01:00
wm4 479eb93d9e vo_opengl_cb: better underflow reporting
This applies to unexpected freezes or deadlocks, not e.g. normal
framedrops. The verbose messages also might remind an API user if the
API usage is incorrect, such as not calling mpv_opengl_cb_draw() when a
redraw request was issued.
2015-11-10 14:35:13 +01:00
wm4 9d9f863f55 vo_opengl: limit GLSL to version 3.3
Fixes custom shaders, which define their entrypoint as sample()
function.
2015-11-10 11:51:11 +01:00
Kevin Mitchell dd0c85679b stream_libarchive: make libarchive seek callback lazy
This fixes problems seeking http streams to their end.
2015-11-09 22:41:19 -08:00
Kevin Mitchell 4efadb2808 stream_libarchive: add multivolume support
This commit introduces logic to read other volumes from the same source
as the primary archive. Both .rar formats as well as 7z are supported for now.

It also changes the libarchive callback structure to be per-volume
consistent with the libarchive intenal client data array constructed
with archive_read_append_callback_data.

Added open, close and switch callbacks. Only the latter is strictly
required to make sure that the streams always start at position 0, but
leaving all volumes open can eat a lot of memory for archives with many
parts.
2015-11-09 22:41:19 -08:00
Kevin Mitchell cf5b117553 libarchive: remove redundant log prefix
"libarchive:" is already added by the logging system
2015-11-09 22:41:19 -08:00
Kevin Mitchell 434512827f external_files: deduplicate bstr functions 2015-11-09 22:41:19 -08:00
Bin Jin 03bbaad686 vo_opengl: fix 10-bit video prescaling
The nnedi3 prescaler requires a normalized range to work properly,
but the original implementation did the range normalization after
the first step of the first pass. This could lead to severe quality
degradation when debanding is not enabled for NNEDI3.

Fix this issue by passing `tex_mul` into the shader code.

Fixes #2464
2015-11-09 22:48:40 +01:00
wm4 3dc0f2ecf0 vo_opengl_cb: make operation more similar to normal VOs
vo_opengl_cb is a special case, because we somehow have to render video
asynchronously, all while "trusting" the API user to do it correctly.
This didn't quite work, and a while ago a compromise using a timeout to
prevent theoretically possible deadlocks was added.

Make it even more synchronous. Basically, go all the way, and
synchronize rendering between VO and user renderer thread to the
full extent possible.

This means the silly frame queue is dropped, and we event attempt to
synchronize the GL SwapBuffer call (via mpv_opengl_cb_report_flip()).

The changes introduced with commit dc33eb56 are effectively dropped. I
don't even remember if they mattered.

In the future, we might make all VOs fetch asynchronously from a frame
queue, which would mostly remove the differences between vo_opengl and
vo_opengl_cb, but this will take a while (if it will even be done).
2015-11-09 20:51:57 +01:00
wm4 eeb5f98758 vo_opengl: handle GL_ARB_uniform_buffer_object with low GLSL versions
Why is this stupid crap being so much a pain for no reason.
2015-11-09 16:24:01 +01:00
wm4 caa497ee8a vo_opengl: fix extension name 2015-11-09 14:29:58 +01:00
wm4 930f841589 vo_opengl: simplify GLSL version detection
Pick the correct GLSL version from the GL_SHADING_LANGUAGE_VERSION
string. Might be somewhat questionable, as we expect the minor version
number not to have leading 0s.

Should help with cases when the reported GLSL version is much higher
than the equivalent of the reported GL version. This problem was
observed in combination with GL_ARB_uniform_buffer_object, which
can't be used if the declared GLSL version is too low.
2015-11-09 14:29:09 +01:00
wm4 8baf773d0e command: make display-fps property writable
Has the same function as setting the option.

This commit changes the property in a bunch of other ways. For example
if the VO is not created, it will return the option value.
2015-11-09 13:59:25 +01:00
wm4 11888a9270 vo_opengl: never load vaapi GLX interop by default
Causes more harm than it helps. Will eventually be removed.

Also rename the "reject_emulated" field to "probing" - this is more
appropriate now.
2015-11-09 11:58:38 +01:00
wm4 76e50f6a3d vo_opengl: always preload hwdec interop
Simplifies some auto detection matters.

I _still_ don't want to remove the lazy loading mechanism, because it's
still slightly useful for filters using the hwdec APIs. My main
motivation for not always preloading them is actually that libva prints
random useless crap to the terminal with no way to prevent this.
2015-11-09 11:57:11 +01:00
wm4 7d5282ea5d vo_opengl: rename "drm_egl" to "drm-egl" 2015-11-09 11:21:28 +01:00
rr- f757163058 vo_opengl: disable drm_egl autopickup 2015-11-09 11:19:56 +01:00
wm4 ac64ce71d6 dec_audio: add missing include
Was masked by FFmpeg's terrible headers, but failed with Libav.
2015-11-08 20:01:20 +01:00
wm4 16cd20c46f win32: request MMCSS "Playback" profile 2015-11-08 19:33:38 +01:00
wm4 8f7b12d9ae manpage: remove examples and authors section
The examples demonstrates use with optical media, which is far from
mpv's main purpose.

The authors section is a leftover from MPlayer times. There are enough
other places which reiterate how mpv is based on mplayer2/MPlayer,
copyright statements, and so on.
2015-11-08 19:02:18 +01:00
wm4 66f8e45311 manpage: slightly improve configuration files section
Hint that the linked section contains information for Windows. (Well,
that's a lie, but it has a link to the Windows section.)

Avoid implying that lines in the config file end with ';'. Also, the <>
are probably just confusing.
2015-11-08 18:09:00 +01:00
wm4 0ff3ffb2be audio: interpolate audio timestamps
Deal with jittering Matroska crap timestamps. This reuses the mechanism
that is needed for frames without PTS, and adds a heuristic to it. If
the interpolated timestamp is less than 1ms away from the real one, it
might be due to Matroska timestamp rounding (or other file formats with
such rounding, or files remuxed from Matroska).

While there actually isn't much of a need to do this (audio PTS
jittering by such a low amount doesn't negatively influence much), it
helps with identifying jitter from other sources.
2015-11-08 18:06:24 +01:00
wm4 d91434756b audio: move PTS setting out of the decoder
Instead of requiring the decoder to set the PTS directly on the
dec_audio context (including handling absence of PTS etc.), transfer the
packet PTS to the decoded audio frame. Marginally simpler, and gives
more control to the generic code.
2015-11-08 17:22:56 +01:00
rr- 03013e0fd7 vo_drm: relicense to LGPL
Also removed authorship information (as per convention seen in other
files)
2015-11-08 15:00:15 +01:00
rr- 62f261a7b8 vo_drm: use bool rather than integer return values
Since the errors weren't used for anything other than simple
success/fail checks, I simplified things a bit.
2015-11-08 15:00:15 +01:00
rr- c3f2ef5491 vo_opengl: add DRM EGL backend
Notes:

- Unfortunately the only way to talk to EGL from within DRM I could find
  involves linking with GBM (generic buffer management for Mesa.)
  Because of this, I'm pretty sure it won't work with proprietary NVidia
  drivers, but then again, last time I checked NVidia didn't offer
  proper screen resolution for VT.

- VT switching doesn't seem to work at all. It's worth mentioning that
  using vo_drm before introduction of VT switcher had an anomaly where
  user could switch to another VT and input text to it, while video
  played on top of that VT. However, that isn't the case with drm_egl:
  I can't switch to other VT during playback like this. This makes me
  think that it's either a limitation coming from my firmware or from
  EGL/KMS itself rather than a bug with my code. Nonetheless, I still
  left (untestable) VT switching code in place, in case it's useful to
  someone else.

- The mode_id, connector_id and device_path should be configurable for
  power users and people who wish to watch videos on nonprimary screen.
  Unfortunately I didn't see anything that would allow OpenGL backends
  to register their own set of options. At the same time, adding them to
  global namespace is pointless.

- A few dozens of lines could be shared with vo_drm (setting up VT
  switching, most of code behind page flipping). I don't have any strong
  opinion on this.

- Sometimes I get minor visual glitches. I'm not sure if there's a race
  condition of some sort, unitialized variable (doubtful), or if it's
  buggy driver. (I'm using integrated Intel HD Graphics 4400 with Mesa)

- .config and .control are very minimal.

Signed-off-by: wm4 <wm4@nowhere>
2015-11-08 15:00:15 +01:00
rr- 67caea357c vo_drm: move initialization to drm_common
Makes KMS initialization procedures reusable so that they can be used by
the upcoming DRM EGL adapter.
2015-11-08 14:58:34 +01:00
rr- b1893d2084 vo_opengl: fix typo 2015-11-07 19:46:51 +01:00
wm4 46cee66563 vo_opengl: rename fancy-downscaling to correct-downscaling
The old name was stupid. Very stupid.
2015-11-07 17:49:14 +01:00
Avi Halachmi (:avih) 0062c98dff vo_opengl: fancy-downscaling: enable also for anamorphic clips 2015-11-07 17:44:50 +01:00
wm4 6bbb1e4cf9 x11: print Xlib errors in verbose mode if Xlib messages are silenced
Follow up to commit b984ec52.
2015-11-07 17:43:10 +01:00
wm4 1356755ad4 demux_mkv: remove --demuxer-mkv-fix-timestamps
While it seemed like a pretty good idea at first, it's just a dead end
and works only in the simplest cases. While it may or may not help
slightly with audio sync mode, the display-sync mode already compensates
this in a better way. The main issue is that timestamps at this layer
are not in order, so it can look at single timestamps only.
2015-11-07 17:37:32 +01:00
wm4 2dc18a2f82 chmap: remove MPlayer layouts
Unused; last uses removed with the previous two commits.
2015-11-07 15:22:30 +01:00
wm4 a7f51f8fd4 ao_jack: remove "alsa" std-channel-layout choice
Same deal as with previous commit. "waveext" is less arbitrary and at
least supports 3/7 channels.
2015-11-07 15:20:34 +01:00
wm4 5a7c22a1ac ao_alsa: remove the last bits of legacy channel map fallback
Essentially we'd use something random, just because it's part of the srt
of traditionally used ALSA channel mappings. But each driver can do its
own things.

This doesn't let me sleep at night, so remove it.
2015-11-07 15:18:05 +01:00
wm4 617aff6cda audio: fix af_fmt_change_bytes() with spdif formats
This could accidentally change some spdif formats to AAC (because AAC is
the first on the list and will match first). spdif formats are
inherently uninterchangeable, so treat them as their own class of
formats (like int vs. float).

Might fix some issues with ao_wasapi.c.
2015-11-07 15:07:50 +01:00
wm4 b984ec52aa vo_opengl: x11: silence error messages when using legacy GL context
glXCreateContextAttribsARB() by design can throw some X11 errors. We
ignore these, but we generally still print error messages to the
terminal. This was confusing/annoying users, so silence it. The stupid
part is that the Xlib error handler is global, so we have to be slightly
careful here.
2015-11-06 21:20:23 +01:00