Commit Graph

2187 Commits

Author SHA1 Message Date
wm4 e23e4c7c60 cocoa: don't accidentally drop initial screen drawing
With --idle --force-window, or when started from the bundle, the cocoa
code dropped the first frame. This resulted in a black frame on start
sometimes.

The reason was that the live resizing/redrawing code was invoked, which
simply set skip_swap_buffer to false, blocking redrawing whatever was
going to be rendered next. Normally this is done so that the following
works:

1. vo_opengl draw a frame, releases GL lock
2. live resizing kicks in, redraw the frame
3. vo_opengl wants to call SwapBuffers, drawing a stale buffer
   overwritten by the live resizing code

This is solved by setting skip_swap_buffer in 2., and querying it in 3.

Fix this by resetting the skip_swap_buffer at a known good point: when
vo_opengl starts drawing a new frame.

The start_frame function returns bool, so that it can be merged with
is_active in a following commit.
2015-05-01 18:26:58 +02:00
Avi Halachmi (:avih) ffcad1a72b vo: improve frame drop logic on high playback rate
Commit f1746741de changed the drop
logic to have more slack (drop more frames but less frequent) to prevent
drops due to timing jitter when the clip and screen have similar rates.

However, if the clip has higher rate than the screen (or just higher
playback rate), then that policy hurts smoothness since these "chunked
drops" look worse than one frame drop at a time.

This patch restores the old drop logic when the playback frame rate is
higher than ~5% above the screen refresh rate, and solves this issue.

Fixes #1897
2015-05-01 19:11:44 +03:00
wm4 8c7f3adb41 vo_rpi: update display size on display mode switches 2015-04-30 21:56:16 +02:00
wm4 6ae66e717f vo_rpi: actually draw a black background
Also factor the display size initialization into a separate function.

For some reason this seems to work, although setting the background
color using this 1x1 pixel bitmap does not work. I blame the RPI
beign a terrible piece of hardware with even worse drivers.
2015-04-30 21:56:13 +02:00
Niklas Haas 99439f11ea
csputils: improve contrast semantics for limited range output
The previous version of this logic resulted in black crush and incorrect
brightness scaling when combined with limited range (TV) output.
2015-04-29 22:09:09 +02:00
wm4 0600d378f9 csputils: apply contrast equalizer in RGB
It's weird that this basically adjusts the contrast between luma and
chroma, and not blackness.

