Commit Graph

312 Commits

Author SHA1 Message Date
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
wm4 eb7959e43a gl_video: add support for more rgb formats
Until now, only formats directly supported by OpenGL were supported.
This excludes various permutations of 8-bit RGB[A|0]. But we can simply
permutate the color channels in the shader, so do that. This also adds
support for all these weird RGB0 formats.

Note that we could use libavutil's pixfmt list instead of the
mp_packed_formats array, but trying to decrypt the pixfmt info would
probably end in pain, so this array with duplicated information is
actually better and shorter.

Note: I didn't actually test whether the alpha components are reproduced
correctly with alpha formats.
2013-07-18 13:52:38 +02:00
wm4 7f88e36911 sws_utils: don't recursively include libswscale header
Add libswscale includes where they are actually needed instead.
2013-07-18 13:46:05 +02:00
wm4 de61561deb vo_x11: use new swscale wrapper 2013-07-18 13:44:56 +02:00
wm4 81698e7116 vo_x11: remove weird inactive code
I guess this code was supposed to handle cases like drawing RGBA as ARGB
by offsetting it by 1 byte.

The code didn't make any sense, though. It used to make sense before mpv
switched internal pixel formats from FourCCs to a simple enum. With the
FourCCs, "fmt | 128" selected the big endian version of a format. Of
course this doesn't work this way with the new pixel formats. It just so
happens that there are no formats with whose values match
IMGFMT_RGB32|128 or IMGFMT_BGR32|128, so this code was inactive.

All involved pixel formats seem to play fine on my setup (though it's
little endian only), and the code strictly matches the mpv pixel formats
against the format of the X image, so I'm not quite sure why this code
was there in the first place.

The original commit that added this was b333ae1 (svn 21602):
  Support for different endianness on client and server with -vo x11
2013-07-18 13:11:13 +02:00
wm4 18b6c01d92 video: redo how colorspaces are handled
Instead of handling colorspaces with VFCTRLs/VOCTRLs, make them part of
the normal video format negotiation. The colorspace is passed down like
other video params with config/reconfig calls.

Forcing colorspaces (via the --colormatrix options and properties) is
handled differently too: if it's changed, completely reinit the video
chain. This is slower and requires a precise seek to the same position
to perform an update, but it's simpler and less bug-prone. Considering
switching the colorspace at runtime by user-interaction is a rather
obscure feature, this is a good change.

The colorspace VFCTRLs and VOCTRLs are still kept. The VOs rely on it,
and would have to be changed to get rid of them. We'll do that later,
and convert them incrementally instead of in one go.

Note that controlling the output range now always works on VO level.
Basically, this means you can't get vf_scale to output full-range YUV
for whatever reason. If that is really wanted, it should be a vf_scale
option. the previous behavior didn't make too much sense anyway.

This commit fixes a few bugs (such as playing RGB video and converting
that to YUV with vf_scale - a recent commit broke this and forced the
VO to display YUV as RGB if possible), and might introduce some new
ones.
2013-07-16 23:22:55 +02:00
Alexander Preisinger 6230e0b896 wayland: early aspect calculation in vo_config
Calculate the aspect ratio in vo_config, when we get the window size and in the
inside the resize function we calculate the aspect ratio of the output in order
to determine if we have to change the height or the width of the video.

If the ratio of the output is bigger than the ratio of the video then we have
to set the width accordingly and if the ratio is smaller we change the size.
But only if no resize edges are passed, because this indicates that we want to
change the windows state instead of just a simple resize and the video should
not grow bigger than the requested size.
2013-07-16 19:13:29 +02:00
Alexander Preisinger dc142991f1 wayland: use default fullscreen method
I misunderstood how the different methods work and if we set the size
accordingly to the wayland configure event then METHOD_DEFAULT is what we want.
2013-07-16 16:53:42 +02:00
wm4 cde55d4c34 w32_common: don't use aspdat.asp for aspect
aspdat.asp is a problem, because it's updated when the VO calls
vo_get_src_dst_rects(). Nothing guarantees that the value has been
updated when the w32 code accesses it.

