Commit Graph

186 Commits

Author SHA1 Message Date
wm4 b424dacbe5 vo_opengl_old: use generic aspect ratio code
Make sure scaled_osd still works. Although this is a completely
worthless feature for a deprecated VO.
2013-03-17 18:51:32 +01:00
wm4 b1b982941d vo_x11: use generic aspect ratio code, refactor
Instead of manually calculating aspect ratio etc., use
vo_get_src_dst_rects(). This has the advantage that we can drop some
special cases in aspect.c later.

Simplify the code, and move resizing the X images from draw_image() to a
new resize() function.

Do some other simplifications. The gXErrorFlag check was actually dead
code, even in mplayer-svn. Special-casing on WinID is not needed
anymore (we created an embedded window, and its size is updated by
x11_common.c).
2013-03-17 18:46:03 +01:00
Stefano Pigozzi ad000fb916 cocoa_common: fix regression when changing videos in fullscreen
I introuced this regression in 8fc0b618d5. The backend would go into
incosistent state caused by calling `vo_cocoa_fullscreen` where it wasn't
needed.

Fixes #44
2013-03-15 22:48:57 +01:00
Alexander Preisinger f7ad81737b wayland: remove asserts from egl_create_context
Instead of assert return false on most check.
Removes the redundant second inclusion of the assert header.
2013-03-13 20:01:12 +01:00
Alexander Preisinger db6325853a wayland: simplify egl_create_window
Removes the local ret because it was only in an assert statement and also
removes the window size assignments, because they are already done in
config_wnidow_wayland.
2013-03-13 19:47:11 +01:00
Alexander Preisinger ba43d98ac2 wayland: use the cursor_autohide_delay option
In the previous implemention the backend always assumed 1 second
instead of honoring the cursor_autohide_delay option
2013-03-11 18:31:09 +01:00
Alexander Preisinger f2debeca66 wayland: move window by grabing it
Because the are no server-side-decorations in the available wayland compositors
use grabbing the surface to move it.
2013-03-11 18:24:12 +01:00
wm4 b1be668b9d vo_opengl: insert a magical glFlush call
Helps a little bit with stuttering with pans and "heavy" subtitles
covering the screen.
2013-03-11 00:44:27 +01:00
Stefano Pigozzi 89aae59e89 cocoa_common: fix window position when bigger than display
Fix a regression introduced in commit 979ce46c64 causing a window to take up
more space than what the display allows.

Add keepCentered:YES, so that the video area is always clipped to the current
visible frame (even when using scale).

Fixes #38.
2013-03-10 17:27:43 +01:00
Rudolf Polzer fe4213b164 vo_sdl: we don't want to minize the window when losing focus
Because: this makes multi-monitor use entirely useless (as soon as
pointer leaves left screen, mpv gets auto minimized).
2013-03-06 18:10:20 +01:00
wm4 a1a9dc9c85 options: remove --no-vsync
Latest nvidia drivers ignore the application setting, so this switch
makes even less sense than before. It's still possible to control this
with VO specific suboptions.
2013-03-06 00:24:34 +01:00
wm4 3a0d647e0f w32_common: fix compilation
Broken by commit 1198c03.
2013-03-05 17:46:17 +01:00
Alexander Preisinger 1198c031e4 vo: Separate vo options from MPOpts
Separate the video output options from the big MPOpts structure and also only
pass the new mp_vo_opts structure to the vo backend.

Move video_driver_list into mp_vo_opts
2013-03-04 23:32:47 +01:00
Stefano Pigozzi 39824c071e cocoa_common: fix crash 2013-03-04 23:23:12 +01:00
Stefano Pigozzi a453a0a57b cocoa_common: fix compilation
7686cd7f broke some stuff
2013-03-04 22:51:43 +01:00
wm4 7889e38f21 Remove vo_fps global variable
This is needed by the encode stuff for some reason, so we have to
explicitly pass it. Functionality shouldn't change.
2013-03-04 22:21:57 +01:00
Alexander Preisinger 7bab84050f wayland: remove unnecessary function pointers
Remove the usage of getdladdr as it only adds to code complexity
2013-03-04 18:59:12 +01:00
Alexander Preisinger 7686cd7f04 vo: remove and cleanup globals
Removes almost every global variabel in vo.h and puts them in a special struct
in MPOpts for video output related options.

Also we completly remove the options/globals pts and refresh rate because
they were unused.
2013-03-04 17:40:21 +01:00
Stefano Pigozzi 8fc0b618d5 cocoa_common: make windows appear again
Commit 9efe32120 stops recreating the hidden window used for OpenGL's
extensions autodetection. The `cocoa_common` code assumed the hidden flag could
only come when creating a window which is now not true anymore.

Move some code around so that hidden, fullscreen and window position are
respected on subsequent calls of config.
2013-03-03 21:52:58 +01:00
wm4 979ce46c64 gl_common: get rid of symbol redefinition warnings with recent Mesa
Apparently newer Mesa versions changed their <GL/glx.h> header, and
unconditionally define GLX_CONTEXT_MAJOR_VERSION_ARB and others. This
clashed with gl_header_fixes.h, a header which quarantines bad hacks
to make compilation possible on systems with outdated GL headers.
Specifically, our header was included before glx.h, so the hacks were
always active, and somehow Mesa's glx.h used to deal with this by not
redefining existing identifiers.

