Commit Graph

512 Commits

Author SHA1 Message Date
wm4 d1de1e090f options: handle presets directly in m_config
This means that "mpv -vo opengl-hq:help" will actually show the correct
defaults, instead those of plain vo_opengl.
2013-07-31 20:56:00 +02:00
Stefano Pigozzi ff3b98d11c cocoa_common: simplify resize code
This introduces some changes in resize behaviour. Most importantly the window
frame is not constrained to it's screen's `visibleFrame`. Anyone who still wants
that kind of behaviour when opening a video, can use `--autofit-larger`.

Even though the size of the window is not constrained, it's position is, so
that the titlebar will always be visible. When using `--no-border` even the
position will not be constrained in any way.
2013-07-30 20:02:48 +02:00
wm4 a34c707f03 vd_lavc: print warning if hardware decoding API is not available
At least currently, this case pretty much happens only in the case vdpau
is requested, but not compiled in.
2013-07-30 16:32:21 +02:00
wm4 7f5303fbb6 vd_lavc: fix CONFIG_VDPAU check
CONFIG_VDPAU was just defined to 0, instead of undefined when vdpau was
unavailable. I blame the old mplayer code, which apparently can't have
consistent conventions.
2013-07-30 16:26:54 +02:00
wm4 fece4e3053 build: fix build with vdpau, simplify
Instead of generating vdpau_template.c with a Perl script, just include
the generated file in git. This is ok because it changes very rarely,
and the script is larger than the output it generates.

It also simplify the Makefile, and fixes the build. The problem was that
transitive dependencies do not work with generated files: there is no
dependency information yet when building it the first time. I overlooked
this because I didn't delete the .d files for testing (which contained
the correct dependencies, but only _after_ a first successful build).
2013-07-29 00:59:07 +02:00
wm4 5accc5e7c1 vdpau: split off decoder parts, use "new" libavcodec vdpau hwaccel API
Move the decoder parts from vo_vdpau.c to a new file vdpau_old.c. This
file is named so because because it's written against the "old"
libavcodec vdpau pseudo-decoder (e.g. "h264_vdpau").

Add support for the "new" libavcodec vdpau support. This was recently
added and replaces the "old" vdpau parts. (In fact, Libav is about to
deprecate and remove the "old" API without deprecation grace period,
so we have to support it now. Moreover, there will probably be no Libav
release which supports both, so the transition is even less smooth than
we could hope, and we have to support both the old and new API.)

Whether the old or new API is used is checked by a configure test: if
the new API is found, it is used, otherwise the old API is assumed.

Some details might be handled differently. Especially display preemption
is a bit problematic with the "new" libavcodec vdpau support: it wants
to keep a pointer to a specific vdpau API function (which can be driver
specific, because preemption might switch drivers). Also, surface IDs
are now directly stored in AVFrames (and mp_images), so they can't be
forced to VDP_INVALID_HANDLE on preemption. (This changes even with
older libavcodec versions, because mp_image always uses the newer
representation to make vo_vdpau.c simpler.)

Decoder initialization in the new code tries to deal with codec
profiles, while the old code always uses the highest profile per codec.

Surface allocation changes. Since the decoder won't call config() in
vo_vdpau.c on video size change anymore, we allow allocating surfaces
of arbitrary size instead of locking it to what the VO was configured.
The non-hwdec code also has slightly different allocation behavior now.

Enabling the old vdpau special decoders via e.g. --vd=lavc:h264_vdpau
doesn't work anymore (a warning suggesting the --hwdec option is
printed instead).
2013-07-28 19:25:07 +02:00
wm4 1a7f062503 lavc_dr1: make reference counting thread-safe
See previous commits. This time, the lock is kept for rather long
times (e.g. for the duration of a big image memory allocation), but
this (probably) still doesn't matter at all.

This also affects legacy code only (pre-refcounting libavcodec).
2013-07-28 19:25:07 +02:00
wm4 c28bafcfb6 mp_image_pool: make reference counting thread-safe
See previous commits. Also simplify this thing: 2 flags per pool image
are enough to avoid a weird central refcount and an associated shared
object keeping the refcount. We could even just store these two flags
in the mp_image itself (like in mp_image.flags or mp_image.priv), but
let's not for the sake of readability.
2013-07-28 19:25:07 +02:00
wm4 a9a6cf3b6c mp_image: make reference counting thread-safe
This hasn't been done yet, because pthreads is still an optional
dependency, so this is a bit annoying. Now doing it anyway, because
maybe we will need this capability in the future.