Instead, use the aspect vo_w32_config() was called with.
2013-07-16 00:03:51 +02:00
wm4 e18ffd6b99 Merge branch 'remove_old_demuxers'
The merged branch doesn't actually just remove old demuxers, but also
includes a branch of cleanups and some refactoring.

Conflicts:
	stream/stream.c
2013-07-14 17:59:26 +02:00
wm4 52c3eb6976 core: change open_stream and demux_open signature
This removes the dependency on DEMUXER_TYPE_* and the file_format
parameter from the stream open functions.

Remove some of the playlist handling code. It looks like this was
needed only for loading linked mov files with demux_mov (which was
removed long ago).

Delete a minor bit of dead network-related code from stream.c as well.
2013-07-12 21:56:40 +02:00
Stefano Pigozzi b0932ecbb6 cocoa_common: change video size when changing screen DPI
This improves the situation when moving a window from screens with different
DPIs.
2013-07-10 22:22:08 +02:00
Martin Herkt 062b22b7cb Merge remote-tracking branch 'origin/low_quality_intel_crap'
Conflicts:
	video/out/gl_video_shaders.glsl
2013-07-08 18:07:54 +02:00
wm4 1709b65a72 dither: don't use long double
This fixes compilation with broken libcs, like on Cygwin. C99
absolutely requires long double and associated functions like expl,
even if long double is double. But newlib (used by cygwin) omits
declaration for these if long double is equivalent to double.

The extra precision is not needed here, so remove it to make life
easier for the single person using mpv with cygwin.
2013-07-05 20:26:32 +02:00
wm4 d084f72a6c core: remove mp_fifo leftovers 2013-07-04 17:53:30 +02:00
Alexander Preisinger 1789449a0a wayland: remove mp_fifo header 2013-07-03 22:43:05 +02:00
Alexander Preisinger 56b9dcaabb wayland: fix typo 2013-07-03 19:00:33 +02:00
Alexander Preisinger 17e5542574 wayland: remove unused members 2013-07-03 18:59:52 +02:00
Alexander Preisinger 8ea39d548b wayland: remove mp_fifo 2013-07-02 18:56:50 +02:00
Alexander Preisinger 37c5867703 wayland: implement MOUSE_LEAVE 2013-07-02 17:31:43 +02:00
wm4 d603e73c24 core: cleanup more mp_fifo leftovers
Now only the OSX and Wayland parts are using this.
2013-07-02 14:11:31 +02:00
wm4 70a8079c8e core: remove mp_fifo indirection
For some reason mp_fifo specifically handled double clicks, and other
than that was a pointless wrapper around input.c functionality.

Move the double click handling into input.c, and get rid of mp_fifo. Add
some compatibility wrappers, because so much VO code uses these
functions. Where struct mp_fifo is still used it's just a casted
struct input_ctx.
2013-07-02 14:00:24 +02:00
wm4 c4766dc3c6 input: require VOs to send key up events, redo input key lookup
Making key up events implicit was sort-of a nice idea, but it's too
tricky and unreliable and makes the key lookup code (interpret_keys())
hard to reason about. See e.g. previous commit for subtle bugs and
issues this caused.

Make key-up events explicit instead. Add key up events to all VOs.
Any time MP_KEY_STATE_DOWN is used, the matching key up event must
use MP_KEY_STATE_UP.

Rewrite the key lookup code. It should be simpler and more robust now.
(Even though the LOC increases, because the new code is less "compact".)
2013-07-02 12:19:16 +02:00
James Ross-Gowan d3b68a283f w32_common: prevent display power management
Handling SC_MONITORPOWER doesn't seem to prevent the screen from
dimming. The recommended way to do this in Windows XP and Vista is to
call SetThreadExecutionState with ES_DISPLAY_REQUIRED. Windows 7 also
has the PowerCreateRequest/PowerSetRequest/PowerClearRequest APIs but
they're probably too complicated for this task.
2013-06-30 23:41:06 +10:00
wm4 1099e0fc99 w32_common: prevent that window dragging and mouse input interfere 2013-06-29 22:58:14 +02:00
wm4 9ff6b472bd w32_common: refactor mouse button code, handle mouse up events
Instead of sending a single event on click, send both down and up
events.
2013-06-29 22:58:13 +02:00
wm4 831a7cf3ee input: trigger mouse_leave key bindings if mouse leaves mouse area
Also, implement mouse leave events for X11. But evne on other
platforms, these events will be generated if mouse crosses a section's
mouse area boundaries within the mpv window.
2013-06-29 22:58:13 +02:00
wm4 5b38a522f1 input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.

Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)