Fix the gl_header_fixes.h logic so the hacks are checked after including
glx.h.
2013-03-03 15:36:56 +01:00
wm4 ca893689fe x11_common: fix --cursor-autohide when paused
When paused, --cursor-autohide worked with a precision of 500ms, which
is the main loop's default sleep time when paused. Cursor hiding is
polled in x11_common, and the main loop never called the X11 code at
the right time. Fix this by allowing the VO to set a time when it
should be called next.
2013-03-03 15:36:56 +01:00
wm4 9efe32120b vo_opengl: don't destroy VOFLAG_HIDDEN window
This was done so because the X11 code had a hard to track down issue
with some window managers, and caused the VO window to be placed
incorrectly. This was fixed in the previous commit. Consequently, we can
remove this bad hack.
2013-03-03 15:36:56 +01:00
wm4 ba35335939 x11_common: fix window mapping, refactor window creation/resize handling
vo_opengl creates an invisible window with VOFLAG_HIDDEN in order to
test whether the OpenGL context is useable. The visible window is
created at a later point. This has been broken forever (in vo_gl,
now called vo_opengl_old, it could be avoided by disabling auto-
detection explicitly using the "yuv" sub-option). Avoiding
VOFLAG_HIDDEN only mitigates the issue, and a related bug can still
happen with some window managers (see below).

As a hack, code was added to vo_gl to destroy the (hidden) window so
that all state was destroyed. Later, more hacks were added to deal with
some caveats that came with recreating the window, such as probing for
the context up to 4 times.

Attempt to fix the problem properly. There were two problems: first,
the window was not resized to video size before mapping. This was the
main cause for the placement issue, e.g. mapping the window as 320x200,
and then resizing it. Second, mpv tried to force the window position
with XSetWMNormalHints and PPosition with values it just read with
XGetGeometry. This messes up the window manager's default placement.
It seems to be a race condition, and behavior is different across
various WMs too: with IceWM, the window manager's placement is usually
preferred, and with Fluxbox, mpv's position is preferred. mpv's default
position is centering the window on the screen, which is much nicer for
video in general than typical WM default placement, so it's possible
that this bug was perceived as a feature. (Users who want this have to
use --geometry="50%:50%", doing this by default is probably not safe
with all WMs.)

Since the old code was hard to follow and full of issues, it's easier
to redo it. Move general window creation stuff out of the
vo_x11_config_vo_window function, and move the resize logic into it.

This has been tested on IcwWM, Fluxbox, awesome, Unity/Compiz.
2013-03-03 15:36:27 +01:00
wm4 1b09f46338 x11_common: use private variables for window state
Store the window state (position and size) in vo_x11_state, instead of
in vo->dx/dy/dwidth/dheight. The VO variables are overwritten by vo.c on
every vo_config() call, which is extremely not helpful.

Now vo->dx/dy are mostly unused (except for passing the position forced
by the --geometry option), and vo->dwidth/dheight are set for the VO,
and otherwise read for resize detection only.

In the long term, the way vo_config() handles the --geometry option
should be changed, and vo->dx/dy should be removed.

Remove some useless stuff: VO_EVENT_MOVE and VO_EVENT_KEYPRESS were
generated, but unused. Wayland changes by Alexander Preisinger.
2013-03-03 14:19:57 +01:00
wm4 152a2024cf video/out: remove VO_EVENT_REINIT
It was once used for vo_sdl (the old one based on SDL 1.2), since SDL
apparently lost the GL state when switching to fullscreen. The new
vo_sdl (using SDL 1.3) doesn't use or need this. It's dead code, so
get rid of it.
2013-03-03 14:19:57 +01:00
wm4 0c07e82136 w32_common: remove unused variable
The depth was printed in verbose mode. Completely useless.
2013-03-03 14:19:53 +01:00
wm4 c9088fff86 m_option: don't define OPT_BASE_STRUCT by default
OPT_BASE_STRUCT defines which struct the OPT_ macros (like OPT_INT etc.)
reference implicitly, since these macros take struct member names but no
struct type. Normally, only cfg-mplayer.h should need this, and other
places shouldn't be bothered with having to #undef it.

(Some files, like demux_lavf.c, still store their options in MPOpts. In
the long term, this should be removed, and handled like e.g. with VO
suboptions instead.)
2013-03-01 11:27:59 +01:00
wm4 fdc1560a0e core: move X11 specific code to x11_common.c
Nothing changes, because vo_check_events() is called at the same place
anyway.
2013-03-01 11:17:56 +01:00
wm4 d511ef79a0 core: simplify OSD capability handling, remove VFCAP_OSD
VFCAP_OSD was used to determine at runtime whether the VO supports OSD
rendering. This was mostly unused. vo_direct3d had an option to disable
OSD (was supposed to allow to force auto-insertion of vf_ass, but we
removed that anyway). vo_opengl_old could disable OSD rendering when a
very old OpenGL version was detected, and had an option to explicitly
disable it as well.