We keep it as simple as possible. We (probably) don't need anything
more sophisticated, and keeping it simple avoids introducing weird
bugs. So, no atomic instructions, no fine grained locks, no cleverness.
2013-07-28 18:56:49 +02:00
wm4 c070fa865f m_config: refactor some things
Change how m_config is initialized. Make it more uniform; now all
m_config structs are intialized in exactly the same way. Make sure
there's only a single m_option[] array defining the options, and keep
around the pointer to the optstruct default value, and the optstruct
size as well. This will allow reconstructing the option default values
in the following commit.

In particular, stop pretending that the handling of some special options
(like --profile, --v, and some others) is in any way elegant, and make
them explicit hacks. This is really more readable and easier to
understand than what was before, and simplifies the code.
2013-07-28 18:44:21 +02:00
wm4 13a0e6373e mp_image: pass through colorspace info to libavfilter
This change affects vf_lavfi. Until recently, libavfilter was not
colorspace aware at all. This changed with the addition of colorspace
fields to AVFrame. libavfilter's vf_scale picks them up (as of recent
ffmpeg git). Since this support is still kind of wonky and not part of
the normal format negotiation, this won't set the correct output
colorspace, though.

Not adding a separate test for HAVE_AVFRAME_COLORSPACE. This is slightly
unclean, but on the other hand adding an explicit test seems like a
waste of effort.
2013-07-28 18:44:20 +02:00
wm4 ff0680c9b4 vf: fix unintended overwriting of image info
The symptom was that "-vf scale,format=rgba" broke the vsfilter
colorspace hack in sd_ass. vf->reconfig is allowed to overwrite its
input parameter for convenience (maybe that was a bad idea).
2013-07-28 18:44:20 +02:00
wm4 efd3361c81 gl_video: make sure image parameters are correctly set on screenshots
Makes sure the chroma_location doesn't get lost.
2013-07-26 00:26:04 +02:00
wm4 9cc5630fd5 video: support setting libswscale chroma position 2013-07-25 23:03:20 +02:00
Diogo Franco (Kovensky) 24e50ee74e w32_common: Don't use globals for TRACKMOUSEEVENT
It seems working on getch2 gave me some brain damage.
2013-07-25 14:47:49 -03:00
Diogo Franco (Kovensky) f0b1834d59 w32_common: Track when the mouse leaves the window
Windows doesn't send WM_MOUSELEAVE by default unless you ask it to;
request tracking for leave events when the mouse enters the window (or is
moved).

Tracking is automatically de-activated once the mouse leaves the window,
so we have to re-request it every time the mouse re-enters the window.
2013-07-25 14:19:12 -03:00
wm4 202b9e8069 mp_image: create AVBuffers for all planes when converting to AVFrame
It appears the API requires you to cover all plane data with AVBuffers
(that is, one AVBuffer per plane in the most general case), because
certain code can make certain assumptions about this. (Insert rant
about how this is barely useful and increases complexity and potential
bugs.) I don't know any cases where the current code actually fails,
but we want to follow the API, so do it anyway.