This is more in line with the behavior of libswscale, the vdpau
"procamp" (which mpv doesn't use), and Xv.
2015-04-29 21:32:19 +02:00
wm4 d51dee093f screenshots: add option to prevent 16 bit output
That's what it's usually about (again).
2015-04-29 21:05:04 +02:00
wm4 f07c9b16f9 screenshots: add option to disable JPEG 4:4:4 output
That's what it's usually about.
2015-04-29 21:01:08 +02:00
Niklas Haas daf4334697
x11: query ICC profile based on center of window
Right now, the default behavior is to pick the numerically lowest screen
ID that overlaps the window in any way - but this means that mpv will
decide to pick an ICC profile in a pretty arbitrary way even if the
window only overlaps another screen by a single pixel.

The new behavior is to query it based on the center of the window
instead.
2015-04-29 14:01:27 +02:00
akemi-san 1e2e504349 vo_drm: zero screen buffers in reconfig function. 2015-04-27 09:22:10 +02:00
Marcin Kurczewski 5f21a68ce9 vo_drm: add window screenshots support 2015-04-26 20:09:26 +02:00
wm4 a5ed6e49bf vdpau: always render to cropped size at most
vo_opengl (or gl_hwdec_vdpau.c to be specific) calls
mp_vdpau_mixer_render() with video_rect=NULL, which means to use the
full surface. This is incorrect if the surface is actually cropped, as
it can happen with h264. In this case, it was rendering the parts
outside of the image.

Fix it by making this case use the cropped size instead.

Alternative fix for PR #1863.
2015-04-26 18:56:46 +02:00
wm4 72e505a944 player: add --window-scale option
Requested. Works similar to the property with the same name.
2015-04-24 23:27:12 +02:00
James Ross-Gowan ad11d877a5 w32_common: add more rounded-down frame rates
Suggested by avih. This handles x/1.001 frame rates for all multiples of
24 and 30 under 144.
2015-04-25 02:11:00 +10:00
James Ross-Gowan 138c4e50df w32_common: use the current monitor's refresh rate 2015-04-25 02:10:59 +10:00
Avi Halachmi (:avih) e2326bda82 dxva2: fix broken build with gcc 5.1
gpu_mempcy should to be called from code which targets SSE

Signed-off-by: wm4 <wm4@nowhere>
2015-04-24 17:40:39 +02:00
wm4 1419aac22a mp_image: remove some unused interlacing flags
MP_IMGFIELD_TOP/MP_IMGFIELD_BOTTOM were completely unused, and
MP_IMGFIELD_ORDERED was always set (even though vf_vdpaupp.c strangely
checked for the latter).
2015-04-23 22:06:14 +02:00
wm4 994438dee5 vf_vapoursynth: update _FieldBased semantics
These changed in VapourSynth. Also, "_Field" is now unused.
2015-04-23 22:02:40 +02:00
wm4 777273c064 image_writer: fix writing screenshots
It passed the unconverted image to the writer function. Broken since
2469cb5d.
2015-04-22 16:28:31 +02:00
Marcin Kurczewski 445527d45c vo_drm: fix return value for void function 2015-04-21 12:04:35 +02:00
Marcin Kurczewski dedb15a429 vo_drm: fix coding style to adhere to guidelines 2015-04-21 11:54:14 +02:00
Marcin Kurczewski 7f29172baf vo_drm: fix releasing VT if received signal twice
If user switched terminals frantically, mpv could get SIGUSR1 twice in a
row, which, up until now, resulted in destroying CRTC twice. This caused
it to segfault. After this fix, double SIGUSR1 should be ignored.
2015-04-21 11:45:55 +02:00
Marcin Kurczewski a7cf35c1ca vo_drm: add vertical sync 2015-04-21 11:45:53 +02:00
wm4 74ae74db0c video: cleanup some old log messages
These are basically MPlayer leftovers, and barely useful due to being
redundant with other messages. The FPS message is used somewhere else.
2015-04-20 23:19:19 +02:00
wm4 2469cb5d1f image_writer: factor image conversion into a separate function
Needed for a later commit.
2015-04-20 23:04:34 +02:00
wm4 07678423fb image_writer: minor cleanup
Instead of using int like bool, use bool directly.
2015-04-20 23:03:32 +02:00
wm4 a1e410e43a vf_vapoursynth: stupid hack to unbreak with recent API change
Vapoursynth made an incompatible API change: clips with unknown length
are not supported anymore. In fact, Vapoursynth abort()s the program
(which by the way invalidate all of its claims of API/ABI stability).

So add some nonsense to make it work again.
2015-04-20 21:05:42 +02:00
wm4 c6d046414b player: change video-bitrate and audio-bitrate properties
Remove the old implementation for these properties. It was never very
good, often returned very innaccurate values or just 0, and was static
even if the source was variable bitrate. Replace it with the
implementation of "packet-video-bitrate". Mark the "packet-..."
properties as deprecated. (The effective difference is different
formatting, and returning the raw value in bits instead of kilobits.)

Also extend the documentation a little.

It appears at least some decoders (sipr?) need the
AVCodecContext.bit_rate field set, so this one is still passed through.
2015-04-20 20:52:16 +02:00
xylosper ebe2c2b6d1 build: fix libavfilter dependency for vf_mirror
Since e207c24b32, vf_mirror requires
libavfilter.

Signed-off-by: wm4 <wm4@nowhere>
2015-04-20 17:08:29 +02:00
James Ross-Gowan 88d3058681 w32_common: prevent system sleep
This prevents the machine from going to sleep while a video-only stream
is playing. When audio is playing, the audio stack should make this
request for us.
2015-04-20 20:24:19 +10:00
Marcin Kurczewski 34d5b73fbb vo_drm: extract vt_switcher to drm_common 2015-04-19 21:18:15 +02:00
Marcin Kurczewski bd5d047c89 vo_drm: disable VT switcher for non-Linux systems 2015-04-19 21:18:12 +02:00
Marcin Kurczewski c96404d824 vo_drm: fix logging problems with connectors
Logging was meant to be silenced only when user uses connector
auto-detection feature. If user supplies connector ID manually, he
should see exact reason why connecting to this specific connector
failed.
2015-04-18 21:20:45 +02:00
Marcin Kurczewski 3313eba1bf vo_drm: fix VT behavior with auxiliary screens
Fixes #1828
2015-04-18 21:20:42 +02:00
Marcin Kurczewski f3c8c613ba vo_drm: fix VT switching
Fixes #1827
2015-04-18 20:53:17 +02:00
wm4 00c18b32bf vf_crop, vf_expand: remove ancient and useless messages
These are redundant.
2015-04-16 22:46:52 +02:00
wm4 e207c24b32 vf_mirror: replace internal implementation with libavfilter
Currently, libavfilter's equivalent vf_hflip is probably not faster or
anything, but there's still no reason to keep the internal code.
2015-04-16 22:43:15 +02:00
wm4 baaa27d6db vo: fix non-sense in init code
I assume this was intended to generate an initial change event in order
to make the user read the initial values.
2015-04-16 22:31:09 +02:00
wm4 e0bb60a708 vo: cosmetics: reindent VO list
And also undoxygenify a comment. (There used to be some inconsistent
doxygen comments in MPlayer time; they are being removed on sight.)
2015-04-16 22:29:25 +02:00
wm4 f4292ebf52 vf_screenshot: remove this filter
It's entirely useless, especially now that vo.c handles screenshots in a
generic way, and requires no special VO support. There are some
potential weird use-cases, but actually I've never seen it being used.
2015-04-16 22:16:04 +02:00
Marcin Kurczewski 7ee18376a9 vo_drm: add KMS/DRM renderer support
Signed-off-by: wm4 <wm4@nowhere>
2015-04-16 21:07:25 +02:00
wm4 dd12040ebe x11: actually disable screensaver
We already use 2 screensaver APIs when attempting to disable the
screensaver: XResetScreenSaver() (from xlib) and XScreenSaverSuspend
(from the X11 Screen Saver extension). None of these actually work.

On modern desktop Linux, we are expected to make dbus calls using some
freedesktop-defined protocol (and possibly we'd have to fallback to a
Gnome specific one). At least xscreensaver doesn't respect the "old"
APIs either.

Solve this by running the xdg-screensaver script. It's a terrible, ugly
piece of shit (just read the script if you disagree), but at least it
appears to work everywhere. It's also simpler than involving various
dbus client libraries.

I hope this can replace the --heartbeat-cmd option, and maybe we could
remove our own DPMS/XSS code too.
2015-04-15 22:40:19 +02:00
wm4 d704d61c61 vo_opengl: change dwmflush option values
Use a choice instead of an integer. This is incompatible, but I'm not
adding any compatibility since this option was added recently.
2015-04-14 14:29:05 +02:00
wm4 3823d5eb7e vo_rpi: explicitly reference MMAL VC driver
This is optional, but ensures that linking with -Wl,--as-needed does
not drop the MMAL VC driver. The driver normally "registers" itself
in the library constructor, but since no symbols are explicitly
referenced, the linker could remove it with as-needed enabled.
2015-04-13 18:35:18 +02:00
Marcin Kurczewski f43017bfe9 Update license headers
Signed-off-by: wm4 <wm4@nowhere>
2015-04-13 12:10:01 +02:00
wm4 544c56bf22 vo_opengl: slightly simplify check_gl_features()
Not sure why this was so roundabout; probably to keep spam down if the
user's OpenGL drivers are crap (but then just don't enable extended
features), or because the "Disabling..." text was so repetitious.

