Commit Graph

36041 Commits

Author SHA1 Message Date
wm4 3e59ee25ea TOOLS: add script for emulating "unique application" functionality on Linux
See github issue #43.

This comes with a load of caveats, so be sure to read the comments at
the start of the script.
2013-07-28 23:08:05 +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 0293eac84a m_config: try to print min/max values as integers in --list-options
This switched to exponential representation too soon, and large integer
values looked bad in the --list-options output.
2013-07-28 18:56:49 +02:00
wm4 a737308f73 m_config: hide no-* opts in --list-options, simplify positional subopts
All these --no-... options in --list-options made the output rather
unreadable, so hide them. Make the code for finding positional
parameters (which are supposed to skip these no-* options) slightly
simpler too.
2013-07-28 18:56:48 +02:00
wm4 85bee4f071 options: print default values in --list-options
Do this by recreating the m_config from scratch, which then must
contain the default values. This doesn't quite work with legacy options
using global variables: the default values get lost, so using
--list-options will print the value as set by the config file. This
also introduces a memory leak for string options backed by global
variables. All of these issues will be eventually fixed by moving all
options to structs.
2013-07-28 18:56:09 +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 da2b4aa587 core: make mpctx->opts a pointer
Prevents some awkwardness in a later commit, and makes the code more
uniform with other places where MPOpts is accessed.

This is a pretty annoying commit (touches tons of lines all over the
place), but it hurts only once.
2013-07-28 18:44:21 +02:00
wm4 2fc07dcf30 command: mark special options as unavailable
Special options (like -v, -playlist, etc.) don't have data associated
with them, so reading them with the "options" property makes no sense.
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
Stefano Pigozzi ca678dce4d ao_coreaudio: prevent buffer underruns to output garbage
This was removed in d427b4fd. I now found a sample that causes underruns when
moving to a chapter and apparently this is also a problem when taking
screenshots.
2013-07-28 11:21:03 +02:00
Dmitry Kalinkin 721071a5ec ao_coreaudio: fix compilation on OS X 10.7
Reverts one of the changes from 18777ecf. `kAudioObjectPropertyScopeOutput`
was introduced in the 10.8 SDK while `kAudioDevicePropertyScopeOutput` was
moved to `AudioHardwareDeprecated.h`. Since the deprecation is silent for now
(no warnings), just use the old constant.

Either way, they both evaluate to 'outp', and in the 10.8 SDK the deprecated
constant is defined in terms of the non-deprecated one.

Fixes #155
2013-07-28 09:48:49 +02:00
James Ross-Gowan 8e1461b9f8 ao_wasapi: don't check the audio feed while paused 2013-07-27 14:28:42 +10:00
Diogo Franco (Kovensky) fac2d9097e getch2: Load the "ce", "ks" and "ke" caps into a static buffer
Fixes reports of printing of garbage (or anything else) other than clearing
the status line to the end of line: the buffer returned by termcap_get
could get moved, and if that happened then these 3 caps pointed to garbage.
2013-07-26 16:03:56 -03:00
Diogo Franco (Kovensky) 630edc0637 getch2: Deactivate getch2 on SIGINT; also handle SIGQUIT 2013-07-26 15:51:48 -03:00
Diogo Franco (Kovensky) 15742504d0 getch2: Only send ESC if it was typed twice
Avoids quitting mpv if any unknown escape is entered.
2013-07-26 11:30:10 -03:00
Diogo Franco (Kovensky) 3928b39988 getch2: Handle setupterm errors
setupterm abort()s if it can't initialize the terminal and the last
parameter is NULL; handle setupterm errors and retry with "ansi" if
the TERM env var was unset.
2013-07-26 11:29:34 -03:00
wm4 ca039d42bb getch2: fix compilation 2013-07-26 02:13:35 +02:00
wm4 3bddc16431 options: simplify --correct-pts handling
Remove the (now unused) code for determining correct-pts mode based on
the demuxer in use. Change its description in the manpage to reflect
what this option does now.
2013-07-26 02:11:34 +02:00
Diogo Franco (Kovensky) fb67770ed6 getch2: Support ESC keypresses again
Due to the termcap matching and the hardcoded fallbacks, the ESC keypress
has to be followed by another non-matching keypress (such as another ESC)
for it to be accepted. We drop the second ESC in case it was typed twice.
2013-07-25 21:10:06 -03:00
wm4 590f011df1 configure: fix terminfo check
On Linux, the check fails because NULL is not defined. Fix by using 0
instead, which is a perfectly valid null pointer constant, but doesn't
require stddef.h.
2013-07-26 01:47:02 +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 bd1d3eaacb command: allow printing time properties with milliseconds
Doing e.g. show_text "${time-pos/full}" will show the time formatted
with a milliseconds part.

This is actually special cased for a few properties which use
CONF_TYPE_TIME, instead of making all properties using CONF_TYPE_TIME
respect this. This is a technical limitation.

I'm not entirely happy with this approach, so I'll leave it
undocumented. It's relatively ok, but he fact that it's special-cased to
some properties is not elegant. So for now, this is just a hack to make
ChrisK2 happy (hi there).
2013-07-26 00:19:15 +02:00
wm4 d1d6db25c0 command: add pseudo-property that allows you to read global options
The "options" pseudo-property allows reading global like this:

   show_text ${options/name}