Remove VFCAP_OSD from everything (and some associated logic). Now the
vo_driver.draw_osd callback can be set to NULL to indicate missing OSD
support (important so that vo_null etc. don't single-step on OSD
redraw), and if OSD support depends on runtime support, the VO's
draw_osd should just do nothing if OSD is not available.

Also, do not access vo->want_redraw directly. Change the want_redraw
reset logic for this purpose, too. (Probably unneeded, vo_flip_page
resets it already.)
2013-03-01 11:16:01 +01:00
wm4 6b3d510165 vo_sdl, vo_xv: remove redundant/useless VOCTRL_PAUSE usage 2013-03-01 11:15:44 +01:00
Alexander Preisinger bf9b9c3bd0 wayland: add wayland support
All wayland only specific routines are placed in wayland_common.
This makes it easier to write other video outputs.

The EGL specific parts, as well as opengl context creation, are in gl_common.

This backend works for:
    * opengl-old
    * opengl
    * opengl-hq

To use it just specify the opengl backend
    --vo=opengl:backend=wayland
or disable the x11 build.

Don't forget to set EGL_PLATFORM to wayland.

Co-Author: Scott Moreau
(Sorry I lost the old commit history due to the file structure changes)
2013-02-28 20:01:33 +01:00
wm4 70346d3be6 video/out: remove video mode switching (--vm)
This allowed making the player switch the monitor video mode when
creating the video window. This was a questionable feature, and with
today's LCD screens certainly not useful anymore. Switching to a random
video mode (going by video width/height) doesn't sound too useful
either.

I'm not sure about the win32 implementation, but the X part had several
bugs. Even in mplayer-svn (where x11_common.c hasn't been receiving any
larger changes for a long time), this code is buggy and doesn't do the
right thing anyway. (And what the hell _did_ it do when using multiple
physical monitors?)

If you really want this, write a shell script that calls xrandr before
and after calling mpv.

vo_sdl still can do mode switching, because SDL has native support for
it, and using it is trivial. Add a new sub-option for this.
2013-02-26 02:01:48 +01:00
wm4 b23dce6d7c x11_common: always create a window, even with --wid
The --wid switch (for embedding the player into other applications)
didn't create a new window, and instead tried to use the window that
was passed via --wid directly. This made the code more complex, caused
strange X errors (mpv and host application fighting for exclusive X
resources), and actually could cause issues if the --wid window wasn't
created with the X Visual needed for OpenGL.

Always create a window instead. This makes it always possible to embed
the player into foreign windows. --geometry doesn't work anymore - the
controlling application should always create a new window to place the
player inside it, and can control the video window by moving and
resizing this window.

w32_common.c actually did this right, and always creates a new window.
2013-02-26 02:01:48 +01:00
wm4 423c0b13c4 video/out: rename create_window to config_window
create_window is really bad naming, because this function can be called
multiple times, while the name implies that it always creates a new
window. At least the name config_window is not actively misleading.
2013-02-26 02:01:48 +01:00
wm4 c61f1ff61b gl_common: simplify window/context creation
Allow the backend code to create a GL context on best effort basis,
instead of having to implement separate functions for each variation.
This means there's only a single create_window callback now. Also,
getFunctions() doesn't have the gl3 parameter anymore, which was
confusing and hard to explain.

create_window() tries to create a GL context of any version. The field
MPGLContext.requested_gl_version is taken as a hint whether a GL3 or a
legacy context is preferred. (This should be easy on all platforms.)

The cocoa part always assumes that GL 3 is always available on
OSX 10.7.0 and higher, and miserably fails if it's not. One could try
to put more effort into probing the context, but apparently this
situation never happens, so don't bother. (And even if, mpv should be
able to fall back to vo_corevideo.)

The X11 part doesn't change much, but moving these functions around
makes the diff bigger.

Note about some corner cases:

This doesn't handle CONTEXT_FORWARD_COMPATIBLE_BIT_ARB on OpenGL 3.0
correctly. This was the one thing getFunctions() actually needed the
gl3 parameter, and we just make sure we never use forward compatible
contexts on 3.0. It should work with any version above (e.g. 3.1, 3.2
and 3.3 should be fine). This is because the GL_ARB_compatibility
extension is specified for 3.1 and up only. There doesn't seem to be
any way to detect presence of legacy GL on 3.0 with a forward
compatible context. As a counter measure, remove the FORWARD_COMPATIBLE
flags from the win32 code. Maybe this will go wrong. (Should this
happen, the flag has the be added back, and the win32 will have to
explicitly check for GL 3.0 and add "GL_ARB_compatibility" to the extra
extension string.)

Note about GLX:

Probing GL versions by trying to create a context on an existing window
was (probably) not always possible. Old code used GLX 1.2 to create
legacy contexts, and it required code different from GLX 1.3 even before
creation of the X window (the problem was selections of the X Visual).
That's why there were two functions for window creation (create_window_old
and create_window_gl3). However, the legacy context creation code was
updated to GLX 1.3 in commit b3b20cc, so having different functions for
window creation is not needed anymore.
2013-02-26 02:00:53 +01:00
wm4 05f76c63d5 gl_common: remove compatibility aliases for backend sub-option
The backend sub-option for vo_opengl and vo_opengl-old accepted numeric
values (like -1, 0, ...) for compatibility with MPlayer. This was added
in mplayer2 times, and is not important anymore.
2013-02-26 01:55:52 +01:00
wm4 af54ff826b Remove --rootwin option and rootwin property
You can just use --wid=0 if you really want this.