But there doesn't seem to be a good reason after all. Also, this could
already overflow the fixed size disabled[] array. Just print the
messages directly.
2015-04-11 19:24:54 +02:00
wm4 2b679020f7 vo_opengl: unify blend-subtitles-res and blend-subtitles 2015-04-11 19:22:10 +02:00
wm4 3bfdc20aa1 vo_opengl: fix blend-subtitles-res=video & anamorphic video
Since scaling the video changes the aspect ratio, we have to compensate
for this when rendering subtitles.
2015-04-11 15:53:00 +02:00
Niklas Haas 6f46bafbd0
vo_opengl: add blend-subtitles-res
This can be used to draw the subtitles at the video's native res, which
can make them look more natural and increases performance.
2015-04-10 22:22:55 +02:00
wm4 37a71e57d4 mp_image: remove redundant flags field
Because gcc (and clang) is a goddamn PITA and unnecessarily warns if
the universal initializer for structs is used (like mp_image x = {})
and the first member of the struct is also a struct, move the w/h
fields to the top.
2015-04-10 21:06:25 +02:00
wm4 41151122e7 mp_image: remove redundant chroma_x/y_shift fields 2015-04-10 21:02:16 +02:00
wm4 b3495d9ccf mp_image: remove redundant plane_w/h fields
Seems relatively painful in this case, but they are morally wrong.
2015-04-10 20:58:26 +02:00
wm4 6efd095dfd vo_opengl: use correct texture coordinates for nv12 2015-04-10 19:10:07 +02:00
wm4 8fe640c47d mp_image: fix build 2015-04-09 21:46:28 +02:00
wm4 be259be15c mp_image: get rid of chroma_width/height fields
They are redundant. They were used by draw_bmp.c only, and only in a
special code path that 1. used fixed image formats, and 2. had image
sized perfectly aligned to chroma boundaries (so computing the chroma
width/height is trivial).
2015-04-09 21:11:20 +02:00
wm4 d737939f1f screenshots: drop some useless jpeg writer options 2015-04-09 21:05:26 +02:00
wm4 8d3c826ad8 screenshots: write jpg files with original subsampling
A screenshot from a 4:2:0 video will use 4:2:0, RGB will use 4:4:4, and
so on. (The image data still goes through RGB conversion always.)
2015-04-09 21:01:34 +02:00
Avi Halachmi (:avih) 843bc822a8 opengl: win32 - add option 'dwmflush' to sync in DWM
This could help in cases where the DWM (Windows desktop compositor) adds another
layer of bufferring and therefore the SwapBuffers timing could get messed up.

Signed-off-by: wm4 <wm4@nowhere>
2015-04-09 20:36:35 +02:00
Avi Halachmi (:avih) c97f014576 opengl: smoothmotion: wake up for next vsync a bit earlier
on my windows system this allows smoothmotion to work perfectly also in windowed
mode. There's no real right or wrong here, with the the only goal being to
always hit the next vsync. however, on cases where vsync timing is jittery (as
could happen with DWM), this patch tries to aim to the middle of the vsync cycle
to get as least affected as possible by such jitter.
2015-04-09 20:34:56 +02:00
Avi Halachmi (:avih) f1746741de opengl: drop less frames when clip and display have similar fps
adds 1 vsync interval "slack" before deciding to drop the first frame. it should
help on cases of timing jitter (sleep duration, container timestamps, compositor
vsync timing, etc). once the drop threshold has been crossed, it will keep
dropping until perfect timing alignment. this prevents crossing the drop
threshold back and forth repeatedly and therefore more resilient to frame drops
2015-04-09 20:34:56 +02:00
wm4 e76f6929e5 vo_opengl_cb: deprecate mpv_opengl_cb_render()
Its vp parameter made no sense anymore. Introduce a new one.
2015-04-09 19:31:01 +02:00
wm4 8dc7156bc0 vo_opengl_cb: add a function to report vsync time
And also let vo.c know of it.

Currently, this does not help much, but will facilitate future
improvements.
2015-04-09 19:30:26 +02:00
wm4 4e8ee522f4 vo_opengl_cb: fix video timing somewhat
Increase the default queue size. This helps with "missed" frames due to
the asynchronous nature of the API. All the other VOs are synchronous,
so if rendering and displaying takes a while, the common code in vo.c
will be blocked until it can continue. But with opengl-cb, vo.c might
immediately push the next ready frame, which causes the current frame
to be dropped _if_ it wasn't rendered yet.

One could fix this by making vo.c wait a while (until the API user calls
the render function, which pulls the frame). But setting the default
queue size to 2 seems much simpler: instead of dropping the frame, it
will be pushed to the API user once the next renderer call finishes.

(This is still a bit strange, and will hopefully be cleaned up when
video scheduling is redone, but for now this appears to deliver
relatively good results.)
2015-04-09 19:22:54 +02:00
wm4 11556e0530 vo_opengl: log used GLXFBConfig
Now don't ask me why the GLXFBConfig type is a pointer, but stores an
integer ID.
2015-04-09 14:38:43 +02:00
wm4 db7d56b19f vo_opengl: remove unused function 2015-04-09 14:37:37 +02:00
wm4 f6b2325c2a video/out: fix screenshot image formats
Use variants without alpha.

I skipped vo_sdl, because format selection seems a bit more complicated
here, and nobody cares about vo_sdl anymore.
2015-04-07 11:43:03 +02:00
wm4 efae88e521 vdpau: don't use a transparent image format for screenshots
Fixes #1779.
2015-04-07 10:18:48 +02:00
wm4 7d116a979b screenshots: select best image format the encoder supports
This matters for png screenshots. We used to hardcode rgb24, but
libavformat's png encoder can do much more. Use the image format list
provided by the encoder, and select the best format from it (according
to the source format).

