Commit Graph

149 Commits

Author SHA1 Message Date
Niklas Haas 393a069112 vo_opengl: expose performance timers as properties
This is plumbed through a new VOCTRL, VOCTRL_PERFORMANCE_DATA, and
exposed as properties render-time-last, render-time-avg etc.

All of these numbers are in microseconds, which gives a good precision
range when just outputting them via show-text. (Lua scripts can
obviously still do their own formatting etc.)

Signed-off-by: wm4 <wm4@nowhere>
2016-06-07 12:17:25 +02:00
wm4 c1cb04b6a3 vo_opengl: apply vo-cmdline command incrementally
Instead of implicitly resetting the options to defaults and then
applying the options, they're always applied on top of the current
options (in the same way adding new options to the CLI command line
will).

This does not apply to vo_opengl_cb, because that has an even worse mess
which I refuse to deal with.
2016-06-05 16:56:34 +02:00
wm4 46fff8d31a video: refactor how VO exports hwdec device handles
The main change is with video/hwdec.h. mp_hwdec_info is made opaque (and
renamed to mp_hwdec_devices). Its accessors are mainly thread-safe (or
documented where not), which makes the whole thing saner and cleaner. In
particular, thread-safety rules become less subtle and more obvious.

The new internal API makes it easier to support multiple OpenGL interop
backends. (Although this is not done yet, and it's not clear whether it
ever will.)

This also removes all the API-specific fields from mp_hwdec_ctx and
replaces them with a "ctx" field. For d3d in particular, we drop the
mp_d3d_ctx struct completely, and pass the interfaces directly.

Remove the emulation checks from vaapi.c and vdpau.c; they are
pointless, and the checks that matter are done on the VO layer.

The d3d hardware decoders might slightly change behavior: dxva2-copy
will not use the VO device anymore if the VO supports proper interop.
This pretty much assumes that any in such cases the VO will not use any
form of exclusive mode, which makes using the VO device in copy mode
unnecessary.

This is a big refactor. Some things may be untested and could be broken.
2016-05-09 20:03:22 +02:00
maniak1349 7d9eab15f0 win32: make taskbar progress indication optional
Add --taskbar-progress command line option and property which controls taskbar
progress indication rendering in Windows 7+. This option is on by default and
can be toggled during playback.

This option does not affect the creation process of ITaskbarList3. When the
option is turned off the progress bar is just hidden with TBPF_NOPROGRESS.

Closes #2535
2016-05-08 17:05:20 +02:00
wm4 9db50c6760 vo: get rid of vo_get_window_title()
It always was a weird artifact - VOCTRLs are meant _not_ to require
special handling in the code that passes them through (like in vo.c).
Removing it is also interesting to further reduce the dependency of
backends on struct vo. Just get rid of it.

Removing it is somewhat inconvenient, because in many situations the UI
window is created after the first VOCTRL_UPDATE_WINDOW_TITLE. This means
these backends have to store it in a new field in their own context.
2015-12-06 18:41:31 +01:00
wm4 318e9801f2 vo_opengl: fix interpolation with display-sync
At least I hope so.

Deriving the duration from the pts was not really correct. It doesn't
include speed adjustments, and becomes completely wrong of the user e.g.
changes the playback speed by a huge amount. Pass through the accurate
duration value by adding a new vo_frame field.

The value for vsync_offset was not correct either. We don't need the
error for the next frame, but the error for the current one. This wasn't
noticed because it makes no difference in symmetric cases, like 24 fps
on 60 Hz.

I'm still not entirely confident in the correctness of this, but it sure
is an improvement.