This only worked/works for X11, and even then it might interact badly
with most desktop environments. All the option did was setting --wid to
0, and the property did nothing.
2013-02-24 17:00:52 +01:00
wm4 bab429870e vo_caca: remove OSD support
Recent changes to the OSD code made vo_caca crash when showing OSD.
Since this is a joke VO (== I'd rather not waste my time with it),
remove the OSD support. It wasn't that great anyway.
2013-02-24 16:15:50 +01:00
wm4 e013fbd34e vo_direct3d: always clear window before drawing video
This fixes the issue that black borders (e.g. on fullscreen) are not
redrawn, even if OSD rendering changes these areas.

In theory, the code could try some clever things to determine whether
clearing the window is really necessary, but that's probably not worth
the trouble and won't bring any significant performance gain, or might
even make things slower (because the GPU can't discard the old
contents).

Also fix redrawing when changing panscan with OSD disabled.
2013-02-24 15:40:48 +01:00
wm4 9b7fb867f7 options: drop --opt:subopt option names
For all suboptions, "flat" options were available by separating the
parent option and the sub option with ":", e.g. "--rawvideo:w=123". Drop
this syntax and use "-" as separator. This means even suboptions are
available as normal options now, e.g. "--rawvideo-w=123". The old syntax
doesn't work anymore.

Note that this is completely separate from actual suboptions. For
example, "-rawvideo w=123:h=123" still works. (Not that this syntax is
worth supporting, but it's needed anyway, for for other things like vf
and vo suboptions.)

As a consequence of this change, we also have to add new "no-" prefixed
options for flag suboptions, so that "--no-input-default-bindings"
works. ("--input-no-default-bindings" also works as a consequence of
allowing "-input no-default-bindings" - they are handled by the same
underlying option.)

For --input, always use the full syntax in the manpage. There exist
suboptions other than --input (like --tv, --rawvideo, etc.), but since
they might be handled differently in the future, don't touch these yet.

M_OPT_PREFIXED becomes the default, so remove it. As a minor unrelated
cleanup, get rid of M_OPT_MERGE too and use the OPT_SUBSTRUCT() macro in
some places.

Unrelated: remove the duplicated --tv:buffersize option, fix a typo in
changes.rst.
2013-02-23 00:07:11 +01:00
Stefano Pigozzi e540e5d4da core: add fs-screen option for fullscreen display selection
`--fs-screen` allows to decide what display to go fullscreen into. The
semantics of `--screen` changed and now it is only used to select the windowed
display when starting the application.

This is useful for people using mpv with an external TV. They will start
windowed on their laptop's screen and switch to fullscreen on the TV.

@wm4 worked on the x11 and w32 parts of the code. All is squashed in one
commit for history clarity.
2013-02-21 22:23:08 +01:00
Stefano Pigozzi 41c1749f46 core: move `xineramascreen` to `MPOpts` as `vo_screen_id`
This is a small cleanup in preparation for the next commit.
2013-02-21 22:23:08 +01:00
wm4 08952f23dd x11_common: uncrustify
Also some other cosmetic changes. And reformat the two remaining doxygen
comments.

Removing MSGLEN in x11_errorhandler() is technically not just a cosmetic
change, but the result is the same anyway.
2013-02-21 22:23:08 +01:00
Stefano Pigozzi 145c965135 cocoa_common: fix crash with dead key input and simplify related code
Fixes #29. When a user used dead input keys (like the accent key), `mpv`
crashed because the code tried to access the 0 element of a characters array
(which was empty).

While I was closing this bug, I refactored some related conditionals to
make the code more readable.
2013-02-19 21:21:50 +01:00
wm4 e4d52330af vo_xv: fix green border on the right 2013-02-14 20:41:09 +01:00
wm4 75e6584ab3 Prefix keycode defines with MP_
Do this to reduce conflicts with <linux/input.h>, which contains some
conflicting defines.

This changes the meaning of MP_KEY_DOWN:

  KEY_DOWN is renamed to MP_KEY_DOWN (cursor down key)
  MP_KEY_DOWN is renamed to MP_KEY_STATE_DOWN (modifier for key down state)
2013-02-12 10:27:00 +01:00
wm4 88d843f909 cleanup: replace OPT_FLAG_ON and OPT_MAKE_FLAGS with OPT_FLAG
OPT_MAKE_FLAGS() used to emit two options (one with "no" prefixed),
but that has been long removed by special casing flag options in the
option parser. OPT_FLAG_ON() used to imply that there's no "no-"
prefixed option, but this hasn't been the case for a while either.
(Conceptually, it has been replaced by OPT_FLAG_STORE().)

Remove OPT_FLAG_OFF, which was unused.
2013-02-09 00:21:17 +01:00
wm4 830560979c options: change handling of "no-" options
Normally, all flag options can be negated by prepending a "no-", for
example "--no-opt" becomes "--opt=no". Some flag options can't actually
be negated, so add a CONF_TYPE_STORE option type to disallow the "no-"
fallback.

Do the same for choice options. Remove the explicit "no-" prefixed
options, add "no" as choice.

Move the handling of automatic "no-" options from parser-mpcmd.c to
m_config.c, and use it in m_config_set_option/m_config_parse_option.
This makes these options available in the config file. It also
simplifies sub-option parsing, because it doesn't need to handle "no-"
anymore.
2013-02-09 00:21:16 +01:00
wm4 ae070a6f1e audio/out, video/out: hide encoding VO/AO
mpv -ao help and mpv -vo help shouldn't show the encoding outputs (named
"lavc" on both cases). Also make it impossible to select these manually
when not encoding.
2013-02-06 23:04:18 +01:00
wm4 4628ea3c46 video/out: change autoprobe order
Basically, move vo_opengl above the other VOs (except vo_vdpau). This
changes preferences on Windows and Linux.