As a consequence, rgb48 (i.e. 16 bit per component) will be selected if
the source format is e.g. 10 bit yuv. This happens in accordance to
FFmpeg's avcodec_find_best_pix_fmt_of_list() function, which assumes
that 16 bit rgb should be preferred for 10 bit yuv.

This also causes it to print this message in this case:

[ffmpeg] swscaler: full chroma interpolation for destination format 'rgb48be' not yet implemented

I'm not 100% sure whether this is a problem.
2015-04-06 20:34:50 +02:00
wm4 a18dc01655 vaapi: fight with Intel's broken video decoding GL interop
Use texture-from-pixmap instead of vaapi's "native" GLX support.
Apparently the latter is unused by other projects. Possibly it's broken
due that, and Intel's inability to provide anything non-broken in
relation to video.

The new code basically uses the X11 output method on a in-memory pixmap,
and maps this pixmap as texture using standard GLX mechanisms. This
requires a lot of X11 and GLX boilerplate, so the code grows. (I don't
know why libva's GLX interop doesn't just do the same under the hood,
instead of bothering the world with their broken/unmaintained "old"
method, whatever it did. I suspect that Intel programmers are just
genuine sadists.)

This change was suggested in issue #1765.

The old GLX support is removed, as it's redundant and broken anyway.

One remaining issue is that the first vaPutSurface() call fails with an
unknown error. It returns -1, which is pretty strange, because vaapi
error codes are normally positive. It happened with the old GLX code
too, but does not happen with vo_vaapi. I couldn't find out why.
2015-04-05 22:48:40 +02:00
Niklas Haas 717e7a5baa vf_format: add gamma override option 2015-04-04 15:48:38 +02:00
Niklas Haas 51bb5e8194 vo_opengl: make csp options consistent with vf_format 2015-04-04 15:47:23 +02:00
Niklas Haas bfbe1342f7
csputils: add some missing colorspaces
With target-prim and target-trc it makes sense to include some common
colorspaces that aren't strictly speaking used for video.
2015-04-04 15:47:14 +02:00
Niklas Haas b51ff8702b vo_opengl: minor cleanup of gamma-related functions 2015-04-04 15:41:15 +02:00
Niklas Haas 27d57af450 vo_opengl: blend-subtitles in non-linear light 2015-04-04 15:41:15 +02:00
Niklas Haas 8876572e2c
vo_opengl: make jinc presets resizable
No real reason this is disabled with the new configuration API.
2015-04-04 15:36:26 +02:00
Niklas Haas 34caa8b01c vo_opengl: add scale-wparam option
This lets us tune the window parameter
2015-04-04 15:36:14 +02:00
Niklas Haas 6bd673c1d2 filter_kernels: add haasnsoft
This is a peculiar filter I stumbled upon while playing around with
windows, it removes aliasing almost completely while not ringing at all.
The downside is that it's quite blurry, but at high resolutions it's not
so noticeable.
2015-04-04 15:36:14 +02:00
Niklas Haas 1984e31706 filter_kernels: remove hermite window
Will have to find a source before re-adding.
2015-04-04 15:36:14 +02:00
Niklas Haas 13efec228b filter_kernels: add bartlett, blackman and welch windows 2015-04-04 15:36:14 +02:00
Niklas Haas 068ff812e4 vo_opengl: refactor scaler configuration
This merges all of the scaler-related options into a single
configuration struct, and also cleans up the way they're passed through
the code. (For example, the scaler index is no longer threaded through
pass_sample, just the scaler configuration itself, and there's no longer
duplication of the params etc.)

In addition, this commit makes scale-down more principled, and turns it
into a scaler in its own right - so there's no longer an ugly separation
between scale and scale-down in the code.

Finally, the radius stuff has been made more proper - filters always
have a radius now (there's no more radius -1), and get a new .resizable
attribute instead for when it's tunable.

User-visible changes:

1. scale-down has been renamed dscale and now has its own set of config
   options (dscale-param1, dscale-radius) etc., instead of reusing
   scale-param1 (which was arguably a bug).

2. The default radius is no longer fixed at 3, but instead uses that
   filter's preferred radius by default. (Scalers with a default radius
   other than 3 include sinc, gaussian, box and triangle)

3. scale-radius etc. now goes down to 0.5, rather than 1.0. 0.5 is the
   smallest radius that theoretically makes sense, and indeed it's used
   by at least one filter (nearest).

Apart from that, it should just be internal changes only.

Note that this sets up for the refactor discussed in #1720, which would
be to merge scaler and window configurations (include parameters etc.)
into a single, simplified string. In the code, this would now basically
just mean getting rid of all the OPT_FLOATRANGE etc. lines related to
scalers and replacing them by a single function that parses a string and
updates the struct scaler_config as appropriate.
2015-04-04 15:36:14 +02:00
Niklas Haas 586dc5574f vo_opengl: separate kernel and window
This makes the core much more elegant, reusable, reconfigurable and also
allows us to more easily add aliases for specific configurations.

Furthermore, this lets us apply a generic blur factor / window function
to arbitrary filters, so we can finally "mix and match" in order to
fine-tune windowing functions.

A few notes are in order:

1. The current system for configuring scalers is ugly and rapidly
   getting unwieldy. I modified the man page to make it a bit more
   bearable, but long-term we have to do something about it; especially
   since..

2. There's currently no way to affect the blur factor or parameters of
   the window functions themselves. For example, I can't actually
   fine-tune the kaiser window's param1, since there's simply no way to
   do so in the current API - even though filter_kernels.c supports it
   just fine!

