Commit Graph

33498 Commits

Author SHA1 Message Date
Uoti Urpala 4fed8ad197 ao_pulse: convert to new AO API 2012-03-26 03:55:31 +03:00
wm4 84b2c79c56 libmpcodecs: rename IMGFMT_GBR24P to IMGFMT_GBRP
This is more in line with the ffmpeg/libav names.
2012-03-25 23:12:57 +02:00
reimar bf3f28f0a8 vf_scale: prefer converting GBR24P to other 8 bit per component RGB formats
Compared to converting to Y444 this should be faster and lossless.

Based on patch by Hans-Kristian Arntzen [maister archlinux us]

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34317 b3059339-0415-0410-9bf9-f77b7e298cf2
2012-03-25 23:09:58 +02:00
cehoyos b223805547 libmpcodecs: support planar GBR24 decoding
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34245 b3059339-0415-0410-9bf9-f77b7e298cf2

Note: ffmpeg first introduced PIX_FMT_GBR24P, which was used in this
commit. Later, it was renamed to PIX_FMT_GBRP in ffmpeg and libav. This
was updated in revision 34492 in mplayer, but the mplayer specific
names (such as IMGFMT_GBR24) were left unchanged.
2012-03-25 23:03:15 +02:00
Stefano Pigozzi 9badc1d786 cocoa_common: update screen info before entering fullscreen
If the user moved the window to another screen, fullscreen mode would
still use the original screen. Fix to use the screen the window is
currently on (unless overridden by --xineramascreen).
2012-03-25 22:30:38 +03:00
Uoti Urpala 215035b31a input.c: simplify command definitions
Change command definitions to allow writing the command definition
table in more readable format.
2012-03-25 22:30:38 +03:00
Stefano Pigozzi ae0a38ddf8 macosx_finder_args: use a custom logfile instead of system.log
Change the macosx_finder_args function so that when mplayer2 is
invoked from the Finder in a Mac application bundle, it redirects the
output to ~/Library/Logs/mplayer2.log instead of cluttering the global
system.log.

This doesn't affect terminal use which keeps writing to stdout and
stderr.
2012-03-25 22:30:37 +03:00
Stefano Pigozzi 19458020a6 VO: move gl+cocoa before corevideo in default VO order
The gl video output is faster and has more features than corevideo, so
it should be preferred on mac osx.