As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).

Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.

Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-06-29 22:58:13 +02:00
Stefano Pigozzi fd7dd83e28 cocoa_common: uninit fs window properly
In fullscreen `s->window` is the windowed window. So freeing that didn't get
rid of the FS window and OpenGL view.

Fixes #122
[ci skip]
2013-06-29 22:55:15 +02:00
wm4 ac266da658 vo_opengl: handle chroma location
Use the video decoder chroma location flags and render chroma locations
other than centered. Until now, we've always used the intuitive and
obvious centered chroma location, but H.264 uses something else.

FFmpeg provides a small overview in libavcodec/avcodec.h:

-----------
/**
 *  X   X      3 4 X      X are luma samples,
 *             1 2        1-6 are possible chroma positions
 *  X   X      5 6 X      0 is undefined/unknown position
 */
enum AVChromaLocation{
    AVCHROMA_LOC_UNSPECIFIED = 0,
    AVCHROMA_LOC_LEFT        = 1, ///< mpeg2/4, h264 default
    AVCHROMA_LOC_CENTER      = 2, ///< mpeg1, jpeg, h263
    AVCHROMA_LOC_TOPLEFT     = 3, ///< DV
    AVCHROMA_LOC_TOP         = 4,
    AVCHROMA_LOC_BOTTOMLEFT  = 5,
    AVCHROMA_LOC_BOTTOM      = 6,
    AVCHROMA_LOC_NB             , ///< Not part of ABI
};
-----------

The visual difference is literally minimal, but since videophiles
apparently consider this detail as quality mark of a video renderer,
support it anyway. We don't bother with chroma locations other than
centered and left, though.

Not sure about correctness, but it's probably ok.
2013-06-28 21:20:41 +02:00
wm4 3382a6f6e4 video: add a new method to configure filters and VOs
The filter chain and the video ouputs have config() functions. They are
strictly limited to transfering the video size and format. Other
parameters (like color levels) have to be transferred separately.

Improve upon this by introducing a separate set of reconfig() functions,
which use mp_image_params to carry format parameters. This struct
contains all image format related parameters from config(), plus
additional parameters such as colorspace.

Change vf_rotate to use it, as well as vo_opengl. vf_rotate is just
an example/test case, but vo_opengl will need it later.

The intention is also to get rid of VOCTRL_SET_YUV_COLORSPACE. This
information is now handed to the VOs via reconfig(). The getter,
VOCTRL_GET_YUV_COLORSPACE, will still be needed though.
2013-06-28 20:34:46 +02:00
Stefano Pigozzi 6669366280 cocoa_common: schedule a redraw frame after a non live resize
A redraw forces recalculation of panscan and other stuff not accounted for in
the resize_redraw codepath. This is actually a hack but works really well in
my tests.

Thanks @wm4 and @Cpuroast for the idea.

Fixes #86
[ci skip]
2013-06-25 22:13:48 +02:00
wm4 403a266d46 Merge branch 'sub_mess2'
...the return.
2013-06-25 00:43:04 +02:00
wm4 4f5e12136d stream: remove padding parameter from stream_read_complete()
Seems like a completely unnecessary complication. Instead, always add a
1 byte padding (could be extended if a caller needs it), and clear it.

Also add some documentation. There was some, but it was outdated and
incomplete.
2013-06-23 22:33:59 +02:00
Stefano Pigozzi 0407869ae3 OSX: fix compilation with 10.7 SDK
Recent work in the OS X parts of the code started using clang's support for
Obj-C's support for Literals and Subscripting. These particular language
features remove a lot of boilerplate code and allow to interact with
collections as consicely as one would do in scripting languages like Ruby or
Python.