Note that we don't really know whether or not planes are from a single
memory allocation, so we have to assume the most general case and create
an AVBuffer for each plane. We simply assume that the data is padded to
the full stride in the last image line. All these extra dummy references
are stupid, but the code might become much simpler once we only support
libavcodec versions with refcounting and can use AVFrame directly.
2013-07-24 19:47:05 +02:00
wm4 e83cbde1a4 Fix some -Wshadow warnings
In general, this warning can hint to actual bugs. We don't enable it
yet, because it would conflict with some unmerged code, and we should
check with clang too (this commit was done by testing with gcc).
2013-07-23 00:45:23 +02:00
wm4 78ebb3c6fa options: make legacy hacks for AFs/VFs more explicit
This means that AOs/VOs with no options set do not take the legacy
option parsing path, but instead report that they have no options.
2013-07-22 23:07:23 +02:00
wm4 1f5ffe7d30 video/out: remove options argument from preinit()
All VOs use proper option parsing now, and compatibility hacks are not
needed.
2013-07-22 22:52:42 +02:00
wm4 1df2ad7e03 Remove subopt-helper
Finally not used by anything anymore. Farewell.
2013-07-22 22:42:55 +02:00
wm4 0b160e1257 vf_scale: actually respect param and param2 suboptions
This was forgotten in commit b81f5e2.
2013-07-22 14:41:33 +02:00
wm4 b38e631ed2 vo_opengl: some option changes
Doing "mpv --vo=opengl:lscale=help" now lists possible scalers and
exits. The "backend" suboption behaves similar. Make the "stereo"
suboption a choice, instead of using magic integer values.
2013-07-22 02:14:15 +02:00
wm4 7bf1b9066c vo_direct3d: use new option API 2013-07-22 01:50:22 +02:00
wm4 1ff35c3a20 vo_opengl_old: use new option API 2013-07-22 01:50:22 +02:00
wm4 5e0ee41617 options: move --colorkey option to vo_xv 2013-07-22 01:50:22 +02:00
wm4 549ef68c62 vo_xv: use new option API 2013-07-22 01:50:16 +02:00
wm4 3fd7794d42 vo_direct3d: fix warning on MinGW
Commit 6ab2eeb attempted to fix it on Cygwin, but now it broke on MinGW
in turn. Don't think too hard about it and just remove the code. (vo.c
already prints the video rectangle anyway.)
2013-07-22 00:14:38 +02:00
wm4 3cdf4cf14d options: hide encoding AO/VO in help output
These can't be used manually. Encoding is enabled with -o instead, and
the encoding AO/VO is selected using internal mechanisms.
2013-07-21 23:27:31 +02:00
wm4 c1afd75142 options: use new code for parsing --vo
Nothing should change from user perspective.

mpv --vo=opengl:help now works.

Remove the vo_opengl inline help text. The new code can list option
names for you, but that's it. Refer to the manpage if you have trouble.
2013-07-21 23:27:31 +02:00
wm4 6629a95b92 options: use m_config for options instead of m_struct
For some reason, both m_config and m_struct are somewhat similar, except
that m_config is much more powerful. m_config is used for VOs and some
other things, so to unify them. We plan to kick out m_struct and use
m_config for everything. (Unfortunately, m_config is also a bit more
bloated, so this commit isn't all that great, but it will allow to
reduce the option parser mess somewhat.)

This commit also switches all video filters to use the option macros.
One reason is that m_struct and m_config, even though they both use
m_option, store the offsets of the option fields differently (sigh...),
meaning the options defined for either are incompatible. It's easier to
switch everything in one go.

This commit will allow using the -vf option parser for other things,
like VOs and AOs.
2013-07-21 23:27:31 +02:00
wm4 c50d5376f2 vf: remove unnecessary indirection 2013-07-21 23:27:30 +02:00
Stefano Pigozzi 644451f4d9 cocoa_common: fix regression in draggable state computation
Regression introduced in 8fb064de5. Prevented the OSC from working correctly.
2013-07-21 21:02:44 +02:00
Stefano Pigozzi 73cd78f8c5 cocoa_common: fix style 2013-07-21 21:02:43 +02:00
Stefano Pigozzi 7c1d707f45 cocoa_common: move tracking area setup to updateTrackingAreas
This makes the tracking area work when going in and out of fullscreen.
2013-07-21 21:02:43 +02:00
wm4 50a84eb32d x11: add key modifiers to mouse button events 2013-07-21 18:07:09 +02:00
James Ross-Gowan d784759bc0 w32_common: show the cursor in the window border
When the cursor was in the window border, it could be hidden but it
wouldn't appear again, since mpv doesn't process mouse input there.

The code used ShowCursor, which is a horrid stateful API designed for
mouseless Win16 systems that incremented or decremented a global counter
to keep track of how many applications needed to display a special
cursor (like a busy cursor.) Replace that with a simple flag, handle
WM_SETCURSOR and use SetCursor(NULL) to hide the mouse cursor, but only
when the mouse is in the client area. DefWindowProc will set the correct
cursor on the border as long as it isn't hidden with ShowCursor.

PowerPoint also uses SetCursor(NULL) to hide the cursor when showing a
presentation, so it's probably safe.