Where "name" maps to the option "--name". This allows retrieving option
values that are not properties. Write-access is not possible: this is
reserved for normal properties.

Note: it is possible that we'll change this again, and don't require the "options/" prefix to access options.
2013-07-26 00:19:15 +02:00
wm4 ad1641c0da m_property: fix non-sense code
Undefined behavior.
2013-07-26 00:19:15 +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
Diogo Franco (Kovensky) 0cfc382355 getch2: Doing it right this time
getch2_pos should be set to 1, not 0, when backtracking. Avoids the
possible infinite loop but correctly.
2013-07-25 13:29:10 -03:00
Diogo Franco (Kovensky) c36a5e0f36 Revert "getch2: Avoid possible infinite loop"
This reverts commit ba95aed6f1.
2013-07-25 13:26:19 -03:00
Diogo Franco (Kovensky) ba95aed6f1 getch2: Avoid possible infinite loop
If the first character is not a valid UTF-8 start code nor is in termcap,
getch2 would enter an infinite loop. Always walk 1 byte in the UTF-8 case
unless it's a valid start code.
2013-07-25 13:24:22 -03:00
Diogo Franco (Kovensky) 1aa0ad2725 Merge branch 'getch2/refactor'
* getch2/refactor:
  configure: Fix bad variable assignment
  getch2, mplayer: Always call load_termcap
  getch2: Remove unused function, fix possible crash
  getch2: Refactor/rewrite
2013-07-25 12:25:31 -03:00
Diogo Franco (Kovensky) 1df1eb0b61 configure: Fix bad variable assignment
Bourne shell hates having spaces before or after the = sign.
2013-07-25 12:24:09 -03:00
Diogo Franco (Kovensky) 5586b02931 getch2, mplayer: Always call load_termcap
getch2 now deals with the cases where we don't have termcap. Add a dummy
load_termcap to getch2-win so we don't get linking errors on mingw.
2013-07-25 12:23:40 -03:00
Diogo Franco (Kovensky) 19b1279bb3 getch2: Remove unused function, fix possible crash
If we still haven't read the full key from the input but it's regardless a
unique match in the database, we could receive a NULL keycode from
keys_search (it's not a full match after all) and proceed to use it.

Don't disable the keycode matching code if we don't have termcap as we can
still match against the hardcoded sequences.
2013-07-25 12:21:22 -03:00
Diogo Franco (Kovensky) 057467f6b3 getch2: Refactor/rewrite
Still uses termcap, but uses terminfo for loading the termcap database if
possible. Adds configure test to find terminfo; skips the termcap test
if terminfo is found since terminfo provides termcap.

Use termcap completely for special keys; if we can't get it from termcap
and it isn't one of the known fallbacks, we ignore its specialness and
treat as a sequence of UTF-8 codes.

Further hardcoded fallbacks can be added by calling keys_push_once in
load_termcap; there is no limit to the amount of keys pushed.

Uses the "ke" and "ks" capabilities to start / exit application mode, which
is necessary on vt100 emulators (including screen, xterm and all terminals
that emulate either of those) to correctly receive arrow keys.

It's now possible to compile getch2 even without termcap, though it won't
be of much use since it'll be unable to detect special keys.

Converted to 4 spaces per tab, prettified some statements.
2013-07-25 00:01:51 -03:00
Diogo Franco (Kovensky) 2c07cb0036 mp_msg: Support colors on cygwin
A cygwin mpv will usually run inside mintty, and even if it were to be run
in a regular console window, the cygwin dll emulates ANSI escapes.
2013-07-24 23:59:05 -03:00
wm4 3f04bf2722 demux_libass: actually set priv context
This was a memory leak: the ASS_Track was never deallocated.
2013-07-24 19:47:22 +02: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 31c271f4ad m_config: don't override profile option if not required
The --profile top-level option is handled specially in m_config.c. But
this code also broke sub-options that happened to be named "profile"
(e.g. when trying to use "-af-add=bs2b=profile=cmoy"). Handle it
specially only if it's the top-level --profile option.
2013-07-24 19:44:10 +02:00
wm4 837377a6ce input: fix dangling pointer issues with multi-part commands
This didn't setup the linked list of sub-commands for multi-part
commands ("a ; b ; c") correctly. Also, the new commands were attached
to the allocation of the _old_ command instead of the new one. (Wow,
whatever the hell I was (not) thinking when I wrote this code.)
2013-07-24 19:43:31 +02:00
wm4 4e7ab517c1 demux_lavf: set keyframe flag on attached pictures
Gives really funky results with PNG attachments otherwise. The main
problem is that avcodec_flush_buffers() does not fully reset the
decoder, so passing multiple PNG packets without keyframe flags will
attempt to combine the new picture with the previously decoded
contents. (Makes no sense with proper PNG - maybe this codepath is
intended for MNG or APNG.)
2013-07-24 19:42:02 +02:00
wm4 782d5ec3a0 mplayer: remove dead code
Attached pictures are now handled specially and on a separate codepath,
so this hack is not needed anymore. Remove it from the normal codepath.
2013-07-24 19:41:24 +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 f32a90a839 audio/out: remove options argument from init()
Same as with VOs in the previous commit.
2013-07-22 22:58:09 +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