0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00
Commit Graph

1743 Commits

Author SHA1 Message Date
wm4
751830da32 vo: handle very long frame durations with smoothmotion enabled
With mf://, rather long frame durations are common. By default, one
frame takes 1 second. This causes the if branch changed with this commit
to always being taken, which in turn leads to the player not being woken
up correctly. (As a consequence, it "freezes" by waiting for events that
never come, and moving the mouse cursor over the window will wake it up
again and advance video.)

Obviously, the code should account for how long the video frame takes.
The code is probably still not fully correct, but for now this fixes the
issue at hand.

Fixes #1521.
2015-01-26 12:06:45 +01:00
wm4
4a06a66501 vo_opengl: drop sRGB framebuffer detection
We've stopped using them some time ago (we're doing things manually
instead).
2015-01-26 06:12:35 +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
df3e6b549c vo_opengl, x11: implement icc-profile-auto
This queries the _ICC_PROFILE property on the root window. It also tries
to reload the ICC when it changes, or if the mpv window changes the
monitor. (If multiple monitors are covered, mpv will randomly select one
of them.)

The official spec is a dead link on freedesktop.org, so don't blame me
for any bugs.

Note that this assumes that Xinerama screen numbers match the way mpv
enumerates the xrandr monitors. Although there is some chance that this
matches, it most likely doesn't, and we actually have to do complicated
things to map the screen numbers. If it turns out that this is required,
I will fix it as soon as someone with a suitable setup for testing the
fix reports it.
2015-01-26 02:18:47 +01:00
wm4
73d5e396fe vo_opengl: minor changes to ICC update code
Merge update_icc_profile() into get_and_update_icc_profile() - there's
no reason anymore to keep them separate. The former is only called by
the latter, and the separation of responsibilities between them is
blurry a best.

Query the ICC profile only if the corresponding feature is actually
enabled. Additionally, change the error behavior of this code. Make
loading failure non-fatal, and distinguish between runtime error and
unimplemented functionality.

