Commit Graph

2537 Commits

Author SHA1 Message Date
wm4 0c0a06140c vo_opengl: restructure format setup
Instead of setting up a weird swizzle (which is linked to how the
internal renderer code works, rather than the generic format code), add
per-component mapping to gl_imgfmt_desc.

The renderer still computes the weird swizzle, but at least it's
confined to itself. Also, it appears the hwdec backends don't need this
anymore.

It's really nice that the messy init_format() goes away too.
2017-06-30 17:07:55 +02:00
wm4 91583fccac options: change path list options, and document list options
The changes to path list options is basically getting rid of the need to
pass multiple paths to a single option. Instead, you can use the option
multiple times. The old behavior can be used by using the -set suffix
with the option.

Change some options to path lists. For example --script is now append by
default, and if you use --script-set, you need to use ":"/";" as
separator instead of ",".

--sub-paths/--audio-file-paths is a deprecated alias now, and will break
if the user tries to pass multiple paths to it. I'm assuming that if
these are used, most users will pass only 1 path anyway.

--opengl-shaders has more compatibility handling, since it's probably
rather common that users pass multiple options to it.

Also document all that in the manpage.

I'll probably regret this later, as it somewhat increases the complexity
of the option parser, rather than increasing it.
2017-06-30 16:39:36 +02:00
wm4 9b5281148c vo_direct3d: fix build
That format is worthless anyway.
2017-06-29 23:13:08 +02:00
wm4 af5a71f52e video: drop some unused IMGFMT aliases
These formats are supported in a generic way.

To get rid of IMGFMT_NV21, remove support from vo_direct3d.c completely.
2017-06-29 20:56:29 +02:00
wm4 1dffcb0167 vo_opengl: rely on FFmpeg pixdesc a bit more
Add something that allows is to extract the component order from various
RGBA formats. In fact, also handle YUV, GBRP, and XYZ formats with this.

It introduces a new struct mp_regular_imgfmt, that hopefully will
eventually replace struct mp_imgfmt_desc. The latter is still needed by
a lot of code though, especially generic code. Also vo_opengl still uses
the old one, so this commit is sort of incomplete.

Due to its genericness, it's also possible that this commit introduces
rendering bugs, or accepts formats it shouldn't accept.
2017-06-29 20:52:05 +02:00
wm4 cd25d98bfa Avoid calling close(-1)
While this is perfectly OK on Unix, it causes annoying valgrind
warnings, and might be otherwise confusing to others.

On Windows, the runtime can actually abort the process if this is
called.

push.c part taken from a patch by Pedro Pombeiro.
2017-06-29 10:31:13 +02:00
Niklas Haas 0af561953a
vo_opengl: unify user_shaders constants
Commit 3fb6380 was supposed to increase MAX_TEXTURE_HOOKS but instead
increased SHADER_MAX_HOOKS, since I forgot that they were separate (for
whatever reason).

To prevent this mistake from happening again, and to unify the location
in which user_shader-specific #defines are placed, get rid of the two
constants in opengl/video.c and move/reuse them from user_shaders.h
instead.

Also bump up MAX_SAVED_TEXTURES (now SHADER_MAX_SAVED) slightly as a
precaution against adding more passes to vo_opengl. I think we're
already flirting with the limit.
2017-06-28 00:01:25 +02:00
Niklas Haas db36aa06f4
vo_opengl: tone map using only luminance information
This is even better at preventing discoloration than tone mapping on the
XYZ image. Partly inspired by the HLG OOTF. Also simplifies the way we
tone map, and moves this logic to the pass_tone_map function where it
belongs.

This also fixes what could arguably be considered a bug in the HLG
implementation when using HLG for non-BT.2020 colorspaces, which is not
permitted by spec but thinkable in theory. Although in this case, I
guess it will be arbitrary whether people use the BT.2020-normalized
luma coefficients or change it to fit the colorspace, so I guess either
way could be considered "right", depending on what people end up doing.
Either way, in lieue of standard practice, we do what makes the most
sense (to me), and hopefully others will follow.