Even if these are compiler features, Subscripting needs some runtime support.
This is provided with libarclite (coming with the compiler), but we need to
add the proper method definitions since the 10.7 SDK headers do not include
them. That is because 10.7 shipped before this language features.

This will cause some warnings when compiling with the 10.7 SDK because the
commit also redefines BOOL to make autoboxing/unboxing of BOOL literals to
work.

If you need to test this for whatever reason on 10.8, just pass in the correct
SDK to configure's extra cflags:

  ./configure --extra-cflags='-mmacosx-version-min=10.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk'

Fixes #117
2013-06-19 21:24:26 +02:00
wm4 656f9e1ba7 vo_lavc: remove unused variable 2013-06-18 12:22:25 +02:00
Rudolf Polzer 66f09d7384 vo_lavc: do NOT fill pict_type from the mp_image
Doing this makes the encoder force the same pict type as original, which
is often not even possible. Rather let the codec decide!

As there is no documented value to mean "decoder shall pick", I rather
save/restore the default value filled by libavcodec.
2013-06-17 17:33:50 +02:00
Rudolf Polzer 1d75d01392 vo_lavc: use mp_image_copy_fields_to_av_frame 2013-06-17 08:56:55 +02:00
Rudolf Polzer dcd36c79c7 encode_lavc strings: use new option syntax 2013-06-16 17:14:47 +02:00
Stefano Pigozzi de63e1d15e cocoa_common: implement VOCTRL_UPDATE_WINDOW_TITLE
Unfortunately this backend creates the window lazily and a call to
`cocoa_set_window_title` is needed inside config.
2013-06-16 11:00:20 +02:00
Alexander Preisinger 3866106be5 wayland: use VOCTRL_UPDATE_WINDOW_TTILE 2013-06-16 09:34:31 +02:00
wm4 a07b99540c vo: fix build on Libav 2013-06-15 19:23:53 +02:00
wm4 168a595bfe video/out: introduce VOCTRL_UPDATE_WINDOW_TITLE
Instead of implicitly changing the window title on config(), do it as
part of the new VOCTRL.

At first I wanted to make all VOs use the VOCTRL argument directly, but
on a second thought it appears vo_get_window_title() is much more useful
for some (namely, if the window is created lazily on first config()).

Not all VOs are changed. Wayland and OSX have to follow.
2013-06-15 19:07:21 +02:00
wm4 70f97efa72 vo: define VO_TRUE/FALSE to C99 constants
This make the intention more apparent, and some VOs are actually using
true instead of VO_TRUE in some places. Hopefully this changes makes it
less confusing (instead of more).

The C99 constants true/false are defined to 1/0 as well, so this commit
doesn't actually change anything.
2013-06-15 18:59:52 +02:00
wm4 73b9b0b830 w32_common: remove some unneeded code
vo_w32_init() can be called only once on a VO.
2013-06-15 18:57:38 +02:00
wm4 63ff79556f w32_common: fix non-sense
Seriously...
2013-06-15 18:54:01 +02:00
wm4 b04ce54711 vo_xv: always request redraw on resize
Fixes using panscan controls with OSD off and video paused.
2013-06-15 18:36:16 +02:00
wm4 0e2fb5d8e8 vo: redo video display rectangle calculations
This code calculates the source/display video rectangle for scaling with
most VOs. It's responsible for clipping the display rectangle against
the screen and adjusting the source rectangle accordingly.

Until now, it assumed that the video was centered on the screen. Change
this so that any rectangle is possible. Basically, the clipping is
extended to two sides (e.g. left and right), instead of handling both at
the same time.

The rounding behavior slightly changes. It seems to be slightly better
than before. On the other hand, the video is not strictly centered
anymore (due to different rounding on either side). When using panscan
controls, the video can "jitter" by 1 or 2 pixels around the center as
the panscan value is changed.
2013-06-15 18:35:09 +02:00
wm4 60631acd29 gl_video: rearrange some code
I think this is slightly nicer. Shouldn't change anything functionally.
2013-06-15 18:34:43 +02:00