3. This removes some lesser used filters (especially those which are
   purely window functions to begin with). If anybody asks, you can get
   eg. the old behavior of scale=hanning by using
   scale=box:scale-window=hanning:scale-radius=1 (and yes, the result is
   just as terrible as that sounds - which is why nobody should have
   been using them in the first place).

4. This changes the semantics of the "triangle" scaler slightly - it now
   has an arbitrary radius. This can possibly produce weird results for
   people who were previously using scale-down=triangle, especially if
   in combination with scale-radius (for the usual upscaling). The
   correct fix for this is to use scale-down=bilinear_slow instead,
   which is an alias for triangle at radius 1.

In regards to the last point, in future I want to make it so that
filters have a filter-specific "preferred radius" (for the ones that
are arbitrarily tunable), once the configuration system for filters has
been redesigned (in particular in a way that will let us separate scale
and scale-down cleanly). That way, "triangle" can simply have the
preferred radius of 1 by default, while still being tunable. (Rather
than the default radius being hard-coded to 3 always)
2015-04-04 15:36:13 +02:00
wm4 8fbc64f74e vf_format: allow forcing aspect ratio
Makes vf_dsize completely useless. Unfortunately, even our "official"
encoding profiles still use it.
2015-04-03 00:14:45 +02:00
wm4 8585845c64 vf_format: allow forcing display size 2015-04-03 00:13:41 +02:00
wm4 3d17b12d9c vo_opengl: remove chroma-location suboption
Terribly obscure, and vf_format can do this for all VOs.
2015-04-03 00:12:32 +02:00
wm4 28fa17dac6 vf_format: allow forcing rotation flags 2015-04-03 00:12:30 +02:00
wm4 14a530f474 vf_format: allow forcing stereo mode parameters 2015-04-03 00:11:10 +02:00
wm4 5a2825ec35 video: cleanup stereo mode parsing
Use OPT_CHOICE_C() instead of the custom parser. The functionality is
pretty much equivalent.