The downside is that we upload an extra vec3 uniform even if we don't
use it, but eliminating that would be ugly.
2017-06-27 01:05:43 +02:00
Niklas Haas 7bfeb8bd26
vo_opengl: silence -Wmaybe-uninitialized false positive
These can never be uninitialized because the enum cases are exhaustive and
the fallback is in the correct order, but GCC is too dumb to understand
this.

Also explicitly initialize tex_type, because while GCC doesn't warn
about it (for some reason), maybe it will in the future.
2017-06-24 22:51:48 +02:00
wm4 aa458c1fef osx: change license header on some more cocoa files
Changing the headers was actually forgotten in the previous commit.
2017-06-24 16:50:52 +02:00
wm4 6b303d5c3c osx: change license of OSX and cocoa files to LGPL
All authors of the current code have agreed.
2017-06-24 16:29:22 +02:00
wm4 c9696a1b14 w32_common, w32_keyboard: change license to LGPL
All authors agreed.
2017-06-24 12:54:45 +02:00
Niklas Haas 3fb6380aa8
vo_opengl: bump up SHADER_MAX_HOOKS
Apparently people are running into the current limit. 64 ought to be
enough for everybody.
2017-06-24 01:55:21 +02:00
quilloss 2ba2062e5b context_dxinterop: lock rendertarget after present when swapping buffers
Moves the DXLockObjectsNV call to after PresentEx. This fixes an issue
where the presented image is a single frame late. This may be due to
DXLockObjectsNV locking the render target before StretchRect is done.
The spec indicates that the lock call should provide synchronization
for the resource, so this may be due to a driver bug.
2017-06-18 20:54:44 +02:00
Anton Kindestam 3d75ba971d vo_drm: nake drm mode help output also output refresh rate
The printout of available modes that you can get with --drm-mode=-1
(with -vo drm or --opengl-backend=drm) does not include the refresh
rate in the printout, which is quite useful to know, if one is to
choose for instance 23.98, or 24 Hz for film material.

Signed-off-by: wm4 <wm4@nowhere>
2017-06-18 20:54:44 +02:00
Niklas Haas 2e45b8fa1a vo_opengl: implement sony s-log2 trc
Apparently this is virtually identical to Panasonic's V-Log, but using
the constants from S-Log1 and an extra scaling coefficient to make the
S-Log1 curve less limited. Whatever floats their NIH boat, I guess.

Source: https://pro.sony.com/bbsccms/assets/files/micro/dmpc/training/S-Log2_Technical_PaperV1_0.pdf
2017-06-18 20:54:44 +02:00
Niklas Haas 326e02e955 vo_opengl: implement sony s-log1 trc
Source: https://pro.sony.com/bbsccms/assets/files/mkt/cinema/solutions/slog_manual.pdf

Not 100% confident in the implementation since the values from the spec
seem to be very subtly off (~1%), but it should be close enough for
practical purposes.
2017-06-18 20:54:44 +02:00
Niklas Haas c3f32f3a6e vo_opengl: tone map in linear XYZ instead of RGB
This preserves channel balance better and helps reduce discoloration due
to nonlinear tone mapping.

I wasn't sure whether to stuff this inside pass_color_manage or
pass_tone_map but decided for the former because adding the extra
mp_csp_prim would have made the signature of the latter longer than
80col, and also because the `mp_get_cms_matrix` below it basically does
the same thing anyway, so it doesn't look that out of place. Also why is
this justification longer than the actual description of the algorithm
and what it's good for?
2017-06-18 20:54:44 +02:00
Niklas Haas 1f3000b03c vo_opengl: implement support for OOTFs and non-display referred content
This introduces (yet another..) mp_colorspace members, an enum `light`
(for lack of a better name) which basically tells us whether we're
dealing with scene-referred or display-referred light, but also a bit
more metadata (in which way is the scene-referred light expected to be
mapped to the display?).

The addition of this parameter accomplishes two goals:

1. Allows us to actually support HLG more-or-less correctly[1]
2. Allows people playing back direct “camera” content (e.g. v-log or
   s-log2) to treat it as scene-referred instead of display-referred