Move vo_opengl_old further down and make it the last fallback (before
vo_x11).

vo_caca is crap (no pun intended), and should never be autoprobed.
2013-02-06 23:04:18 +01:00
Stefano Pigozzi 37c83abe61 cocoa_common: fix `--ontop` behaviour when windowed
Apply setLevel hacks for fullscreen switching with ontop active only in
fullscreen. This keeps the window correctly on top even when losing focus.

Fixes #21

I also reverted NSScreenSaverWindowLevel to NSNormalWindowLevel + 1, so that
the cmd-tab UI is visible
2013-02-03 14:04:13 +01:00
Stefano Pigozzi 530036e5b3 cocoa_common: fix focus with --ontop and space switching
The main problem this commit addresses is when you switched spaced back and
forth with `--ontop` active the video window didn't recive focus again.

Turns out that setting a normal window level just before conceding focus to
other apps / spaces fixes the problem. I think Cocoa is misbehaving here, and
should probably file a radar.

I found 3 related improvements while fixing this:
 *  fullscreen_window_level is a dead body from an older implementation.
 *  Use NSScreenSaverWindowLevel for ontop. This should be a really high window
    level. Definitely higher than NSNormalWindowLevel + 1.
 *  The window level was set correctly only when out of fullscreen.
2013-02-03 11:39:30 +01:00
Stefano Pigozzi ce29e58fe3 cocoa_common: make the resize window menu items use video size
Make the window resizing menu items calculate the new window size based on the
video size and not the current window size.

This only makes a difference when using `--autofit`.
2013-02-03 10:18:55 +01:00
Stefano Pigozzi 68fa3c49db cocoa_events: remove this functionality
This functionality looked smart but created problems with some kinds of
multi touch events. Moreover some events coming from the windows server – like
hovering a corner for window resize – didn't cause the player to wake up
immediately.

The "correct" non hacky way to implement async event polling with cocoa would
be having the vanilla cocoa event loop driving the player and setting up mpv's
terminal FDs as event sources for the cocoa event loop.

Fixes #20
2013-02-02 14:36:05 +01:00
Stefano Pigozzi a3322cb171 osx_common: cache OSX version number
This commit makes `is_osx_version_at_least` cache the result of reading
`/System/Library/CoreServices/SystemVersion.plist`. Since that is a file
read operation it was bad to use this function frequently (i.e.: when
processing user events).

Remove `is_lion_or_above` (introduced in c9396c0a) as that was a more
specialized wrapper which had the only advantage of adding it's own cache.
2013-01-27 18:38:25 +01:00
wm4 fddba2d529 vo_x11: fix redrawing on expose events
This part wasn't converted when changing to the new OSD redrawing way.
2013-01-27 13:32:39 +01:00
wm4 df80cd379a x11: simplify handling of X Visuals and Colormaps in VOs
Don't force VOs to pick an arbitrary default Visual and Colormap. They
still can override them if needed. This simplifies the X11 VO interface.

Always create a Colormap for simplicity. Using CopyFromParent fails if
the selected visual is not the same of that of the parent window, which
happens for me with vo_opengl.

vo_vdpau and vo_xv explicitly set CWBorderPixel, do that in x11_common
instead (it was already done for native windows, but not for slave mode
windows).

What gl_common did was incorrect in theory: freeing a colormap while a
window uses it will change the colormap of the window to "None", and
the color mapping for such windows is "undefined".
2013-01-27 13:32:27 +01:00
wm4 75164a0e0a x11: fix some obvious video mode switching bugs
The original video mode wasn't reliably restored, so just store the
mode separately.

For some reason, window decorations got into the picture, possibly due
to an incorrect initial window position or something like this.
Normally, the window is positioned and sized such that it covers the
screen entirely, even though the window still has decorations and is
not in fullscreen mode (fullscreen wouldn't be correct, because the
virtual desktop size is not screen size). Hack-fix by forcing window
decorations off when VM-switching.

All in all, VM switching is still buggy and useless.
2013-01-27 13:30:54 +01:00
wm4 0535a14505 x11: reduce VO mode switching code duplication
Some parts for initiating mode switches were duplicated in every VO
supporting X11 (except vo_opengl/gl_common, which didn't support mode
switching). Move this to x11_common.c.