Fix a memory leak in gl_lcms.c (although the changes in vo_opengl.c
already take care of this, it's just logical and cleaner).
2015-01-26 02:11:14 +01:00
wm4
9fc15e5e1c vo_opengl: update a comment
We don't use the hwdec-provided video texture for screenshots anymore.
2015-01-26 02:06:18 +01:00
wm4
dc1793048f vo_opengl: make "mitchell" the hq default filter for downscaling
Seems like several people agree that it's a good filter for downscaling.

Setting this option by default may also prevent people from accidentally
using an unsuitable filter for downscaling by setting "scale" and
without being aware of the impliciations (maybe). On the other hand,
this change is not strictly backwards compatible for the same reasons.

Also, allow disabling this option with scale-down="" (before this, not
setting it was the only way to do this - not possible anymore if it's
set by default). This is what the change in handle_scaler_opt() does.
2015-01-26 02:03:44 +01:00
wm4
639e2bd12f vo_opengl: simplify radius initialization
Somehow, the default radius for filters with variable radius was set in
mp_init_filter(). gl_video.c used NAN as default value for the radius,
which would make the filter use the default radius. Simplify this, and
set the default radius directly in the gl_video options. It also makes
the options easier to understand, because the default value listed in
--vo=opengl:help actually shows the default value.

Remove the function can_use_filter_kernel(), because it doesn't set a
radius if none is set. The function is worthless anyway (something about
making filter_kernels.c reusable to other VOs, and trying to deal with
the possibility that it could provide filters not supported by
vo_opengl.)
2015-01-26 01:56:19 +01:00
wm4
6945369e9c vo_opengl: fancy-downscale affects luma-scaler only 2015-01-25 01:35:17 +01:00
wm4
99c856d3cd vo: fix redraw logic
It actually can and does happen that you want to redraw, even if no
image was queued yet.

Broken by commit 28582322.
Fixes #1510.
2015-01-25 00:52:44 +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
Stefano Pigozzi
13e35730b4 cocoa: fix fallback for OpenGL 2.1 hardware [2]
Looks like it fails on context creation, not pixfmt creation.
2015-01-24 16:54:24 +01:00
Stefano Pigozzi
3dc3bcf8b6 cocoa: fix fallback for OpenGL 2.1 hardware
This was previously done in common code but now it's left to backends. Also
remove the GL4 stuff since requesting a 3_2_Core context creates a 4.1 context
here (wtf).
2015-01-24 16:31:38 +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
wm4
e5bceb061b vf_vavpp: add more deinterlacing algorithms
These are untested due to lack of hardware. From what I've heard, the
drivers are pretty buggy, so it's not clear how well this works, if at
all.
2015-01-23 13:26:41 +01:00
wm4
60dbf192d1 x11: remove unnecessary code 2015-01-23 12:46:36 +01:00
wm4
a96c3ac90e vo: allow dropping additional frames with smoothmotion
The logic disabled framedropping if the frame was interpolated (i.e. the
render call is only done to interpolate between the previous frame, and
the frame before that).

It seems doing this wasn't even necessary, and broke framedrop in
smoothmotion mode. In fact, this code did nothing for display with video
fps below display fps. It did prevent the framedrop counter from going
up, though. So change it so that dropped interpolated frames are never
reported. (Doing so can give confusing results, such as dropping 1000s
of frames on slow operations like video start or changing filters.)
2015-01-23 12:21:45 +01:00
wm4
55cdc734c5 vo: cosmetics 2015-01-23 12:21:45 +01:00
wm4
9c45cdd55e vo: fix framedrop in normal case
vsync_timed is true if smoothmotion is used. That would mean framedrop
is always disabled in the normal case.
2015-01-23 11:21:27 +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
2575c01c77 filter_kernels: improve a comment
It's not true anymore that the size necessarily depends on the radius.
2015-01-22 20:08:47 +01:00
wm4
93f1bf48d9 vo_opengl: improve terminal messages with lscale suboption errors
Make it more apparent what the hell the user did wrong.
2015-01-22 19:58:22 +01:00
Niklas Haas
27261bea31
vo_opengl: remove scale-sep and indirect options
These are now auto-detected sanely; and enabled whenever it would be a
performance or quality gain (which is pretty much everything except
bilinear/bilinear scaling).

Perhaps notably, with the absence of scale_sep, there's no more way to
use convolution filters on hardware without FBOs, but I don't think
there's hardware in existence that doesn't have FBOs but is still fast
enough to run the fallback (slow) 2D convolution filters, so I don't
think it's a net loss.
2015-01-22 19:40:06 +01:00
Niklas Haas
1ec77214b1 filter_kernels: get rid of sinc/lanczos aliases
Just set the radius with scale-radius if it's really needed
2015-01-22 19:40:04 +01:00
Niklas Haas
8eb9ddd868 vo_opengl: rename all scale options to make more sense
This emphasizes the fact that scale is used for *all* image upscaling,
with cscale only serving a minor role for subsampled material.
2015-01-22 19:40:04 +01:00
Niklas Haas
02df9886ea vo_opengl: switch to nearest neighbour for trivial resampling
This is significantly faster for FBOs on most modern GPUs, although it
did not result in a huge difference for the video source texture on the
sizes I tested. It might be more significant for 1080p or 4K content, so
it's worth revisiting this in the future.

It also renames SAMPLE_BILINEAR to SAMPLE_TRIVIAL to match the
semantics.
2015-01-22 19:40:04 +01:00
Niklas Haas
f24c2e0f56 vo_opengl: always prefer indirect scaling
This is better even for non-separable. The only exception is when using
bilinear for both lscale and cscale. I've fixed the
documentation/comments to make more sense.
2015-01-22 19:40:04 +01:00
Niklas Haas
2d182fdea0
vo_opengl: implement naive anti-ringing
This is not quite the same thing as madVR's antiringing algorithm, but
it essentially does something similar.

Porting madVR's approach to elliptic coordinates will take some amount
of thought.
2015-01-22 19:39:58 +01:00
Niklas Haas
6c250505fe vo_opengl: unroll ewa_lanczos to avoid looping and unnecessary samples
This speeds up performance by a factor of something like 10%,
since it omits unnecessary checks.

This will also make adding anti-ringing easier.
2015-01-22 19:29:23 +01:00
Niklas Haas
f5e48f0235 vo_opengl: clean up ewa_lanczos code
This fixes compatibility with GLES 2.0 and makes the code a bit neater
in general. It also properly forces indirect scaling for subsampled
video regardless of the lscale setting.
2015-01-22 19:29:23 +01:00
wm4
571fe8f729 vo_opengl: guarantee correct reinitialization on setting options
At least the scale_sep_fbo could have been uninitialized or initialized
incorrectly when switching between scalers (e.g. from bilinear to
lanczos). Calling check_resize() should take care of this.
2015-01-22 19:25:16 +01:00
wm4
a8f565008b vo_opengl: don't reset unused GL_PACK_... state 2015-01-22 18:54:05 +01:00
wm4
5bb24980ae vo_opengl: simplify screenshot code
Instead of reading back the image from textures, keep a reference to the
original image, and return that.

The main reason this was done this way was that originally, images
weren't refcounted, and would be deallocated or overwritten as soon as
the VO's draw call returned. But now there isn't really a good reason
for this anymore. One possibly _could_ argue that it was better because
other code could reuse the image sooner (e.g. for the cache), but on the
other hand, the VO runs already on a different thread, and filtering and
decoding each run on other threads too, so this argument probably
wouldn't hold up.
2015-01-22 18:31:10 +01:00
wm4
16cc429eb8 vo_vdpau: don't render to an output surface if it could be busy
There was a case when we could have rendered to an output surface while
it's still used for display. Not sure why the API doesn't do this
automatically.
2015-01-22 18:18:23 +01:00
wm4
74581a6106 video: handle hwdec screenshots differently
Instead of converting the hw surface to an image in the VO, provide a
generic way to convet hw surfaces, and use this in the screenshot code.

It's all relatively straightforward, except vdpau is being terrible. It
needs a huge chunk of new code, because copying back is not simple.
2015-01-22 18:18:23 +01:00
wm4
e9ac3fc3a1 mp_image_pool: allow passing pool=NULL in more places
It's convenient.
2015-01-22 17:37:40 +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
Stefano Pigozzi
29cf62d201 cocoa: remove support for systems without gl3.h header 2015-01-22 08:27:03 +01:00
Niklas Haas
edc100eee0
vo_opengl: make the default radius 3.0 and simplify scaler documentation
This also fixes the maximum range to 16.0, which was previously set to
32.0 and incorrectly documented as 8.0. 16 taps should be more than
anybody will ever need, but it's the highest radius that's supported by
all affected filters.
2015-01-21 23:08:41 +01:00
wm4
b2149f7fe1 vaapi: minor simplification 2015-01-21 22:12:30 +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
2a691d1ede video: try to keep implied alpha when using conversion filters
Don't just discard alpha. This probably does the right thing, in the
rare situations when alpha matters at all.
2015-01-21 21:49:15 +01:00
wm4
3f49c60762 vo_direct3d: unify d3d "reset" and uninit paths
I'm still not sure how exactly handling of "lost" devices is supposed
to be handled. In theory, you only have to "reset" the device, instead
of recreating _everything_. But as it is, the code for proper uninit
and for handling the reset is exactly the same, so move it into a
function to reduce code duplication and the danger of potential bugs.
2015-01-21 21:12:18 +01:00
wm4
39231e5dfd vo_direct3d: disable shaders if unavailable
Apparently, extremely crappy graphics drivers don't allow you to use
shaders. Simply disable use of shaders if this happens, and use the
"old" method instead.

One unexpectedly tricky thing is that you need a d3d_device to create
a shader, which in turn requires a window, so the initialization order
changes.
2015-01-21 21:06:56 +01:00
wm4
e34957940b vo_opengl: cleanups after vo_opengl_old removal
Don't load all the legacy functions (including ancient extensions).
Slightly simplify function loader and context creation, now that legacy
GL doesn't need to be handled. Remove the code for drawing OSD in legacy
mode.

Remove all the header hacks, which were meant for ancient OpenGL headers
which didn't even support things like OpenGL 1.3. Instead, adjust the
GLX check to make sure we get both OpenGL 3x and 2.1 symbols. For win32
and OSX, we assume that the user has the latest headers anyway. For
wayland, we hope that things somehow go right.
2015-01-21 20:32:42 +01:00
wm4
c15697477f vo: never autoselect vo_null
Same deal as with commit d44b4ccb.
2015-01-21 19:39:58 +01:00
wm4
a0caadd512 vo_opengl: handle grayscale input better, add YA16 support
Simply clamp off the U/V components in the colormatrix, instead of doing
something special in the shader.

Also, since YA8/YA16 gave a plane_bits value of 16/32, and a colormatrix
calculation overflowed with 32, add a component_bits field to the image
format descriptor, which for YA8/YA16 returns 8/16 (the wrong value had
no bad consequences otherwise).
2015-01-21 19:29:18 +01:00