[1] Even better would be to use the display-referred OOTF instead of the
idealized OOTF, but this would require either native HLG support in
LittleCMS (unlikely) or more communication between lcms.c and
video_shaders.c than I'm remotely comfortable with

That being said, in principle we could switch our usage of the BT.1886
EOTF to the BT.709 OETF instead and treat BT.709 content as being
scene-referred under application of the 709+1886 OOTF; which moves that
particular conversion from the 3dlut to the shader code; but also allows
a) users like UliZappe to turn it off and b) supporting the full HLG
OOTF in the same framework. But I think I prefer things as they are
right now.
2017-06-18 20:54:44 +02:00
Niklas Haas fe1227883a csputils: rename HDR curves
st2084 and std-b67 are really weird names for PQ and HLG, which is what
everybody else (including e.g. the ITU-R) calls them. Follow their
example.

I decided against naming them bt2020-pq and bt2020-hlg because it's not
necessary in this case. The standard name is only used for the other
colorspaces etc. because those literally have no other names.
2017-06-18 20:54:44 +02:00
Niklas Haas c335e84230 video: refactor HDR implementation
List of changes:

1. Kill nom_peak, since it's a pointless non-field that stores nothing
   of value and is _always_ derived from ref_white anyway.

2. Kill ref_white/--target-brightness, because the only case it really
   existed for (PQ) actually doesn't need to be this general: According
   to ITU-R BT.2100, PQ *always* assumes a reference monitor with a
   white point of 100 cd/m².

3. Improve documentation and comments surrounding this stuff.
4. Clean up some of the code in general. Move stuff where it belongs.
2017-06-18 20:48:23 +02:00
wm4 078b275514 image_writer, vo_image: change license to LGPL
image_writer.c has code originating from vf_screenshot.c, vo_jpeg.c, and
potentially others. vo_image.c is based on a bunch of those VOs as well,
and the intention was to replace them with a single codebase.

vo_tga.c was written by someone who was not or not could be contacted,
but it doesn't matter anyway, as no code from that initial patch was
used.

One rather old patch (57f77bb41a) reordered by libjpeg patch API calls,
and the author of the patch was not contacted. But at least with the
smoothing_factor override removed, this pretty much exactly corresponds
to the official libjpeg API example (and might even reflect a change to
those - didn't dig deeper). This removes the -jpeg-smooth option. While
we're at it, remove all the other dropped jpeg options from the manpage
(which was forgotten in past changes).
2017-06-18 15:45:24 +02:00
wm4 b6d0b57e85 Drop/move img_fourcc.h
This file is an leftover from when img_format.h was changed from using
the ancient FourCCs (based on Microsoft multimedia conventions) for
pixel formats to a simple enum. The remaining cases still inherently
used FourCCs for whatever reasons.

Instead of worrying about residual copyrights in this file, just move it
into code we don't want to relicense (the ancient Linux TV code). We
have to fix some other code depending on it. For the most part, we just
replace the MP_FOURCC macro with libavutil's MKTAG (although the macro
definition is exactly the same). In demux_raw, we drop some pre-defined
FourCCs, but it's not like it matters. (Instead of
--demuxer-rawvideo-format use --demuxer-rawvideo-mp-format.)
2017-06-18 15:13:45 +02:00
wm4 0bac1a52e8 win_state: change license to LGPL
All relevant authors have agreed.

Also correct an unrelated entry in the "Copyright" file.
2017-06-17 21:10:24 +02:00
wm4 9c0239ca63 aspect: change license to LGPL
Quite chaotic history, which code being moved, refactored, duplicated,
unified a bunch of times. But I think everything is covered by LGPL
agreements.

In one case, cehoyos (who didn't agree) applied a patch by someone who
agreed, but didn't change anything (except weirdly adding German
translations). In another case, cehoyos moved code covered by LGPL
agreements (without changing it), which was later used for some other
code. We consider both cases not relevant for copyright.