Note that this might be slightly risky: is it really guaranteed that no
VO needed to do "special" setup that depends on X parameters changing
after a mode switch, such as bit depth, visuals etc.? From what I can
see, this shouldn't be the case (X probably can't even change depth on
the fly). Even if this should be a one-way road, VM switching is in
general very useless, and its implementation buggy, so it can just be
removed should unfixable problems arise.
2013-01-27 13:30:54 +01:00
wm4 e4943165c1 x11_common: do not set custom error handler when calling XSelectInput
Do this because we want to remove the global variables required with the
old code. In particular, there doesn't seem any way to set a secure user
data pointer with xlib.

XSelectInput() causes a BadAccess error when some of the requested event
flags are reserved (for exclusive flags like ButtonPress). The custom
error handler caught this and set a global variable, so that the code
could retry the XSelectInput() call without the conflicting flags. Use a
different approach that doesn't need a custom error handler. (Although
we still assume that the error handler doesn't terminate the program.)
2013-01-27 13:30:54 +01:00
wm4 a243acb1de x11: cleanup, refactor
Move things that are used by vo_xv only into vo_xv, same for vo_x11.

Rename some functions exported by x11_common, like vo_init to
vo_x11_common. Make functions not used outsode of x11_common.c private
to that file. Eliminate all global variables defined by x11_common
(except error handler and colormap stuff).

There shouldn't be any functional changes, and only code is moved
around. There are some minor simplifications in the X11 init code, as
we completely remove the ability to initialize X11 and X11+VO
separately (see commit b4d9647 "mplayer: do not create X11 state in player frontend"),
and the respective functions are conflated into vo_x11_init() and
vo_x11_uninit().
2013-01-27 13:30:53 +01:00
Wessel Dankers d84b572b8c vo_opengl: always dither
Dithering was disabled if the input bit depth was not larger than the
output bit depth of the screen framebuffer. But since scaling, RGB
conversion, and other filters change the number of significant bits
anyway, dithering could still benefit image quality even in these
cases. Always do dithering, unless dithering is completely disabled.

The original intention of this mechanism was not to change the image
needlessly when playing video that matches the native bit depth of the
screen.
2013-01-27 13:27:32 +01:00
wm4 d275e21d6a vo_xv: always try to use native bit depth
Exactly the same issue as with the previous commit. Just like the vdpau
code, this was apparently copy-pasted from the vo_x11 code, even though
it doesn't make much sense.
2013-01-23 16:20:06 +01:00
wm4 d49b58e78f vo_vdpau: always try to native bit depth (makes 30 bit work)
Using vdpau on an X server configured to a bit depth of 30 (10 bit per
component) failed finding a visual. The cause was a hack that tried to
normalize the bit depth to 24 if it was not a known depth. It's unknown
why/if this is needed, but the following things speak against it:
- it prevented unusual bit depths like 30 bit from working
- it wasn't needed with normal bit depth like 24 bit
- it's probably copy-pasted from vo_x11 (where this code possibly makes
  sense, unlike in vo_vdpau)

Just remove this code and look for a visual with native depth.
2013-01-23 15:48:08 +01:00
wm4 704c0cb2db video: remove -x/-y/-xy options
-x/-y were rather useless and obscure. The only use I can see is
forcing a specific aspect ratio without having to calculate the aspect
ratio float value (although --aspect takes values of the form w:h).
This can be also done with --geometry and --no-keepaspect. There was
also a comment that -x/-y is useful for -vm, although I don't see how
this is useful as it still messes up aspect ratio.

-xy is mostly obsolete. It does two things: a) set the window width to
a pixel value, b) scale the window size by a factor. a) is already done
by --autofit (--autofit=num does exactly the same thing as --xy=num, if
num >= 8). b) is not all that useful, so we just drop that
functionality.
2013-01-23 10:56:47 +01:00
wm4 7885fce7ea video: add --autofit and --autofit-larger options
--autofit=WxH sets the window size to a maximum width and/or height,
without changing the window's aspect ratio.

--autofit-larger=WxH does the same, but only if the video size is
actually larger than the window size that would result when using
the --autofit=WxH option with the same arguments.
2013-01-23 10:56:36 +01:00
wm4 4c56baba40 options: move -geometry parsing to m_option.c
This also means the option is verified on program start, not when the VO
is created. The actual code becomes a bit more complex, because the
screen width/height is not available at program start.

The actual parsing code is still the same, with its unusual sscanf()
usage.
2013-01-23 10:56:11 +01:00
wm4 f2dcdca0c2 video: move handling of -x/-y/-xy options to VO
Now the calculations of the final display size are done after the filter
chain. This makes the difference between display aspect ratio and window
size a bit more clear, especially in the -xy case.

With an empty filter chain, the behavior of the options should be the
same, except that they don't affect vo_image and vo_lavc anymore.
2013-01-23 10:55:00 +01:00
Mad Fish c9396c0aab cocoa_common: improved trackpad scrolling 2013-01-20 23:43:21 +01:00
Mad Fish ec0bd69619 cocoa_common: handle all pending events instead of just one 2013-01-20 16:53:51 +01:00
Stefano Pigozzi 89a49ffd74 osxbundle: cocoa_common: change playlist on fileopen events
When opening new files in Finder when `mpv` is running from an application
bundle, the new files will now replace the current playlist.

