Commit Graph

26 Commits

Author SHA1 Message Date
wm4 2a9534871d command: add property returning detected hwdec API
This is somewhat imperfect, because detection of hw decoding APIs is
mostly done on demand, and often avoided if not necessary. (For example,
we know very well that there are no hw decoders for certain codecs.)

This also requires every hwdec backend to identify itself (see hwdec.h
changes).
2015-02-02 22:43:13 +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
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 aae9af348e video: have a generic context struct for hwdec backends
Before this commit, each hw backend had their own specific struct types
for context, and some, like VDA, had none at all. Add a context struct
(mp_hwdec_ctx) that provides a somewhat generic way to pass the hwdec
context around. Some things get slightly better, some slightly more
verbose.

mp_hwdec_info is still around; it's still needed, but is reduced to its
role of handling delayed loading of the hwdec backend.
2015-01-22 15:32:23 +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 66c8a87485 vo_opengl_cb: initial screenshot support
Support for taking screenshots when doing hardware decoding needs to be
added later.

This takes the last image queued to the VO, which is logically the image
the player thinks is on screen (so e.g. subtitles will match).

forget_frames() does not clear this, because seeking does not remove the
current image from the screen (until the next one is drawn).
2015-01-15 20:10:11 +01:00
xylosper a4c0e254a3 vo_opengl_cb: make mpv_opengl_cb_render() return left frames
Instead of error code which was not helpful because it's always 0,
mpv_opengl_cb_render() returns the number of left frames in the
frame queue now.
2015-01-08 21:32:22 +01:00
xylosper e66acd52af vo_opengl_cb: use vo's drop_count instead of internal counter
This commit makes it possible to query dropped frames by opengl-cb
through vo-drop-frame-count property.
2015-01-08 21:15:24 +01:00
xylosper 5b4d587ede vo_opengl_cb: introduce frame queue
The previous implementation of opengl-cb kept only latest flipped frame.
This can cause massive frame drops because rendering is done asynchronously
and only the latest frame can be rendered.

This commit introduces frame queue and releated options to opengl-cb.

frame-queue-size: the maximum size of frame queue (1-100, default: 1)
frame-drop-mode: behavior when frame queue is full (pop, clear, default: pop)

The frame queue holds delayed frames and drops frames if the frame queue is
overflowed with next method:

'pop' mode: drops all the oldest frames overflown.
'clear' mode: drops all frames in queue and clear it.

With default options(frame-queue-size=1:frame-drop-mode=pop),
opengl-cb behaves in the same way as previous implementation effectively.

For frame-queue-size > 1, opengl-cb tries to calls update() without waiting
next flip_page() in order to consume queued frames.

Signed-off-by: wm4 <wm4@nowhere>
2015-01-08 18:50:25 +01:00
wm4 88c6f18209 vo_opengl_cb: fix a typo 2015-01-08 16:54:15 +01:00
wm4 41f6c15df5 vo_opengl_cb: allow changing debug option at runtime
This was always supposed to work.

Just add the option declaration. Normally I'm not a fan of duplicating
such things, but in this case it's (still) harmless.
2015-01-08 13:36:09 +01:00
wm4 f52ec079b2 vo_opengl_cb: fix flipped rendering
Oops.
2015-01-08 02:19:12 +01:00
wm4 b5529707f5 vo_opengl_cb: implement equalizer controls
This makes vo_opengl_cb respond to controls like "gamma" and
"brightness". The commit includes an awkward refactor for vo_opengl to
make it easier for vo_opengl_cb.

One problem is a logical race condition. The set of supported controls
depends on the pixelformat, which in turn is set by reconfig(). But the
actual reconfig() call (on the renderer) happens asynchronously on the
renderer thread. At the time it happens, the player most likely already
tried to set some controls for command line options (see init_vo() in
video.c). So setting this command line options will fail most of the
time, though it could randomly succeed. This can't be fixed directly,
because the player can't wait on the renderer thread, because the
renderer thread might already wait on the player.
2015-01-06 17:34:29 +01:00
wm4 31e9630788 vo_opengl_cb: don't resize when redrawing 2015-01-06 11:32:08 +01:00
wm4 df595b06e6 vo_opengl_cb: support changing options at runtime
Like vo_opengl, but way messier, because the already messy config
handling meets threading.
2015-01-05 15:25:58 +01:00
wm4 a850bf786e vo_opengl_cb: simplify API uninitialization
Until now, calling mpv_opengl_cb_uninit_gl() at a "bad moment" could
make the whole thing to explode. The API user was asked to avoid such
situations by calling it only in "good moments". But this was probably a
bit too subtle and could easily be overlooked.

Integrate the approach the qml example uses directly into the
implementation. If the OpenGL context is to be unitialized, forcefully
disable video, and block until this is done.
2014-12-31 20:31:19 +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 a8ffa0d0eb vo_opengl: make use of newer OpenGL logging API
GL_ARB_debug_output provides a logging callback, which can be used to
diagnose problems etc. in case the driver supports it. It's enabled only
if the vo_opengl "debug" suboption is set.
2014-12-23 02:46:44 +01:00
wm4 c912288e57 vo_opengl_cb: parse renderer parameters
Now it accepts the same renderer arguments as vo_opengl. This also
disables debug checks by default, and reverts the background color
override. Both can now be controlled by the host application.
2014-12-22 12:51:23 +01:00
wm4 2b9a7c4b5b vo_opengl, vo_opengl_cb: check GL version in renderer
vo_opengl actually checks this in the context creation code already, but
it still increases robustness in case the requirements are changed
later.
2014-12-22 12:49:20 +01:00
wm4 16a5971d28 vo_opengl_cb: free context on exit
Minor memory leak.

Actually, this also exposes some problems in the QtQuick example. This
will have to be fixed in the example.
2014-12-22 12:45:43 +01:00
wm4 0e8fbdbdb1 vo_opengl: remove requirement for RG textures
Features not supported are disabled (although with a misleading error
message).
2014-12-16 18:55:20 +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 273565c525 vo_opengl_cb: simplify reconfigure, render transparent if unconfigured
I think that's expected; mpv shouldn't draw anything while no video is
active. This doesn't blend transparently, though.

Also document the vo_opengl_cb thing.
2014-12-09 21:55:27 +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