win_state.c/.h is similar, but pending for reply by the author of
2ab259e68 (I guess).
2017-06-17 17:08:51 +02:00
wm4 182bbb5917 vo_opengl: fall back to ordered dither instead of blowing up
In GLES 2 mode, we can do dither, but "fruit" dithering is still out of
the question, because it does not support any high depth textures.
(Actually we probably could use an 8 bit texture too for this, at least
with small matrix sizes, but it's still too much of a pain to convert
the data, so why bother.)

This is actually a regression; before this, forcibly enabling dumb mode
due to low GL caps actually happened to avoid this case.

Fixes #4519.
2017-06-17 13:55:07 +02:00
Rudolf Polzer e2573e5b8d encode_lavc: move from GPL 2+ to LGPL 2.1+. 2017-06-13 14:22:15 -04:00
Niklas Haas 4e12baf3d7 vo_opengl: change default tone mapping algorithm
d8a3b10f4 was supposed to change this (as reflected in the man page and
commit message), I just forgot.
2017-06-10 13:48:35 +02:00
Niklas Haas d8a3b10f45
vo_opengl: add new HDR tone mapping algorithm
I call it `mobius` because apparently the form f(x) = (cx+a)/(dx+b) is
called a Möbius transform, which is the algorithm this is based on. In
the extremes it becomes `reinhard` (param=0.0 and `clip` (param=1.0),
smoothly transitioning between the two depending on the parameter.

This is a useful tone mapping algorithm since the tunable mobius
transform allows the user to decide the trade-off between color accuracy
and detail preservation on a continuous scale. The default of 0.3 is
already far more accurate than `reinhard` while also being reasonably
good at preserving highlights, without suffering from the overall
brightness drop and color distortion of `hable`.

For these reasons, make this the new default. Also expand and improve
the documentation for these tone mapping functions.
2017-06-09 11:27:28 +01:00
wm4 0754cbc83e d3d: add support for new libavcodec hwaccel API
Unfortunately quite a mess, in particular due to the need to have some
compatibility with the old API. (The old API will be supported only in
short term.)
2017-06-08 21:51:25 +02:00
rslovers 9821737d06 vo_drm: fallback to vo_wait_default if VT switcher is not available
When the drm video output is used under VT with a terminal multiplexer
like screen, the VT_SETMODE ioctl call will fail since the controlling
terminal is a pseudoterminal instead of a real one, thus the VT switcher
will be unavailable.

The problem is, the wait_events function inside vo_drm.c will test for
this, and will do nothing if the switcher is not active. Normally, this
would not be noticed, however, when you pause a video, or if you're playing
multiple image files, mpv will suddenly start busy waiting on a single
core.

I confirmed this by building mpv with gprof support, in a few seconds,
wait_events got called about 90 million times.

So I added a fallback, when the VT switcher is not availble, just use the
vo_wait_default function. I tested it and it's working well so far.
2017-06-08 15:24:10 +02:00
Philip Langdale 7424651b96 vo_opengl: hwdec_cuda: Support separate decode and display devices
In a multi GPU scenario, it may be desirable to use different GPUs
for decode and display responsibilities. For example, if a secondary
GPU has better video decoding capabilities.

In such a scenario, we need to initialise a separate context for each
GPU, and use the display context in hwdec_cuda, while passing the
decode context to avcodec.

Once that's done, the actually hand-off between the two GPUs is
transparent to us (It happens during the cuMemcpy2D operation which
copies the decoded frame from a cuda buffer to the OpenGL texture).

In the end, the bulk of the work is around introducing a new
configuration option to specify the decode device.
2017-06-03 16:41:03 +02:00
Raúl Peñacoba bc3365b169 video/out/wayland/buffer.c: Add missing free() 2017-05-26 08:52:12 +01:00
wm4 83a9b0bc48 videotoolbox: support new libavcodec API
The new API has literally no advantages (other than that we can drop
mp_vt_download_image and other things later), but it's sort-of uniform
with the other hwaccels.

"--videotoolbox-format=no" is not supported with the new API, because it
doesn't "fit in". Probably could be added later again.

The iOS code change is untested (no way to test).
2017-05-24 15:25:48 +02:00
Akemi 37f0571973 cocoa: properly unhide Dock when quitting during System fs animation
when quitting mpv during the System fullscreen animation cocoa can't
reset some flags properly and won't reset the Dock hiding behaviour
to it's previous state.

Fixes #4400
2017-05-19 19:19:29 +02:00
James Ross-Gowan 6a00059850 context_angle: fix fallback to D3D9 device
This was broken in e0250b9604. In some cases, device creation will
succeed, but creating an EGL context on the device will fail. With
--angle-renderer=auto, it should try to create the context again on a
D3D9 device.

This fixes mpv in Windows Vista on VirtualBox for me.
2017-05-16 22:59:15 +10:00
James Ross-Gowan fe09d76142 w32_common: drop TLS usage
This was added in 3f268cc4f2 because it wasn't clear whether
WM_NCCREATE could be used to send a context pointer from CreateWindowEx
to the window procedure. WM_NCCREATE isn't always the first message sent
to a window, but this seems to be because of an undocumented but
well-known bug where, for top-level overlapped windows, a spurious
WM_GETMINMAXINFO arrives first instead. The WM_GETMINMAXINFO can be
safely ignored, so it is still okay to pass the context struct in
WM_NCCREATE.
2017-05-16 20:13:09 +10:00
James Ross-Gowan e6a6677630 w32_common: use the proper keycodes for XBUTTON1/2
mpv's mouse button numbering is based on X11, which means XBUTTON1 and 2
on Windows (the "back" and "forward" buttons) should map to MOUSE_BTN7
and 8 in mpv. MOUSE_BTN5 and 6 refer to the horizontal scroll buttons on
mouses that have them.
2017-05-12 22:58:58 +10:00
James Ross-Gowan 18a45a42d5 w32_common: generate MP_AXIS_* keycodes for scrolling
Windows doesn't have a way to distinguish "precise" mouse wheel events
and events from regular notched mouse wheels. A notched wheel should
always send events with a delta of 120, but a precise wheel could also
happen to send 120 if multiple scroll events are coalesced (and to make
things even harder, some buggy Microsoft drivers send deltas less than
120, even for notched wheels.) Since there is no distinction, but
MP_AXIS_* keycodes can hold more information (the delta value,) send
MP_AXIS_* events for both kinds of mouse wheel scrolling.
2017-05-12 22:58:58 +10:00
wm4 2b616c0682 vo_opengl: drop TLS usage
TLS is a headache. We should avoid it if we can.

The involved mechanism is unfortunately entangled with the unfortunate
libmpv API for returning pointers to host API objects. This has to be
kept until we change the API somehow.

Practically untested out of pure laziness. I'm sure I'll get a bunch of
reports if it's broken.
2017-05-11 17:47:33 +02:00
wm4 0e09533c73 vo.c, vo.h, vo_null.c: change license to LGPL
Most contributors have agreed. vo.c requires a "driver" entry for each
video output - we assume that if someone who didn't agree to LGPL added
a line, it's fine for vo.c to be LGPL anyway. If the affected video
output is not disabled at compilation time, the resulting binary will be
GPL anyway.

One problem are the changes by Nick Kurshev (usually using "nick" as SVN
username). He could not be reached. I believe all changes to his files
are actually gone, but here is a detailed listing:

fa1d5742bc: nick introduces a new VO API. It was removed in 64bedd9683.
Some of this was replaced by VOCTRLs are introduced in 7c51652a1b,
obviously replacing at least some functionality by his API.

b587a3d642: nick adds a vo_tune_info_t struct. Removed in 64bedd9683
too.

9caad2c29a: nick adds some VOCTRLs, which were silently removed in
8cc5ba5ab8 (they became unused probably with the VIDIX removal).

340183b0e9: nick adds VO-based screenshots, which got removed in
2f4b840f62. Strangely the same name was introduced in 01cf896a2f again,
but this is a coincidence and worked differently (also it was removed
yet again in 2858232220).

104c125e6d: nick adds an option for "direct rendering". It was renamed
in 6403904ae9 and fully removed in e48b21dd87.

5ddd8e92a1: nick adds code to check the VO driver preinit arg to every
single VO driver. The argument itself and any possibly remaining code
associated with it was removed in 1f5ffe7d30.

f6878753fb: nick adds header inclusion guards. We assume this is not
relevant for copyright.

Some of nick's code was merely moved to other files, such as the
equalizer stuff added in 555c676683 and moved in 4db72f6a80 and
12579136ff, and don't affect copyright of these files anymore.

Other notes:

fef7b17c34: a patch by someone who wasn't asked for relicensing added a
symbol that was removed again in 1b09f4633.

4a8a46fafd: author probably didn't agree to LGPL, but the function
signature was changed later on anyway, and nothing of this is left.

7b25afd742: the same author adds a symbol to what is vo.h today, which
this relicensing commit removes, as it was unused. (It's not clear
whether the mere symbol is copyrightable, but no need to take a risk.)

3a406e94d7, 9dd8f241ac: slave mode things by someone who couldn't be
reached. This aspect of the old slave mode was completely removed.

bbeb54d80a: patch by someone who was not asked, but the added code was
completely removed again.
2017-05-10 15:06:20 +02:00
wm4 1143f2877a d3d11: change mp_image plane pointer semantics
Until now, the texture pointer was stored in plane 1, and the texture
array index was in plane 2. Move this down to plane 0 and plane 1. This
is to align it to the new WIP D3D11 decoding API in Libav, where we
decided that there is no reason to avoid setting plane 0, and that it
would be less weird to start at plane 0.
2017-05-04 01:13:03 +02:00
wm4 2eaa43e5da vo_opengl: another attempt at removing the overlay correctly
This reverts commit 142b2f23d4, and replaces it with another try. The
previous attempt removed the overlay on every rendering, because the
normal rendering path actually unrefs the mp_image. Consequently,
unmap_current_image() was completely inappropriate for removing the
overlay.
2017-05-02 17:10:26 +02:00
wm4 142b2f23d4 vo_opengl: make sure overlays are removed on gl_video_config()
This should make vo_opengl_cb uninit remove the frame, even if the
renderer and OpenGL state remains active.
2017-04-29 15:09:40 +02:00
wm4 010c7d4992 vo_opengl: context_drm_egl: remove unnecessary include
Could be broken after the previous commit removed finding the GL include
dir.
2017-04-26 17:43:23 +02:00
wm4 f59371de21 video: drop vaapi/vdpau hw decoding support with FFmpeg 3.2
This drops support for the old libavcodec APIs. Now FFmpeg 3.3 or FFmpeg
git is required. Libav has no release with the new APIs yet, so for
Libav git as of a few weeks or months ago or so is required if you want
to use Libav.

Not much actually changes in hwdec_vaegl.c - some code is removed, but
the reindentation inflates the diff.
2017-04-23 16:07:03 +02:00
wm4 927afa311d build: make various x11 protocol extension libs mandatory
Reduces the ifdeffery, which is good and will avoid silent breakages, or
weird behavior if a lib is omitted.

Also reorder the x11_common.c include statements.
2017-04-21 07:30:03 +02:00
wm4 4d1eab6e55 vo_opengl: fix crash by coping temporal_dither_period for dumb mode too
Specifically, this field must never be 0 (and the option can naturally
not be 0 in any way, unless it wasn't initialized correctly).
2017-04-21 07:16:26 +02:00
Akemi f7637db377 cocoa: fix retrieval of unfs window size while animating
due to the System inherent fullscreen animation the option and the
actual fullscreen state can be out of sync, leading to a wrongly
reported unfs window size in the time of the animation.

just always fall back to the window size, we keep track of, when we
either are in fullscreen or are currently switching to it.

Fixes #4323
2017-04-17 02:45:26 +02:00
wm4 bba08e38ff vo_opengl: move X11 backends before Wayland
Wayland is still too amateurish, and multiple features don't work,
including critical ones. There is no solution in sight, so prefer X11.
(Which seems to mostly work ok via xwayland.)

Once all problems are solved, the defaults can be switched back.
2017-04-16 02:35:12 +02:00