Also, remove the MP_STATS() calls - they're not really useful to debug
anything anymore.
2015-11-28 15:45:49 +01:00
wm4 7023c383b2 vo: change vo_frame field units
This was just converting back and forth between int64_t/microseconds and
double/seconds. Remove this stupidity. The pts/duration fields are still
in microseconds, but they have no meaning in the display-sync case (also
drop printing the pts field from opengl/video.c - it's always 0).
2015-11-27 22:04:44 +01:00
wm4 1fe64c61be vo_opengl: disable interpolation without display-sync
Without display-sync mode, our guesses wrt. vsync phase etc. are much
worse, and I see no reason to keep the complicated "vsync_timed" code.
2015-11-25 22:10:55 +01:00
wm4 772961f0ce command, vo: add estimated-display-fps property
This is simply the average refresh rate. Including "bad" samples is
actually an advantage, because the property exists only for
informational purposes, and will reflect problems such as the driver
skipping a vsync.

Also export the standard deviation of the vsync frame duration
(normalized to the range 0-1) as vsync-jitter property.
2015-11-25 22:07:56 +01:00
wm4 2e401201ad vo: remove VOCTRL_GET_RECENT_FLIP_TIME
It doesn't have any real purpose anymore. Up until now, it was still
implemented by vo_wayland, but since we changed how the frame callbacks
work, even that appears to be pointless.

Originally, the plan was to somehow extend this mechanism to all
backends and to magically fix frame scheduling, but since we can't hope
for proper mechanisms even on wayland, this idea looks way less
interesting.
2015-11-23 16:54:53 +01:00
James Ross-Gowan 718807b78b win32: don't show progress indicator in idle mode 2015-11-23 19:50:13 +11:00
Martin Herkt bf0b178e71
win32: support taskbar button progress indicator
This adds support for the progress indicator taskbar extension
that was introduced with Windows 7 and Windows Server 2008 R2.

I don’t like this solution because it keeps its own state and
introduces another VOCTRL, but I couldn’t come up with anything
less messy.

closes #2399
2015-11-15 23:18:24 +01:00
wm4 a790009a63 player: account for minor VO underruns
If the player sends a frame with duration==0 to the VO, it can trivially
underrun. Don't panic, but keep the correct time.

Also, returning the absolute time from vo_get_next_frame_start_time()
just to turn it into a float with relative time was silly. Rename it and
make it return what the caller needs.
2015-11-14 21:49:48 +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
wm4 e6a395c297 vo_opengl, vo_opengl_cb: drop unneeded vo_frame fields
next_vsync/prev_vsync was only used to retrieve the vsync duration. We
can get this in a simpler way.

This also removes the vsync duration estimation from vo_opengl_cb.c,
which is probably worthless anyway. (And once interpolation is made
display-sync only, this won't matter at all.)
2015-11-04 21:49:54 +01:00
wm4 291f301c10 video/out: remove an unused parameter
This parameter has been unused for years (the last flag was removed in
commit d658b115). Get rid of it.

This affects the general VO API, as well as the vo_opengl backend API,
so it touches a lot of files.

The VOFLAGs are still used to control OpenGL context creation, so move
them to the OpenGL backend code.
2015-10-03 18:20:16 +02:00
wm4 e448e10fd7 vo: change some defines to enums
Why not.
2015-10-02 18:49:35 +02:00
wm4 e72ca08554 vo_opengl: drop old backend API 2015-10-02 18:49:35 +02:00
wm4 98c4ab6d13 vo_opengl: make sw suboption work without explicit backend selection
You needed to select a GL backend with the backend suboption. This was
confusing.

Fixes #2361.
2015-10-01 20:57:29 +02:00
wm4 031555fbe6 player: add display sync mode
If this mode is enabled, the player tries to strictly synchronize video
to display refresh. It will adjust playback speed to match the display,
so if you play 23.976 fps video on a 24 Hz screen, playback speed is
increased by approximately 1/1000. Audio wll be resampled to keep up
with playback.

This is different from the default sync mode, which will sync video to
audio, with the consequence that video might skip or repeat a frame once
in a while to make video keep up with audio.

This is still unpolished. There are some major problems as well; in
particular, mkv VFR files won't work well. The reason is that Matroska
is terrible and rounds timestamps to milliseconds. This makes it rather
hard to guess the framerate of a section of video that is playing. We
could probably fix this by just accepting jittery timestamps (instead
of explicitly disabling the sync code in this case), but I'm not ready
to accept such a solution yet.

Another issue is that we are extremely reliant on OS video and audio
APIs working in an expected manner, which of course is not too often
the case. Consequently, the new sync mode is a bit fragile.
2015-08-10 18:48:45 +02:00
wm4 4a1657da01 vo: minor simplification for queue size handling
Instead of calling it "future frames" and adding or subtracting 1 from
it, always call it "requested frames". This simplifies it a bit.

MPContext.next_frames had 2 added to it; this was mainly to ensure a
minimum size of 2. Drop it and assume VO_MAX_REQ_FRAMES is at least 2;
together with the other changes, this can be the exact size of the
array.
2015-07-20 21:12:46 +02:00
wm4 bb9717a630 vo: fix number of future frames
That was 2 too many.

Also fix a documentation comment.
2015-07-16 22:10:08 +02:00
wm4 0739cfc209 vo: change internal API for drawing frames
draw_image_timed is renamed to draw_frame. struct frame_timing is
renamed to vo_frame. flip_page_timed is merged into draw_frame (the
additional parameters are part of struct vo_frame). draw_frame also
deprecates VOCTRL_REDRAW_FRAME, and replaces it with a method that
works for both VOs which can cache the current frame, and VOs which
need to redraw it anyway.

This is preparation to making the interpolation and (work in progress)
display sync code saner.

Lots of other refactoring, and also some simplifications.
2015-07-01 22:38:02 +02:00
wm4 c5e3613bba video: pass vsync offset to VO
For now, this is trivial (and actually redundant). The future display
sync code will make better use of it. The main point is that the new
internal API pretty much makes this transparent to the vo_opengl
interpolation code.
2015-07-01 22:37:51 +02:00
wm4 41ad9d8924 video: pass future frames to VO
Now the VO can request a number of future frames with the last parameter
of vo_set_queue_params(). This will be helpful to fix the interpolation
code.

Note that the first frame (after playback start or seeking) will usually
not have any future frames (to make seeking fast). Near the end of the
file, the number of future frames will become lower as well.
2015-07-01 22:37:46 +02:00
wm4 10de9b091a vo_opengl: change user options for requesting GLES
Instead of having separate backends, make use of GLES a flag. This
reduces the number of backends and the resulting annoyances.

Also, nobody cares about using GLES, so there's no backward
compatibility either.
2015-05-14 00:05:39 +02:00
wm4 29eb764fe0 cocoa: make live-resizing as fast as before
Interrupt video timing. This means the Cocoa event loop does not have
to up to 2 video frame durations until redrawing the frame finally has
finished.

We abuse the VO event flags for this. Eventually this should use
wait_vo() or so in the video timing wait function, but for now the
interaction this would require with the code of other VOs/backends
would cause too much of a mess.
2015-05-12 22:42:06 +02:00
wm4 e185887ba0 video/out: remove VOFLAG_FLIPPING
I think this used to be quite important, because the ancient VfW support
in MPlayer used to output flipped frames. This code has been dead in mpv
for quite some time (because VfW decoders were removed, and the --flip
option was dropped too), so get rid of it.
2015-05-01 18:47:27 +02:00
Marcin Kurczewski f43017bfe9 Update license headers
Signed-off-by: wm4 <wm4@nowhere>
2015-04-13 12:10:01 +02:00
wm4 8f0f73e591 video/out: remove unused colorspace reporting
Rarely used and essentially useless. The only VO for which this was
implemented correctly and for which this did anything was vo_xv, but you
shouldn't use vo_xv anyway (plus it support BT.601 only, plus a vendor
specific extension for BT.709, whose presence this function essentially
reported - use xvinfo instead).
2015-03-31 00:09:03 +02:00
wm4 6de3fe0b34 command: fix display-fps property (again)
This caused complaints because the fps was basically rounded on
microsecond boundaries in the vsync interval (it seemed convenient to
store only the vsync interval). So store the fps as float too, and let
the "display-fps" property return it directly.
2015-03-13 13:14:11 +01:00
wm4 209f8225ed vo: update FPS only on state changes
I'm not comfortable with VOCTRL_GET_DISPLAY_FPS being called every
frame.

This requires the VO to set VO_EVENT_WIN_STATE if the FPS could have
changed. At least the X11 backend does this.
2015-03-12 23:35:38 +01:00
Stefano Pigozzi 89306818bb cocoa: add support for querying ambient lighting
This will be pretty useful to let mpv automatically change VO parameters based
on ambient lighting conditions.

The conversion code and polinomial equation from Apple LMU values to Lux is
taken from Firefox: their license, MPL is GPL compatible and allows
relicensing to GPL (MPL is more liberal).
2015-03-04 10:06:08 +01:00
Stefano Pigozzi 3931544ef3 vo_opengl: fix smoothmotion coefficient calculation
Using prev_pts as the start of the scale was plain wrong. Change it to
prev_vsync.
2015-02-13 20:39:53 +01:00
wm4 f47b14b717 video/out: cosmetics: rename VO_EVENT_ICC_PROFILE_PATH_CHANGED
Remove the "PATH" bit, because VOCTRL_GET_ICC_PROFILE returns an in-
memory profile, and not a path. (This was changed a while ago.)
2015-01-26 02:21:00 +01:00
wm4 32f726703d vo_opengl: remove remnants of dropped stereo buffer support 2015-01-24 23:29:54 +01:00
wm4 8657b8e1f3 vo: generic redraw support
Usually, a VO must react to VOCTRL_REDRAW_FRAME in order to redraw the
current screen correctly if video is paused (this is done to update
OSD). But if it's not supported, we can just draw the current image
again in the generic vo.c code.

Unfortunately, this turned out pretty useless, because the VOs which
would benefit from this need to redraw even if there is no image, in
order to draw a black screen in --idle --force-window mode. The way
redrawing is handled in the X11 common code and in vo_x11 and vo_xv is
in the way, and I'm not sure what exactly vo_wayland requires. Other VOs
have a non-trivial implementation of VOCTRL_REDRAW_FRAME, which
(probably) makes redrawing slightly more efficient, e.g. by skipping
texture upload. So for now, no VO uses this new functionality, but since
it's trivial, commit it anyway.

The vo_driver->untimed case is for forcibly disabling redraw for vo_lavc
and vo_image always.
2015-01-24 23:28:38 +01:00
wm4 2858232220 vo: simplify VOs by adding generic screenshot support
At the time screenshot support was added, images weren't refcounted yet,
so screenshots required specialized implementations in the VOs. But now
we can handle these things much simpler. Also see commit 5bb24980.

If there are VOs in the future which can't do this (e.g. they need to
write to the image passed to vo_driver->draw_image), this still could be
disabled on a per-VO basis etc., so we lose no potential performance
advantages.
2015-01-24 23:16:27 +01:00
wm4 5e9f791667 video: separate screenshot modes
Use different VOCTRLs for "window" and normal screenshot modes. The
normal one will probably be removed, and replaced by generic code in
vo.c, and this commit is preparation for this. (Doing it the other way
around would be slightly simpler, but I haven't decided yet about the
second one, and touching every VO is needed anyway in order to remove
the unneeded crap. E.g. has_osd has been unused for a long time.)
2015-01-23 22:08:20 +01:00
wm4 a0a40eb287 vo: fix disabling/enabling smoothmotion at runtime
vo.c queried the VO at initialization whether it wants to be updated on
every display frame, or every video frame. If the smoothmotion option
was changed at runtime, the rendering mode in vo.c wasn't updated.