See http://blogs.msdn.com/b/oldnewthing/archive/2009/12/17/9937972.aspx
2013-07-21 18:05:22 +02:00
Stefano Pigozzi 5f265d5930 cocoa_common: handle keyboard modifiers for mouse events 2013-07-21 10:49:27 +02:00
Alexander Preisinger ccc4512e1d Merge remote-tracking branch 'michaelforney/master' 2013-07-20 17:21:51 +02:00
Stefano Pigozzi 7088fe3fec cocoa_common: make the fullscreen transition only when necessary
This makes the cocoa backend follow more closely the new fullscreen semantics
added in c4b08a9a.
2013-07-20 12:08:14 +02:00
Stefano Pigozzi 8fb064de58 cocoa_common: use a tracking area to handle mouse events
This change which also flipse the coordinate system of the view, greatly
simplifies the mouse event handling code.

There are still some uglities mostly related to the cursor visibility
code. For instance the core doesn't show the cursor when it receives a mouse
leave event.
2013-07-20 11:45:32 +02:00
Stefano Pigozzi 2765153214 cocoa_common: fix typo in comment
Surely it's copy pasta's fault.
2013-07-20 11:44:06 +02:00
Stefano Pigozzi 20c0231f02 cocoa_common: implement MP_MOUSE_LEAVE notifications
This is needed for the OSC. At the moment I'm sending a notification for any
mouse movement outside of the video surface. This might be overkill.
2013-07-20 11:44:06 +02:00
Stefano Pigozzi 891e092669 cocoa_common: implement conditional video dragging
This was more roundabout than expected, since it looks like the framework
caches isMovabileByWindowBackground so in mpv's case it's needed to set it
with setMovableByWindowBackground.
2013-07-20 11:44:06 +02:00
Diogo Franco (Kovensky) 6ab2eebe5f direct3d: Fixes format string that assumed sizeof(LONG) == sizeof(long) 2013-07-20 02:20:26 +02:00
Michael Forney 906315f075 wayland: Fallback to any GL version if 3.0 is not supported
This fixes playback on Wayland with older GPUs.
2013-07-19 04:30:23 -07:00
Alexander Preisinger 3dc063a330 wayland: use a unified struct for the state
This commit removes the pointer to the single different structures for input
and window and puts them as anonymous structures inside the wayland_state
structure.

This has the disadvantage of passing the substructure to the listeners, but the
advantage is that we don't have to allocate them and check for NULL pointers.
This makes it more reliable and easier to follow.
2013-07-18 17:52:56 +02:00
Alexander Preisinger c5b76714a0 wayland: don't resize in gl_wayland.c
The vo_wayland_fullscreen handles resizing for the video, because the video
could still be in fullscreen mode and resizing it in gl_wayland could make it
grow or shrink.
2013-07-18 14:17:30 +02:00
wm4 c4b08a9a11 video: remove fullscreen flags chaos
There was a MPOpts fullscreen field, a mp_vo_opts.fs field, and
VOFLAG_FULLSCREEN. Remove all these and introduce a
mp_vo_opts.fullscreen flag instead.

When VOs receive VOCTRL_FULLSCREEN, they are supposed to set the
current fullscreen mode to the state in mp_vo_opts.fullscreen. They
also should do this implicitly on config().

VOs which are capable of doing so can update the mp_vo_opts.fullscreen
if the actual fullscreen mode changes (e.g. if the user uses the
window manager controls). If fullscreen mode switching fails, they
can also set mp_vo_opts.fullscreen to the actual state.

Note that the X11 backend does almost none of this, and it has a
private fs flag to store the fullscreen flag, instead of getting it
from the WM. (Possibly because it has to deal with broken WMs.)

The fullscreen option has to be checked on config() to deal with
the -fs option, especially with something like:

   mpv --fs file1.mkv --{ --no-fs file2.mkv --}

(It should start in fullscreen mode, but go to windowed mode when
playing file2.mkv.)

Wayland changes by: Alexander Preisinger <alexander.preisinger@gmail.com>
Cocoa changes by: Stefano Pigozzi <stefano.pigozzi@gmail.com>
2013-07-18 14:07:21 +02:00
wm4 05cf512dc5 vo: remove aspdat.asp member
This was bad, because it was the only aspdat member updated by
vo_get_src_dst_rects() instead of vo_reconfig(). Now it isn't
accessed anymore, so remove it.
2013-07-18 13:57:28 +02:00