Fixes #14
2013-01-16 22:27:04 +01:00
wm4 efcd479e7e vo_opengl_old: add missing include statement
<ctype.h> is needed at least for isalnum(). Most time this worked,
because some ffmpeg or Libav versions recursively include this header
from libavutil/common.h. Fix it so it always works.
2013-01-15 21:16:10 +01:00
Rudolf Polzer 32d2e958a8 vo_sdl: I think the XVidmode hack is no longer needed
I can no longer reproduce the XVidmode related hang.
2013-01-15 12:11:59 +01:00
Rudolf Polzer 708fb47bcb vo_sdl: request "desktop" fullscreen mode if -vm is not used
This is a lot cleaner than our current workaround that first queries the
desktop resolution.
2013-01-15 11:38:04 +01:00
Stefano Pigozzi 645923f634 vo_corevideo: make compile with recent changes
Width and height were removed from mp_image. Use w and h instead.
2013-01-15 01:00:07 +01:00
wm4 f0a08a9fdf gl_common: move things used by vo_opengl_old.c only to vo_opengl_old.c
Having this in gl_common is confusing.
2013-01-13 23:30:13 +01:00
Rudolf Polzer aaa27ead86 vo_x11: use two buffers like Xv 2013-01-13 22:36:42 +01:00
Rudolf Polzer 4044754d24 vo_x11, vo_xv: XShmCompletion event support
This fixes OSD flicker with vo_xv at high frame rates.
2013-01-13 22:36:42 +01:00
wm4 9f27ebbe63 vo_direct3d: remove 2ch hack for 10 bit playback
This was an awkward hack that attempted to avoid the use of 16 bit
textures, while still allowing rendering 10-16 bit YUV formats. The
idea was that even if the hardware doesn't support 16 bit textures,
an A8L8 textures could be used to convert 10 bit (etc.) to 8 bit in
the shader, instead of doing this on the CPU.

This was an experiment, disabled by default, and was (probably) rarely
used. I've never heard of this being used successfully. Remove it.
2013-01-13 20:04:14 +01:00
wm4 dd89c542e3 vo_sdl: avoid copying just for taking screenshots
Use reference counting instead.
2013-01-13 20:04:14 +01:00
wm4 1800761a65 mp_image: remove mp_image.bpp
This field contained the "average" bit depth per pixel. It serves no
purpose anymore. Remove it.

Only vo_opengl_old still uses this in order to allocate a buffer that is
shared between all planes.
2013-01-13 20:04:13 +01:00
wm4 ded932dbd4 vo_image: render subs
This makes it behave like vo_lavc.

Unfortunately, the code for setting up the OSD dimensions (mp_osd_res)
is copied from vo_lavc, but it doesn't look like something that should
be factored out.
2013-01-13 20:04:12 +01:00
wm4 5e8b3e74ec vo_xv: fix OSD redrawing flicker
redraw_frame() copied the image into the currently visible buffer. This
resulted in flicker when doing heavy OSD redrawing (like changing the
subtitle size to something absurdly large).

Use the same logic as draw_image instead.
2013-01-13 20:04:12 +01:00
wm4 3d6d549dac vo_xv, vo_x11: simplify OSD redrawing
In order to support OSD redrawing for vo_xv and vo_x11, draw_bmp.c
included an awkward "backup" mechanism to copy and restore image
regions that have been changed by OSD/subtitles.

Replace this by a much simpler mechanism: keep a reference to the
original image, and use that to restore the Xv/X framebuffers.

In the worst case, this may increase cache pressure and memory usage,
even if no OSD or subtitles are rendered. In practice, it seems to be
always faster.
2013-01-13 20:04:12 +01:00
wm4 1c65428d6f sub: do not copy the target image if there is no OSD/subs
It's not easy to tell whether the OSD/subs are empty, or if something is
drawn. In general you have to use osd_draw() with a custom callback. If
nothing is visible, the callback is never invoked. (The actual reason
why this is so "hard" is the implementation of osd_libass.c, which
doesn't allow separating rendering and drawing of OSD elements, because
all OSD elements share the same ASS_Renderer.)

To simplify avoiding copies, make osd_draw_on_image() instead of the
caller use mp_image_make_writeable(). Introduce osd_draw_on_image_p(),
which works like osd_draw_on_image(), but gets the new image allocation
from an image pool. This is supposed to be an optimization, because it
reduces the frequency of large allocations/deallocations for image data.

The result of this is that the frequency of copies needed in conjunction
with vf_sub, screenshots, and vo_lavc (encoding) should be reduced.
vf_sub now always does true pass-through if no subs are shown.

Drop the pts check from vf_sub. This didn't make much sense.
2013-01-13 20:04:12 +01:00
wm4 233cc15be9 vo_lavc: use reference counting
Helps avoiding additional copies.
2013-01-13 20:04:11 +01:00
wm4 5830d639b8 video: remove img_format compat hacks
Remove the strange things the old mp_image_setfmt() code did to the
image format parameters. This includes setting chroma shift to 31 for
gray (Y8) formats and more.

Y8 + vo_opengl_old didn't actually work for unknown reasons (regression
in this branch). Fix this. The difference is that Y8 is now interpreted
as gray RGB (LUMINANCE texture) instead of involving YUV (and levels)
conversion.