(On a side note, it seems --video-stereo-mode can't be removed, because
it controls whether to "reduce" stereo video to mono, which is also the
default. In fact I'm not sure how this should be handled at all.)
2015-04-02 23:54:08 +02:00
Dan Oscarsson 33d587ffa9 vdpau: fix preemption handling
Signed-off-by: wm4 <wm4@nowhere>
2015-03-31 14:48:34 +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 27715b7dd1 video: move colorspace overrides to vf_format, simplify
Remove the colorspace-related top-level options, add them to vf_format.
They are rather obscure and not needed often, so it's better to get them
out of the way. In particular, this gets rid of the semi-complicated
logic in command.c (most of which was needed for OSD display and the
direct feedback from the VO). It removes the duplicated color-related
name mappings.

This removes the ability to write the colormatrix and related
properties. Since filters can be changed at runtime, there's no loss of
functionality, except that you can't cycle automatically through the
color constants anymore (but who needs to do this).

This also changes the type of the mp_csp_names and related variables, so
they can directly be used with OPT_CHOICE. This probably ended up a bit
awkward, for the sake of not adding a new option type which would have
used the previous format.
2015-03-31 00:09:03 +02:00
wm4 273afdc3a4 vf_format: don't crash if nonsense parameters are passed
It was "by design" possible to make mpv crash if the parameters didn't
make enough sense, like "format=rgb24:yuv420p". While forcing the format
has some minor (rather questionable) use for debugging, allowing it to
crash is just stupid.
2015-03-31 00:09:03 +02:00
wm4 1164dc572c vf_format: by default, pass through video without change
Instead of forcing a useless format (packed YUV??) by default.

Also cleanup.
2015-03-31 00:09:03 +02:00
wm4 205a2ef169 csputils: unify names for colorspace/etc. names 2015-03-31 00:09:03 +02:00
wm4 8fff125422 RPI support
This requires FFmpeg git master for accelerated hardware decoding.
Keep in mind that FFmpeg must be compiled with --enable-mmal. Libav
will also work.

Most things work. Screenshots don't work with accelerated/opaque
decoding (except using full window screenshot mode). Subtitles are
very slow - even simple but huge overlays can cause frame drops.

This always uses fullscreen mode. It uses dispmanx and mmal directly,
and there are no window managers or anything on this level.

vo_opengl also kind of works, but is pretty useless and slow. It can't
use opaque hardware decoding (copy back can be used by forcing the
option --vd=lavc:h264_mmal). Keep in mind that the dispmanx backend
is preferred over the X11 ones in case you're trying on X11; but X11
is even more useless on RPI.

This doesn't correctly reject extended h264 profiles and thus doesn't
fallback to software decoding. The hw supports only up to the high
profile, and will e.g. return garbage for Hi10P video.

This sets a precedent of enabling hw decoding by default, but only
if RPI support is compiled (which most hopefully it will be disabled
on desktop Linux platforms). While it's more or less required to use
hw decoding on the weak RPI, it causes more problems than it solves
on real platforms (Linux has the Intel GPU problem, OSX still has
some cases with broken decoding.) So I can live with this compromise
of having different defaults depending on the platform.

Raspberry Pi 2 is required. This wasn't tested on the original RPI,
though at least decoding itself seems to work (but full playback was
not tested).
2015-03-29 16:09:56 +02:00
Niklas Haas 634b4afa2b vo_opengl: treat non-blended subtitles as sRGB
Currently, the code just skipped CMS completely. This commit treats them
as sRGB by default, instead.

This also refactors much of the color management code to make it more
generalized and re-usable.
2015-03-27 12:31:08 +01:00
Niklas Haas a60e725113 vo_opengl: add FBOTEX_FUZZY alias
Minor reusability factor
2015-03-26 00:04:08 +01:00
Niklas Haas 6e1c950069 vo_opengl: simplify sampler prelude
This moves common re-definitions to a custom function and also shortens the
names to make stuff less verbose in general.
2015-03-26 00:04:08 +01:00
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
wm4 af705d0122 vo_opengl: remove hwdec unmap_image callback
Not needed anymore; see previous commit.
2015-03-14 22:39:22 +01:00
wm4 a1b3af5df3 vo_opengl: silence vdpau hwdec warnings with smoothmotion
Since the gl_rework merge, this started to print some OpenGL errors when
using vdpau hardware decoding with vo_opengl smoothmotion. This happens
because some hwdec unmap_image call were not paired with a map_image
call. Unlike the old vo_opengl, the new code does not do this out of
convenience (it would be a pain to track this exactly). It was triggered
by smoothmotion, because not every rendered frame has actually a new
input video frame (i.e. no map_image call, but it called unmap_image
anyway).

Solve this by handling unmapping differently in the vdpau code. The next
commit will remove the unmap_image callback completely.

Fixes #1687.
2015-03-14 22:36:59 +01:00
Niklas Haas a0e747ab35
vo_opengl: only clamp when necessary
This essentially makes it so that every gamma function that crops up
somewhere has a corresponding clamp in front of it.
2015-03-14 21:14:50 +01:00
Stefano Pigozzi efe0fb75bc cocoa: signal VO_EVENT_WIN_STATE on fps change
Fixes #1686
2015-03-14 12:33:09 +01:00
Niklas Haas 0c9c0474bc
vo_opengl: fix incorrect wording in comment
"compand" was used where the actual operation was "compress". Change to
avoid confusion.
2015-03-14 03:05:03 +01:00
Niklas Haas e07b6fcdfd
vo_opengl: fix uninitialization logic
The FBOs we use never actually got cleaned up anywhere, and the vimg
planes were hard-coded to only clean up 3.
2015-03-14 00:32:20 +01:00
Niklas Haas 59c18dc73d
vo_opengl: apply alpha after conversion to rgb
Currently this was done before conversion, which could fuck up a
hypothetical YUVA stream.
2015-03-13 21:30:38 +01:00
wm4 add208c58a vo_opengl: replace float array with a struct
Slightly less painful, because C arrays suck.
2015-03-13 21:14:18 +01:00
wm4 697fb963c2 vo_opengl: remove unused declaration
Stupid compiler.
2015-03-13 20:50:17 +01:00
wm4 d64c9d8e8c vo: make sure display-fps is up-to-date
Sigh.
2015-03-13 18:48:14 +01:00
Avi Halachmi (:avih) f881a520fd win32: support get display fps 2015-03-13 13:32:36 +01: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 a38b85ce42 vo_opengl: restore GL(ES) 2 compatibility 2015-03-13 12:22:18 +01:00
wm4 aedea2a79f vo_opengl: don't test for arrays
Even the lowest supported GL versions have arrays. This test was for
returning arrays from functions, which didn't work in lower GL versions,
but we don't need it anymore.
2015-03-13 11:55:31 +01:00
wm4 b2ad2e2fd1 vo_opengl: minor fix to a comment 2015-03-13 11:53:54 +01:00
James Ross-Gowan acbac01a73 w32_common: don't hide cursor when the menu is open
Previously, mpv would hide the cursor when the autohide timer expired,
even if the window menu was open. This made it difficult to use the menu
with the mouse.

When handling VOCTRL_SET_CURSOR_VISIBILITY, instead of determining
whether to call SetCursor by checking if the cursor is in the client
area, call it based on the parameters to the last WM_SETCURSOR message.
When the window enters "menu mode," it gets a WM_SETCURSOR message with
HIWORD(lParam) set to 0 to indicate that the cursor shouldn't be set.
2015-03-13 21:31:58 +11:00
Niklas Haas 3ee9d7c416
vo_opengl: sample from the right tex for separated scalers
These were still hard-coded to texture0, rather than respecting src_tex
like they should. A simple oversight.
2015-03-13 00:37:16 +01:00
wm4 9a7fc55607 command: display-fps is the display FPS as assumed by the VO
Requested change in behavior.

Note that we set the assumed "infinite" display_fps to 1e6, which
conveniently lets vo_get_vsync_interval() return a dummy value of 1,
which can be easily checked against, and still avoids doing math with
float INFs.
2015-03-12 23:41:25 +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
Niklas Haas 3974a5ca5e vo_opengl: refactor shader generation (part 2)
This adds stuff related to gamma, linear light, sigmoid, BT.2020-CL,
etc, as well as color management. Also adds a new gamma function (gamma22).

This adds new parameters to configure the CMS settings, in particular
letting us target simple colorspaces without requiring usage of a 3DLUT.

This adds smoothmotion. Mostly working, but it's still sensitive to
timing issues. It's based on an actual queue now, but the queue size
is kept small to avoid larger amounts of latency.

Also makes “upscale before blending” the default strategy.
This is justified because the "render after blending" thing doesn't seme
to work consistently any way (introduces stutter due to the way vsync
timing works, or something), so this behavior is a bit closer to master
and makes pausing/unpausing less weird/jumpy.

This adds the remaining scalers, including bicubic_fast, sharpen3,
sharpen5, polar filters and antiringing. Apparently, sharpen3/5 also
consult scale-param1, which was undocumented in master.

This also implements cropping and chroma transformation, plus
rotation/flipping. These are inherently part of the same logic, although
it's a bit rough around the edges in some case, mainly due to the fallback
code paths (for bilinear scaling without indirection).
2015-03-12 23:20:21 +01:00
wm4 e74a4d5bc0 vo_opengl: refactor shader generation (part 1)
The basic idea is to use dynamically generated shaders instead of a
single monolithic file + a ton of ifdefs. Instead of having to setup
every aspect of it separately (like compiling shaders, setting uniforms,
perfoming the actual rendering steps, the GLSL parts), we generate the
GLSL on the fly, and perform the rendering at the same time. The GLSL
is regenerated every frame, but the actual compiled OpenGL-level shaders
are cached, which makes it fast again. Almost all logic can be in a
single place.

The new code is significantly more flexible, which allows us to improve
the code clarity, performance and add more features easily.

This commit is incomplete. It drops almost all previous code, and
readds only the most important things (some of them actually buggy).
The next commit will complete it - it's separate to preserve authorship
information.
2015-03-12 23:20:20 +01:00
wm4 30860f7b10 x11: ignore mouse enter/leave events due to pointer grab
If you click on a window that doesn't have a focus, a LeaveNotify
followed by a EnterNotify event can be generated. The former will have
mode set to NotifyGrab, the latter to NotifyUngrab. This will make the
player think the mouse left the window, even though this is not the
case. Ignore these and only react to those with mode set to
NotifyNormal.

Probably fixes #1672, and some other strange issues on some WMs.
2015-03-11 11:52:33 +01:00
wm4 c7790b4526 vo: hide opengl-cb in --vo=help
Avoids stupid questions.
2015-03-10 17:17:15 +01:00
wm4 eff265c140 vo_opengl_cb: clear last video frame on uninit()
mpv_opengl_cb_render() is supposed to clear the screen with the
background color if there's no video... I think.

It didn't do this, because although uninit() requested gl_video_config()
to be called, this didn't happen, because this function checks whether
the VO is set - and it's unsert after uninit() releases the lock.

Also call the user wakeup callback in this situation, so the user
actually redraws immediately.
2015-03-10 14:16:07 +01:00
wm4 cfa44f4e90 vo_opengl: move minor helper to common code
The generic image format code should cary most of the "knowledge" about
image formats.
2015-03-09 22:47:33 +01:00
James Ross-Gowan 5f0eda7b94 w32_common: remove redundant is_maximized function
This already exists as IsMaximized in the Windows API.
2015-03-09 22:16:26 +11:00
Stefano Pigozzi 735bf48496 cocoa: fix minimized state getter 2015-03-09 12:01:55 +01:00
wm4 b7f242dfcf x11: fix VOCTRL_GET_WIN_STATE
Do not rely on the pointed-to argument to be initialized; VOCTRLs are
supposed to completely overwrite them on success (or not to touch them
on failure).

The currently only caller of VOCTRL_GET_WIN_STATE initializes the value
before calling this, so this is merely about correctness and didn't lead
to any actual bugs.
2015-03-09 11:46:16 +01:00
James Ross-Gowan a26ea50694 w32_common: support the "window-minimized" property 2015-03-09 11:46:06 +01:00
Jaime Marquínez Ferrándiz d7f04e2085 cocoa: support the "window-minimized" property
Signed-off-by: Stefano Pigozzi <stefano.pigozzi@gmail.com>
2015-03-08 22:00:47 +01:00
Filip Milivojevic 5c3a6ca96e vf_vavpp: fix deinterlacing
Add filter parameters to VAAPI deinterlacing filter to actually process
bottom fields instead of deinterlacing top field twice.

Signed-off-by: wm4 <wm4@nowhere>
2015-03-08 21:44:18 +01:00
Stefano Pigozzi 8ec9bce2d3 cocoa: fix autohide in fullscreen 2015-03-08 15:19:17 +01:00
Stefano Pigozzi ce239f1577 cocoa: fix mouse hiding with launchpad and dock folders
Some UI elements in OS X – like Launchpad and Dock folders – are implemented
using borderless windows in background demonized applications.
When we use these elements, mpv doesn't stop to be the active application, but
the mpv window leaves keyWindow state while we use the OS controls.

This commit just keeps track of window state to update the cursor visibility
accordingly.

Fixes #513
2015-03-08 11:56:56 +01:00
torque 39537f6474 cocoa: clamp mouse position to window.
Prevents out-of-window coordinates being reported for mouse coordinates.
Previously they could be out-of-window coordinates on init or on resize.
2015-03-07 19:32:02 +01:00
torque bce753060e cocoa: update mouse coordinates when window is initialized.
Make MpvEventsView -signalMousePosition a public method so it can be
called without a compiler warning. Previously, the mouse position would
be reported as (0,0) until the cursor was moved.
2015-03-07 19:31:52 +01:00
Stefano Pigozzi 678cd30904 cocoa: don't uninit light sensor if not present 2015-03-07 19:28:00 +01:00
Martin Herkt 1bab7f69ae vo_opengl/x11: fix automatic ICC profile loading
mpv would attempt to load ICC profiles several times during VO init
even if no window is displayed. This potentially causes it to load
a profile for a different screen than it is going to be displayed
on, thereby invalidating the profile cache and rebuilding the LUT
every single time.
It would not unload a previously loaded profile when the video
window is moved to a display without an installed profile.

Fix these issues and tweak the log messages a little.
2015-03-07 13:00:06 +01:00
Stefano Pigozzi 5cddd4ccca cocoa: remove possible use after free 2015-03-07 09:13:05 +01:00
Stefano Pigozzi c66b51dab0 cocoa: fix some crashes caused by async uninit
Always keep around our private state and destroy it when we are really done in
the async uninit callback.

Fixes #1657
2015-03-07 08:54:05 +01:00
wm4 fc571e0adb vo_vaapi: fix video equalizer (second try)
The vaapi equalizer have a custom range, and can have a smaller range
than mpv's normalized video equalizer values. The result is that a vaapi
equalizer value can map to multiple mpv values, so changing a mpv value
by 1 can get "stuck". Fix by remember the mpv value, and returning it if
it still corresponds to the vaapi value.

Really fixes #1647.

(Why am I even bothering with this irredeemable crap?)
2015-03-06 12:15:03 +01:00
Niklas Haas 05bb2a9e8a
vo_opengl: make smoothmotion-threshold inclusive
This behavior makes more sense near the borders, eg.
smoothmotion-threshold=0 and smoothmotion-threshold=0.5.
2015-03-05 16:39:22 +01:00
wm4 27b5492a82 vd_lavc: let --hwdec=auto select "vaapi-copy"
Instead of "vaapi", simply by changing the probe order.

"vaapi" uses the GLX GL interop, which has causing us more problems than
it solved.

Unfortunately this leads also to copying if "--hwdec=auto --vo=vaapi" is
used, even though GLX is not involved in this case - but I don't care
enough to make the probe logic cleverer just for this. You can still get
the zero-copy path with --hwdec=vaapi.
2015-03-05 13:02:30 +01:00
wm4 4e3f8ccb9d vo_vaapi: round equalizer values
Probably fixes #1647 (if it's correct at all). I couldn't reproduce with
the vdpau libva driver, but a driver can use different ranges.
2015-03-05 12:49:18 +01:00
Stefano Pigozzi ae33ec2c5b vo_opengl: increase ambient light changes log level
info is a quite too annoying. increase it to verbose.
2015-03-04 20:18:14 +01:00
wm4 85bf102f54 win32: fix some more -Wparentheses warnings
Stupid compiler.

For decode_surrogate_pair(), I changed the order of evaluation; it
shouldn't matter, but this order is more readable in my opinion.
2015-03-04 17:28:41 +01:00
Stefano Pigozzi c028d782c1 vo_opengl: add gamma-auto option
This automatically sets the gamma option depending on lighting conditions
measured from the computer's ambient light sensor.

sRGB – arguably the “sibling” to BT.709 for still images – has a reference
viewing environment defined in its specification (IEC 61966-2-1:1999, see
http://www.color.org/chardata/rgb/srgb.xalter). According to this data, the
assumed ambient illuminance is 64 lux. This is the illuminance where the gamma
that results from ICC color management is correct.

On the other hand, BT.1886 formalizes that the gamma level for dim environments
to be 2.40, and Apple resources (WWDC12: 2012 Session 523: Best practices for
color management) define the BT.1886 dim at 16 lux.

So the logic we apply is:

  * >= 64lux -> 1.961 gamma
  * =< 16lux -> 2.400 gamma
  * 16lux < x < 64lux -> logaritmic rescale of lux to gamma. The human
    perception of illuminance roughly follows a logaritmic scale of lux [1].

[1]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd319008%28v=vs.85%29.aspx
2015-03-04 10:06:08 +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
wm4 c31e5da734 Remove some FFmpeg/Libav compatibility hacks
All of these are now in the supported FFmpeg and Libav versions.

The 3 remaining API checks are for FFmpeg-only things.
2015-03-03 12:28:46 +01:00
wm4 445b3fbf82 buid: readd -Wparentheses
This warning wasn't overly helpful in the past, and warned against
perfectly fine code. But at least with recent gcc versions, this is the
warning that complains about assignments in if expressions (why???), so
we want to enable it.

Also change all the code this warning complains about for no reason.
2015-03-02 19:09:25 +01:00
wm4 4b177bd5c2 vo_direct3d: support NV12 with shaders
Semi-important, because --hwdec=dxva2 outputs NV12, and we really don't
want people to end up with the "old" StretchRect method.

Unfortunately, I couldn't actually get it to work. It seems most D3D
drivers (including the wine D3D implementation) reject D3DFMT_A8L8,
and I could not find any other 2-channel 8 bit Direct3D 9 format. It
seems newer D3D APIs have DXGI_FORMAT_R8G8_UNORM, but there's no way
to get it in D3D9.

Still pushing this; maybe it actually works on some drivers.
2015-03-02 19:09:18 +01:00
wm4 08199a64d2 vf_scale: libswscale is being stupid
This time (there are a lot of times), libswscale randomly ignores
brightness/saturation/contrast settings.

Looking at MPlayer code, it appears the return value of
sws_setColorspaceDetails() signals if changing these settings is
supported at all.

(Nevermind that supporting this feature has almost 0 value, and
obviously eats maintenance time.)
2015-03-01 22:32:38 +01:00
Niklas Haas a76cc1dafc
Revert "Revert recent vo_opengl related commits"
Omitted a simple, but devastasting check. Fixed the relevant commits
now.

This reverts commit 8d24e9d9b8.

diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index 9c8a643..f1ea03e 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -1034,9 +1034,9 @@ static void compile_shaders(struct gl_video *p)
     shader_def_opt(&header_conv, "USE_CONV_GAMMA", use_conv_gamma);
     shader_def_opt(&header_conv, "USE_CONST_LUMA", use_const_luma);
     shader_def_opt(&header_conv, "USE_LINEAR_LIGHT_BT1886",
-                   gamma_fun == MP_CSP_TRC_BT_1886);
+                   use_linear_light && gamma_fun == MP_CSP_TRC_BT_1886);
     shader_def_opt(&header_conv, "USE_LINEAR_LIGHT_SRGB",
-                   gamma_fun == MP_CSP_TRC_SRGB);
+                   use_linear_light && gamma_fun == MP_CSP_TRC_SRGB);
     shader_def_opt(&header_conv, "USE_SIGMOID", use_sigmoid);
     if (p->opts.alpha_mode > 0 && p->has_alpha && p->plane_count > 3)
         shader_def(&header_conv, "USE_ALPHA_PLANE", "3");
2015-02-28 20:23:47 +01:00
wm4 8d24e9d9b8 Revert recent vo_opengl related commits
Breaks vo_opengl by default. I'm hot able to fix this myself, because I
have no clue about the overcomplicated color management logic. Also,
whilethis is apparently caused by commit fbacd5, the following commits
all depend on it, so revert them too.

This reverts the following commits:
 e141caa97d
 653b0dd529
 729c8b3f64
 fbacd5de31

Fixes #1636.
2015-02-28 19:29:03 +01:00