Just let vo_opengl set the mode directly. Abuse the existing
vo_set_flip_queue_offset() function for this.

Also add a comment suggesting the use of --display-fps to the manpage,
which doesn't have anything to do with the rest of this commit, but is
important to make smoothmotion run well.
2015-01-23 20:56:25 +01:00
Stefano Pigozzi c29ab5a46b vo_opengl: add smoothmotion frame blending
SmoothMotion is a way to time and blend frames made popular by MadVR. It's
intended behaviour is to remove stuttering caused by mismatches between the
display refresh rate and the video fps, while preserving the video's original
artistic qualities (no soap opera effect). It's supposed to make 24fps video
playback on 60hz monitors as close as possible to a 24hz monitor.

Instead of drawing a frame once once it's pts has passed the vsync time, we
redraw at the display refresh rate, and if we detect the vsync is between two
frames we interpolated them (depending on their position relative to the vsync).
We actually interpolate as few frames as possible to avoid a blur effect as
much as possible. For example, if we were to play back a 1fps video on a 60hz
monitor, we would blend at most on 1 vsync for each frame (while the other 59
vsyncs would be rendered as is).

Frame interpolation is always done before scaling and in linear light when
possible (an ICC profile is used, or :srgb is used).
2015-01-23 09:14:41 +01:00
wm4 a1ed13869c video: remove vfcap.h
And remove all uses of the VFCAP_CSP_SUPPORTED* constants. This is
supposed to reduce conversions if many filters are used (with many
incompatible pixel formats), and also for preferring the VO's natively
supported pixel formats (as opposed to conversion).