Get rid of distinguishing RGB and BGR. There wasn't really any good
reason for this.

Remove mp_get_chroma_shift() and IMGFMT_IS_YUVP16*(). mp_imgfmt_desc
gives the same information and more.
2013-01-13 20:04:11 +01:00
wm4 8751a0e261 video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)

Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.

Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)

The TV code has not been tested.

Some corrective changes regarding endian and other image format flags
creep in.
2013-01-13 20:04:11 +01:00
wm4 0c5311f17c video: cleanup: replace old mp_image function names
mp_image_alloc() also changes argument order compared to alloc_mpi().
The format now comes first, then width/height.
2013-01-13 20:04:11 +01:00
wm4 15c7f7a339 video: cleanup: move and rename vf_mpi_clear and vf_clone_attributes
These functions weren't specific to video filters and were misplaced
in vf.c. Move them to mp_image.c.

Fix the big endian test in vf_mpi_clear/mp_image_clear, which has been
messed up in 74df1d.
2013-01-13 20:04:11 +01:00
wm4 aa6ba6372c mp_image: change how palette is handled
According to DOCS/OUTDATED-tech/colorspaces.txt, the following formats
are supposed to be palettized:

    IMGFMT_BGR8
    IMGFMT_RGB8,
    IMGFMT_BGR4_CHAR
    IMGFMT_RGB4_CHAR
    IMGFMT_BGR4
    IMGFMT_RGB4

Of these, only BGR8 and RGB8 are actually treated as palettized in some
way. ffmpeg has only one palettized format (AV_PIX_FMT_PAL8), and
IMGFMT_BGR8 was inconsistently mapped to packed non-palettized RGB
formats too (AV_PIX_FMT_BGR8). Moreover, vf_scale.c contained messy
hacks to generate a palette when AV_PIX_FMT_BGR8 is output. (libswscale
does not support AV_PIX_FMT_PAL8 output in the first place.)

Get rid of all of this, and introduce IMGFMT_PAL8, which directly maps
to AV_PIX_FMT_PAL8. Remove the palette creation code from vf_scale.c.
IMGFMT_BGR8 maps to AV_PIX_FMT_RGB8 (don't ask me why it's swapped),
without any palette use. Enabling it in vo_x11 or using it as vf_scale
input seems to give correct results.
2013-01-13 20:04:11 +01:00
wm4 b7cacf9165 video/out: replace VFCAP_TIMER with vo->untimed, fix vo_image and vo_lavc
VFCAP_TIMER disables any additional waiting done by mpv in the
playloop. Remove VFCAP_TIMER, but re-use the idea for vo_image and
vo_lavc.

This means --untimed doesn't have to be passed when using --vo=image.
2013-01-13 20:04:10 +01:00
wm4 1b9d4a771a video: remove things related to old DR code
Remove mp_image.width/height. The w/h members are the ones to use.
width/height were used internally by vf_get_image(), and sometimes for
other purposes.

Remove some image flags, most of which are now useless or completely
unused. This includes VFCAP_ACCEPT_STRIDE: the vf_expand insertion in
vf.c does nothing.

Remove some other unused mp_image fields.

Some rather messy changes in vo_opengl[_old] to get rid of legacy
mp_image flags and fields. This is left from when vo_gl supported DR.
2013-01-13 20:04:10 +01:00
wm4 c54fc507da video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().

Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).

Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.

Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2013-01-13 20:04:10 +01:00
wm4 1c412169ac vo_caca: accept any stride for output image
Similar to previous commit.
2013-01-13 17:39:32 +01:00
wm4 4570a04a17 vo_corevideo: use stride
The code was entirely correct, as the VO doesn't report VFCAP_ACCEPT_STRIDE
in query_format. Add stride capability in preparation for changing the
video chain: soon all VOs will have to support arbitrary strides.
2013-01-13 17:39:32 +01:00
wm4 f4a95058c7 vo_corevideo: correct stride usage
The code assumed mp_image_alloc() would allocate an image large enough
for corevideo's stride, which doesn't have to be the case. If
corevideo's stride was larger than the stride of mp_image, the memcpy()
would write beyond the mp_image allocation.

This probably didn't actually happen, but fix the code to be more
correct anyway.
2013-01-13 17:39:32 +01:00
wm4 d77d9fb933 mp_image: require using mp_image_set_size() for setting w/h
Setting the size of a mp_image must be done with mp_image_set_size()
now. Do this to guarantee that the redundant fields (like chroma_width)
are updated consistently. Replacing the redundant fields by function
calls would probably be better, but there are too many uses of them,
and is a bit less convenient.

Most code actually called mp_image_setfmt(), which did this as well.
This commit just makes things a bit more explicit.

Warning: the video filter chain still sets up mp_images manually,
and vf_get_image() is not updated.
2013-01-13 17:39:32 +01:00
wm4 2d8fb838d7 video: make vdpau hardware decoding not use DR code path
vdpau hardware decoding used the DR (direct rendering) path to let the
decoder query a surface from the VO. Special-case the HW decoding path
instead, to make it separate from DR.
2013-01-13 17:39:32 +01:00
wm4 42e0afe641 vo_direct3d: simplify 2013-01-13 17:39:31 +01:00