Commit Graph

1940 Commits

Author SHA1 Message Date
Niklas Haas 987197be46 vo_opengl: reset surfaces on equalizer updates
This makes the VO more responsive to equalizer changes (eg. brightness)
when interpolation is used.
2015-03-26 00:04:08 +01:00
Niklas Haas dfbe1832ee vo_opengl: increase shader cache size
This is a minor precaution, because in some cases the number of shader
programs can already hit 10. (chroma merging + separated cscale/scale +
+ sub blending (interpolated) + sub blending (non-interpolated)
+ output (interpolated) + output (non-interpolated) + OSD)
2015-03-26 00:04:08 +01:00
Niklas Haas 8c43e12b20 vo_opengl: draw subtitles directly onto the video
This has a number of user-visible changes:

1. A new flag blend-subtitles (default on for opengl-hq) to control this
   behavior.

2. The OSD itself will not be color managed or affected by
   gamma controls. To get subtitle CMS/gamma, blend-subtitles must be
   used.

3. When enabled, this will make subtitles be cleanly interpolated by
   :interpolation, and also dithered etc. (just like the normal output).

Signed-off-by: wm4 <wm4@nowhere>
2015-03-26 00:04:03 +01:00
Niklas Haas a67494e86b vo_opengl: set cscale=spline36 as default for opengl-hq
Bilinear scaling is not a suitable default for something named "hq"; the
whole reason this was done in the past was because cscale used to be
obscenely slow. This is no longer the case, with cscale being nearly
free.
2015-03-25 22:40:19 +01:00
Niklas Haas 62d3c95367
vo_opengl: correct OSD PTS when using interpolation 2015-03-25 22:40:10 +01:00
wm4 72308256e4 vf_vapoursynth: handle approximate EOF draining
Handling this perfectly with VapourSynth is probably not possible: you
either need to tell it the total number of input frames in advance, or
deliver an infinite stream. With playback, EOF can happen at an
unpredictable point, for which the VapourSynth API has no mechanism at
all. We handle EOF by returning an error to the filter, which will the
filter return all pending frame callbacks.

We still can try to handle it approximately: if the filter requests a
frame past EOF, then send it an error. This seems to work relatively
well with filters which don't request future frames.
2015-03-25 14:33:20 +01:00
wm4 45ff6cef62 vo_opengl: minor simplification
We don't need alternative function names in the GL loader anymore.
2015-03-25 12:40:45 +01:00
wm4 6d9f15a8ab vo_opengl: check extensions properly
With the previous commit, we have no need anymore to check a part of an
extension string (for ignoring a prefix). So check the extension string
properly, instead of just using the broken old strstr() method, which
could accidentally ignore prefixes or suffixes. Do this by extending
the check to whether the extension name is properly delimited by spaces
or string start/end.
2015-03-25 12:36:36 +01:00
wm4 85c21ae409 vo_opengl: cleanup swap_control extension loading
Instead of somehow looking for the substring "_swap_control" and trying
to several arbitrary function names, do it cleanly. The old approach has
the problem that it's not very exact, and may even load a pointer to a
function which doesn't exist. (Some GL implementations like Mesa return
function pointers even the functions which don't exist, and calling them
crashes.)

I couldn't find any evidence that glXSwapInterval, wglSwapIntervalSGI,
or wglSwapInterval actually exist, so don't include them. They were
carried over from MPlayer times.

To make diagnostics easier, print a warning in verbose mode if the
function could not be loaded.
2015-03-25 12:29:19 +01:00
wm4 cdf9abd872 vo_opengl: drop support for old framebuffer extension
Drop support for GL_EXT_framebuffer_object. It has 2 problems: semantics
might be slightly different from the "proper" GL_ARB_framebuffer_object
extension (but is likely completely untested), and also our extension
loader is too dumb to load the same group of function pointers
represented by different extensions only once.
2015-03-25 12:00:57 +01:00
Jari Vetoniemi 3f4e154ec6 vo_wayland: fix null dereference
If compositor sends configure event before back_buffer is allocated, it
will cause null dereference.
2015-03-23 21:53:32 +01:00
Jari Vetoniemi 3a6ade7a84 vo_opengl: do not block on wayland
When not receiving frame callbacks, we should not draw anything to avoid
blocking the OpenGL renderer. We do this by extending gl context api, by
introducing new optional function 'is_active', that indicates whether
OpenGL renderers should draw or not.

This fixes issue #249.
2015-03-23 21:53:32 +01:00
Jari Vetoniemi c10fb4ce9f vo_wayland: define opaque region
This allows compositor to optimize rendering, as it will know mpv is not
transparent.
2015-03-23 21:53:32 +01:00
Jari Vetoniemi 3714430cdf vo_wayland: share frame callbacks.
Define frame callback logic in wayland_common.c
As this should be used by opengl renderer as well.