This is worthless by now. Not only do the main VOs not use software
conversion, but also the way vf_lavfi and libavfilter work mostly break
the way the old MPlayer mechanism worked. Other important filters like
vf_vapoursynth do not support "proper" format negotation either.

Part of this was already removed with the vf_scale cleanup from today.

While I'm touching every single VO, also fix the query_format argument
(it's not a FourCC anymore).
2015-01-21 22:08:24 +01:00
wm4 eb5a83e1c1 x11: add --on-all-workspaces option and property
Fixes #1469.
2015-01-16 23:38:47 +01:00
xylosper 5bb3b1b4cf vo: add functions to increment drop_count
Add two functions which increment drop_count thread-safely.
This is for the commit followed.
2015-01-08 21:15:09 +01:00
Stefano Pigozzi f811348d0c vo_opengl: add support for in memory icc profiles
Previously we just forced loading a profile from file, but that has poor
integration for querying the OS / display server for an ICC profile, and
generating profiles on the fly (which we might use in the future for creating
preset 3dluts).

Also changed the previous icc-profile-auto code to use this mechanism, and
moved gl_lcms to be an opaque type with state instead of just providing pure
functions.
2015-01-07 18:47:27 +01:00
wm4 a7dddbacc6 video: batch query_format calls
There are currently 568 pixel formats (actually fewer, but the namespace
is this big), and for each format elaborate synchronization was done to
call it synchronously on the VO. This is completely unnecessary, and we
can do with just a single call.
2015-01-03 17:23:01 +01:00
wm4 65f2c6c716 vo_opengl_cb: pass context directly
This is simpler than setting the context after VO creation, which
requires the code to check for the context on every entrypoint.
2014-12-31 19:12:44 +01:00
wm4 282e3202d5 video: pass some VO params as struct
Not particularly elegant, but better than adding more and more stuff to
the relevant function signatures.
2014-12-31 19:01:28 +01:00
wm4 56eb2b71b8 vo: fix some nonsense
Commit d38bc531 is incorrect: the 50ms queue-ahead value and the flip
queue offset have different functions. The latter is about calling
flip_page in advance, so the change attempted to show video frames 50ms
in advance on all VOs.

The change was for vo_opengl_cb, but that can be handled differently.
2014-12-10 17:00:18 +01:00
wm4 fb855b8659 client API: expose OpenGL renderer
This adds API to libmpv that lets host applications use the mpv opengl
renderer. This is a more flexible (and possibly more portable) option to
foreign window embedding (via --wid).

This assumes that methods like context sharing and multithreaded OpenGL
rendering are infeasible, and that a way is needed to integrate it with
an application that uses a single thread to render everything.

Add an example that does this with QtQuick/qml. The example is
relatively lazy, but still shows how relatively simple the integration
is. The FBO indirection could probably be avoided, but would require
more work (and would probably lead to worse QtQuick integration, because
it would have to ignore transformations like rotation).

Because this makes mpv directly use the host application's OpenGL
context, there is no platform specific code involved in mpv, except
for hw decoding interop.

main.qml is derived from some Qt example.

The following things are still missing:
- a way to do better video timing
- expose GL renderer options, allow changing them at runtime
- support for color equalizer controls
- support for screenshots
2014-12-09 17:59:04 +01:00