This doesn't affect GUI compatibility because they specify the
corevideo video output along with the suboptions for the shared buffer
name to mmap in.
2012-03-25 22:30:37 +03:00
Stefano Pigozzi e37d7b1452 configure: disable X11 opengl backend if Cocoa is enabled
The recommended way to get function pointers to the functions in the
OpenGL library is through dlopen/dlsym/dlclose. This causes problems
in the Cocoa OpenGL backend when -lGL (X11's OpenGL headers) is linked
to the binary together with -framework OpenGL.
The linked OpenGL symbols are always from -lGL, causing all the
function pointers to point to null when getFunctions is called against
a Cocoa OpenGL context.

For this reason change the configure autodetection code to disable
the vo_gl X11 backend when cocoa is active.
2012-03-25 22:30:37 +03:00
Stefano Pigozzi e89ea0c371 cocoa_common: add license information 2012-03-25 22:30:37 +03:00
Stefano Pigozzi d0f0bf7fd2 vo_quartz: remove this video output
This video output is not useful anymore. It is based on Carbon to draw
the mplayer window and this has been deprecated by Apple in 10.5.

The upcoming 10.8 OSX release should deprecate most of Carbon, so it
doesn't make sense to keep vo_quartz in the codebase when there are
modern and better alternatives (vo_gl and vo_corevideo).
2012-03-25 22:30:37 +03:00
Stefano Pigozzi 24e08eb5f2 macosx_finder_args: use cocoa instead of carbon
macosx_finder_args was using Carbon and wasn't usable any longer on
modern versions of MacOSX. This is very useful to embed mplayer in a
mac application bundle.

When using application bundles, the operating system will call the
main function with only one argument that identifies the process
serial number (this is some additional process identifier in osx other
than the pid). File open events are then dispatched to the application
through events that must be handled accordingly.
2012-03-25 22:30:37 +03:00
Stefano Pigozzi 98d399e2f3 cocoa_common: fix double click handling
The Cocoa framework generates only a NS*MouseDown event when handling
the second click of a double click (no NS*MouseUp). If that's the case
put mouse up key in mplayer2's fifo when dealing with the MouseDown
Cocoa event.
2012-03-25 22:30:37 +03:00
Stefano Pigozzi 09beba6e9e cocoa_common: accept window drag event from the whole window surface
Change the window to accept mouse drag events not only on the title
bar, but also on the rest of the window surface; this includes the
video area.

It looks like the changing of the window mask resets the behaviour
specified in the delegate method, probably due to some strange
interaction with NSBorderlessWindow. For this reason call
-setPresentationOptions in the -fullscreen method to remind cocoa the
behaviour we want.
2012-03-25 22:30:37 +03:00
Stefano Pigozzi 495dde4018 options, x11+cocoa: add option --cursor-autohide-delay
Add option --cursor-autohide-delay to control the number of milliseconds
with no user interaction before the mouse cursor is hidden.

There are two negative values with useful special meanings:
* A value of -1 prevents the cursor from hiding (useful for users
  with multiple displays).
* A value of -2 prevents the cursor from showing upon activity.

The default is 1 second to keep the behaviour consistent with the
past X11 backend implementation.

Remove the vo_mouse_autohide field as it was always true.
2012-03-25 22:30:37 +03:00
wm4 f30bf73bf2 etc/input.conf: make file contents match default key bindings
There were some slight differences between what input.conf mapped, and
what was in input.c def_cmd_binds[]. Make them match.

Add some minor documentation improvements in input.cfg.

Also remove double comments ('##'), because they were confusing.
2012-03-25 22:30:37 +03:00
wm4 adf100cd49 x11: remove wskeys.h
Use the <X11/keysym.h> xlib header instead. I'm not sure why mplayer
defined these constants itself.
2012-03-25 22:30:37 +03:00
wm4 f561c19fe1 x11: input: add print and menu keys 2012-03-25 22:30:37 +03:00
wm4 7f6dae08e1 x11: add KP_Separator to key mapping
At least on some keyboards, the key between '0' and 'Enter' on the
key pad is mapped to KP_Separator. Since X11 VOs accept unicode
input, the mplayer keycode this key generates depended on the numlock
state, and with numlock enabled this mapped to an ASCII character.
This is probably not what the user wanted, since two physical keys
will always map to the same key code.

Map it to KP_DEC.
2012-03-25 22:30:37 +03:00
wm4 467817ff9f x11: allow unicode input
This change allows using non-ASCII keys with X11. These keys were ingored
before.

Technically, this creates an invisible, non-interactive input method
context. If creation fails, the code falls back to the old method, which
allows a subset of ASCII only.
2012-03-25 22:30:37 +03:00
wm4 7ea5c4c26c input: handle UTF-8 terminal input
This assumes the terminal uses UTF-8. If invalid UTF-8 is encountered (for
example because the terminal uses a legacy encoding), the code falls back
to the old method and feeds each byte as key code to the input code.

In theory, UTF-8 input could randomly fail, because the code in getch2.c
doesn't try to fill the input buffer correctly with input sequences
longer than a byte. This is a problem with the design of the existing
code.
2012-03-25 22:30:37 +03:00
wm4 166a7de4cf input: allow unicode keys and reassign internal key codes
This moves all key codes above the highest valid unicode code point
(which is 0x10FFFF). All key codes below MP_KEY_BASE now directly map
to unicode (KEY_ENTER is 13, carriage return). Configuration files
(input.conf) can contain unicode characters in UTF-8 to map non-ASCII
characters/keys.

This shouldn't change anything user visible, except that "direct key
codes" (as used in input.conf) will change their meaning.

Parts of the bstr functions taken from libavutil's GET_UTF8 and
slightly modified.
2012-03-25 22:30:37 +03:00
wm4 3e6e80a32c x11: fix setting UTF-8 window titles for some special cases
Setting the WM_NAME/WM_ICON_NAME window properties didn't always work:
apparently there are some characters that can't be represented in the X
STRING or COMPOUND_TEXT encodings, such as U+2013 EN DASH. The function
Xutf8TextListToTextProperty partially converts the string, and returns
a value different from 'Success'. This means vo_x11_set_property_string
didn't set these window properties.

On most modern window managers, this is not a problem, since these use
the _NET_WM_NAME/_NET_ICON_NAME and the UTF8_STRING encoding. Some older
WMs like IceWM don't read these, and the window title remains blank.

It's not clear what exactly we should do in this situation, but fix it
by setting set the WM_NAME/WM_ICON_NAME properties as UTF8_TEXT. This
violates the ICCCM, but at least IceWM seems to handle this well.

See also:
  http://lists.freedesktop.org/archives/xorg/2004-September/003391.html
  http://lists.freedesktop.org/archives/xorg/2004-September/003395.html
2012-03-25 22:30:37 +03:00
Stefano Pigozzi 506d9beb66 vo_gl: cocoa: add support for --ontop
Make the cocoa backend change the non-fullscreen window level
according to the value of the ontop property.
2012-03-25 22:30:37 +03:00
Uoti Urpala 06e3dc8eba timeline: subs: keep subtitle tracks in source time
Timeline handling converted the pts values from demuxed subtitles to
timeline scale. Change the code to do most subtitle handling in
original subtitle source pts, and instead convert current playback
timeline pts to those units when deciding which subtitle to show.
The main functionality changes are that now demuxed subtitles which
overlap chapter boundaries are handled correctly (at least for libass
subtitles), and external subtitles are assumed to use same pts scale
as current source (this needs improvements later).

Before, a video subtitle that had a duration continuing past the end
of the chapter would continue to be shown for the original duration,
even if the chapter ended and playback switched to a position in the
source where the subtitle shouldn't exist. Now, the subtitle will
correctly end.

Before, external subtitle files were interpreted as specifying pts
values in timeline scale. Now, they're interpreted as specifying pts
values in source file time scale, for _every_ source file. This is
probably more likely to be what the user wants for the "main" source
file in case there is one, but almost certainly not quite right for
multiple source files where the same subs could be shown over
different scenes. If the user wants them to match some main source
file, it's probably still better to have incorrect extra subs for
video from some files than to have every subtitle appearing at the
wrong time. The new code makes it easier to change the interpretation
of the subtitle times, and some configurability should be added in
the future.
2012-03-25 22:30:37 +03:00
Uoti Urpala 1ff7efe2ec vo_xv: remove direct rendering support
Direct rendering support in vo_xv (used with --dr) had at least two
problems. First, OSD drawing modified the buffers; this meant that
if the buffers were used for reference frames there would be video
corruption. I don't think "performance optimization" with this level
of drawbacks is appropriate with today's machines any more. Direct
rendering could still be used for non-reference frames, but there's a
second problem: with direct rendering enabled the same buffer is used
for every frame, and with the XShm extension that is used by default
there's no checking that the previous frame has been completely
uploaded to the graphics card before it's overwritten by the next one.
This could be fixed, but as Xv is becoming obsolete I don't see it as
a priority to improve it. Thus I'm simply removing the parts of
functionality that were more likely to break things than improve
playback.
2012-03-25 22:30:37 +03:00
Uoti Urpala a3b4f64df4 cosmetics: vf_vo.c: reformat 2012-03-25 22:30:37 +03:00
Uoti Urpala 4f1e4eae99 cosmetics: misc minor cleanups
The deleted ZRM* things were only relevant to vo_zr, which was deleted
earlier.
2012-03-25 22:30:37 +03:00
Uoti Urpala fd50478659 core: improve sub and audio start after timeline part switch
When switching to a timeline part from another file, decoders were
reinitialized after doing the demuxer-level seek. This is necessary
for audio because some decoders read from the demuxer stream during
initialization and the previous stream position before seek could have
been at EOF. However, this initialization sequence could lose first
subtitles or first part of audio.

The problem for subtitles was that the seek itself or audio
initialization could already have buffered subtitle packets from the
new position, and the way subtitles are reinitialized flushes packet
buffers. Thus early subtitles could be lost (even if they were demuxed
- unfortunately demuxers may not know about still active subtitles
earlier in the file, but that's another issue). Fix this by moving
subtitle and video reinitialization before the demuxer seek; they
don't have the problems which prevent that for audio.

Audio initialization can already decode and buffer some output.
However, the seek_reset() call done last would then throw away this
buffered output. Work around this by adding an extra flag to
seek_reset().
2012-03-20 14:51:32 +02:00
Uoti Urpala ec58e5a384 options: move mixer.h options to struct 2012-03-20 14:51:32 +02:00
wm4 7a699cea28 mixer: reindent/cosmetic changes
There should be no real semantic changes.

Remove the mixer_setbothvolume macro, as it was unused.
2012-03-20 14:51:32 +02:00
wm4 7d0c4c3c31 mixer: remove useless includes
These have been unneeded ever since 2004.
2012-03-19 22:55:41 +01:00
Uoti Urpala 7040968be4 core: restructure main play loop, continue audio after video
Restructure parts of the code in the main play loop. The main
functionality difference is that if a video track ends first, now
audio will continue to be played until it ends too.

Now the process also wakes up less often if there's no need to update
video or audio. This will reduce unnecessary wakeups especially when
paused, but may make handling of input events laggier when fd-based
notifications are not supported (like most input on Windows).
2012-03-19 23:05:02 +02:00
wm4 00421e5eec ao_openal: allow setting the OpenAL sub-device
Now "-ao openal:device=<subdevice>" will pass <subdevice> as device to
OpenAL. This allows selecting both the OpenAL backend (OS-level audio
API) and the physical output device.

The available devices can be listed with "-ao openal:device=help".
2012-03-17 21:06:30 +01:00
wm4 c48c0f453b ao_dsound: fix volume controls
The recent changes in mixer.c require the AO to return a volume of
exactly 0 when audio has been muted. Rather than adding just another
special case to mixer.c, fix ao_dsound.c to return previously set
volumes exactly. Because DirectSound volume control is not connected
with the system mixer, which could change the volume without mplayer
knowing, reading the volume back from DirectSound is pointless.

Also, the code tried to calculate log10(0). Clip the volume to 1,
which results in -10000, DirectSound's definition of silence.
2012-03-17 21:06:30 +01:00
wm4 2f9b14916f ao_dsound: don't repeat parts of the audio buffer when playback ends
When layback of a file ends, the audio output doesn't receive new audio
data, but the rest of the data must be played properly. ao_dsound.c
doesn't handle this properly: DirectSound will continue to play the
ringbuffer, even if mplayer doesn't write any data. There's no explicit
way to prevent such a buffer underrun. Try to detect it and stop
playback.
2012-03-17 21:06:30 +01:00
wm4 ea1cc7f3e2 windows support: prefer vo_direct3d_shaders over vo_direct3d
Since "direct3d" has broken color levels with some drivers, and there
is no simple fix for this, prefer "direct3d_shaders".
2012-03-17 21:06:30 +01:00
wm4 8bfac76092 vo_direct3d: fix bug in screenshot code with some pixel formats
A typo caused the height of the image copy to be incorrectly calculated
with some less common pixel formats, when X chroma shift != Y chroma
shift.
2012-03-17 21:06:30 +01:00
wm4 0e92bbef2f vo_direct3d: fix crash when repeatedly reinitializing an uncooperative device 2012-03-17 21:06:30 +01:00
wm4 da4dd6d14b vo_direct3d: stop D3D from switching the FPU to single precision mode
Add the flag D3DCREATE_FPU_PRESERVE, which tells Direct3D not to switch
the FPU to single precision mode. Single precision mode would mean that
all floating point calculations are done in float precision, even if
using double variables.

The MSDN documentation seems to discourage use of this flag with scary
warnings about bad performance and stability, but I suspect in practice
switching off this completely unreasonable behavior is fine.
2012-03-17 21:06:30 +01:00
wm4 1575ba6293 vo: fix EOSD change detection
The case when the EOSD sub-images changed position, but didn't need
re-upload, wasn't handled correctly. If a subtitle script made text move
over the screen (without any other changes), the subtitle display wasn't
updated. vo_vdpau was not affected, because vdpau directly reads the
sub-image positions on every frame.

The fix could be simpler. It could recreate the vertex array every frame.
This commit keeps the optimization that nothing is done when the libass
native change detection doesn't report any change. Maybe this optimization
isn't worth doing, since recreating the vertex array is relatively cheap
compared to amount of work required to render complicated subtitles.

The eosd_packer_generate function returning 3 boolean flags is ugly.
2012-03-17 21:06:30 +01:00
wm4 1bb08fc1e6 win32: properly set window title
Set the window title on win32 based VOs using the same logic as on X11
and Cocoa.

Until now, the window title when using vo_direct3d and vo_gl was hardcoded
to "MPlayer - The Movie Player", and vo_directx showed "MPlayer". Now it
will show "mplayer2", unless the --title or --use-filename-title options
are used.

Change the internal window class name to the string "mplayer2" too.
2012-03-17 21:06:30 +01:00
wm4 7c6a4e1e98 vo_direct3d: implement screenshots
There are 4 code paths when taking a screenshot:
- textured rendering mode
- StretchRect rendering mode with planar formats
- StretchRect with packed formats
- full-window screenshot mode

The implementation of the full-window mode (capturing the window contents,
instead of the video) is very inefficient: it will create a surface of
desktop size, copy the desktop contents, allocate a new memory image, and
copy in the window contents. The code in screenshot.c will (as of now)
allocate and convert the image from BGR to RGB, and allocate a destination
buffer for the libavcodec PNG writer.

If parts of the mplayer window are obscured, the full-window mode wil
contain these parts as seen on the screen. Parts of the window that are
outside the bounds of the desktop are clipped away. It is not known
whether full-window mode works on multi-monitor setups.
2012-03-17 21:06:30 +01:00
wm4 d813a4ede8 win32: fix fullscreen not working on Windows 7
Switching to fullscreen mode on Windows 7 didn't work: the window position
and size weren't set to fullscreen. It turns out that merely calling
SetWindowLong caused windows to send move/resize messages, which changed
the global variables that were supposed to contain the new window size.
Move the SetWindowLong call out of the way to guarantee that always the
correct values are used.
2012-03-17 21:06:30 +01:00
wm4 0ab7c39a1e vo_direct3d: fix dealing with uncooperative devices
If the Direct3D device is "lost" (e,g, when minimizing mplayer, or when
another application uses Direct3D exclusive mode), we free it and try to
recrate the device. This can fail, and may fail for an extended period of
time, until D3D is available again and the device can be created. So we
basically have to provide all VO functionality while d3d_device is NULL.

Don't terminate if device creation fails, and re-add the NULL checks that
were removed in the commit "vo_direct3d: refactor D3D initialization and
reconfigure code".

If mplayer calls the VO's config() while the D3D device can not be
created, the VO will return an error and mplayer will terminate.
config() is typically called when new files are played, when ordered
chapter boundaries are crossed, or on other events.
2012-03-17 21:06:29 +01:00
wm4 032a3b8272 vo_direct3d: add hack for using 2 channel textures for 10 bit pixel formats
This actually applies to YUV formats with 9-16 bit depths. This hack is
disabled by default, and the VO will use 16 bit textures normally.

It can be enabled by passing the no16bit-textures option is passed to
vo_direct3d. Then the VO will use D3DFMT_A8L8 as texture formats for the
YUV plane (instead of D3DFMT_L16), and compute the sampled two color
values back into one.

In some cases it might be undesireable to use 16 bit texture formats. At
least some OpenGL drivers on Linux (Mesa + Intel) round values sampled
from 16 bit textures back into 8 bit, which loses 8 from 10 bit color
information when playing 10 bit formats. It is unknown whether there are
D3D9 drivers which do this, so this commit might be removed later.
2012-03-17 21:06:28 +01:00
wm4 8393796f0b vo_direct3d: add some debugging options
This is for testing. Most of these make no sense, or even if they do, might
not improve anything.
2012-03-17 21:05:39 +01:00
wm4 c67e1ba4a6 vo_direct3d: refactor D3D initialization and reconfigure code
This simplifies the code and removes code duplication.

There should be no actual semantic differences to the previous code. The
only exception is that the new code doesn't query the display adapter's
desktop pixel format on backbuffer resizing anymore. In my opinion the
format can never change anyway, and if it does, it will cause the D3D
device to become "uncooperative" and we will recreate it in flip_page.

Remove attempts to handle d3d_device when it's NULL (outside of the
initialization paths). d3d_device can only be NULL if recreating a D3D
device, that was in "incooperative" state, fails. The current (and
previous) code seems to assume that this never happens. It is unlikely
that these NULL checks improved correct operation in any way, or at least
they won't anymore after the recent changes done to the code.

If it should be possible that a device can't be reset/recreated for a
while (during display resolution changes? when another D3D application is
in fullscreen mode?), another solution has to be found.

It is unknown why the code recreates the IDirect3D9 interface when the
device was uncooperative. At least on Windows XP + reference rasterizer,
resuming works without recreating it. Leave this code just in case.
2012-03-17 21:05:39 +01:00
wm4 6f02fb1cce vo_direct3d: disable using shaders by default, and add direct3d_shaders VO
Now using the "direct3d" VO will never make use of shaders. Instead, users
are supposed to use the direct3d_shaders VO entry, which is exactly the
same as direct3d, except with shaders enabled by default.

"direct3d" always uses the Direct3D StretcRect API call to render videos.
Playing formats not supported by this function will force mplayer to
insert a scale filter to convert video frames in software.

"direct3d_shaders" prefers shader color conversion, but can fall back to
StretchRect if the format can be handled. (This happens only with some
insignificant packed YUV formats.)
2012-03-17 21:05:39 +01:00
wm4 5ee7797bf8 vo_direct3d: use new VO API, and do some minor reformatting
The minor reformats are mainly about adding more line breaks to fit a 80
column limit.

Using the new VO API implies removing all non-const global variables
(because that is one important goal of the new API), so do that as well.
The code already had all variables in a context struct, and changing all
the functions to pass this context struct along was all what had to be
done.

Also handle redrawing properly: if something changes that requires an
immediate redrawing operation (e.g. setting video equalizers when paused
or when playback is slow), vo->want_redraw should be set, instead of
redrawing on your own.
2012-03-17 21:05:38 +01:00