Preferably drawing should be skipped entierly when no frame callbacks
are received. However, for now only swap buffers is skipped.
2015-03-23 21:53:32 +01:00
wm4 e52f7d3da8 mp_image: reject 0-sized images
Like FFmpeg/Libav do. It seems not all code can actually deal with this
situation, so it's better to shift the special-cases to code which needs
it (possibly OSD code; screenshots of 0x0 windows would just fail).
2015-03-23 18:38:19 +01:00
Niklas Haas cfb5e0cea6 vo_opengl: fix XYZ input gamma
This seems to have been a mistranslation from the original code, which
multiplied the gamma by 2.6 (*not* the color itself).
2015-03-23 18:36:48 +01:00
wm4 a09e5dd891 vo_vdpau: remove some minor code duplication
The way-too-big API call for clearing the screen can be easily shared
between two completely different codepaths.
2015-03-23 18:15:40 +01:00
wm4 7363b0439f vo_vdpau: check vdpau API return value 2015-03-23 18:12:05 +01:00
wm4 180e35a175 vdpau: remove dead assignment
I guess we don't really care whether this particular function succeeds.
If it fails, it must be completely broken anyway and it would not matter
much to us.
2015-03-23 18:09:40 +01:00
wm4 9d84b2c07d vo_opengl: remove dead assignment 2015-03-23 18:04:56 +01:00
wm4 167b75c50c vo_opengl_cb: don't render OSD while VO is not created
Unlike other VOs, this rendered OSD even while no VO was created
(because the renderer lives as long as the API user wants). Change this,
and refactor the code so that the OSD object is accessible only while
the VO is created.

(There is a short time where the OSD can still be accessed even after VO
destruction - this is not a race condition, though it's inelegant and
unfortunately unavoidable.)
2015-03-23 16:32:59 +01:00
wm4 67bdad9a43 vo_opengl: move OSD rendering to separate function
Also reindent the few lines that call into the actual renderer to remove
the "draw_osd" goto.
2015-03-23 16:28:33 +01:00
wm4 612b8a8ab3 vo_opengl: fix video equalizer gamma controls
It was ignored.
2015-03-22 13:28:47 +01:00
wm4 6f5db977c0 vo_opengl: fix background color option
gl_video_set_options() didn't update it, so the default value set on
initialization was used. Fix by always setting the clear color before
the clear command; it's slightly easier to follow too.
2015-03-21 17:32:59 +01:00
wm4 d790dbc3b5 vo_opengl: fix bicubic_fast scaler 2015-03-21 17:29:34 +01:00
wm4 72e67064a3 vd_lavc: less confusing message when hardware decoding won't work
Codecs for hardware acceleration are not blacklisted, but whitelisted.
Also, if this emssage is printed, the codec might not have any hardware
acceleration support in the first place.
2015-03-20 22:14:14 +01:00
wm4 fe0c37b007 player: better handling of video with no timestamps
Trying to handle such video is almost worthless, but it was requested by
at least 2 users.

If there are no timestamps, enable byte seeking by setting
ts_resets_possible. Use the video FPS (wherever it comes from) and the
audio samplerate for timing. The latter was already done by making the
first packet emit DTS=0; remove this again and do it "properly" in a
higher level.
2015-03-20 22:08:12 +01:00
wm4 29083ae31b vo_xv: remove pointless cast 2015-03-20 00:46:56 +01:00
wm4 25c8bf8754 vf_expand: fix memory leak on memory allocation failure
Isn't it ironic.
2015-03-20 00:38:29 +01:00
wm4 6b53897d75 mp_image: do not assume trailing stride padding exists
Normally, the size of an mage plane is assumed to be stride*height. But
in theory, if stride is larger than width*bpp, the last line might not
be padded, simply because it's not necessary. FFmpeg's or mpv's image
allocators always guarantee that this padding exists (it wastes some
insignificant memory for avoiding such subtle issues), but some other
libraries might not.

I suspect one such case might be Xv via vo_xv (see #1698), although my X
server appears to provide full padding. In any case, it can't harm.
2015-03-20 00:34:15 +01:00
wm4 5f2a8474ae video: uninline memcpy_pic functions
There's literally no reason why these functions have to be inline (they
might be performance critical, but then the function call overhead isn't
going to matter at all).

Uninline them and move them to mp_image.c. Drop the header file and fix
all uses of it.
2015-03-20 00:21:23 +01:00
wm4 145922a070 video: replace pointless macro
Some old absurdity.
2015-03-20 00:12:03 +01:00
wm4 713a8c1a89 mp_image: remove unneeded things
(But I'd really prefer removing our own refcounting mechanism fully.)
2015-03-20 00:09:18 +01:00
wm4 47c131bb0c player: warn against non-monotonic video PTS only once
For some reason there were two points in the code where it warned
against non-monotonic video PTS. The one in video.c triggered on PTS
going backwards or making large jumps forwards, while dec_video.c
triggered on PTS going backwards or PTS not changing. Merge them into a
single check, which warns against all cases.
2015-03-18 22:26:49 +01:00
wm4 51befc9deb osd: simplify an aspect of change detection handling
There was a somewhat obscure optimization in the OSD and subtitle
rendering path: if only the position of the sub-images changed, and not
the actual image data, uploading of the image data could be skipped. In
theory, this could speed up things like scrolling subtitles.

But it turns out that even in the rare cases subtitles have such scrolls
or axis-aligned movement, modern libass rarely signals this kind of
change. Possibly this is because of sub-pixel handling and such, which
break this.

As such, it's a worthless optimization and just introduces additional
complexity and subtle bugs (especially in cases libass does the
opposite: incorrectly signaling a position change only, which happened
before). Remove this optimization, and rename bitmap_pos_id to
change_id.
2015-03-18 13:15:20 +01:00
wm4 37cb9a965a vd_lavc: change message about using hardware decoding
This was requested. Apparently some find the old mesage confusing.
2015-03-17 22:33:31 +01:00
wm4 d96fad04be video: don't drop anamorphic scaling if it's too minor
This played e.g. a 1264x722 file as 1264x720. There was some code which
dropped the aspect ratio if the video (in original resolution) wasn't
scaled by more than 4 pixels. Commit 5f3c3f8c introduced this (although
I'm not really sure what the code replaced by it did).

Just remove this "feature".
2015-03-16 20:39:24 +01:00
wm4 7c2f21cb50 vo_opengl: reduce number of uniforms in dithering pass
We now update uniforms every time, so we should try to reduce the number
of uniforms to avoid performance penalties. (Originally, some caching
was planned, but it looks like it would be too complicated to implement
compared to the expected gains.)
2015-03-16 20:22:09 +01:00
wm4 2fe81ce789 vo_opengl: move glViewport call closer to draw call 2015-03-16 20:22:04 +01:00
James Ross-Gowan 92f1309974 vo_opengl: fix srgb replacement options
OPT_REPLACED can't specify option values or multiple options. Change to
OPT_REMOVED. Also, target-prim doesn't have an srgb option. BT.709 uses
sRGB primaries, so use it instead.
2015-03-16 21:02:27 +11:00
wm4 e744eef322 vo_opengl: fix incorrectly drawn OSD in idle mode
Trade one bug for another, I don't even care anymore.

Fixes #1691.
2015-03-16 10:22:28 +01:00
Niklas Haas aa728d5d6f vo_opengl: apply OSD color management 2015-03-16 09:29:55 +01:00
Niklas Haas 4eec5b432b vo_opengl: improve queue size heuristic
The default scaling was a slight bit too low, which could cause buffer
underruns in some cases.

This should improve the result when using tscale filters other than
oversample. The oversample case should be unaffected.
2015-03-16 09:29:52 +01:00
Niklas Haas 0329b81354 vo_opengl: improve interpolation diagnostics
This adds extra debugging output for buffer underruns, to help track
down possible queueing issues. It also inverts the numberic output for
tscale=oversample to make more sense, without changing the logic.
2015-03-16 09:29:50 +01:00
Niklas Haas ce2da9cfcf vo_opengl: color manage after interpolation
This moves the color management code out of pass_render_main (which is
now dedicated solely to up/downscaling and hence renamed pass_scale_main)
and into a new function, which gets called from pass_draw_to_screen
instead.

This makes more sense from a logical standpoint, and also means that we
interpolate in linear RGB, before color management - rather than after
it, which is significantly better for color accuracy and probably also
interpolation quality.
2015-03-16 09:29:47 +01:00
Niklas Haas 9cd523bf5f
filter_kernels: add comment to prevent confusion
There are conflicting definitons of Ginseng.
2015-03-15 18:06:27 +01:00
Niklas Haas 31a5f08f13 vo_opengl: add oversample support for tscale
This is interesting mainly because it's essentially equivalent to the
old smoothmotion algorithm. As such, it is now the default for tscale.
2015-03-15 18:01:39 +01:00
Niklas Haas ac1e31957d vo_opengl: add oversample scaler
This is like nearest neighbour, but the edges between pixels are
linearly interpolating if needed, as if they had been (naively)
oversampled.
2015-03-15 18:01:39 +01:00
Niklas Haas 44a78a2be2 vo_opengl: refactor smoothmotion -> interpolation
This replaces the old smoothmotion code by a more flexible tscale
option, which essentially allows any scaler to be used for interpolating
frames. (The actual "smoothmotion" scaler which behaves identical to the
old code does not currently exist, but it will be re-added in a later commit)

The only odd thing is that larger filters require a larger queue size
offset, which is currently set dynamically as it introduces some issues
when pausing or framestepping. Filters with a lower radius are not
affected as much, so this is identical to the old smoothmotion if the
smoothmotion interpolator is used.
2015-03-15 18:01:39 +01:00
Niklas Haas 6f3292813f vo_opengl: increase the number of video buffers
Also the size is now a simple #define that can easily be changed later.
This is done for smoothmotion, which might want to blend more than 4
frames at once, depending on the setting.
2015-03-15 18:01:39 +01:00