Compare commits

...
1730 Commits
Author SHA1 Message Date
Alessandro Ghedini b677937c27 Release 0.5.1 2014-08-26 10:27:40 +02:00
Otto Modinos fdd648bdf9 manpage: mention that mp.commandv doesn't expand properties
The little lua snippet at #488 as well as the actual implementation
seems to indicate that not expanding properties is indeed the correct
behavior.  Document that.

Signed-off-by: wm4 <wm4@nowhere>
2014-08-26 10:24:21 +02:00
Stefano Pigozzi 334fd10f1c coreaudio_device: fix overwriting of user input
Fixes #1030
2014-08-25 11:24:01 +02:00
wm4 226735331c options: compatibility hack for --slave-broken
Seems some programs were still relying on it. Whatever, it's not hard to
support.

CC: @mpv-player/stable
2014-08-25 11:23:30 +02:00
wm4 5523370ab9 player: don't clobber playback position on video end
If video reaches EOF, and audio is also EOF (or is otherwise not
meaningful, like audio disabled), then the playback position was briefly
set to 0. Fix this by not trying to use a bogus audio PTS.

CC: @mpv-player/stable (maybe)
2014-08-25 11:23:26 +02:00
Bin Jin 8c7d61f1d9 manpage: remove duplicated content
Probably be accidentally added in b6b8bffd.

CC: @mpv-player/stable
Signed-off-by: wm4 <wm4@nowhere>
2014-08-25 11:23:05 +02:00
wm4 f021b5a379 etc/mpv.desktop: add audio/flac mimetype
Fixes #1025.

CC: @mpv-player/stable
2014-08-21 15:16:58 +02:00
wm4 43e164964c manpage: fix opengl-hq defaults
The FBO format was changed some time ago.

CC: @mpv-player/stable
2014-08-18 11:14:48 +02:00
Philip Sequeira aeb64723fd TOOLS/zsh.pl: protect global environment 2014-08-17 14:14:48 +02:00
Philip Sequeira f935838b2d TOOLS/zsh.pl: fix a ret that hadn't been changed to rc 2014-08-17 14:14:30 +02:00
Alessandro Ghedini ec46ad79e2 TOOLS/zsh.pl: properly set the return value
The previous commit made the completion script always return non-zero, even when
a match is found. This explicitly sets the return value to zero whenever a match
is found but defaults to non-zero in case nothing is matched.
2014-08-15 16:31:18 +02:00
c_14 d6ccc4d8de TOOLS/zsh.pl: properly return non-zero when no matches are found
Returning a non-zero value signals to the zsh completion system that no matches
were added by the script so that it can try the user-defined matchers (e.g.
those defined with matcher-list).

Fixes #1008.
2014-08-13 23:00:36 +02:00
Alexander Preisinger 8664dc3c47 wayland: pointer interface is created after theme
Just always load the theme. It gets freed properly and dosn't bother anyone.

Fixes #1012.

CC: @mpv-player/stable
2014-08-13 23:00:26 +02:00
wm4 51ce535822 player: don't quit with --loop-file
Fixes #1009.

CC: @mpv-player/stable
2014-08-13 23:00:21 +02:00
Alessandro Ghedini e33df9b7bc vdpau: correctly mark invalid mixer as such on vdp_video_mixer_create() failure
Otherwise vdp_video_mixer_destroy() would later fail when called on an invalid
video mixer handle. With mesa r600 vdpau driver, this would cause a segfault.
2014-08-13 19:16:53 +02:00
wm4 6310bd60e6 vo_vdpau: fix screenshots with anamorphic video
Fixes #1007.

CC: @mpv-player/stable
2014-08-13 10:55:49 +02:00
wm4 6729e39983 DOCS: mark the recent release in client-api-changes.rst
Also add instructions to release-policy.md, since this can be easily
forgotten.

CC: @mpv-player/stable
2014-08-13 10:55:44 +02:00
Alessandro Ghedini 88f247c0af Release 0.5.0 2014-08-12 10:50:38 +02:00
wm4 52f2f67553 input.conf: add some bindings for changing audio-delay
Requested on: https://github.com/mpv-player/mpv/commit/90ec3334174e80c16f00971886223a3afabc1aca#commitcomment-7331673

Might remove or remap them again later.
2014-08-11 23:40:35 +02:00
wm4 3f353f1219 input.conf: make explanatory text more readable
Or at leats this is the intention. It's a bit hard to tell which
information is needed, and which not.
2014-08-11 23:32:37 +02:00
wm4 b8f025a58a video: don't keep multiple pointers to hwdec info struct
This makes a certain corner case simpler at a later point.
2014-08-11 23:09:39 +02:00
wm4 056622c33e vaapi: fix uninitialized value read
Found with valgrind. This is somewhat terrifying, because the VA-API API
function is supposed to fill these values, and we access them only if
the API functions return success. So this shouldn't have happened.
2014-08-11 21:57:41 +02:00
wm4 beceb2fedc vf_vapoursynth: print more diagnostics on error 2014-08-11 21:57:15 +02:00
wm4 bead9766bc manpage: update keybindings 2014-08-11 21:56:37 +02:00
wm4 f9d2ad6c17 Move status-line.lua
Looks like TOOLS/lua/ is now established as dumping ground for random
Lua scripts, so DOCS/lua_examples/ is not needed anymore.
2014-08-11 17:08:32 +02:00
wm4 0ed48f5ec9 player: remove cache status from video OSD 2014-08-11 17:01:20 +02:00
wm4 9dd160ea97 demux: reduce log spam if threading is disabled 2014-08-11 15:55:12 +02:00
wm4 37357e2265 video: fix dangling pointer issue
The function video_decode_and_filter(), called between initializing the
local vf variable and using it, can actually destroy and recreate the
filter. Thus, the vf variable turns into a dangling pointer if that
happens.

Could be observed with: --hwdec=vda --deinterlace=yes --vf=yadif

(Also happens with vdpau/vaapi.)
2014-08-11 15:37:13 +02:00
wm4 33a8e2a9ad vdpau: allocate surfaces by age
Whether this helps is probably questionable and depends on the GPU. But
the vaapi code does it too.
2014-08-11 14:03:53 +02:00
wm4 ef9b399020 input: fix event wakeup
When a new event was added, merely a flag was set, instead of actually
waking up the core (if needed). This was ok in ancient times when all
event sources were part of the select() loop. But now there are several
cases where other threads can add input, and then you actually need to
wakeup the core in order to make it read the events at all.
2014-08-11 13:50:56 +02:00
wm4 bce48f30d2 input.conf: change LEFT/RIGHT keys to seek 5s instead of 10s 2014-08-11 13:37:18 +02:00
wm4 a87005b7fa command: for OSD, format cache property as integer
For convenience. Use ${=cache} to get the old formatting.
2014-08-11 13:30:08 +02:00
wm4 b016f92309 command: fix dangling pointer issue in script key bindings code
This code was sending a string to a different thread, and then
deallocated the string shortly after, which means most of the time
the other thread was accessing a dangling pointer.

It's possible that this is the cause for #1002.
2014-08-11 13:00:57 +02:00
wm4 ece61bfa10 player: don't delay OSD redraw when paused
We want this heuristic to trigger during normal playback only.
2014-08-10 13:24:29 +02:00
wm4 f5257e2c7d vo_sdl: fix redrawing issue
vo_sdl.c has broken event handling and just polls. The polling time was
quite low, so the playloop OSD redrawing heuristic inhibited redraws,
which made the window appear frozen when paused.
2014-08-10 13:24:29 +02:00
wm4 2a403092cd input.conf: map shift+pgup/dwn to the old seek bindings 2014-08-09 02:24:10 +02:00
wm4 8dfe0c73c9 video: remove "hard" framedrop mode
Completely useless, and could accidentally be enabled by cycling
framedrop modes. Just get rid of it.

But still allow triggering the old code with --vd-lavc-framedrop, in
case someone asks for it. If nobody does, this new option will be
removed eventually.
2014-08-09 00:35:35 +02:00
wm4 91be5e5c31 etc/example.conf: update cache options
Some of them changed semantics or got renamed.

Note that the replacements in the example.conf are not necessarily the
equivalents of the replaced options.
2014-08-09 00:13:16 +02:00
wm4 26d69758f6 command: run OSD display code even if a property is unavailable
Trying to jump chapters in a gile that has no chapters does nothing,
not even show a warning. This is confusing. The reason is that the
"add chapter" command will just bail out completely if the property
is unavailable.

This was because it exited when it couldn't get the property type.
Instead of exiting, just don't enter the code that needs the type.

(I'm not sure when this behavior changed. I consider it a regression.
It was probably caused by changes to the chapter code, which perhaps
started returning UNAVAILABLE instead of OK if there are no chapters.)
2014-08-09 00:08:04 +02:00
wm4 e0fb2a4f2d etc: add mplayer-input.conf 2014-08-09 00:08:04 +02:00
wm4 8b48b3fd3b input.conf: switch chapter seek next/previous keys
"UP" seeks forward, so "PGUP" should skip to the next chapter.

Fixes #998.
2014-08-08 23:26:03 +02:00
wm4 c4feba847c manpage: update key bindings 2014-08-08 12:06:01 +02:00
Alexander Preisinger b6b8bffd2d manpage: add sections and order by usage
Split the options into the following sections:

 * Playback Control
 * Program Behaviour
 * Video
 * Audio
 * Subtitles
 * Window
 * Disc Devices
 * Equalizer
 * Demuxer
 * Input
 * OSD
 * Screenshot
 * Software Scaler
 * Terminal
 * TV
 * Cache
 * Network
 * DVB
 * PVR
 * Miscellaneous

Most options are sorted by usefullness and how often they're used or how
important they are.
This makes finding the right options easier and adds some sort of structure.
2014-08-08 08:30:06 +02:00
wm4 b4f72b46e5 ao_dsound: reduce default buffer size
Reduce from 1000ms to 100ms. Since there is an audio thread updating AOs
quickly enough now, requesting such a large buffer size makes no sense
anymore.
2014-08-08 01:56:23 +02:00
wm4 90ec333417 input.conf: unmap some more obscure bindings
Changing audio-delay is probably not needed.

Changing balance "works", but not as expected (sets up a pan matrix to
change left/right contributions to each other, rather than changing the
relative volumes of each channel).

I expect that the rest are not in use by anyone.
2014-08-08 00:43:14 +02:00
wm4 fa682af6ee command: add a "seeking" property
The client API exports this state via events already, but maybe it's
better to explicitly provide this property in order to facilitate use on
OSD and similar cases.
2014-08-08 00:16:20 +02:00
wm4 5f042864f5 player: indicate on the status line whether a seek is active
This is delayed by 300ms - before that, the status doesn't change. I
feel like it would too annoying if the status line would "flicker" on
normal seek by quickly showing and hiding the indicator.
2014-08-08 00:05:24 +02:00
wm4 e1ff914679 input.conf: remap pgup/dwn to chapter seeks
As discussed in #973.

Keep the old bindings for now; there's no reason to unmap them yet.
2014-08-07 23:55:09 +02:00
wm4 7898169484 build: add hacks to force waf to generate valid .pc files
Don't like this? You're invited to fix this crap.
2014-08-07 23:45:40 +02:00
wm4 5906041343 input: fix off by one error in command parser
Should fix #989.
2014-08-07 18:21:36 +02:00
wm4 886ac09699 audio: fix encoding mode
If this code is not skipped, encoding (or dumping with --ao=pcm) will
attempt to adjust video timing to audio. Since another commit (0cce8fe6)
already avoids writing audio ahead, this didn't slow down encoding to
realtime, but it was still significantly slower.

This change should actually remove all extra sleeping.
2014-08-07 18:07:43 +02:00
wm4 483595e2d4 client API: qtexample: don't pass deallocated strings to mpv
The temporary QByteArray is deallocated already at the end of the
statement in C++, instead of the end of the scope (like in C).
2014-08-07 00:35:38 +02:00
wm4 1483fd443a demux: fix playback abort if --demuxer-thread is not used
Switching tracks caused cached_demux_control() to catch the command to
switch tracks, even if no thread was running. Thus, the tracks were
never really switched, and EOF happened immediately on playback start.

Fix it by not using the cache at all if the demuxer thread is disabled.
The cache code still has to be called somewhere, though, because it
handles stream metadata update.

Regression from today.
2014-08-07 00:34:14 +02:00
wm4 af57444bcb player: remove unused declaration 2014-08-07 00:30:43 +02:00
wm4 dfc5d96916 gitignore: fix manpage entries 2014-08-06 20:35:55 +02:00
wm4 41ff8a661b old-build: HAVE_COCOA_APPLICATION must be set
Also fix a typo in the Makefile manpage rule.
2014-08-06 20:33:51 +02:00
wm4 3234f5a123 stream_dvb: restore --dvbin-file option
Got lost some time ago. Although I'm not sure if it actually does
anything on MPlayer (it exists there, but might broken, not sure).

Fixes #988 (untested).
2014-08-06 20:30:48 +02:00
wm4 796db66174 stream_dvb: fix channels.conf preference order
channels.conf was never used (even though its config path was resolved).

Also remove the non-sense with the access() call.

Fixes #987 (untested).
2014-08-06 20:30:47 +02:00
wm4 19fd67096b vo_direct3d: allow resizing before video init
This can just happen in the time between VO creation, and the first call
to vo_reconfig. It seems the recent threading changes exposed this bug.

Fixes #986.
2014-08-06 20:30:47 +02:00
wm4 77ad49411a win32: never call GetClientRect(0, ...)
Sometimes GetClientRect() appeared to fail during init, and since we
don't check GetClientRect() calls (because they're on our own window,
and logically can never fail), bogus resizes were triggered. This could
cause vo_direct3d to fail initialization.

The reason was that w32->window was set to 0 during early window
initialization: CreateWindow*() can send messages to the new window,
even though it hasn't returned yet. This means w32->window is not yet
set to our window handle, and functions in WndProc may accidentally pass
hwnd=0 to win32 API functions.

Fix it by initializing w32->window on opportunity. This also means we
always strictly expect that the WndProc is used with our own window
only.
2014-08-06 20:30:47 +02:00
wm4 64e1132d39 demux: make track switching asynchronous
Because why not.

This can lead to reordering of operations between seeking and track
switching (happens when the demuxer wakes up after seek and track
switching operations were queued). Do the track switching strictly
before seeks if there is a chance of reordering, which guarantees that
the seek position will always start with key frames. The reverse
(seeking, then switching) does not really have any advantages.

(Not sure if the player relies on this behavior.)
2014-08-06 20:30:47 +02:00
wm4 b38ac38aec client API: trigger MPV_EVENT_VIDEO_RECONFIG on vf recreation
Until now, it was done only on VO reconfig, but this easily can miss
some events, in case the VO output format doesn't change.
2014-08-06 20:30:47 +02:00
wm4 be64535a4e audio: fix inverted condition
Recent regression. Could perhaps make gapless audio fail to work
correctly.
2014-08-06 20:30:46 +02:00
Alexander Preisinger 6ec39b4641 wayland: remove redundant line 2014-08-06 12:58:39 +02:00
Alexander Preisinger f175f2c38f wayland: changes for nested compositors
Adds necessary checks for nested compositors which only have limited
interfaces. Might also be useful for other minimal compositors.
2014-08-06 12:55:51 +02:00
Stefano Pigozzi 2e241c0a47 build: allow to disable building the cplayer 2014-08-06 09:31:59 +02:00
Stefano Pigozzi 212374149f build: expose waf variants to the user
This allows the user to execute multiple configuration and build steps. It
can be used for several scenarios where you need different compiler flags.
2014-08-06 09:31:59 +02:00
Stefano Pigozzi c8cf864bff cocoa: fix build by using the correct HAVE_* macro
This builds but both the libmpv example and the cplayer block infinitely when
building libmpv. That's because we wait inifinitely in `dispatch_sync` as
there's no event loop in the main thread that allows for libdispatch to work..

Whiel we are at it, we should probably investigate how to use mp_dispatch
instead since it is a little lower level and could give us higher control in
building and event loop.
2014-08-06 09:31:59 +02:00
FRAU KOUJIRO b8a431c892 cocoa: macosx_application needs cocoa-application 2014-08-06 09:31:59 +02:00
FRAU KOUJIRO 022a43de8e build: cocoa-application config target
I had to put it after video options because it depends on cocoa;
is there anywhere better to put it rather than making a new group?
2014-08-06 09:31:59 +02:00
FRAU KOUJIRO 0be25a8dbf cocoa: move handleFilesArray: to macosx_events 2014-08-06 09:31:58 +02:00
FRAU KOUJIRO 4fc8dcde2a cocoa: move set_input_context to macosx_events 2014-08-06 09:31:58 +02:00
FRAU KOUJIRO 78a2d99de1 cocoa: sync inputContext inside EventsResponder 2014-08-06 09:31:58 +02:00
FRAU KOUJIRO 78a266d599 cocoa: decouple events from application somewhat 2014-08-06 09:31:58 +02:00
wm4 ff6c387a73 win32: fix build 2014-08-05 23:43:40 +02:00
wm4 5a0db9bf8a build: move def file to libmpv/
This is more consistent with mpv.pc, which is also in libmpv/.
2014-08-05 20:02:41 +02:00
wm4 210c83ab31 win32: create OpenGL context on the GUI thread
This fixes the fullscreen issues on Intel for me. I'm baffled by it and
don't understand why this suddenly works. Intel drivers being shit?
Windows being shit? HWND or HDC being only 97% thread-safe instead of
98%? Me missing something subtle that is not documented anywhere?

Who knows.

Now instead of creating the HDC and OpenGL context on the renderer
thread, they're created on the GUI thread. The renderer thread will
then only call wglMakeCurrent, SwapBuffers, and OpenGL standard
functions.

Probably fixes github issue #968.
2014-08-05 20:02:23 +02:00
wm4 afcbee8305 win32: cleanup OpenGL context creation
Might handle some corner cases better. In particular, always call
wglMakeCurrent() with non-NULL HDC argument.
2014-08-05 19:59:32 +02:00
Stefano Pigozzi 8af0d9fec8 build: syms: reindent
We avoided reindenting this in the past to allow merging upstream changes.
In hindsight these are very unlikely and we are actually doing changes on
the code, so it's better to have the correct indentation and formatting in
our source file.
2014-08-05 12:57:34 +02:00
Stefano Pigozzi b34621e1b1 build: syms: fix *.def file for mach-o binary format
There was a missing trailing newline which caused some warnings when calling
`ld`.
2014-08-05 12:13:27 +02:00
wm4 9a6d7af074 options: fix key-value-list options
The parser can be called with dst (the target) set to NULL if the option
should be verified only. The code didn't respect this, and could result
in crashes when used in config profiles or filter sub-options.

Fixes #981.
2014-08-05 02:24:45 +02:00
wm4 43ddf2099b client API: add and use the MPV_MAKE_VERSION macro
This is probably nicer. The actual version number doesn't change (other
than the minor being incremented).

The "| 0UL" is to make the type unsigned long int, like it was before.
2014-08-05 02:23:14 +02:00
wm4 bdf607ea5f build: list exported symbols explicitly
Instead of using a regex to match names to be exported from the libmpv
dynamic shared library, use a libmpv.def file, which lists all exported
functions explicitly.

This reduces the platform specifics in syms.py. I'm not sure if the
separate compile_sym task is still needed (it could probably be
collapsed, which would concentrate the platform specifics into one
place).
2014-08-05 02:21:29 +02:00
wm4 62a79ae556 build: fix export of libmpv symbols on mingw
The _ usually prefixed to functions on Windows was unexpectedly missing.
2014-08-05 01:02:54 +02:00
wm4 91fbaa7d34 build: fix cross-compilation of libmpv
libmpv requires nm for creating the list of exported symbols (this is
done in syms.py). We should probably just make this list static instead,
but since this involves platform-specific code, for now this quick-fix
will do.
2014-08-05 00:20:31 +02:00
wm4 d634f7b01a vdpau: don't crash on flipped images
It seems the vdpau API does not support these.

Do a semi-expensive emulation of it. On the other hand, it's not like
this is a commonly-used feature. (It might be better to make --vf=flip
always copy instead of flipping it via pointer tricks - but everything
allows flipped images, and even decoders or libavfilter filters could
output them.)
2014-08-05 00:18:57 +02:00
wm4 ee6df2f76c sub: fix subtitle timing for TS
The subtitle timing logic always used the demuxer's start time as video
offset. This made external subtitle files "just work" with file formats
like TS, which usually have a non-0 start time. But it was wrong for
subtitles muxed with the TS, so adjust the time offset explicitly with
external files only.
2014-08-04 18:17:30 +02:00
wm4 922b1d8504 sub: don't read packets if video and audio are disabled
Although disabling both video and audio is surely an obscure corner
case, it's allowed, and we don't want the demuxer to skip arbitrary
packets.

Basically, make the heuristic for checking interleaved files affect
external files only.
2014-08-04 18:17:30 +02:00
Michael Forney 618361c697 gl_wayland: Don't try to resize the egl_window before it exists
If the compositor sends a configure event immediately after a window is
created (for example, if it implements tiling window management), mpv
will attempt to call wl_egl_window_resize before it has actually created
the egl_window, causing a crash.
2014-08-04 09:50:24 +02:00
wm4 913b49fcbc input.conf: remap 2 keys
Nobody uses 'c' (except accidentally) - remove.

Everyone agrees that OSD level cycling on 'o' is dumb, so map it to
show_progress instead. Cycling the OSD level is now available on 'O'.
No reason to ummap 'P' yet.

Also see issue #973.
2014-08-03 21:15:33 +02:00
wm4 0f5aed9c62 player: some further playloop cleanups
Handle --term-playing-msg at a better place.

Move MPV_EVENT_TICK hack into a separate function. Also add some words
to the client API that you shouldn't use it. (But better leave breaking
it for later.)

Handle --frames and frame_step differently. Remove the mess from the
playloop, and do it after frame display. Give up on the weird semantics
for audio-only mode (they didn't make sense anyway), and adjust the
manpage accordingly.
2014-08-03 20:31:00 +02:00
wm4 0ddbf92d06 player: make quit exit immediately
Stopping playback canceled waiting, but executed the remainder of the
playloop, including things like executing pointless seeks.
2014-08-03 20:30:39 +02:00
wm4 575314eafa player: allow redrawing screen during seeks
If seeks take very long, it's better not to freeze up the display.

(This doesn't handle the case when decoding video frames is extremely
slow; just if hr-seek is used, or the demuxer is threaded and blocks on
network I/O.)
2014-08-03 20:30:34 +02:00
wm4 27301ee691 manpage: be more explicit where input.conf is located 2014-08-02 06:57:36 +02:00
wm4 d68a759fa4 Improve setting AVOptions
Use OPT_KEYVALUELIST() for all places where AVOptions are directly set
from mpv command line options. This allows escaping values, better
diagnostics (also no more "pal"), and somehow reduces code size.

Remove the old crappy option parser (av_opts.c).
2014-08-02 03:12:33 +02:00
wm4 0c6c2da8bc manpage: explain how to replace --slave-broken 2014-08-02 03:12:33 +02:00
wm4 c94e8bcdd6 player: don't show the path part for external subtitle files
Show the filename only. Feature request on IRC.
2014-08-02 03:12:31 +02:00
wm4 733bdebcb9 client API: minor optimizations for property notification
Internally, there are two mechanisms which can trigger property
notification as used with "observed" properties in the client API.

The first mechanism associates events with a group of properties that
are potentially changed by a certain event. mp_event_property_change[]
declares these associations, and maps each event to a set of strings.
When an event happens, the set of strings is matched against the list of
observed properties of each client. Make this more efficient by
comparing bitsets of events instead. This way, only a bit-wise "and" is
needed for each observed property. Even better, we can completely skip
clients which have no observed properties that match.

The second mechanism just updates individual properties explicitly by
name. Optimize this by using the property index instead. It would be
nice if we could reuse the first mechanism for the second one, but
there are too many properties to fit into a 64 bit mask.

(Though the limit on 64 events might get us into trouble later...)
2014-08-02 01:53:22 +02:00
wm4 82a223e4e0 TOOLS: add test script for property change notifications 2014-08-02 01:53:21 +02:00
wm4 be337aa415 command: add a property that returns a list of all properties
Also remove the undocumented Lua mp.property_list() function.
2014-08-02 01:53:21 +02:00
wm4 16e5ec88e1 manpage: remove duplicated misplaced description of a command 2014-08-02 01:53:18 +02:00
wm4 aa46968ed0 win32: fix assertion failure
If OpenGL 3.x doesn't work, the fallback to legacy GL will call the
function to create the DC again, and it will assert. Just make it not
to, and also simplify the code a bit.

Fixes #974.
2014-08-01 23:03:52 +02:00
wm4 bf5b1e9a05 Remove the last remains of slave mode
Almost nothing was left of it.

The only thing this commit actually removes is support for reading
input commands from stdin. But you can emulate this via:

 --input-file=/dev/stdin --input-terminal=no

However, this won't work on Windows. Just use a named pipe.
2014-08-01 22:57:56 +02:00
Stefano Pigozzi 6aac17cebb vda: only support the new hwaccel 1.2 API (remove old code)
Since the new hwaccel API is now merged in ffmpeg's stable release, we can
finally remove support for the old API.

I pretty much kept lu_zero's new code unchanged and just added some error
printing (that we had with the old glue code) to make the life of our users
less miserable.
2014-08-01 10:38:18 +02:00
Stefano Pigozzi 33137606e9 travis: use homebrew to build ffmpeg on OS X
This allows us to use a newer version of ffmpeg and to test the build of our
VDA code.
2014-08-01 10:38:18 +02:00
wm4 33f465d9a7 player: don't ignore first chapter
It's a mystery why this was done this way. If the first chapter starts
later than the current position, we do have to return -1.
2014-07-31 22:54:57 +02:00
wm4 de8e9ca9d2 video: fix attached picture mode
Playing audio files with embedded cover art broke due to some of the
recent changes. Treat video EOF properly, and don't burn the CPU.
Disable hrseek for video in attached picture mode, since the decoder
will always produce a new image, which makes hrseek never terminate.

Fixes #970.
2014-07-31 21:57:11 +02:00
wm4 4cf3f3ca2c audio: simplify condition
The expression added with the previous commit (0cce8fe6) looked slightly
more complicated than it has to be. The code is equivalent.
2014-07-31 21:11:49 +02:00
wm4 0cce8fe64f audio: fix A/V sync in encoding mode
In encoding mode, the AO pretends to be infinitely fast (it will take
whatever we write, without ever rejecting input). Commit 261506e3 broke
this somehow. It turns out an old hack dealing with this was accidentally
dropped.

This is the hunk of code whose semantics were (partially) dropped:

    if (mpctx->d_audio && (mpctx->restart_playback ? !video_left :
                           ao_untimed(mpctx->ao) && (mpctx->delay <= 0 ||
                                                     !video_left)))
    {
        int status = fill_audio_out_buffers(mpctx, endpts);
        // Not at audio stream EOF yet
        audio_left = status > -2;
    }

This if condition is pretty wild, and it looked like it was pretty much
for audio-only mode, rather than subtle handling for encoding mode.
2014-07-31 04:49:44 +02:00
wm4 a1b54d3b89 client API: don't send internal events to the clients
"Internal" events were added in the previous commits to leverage the
client API property mechanism, without making weird properties public.

But they were sent to clients too (and returned by mpv_wait_event()).
2014-07-31 04:35:23 +02:00
wm4 c1b64cc693 command: add cache-idle property 2014-07-31 04:25:39 +02:00
wm4 b4f24544bb client API: make "cache" property and similar observable
Achieve this by polling. Will be used by the OSC. Basically a bad hack -
but the point is that the mpv core itself is in the best position to
improve this later.
2014-07-31 04:19:41 +02:00
wm4 aaa90e1a33 client API: fix deadlock when calling mpv_terminate_destroy before init
This is perfectly allowed, but was ignored, because it's a corner case.

It doesn't actually wait for other clients to be destroyed, but on the
other hand I think there's no way to have other clients before
initialization.

CC: @mpv-player/stable
2014-07-31 03:12:18 +02:00
wm4 dacbaea1a8 player: rename a variable
Make it clear that this condition happens when switching to a new
timeline segment. It doesn't even need to coincide with a chapter.
2014-07-30 23:29:01 +02:00
wm4 1423bd0bfd player: move video display code out of the playloop
Basically move the code from playloop.c to video.c. The new function
write_video() now contains the code that was part of run_playloop().

There are no functional changes, except handling "new_frame_shown"
slightly differently. This is done so that we don't need new a new
MPContext field or a return value for write_video() to signal this
condition. Instead, it's handled indirectly.
2014-07-30 23:29:00 +02:00
wm4 8f2e9f1d61 player: split seek_reset()
This also reduces some code duplication with other parts of the code.

The changfe is mostly cosmetic, although there are also some subtle
changes in behavior. At least one change is that the big desync message
is now printed after every seek.
2014-07-30 23:29:00 +02:00
wm4 c38013bffb video: actually flush filter chain
Frames buffered in filters weren't flushed, so on EOF, the last frames
were dropped, depending on how much filters buffered. Oops.

Test case: "mpv something.jpg --vf=buffer"
2014-07-30 23:29:00 +02:00
wm4 f8ab732ac3 video/filter: add vf_buffer
Mostly useful for debugging.
2014-07-30 23:29:00 +02:00
wm4 8d990408d7 audio: better sync behavior on bogus EOF
In situations when the demuxer reports EOF, but immediately "recovers"
after that and returns new data, it could happen that audio sync was
skipped. Deal with this by actually entering the EOF state, instead of
assuming this will happen later.
2014-07-30 23:29:00 +02:00
wm4 6afa1a2afc ao_alsa: disable use of non-interleaved formats by default
Some ALSA plugins take non-interleaved audio, but treat it as
interleaved, which results in various funny bugs. Users keep hitting
this issue, and it just doesn't seem worth the trouble.

CC: @mpv-player/stable
2014-07-30 23:28:44 +02:00
Stefano Pigozzi c3d15b50b4 cocoa: fix key equivalent dispatching
Prior to this commit we had a list of key modifiers and checked against that.
Actually, the Cocoa framework has a built in way to do it and it involves
calling performKeyEquivalent: on the menu instance.

Fixes #946

cc @mpv-player/stable: this should apply with no conflicts
2014-07-30 11:26:49 +02:00
wm4 471dfba018 client API: fix typos in documentation 2014-07-30 03:33:37 +02:00
wm4 0dd5228626 demux_lavf: don't consider EAGAIN as EOF condition
This happens apparently randomly with rtmp:// and after seeks. This
eventually leads to audio decoding returning an EOF status, which
basically disables audio sync. This will lead to audio desync, even if
audio decoding later "recovers" when the demuxer actually returns audio
packets.

Hack-fix this by special-casing EAGAIN.
2014-07-30 03:32:56 +02:00
wm4 6856d81c68 stream: hack-fix rtmp-level seeking
This didn't work, because the timebase was wrong. According to the
ffmpeg doxygen, if the stream index is -1 (which is what we used), the
timebase is AV_TIME_BASE. But this didn't work, and it really expected
the stream's timebase. Quite "surprising", since this feature
(avio_seek_time) is used by rtmp only.

Fixing this properly is too hard, so hack-fix our way around it.
STREAM_CTRL_SEEK_TO_TIME is also used by DVD/BD, so a new
STREAM_CTRL_AVSEEK is added. We simply pass-through the request
verbatim.
2014-07-30 02:21:51 +02:00
wm4 26d973ce82 stream_lavf: allow setting AVOptions with --stream-lavf-o
This commit also creates a private option struct for stream_lavf.c, but
since I'm lazy, I'm not moving any existing options to it.
2014-07-30 01:15:42 +02:00
wm4 da780309d7 audio: better initial sync for files where audio starts later
Some files have the first audio much later into the video (for whatever
reasons). Instead of appending large amounts of silence to the audio
buffer (and refusing to sync if the audio to append is "too large"),
just wait until enough video has played.
2014-07-30 00:40:45 +02:00
wm4 1cd2b5976d audio: cosmetics: remove unused return value 2014-07-30 00:24:57 +02:00
wm4 6b928fa2a0 demux_mf: allow seeking past the end
How's this for a corner case.
2014-07-30 00:23:16 +02:00
wm4 593ad996e0 player: fix time display wheen seeking past EOF with --keep-open
Regression since commit 261506e3. Internally speaking, playback was
often not properly terminated, and the main part of handle_keep_open()
was just executed once, instead of any time the user tries to seek. This
means playback_pts was not set, and the "current time" was determined by
the seek target PTS.

So fix this aspect of video EOF handling, and also remove the now
unnecessary eof_reached field.

The pause check before calling pause_player() is a lazy workaround for
a strange event feedback loop that happens on EOF with --keep-open.
2014-07-30 00:22:38 +02:00
wm4 b6a7c321db player: let explicitly imprecise seeks cancel precise seeks
If an imprecise seek is issues while a precise seek is ongoing,
don't wait up to 300ms (herustistic which usually improves user
experience), but instead let it cancel the seek.

Improves responsiveness of the OSC after the previous commit.

Note that we don't do this on "default-precise" seeks, because we
don't know if they're going to be precise or not.
2014-07-29 20:04:08 +02:00
ChrisK2 48f4f791f4 osc: Do precise seeks on simple clicks on seekbar 2014-07-29 19:26:32 +02:00
wm4 63d1d53d2f audio: ignore (some) decoding errors on initialization
It probably happens relatively often that the first packet (or even the
first N packets) of a stream will fail to decode, but decoding will
eventually succeed at a later point. Before commit 261506e3, this was
handled by an explicit retry loop (although this was also for other
purposes), but with then was changed to abort on the first error. This
makes it impossible to decode some audio streams.

Change this so that errors are ignored for the first 50 packets, which
should make it equivalent to the old code.
2014-07-29 18:05:55 +02:00
wm4 862d7d8a1a player: fix desync when seeking and switching external tracks
If you for example use --audio-file, disable the external track, seek,
and enable the external track again, the playback position of the
external file was off, and you would get major A/V desync. This was
actually supposed to work, but broke at some time ago (probably commit
2b87415f). It didn't work, because it attempted to seek the stream if it
was already selected, which was always true due to
reselect_demux_streams() being called before that.

Fix by putting the initial selection and the seek together.
2014-07-29 17:55:28 +02:00
wm4 6d15c491b0 player: remove a pointless field 2014-07-29 01:00:54 +02:00
wm4 25ceb3289d player: disable hr-seek in .ts files
Seeking in .ts files (and some other formats) is too unreliable, so
there's a separate code path for this case. But it breaks hr-seek.

Maybe hr-seek could actually be enabled in this case if we're careful
enough about timestamp resets, but for now nothing changes.
2014-07-29 00:59:00 +02:00
wm4 d6445d7ab6 player: allow precise seeking with percent seeks
I'm not sure why this was explicitly disabled. It's from mplayer2 times.
2014-07-29 00:26:52 +02:00
wm4 ecad4a20de manpage: lua: document timer timeout and oneshot fields
Might be useful for scripts, so document them. (Which means scripts
are allowed to use them, without risking breakage.)
2014-07-29 00:22:21 +02:00
wm4 fa34b4920a vdpau: don't upload video images in advance
With software decoding, images were uploaded to vdpau surfaces as they
were queued to the VO. This makes it slightly more complicated
(especially later on), and has no advantages - so stop doing it.

The only reason why this was done explicitly was due to attempts to keep
the code equivalent (instead of risking performance regressions). The
original code did this naturally for certain reasons, but now that we
can measure that it has no advantages and just requires extra code, we
can just drop it.
2014-07-29 00:21:02 +02:00
wm4 d563dc8cb9 player: update playback position on seek
If the actual PTS is not known yet right after a seek, the "time-pos"
property will just return the seek target PTS. For this purpose, trigger
a change event to make the client API update the "time-pos" and related
properties. (MPV_EVENT_TICK triggers this update.)
2014-07-29 00:20:54 +02:00
wm4 846257da13 player: logically speed up seek logic
Commit 261506e3 made constant seeking feel slower, because a subtle
change in the restart logic makes it now waste time showing another
video frame. The slowdown is about 20%.

(Background: the seek logic explicitly waits until a video frame is
displayed, because this makes it easier for the user to search for
something in the video. Without this logic, the display would freeze
until the user stops giving seek commands.)

Fix this by letting the seek logic issue another seek as soon as the
first video frame is displayed. This will prevent it from showing a
(useless, slow) second frame. Now it seems to be as fast as before the
change.

One side-effect is that the next seek happens after the first video
frame, but _before_ audio is restarted. Seeking is now silent. I guess
this is ok, so we don't do anything about it. Actually, I think whether
this happens is probably random; the seeking logic simply doesn't make
this explicit, so anything can happen.
2014-07-28 22:13:42 +02:00
wm4 26bfcc9c82 vo_x11: fix build with older Libav versions
Why does this happen everytime...
2014-07-28 21:48:43 +02:00
Niklas Haas d0a8b571c9 video: add a default color space for files with no video
Usually mp_image_params_guess_csp takes care of finding *some* default
for a video channel, but files with no video (or with extremely broken
configurations) end up leaving the colorspace information as
MP_CSP_PRIM_AUTO, which has no associated primaries.

As a result of this, color managed OSD messages could not display
because they were being color managed to match the (non-existing/absurd)
video channel. With this change, such non-spaces will have BT.709
primaries as far as color management and the OSD is concerned.

This fixes #961.

CC: @mpv-player/stable

Signed-off-by: wm4 <wm4@nowhere>
2014-07-28 21:24:44 +02:00
wm4 261506e36e audio: change playback restart and resyncing
This commit makes audio decoding non-blocking. If e.g. the network is
too slow the playloop will just go to sleep, instead of blocking until
enough data is available.

For video, this was already done with commit 7083f88c. For audio, it's
unfortunately much more complicated, because the audio decoder was used
in a blocking manner. Large changes are required to get around this.
The whole playback restart mechanism must be turned into a statemachine,
especially since it has close interactions with video restart. Lots of
video code is thus also changed.

(For the record, I don't think switching this code to threads would
make this conceptually easier: the code would still have to deal with
external input while blocked, so these in-between states do get visible
[and thus need to be handled] anyway. On the other hand, it certainly
should be possible to modularize this code a bit better.)

This will probably cause a bunch of regressions.
2014-07-28 21:20:37 +02:00
wm4 58255e0e2b input: be stricter about rejecting mouse input with --no-input-cursor
Apparently this switch means all mouse input should be strictly
rejected. Some VO backends (such as X11) explicitly disable all mouse
events if this option is set, but others don't. So check them in
input.c, which increases consistency.
2014-07-27 22:00:55 +02:00
wm4 4c533fbb16 vo: remove vo_mouse_movement() wrapper
So that VO backends don't have to access the VO just for that.
2014-07-27 21:53:29 +02:00
wm4 89391e7c94 vo: different hack for VOs which need to mangle mouse input
Follow up on commit 760548da. Mouse handling is a bit confusing, because
there are at least 3 coordinate systems associated with it, and it
should be cleaned up. But that is hard, so just apply a hack which gets
the currently-annoying issue (VO backends needing access to the VO) out
of the way.
2014-07-27 21:33:11 +02:00
wm4 bc6359313f ao_pulse: allow disabling timing bug workarounds
Add an option that enables using native PulseAudio auto-updated timing
information, instead of the manual calculations added in mplayer2 times.
You can use --ao=pulse:no-latency-hacks to enable the new code. The code
is almost the same as the code that was removed with commit de435ed5,
but I didn't readd some bits I didn't understand. Likewise, the option
will disable the code added with that commit.

In my tests this seemed to work well, though the A/V sync display looks
funny when seeking.

The default is still the old behavior.

See issue #959.
2014-07-26 23:20:09 +02:00
wm4 77d9e4b8a9 ao_pulse: remove hacks for ancient PulseAudio versions
This was needed by very old (0.9) versions only. Get rid of it.

Unfortunately, I can't cross-check with the original bug report, since
the bug URL leads to this:

Internal Server Error

TracError: IOError: [Errno 2] No such file or directory: '/home/lennart/svn/trac/pulseaudio/VERSION'
2014-07-26 23:19:48 +02:00
wm4 3c7675ae9a manpage: eliminate the word "movie"
It's evil and sounds outdated. Use the words "media" and "video"
instead.

Closes #935.
2014-07-26 23:19:47 +02:00
wm4 025431a7ae win32: remove minor non-sense
This is done in the wrong thread. Was harmless and had no effect at all.
2014-07-26 23:19:43 +02:00
wm4 97a82bcd56 win32: move window handling to a separate thread
The windows message loop now runs in a separate thread. Rendering,
such as with Direct3D or OpenGL, still happens in the main thread.

In particular, this should prevent the video from freezing if the
window is dragged. (The reason was that the message dispatcher won't
return while the dragging is active, so mpv couldn't update the
video at all.)

This is pretty "rough" and just hacked in, and there's no API yet to
make this easier for other backends. It will be cleaned up later
once we're sure that it works, or when we know how exactly it should
work. One oddity is that OpenGL is actually completely managed in the
renderer thread, while e.g. Cocoa (which has its own threading code)
creates the context in the GUI thread, and then lets the renderer
thread access it.

One strange issue is that we now have to stop WM_CLOSE from actually
closing the window. Instead, we wait until the playloop handles the
close command, and requests the VO to shutdown. This is done mainly
because closing the window apparently destroys it, and then WM_USER
can't be handled anymore - which means the playloop has no way to
wakeup the GUI thread. It seems you can't really win here... maybe
there's a better way to have a thread receive messages with and
without a window, but I didn't find one yet.

Dragging the window (by clicking into the middle of it) behaves
strangely in wine, but didn't before the change. Reason unknown.
2014-07-26 20:36:46 +02:00
wm4 760548da28 vo: hack to avoid threading issues with mouse input
VO backends which are or will run in their own thread have a problem
with vo_mouse_movement() calling vo_control(). Restrict this to VOs
which actually need this.
2014-07-26 20:31:26 +02:00
wm4 3f268cc4f2 win32: use gcc TLS instead of WM_NCCREATE tricks for window context
win32 does not provide a proper per-window context pointer. Although it
does allow passing a user-chosen value to WM_CREATE/WM_NCCREATE, this
is not enough - the first message doesn't even have to be WM_NCCREATE.
This gets us in trouble later on, so go the easy route and just use a
TLS variable.

__thread is gcc specific, but Windows is a very "special" platform
anyway. We support only MinGW and Cygwin on it, so who cares. (C11
standardizes __thread as _Thread_local; we can use that later.)
2014-07-26 20:30:52 +02:00
wm4 559fe1daac Add Plan 9-style barriers
Plan 9 has a very interesting synchronization mechanism, the
rendezvous() call. A good property of this is that you don't need to
explicitly initialize and destroy a barrier object, unlike as with e.g.
POSIX barriers (which are mandatory to begin with). Upon "meeting", they
can exchange a value.

This mechanism will be nice to synchronize certain stages of
initialization between threads in the following commit.

Unlike Plan 9 rendezvous(), this is not implemented with a hashtable,
because that would require additional effort (especially if you want to
make it actually scele). Unlike the Plan 9 variant, we use intptr_t
instead of void* as type for the value, because I expect that we will be
mostly passing a status code as value and not a pointer. Converting an
integer to void* requires two cast (because the integer needs to be
intptr_t), the other way around it's only one cast.

We don't particularly care about performance in this case either. It's
simply not important for our use-case. So a simple linked list is used
for waiters, and on wakeup, all waiters are temporarily woken up.
2014-07-26 20:29:48 +02:00
wm4 8ed6d298c5 win32: make a flag explicit
This shouldn't change anything. But it's worth making this explicit,
since it's very subtle and unintuitive: if the X parameter is the
magic value CW_USEDEFAULT, then the Y parameter is used as nCmdShow
parameter to ShowWindow(). And in our case, this is SW_HIDE (0),
because we want to create a hidden window.
2014-07-26 20:29:18 +02:00
wm4 9969694ece win32: simplify some --wid embedding code
This looked a bit overcomplicated. We don't care about the window
position (it should always be 0/0, unless the parent program moved it,
which it shouldn't). We don't care about the global on-screen position.
Also, we will just retrieve a WM_SIZE message if our window is resized,
and we don't need to update it manually.

The only thing we have to do is making sure our window fills the parent
window completely.
2014-07-26 20:28:36 +02:00
wm4 9a3f1f24ca win32: don't use CS_OWNDC
CS_OWNDC will make GetDC() always return the same HDC. This might
become a problem when OpenGL rendering and window management are
on different threads. Although I'm not too sure about this; our
code never requests a HDC outside of the OpenGL backend, and it
depends on whether win32 will internally request DCs. But in any
case, this seems to be cleaner.

Move the GL pixelformat setup code to gl_w32.c, where it's actually
needed. This also fixes that SetPixelFormat() should be called only
once, and not every time video params change.
2014-07-26 20:28:01 +02:00
wm4 7f0d9a95fa win32: remove worthless doxygen comments
These mostly describe self-explanatory things, and fail to explain
actually tricky things. Which means you just waste your time reading
this, and have to figure it out from the code anyway.
2014-07-26 20:27:57 +02:00
wm4 b3169390f5 win32: make private struct private, refactor
Preparation for moving win32 windowing to a separate thread.

The codesize is reduced a bit, because some small functions are
inlined, which reduces noise.

The main change is that now most functions use the private struct
directly, instead of accessing it indirectly through vo->w32.
Accesses to vo are minimalized.

The final goal is adding some sort of new windowing backend API. It
would be cleaner to use that as context pointer for all functions
(like struct vo was previously used), but since this is work in
progress, we just go with this commit.
2014-07-26 20:27:03 +02:00
wm4 7077526ffb ao_null: never fail at initialization
ao_null is used to stop autoprobing (if all AOs before fail to init).
After it come things like ao_pcm, which should never be automatically
selected.

Remove a certain theoretically possible failure case, and force "some"
fallback.
2014-07-26 20:26:57 +02:00
wm4 ac62244983 audio/out: fix initialization failure with win32
mp_make_wakeup_pipe() always fails on win32. If this call fails on Linux
(and e.g. ao_alsa is used), this will probably burn CPU since poll()
won't work on the invalid file descriptor, but whatever, the failure
case is obscure enough.
2014-07-26 20:26:27 +02:00
wm4 ef600041ba audio, client API: check mp_make_wakeup_pipe() return value
Could fail e.g. due to FD exhaustion.
2014-07-25 14:32:45 +02:00
wm4 18c432b83a osdep: don't assume errno is positive
Apparently this is not necessarily the case, so just drop the silly idea
that depended on this assumption.
2014-07-25 14:32:45 +02:00
wm4 f24f960ec7 command: fix and simplify overlay_add
Actually free the old mmap region when readding an overlay of the same
ID without removing it before. (This is explicitly documented as
working.)

Replace the OSD atomically. Before this commit, the overlays were
removed and then readded to avoid synchronization problems.

Simplify the code: now there is no weird mapping between index and ID.
The OSD sub-bitmap list still needs to be prepared to skip unused IDs
(since each sub-bitmap list entry must be in use), but the code for this
is relatively separated now.

Fixes issue #956.
2014-07-25 14:32:45 +02:00
Alessandro Ghedini 08415933db command: append entries to the end of the playlist with loadlist append
Currently entries are added after the current playlist element. This is kinda
confusing, more so given that "loadfile append" appends at the end of the
playlist.
2014-07-25 14:32:34 +02:00
wm4 623eac2b1b audio: cosmetics: collapse a function
There's no need for build_afilter_chain() to be a separate function
anymore.
2014-07-24 15:27:40 +02:00
wm4 69eb056333 audio: fix timestamps
Accidentally broken in b6af44d3. For ad_lavc (and in general), the PTS
was not updated correctly when filtering only parts of audio frames,
and for ad_mpg123 and ad_spdif the PTS was additionally offset by the
frame size.

This could lead to incorrect time display, and possibly broken A/V sync.
2014-07-24 15:27:31 +02:00
wm4 fc28e4af4d audio: adjust format change code
Execute the format change based on whether we logically detected EOF
(after filters), instead of when the decode buffer was drained. It's
slightly cleaner. (The requirement of len>0 existed before.)
2014-07-24 15:26:43 +02:00
wm4 986099d323 audio: fix race condition in EOF code
Don't return an EOF code if there's still buffered data.

Also, don't call demux_stream_eof() in the playloop. There's probably
nothing wrong with it, but it's cleaner not to use it.

Also give AD_EOF its own value, so that a decoding error doesn't drain
audio by causing an EOF condition.
2014-07-24 15:26:07 +02:00
wm4 b77dab0f6e audio: cosmetics
Move a function call, which does not change semantics.

Write the extra buffer sample count in a more straight-forward way; the
old code was not meaningful in any way (anymore).
2014-07-24 15:25:48 +02:00
wm4 6455bcc1da audio: remove unnecessary code
It's true that the decoder can successfully decode, but return no data
(for various reasons). We don't need to handle this specially, though.
We just let the decoder decode some more data. This doesn't increase the
danger of an endless loop either, because audio_decode() already calls
this function until enough is decoded.
2014-07-24 15:25:36 +02:00
wm4 cb4aa2df92 manpage: fix a typo 2014-07-24 15:25:24 +02:00
Rudolf Polzer c19ec6f6f6 encode: deal even more with codec->time_base deprecation.
I assume this works too with Libav 10 and FFmpeg d3e51b41.
2014-07-23 16:09:44 +02:00
wm4 843f5f4723 command: add append-play loadfile mode
"loadfile filename append-play" will now always append the file to the
playlist, and if nothing is playing yet, start playback. I don't want to
change the semantics of "append" mode, so a new mode is needed.

Probably fixes issue #950.
2014-07-23 00:20:53 +02:00
wm4 10debffc06 player: remove something DVD specific
This is not needed anymore, because demux_disc isolates us from this
crap.
2014-07-22 23:49:23 +02:00
wm4 870dc84839 sub: offset subtitle timing to video start PTS
This allows using external subtitle files with e.g. transport stream
files that don't start at time 0.

Note that if the .ts file has timestamp resets, everything goes south.
But I guess this was already the case before, unless there are external
subtitle files that also include timestamp resets, which is unlikely.
(On the other hand, you could for example expect that it works with
embedded DVB subtitles, that were somehow captured from the same stream
and use the same timestamps.)
2014-07-22 23:48:29 +02:00
wm4 aa1a383342 sub: add detection via BOM
Useful for Windows stuff. Actually, ENCA support should catch this, but,
well, whatever, everyone seems to hate ENCA.

Detection with BOM is trivial, although it needs some hackery to
integrate it with the existing autodetection support. For one, change
the default value of --sub-codepage to make this easier.

Probably fixes issue #937 (the second part).
2014-07-22 23:40:48 +02:00
wm4 63373ca424 encode: deal with codec->time_base deprecation
This seems to work with both Libav 10 and FFmpeg d3e51b41.
2014-07-22 23:04:12 +02:00
wm4 1041850523 video: fix corner case with accidental EOF
The video flushing logic was broken: if there are no more packets,
decode_image() will feed flush packets to the decoder. Even if an image
was produced, it will return the demuxer EOF state, and since commit
7083f88c, this EOF state is returned to the caller, which is incorrect.

Revert this part of the change, and explicitly check for VD_WAIT (the
bogus change was intended to forward this error code to the caller).

Also, turn the "r < 1" into something equivalent that doesn't rely on
the exact value of VD_EOF. "r < 0" is ok, because at least here, errors
are always negative.
2014-07-22 21:08:42 +02:00
wm4 8f8d524112 ass: remove some pointless ifdeffery
This will print compiler warnings about unused variables with older
libass versions, but that's harmless.
2014-07-22 20:49:01 +02:00
wm4 6b51b73a04 player: fix idle mode event handling 2014-07-22 19:33:24 +02:00
wm4 80d36a0aa2 ao_pulse: fix potential compilation problem
It seems at least on some platforms (OSX 10.9), the POSIX wait()
function becomes visible, and conflicts with this unrelated function.
Just rename it.
2014-07-22 19:26:53 +02:00
Stefano Pigozzi 12b2465c1e travis: add OS X continous integration
The travis guys were so nice to activate multi OS support for us (it's a beta
feature). So now we build on OS X ass well to check for OS X specific breakage.

Later I might investigate further and build with the minimum supported SDK
version so that we don't break older systems by using newer Cocoa features.
2014-07-21 20:43:39 +02:00
wm4 17256f13dc osd: properly handle OSD bar timeout
This could just remain stuck on the screen, until the playloop happened
to be run again.
2014-07-21 19:35:20 +02:00
wm4 a84517c1d8 player: don't sleep after seeks 2014-07-21 19:31:25 +02:00
wm4 b6af44d31e audio: move initial decode to generic code
This commit mainly moves the initial decoding of data (done to probe the
audio format) to generic code. This will make it easier to make audio
decoding non-blocking in a later commit.

This commit also changes how decoders return data: instead of having
them write the data into a prepared buffer, they return a reference to
an internal buffer (by setting dec_audio.decoded). This makes it
significantly easier to handle audio format changes, since the decoders
don't really need to care anymore.
2014-07-21 19:29:58 +02:00
wm4 1f9e0a15a1 ad_lavc: drop questionable fallback code
If the decoder didn't set a samplerate, it was initialized from the
container samplerate.

This probably didn't make much sense, because it's passed to the
decoder on initialization (so it could definitely use it). It's an
artifact from commit 66a9eb57 (which removed some Matroska-specific non-
sense), and I've never seen it actually happen since it was made into a
warning. Just get rid of it.
2014-07-21 19:29:58 +02:00
wm4 967add9f0f audio: remove unused metadata field
This was used for replaygain at some point, until replaygain info was
passed through explicitly.
2014-07-21 19:29:58 +02:00
wm4 d1bb1bf8af demux: fix timestamp type for seek calls
mpv/mplayer2/MPlayer use double for timestamps, but the demuxer API used
float.
2014-07-21 19:29:58 +02:00
wm4 4b4bd9e5f7 demux: asynchronous seeking
This tells the demuxer thread that it should seek, instead of waiting
until the demuxer thread is ready.

Care has to be taken about the state between seek request and actual
seeking: newly demuxed packets have to be discarded. We can't just
flush when doing the actual seek, because the user thread could read
these packets.

I'm wondering if this could lead to issues due to relaxed ordering of
operations. But it should be fine, since seeking influences packet
reading only, and seeking is always strictly done before that.

Currently, this will have no advantages; unless audio is disabled. Then
seeking as well as normal playback can be non-blocking.
2014-07-21 19:29:50 +02:00
wm4 b6dd1341d2 manpage: correct the --mf options
The MPlayer style syntax ("-mf fps=10:type=png") was removed a while
ago, and now only the flat variants ("--mf-fps=10" etc.) work.

CC: @mpv-player/stable
2014-07-21 19:27:15 +02:00
wm4 0248de84ea player: simplify a condition
Move a condition somewhere else, which makes it conceptually simpler.

Also, the assignment to full_audio_buffers removed with this commit was
dead, and its value never used.
2014-07-20 20:47:30 +02:00
wm4 ba621ac140 manpage: fix wording for --aid 2014-07-20 20:47:03 +02:00
wm4 da1925ae2e player: simplify logic on video errors
Fatal errors in the vidoe chain (such as failing to initialize the video
chain) disable video decoding. Restart the playloop, instead of just
continuing the current iteration.

The resulting behavior should be the same, but it gets rid of possible
corner cases.
2014-07-20 20:43:06 +02:00
wm4 9736f3309a audio: use symbolic constants instead of magic integers
Similar to commit 26468743.
2014-07-20 20:42:03 +02:00
wm4 e982b5b287 player: readd code accidentally removed with commit 61efe87e
Oops.
2014-07-20 20:41:20 +02:00
wm4 5526603a43 demux: don't start reading if no packets were requested yet
Instead of starting to fill the packet queue if at least 1 stream is
selected, wait until there is at least 1 stream had new packets
requested.

In theory this is cleaner, because it allows you to e.g. do a seek and
then reselect streams without losing packets. Seeking marks all streams
as inactive, and without this new logic, the thread would read new
packets anyway right after seek.
2014-07-20 20:13:08 +02:00
wm4 61efe87e48 player: fix regression with ordered chapters
Broken by commit 1301a907. This commit added demuxer threading, and
changed some other things to make them simpler and more orthogonal. One
of these things was ntofications about streams that appear during
playback. That's an obscure corner case, but the change made handling of
it as natural as normal initialization.

This didn't work for two reasons:
1. When playing an ordered chapters file where the initial segment was
not from the main file, its streams were added to the track list. So
they were printed twice, and switching to the next segment didn't work,
because the right streams were not selected.
2. EDL, CUE, as well as possibly certain Matroska files don't have any
data or tracks in the "main" demuxer, so normally the first segment is
picked for the track list. This was simply broken.

Fix by sprinkling the code with various hacks.
2014-07-20 20:13:08 +02:00
wm4 d320695207 command: potentially fix dvd angle setting
This called demux_flush(), but that doesn't make any sense with an
asynchronously running demuxer. It would just keep reading and add new
packets again. Explicitly pause the demuxer, so that this can't happen.
Also, when flushing, data will be missing, so the decoders should
always be reinitialized, even if the operation fails.
2014-07-20 20:13:07 +02:00
foo86 6a556f524e input: enable wakeup on LIRC socket
Commit dc00b14 removed playloop polling. Enable wakeup on LIRC socket,
otherwise remote control doesn't work when paused.
2014-07-20 13:52:06 +02:00
wm4 ded02bb78c demux: make the cache refresh cached STREAM_CTRLs
This fixes the same symptom as the previous commit, but when the demuxer
thread is enabled. In this case, if nothing was read from the demuxer,
the STREAM_CTRLs weren't updated either. To the player, this looked like
the stream cache was never making progress, so playback was kept paused.
2014-07-20 00:19:58 +02:00
wm4 1313d38efb player: don't wait forever with --cache-pause-below behavior
Commit dc00b146, which disables polling by default, missed another
instance of polling: when the player pauses automatically on low cache.

This could lead to apparent freezes when playing network streams.
2014-07-20 00:16:43 +02:00
Tsukasa OMOTO b0ff0527a3 build: enable compiler optimization by default 2014-07-20 00:08:36 +02:00
wm4 887140b7d4 demux: fix a corner case (2)
It can happen that read_packet() doesn't read a packet, even if it
succeeds. Typically this is because a packet was read, but then thrown
away, because it's not part of a selected stream. The result would be a
bogus EOF condition.

Fix by explicitly checking for EOF.
2014-07-19 12:34:07 +02:00
wm4 cfdb1312da demux: ensure demux_read_packet_async() always reads
In corner cases, it might be possible that a demux_read_packet_async()
call fails to make the demuxer thread to read more packets.

If a packet is queued, the function will simply return a packet, without
marking the stream as active. As a consequence, read_packet() might
decide not to read any further packets, and the demuxer will never read
a packet and wake up the playback thread.

This was originally done to align it with demux_read_packet() semantics;
just drop this.
2014-07-19 12:27:25 +02:00
wm4 24efaa3ad7 demux: fix a corner case
demux_read_any_packet() attempts to call read_packet(), but if no stream
is active, it can decide not to read anything. The function will return
NULL, which implies EOF. Fix this by explicitly
setting demux_stream->active if needed.

Also use dequeue_packet() instead of demux_read_packet(), because it's
cleaner. (Shouldn't change behavior.)

Possibly fixes #938.
2014-07-19 12:27:21 +02:00
Stefano Pigozzi c76958d20c cocoa: don't send messages to uninitialized gl contexts
This should fix some crashes where we sent makeCurrentContext to a context that
was being freed from another thread.

/cc @mpv-player/stable
2014-07-19 12:01:53 +02:00
wm4 1942e424e3 demux: fix opening pipes with demux_lavf
We told the demuxer that a pipe (if stream cache is enabled) is
seekable. This is because the stream cache is technically seekable, it's
just that seeking may fail at runtime if a non-cached byte range is
requested.

This caused libavformat to issue seeks on initialization (at least when
piping mp4 youtube videos). Initialization failed completely after
spamming tons of error messages.

So, if an unseekable stream is cached, tell the demuxer that the file is
not seekable. This gets reversed later (when printing a message about
caching an unseekable stream), so the user can still try his luck by
issuing a seek command. The important part is that libavformat
initialization will not take code paths that will unnecessarily seek for
whatever reasons.

CC: @mpv-player/stable: regression from 0.3.x
2014-07-18 16:16:05 +02:00
wm4 2646874369 video: use symbolic constants instead of magic integers
In my opinion this is not really necessary, since there's only a single
user of update_video(), but others reading this code would probably hate
me for using magic integer values instead of symbolic constants.

This should be a purely cosmetic commit; any changes in behavior are
bugs.
2014-07-18 15:11:21 +02:00
wm4 7083f88ca8 video: don't block when reading video packets
Instead of blocking on the demuxer when reading a packet, let packets be
read asynchronously. Basically, it polls whether a packet is available,
and if not, the playloop goes to sleep until the demuxer thread wakes it
up.

Note that the player will still block for I/O, because audio is still
read synchronously. It's much harder to do the same change for audio
(because of the design of the audio decoding path and especially
initialization), so audio will have to be done later.
2014-07-18 15:10:28 +02:00
wm4 848546f2de demux: fix problems with EOF
It was easy to get into a wakeup feedback loop on EOF. The reason that
EOF is complicated is that we try to retry reading when EOF is reached,
in case the EOF state actually disappears (e.g. when watching a
currently downloaded file).

This feature is probably worthless, since in practice you have to do a
seek to "unstuck" it anyway, but since the old code also did this, we
want to keep this behavior for now.

Avoid the feedback loop by introducing another EOF flag (last_eof), that
contains the actual previous EOF state, and is not overwritten when
retrying reading. Wakeup is skipped if the EOF state didn't change.

Also, actually call the wakeup callback when EOF is detected.

The line that adds "ds->active = false;" actually does nothing, but in
theory it's cleaner.
2014-07-18 15:08:38 +02:00
wm4 152a099c3a demux: add function to read packets asychronously 2014-07-18 15:08:31 +02:00
wm4 dc00b146c4 player: remove the last instances of polling
Mouse cursor handling, --heartbeat-cmd, and OSD messages basically
relied on polling. For this reason, the playloop always used a small
timeout (not more than 500ms).

Fix these cases, and raise the timeout to 100 seconds. There is no
reason behind this number; for this specific purpose it's as close to
infinity as any other number.

On MS Windows, or if vo_sdl is used, the timeout remains very small.
In these cases the GUI code doesn't do proper event handling in the
first place, and fixing it requires much more effort.

getch2_poll() still does polling, because as far as I'm aware no event-
based way to detect this state change exists.
2014-07-18 15:04:46 +02:00
wm4 34fdf082d8 dvd, bd: fix A/V sync
Slightly less robust, but simpler, and usually guarantees that audio
and video are properly in sync.
2014-07-18 01:26:46 +02:00
wm4 1d7a68d75c demux: fix debug log output
It printed the PTS instead of the DTS.
2014-07-17 22:03:12 +02:00
wm4 9faa131959 demux: drop some unused definitions 2014-07-17 21:53:44 +02:00
wm4 11944e0b83 manpage: fix documented default for --demuxer-thread 2014-07-17 01:50:29 +02:00
wm4 30542456c3 demux_lavf: reverse rotation direction with new API
The old FFmpeg API and the new Libav API disagree about mp4 display
rotation direction. Well, whatever, fix it trial-and-error-style.

CC: @mpv-player/stable: add
2014-07-17 00:30:03 +02:00
wm4 1301a90761 demux: add a demuxer thread
This adds a thread to the demuxer which reads packets asynchronously.
It will do so until a configurable minimum packet queue size is
reached. (See options.rst additions.)

For now, the thread is disabled by default. There are some corner cases
that have to be fixed, such as fixing cache behavior with webradios.

Note that most interaction with the demuxer is still blocking, so if
e.g. network dies, the player will still freeze. But this change will
make it possible to remove most causes for freezing.

Most of the new code in demux.c actually consists of weird caches to
compensate for thread-safety issues (with the previously single-threaded
design), or to avoid blocking by having to wait on the demuxer thread.

Most of the changes in the player are due to the fact that we must not
access the source stream directly. the demuxer thread already accesses
it, and the stream stuff is not thread-safe.

For timeline stuff (like ordered chapters), we enable the thread for the
current segment only. We also clear its packet queue on seek, so that
the remaining (unconsumed) readahead buffer doesn't waste memory.

Keep in mind that insane subtitles (such as ASS typesetting muxed into
mkv files) will practically disable the readahead, because the total
queue size is considered when checking whether the minimum queue size
was reached.
2014-07-16 23:25:56 +02:00
wm4 69a8f08f3e tags: add copy function 2014-07-16 22:40:12 +02:00
Rudolf Polzer 073b2becfe ao_lavc: Fix design of audio pts handling.
There was confusion about what should go into audio pts calculation and
what not (mainly due to the audio push thread). This has been fixed by
using the playing - not written - audio pts (which properly takes into
account the ao's buffer), and incrementing the samples count only by the
amount of samples actually taken from the buffer (unfortunately this
now forces us to keep the lock too long for my taste).
2014-07-16 16:18:34 +02:00
Rudolf Polzer e257cbfdbb ao_lavc: Add a missing newline for the log. 2014-07-16 16:18:34 +02:00
Rudolf Polzer 2a985716cd ao_lavc: Fix advancing of audio pts. 2014-07-16 16:18:34 +02:00
Rudolf Polzer 35c20c3094 idet.sh: Fix a typo. 2014-07-16 16:15:12 +02:00
Tsukasa OMOTO 1c850ff559 osxbundle: fix detection of user libraries
Previous code would detect for example `libcaca.0.dylib` as a system library,
because it matched the `libc` condition.
2014-07-16 08:36:34 +02:00
Stefano Pigozzi 135ba132a8 cocoa: fix regression preventing window resize
I introduced this bug in b5bbb49. Sorry!
This could fix #943 and #930 even though I can't reproduce those specific bugs.
2014-07-15 21:33:19 +02:00
Rudolf Polzer f5449870e0 idet.sh: Fix telecine detection. 2014-07-15 11:10:24 +02:00
wm4 23a7257cca Revert "Remove DVD and Bluray support"
This reverts commit 4b93210e0c.

*shrug*
2014-07-15 01:49:02 +02:00
wm4 4b93210e0c Remove DVD and Bluray support
It never worked well. Just remux your DVD and BD images to mkv.
2014-07-14 14:34:14 +02:00
wm4 c129e3f666 demux_lavf: don't let metadata update mess up ogm playback
For OGG audio files, we usually merge the per-stream metadata back to
the file-global metadata. Don't do that for OGM, because with OGM most
metadata is actually per-stream.
2014-07-14 14:34:14 +02:00
Stefano Pigozzi ac71cb8611 cocoa: fix compilation on OS X 10.8 2014-07-14 07:21:44 +02:00
wm4 9fadc92eb1 command: don't show VO information in colorspace properties
Until now, changing the properties showed the VO colorspace parameters
on OSD. This didn't work quite well, because it showed the VO parameters
_before_ the change. This is because at least one video frame with the
new parameters has to be shown, and this doesn't happen right after
changing the property, but a bit later.

Also fix a random typo in unrelated code.
2014-07-13 20:12:55 +02:00
wm4 417ffa8b40 Remove some mp_msg calls with no trailing \n
The final goal is all mp_msg calls produce complete lines. We want this
because otherwise, race conditions could corrupt the terminal output,
and it's inconvenient for the client API too. This commit works towards
this goal. There's still code that has this not fixed yet, though.
2014-07-13 20:12:13 +02:00
wm4 d54d21cbd5 config: adjust config parser messages
Some cleanup. Also, try not to call mp_msg multiple times for 1 line.
2014-07-13 20:11:46 +02:00
wm4 9b654fd540 player: remove some inactive code
demux_seek() actually doesn't return seek success. Instead, it fails if
the demuxer is flagged as unseekable (but this is checked explicitly at
the beginning of this function), or if the seek target PTS is
MP_NOPTS_VALUE (which can never happen).
2014-07-13 20:07:29 +02:00
wm4 ae7228c6a3 audio: drop buffered audio when switching tracks or filters
No reason to wait until the audio has been played. This isn't a problem
with gapless audio disabled, and since gapless is now default, this
behavior might be perceived as regression.

CC: @mpv-player/stable
2014-07-13 20:07:14 +02:00
wm4 fb54a1436a audio: don't wait for draining if paused
Logic for this was missing from pull.c. For push.c it was missing if the
driver didn't support it. But even if the driver supported it (such as
with ao_alsa), strange behavior was observed by users. See issue #933.

Always check explicitly whether the AO is in paused mode, and if so,
don't drain.

Possibly fixes #933.

CC: @mpv-player/stable
2014-07-13 20:06:33 +02:00
wm4 b505cab597 dvdnav: fix time display when starting in the middle of the DVD
libdvdnav can actually jump into the middle of the DVD (e.g. scene
selection menus do that). Then time display is incorrect: we start from
0, even though playback time is somewhere else. This really matters when
seeking. If the display time mismatches, a small relative seek will
apparently jump to the beginning of the movie.

Fix this by initializing the PTS stuff on opening. We have to do this
after some small amount of data has been read from the stream (because
libdvdnav is crap and doesn't always update the time between seeks and
the first read; also see STREAM_CTRL_GET_CURRENT_TIME remarks in
cache.c; although this was not observed when testing with scene
selection menus). On the other hand, we want to do it before opening the
demuxer, because that will read large amounts of data and likely will
change the stream position.

Also see commit 49813670.
2014-07-13 20:05:25 +02:00
Alessandro Ghedini 1f98bb3adc stream_dvdnav: suspend read on vts change even if the requested title is not found 2014-07-13 18:26:08 +02:00
Alessandro Ghedini 712cf3342e DOCS/release-policy: mention the release version in the RELEASE_NOTES template
Also suggest adding changes in point releases to RELEASE_NOTES as well.
2014-07-13 15:03:47 +02:00
wm4 a09329bcf7 input: skip BOM in input.conf 2014-07-12 21:25:32 +02:00
wm4 fed69f3637 config: skip BOM 2014-07-12 21:24:55 +02:00
wm4 5b820ff1b4 dvd: potentially fix video aspect ratio
This overwrote the source stream header, instead of the stream header
exported to the decoder.
2014-07-12 20:17:19 +02:00
wm4 c37956b364 stream: don't sleep for reconnecting network if playback is stopped
Also silences the bogus message if that happens.

CC: @mpv-player/stable
2014-07-12 19:19:04 +02:00
wm4 64e3b07a9d cache_file: fix operation if stream size is unknown
Happens when playing from a pipe.

Note that seeking forward doesn't work. It would be possible to create a
workaround for that by reading and skipping data until the target
position is reached (and writing the skipped data into the cache file),
but I'm not sure about that.

Fixes #928.

CC: @mpv-player/stable
2014-07-12 19:18:21 +02:00
ChrisK2 1e8b98af73 osc: improve previous commit 2014-07-10 11:22:05 +02:00
ChrisK2 549afdb9c5 osc: round displayed cache value
Fixes #919
2014-07-10 11:17:51 +02:00
wm4 d68d4dd984 Revert "build: avoid defining _GNU_SOURCE"
This reverts commit 2e6a8f260c.

Too many problems for now, such as with OSX and asprintf().
2014-07-10 09:25:37 +02:00
wm4 f8c2dd1b78 build: include <strings.h> for strcasecmp()
It happens to work without strings.h on glibc or with _GNU_SOURCE, but
the POSIX standard requires including <strings.h>.

Hopefully fixes OSX build.
2014-07-10 08:29:32 +02:00
wm4 e1f2540ede video/out: use strcmp() instead of strcasecmp() for equalizers
This makes it more consistent with the more important VOs.
2014-07-10 08:27:15 +02:00
wm4 1a1e631ccd build: deal with endian mess
There is no standard mechanism for detecting endianess. Doing it at
compile time in a portable way is probably hard. Doing it properly
with a configure check is probably hard too. Using the endian
definitions in <sys/types.h> (usually includes <endian.h>, which is
not available everywhere) works under circumstances, but the previous
commit broke it on OSX.

Ideally all code should be endian dependent, but that is not possible
due to the dependencies (such as FFmpeg, some video output APIs, some
audio output APIs).

Create a header osdep/endian.h, which contains various fallbacks.
Note that the last fallback uses libavutil; however, it's not clear
whether AV_HAVE_BIGENDIAN is a public symbol, or whether including
<libavutil/bswap.h> really makes it visible. And in fact we don't want
to pollute the namespace with libavutil definitions either. Thus it's
only the last fallback.
2014-07-10 00:58:56 +02:00
wm4 2e6a8f260c build: avoid defining _GNU_SOURCE
_GNU_SOURCE defines the kitchen sink, and also prefers glibc definitions
where glibc and POSIX conflict. Even though POSIX is worth less than
toilet paper, we still prefer the POSIX definitions.

rar.c needs asprintf(), which is _GNU_SOURCE-only. So we define
_GNU_SOURCE too specifically for this file.
2014-07-09 22:10:33 +02:00
wm4 5d3f1a17a7 DOCS/tech-overview: minor updates 2014-07-09 02:14:23 +02:00
wm4 93f63214e0 demux: remove accurate_seek field
It's unused now. (Only the dvd code used it until recently.)
2014-07-08 22:20:39 +02:00
Stefano Pigozzi 609187082f cocoa: simplify logic that returns used bits per color 2014-07-08 22:06:57 +02:00
Stefano Pigozzi b5bbb49a1a cocoa: move CGL context creation to gl_cocoa
This approach is similar to what other vo_opengl backends do. It can also be
used in the future to create another cocoa backend that renders offscreen
with IOSurfaces or FBOs.
2014-07-08 21:06:57 +02:00
wm4 469ec23f85 demux_disc: flush slave demuxer packet queue on resync
Technically needed, but not strictly. It seems it works without in
practice, because demux_lavf.c reads exactly one packet for fill_buffer
call, so there are never packets queued.
2014-07-07 19:24:22 +02:00
wm4 4981367021 cache, dvd, bluray: simplify stream time handling
We used a complicated and approximate method to cache the stream
timestamp, which is basically per-byte. (To reduce overhead, it was only
cached per 8KB-block, so it was approximate.)

Simplify this, and read/keep the timestamp only on discontinuities. This
is when demux_disc.c actually needs the timestamp.

Note that caching is currently disabled for dvdnav, but we still read
the timestamp only after some data is read. libdvdread behaves well, but
I don't know about libbluray, and the previous code also read the
timestamp only after reading data, so try to keep it safe.

Also drop the start_time offset. It wouldn't be correct anymore if used
with the cache, and the idea behind it wasn't very sane either (making
the player to offset the initial playback time to 0).
2014-07-07 19:09:37 +02:00
wm4 4d829d750c input: restore ability to combine mouse buttons
Key bindings are decided on the "down" event, so if the prefix is not
unique, the first/shortest will be used (e.g. when both "a" and "a-b"
are mapped, "a" will always be chosen).

This also breaks combining multiple mouse buttons. But it seems users
expect it to work, and it's indeed a bit strange that it shouldn't work,
as mouse bindings are emitted on the key "up" event, not "down" (if the
shorter binding didn't emit a command yet, why shouldn't it be
combinable).

Deal with this by clearing the key history when a command is actually
emitted, instead of when a command is decided. This means if both
MOUSE_BTN0 and MOUSE_BTN0-MOUSE_BTN1 are mapped, the sequence of holding
down BTN0 and then BTN1 will redecide the current command. On the other
hand, if BTN0 is released before BTN1 is pressed, the command is
emitted, and the key history is deleted. So the BTN1 press will not
trigger BTN0-BTN1.

For normal keys, nothing should change, because commands are emitted on
the "down" event already, so the key history is always cleared.

Might fix #902.

CC: @mpv-player/stable (if this fix is successful)
2014-07-07 18:18:41 +02:00
wm4 c07bae02e2 ao_null: disable latency emulation
Doesn't work quite right, and will pause for the latency duration after
seeking. Some users use --ao=null to disable audio (even though they
should probably use --no-audio), and this use-case is broken by this
issue too.

CC: @mpv-player/stable
2014-07-07 18:00:48 +02:00
wm4 19dde186a0 demux: print initial metadata
This was accidentally broken in 7e209185, and metadata was printed only
when it changed.
2014-07-07 18:00:41 +02:00
wm4 e2b0416ae1 osc: fix failure when using DVD menus
[osc] Lua error: mp.assdraw:31: attempt to concatenate local 's' (a nil value)
2014-07-07 18:00:41 +02:00
wm4 02ca42c7f1 lua: redo error handling, print backtraces
The original goal was just adding backtraces, however making the code
safe (especially wrt. to out of memory Lua errors) was hard. So this
commit also restructures error handling to make it conceptually simpler.
Now all Lua code is run inside a Lua error handling, except the calls
for creating and destroying the Lua context, and calling the wrapper C
function in a safe way.

The new error handling is actually conceptually simpler and more
correct, because you can just call any Lua function at initialization,
without having to worry whwther it throws errors or not.

Unfortunately, Lua 5.2 removes lua_cpcall(), so we have to emulate it.
There isn't any way to emulate it in a way that works the same on 5.1
and 5.2 with the same semantics in error cases, so ifdeffery is needed.
The debug.traceback() function also behaves weirdly differently between
the Lua versions, so its output is not as nice as it could be (empty
extra line).
2014-07-07 18:00:41 +02:00
wm4 0ea2bc2778 old-configure: fix Lua tests
This added every Lua that was found on the system.
2014-07-07 18:00:41 +02:00
wm4 acd60736ef Remove stream_pts stuff
This was used by DVD/BD, but its usage was removed with one of the
previous commits.
2014-07-06 19:05:59 +02:00
wm4 a90b5cfddf DOCS/client-api-changes: try to fix rst formatting again 2014-07-06 19:05:45 +02:00
wm4 f512604f02 dvd, bd: enable precise seeking
This should work now, at least kind of. Note that actual success depends
on the behavior of the underlying lib{dvd{nav,read},bluray}
implementation, which could go very wrong.

In the worst case, it could happen that the underlying implementation
seeks a long time before the seek target time. In this case, the player
will just decode video until the target time is reached, even if that
requires e.g. decoding 30 mintues of video before refreshing.

In the not-so-bad but still bad case, it would just miss the seek
target, and seek past it.

In my tests, it works mostly ok, though. Seeking backwards usually
fails, unless something like --hr-seek-demuxer-offset=1 is used (this
makes it seek to 1 second before the target, which may or may not be
enough to compensate for the DVD/BD imprecision).
2014-07-06 19:03:43 +02:00
wm4 7bf090ad24 dvd, bluray: handle playback display time handling differently
This is a pretty big change. Instead of doing a half-hearted passthrough
of the playback timestamp, we attempt to rewrite the raw MPEG timestamps
such that they match with the playback time.

We add the offset between raw start timestamp and playback time to the
packet timestamps. This is the easy part; but the problem is with
timestamp resets. We simply detect timestamp discontinuities by checking
whether they are more than 500ms apart (large enough for all video
faster than 2 FPS and audio with reasonable framesizes/samplerates), and
adjust the timestamp offset accordingly.

This should work pretty well. There may be some problems with subtitles.
If the first packet after a timestamp reset is a subtitle instead of
video, it will fail. Also, selecting multiple audio or video streams
won't work (but mpv doesn't allow selecting several anyway). Trying to
demux subtitles with no video stream enabled will probably fail.

Untested with Bluray, because I have no Bluray sample.

Background:

libdvdnav/libdvdread/libbluray make this relatively hard. They return a
raw MPEG (PS/TS) byte stream, and additionally to that provide a
function to retrieve the current "playback" time. The playback time is
what should be displayed to the user, while the MPEG timestamps can be
completely different. Even worse, the MPEG timestamps can reset. Since
we use the libavformat demuxer (instead of parsing the MPEG packets in
the DVD/BD code), it's hard to associate between these timestamps. As a
result, the time display is special cased in the playloop, and of low
quality (updates only all 1 or 2 seconds, sometimes is incorrect). The
fact that the stream cache can be between demuxer and the stream source
makes things worse.

All the libs seem to provide an event that tells whether timestamps are
resetting. But since this signalling is byte based, it's hard to connect
it to the demuxed MPEG packets. It might be possible to create some sort
of table mapping file positions to discontinuities and new timestamps.
(For simplicity, this table could be 2 entries large, sufficient to
catch all discontinuities if the distance between them is larger than
the total buffering.)
2014-07-06 19:03:12 +02:00
wm4 361be8385b stream_dvdnav: more debugging output 2014-07-06 19:03:05 +02:00
wm4 f3604fc3fb demux: fix a corner case related to demux_disc
It can happen that demux_fill_buffer() adds more than 1 packet, and then
the packets would add up. Affects demux_disc.c only (nothing else uses
this function).
2014-07-06 19:02:58 +02:00
wm4 e3a3b764c8 dvd: fix first subtitle with delayed subtitle streams
This was accidentally broken with moving the DVD code to demux_disc.c.

Also remove an abort() call meant for debugging.
2014-07-06 19:02:49 +02:00
wm4 1d55547adf stream: remove now unused STREAM_CTRL_GET_START_TIME
demux_disc.c takes care of this now.
2014-07-06 19:02:33 +02:00
wm4 de28876222 demux: minor simplification
Oops, should have been part of commit 37085788.
2014-07-06 19:02:21 +02:00
atomnuker e6643abc98 ao_pulse: set icon name
Will replace the generic XDG video icon inherited from media role.
2014-07-05 17:07:16 +02:00
wm4 6fcb34d887 vf_vapoursynth: reset error state on seeking
When seeking, we violently destroy the filter, because vapoursynth has
no proper API for terminating a video with unknown frame count. This
looks like an error to vapoursynth, and the error is returned via the
frame callbacks. The bug is that we remember this error state across
reinitialization, so on the first filter call after reinitialization, we
thought filtering the current frame failed. This caused a shift by 1
frame on each seek.

CC: @mpv-player/stable
2014-07-05 17:07:16 +02:00
wm4 d27a2bc546 build: allow compilation without any atomics
Not all compilers on all platforms have atomics available (even if they
could, technically speaking).

We don't use atomics that much, only the following things rely on it:
1. the audio pull code, and all audio outputs using it
2. updating global msg levels
3. reading log messages through the client API

Just disable 1. and 3. if atomics are not available. For 2., using fake-
atomics isn't too bad; at worst, message levels won't properly update
under certain situations (but most likely, it will work just fine).

This means if atomics are not available, the client API function
mpv_request_log_messages() will do nothing.

CC: @mpv-player/stable
2014-07-05 17:07:16 +02:00
wm4 49df035514 options: remove bogus replacement message for --fstype
CC: @mpv-player/stable
2014-07-05 17:07:16 +02:00
wm4 962b928192 options: add --autosub-match to option replacement list
CC: @mpv-player/stable
2014-07-05 17:07:16 +02:00
wm4 4f00c74491 player: don't use stream position as fallback for percent-pos
This should be unneeded, and the packet position is already sufficient
for this case.

Accessing the stream position directly is going to be a problem when the
stream is accessed from another thread later.
2014-07-05 17:07:15 +02:00
wm4 54a4a25fe9 tv: move demuxer parts to separate file
Now all demuxer implementations (at least demuxer API-wise) are in the
demux directory.
2014-07-05 17:07:15 +02:00
wm4 37085788e4 demux: minor simplification to internal API
Also some other unrelated minor changes.
2014-07-05 17:07:15 +02:00
wm4 de71b50249 dvd: move angle switching code
No need to provide a "nice" API for it; just do this stuff directly in
the command code.
2014-07-05 17:07:15 +02:00
wm4 0cc3594623 dvd: flush buffers properly on seek
Suggested by tholin on github issue #882.

This is not entirely clean, but the fields we're accessing might be
considered internal to libavformat. On the other hand, existence of the
fields is guaranteed by the ABI, and nothing in the libavformat doxygen
suggestes they're not allowed to be accessed.

CC: @mpv-player/stable
2014-07-05 17:07:15 +02:00
wm4 338004bcfc dvd, bluray, cdda: add demux_disc containing all related hacks
DVD and Bluray (and to some extent cdda) require awful hacks all over
the codebase to make them work. The main reason is that they act like
container, but are entirely implemented on the stream layer. The raw
mpeg data resulting from these streams must be "extended" with the
container-like metadata transported via STREAM_CTRLs. The result were
hacks all over demux.c and some higher-level parts.

Add a "disc" pseudo-demuxer, and move all these hacks and special-cases
to it.
2014-07-05 17:07:15 +02:00
wm4 4d2a4afdef discnav: fix a comment 2014-07-05 17:07:15 +02:00
wm4 942619c779 demux: set filepos field when dequeuing a packet
Otherwise the position can be too far ahead.
2014-07-05 17:07:15 +02:00
wm4 85eb2bee3a demux: cosmetics: minimize code 2014-07-05 17:07:15 +02:00
wm4 8d40b1e8ab demux: make start time a simple field
Simpler, especially for later changes.
2014-07-05 17:07:15 +02:00
wm4 7e209185f1 demux, stream: change metadata notification
(Again.)

This time, we simply make it event-based, as it should be. This is done
for both demuxer metadata and stream metadata.

For some ogg-over-icy streams, 2 updates are reported on stream start.
This is because libavformat reports an update right on start, while
including the same info in the "static" metadata. I don't know if that's
a bug or a feature.
2014-07-05 17:07:14 +02:00
wm4 58880c00ee demux: make replaygain per-track
It's unlikely that files with multiple audio tracks and with replaygain
actually happen, but this change might help avoid minor corner cases
with later changes.
2014-07-05 17:07:14 +02:00
wm4 a97256c1d5 demux: move packet functions to a separate source file 2014-07-05 17:07:14 +02:00
wm4 e4221f3189 demux: move packet list functions
Move them to the only place where they are used, demux_subreader.c.
2014-07-05 17:07:14 +02:00
wm4 18e6d07612 demux_lavf: for now, ignore the new libavformat image demuxers
Recently, libavformat added demuxers to open image files like normal
demuxers. This is a good thing, but for now they interfere with the
operation of demux_mf. Add them to the blacklist until there is a proper
solution.

(The list doesn't contain _all_ recognized image formats, just those
that might interfere with demux_mf.)

CC: @mpv-player/stable
2014-07-05 17:07:14 +02:00
wm4 5eb9039c6b demux_lavf: support OTF fonts in Matroska
Apparently it's FFmpeg only.
2014-07-05 17:07:14 +02:00
wm4 1713dc58f1 demux_lavf: don't dump transport stream programs
Probably useless.
2014-07-05 17:07:14 +02:00
wm4 78f3ba73b9 demux_lavf: cleanup debug output
Remove unnecessary prefix, remove some messages.
2014-07-05 17:07:14 +02:00
wm4 bc29e17bcf demux_lavf: fix read_seek return value
This returned a stream error value directly to libavformat, which can't
make sense. For example STREAM_ERROR (0) means success in libavformat
error codes. (The meaning of the libavformat read_seek return value is
underdocumented too.)
2014-07-05 17:07:14 +02:00
wm4 44d7499190 demux_mkv: cosmetics 2014-07-05 17:07:14 +02:00
wm4 e21ecaa18d DOCS, client API: add mpv release versions
The intention is to make it obvious which mpv releases certain changes
will apply to.

Also attempt to fix RST formatting of the list. This is not very proper,
but probably good enough.
2014-07-05 17:07:14 +02:00
Stefano Pigozzi 055bc74ed4 Merge pull request #909 from Nyx0uf/patch-1
OS X bundle: Add more imported UTI
2014-07-05 10:15:14 +02:00
Nyx0uf 22c3de3f8a OS X bundle: Add more imported UTI
Not that there are widely used formats, but it will allow to play them directly from the Finder.
2014-07-04 10:05:52 +02:00
tholin bc5e539d3b stream_dvdnav: check the length of all titles with dvdnav://longest
The last title was ignored before.

CC: @mpv-player/stable

Signed-off-by: wm4 <wm4@nowhere>
2014-07-04 02:24:50 +02:00
tholin f8a7517fb7 stream_dvdnav: free pointer to priv->filename on close
CC: @mpv-player/stable

Signed-off-by: wm4 <wm4@nowhere>
2014-07-04 02:24:50 +02:00
tholin 4bd75313d1 stream_dvdnav: make sure seeking bounds are within range
libdvdnav returns an error is the seek position is out of range.

CC: @mpv-player/stable

Signed-off-by: wm4 <wm4@nowhere>
2014-07-04 02:24:50 +02:00
wm4 fe4fbb5775 DOCS/client_api_examples: add a Qt example
This is pretty dumb and extremely basic. The main purpose is
demonstrating how to integrate mpv into the Qt GUI thread.
2014-07-04 02:24:49 +02:00
wm4 4fedf86b8a client API: allow calling mpv_terminate_destroy(NULL)
This is an oversight and a bug.

CC: @mpv-player/stable
2014-07-04 02:24:49 +02:00
wm4 4a5cfb4323 x11: avoid obscure behavior when --wid is partially garbage
Cast away the "extra" bits (since apparently Window/XID is always
32 bit unsigned). This is not striclty needed, because you're not
supposed to pass garbage to --wid, just because the upper bits are
possibly not interpreted. But if you do so, this change increases
consistency in behavior and removes a strange behavior that was
thought to be a bug.

Also see github issue #906.
2014-07-04 02:23:05 +02:00
Stefano Pigozzi 97f6d7f4ec ao_coreaudio: report hardware latency to ao_read_data
Commit a6a4cd2c88 added reporting of playout latency, this commit also adds
support for reporting hardware and constant audio unit latency.
2014-07-03 20:05:15 +02:00
Alessandro Ghedini 29b047da6f TOOLS/zsh.pl: complete URL schemes based on --list-protocols 2014-07-03 11:03:56 +02:00
Alessandro Ghedini 17d65f9aff TOOLS/zsh.pl: sort options in reverse order by length
This stops options that are prefixes of other options from blocking
completion of values for the longer ones.
2014-07-03 11:03:56 +02:00
Philip Sequeira e940afec15 TOOLS/zsh.pl: untabify 2014-07-03 11:03:56 +02:00
Philip Sequeira 7450a7f531 TOOLS/zsh.pl: fix _arguments line
Don't use _x_arguments, as we don't support X arguments.

Get rid of -s, because we don't support multiple single-letter options
in one argument.

Add -S, because we ignore options after "--".
2014-07-03 11:03:56 +02:00
Philip Sequeira bbc005825a TOOLS/zsh.pl: don't consume extra arguments
Completion now uses "--opt=value" instead of "--opt value". Once the
user presses space and starts a new argument, the option just
completed is out of the picture, whether or not it was given an
argument. This handles options with no arguments or optional arguments
much better; previously, completing such an option would effectively
disable completion for the next argument.

Custom completed options such as "--ao" and friends will no longer
claim to consume an extra argument.
2014-07-03 11:03:56 +02:00
Philip Sequeira fd09578f0f TOOLS/zsh.pl: escape all colons in option descriptions 2014-07-03 11:03:56 +02:00
wm4 4d9ce2993f command: include new "playback-time" property in update mechanism 2014-07-03 01:26:19 +02:00
wm4 0004aaf788 DOCS: add a file listing API changes for the client API 2014-07-03 01:26:19 +02:00
Stefano Pigozzi 0bda8f48e2 manpage: reflect new coreaudio changes 2014-07-02 23:17:44 +02:00
Stefano Pigozzi a6a4cd2c88 ao_coreaudio: report latency more correctly
Previous code was completly wrong. This still doesn't report the device
latency, but we report the buffer latency (as before the AO refactoring) and
the AudioUnit's latency (this is a new 'feature').

Apparently we can also report the device actual latency and we should also
calculate the actual sample rate of the audio device instead of using the
nominal sample rate, but I'll leave this for a later commit.
2014-07-02 23:17:44 +02:00
wm4 703de5d84e cache_file: use unicode on windows
This enables the MinGW Windows crap wrapper for fopen().
2014-07-02 22:01:56 +02:00
Stefano Pigozzi 4f5f034ba2 ao_coreaudio: move channel mapping away from utils
Channel mapping functions are only used in the AUHAL based coreaudio, so move
them there.
2014-07-02 21:43:08 +02:00
Stefano Pigozzi c8fc02612e ao_coreaudio: use mpv's internal pull API 2014-07-02 21:43:08 +02:00
Stefano Pigozzi d16e4b836a ao_coreaudio: remove useless comments 2014-07-02 21:43:08 +02:00
Stefano Pigozzi 0ffbd05e99 ao_coreaudio: rename init_lpcm -> init_audiounit 2014-07-02 21:43:08 +02:00
Stefano Pigozzi 80ec0ba6d0 ao_coreaudio: fill asbd with an helper function 2014-07-02 21:43:07 +02:00
Stefano Pigozzi fa85bfde69 ao_coreaudio: split control to helper functions 2014-07-02 21:43:07 +02:00
Stefano Pigozzi f317d24a39 ao_coreaudio: move device related functions to the new AO 2014-07-02 21:43:07 +02:00
Stefano Pigozzi a8ef70b0f8 ao_coreaudio: remove useless call to print_asbd 2014-07-02 21:43:07 +02:00
Stefano Pigozzi 041557b639 ao_coreaudio: move spdif code to a new AO
The mplayer1/2/mpv CoreAudio audio output historically contained both usage
of AUHAL APIs (these go through the CoreAudio audio server) and the Device
based APIs (used only for output of compressed formats in exclusive mode).

The latter is a very unwieldy and low level API and pretty much forces us to
write a lot of code for little workr. Also with the widespread of HDMI, the
actual need for outputting compressed audio directly to the device is getting
lower (it was very useful with S/PDIF for bandwidth constraints not allowing
a number if channels transmitted in LPCM).

Considering how invasive it is (uses hog/exclusive mode), the new AO
(`ao_coreaudio_device`) is not going to be autoprobed but the user will have
to select it.
2014-07-02 21:43:07 +02:00
wm4 7084e800be cache: clear DVD timestamps
When resizing the cache, the buffer for the DVD timestamps is
initialized with 0. This causes the player to always return playback
position 0 with any file format (not just DVD), and also makes all
relative seeks relative to position 0. Fix this by clearing the
timestamps explicitly.

Closes #899.

CC: @mpv-player/stable
2014-07-02 19:01:47 +02:00
wm4 6d38ad1410 x11: clear window only on initial map
Apparently clearing on every map can cause problems with vdpau when
switching virtual desktops and such. This was observed with at least
XMonad and nvidia-340.17. It's not observed on some other setups without
XMonad.

It's not clear why this happens. Normally, the window background is not
saved, so clearing should have no additional affect. It's a complete
mystery. Possible, the use of legacy X drawing commands (used to clear
the window) interferes with vdpau operation in non-trivial ways.

Work this around by clearing on initial map only. This probably only
hides the underlying issue, but good enough.

Closes #897.

CC: @mpv-player/stable
2014-07-02 02:07:06 +02:00
wm4 4b5fbb3ee0 command: remove some code duplication in cache properties
This also means that the printed size is always rounded to KBs, because
the cache properties are returned in KB. I think this doesn't matter
much. But if it does, the cache properties should probably changed to
return bytes in the first place.
2014-07-02 01:46:04 +02:00
wm4 94450bf410 command: cache can actually have full-size 0
Then it's simply empty.
2014-07-02 01:32:05 +02:00
Andrey Morozov b1969c0eba command: change cache perentage to float, add cache-free and cache-used 2014-07-02 01:28:11 +02:00
wm4 9fee8fd3b3 demux: drop AVI special code
I'm pretty sure libavformat does this automatically, and we don't have
other demuxers where this could happen.

Still, slightly "risky" - so let's see.
2014-07-02 00:32:46 +02:00
wm4 bb131f4c66 demux_mkv: minor improvement to overflow check
CC: @mpv-player/stable
2014-07-02 00:14:18 +02:00
wm4 9a210ca2d5 Audit and replace all ctype.h uses
Something like "char *s = ...; isdigit(s[0]);" triggers undefined
behavior, because char can be signed, and thus s[0] can be a negative
value. The is*() functions require unsigned char _or_ EOF. EOF is a
special value outside of unsigned char range, thus the argument to the
is*() functions can't be a char.

This undefined behavior can actually trigger crashes if the
implementation of these functions e.g. uses lookup tables, which are
then indexed with out-of-range values.

Replace all <ctype.h> uses with our own custom mp_is*() functions added
with misc/ctype.h. As a bonus, these functions are locale-independent.
(Although currently, we _require_ C locale for other reasons.)
2014-07-01 23:11:08 +02:00
wm4 0208ad4f3b demux: minor cleanups 2014-07-01 21:53:23 +02:00
Alessandro Ghedini 2224ac5190 README: fix link to release policy document 2014-06-30 23:23:50 +02:00
Alessandro Ghedini ab241c05c8 options: add --list-protocols option 2014-06-30 23:20:10 +02:00
Alessandro Ghedini 211ca98e9c build: set default cdrom and dvd devices on linux 2014-06-30 23:19:53 +02:00
wm4 1c0939cb80 options: fix --gapless-audio default value
It was intended to be set to "weak" (and that was even documented), but
the actual setting was "no".

Closes #890.

CC: @mpv-player/stable
2014-06-30 18:24:35 +02:00
wm4 dd9420471f demux_mkv: cosmetics 2014-06-29 23:28:47 +02:00
wm4 37251cef69 demux_mkv: add some overflow checks etc.
Some of these might be security relevant.

The RealAudio code was especially bad. I'm not sure if all RealAudio
stuff still plays correctly; I didn't have that many samples for
testing. Some checks might be unnecessary or overcomplicated compared
to the (obfuscated) nature of the code.

CC: @mpv-player/stable
2014-06-29 23:27:28 +02:00
Tsukasa OMOTO 1646584058 player: fix start position when specifying with percent 2014-06-29 20:39:49 +02:00
Tsukasa OMOTO 1aef780b6c options: support setting start time relative to start PTS
Signed-off-by: wm4 <wm4@nowhere>
2014-06-29 20:39:49 +02:00
Tsukasa OMOTO a73415584c player: make the time display relative to start PTS
This commit makes the playback start time always at time 0.

Signed-off-by: wm4 <wm4@nowhere>
2014-06-29 20:39:49 +02:00
wm4 7412257305 av_common: remove unneeded field
This is actually needed for encoding only, and not decoding. Drop it.
2014-06-29 20:39:32 +02:00
Mohammad Alsaleh 8b06fc86f3 af_volume: fix calculations including replay-gain
rgain is not an additive value. It's a multiplier/gain.

Previous behaviour produced negative level values in some cases
(when rgain < 1.0) which caused volume to be louder when its value
was lowered.

CC: @mpv-player/stable

Signed-off-by: Mohammad Alsaleh <CE.Mohammad.AlSaleh@gmail.com>
Signed-off-by: wm4 <wm4@nowhere>
2014-06-28 15:56:16 +02:00
wm4 88225d0afb sub: fix undefined behavior with dvd://
The string could get reallocated.

CC: @mpv-player/stable
2014-06-28 15:55:24 +02:00
wm4 6eb955e274 manpage: update config file locations
Also add some explanations how the config paths are determined.
2014-06-28 15:55:09 +02:00
wm4 07bc199e35 scripting: shorten a line
Also allows it to deal with NULL return values, which currently is not
needed, but may or may not be required at some point in the future (what
if malloc fails).
2014-06-26 19:56:45 +02:00
wm4 3e631b9cb8 config: use the same signature for win32/OSX specific path functions
Seems like a good idea, even if it's basically unused (yet).

Also document requirements on the functions (they're not obvious).

OSX changes untested.
2014-06-26 19:56:45 +02:00
wm4 7f55a39646 config: handle --no-config case directly in mp_config_dirs()
Requires less special-casing, and probably also avoids that starting mpv
with --no-config creates a config dir (even if nothing is loaded).
2014-06-26 19:56:45 +02:00
wm4 b4d64ac434 config, player: avoid some temporary talloc contexts
IMO a semi-bad concept, that the mpv code unfortunately uses way too
much.
2014-06-26 19:56:45 +02:00
wm4 3e1c0e5853 config: make passing talloc context optional for some functions
Until now, the config functions added various allocations to the user-
provided talloc context. Make it so that they're all under the returned
allocation instead. This allows avoiding having to create an extra
temporary context for some callers, and also avoids adding random memory
leaks by accidentally passing a NULL context.

mp_find_all_config_files() has to be changed not to return a pointer
into the middle array for this to work. Make it add paths in order
(instead of reverse), and then reverse the array entries after that.

Also remove the declarations for the win-specific private functions.
Remove STRNULL(); it's barely needed anymore and the functions are
not called with NULL filenames anymore.
2014-06-26 19:56:45 +02:00
wm4 0dcde951b9 player: create config dir if it doesn't exist
This was dropped in the commit adding XDG support, probably
accidentally.

Also normalize some whitespace.
2014-06-26 19:43:23 +02:00
wm4 236fcd3648 config: prefer the old config dir if it exists, but XDG doesn't
This means normally the XDG config dir will be used. But if the old
config dir (~/.mpv) exists and the XDG config dir does not, then don't
create it.

To simplify the code, also make mp_path_exists() accept NULL paths. In
that case it's considered as not existing. (Funnily, on Linux this
already worked, because the string is passed directly to the kernel,
and the kernel will just return EFAULT on invalid memory.)
2014-06-26 19:41:48 +02:00
wm4 c63378d41c player: remove some minor code duplication in config loader code
It's better to keep the logic in one place.

Also drop that a broken config file aborts loading of the player. I
don't see much reason for this, and it inflates the code slightly.
2014-06-26 19:37:26 +02:00
Kenneth Zhou cb250d490c Basic xdg directory implementation
Search $XDG_CONFIG_HOME and $XDG_CONFIG_DIRS for config files.
This also negates the need to have separate user and global variants of
mp_find_config_file()

Closes #864, #109.

Signed-off-by: wm4 <wm4@nowhere>
2014-06-26 19:37:25 +02:00
wm4 8bb7d427e2 input: readd some TV default key bindings
Requested by a user. Closes #878.
2014-06-25 20:29:14 +02:00
Alessandro Ghedini 02e0882b60 DOCS: add document describing the release policy and procedure 2014-06-25 18:46:25 +02:00
wm4 1dc760f911 command: fix tv-channel property
Now it's at least actually relayed to the TV code. I didn't/couldn't
test whether it actually works, though.
2014-06-25 17:41:16 +02:00
wm4 5dd0193d1f manpage: update changed defaults from previous commit
Oops.
2014-06-23 01:23:43 +02:00
wm4 cae2977129 cache: change auto-pause/resume defaults
This is hopefully better for web streams.

Temporary workaround for #870.
2014-06-23 01:16:31 +02:00
wm4 a1c220cffd demux_lavf: remove unused symbol 2014-06-23 01:15:58 +02:00
Niklas Haas 856b57e418 vo_opengl: Make approx-gamma affect OSD/sub
Close #837

Signed-off-by: wm4 <wm4@nowhere>
2014-06-22 19:07:02 +02:00
Niklas Haas 664f8e9832 video: Include better heuristics for guessing primaries
These consult the vertical resolution, matching against 576 for
PAL and 480/486 for NTSC. The documentation has also been updated.

Signed-off-by: wm4 <wm4@nowhere>
2014-06-22 19:05:43 +02:00
Niklas Haas fbd35caef8 video: Refactor rendering intent for DCP XYZ and :srgb
Notably, we now conform to SMPTE 428-1-2006 when decoding XYZ12 input,
and we can support rendering intents other than colorimetric when
converting between BT.709 and BT.2020, like with :srgb or :icc-profile.
2014-06-22 19:02:06 +02:00
Niklas Haas 7f3ea12802 video: Better support for XYZ input
With this change, XYZ input is directly converted to the output
colorspace wherever possible, and to the colorspace specified by the
tags and/or --primaries option, otherwise.

This commit also restructures some of the CMS code in gl_video.c to
hopefully make it clearer which decision is being done where and why.
2014-06-22 19:02:06 +02:00
Niklas Haas 17762a1919 video: Generate an accurate CMS matrix instead of hard-coding
This also avoids an extra matrix multiplication when using :srgb, making
that path both more efficient and also eliminating more hard-coded
values.

In addition, the previously hard-coded XYZ to RGB matrix will be
dynamically generated.
2014-06-22 19:02:06 +02:00
Niklas Haas 204fed4d5b video: Support BT.2020 constant luminance system
Signed-off-by: wm4 <wm4@nowhere>
2014-06-22 19:02:00 +02:00
Niklas Haas ef6db24366 options: Expose --colormatrix-primaries to the user
Signed-off-by: wm4 <wm4@nowhere>
2014-06-22 19:01:25 +02:00
Niklas Haas 70f50ddc5e video: Add support for non-BT.709 primaries
This add support for reading primary information from lavc, categorized
into BT.601-525, BT.601-625, BT.709 and BT.2020; and passes it on to the
vo. In vo_opengl, we always generate the 3dlut against the wider BT.2020
and transform our source into this colorspace in the shader.
2014-06-22 19:00:38 +02:00
Niklas Haas 86d3d11a68 video: Add BT.2020-NCL colorspace and transfer function
Source: http://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2020-0-201208-I!!PDF-E.pdf
2014-06-22 19:00:38 +02:00
James Ross-Gowan 082fbe39e8 win32: add missing priority classes 2014-06-22 18:59:24 +02:00
wm4 5b8298376b stream: add a file cache
For remarks, pretty much see the manpage additions. Could help with
network streams that require too much seeking (maybe), or might be
extended to help with the use case of watching and downloading a file
at the same time.

In general, it might be a useless feature and could be removed again.
2014-06-22 05:04:05 +02:00
wm4 ea1650fcc3 stream: minor cleanups
Remove unused stream type constants. Move some now DVD specific crap
to stream_dvd.c.
2014-06-22 05:01:03 +02:00
wm4 b443f8471f vo_xv: de-ancient some help messages
One message pointed to a removed file, so just get rid of the messages.
They were helpful in the earlier 2000s, but now they're just confusing.
2014-06-21 20:41:07 +02:00
wm4 f5e1756475 DOCS: remove en/ sub-directory
This additional sub-directory doesn't serve any purpose anymore. Get rid
of it.
2014-06-20 23:01:12 +02:00
wm4 199e3b2763 manpage: explicitly document protocols 2014-06-20 22:52:16 +02:00
wm4 689aae56b6 manpage: remove some trailing whitespace
I wish I could make github run a hook to reject these.
2014-06-20 22:45:03 +02:00
wm4 fd64bcbe8e build: remove BSD-specific /usr/local include path additions
It seems it's generally cleaner to leave this stuff to the BSDs.
Additionally, the NetBSD part wasn't even correct, because it made the
compiler prefer the system include path before local include files.
2014-06-20 22:37:41 +02:00
wm4 8ce73ebbe0 stream_dvd, stream_dvdnav: map dvd:// to dvdnav
The old stream_dvd.c implementation is still available under dvdread://.
2014-06-20 19:43:51 +02:00
wm4 e41755553b stream_dvd: fix potential endless loop on seeking
Attempt to fix a reported freeze with some DVDs. Unknown if this helps,
and it still might read the whole DVD before terminating.
2014-06-20 19:26:04 +02:00
wm4 05fd3e701b client API: declare as stable
It is reasonably stable, so all further changes will be versioned.

Also change how the libmpv version number is generated. Fix the patch
version number to 0; I don't think we have a use for this. In
particular, the version doesn't version mpv, just the client API.
2014-06-20 19:26:04 +02:00
wm4 af9e40119d build: remove some trailing whitespace 2014-06-20 19:21:11 +02:00
wm4 745889c68c vo_vaapi: fix reference counting when using software decoding
Recent regression.
2014-06-20 19:20:59 +02:00
Marcoen Hirschberg c4f518f132 vf_dlopen: fix the order of the arguments to mp_image_alloc 2014-06-19 23:07:02 +02:00
wm4 0a55ee400a sd_lavc: fix stupidity
Reallocating an array while you still have pointers to it -> bad idea.

Recent regression.
2014-06-19 18:49:46 +02:00
wm4 d9b1661895 vo_wayland: fix clearing the screen on reconfig
Do this simply by clearing the mapped buffer on every draw_image() call
without an actual video frame. (Maybe this is a bit expensive, but at
least not more expensive than regular video display.)
2014-06-18 20:22:10 +02:00
wm4 fc59a765eb vo_sdl: fix clearing the screen on reconfig
Clear the texture on reconfig(). (We could probably also do this simpler
with a flag, but this is actually less complicated - except that we move
the code to "map" a texture to a separate function.)
2014-06-18 20:21:07 +02:00
wm4 9accfe0426 video/out: fix redrawing with no video frame for some VOs
With the change to merge osd drawing into video frame drawing, some
bogus logic got in: they skipped drawing the OSD if no video frame is
available. This broke --no-video --force-window mode.
2014-06-18 20:04:59 +02:00
Timothy Gu 86e5f15592 bootstrap: update waf website and version
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: wm4 <wm4@nowhere>
2014-06-18 15:56:57 +02:00
wm4 504f67a759 vo_opengl: fix regression with opengl:pbo
In the pbo case, mpi was reassigned to a stack pointer, and later
deallocated. Just change the code so it doesn't need to be reassigned.
2014-06-18 15:55:01 +02:00
wm4 af6ecb0256 manpage: remove bogus significant whitespace
Made the first line formatted differently.
2014-06-18 15:48:22 +02:00
wm4 8161d45408 gl_video: fix refcounting 2014-06-18 02:13:38 +02:00
wm4 c048b5db02 options: allow adding multiple files with --audio-file
At least 1 person expected that this works this way.
2014-06-18 01:58:05 +02:00
wm4 c48dd85821 sd_lavc: improve bitmap subtitle timing
Until now, bitmap subtitles were decoded at "some" point, and then
simply replaced the old subtitle. Although the subtitle is selected
by time (PTS), it could happen that a subtitle was replaced too early.
One consequence is that this might lead to flicker even if the
subtitles are timed to follow each other without a gap (although most
subtitles are explicitly timed to introduce such a gap). With this
commit the past 4 subtitles are kept (instead of 1), so that the
correct one can be picked by time. This should fix the aforementioned
cases, but more importantly will allow demuxing/decoding and video
display to be somewhat asynchronous.

Still missing: somehow making sure the correct range of decoded
subtitles is available, instead of just passing along whatever comes
from the demuxer, and hoping that 4 queued subtitles are enough. But it
should certainly be good enough for now.

This removes a check that resets the subtitles if the PTS is 5 minutes
before the end of the current subtitle; this is probably not needed.
2014-06-18 01:57:57 +02:00
wm4 a28e2a7432 video: correct spelling: mp_image_params_equals -> mp_image_params_equal
The type is struct mp_image_params, so the "params" should have a "s".
"equals" shouldn't, because it's plural for 2 params. Important.
2014-06-17 23:30:27 +02:00
wm4 efa6b09b65 video: remove redundant function
mp_image_params_from_image() is now trivial and can be removed.
2014-06-17 23:26:53 +02:00
wm4 2827ff1eab DOCS/contribute.md: move instructions for sending patches to the top
Separate to not confuse git history tracking.
2014-06-17 23:18:13 +02:00
wm4 ed1250b080 DOCS: remove coding-style.md to contribute.md
I wonder if this is better. The intention is to make the instructions
for sending patches more visible.
2014-06-17 23:15:39 +02:00
wm4 90cd5aa8c8 vo: make draw_image and vo_queue_image transfer image ownership
Basically a cosmetic change. This is probably more intuitive.
2014-06-17 23:05:50 +02:00
Alessandro Ghedini 84eebc6e4e build: check for 64bit stdatomic.h operations too
This fixes the build on platform where the atomic calls can't be turned into
lock-free instructions and thus need the external libatomic library (e.g. mips).
2014-06-17 22:44:51 +02:00
wm4 8ffef4be92 demux_mkv: add S_DVBSUB
Probably works; untested.
2014-06-17 22:44:27 +02:00
wm4 f76b3f8d19 encode: disable playback framedropping
--framedrop is intended for playback only, and does nothing good with
encoding. It would just randomly drop frames.
2014-06-17 22:44:19 +02:00
wm4 d107cae0e7 video: check image parameters
Make sure every video filter has valid parameters for input and output.
(This also ensures we don't take possibly invalid decoder output, or
feed invalid decodr/filter output to VOs.)

Also, the updated image size check now (almost) works like the
corresponding check in FFmpeg.
2014-06-17 22:44:13 +02:00
wm4 72aac9ae8a video: introduce failure path for image allocations
Until now, failure to allocate image data resulted in a crash (i.e.
abort() was called). This was intentional, because it's pretty silly to
degrade playback, and in almost all situations, the OOM will probably
kill you anyway. (And then there's the standard Linux overcommit
behavior, which also will kill you at some point.)

But I changed my opinion, so here we go. This change does not affect
_all_ memory allocations, just image data. Now in most failure cases,
the output will just be skipped. For video filters, this coincidentally
means that failure is treated as EOF (because the playback core assumes
EOF if nothing comes out of the video filter chain). In other
situations, output might be in some way degraded, like skipping frames,
not scaling OSD, and such.

Functions whose return values changed semantics:

  mp_image_alloc
  mp_image_new_copy
  mp_image_new_ref
  mp_image_make_writeable
  mp_image_setrefp
  mp_image_to_av_frame_and_unref
  mp_image_from_av_frame
  mp_image_new_external_ref
  mp_image_new_custom_ref
  mp_image_pool_make_writeable
  mp_image_pool_get
  mp_image_pool_new_copy
  mp_vdpau_mixed_frame_create
  vf_alloc_out_image
  vf_make_out_image_writeable
  glGetWindowScreenshot
2014-06-17 22:43:43 +02:00
wm4 973c1fa570 gl_lcms: use thread-safe lcms API, require lcms2 2.6
The error log callback was not thread-safe and not library-safe. And
apparently there were some other details that made it not library-safe,
such as a global lcms plugin registry.

Switch the the thread-safe API provided by lcms2 starting with 2.6.
Remove our approximate thread-safety hacks.

Note that lcms basically provides 2 APIs now, the old functions, and
the thread-safe alternatives whose names end with THR. Some functions
don't change, because they already have a context of some sort. Care
must be taken not to accidentally use old APIs.
2014-06-16 18:02:52 +02:00
xylosper 858d6d93cb build: add '--enable-libmpv-static' option
Signed-off-by: wm4 <wm4@nowhere>
2014-06-16 18:02:50 +02:00
wm4 ae1b1a68cb cache: avoid race condition between cache wakeup and idling
When the reader is out of data, it tries to wake up the cache thread to
get more data. In theory, there's a small race condition, which could
cause the cache to miss the wakeup and idle before reaction.

Most certainly didn't cause real issues, because even if this extremely
unlikely race condition happens, the cache won't idle for longer than
1 second (the hardcoded cache idle time).
2014-06-16 01:00:59 +02:00
wm4 eca0fcb77a vo_opengl: simplify redraw callback OSD handling
OSD used to be not thread-safe at all, so a track was used to get it
redrawn. This mostly reverts commit 6a2a8880, because OSD not being
thread-safe was the non-trivial part of it.

Mostly untested, because this code path is used on OSX only, and I don't
have OSX.
2014-06-16 01:00:59 +02:00
wm4 c5e13cce52 discnav: make OSD path explicitly thread-safe
The main issue was actually that the OSD callback locked the subtitle
decoder, which does not necessarily work, because the OSD code is
already allowed to lock it. The state was already protected by
unsetting the callback (which involes the OSD lock). So, in summary,
this is probably just a cleanup.
2014-06-16 01:00:53 +02:00
wm4 c54174b40e sub: prefer ffmpeg microdvd converter over internal one
We certainly don't want to maintain and improve the internal converter,
but we still need the internal one for Libav. (In the Libav case,
demux_subreader.c will be used to read the MicroDVD file.)
2014-06-15 21:10:38 +02:00
wm4 716285782d video/out: change aspects of OSD handling
Let the VOs draw the OSD on their own, instead of making OSD drawing a
separate VO driver call. Further, let it be the VOs responsibility to
request subtitles with the correct PTS. We also basically allow the VO
to request OSD/subtitles at any time.

OSX changes untested.
2014-06-15 20:53:15 +02:00
wm4 d88aca6fb2 vo_vaapi: fix a crash on the init error handling path
No X display or libva can't be initialized -> crash.
2014-06-15 16:58:31 +02:00
Alexander Preisinger 73121dbcc1 wayland: move subsurfaces to wayland vo
Subsurfaces are only used by the wayland vo. Thats why it makes sense to move
all osd and subsurface specific parts to the vo_wayland.c

Also destroy the subsurfaces and subcompositor properly.
2014-06-15 14:46:27 +02:00
Alexander Preisinger f14b45588e wayland: attach NULL surface on osd creation
When using the EGL output the subsurfaces have no buffer attached and the size
seems to be infinite. Fix this by attaching a NULL buffer.

Fixes #846
2014-06-15 14:27:12 +02:00
Amos Onn 8593c4f70b ao_pcm: fix message strings
Signed-off-by: wm4 <wm4@nowhere>
2014-06-15 09:25:15 +02:00
Stefano Pigozzi f645e8921c cocoa: add fallback for automatic GPU switching
Not all the hardware supports kCGLPFASupportsAutomaticGraphicsSwitching
(apparently all Mid-2010 and before MacBooks do not work with it), so fallback
to not asking for this attribute in the GL pixel format.
2014-06-15 08:20:06 +02:00
Stefano Pigozzi 1927f4535c cocoa: allow automatic gpu switching
Fixes #820
2014-06-15 08:19:55 +02:00
Stefano Pigozzi c3d17ece7b cocoa: switch to CGL APIs for GL context creation
CGL APIs are lower level thus giving us better control and more options for
the context creation.
2014-06-15 08:18:48 +02:00
wm4 3a998e5b1e demux: use position as signed integer
Seeing (uint64_t)-1 as value when position was unset was annoying.
2014-06-14 22:18:29 +02:00
wm4 53d762e972 tv: if timestamp is unset, return NOPTS
Well, not sure if this really improves anything, but at least it's less
of a WTF to the playback core than always returning the same timestamp
for every frame.
2014-06-14 22:17:55 +02:00
wm4 dfd93a108c tv: remove some non-sense
There's really no need to convert this to float and then back. This is
mostly of cosmetic nature, double precision was probably enough to avoid
rounding.
2014-06-14 21:29:40 +02:00
wm4 1d920047ab tv: fix compilation without clock_gettime, don't claim to be MPlayer
mp_msg() doesn't exist anymore in this form. Oops.
2014-06-14 21:26:17 +02:00
wm4 63266d4372 sub: add --sub-scale-with-window option
Implements the feature requested in #839 and #186.
2014-06-14 19:17:31 +02:00
wm4 a9fd52e493 gl_w32: remove unused variable 2014-06-14 19:17:25 +02:00
Philip Sequeira a7293b92f4 build: version string as native str type for each Python version
Should resolve the "mpv b'...'" issue on Python 3 without breaking
things on Python 2.

Also, remove redundant wait for process.
2014-06-14 10:11:07 +02:00
wm4 f193d25844 video: cosmetics: reformat image format names table 2014-06-14 10:06:23 +02:00
wm4 a9538e17ad video: synchronize mpv rgb pixel format names with ffmpeg names
This affects packed RGB formats up to 16 bits per pixel. The old mplayer
names used LSB-to-MSB order, while FFmpeg (and some other libraries) use
MSB-to-LSB.

Nothing should change with this commit, i.e. no bit order or endian bugs
should be added or fixed. In some cases, the name stays the same, even
though the byte order changes, e.g. RGB8->BGR8 and BGR8->RGB8, and this
affects the user-visible names too; this might cause confusion.
2014-06-14 10:03:04 +02:00
wm4 6ab72f9760 video: automatically strip "le" and "be" suffix from pixle format names
These suffixes are annoying when they're redundant, so strip them
automatically. On little endian machines, always strip the "le" suffix,
and on big endian machines vice versa (although I don't think anyone
ever tried to run mpv on a big endian machine).

Since pixel format strings are returned by a certain function and we
can't just change static strings, use a trick to pass a stack buffer
transparently. But this also means the string can't be permanently
stored by the caller, so vf_dlopen.c has to be updated. There seems
to be no other case where this is done, though.
2014-06-14 09:58:48 +02:00
Alessandro Ghedini 6842d4bde5 build: fix generation of zsh completion
The Perl script must be run *after* the mpv executable is generated. Also use
an absolute path to it.
2014-06-13 12:27:01 +02:00
wm4 85cd114e54 tv: add missing header for clock_gettime
Not sure how this symbol becomes visible in glibc (probably accidental
or mandatory recursive inclusion via the other standard or Linux-
specific headers), but normally this include file is needed to get the
symbol.
2014-06-13 12:26:32 +02:00
wm4 b7bedbbc36 options: remove some more stuff
The "classic" sub-option stuff is not really needed anymore. The only
remaining use can be emulated in a simpler way. But note that this
breaks the --screenshot option (instead of the "flat" options like
--screenshot-...). This was undocumented and discouraged, so it
shouldn't affect anyone.
2014-06-13 02:18:26 +02:00
wm4 a64e099efc options: remove some unneeded stuff
No options pointing to global variables are in use anymore, so that part
can be removed.
2014-06-13 02:16:47 +02:00
wm4 e00aad18cb command: redo the property type
Instead of absuing m_option to store the property list, introduce a
separate type for properties. m_option is still used to handle data
types. The property declaration itself now never contains the option
type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This
was already done with some properties, now all properties use it.)

This also fixes that the function signatures did not match the function
type with which these functions were called. They were called as:

   int (*)(const m_option_t*, int, void*, void*)

but the actual function signatures were:

   int (*)(m_option_t*, int, void*, MPContext *)

Two arguments were mismatched.

This adds one line per property implementation. With additional the
reordering of the parameters, this makes most of the changes in this
commit.
2014-06-13 02:11:39 +02:00
wm4 6a4a5595d8 options: remove OPT_FLAG_CONSTANTS
This means use of the min/max fields can be dropped for the flag option
type, which makes some things slightly easier. I'm also not sure if the
client API handled the case of flag not being 0 or 1 correctly, and this
change gets rid of this concern.
2014-06-13 02:10:45 +02:00
wm4 09a61ba03a options: remove use of an inverted option value
Now MPOpts.sub_fix_timing corresponds to the commandline switch
directly, instead of storing the inverted value.
2014-06-13 02:06:03 +02:00
wm4 98a31d5937 options: turn --idx, --forceidx into --index
Also clarify the semantics.

It seems --idx didn't do anything. Possibly it used to change how the
now removed legacy demuxers like demux_avi used to behave. Or maybe
it was accidental.

--forceidx basically becomes --index=force. It's possible that new
index modes will be added in the future, so I'm keeping it
extensible, instead of e.g. creating --force-index.
2014-06-13 02:05:37 +02:00
wm4 a7a14be088 vd_lavc: use option parser for skip suboptions 2014-06-13 02:03:45 +02:00
wm4 f3582c4993 input.conf: make ESC quit when encoding 2014-06-13 02:03:14 +02:00
wm4 5fed3a253e demux: use av_malloc for packets
Probably "needed" to get the correct alignment, although I'm not aware
of actual breakages or performance issues.

In fact we should probably always just allocate AVPackets, but for now
use the simple fix.
2014-06-13 02:03:10 +02:00
wm4 7e7ff4b0ea demux: simplify packet resizing
Actually we don't need to resize packets; we just need to make them
shorter.
2014-06-13 02:02:30 +02:00
Rudolf Polzer ee2e91dce1 encode: get rid of the recursion that led to a deadlock.
Instead, the recursive call has been flattened away by instead
overwriting a parameter and continuing.
2014-06-12 11:42:00 +02:00
Rudolf Polzer 309eb6398c Revert "encode: make the central lock recursive"
This reverts commit 231c667214.
2014-06-12 10:37:17 +02:00
wm4 d69e068fda demux: fix compilation with FFmpeg git
FFmpeg requires a bullshit padding after each input buffer, and they
just increased that padding without warning and without ABI or API bump.

We need this only in one file (although mp_image hardcodes something
similar, for which no FFmpeg API define is available), so drop our own
define.
2014-06-12 01:04:53 +02:00
wm4 598245a80f cache: print cache size only in verbose mode
Seems pretty useless in general, so this reduces output noise.
2014-06-12 00:55:14 +02:00
wm4 8ad8dedca8 win32: implement --priority differently
Does anyone actually use this?

For now, update it, because it's the only case left where an option
points to a global variable (and not a struct offset).
2014-06-12 00:55:14 +02:00
wm4 66f67835c3 tv: fix a hidden static variable 2014-06-12 00:55:13 +02:00
wm4 58b8a10bab stream_bluray: fix some const declarations
Like in commit 99f5fe.
2014-06-12 00:55:13 +02:00
wm4 0d7c4b24c1 encode: don't load Lua scripts
This is most likely never intended.
2014-06-12 00:55:13 +02:00
wm4 9a0baa4c53 audio: more detailed debugging output
Dump what the AO does on driver->play().
2014-06-12 00:55:13 +02:00
wm4 d07cd11b14 audio: don't wait when draining and paused
A corner case that could possibly lead to infinite waiting. Though
I'm not aware that this actually happened in practice.
2014-06-12 00:55:13 +02:00
wm4 231c667214 encode: make the central lock recursive
Unfortunately, there's a recursive function call in ao_lavc.c (play
function), leading to a deadlock. The locking is getting a bit messy, so
just make the lock recursive.

This fixes #844.
2014-06-12 00:55:10 +02:00
xylosper 0b7facf05d options: fix for compilation when encoding disabled
HAVE_* flags are always defined so ifdef will never work.
They should be checked with their values.
2014-06-12 00:29:22 +02:00
iive e302e1da58 tv: use correct timestamps
Squashed from the following mplayer-svn commits. The '#' is removed from
the bug ID to prevent github from doing something stupid. Instead of
adding the mplayer configure check for clock_gettime(), the POSIX
identifiers are used for checking presence of the function.

Use correct type of timestamps when recording from v4l2. Fix 2176

Patch by Jarek Czekalski <jarekczek at poczta onet pl>.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@37222 b3059339-0415-0410-9bf9-f77b7e298cf2

Allow building of v4l2 without clock_gettime().
Add overly verbose message in case monotone timestamps are required by the kernel.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@37223 b3059339-0415-0410-9bf9-f77b7e298cf2
2014-06-12 00:28:58 +02:00
wm4 8f60de98be encode: make option struct local
Similar to previous commits.
2014-06-11 02:05:07 +02:00
wm4 be5725ebc4 input: make option struct local
Similar to previous commits.

This also renames --doubleclick-time to --input-doubleclick-time, and
--key-fifo-size to --input-key-fifo-size. We could keep the old names,
but these options are very obscure, and renaming them seems better for
consistency.
2014-06-11 01:54:03 +02:00
wm4 654930aa47 demux_lavf: make option struct local
Similar to previous commits.
2014-06-11 01:46:20 +02:00
wm4 7f7aa03eda ad_lavc: make option struct local
Similar to previous commit.
2014-06-11 01:39:51 +02:00
wm4 14983eb37d vd_lavc: make option struct local
Removes specifics from options.h and options.c, and puts everything into
vd_lavc.c.
2014-06-11 01:36:11 +02:00
wm4 a7ed3610ca options: remove a global variable
This is probably the last one, at least with my current configuration.
2014-06-11 00:39:14 +02:00
wm4 e34e1080d2 vf_noise: remove global variables 2014-06-11 00:39:14 +02:00
wm4 e9391e5827 vf_divtc: remove a global variable 2014-06-11 00:39:14 +02:00
wm4 99f5fef0ea Add more const
While I'm not very fond of "const", it's important for declarations
(it decides whether a symbol is emitted in a read-only or read/write
section). Fix all these cases, so we have writeable global data only
when we really need.
2014-06-11 00:39:14 +02:00
wm4 ad4b7a8c96 vo_caca: remove global variables
The shit I put up with...
2014-06-11 00:39:13 +02:00
wm4 f9f89b9049 demux_raw: remove global option variables 2014-06-11 00:39:13 +02:00
wm4 099cdbf019 demux_mf: remove global option variables 2014-06-11 00:39:13 +02:00
wm4 fd5207f56d options: remove global variables for swscale options; rename them
Additionally to removing the global variables, this makes the options
more uniform. --ssf-... becomes --sws-..., and --sws becomes --sws-
scaler. For --sws-scaler, use choices instead of magic integer values.
2014-06-11 00:39:13 +02:00
wm4 2fc3be582c stream_dvd: minor cleanups
We don't need a separate stream_dvd.h header file anymore. Some dead
functions become apparent; remove them.
2014-06-11 00:39:13 +02:00
wm4 35e6d1abe0 stream_dvd, stream_dvdnav, stream_bluray: remove global option variables 2014-06-11 00:39:06 +02:00
wm4 959b718957 stream_dvb: remove global option variables 2014-06-11 00:35:03 +02:00
wm4 77a7aa2c41 stream_cdda: remove global option variables 2014-06-11 00:34:46 +02:00
wm4 7689f5f7ce stream: add a generic way to setup stream priv defaults
Usually, each stream driver declares the size and option list of its
private data. This was pretty natural for when most streams still used
global variables to setup their defaults. They did by pointing
priv_defaults to the (mutable) struct containing the option values. But
falls short when storing the option values in MPOpts. So provide a
somewhat inelegant but simple way to let the stream implementation setup
the priv struct at initialization time.

This is done with the get_defaults callback. It should return a copy of
the struct used in MPOpts. (A copy, because if MPOpts is changed, string
fields might be deallocated, and if that field is not described by
stream_info.options, it won't be copied on init.)
2014-06-11 00:34:46 +02:00
wm4 73ac34b220 stream_pvr: remove global option variables 2014-06-11 00:34:42 +02:00
wm4 fcf9bb95b5 tv: remove printing of useless comment information 2014-06-11 00:34:42 +02:00
wm4 383cf20785 tv: remove global option variables
Pretty much nothing changes, but using -tv-scan with suboptions doesn't
work anymore (instead of "-tv-scan x" it's "-tv scan-x" now). Flat
options ("-tv-scan-x") stay compatible.
2014-06-11 00:34:42 +02:00
wm4 98c0930f9b m_config: add function to copy subopt-struct 2014-06-11 00:34:41 +02:00
wm4 e033f3c8bc command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not
sure what to do with this.) Also, internally, don't access stream
details directly, but dispatch commands with stream ctrls.

Many of the new properties are a bit strange, because they're write-
only. Also remove some OSD output these commands produced, because I
couldn't be bothered to port these.

In general, this makes everything much cleaner, and will also make it
easier to e.g. move the demuxer to its own thread.

Don't bother updating input.conf, but changes.rst documents how old
commands map to the new ones.

Mostly untested, due to lack of hardware.
2014-06-11 00:34:41 +02:00
ChrisK2 9420eb5a07 osd: Center the volume icon in the osd font 2014-06-10 02:16:46 +02:00
wm4 9d3232e058 build: disable zsh completions by default, fixes e.g. cross compilation
The Perl script generating the completions actually invokes mpv, and it
runs during the build. This is not sane and breaks at least cross
compilation.

As a workaround, disable the completions by default for now.
2014-06-09 15:17:03 +02:00
wm4 ce0bf5e7dd player: hide some messages in verbose mode
This started getting annoying.
2014-06-09 01:21:13 +02:00
wm4 e1d846263a video: fix another cover art corner case
Playing a video and then an audio file with cover art kept displaying
the last frame of the video. This was because the hasframe flag was set,
perhaps due to redrawing the last video frame before the cover art image
is decoded.
2014-06-09 01:21:08 +02:00
wm4 adea4386bc client API: disable LIRC input by default
Not only should using libmpv hog such global resources; it's also very
unlikely an application embedding mpv will ever want to make use of
this.
2014-06-09 01:20:55 +02:00
wm4 3e2f16a89e audio: add a "weak" gapless mode, and make it default
Basically, this allows gapless playback with similar files (including
the ordered chapter case), while still being robust in general.

The implementation is quite simplistic on purpose, in order to avoid
all the weird corner cases that can occur when creating the filter
chain. The consequence is that it might do not-gapless playback in
more cases when needed, but if that bothers you, you still can use
the normal gapless mode.

Just using "--gapless-audio" or "--gapless-audio=yes" selects the old
mode.
2014-06-09 01:20:53 +02:00
wm4 da89af1076 player: show "neutral" position markers for OSD bars
This commit implements them for volume and some video properties.
2014-06-08 23:52:58 +02:00
Alessandro Ghedini cc74bc3fec build: generate and install zsh completion script 2014-06-08 20:48:42 +02:00
Alessandro Ghedini da27eceb85 TOOLS: add script for generating a zsh completion script
As discussed in #775
2014-06-08 20:48:39 +02:00
wm4 09dd1ed47c client API: minor documentation fixes/enhancements 2014-06-08 16:11:39 +02:00
wm4 51834592fc client API: trigger wakeup when creating wakeup pipe/callback
Since redundant wakeups are avoided now, it's easy to miss a wakeup when
creating/setting the pipe/callback after the client API was signalled.
If the client API is signalled, need_wakeup is set to true, and
wakeup_client skips writing to the pipe or calling the client API. That
this can happen is not very obvious to the client API, so trigger a
wakeup right on start in order to remove this special case.
2014-06-08 16:11:11 +02:00
wm4 f118d2af6a manpage: document new --sub-file semantics
This was forgotten in the previous commit.
2014-06-08 00:20:58 +02:00
wm4 924d4db0de options: change --sub-file behavior
--sub-file is actually a string list, so you can add multipel external
subtitle files. But to be able to set a list, the option value was split
on ",". This made it impossible to add filenames.

One possible solution would be adding escaping. That's probably a good
idea (and some other options already do this), but it's also complicated
both to implement and for the user.

The simpler solution is making --sub-file appending, and make it take
only a single entry.

I'm not quite sure about this yet. It breaks the invariant that if a
value is printed and parsed, you get the same value back. So for now,
just go with the simple solution.

Fixes #840.
2014-06-08 00:03:45 +02:00
wm4 5cc68c792b client API: restructure waiting, do log msg wakeup properly
Until now, availability of new log messages (through the mechanism
associated with mpv_request_log_messages()) did not wakeup the client
API properly. Commit 3b7402b5 was basically a hack to improve that
somewhat, but it wasn't a solution.

The main problem is that the client API itself is producing messages, so
the message callback would attempt to lock the client API lock,
resulting in a deadlock. Even if the lock was recursive, we'd run into
lock-order issues.

Solve this by using a separate lock for waiting and wakeup. Also, since
it's a natural addition, avoid redundant wakeups. This means the wakeup
callback as well as the wakeup pipe will be triggered only once until
the next mpv_wait_event() call happens.

This might make the wakeup callback be invoked in a reentrant way for
the first time, for example if a mpv_* function prints to a log. Adjust
the docs accordingly. (Note that non-reentrant beheavior was never
guaranteed - basically the wakeup callback is somewhat dangerous and
inconvenient.)

Also remove some traces of unneeded code. ctx->shutdown for one was
never set, and probably a leftover of an abandoned idea.
2014-06-07 23:16:46 +02:00
wm4 fca608ccb9 client API: rename mpv_destroy() to mpv_detach_destroy()
A bit verbose, but less misleading. In most cases, the API user probably
actually wants mpv_terminate_destroy() instead, so the less-useful
function shouldn't have a simnpler name anyway.
2014-06-07 20:25:48 +02:00
wm4 0b9468f65f client API: clarify mpv_get_wakeup_pipe docs
It wasn't necessarily clear how this works. Especially make clear that
the API user shouldn't expect that there's one byte per readable event
in the wakeup pipe. Actually, the reason why this currently won't work
is because property notifications can generate more events than wakeups.
The limit of 4096 is a more fundamental issue, but the event ringbuffer
is currently limited to 1000 entries anyway.

Also add some important comments to mpv_set_wakeup_callback.
2014-06-07 20:13:01 +02:00
wm4 500ce69a06 client API: add API function that ensures total destruction
mpv_destroy() should perhaps better be called mpv_detach(), because it
destroys only the handle, not necessarily the player. The player is only
terminated if a quit command is sent.

This function quits automatically, and additionally waits until the
player is completely destroyed. It removes the possibility that the
player core is still uninitializing, while all client handles are
already destroyed. (Although in practice, the difference is usually not
important.)
2014-06-07 15:57:54 +02:00
wm4 d64bd9efa1 client API: docs: some clarifications 2014-06-07 15:57:54 +02:00
wm4 a1000962e3 client API: change mpv_wait_event() timeout semantics
Now a negative timeout mean an infinite timeout. This is similar to the
poll() system call. Apparently this is more intuitive and less confusing
than specifying a "very high" value as timeout if you want to wait
forever.

For callers that never pass negative timeouts, nothing changes.
2014-06-07 15:57:47 +02:00
wm4 60e0833f1f build: prevent installation of client API example
This was never intended to be installed; waf just picked it up
automagically. There's also a closed ticket on github where someone
complains that the program "simple" is installed, and I didn't realize
at this point that it was actually installed by default when enabling
the client API.
2014-06-06 19:43:53 +02:00
wm4 43d46a28fe client API: enlarge the message buffer if log level is high 2014-06-06 19:25:52 +02:00
wm4 3b7402b51c client API: call wakeup callback if there are new messages
Listening on messages currently uses polling (every time
mpv_wait_event() has no new events, the message buffer is polled and a
message event is possibly created). Improve this situation a bit, and
call the user-supplied wakeup callback.

This will increase the frequency with which the wakeup callback is
called, but the client is already supposed to be able to deal with this
situation. Also, as before, calling mpv_wait_event() from the wakeup
callback is forbidden, so the client can't read new messages from the
callback directly.

The wakeup pipe is written either. Since the wakeup pipe is created
lazily, we can't access the pipe handle without creating a race
condition or a deadlock. (This is actually very silly, since in practice
the race condition won't matter, but for now let's keep it clean.)
2014-06-06 19:24:30 +02:00
wm4 79e76abb4d x11: cleanup motif hints handling
It seems we can't really get rid of this. There are no other hints to
remove decorations that work across all reasonable WMs, so we're stuck
with the ugly motif stuff.

But at least we can make the code for it less ugly.
2014-06-06 18:45:38 +02:00
wm4 cdcdddfc63 client API: fix terminal usage
By default this is disabled. But if it's enabled, then we have to
account for proper states when enabling/disabling the terminal state
itself.
2014-06-06 17:28:13 +02:00
wm4 ecbb12923f client API: don't update properties in uninitialized state
If an API user calls mpv_wait_event() and mpv_observe_property() before
mpv_initialize(), it could happen that a property was accessed before
initialization, which is not ok.
2014-06-06 17:27:05 +02:00
wm4 4279712d1e client API: don't use the mpv config files by default
This was always intended this way, and even documented in client.h. Due
to an oversight it was never actually implemented.

The intention is that mpv embedded in applications and "real mpv" don't
conflict. An API user can undo this by setting the "config" option to
"yes", if using the user's mpv config is desired.
2014-06-06 17:26:01 +02:00
wm4 7716424d48 client API: use shared code for creating the wakeup pipe
Should be equivalent, reduces code duplication.
2014-06-06 17:22:53 +02:00
wm4 662592c860 client API: fix swapped pipe ends used with mpv_set_wakeup_callback
This was extremely wrong. It was never tested because nobody ever used
it (the feature was added for someone who never tried it in the end).
2014-06-06 17:21:30 +02:00
wm4 a854583b57 input: don't print warning when aboting playback via commands
I don't really see a reason for this.
2014-06-06 17:17:22 +02:00
wm4 aafc03aab3 wscript: update waf version check to the version in bootstrap.py 2014-06-06 17:13:50 +02:00
wm4 b4c1699aaf sub: remove old style override option
Didn't work too well.
2014-06-05 01:10:48 +02:00
wm4 015399f696 sub: add --ass-style-override=force option
(The old "force" choice of that option is renamed to "force-default".)

This allows overriding native ASS script subtitle styles with the style
provided by the --sub-text-* options (like --sub-text-font etc.). This
is disabled by default, and needs to be explicitly enabled with the
--ass-style-override=force option and input property.

This uses in fact exactly the same options (--sub-text-*) and semantics
as the ones used to configure unstyled text subtitles.

It's recommended to combine this with this in the mpv config file:

ass-force-style="ScaledBorderAndShadow=1"   # work around dumb libass behavior

Also, adding a key binding to toggle this behavior should be added,
because overriding can easily break:

L cycle ass-style-override

This would cycle override behavior on Shift+L and allows quickly
disabling/enabling style overrides.

Note: ASS should be considered a vector format rather than a subtitle
format. There is no easy or reliable way to determine whether the style
of a given subtitle event can be changed without destroying visuals or
not. This patch relies on a simple heuristic, which often works and
often breaks.
2014-06-05 01:10:37 +02:00
wm4 e82af029a9 stream/cache: handle failure of seeking underlying stream
This could for example happen when serving an incomplete file from http,
and the demuxer tries reading data from the end of the file when opening
it (e.g. with avi). Seeking past EOF fails with http, so the file could
never be opened, and the cache would get stuck trying to seek to the
position.

We can't really make the cache report seek failure directly (it would
suck for various reasons), so just make the cache report EOF if seeking
fails.
2014-06-05 00:19:50 +02:00
wm4 99e498611e lua: make warning about unknown scripts -v only 2014-06-04 00:33:17 +02:00
wm4 80907d007b filter_kernels: fix nearest scaler
The previous commit assumed the filter would be 1x1 (then constant
weight is correct) - but our code in fact uses at least a 2x2 filter. A
1x1 filter would generally be useless, except for nearest scaling - so
it didn't exist.

Insteasd of adding such a 1x1 filter, just turn the nearest weight
function into a scare function, which should take care of the issue.
2014-06-04 00:23:31 +02:00
lucy a3b466e88d filter_kernels: add nearest neighbour scaling
This is useful for playing content containing pixel art that hasn't been
pre-scaled, such as TASVideos' high quality encodes. The implementation is
lifted from <https://code.google.com/p/glumpy/source/browse/glumpy/image/filter.py#413>.
2014-06-03 23:00:24 +02:00
wm4 35f87dc692 audio/out/push: don't attempt to fill AO buffer when paused
Doing so will implicitly resume playback. Broken in commit 5929dc45.
2014-06-03 15:58:25 +02:00
Marcoen Hirschberg af25e0aba8 command: format_bitrate: fix conversion to kbits and mbits
Bitrates are now expressed in bits/second. This commit fixes conversions
which assumed it was still in bytes/second.

Signed-off-by: wm4 <wm4@nowhere>
2014-06-02 22:20:25 +02:00
Marcoen Hirschberg d838bd6420 osc: keep track of the "fullscreen" state when it changes
This avoids having to poll the "fullscreen" property in the tick
callback.
2014-06-02 22:20:25 +02:00
wm4 58b070d178 wayland: remove stub for unimplemented function 2014-06-02 20:20:35 +02:00
wm4 c56520f232 osd/libass: use BorderStyle=4 for background
Avoids (some) overlaps. Hopefully fixes #822.
2014-06-01 23:53:24 +02:00
Alessandro Ghedini f2a00f3de3 player: write file name to the watch later config file
This simply writes the file name as a comment to the top of the watch later
config file.

It can be useful to the user for determining whether a watch later config file
can be manually removed (e.g. in case the corresponding media file has been
deleted) or not.
2014-06-01 19:55:45 +02:00
wm4 b8cb860471 audio: prefer dsound over wasapi
ao_wasapi has too many subtle failures that were reported, but there's
nobody to fix them. ao_dsound seems to be more robust; so prefer it.
2014-06-01 19:00:44 +02:00
wm4 556bb1cf13 demux_lavf: support new rotation metadata API 2014-06-01 17:56:10 +02:00
Andrey Morozov b5e40e15a3 command: improve video-bitrate property
Signed-off-by: wm4 <wm4@nowhere>

Includes some cosmetic changes over the original PR.
2014-06-01 17:27:17 +02:00
wm4 ae09c0d8eb vo: correctly initialize parameters in corner cases 2014-06-01 17:24:19 +02:00
wm4 2bc871b577 m_option: use isfinite() instead of isnormal()
This accidentally rejected d==0. We can actually deal with sub-normals
fine, we just want to exclude nan and infinity (although infinity is
already accounted for, but anyway).
2014-06-01 17:23:56 +02:00
wm4 a192f32a3a stream: remove VCD support
If a single person complains, I will readd it. But I don't expect that
this will happen.

The main reason for removing this is that it's some of the most unclean
code remaining, it's unmaintained, and I've never ever heard of someone
using it.
2014-06-01 17:22:21 +02:00
wm4 5a5a3c53f7 client API: report success status when running commands
Until now, an error was reported only if the command couldn't be parsed.
Attempt to do more fine-grained reporting. This is not necessarily
perfect, but it's an improvement.
2014-06-01 03:41:46 +02:00
wm4 c84f873596 command: property notification when changing af/vf 2014-06-01 03:41:43 +02:00
wm4 69ad734af8 command: add const to mp_notify_property 2014-06-01 03:41:36 +02:00
wm4 498c997474 player: hide audio/video codec and file format messages
None of these are very important usually. For error analysis, the plain
log is useless anyway, and this information is still printed with "-v".
2014-05-31 22:07:36 +02:00
wm4 5567aa131b gl_common: remove dlsym() fallback
See previous commits.
2014-05-31 22:02:35 +02:00
wm4 caf35e695f gl_wayland: remove probably unneeded workaround
This would imply eglGetProcAddress() doesn't work correctly, but using
dlsym() does. For now get rid of it - it won't work in libmpv, and we'll
probably need a better workaround if it's still broken.

This code was in the initial wayland commit.
2014-05-31 22:00:06 +02:00
wm4 c42ac83c7c gl_x11: remove workaround for PPC OSX 10.4
Added in 2010 with commit 4a8486f8 (svn commit 30994). I doubt anyone
still uses X11 on OSX, and we probably don't support 10.4 either.
2014-05-31 21:56:45 +02:00
wm4 8178b80748 gl_x11: always require some GLX API functions, avoid dlsym()
The functions glXGetProcAddressARB() and glXQueryExtensionsString() were
loaded using dlsym(). This could fail when compiling to libmpv, because
then dlopen(NULL, ...) will look in the main program's list of
libraries, and the libGL linked to libmpv is never considered. (Don't
know if this somehow could be worked around.) The result is that using
vo_opengl with libmpv can fail.

Avoid this by not using dlsym(). glXGetProcAddressARB() was already used
directly in the same file, and that never caused any problems. (Still
add it to the configure test.) glXQueryExtensionsString() is documented
as added in GLX 1.1 - that's ancient.
2014-05-31 21:53:04 +02:00
wm4 9f6e8d64de ao_alsa: make device the first sub option
This is more convenient.
2014-05-31 01:40:12 +02:00
wm4 4fa3ffebfe audio/out/push: keep some extra buffer
So the device buffer can be refilled quickly. Fixes dropouts in certain
cases: if all data is moved from the soft buffer to the audio device
buffer, the waiting code thinks it has to enter the mode in which it
waits for new data from the decoder. This doesn't work, because the
get_space() logic tries to keep the total buffer size down. get_space()
will return 0 (or a very low value) because the device buffer is full,
and the decoder can't refill the soft buffer. But this means if the AO
buffer runs out, the device buffer can't be refilled from the soft
buffer. I guess this mess happened because the code is trying to deal
with both AOs with proper event handling, and AOs with arbitrary
behavior.

Unfortunately this increases latency, as the total buffered audio
becomes larger. There are other ways to fix this again, but not today.

Fixes #818.
2014-05-31 01:26:50 +02:00
wm4 9c9f23eee9 ao_alsa: reduce spurious wakeups
Apparently this can happen. So actually only return from waiting if ALSA
excplicitly signals that new output is available, or if we are woken up
externally.
2014-05-30 23:54:11 +02:00
wm4 3053a68d2d tv: remove sysinfo() usage
This call was used limited the buffer size if installed RAM was below 16
MB. This stopped being useful a decade ago. The check could also
overflow on 32 bit systems. Just get rid of it.
2014-05-30 13:30:56 +02:00
wm4 8ba346a554 audio/out/push: handle draining correctly
This did not flush remaining audio in the buffer correctly (in case an
AO has an internal block size). So we have to make the audio feed thread
to write the remaining audio, and wait until it's done.

Checking the avoid_ao_wait variable should be enough to be sure that all
data that can be written was written to the AO driver.
2014-05-30 02:17:15 +02:00
wm4 c79689206c audio: change handling of an EOF corner case
This code handles buggy AOs (even if all AOs are bug-free, it's good for
robustness). Move handling of it to the AO feed thread. Now this check
doesn't require magic numbers and does exactly what's it supposed to do.
2014-05-30 02:16:43 +02:00
wm4 b7c6981278 ao_alsa: use poll() to wait for device
This means the audio feed thread is woken up exactly at the time new
data is needed, instead of using a time-based heuristic.
2014-05-30 02:16:35 +02:00
wm4 5dcfc4f604 audio/out/push: add a way to wait for the audio device with poll()
Will be used for ALSA.
2014-05-30 02:16:25 +02:00
wm4 ec18df8466 input: separate wakeup pipe creation into a separate function
Error handling is slightly reduced: we assume that setting a pipe
to non-blocking can never fail.
2014-05-30 02:16:20 +02:00
wm4 5929dc458f audio/out/push: add mechanism for event-based waiting
Until now, we've always calculated a timeout based on a heuristic when
to refill the audio buffers. Allow AOs to do it completely event-based
by providing wait and wakeup callbacks.

This also shuffles around the heuristic used for other AOs, and there is
a minor possibility that behavior slightly changes in real-world cases.
But in general it should be much more robust now.

ao_pulse.c now makes use of event-based waiting. It already did before,
but the code for time-based waiting was also involved. This commit also
removes one awkward artifact of the PulseAudio API out of the generic
code: the callback asking for more data can be reentrant, and thus
requires a separate lock for waiting (or a recursive mutex).
2014-05-30 02:15:47 +02:00
wm4 35aba9675d audio/out: adjust documentation comments 2014-05-30 02:15:38 +02:00
wm4 d87a84ca89 ring: use a different type for read/write pointers
uint_least32_t could be larger than uint32_t, so the return values of
mp_ring_get_wpos/rpos must be adjusted. Actually just use unsigned long
as type instead, because that is less awkward than uint_least32_t.
2014-05-30 02:15:25 +02:00
wm4 e127cfa0b5 build: disable PortAudio by default
This was originally added because we thought this would make a good
portable audio API, which would give us good behavior on Windows, Linux,
and OSX. But this hope was disappointed: it's not reliable enough (nice
deadlocks on Linux when seeking, i.e. resetting the audio device),
doesn't have enough features (no channel maps, no digital passthrough),
and in general just is not very good.
2014-05-29 02:24:21 +02:00
wm4 c36faf8c49 audio/out/pull: remove race conditions
There were subtle and minor race conditions in the pull.c code, and AOs
using it (jack, portaudio, sdl, wasapi). Attempt to remove these.

There was at least a race condition in the ao_reset() implementation:
mp_ring_reset() was called concurrently to the audio callback. While the
ringbuffer uses atomics to allow concurrent access, the reset function
wasn't concurrency-safe (and can't easily be made to).

Fix this by stopping the audio callback before doing a reset. After
that, we can do anything without needing synchronization. The callback
is resumed when resuming playback at a later point.

Don't call driver->pause, and make driver->resume and driver->reset
start/stop the audio callback. In the initial state, the audio callback
must be disabled.

JackAudio of course is different. Maybe there is no way to suspend the
audio callback without "disconnecting" it (what jack_deactivate() would
do), so I'm not trying my luck, and implemented a really bad hack doing
active waiting until we get the audio callback into a state where it
won't interfere. Once the callback goes from AO_STATE_WAIT to NONE, we
can be sure that the callback doesn't access the ringbuffer or anything
else anymore. Since both sched_yield() and pthread_yield() apparently
are not always available, use mp_sleep_us(1) to avoid burning CPU during
active waiting.

The ao_jack.c change also removes a race condition: apparently we didn't
initialize _all_ ao fields before starting the audio callback.

In ao_wasapi.c, I'm not sure whether reset really waits for the audio
callback to return. Kovensky says it's not guaranteed, so disable the
reset callback - for now the behavior of ao_wasapi.c is like with
ao_jack.c, and active waiting is used to deal with the audio callback.
2014-05-29 02:24:17 +02:00
wm4 690ea07b7a ring: implement drain in terms of read
I think this makes it easier to reason about it and avoids duplicate
logic.
2014-05-29 02:24:05 +02:00
wm4 3238cd3dac atomics: some corrections to __sync builtins usage
We don't need to combine __sync_add_and_fetch with a memory barrier,
since these intrinsics are documented as using a full barrier already.

Use __sync_fetch_and_add instead of __sync_add_and_fetch; this gives
atomic_fetch_add() the correct return value (although we don't use it).

Use __sync_fetch_and_add to emulate atomic_load(). This should enforce
the full barrier semantics better. (This trick is stolen from the
FreeBSD based stdatomic.h emulation.)
2014-05-28 22:44:43 +02:00
Paweł Forysiuk f289060259 Fix gcc 4.7 warning about shadowing talloc_parent in mp_dispact_queue 2014-05-28 22:44:43 +02:00
Marcoen Hirschberg 696733d077 ad_lavc: don't overwrite lavc bitrate
If the bitrate is already known in avcodec there is no need to overwrite
it again with the value from sh_audio.
2014-05-28 21:38:20 +02:00
Marcoen Hirschberg ecea66e8dc vd_lavc: set video bitrate if available
Set the bitrate of dec_video if it is available in avcodec.
2014-05-28 21:38:20 +02:00
Marcoen Hirschberg 1fa48a2452 ao_wasapi: simplify nAvgBytesPerSec calculation
Calculate nBlockAlign seperately to reuse in the calculation of
nAvgBytesPerSec.
2014-05-28 21:38:15 +02:00
Marcoen Hirschberg 31a10f7c38 af_fmt2bits: change to af_fmt2bps (bytes/sample) where appropriate
In most places where af_fmt2bits is called to get the bits/sample, the
result is immediately converted to bytes/sample. Avoid this by getting
bytes/sample directly by introducing af_fmt2bps.
2014-05-28 21:38:00 +02:00
Marcoen Hirschberg 434242adb5 audio: rename i_bps to 'bitrate' to avoid confusion
Since i_bps now contains bits/sec, rename it to reflect this change.
2014-05-28 21:37:50 +02:00
Marcoen Hirschberg 6e58b20cce audio: change values from bytes-per-second to bits-per-second
The i_bps members of the sh_audio and dev_video structs are mostly used
for displaying the average audio and video bitrates. Keeping them in
bits-per-second avoids truncating them to bytes-per-second and changing
them back lateron.
2014-05-28 21:37:44 +02:00
wm4 b442b522f6 vaapi: fix destruction with --hwdec=haapi-copy
This is incomplete; the video chain will still hold some vaapi objects
after destroying the decoder and thus the vaapi context. This is very
bad. Fixing it would require something like refcounting the vaapi
context, but I don't really want to.
2014-05-28 02:08:45 +02:00
wm4 d99f30d726 video: warn if an emulated hwdec API is used
mpv supports two hardware decoding APIs on Linux: vdpau and vaapi. Each
of these has emulation wrappers. The wrappers are usually slower and
have fewer features than their native opposites. In particular the libva
vdpau driver is practically unmaintained.

Check the vendor string and print a warning if emulation is detected.
Checking vendor strings is a very stupid thing to do, but I find the
thought of people using an emulated API for no reason worse.

Also, make --hwdec=auto never use an API that is detected as emulated.
This doesn't work quite right yet, because once one API is loaded,
vo_opengl doesn't unload it, so no hardware decoding will be used if the
first probed API (usually vdpau) is rejected. But good enough.
2014-05-28 02:08:45 +02:00
wm4 8dfd93c6fb vo_vaapi: cleanup error handling on init
Close the X connection if initializing vaapi fails.
2014-05-28 02:08:45 +02:00
ChrisK2 ff73d25308 osc: correct calculation of slider position
calculation the mouse position on the slider relied on how the
hitbox is positioned, change it according to new hitbox size.
2014-05-28 01:55:52 +02:00
ChrisK2 518e0b7320 osc: extend hitbox of seekbars to include gap
should make usage a bit easy

Fixes #810
2014-05-27 22:52:34 +02:00
wm4 baaa32621e stream: unbreak writeable streams
So, basically this worked only with streams that were not local files,
because stream_dvd.c "intercepts" local files to check whether they
point to DVD images. This means if a stream is not writeable, we have to
try the next stream implementation.

Unbreaks 2-pass encoding.
2014-05-27 22:05:22 +02:00
wm4 22b16a40e5 video: better handling for (very) broken timestamps
Sometimes, Matroska files store monotonic PTS for h264 tracks with
b-frames, which means the decoder actually returns non-monotonic PTS.

Handle this with an evil trick: if DTS is missing, set it to the PTS.
Then the existing logic, which deals with falling back to DTS if PTS is
broken. Actually, this trick is not so evil at all, because usually, PTS
has no errors, and DTS is either always set, or always unset. So this
_should_ provoke no regressions (famous last words).

libavformat actually does something similar: it derives DTS from PTS in
ways unknown to me. The result is very broken, but it causes the DTS
fallback to become active, and thus happens to work.

Also, prevent the heuristic from being active if PTS is merely monotonic
instead of strictly-monotonic. Non-unique PTS is broken, but we can't
fallback to DTS anyway in these cases.

The specific mkv file that is fixed with this commit had the following
fields set:

  Muxing application: libebml v1.3.0 + libmatroska v1.4.1
  Writing application: mkvmerge v6.7.0 ('Back to the Ground') [...]

But I know that this should also fix playback of mencoder produced mkv
files.
2014-05-27 21:58:07 +02:00
wm4 96bc188172 manpage: document write_watch_later_config command 2014-05-27 21:58:06 +02:00
Rudolf Polzer c0cd58e3f5 idet.sh: An alternative to ildetect.sh.
This script uses ffmpeg's "idet" filter for interlace detection. In the
long run this should replace ildetect.sh+ildetect.sh.
2014-05-27 18:41:40 +02:00
wm4 799b5e1a5d lua: slightly nicer diagnostics output
When Lua itself prints errors such as:

  Error: [string "mp.defaults"]:387: syntax error near 'function'

It's unclear why the location is prefixed with "string ". And for some
reason, it disappears if you prefix the name with '@'. I suppose this is
done for the sake of luaL_loadstring. With the '@' prefix added, the
output is now:

  Error: mp.defaults:387: syntax error near 'function'
2014-05-27 00:02:34 +02:00
wm4 9acd263542 gl_common: minor cosmetic changes
Why are you reading this message.
2014-05-26 23:08:07 +02:00
wm4 66f3e93ed3 gl_common: correct a type
We pass a pointer to a GLint to sscanf, using the %d format. That format
_always_ takes int, and not GLint (whatever the heck that is). If GLint
is always int, then it doesn't make a difference, but is still better
because it doesn't play russian roulette with pointers.
2014-05-26 23:05:22 +02:00
wm4 53445d3b44 gl_w32: remove some non-sense
Really now...
2014-05-26 23:00:39 +02:00
wm4 7248988714 vo_opengl: always dynamically load OpenGL symbols
Don't emit "hard" references to OpenGL functions. Always use the
platform specific function to lookup OpenGL functions, such as
glXGetProcAddress() with GLX (x11).

This actually fixes the build if only Wayland is enabled (e.g. using
--disable-gl-x11 on Linux).

Note that some sources claim that wglGetProcAddress() (win32) does not
return function pointers for OpenGL 1.1 functions (even if they are
valid and necessary in OpenGL 3.0). But if that happens, the fallback
employed in gl_w32.c/w32gpa() should catch this.
2014-05-26 22:56:13 +02:00
wm4 d04ce8a7c2 x11: fix restoring position when leaving fullscreen
Accidentally broken in commit 7163bf7d by inverting the condition.
2014-05-26 21:59:30 +02:00
wm4 44e8a4085e x11: fix datatype for _NET_WM_PID
Setting this property was added 12 years ago, and the code was always
incorrect. The underlying data type is "long", not "pid_t". It's well
possible that the data types are different, and the pointer to the pid
variable is directly passed to XChangeProperty, possibly invoking
undefined behavior.

It's funny, because in theory using pid_t for PIDs sounds more correct.
2014-05-26 21:59:30 +02:00
wm4 6710527a83 input: make combined commands repeatable
Binding multiple commands at once where always considered not
repeatable, because the MP_CMD_COMMAND_LIST wasn't considered
repeatable.

Fixes #807 (probably).
2014-05-26 21:59:30 +02:00
wm4 fbe59b23b1 lua: add missing include files
These are actually already included in osdep/io.h, but I think it's
cleaner to repeat them in the file where they are actually needed.
(osdep/io.h needs to have them for other reasons.)
2014-05-26 21:59:30 +02:00
wm4 6f20d6b74e lua: fix compilation with lua 5.2
Commit e2e450f9 started making use of luaL_register(), but OF COURSE
this function disappeared in Lua 5.2, and was replaced with a 5.2-only
alternative, slightly different mechanism.

So just NIH our own function. This is actually slightly more correct,
since it forces the user to call "require" to actually make the module
visible for builtin C-only modules other than "mp". Fix autoload.lua
accordingly.
2014-05-26 21:59:29 +02:00
Martin 9c18a920ff command: add write_watch_later_config command
Closes #808.

Signed-off-by: wm4 <wm4@nowhere>
2014-05-26 21:59:17 +02:00
wm4 0e1ab2a8da autoload.lua: fix autoloading of files to prepend
This used the wrong index variable, and thus didn't work.
2014-05-25 20:17:03 +02:00
wm4 2309bb91cc DOCS/coding-style: add a hint that new features should be documented 2014-05-25 19:52:51 +02:00
wm4 fea1bad856 TOOLS: add a Lua script to autoload playlist entries
This will load other files in the same directory when a single file is
played. It's an often requested feature, but we definitely don't want it
in the core.
2014-05-25 19:52:26 +02:00
wm4 e2e450f961 lua: add some filesystem utility functions
We need this only because Lua's stdlib is so scarce. Lua doesn't intend
to include a complete stdlib - they confine themselves to standard C,
both for portability reasons and to keep the code minimal. But standard
C does not provide much either.

It would be possible to use Lua POSIX wrapper libraries, but that would
be a messy (and unobvious) dependency. It's better to implement the
missing functions ourselves, as long as they're small in number.
2014-05-25 19:51:11 +02:00
wm4 e648f7e783 manpage: lua: cosmetic changes to mp.options section 2014-05-25 19:43:25 +02:00
wm4 9d0e5f6da6 playlist: fix playlist_move on itself
A playlist_move command that moves an entry onto itself (both arguments
have the same index) should do nothing, but it did something broken. The
underlying reason is that it checks the prev pointer of the entry which
is temporarily removed for moving.
2014-05-25 19:42:51 +02:00
wm4 ba1447822c vf_vdpaupp: cosmetics: rename function 2014-05-25 16:01:33 +02:00
Tsukasa OMOTO 0304c4f92d osxbundle: fix recursion termination
Prevents the binary from being copied over to the lib directory.
2014-05-25 07:42:40 +02:00
ChrisK2 30fc1a42be osc: fix chapter list display
also fix small typo in DOCS
2014-05-24 17:47:31 +02:00
wm4 7cc48f26e0 build: disable cdda and vcd by default
Let's see if anyone complains. cdda is relatively inoffensive, but the
vcd code is the definition of ifdef-hell.
2014-05-24 17:09:29 +02:00
wm4 f5eb209ce9 stream_cdda: fix compilation
See previous commit. Sigh...
2014-05-24 17:07:13 +02:00
wm4 e47e818356 stream_smb: fix compilation
Accidentally forgotten in commit a4d487.
2014-05-24 17:00:30 +02:00
wm4 01c3847b80 client API: fix mpv_observe_property with MP_FORMAT_NONE
It returned only 1 change event (after registration), and then went
silent. This was accidentally broken some time ago.
2014-05-24 16:17:52 +02:00
wm4 6125ba613f video: add --video-rotate option for controlling auto-rotation 2014-05-24 16:17:52 +02:00
wm4 8665f78018 stream_file: readjust some windows ifdeffery
Also sneak in some cosmetics.

setmode() exists on Windows/msvcrt only, so there's no need for a
config test.

I couldn't reproduce the problem with seekable pipes on wine, so axe
it. (I'm aware that it still could be an issue on real Windows.)
2014-05-24 16:17:52 +02:00
wm4 aa87c143cb stream: remove chaos related to writeable streams
For some reason, we support writeable streams. (Only encoding uses that,
and the use of it looks messy enough that I want to replace it with FILE
or avio today.)

It's a chaos: most streams do not actually check the mode parameter like
they should. Simplify it, and let streams signal availability of write
mode by setting a flag in the stream info struct.
2014-05-24 16:17:52 +02:00
wm4 80cbb3bac2 stream_lavf: remove redundant message prefixes 2014-05-24 16:17:51 +02:00
wm4 a4d487f5b2 stream: don't use end_pos
Stop using it in most places, and prefer STREAM_CTRL_GET_SIZE. The
advantage is that always the correct size will be used. There can be no
doubt anymore whether the end_pos value is outdated (as it happens often
with files that are being downloaded).

Some streams still use end_pos. They don't change size, and it's easier
to emulate STREAM_CTRL_GET_SIZE using end_pos, instead of adding a
STREAM_CTRL_GET_SIZE implementation to these streams.

Make sure int64_t is always used for STREAM_CTRL_GET_SIZE (it was
uint64_t before).

Remove the seek flags mess, and replace them with a seekable flag. Every
stream must set it consistently now, and an assertion in stream.c checks
this. Don't distinguish between streams that can only be forward or
backwards seeked, since we have no such stream types.
2014-05-24 16:17:51 +02:00
wm4 e3c20bf350 stream: kill start_pos, remove --sb option
stream.start_pos was needed for optical media only, and (apparently) not
for very good reasons. Just get rid of it.

For stream_dvd, we don't need to do anything. Byte seeking was already
removed from it earlier.

For stream_cdda and stream_vcd, emulate the start_pos by offsetting the
stream pos as seen by the rest of mpv.

The bits in discnav.c and loadfile.c were for dealing with the code
seeking back to the start in demux.c. Handle this differently by
assuming the demuxer is always initialized with the stream at start
position, and instead seek back if initializing the demuxer fails.

Remove the --sb option, which worked by modifying stream.start_pos. If
someone really wants this option, it could be added back by creating a
"slice" stream (actually ffmpeg already has such a thing).
2014-05-24 16:17:50 +02:00
wm4 3316cf5f9b player: don't init/uninit terminal at runtime
This seems like an unnecessary complication.
2014-05-24 16:17:50 +02:00
wm4 6ca8a67f96 timer: remove unneeded time_t overflow check
This is mostly covered by the OSX workaround, if the timeout is very
high. It also means that with systems using 32 bit time_t, the time will
overflow 2036 already, instead of 2037, but we don't consider this a
problem.
2014-05-24 16:17:45 +02:00
Alessandro Ghedini cec9613505 manpage: update references to renamed options 2014-05-23 21:14:22 +02:00
wm4 76bd701a7a x11: un-inline GNOME layer stuff
Having it as separate function is not useful.

Also remove the useless vo_window parameter.
2014-05-23 20:59:36 +02:00
wm4 e2e318a213 x11: prefer NetWM hints over _WIN_LAYER for --ontop
_WIN_LAYER is apparently an old GNOME thing (also explains why there is
a function vo_x11_get_gnome_layer() involved in this code). Prefer the
NetWM hints over this. This just moves the NetWM case if-body over the
_WIN_LAYER one.
2014-05-23 20:59:36 +02:00
wm4 8033b4b4ba x11: rename identifiers using reserved namespace
You can't use identifiers starting with "_" and an uppercase letter in
application programs. They are reserved by the C standard.

Unrelated change: drop unused/misleading vo_wm_NETWM define.
2014-05-23 20:59:06 +02:00
wm4 990888f968 x11: fix NetWM ontop setting
I can only assume the old code was wrong. EWMH does not document
anything with _WIN_LAYER. Instead, you have to toggle the state using a
client message. We also remove these weird non-sense fallbacks, like
using _NET_WM_STATE_BELOW - what the hell?
2014-05-23 20:57:26 +02:00
wm4 7163bf7db8 x11: add a generic function for NetWM state setting
And use it for fullscreening. It will also be used for fixing --ontop.
2014-05-23 20:57:21 +02:00
wm4 436b9a2258 old-build: fix building with libquvi4 2014-05-23 16:04:17 +02:00
wm4 e29e567f07 old-makefile: add options.lua
Also, make use of generic rules.
2014-05-23 15:58:51 +02:00
ChrisK2 ce69afab44 lua/osc: forgot some changed files in previous commit 2014-05-23 13:24:27 +02:00
ChrisK2 c6915d7325 lua/osc: small overhaul
Small fixes for the OSC, seektooltip now enabled by default.

Option-parser now moved to separate package, can be used from
other scripts, see DOCS/man/en/lua.rst.

OSC config file location moved to lua-settings/osc.conf
2014-05-23 13:14:17 +02:00
wm4 b69d57ebe8 timer: workaround for crappy operating systems
Some operating systems apparently can't deal with really long timeouts
in pthread_cond_timedwait(). Passing a time about 300000 in the future
makes the call return immediately. (tv_sec/time_t doesn't overflow in
this situation.) Reduce the wait time to about 100 days, which seems
to work fine.

The list of affected OSes follows: OSX
2014-05-23 00:20:57 +02:00
wm4 2e6b0b4ee4 timer: fix previous commit
Sigh... of course the type of the (?:) exprsssion is double, so
INT64_MAX was converted to double, which is a problem.
2014-05-22 22:50:39 +02:00
wm4 c9b68957c9 timer: improve overflow checks
Probably more correct and better readable. Although the special-casing
of 0x1p63 is weird in terms of readability (the value itself is
INT64_MAX+1, so it's already outside of range, but INT64_MAX is not
exactly representable with double precision).
2014-05-22 22:36:42 +02:00
wm4 cb2e784c07 player: give quit_watch_later an exit code argument like quit
The quit command has an optional argument that is used as exit code.
Extend that to the quit_watch_later command. Actually, unify the
implementations of the two commands.

Requested in #798.
2014-05-22 21:28:20 +02:00
Yomi0 aca4f9f474 tl_mpv_edl: correct misspelling on line 233
Closes #783

Signed-off-by: wm4 <wm4@nowhere>
2014-05-22 20:59:31 +02:00
wm4 d31b594f77 timer: fix (usually impossible) timespec.tv_sec overflow
This usually can't happen, because even if time_us (first input value)
is INT64_MAX, the value added to tv_sec will be about 2^43, and tv_sec
will be <2^31, far below a possible overflow in 64 bits. But should
time_t be 32 bits (32 bit Linux/Windows?), an overflow could happen.
2014-05-22 20:59:31 +02:00
wm4 7b7e15a460 vdpau: move RGB surface management out of the VO
Integrate it with the existing surface allocator in vdpau.c. The changes
are a bit violent, because the vdpau API is so non-orthogonal: compared
to video surfaces, output surfaces use a different ID type, different
format types, and different API functions.

Also, introduce IMGFMT_VDPAU_OUTPUT for VdpOutputSurfaces wrapped in
mp_image, rather than hacking it. This is a bit cleaner.
2014-05-22 20:59:31 +02:00
wm4 dbed21cde4 vo_vdpau: always allocate the black pixel
black_pixel is an (apparently necessary) 1x1 black surface used for
clearing the screen. It was allocated in RGB mode only, but is sometimes
used in YUV mode too.
2014-05-22 20:55:05 +02:00
wm4 52ff1cf313 old-configure: we accidentally used bash features
In at least 2 places, we want to "shift" positional parameters by a
certain amount, or remove all parameters if there are fewer parameters.
bash handled this just fine, but dash vomits upon it. POSIX shell allows
both behaviors, so we have to fix it.

Fix a comparison done with "==" instead of "=".
2014-05-22 20:54:57 +02:00
wm4 d45b68b938 player: fix cover art sometimes "syncing" against audio
Cover art is treated like video, but is not really video. In one case,
the audio sync code was accidentally still active. Fixes cover art
playback with --ao=null. (This is due to ao_null's latency emulation.
Although it's not very clear whether that is actually correct...)
2014-05-22 20:54:50 +02:00
wm4 85a513abdf player: suggest --no-audio-display on cover art 2014-05-22 13:51:31 +02:00
wm4 2f2b3f8d5c video: fix display of cover art with vo_vdpau
vo_vdpau currently has a video queue larger than 1 entry, which causes
the video display code to never queue display the video frame. This is
because we consider cover art an endless stream of frames decoded from
the same source packet, and include special logic to actually only
decode and display 1 frame.

Also, make decode_image() also signal EOF in the cover art case.
2014-05-22 13:50:10 +02:00
wm4 b37e3cc0ee cache: be silent if no initial fill is requested
Hides the "Cache fill:" message with default settings.
2014-05-22 13:07:18 +02:00
wm4 d62dad55ef edl: use start PTS of the source files as default start time 2014-05-22 13:04:36 +02:00
Jerome Leclanche 3d065a53fc x11: fix a warning with --disable-xext
Signed-off-by: wm4 <wm4@nowhere>
2014-05-22 09:29:56 +02:00
wm4 fcdaaa203b build: "tv-v4l2" needs "tv"
Fixes #795.
2014-05-22 09:29:41 +02:00
wm4 46cb1b7c45 vo: minor simplifications 2014-05-22 09:28:39 +02:00
wm4 09386b173e vo: remove config_ok check from vo_check_events()
This should be ok now after the x11 code was adjusted.
2014-05-22 09:28:28 +02:00
wm4 85c3459bf8 vo_vaapi: don't redraw twice
After VOCTRL_REDRAW_FRAME, flip_page is called, which renders the frame.
The current code rendered the frame twice; drop the redundant call.
2014-05-22 09:28:17 +02:00
Juan Francisco Cantero Hurtado 38c8f5ea57 Fix the build on OpenBSD and FreeBSD
Without this change, the compiler uses by default the "talloc.h" file
installed by the package libtalloc within /usr/local/include. Found and
tested on OpenBSD but FreeBSD has the same patch on its ports tree.
2014-05-21 02:23:23 +02:00
wm4 c0641c63fc osdep: silence a -Wshadow warning 2014-05-21 02:21:18 +02:00
wm4 885b744767 atomics: more correct usage of gcc/clang __atomic builtins
This should be more correct. The builtins were made to directly map to
C11, and the way we use them is now relatively close to how gcc
implements atomics in 4.9. In particular, we make use of the load and
store builtins.

I'm not entirely sure why gcc didn't support stdatomic.h in 4.8 already.
Maybe support for the builtins was incomplete or broken - so there's a
lot of room for doubt about the correctness of this.
2014-05-21 02:21:18 +02:00
wm4 8e7cf4bc99 atomics: switch to C11 stdatomic.h
In my opinion, we shouldn't use atomics at all, but ok.

This switches the mpv code to use C11 stdatomic.h, and for compilers
that don't support stdatomic.h yet, we emulate the subset used by mpv
using the builtins commonly provided by gcc and clang.

This supersedes an earlier similar attempt by Kovensky. That attempt
unfortunately relied on a big copypasted freebsd header (which also
depended on much more highly compiler-specific functionality, defined
reserved symbols, etc.), so it had to be NIH'ed.

Some issues:
- C11 says default initialization of atomics "produces a valid state",
  but it's not sure whether the stored value is really 0. But we rely on
  this.
- I'm pretty sure our use of the __atomic... builtins is/was incorrect.
  We don't use atomic load/store intrinsics, and access stuff directly.
- Our wrapper actually does stricter typechecking than the stdatomic.h
  implementation by gcc 4.9. We make the atomic types incompatible with
  normal types by wrapping them into structs. (The FreeBSD wrapper does
  the same.)
- I couldn't test on MinGW.
2014-05-21 02:21:18 +02:00
wm4 2f65f0e254 input: allow disabling window dragging with --no-window-dragging
Requested in github issue #608.
2014-05-20 02:40:28 +02:00
wm4 15c22fb0eb input: fix compilation on windows
Currently I don't have a crosscompilation toolchain, so I couldn't test
whether this actually compiles (and still can't).
2014-05-20 02:40:28 +02:00
wm4 7dc74bab32 manpage: mention bdnav:// 2014-05-20 02:40:28 +02:00
wm4 094d03fd91 README: describe release cycle 2014-05-20 02:40:28 +02:00
wm4 4664f8b3b7 cache: redo options and default settings
Some options change from percentages to number of kilobytes; there are
no cache options using percentages anymore.

Raise the default values. The cache is now 25000 kilobytes, although if
your connection is slow enough, the maximum is probably never reached.
(Although all the memory will still be used as seekback-cache.)

Remove the separate --audio-file-cache option, and use the cache default
settings for it.
2014-05-20 02:40:22 +02:00
wm4 ac66bcc259 x11: unbreak build without xinerama 2014-05-19 22:09:26 +02:00
wm4 5f6406f450 x11: leaving fullscreen -> reset WM hints only if needed
This works around an issue in OpenBox: OpenBox apparently sizes the
normal window incorrectly if aspect ratio hints are set, and the window
size is off by 1 pixel. Then, when going fullscreen and leaving
fullscreen again, mpv sets the hints based on OpenBox' broken window
size, and as result, OpenBox sizes the window incorrectly and is off by
1 pixel again - so it's 2 pixels off in total. The error gets more
visible, the more often you toggle fullscreen mode.

Work this around by not setting the window hints if we don't need to.
Actually we only need to do this when the video is resized during
fullscreen, which happens rarely. Under normal circumstances, leaving
fullscreen mode requires that the WM restores the old state.

As such, this commit is not only a workaround, but actually a cleanup.

Note that we do need to set the hints when leaving fullscreen if the
window has resized: even though we set the hints in
vo_x11_highlevel_resize (called by vo_x11_config_vo_window), this
doesn't seem to have an effect (at least on IceWM), so we have to do it
after that.

Side note: ot seems commit 625ad57a strangely triggered the OpenBox
issue according to user reports; I'm not sure why.
2014-05-19 21:59:10 +02:00
wm4 ebe798cbc0 demux_subreader: remove support for some subtitle formats
Drop: sami, vplayer, rt, pjs, mpsub, aqt, jacosub. None of these seem
to be actually in use, except sami. Sami is very complex, and the
results subreader produces are not very useful.

For all these formats, there are still parsers in FFmpeg. We remove the
subreader implementation, because it might contain security relevant
bugs and such. (This is old, unmaintained C string parsing code, written
in times where absolutely nobody cared about security. The kind of
awesome code.)

We keep the other formats, because they're (mostly) commonly used and
relatively simple, for UTF16 support (still missing in FFmpeg), and for
the sake of Libav.
2014-05-19 01:40:41 +02:00
wm4 a332a227f4 x11: always check whether a window exists
So any VOCTRL can be called at any time. Working towards removing all
these config_ok checks in vo.c.
2014-05-19 01:07:54 +02:00
wm4 821f37db62 x11: request and handle resize events of parent windows with --wid
Before this commit, this was somehow polled (i.e. not the right way).

Also, selects the correct window when doing --wid=0 (which is another
weird special-case).
2014-05-19 01:07:10 +02:00
wm4 2c012e9eb2 x11: remove a duplicated line 2014-05-18 23:47:28 +02:00
wm4 0a4adce00c etc/input.conf: add example how to change window size by key binding
Also drop a vague hint how to do it in the manpage.
2014-05-18 22:22:33 +02:00
wm4 d9bd5bacc1 x11: never enable DPMS if we didn't disable it
Enabling DPMS even though you disabled it globally is pretty unfriendly,
so don't do it. Instead, we only disable DPMS if it was enabled, and
only enable it if we disabled it ourselves.

The other way should never happen (disabling DPMS permanently), unless
mpv crashes during playback.
2014-05-18 22:16:53 +02:00
wm4 42a51310c1 timer: account for negative time values
It can easily happen that mp_time_us_to_timespec() gets a time in the
past, and then the time difference will be negative. Regression
introduced in commit f47a4fc3.

Also fix an underflow check in mp_add_timeout().
2014-05-18 21:44:45 +02:00
wm4 7fec0c630b compat/libav: remove unneeded things
Currently, it's unused. Still keep the file, because it's not unlikely
we'll need it again, and removing/readding the include statements for
this file is too annoying.
2014-05-18 21:20:40 +02:00
wm4 b3aa5dafa3 vdpau: don't fallback to software decoding on preemption
This was requested by someone. Not sure if it's a good idea; it seems
more can go wrong than right.
2014-05-18 19:21:39 +02:00
wm4 537ac1a15f client API: add mpv_load_config_file()
This is probably a good idea, because it would make it easier for
software embedding mpv to configure the mpv parts, without requiring the
host program to provide explicit mechanisms for this (other than calling
mpv_load_config_file()).
2014-05-18 19:21:39 +02:00
wm4 caa939aa91 options: unify code for setting string and "raw" options
The code paths for setting options by string and by direct "raw" value
were too different, which resulted in some weird code. Make the code
paths closer to each other.

Also, use this to remove the weirdness in the mpv_set_option()
implementation.
2014-05-18 19:21:39 +02:00
wm4 f47a4fc3d9 threads: use mpv time for mpthread_cond_timedwait wrapper
Use the time as returned by mp_time_us() for mpthread_cond_timedwait(),
instead of calculating the struct timespec value based on a timeout.
This (probably) makes it easier to wait for a specific deadline.
2014-05-18 19:20:32 +02:00
wm4 e209e44ca2 manpage: fix a minor aspect of the discnav command
"menu" is in fact understood by stream_bluray.c, so just drop that
sentence.
2014-05-18 14:09:38 +02:00
wm4 dbdf7c39e7 player: increase seek accuracy when refreshing display on filter change
When the player is paused, and video filters are changed, an exact seek
is executed to refresh the display. Increase the exactness of the seek
in this case; this reuses the code used for frame backstepping.

It might help in cases where seeking is very imprecise, such as with
transport streams.
2014-05-18 14:08:45 +02:00
wm4 dc96523536 manpage: document discnav command 2014-05-18 00:03:59 +02:00
wm4 5841685e09 command: add a disc-menu-active property
Returns whether a DVD/BD menu is active. As requested by #788.
2014-05-18 00:03:47 +02:00
wm4 1ef1e8e509 client API: fix "missed" property notifications
If a property is notified as changed, and then again (before the change
notification is returned to the client), and the second change is a
sporadic change (i.e. nothing actually changed) and the change
notification was associated with with a data type, it could happen that
a change was "overlooked", because it would detect no change on the
second notification.

This is actually a pretty annoying corner case, due to the annoying way
we do things, so just store both the previously returned _and_ the newly
obtained property value. then we always compare with the user value to
check for a change, excluding any possibility of a missed change.

Note that we don't (can't/shouldn't) care if a value changes, and then
changes back; it's fine if that doesn't generate a notification. This is
due to how property notifications are supposed to be coalesced.
2014-05-18 00:02:55 +02:00
wm4 c2039572b7 x11: make screensaver code more compact, change DPMS handling
Reduces some code-duplication.

Just call DPMSEnable/DPMSDisable, instead of DPMSForceLevel when
reenabling DPMS. "Force" sounds evil, and messing with DPMS is already
pretty evil. I'm not even sure that we should.
2014-05-17 21:36:34 +02:00
wm4 b4b68ebf5a x11: add wrapper for EWMH XSendEvent calls 2014-05-17 18:03:28 +02:00
wm4 347eaaa93c x11: fix Drag & Drop
Accidentally broken in commit 95462747.
2014-05-17 17:49:47 +02:00
wm4 8304478149 x11: add a wrapper for XGetWindowProperty
XGetWindowProperty is a really bad API, almost as if the NSA designed
it. The wrapper takes care of verifying the return values and handle
corner cases.
2014-05-17 17:49:47 +02:00
wm4 5a1bf25523 x11: comment about gravity
The window "gravity" influences how placement interacts with WM added
borders (i.e. from decorations). This is probably what the code removed
in commit c14721c8 was about.

In theory, we'd probably want to set the gravity depending on the
relative placement requested by the user (so that it's possible to line
up the top/left video pixel with the monitor corner, as well as the
bottom/right pixel - but that would be too complicated, and who cares
after all?).

I'm also not sure whether CenterGravity really uses the top/left corner
as reference point (instead of making coordinates relative to the window
center), but empirically it's correct.
2014-05-17 14:26:49 +02:00
wm4 0e579f8439 x11: replace x/y/w/h with mp_rect 2014-05-17 03:29:36 +02:00
wm4 b4ccf765af x11: remove some unused fields 2014-05-17 03:02:47 +02:00
wm4 625ad57add x11: don't set PBaseSize
There's apparently no reason why we should set a bogus size.
2014-05-17 02:53:57 +02:00
wm4 3afff3fe9b x11: remove vo_hint member
Now it's always recreated in vo_x11_sizehint(). Also, the Xlib manual
says you must use XAllocSizeHints() (for ABI reasons), so do that.
2014-05-17 02:27:46 +02:00
wm4 4807f8bdd2 x11: always raise layer in fullscreen mode without NetWM 2014-05-17 01:53:56 +02:00
wm4 faeaa6c358 x11: implement --fs-screen properly, separate old code path
Try to get the "new" code path (using NetWM/EWMH) free of hacks done for
the sake of old WMs or the no-WM case.

Implement --fs-screen using _NET_WM_FULLSCREEN_MONITORS.
2014-05-17 01:14:59 +02:00
wm4 444e583b6d x11: use CenterGravity by default
Keeps the window centered on resize. Seems nicer. (Although it's worse
if 1. the default placement of the WM puts it into a monitor corner,
and 2. you switch to a larger video.)
2014-05-17 00:53:54 +02:00
wm4 c14721c8b9 x11: remove gravity restore code
It was added with 3813c685 in 2004. I'm not really sure why this gravity
stuff would be needed; apparently it has to do with misplacements with
broken WMs and had to be changed on fullscreen. Just get rid of it; it
works perfectly fine without on modern WMs.

The thread discussing this is here:
http://mplayerhq.hu/pipermail/mplayer-dev-eng/2004-July/027674.html
2014-05-17 00:53:53 +02:00
wm4 9546274710 x11: don't cache X Atoms manually
XInternAtom() already caches lookups. Even if calling XInternAtom would
be always inefficient, it wouldn't matter much during normal playback.
2014-05-16 23:17:09 +02:00
wm4 7c2cf7cdf1 x11: inline a function
Keeping it separate seems less readable.
2014-05-16 23:17:02 +02:00
Rudolf Polzer 4ac4269389 encoding: No error when the output format doesn't support a stream type at all.
When writing a video to foo.mp3, the user's intention is clearly to drop
the video stream, and similarly, when writing to foo-%d.png, the
intention is clearly to drop the audio stream. Now, explicit
specification of --no-audio or --no-video is no longer necessary in
these cases.
2014-05-16 21:41:32 +02:00
wm4 129ab5833d etc/example.conf: add example options for multichannel audio 2014-05-16 01:24:03 +02:00
wm4 014c0fb997 etc/example.conf: minor adjustments 2014-05-16 01:15:11 +02:00
wm4 07fe0412d9 etc/example.conf: remove spaces between key and value
Currently, they are allowed, but only because MPlayer happened to do
that. This might or might not be changed in the future.
2014-05-16 01:13:20 +02:00
wm4 ebd5bbd241 x11: replace--[x11-]fstype option with --x11-netwm
Simplifies the code a lot. You can still use --x11-netwm=no to disable
NetWM for whatever reasons.
2014-05-16 00:47:13 +02:00
wm4 b6e675a9bc x11: remove a MWM hack
This was for Motif Window Manager. No, I don't care about Motif.
2014-05-16 00:08:18 +02:00
wm4 c4cbf6b540 x11: remove unused stuff
Unfortunately, it looks like some Motif functionality is still needed
to allow for --no-border.
2014-05-16 00:03:31 +02:00
wm4 7ad8c5ff33 x11: set the fullscreen state before mapping the window
This should get rid of some flickering. Since this actually skips all
the wacky fullscreening code on startup, this might lead to certain
wacky features to stop working. In this case, you'll have to use the
--x11-fstype option, and disable _NETWM_STATE_FULLSCREEN usage.
2014-05-15 23:56:14 +02:00
wm4 8f29f6fc61 x11: clear window on map
vo_x11_map_window() was attempting to clear the window on map. However,
it did so immediately after the map request. It probably assumed that
the drawing calls for clearing the window would be queued along with the
map request, and then executed in the right order. However, this
assumption was wrong - the map request first has to go to the window
manager (I guess?), so a lot of things happen before the window is even
mapped.

Fix this by moving the call to the MapNotify message handler, when the
window (apparently) becomes really visible.

I also tried to set CWBackPixel to black instead, but this seemed to
result in flickering on manual resizing.
2014-05-15 23:56:14 +02:00
wm4 9bfe3f394c x11: wait until the window is mapped
This blocks everything, until the window is actually reported as mapped.

This fixes the race condition between VO initialization and mapping the
window, which resulted in possibly different window sizes, leading to an
immediate redraw, visible as flashing.

Note that if the map event never comes for some reason, we're out of
luck and will block forever.
2014-05-15 23:56:14 +02:00
Kevin Mitchell 1eee4d7799 TOOLS/vf_dlopen: use new pixelformats, fix usage for newstyle args 2014-05-15 10:32:16 -07:00
Kevin Mitchell 2b1b8d6c95 vf_dlopen: update usage message to new-style args 2014-05-15 10:32:16 -07:00
Kevin Mitchell 125dcf306a vf_dlopen: remove buggy private name -> imgfmt conversion
This was presumably for backward compatibility,
but it was preventing the use of the new names.
2014-05-15 10:32:16 -07:00
wm4 0128579542 vf_vapoursynth: fix debug output 2014-05-15 16:59:26 +02:00
wm4 97604ebcd2 vf_vapoursynth: add more debug output
Also, move num_requested() to where it's used. Remove newlines from VS
error messages. Remove an assert(0) on an error path.
2014-05-15 14:50:35 +02:00
wm4 a5e22c70e8 manpage: changes.rst: minor fixups 2014-05-15 14:49:19 +02:00
wm4 daf4898668 vf_vapoursynth: avoid unnecessary waiting
It could in theory happen that the filter loop will enter a blocking
wait, even though it could make progress by emptying the list of
already-filtered images. I'm not quite sure if this could actually cause
a real issue - probably not.
2014-05-14 21:02:56 +02:00
wm4 6dec78e475 TOOLS/mpv_identify.sh: unbreak 2014-05-14 20:56:09 +02:00
wm4 bc6959c35d vf_vapoursynth: allow parallel processing
VapourSynth won't just filter multiple frames at once on its own. You
have to request multiple frames at once manually. This is what this
commit introduces: a sub-option controls how many frames will be
requested at once. This also changes the semantics of the maxbuffer sub-
option, now renamed to buffered-frames.
2014-05-14 20:42:04 +02:00
wm4 d6774515a7 manpage: updates changes.rst
The situation has changed a bit since the days of mplayer2, so we can
use more/less diplomatic wording. Merge the two sections listing
changes from MPlayer and mplayer2. Mention the client API and Lua
scripting as alternatives to slave mode.

I'm calling MPlayer code "horrible". This is not meant as an offense,
but after turning around almost every line of MPlayer code, I believe
I have a right to say this. Sorry. I would say that MPlayer has a
surprisingly sane and simple architecture (for what it is), but much
of it drowned under a load of evil hacks or not-cleaned-up-yet code.
2014-05-14 20:42:04 +02:00
wm4 d0a66dbd5d old-build: accidental rewrite
This started as a bunch of smaller changes to make the old configure
script maintainable with minimum effort. It ended up as complete
rewrite, because at once point I started to like shell programming (I
hope this sickness is curable), and I wanted to see how small I can
make the configure script. The typical configure test is now 1 or 2
lines big, located in 1 or 2 places, instead of >15 lines and being
spread over 5 or 6 places.

The main "trick" is factoring the tests into a few generic, commonly
needed tests, instead of writing everything manually.
2014-05-14 20:42:04 +02:00
wm4 eb4487cc4f old-build: drop support for anything but Linux, simplify
A lot of effort was spent on making the waf based build-system work
properly on all supported platforms, while the old configure script was
neglected. It seems that nobody maintains the non-Linux parts of the
configure script anymore, and all improvements go into the waf scripts.

Thus it makes no sense anymore to maintain the non-Linux parts. They're
just dead weight. Remove them completely.

Also apply some additional simplifications. For example, listing
enabled/disabled VO modules seems like a waste of effort.
2014-05-14 20:42:04 +02:00
wm4 fe4526195a build: add some warning cflags
These were in the old configure script too.

Two flags are explicitly tested, because I have no idea how widespread
support for them is, and testing them is just easier than trying to look
them up in various gcc/clang manuals. There are people using gcc 4.2
out there, so some caution is warranted.
2014-05-14 20:42:04 +02:00
Alexander Preisinger adf20c9775 wayland: fix typo
So long in the code without me noticing. Embarassing!
2014-05-14 20:29:08 +02:00
wm4 2279f718de player: reorganize how lua scripts are loaded
Make loading of scripts independent of Lua. Move some of the loading
code from lua.c to scripting.c, and make it easier to add new scripting
backends.
2014-05-13 02:39:37 +02:00
wm4 2a2dd8aac2 old-build: define a new symbol
waf has a proper test, but no test was added to old-configure.

This means that on OSX, old-configure is not supposed to work anymore.
But still allow it to compile cleanly on OSX.
2014-05-13 01:09:53 +02:00
Kevin Mitchell a6762dbc16 stream_smb: increase to 128k read_chuuk from default 8k
Previous to this commit, read_chunk was not set in stream_smb. The
cache was therefore filled in small 8K chunks. This resulted in poor
performance when compared to, for example, smbnetfs on the same
network.

The value of 128k is chosen both because it is emperically
the "levelling off point" for throughput into mpv's cache, and because
it is the value chosen by smbnetfs when serving smb shares to
mpv.

Note that this change has no effect unless --cache is explicitly
specified as smb:// streams do not activate cache by default. This is
because the default cache size of 320K is so small it actually makes
smb:// perfomance worse. For best results use at least --cache=1024.
2014-05-12 15:09:38 -07:00
wm4 9e94de29b7 player: disable hr-seek framedropping during backstepping 2014-05-12 23:24:19 +02:00
wm4 176b4abd53 build: fix OpenBSD DVD/CDROM device names
Closes #781.
2014-05-12 23:24:19 +02:00
Luca Barbato e0e79a2e7e vda: Hwaccel 1.2 support
Use the new context and the default functions provided.
2014-05-12 12:59:16 +02:00
Luca Barbato dab56b5fd5 vda: Simplify codec selection
VDA supports h264 only.
2014-05-12 12:59:16 +02:00
Luca Barbato 5cbfdac2a8 vd_lavc: Support hwaccel 1.2 and later
Hwaccel 1.2 populates only the third data field and assumes
that the AVCodecContext is available to the dealloc function.
2014-05-12 12:59:16 +02:00
wm4 c78b8b2c0c audio/out: fix previous commit
This didn't quite work. The main issue was that get_space tries to be
clever to reduce overall buffering, so it will cause the playloop to
decode and queue only as much audio as is needed to refill the AO in
reasonable time. Also, even if ignoring the problem, the logic of the
previous commit was slightly broken. (This required a few retries,
because I couldn't reproduce the issue on my own machine.)
2014-05-11 20:51:49 +02:00
wm4 665c8b59be audio/out: avoid wakeup feedback loop
When the audio buffer went low, but could not be refilled yet, it could
happen that the AO playback thread and the decode thread could enter a
wakeup feedback loop, causing up to 100% CPU usage doing nothing. This
happened because the decoder thread would wake up the AO thread when
writing 0 bytes of newly decoded data, and the AO thread in reaction
wakes up the decoder thread after writing 0 bytes to the AO buffer.

Fix this by waking up the decoder thread only if data was actually
played or queued. (This will still cause some redundant wakeups, but
will eventually settle down, reducing CPU usage close to ideal.)
2014-05-11 19:00:05 +02:00
wm4 fd56e2dbe6 TOOLS/stats-conv: don't crash on empty lines 2014-05-11 18:16:33 +02:00
wm4 cc94436c5b TOOLS/stats-conv: draw playloop and AO thread events separately
Use for all AO thread events y=0.5, while playloop events remain at y=1.
This makes the graph easier to read.
2014-05-11 17:07:26 +02:00
wm4 7cab9ea2fa manpage: update --playlist entry 2014-05-11 16:51:33 +02:00
wm4 77ce54c698 mixer: make code more readable
You wouldn't have guessed that the bottom-most "level[i] = 0.f;" line
was actually required. It even confused cppcheck.
2014-05-11 16:41:19 +02:00
wm4 09ecf7a68a audio/out: more debugging info for --dump-stats 2014-05-11 16:41:19 +02:00
wm4 342298fd1a wayland: fix unchecked malloc usage
Found by cppcheck.

Actually untested. (This is the file drag&drop code, I don't even know
which wayland clients support this.)
2014-05-11 16:41:17 +02:00
wm4 3d530af8ef player: don't assign "false" to pointer
This is legal in theory. "false" expand to 0, and 0 is a valid pointer
value. But I guess this was not really intended.

Found by cppcheck.
2014-05-11 16:41:09 +02:00
wm4 0d916c7f96 build: removed undefined behavior from PVR check
This shouldn't matter, but it's probably better if the code to check is
valid - otherwise an extremely clever compiler might fail to compile it,
and the feature would be misdetected. (Probably.)

Found by cppcheck.
2014-05-11 16:41:02 +02:00
wm4 194e221181 demux_playlist: fix m3u detection logic
Caused failure to detect .pls files, because they were misdetected as
m3u. The problem is that "forcing playlist files" and "forcing a
specific playlist format" are not really treated separate, and in both
cases p->force is set to true. This made m3u detect all files as m3u
if --playlist was used. So correctly check whether the file format is
actually being probed or not.
2014-05-11 16:40:41 +02:00
wm4 f5be96a6e5 manpage: minor corrections 2014-05-11 15:42:12 +02:00
wm4 31663beeac input: remove pausing command prefixes
These are now equivalent to combining commands with the "cycle pause" or
"set pause" commands, and thus are not needed anymore. They were also
obscure and undocumented.
2014-05-11 15:41:34 +02:00
wm4 4b367d1602 player: don't complain on too long filenames
mpv supports per-file config files, basically filename+".conf". We use
a static buffer for the new filename, and if that buffer is too small,
we print a warning. This is confusing for e.g. long URLs, so just hide
the warning by default.

Why not dynamically allocate the buffer? Who cares.
2014-05-10 16:08:07 +02:00
wm4 6f86e32630 old-makefile: add a missing source directory
Fixes "make clean".
2014-05-10 15:46:12 +02:00
Stefano Pigozzi b4e598badf ao_coreaudio: skip unknown channel labels
I don't think this is really a very good idea because it is conceptually
incorrect but other prominent multimedia programs use this approach
(VLC and xbmc), and it seems to make the conversion more robust in certain
cases.

For example it has been reported, that configuring a receiver that can output
7.1 to output 5.1, will make CoreAudio report 8 channel descriptions, and the
last 2 descriptions will be tagged kAudioChannelLabel_Unknown.

Fixes #737
2014-05-10 14:07:45 +02:00
Stefano Pigozzi 1a4f4f80bf ao_coreaudio: remove useless code
This code doesn't actually makes much of a difference, and the AudioUnit
mostly wants layout tags anyway.
2014-05-10 14:07:45 +02:00
Stefano Pigozzi 2a0a13425f ao_coreaudio: don't fallback to full waveext
The code was falling back to the full waveext chmap_sel when less than 2
channels were detected. This new code is slightly more correct since it only
fills the chmap_sel with the stereo or mono chmap in the fallback case.
2014-05-10 14:07:45 +02:00
Stefano Pigozzi 39b316ff06 ao_coreaudio: cosmetic change of loop ending condition 2014-05-10 14:07:45 +02:00
Stefano Pigozzi eb9d7d5c78 ao_coreaudio: print an error when channel mapping fails 2014-05-10 14:07:45 +02:00
Stefano Pigozzi b46ffaec7c ao_coreaudio: use description-based channel layouts
CoreAudio supports 3 kinds of layouts: bitmap based, tag based, and speaker
description based (using either channel labels or positional data).

Previously we tried to convert everything to bitmap based channel layouts,
but it turns out description based ones are the most generic and there are
built-in CoreAudio APIs to perform the conversion in this direction.

Moreover description based layouts support waveext extensions (like SDL and
SDR), and are easier to map to mp_chmaps.
2014-05-10 14:07:45 +02:00
Stefano Pigozzi e2f26f01fe ao_coreaudio: pass layout by reference to logging function
Apparently passing the struct by value somehow messed with the value of some
fields.
2014-05-10 14:07:45 +02:00
Stefano Pigozzi e7d1c12131 chmap_sel: add channel replacement for sl/sr <-> sdl/sdr
This can be use useful for the 7.1 rear layout. In particular it looks like
OS X likes to use sdl/sdr as opposed to sl/sr.
2014-05-10 14:07:45 +02:00
wm4 26b00ffe8a x11: fix potentially unaligned access in icon loader
Tried to load a 32 bit value by dereferencing a uint32_t pointer, but
the pointer is not guaranteed to be aligned, not even in practice.
2014-05-10 10:44:16 +02:00
wm4 3075ea01db sub: fix undefined behavior in ASS color calculation (2)
Same problem as previous commit, fix by using the MP_ASS_RGBA() macro.
2014-05-10 10:44:16 +02:00
wm4 485d033b5f sub: fix undefined behavior in ASS color calculation
This might shift bits into the sign, which is undefined behavior. Making
the right operand unsigned was supposed to help with this, but it seems
it did nothing, and C99 makes the result type dependent on the left
operand only.
2014-05-10 10:44:16 +02:00
wm4 3c322b1022 common: change MP_NOPTS_VALUE definition
Use the exact floating point value, instead of a broken integer
constant. The expression calculating the constant probably relied on
undefined behavior, because it left-shifts a negative value.

This also changes the type of the constant to double, which is perfectly
fine, and maybe better than an integer constant.
2014-05-10 10:44:16 +02:00
wm4 fc385baf02 encode: fix PTS unit mismatch
This used MP_NOPTS_VALUE to compare with ffmpeg-style int64_t PTS
values. This probably happened to work, because both constants use the
same value.
2014-05-10 10:44:16 +02:00
wm4 bc9a86c392 vdpau: make mp_vdpau_ctx thread-safe
Preparation so that various things related to video can run in different
threads. One part to this is making the video surface pool safe.

Another issue is the preemption mechanism, which continues to give us
endless pain. In theory, it's probably impossible to handle preemption
100% correctly and race-condition free, unless _every_ API user in the
same process uses a central, shared mutex to protect every vdpau API
call. Otherwise, it could happen that one thread recovering from
preemption allocates a vdpau object, and then another thread (which
hasn't recovered yet) happens to free the object for some reason. This
is because objects are referenced by integer IDs, and vdpau will reuse
IDs invalidated by preemption after preemption.

Since this is unreasonable, we're as lazy as possible when it comes to
handling preemption. We don't do any locking around the mp_vdpau_ctx
fields that are normally immutable, and only can change when recovering
from preemption. In practice, this will work, because it doesn't matter
whether not-yet-recovered components use the old or new vdpau function
pointers or device ID. Code calls mp_vdpau_handle_preemption() anyway to
check for the preemption event and possibly to recover, and that
function acquires the lock protecting the preemption state.

Another possible source of potential grandiose fuckup is the fact that
the vdpau library is in fact only a tiny wrapper, and the real driver
lives in a shared object dlopen()ed by the wrapper. The wrapper also
calls dlclose() on the loaded shared object in some situations. One
possible danger is that failing to recreate a vdpau device could trigger
a dlclose() call, and that glibc might unload it. Currently, glibc
implements full unloading of shared objects on the last dlclose() call,
and if that happens, calls to function pointers pointing into the shared
object would obviously crash. Fortunately, it seems the existing vdpau
wrapper won't trigger this case and never unloads the driver once it's
successfully loaded.

To make it short, vdpau preemption opens up endless depths of WTFs.

Another issue is that any participating thread might do the preemption
recovery (whichever comes first). This is easier to implement. The
implication is that we need threadsafe xlib. We just hope and pray that
this will actually work. This also means that once vdpau code is
actually involved in a multithreaded scenario, we have to add
XInitThreads() to the X11 code.
2014-05-10 10:44:16 +02:00
wm4 280e7e171a vdpau: remove some code
There's no reason why we should treat the preemption case differently
here.
2014-05-10 10:44:16 +02:00
wm4 0e1491346e vo_vdpau, vo_opengl: handle vdpau preemption differently
Use the newly provided mp_vdpau_handle_preemption() function, instead of
accessing mp_vdpau_ctx fields directly. Will probably make multithreaded
access to the vdpau context easier.

Mostly unrelated to the actual changes, I've noticed that using hw
decoding with vo_opengl sometimes leads to segfaults inside of nvidia's
libGL when doing the following:

1. use hw decoding + vo_opengl
2. switch to console (will preempt on nvidia systems)
3. switch back to X (mpv will recover, switches to sw decoding)
4. enable hw decoding again
5. exit mpv

Then it segfaults when mpv finally calls exit(). I'll just blame nvidia,
although it seems likely that something in the gl_hwdec_vdpau.c
preemption handling triggers corner cases in nvidia's code.
2014-05-10 10:44:16 +02:00
wm4 203be26588 vdpau: handle display preemption during decoding
This was broken for some time, and it didn't recover correctly.

Redo decoder display preemption. Instead of trying to reinitialize the
hw decoder, simply fallback to software decoding. I consider display
preemption a bug in the vdpau API, so being able to _somehow_ recover
playback is good enough.

The approach taking here will probably also make it easier to handle
multithreading.
2014-05-10 10:44:16 +02:00
wm4 66391dbb64 input: fix typos, cosmetics 2014-05-10 10:44:15 +02:00
wm4 6e83864823 w32_common: fix typo
Also, reset rc completely, instead of assuming things.
2014-05-10 10:44:15 +02:00
Stefano Pigozzi fc4a43d39a osxbundle: split and optimize bundling script
Move the code that copies the dylib's to the bundle to a new script
(dylib-unhell.py) which is called by osxbundle.py.

dylib-unhell is about 20x faster than the previous implementation. This is
accomplished by removing superflous shell-out operations which are kept track
of using an in memory tree of all the needed dependencies. Moreover the
shell-outs have been further optimized by not requiring a complete shell for
every operation and just using subprocess.call (which is equivalent to Popen).
2014-05-09 20:48:15 +02:00
kevmitch 0a328bd5c1 Merge pull request #774 from kevmitch/man_pdf_tweaks
man: tweak --sub-codepage for concision
2014-05-09 08:25:14 -07:00
Kevin Mitchell aee35666c1 man: tweak --sub-codepage for concision
The many "boxes" in this entry were causing rst2pdf to fail because it
couldn't figure out where to break the page. Make the boxes smaller by
removing semi-redundant examples. Also try and make surrounding text a
little shorter by rewording.
2014-05-09 00:56:01 -07:00
wm4 996ab61a6a command: add property that estimates current video FPS
This is done after filters, so things like framerate-doubling
deinterlacing is accounted for.

Unfortunately, framedropping can cause inaccuracies (especially after
precise seeks), and we can't really know when that happens. Even though
we know that the decoder might drop a frame if we request it to do so,
we don't know when the dropped frame will start or stop affecting the
video filter chain. Video filters can have frames buffered, and we
can't tell at which point the dropped frame would have been output.
It's not even possible to mark a discontinuity after seek, because
again we don't know if the filter chain still has the discontinuity
within its buffers.

So we have to live with the fact that the output of this property can
be completely broken after seek, unless --no-hr-seek-framedrop is used.
2014-05-08 01:25:48 +02:00
wm4 c57660fbf7 options: add --hr-seek-framedrop option
This allows disabling of decoder framedrop during hr-seek.

It's basically another useless option, but it will help exploring
whether this framedropping really makes seeking faster, or whether
disabling it helps with precise seeking (especially frame backstepping).
2014-05-07 22:05:30 +02:00
wm4 2a783d7035 player: avoid reconfig during seeking
This probably matters only in extremely corner-case heavy testcases,
such as using mf:// with a bunch of differently sized images.
2014-05-07 21:50:38 +02:00
wm4 f3362e22eb player: remove VO from seeking code path
Until recently, the VO was an unavoidable part of the seeking code path.
This was because vdpau deinterlacing could double the framerate, and hr-
seek and framestepping etc. all had to "see" the additional frames. But
we've removed the frame doubling from the vdpau VO and moved it into a
video filter (vf_vdpaupp), and there's no reason left why the VO should
participate in seeking.

Instead of queuing frames to the VO during seek and skipping them
afterwards, drop the frames early.

This actually might make seeking with vo_vdpau and software decoding
faster, although I haven't measured it.
2014-05-07 21:50:16 +02:00
wm4 bd2bcc4399 player: minor reshuffling of video code 2014-05-07 21:48:36 +02:00
wm4 725e956b11 player: limit max. fallback frame duration
It's calculated from the demuxer reported FPS, which is not very
reliable. Limit the damage a completely insane and broken value could
cause.
2014-05-07 21:41:14 +02:00
wm4 eada87853e player: handle video reconfig slightly different again
Now we avoid calling update_video() twice on reconfig (once to check
whether there are still new frames, and again to actually do the
reconfig). Instead, we check whether there's still something going on
before calling update_video() at all, and depending on that
update_video() will be allowed to reconfig or not.

This will simplify some things later.
2014-05-07 21:39:17 +02:00
wm4 6a8a0e3aa9 player: reset last_frame_duration on init 2014-05-07 21:38:46 +02:00
wm4 ca343d82a6 video/out: remove unused config() parameters
This was cleaned up yesterday.
2014-05-07 21:34:05 +02:00
Martin Herkt b9474ab875 waf: make shlib tasks less noisy 2014-05-07 21:16:07 +02:00
wm4 5704958573 vo: remove old stuff 2014-05-06 23:20:33 +02:00
wm4 f0ee4e8766 vo_wayland: always assume resize on reconfigure
It doesn't look like vo_wayland_config() necessarily sets this flag, so
it seems safer to trigger an explicit resize. This accounts for the case
when playing a new file with different size than the one before.
2014-05-06 23:18:57 +02:00
wm4 b51664c04a wayland: don't use VOCTRL_UPDATE_SCREENINFO
Not very tested. Appears to work.
2014-05-06 23:16:18 +02:00
wm4 41b1ed7b2e win32: don't use VOCTRL_UPDATE_SCREENINFO
Not very tested. At least it compiles.
2014-05-06 23:04:33 +02:00
wm4 836893fed9 cocoa: don't use VOCTRL_UPDATE_SCREENINFO 2014-05-06 22:00:17 +02:00
wm4 a9dece9f20 manpage: fix typo in previous commit 2014-05-06 20:43:20 +02:00
wm4 3c45156448 manpage: adjustments to file-size property 2014-05-06 20:39:00 +02:00
Andrey Morozov dc8684805b command: rename stream-length to file-size, format file size
Signed-off-by: wm4 <wm4@nowhere>
2014-05-06 20:36:42 +02:00
wm4 f4bbd4c1df vo_sdl: don't use VOCTRL_UPDATE_SCREENINFO 2014-05-06 20:35:19 +02:00
wm4 5eaefaa98a x11: don't use VOCTRL_UPDATE_SCREENINFO
See previous commit.
2014-05-06 20:24:35 +02:00
wm4 feb1f8f18f video/out: separate out code to compute window size
Currently, vo_reconfig() calculates the requested window size and sets
the vo->dwidth/dheight fields _if_ VOCTRL_UPDATE_SCREENINFO is
implemented by the VO or the windowing backend. The window size can be
different from the display size if e.g. the --geometry option is used.
It will also set the vo->dx/dy fields and read vo->xinerama_x/y.

It turned out that this is very backwards and actually requires the
windowing backends to workaround these things. There's also
MPOpts.screenwidth/screenheight, which used to map to actual options,
but is now used only to communicate the screen size to the vo.c code
calculating the window size and position.

Change this by making the window geometry calculations available as
separate functions. This commit doesn't change any VO code yet, and just
emulates the old way using the new functions. VO code will remove its
usage of VOCTRL_UPDATE_SCREENINFO and use the new functions directly.
2014-05-06 20:22:32 +02:00
wm4 587f42b56c Fix bogus copyright text
This file was copied from gl_hwdec_vaglx.c to have a basic skeleton, but
no actual code is left from it.
2014-05-06 20:14:53 +02:00
wm4 771199e6d4 demux_playlist: don't require header for m3u
Because the http playlist URL I had for testing claimed to be m3u by
file extension and mime type, but didn't have the header.

Note that this actually changes behavior only in the case the format is
detected by mime type. Then p->force will be set before calling the
parser, and the header becomes optional.
2014-05-06 20:11:15 +02:00
wm4 690b5c5161 demux_playlist: add some mime types 2014-05-06 20:09:55 +02:00
wm4 8bb61f97b4 demux_playlist: allow recognizing format by mime type
This commit just adds basic support. The following commit will add
actual mime types.
2014-05-06 20:09:46 +02:00
wm4 b7669d533b mixer: don't restore volume with different --softvol-max settings
Changing --softvol-max and then resuming would change the volume level
on resume to something different than the original volume. This is
because the user volume setting is always between 0-100, and 100
corresponds to --softvol-max gain.

Avoid that changing -softvol-max and resuming an older file could lead
to a too loud volume level by refusing to restore if --softvol-max
changed.
2014-05-06 20:09:36 +02:00
Kevin Mitchell 0467e13725 TOOLS/lua: add cycle-deinterlace-pullup script
Override the shift+d hotkey to add a pullup step to the cycle.
2014-05-06 10:02:41 -07:00
Kevin Mitchell 6e62779e98 TOOLS/lua: conform to whitespace coding-style 2014-05-06 09:59:59 -07:00
wm4 088031f691 options: fix "-" (stdin) input
Input through stdin requires disabling the terminal layer, and commit
32c63f forgot to rename the option correctly.
2014-05-06 01:06:07 +02:00
wm4 7267588a98 vo: fix previous commit
Commit 433161 actually broke vo_opengl (and maybe others), because
config_ok is not necessarily set correctly yet _during_ reconfig. So a
vo_get_src_dst_rects() call during reconfig did nothing.
2014-05-06 01:04:51 +02:00
wm4 73c7938d74 command: remove ifdefs for deint filters
Doesn't have much of a purpose.
2014-05-06 00:47:28 +02:00
wm4 4331617bce vo: don't crash when changing panscan before first configuration
When the VO was not initialized with vo_reconfig(), or if the last
vo_reconfig() failed, changing panscan would cause a crash due to
vo_get_src_dst_rects() dereferencing vo->params (NULL if not
configured).

Just do nothing if that happens, as there is no video that could be
displayed anyway.
2014-05-06 00:33:59 +02:00
wm4 143cf79a96 vo: get rid of config_count field
Doesn't really seem to be much of use. Get rid of the remaining uses of
it.

Concerning vo_opengl_old, it seems uninitGl() works fine even if called
before initialization.
2014-05-06 00:21:15 +02:00
wm4 a8b267540e common: change mp_snprintf_append semantics
Make it more suitable for chaining. This means a function formatting a
value to a string using a static buffer can work exactly like
mp_snprintf_append itself.

Also rename it to mp_snprintf_cat, because that's shorter.
2014-05-05 23:56:12 +02:00
wm4 7fb5df0d3e options: print replacement for renamed/replaced options
Basically, extract the option table from DOCS/man/en/changes.rst, and
search the table if an option wasn't found. If there's an entry about
it, print it. Hopefully this behavior is slightly more userfriendly.

This is strictly bound to option names. It doesn't work for option
values, nor does it attempt to emulate the old option.
2014-05-05 23:56:01 +02:00
wm4 7c01dee153 options: let unknown option case be handled by final option parser
If an option is completely missing, let m_config_parse_option() handle
this case, instead of erroring out early.

Needed for the following commit.
2014-05-05 23:55:47 +02:00
Kevin Mitchell 20b5fecdf1 TOOLS/lua: use double quotes unless there's a good reason 2014-05-04 12:59:21 -07:00
Kevin Mitchell c91373a202 TOOLS/lua/autocrop: handle case of user hitting hotkey while cropdetection already running 2014-05-04 12:54:03 -07:00
Kevin Mitchell 74984aaff1 TOOLS/lua: no longer gsub out "lua/" prefix, now that its no longer there 2014-05-04 12:29:32 -07:00
wm4 040c050f2d audio: fix the exact value that is used for the wait time
The comment says that it wakes up the main thread if 50% has been
played, but in reality the value was 0.74/2 => 37.5%. Correct this. This
probably changes little, because it's a very fuzzy heuristic in the
first place.

Also move down the min_wait calculation to where it's actually used.
2014-05-04 20:41:00 +02:00
wm4 fb2e8387d4 demux_lavf: one more hack for mp3 from network
mp3 has a hack lowering the probescore for format detection. This is
because detecting mp3s is hard due to their nature, and the fact that
ID3v2 tags are sometimes several megabytes big.

When playing mp3 from network, the mime-type is usually set, and that
matches the format hack entry meant for webradios, overriding the normal
mp3 entry. This can lead to network mp3s not being detected. Lower the
network case to the same probescore as on-disk mp3s. The difference is
that for network mp3s, we don't load the full probe-buffer, and we lower
the amount of audio the demuxer will read to collect data on opening
(0.5 seconds instead of typically 5 seconds).
2014-05-04 20:38:46 +02:00
wm4 767bcdc322 ao_null: fix unit mismatch with latency option
It's in seconds, but the code used it as sample count.
2014-05-04 16:57:32 +02:00
wm4 70ffbbe927 vf: print for which filter initialization failed 2014-05-04 16:07:43 +02:00
wm4 aa2a9c3e42 manpage: fix vf_scale options 2014-05-04 16:07:01 +02:00
wm4 ca7d8681fb stream_bluray: remove unused variables
They were used for printing slave mode stuff, which was recently
removed.
2014-05-04 13:13:31 +02:00
wm4 f5a564d417 vf_vdpaupp: make code clarity improvements
This shouldn't change anything functionally, except that it buffers 1
frame less in the first-field deinterlacing mode.
2014-05-04 11:03:21 +02:00
wm4 a7fe47e495 vdpau: deduplicate video surface upload code
This was a minor code duplication between vf_vdpaupp.c and vo_vdpau.c.

(In theory, we could always require using vf_vdpaupp with vo_vdpau, but
I think it's better if vo_vdpau can work standalone.)
2014-05-04 10:51:14 +02:00
wm4 94441ed139 options: merge ---sub-auto-match with --sub-auto
There's no reason why these should be separate.
2014-05-04 10:31:24 +02:00
wm4 f26fe90c8a manpage: improve --input-cursor description 2014-05-04 10:18:49 +02:00
Martin Herkt 48bd03dd91 options: remove deprecated --identify
Also remove MSGL_SMODE and friends.

Note: The indent in options.rst was added to work around a bug in
ReportLab that causes the PDF manual build to fail.
2014-05-04 02:46:11 +02:00
Martin Herkt 81c076b2f8 options: remove obsolete --fsmode-dontuse 2014-05-04 02:46:11 +02:00
Martin Herkt 9d9bba8f13 options: rename device-specific options
--dvdangle → --dvd-angle
--tvscan   → --tv-scan
2014-05-04 02:46:11 +02:00
Martin Herkt 11eaa52529 options: rename msg-related options
--msgcolor    → --msg-color
--msglevel    → --msg-level
--msgmodule   → --msg-module
--msgtime     → --msg-time (also document this one)
--playing-msg → --term-playing-msg
--status-msg  → --term-status-msg
2014-05-04 02:46:11 +02:00
Martin Herkt b54c963258 options: rename video-related options/properties
Renamed options:
--aspect    → --video-aspect
--fstype    → --x11-fstype
--native-fs → --fs-missioncontrol
--name      → --x11-name

Renamed properties:
aspect → video-aspect
2014-05-04 02:46:11 +02:00
Martin Herkt 2b7bc2dfc9 options: rename audio-related options/properties
Renamed options:
--audiofile       → --audio-file
--audiofile-cache → --audio-file-cache
--channels        → --audio-channels
--format          → --audio-format
--srate           → --audio-samplerate

Renamed properties:
samplerate → audio-samplerate
channels   → audio-channels
2014-05-04 02:46:11 +02:00
Martin Herkt 8d7d6caeaf options: rename subtitle-related options
--ass           → --sub-ass
--autosub       → --sub-auto
--autosub-match → --sub-auto-match
--sub           → --sub-file
--subcp         → --sub-codepage
--subfps        → --sub-fps
2014-05-04 02:46:11 +02:00
Martin Herkt 32c63fc119 options: rename input-related options
--ar              → --input-appleremote
--consolecontrols → --input-terminal
--media-keys      → --input-media-keys
--joystick        → --input-joystick
--lirc            → --input-lirc
--lircconf        → --input-lirc-conf
--mouse-movements → --input-cursor
--right-alt-gr    → --input-right-alt-gr
2014-05-04 02:46:05 +02:00
Martin Herkt e24d736404 DOCS: update changes.rst
Better to tell users straight away that mpv should not be treated
as just another MPlayer.
2014-05-03 22:08:32 +02:00
wm4 6589c5424e video: remove a corner case by introducing another one
When loading a video, and a script reacts to MPV_EVENT_VIDEO_RECONFIG,
and the script inserts a video filter, the first frame can be skipped.
This happens simply because the first frame is (usually) still queued in
the video filter chain, and changing the filter chain will drop all
queued frames. So this is just a corner case that just happens in a
weird situation.

But it's still annoying when having such a script, and starting
something where the first frame is very visible, and not starting in
paused mode. (All in all, a corner case.) Do this by immediately queuing
1 filtered frame to the VO immediately after reconfig, instead of
leaving it to the video loop doing it as "incremental" work. Simply
fallthrough to the next case. We must not overwrite "r" in this case,
because that contains the current status.

Note that the first frame will not be filtered using the inserted
filter.
2014-05-03 16:33:07 +02:00
wm4 ae4613cd3b video: fix video end condition
This wasn't really fine, and could (perhaps) cause weird corner cases on
reinit or when the player was paused.

Before eb9d20, video_left was also set to true if vo->frame_loaded was
set, and this variable basically indicated whether the previous
update_video() call was successful. This was overlooked when changing
everything. Simply always call update_video(), it should be equivalent.
2014-05-03 15:29:48 +02:00
wm4 c9ed70b666 video: rename a variable
Cosmetic change, reduce the diff of the following commit.
2014-05-03 15:27:17 +02:00
wm4 bc07c86da5 vf_vapoursynth: fix aspect ratio passed to vapoursynth
This was recently either changed or clarified in vapoursynth.

Pass the aspect ratio as pixel aspect to VS.
2014-05-03 15:17:13 +02:00
wm4 4bd9bdf5c9 input: fix stack overflow when checking for abort cmd
This can happen when the input stream is somehow blocking on network,
and the user still send input in one way or another, and one of the
commands is a compound command ("cmd a ; cmd b").
2014-05-02 17:43:56 +02:00
wm4 1279ebf5c5 client API: fix inverted condition
Oops. Sigh.
2014-05-02 17:23:25 +02:00
wm4 3b755642c8 manpage: adjust description of vdpau deint sub-option 2014-05-02 17:08:19 +02:00
wm4 0d47509025 manpage: deprecated vo_vdpau postprocessing options
This seems a bit silly, but the way vf_vdpaupp works, this is cleaner.
2014-05-02 16:57:39 +02:00
wm4 5d9ea7f22f manpage: document vf_vdpaupp 2014-05-02 16:41:01 +02:00
wm4 33a945cc7e video: removed unused stuff 2014-05-02 14:48:52 +02:00
wm4 d81a374c89 player: remove extremely obscure undefined behavior
Apparently the value of a pointer is "indeterminate" after a free()
call, even if you never dereference the pointer after the free. Since
talloc_free() calls free(), this applies here.
2014-05-02 14:45:56 +02:00
wm4 2386e183fe client API, video: signal reconfig at the right time
Filter reconfig can now happen a few frames before VO reconfig.
2014-05-02 01:28:52 +02:00
wm4 585d8c6856 input: increase number of maximum sections
This is because Lua scripts creating key bindings create 2 input
sections per script.

Probably fixes #759.
2014-05-02 01:27:17 +02:00
wm4 beaa7c7153 lua: remove "lua/" prefix from script names
This affects the return value of mp.script_name, the "client name"
(what's returned by mpv_client_name()) and all associated features, as
well as the mpv terminal output module prefix when scripts print
something.

As discussed in #748.
2014-05-02 01:25:58 +02:00
wm4 eb9d203946 video: change everything
Change how the video decoding loop works. The structure should now be a
bit easier to follow. The interactions on format changes are (probably)
simpler. This also aligns the decoding loop with future planned changes,
such as moving various things to separate threads.
2014-05-02 01:09:58 +02:00
wm4 346daec403 manpage: fix the alternative suggested for stream-path
${filename} didn't make much sense, since that doesn't include the path
components, and can be otherwise mangled.
2014-05-02 01:09:58 +02:00
wm4 50ebcf1a43 video: handle colorspace and aspect overrides separately
Now the video filter code handles these explicitly, which should
increase robustness (or at least find bugs earlier).
2014-05-02 01:09:55 +02:00
wm4 f4eaceee0f vf: sanitize filter input, instead of overriding it
vf_fix_img_params() takes care of overwriting image parameters that are
normally not set correctly by filters. But this makes no sense for input
images. So instead, check that the input is correct.

It still has to be done for the first input image, because that's used
to handle some overrides (see video_reconfig_filters()).
2014-05-02 01:09:03 +02:00
wm4 4049532501 vf: add alternate functions for retrieving filter output
These replace vf_read_output_frame(), although we still emulate that
function. This change is preparation for another commit (and this is
basically just to reduce the diff and signal/noise ratio in that
commit).
2014-05-02 01:08:06 +02:00
wm4 9243249a0e vf: expose input parameters; clear parameters on failure
Preparation (and simplification) for following commits.
2014-05-02 01:08:05 +02:00
wm4 2a9b1d19ba vf: mark auto-inserted conversion filters in verbose output
Nota that this flag is not set for other auto-inserted filters (like
deinterlacing or rotation).
2014-05-02 01:08:05 +02:00
wm4 ffde8083f6 vf_lavfi: reinit after libavfilter EOF
Basically, if we feed the filter a new image even after the EOF state
has been reached (e.g. because the input stream "recovered"), we want
the filter to restart, instead of returning an error forever.
2014-05-02 01:08:05 +02:00
wm4 bd230a8d47 vo: verify format of queued image
Currently, only the configured format is accepted, so assert that the
playback core code (which handles format changes) is correct.
2014-05-02 01:08:05 +02:00
wm4 a014a2402d video: fix screenshots with anamorphic video
(Again.)

This was caused by mp_image_set_params() not properly copying d_w/d_h,
because mp_image_set_size() resets them.
2014-05-02 01:08:05 +02:00
wm4 50538c0ea2 vf_vdpaupp: always provide past and future fields
Some non-deinterlacing filters (potentially denoising) also use
additional frames for filtering. The vdpau docs suggest providing at
least 1 future and 2 past _fields_, which means we need to provide 1
past frame (the future field is already the other field of the current
field, and both fields are in the same frame).

We can easily achieve this by buffering an additional frame in the non-
deint case.
2014-05-02 01:08:05 +02:00
wm4 586ea206da vo_vdpau: keep colorspace flags
Since vdpau_mixer.c initializes the YUV conversion using the mp_image
flags, these images should have all flags set properly.
2014-05-02 01:08:05 +02:00
wm4 6775487a46 video: move video frame queue from vo_vdpau.c to vo.c
Remove the special casing of vo_vdpau vs. other VOs. Replace the
complicated interaction between vo.c and vo_vdpau.c with a simple queue
in vo.c. VOs other than vdpau are handled by setting the length of the
queue to 1 (this is essentially what waiting_mpi was).

Note that vo_vdpau.c seems to have buffered only 1 or 2 frames into the
future, while the remaining 3 or 4 frames were past frames. So the new
code buffers 2 frames (vo_vdpau.c requests this queue length by setting
vo->max_video_queue to 2). It should probably be investigated why
vo_vdpau.c kept so many past frames.

The field vo->redrawing is removed. I'm not really sure what that would
be needed for; it seems pointless.

Future directions include making the interface between playloop and VO
simpler, as well as making rendering a frame a single operation, as
opposed to the weird 3-step sequence of rendering, drawing OSD, and
flipping.
2014-05-02 01:08:05 +02:00
wm4 d6dc8642ae vo_vdpau: always use mp_image for internal buffer queue 2014-05-02 01:08:05 +02:00
wm4 90a039a599 command, vo_vdpau: respect vdpau deint sub-option
This is a horrible hack to keep compatibility with the vo_vdpau deint
sub-option.
2014-05-02 01:08:05 +02:00
wm4 3f060a19d8 command: redo deinterlace filter probing
Give up on the deint_filters[] array, and probe using explicit code
instead. Add additional checks to test the pixel format to avoid
annoying warnings when a hardware deinterlacer is inserted when the
current video chain is obviously incompatible.
2014-05-02 01:08:04 +02:00
wm4 c42795f1ea command: make enabling deinterlacing with vdpau work
This restores the capability of enabling deinterlacing with the
'cycle deinterlace' command with vo_vdpau, and also makes it work
with vo_opengl.
2014-05-02 01:08:04 +02:00
wm4 1efb5fd465 vf_vdpaupp: allow toggling deinterlace
Basically makes the 'D' key work again. (But only if the filter is
already inserted.)
2014-05-02 01:08:04 +02:00
wm4 ffbf6037cb vo_vdpau: apply vo_vdpau postprocessing options
The previous commits changed vo_vdpau so that these options are set by
vf_vdpaupp, and the corresponding vo_vdpau were ignored. But for
compatibility, keep the "old" options working.

The value of this is questionable - maybe the vo_vdpau options should
just be removed. For now, at least demonstrate that it's possible.

The "deint" suboption still doesn't work, because the framerate doubling
logic required for some deint modes was moved to vf_vdpaupp. This
requires more elaborate workarounds.
2014-05-02 01:08:04 +02:00
wm4 fd63f2f037 vdpau_mixer: allow overriding frame opts
So a caller can override the filter options dictated by vf_vdpaupp.
2014-05-02 01:08:04 +02:00
wm4 ec28a281b9 vo_vdpau: support vf_vdpaupp
This is slightly incomplete: the mixer options, such as sharpen and
especially deinterlacing, are ignored. This also breaks automatic
enabling of interlacing with 'D' or --deinterlace. These issues will be
fixed later in the following commits.

Note that we keep all the custom vdpau queue stuff. This will also be
simplified later.
2014-05-02 01:08:04 +02:00
wm4 d8385091a6 vo_opengl: make it work with vf_vdpaupp
This uses mp_vdpau_mixer_render(). The benefit is that it makes vdpau
deinterlacing just work. One additional minor advantage is that the
video mixer creation code is factored out (although that is a double-
edged sword).
2014-05-02 01:08:04 +02:00
wm4 073ee146ea vf_vdpaupp: allow non-vdpau input
So you can use vdpau deinterlacing without using vdpau hardware
decoding.

vf_vavpp does something similar.
2014-05-02 01:08:04 +02:00
wm4 ec60669cd1 vdpau: add a postprocessing pseudo-filter
This factors out some code from vo_vdpau.c, especially deinterlacing
handling. The intention is to use this for vo_vdpau.c to make the logic
significantly easier, and to use it for vo_opengl (gl_hwdec_vdpau.c) to
allow selecting deinterlace and postprocessing modes.

As of this commit, the filter actually does nothing, since both vo_vdpau
and vo_opengl treat the generated images as normal vdpau images. This
will change in the following commits.
2014-05-02 01:08:02 +02:00
wm4 7fc999b577 vo: document draw_image 2014-04-30 22:25:11 +02:00
wm4 cb411ac520 vo_lavc: remove code with no effect
This field will also removed in the future.
2014-04-30 22:24:48 +02:00
wm4 ee574c67ea video: improve error messages 2014-04-30 22:20:08 +02:00
wm4 3f0f666d14 vf: print error if filtering a frame fails
The filters don't always print an error on their own, and printing an
error is better than silently dropping the frame.
2014-04-30 22:19:38 +02:00
Kevin Mitchell 8e8758dbe1 TOOLS: better documentation of lua scripts 2014-04-29 08:31:44 -07:00
Kevin Mitchell 4b0a760d86 TOOLS: improve autocrop.lua
It now inserts no filters and does nothing until the hot-key is pressed.
This makes it more suitable to be put in ~/.mpv/lua.

When the hot-key is pressed, it now inserts the cropdetect filter and
waits 1 second (or a --lua-opts specified duration) before gathering
the cropdetect metadata and inserting the appropriate crop filter. A
second press of the hotkey removes the crop.
2014-04-29 08:31:44 -07:00
Kevin Mitchell 479dab5718 vf_lavfi: reset metadata in reset()
It might have been nice not to do this so that metadata could
accumulate accross seeks, but it seems libavfilter looses its copy
anyway on recreate_graph.
2014-04-29 08:31:44 -07:00
Kevin Mitchell e3e565c194 vf-metadata: fix handling of NULL metadata
lavfi would segfault due to a NULL dereference if it was asked for its
metadata and none had been allocated (oops). This happens for libav
which has no concept of filter metadata.
2014-04-29 08:31:44 -07:00
Kevin Mitchell 164cfeba56 man: grammar tweak of mp.add_timeout() 2014-04-29 08:31:44 -07:00
wm4 f6f8dc7782 video: remove redundant mp_image display_w/_h members
Commit 5e4e248 added a mp_image_params field to mp_image, and moved many
parameters to that struct. display_w/h was left redundant with
mp_image_params.d_w/d_h. These fields were supposed to be always in
sync, but it seems some code forgot to do this correctly, such as
vf_fix_img_params() or mp_image_copy_attributes(). This led to the
problem in github issue #756, because display_w/_h could become
incorrect.

It turns out that most code didn't use the old fields anyway. Just
remove them. Note that mp_image_params.d_w/d_h are supposed to be always
valid, so the additional checks for 0 shouldn't be needed. Remove these
checks as well.

Fixes #756.
2014-04-29 13:31:59 +02:00
wm4 a69e91756d vo_vdpau: let vdpau scale anamorphic screenshots
In theory, returning the screenshot with original pixel aspect would
allow avoiding scaling them with image formats that support non-square
pixels, but in practice this isn't used anyway (nothing seems to
understand e.g. jpeg aspect ratio tags).
2014-04-29 13:27:07 +02:00
wm4 81171e37b2 common: add mp_snprintf_append() utility function 2014-04-29 13:14:48 +02:00
wm4 8562f53cf9 TOOLS/umpv: make it work with Python 3 (again)
Apparently, the 3rd (2nd) parameter to string.translate() function was
removed.

Also, make_abs() had a mistake - not sure how this passed testing.
2014-04-29 02:21:59 +02:00
wm4 2a8f7181e3 TOOLS/umpv: don't mangle URLs
This attempted to prefix the current directory to URLs, because it
didn't recognize them as already absolute paths.
2014-04-29 02:16:18 +02:00
wm4 fa1b9517bc TOOLS/umpv, mpv.desktop: use --no-terminal instead of --really-quiet
So this won't initialize terminal handling if stdout happens to be a
terminal. It also suppresses all output to stdout/stderr.
2014-04-29 02:09:59 +02:00
wm4 f2f19b3404 TOOLS/umpv: allow passing 0 files
Some might use that to just create an empty window with --force-window
--idle (for whatever reasons).
2014-04-29 02:06:40 +02:00
wm4 1800becf6a TOOLS/umpv: allow passing options
But only via a special environment variable.
2014-04-29 01:24:21 +02:00
wm4 6c87b50727 TOOLS/umpv: make it work with Python 3
Apparently they removed octal literals, and made them invalid syntax.
2014-04-29 01:21:21 +02:00
wm4 48587e88e0 vf_vapoursynth: add more VS frame properties
We only support them for input. The frame properties of output frames
are ignored (except frame durations).

Properties not set for now: _ChromaLocation, _Field, _FieldBased
2014-04-28 23:44:57 +02:00
wm4 6b0b8368a4 vf_vapoursynth: use frame durations instead of _AbsoluteTime
Set _DurationNum/_DurationDen on each VS frame, instead of
_AbsoluteTime. The duration is the difference between the timestamp of
the frame and the next frame, and when receiving filtered VS frames, we
convert them back to an absolute PTS by summing them.

We pass the timestamps with microsecond resolution. mpv uses double for
timestamps internally, so we don't know the "real" timebase or FPS. VS
on the other hand uses fractions for frame durations. We can't pass
through the numbers exactly, but microseconds ought to be enough to be
even safe from accumulating rounding errors.
2014-04-28 22:23:32 +02:00
wm4 062d5eea3b vf_vapoursynth: fix memory leak on error
Since this leaks video images, and the player keeps feeding new images
to the fitler even if it fails, this would probably have disastrous
consequences.
2014-04-28 22:23:32 +02:00
wm4 dffb7c2409 vf_vapoursynth: remove incorrect copyright notice
This file merely started out by copy&pasting vf_lavfi.c and removing
everything to have a basic skeleton.
2014-04-28 22:23:32 +02:00
wm4 f39e4210f7 vf_lavfi: distinguish real errors from other states
Don't just hide real errors, should a filter return them.
2014-04-28 22:23:31 +02:00
wm4 42f65ce108 video: don't drop last frame when deinterlacing with yadif
Or in other words, add support for properly draining remaining frames
from video filters. vf_yadif is buffering at least one frame, and the
buffered frame was not retrieved on EOF.

For most filters, ignore this for now, and just adjust them to the
changed semantics of filter_ext. But for vf_lavfi (used by vf_yadif),
real support is implemented. libavfilter handles this simply by passing
a NULL frame to av_buffersrc_add_frame(), so we just have to make
mp_to_av() handle NULL arguments.

In load_next_vo_frame(), we first try to output a frame buffered in the
VO, then the filter, and then (if EOF is reached and there's still no
new frame) the VO again, with draining enabled. I guess this was
implemented slightly incorrectly before, because the filter chain still
could have had remaining output frames.
2014-04-28 22:23:31 +02:00
wm4 a6dafb061f TOOLS: make youtube-dl_mpv.sh executable 2014-04-28 22:23:31 +02:00
Stefano Pigozzi 9d0c1d6913 cocoa: refactor sync scheduling to a function
This extracts the scheduling logic to a single function which is nicer to keep
it consistent.

Additionally make sure we don't schedule sync operations from a sync operation
itself since that could cause deadlocks (even if it should not be happening
with the current code).
2014-04-28 21:51:04 +02:00
Stefano Pigozzi fbc8ba5855 cocoa: use mainScreen as a fallback for window constraining 2014-04-28 21:32:59 +02:00
Stefano Pigozzi 8eb7e2aa0b cocoa: disallow the titlebar to exit the visibleFrame on the bottom edge 2014-04-28 21:32:59 +02:00
Stefano Pigozzi 2c08ab1c6a cocoa: add constraints to prevent the window to exit the screen
Previously the window could be made to completly exit the screen with a
combination or moving it close to an edge and halving it's size (via cmd+0).

This commit address the problem in the most simple way possibile by
constraining the window to the closest edge in these edge cases.
2014-04-28 21:32:58 +02:00
Ryan Goulden 80ec0bac43 cocoa: move sync section assignments in vo_control 2014-04-28 21:32:58 +02:00
Ryan Goulden 4d8489efae cocoa: cosmetics: use NSMakeSize 2014-04-28 21:32:58 +02:00
Ryan Goulden 2878c2a914 cocoa: fix native fullscreen
This fixes a couple of issues with the Cocoa `--native-fs` mode, primarily:

 - A ghost titlebar at the top of the screen in full screen:

   This was caused by the window constraining code kicking in during
   fullscreen. Simply returning the unconstrained rect from the constraining
   method fixes the problem.

 - Incorrect behavior when using the titlebar buttons to enter/exit
   fullscreen, as opposed to the OSD button.

   This was caused by mpv's internal fullscreen state going out of sync with
   the NSWindow's one. This was the case because `toggleFullScreen:`
   completely bypassed the normal event flow that mpv expects.

Signed-off-by: Ryan Goulden <percontation@gmail.com>

Change style for mpv, simplify and refactor some of the constraining code.

Signed-off-by: Stefano Pigozzi <stefano.pigozzi@gmail.com>
2014-04-28 21:32:58 +02:00
wm4 e8a996cede client API: add chapter change event
Also works for mpv_observe_property() on the "chapter" property.
2014-04-27 22:28:07 +02:00
wm4 b20416abe3 vf_vapoursynth: use official AbsoluteTime property
I thought the "_" in "_AbsoluteTime" was part of the documentation
markup.

This still doesn't help us with VS filters that change timing;
apparently you must use frame durations instead.
2014-04-27 22:16:56 +02:00
wm4 9e47bd11cc vf_vapoursynth: keep pixel aspect ratio
Make the filter apply the pixel aspect ratio of the input to the output.
This is more useful than forcing 1:1 PAR when playing anamorphic video
such as DVDs.

VapourSynth itself actually allows passing through the aspect ratio, but
it's in a not very useful form for us: it's per video-frame instead of
constant (i.e in VSVideoInfo). As long as we don't have a way to allow a
filter to spontaneously change output parameters, we can't use this.
(And I don't really feel like making this possible.)
2014-04-27 17:05:26 +02:00
Kevin Mitchell 4e973c059a TOOLS: indent lua scripts by 4 spaces instead of 3 2014-04-27 15:34:53 +02:00
Kevin Mitchell 7ef045555d TOOLS: add lua/drc-control
allows live insertion/deletion/adjustment of drc audio filter
2014-04-27 15:34:53 +02:00
Kevin Mitchell ae56b8d237 TOOLS: move autocrop.lua to TOOLS/lua
in anticipation of more lua scripts
2014-04-27 15:34:52 +02:00
Stefano Pigozzi ce48da9e02 build: use -pthread when available
Our code currently tries to link -lpthread and adds stuff like -D_REENTRANT
based on the target platform.

GCC actually supports to just pass a -pthread compiler and linker flag that
will automatically enable threading and define the correct symbols for the
platform, so let's try to just use that as our first choice.

clang also supports -pthread but it must be used only as a compiler flag,
so we also take care of that scenario with this commit.
2014-04-27 10:40:01 +02:00
Stefano Pigozzi ae0c8ca219 build: conditionally use -Wempty-body
-Wempty-body is not available on all gcc versions but we were using it
unconditionally. Also remove the usage from the clang case. clang still
defines `__GNUC__` so it still gets all the gcc specific flags.

This should fix the build on systems with older gcc versions like OpenBSD which
still comes bundled with gcc 4.2 for license issues.
2014-04-26 23:53:09 +02:00
wm4 cdafc2f7d7 terminal: always use SA_RESTART with sigaction()
One problem is that for example stdio functions won't restart syscalls
manually, and instead treat EINTR as an error. So passing SA_RESTART is
the only sane thing to do, unless you have special requirements, which
we don't.
2014-04-26 22:52:26 +02:00
wm4 eb3cc32f9b demux_mkv: enable parsing for VP9
VP9 packets can contain 2 frames in some video packets (from which 1
frame is invisible). Due to a design mismatch between libvpx and the
libavcodec vp9 decoder, libvpx can take the "full" packets, but lavc vp9
can not. The consequence is that we have to split the packets if we want
to feed them to the lavc codec.

This is not entirely correct yet: timestamp handling is missing.
--demuxer=lavf and ffmpeg native utilities have the same problem. We can
fix this only once the ffmpeg VP9 parser is fixed.
2014-04-26 22:24:15 +02:00
wm4 a29597cb65 input: fix mouse_leave/OSC behavior
This essentially reverts commit cca13efb. The code in the if was
supposed to be run only if the mouse button was down, because in this
case the mouse area is never considered to be left. Since it was run
for every mouse button, mouse_leave wasn't sent.

Fixes #745.
2014-04-26 20:30:24 +02:00
wm4 d44dd30ac7 input: fix inverted condition
pthread_equal() returns 0 if the threads are not the same, and somehow
I got that wrong. The worst is that I actually explicitly checked the
manpage when I wrote this code.
2014-04-26 16:58:23 +02:00
wm4 75d7d87e1b osd: make code C99
This used an unnamed union, which is allowed in GNU C and C11, but not
C99. This broke the build with some older compilers.

Replaces pull request #744.
2014-04-26 16:04:09 +02:00
Alexander Preisinger a5282e3a69 Revert "wayland: print waylands display erros"
This reverts commit 6e34b0ec1f.

There has always been an error message "proxy already has a listener" and
I couldn't reproduce where it is comming from until now. The display interface
already has a listener and we can't overwrite it. Now remove the code and avoid
this error message.

Conflicts:
	video/out/wayland_common.c
2014-04-26 14:51:48 +02:00
wm4 2584dcc873 manpage: fix grammar 2014-04-26 13:28:31 +02:00
wm4 3a80308e6d manpage: forced->used 2014-04-26 12:49:38 +02:00
wm4 40c517cc41 vf_pp: PP_PICT_TYPE_QP2 is always defined 2014-04-25 19:21:17 +02:00
wm4 1c2c09adf7 stream: use libavformat interrupt callback
This will allow to cancel opening slow/stuck network streams faster. How
well his work probably depends on the protocol implementation in
libavformat.
2014-04-25 19:13:12 +02:00
wm4 93de4c81b9 stream: make mp_input_check_interrupt thread-safe
The interrupt callback will can be called from another thread if the
cache is enabled, and the stream disconnects. Then stream_reconnect()
will call this function from within the cache thread.

mp_input_check_interrupt() is not thread-safe due to read_events() not
being thread-safe. It will call input callbacks added with
mp_input_add_fd() - these callbacks lead to code not protected by locks,
such as reading X11 events.

Solve this by adding a stupid hack, which checks whether the calling
thread is the main playback thread (i.e. calling the input callbacks
will be safe). We can remove this hack later, but it requires at least
moving the VO to its own thread first.
2014-04-25 19:13:03 +02:00
wm4 e0cf983e53 stream: remove interrupt callback global variables
This used global variables for the asynchronous interrupt callback.

Pick the simple and dumb solution and stuff the callback into
mpv_global. Do this because interrupt checking should also work in the
connect phase, and currently stream creation equates connecting.
Ideally, this would be passed to the stream on creation instead, or
connecting would be separated from creation. But since I don't know yet
which is better, and since moving stream/demuxer into their own thread
is something that will happen later, go with the mpv_global solution.
2014-04-25 19:12:24 +02:00
wm4 3d51ef3dc8 stream: use uninterruptible sleep on reconnecting
This is the only function which actually used the time argument of
stream_check_interrupt(). Considering that the whole player freezes
anyway, this is not worth the complication.

Also generally reduce the maximum wait time due to timeout. Introduce
exponential backoff, which makes the first reconnect retries faster, but
still waits up to 500ms in the later retries.
2014-04-25 19:11:58 +02:00
wm4 cbeb558c6c stream: remove unused functions
Interestingly, their last use was removed with commit bbbea793, over
4 months ago.

Also remove a stray struct demux_stream forward declaration.
2014-04-25 19:11:07 +02:00
wm4 efaed93861 manpage: improve --osd-level description 2014-04-25 19:10:57 +02:00
Nyx0uf 653b7aa32d OS X bundle: add UTImportedTypeDeclarations
Allows to declare UTIs [1] for types of file that OS X doesn't know, like mkv,
mka, etc.

For example: instead of having a dynamically generated UTI for .mkv like
'dyn.somerandomstring', 'io.mpv.mkv' is registered and conforms to public.movie
and is known system wide.

Note: The list is far from being complete but it should cover the most used
type of files.

[1]: https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html#//apple_ref/doc/uid/TP40001319-CH202-CHDHIJDE

Fixes: #734
2014-04-25 09:18:52 +02:00
Alessandro Ghedini b6162dda12 build: bump required libpostproc version
The CPU autodetect feature was added in 52.2.100 and is lacking from the
stand-alone version at http://git.videolan.org/?p=libpostproc.git
2014-04-25 08:37:42 +02:00
Alessandro Ghedini 3547915798 af.rst: fix replaygain-track description
libav now supports reading ReplayGain values from LAME's Info/XING tag as well.
2014-04-25 08:37:42 +02:00
wm4 ca320f6e69 demux_mkv: enable parsing for mp3
For some reason, some files appear to have broken mp3 packets, or at
least in a form that libavcodec can't deal with. The audio in the sample
file in question could not be decoded using libavcodec.

The problematic file had variable packet sizes, and the libavcodec
decoder kept printing "mp3: Header missing" for each packet it was fed.
Remuxing with mkvmerge fixes the problem. The mp3 data is probably not
VBR, and remuxing resulted in fixed-size mp3 frames. So I don't know why
the sample file was muxed this way - it might just be incorrect.

The sample file had "libmkv 0.6.4" as MuxingApp (although I could not
get mkvinfo to print this element, maybe the file uses an incorrect
element ID), and "HandBrake 0.9.4" as WritingApp.

Note that the libmpg123 decoder does not have any issues with it. It's
probably more robust, because libmpg123 was made to decode whole mp3
files, not just single frames.

Fixes issue #742.
2014-04-25 08:36:58 +02:00
wm4 5c3dd6402a dispatch: document some guarantees
The here documented guarantee might simplify code using this mechanism
a lot, because it becomes unnecessary to invent a separate mechanism to
make the mp_dispatch_queue_process loop exit after processing a dispatch
callback. (Instead, the dispatch callback can set a flag, and the caller
of mp_dispatch_queue_process can check it.)
2014-04-25 08:35:02 +02:00
Martin Herkt 89a19aafd9 vo: do not check for events on unconfigured VO
fixes #741
2014-04-25 05:03:24 +02:00
Stefano Pigozzi 26ce2e750d ao_coreaudio: log even more info in verbose mode
This logs more info that can be used for debugging purposes, in particular
it prints all the AudioChannelDescription in the descriptions array.
2014-04-24 09:52:38 +02:00
wm4 8b7ac6e029 lua: fix stack going out of sync
This broke with recursive tables.
2014-04-24 02:30:19 +02:00
wm4 05bad1f57a command: allow native access to "vf" property
This allows client API users and Lua scripts to side-step the pretty
horrible video filter string "language" (although it's back and can't be
avoided when using libavfilter).
2014-04-24 02:30:00 +02:00
wm4 f5df78b3fc dispatch: wakeup only if needed on mp_dispatch_resume()
The wakeup is needed to make mp_dispatch_queue_process() return if
suspension is not needed anymore - which is only the case when the
request count reaches 0.

The assertion added with this commit always has/had to be true.
2014-04-24 01:03:05 +02:00
Stefano Pigozzi 2f7cef117a ao_coreaudio: add verbose output of detected channel layouts
This can be useful for debugging purposes.
2014-04-23 23:30:35 +02:00
wm4 4e3534f82c cache: remove redundant log prefix 2014-04-23 22:30:37 +02:00
wm4 04c4927140 audio: minor simplification in wait code 2014-04-23 21:16:52 +02:00
wm4 26723b32a9 dispatch: improve documentation comments 2014-04-23 21:16:52 +02:00
wm4 cd10af4db6 threads: fix function name
Closer to the corresponding standard function pthread_cond_timedwait.
2014-04-23 21:16:52 +02:00
wm4 80ff94131b dispatch: implement timeout
Note that this mechanism is similarly "unreliable" as for example
pthread_cond_timedwait(). Trying to target the exact wait time will just
make it more complex.

The main use case for this is for threads which either use the dispatch
centrally and want mp_dispatch_queue_process to do a blocking wait for
new work, or threads which have to implement timers. For the former,
anything is fine, as long as they don't have to do active waiting for
new works. For the former, callers are better off recalculating their
deadline after every call.
2014-04-23 21:16:52 +02:00
wm4 29b7260398 dispatch: use a real lock for mp_dispatch_lock()
This is much simpler, leaves fairness isues etc. to the operating
system, and will work better with threading-related debugging tools.

The "trick" to this is that the lock can be acquired and held only while
the queue is in suspend mode. This way we don't need to make sure the
lock is held outside of mp_dispatch_queue_process, which would be quite
messy to get right, because it would have to be in locked state by
default.
2014-04-23 21:16:52 +02:00
wm4 ed7e7e2eb4 dispatch: fix broken locking
mp_dispatch_queue_process() releases the queue->lock mutex while
processing a dispatch callback. But this allowed mp_dispatch_lock() to
grab the "logical" lock represented by queue->locked. Grabbing the
logical lock is not a problem in itself, but it can't be allowed to
happen while the callback is still running.

Fix this by claiming the logical lock while the dispatch callback is
processed. Also make sure that the thread calling mp_dispatch_lock() is
woken up properly.

Fortunately, this didn't matter, because the locking function is unused.
2014-04-23 21:16:52 +02:00
wm4 ff4028f3bf dispatch: wakeup target thread when locking/suspending
Without this, it could happen that both the caller thread and the target
thread sleep.
2014-04-23 21:16:52 +02:00
wm4 2b26517ef7 dispatch: move into its own source file
This was part of osdep/threads.c out of laziness. But it doesn't contain
anything OS dependent. Note that the rest of threads.c actually isn't
all that OS dependent either (just some minor ifdeffery to work around
the lack of clock_gettime() on OSX).
2014-04-23 21:16:51 +02:00
wm4 ac1a21e488 terminal: fix printing of prefix
This was subtly change in 5cfb18. Revert the change.
2014-04-23 21:16:50 +02:00
wm4 8a74638dc7 video: add a "hwdec" property to enable or disable hw decoding at runtime 2014-04-23 01:58:12 +02:00
Kevin Mitchell c7ab0019a3 man: minor typo why not to use portaudio 2014-04-22 21:27:39 +02:00
wm4 a45363a28a vo: simplify event_fd handling
Add the event FD after preinit, remove it before destroy. There's no
need to do it on vo_config, and there's no need to remove the event
FD when vo_config fails.
2014-04-22 21:06:23 +02:00
wm4 e156f8b052 vo: cosmetics: move around some code
Group together related functionality.
2014-04-22 21:03:57 +02:00
wm4 1e818b130a vo: minor cosmetic change 2014-04-22 21:03:35 +02:00
wm4 b430c886aa client API: make mpv_set_option set options natively
This should fix some issues, such as not being able to set the
"no-video" option with MPV_FORMAT_FLAG.

Note that this changes semantics a bit. Now setting an option strictly
overwrite it, even if the corresponding command line option does not.
For example, if we change --sub to append by default, then setting the
"sub" option via the client API would still never append. (Oddly, this
also applies to --vf-add, which will overwrite the old value when using
the client API.)

I'm doing this because there's no proper separation between the command
line parser and setting an option using the MPV_FORMAT_STRING format.
Maybe the solution to this mess would be adding format aware code (i.e.
m_option_set_node) to every option type, and falling back to strings
only if needed - but this would mean that you couldn't set e.g. an
integer option using MPV_FORMAT_STRING, which doesn't seem to be ideal
either.

In conclusion, the current approach seems to be most robust, but I'm
open to suggestions should someone find that these semantics are a
problem.
2014-04-22 01:42:57 +02:00
wm4 bdfe02158f build: glob() is always available
glob() is mandated by POSIX. For the only non-POSIX platform we support,
Windows, we have our own replacement. So the ifdeffery is not needed.

Still leave the checks in the configure scripts, because they have to
decide whether to compile the replacement or not. (Although this could
be special cased to mingw-only, the wscript seems to make this hard.)
2014-04-22 01:42:57 +02:00
wm4 c57e51097b command: export rotation parameter
For completeness.
2014-04-22 01:42:57 +02:00
wm4 dd39b47f7c vf: print all image parameter information in verbose output 2014-04-22 01:42:57 +02:00
wm4 259fb392a5 vo: warn if the VO doesn't support certain flags
Unfortunately, if a VO can't display something as intended, we can just
complain to the user, and leave it at it. But it's still better than
silently displaying things differently with different VOs.

For now, this is used for rotation only. Other things that we should
check includes colorspace and colorlevels stuff.
2014-04-22 01:42:54 +02:00
wm4 ba1380223a vf: remove autoinserted filters on reconfig
When using rotation with hw decoding, and the VO does not support
rotation, vf_rotate is attempted to be inserted. This will go wrong, and
after that it can't recover because a vf_scale filter was autoinserted.
Just removing all autoinserted filters before reconfig fixes this.
2014-04-21 02:57:17 +02:00
James Ross-Gowan 2a6c084e4c parse_commandline: glob filenames on Windows
The Windows port uses CommandLineToArgvW, which doesn't expand wildcards
in command line arguments. Use glob to expand them instead, but only for
non-option arguments.
2014-04-21 02:57:17 +02:00
James Ross-Gowan 0cef033d48 glob-win: support Unicode
glob-win.c wasn't big, so it was easier to rewrite it. The new version
supports Unicode, handles directories properly, sorts the output and
puts all its allocations in the same talloc context to simplify the
implementation of globfree.

Notably, the old glob had error checking code, but didn't do anything
with the errors since the error reporting code was commented out. The
new glob doesn't copy this behaviour. It just treats errors as if there
were no more matching files, which shouldn't matter for mpv, since it
ignores glob errors too.

To match the other Windows I/O helper functions, the definition is moved
to osdep/io.h.
2014-04-21 02:57:16 +02:00
wm4 ff9ac83419 video: auto-insert software rotation filter
If the VO can't do rotation, insert a filter to do this. Note that this
doesn't reuse the filter insertion code from command.c (used by "vf"
input command), because that would end up more complicated: we don't
even want to change the user filter option.
2014-04-21 02:57:16 +02:00
wm4 f69312e329 vf: add function to remove a filter from the chain 2014-04-21 02:57:16 +02:00
wm4 7791b5cf7c vo_opengl: support rotation
This turned out much more complicated than I thought. It's not just a
matter of adjusting the texture coordinates, but you also have to
consider separated scaling and panscan clipping, which make everything
complicated.

This actually still doesn't clip 100% correctly, but the bug is only
visible when rotating (or flipping with --vf=flip), and using something
like --video-pan-x/y at the same time.
2014-04-21 02:57:16 +02:00
wm4 ef2885e771 vo: add some general support code for VOs that allow rotation
For rotation, we assume that the source image will be rotated within the
VO, so the aspect/panscan code needs to calculate its param using
rotated coordinates. VOs which support rotation natively can use this.
2014-04-21 02:57:16 +02:00
wm4 cc00b3ff36 vo_opengl: clean up rendering path
Shuffle the special cases around so that it looks cleaner. The result
should be equivalent to the code before.
2014-04-21 02:57:16 +02:00
wm4 fd2f40762f demux: export video rotation parameter
Now the rotation hint is propagated everywhere. It just isn't used
anywhere yet.
2014-04-21 02:57:16 +02:00
wm4 3b5a331c40 mp_image: add rotation parameter 2014-04-21 02:57:16 +02:00
wm4 5e4e248dc2 video: make mp_image use mp_image_params directly
Minor cleanup, so that we can stuff more information into
mp_image_params later.
2014-04-21 02:57:16 +02:00
wm4 44096073e9 vf_rotate: support all multiples of 90 degrees
This couldn't rotate by 180°. Add this, and also make the parameter in
degrees, instead of magic numbers.

For now, drop the flipping stuff. You can still flip with --vf=flip or
--vf=mirror. Drop the landscape/portrait stuff - I think this is
something almost nobody will use. If it turns out that we need some of
these things, they can be readded later.

Make it use libavfilter. Its vf_transpose implementation looks pretty
simple, except that it uses slice threading and should be much faster.
2014-04-21 02:56:48 +02:00
wm4 0879db960d encode: don't resume playback when encoding
The previous commit doesn't handle additionally loaded config files,
such as the playback resume mechanism.
2014-04-19 22:31:35 +02:00
wm4 b85983a4a6 encode: don't apply default config options
Often, user configs set options that are not suitable for encoding.
Usually, playback and encoding are pretty different things, so it makes
sense to keep them strictly separate. There are several possible
solutions. The approach taken by this commit is to basically ignore the
default config settings, and switch to an [encoding] config profile
section instead. This also makes it impossible to have --o in a config
file, because --o enables encode mode.

See github issue #727 for discussion.
2014-04-19 22:05:17 +02:00
wm4 85998f6121 Fix some libav* include statements
Fix all include statements of the form:

   #include "libav.../..."

These come from MPlayer times, when FFmpeg was somehow part of the
MPlayer build tree, and this form was needed to prefer the local files
over system FFmpeg.

In some cases, the include statement wasn't needed or could be replaced
with mpv defined symbols.
2014-04-19 17:18:10 +02:00
wm4 0cff5836c3 Remove CPU detection and inline asm handling
Not needed anymore. I'm not opposed to having asm, but inline asm is too
much of a pain, and it was planned long ago to eventually get rid fo all
inline asm uses.

For the note, the inline asm use that was removed with the previous
commits was almost worthless. It was confined to video filters, and most
video filtering is now done with libavfilter. Some mpv filters (like
vf_pullup) actually redirect to libavfilter if possible.

If asm is added in the future, it should happen in the form of external
files.
2014-04-19 17:10:56 +02:00
wm4 061c7eba97 vf_pp: fix include statement 2014-04-19 17:10:20 +02:00
wm4 c56b1f2d90 vf_pp: use native libpostproc CPU detection 2014-04-19 17:10:20 +02:00
wm4 60fbce16bb vf_divtc: remove inline asm
Becomes a bit slower (tested with progressive solid color video only),
but this filter is pretty obscure and I'm not even sure what it's useful
for.
2014-04-19 17:10:20 +02:00
wm4 d0ebecb1c4 vf_pullup: remove inline asm
No change in speed (or even slightly faster, though I tested with
progressive solid color video only), and normally we use libavformat's
vf_pullup anyway.
2014-04-19 17:10:20 +02:00
wm4 d55ed011ab vf_noise: remove line asm
I didn't test the speed, but by default, this filter diverts to
libavfilter already. So this would help only if libavfilter is disabled,
or libavfilter doesn't have vf_noise (like on Libav). For these cases,
we still provide the (possibly but not necessarily) slower C
implementation of vf_noise.
2014-04-19 15:50:52 +02:00
wm4 b69c835945 vf_ilpack: remove inline asm
This makes it multiple times slower. However, the output format (packed
YUV) isn't handled efficiently by anything to begin with, and I have no
clue we even have this filter. I guess it's one of these filters which
find some use sometimes, but are not of higher importance, which
justifies removing the faster inline asm.
2014-04-19 15:48:30 +02:00
wm4 c4f5dc0d53 vf_eq: remove slow inline asm
Compiled with -O2, the C code runs just as far (or even slightly faster)
then the MMX inline asm.
2014-04-19 15:38:04 +02:00
wm4 0a444511e8 manpage: add notes when to use/not use certain AO and VO drivers 2014-04-19 15:29:05 +02:00
James Ross-Gowan 78b07c7b60 encode: disable keep-open when encoding 2014-04-19 14:35:57 +02:00
David Weber 2f5217dd05 lua: add example to rebuild the status line
This can be used to easily extent the status line for one's own needs.

I'm not experienced with lua so a few things could probably be done a
better way.
2014-04-19 14:35:57 +02:00
wm4 14421f732b input: make key binds order-independent again
This is for the sake of multi-key commands again. This could break:

   SPACE ignore
   SPACE-SPACE command

while this worked:

   SPACE-SPACE command
   SPACE ignore

The reason being that if the shorter command was first in the list,
it would obviously match, and searching was stopped.
2014-04-19 14:31:54 +02:00
wm4 d910677937 input: discard key history when a key is mapped
This is for the sake of multi-key combinations (see github issue #718).
Now a multi-key sequence isn't matched if any of the previous keys were
actually mapped.
2014-04-19 14:27:26 +02:00
wm4 ec18d24683 input: remove minor code duplication 2014-04-19 14:11:55 +02:00
wm4 8f3850e7ed input: ignore modifiers on MOUSE_LEAVE
Just in case something adds shift/alt/ctrl state to it.
2014-04-19 14:11:25 +02:00
wm4 ba4263e992 manpage: clarify one aspect of multi-keybindings
The explanation is kind of obvious, but on the other it'd probably be
confusing not to clarify this.
2014-04-18 18:20:23 +02:00
wm4 3ded6077ae input: don't wakeup core if key repeat is requested but not possible
There's no need to wakeup the core in this situation.
2014-04-18 18:15:41 +02:00
wm4 395fd9aded input: remove minor redundancy 2014-04-18 18:06:19 +02:00
wm4 46966b942d input: keycodes: reorder flags
MP_KEY_EMIT_ON_UP and MP_NO_REPEAT_KEY are not modifiers, just static
flags that some keycodes set.

This is just a cosmetic change.
2014-04-18 17:50:36 +02:00
wm4 6b9ec41a43 input: simplify by not tracking key up/down states
We only need to track key up/down for a single key. There may be some
minor loss of robustness, but this can (probably) happen only if a VO or
user sends strange or complicated sequences of events. In the normal
case, what we do is more than enough. Most simplification comes from the
fact that mpv is not a game console, and users normally execute only one
action at once.
2014-04-18 17:46:00 +02:00
wm4 46e0ede228 input: rename a variable
Squashing this with the following commit would be confusing.
2014-04-18 17:16:33 +02:00
wm4 cca13efb19 input: slightly simplify mouse dispatching
I admit I don't really understand anymore why this was needed. Delete it
anyway. It was added with commit 42fa7cbbf.
2014-04-18 17:00:24 +02:00
wm4 b87191d176 input: move a function 2014-04-18 16:48:13 +02:00
wm4 ecb4c08ee2 input: close window when window close button is pressed with --input-test
The window close button is usually mapped to the CLOSE_WIN pseudo-key.
Until now, --input-test treated this pseudo-key like any other key (like
the rest of the input handling code), so you couldn't close the window
in this mode. The manpage had silly instructions and warnings how to
deal with this.

Just always quit when CLOSE_WIN is received, and improve the
instructions.
2014-04-18 16:37:27 +02:00
wm4 3b12d0add9 input: handle multi-combinations as key sequences
The input code always supported combinations of multiple keys (even in
MPlayer, although there the code was active really only for mouse
buttons). This was arcance and also made the code more complicated. I
only know of a single person who ever made use of this feature.

Remove this feature, and repurpose some of the support code (e.g.
parsing, display of key combinations, etc.) to handle such multi-
combinations as sequences, instead of keys to be pressed at the same
time. This is much simpler and implements the feature requested in
github issue #718.

This commit will probably cause a bunch of regressions, since the input
handling code has some weird corner cases. I couldn't find any problems
when testing, though.
2014-04-18 16:27:02 +02:00
wm4 5616229dde audio: preallocate audio buffers on resize
This avoids too many realloc() calls if the caller is appending to an
audo buffer. This case is actually quite noticeable when using something
that buffers a large amount of audio.
2014-04-18 16:19:46 +02:00
wm4 8931bc46ba manpage: document loop-file property
Was forgotten in commit 1b398e99.
2014-04-18 00:12:53 +02:00
wm4 e6f4c50f46 player: fix audio EOF check on --no-audio
This considered audio to never reach EOF when audio was disabled,
instead of always being EOF.
2014-04-18 00:03:49 +02:00
wm4 1b398e99f7 player: add a --loop-file option
Unlike --loop, loops a file instead of the playlist.
2014-04-17 23:55:42 +02:00
wm4 5059039c95 player: unrangle one aspect of audio EOF handling
For some reason, the buffered_audio variable was used to "cache" the
ao_get_delay() result. But I can't really see any reason why this should
be done, and it just seems to complicate everything.

One reason might be that the value should be checked only if the AO
buffers have been recently filled (as otherwise the delay could go low
and trigger an accidental EOF condition), but this didn't work anyway,
since buffered_audio is set from ao_get_delay() anyway at a later point
if it was unset. And in both cases, the value is used _after_ filling
the audio buffers anyway.

Simplify it. Also, move the audio EOF condition to a separate function.
(Note that ao_eof_reached() probably could/should whether the last
ao_play() call had AOPLAY_FINAL_CHUNK set to avoid accidental EOF on
underflows, but for now let's keep the code equivalent.)
2014-04-17 23:48:09 +02:00
James Ross-Gowan 0ab3482f73 w32_common: use ToUnicode to translate key input
This replaces translate_key_input with a solution that gives mpv more
control over how keyboard input is converted to unicode. As a result:

- Key up/down events are generated the same way for all keys.
- Dead keys generate their base character instead of being combined with
  the following character.
- Many Ctrl and Ctrl+Alt key combinations that were previously broken
  are fixed, since it's possible to discover the base keys.
- AltGr doesn't produce special characters when mp_input_use_alt_gr is
  false.

This also fixes some logic to do with detecting AltGr and adds proper
UTF-16 decoding.
2014-04-17 22:52:19 +02:00
wm4 40a072480c audio: add hack against broken pulseaudio EOF condition
This was reported with PulseAudio 2.1. Apparently it still has problems
with reporting the correct delay. Since ao_pulse.c still has our custom
get_delay implementation, there's a possibility that this is our fault,
but this seems unlikely, because it's full of workarounds for issues
like this. It's also possible that this problem doesn't exist on
PulseAudio 5.0 anymore (I didn't explicitly retest it).

The check is general and works for all push based AOs. For pull based
AOs, this can't happen as pull.c implements all the logic correctly.
2014-04-17 22:50:49 +02:00
wm4 fe298bc2a5 audio: explicitly document audio EOF condition
This should probably be an AO function, but since the playloop still has
some strange stuff (using the buffered_audio variable instead of calling
ao_get_delay() directly), just leave it and make it more explicit.
2014-04-17 22:45:49 +02:00
wm4 1b92f3b472 ao_null: add simulated device latency, simulate EOF problems
This EOF problems happen at least with PulseAudio, but since it's hard
to reproduce, let ao_null optionally simulate it.
2014-04-17 22:35:05 +02:00
wm4 491f5bc9ac vo_opengl: make spline36 default with --vo=opengl-hq 2014-04-17 21:53:42 +02:00
wm4 9dba2a52db player: add a --dump-stats option
This collects statistics and other things. The option dumps raw data
into a file. A script to visualize this data is included too.

Litter some of the player code with calls that generate these
statistics.

In general, this will be helpful to debug timing dependent issues, such
as A/V sync problems. Normally, one could argue that this is the task of
a real profiler, but then we'd have a hard time to include extra
information like audio/video PTS differences. We could also just
hardcode all statistics collection and processing in the player code,
but then we'd end up with something like mplayer's status line, which
was cluttered and required a centralized approach (i.e. getting the data
to the status line; so it was all in mplayer.c). Some players can
visualize such statistics on OSD, but that sounds even more complicated.
So the approach added with this commit sounds sensible.

The stats-conv.py script is rather primitive at the moment and its
output is semi-ugly. It uses matplotlib, so it could probably be
extended to do a lot, so it's not a dead-end.
2014-04-17 21:47:00 +02:00
FRAU KOUJIRO 6c24a80009 msg: correct ringbuffer log level comparison 2014-04-17 01:43:07 +02:00
wm4 5027469c3b stream_dvdnav: print more debugging info 2014-04-17 01:43:07 +02:00
wm4 8ed1641c3b stream_dvd: fix seeking regression
This was accidentally completely destroyed with commit 24f1878e. I
didn't notice it when testing, because forward seeking still worked
mostly.

The issue was that dvd_seek_to_time() actually called stream_seek(),
which was supposed to call the byte-level seek function dvd_seek(). So
we have to restore this function, and replace all generic stream calls
with stream_dvd.c internal ones. This also affects stream->pos (now a
random number as far as stream_dvd.c is concerned) and stream_skip().
2014-04-17 01:43:07 +02:00
wm4 c5613aa8a2 ao: remove redundant get_delay check
It did nothing; the real check is in push.c.
2014-04-17 01:43:07 +02:00
Alexander Preisinger 49cbc174c1 wayland: unset input regions for osd
Set a zero sized input region for the osd surfaces in order to avoid getting
input for the subsurfaces which might dissapear any time.
2014-04-16 16:38:54 +02:00
Alexander Preisinger 5528ad3031 wayland/shm: Use subsurfaces for OSD 2014-04-16 16:38:54 +02:00
wm4 6fcec75baa af_lavcac3enc: detach on any passthrough format, not just ac3 2014-04-16 00:30:34 +02:00
wm4 3004661bf2 input: deal with playback thread wakeup on windows
The recent change of waking up the playback thread using a wakeup pipe
doesn't work on windows, because windows is horrible. So use a condition
variable instead to wake up the thread. To make things worse, jackaudio
is also horrible and "disallows" the use of mutexes, so all we can do is
implementing a half-solution that is not race condition free.

It would probably better to give up on this lock-free crap in the pull-
API audio path.

Mostly untested.
2014-04-15 23:12:15 +02:00
wm4 824e4982bd player: remove audio waiting
The audio subsystem now wakes up the playback thread explicitly, and we
don't need this anymore.

It still could cause dropouts and such if there are bugs in the recently
introduced audio changes, so this is a thing to watch out for.
2014-04-15 22:54:52 +02:00
wm4 5aeec9aa70 audio: wake up the core when audio buffer is running low (2)
Same change as in e2184fcb, but this time for pull based AOs. This is
slightly controversial, because it will make a fast syscall from e.g.
ao_jack. And according to JackAudio developers, syscalls are evil and
will destroy realtime operation. But I don't think this is an issue at
all.

Still avoid locking a mutex. I'm not sure what jackaudio does in the
worst case - but if they set the jackaudio thread (and only this thread)
to realtime, we might run into deadlock situations due to priority
inversion and such. I'm not quite sure whether this can happen, but I'll
readily follow the cargo cult if it makes hack happy.
2014-04-15 22:50:16 +02:00
wm4 ad75b8e339 ao_pulse: use ao_need_data()
I'm not quite sure why ao_pulse needs this. It was broken when a thread
to fill audio buffers was added to AO - the pulseaudio callback was
waking up the playback thread, not the audio thread. But nobody noticed,
so it can't be very important. In any case, this change makes it wake up
the audio thread instead (which in turn wakes up the playback thread if
needed).
2014-04-15 22:42:15 +02:00
wm4 e2184fcbfb audio: wake up the core when audio buffer is running low
And also add a function ao_need_data(), which AO drivers can call if
their audio buffer runs low.

This change intends to make it easier for the playback thread: instead
of making the playback thread calculate a timeout at which the audio
buffer should be refilled, make the push.c audio thread wakeup the core
instead.

ao_need_data() is going to be used by ao_pulse, and we need to
workaround a stupid situation with pulseaudio causing a deadlock because
its callback still holds the internal pulseaudio lock.

For AOs that don't call ao_need_data(), the deadline is calculated by
the buffer fill status and latency, as before.
2014-04-15 22:38:16 +02:00
wm4 cad6425c46 video: remove use of deprecated AVFrame fields on Libav
qscale export has been completely removed from Libav 10, and FFmpeg has
an alternative API, so this code does nothing and only causes
deprecation warnings on Libav.
2014-04-15 19:55:26 +02:00
wm4 05fa813952 README: mention minimum FFmpeg/Libav versions 2014-04-15 19:53:14 +02:00
wm4 196619671d client API: remove mpv_event_pause_reason
And slightly adjust the semantics of MPV_EVENT_PAUSE/MPV_EVENT_UNPAUSE.

The real pause state can now be queried with the "core-idle" property,
the user pause state with the "pause" property, whether the player is
paused due to cache with "paused-for-cache", and the keep open event can
be guessed with the "eof-reached" property.
2014-04-14 22:33:41 +02:00
wm4 60b9004872 command: add property to indicate when pausing due to --keep-open
This property is set to "yes" if playback was paused due to --keep-open.

The change notification might not always be perfect; maybe that should
be improved.
2014-04-14 22:19:07 +02:00
wm4 1e3e7bb7f4 command: add a property to indicate core pause state
Currently this is (probably) equivalent to "paused-for-cache", but the
latter is a bit special, while this new property is a bit more general.
One case where they might actually be different is dvdnav menus, but I
haven't checked.

Also add property change notifications for these two properties.
2014-04-14 22:08:33 +02:00
wm4 e1f1b0c275 vf_vapoursynth: handle destruction more gracefully
We were relying on vsscript_freeScript() to take care of proper
termination. But it doesn't do that: it doesn't wait for the filters to
finish and exit at all. Instead, it just destroys all objects, which
causes the worker threads to crash sometimes.

Also, we're supposed to wait for the frame callback to finish before
freeing the associated node.

Handle this by explicitly waiting as far as we can. Probably fixes
crashes on seeking, although VapourSynth itself might also need some
work to make this case completely stable.
2014-04-14 20:51:27 +02:00
wm4 059d989bf6 options: don't allow --no-foo=yes
It's a bit strange to allow this, so get rid of it.

This probably breaks a bunch of user config files.

The client API still allows setting them with MPV_FORMAT_FLAG with a
value of 1 (i.e. true), but I guess this is tolerable.
2014-04-14 20:51:27 +02:00
wm4 186fd0311d video: change image format names, prefer mostly FFmpeg names
The most user visible change is that "420p" is now displayed as
"yuv420p". This is what FFmpeg uses (almost), and is also less confusing
since "420p" is often confused with "420 pixels vertical resolution".

In general, we return the FFmpeg pixel format name. We still use our own
old mechanism to keep a list of exceptions to provide compatibility for
a while.

Also, never return NULL for image format names. If the format is unset
(0/IMGFMT_NONE), return "none". If the format has no name (probably
never happens, FFmpeg seems to guarantee that a name is set), return
"unknown".
2014-04-14 20:51:27 +02:00
Rudolf Polzer a7c6c4656d New option --no-ometadata to opt out of including metadata when encoding.
This re-allows the previous behaviour of being able to reencode with
metadata removed, which is useful when encoding "inconsistently" tagged
data for a device/player that shows file names when tags are not
present.
2014-04-14 20:33:35 +02:00
wm4 7178257bb6 vf_vapoursynth: wipe vapoursynth state completely on reloading
Before this commit, the filter attempted to keep the vsscript state
(p->se) even when the script was reloaded. Change it to destroy the
script state too on reloading. Now no workaround for LoadPlugin is
necessary, and this also fixes a weird theoretical race condition when
destroying and recreating the mpv source filter.
2014-04-14 18:03:13 +02:00
Kevin Mitchell 9ffb35848b command: vf-metadata: minor fixup of return status
Signed-off-by: wm4 <wm4@nowhere>
2014-04-14 09:38:45 +02:00
wm4 132f395aac Remove radio://
It was disabled by default, works only for analogue radio, and I bet
nobody uses it.
2014-04-13 18:51:43 +02:00
wm4 78128bddda Kill all tabs
I hate tabs.

This replaces all tabs in all source files with spaces. The only
exception is old-makefile. The replacement was made by running the
GNU coreutils "expand" command on every file. Since the replacement was
automatic, it's possible that some formatting was destroyed (but perhaps
only if it was assuming that the end of a tab does not correspond to
aligning the end to multiples of 8 spaces).
2014-04-13 18:03:01 +02:00
Kevin Mitchell 44f382cf98 af_volume: fix clang -Wsometimes-uninitialized 2014-04-13 18:03:01 +02:00
Kevin Mitchell 09528da0e2 af_lavfi: fix graph parse deprecation warning 2014-04-13 18:03:01 +02:00
Kevin Mitchell f5954b2223 TOOLS: vf-metadata: lua cropdetect example script
Signed-off-by: wm4 <wm4@nowhere>
2014-04-13 18:03:01 +02:00
Kevin Mitchell 9eb061a72b command: add vf-metadata property
This is a read-only property that uses VFCTRL_GET_METADATA
to retrieve mp_tags metadata from a filter specified by label

Signed-off-by: wm4 <wm4@nowhere>
2014-04-13 18:03:01 +02:00
Kevin Mitchell f09134b76d vf_lavfi: copy AVFrame metadata into vf_lavfi priv
store it as mp_tas and add VFCTRL_GET_METADATA to access it from elsewhere

Signed-off-by: wm4 <wm4@nowhere>

old-configure test by wm4.
2014-04-13 18:03:01 +02:00
Kevin Mitchell 0a278f92e6 vf_lavfi: fix ffmpeg deprecation warning for avfilter_graph_parse
use avfilter_graph_parse_ptr for ffmpeg
2014-04-13 18:03:01 +02:00
Kevin Mitchell 7305140a8a vf: auto-label video filters if no label is specified
Signed-off-by: wm4 <wm4@nowhere>
2014-04-13 18:03:01 +02:00
Kevin Mitchell 7ae2eb8e2c vf: add vf_control_by_label to send vfctrl to specific filter 2014-04-13 18:03:01 +02:00
Kevin Mitchell b11fdeab9e talloc README: more human readible api reference 2014-04-13 18:03:01 +02:00
Kevin Mitchell bc79ded75a mp_tags: move generic mp_tags stuff into its own .c/.h files in common/
rename add_metadata to the more genera/descriptive mp_tags_copy_items_from_av_dictionary

Signed-off-by: wm4 <wm4@nowhere>
2014-04-13 18:03:01 +02:00
wm4 47972a0077 player: remove ASX, SMIL and NSC playlist parsers
These playlist parsers are all what's left from the old mplayer playlist
parsing code. All of it is old code that does little error checking; the
type of C string parsing code that gives you nightmare.

Some playlist parsers have been rewritten and are located in
demux_playlist.c. The removed formats were not reimplemented. ASX and
SMIL use XML, and since we don't want to depend on a full blown XML
parser, this is not so easy. Possibly these formats could be supported
by writing a very primitive XML-like lexer, which would lead to success
with most real world files, but I haven't attempted that. As for NSC, I
couldn't find any URL that worked with MPlayer, and in general this
formats seems to be more than dead.

Move playlist_parse_file() to playlist.c. It's pretty small now, and
basically just opens a stream and a demuxer. No use keeping
playlist_parser.c just for this.
2014-04-13 15:40:05 +02:00
Ricardo Vieira 586b02e7bd wayland: don't schedule resize if going fullscreen
mpv was resizing to the same size before it went to fullscreen, we don't need to schedule a resize because the compositor will send a configure event with the new dimensions and thats when we should do it.
2014-04-13 15:30:23 +02:00
wm4 62a483f18b player: hack to fix --msgmodule --term-osd-bar
Basically a cheap hack to fix that the --msgmodule prefix will cause an
unwanted linebreak by making the line too long.

Suggested by Hamuko in github issue #710.

Fixes #710.
2014-04-13 13:03:31 +02:00
David Weber 750de181d7 command: add paused-for-cache, total-avsync-change, drop-frame-count properties
This is needed if you want to reimplement the status line in lua

I could only test drop-frame-count because I didn't find an easy way to
trigger paused-for-cache and total-avsync-change

Signed-off-by: wm4 <wm4@nowhere>
2014-04-13 12:32:14 +02:00
wm4 7ded55f667 vf_vapoursynth: print an error if VapourSynth returns an unknown format
Apparently there is no real format negotiation, so this can actually
happen.
2014-04-13 12:30:57 +02:00
wm4 8161f4374c vf_vapoursynth: error out early if the file sub-option is not set
Instead of crashing by possibly passing a NULL pointer to VapourSynth.
2014-04-13 12:29:40 +02:00
wm4 f3043a77a3 manpage: vf_vapoursynth: document what happens on seeking
Unfortunately, reloading on seeking causes real problems.
2014-04-13 12:27:26 +02:00
wm4 76961843c3 manpage: lua: separate "advanced" functions into a separate section
This will be less confusing.
2014-04-12 20:44:13 +02:00
wm4 f3c0897b3f lua: make it easier to integrate with foreign event loops
We provide some "official" utility functions for this.
2014-04-12 20:41:12 +02:00
wm4 19abeaf62d lua: wrap mpv_get_wakeup_pipe()
Pretty much experimental for issue #661.
2014-04-12 20:13:53 +02:00
wm4 4e5cea86c2 client API: add mpv_get_wakeup_pipe convenience function
Should make integreating with some event loops easier. Untested.
2014-04-12 20:13:07 +02:00
wm4 33f822b715 video: add VapourSynth filter bridge
Mainly meant to apply simple VapourSynth filters to video at runtime.
This has various restrictions, which are listed in the manpage.

Additionally, this actually copies video frames when converting frame
references from mpv to VapourSynth, and a second time when going from
VapourSynth to mpv. This is inefficient and could probably be easily
improved. But for now, this is simpler, and in fact I'm not sure if
we even can references VapourSynth frames after the core has been
destroyed.
2014-04-12 19:31:50 +02:00
wm4 839c3ae64b options: don't sort sub-option help output
Commit 2c2c1203 sorted the output of --list-options, but the same code
ias also used for listing sub-options, such as --vo=scale:help. For sub-
options, the order actually matters.
2014-04-12 11:38:00 +02:00
Evan Purkhiser 5cfb180a89 terminal: pretty print modules for --msgmodule 2014-04-12 11:37:53 +02:00
James Ross-Gowan 2370ef9d22 manpage: fix --vf=scale options 2014-04-11 14:12:11 +02:00
wm4 2c2c1203c3 options: sort --list-options
Until now, --list-options printed options in random order. There
literally wasn't any logic in its order, they just appeared as they were
declared. So just sort them.

Note that we can't sort them in advance, because for certain things
internal to m_config, the order actually matters.

Also we're using strcasecmp(), which is bad (locale dependent), but this
is output intended for human consumption, so it's not a problem.
2014-04-11 01:39:30 +02:00
wm4 333c8cbc29 command: remove extended information from --list-properties
This used to display the property type, but it was not always correct or
even available. The way the property mechanism works, we can know this
only at runtime.
2014-04-11 01:27:57 +02:00
wm4 86094c2c5a client API: include the reason in MPV_EVENT_END_FILE
Otherwise, the client API user could not know why playback was stopped.

Regarding the fact that 0 is used both for normal EOF and EOF on error:
this is because mplayer traditionally did not distinguish these, and in
general it's hard to tell the real reason. (There are various weird
corner cases which make it hard.)
2014-04-11 01:23:32 +02:00
wm4 d3e9f51c71 manpage: document how the client API retrieves the complicated properties
"Complicated" as in they use sub-properties, and using MPV_FORMAT_NODE
allows an application to retrieve all information at once.
2014-04-11 01:05:06 +02:00
wm4 55d6e1f98d lua: add helper function for printing a table
Although this is something really basic, Lua's standard library doesn't
provide anything like this. Probably because there are too many ways to
do it right or wrong.

This code tries to be really careful when dealing with mixed
arrays/maps, e.g. when a table has integer keys starting from 1, making
it look like an array, but then also has other keys.
2014-04-11 00:40:09 +02:00
wm4 fa35079361 client API: remove outdated comments 2014-04-11 00:12:35 +02:00
wm4 04bcb539fd encode: write 2-pass stats only per-packet
The stats were retrieved and written on every encode call, instead of
every encode call that actually returned a packet. ffmpeg.c also does it
this way, so it must be "more correct". Fixes 2-pass encoding.
2014-04-11 00:08:32 +02:00
wm4 856d2c2491 encode: add a missing \n to a log call 2014-04-10 23:58:12 +02:00
wm4 fb06e30b7b lua: add a minor helper function 2014-04-10 23:56:06 +02:00
wm4 f0c8c26e29 client API: improve comments 2014-04-10 23:53:42 +02:00
wm4 f0e08c01ff terminal-unix: reject overlong termcap strings
Our own tables have size for only 8 chars, so these sequences must be
rejected. It seems strings of length 8 are still ok, because the code
uses memcmp and not strcmp, so still allow these.

Based on mplayer-svn commit r37129.
2014-04-10 00:18:26 +02:00
reimar 39b2e20698 joystick: Fix incorrect pointer offset code.
I have some doubts that short reads are even allowed/
possible for /dev/js*, does someone know for sure?

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@37132 b3059339-0415-0410-9bf9-f77b7e298cf2
2014-04-10 00:08:08 +02:00
wm4 a20aa15969 sws_utils: remove custom GBRP conversion
We needed this because the OSD rendering path used GBRP for RGB
rendering, and not all swscale versions supported this conversion. But
recently we've dropped support for very old ffmpeg/libav versions, so
this isn't needed anymore.
2014-04-10 00:07:25 +02:00
wm4 24f1878e95 stream_dvd, cache: hack seeking with --cache + dvd:// back into working
This was broken at some unknown point (even before the recent cache
changes). There are several problems:
- stream_dvd returning a random stream position, confusing the cache
  layer (cached data and stream data lost their 1:1 corrospondence by
  position)
- this also confused the mechanism added with commit a9671524, which
  basically triggered random seeking (although this was not the only
  problem)
- demux_lavf requesting seeks in the stream layer, which resulted in
  seeks in the cache or the real stream

Fix this by completely removing byte-based seeking from stream_dvd. This
already works fine for stream_dvdnav and stream_bluray. Now all these
streams do time-based seeks, and pretend to be infinite streams of data,
and the rest of the player simply doesn't care about the stream byte
positions.
2014-04-09 23:12:31 +02:00
wm4 d6086fa9ec cache: fix description of the offset field
This field sure is a bit strange. I hope the description is correct now.
2014-04-09 22:45:55 +02:00
wm4 5131fe13e1 cache: change a define to an enum
More consistent.
2014-04-09 22:36:01 +02:00
wm4 3836bfb1ad cache: fix checks/output on initialization
resize_cache() checks the size itself and clamps the size to the valid
range if necessary, so we don't need these checks. In fact, the checks
are different. Also, output the cache size after clamping, instead of
before.
2014-04-09 22:34:58 +02:00
Nikoli 65099833f7 TOOLS: add script for using mpv with youtube-dl
Signed-off-by: wm4 <wm4@nowhere>
2014-04-09 20:41:51 +02:00
James Ross-Gowan 17d0609d1e stream_file: Check the handle for network streams
Use NtQueryVolumeInformationFile instead of GetDriveType for detecting
remote filesystems on Windows. This has the advantage of working
directly on the file handle instead of needing a path and it works
unmodified in Cygwin where the previous code wouldn't understand Cygwin
paths or symlinks.

There is some risk in using NtQueryVolumeInformationFile, since it's an
internal function and its behaviour could change at any time or it could
be removed in a future version of Windows, however it's documented[1] in
the WDK and it's used successfully by Cygwin, so it should be fine. If
it's removed, the code should fail gracefully by treating all files as
local.

[1]: http://msdn.microsoft.com/en-us/library/windows/hardware/ff567070.aspx

Signed-off-by: wm4 <wm4@nowhere>
2014-04-09 20:41:51 +02:00
wm4 217008be4a client: change equality rules for MPV_FORMAT_NONE 2014-04-09 20:27:26 +02:00
wm4 b23a1edf55 client: add a comment 2014-04-09 19:27:28 +02:00
wm4 e06d57b7f8 cache: simplify
Merge the cache_read function into cache_fill_buffer, since there's
not much reason to keep them separate. Also, simply call read_buffer()
to see if there's any readable data, instead of checking for the
condition manually.
2014-04-09 19:26:35 +02:00
wm4 5f65a5cfea cache: allow resizing at runtime
The only tricky part is keeping the cache contents, which is made simple
by allocating the new cache while still keeping the old cache around,
and then copying the old data.

To explain the "Don't use this when playing DVD or Bluray." comment: the
cache also associates timestamps to blocks of bytes, but throws away the
timestamps on seek. Thus you will experience strange behavior after
resizing the cache until the old cached region is exhausted.
2014-04-09 19:15:23 +02:00
wm4 6ac98c042f cache: minor simplification
The only difference is that the MP_DBG message is not printed anymore if
the current user read position is outside of the current cache range.

(In order to handle seek_limit==0 gracefully in the normal case of
linear reading, change the comparison from ">=" to ">".)
2014-04-09 19:07:50 +02:00
wm4 a967152498 cache: adjust stream position if necessary
Until now, this could never happen, because new data was simply always
appended to the end of the cache. But for making stream cache resizing
easier, doing it this way seems advantageous. It also makes it harder to
make the internal state inconsistent. (Before this change it could
happen that cache and stream position went out of sync if the read
position was adjusted "inappropriately".)
2014-04-09 19:06:21 +02:00
wm4 80392efaea cache: no short reads in read_buffer
Until now, cache_read() (which calls read_buffer()) could return short
reads. This was a simplification allowed by the stream interface. But
for cache resizing, it will be more practical to make read_buffer() do
a full read.
2014-04-09 19:05:41 +02:00
wm4 e7a5124b36 cache: move ringbuffer read into a separate function
No functional changes yet.
2014-04-09 19:03:23 +02:00
wm4 4c4c7bdeda cache: fix typo in comment 2014-04-09 19:03:17 +02:00
wm4 d6c4b35b0b cache: always update cached controls after running a stream control
Seems like a good idea. One possible bad effect would be slowing down
uncached controls, but they're already slow. The good thing is that
many controls make intrusive changes to the stream (at least controls
which do write accesses), so the cached parameters should be updated.
2014-04-09 19:01:32 +02:00
ChrisK2 4f689258cb osc: fix playlist display 2014-04-09 18:10:51 +02:00
wm4 83874e9429 manpage: --ad-spdif-dtshd=yes works now
It was fixed a while ago. There are still some issues, as pointed
out in the manpage addition.
2014-04-08 23:19:04 +02:00
wm4 98f5d4c30c vd_lavc: by default, do not show corrupt frames
This flips the default value. Use --vd-lavc-show-all=yes to revert.
2014-04-08 23:05:15 +02:00
Vika Apelsinova 77a2d79edb demux: add "BIKb" FourCC
More support for the worst codec ever.

Signed-off-by: wm4 <wm4@nowhere>
2014-04-08 22:59:53 +02:00
wm4 89d400dc21 client API: avoid redundant property change events if possible
This is done simply by comparing the previous and current values. Do
this only if the requested format is not MPV_FORMAT_NONE.
2014-04-08 22:06:39 +02:00
wm4 d6022f33d6 command: property set commands should send property change notifications
Some of these property implementations already send notifications on
their own, but most don't. This takes care of them.

Of course this still doesn't handle all propertry changes - this is
impossible without special-casing each property that can change on its
own.
2014-04-08 21:24:14 +02:00
wm4 a94020e25b lua: add API for observing property changes
A low level API was added already earlier, but that was merely a binding
for the raw C API. Add a "proper" one, and document it.
2014-04-08 21:10:00 +02:00
wm4 708f32b746 vo_vdpau: add an additional check for timestamp robustness
This might be a good idea in order to prevent queuing a frame too far in
the future (causing apparent freezing of the video display), or dropping
an infinite number of frames (also apparent as freezing).

I think at this point this is most of what we can do if the vdpau time
source is unreliable (like with Mesa). There are still inherent race
conditions which can't be fixed.
2014-04-08 20:16:53 +02:00
wm4 a62276bf56 vo_vdpau: document what WRAP_ADD does
This wasn't necessarily clear.
2014-04-08 19:13:15 +02:00
wm4 a748b62709 vo_vdpau: simplify previous vsync timestamp calculation
The strange thing about this code was the shift parameter of the
prev_vs2 function. The parameter is used to handle timestamps before the
last vsync, since the % operator handles negative values incorrectly.
Most callers set shift to 0, and _usually_ pass a timestamp after the
last vsync. One caller sets it to 16, and can pass a timestamp before
the last timestamp.

The mystery is why prev_vs2 doesn't just compensate for the % operator
semantics in the most simple way: if the result of the operator is
negative, add the divisor to it. Instead, it adds a huge value to it
(how huge is influenced by shift). If shift is 0, the result of the
function will not be aligned to vsyncs.

I have no idea why it was written in this way. Were there concerns about
certain numeric overflows that could happen in the calculations? But I
can't think of any (the difference between ts and vc->recent_vsync_time
is usually not that huge). Or is there something more clever about it,
which is important for the timing code? I can't think of anything
either.

So scrap it and simplify it.
2014-04-08 19:02:57 +02:00
wm4 929793be7f vo_vdpau: simplify time management and make it more robust
vo_vdpau used a somewhat complicated and fragile mechanism to convert
the vdpau time to internal mpv time. This was fragile as in it couldn't
deal well with Mesa's (apparently) random timestamps, which can change
the base offset in multiple situations. It can happen when moving the
mpv window to a different screen, and somehow it also happens when
pausing the player.

It seems this mechanism to synchronize the vdpau time is not actually
needed. There are only 2 places where sync_vdptime() is used (i.e.
returning the current vdpau time interpolated by system time).

The first call is for determining the PTS used to queue a frame. This
also uses convert_to_vdptime(). It's easily replaced by querying the
time directly, and adding the wait time to it (rel_pts_ns in the patch).

The second call is pretty odd: it updates the vdpau time a second time
in the same function. From what I can see, this can matter only if
update_presentation_queue_status() is very slow. I'm not sure what to
make out of this, because the call merely queries the presentation
queue. Just assume it isn't slow, and that we don't have to update the
time.

Another potential issue with this is that we call VdpPresentationQueueGetTime()
every frame now, instead of every 5 seconds and interpolating the other
calls via system time. More over, this is per video frame (which can be
portantially dropped, and not per actually displayed frame. Assume this
doesn't matter.

This simplifies the code, and should make it more robust on Mesa. But
note that what Mesa does is obviously insane - this is one situation
where you really need a stable time source. There are still plenty of
race condition windows where things can go wrong, although this commit
should drastically reduce the possibility of this.

In my tests, everything worked well. But I have no access to a Mesa
system with vdpau, so it needs testing by others.

See github issues #520, #694, #695.
2014-04-07 18:37:12 +02:00
wm4 6f8c5d1f6d lua: add basic mpv_observe_property support
Undocumented and only the most basic functionality for now.
2014-04-06 03:22:49 +02:00
wm4 49d1b42f70 client API: add a way to notify clients of property changes
This turned out ridiculously complex. I think it will have to be
simplified some day. Main reason for the complexity are:
- filtering properties by forcing clients to observe individual
  properties explicitly
  (to avoid spamming clients with changes they don't want)
- optional retrieval of property value with the notification
  (the basic idea was that this is more user friendly)
- allowing to the client to specify a format in which the value
  should be retrieved
  (because if a property changes its type, the client API couldn't
  convert it properly, and compatibility would break)

I don't know yet which of these are important, and everything could
change. In particular, the interface and semantics should be adjusted
to reduce the implementation complexity.

While I consider the API complete, there could (and probably will) be
bugs left. Also while the implementation is complete, it's inefficient.
The complexity of the property matching is O(a*b*c) with a clients,
b observed properties, and c properties changing at once. I threw away
an earlier implementation using bitmasks, because it was too unwieldy.
2014-04-06 03:22:49 +02:00
wm4 14eb233da9 client API: use a manual ringbuffer
Remove the use of mp_ring and use a simple array and a bunch of
variables instead. This is way less awkwad.

The change in reserve_reply fixes incorrect tracking of free events.
2014-04-06 03:22:49 +02:00
Stefano Pigozzi aa77f5dd3c gl_lcms: properly expand the cache filename being written
This is needed to preserve the same path used when opening the cache file, and
correctly expands ~ when icc-cache is added to the mpv config file.
2014-04-05 18:13:00 +02:00
Stefano Pigozzi e2bd5139ad build: bump libbluray minimum version
The code uses BD_OVERLAY_HIDE which seems to be available from 0.3.0. Update
the pkg-config query.
2014-04-05 18:12:33 +02:00
wm4 dad50c379c build: add -Wempty-body to compiler flags
Warns against "if(0);" but not "if(0){}" - perfect for our purposes.
2014-04-04 18:35:30 +02:00
Alessandro Ghedini 60e24fa842 demux: move metadata-based replaygain decoding out of af_volume 2014-04-04 18:35:30 +02:00
Alessandro Ghedini da984c3648 af_volume: use replaygain side data 2014-04-04 18:35:29 +02:00
Alessandro Ghedini e7977ec875 af: add replaygain_data field to af_stream and af_instance
Closes #664
2014-04-04 18:35:29 +02:00
Alessandro Ghedini 41ba6dad72 demux: add replaygain_data field to demuxer_t 2014-04-04 18:35:29 +02:00
Alessandro Ghedini cc3d4a2725 build: check if replaygain side data is available
Signed-off-by: wm4 <wm4@nowhere>

old-configure change by wm4.
2014-04-04 18:35:29 +02:00
wm4 d26db0662a vo_vdpau: more debugging output
Might help to debug certain problems with Mesa.
2014-04-03 19:41:09 +02:00
Kevin Mitchell 12e4a31594 remove redundant/outdated line from encodeing.rst:"what works" 2014-04-03 11:13:31 +02:00
wm4 e3e9661a33 lua: give more control over timers
Now they can be paused and resumed.

Since pausing and disabling the timer is essentially the same underlying
operation, we also just provide one method for it.

mp.cancel_timer probably still works, but I'm considering this
deprecated, and it's removed from the manpage. (We didn't have a release
with this function yet, so no formal deprecation.)
2014-04-02 17:09:45 +02:00
wm4 3207366daa lua: add mp.unregister_event() function
Someone requested this... I think.
2014-04-01 00:37:50 +02:00
wm4 84ab860031 DOCS/encoding: make "What does not work yet" a proper RST section 2014-04-01 00:37:50 +02:00
Stefano Pigozzi c2c9cb2bbf gl_lcms: fix build when lcms2 is not available
Was broken in b0ee9334e.
2014-03-31 22:31:24 +02:00
Stefano Pigozzi 12e2290703 vo_corevideo: remove unused variable 2014-03-31 22:10:33 +02:00
Stefano Pigozzi b0ee9334e3 vo_opengl, cocoa: allow to autoselect a color profile
This commit adds support for automatic selection of color profiles based on
the display where mpv is initialized, and automatically changes the color
profile when display is changed or the profile itself is changed from
System Preferences.

@UliZappe was responsible with the testing and implementation of a lot of this
commit, including the original implementation of `cocoa_get_icc_profile_path`
(See #594).

Fixes #594
2014-03-31 22:07:33 +02:00
wm4 956b01ec4e ass_mp: don't use --subcp for --ass-styles
The --ass-styles option is implemented by calling ass_read_styles().
This function can take a codepage (so libass will use iconv to convert
it). This was implemented before our --subcp option was changed, and
this code was not updated. Now libass fails opening iconv, because
--subcp is not always (and not by default) a valid iconv codepage.

Just always pass NULL, which means the file passed to --ass-styles must
be in UTF-8. The --ass-styles option is a fringe option anyway (and will
destroy your subtitles), so having codepage support for it isn't
important at all.
2014-03-31 18:44:44 +02:00
Alessandro Ghedini 01e8a9c9e3 encode_lavc: copy metadata to output file
Closes #684

Signed-off-by: wm4 <wm4@nowhere>

Includes some minor cosmetic changes additional to the original PR.
2014-03-30 20:04:20 +02:00
wm4 239dc2851a command: allow changing filters before video chain initialization
Apparently this is more intuitive.

Somewhat tricky, because of the odd state after loading a file but
before initializing the VO.
2014-03-30 19:59:26 +02:00
wm4 392997fa10 command: change what the metadata property returns
Change the type of the property from a string list (alternating
key/value entries) to a map. Using the client API, this will return
MPV_FORMAT_NODE_MAP, while Lua mp.get_property_native returns a
dictionary-like table.
2014-03-30 19:21:33 +02:00
wm4 3fe6426ae0 command: minor simplification 2014-03-30 18:50:35 +02:00
wm4 01f3e46290 command: fix access to "metadata/list" property
The function tag_property() in command.c passed a key action with empty
path to m_property_read_list. This is normally not valid, because key
actions are supposed to access sub-paths. But it's kind of inconvenient
to check for this case in tag_property(). So make it valid by providing
a m_property_unkey() function, which turns a key access to "" into a
top-level action.
2014-03-30 13:50:23 +02:00
wm4 5cd20c7320 command: add helper function to split property paths
We've just checked whether a sub-path started with "name/", but that
changes behavior whether the property name has a trailing '/' or not.
Using a helper function to split of path components avoids this problem.
2014-03-30 13:41:03 +02:00
wm4 7cc985f3d0 m_property: don't parse empty string as 0
Nice strtol() usage error.
2014-03-30 13:29:56 +02:00
ChrisK2 1a23ca2766 osc: make OSC more responsive when paused
Quick hack to impove situtation until the next major overhaul
comes
2014-03-30 12:24:12 +02:00
wm4 9db08cf53b vf_eq: don't malloc priv struct
There wasn't any reason for this. In fact, it's a memory leak. The
proper priv struct is already allocated vf.c and the option parser.
2014-03-30 10:19:02 +02:00
Sebastian Morr 9b5cbe4bf0 player: add missing "-" to options in workaround notice on A/V desynchronization
While it technically works, using GNU-style options seems cleaner nowadays.

Signed-off-by: wm4 <wm4@nowhere>
2014-03-30 09:17:24 +02:00
wm4 a1afc15786 ao_wasapi: make code shorter
Also fix a format string mistake in a log call using it.

I wonder if this code shouldn't use FormatMessage, but it looks kind
of involved [1], so: no, thanks.

[1] http://support.microsoft.com/kb/256348/en-us
2014-03-30 09:13:52 +02:00
wm4 1bc17a4fb8 stream_bluray: move lookup of AACS error codes into a function
Mostly a cosmetic change. Makes the code a little bit shorter.
2014-03-30 08:57:14 +02:00
xylosper c2bd34cfce stream_bluray: check AACS and BD+ protections
There are two kind of encryption for Blu-ray disc, AACS and BD+,
and both of them can be checked through BLURAY_DISC_INFO object.
This commit makes the bluray and bdnav streams refuse playback
if AACS/BD+ is detected and decryption is failed.
2014-03-30 08:51:43 +02:00
wm4 ae448e198f audio: remove sample rate limit checks
This played the file at a wrong sample rate if the rate was out of
certain bounds.

A comment says this was for the sake of libaf/af_resample.c. This
resampler has been long removed. Our current resampler
(libav/swresample) checks supported sample rates on reconfiguration, and
will error out if a sample rate is not supported. And I think that is
the correct behavior.
2014-03-30 07:34:43 +02:00
wm4 9be2f6b9f8 player: dvdnav: fix start time when entering and leaving menu
Unfortunately, quite a hack, because we have check the nav state
outside of discnav.c.
2014-03-30 07:31:02 +02:00
wm4 8487bb2c54 Merge remote-tracking branch 'mpv/pr/676' 2014-03-30 07:21:25 +02:00
xylosper fb47f2f940 player: rename dvdnav to discnav
Now, navigation works both of DVD and non-BD-J Blu-ray. Therefore,
rename all 'dvdnav' strings which are not DVD specific to 'discnav'
2014-03-30 11:42:49 +09:00
xylosper f2088c73e3 stream_bluray: cosmetic refactoring
Remove unused variables. Declare variables when they are needed.
Adjust brackets for mpv's convention. Clean up too many empty lines.
2014-03-30 11:16:32 +09:00
xylosper a78ac37aa9 stream_bluray: select initial angle only if peeking title succeeded
The angles should be set and queried only if a valid title is
selected. Also, in navigation mode, there are some limitations
which make it impossible to query current title/angle.
2014-03-30 11:13:46 +09:00
xylosper 9946b8d4dd stream_bluray: use more proper error code for stream control
Use STREAM_OK instead of hardcoded value 1.
Handle failure of setting title as an unsupported behaviour rather
than an error.
2014-03-30 10:01:43 +09:00
Stefano Pigozzi bdc936af05 manpage: remove misleading description for --ontop
Pretty much all the VOs and backends support this, so there is no point in
listing only X11 and corevideo support.
2014-03-29 21:22:02 +01:00
xylosper 8cee8279ad stream_bluray: implement navigation interface for Blu-ray stream
This commit introduces new stream protocols: bdnav(and others).
bdnav stream shares lots of codes with original bluray stream, so
it's not separated in different source file.

Major difference from bluray is that bdnav does not support longest
title because there is no way to query that information.
bdnav://menu and bdnav://first correspond to top menu title and
first play title respectively, though they often point same title.

Also, binary position based seeking has been removed, because it
didn't have no point.
2014-03-29 23:31:46 +09:00
wm4 d27613b690 Fix compilation on OSX and win32
Probably.
2014-03-29 03:40:49 +01:00
wm4 bd0618f01f video/out: remove legacy colorspace stuff
Reduce most dependencies on struct mp_csp_details, which was a bad first
attempt at dealing with colorspace stuff. Instead, consistently use
mp_image_params.

Code which retrieves colorspace matrices from csputils.c still uses this
type, though.
2014-03-29 00:25:08 +01:00
wm4 fdeda359f7 mp_image: add missing field to mp_image_params_equals()
This is pretty obscure, so it didn't matter much. It still breaks
switching output levels at runtime, because the video output is not
reinitialized with the new params.
2014-03-28 23:13:41 +01:00
wm4 cd2d4ebf3b af_volume: fix replaygain
This was accidentally broken in commit b72ba3f7. I somehow made the
wild assumption that replaygain adjusted the volume relative to 0%
instead of 100%.

The detach suboption was similarly broken.
2014-03-27 21:15:15 +01:00
wm4 e8d952c807 stream_bluray: remove BD_EVENT_IDLE
This was actually supposed to be removed with pull reuqest #671, but
I accidentally re-added it with a rebasing mistake.

This probably also coincidentally fixes compilation with older
libbluray (issue #672).
2014-03-26 23:34:52 +01:00
xylosper facba0b317 stream_bluray: use bd_get_playlist_info()
Use bd_get_playlist_info() instead of bd_get_title_info(). The
previous implementation couldn't query current playlist and this
made it impossible to call bd_get_playlist_info() which is more
desirable than bd_get_title_info() because, for Blu-rays, playlist
is the unit of playback not title. This commit fixes that.
2014-03-26 21:00:48 +01:00
xylosper 6c947c64a1 stream_bluray: cache current playback informations
The cost of calling bd_get_title_info() is quite expensive and
requires lots of CPU usage. Using BD_EVENT_PLAYLIST and
BD_EVENT_TITLE, it's possible to cache BLURAY_TITLE_INFO object for
current title and BD_EVENT_ANGLE handler caches current angle. In
my test case, with this commit, CPU usage can be saved about 15-20%.
2014-03-26 21:00:48 +01:00
xylosper 4086a09695 stream_bluray: implement event handler for libbluray
This commit brings libbluray's event queue into stream_bluray.

Signed-off-by: wm4 <wm4@nowhere>
2014-03-26 21:00:47 +01:00
wm4 b292ca8702 mf: fix operation with --cache
demux_mf.c explicitly checks for the stream type to check whether images
are opened via pattern (mf://..., i.e. stream_mf.c) or directly. Of
course the stream type is not set to STREAMTYPE_MF if the stream is
wrapped through the cache, so it tried to open the pattern directly as
file, which failed.

Fix this by disabling caching for mf://. The cache doesn't make sense
here anyway, because each file is opened and closed every frame (perhaps
to avoid memory bloat).
2014-03-26 20:42:09 +01:00
wm4 5afef03a70 player: fix unchecked access for chapter metadata
It's possible that MPContext has a chapter list, but the demuxer
doesn't. In this case, accesing the chapter-metadata property would
lead to invalid accesses.

(This fixes the out of bound access, but in theory, the returned data
can still be incorrect, since MPContext chapters don't need to map
directly to demuxer chapters.)
2014-03-26 17:07:53 +01:00
wm4 3ad2a67d3f stream_cdda: print cd text header only if there are any cd text fields 2014-03-26 17:00:29 +01:00
wm4 6fa2c52589 stream_cdda: remove unused stuff
This cd_info_t struct was practically unused. The only thing it did was
storing the track name of the form "Track %d" in a very roundabout way.
Remove it. (It made more sense when there was still CDDB support.)
2014-03-26 16:55:27 +01:00
wm4 32d818f02b stream_cdda: fix track time accuracy
Don't use an integer division to get the time, since that would round on
second boundaries. Also round up the time by sector size. Seeking rounds
down due to alignment constraints, but if we round up the time, we can
make it land on the exact destination sector.

This fixes that the track change code printed the previous track when
seeking by chapter.
2014-03-26 16:51:17 +01:00
wm4 b342b1a30e dvdnav: fix minor memory leak
This was usually handled at the end of the switch statement, so if
something returns from the function before that, the event has to be
freed explicitly.
2014-03-25 15:44:47 +01:00
xylosper b5fe3e9a82 dvdnav: check and update video resolution whenever rendering
Previous implementation updated video resolution when highlight
event was given. However, this may not work if highlight event
is given before video size is queried.
This commit adds checking routine into rendering function, too.
2014-03-25 15:37:14 +01:00
xylosper 448b535d48 dvdnav: make MP_NAV_EVENT_RESET_ALL handled properly
dvdnav.c did not handle event in regular sequence. Usually this
does not make any trouble except around MP_NAV_EVENT_RESET_ALL.
Those events should be handled in regular sequence. If they're
mixed, it can make wrong result.
For instance, MP_NAV_EVENT_HIGHLIGHT right after
MP_NAV_EVENT_RESET_ALL should not be ignored but it might be
because MP_NAV_EVENT_RESET_ALL makes the demuxer reloaded and osd
hidden.
2014-03-25 15:37:14 +01:00
xylosper cb7cf1cfb1 dvdnav: prevent reallocation of fake highlight buffer
Since subsizes were never updated, the bitmap buffer was always
reallocated whenever mp_nav_get_highlight() called.
2014-03-25 22:25:29 +09:00
wm4 d2e4938c78 player: use MP_NOPTS_VALUE as rel_time_to_abs() error value
And consistently use MP_NOPTS_VALUE as error value for the users of this
function. This is better than using -1, especially because negative
values can be valid timestamps.
2014-03-25 02:32:24 +01:00
wm4 6c2cd08aff player: handle chapter range like --start/--end
Instead of comparing the current chapter every time, set the playback
end timestamp to the chapter end. Likewise, don't execute an extra seek
for the start chapter.

Maybe we could also use the timeline facility to restrict playback to
the given chapter range, but this would be strange when using
--chapter=N to start playback at a given chapter. Then you couldn't seek
back, which is possibly not what the user wants.
2014-03-25 02:27:22 +01:00
wm4 c19c777061 player: let chapter_start_time() return MP_NOPTS_VALUE for unknown times 2014-03-25 02:18:12 +01:00
wm4 5cae4a807c player: remove weird separation between no chapters and 0 chapters
For some reason, it mattered whether mpctx->chapters was NULL or not,
even if mpctx->num_chapters was 0. Remove this separation; it serves no
purpose.
2014-03-25 02:10:24 +01:00
wm4 92d7dc9e88 player: remove demuxer chapoter API wrappers
Instead, always use the mpctx->chapters array. Before this commit, this
array was used only for ordered chapters and such, but now it's always
populated if there are chapters.
2014-03-25 02:05:48 +01:00
wm4 2c693a4732 stream: remove old chapter handling code
Stream-level chapters (like DVD etc.) did potentially not have
timestamps for each chapter, so STREAM_CTRL_SEEK_TO_CHAPTER and
STREAM_CTRL_GET_CURRENT_CHAPTER were needed to navigate chapters. We've
switched everything to use timestamps and that seems to work, so we can
simplify the code and remove this old mechanism.
2014-03-25 01:38:18 +01:00
wm4 7bd3f26481 stream_cdda: report track times
Report the time for each chapter (tracks are treated as chapters). This
allows us to get rid of the "old" chapter mechanism, and also behaves
better with the frontend.

This makes assumptions about the audio formats, but that format is
hardcoded anyway in the rawaudio demuxer defaults (and always was).
2014-03-25 01:24:27 +01:00
wm4 7f39b4655e vo_opengl: runtime icc profile switching
The changes in vo_opengl.c are merely for adding the icc options to the
set of options than can be changed with the vo_cmdline command.
2014-03-24 23:33:10 +01:00
xylosper 99044308b5 stream_bluray: fix for significant memory leak
It's obvious but, since STREAM_CTRL_GET_TIME_LENGTH is called
frequently, the amount of leaked memory here is quite big.
2014-03-24 21:50:04 +09:00
wm4 f4fe22266d travis-ci: update Libav release
Libav 10 was released, so we can enable testing the stable Libav version
again.

FFmpeg 2.2 was also released, but since we still support 2.1.4, we stick
with the older version. This is better for testing.
2014-03-24 00:12:48 +01:00
wm4 bb1b0a9f42 player: remove confusing argc/argv adjustment
It's better if argc/argv always mean the same thing.
2014-03-23 21:46:29 +01:00
wm4 ba62e01cd3 x11_common: fix some problems with window dragging
There were some bad interactions with the OSC.

For one, dragging the OSC bar, and then moving the mouse outside of the
OSC (while mouse button still held) would suddenly initiate window
dragging. This was because win_drag_button1_down was not reset when
sending a normal mouse event, which means the window dragging code can
become active even after we've basically decided that the preceding
click didn't initiate window dragging.

Second, dragging the window and clicking on the OSC bar after that did
nothing. This was because no mouse button up event was sent to the core,
even though a mouse down event was sent. So make sure the key state is
erased with MP_INPUT_RELEASE_ALL.
2014-03-22 02:12:20 +01:00
wm4 f705bbb2d5 manpage: osc: document some recent additions 2014-03-20 22:49:31 +01:00
wm4 edf0dda2e4 manpage: clarify what to pass to --hwdec-codecs option 2014-03-20 22:49:09 +01:00
wm4 9be93d6b60 vdpau: remove pointer indirection for a field
There's no reason to. This is basically a cosmetic change.
2014-03-19 19:57:08 +01:00
wm4 917650fefa vdpau: fix decoder init return value 2014-03-19 19:35:25 +01:00
wm4 19f101db68 x11: implement window dragging by grabbing
We don't check whether the WM supports _NET_WM_MOVERESIZE_MOVE, but
if it doesn't, nothing bad happens. There might be a race condition
when pressing a button, and then moving the mouse and releasing the
button at the same time; then the WM might get the message to initiate
moving the window after the mouse button has been released, in which
case the result will probably be annoying. This could possibly be fixed
by sending _NET_WM_MOVERESIZE_CANCEL on button release, but on the
other hand, we probably won't receive a button release event in this
situation, so ignore this problem.

The dragging is initiated only when moving the mouse pointer after a
click in order to reduce annoying behavior when the user is e.g.
doubleclicking.

Closes #608.
2014-03-18 20:43:45 +01:00
wm4 4751fe408b manpage: mark disc-title as writeable 2014-03-18 15:26:41 +01:00
xylosper 56b0762256 stream_bluray: fix for zero-based title index for Blu-ray
The title for stream_bluray DID start from 1 and I misunderstood
that it started from 0 because mpv accepted bd://0 as a proper
argument. In fact, 0 title was an alias for the longest title but
it was not handled as a special value. This commit fixes these
behavious. 'disc-title' property for Blu-ray now starts from 0 and
the default title can be specified by 'longest' title just like
stream_dvdnav: bd://longest. Of course, 'longest' can be omitted.
2014-03-18 15:24:53 +01:00
xylosper d2e35b2faa command: make 'disc-title' property writable
This commit makes 'disc-title' property writable using
STREAM_CTRL_SET_CURRENT_TITLE. This commit also contains
implementation of STREAM_CTRL_SET_CURRENT_TITLE for stream_bluray.
Currently, 'disc-title' is writable only for stream_dvdnav and
stream_bluray and stream_dvd is not supported.
2014-03-18 15:24:45 +01:00
wm4 5c2b4d9356 changes.rst: add dvd://1 -> dvd://0 change
Done two commits ago.
2014-03-17 18:32:16 +01:00
wm4 2a20a5b0c9 options: fix allowed DVD start title 2014-03-17 18:30:43 +01:00
xylosper f811d43061 stream_dvd/stream_dvdnav: make disc-title for DVDs start from 0
This commit makes 'disc-title' properties for DVDs start from 0.
There was an inconsistency around 'disc-title' property between
DVDs (from 1) and Blu-rays (from 0). This fixes #648.

Signed-off-by: wm4 <wm4@nowhere>
2014-03-17 18:29:37 +01:00
James Ross-Gowan 065c301739 build: only check for Linux fstatfs on Linux
This check incorrectly passed on Cygwin. While Cygwin has the
statfs.f_type field, it contains the volume's FileSystemAttributes,
which aren't useful for detecting network mounts.
2014-03-17 18:28:29 +01:00
wm4 791068d255 osc: add enable/disable message, and map DEL to disabling the OSC
"enable-osc" will make the OSC appear at any time (although it'll
quickly disappear again if the mouse is not inside the OSC). "disable-
osc" will make it disappear permanently.

Also, if the OSC is visible, force remap the DEL key to make the OSC
disappear.
2014-03-17 18:27:44 +01:00
wm4 780f172a8a lua: rename mp.register_script_command() to mp.register_script_message()
More consistent naming.
2014-03-17 18:27:25 +01:00
wm4 637664d95a command, lua: change script_message semantics
Change script_message to broadcast the message to all clients. Add a new
script_message_to command, which does what the old script_message
command did.

This is intended as simplification, although it might lead to chaos too.
2014-03-17 18:26:56 +01:00
wm4 422af1b948 vaapi: solve potential problem with ambiguous image formats
VAAPI has some ambiguous image formats, like VA_FOURCC_I420,
VA_FOURCC_IYUV, VA_FOURCC_YV12 (the latter exactly the same as the first
two, just with swapped planes). There is potentially a problem when one
specific VAAPI format was picked, and converting it to a mpv format and
back to a VAAPI FourCC would result in a numerically different format
(even if it's actually the same). Then it could e.g. happen that
functions like va_surface_upload() reallocate the underlying VAImage,
which would be inefficient. Change the code so that this can't happen.

(Probably not a problem in practice with the current VAAPI usage.)
2014-03-17 18:23:24 +01:00
wm4 123c34a12e vaapi: simplify
Merge va_surface_priv into va_surface.
2014-03-17 18:22:48 +01:00
wm4 49d13f76ca vaapi: make struct va_surface private
It's not really needed to be public. Other code can just use mp_image.
The only disadvantage is that the other code needs to call an accessor
to get the VASurfaceID.
2014-03-17 18:22:35 +01:00
wm4 31fc5e8563 vaapi: replace image pool implementation with mp_image_pool
Although I at first thought it would be better to have a separate
implementation for hwaccels because the difference to software images
are too large, it turns out you can actually save some code with it.

Note that the old implementation had a small memory management bug. This
got painted over in commit 269c1e1, but is hereby solved properly.

Also note that I couldn't test vf_vavpp.c (due to lack of hardware), and
I hope I didn't accidentally break it.
2014-03-17 18:22:25 +01:00
wm4 88aa3b8c98 mp_image_pool: add features needed for use with hwaccel
The plan is to get rid of the custom VAAPI and possibly VDPAU surface
allocators.

Add custom surface allocation, because hwaccel surfaces are allocated
completely differently from software surfaces.

Add optional LRU allocation, which is (probably) helpful for hwaccel,
but (probably) less optimal for software surfaces.

mp_image_pool_get_no_alloc() is specifically for VAAPI, which can't
allocate new decoder surfaces after decoder init.
2014-03-17 18:21:29 +01:00
wm4 6389507314 vdpau: remove legacy pixel formats
They were used by ancient libavcodec versions. This also removes the
need to distinguish vdpau image formats at all (since there is only
one), and some code can be simplified.
2014-03-17 18:21:11 +01:00
wm4 4e70335c2f vdpau: remove unused type 2014-03-17 18:20:44 +01:00
wm4 5ed24862c0 video: change image format from unsigned int to int in some places
Image formats used to be FourCCs, so unsigned int was better. But now
it's annoying and the only difference is that unsigned int is more to
type than int.
2014-03-17 18:19:57 +01:00
wm4 6aa2d1f120 img_format: AV_PIX_FMT_FLAG_ALPHA is always available
We no more support ancient libavutil versions.
2014-03-17 18:19:28 +01:00
wm4 8fbf0300d8 vd_lavc: reinit hwdec on profile changes
Needed in theory. I don't know if there are even any real-world files
which change the profile mid-stream.
2014-03-17 18:19:03 +01:00
wm4 3db3653227 video: fix FFmpeg or Libav being a special snowflake 2014-03-16 16:23:12 +01:00
wm4 2963d84a9b vd_lavc: remove unused field 2014-03-16 15:05:46 +01:00
wm4 269c1e1f41 vd_lavc: reduce hardware decoder mid-stream reinitializations
Instead of doing it on every seek (libavcodec calls get_format on every
seek), reinitialize the decoder only if the video resolution changes.

Note that this may be relatively naive, since we e.g. (or: in
particular) don't check for profile changes. But it's not worse than the
state before the get_format change, and at least it paints over the
current vaapi breakage (issue #646).
2014-03-16 14:54:21 +01:00
wm4 61f3b188a5 manpage: remove author field
There's already a more detailed "AUTHORS" section.

Closes #647.
2014-03-16 13:20:30 +01:00
wm4 113ec0aba1 af_lavcac3enc: use new AVFrame API 2014-03-16 13:19:29 +01:00
wm4 05e3a5a2b4 ao_lavc: set AVFrame.format
Seems kind of wrong that this wasn't done, although it didn't have any
bad consequences.
2014-03-16 13:19:29 +01:00
wm4 62c88a52c4 encode: use new AVFrame API 2014-03-16 13:19:29 +01:00
wm4 62ab6a91bd image_writer: use new AVFrame API 2014-03-16 13:19:29 +01:00
wm4 f2374f4e4b ad_lavc: use new AVFrame API
Set refcounted_frames, because in some versions of libavcodec mixing the
new AVFrame API and non-refcounted decoding could cause memory
corruption. Likewise, it's probably still required to unref a frame
before calling the decoder.
2014-03-16 13:19:29 +01:00
wm4 8e6bd496ca vf_delogo: remove internal implementation
See previous commit.
2014-03-16 13:19:29 +01:00
wm4 48e32e13fe vf_hqdn3d: remove internal implementation
See previous commit.
2014-03-16 13:19:29 +01:00
wm4 2520249b16 vf_yadif: remove internal implementation
See previous commit.
2014-03-16 13:19:29 +01:00
wm4 04a74ea3e2 vf_unsharp: remove internal implementation
See previous commit.
2014-03-16 13:19:29 +01:00
wm4 b2ec5c4b66 vf_gradfun: remove internal implementation
This follows the (only slowly progressing) plan to replace all internal
video filters with libavfilter.

All what's left in vf_gradfun.c is the weird wrapper around vf_lavfi.c.
2014-03-16 13:19:29 +01:00
wm4 98cd2c4122 build: simplify libavfilter configure checks
This is all not needed anymore. In particular, remove all configure
switches except --enable-libavfilter.
2014-03-16 13:19:29 +01:00
wm4 c9d328319e demux: use av_packet_ref()
av_copy_packet() was FFmpeg specific, av_packet_ref() is now available
on all supported libavcodec releases.
2014-03-16 13:19:28 +01:00
wm4 64c01a814c Remove some more unneeded version checks
All of these check against things that happened before the latest
supported FFmpeg/Libav release.
2014-03-16 13:19:28 +01:00
wm4 5506c8d0f6 ad_lavc: remove deprecated downmixing by channel count
Downmixing by channel layout now hopefully works with all supported
libavcodec versions.
2014-03-16 13:19:28 +01:00
wm4 822e040ddb ao_dsound: remove duplicated code 2014-03-16 13:19:28 +01:00
wm4 c7e620df96 af_lavrresample: remove avresample_set_channel_mapping() fallbacks
This function is now always available.

Also remove includes of reorder_ch.h from some AOs (these are just old
relicts).
2014-03-16 13:19:28 +01:00
wm4 bb0290145a sub: remove old MPlayer DVD sub decoder
The DVD sub decoder in Libav 9 was broken/incomplete, so we kept the
MPlayer decoder around. Now it's not needed anymore.
2014-03-16 13:19:28 +01:00
wm4 3ec7f528c4 vd_lavc: remove compatibility crap
All this code was needed for compatibility with very old libavcodec
versions only (such as Libav 9).

Includes some now-possible simplifications too.
2014-03-16 13:19:19 +01:00
wm4 75b185dfc5 travis-ci: update ffmpeg stable tarball 2014-03-16 02:57:41 +01:00
wm4 f50455507e build: drop support for Libav 9
I have no tolerance for this garbage anymore. There are tons of issues
with it (see e.g. previous commit), and there is no reason to use it
either. Use Libav git, or Libav 10 when it's released.

This also drops support for earlier FFmpeg release, which have exactly
the same issues as Libav 9. FFmpeg 2.1.4 is still supported, because
it's the latest release, and is reasonably recent. (Although this will
probably also be dropped as soon as FFmpeg 2.2 is released.)

Assumed version table (lots of nonsensical numbers):

        FFmpeg 2.1.4    FFmpeg (n2.2-rc2)   Libav (v10_beta2)

lavu    52.48.101       52.66.100           53.3.0
lavc    55.39.101       55.52.102           55.34.1
lavf    55.19.104       55.33.100           55.12.0
lsws    2.5.101         2.5.101             2.1.2
lavi    3.90.100        4.2.100             4.2.0
lswr    0.17.104        0.18.100            -
lavr    1.1.0           1.2.0               1.1.0

libpostproc and libavdevice are not interesting.

Following this commit, code needed just to support old Libav versions
will start to be removed.
2014-03-16 02:45:58 +01:00
wm4 ba160f5c84 vd_lavc: ridiculous workaround for Libav 9 compatibility
This "sometimes" crashed when seeking. The fault apparently lies in
libavcodec: the decoder returns an unreferenced frame! This is
completely insane, but somehow I'm apparently still expected to
work this around. As a reaction, I will drop Libav 9 support in the
next commit. (While this commit will go into release/0.3.)
2014-03-16 01:38:13 +01:00
wm4 86689f7bf2 demux_libass: change how external ASS subtitles are loaded
Instead of parsing the ASS file in demux_libass.c and trying to pass the
ASS_Track to the subtitle renderer, just read all file data in
demux_libass.c, and let the subtitle renderer pass the file contents to
ass_process_codec_private(). (This happens to parse full files too.)

Makes the code simpler, though it also relies harder on the (messy)
probe logic in demux_libass.c.
2014-03-15 22:17:51 +01:00
wm4 f6b4f60264 command: rename dvd- properties to disc-
Since these are not DVD-only, but can also be used with BDs.
2014-03-15 20:53:59 +01:00
wm4 e09a8ec4fa DOCS/coding-style: add another requirement for commit messages 2014-03-15 18:44:32 +01:00
wm4 5dde276018 options: fix off-by-1 error in option help output 2014-03-15 18:42:10 +01:00
wm4 8a75b19cd4 command: prefix DVD title properties with "dvd-"
They're strictly DVD-only, so it's better to mark them as such. This
also documentes the "title" (now renamed to "dvd-title") property.

This also avoids collision with the --title option. (Technically, there
was no problem. But it might be confusing for users, since we have a
policy of naming properties and options the same if they refer to the
same underlying functionality.)
2014-03-15 18:42:10 +01:00
xylosper 746666f096 command: add new property 'title'
This commit adds new property 'title' which indicates current
playing title of disc. This property is useful when using a stream
whose title can be changed during playback, e.g., dvdnav.
2014-03-15 18:42:10 +01:00
xylosper 9e4014d876 stream_dvdnav: implement STREAM_CTRL_GET_NUM_TITLES for dvdnav
This commit provides impelmentation of STREAM_CTRL_GET_NUM_TITLES
for dvdnav stream. Other streams for DVD or Blu-ray are already
provide STREAM_CTRL_GET_NUM_TITLES.
2014-03-15 18:42:07 +01:00
wm4 16596d025a ao: print (estimated) device buffer size on init in verbose mode 2014-03-14 22:37:46 +01:00
wm4 c473635f66 af_volume: don't print missing replaygain tags as error
There's no reason to. Audio files often lack them.
2014-03-14 22:37:46 +01:00
wm4 dc0f2308d1 af_volume: add detach option
Maybe this should be default. On the other hand, this filter does
something even if the volume is neutral: it clips samples against the
allowed range, should the decoder or a previous filter output garbage.
2014-03-14 22:37:46 +01:00
wm4 b72ba3f744 af_volume: separate softvol volume control from replaygain level
Currently, both replaygain adjustment and user volume control (if
softvol is enabled) share the same variable. Sharing the variable would
cause especially if --volume is used; then the replaygain volume would
always be overwritten.

Now both gain values are simple added right before doing filtering.
2014-03-14 22:37:46 +01:00
wm4 66bfb17979 manpage: af: minor syntax improvements 2014-03-14 22:37:45 +01:00
wm4 f8f69cdffe af_volume: remove double-negated suboption
You had to use "no-replaygain-noclip" to set this option. Rename it, so
that only one negation is needed.
2014-03-14 22:37:45 +01:00
Ryan Goulden 3160182a7b build: fix unicode handling of the version string
Don't pass unicode types to waf ENV.
As per https://code.google.com/p/waf/issues/detail?id=1420
This directly fixes the "CFVersion" key in the .app bundle plist.
2014-03-14 22:10:22 +01:00
James Ross-Gowan 5e698a7b39 player/main: Fix Cygwin build
Xlib.h (included from x11_common.h) defines a macro 'Status' as 'int'.
This messed up a bunch of definitions in windows.h and broke the build
in Cygwin. Including windows.h first seems to solve the problem.

This commit also removes the definition of an unused flag.
2014-03-13 14:36:20 +01:00
xylosper d391e2d204 command: fix wrong condition & remove redundant stream type checking 2014-03-13 14:36:20 +01:00
xylosper 2f72eecd89 command: set 'media-title' property for bluray disc with meta-data 2014-03-13 14:36:20 +01:00
Alessandro Ghedini d80dc885c6 af_volume: add support for replaygain pre-amp and clipping prevention 2014-03-13 14:36:20 +01:00
Alessandro Ghedini 3f0139e5db af_volume: add replaygain support
This adds the options replaygain-track and replaygain-album. If either is set,
the replaygain track or album gain will be automatically read from the track
metadata and the volume adjusted accordingly.

This only supports reading REPLAYGAIN_(TRACK|ALBUM)_GAIN tags. Other formats
like LAME's info header would probably require support from libav.
2014-03-13 14:36:20 +01:00
Alessandro Ghedini 04e14ec8f6 af: add metadata field to af_stream and af_instance
This allows to propagate metadata information to audio filters.

Closes #632
2014-03-13 14:36:20 +01:00
wm4 7918034e15 DOCS/coding-style: add an example and another rule 2014-03-13 00:42:50 +01:00
wm4 3bc78a84cd af_lavfi: beat it into working with Libav
The main incompatibility was that Libav didn't have av_opt_set_int_list.
But since that function is excessively ugly and idiotic (look how it
handles types), I'm not missing it much. Use an aformat filter instead
to handle the functionality that was indirectly provided by it. This is
similar to how vf_lavfi works.

The other incompatibility was channel handling. Libav consistently uses
channel layouts only, why ffmpeg still requires messing with channel
counts to some degree. Get rid of most channel count uses (and hope
channel layouts are "exact" enough). Only in one case FFmpeg fails with
a runtime check if we feed it AVFrames with channel count unset.

Another issue were AVFrame accessor functions. FFmpeg introduced these
for ABI compatibility with Libav. I refuse to use them, and it's not my
problem if FFmpeg doesn't manage to provide a stable ABI for fields
provided both by FFmpeg and Libav.
2014-03-13 00:29:17 +01:00
wm4 1a86322dca README: split list of dependencies
And make some additions.

I'm not really sure why we list dependencies that are not ours, but that
of external libraries. Still might be useful, though.
2014-03-12 17:02:57 +01:00
wm4 4ded6204a1 DOCS/tech-overview: DOCS/OUTDATED-tech/ was deleted 2014-03-12 16:38:25 +01:00
wm4 d1fef81e8c DOCS: add coding style
I've tried not to be too detailed (because it's not a reference, just
some guidelines), but it still got relatively long. Also contains
conventions for sending patches.
2014-03-12 16:38:20 +01:00
James Ross-Gowan 3bcb4b8a9e w32_common: prevent MOUSE_BTN0 sticking after drag
The window doesn't recieve a WM_LBUTTONUP message after it's dragged,
probably because it's swallowed by the modal loop. To stop the button
from sticking, release it manually when the drag is complete.
2014-03-12 14:51:25 +01:00
James Ross-Gowan 6402b9dc38 w32_common: capture mouse input
Mouse buttons can get stuck down if the button is pressed inside the
video window and released outside. Avoid this by capturing mouse input
when a button is pressed.
2014-03-12 14:51:07 +01:00
wm4 b05803c2e1 build: make check for BSD fstatfs() a bit more strict
Linux also has fstatfs(), and the test relied on certain system include
files being available on BSD, but not on Linux. It would break if Linux
added the missing includes for some reason.

Make it a bit stricter, and check for the struct statfs field the code
needs.
2014-03-12 00:49:16 +01:00
Philip Sequeira ac4b9a47ce stream_file: network file system detection for Linux
Addresses issue #558 on Linux systems.

Signed-off-by: wm4 <wm4@nowhere>
2014-03-12 00:46:18 +01:00
wm4 14c1816c71 build: automagically extract client library version
This reads MPV_CLIENT_API_VERSION from the source header, and turns it
into a 3 part version number.

E.g. if MPV_CLIENT_API_VERSION were 0x12abcdef, this would result in
"18.171.773615" (8 bits, 8 bits, 16 bits).

We'll see if this is actually useful, or if it's too clever.
2014-03-12 00:40:55 +01:00
wm4 40855d6c12 build: rename --enable-shared switch
Rename it to --enable-libmpv-shared. The option name didn't really
tell much. When we add the possibility to create a static library,
it would also be bad if that were named --enable-static (because it
would sound like it does what --static-build does).
2014-03-11 23:56:19 +01:00
Alessandro Ghedini 8737ca9582 build: fix version in mpv.pc 2014-03-11 23:30:50 +01:00
Diogo Franco (Kovensky) a0347e0651 ao_wasapi: Use the character set conversion functions from io.h
...rather than rolling out our own. The only possible advantage is that
the "custom" ones didn't use talloc.
2014-03-11 16:37:22 -03:00
Diogo Franco (Kovensky) c5012946ee ao_wasapi: Implement AOCONTROL_UPDATE_STREAM_TITLE 2014-03-11 16:37:22 -03:00
Diogo Franco (Kovensky) f8bdada77f ao_wasapi: Implement per-application mixing
The volume controls in mpv now affect the session's volume (the
application's volume in the mixer). Since we do not request a
non-persistent session, the volume and mute status persist across mpv
invocations and system reboots.

In exclusive mode, WASAPI doesn't have access to a mixer so the endpoint
(sound card)'s master volume is modified instead. Since by definition
mpv is the only thing outputting audio in exclusive mode, this causes no
conflict, and ao_wasapi restores the last user-set volume when it's
uninitialized.
2014-03-11 16:37:21 -03:00
Diogo Franco (Kovensky) f3e9b94622 ao_wasapi: Move non-critical code outside of the event thread
Due to the COM Single-Threaded Apartment model, the thread owning the
objects will still do all the actual method calls (in the form of
message dispatches), but at least this will be COM's problem rather than
having to set up several handles and adding extra code to the event
thread.

Since the event thread still needs to own the WASAPI handles to avoid
waiting on another thread to dispatch the messages, the init and uninit
code still has to run in the thread.

This also removes a broken drain implementation and removes unused
headers from each of the files split from the original ao_wasapi.c.
2014-03-11 16:37:02 -03:00
Diogo Franco (Kovensky) 58011810e5 ao_wasapi: Split into 2 files
ao_wasapi.c was almost entirely init code mixed with option code and
occasionally actual audio handling code. Split most things to
ao_wasapi_utils.c and keep the audio handling code in ao_wasapi.c.
2014-03-11 16:37:02 -03:00
Diogo Franco (Kovensky) f3514fb4bd ao_wasapi: Initial conversion to the new pull model
Gets rid of the internal ring buffer and get_buffer. Corrects an
implementation error in thread_reset.

There is still a possible race condition on reset, and a few refactors
left to do. If feasible, the thread that handles everything
WASAPI-related will be made to only handle feed events.
2014-03-11 16:37:01 -03:00
Alessandro Ghedini 499a67582a build: install client.h under mpv/ instead of libmpv/ 2014-03-11 19:15:42 +01:00
Alessandro Ghedini dfc57e6d32 libmpv: add pkg-config file 2014-03-11 19:15:42 +01:00
Diogo Franco e00dcfb0f5 options.rst: correct broken URL 2014-03-11 14:09:19 -02:00
wm4 d7dfd2cca3 Revert "player: simplify audio reset when seeking"
This reverts commit 75dd3ec210.

This broke seeking with ordered chapters in some situations. While
the reverted commit was perfectly fine for playback of normal files,
it overlooked that in the ordered chapters case switching segments
actually reinitialized the audio chain completely, including the
decoder. And decoders still read packets on initialization. We can
restore the original commit as soon as decoders stop doing this.
2014-03-10 23:47:31 +01:00
wm4 ccce58d6d6 video: initialize hw decoder in get_format
Apparently the "right" place to initialize the hardware decoder is in
the libavcodec get_format callback.

This doesn't change vda.c and vdpau_old.c, because I don't have OSX, and
vdpau_old.c is probably going to be removed soon (if Libav ever manages
to release Libav 10). So for now the init_decoder callback added with
this commit is optional.

This also means vdpau.c and vaapi.c don't have to manage and check the
image parameters anymore.

This change is probably needed for when libavcodec VDA supports gets a
new iteration of its API.
2014-03-10 22:56:26 +01:00
Niklas Haas fbddbce01d vo_opengl: Correct and clarify gl_check_features
This updates the logic for the new, somewhat unified behavior of SRGB
and 3DLUT since 34bf9be (not that it was particularly correct even that
change) and checks for the presence of corresponding extensions only in
the cases in which they're needed.
2014-03-10 22:56:26 +01:00
Niklas Haas 6a833797db vo_opengl: Simplify and clarify color correction code
This commit:

- Changes some of the #define and variable names for clarification and
  adds comments where appropriate.
- Unifies :srgb and :icc-profile, making them fit into the same step of
  the decoding process and removing the weird interactions between both
  of them.
- Makes :icc-profile take precedence over :srgb (to significantly reduce
  the number of confusing and useless special cases)
- Moves BT709 decompanding (approximate or actual) to the shader in all
  cases, making it happen before upscaling (instead of the old 0.45
  gamma function). This is the simpler and more proper way to do it.
- Enables the approx gamma function to work with :srgb as well due to
  this (since they now share the gamma expansion code).
- Renames :icc-approx-gamma to :approx-gamma since it is no longer tied
  to the ICC options or LittleCMS.
- Uses gamma 2.4 as input space for the actual 3DLUT, this is now a
  pretty arbitrary factor but I picked 2.4 mainly because a higher pure
  power value here seems to produce visually better results with wide
  gamut profiles, rather then the previous 1.95 or BT.709.
- Adds the input gamma space to the 3dlut cache header in case we change
  it more in the future, or even make it user customizable (though I
  don't see why the latter would really be necessary).
- Fixes the OSD's gamma when using :srgb, which was previously still
  using the old (0.45) approximation in all cases.
- Updates documentation on :srgb, it was still mentioning the old
  behavior from circa a year ago.

This commit should serve to both open up and make the CMS/shader code much
more accessible and less confusing/error-prone and simultaneously also
improve the performance of 3DLUTs with wide gamut color spaces.

I would liked to have made it more modular but almost all of these
changes are interdependent, save for the documentation updates.

Note: Right now, the "3DLUT takes precedence over SRGB" logic is just
coded into gl_lcms.c's compile_shaders function. Ideally, this should be
done earlier, when parsing the options (by overriding the actual
opts.srgb flag) and output a warning to the user.

Note: I'm not sure how well this works together with real-world
subtitles that may need to be color corrected as well. I'm not sure
whether :approx-gamma needs to apply to subtitles as well. I'll need to
test this on proper files later.

Note: As of now, linear light scaling is still intrinsically tied to
either :srgb or :icc-profile. It would be thinkable to have this as an
extra option, :linear-scaling or similar, that could be used with or
without the two color management options.
2014-03-10 22:56:25 +01:00
Niklas Haas 76554ca62a vo_opengl: Use bt709_expand on OSD for :srgb
This affects the OSD only when :srgb is enabled, this still used the old
gamma approximation of 2.22 previously.
2014-03-10 22:56:25 +01:00
wm4 7221d96ba3 ao_sdl: make sure our buffer is always larger than what SDL requests
Assume obtained.samples contains the number of samples the SDL audio
callback will request at once. Then make sure ao.c will set the buffer
size at least to 3 times that value (or more).

Might help with bad SDL audio backends like ESD, which supposedly uses a
500ms buffer.
2014-03-10 22:56:23 +01:00
wm4 b0b0e69570 audio: don't downmix when doing digital passthrough
This obviously doesn't work. It wasn't much of a problem in the past
because most passthrough formats use 2 channels, which is also the
default for downmix.
2014-03-10 02:14:51 +01:00
wm4 249789c256 audio: make --channels option always force the output layout
Use the --channels value directly on the AO, instead of doing it only in
the --channels=stereo (default) case and if the decoder output is not
stereo.
2014-03-10 02:09:18 +01:00
wm4 378a15564c m_option: fix handling of empty channel layouts
Even if a channel map option signaled that empty layouts are accepted,
the option parser never actually accepted them.
2014-03-10 01:48:18 +01:00
wm4 b3f9d3750b ao_alsa: reduce default buffer size
In general, we don't need to have a large hw audio buffer size anymore,
because we can quickly fill it from the soft buffer.

Note that this probably doesn't change much anyway. On my system (dmix
enabled), the buffer size is only 170ms, and ALSA won't give more. Even
when using a hardware device the buffer size seems to be limited to
341ms.
2014-03-10 01:28:39 +01:00
wm4 2e10f536db ao_alsa: fix return value for volume operations with spdif
This AO pretended to support volume operations when in spdif passthrough
mode, but actually did nothing. This is wrong: at least the GET
operations must write their argument. Signal that volume is unsupported
instead.

This was probably a hack to prevent insertion of volume filters or so,
but it didn't work anyway, while recovering after failed volume filter
insertion does work, so this is not needed at all.
2014-03-10 01:18:10 +01:00
wm4 d842b017e4 audio/out: reduce amount of audio buffering
Since the addition of the AO feed thread, 200ms of latency (MIN_BUFFER)
was added to all push-based AOs. This is not so nice, because even AOs
with relatively small buffering (e.g. ao_alsa on my system with ~170ms
of buffer size), the additional latency becomes noticable when e.g.
toggling mute with softvol.

Fix this by trying to keep not only 200ms minimum buffer, but also 200ms
maximum buffer. In other words, never buffer beyond 200ms in total. Do
this by estimating the AO's buffer fill status using get_space and the
initially known AO buffer size (the get_space return value on
initialization, before any audio was played). We limit the maximum
amount of data written to the soft buffer so that soft buffer size and
audio buffer size equal to 200ms (MIN_BUFFER).

To avoid weird problems with weird AOs, we buffer beyond MIN_BUFFER if
the AO's get_space requests more data than that, and as long as the soft
buffer is large enough.

Note that this is just a hack to improve the latency. When the audio
chain gains the ability to refilter data, this won't be needed anymore,
and instead we can introduce some sort of buffer replacement function in
order to update data in the soft buffer.
2014-03-10 01:13:40 +01:00
wm4 4c19c71b85 ao_alsa: remove unneeded initializations
priv is 0-initialized, can_pause is always overwritten later.
2014-03-09 22:11:08 +01:00
foo86 d350181aaf ao_alsa: check ALSA PCM state before pause and resume
It is possible to have ao->reset() called between ao->pause() and
ao->resume() when seeking during the pause. If the underlying PCM
supports pausing, resuming an already reset PCM will produce an error.
Avoid that by explicitly checking PCM state before calling
snd_pcm_pause().

Signed-off-by: wm4 <wm4@nowhere>
2014-03-09 22:06:06 +01:00
Diogo Franco (Kovensky) 5c9c81efcc ao_wasapi: Use double math for QueryPerformanceCounter correction
The uint64_t math would cause overflow at long enough system uptimes
(...such as 3 days), and any precision error given by the double math will
be under one milisecond.
2014-03-09 17:56:29 -03:00
Hans-Kristian Arntzen a84e25eb59 ao_rsound: pass correct data type to rsd_set_param()
Signed-off-by: wm4 <wm4@nowhere>
2014-03-09 19:11:49 +01:00
Hans-Kristian Arntzen baa6d9491c build: fix compilation with MinGW-w64
References to WinMM/OLE/UUID were missing.

Signed-off-by: wm4 <wm4@nowhere>
2014-03-09 19:11:17 +01:00
wm4 346c687d5a ao_sdl: use new pull API helpers
One strange issue is that we apparently can't stop the audio API on
audio reset (ao_driver.reset). We could use SDL_PauseAudio, but that
doesn't specify whether remaining audio is dropped. We also could use
SDL_LockAudio, but holding that over a long time will probably be bad,
and it probably doesn't drop audio. This means we simply play silence
after a reset, instead of stopping the callback completely. (The
existing code ran into an underrun in this situation.)

The delay estimation works about the same. We simply assume that the
callback is locked to audio timing (like ao_jack), and that 1 callback
corresponds to 1 period. It seems this (removed) code fragment assumes
there 1 one period size delay:

// delay subcomponent: remaining audio from the next played buffer, as
// provided by the callback
buffer_interval += callback_interval;

so we explicitly do that too.
2014-03-09 19:08:47 +01:00
wm4 3ca034228d timer: reduce ifdef headsplitting-factor
I'd rather duplicate some trivial code, rather than split functions in
the middle with ifdefs.
2014-03-09 16:58:00 +01:00
wm4 3620cf97ad timer: switch to CLOCK_MONOTONIC
Apparently, this is always _really_ monotonic, despite what the Linux
manpages say. So this should be much better than gettimeofday(). (At
times there were kernel bugs which broke the monotonic property.)

From the perspective of the player, time can still be discontinuous
(you could just stop the process with ^Z), but at least it's guaranteed
to be monotonic without further hacks required.

Also note that clock_gettime() returns the time in nanoseconds. We want
microseconds only, because that's the unit we chose internally. Another
problem is that nanoseconds can wrap pretty quickly (less than 300 years
in 63 bits), so it's just better to use microseconds. The devision won't
make the code that much slower (compilers can avoid a real division).

Note: this expects that the system provides clock_gettime() as well as
CLOCK_MONOTONIC. Both are optional according to POSIX. The only system
I know which doesn't have these, OSX, has seperate timer code anyway,
but I still don't know whether more obscure (yet supported) platforms
have a problem with this, so I'm playing safely. But this still expects
that CLOCK_MONOTONIC always works at runtime if it's defined.
2014-03-09 16:49:02 +01:00
wm4 f50c1d2c26 DOCS: fix an external link
This got lost in commit b980884f.
2014-03-09 15:02:28 +01:00
wm4 f03abf64b6 mpv.desktop: add video/mp2t mime type
Closes #625.
2014-03-09 01:28:40 +01:00
wm4 3da0a3ccc3 audio: don't write audio when paused
This is probably "safer". Without it, we will play 1 sample, because the
logic was written in a way to decode 1 sample if audio is paused. 1
sample usually will initialize the audio PTS, but not play any real
audio. Also see previous commit.

In ancient times, this actually used 1 byte (instead of 1 sample), so
clearly no sample was written, unless the audio was 8-bit mono.
2014-03-09 01:27:42 +01:00
wm4 7b6e211e63 audio: remove handling of partially written data
Remove the ao_buffer_playable_samples field. This contained the number
of samples that fill_audio_out_buffers() wanted to write to the AO (i.e.
this data was supposed to be played at some point), but ao_play()
rejected it due to partial fill.

This could happen with many AOs, notably those which align all written
data to an internal period size (often called "outburst" in the AO
code), and the accepted number of samples is rounded down to period
boundaries. The left-over samples at the end were still kept in
mpctx->ao_buffer, and had to be played later.

The reason ao_buffer_playable_samples had to exist was to make sure that
at EOF, the correct number of left-over samples was played (and not
possibly other data in the buffer that had to be sliced off due to
endpts in fill_audio_out_buffers()). (You'd think you could just slice
the entire buffer, but I suspect this wasn't done because the end time
could actually change due to A/V sync changes. Maybe that was the reason
it's so complicated.)

Some commits ago, ao.c gained internal buffering, and ao_play() will
never return partial writes - as long as you don't try to write more
samples than ao_get_space() reports. This is always the case. The only
exception is filling the audio buffers while paused. In this case, we
decode and play only 1 sample in order to initialize decoding (e.g. on
seeking). Actually playing this 1 sample is in fact a bug, but even of
the AO doesn't have period size alignment, you won't notice it. In
summary, this means we can safely remove the code.
2014-03-09 01:27:42 +01:00
wm4 e16c91d07a audio/out: make draining a separate operation
Until now, this was always conflated with uninit. This was ugly, and
also many AOs emulated this manually (or just ignored it). Make draining
an explicit operation, so AOs which support it can provide it, and for
all others generic code will emulate it.

For ao_wasapi, we keep it simple and basically disable the internal
draining implementation (maybe it should be restored later).

Tested on Linux only.
2014-03-09 01:27:41 +01:00
wm4 2f03dc2599 ao_portaudio: use new pull API helpers
Same deal as with the previous commit. We don't lose any functionality,
except for waiting "properly" on audio end, instead of waiting using the
delay estimate.
2014-03-09 01:27:41 +01:00
wm4 e5e8608332 ao_jack: use new pull API helpers
This removes the ringbuffer management from the code, and uses the
generic code added with the previous commit. The result should be
pretty much the same.

The "estimate" sub-option goes away. This estimation is now always
active. The new code for delay estimation is slightly different, and
follows the claim of the jack framework that callbacks are timed
exactly.
2014-03-09 01:27:41 +01:00
wm4 a477481aab audio/out: feed AOs from a separate thread
This has 2 goals:
- Ensure that AOs have always enough data, even if the device buffers
  are very small.
- Reduce complexity in some AOs, which do their own buffering.

One disadvantage is that performance is slightly reduced due to more
copying.

Implementation-wise, we don't change ao.c much, and instead "redirect"
the driver's callback to an API wrapper in push.c.

Additionally, we add code for dealing with AOs that have a pull API.
These AOs usually do their own buffering (jack, coreaudio, portaudio),
and adding a thread is basically a waste. The code in pull.c manages
a ringbuffer, and allows callback-based AOs to read data directly.
2014-03-09 01:27:41 +01:00
wm4 5ffd6a9e9b encode: add locking
Since the AO will run in a thread, and there's lots of shared state with
encoding, we have to add locking.

One case this doesn't handle correctly are the encode_lavc_available()
calls in ao_lavc.c and vo_lavc.c. They don't do much (and usually only
to protect against doing --ao=lavc with normal playback), and changing
it would be a bit messy. So just leave them.
2014-03-09 00:19:35 +01:00
wm4 b48d09a89d command: fix osd-height property 2014-03-09 00:19:35 +01:00
wm4 3cd1cfb51c ao_null: add option for simulated device speed
Helps with testing and debugging.
2014-03-09 00:19:34 +01:00
wm4 76eca81455 ao: remove opts field
Apparently unused.
2014-03-09 00:19:34 +01:00
wm4 41f2b26d11 audio/out: make ao struct opaque
We want to move the AO to its own thread. There's no technical reason
for making the ao struct opaque to do this. But it helps us sleep at
night, because we can control access to shared state better.
2014-03-09 00:19:31 +01:00
wm4 74b7001500 encode: don't access ao->pts
This field will be moved out of the ao struct. The encoding code was
basically using an invalid way of accessing this field.

Since the AO will be moved into its own thread too and will do its own
buffering, the AO and the playback core might not even agree which
sample a PTS timestamp belongs to. Add some extrapolation code to handle
this case.
2014-03-07 15:23:03 +01:00
wm4 4579d9ca58 lua: add license header
Oops.
2014-03-07 12:47:07 +01:00
wm4 9cc9d19eee common: add some helper macros 2014-03-07 12:47:07 +01:00
Diogo Franco 52428ece91 Merge pull request #619 from mpv-player/wasapi/better_timing
ao_wasapi: Add device latency to get_delay
2014-03-06 18:22:41 -02:00
Diogo Franco (Kovensky) fe03981bbc ao_wasapi: Slightly improve timer accuracy
Use QueryPerformanceCounter to improve the accuracy of
IAudioClock::GetPosition.

While this is mainly for "realtime correctness" (usually the delay is a
single sample or less), there are cases where IAudioClock::GetPosition
takes a long time to return from its call (though the documentation doesn't
define what a "long time" is), so correcting its value might be important in
case the documented possible delay happens.
2014-03-06 17:21:34 -03:00
Diogo Franco (Kovensky) 1d096f9f1b ao_wasapi: Add device latency to get_delay
The lack of device latency made get_delay report latencies shorter than
they should; on systems with fast enough drivers, the delay is not
perceptible, but high enough invisible delays would cause desyncs.

I'm not yet completely sure whether this is 100% accurate, there are
some issues involved when repeatedly pausing+unpausing (the delay might
jump around by several dozen miliseconds), but seeking seems to be
working correctly now.
2014-03-06 17:21:33 -03:00
Alexander Preisinger a9eae4276d wayland/shm: fix leak in buffer pool
Rename it to reinit and check if parts of the pool are already allocated.
2014-03-06 14:43:20 +01:00
wm4 d268d896d9 ao_jack: fix termination on the end of file
The player didn't quit when the end of a file was reached. The reason
for this is that jack reported a constant audio delay even when all
audio was done playing. Whether that was recognized as EOF by the player
depended whether the exact value was higher or lower than the player's
threshhold for what it considers no more audio.

get_delay() should return amount of time it takes until the last sample
written to the audio buffer reaches the speaker. Therefore, we have to
track the estimated time when the last sample is done, and subtract it
from the calculated latency. Basically, the latency is the only amount
of time left in the delay, and it should go towards 0 as audio reaches
ths speakers.

I'm not sure if this is correct, but at least it solves the problem. One
suspicious thing is that we use system time to estimate the end of the
audio time. Maybe using jack_frame_time() would be more correct. But
apart from this, there doesn't seem to be a better way to handle this.
2014-03-05 18:02:41 +01:00
wm4 5b3fd09908 build: update waf
<lachs0r> it fixes issues with recent python3
2014-03-04 12:08:40 +01:00
wm4 44fc61cec0 demux_lavf: fix typo in comment
Pushed too early...
2014-03-04 00:32:29 +01:00
wm4 5606cf2948 sub: use new FFmpeg API to check MicroDVD FPS
Before this, it wasn't possible to distinguish MicroDVD subtitles
without FPS header, and subtitles with FPS header equal to FFmpeg's
fallback FPS.
2014-03-04 00:28:10 +01:00
wm4 43e997ca07 player: reformat some code 2014-03-03 23:58:19 +01:00
wm4 59d9007e15 player: make separation between user/automatic track selection stronger
For example, consider the case when audio initialization fails. Then the
audio track is deselected. Before this commit, this would have been
equivalent to the user disabling audio. This is bad when multiple files
are played at once (the next file would have audio disabled, even if it
works), or if playback resume is used (if e.g. audio output failed to
initialize, then audio would be disabled when resuming, even if the
system's audio driver was fixed).
2014-03-03 23:53:12 +01:00
wm4 082b1cdeaa m_property: allow setting string properties via M_PROPERTY_SET_STRING
Setting string options to strings over the m_option fallback (i.e.
M_PROPERTY_SET_STRING is called if the option type is CONF_TYPE_STRING)
failed. This was because m_option_parse() returns 0. 0 still means
success, but the property code tried to be clever, and considered 0 not
a success in order to disallow setting flags to an emtpy string (which
in turn is allowed, because the command line allows flag options without
parameters).

Fix this by removing the overly clever code.

This could happen when e.g. using the "set" command on options/title (a
string option), and also was a problem for the client API.

Closes #610.
2014-03-03 12:48:41 +01:00
wm4 4bc0e3feac command: fix null pointer dereference in idle mode
Pressing 'h' in idle mode -> crash.
2014-03-02 22:39:20 +01:00
wm4 8f2ee917d4 player: cheap hack against idle event feedback loop
The OSC used significant CPU time while the player was paused. It turned
out that the "tick" event sent during pause is the problem. The OSC
accesses the player core when receiving a tick event, which in turn will
cause the core to send another tick event, leading to infinite feedback.

Fix this by sending an idle tick only every 500ms. This is not very
proper, but the idea behind the tick event isn't very clean to begin
with (and the OSC should use timers instead).
2014-03-01 21:29:13 +01:00
wm4 4de22d1cbc client API: fix playloop thread wakeup
The playloop usually waits in select(), using a timeout needed for
refilling audio and video buffers. This means the client API needs
a separate mechanism to interrupt the select() call. This mechanism
exists, but I forgot to use it. This commit fixes it.

If it works, this will make the client API react faster, epsecially
in audio-only mode. If video is enabled, the reaction time is capped
to 50ms (or somewhat faster if the framerate is >20 fps), because
the playloop stops reacting to anything in order to render and time
the next video frame. (This will be fixed later by moving the VO
to its own thread.)
2014-03-01 15:46:39 +01:00
wm4 b684ea55a5 vo_opengl: minor simplification
I think this is easier to follow.
2014-03-01 15:40:46 +01:00
Niklas Haas d5b5ed0b46 vo_opengl: Include :icc-approx-gamma option in the 3DLUT cache header
This makes sure the ICC cache is recomputed when the :icc-approx-gamma
option is changed, since it affects the output quite a lot.
2014-03-01 02:28:46 +01:00
wm4 bcceeec737 sd_ass: add a very simple and evil way to override ASS subtitle styles
--ass-style-override=force now attempts to override the 'Default' style.
May or may not work. In some situations it will work, but also mess up
seemingly unrelated things like signs typeset with ASS.
2014-03-01 02:18:03 +01:00
wm4 32d18d77cd lua: set a proper chunk name for builtin modules
luaL_loadstring(), which was used until now, uses the start of the Lua
code itself as chunk name. Since the chunk name shows up even with
runtime errors triggered by e.g. Lua code loaded from user scripts, this
looks a but ugly. Switch to luaL_loadbuffer(), which is almost the same
as luaL_loadstring(), but allows setting a chunk name.
2014-03-01 00:50:59 +01:00
wm4 d706f8181a lua: fix add_key_binding()
add_key_binding() didn't work, because it passed a flag that was
renamed. add_forced_key_binding() worked, but did the wrong thing.
2014-03-01 00:42:53 +01:00
wm4 6357c27ab6 lua: fix format string in luaL_error() 2014-03-01 00:40:22 +01:00
wm4 93065af3ed client API: fix timeout handling
(Again.)

Fixed Lua timers as well.
2014-03-01 00:38:17 +01:00
wm4 0ad267c1d5 lua: fix use of renamed function
Apparently this was overlooked when get_timer was renamed to get_time.
2014-03-01 00:37:57 +01:00
wm4 1f8a400ad7 timer: add utility function to get relative time 2014-02-28 23:18:52 +01:00
wm4 97409ec4e6 msg: add --msgtime option to add timestamps to each output message
Will be helpful to track down strange wait times and such issues, as
well when you have develop something timing related. (Then you may print
timestamps in your debug output, and the --msgtime timestamps will help
giving context.)
2014-02-28 22:45:34 +01:00
wm4 1e2d409fb4 lua: add option to disable auto-loading of lua scripts 2014-02-28 22:25:48 +01:00
wm4 47ede0f5e3 config: don't load global config files with --config-dir
This sidestepped the usual logic by hardcoding the path.
2014-02-28 21:32:04 +01:00
wm4 42299ed868 config: fix --config-dir logic for global config files
Global config files should be loaded only when --no-config is missing
_and_ --config-dir is not set.
2014-02-28 21:32:00 +01:00
wm4 3020490ab1 manpage: document properties added in previous commit 2014-02-28 20:57:54 +01:00
xylosper 70b6c163ff client API: add two properties, 'time-start' and 'seekable' 2014-02-28 20:54:58 +01:00
xylosper dd13e29cc2 client APIs: fix some typos 2014-02-28 20:54:47 +01:00
xylosper c6448d7a9b audio: add enum name for speaker id 2014-02-28 20:54:15 +01:00
wm4 37ada157eb manpage: lua: fix typo 2014-02-28 20:53:15 +01:00
wm4 c49a8427d4 manpage: lua: update from previous commit
I forgot about this.
2014-02-28 02:04:33 +01:00
wm4 c30bf22d8d client API: rename MPV_EVENT_PLAYBACK_START, add MPV_EVENT_SEEK
Rename MPV_EVENT_PLAYBACK_START to MPV_EVENT_FILE_LOADED.

Add MPV_EVENT_SEEK and MPV_EVENT_PLAYBACK_RESTART.
2014-02-28 01:31:38 +01:00
wm4 1852555ca1 client API: wait for remaining asynchronous requests before terminating
Sending an asynchronous request and then calling mpv_destroy() would
crash the player when trying to send the reply to the removed client.
Fix this by waiting until all remaining replies have been sent.
2014-02-28 01:03:37 +01:00
wm4 6b2a929ca7 ao: document some functions 2014-02-28 00:56:10 +01:00
wm4 91404e8a19 DOCS: kill the rest of the old mplayer tech documentation
Not really useful anymore, other than confusing everyone.
2014-02-28 00:24:59 +01:00
wm4 14607f27ef command: use the step size for "add volume" commands
The step argument for "add volume <step>" was ignored until now. Fix it.

There is one problem: by defualt, "add volume" should use the value set
with --volstep. This value is 3 by default. Since the default volue for
the step argument is always 1 (and we don't really want to make the
generic code more complicated by introducing custom step sizes), we
simply multiply the step argument with --volstep to keep it compatible.

The --volstep option should probably be just removed in the future.
2014-02-27 01:07:46 +01:00
wm4 b4fb71634c command: format volume property as integer for OSD
The value range is 0-100, so fractional values don't make much sense.
But the underlying data type is probably float to avoid getting "stuck"
when doing small volume increments. So step this around and pretend it's
an integer just on display.
2014-02-27 00:57:41 +01:00
wm4 8a51a6b79c vo_opengl: change gamma suboption to take a value
The previous version of the gamma suboption was pretty useless. It could
be used to disable delayed gamma enabling, which is a mechanism to avoid
having to adjust gamma in the shader by default.

Repurpose the suboption and allow setting an exact gamma value with it.
You can already override gamma with the --gamma option as well as the
gamma input property, but these use a weird curve to create the
impression of a linear perceived brightness change when changing the
value. This suboption now allows setting an exact gamma value.
2014-02-27 00:53:41 +01:00
Niklas Haas 6119cf13be vo_opengl: Change the default icc-intent to relative colorimetric
This used to be absolute colorimetric, but relative colorimetric is a
saner default due to the arguments presented in issue #595.

A short summary: In general it doesn't affect much because our eyes
adapt to the white point either way, but if running in windowed mode it
would make the whites seem inconsistent/tinted. For fullscreen
projection it's also undesirable since it reduces the dynamic range
without much benefit (again, since our eyes adapt either way) and it
also breaks calibration against ambient lighting.

This shouldn't change much, since most profile types that aren't 3DLUTs
aren't capable of either of those transforms, and most displays are
calibrated against D65 (same as BT.709 source) either way.
2014-02-26 23:05:20 +01:00
wm4 c1cb0dd7ee lua: add set_property_native function
Probably completely useless, at least for now.

Also not very well tested, but initial test seems successful.
2014-02-26 22:38:34 +01:00
wm4 1513493560 lua: mark table values returned by get_property_native with their type
Lua doesn't distinguish between arrays and maps on the language level;
there are just tables. Use metatables to mark these tables with their
actual types. In particular, it allows distinguishing empty arrays from
empty tables.
2014-02-26 22:32:57 +01:00
wm4 5eab4f43ec m_option: make converting mpv_node to string always fail 2014-02-26 22:30:18 +01:00
wm4 11ee72fe1b lua: implement mp.get_opt() in Lua
Will be more expensive if used very often, but it's probably ok.

Reduce the dependency of lua.c on MPContext a bit further.
2014-02-26 21:03:36 +01:00
wm4 25f086973f m_option: fix key/value list string conversion
Meh.
2014-02-26 21:03:35 +01:00
wm4 5bfe131340 client API: don't send MPV_EVENT_IDLE when not entering idle mode
For simplicity, this was sent before actually checking the idle
condition, which meant that we'd send it even of the idle loop is never
entered.
2014-02-26 21:03:35 +01:00
wm4 9ccbc03ab1 threads: fix wait time overflow check
When passing a very large timeout to mpthread_cond_timed_wait(), the
calculations could overflow, setting tv_sec to a negative value, and
making the pthread_cond_timed_wait() call return immediately. This
accidentally made Lua support poll and burn CPU for no reason.

The existing overflow check was ineffective on 32 bit systems. tv_sec is
usually a long, so adding INT_MAX to it will usually not overflow on 64
bit systems, but on 32 bit systems it's guaranteed to overflow. Simply
fix by clamping against a relatively high value. This will work until 1
week before the UNIX time wraps around in 32 bits.
2014-02-26 21:03:35 +01:00
wm4 412bb336ab client API: don't explode when destroying uninitialized mpv_handle 2014-02-26 21:03:35 +01:00
wm4 bd75766ef0 client API: accept NULL as mpv_destroy() argument 2014-02-26 21:03:35 +01:00
wm4 e749470018 options: fix --list-options output
This was a bit damaged by commit f3c933e5.
2014-02-26 21:03:35 +01:00
wm4 eca9210399 client API: treat MPV_FORMAT_STRING differently in mpv_set_property
Always map MPV_FORMAT_STRING to setting property value directly through
M_PROPERTY_SET_STRING, instead of trying to go through
M_PROPERTY_SET_NODE.

This treats a direct MPV_FORMAT_STRING query differently from a
MPV_FORMAT_STRING wrapped in a mpv_node. This was already the case in
mpv_get_property(). The reason for all this is that mpv_node is supposed
to be the exact type, while a direct MPV_FORMAT_STRING goes through all
possible conversions.

Not sure if these semantics are good.
2014-02-26 21:03:35 +01:00
wm4 a0b1d5f888 m_property: fix confused error code
This broke the client API.
2014-02-26 21:03:35 +01:00
wm4 8461143ed7 m_option: don't make "unset" string and string list return NULL strings
This is a bit weird: m_option_string types (i.e. char*) can be NULL. But
they're supposed to be treated just like empty strings. So don't make
the m_option_type.print function return NULL for these values. Returning
NULL would mean failure.

This didn't matter much before, but was quite visible through the client
API.
2014-02-26 21:03:35 +01:00
xylosper c176f2be39 client API: fix broken property/option functions
1. Cannot set option after initialized: it seems that this bug has
   existed since libmpv was introduced first. Maybe just a typo.
2. Crash when setting property with native format: mpv_set_property
   just causes a crash when using a native format. I found an invalid
   casting and fixed it.
3. Wrong error value for mpv_get_property: when an error occurred,
   mpv_get_property always returns wrong format error because every
   error for property except M_PROPERTY_NOT_IMPLEMENTED is just ignored.

Signed-off-by: wm4 <wm4@nowhere>

Closes pull request #593. Does not incldue the first fix, which was not
correct. The underlying bug will be fixed by a later commit.

Commit message extracted from pull request and slightly edited.
2014-02-26 21:01:54 +01:00
wm4 9a7a3d125b osd: override user bindings for OSC input
E.g. binding MOUSE_BTN0 always used the user defined binding. While it
is ok that the user can override mouse_move and mouse_leave (for
whatever reasons), we want to strictly override the bindings when input
is sent to the OSC itself.

Regression since 03624a1.
2014-02-26 00:59:19 +01:00
wm4 f3c933e5d3 options: allow changing options at runtime
Allow changing all options at runtime, except some cherry-picked
options, which are disabled with M_OPT_FIXED.
2014-02-25 23:59:27 +01:00
wm4 279bd8db1f client API: change description of format conversions
This changed during the time between writing the comment, and finishing
up the implementation.

Although I'm still unsure about this.
2014-02-25 22:57:48 +01:00
wm4 008fe558dc config: when writing resume config, read options, not properties
This lowers the number of data stored in the resume config a bit
further, because some properties can't be read at program start and when
e.g. the VO wasn't created yet.

Some fields still need to be read from a property (actually only
"volume-restore-data", a hack to save the full volume information). So
abuse the "options/" property, and make use of the fact that changing
things at runtime also changes the options.
2014-02-25 22:51:55 +01:00
wm4 67f244c6d4 config: don't save options to resume-config that didn't change
This is approximate: we read each option value on program start
(before starting playback of a file), and when writing the resume
config, compare each value to the current state. This also means
when a value is changed and then changed back, it's not stored. In
particular, option values set in config files and on the command
line are considered the default.

This should help reducing the numbers of options overridden by the
resume config. If too much is overridden, it becomes an inconvenience,
because changes in config files will apparently have no effect when
resuming a file.

Also see github issue #574.
2014-02-25 22:34:32 +01:00
wm4 70ff543029 input: allow input.conf bindings to be declared as builtin
This might be helpful if we ever want cascading config files. Also, we
will probably need it if we change the default input.conf bindings, and
want to provide compatibility input.conf files.
2014-02-25 22:09:20 +01:00
wm4 a85ff44511 config: always print resolved config paths in verbose mode
Restructure the code to make that easier. There should be no functional
changes, other than the log call at the end of each function.
2014-02-25 21:19:18 +01:00
wm4 0ee4e06376 manpage: remove unused environment variable
We removed gettext (which was disabled by default) a while ago.
2014-02-25 21:04:26 +01:00
wm4 428ffb01cf config: add a --config-dir option to force config directory
Useful for slave-mode like uses, and not as radical as --no-config.
2014-02-25 21:04:04 +01:00
wm4 2ea614ada6 config: don't write default config file
This created an essentially empty config file. This is not really
needed and probably causes more trouble than it solves (such as
littering the home directory with crap), so get rid of it.
2014-02-25 20:36:31 +01:00
Niklas Haas 90b4923f4a manpage: Improve wording on icc-approx-gamma
This version is clearer on its origin, prevalence and use case and
offers some advice to the user.
2014-02-25 17:23:46 +01:00
wm4 36bc6e04ea manpage: document the new loadfile argument
I forgot about this.
2014-02-25 00:00:46 +01:00
wm4 af6305b88a client api examples: set an option with MPV_FORMAT_FLAG 2014-02-24 23:02:50 +01:00
wm4 761975d47b command: fix loadfile command
This was broken by commit bb6b543812. Note that the original pull
request was fine, but it was broken by my own stupidity when I was
"improving" it.

The problem is that the new loadfile argument was not considered
optional anymore after my changes. The original pull request did handle
this by setting .defval to a dummy value, but I removed that part.

Fix it again by introducing a flag that designates that the parameter is
optional. (I didn't want to add it to m_option.h, because technically,
all options are optional, and it's not possible to have non-optional
options.)
2014-02-24 23:02:20 +01:00
wm4 0adb8a9aaf client API: report pause/unpause reason
Not sure about this... might redo.

At least this provides a case of a broadcasted event, which requires
per-event data allocation.

See github issue #576.
2014-02-24 22:50:25 +01:00
wm4 5d7007c644 client API: expose the internal clock
May or may not be useful in some ways.

We require a context parameter for this just to be sure, even if the
internal implementation currently doesn't.

That's one less mpv internal function for the Lua wrapper.
2014-02-24 22:50:25 +01:00
wm4 0797babbfa lua, osc: use properties for chapter/track lists 2014-02-24 22:50:24 +01:00
wm4 4d1575173b command: make options property return the list of all options 2014-02-24 22:50:24 +01:00
wm4 38a36fd7ea client API: add comment about character encoding issues
Also mention that NULL isn't valid. Although I'm not sure whether the
implementation strictly follows this (it should, but there are some
wacky corner cases).
2014-02-24 22:50:24 +01:00
wm4 f628d5e859 lua: add a bunch of functions to get/set properties by their native type
There are some complications because the client API distinguishes
between integers and floats, while Lua has only "numbers" (which are
usually floats). But I think this should work now.
2014-02-24 22:50:24 +01:00
wm4 942fb43d0c client API: implement setting options using their native type too
This is only half-implemented: actually the option will first be
converted from mpv_node to its native type, then it's converted to a
string, and then back to its native type. This is because the option
API was made for strings and not anything else.

Other than being grossly inelegant, the only downside is probably with
string lists and key/value lists, which don't escape strings containing
syntax elements correctly.
2014-02-24 22:50:23 +01:00
wm4 a6ebfbea69 m_property: retrieve chapter lists etc. as mpv_node
This automatically allows accessing properties like chapter-list and
track-list to be read as mpv_node. This affects all properties which use
m_property_read_sub() and m_property_read_list().
2014-02-24 22:50:23 +01:00
wm4 62653605da client API: add support for accessing properties by their native type
This actually makes use of the client.h declarations and the mpv_node
mechanisms added some commits ago.

For now, using MPV_FORMAT_STRING will usually fallback to explicit
string conversion, but not in the other cases. E.g. reading a numeric
property as string will work, but not reading a string property as
number. Other than that, only MPV_FORMAT_INT64->MPV_FORMAT_DOUBLE does
an automatic conversion.

I'm not sure whether these semantics and API are good, so comments and
suggestions are welcome.
2014-02-24 22:50:23 +01:00
wm4 91f752f43f m_property: add mechanism to access properties as mpv_node
Allows retrieving properties by their native values (or something close
to it), rather than having to go through string conversion. The caller
could actually just copy the value itself and then use the m_option
functions to convert it to mpv_node, but maybe it's more flexible this
way.
2014-02-24 22:50:23 +01:00
wm4 e94bab5a99 m_option: add a way to convert values to/from mpv_node
m_option is basically the mechanism to handle C data types in a dynamic
way. Add functions to convert values to and from mpv_node. For example,
string lists are turned into mpv_node using MPV_FORMAT_NODE_ARRAY, and
so on.
2014-02-24 22:50:23 +01:00
wm4 74e0654733 client API: adjust error strings
These error codes can be used for setting and getting, not just for
settings (although currently there's no API to get options directly).
2014-02-24 20:51:05 +01:00
wm4 b097d76281 m_property: simplify some code 2014-02-24 20:51:05 +01:00
wm4 43ad09393c client API: add more data formats, add a structured data type
This adds declarations for new formats. The implementation will be added
in the following commits. (It still compiles and runs with this commit,
because it adds constants only.)

The obvious new types are MPV_FORMAT_FLAG, MPV_FORMAT_INT64,
MPV_FORMAT_DOUBLE. MPV_FORMAT_FLAG is a boolean, but to avoid nasty ABI
issues or with languages that don't have a bool data type (C89), it uses
int. Thus the format is not named MPV_FORMAT_BOOL, to avoid confusion.

The MPV_FORMAT_NONE type (mpv_node) is a generic structured type, like a
variant or, say, JSON. It can store strings/bools/numbers, as well as
arrays and key/value pairs (with string keys only).

The MPV_FORMAT_NODE_ARRAY and MPV_FORMAT_NODE_MAP types are used
internally by mpv_node only and can't be used with most of the other API
(like mpv_set_property()) directly.
2014-02-24 20:50:47 +01:00
wm4 1e27d130a2 client API: change semantics for MPV_FORMAT_STRING
With mpv_set_property(h, "property", MPV_FORMAT_STRING, ptr), ptr now
has to be of type char** instead of char*. This makes it more consistent
with mpv_get_property() and also non-pointer formats, which will be
introduced in the following commits. mpv_set_property() of course does
not change its interface (only its implementation is adjusted to keep
its interface).

This also affects mpv_set_option(), but again not
mpv_set_option_string().
2014-02-24 20:50:47 +01:00
wm4 1e30048184 client API: fix a typo 2014-02-24 20:48:59 +01:00
wm4 47aeb22b75 client API: remove trailing "," from enums
This is allowed in C99 and C++11, but apparently not in C89 and C++98.

Make it conform to the older standards, since we want the client API
header to be highly portable.
2014-02-24 20:48:59 +01:00
wm4 4123c2a708 client API: spelling 2014-02-24 20:48:55 +01:00
Andrey Morozov d0e64dcc9b vdpau: change the error message when video too large 2014-02-24 17:59:52 +01:00
Niklas Haas 701c8c8254 vo_opengl: Add :icc-approx-gamma suboption to approximate BT.709 gamma
This uses the value of 1.95 as an approximation for the exact gamma
curve, which replicates the behavior of popular video software including
anything in the Apple ecosystem, as per issue #534.
2014-02-24 14:34:12 +01:00
wm4 e3f7d4f5ea m_option: fix printf format specifier 2014-02-24 12:00:56 +01:00
Nyx0uf 8f4bc16cd7 configure: fix typo
When using help, the output for --enable-shared was :
`--enable-shared     enable enable shared library [disable]`
2014-02-24 11:50:21 +01:00
wm4 40486fd8bd dvd: treat missing volume ID as "unsupported", not error
This is probably better and more consistent with the rest of the code,
although it doesn't change any currently existing behavior in this case.
2014-02-23 18:16:33 +01:00
wm4 f30149e80e cache: cache DVD volume ID
Since this might be queried every frame or so, it's important not to
stall the cache by doing a synchronous stream_control().
2014-02-23 18:16:33 +01:00
wm4 42e70868ab dvd: check for empty DVD volume ID
The only DVD sample I have just returns an empty string for this. Let
command.c use the filename if the ID is empty.
2014-02-23 18:16:33 +01:00
xylosper 5cbef87c17 command: use DVD volume ID for media-title property
Signed-off-by: wm4 <wm4@nowhere>

Closes #582.
2014-02-23 18:16:24 +01:00
wm4 8906e40925 example.conf: change subtitle codepage example to use UTF-8 fallback
This should be pretty safe compared to forcing the codepage.
2014-02-23 17:57:16 +01:00
Yaser Alraddadi d364e09174 example.conf: subtitle encoding
Signed-off-by: wm4 <wm4@nowhere>

Closes #580.
2014-02-23 17:54:13 +01:00
xylosper bb6b543812 command: provide per-file-options for loadfile command
Signed-off-by: wm4 <wm4@nowhere>

Closes #575. Minor changes over original pull request.
2014-02-23 17:49:34 +01:00
wm4 f5c781b0d5 command: remove special casing for strings in input commands
Until now, strings were the only allowed dynamically allocated argument
type in input commands. Extend it so that it works for any type. (The
string expansion in command.c is of course still string specific.)
2014-02-23 17:43:38 +01:00
wm4 b184c7d1e7 old build: add a missing config.h define
The configure check was added to waf only.
2014-02-23 17:41:58 +01:00
wm4 82648ff229 ta: fix comment
If this function could return the input value (i.e. the == case was
correct), then macros like MP_GROW_ARRAY would have been incorrect. The
implementation was correct though, so there's no bug.
2014-02-23 16:51:00 +01:00
wm4 7dae316d50 ta: clarify a corner case 2014-02-23 16:50:51 +01:00
wm4 ae2472f0ee manpage: fix a metadata property name 2014-02-23 16:49:59 +01:00
wm4 f225b5fc00 command: don't use option name in properties
Some code accessed m_option.name to get the property name. (Maybe only
show_property_osd() had a significant use of it.) Remove that, and
remove setting names and dummy names as well.

The old code usually assumed that the name was set, and
show_property_osd() used it to get the proper name of deprecated
aliases.

The "vf" property was listed as "vf*". Not sure why that was done, but
it works without anyway.
2014-02-23 16:49:47 +01:00
wm4 0d4ec7d665 manpage: fix yadif example in one case 2014-02-23 16:49:27 +01:00
wm4 c3c82f5c3b m_option: explicitly allow m_option.name==NULL
Doesn't require other code to care about this, which will allow us to
simplify the property code.

Only "wildcard" options like "vf" and string lists used this, and
m_option_list_findb() (which is excused).
2014-02-23 16:49:18 +01:00
wm4 641fdff65f lua: fix behavior if no script command handler is registered 2014-02-23 16:48:48 +01:00
wm4 98dc8206ae options: handle escape sequences in e.g. --playing-msg differently
M_OPT_PARSE_ESCAPES was pretty stupid, and broke the (useful) assumption
that string variables contain exactly the same value as set by the
option. Simplify it, and move escape handling to the place where it's
used.

Escape handling itself is not terribly useful, but still allows useful
things like multiline custom OSD with "\n".
2014-02-20 14:46:23 +01:00
wm4 857952dce3 input: check for abort cmd in multi-commands
MP_CMD_COMMAND_LIST commands (used to implement key bindings with
multiple commands) were not checked for abort commands. Implement it.

Remove the remarks about multi-commands being special from the manpage.
Seek coalescing is handled differently now, and the issue with abort
commands is fixed with this commit.
2014-02-20 13:40:32 +01:00
James Ross-Gowan 1d0730d22d input: ignore modifiers when releasing keys
This prevents keys from getting stuck if the modifier is released before
the base key.
2014-02-20 23:07:53 +11:00
Stefano Pigozzi 08170c6a67 build: syms: add support for Mach-O binaries
Current code stolen from waf's extras, only supported 'pe' and 'elf'. OS X
uses the 'Mach-O' binary format (which waf calls 'mac-o'... go figure).

Add support for generating the global symbols file with nm and using it from
clang.
2014-02-19 21:56:39 +01:00
wm4 f6ed246826 manpage: input: clarify chapter-metadata property 2014-02-19 16:32:54 +01:00
wm4 bda0e7da13 command: allow accessing metadata entries as list
Not sure about these deep path-names. Maybe "metadata/0" should work
instead of "metadata/list/0". I'm so unsure about it, that I'm leaving
it open.
2014-02-19 16:29:04 +01:00
wm4 844efa5431 command: move metadata entry access to metadata/by-key/
The old way still works, and is fine to use. Still discourage it,
because it might conflict with other ways to access this property, such
as the one added in the next commit.
2014-02-19 16:16:42 +01:00
wm4 15fa120222 manpage: lua: improve explanation of tracks-changed and tracks-switched 2014-02-19 16:01:18 +01:00
wm4 0ad2211508 client API: add event for metadata changes 2014-02-19 16:00:37 +01:00
wm4 57c9f5236a input, dvdnav: fix osc stealing input from dvdnav
This is a regression introduced from moving Lua scripts (including the
OSC) to their own threads. Now OSC and dvdnav can add their bindings at
the same time without coordination, which seems to result in the OSC
winning most time, and thus overriding the dvdnav menu bindings.

Fix this by adding a flag that makes dvdnav menu bindings take priority
over all other bindings.
2014-02-19 15:40:04 +01:00
wm4 8b57e4bc12 input: minor simplification for --input-test 2014-02-19 15:39:59 +01:00
wm4 5d7cf6e508 video: add rounding to aspect ratio calculations
Small errors are unavoidable, but truncation can cause anamorphic video
to be off by 1 or 2 pixels.
2014-02-19 15:37:47 +01:00
wm4 283139607c command: export list of editions as properties 2014-02-19 00:42:05 +01:00
wm4 dc0636102c command: export codec for each track 2014-02-19 00:42:05 +01:00
wm4 09d873d5d4 player: fix start time if timeline is used (ordered chapters, EDL)
When timeline was used, and the --start option was not used, the initial
seek (needed to switch to the first timeline segment) seeked to -1 due
to an oversight.
2014-02-19 00:41:34 +01:00
wm4 e6f543ebec edl: extend with chapter timestamps
Example see edl-mpv.rst.

What is this useful for? No clue...
2014-02-19 00:06:00 +01:00
wm4 d29661af8a edl: fix offset of user-visible chapters
Basically, chapter marks and chapter seek-points were incorrect, while
the rest worked.
2014-02-19 00:05:14 +01:00
James Ross-Gowan 8567f1a997 stream_file: cache remote files on Windows
Same as 6896469 but for Windows.
2014-02-18 12:23:56 +01:00
Grigori Goronzy 472bb04e9d vo_opengl: use GL_RGBA16 FBO format for HQ
GL_RGB16 is definitely not a required format, after review of the
OpenGL 3.3 spec. Most HW doesn't have native support for RGB16 anyway.
2014-02-17 20:31:14 +01:00
wm4 333d1045b7 manpage: lua: shorten description of register_script_command()
This is simply not important enough to warrant so much space, and it's
perhaps also very confusing.

Although I'm not fully sure, since this is about the only way that
allows a user to interact with a script, besides key bindings and static
options.
2014-02-17 20:30:44 +01:00
wm4 6d87f6f550 manpage: lua: attempt to improve add_key_binding() description 2014-02-17 20:30:44 +01:00
wm4 c79ea489bf manpage: lua: improve introduction, add simplistic example 2014-02-17 20:30:44 +01:00
wm4 ceca513e9d manpage: lua: fix typo 2014-02-17 20:30:44 +01:00
wm4 0f973cc8c6 manpage: input: document script_message command 2014-02-17 20:30:44 +01:00
Stefano Pigozzi b1328418ee vo_corevideo: remove unused variable 2014-02-17 19:39:49 +01:00
Stefano Pigozzi 689646962e stream_file: activate cache with files on network file systems
Detected 'protocols' are AFP, nfs, smb and webdav. This can be extended on
request.

This is currently only implemented for BSD systems (using fstatfs). This
addresses issue #558 on the above platforms.
2014-02-17 19:39:49 +01:00
wm4 5fcf4b46f7 client API: add events for video and audio reconfig 2014-02-17 02:52:59 +01:00
James Ross-Gowan b3b59b9a2d w32_common: don't set small icon
Windows will automatically choose the correct icon size if this field is
unset.
2014-02-17 02:52:58 +01:00
wm4 24fa69dbfa lua: add mechanism for script provided key bindings
There was already an undocumented mechanism provided by
mp.set_key_bindings and other functions, but this was relatively
verbose, and also weird. It was mainly to make the OSC happy (including
being efficient and supporting weird corner cases), while the new
functions try to be a bit simpler.

This also provides a way to let users rebind script-provided commands.

(This mechanism is less efficient, because it's O(n^2) for n added key
bindings, but it shouldn't matter.)
2014-02-17 02:52:58 +01:00
wm4 12b7850f11 input: debug output for registered bindings 2014-02-17 02:52:58 +01:00
wm4 03624a1747 input: don't let builtin bindings overwrite user bindings
This was already done, except when the bindings were in different input
sections. This commit fixed it. Useful for scripts, probably.
2014-02-17 02:52:58 +01:00
wm4 75d3267b43 client API: add a client message event
This comes with a "script_message" input command, which sends these
messages. Used by the following commits.
2014-02-17 02:52:58 +01:00
wm4 fe586dbbdb keycodes: add const to a function argument 2014-02-17 02:52:58 +01:00
wm4 5fd661b50e lua: allow giving fallback values in get_property() calls
E.g. ``mp.get_property("foo", "value")`` will return ``value`` if the
property can't be read.
2014-02-17 02:52:58 +01:00
wm4 1fa8e2b602 lua: remove redundant inline documentation
Nobody will loom at this, and the proper documentation of these
functions is in lua.rst.
2014-02-17 02:52:58 +01:00
Timothy Gu d85e2588cf DOCS/crosscompile-mingw: use settings.mk instead of make variables
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
2014-02-17 02:52:58 +01:00
Timothy Gu da4e33074e DOCS/crosscompile-mingw: update disk space stats 2014-02-17 02:52:58 +01:00
Timothy Gu b980884f92 DOCS/crosscompile-mingw: update
- Adds description of and uses $JOBS envvar in MXE instructions
- Adds MXE_TARGETS to command line instead of echoing it to settings.mk
- Prettify and sentence usage
2014-02-17 02:52:57 +01:00
Alexander Preisinger 891268955e wayland/shm: remove unused define 2014-02-16 18:14:17 +01:00
wm4 98349fa910 command: export chapter list as properties 2014-02-16 03:51:02 +01:00
wm4 e41d27c7db command: export playlist as properties 2014-02-16 03:51:02 +01:00
wm4 92133b1dcd command: expose track list as properties 2014-02-16 03:51:02 +01:00
wm4 801de5ac6d m_property: add a mechanism to organize a list of sub-properties
This automatically adds a "count" sub-property, and for each entry in
the range [0, count), a numbered sub-property to access the item.
2014-02-16 03:51:02 +01:00
wm4 486658e5c7 demux: expose stream_type_name() function 2014-02-16 03:51:02 +01:00
wm4 c236cb7679 command: export more video params as properties
This uses the previously added sub-property mechanism to export a bunch
of stuff. For example, "video-params/w" now contains the video width.
2014-02-16 03:51:02 +01:00
wm4 309ae76e0b m_property: add a sub-property mechanism
This adds a mechanism for easier export of sub-properties. The following
commits will make use of it to export fine grained information about
certain things. The sub-property mechanism reduces the amount of code
needed to export a data value to 1 line.
2014-02-16 03:51:02 +01:00
wm4 ccfbe43455 csputils: provide string descriptions of chroma locations 2014-02-16 03:51:02 +01:00
Diogo Franco (Kovensky) 317a02bdd4 Merge branch 'master' of git://github.com/mpv-player/mpv
* 'master' of git://github.com/mpv-player/mpv:
  win32: restore support for exe directory as config directory
  crosscompile-mingw: improve instructions for MXE
  sd_lavc: handle subtitles with no subtitle resolution set
  options: make --no-config block all auto-loaded configuration files
  lua: auto-load scripts from ~/.mpv/lua/
  lua: make register_event() not overwrite previous event handler
2014-02-15 19:44:58 -03:00
Diogo Franco (Kovensky) 4a66fce7d3 Parse::Matroska::Reader: get rid of bigrat
It seems that it was causing issues with certain perl setups (such as
the one on issue #549). It also turns out that it was not behaving correctly
(not all constants were being promoted to big nums as they should), so we
use explicit objects to derive the constants.

There were also precedence issues. I wonder if this even worked right to
begin with.

The 'double' path (8-byte floats) is untested, as I couldn't easily find
a file with such a field.

Closes #549.
2014-02-15 19:43:22 -03:00
elevengu 792c1750ec win32: restore support for exe directory as config directory
Same rationale as b2c2fe7a but updated to work with path-win.c

Signed-off-by: wm4 <wm4@nowhere>

Merges/closes #543.
2014-02-14 21:55:04 +01:00
wm4 cf6d6666e2 crosscompile-mingw: improve instructions for MXE 2014-02-14 20:12:09 +01:00
xylosper 87c13de656 sd_lavc: handle subtitles with no subtitle resolution set
Set subtitle resolution to video resolution when avctx->width and
avctx->height are zero.

This can happen with broken vobsubs that have no size set in their
.idx file (or Matroska extradata). At least with the test file provided
in issue #551, using the video resolution as fallback instead of what
guess_resolution() does is better.

Note that these files clearly are broken. It seems this particular
file was created by trying to use ffmpeg to transcode DVB subtitles
to vobsub, and ffmpeg "forgot" to set the subtitle resolution in the
destination file. On the other hand, ffmpeg DVB and PGS decoders set
the resolution on the first subtitle packet (or somewhere close), so
it's not really clear what to do here.

Closes #551.

Signed-off-by: wm4 <wm4@nowhere>

Patch by xylosper, rewritten commit message by wm4.
2014-02-14 16:38:31 +01:00
wm4 ce6fb9175c options: make --no-config block all auto-loaded configuration files
Until now, the --no-config was explicitly checked in multiple places to
suppress loading of config files.

Add such a check to the config path code itself, and refuse to resolve
_any_ configuration file locations if the option is set.

osc.lua needs a small fixup, because it didn't handle the situation when
no path was returned. There may some of such cases in the C code too,
but I didn't find any on a quick look.
2014-02-14 14:01:27 +01:00
wm4 c2e8f8fb89 lua: auto-load scripts from ~/.mpv/lua/
This is like passing them to --lua.
2014-02-14 14:01:27 +01:00
wm4 414c4f9322 lua: make register_event() not overwrite previous event handler
Instead, chain them.

Note that there's no logic to prevent the other event handlers to be run
from an event handler (like it's popular in GUI toolkits), because I
think that's not very useful for this purpose.
2014-02-14 14:01:27 +01:00
Diogo Franco (Kovensky) 99e38aee9a build: Add -U__STRICT_ANSI__ to CFLAGS on Cygwin
Cygwin's libc (newlib) doesn't obey a lot of unix feature test macros,
including _GNU_SOURCE; as a result, a lot of functions and defines get
masked out -- important defines such as M_PI and strcasecmp. Work around
it by undefining __STRICT_ANSI__ on cygwin systems.

This will still cause compilation issues on any non-cygwin system that
uses newlib, but hopefully nobody does that, or if they do, they will
find this commit message and know to add -U__STRICT_ANSI__ to their
CFLAGS. Hopefully.
2014-02-13 19:29:23 -03:00
Stefano Pigozzi 590b28c08b build: disable clang's tautological compare warnings [2]
Fixup 8009646583.
2014-02-13 23:16:12 +01:00
wm4 2a2dfd2327 sub: handle vobsub-in-mp4
The mplayer decoder (spudec.c) actually handled this. There was explicit
code for binary palettes (16 32 bit values), and the subtitle resolution
was handled by video resolution coincidentally matching the subtitle
resolution.

Whoever puts vobsub into mp4 should be punished.

Fixes the sample gundam_sample.mp4, closes github issue #547.
2014-02-13 22:54:47 +01:00
Stefano Pigozzi 8009646583 build: disable clang's tautological compare warnings
This silences two non issues in the client.c file. Fixing them as clang would
want us to, would introduce security bugs and potential crashes.
2014-02-13 22:43:17 +01:00
Stefano Pigozzi 2705c66799 cocoa: fix deadlock during initialization [2]
Fixup commit for 20fa191ad.
2014-02-13 22:22:44 +01:00
wm4 098f0c67e6 player: select subtitles added with sub_add
In particular, this affects drag & drop of subtitles, which uses sub_add
internally. This will make the subtitles show up immediately, instead of
requiring manual selection of the added subtitle.

Might be not so ideal when adding multiple subtitles at once, because
that leads to multiple sub_add commands, and will end up with the last
subtitle instead of the first selected. But this is a minor detail.
2014-02-13 13:30:31 +01:00
wm4 adfda51e8a build: bump libmpg123 version
The minimum required version was bumped in the old configure script, but
for the waf build system is was somehow forgotten or overlooked.
Probably happened while the waf build system was developed in a separate
branch.

Closes #546.
2014-02-13 13:30:30 +01:00
Stefano Pigozzi 20fa191adb cocoa: fix deadlock during initialization
Thanks to @wm4 for catching the bug.

Fixes #405
2014-02-13 13:01:51 +01:00
nand 55f4b592d1 vo_opengl: make :srgb decompand the BT.709 values correctly
This is the same issue as addressed by 257d9f1, except this time for
the :srgb option as well. (257d9f1 only addressed :icc-profile)

The conditions of the srgb_compand mix() call are also flipped to
prevent an off-by-one error.
2014-02-12 22:00:42 +01:00
wm4 958455ac39 vo_wayland: silence shadowing warning 2014-02-12 22:00:23 +01:00
wm4 b8901bf04d command: fix metadata property
This crashed when retrieving the raw property value. Oops.
2014-02-12 22:00:23 +01:00
wm4 914f281bcb manpage: reformat property list
Use a list instead of a table. This makes it easier to provide extended
information about a property, and doesn't require you to fiddle with rhe
RST ASCII-art tables.

Also, extend some property descriptions.
2014-02-12 22:00:22 +01:00
wm4 69769860c2 manpage: lua: move less important events to the end of the list 2014-02-12 22:00:22 +01:00
wm4 b71d492555 manpage: lua: document receiving of terminal messages 2014-02-12 22:00:18 +01:00
wm4 c342dcf096 manpage: lua: rewrite event description
Using such a small table is not such a great idea, because you can't put
much information in it, even if you need to.
2014-02-12 22:00:13 +01:00
wm4 5af8070a97 client API: fix description of mpv_event.error field
The description was a left over from an earlier iteration of the API.
2014-02-12 22:00:13 +01:00
wm4 3abbe31d6b manpage: lua: minor fixes 2014-02-12 22:00:07 +01:00
wm4 623cffdce9 player: fix --force-window on OSX
The initialization code was split and refactored for the libmpv changes.
One change, moving a part of cocoa initialization, accidentally broke
--force-window on OSX, which creates a VO in a certain initialization
stage. We still don't know how cocoa should behave with libmpv, so fix
this with a hack to beat it back into working. Untested.
2014-02-11 20:11:05 +01:00
Alexander Preisinger 5020395c83 man: update wayland options 2014-02-11 18:55:25 +01:00
Alexander Preisinger 0920dc1e26 wayland/shm: rewrite buffer handling
I was unhappy with the old way of handling buffers, especially resizing. But my
original plan to use wl_shm_pool_resize wasn't as good as I initially thought.
I might get back to it.

With the new buffer pools it now possible to select triple buffering. Also the
buffer pools are also needed for the upcoming subsurfaces for osd and subtitles.

I hope this change was worth it.
2014-02-11 18:44:53 +01:00
Alexander Preisinger 0670c541a5 wayland/shm: prevent the window from flying away
With the new xdg_shell the problem will be no gone by itself.
2014-02-11 18:11:14 +01:00
wm4 157d470b31 manpage: fix Lua script shutdown description again
It was split at the wrong sentence.

Also, sneak in a reference to mp.suspend.
2014-02-11 17:41:14 +01:00
wm4 3c13e68a28 manpage: document --aspect special values
Use of these is "discouraged", but they're there to select these special
cases with the "aspect" property. They really should use some sort of
choice option type, but since it would be some work to make these work
with float values, the simple and dumb alternative was picked.
2014-02-11 17:38:55 +01:00
wm4 7448d1958d video: fix --no-aspect
This also affects the --aspect option and the "aspect" property.
2014-02-11 17:36:25 +01:00
wm4 00bb8083ed build: add SONAME to libmpv.so 2014-02-11 15:24:49 +01:00
wm4 37a4e6b583 manpage: use Lua for Lua example 2014-02-11 15:22:02 +01:00
wm4 891f58e834 manpage: document mp.commandv Lua command 2014-02-11 01:25:26 +01:00
wm4 c776ac33e3 manpage: move description of script shutdown to a separate paragraph
No other changes, just adding a paragraph break and reflowing the text.
2014-02-11 01:25:15 +01:00
wm4 d473933923 manpage: fix formatting of example code 2014-02-11 01:14:08 +01:00
wm4 0ed6644ded manpage: document some Lua scripting functions 2014-02-11 01:05:05 +01:00
wm4 212d4e6061 lua: some minor API changes 2014-02-11 00:57:40 +01:00
wm4 33c6cbef3a lua: add set_property function 2014-02-11 00:23:10 +01:00
wm4 444f79d86f lua: change error behavior
Return the error Lua-style, instead of raising it as Lua error. This is
better, because raising errors is reserved for more "fatal" conditions.
Pretending they're exceptions and trying to do exception-style error
handling will just lead to pain in this language.
2014-02-11 00:10:25 +01:00
wm4 7a53dd5f2f lua: rename some API functions
send_command     -> command
send_commandv    -> commandv
get_timer        -> get_time
property_get     -> get_property
property_get_string -> get_property_osd
getopt           -> get_opt
2014-02-11 00:01:57 +01:00
wm4 2868fbea3f av_log: add tons of warnings against mismatched ffmpeg/libav libraries
Print a warning if a library has mismatched compile time and link time
versions.

Refuse to work if the compile time and link time versions are a mix of
ffmpeg and libav. We print an error message and call exit(). Since we'd
randomly crash anyway, I think this is ok.

This doesn't catch the case if you e.g. use a ffmpeg libavcodec and a
libav libavformat, which would of course just crash as quickly, but I
think this checks enough already.
2014-02-10 23:28:10 +01:00
wm4 476a4a378a av_log: restructure version printing code
Makes the following commit simpler.
2014-02-10 23:11:30 +01:00
nand 7d9fff9c6b vo_opengl: fix typo in gamma function's parameter
The correct value is 0.081, not 0.18. The scale factor also needed
slight adjustment due to the order of operations.
2014-02-10 22:11:13 +01:00
Jonas Zetterberg 1fcdf2d849 vo_vdpau: Discard zero timestamps
Some drivers do not supply timestamps, use old timestamp in these conditions.
2014-02-10 22:10:56 +01:00
Jonas Zetterberg c60c784a6a vo_vdpau: Ensure presentation time is within bounds
When a time sync happens the last sync time is the minimum time that can be
used for presentation.
2014-02-10 22:10:54 +01:00
wm4 bbdc47ee80 Merge branch 'client_api' 2014-02-10 22:10:31 +01:00
wm4 a6da2a6608 Add a client API example 2014-02-10 21:30:55 +01:00
wm4 3dd12104d9 build: add option to build a library
This library will export the client API functions.

Note that this doesn't allow compiling the command line player to link
against this library yet. The reason is that there's lots of weird stuff
required to setup the execution environment (mostly Windows and OSX
specifics), as well as things which are out of scope of the client API
and every application has to do on its own. However, since the mpv
command line player basically reuses functions from the mpv core to
implement these things, it's not very easy to separate the command
line player form the mpv core.
2014-02-10 21:25:22 +01:00
wm4 238c9b1d8d build: include a copy of syms.py from upstream waf
The alternatives to copying this small bit of code are even worse.

This is unmodified, except for the added line 3.
2014-02-10 21:08:37 +01:00
wm4 92a004bf87 lua: add a timer API 2014-02-10 21:07:23 +01:00
wm4 206616b697 lua: port to client API
This is partial only, and it still accesses some MPContext internals.
Specifically, chapter and track lists are still read directly, and OSD
access is special-cased too.

The OSC seems to work fine, except using the fast-forward/backward
buttons. These buttons behave differently, because the OSC code had
certain assumptions how often its update code is called.

The Lua interface changes slightly.

Note that this has the odd property that Lua script and video start
at the same time, asynchronously. If this becomes an issue, explicit
synchronization could be added.
2014-02-10 21:03:59 +01:00
wm4 88ae914b1e Add a client API
Add a client API, which is intended to be a stable API to get some rough
control over the player. Basically, it reflects what can be done with
input.conf commands or the old slavemode. It will replace the old
slavemode (and enable the implementation of a new slave protocol).
2014-02-10 21:01:35 +01:00
wm4 c6166ff448 timer: init only once
This avoids trouble if another mpv instance is initialized in the same
process.

Since timeBeginPeriod/timeEndPeriod are hereby not easily matched
anymore, use an atexit() handler to call timeEndPeriod, so that we
can be sure these calls are matched, even if we allow multiple
initializations later when introducing the client API.
2014-02-10 01:12:34 +01:00
wm4 8437356b6c options: add --no-terminal switch
Mostly useful for internal reasons. This code will be enabled by
default if mpv is started via the client API.
2014-02-10 00:14:52 +01:00
wm4 20fbe2fb8c threads: add a dispatch queue thing
Makes working with the (still) single-threaded playback thread easier.

Might be reusable for other stuff.
2014-02-10 00:04:39 +01:00
wm4 dd264ebe9d threads: avoid timeout calculation overflow
It's quite possible to overflow the calculation by setting the timeout
to high values. Limit it to INT_MAX, which should be safe. The issue is
mainly the secs variable.

timespec.tv_sec will normally be 64 bit on sane systems, and we assume
it can't overflow by adding INT_MAX to it.
2014-02-10 00:04:39 +01:00
wm4 7aa3726c9a demux_mkv: remove weird seeking semantics for audio
This skipped all audio packets before the first video key frame was
found. I'm not really sure why this would be needed; most likely it
isn't. So get rid of it. Even if audio packets are returned to the
player too soon, the player will sync the audio start to the video
start by decoding and discarding audio data.

Note that although the removed code was just added in the previous
commit, it merely kept the old keeping semantics which demux_mkv
always followed. This commit removes these special semantics.
2014-02-09 21:13:03 +01:00
wm4 4dbd5df174 demux_mkv: improve audio-only seeking
v_skip_to_keyframe is set to true while non-keyframe video packets are
skipped. Until now, audio packets were also skipped when doing this. I
can't see any good reason why this would be done, but for now I want to
keep the old logic when audio+video seeks are done.

However, for audio-only mode, do proper seeking, which also fixes
behavior when trying to seek past the end of the file: playback is
terminated properly, instead of starting playback on the start of the
last cluster.

Note that a_no_timecode_check is used only for audio+video seek. I'm
not sure what this is needed for, but it might influence A/V sync after
seeking.
2014-02-09 20:50:24 +01:00
wm4 ad782a53ef demux: fix some newlines in output messages 2014-02-09 18:59:57 +01:00
wm4 c0771b8144 player: fix an assert when reinitializing audio in some cases
This sometimes happened when changing playback speed (= reinitializing
audio) after seeking of playback start. The assertion in audio.c:441 was
triggered, because buffer_playable_samples wasn't reset correctly when
the audio buffer was cleared or shortened. The assertion is correct and
should hold up any time.
2014-02-09 18:59:44 +01:00
nand 257d9f1610 vo_opengl: use exactly the values defined by BT.709 for CMS
I could not see any difference whatsoever, but for usage with a 3DLUT
there's zero performance difference so we might as well follow the spec to
the letter.
2014-02-09 14:42:39 +01:00
wm4 7f744c9a16 msg: clear lines by printing spaces on MS Windows
On Windows, no ANSI control sequences are available, so we can't easily
clear lines, move the cursor, etc. It's yet to be decided how this
should be handled (emulate ANSI escapes in osdep/terminal-win.c, or
provide abstracted terminal API functions to unify the Linux and Windows
code).

For now, this fixes the regression that was introduced earlier by the
status line rewrite. It doesn't fix all aspects of status line and
terminal OSD handling, as can be clearly seen by the unconditional use
of terminal_erase_to_end_of_line further down the changed code.

Fixes github issue #499 (sort of).
2014-02-09 00:45:26 +01:00
wm4 8eaf6c42ac demux_lavf: work around idiotic libavutil API printing a warning
Trying to set a non-existent flag (like +keepside on Libav) causes
libavutil print an incomprehensible warning (something about eval;
probably the overengineered libavutil option parser tripping over the
'+' normally used for flags, and trying to interpret it as formula).

There's apparently no easy way to check for the existence of a flag,
so add some more ifdeffery to shut it up.
2014-02-08 01:04:37 +01:00
wm4 17ec073a15 player: handle seek delays differently
The code removed from handle_input_and_seek_coalesce() did two things:

1. If there's a queued seek, stop accepting non-seek commands, and delay
   them to the next playloop iteration.
2. If a seek is executing (i.e. the seek was unqueued, and now it's
   trying to decode and display the first video frame), stop accepting
   seek commands (and in fact all commands that were queued after the
   first seek command). This logic is disabled if seeking started longer
   than 300ms ago. (To avoid starvation.)

I'm not sure why 1. would be needed. It's still possible that a command
immediately executed after a seek command sees a "seeking in progress"
state, because it affects queued seeks only, and not seeks in progress.
Drop this code, since it can easily lead to input starvation, and I'm
not aware of any disadvantages.

The logic in 2. is good to make seeking behave much better, as it
guarantees that the video display is updated frequently. Keep the core
idea, but implement it differently. Now this logic is applied to seeks
only. Commands after the seek can execute freely, and like with 1., I
don't see a reason why they couldn't. However, in some cases, seeks are
supposed to be executed instantly, so queue_seek() needs an additional
parameter to signal the need for immediate update.

One nice thing is that commands like sub_seek automatically profit from
the seek delay logic. On the other hand, hitting chapter seek multiple
times still does not update the video on chapter boundaries (as it
should be).

Note that the main goal of this commit is actually simplification of the
input processing logic and to allow all commands to be executed
immediately.
2014-02-07 22:29:50 +01:00
wm4 67769db1a4 gl_x11: don't require a X visual for modern GL context creation
Legacy GL context creation (glXCreateContext) explicitly requires a X
visual, while the modern one (glXCreateContextAttribsARB) does not for
some reason. So fail only on the legacy code path if we don't find a
visual. Note that vo_x11_config_vo_window() will select a default visual
if a NULL visual is passed to it.
2014-02-06 14:33:30 +01:00
wm4 7134574f53 gl_x11: always request true color visual
This fixes issue #504. For some reason, glXChooseFBConfig() will return
a fbconfig with no associated visual. (I'm not sure if this allowed.
They don't always have a visual, but since GLX_X_RENDERABLE is set
and GLX_DRAWABLE_TYPE is (implicitly) set to GLX_WINDOW_BIT, why would
there be no visual?)

Even worse, a test program seems to show that a 16 bit fbconfig is
selected (instead of 24/32 bit), which doesn't sound nice at all. Since
there _are_ better fbconfigs available, glXChooseFBConfig() should
normally sort them by quality, and return the better ones first. It's
worth noting that this function should also prefer GLX_TRUE_COLOR
over anything else, although this comes last in the sort order.

Whatever is going on, requesting GLX_X_VISUAL_TYPE with GLX_TRUE_COLOR
seems to fix it.
2014-02-06 14:12:04 +01:00
wm4 41a5837e2b demux_lavf: do metadata-from-packet update before possibly discarding it
There is some logic to discard packets from streams that are not
selected. Run the metadata update code before this, just to make 100%
sure that no metadata updates can be lost when streams are deselected.

(I'm not sure why this logic would be needed, since both libavformat and
the generic demuxer code do this already. But a quick test shows that
av_read_frame() can return a packet from a stream even if the stream has
AVStream.discard set to AVDISCARD_ALL. This happened after stream
switching. Maybe libavformat doesn't discard already queued packets.)
2014-02-06 14:11:12 +01:00
wm4 47bc87208b demux_lavf: don't check for error when setting "keepside" flag
This flag doesn't exist on Libav (because they never do this insane
packet merging stuff), so this would print unnecessary warnings there.
2014-02-06 14:05:04 +01:00
Timothy Gu 30ffbc65bd DOCS/waf-buildsystem: add link to the Waf book 2014-02-06 13:45:35 +01:00
Timothy Gu 01d9e40200 DOCS/crosscompile-mingw: use Markdown 2014-02-06 13:45:23 +01:00
Timothy Gu 515a30d9a5 DOCS/crosscompile-mingw: update
MXE's ffmpeg is not old anymore.
2014-02-06 13:45:11 +01:00
wm4 7fbf9e0efd demux: reword "Clip info:" line to "File tags:" 2014-02-06 13:43:30 +01:00
wm4 bc35d4fcb4 demux: fill metadata directly, instead of using wrapper functions
Get rid of demux_info_add[_bstr] and demuxer_add_chapter_info.

Make demuxer_add_chapter_info return the chapter index for convenience.
2014-02-06 13:43:01 +01:00
wm4 39b932042b demux_lavf: clear metadata on update, instead of merging it
Assume a metadata update is a full update. Clear the previous metadata,
so that tags which existed only in the previous metadata are removed.
2014-02-06 13:42:30 +01:00
wm4 eb1ec14b67 demux: handle tag updates differently
Instead of printing lines like:

    Demuxer info GENRE changed to Alternative Rock

Just output all tags once they change. The assumption is that individual
tags rarely change, while all tags change in the common case.

This changes tag updates to use polling. This could be fixed later,
although the ICY stuff makes it a bit painful, so maybe it will remain
this way.

Also remove DEMUXER_CTRL_UPDATE_INFO. This was intended to check for tag
updates, but now we use a different approach.
2014-02-06 13:41:20 +01:00
wm4 5693b5ae16 stream_lavf: prefix icy metadata with "icy-"
ICY metadata is not always of good quality, and especially if there are
proper tags. We don't want the ICY metadata override the tags.
2014-02-06 13:40:09 +01:00
Ben Boeckel ef68cfcc8a demux_lavf: get updated metadata from a packet if available
The side_data type is brand new in ffmpeg.
2014-02-06 13:39:55 +01:00
wm4 e6861ca51f umpv: silence mpv terminal output
Now it does basically the same as mkv.desktop. Explanation is included
in the description comment.
2014-02-05 19:04:35 +01:00
wm4 a6f04a41fe umpv: improve description 2014-02-05 19:01:06 +01:00
wm4 f77efbcce9 umpv: use --force-window
This makes it show a window even when playing audio-only files.
2014-02-05 18:55:06 +01:00
wm4 fdd5d00be3 audio: fix signedness of AF_FORMAT_S32P
This was marked as unsigned, but it's signed. Found by xylosper.
2014-02-05 18:53:00 +01:00
wm4 8edf2cda4b io: make MP_PATH_MAX private to win32 code
The win32 code is the only thing which actually needs this (and it's
used to make emulation of UTF-8 filename APIs easier).
2014-02-03 22:12:30 +01:00
wm4 d91b9e9f3b mf: don't limit filename length with PATH_MAX
Use an arbitrary constant instead, which is as good as PATH_MAX.

This helps us to avoid having to think about pull request #523.

Also fix a case where a potentially signed char was passed to isspace().
2014-02-03 22:11:03 +01:00
wm4 208c54a710 player: refresh OSD on track switching
Apparently, at least sub_reload was missing a refresh at all.
2014-02-03 22:01:09 +01:00
wm4 b270f5e177 command: output more information in colorspace properties and simplify
Instead of trying to be clever to avoid outputting redundant
information, simply output everything that we have.
2014-02-03 22:01:09 +01:00
wm4 d03111c5be csputils: correct constness of csp name constants 2014-02-03 22:01:09 +01:00
Alexander Preisinger 44bfe3b14a wayland: change minimum version
Change minimum version to 1.3 and remove the version checking in the source
code.
2014-02-02 08:46:13 +01:00
wm4 c8b754e38f x11: fix initial VO size
This was done incorrectly in the previous commit: the fallback size used
the window size as requested with the first config call, which is the
size of the hidden window in the vo_opengl case. (That damn hidden
window again...)
2014-02-02 03:19:36 +01:00
wm4 b57a0a0bc6 x11: remove apparently useless code
This code essentially does nothing. As far as I could find out, this
actually used to do something. Then it was removed with commit efe7c39f,
leaving some leftover code that didn't do anything useful. This happened
12 years ago!

Also remove a commented debug printf.
2014-02-02 01:50:25 +01:00
wm4 fc04be708c x11: fix race condition when setting aspect when leaving fullscreen
vo_opengl creates a hidden X11 window to probe the OpenGL context. It
must do that before creating a visible window, because VO creation and
VO config are separate phases.

There's a race condition involving the hidden window: when starting with
--fs, and then leaving fullscreen, the unfullscreened window is
sometimes set to the aspect ratio of the hidden window. I'm not sure why
the window size itself uses the correct size (but corrupted by the wrong
aspect), but that's perhaps because the window manager is free to ignore
the size hint while honoring the aspect, or something equally messed up.

It turns out this happens because x11_common.c thinks the size of the
hidden window is the size of the unfullscreened window. This in turn
happens because vo_x11_update_geometry() reads the size of the hidden
window when called in vo_x11_fullscreen() (called from
vo_x11_config_vo_window()) when mapping the fullscreen window. At that
point, the window could be mapped, but not necessarily. If it's not
mapped, it will get the size of the unfullscreened window... I think.

One could fix this by actively waiting until the window is mapped. Try
to pick a less hacky approach instead, and never read the window size
until MapNotify is received.

vo_x11_create_window() needs a hack, because we'd possibly set the VO's
size to 0, resulting e.g. in vdpau to fail initialization. (It'll print
error messages until a proper resize is received.)
2014-02-02 01:35:46 +01:00
wm4 fc541ab4f5 old-configure: use -std=c99
See previous commit.
2014-02-02 00:54:56 +01:00
wm4 74b8223da6 build: switch to -std=c99 for saner float semantics
This fixes a weird bug with aspect ratio handling. It has to do with
float handling: with -std=gnu99, gcc implicitly enables broken non-
standard semantics giving float variables excess precision. This can for
example make this fail in theory: "float a = 0.1; assert(a == a);"

While standard C allows excess precision _within_ expressions, it
requires truncation when storing float values in variables of types
"float" or "double". The "gnu99" mode breaks this. It can be unbroken by
using "c99", or by specifying -fexcess-precision=standard. The former
seems less likely to break compilers other than modern gcc. Note that
-ffloat-store would also fix this, but also makes float expressions less
efficient and less precise for no reason.

The code that mistakenly fails because of this is dec_video.c line 393.
It caused the container aspect to be ignored in some or all situations,
depending how the compiler optimizes. For example, on gcc-4.6 with -Os,
the aspect is always ignored.

In future, we should probably just get rid of storing aspects as floats.
2014-02-02 00:00:14 +01:00
wm4 eb17780740 cache: refuse to seek outside of cache boundaries
Note that this still happens in the stream level, so we can't have
nice highlevel behavior restricting seeking. Instead, if a seek leads
to the demuxer requesting data outside of the cached range, the seek
will simply fail. This might confuse the demuxer, and the resulting
behavior is not necessarily useful.

Note that this also doesn't try to skip data on a forward seek. This
would just freeze the stream with slow unseekable streams.

One nice thing is that stream.h has a separate function for merely
skipping data (separate from seeking forward), which is pretty useful
in this case: we want skipping of data to work, even if we reject
seeking forward by skipping data as too expensive. This probably is
or will be useful for demux_mkv.c.
2014-01-31 22:40:35 +01:00
wm4 d8dd9a6725 threads: add function to calculate deadline for timed waits
Usually, you have to call pthread_cond_timedwait() in a loop (because it
can wake up sporadically). If this function is used by another higher
level function, which uses a relative timeout, we actually have to
reduce the timeout on each iteration - or, simpler, compute the
"deadline" at the beginning of the function, and always pass the same
absolute time to the waiting function.

Might be unsafe if the system time is changed. On the other hand, this
is a fundamental race condition with these APIs.
2014-01-31 22:17:43 +01:00
wm4 a17be5576f threads: add wrapper for initializing recursive mutexes
Damn this overly verbose pthread API.
2014-01-31 19:50:25 +01:00
wm4 2305ffcaba demux_mkv: remove unused field 2014-01-31 19:49:48 +01:00
wm4 00af143176 demux_lavf: fix crash with empty files
This used to work; I'm not sure when or why it regressed. When setting
AVProbeData.filename to NULL, libavformat will crash in rtp_probe() by
unconditionally accessing the string.

We used to set the filename to NULL to prevent probing by file extension
when we don't deem it as necessary. Using an empty string also works for
this purpose.
2014-01-31 01:36:09 +01:00
wm4 8ff1a339e9 quvi: disable subtitle fetching by default
This is slow and unreliable, basically unusable.
2014-01-31 00:46:52 +01:00
wm4 36f6e6b826 options: alternative way to specify color options
Try to make it more intuitive by not requiring hex values. The new way
uses float values in the range 0.0-1.0, separated by '/' (':' was
suggested, but that wouldn't allow color options in sub-options).

Example: --osd-color=1.0/0.0/0.0/0.75

Using the range 0.0-1.0 has the advantage that it could be easily
extended to colors beyond 8 bit.

Details see manpage.

Suggestions for alternative syntax or value ranges are welcome, but be
quick with it.
2014-01-31 00:41:54 +01:00
wm4 5c8ec31ba3 vo_wayland: silence shadowing warning
No real problem.
2014-01-29 17:16:36 +01:00
wm4 5035bccb41 msg: don't clear the status line if new and previous status was empty
This avoids stray newlines when:

1. Some (non-status line) text was output
2. Then an empty status line is output

According to the logic, 2. should print an empty line to show the blank
status line. Don't do that, and instead output nothing in this case.

This caused problems with mpv_identify.sh, and also looked ugly when
using --quiet.
2014-01-29 17:15:05 +01:00
wm4 8e61e9ed6e mp_image: reject too large image sizes
Larger sizes can introduce overflows, depending on the image format. In
the worst case, something larger than 16000x16000 with 8 bytes per pixel
will overflow 31 bits.

Maybe there should be a proper failure path instead of a hard crash, but
not yet. I imagine anything that sets a higher image size than a known
working size should be forced to call a function to check the size (much
like in ffmpeg/libavutil).
2014-01-29 17:01:42 +01:00
wm4 46c9dfe2e7 sd_lavc: skip 0 sized sub-bitmaps
Not everything in the OSD path handles 0x0 sized sub-bitmaps well. At
least the code implementing --sub-gray had severe problems with it.

Fix this by skipping such bitmaps.
2014-01-29 16:52:40 +01:00
Alexander Preisinger cd2cfc8056 wayland/shm: RGB888 as default, change options
RGB565 is one of the fastest and most supported formats on low end consumer
devices, but ffmpeg spams warning when using it. Make it opt-in instead of
opt-out.
2014-01-28 13:52:12 +01:00
Alexander Preisinger 0f90288bf6 wayland/shm: fix memory leak 2014-01-28 13:30:58 +01:00
Alexander Preisinger 3114390c5b wayland/shm: remove resize boilerplate
The problem seems to have solved itself. I guess the previous changes to
resizing and commit ba101ab made this possible. Consider me happy for removing
that crap.
2014-01-28 13:15:36 +01:00
James Ross-Gowan d26ee98fa6 w32: use safe DLL search paths everywhere
Windows applications that use LoadLibrary are vulnerable to DLL
preloading attacks if a malicious DLL with the same name as a system DLL
is placed in the current directory. mpv had some code to avoid this in
ao_wasapi.c. This commit just moves it to main.c, since there's no
reason it can't be used process-wide.

This change can affect how plugins are loaded in AviSynth, but it
shouldn't be a problem since MPC-HC also does this and it's a very
popular AviSynth client.
2014-01-27 10:04:29 +01:00
James Ross-Gowan 4c83a93617 w32: enable heap corruption detection
Enable the terminate-on-corruption feature. This is recommended for new
Windows applications and shouldn't cause a performance hit. It actually
shouldn't change anything for 64-bit builds, since Win64 has this
switched on by default.

See:
http://blogs.msdn.com/b/michael_howard/archive/2008/02/18/faq-about-heapsetinformation-in-windows-vista-and-heap-based-buffer-overruns.aspx
2014-01-27 10:04:29 +01:00
James Ross-Gowan c3bcc12a3c w32: don't disable the error reporting dialog
Windows users expect this when a program crashes. Without it, the
program just disappears. Also change the SetErrorMode call to use macros
instead of a hardcoded constant.
2014-01-27 10:04:29 +01:00
wm4 1e73da47da sub: fix crash with certain uses of --vf=sub
If, for some reason, the subtitle renderer attempts to render a
subtitle before SD_CTRL_SET_VIDEO_PARAMS was called, it passed a
value calculated from invalid values. This can happen with --vf=sub
and --start. The crash happens if 1. there was a subtitle packet that
falls into the timestamp of the rendered video frame, 2. the playloop
hasn't informed the subtitle decoder about the video resolution yet
(normally unneeded, because that is used for weird corner cases only,
so this code is a bit fuzzy), and 3. something actually requests a
frame to be drawn from the subtitle renderer, like with vf_sub.

The actual crash was due to passing NaN as pixel aspect to libass,
which then created glyphs with ridiculous sizes, involving a few
integer overflows and unchecked mallocs.

The sd_lavc.c and sd_spu.c cases probably don't crash, but I'm not
sure, and it's better fix them anyway.

Not bothering with sd_spu.c, this crap is for compatibility and will
be removed soon.

Note that this would have been no problem, had the code checked whether
SD_CTRL_SET_VIDEO_PARAMS was actually called. This commit adds such a
check (although it basically checks after using the parameters).

Regression since 49caa0a7 and 633fde4a.
2014-01-26 18:58:40 +01:00
wm4 b4ea5018f2 demux_lavf: add hack to workaround too unreliable mp3 detection
This generally affects mp3 files that don't have any (or many) mp3
frames in the first 2 MB. 2 MB is the maximum probe size, and
libavformat returns a low probescore even if we give it the full 2 MB.
Trying to probe a larger buffer (or even the full file) doesn't work for
mysterious reasons.

The workaround consists in accepting a very weak probescore if the
format is detected as mp3 and we probed already 2 MB.
2014-01-25 23:01:00 +01:00
wm4 4ed7b3c2f9 demux_lavf: refactor format probing hack
Restructure it a bit, so we can use the format hack list even if no mime
type applies. Shouldn't change anything functionally yet. Preparation
for the next commit.
2014-01-25 22:57:52 +01:00
Stefano Pigozzi 3137a1a7b5 build: fix usage of HAVE_SDL1 define
This is needed after fd1f8ed49.
2014-01-25 09:18:07 +01:00
wm4 fd1f8ed490 waf: rename --enable-sdl to --enable-sdl1
Grossly misleading.
2014-01-25 00:30:28 +01:00
wm4 bb54cf9559 vo_sdl: fix compilation
Still untested, because now it crashes inside of libSDL for unknown
reasons. (This also happens with mpv git from yesterday - probably an
installation problem, or SDL doing weird things it shouldn't be doing.)
2014-01-25 00:26:35 +01:00
wm4 39b40e1ffb audio/filter: remove redundant log message prefixes
These are now appended automatically, so you'd get them twice before
this commit.
2014-01-24 21:30:15 +01:00
wm4 f46e188ec5 vo_wayland: fix confusion of video and window sizes 2014-01-24 21:23:07 +01:00
wm4 2e66f4b89b video/out: do remaining config to reconfig replacements
The main difference between the old and new callbacks is that the old
callbacks required passing the window size, which is and always was very
inconvenient and confusing, since the window size is already in
vo->dwidth and vo->dheight.
2014-01-24 21:22:25 +01:00
reimar 7a6227a184 stream_pvr: Fix fd check, -1 indicates invalid, not 0.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@36677 b3059339-0415-0410-9bf9-f77b7e298cf2
2014-01-23 22:44:10 +01:00
wm4 8b0cfdc81e audio: fix balance control
Balance controls as used by mixer.c was broken, because af_pan.c stopped
accepting its arguments. We have to allow 0 channels explicitly. Also,
fix null pointer access if the matrix parameter is not used.

Regression from commit 82983970.
2014-01-23 15:53:36 +01:00
wm4 af5c393d2c demux_mkv: nicer edition output
If there's more than one edition, print the list of editions, including
the edition name, whether the edition is selected, whether the edition
is default, and the command line option to select the edition. (Similar
to stream list.)

Move reading the tags to a separate function process_tags(), which is
called when all other state is parsed. Otherwise, that tags will be lost
if chapters are read after the tags.
2014-01-23 00:54:08 +01:00
wm4 16534bbd81 demux_mkv: don't attempt to seek back when indexing
Pretty worthless. This is called from the seek code, which will
reinitialize these anyway. Even if seeking somehow decides to fail, the
new values are still valid.

One could say a failed seek (if that happens) should jump back to the
original position, and thus it would be better to make sure the state
is restored. But then demux_mkv_seek needs to do this correctly,
including not setting up skipping to the target timestamp. But not
bothering with this.
2014-01-22 23:48:57 +01:00
wm4 63fdeb79be demux_mkv: fix EOF with concatenated segments
Extremely obscure corner case with concatenated segments, in which EOF
wasn't recognized correctly, and it tried to demux clusters from the
next segment.

See [MKV]_Editions,_Linked_Segments,_&_Tracksets.mkv from the CCCP test
file collection.
2014-01-22 23:37:03 +01:00
wm4 f3db4b0b93 demux_mkv: remove old track printing code
This basically used to be part of the user interface, before mpv moved
printing the track list to the frontend, and this code was raised to
verbose output level.
2014-01-22 22:37:26 +01:00
wm4 774eb1d98d demux_mkv: always fail on header reading error
For some reason, if an error happened when reading headers, it merely
stopped reading the headers, and then continued normally. (It looks like
the case to exit hard (-2) was mainly used for skipping unwanted ordered
chapter segments.)

I can't comprehend this. Always exit on error when reading headers.
(Maybe some more error tolerance would be good, but I have no test case,
and there's some danger of entering endless loops.)
2014-01-22 22:33:55 +01:00
wm4 85bd178dbe demux_mkv: avoid seeking when reading headers
This makes everything more robust, and also somewhat simpler (even if
the diffstat isn't very impressive).

Instead of recursively following SeekHeads while reading headers, just
read the headers until the first cluster, and then possibly use
SeekHeads to read the remaining missing headers.
2014-01-22 22:17:01 +01:00
wm4 0931cff1e9 aspect: remove a small ffmpeg dependency
Not strictly needed, but probably saves us pain the next time
ffmpeg mess up their headers.
2014-01-22 00:35:52 +01:00
wm4 38d29c487c vo: merge get rid of vo.aspdat field
Rename vo_get_src_dst_rects() to mp_get_src_dst_rects() and make it
independent from the VO (it takes a comical amount of parameters now to
pass all required state). Add a convenience wrapper with the name
vo_get_src_dst_rects() to vo.c. Replace all aspdat and vo usages with
immediate parameters.

Functionally, nothing should change, except that the window size is
clamped to a minimum of size 1 much earlier, and some log messages
change the prefix (don't bother with vo.vo_log stuff).
2014-01-22 00:35:52 +01:00
wm4 0f2acd4a80 vo: move vo_get_src_dst_rects to aspect.c
The plan is to make all the code in aspect.c independent from vo.c,
which should make the code easier to understand, will allow removal of
vo->aspdat, and reduces the amount of code that accesses weird mutable
struct vo fields.
2014-01-22 00:35:52 +01:00
wm4 4de73fd5c1 video/out: don't access aspdat in VOs
vo->aspdat is basically an outdated version of vo->params, plus some
weirdness. Get rid of it, which will allow further cleanups and which
will make multithreading easier (less state to care about).

Also, simplify some VO code by using mp_image_set_attributes() instead
of caring about display size, colorspace, etc. manually. Add the
function osd_res_from_image_params(), which is often needed in the case
OSD renders into an image.
2014-01-22 00:35:52 +01:00
wm4 302e8ff464 vo_opengl: don't assume there'a always 1 fbconfig on success
Seems to be a reasonable assumption, but it's probably not guaranteed.
2014-01-21 23:34:02 +01:00
Stefano Pigozzi 369e88c99b cocoa: remove dead code
This became dead code in commit 3f594c2e.
2014-01-21 23:32:07 +01:00
wm4 a48a1db1d0 waf: try to fix unicode/byte string messup
Some mpv builds identify with e.g. "mpv b'0.3.3' ". The version looks
like str() was called on a Python byte string. I couldn't reproduce it
on my machine (I tried with both Python 2 and 3), so I'm not exactly
sure what's going on here, but I'm hoping this commit does fix it.
2014-01-21 21:41:53 +01:00
wm4 0a4fc15d26 lua: allow ~ path convention for --lua
Paths passed to the --lua option now follow the convention for paths
starting with ~ documented in mpv.rst.
2014-01-21 21:23:42 +01:00
James Ross-Gowan 63a76b3d1c w32_common: Fix extended keys
The KF_* flags work on the HIWORD of lParam. Whoops
2014-01-21 00:41:56 +01:00
wm4 119efdc197 lua: add playback-start event 2014-01-20 19:31:23 +01:00
wm4 0f5e22079a playlist_parser: restore ASX parsing etc.
This was broken yesterday: the playlist demuxer will always fall back to
plaintext playlist files, which will cause the ASX playlist parser and
some others never to be called.
2014-01-20 19:31:23 +01:00
wm4 1179676eb4 player: fix initial osd progbar state
This made seeking show an empty progbar if --osd-level=0 was used.
2014-01-20 19:31:23 +01:00
Bilal Syed Hussain 32fea9e607 cocoa: sort files opened from Finder the same way Finder does
Fixes #497
2014-01-20 09:06:30 +01:00
wm4 1485711d61 manpage: fix af_equalizer syntax
This doesn't need quoting, for some reason.
2014-01-19 22:47:12 +01:00
wm4 7c34e0226f demux_playlist: move parser for plaintext playlists
This was implemented in playlist_parser.c. To make it use the improved
implementation of stream_read_line(), move it to demux_playlist.c.
2014-01-19 21:15:55 +01:00
wm4 ef006dcae6 stream: print stream_read_line warnings by default
This is probably ok. Probing could hit this case very often, since it'll
mean running this function on potentially binary data, but on the other
hand, probing usually uses a memory stream (to limit the amount of data
read), and memory streams have s->log silenced (details see
open_memory_stream()).
2014-01-19 21:15:55 +01:00
wm4 77e92bbb11 stream: treat embedded 0 bytes as error in stream_read_line
Text files should never contain these.
2014-01-19 21:15:54 +01:00
wm4 333a9491b7 stream: redo stream_read_line()
This simplifies the implementation and should make it more robust. For
example, we return an error if a line is longer than the provided buffer
(instead of splitting the line).

The code is much shorter, because now finding the new line and reading
characters is done in one go.
2014-01-19 21:15:54 +01:00
wm4 6afebbd0d9 demux_playlist: handle stream_read_line() errors
As of this commit, stream_read_line() can't actually error (except in
the case the passed in buffer is 0, which never happens here). This
commit is preparation for the following commit, which checks harder
whether the read data is actually text. Before this commit, an error
was treated as end-of-file, but the data read so far was considered
valid.
2014-01-19 21:15:54 +01:00
11rcombs a0cc204528 af: fixed out-of-bounds accesses caused by NUM_FMT and co.
Signed-off-by: wm4 <wm4@nowhere>

This merges pull request #496. The problem was that at least the
initialization of the distance[] array accessed af_fmtstr_table[]
entries that were out of bounds. Small cosmetic changes applied to
the original pull request.
2014-01-19 21:15:54 +01:00
James Ross-Gowan 32c0df1b53 w32: use the w32_common keymap in terminal-win too 2014-01-19 14:42:15 +01:00
reimar 55ea419ae3 cookies.c: cols must (and does) have 7 elements.
Doesn't affect the generated code, but avoids confusion
in both humans and newer Coverity versions.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@36623 b3059339-0415-0410-9bf9-f77b7e298cf2
2014-01-19 12:58:03 +01:00
reimar 8e2f301ee4 vcd_read: Fix sizeof argument.
The struct we need to copy is actually a cdrom_msf0, not cdrom_msf.
Even though the kernel for no good reason reads it in as a
cdrom_msf struct, but only uses the part shared with cdrom_msf0 -
this is probably a kernel bug.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@36622 b3059339-0415-0410-9bf9-f77b7e298cf2
2014-01-19 12:57:50 +01:00
wm4 2120a75a83 mpv.desktop: add some more mimetypes
Again from github issue #484.

Also, sorry for the typo in the earlier commit message.
2014-01-18 22:42:59 +01:00
wm4 03859a581c player: prevent null pointer deref on uninit after -V
Caused by the OSD changes. Fixes #490.
2014-01-18 17:59:34 +01:00
wm4 8cbed35403 mkv.desktop: add two more mime types
Stolen from github issue #484. No idea whether they're needed.
2014-01-18 16:46:27 +01:00
wm4 6f520bb956 osd: fix dvdnav highlights
Broken by previous commit.
2014-01-18 16:40:39 +01:00
wm4 7f4a09bb85 sub: uglify OSD code path with locking
Do two things:
1. add locking to struct osd_state
2. make struct osd_state opaque

While 1. is somewhat simple, 2. is quite horrible. Lots of code accesses
lots of osd_state (and osd_object) members. To make sure everything is
accessed synchronously, I prefer making osd_state opaque, even if it
means adding pretty dumb accessors.

All of this is meant to allow running VO in their own threads.
Eventually, VOs will request OSD on their own, which means osd_state
will be accessed from foreign threads.
2014-01-18 01:27:43 +01:00
wm4 92a9f11a0b sub: uglify sub decoder with locking
The plan is to make the whole OSD thread-safe, and we start with this.

We just put locks on all entry points (fortunately, dec_sub.c and all
sd_*.c decoders are very closed off, and only the entry points in
dec_sub.h let you access it). I think this is pretty ugly, but at least
it's very simple.

There's a special case with sub_get_bitmaps(): this function returns
pointers to decoder data (specifically, libass images). There's no way
to synchronize this internally, so expose sub_lock/sub_unlock functions.

To make things simpler, and especially because the lock is sort-of
exposed to the outside world, make the locks recursive. Although the
only case where this is actually needed (although trivial) is
sub_set_extradata().

One corner case are ASS subtitles: for some reason, we keep a single
ASS_Renderer instance for subtitles around (probably to avoid rescanning
fonts with ordered chapters), and this ASS_Renderer instance is not
synchronized. Also, demux_libass.c loads ASS_Track objects, which are
directly passed to sd_ass.c. These things are not synchronized (and
would be hard to synchronize), and basically we're out of luck. But I
think for now, accesses happen reasonably serialized, so there is no
actual problem yet, even if we start to access OSD from other threads.
2014-01-17 23:21:17 +01:00
wm4 49ebbce3e0 player: remove OSD message IDs
These were needed before the last commit, but now they don't do anything
anymore. (They were used to decide whether to replace or stack the
previous OSD message when a new one was displayed.)
2014-01-17 22:34:47 +01:00
wm4 a0a2ea8713 player: remove OSD stack
If certain OSD messages were displayed at the same time, the hidden
messages were put on the stack, and displayed again once the higher
priority messages disappeared. The idea was probably that lower priority
messages could not hide higher priority ones, and also that the lower
messages did not get lost.

But in practice, this gives confusing results with OSD messages randomly
reappearing for a brief time. Remove it.
2014-01-17 22:26:04 +01:00
wm4 c47c59f2df player: don't use OSD message stack for term OSD subs
Showing subtitles on terminal used the OSD message stack (which uses a
stack to "pile up" messages that were displayed at the same time). This
had a bunch of weird and annoying consequences. This accessed a certain
osd_state field, which is a minor annoyance since I want to make that
struct opaque. Implement this differently.
2014-01-17 21:55:23 +01:00
wm4 7e1bc6be00 cache: remove debug code
This was accidentally committed.

<rcombs> `mp_sleep_us(100000);` <-- are you drunk?
2014-01-17 00:15:14 +01:00
wm4 d3b5643589 lua: add a --lua-opts option, which can be queried by scripts
The values set by this new option can be queried by Lua scripts using
the mp.getopt() function. The function takes a string parameter, and
returns the value of the first key that matches. If no key matches, nil
is returned.
2014-01-16 23:06:41 +01:00
wm4 82067e6ac3 options: add key/value pair list option type 2014-01-16 23:06:41 +01:00
wm4 68f46675bc cache: reduce message spam
Output only 1 message every 5 seconds at most.
2014-01-16 23:06:41 +01:00
Tomáš Chvátal 788241649d mpv.desktop: use %U in desktop file as we can open urls
Signed-off-by: wm4 <wm4@nowhere>
2014-01-16 23:06:41 +01:00
wm4 e10e1a57d0 lua: use core log level names
When the Lua code was written, the core didn't have names for log levels
yet (just numbers). The only user visible change is that "verbose"
becomes "v", since this level had different names.
2014-01-16 23:06:41 +01:00
wm4 d646d78ccb lua: allow scripts to snoop messages
Adds the following Lua function to enable message events:

    mp.enable_messages(size, level)

size is the maximum number of messages the ringbuffer consists of. level
is the minimum log level for a message to be added to the ringbuffer,
and uses the same values as the mp.log() function. (Actually not yet,
but this will be fixed in the following commit.)

The messages will be delivered via the mp_event() in the user script,
using "message" as event name. The event argument is a table with the
following fields:

    level: log level of the message (string as in mp.log())
    prefix: string identifying the module of origin
    text: contents of the message

As of currently, the message text will contain newline characters. A
message can consist of several lines. It is also possible that a
message doesn't end with a newline, and a caller can use multiple
messages to "build" a line. Most messages will contain exactly 1 line
ending with a single newline character, though.

If the message buffer overflows (messages are not read quickly enough),
new messages are lost until the queued up messages are read. At the
point of the overflow, a special overflow message is inserted. It will
have prefix set to "overflow", and the message text is set to "".

Care should be taken not to print any messages from the message event
handler. This would lead to an infinite loop (the event handler would be
called again after returning, because a new message is available). This
includes mp.log() and all mp.msg.* functions. Keep in mind that the Lua
print() function is mapped to mp.msg.info().
2014-01-16 23:06:40 +01:00
wm4 8c5ea38cda msg: expose log level names 2014-01-16 23:06:40 +01:00
wm4 738dfbb2fe msg: add a mechanism to output messages to a ringbuffer
Until now, mp_msg output always went to the terminal. There was no way
to grab the stream of output messages. But this will be needed by
various future changes: Lua scripts, slave mode, client library...

This commit allows registering a ring buffer. A callback would be more
straight-forward, but since msg.c sits at the bottom of the lock
hierarchy (it's used by virtually everything), this would probably be a
nightmare. A ring buffer will be simpler and more predictable in the
long run.

We allocate new memory for each ringbuffer entry, which is probably a
bit expensive. We could try to be clever and somehow pack the data
directly into the buffer, but I felt like this wouldn't be worth the
complexity. You'd have to copy the data a bunch of times anyway. I'm
hoping that we can get away with using the ringbuffer mechanism for
low frequency important messages only (and not e.g. for high volume
debug messages), so the cost doesn't matter that much.

A ringbuffer has a simple, single log level. I considered allowing
--msglevel style per-prefix configuration for each ringbuffer, but
that would have been pretty complicated to implement, and wouldn't
have been that useful either.
2014-01-16 23:06:40 +01:00
wm4 49eb3c4025 msg: fix typo in comment 2014-01-16 23:06:40 +01:00
wm4 99ee43b33b msg: move special declarations to msg_control.h
While almost everything uses msg.h, the moved definitions are rarely
needed by anything.
2014-01-16 23:06:40 +01:00
wm4 5b14db5ab1 msg: print module prefixes even if message contains newlines
This makes

    mp_msg(x, y, "a\nb\n")

behave the same as

    mp_msg(x, y, "a\n")
    mp_msg(x, y, "b\n")

which is probably what one would expect. Before this commit, the "b"
line didn't have a prefix when using ths single mp_msg call.
2014-01-16 23:06:40 +01:00
Martin Herkt 26d6eb4a8a io/win32: move mp_attach_console to terminal-win.c
Why didn't I put it there from the start?
2014-01-16 11:25:52 +01:00
Johannes Nixdorf d5fce546a4 player: handle the corner cases in --term-osd-bar correctly
With the old code and pos == width - 2 one character too many is drawn.
2014-01-15 23:12:46 +01:00
Johannes Nixdorf 1d9c62b644 player: use more than 1/100 resolution for --term-osd-bar
If the terminal width is large enough the position marker jumps over
several characters because currently pos only increases in 1/100th steps.
2014-01-15 23:12:34 +01:00
ChrisK2 195e087086 osc: check for availabillity of percent-pos instead of length
... to decide wether the seekbar should be enabled or not.
2014-01-15 22:33:58 +01:00
wm4 5655038a95 command: if playback position is unknown, make percent-pos unavailable
Before that, it just returned -1.

The print case is inconsistent with that, but I'll leave it for now,
because it's consistent with status line / show_progress behavior.
2014-01-15 22:25:14 +01:00
James Ross-Gowan 80c11eba66 w32_common: add extended keys
Also VK_APPS/MP_KEY_MENU was missing.
2014-01-15 16:15:30 +01:00
wm4 45641378a2 player: add --term-osd-bar, which shows a status bar on the terminal
Feature request from github issue #451. Disabled by default, will
probably stay this way.
2014-01-15 16:14:37 +01:00
wm4 ca8937d7d2 bstr: add function for splitting UTF-8 2014-01-15 16:13:07 +01:00
wm4 904060ad7b msg: update comment 2014-01-15 13:36:48 +01:00
wm4 44993ba0fb msg: terminal OSD uses stderr, not stdout
This is more correct. E.g. if you do "mpv file.mkv > /dev/null", stdout
will not be a terminal, but stderr (used by terminal OSD and status
line) is.
2014-01-15 13:36:39 +01:00
James Ross-Gowan 4276e9443d w32_common: prevent decoding certain keys twice
This is a bit of a hack, but in order to prevent TranslateMessage from
seeing WM_KEYDOWN messages that we already know how to decode, move the
decoding logic to the event loop. This should fix #476, since it stops
the generation of extraneous WM_CHAR messages that were triggering more
than one action on keydown.
2014-01-15 13:32:25 +01:00
Grzegorz Blach 8255400e9c Detect Lua on FreeBSD 2014-01-15 00:18:14 +01:00
wm4 635b2f2690 player: don't print status in --idle mode
Apparently this annoys certain users. Restores old behavior.
2014-01-14 22:24:07 +01:00
wm4 5196b03fb2 player: avoid stalling when starting a network stream
Starting a network stream could stall by executing uncacheable stream
control requests (STREAM_CTRL_GET_LANG and STREAM_CTRL_GET_DVD_INFO).
Being uncacheable means the player has to wait until the cache is done
reading the current block of data. These requests can't be cached
because they're too complicated, so the only way to avoid them is
special casing the DVD and Bluray streams (which are the only things
which need these requests), and not doing them in other cases.

(This is kind of inelegant, but so is the rest of the DVD/BD code.)
2014-01-14 22:24:07 +01:00
Stefano Pigozzi 9dc9254da2 cocoa: add application icon to the Dock when run from CLI
Application icon was added to the Dock only when run inside of a bundle. That
was handled automatically by OS X using the Info.plist definition.

To add the Application icon when run as a CLI program, I used the samme
approach in the X11 code and loaded the icon as a static binary blob inside
of mpv's binary. This is the simplest approach as it avoid headackes when
relocating the binary and such.
2014-01-14 20:42:12 +01:00
wm4 e32adef9c4 ebml: remove length parameters from read functions
Many ebml_read_* functions have a length int pointer parameter, which
returns the number of bytes skipped. Nothing actually needed this
(anymore), and code using it was rather hard to understand, so get rid
of them.
2014-01-14 17:38:51 +01:00
wm4 bbbea7934f ebml: remove unused functions
These were mostly replaced by ebml_read_element().
2014-01-14 17:38:44 +01:00
wm4 72d5273bc1 demux_mkv: remove unused macros 2014-01-14 17:38:32 +01:00
wm4 3c2f93aec8 demux_mkv: improve robustness by explicitly checking for level 1 elements
Matroska makes it pretty hard to resync correctly on broken files:
random data returns "valid" EBML IDs with a high probability, and when
trying to skip them it's likely that you skip a random amount of data
(instead of considering the element length invalid).

Improve upon this by skipping known level 1 elements only. Consider
everything else invalid and call the resync code. This might result in
annoying behavior when Matroska adds new level 1 elements, although it
won't be particularly harmful. Matroska doesn't really allow us to do
better (even mkvtoolnix explicitly checks for known level 1 elements).

Since we now don't always want to combine EBML element skipping and
resyncing, remove ebml_read_skip_or_resync_cluster(), and make
ebml_read_skip() more tolerant against skipping broken elements.

Also, don't resync when reading sub-elements, and instead do resyncing
when reading them results in an error.
2014-01-14 17:38:21 +01:00
wm4 ae27e13a0a demux_mkv: avoid skipping too much data in corrupted files
Until now, corrupted files were detected if the size of an element (that
should be skipped) was larger than the remaining file. This still could
skip larger regions of the file itself if the broken size happened to be
within the file.

Change it so that it's never allowed to skip outside the parent's
element.
2014-01-14 17:38:08 +01:00
wm4 b51713e8e7 msg: don't clear term OSD lines that are not used 2014-01-14 17:37:55 +01:00
wm4 f3133e8704 terminal-unix: fix terminfo/termcap name for cursor up
"ku" is for input, not output. This happened to work on urxvt, but broke
on xterm (and probably a dozen of other terminals).
2014-01-14 17:37:40 +01:00
wm4 da00282e3a msg: fix printing of module header
The code to set root->header was moved before the point where it's used,
which broke the logic.
2014-01-14 17:37:30 +01:00
wm4 1cd1fb9e5c terminal-unix: add fallback for enter key
This worked just fine if terminfo or termcap was available.
2014-01-13 23:12:14 +01:00
wm4 d52fc906c3 terminal-unix: fix fallbacks in case terminfo/termcap are disabled
These two escape sequences were swapped. (They are used only if
terminfo/termcap are not available.)
2014-01-13 23:11:46 +01:00
wm4 710a45a386 terminal-unix: add termcap/terminfo documentation links
Apparently, some people are not clever enough to google this
information.

Proper googling to find these links done by Kovensky.
2014-01-13 20:13:16 +01:00
wm4 1d64b0101f manpage: document --term-osd=force
Apparently this was forgotten when it was first added, or maybe it's an
arrifact from the rst conversion.
2014-01-13 20:11:18 +01:00
wm4 6759941fca player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).

This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).

Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.

Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.

Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).

Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.

The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.

In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 20:08:13 +01:00
wm4 8721f9151f player: don't block terminal OSD while seeking
Seeking usually show the status on OSD. In terminal OSD mode, no status
is shown, because there is already a separate status line.
Unfortunately, the mechanism for showing the status was still active,
which forced showing no message while the code for showing seek status
was active.
2014-01-13 19:46:16 +01:00
wm4 a1c22f763d player: mention subtitles in av_desync_help_text
Insane .ass subtitle scripts can cause severe slowdown (depending on the
speed of the machine, or the insanity of the script), so mention how to
test without subtitles. This is mainly to make the user aware that
subtitle rendering can be a problem. For longwinded explanation, there
isn't enough space.
2014-01-12 21:41:09 +01:00
wm4 ad654f3803 options: remove --screenw and --screenh
Doesn't make any sense anymore. X11 (which was mentioned in the manpage)
autodetects it, and everything else ignored the option values.

Since for incomprehensible reasons the backends and vo.c still need to
exchange information about the screensize using the option fields,
they're not removed yet.
2014-01-11 18:58:07 +01:00
wm4 905029ec0c video/out: remove pointless x/y parameter from vo_x11_config_vo_window
This never made any real sense; the "backend" has to access vo->dx/dy
anyway.
2014-01-11 18:58:07 +01:00
wm4 d956bbc065 video/out: simplify monitor aspect handling
For some reason, this made all VO backends both set the screen
resolution in opts->screenwidth/height, and call
aspect_save_screenres(). Remove the latter. Move the code to calculate
the PAR-corrected window size from aspect.c to vo.c, and make it so that
the monitor PAR is recalculated when it makes sense.
2014-01-11 18:58:06 +01:00
wm4 3b8e457379 video/out: remove fallback handling for screensize/monitor pixel aspect
When using --monitoraspect, but either the screen width or height or
both are unknown, a fallback is applied. This is a completely useless
obscure corner case that's going to help nobody, so get it out of the
way.
2014-01-11 18:58:06 +01:00
Stefano Pigozzi 6a3ab66427 cocoa: fix window placement on secondary screens
For a long time the cocoa backend set the xinerama_x/y and used dx/dy from the
VO instance. This somewhat worked with some workarounds but wasn't really
what was supposed to be happening. Moreover 27e4360, which touched this
workaround introduced a regression.

New code doesn't set the xinerama_x/y values so that dx/dy are offsets in the
current screen (not a virtual screen composed of all the screens). The screen
reference detected during VOCTRL_UPDATE_SCREENINFO is also passed down to the
window initialization code.

Fixes #472
2014-01-11 14:06:40 +01:00
wm4 3433f25697 vd_lavc: matroska: remove weird code setting extra_huff for mjpeg
Like with the previous commit, this is probably not needed, but it's
unclear whether that really is the case. Most likely, it used to be
needed by some demuxer, and now the only demuxer left that could
_possibly_ trigger this is demux_mkv.c.

Note that mjpeg is the only decoder that reads the extra_huff option,
and nothing in libavformat actually sets the option. So maybe it's
fundamentally not needed anymore.
2014-01-11 01:49:20 +01:00
wm4 589f4871ea vd_lavc: matroska: remove weird realvideo special handling
This case can't happen with the normal realvideo codepath in
demux_mkv.c, because the code would errors out if the extradata is too
small, and everything would be broken anyway in the case the vd_lavc.c
condition is actually triggered.

It still might happen with VfW-muxed realvideo in Matroska, though.
Basically, I'm hoping this doesn't matter anyway, and that the vd_lavc.c
code was for other old demuxers, like demux_avi or demux_rm. Following
the commit history, it's not really clear for what demuxer this code
was added.
2014-01-11 01:47:14 +01:00
wm4 85e90668ae vd_lavc: minor simplification 2014-01-11 01:33:07 +01:00
wm4 14bd02a034 sd_lavc: use mp_lavc_set_extradata()
This includes the magical input padding required by libavcodec, which we
possibly didn't do before this commit.
2014-01-11 01:28:18 +01:00
wm4 4b4926bbb3 Factor out setting AVCodecContext extradata 2014-01-11 01:25:49 +01:00
Stefano Pigozzi 27e4360b0b cocoa: refactor init window positioning code 2014-01-10 20:39:25 +01:00
Nyx0uf 0f8558a723 cocoa: allow to drag and drop URLs
This commit also improves the visual feedback to the user by showing a plus
icon in the mouse cursor when dragging supported types.

Fixes #469
2014-01-10 10:48:54 +01:00
wm4 b6907a7bb5 demux_lavf: add hack for MicroDVD for assuming frame based timing
MicroDVD files _can_ contain real timestamps instead of frame timestamps
if they declare a FPS. But this seems to be rare, so ignore that if the
FPS happens to match with the libavformat microdvd parser's default FPS.

This might actually break files that declare 23.976 FPS, but the video
file is not 23.976 FPS, but the chance that this happens is probably
very low, and the commit fixes the more common breakage with 25 FPS
video.
2014-01-10 00:02:06 +01:00
wm4 cf02369aaf sub: fix frame based subtitle timestamp handling
Subtitle formats with frame based timing require using the video FPS to
compute proper subtitle timestamps. But it looks like the calculation to
do that was inversed.
2014-01-09 23:04:38 +01:00
wm4 09bf69afdb options: don't reset pause mode when switching to next file
This basically reverts the default as set by commit 812798c5. This seems
to be a matter of taste, but personally I think keeping the pause
setting is better.
2014-01-09 21:23:19 +01:00
wm4 72743ef6fe command: don't access VO for output parameters
Use the video chain for this instead. This is for facilitating coming
changes, which will clean up the vo->aspdat stuff, and this code would
be in the way.
2014-01-09 21:19:19 +01:00
Alexander Preisinger c555b2ae55 wayland: properly empty output list 2014-01-08 22:16:41 +01:00
Alexander Preisinger 525c7f1add wayland/shm: don't crash if initialization failed 2014-01-08 22:15:40 +01:00
wm4 34abe7e255 wayland: fix crash when initialization fails
On X11, if no wayland compositor is running, wl_list_init() will never
be called. This will cause destroy_display() to segfault when trying to
iterate over the list.
2014-01-08 21:49:18 +01:00
wm4 1d2a111337 player: strip 'file://' from filenames on playback start
This fixes two things:

1. Dropping files on the VO window will auto-load subtitles (since most
   drag & drop code prefixes the filenames with 'file://', and the
   subtitle auto-load code considers 'file://' non-local)
2. Fix behavior of the %x screenshot filename template (similar problem)

One could force all that code to special-case 'file://' URLs, but just
replacing the filename on playback start is simpler.
2014-01-08 21:46:42 +01:00
wm4 59c6fa2201 screenshot: add format specifiers to get file directory path
Useful if you want to put the screenshot into the same directory as the
file that is being played.
2014-01-08 21:09:01 +01:00
Alexander Preisinger 3e6fdc94d6 wayland/shm: tone down warnings
Those warnings are printed far too often and actually aren't usefull at all.
2014-01-08 21:03:57 +01:00
Alexander Preisinger 4b10255008 wayland: fix memory leaks
There are still some leaks from wayland-cursor stuff, but there is no way to
free the memory as user of the cursor library.
2014-01-08 20:59:40 +01:00
wm4 0b1ba0bf64 player: fix setting smaller timeout on Windows systems
On Windows, we don't have proper input event wakeup handling, so we
need to lower the playloop timeout in order to react fast to input.

Closes #387.
2014-01-08 19:16:30 +01:00
Martin Herkt cbc344236c waf: do not use TaskGen for PDF build rule
No longer necessary.
2014-01-08 16:46:31 +01:00
Alexander Preisinger 61e5670684 wayland: cleanup registry_handle_global
The wl_registry object is already passed as a parameter. No need to create
a temporary variable.
2014-01-08 16:23:19 +01:00
Alexander Preisinger 74d9504b65 wayland: remove set_user_data from seat_listener
The user_data is passed on add_listener and can later be changed with
set_user_data. But because we don't want to change it later and because it is
the same object remove the set_user_data call.

This might be a copy&paste leftover from the initial draft for the wayland
backend.
2014-01-08 16:23:19 +01:00
Alexander Preisinger fa5f1e7800 wayland: use static consistently
Declare everything that is only needed inside wayland_common.c as static.
2014-01-08 16:23:11 +01:00
Martin Herkt c2fe43361f Switch PDF manual generation to rst2pdf
This finally gets rid of the LaTeX dependency.

We should actually be using docultils directly here, but I didn't
do this because of all the potential Python 2/3 breakage.
2014-01-08 16:00:40 +01:00
wm4 49646f10f0 terminal: don't initialize termcap etc. if stdout is not a terminal
Otherwise, it seems one of the term* libraries will write escape
sequences to stdout, for whatever reason.
2014-01-07 23:57:46 +01:00
wm4 e0d7876eca ao_pulse: lower default buffer size from 1000ms to 250ms
1000ms is a bit insane. It makes behavior on playback speed changes
worse (because the player has to catch up the dropped audio due to
audio-chain reset), and perhaps makes seeking slower.

Note that the problem of playback speed changes misbehaving will be
fixed in the future, but even then we don't want to have a buffer that
large.
2014-01-07 23:52:18 +01:00
wm4 a220a3aae6 ao_pulse: add suboption to control buffer size 2014-01-07 23:50:22 +01:00
Alexander Preisinger 374f40de30 wayland: fix fullscreen & resizing for good
I added enough logic to never set ontop or fullscreen twitce.
This commit keeps also the size of the video if multiple videos are played.
If the ratio differs the width will be kept at the same size and only the
height changes.
2014-01-07 21:12:24 +01:00
wm4 bde15f3301 manpage: mention how to get a list of codecs for use with --hwdec-codecs 2014-01-07 17:14:05 +01:00
wm4 2c4c912c15 wayland: silence annoying libwayland-client message
libwayland-client contains the following code [1]:

	runtime_dir = getenv("XDG_RUNTIME_DIR");
	if (!runtime_dir) {
		fprintf(stderr,
			"error: XDG_RUNTIME_DIR not set in the environment.\n");

This means this message will unconditionally and unavoidably be printed
if XDG_RUNTIME_DIR is not set. Since mpv is a terminal program, and we
want to avoid unnecessary output, work it around by not attempting to
use wayland if this environment variable is not set.

[1] http://cgit.freedesktop.org/wayland/wayland/tree/src/wayland-client.c#n636
    (cd0dccd01e16fa404e03974d30ded3aebdb1c4bc)
2014-01-07 01:07:52 +01:00
wm4 326d887a41 wayland: fix some memory leaks on initialization failure
This commonly happens when initializing vo_opengl on a X11-only system.

Unfortunately, most wl_*_destroy() functions appear not to accept NULL
pointers, making partial deinitialization a pain: you have to add your
own NULL checks everywhere to avoid crashes.

xkb.context is uninitialized separately, because you can initialize it
just fine, even if the rest of input initialization fails.
2014-01-07 01:07:50 +01:00
wm4 cf6f1106ea demux_lavf: fix minor memory leak 2014-01-07 01:07:46 +01:00
wm4 98ffa7c476 audio: fix previous commit 2014-01-06 18:51:02 +01:00
Martin Herkt cd53de958d Fix audio delay inversion 2014-01-06 18:40:31 +01:00
wm4 936a204e27 sub: fix previous commit
sub_seek and sub_step were broken.
2014-01-06 17:38:10 +01:00
Martin Herkt e62c917abf Fix subtitle delay inversion 2014-01-06 17:09:31 +01:00
Martin Herkt df116958df w32_common: reformat yet again
I've been told mpv prefers switch/case on the same indent level.
Sorry about the noise :P
2014-01-06 15:37:21 +01:00
Stefano Pigozzi 48e3344f84 cocoa: don't reset window size when the video size doesn't change
Fixes #459
2014-01-06 14:19:04 +01:00
Martin Herkt 1fdc7e6c37 w32_common: don't force topmost on fullscreen
Fixes #457, #444.
2014-01-06 14:12:08 +01:00
Martin Herkt a857aa8828 Windows: use roaming AppData instead of local
Whatever. Fixes #458.
2014-01-06 13:44:48 +01:00
Martin Herkt 7d8cdc810c win32-console-wrapper: use child process exit code 2014-01-06 13:31:15 +01:00
Martin Herkt c849f1aa23 win32-console-wrapper: remove command line mangling
This wasn't really necessary and caused a lot of problems.
2014-01-06 13:18:02 +01:00
Martin Herkt 8bfb20acdc w32_common: reformat slightly
This really needs more whitespace.
2014-01-06 12:26:42 +01:00
xnoreq 43aafc61b0 w32_common: use OLE DnD for text/uri-list support
Signed-off-by: Martin Herkt <lachs0r@srsfckn.biz>
2014-01-06 12:26:28 +01:00
Martin Herkt 995d1c4d98 win32-console-wrapper: Fix heap corruption
FUCK the Windows API.
2014-01-06 11:09:08 +01:00
wm4 917374a7bf build: don't depend on both libavresample and libswresample
When both libavresample and libswresample were detected, the script
enabled both at the same time. This is not supported; although nothing
bad happened apparently. Make the dependencies both mutually exclusive.
2014-01-05 23:27:14 +01:00
Andre D 7c425fb71f quvi: add option to not fetch subtitles
Signed-off-by: wm4 <wm4@nowhere>
2014-01-05 23:07:34 +01:00
wm4 5819f4b7c9 player: always ise [statusline] for terminal OSD
This was inconsistent: the actual statusline used [statusline] as
message prefix, while other parts of the terminal OSD used [cplayer]
(and MSGL_STATUS). This commit makes it consistent.
2014-01-05 20:15:19 +01:00
wm4 2123ca52c9 player: print an error message if run command fails
Note that we can't use mp_msg, because it's not async-signal safe (we
might be running other threads while forking, so only functions
specified to be async-signal safe can be called, and this doesn't
include stdio; mp_msg acquires a mutex too).

Also, always print a \n before running the program to flush the status
line. The effect is that a program running successfully as well as the
error message will effectively start on a new line.
2014-01-05 20:11:01 +01:00
wm4 2da916f6df manpage: fix typo 2014-01-05 19:28:45 +01:00
wm4 365cc79d94 player: don't select subtitles added from quvi by default
Quvi subtitles are considered external subtitles (simply because they're
separate from the audio/video stream), but for the sake of subtitle
auto-selection, they should not be considered external.

Change this so that quvi subtitles are treated like muxed subtitles
(with default flag never set). This means subtitles won't be selected by
default, unless explicitly requested with --sid or --slang.
2014-01-05 16:15:30 +01:00
Alexander Preisinger 8a130e08e2 Revert "wayland/egl: use redraw callback"
Because of this commit there were problems displaying the frmase in their right
order.

This reverts commit 96e75d234a.

Conflicts:
	video/out/gl_wayland.c
	video/out/wayland_common.h
2014-01-04 21:18:46 +01:00
Alexander Preisinger 68e179bcf0 wayland: remove workaround
The changes in the vo_wayland_ontop function have no effect on the workaround.

Somehow the problem just disappeared. I guess it is because of the new control
function in gl_wayland.c where the resize happens immediatly after the event
dispatch/flush.
2014-01-04 20:54:51 +01:00
Alexander Preisinger 148918dd53 wayland: fix obvious bug in dnd code
I still don't think this is the right approach.
2014-01-04 20:28:52 +01:00
wm4 5d57a338ce input: change mp_input_run_cmd signature
I don't like this function at all, but it's basically a trick to get the
input's mp_log instance in a case the mp_input_parse_cmd_strv() is
almost certainly not going to output anything. But still make it
somewhat more consistent with mp_input_parse_cmd_strv() - why force the
caller to always use MP_ON_OSD_AUTO?
2014-01-04 19:42:16 +01:00
wm4 7c6bb321eb video/out: remove some code duplication between X11 and wayland
Both X11 and Wayland support the same format for drag & drop operations
(text/uri-list), and the code for that was copied from x11_common.c to
wayland_common.c. Factor it out.
2014-01-04 19:33:40 +01:00
wm4 6534839154 demux_subreader: reject file if not opened by --sub
demux_subreader.c contains the old MPlayer subtitle parser, and I have
absolutely no confidence in this (very crappy) code. There might be
one or two security risks associated with running that code on
arbitrary input.
2014-01-04 19:00:01 +01:00
Stefano Pigozzi 5a36d027f0 build: fix build on old build system
Regression from 082c5c19
2014-01-04 17:36:13 +01:00
Stefano Pigozzi 1e988c595b cocoa: handle files drag and drop on the player video view 2014-01-04 17:29:53 +01:00
Stefano Pigozzi 69d44d992c cocoa: refactor files drag and drop on the Dock icon
Use the newly added `mp_event_drop_files` core function instead of having
logic in the platform dependent code.
2014-01-04 17:29:41 +01:00
Stefano Pigozzi 082c5c19a1 input: move files drag and drop to a new event.c file
event.c will be used to feed the input queue with 'global' events that don't
mesh well with the usual check_events path in mpv.
2014-01-04 17:28:55 +01:00
Alexander Preisinger bb3ea1580e wayland/egl: misc fixes and cleanups 2014-01-04 17:26:55 +01:00
Alexander Preisinger 96e75d234a wayland/egl: use redraw callback
This solves the issue where we would not receive any frame events. The
difference to my earlier tests is that now it looks like eglSwapBuffers uses
it's own event queue or something similiar along the lines. Becaues the
performance is the same as without any redraw callback.
2014-01-04 17:23:35 +01:00
Alexander Preisinger 17b52cc4a9 wayland/egl: add egl_context to the wayland state
At the moment there are visual glitches when we resize the window. This happens
because in wayland there a special function for resizing EGL windows.

To prevent the glitches move the egl_context to the wayland state in
wayland_common.h and add a new control function to gl_wayland.c to wrap the
vo_wayland_control function to check for resize events.

With the new control wrapper the glitches are gone and the resizing is fluid.
2014-01-04 16:43:58 +01:00
Alexander Preisinger f5565f33c7 wayland: Remove nonsense comment and add warning
The reason a segmentation happend here was because we couldn't get the
requested minor version. The major version is enough for differentiating
between OpenGL 3 and OpenGL 2. If it fails there is still a fallback to any
version available.

Also add a warning if we use the fallback.
2014-01-04 15:37:45 +01:00
Alexander Preisinger 340ab6cd72 wayland: move workaround to fullscreen code
Because of this workaround there was a bug in the wayland vo.
Now it works on both vos (opengl and shm) as it should.
2014-01-04 13:57:47 +01:00
Alexander Preisinger 8f241998c0 wayland: implement dropping files on the VO window
Needs some proper testing.
2014-01-04 13:48:50 +01:00
wm4 7041d8cd37 vo: dropping subtitle files on the VO window adds them as subtitle files
Note that we don't try to be clever about detecting the files as
subtitles: we just check the file extension. We could go all the way and
check the files by opening them with a demuxer, but that would probably
do more bad than good.
2014-01-04 01:27:29 +01:00
wm4 6a1b12158d x11: implement dropping files on the VO window
Drag and drop is pretty complicated (just note how the number of Atoms
in use almost doubles), so I'm not sure whether this works everywhere.

This has been written by looking at the specification [1] or what looks
like the specification, and some external example code [2]. (The latter
one has no code license, but we didn't copy any code.)

We completely ignore the "requirement" of the spec. that the filename
"must" include username and hostname, e.g. "file://user@host/path/file".
In theory, this is required because X is network transparent, but at
this point the so called network transparency is a complete joke, and
Konqueror for one didn't include hostnames in "file://" URIs.

Tested with konqueror as drop source.

[1] http://www.newplanetsoftware.com/xdnd/
[2] http://www.edwardrosten.com/code/dist/x_clipboard-1.1/paste.cc
2014-01-04 01:27:28 +01:00
wm4 0702f642d5 vo: add vo_drop_files()
Intended to be used for GUI drag & drop.
2014-01-04 01:27:28 +01:00
Martin Herkt e3ab2ac112 manpage: mention --pause 2014-01-03 20:35:10 +01:00
wm4 79a8018ca2 dvdnav: set correct stride for fake highlights
This didn't really matter, because the fake highlight rectangle is in a
single color, and every pixel has the same color value.
2014-01-03 16:45:59 +01:00
wm4 6e6291dcfd stream_pvr: fix crash on initialization
Fallout from the mp_msg conversions.
2014-01-03 16:44:44 +01:00
wm4 52ed634811 audio: check for overflows 2014-01-03 00:42:40 +01:00
wm4 7ed4ce91e8 bstr: check for overflow in buffer allocation
We're being a little bit lazy here and limit the max allocation to
SIZE_MAX/2, which is practically infinite anyway on 64 bit systems.
2014-01-03 00:34:15 +01:00
wm4 2cad237f8b ta: check overflow in array realloc macros 2014-01-02 23:54:59 +01:00
Stefano Pigozzi d4f37174a1 vda: fix build on OS X 10.7
Looks like on 10.8 OpenGL.h recursively includes CGLIOSurface.h. That is not
the case for 10.7 so the build was broken on that version of OS X.
2014-01-02 22:45:39 +01:00
wm4 d4588bf577 ao_alsa: remove 9 year old typo
Actually, remove the whole comment, because it's outdated and
get_space() returns the number of free samples now.
2014-01-02 21:29:33 +01:00
Stefano Pigozzi fb2d418327 build: fix cocoa configure check on OS X 10.7
It failed because the 10.7 SDK doesn't natively support array and dictionary
subscripting.
2014-01-02 20:42:03 +01:00
Alexander Preisinger 52fa38079d wayland/opengl: fix garbage borders
It seems mpv draws garbage in those regions. Now we calculate the aspect and
let weston draw the black borders.
2014-01-02 20:33:39 +01:00
Alexander Preisinger ba101abfbe wayland/shm: only commit new frames
Only attach and commit new buffers. This also increases performance when
paused.
2014-01-02 20:33:31 +01:00
Alexander Preisinger e947c72fe9 wayland: don't change set fullscreen twice
Newest weston chrashes if we call set_fullscreen twice. This is a major bug
I which I should probably report.
2014-01-02 20:33:06 +01:00
Martin Herkt 4350a76a01 ao_alsa: Unbreak pause/resume
Well that was dumb.
2014-01-02 18:46:11 +01:00
Martin Herkt 4083ae1de3 ao_alsa: Fix PCM resume after suspend
Fixes #324
2014-01-02 16:09:27 +01:00
Martin Herkt 1437d9b8bc Add Windows console wrapper program (mpv.com) 2014-01-02 05:30:49 +01:00
Martin Herkt e9f577eb9a Windows: use the GUI subsystem, attach to console
This is necessary to start mpv without forcing a console window,
but also breaks console usability. A workaround is to call mpv
from a wrapper process that uses the console subsystem and helps
redirecting the standard streams and WriteConsole output to where
they belong.
2014-01-02 05:30:49 +01:00
Martin Herkt fd89a75988 osdep/io, mp_vfprintf: split out console detection 2014-01-02 05:30:49 +01:00
wm4 b04b48fc10 stream: always respect sector_size, fixes cdda://
Streams like CDDA have special requirements in what quantities data can
be read: you can only read a sector at once, not more and not less. The
stream_peek() function didn't respect that and set less (used internal
buffer size of 2048 bytes, instead of CD sector size of 2352 bytes), so
no data was read and EOF was accidentally set, making playback with
cdda:// fail.

This is a regression since commit 9a723f, but that commit merely exposed
the issue (the redundant seek would clear the EOF flag).
2014-01-02 00:39:14 +01:00
Stefano Pigozzi b467df073e build: fix typo 2014-01-01 21:44:05 +01:00
Stefano Pigozzi e568299c2c build: make configure fail if both __atomic and __sync are not available 2014-01-01 20:52:54 +01:00
wm4 faf68f3b8e manpage: clarifications about bitmap subtitles and --secondary-sid 2014-01-01 19:45:34 +01:00
wm4 2214ee8472 options: make --msglevel=help print something helpful 2014-01-01 19:42:48 +01:00
wm4 cf4a110261 manpage: fix description on the slave mode msglevel 2014-01-01 19:28:17 +01:00
wm4 9169737a47 player: load encoding-profiles.conf before the main config
Otherwise one can't add profiles based on the encoding profiles.
2014-01-01 19:25:52 +01:00
Miro Hrončok bbdd030a58 mpv.desktop: Add Czech translations 2014-01-01 18:53:33 +01:00
wm4 aeb9e6ddf5 player: fix DVD playback
Crashed in case of lazily added subtitle streams, which add tracks with
track->stream set to NULL.

Fixes gituhub issue #439.
2014-01-01 16:18:54 +01:00
wm4 66fe4f5713 Update copyright year 2014-01-01 00:00:00 +01:00
Alessandro Ghedini 4530d787d0 compat: use __atomic operations instead of __sync, when present
Fixes #434
Fixes #437
2013-12-31 10:53:36 +01:00
Alessandro Ghedini e19060d89f build: check for libatomic and __atomic operations
Add check in old-configure as well. Reformat the check to use a maximum of 80
columns in the wscript.
Signed-off-by: Stefano Pigozzi <stefano.pigozzi@gmail.com>
2013-12-31 10:53:36 +01:00
wm4 548aa81196 manpage: fix vf_noise parameter name 2013-12-30 22:50:01 +01:00
wm4 ec539dad2b common: drop mp_append_utf8_buffer() 2013-12-30 22:49:51 +01:00
wm4 7639e05ea8 bstr: use mp_append_utf8_bstr()
Drop usage of the ugly PUT_UTF8() macro.
2013-12-30 22:49:51 +01:00
wm4 b0efd3f36a input: use bstr_xappend()
To get rid of mp_append_utf8_buffer().
2013-12-30 22:49:51 +01:00
wm4 963a3d2c64 osd_libass: use bstr_xappend()
Partially, just enough to drop mp_append_utf8_buffer().
2013-12-30 22:49:50 +01:00
wm4 066ecfcbfb common: simplify and optimize string escape parsing
This code is shared between input.conf parser and option parser. Until
now, the performance didn't really matter. But I want to use this code
for JSON parsing too, and since JSON will have to be parsed a lot, it
should probably try to avoid realloc'ing too much.

This commit moves parsing of C-style escaped strings into a common
function, and allows using it in a way realloc can be completely
avoided, if the already allocated buffer is large enough.
2013-12-30 22:49:50 +01:00
wm4 097fe8ea6f bstr: add bstr_xappend function
Apparently this can be really useful when being paranoid and trying to
avoid too much malloc/realloc, since it can be used to appending into a
buffer (with transparent realloc only if the buffer is too small).
2013-12-30 22:49:50 +01:00
wm4 56ce2a39be video: fix --brightness etc. options
They were set before the VO was intitialized, which silently failed.
2013-12-29 22:18:27 +01:00
502 changed files with 45996 additions and 40528 deletions

No files matched your search

+6 -6
View File
@@ -20,12 +20,12 @@
/demux/ebml_types.h
/sub/osd_font.h
/player/lua/*.inc
/DOCS/man/*/mpv.1
/DOCS/man/*/mpv.aux
/DOCS/man/*/mpv.log
/DOCS/man/*/mpv.out
/DOCS/man/*/mpv.pdf
/DOCS/man/*/mpv.toc
/DOCS/man/mpv.1
/DOCS/man/mpv.aux
/DOCS/man/mpv.log
/DOCS/man/mpv.out
/DOCS/man/mpv.pdf
/DOCS/man/mpv.toc
/waf
/build
+15 -5
View File
@@ -1,5 +1,8 @@
language: c
os:
- linux
- osx
env:
- LIBAV=libav-stable
- LIBAV=libav-git
@@ -7,24 +10,31 @@ env:
- LIBAV=ffmpeg-git
compiler:
- clang
branches:
only:
- master
- ci
matrix:
exclude:
- os: osx
env: LIBAV=libav-stable
- os: osx
env: LIBAV=libav-git
- os: osx
env: LIBAV=ffmpeg-git
before_install: ./travis-deps libass-stable $LIBAV
script:
- ./bootstrap.py
- ./waf configure
- ./waf build
notifications-policy: &notifications-policy
on_success: change
on_failure: always
notifications:
email: false
irc:
channels:
- "irc.freenode.org#mpv-player-dev"
<<: *notifications-policy
on_success: change
on_failure: always
-160
View File
@@ -1,160 +0,0 @@
1. Input layer, supported devices, methods:
- plain file, with seeking
- STDIN, without seeking backward
- network streaming (currently plain wget-like HTTP and MMS (.asx))
- VCD (Video CD) track, by direct CDROM device access (not requires mounting disc)
- DVD titles using .IFO structure, by direct DVD device access (not requires mounting disc)
- DVD titles using menu navigation (experimental/alpha, not yet finished!!!)
- CDDA - raw audio from audio CD-ROM discs (using cdparanoia libs)
- RTP streaming (mpeg-ps over multicast only)
- LIVE555 streaming - support SDP/RTSP (using the LIVE555 libs)
- SMB - file access over samba (experimental)
2. Demuxer/parser layer, supported file/media formats:
- MPEG streams (ES,PES,PS. no TS support yet)
note: mpeg demuxer silently ignore non-mpeg content, and find mpeg packets
in arbitrary streams. it means you can play directly VCD images (for example
CDRwin's .BIN files) without extracting mpeg files first (with tools like vcdgear)
It accepts all PES variants, including files created by VDR.
Note: VOB (video object) is simple mpeg stream, but it usually has 01BD
packets which may contain subtitles and non-mpeg audio. Usually found on DVD discs.
Headers: mpeg streams has no global header. each frame sequence (also called GOP,
group of pictures) contains an sequence header, it describes that block.
In normal mpeg 1/2 content there are groups of 12-15 frames (24/30 fps).
It means you can freely seek in mpeg streams, and even can cut it to
small parts with standard file tools (dd, cut) without destroying it.
Codecs: video is always mpeg video (mpeg1, mpeg2 or mpeg4).
audio is usually mpeg audio (any layer allowed, but it's layer 2 in most files)
but 01BD packets may contain AC3, DTS or LPCM too.
FPS: mpeg2 content allows variable framerate, in form of delayed frames.
It's mostly used for playback 24fps content at 29.97/30 fps (NTSC) rate.
(so called Telecine or 3:2 pulldown effect)
It means you see 30 frames per second, but there are only 24 different
pictures and some of them are shown longer to fill 30 frame time.
If you encode such files with mencoder, using -ofps 24 or -ofps 23.976
is recommended.
- AVI streams.
Two kind of RIFF AVI files exists:
1. interleaved: audio and video content is interleaved. it's faster and
requires only 1 reading thread, so it's recommended (and mostly used).
2. non-interleaved: audio and video aren't interleaved, i mean first come
whole video followed by whole audio. it requires 2 reading process or
1 reading with lots of seeking. very bad for network or cdrom.
3. badly interleaved streams: mplayer detects interleaving at startup and
enables -ni option if it finds non-interleaved content. but sometimes
the stream seems to be interleaved, but with bad sync so it should be
played as non-interleaved otherwise you get a-v desync or buffer overflow.
MPlayer supports 2 kind of timing for AVI files:
- bps-based: it is based on bitrate/samplerate of video/audio stream.
this method is used by most players, including avifile and wmp.
files with broken headers, and files created with VBR audio but not
vbr-compliant encoder will result a-v desync with this method.
(mostly at seeking).
- interleaving-based: note: it can't be used togethwer with -ni
it doesn't use bitrate stuff of header, it uses the relative position
of interleaved audio and video chunks. makes some badly encoded file
with vbr audio playable.
Headers: AVI files has a mandatory header at the begin of the file,
describing video parameters (resolution, fps) and codecs. Optionally
they have an INDEX block at the end of the file. It's optional, but
most files has such block, because it's REQUIRED for seeking.
Btw usually it can be rebuilt from file content, mplayer does it with
the -idx switch. MPlayer can recreate broken index blocks using -forceidx.
As AVI files needs index for random access, broken files with no index
are usually unplayable.
Of course, cutting/joining AVI files needs special programs.
Codecs: any audio and video codecs allowed, but I note that VBR audio is
not well supported by most players. The file format makes it possible to
use VBR audio, but most players expect CBR audio and fails with VBR,
as VBR is unusual, and Microsoft's AVI specs only describe CBR audio.
I also note, that most AVI encoders/multiplexers create bad files if
using VBR audio. only 2 exception (known by me): NaNDub and MEncoder.
FPS: only constant framerate allowed, but it's possible to skip frames.
- ASF streams:
ASF (active streaming format) comes from Microsoft. they developed two
variant of ASF, v1.0 and v2.0. v1.0 is used by their media tools (wmp and
wme) and v2.0 is published and patented :). of course, they differ,
no compatibility at all. (it's just a legality game)
MPlayer supports only v1.0, as nobody ever seen v2.0 files :)
Note, that .ASF files are nowdays come with extension .WMA or .WMV.
UPDATE: MS recently released the ASF v1.0 specs too, but it has some
restrictions making it illegal to read by us :)
Headers: Stream headers (codecs parameters) can be everywhere (in theory),
but all files i've seen had it at the beginning of the file.
Asf uses fixed packet size, so it is seekable without any INDEX block,
and broken files are playable well.
Codecs: video is mostly microsoft's mpeg4 variants: MP42, MP43 (aka DivX),
WMV1 and WMV2. but any codecs allowed.
audio is usually wma or voxware, sometimes mp3, but any codecs allowed.
FPS: no fixed fps, every video frame has an exact timestamp instead.
I've got stream with up to 3 sec frame display times.
- QuickTime / MOV files:
They come from Mac users, usually with .mov or .qt extension, but as
MPEG Group chose quicktime as recommended file format for MPEG4,
sometimes you meet quicktime files with .mpg or .mp4 extension.
At first look, it's a mixture of ASF and AVI.
It requires INDEX block for random access and seeking, and even for
playback, like AVI, but uses timestamps instead of constant framerate
and has more flexible stream options (including network stuff) like ASF.
Headers: header can be placed at the beginning or at the end of file.
About half of my files have it at the beginning, others have it at the end.
Broken files are only playable if they have header at the beginning!
Codecs: any codecs allowed, both CBR and VBR.
Note: most new mov files use Sorenson video and QDesign Music audio,
they are patented, closed, secret, (TM)-ed etc formats, only Apple's
quicktime player is able to playback these files (on win/mac only).
- VIVO files:
They are funny streams. They have a human-readable ascii header at
the beginning, followed by interleaved audio and video chunks.
It has no index block, has no fixed packetsize or sync bytes, and most
files even has no keyframes, so forget seeking!
Video is standard h.263 (in vivo/2.0 files it's modified, non-standard
h.263), audio is either standard g.723 or Vivo Siren codec.
Note, that microsoft licensed vivo stuff, and included in their netshow
v2.0 program, so there are VfW/ACM codecs for vivo video and audio.
- RealMedia files:
A mixture of AVI and ASF features. It has mandatory headers at the
beginning and an optional INDEX (missing in most files).
The file is constructed of variable size chunks, with small header
telling the stream ID, timestamp, flags (keyframe...) and size.
But it has some features found in ASF files:
The video is actually double-muxed, the video chunks are really
appended fragments of the video frame. RV30+ supports B frames, so
you have to parse some bits of the first fragment to get the real PTS.
The audio frames are fixed size (CBR) but using the same scrambling
(out-of-order interleaving) as in the ASF files.
Codecs: Audio is either COOK(er), SIPR(o), ATRAC3 or DNET.
The DNET is actually a byte-swapped low-bitrate Dolby AC3 variant :)
Video is RV10 (h263 variant), RV20 (rp G2), RV30 (rp v8) or RV40 (rp v9).
FPS: variable, just like in ASF.
Note, that similarity of real and asf has some background - they worked
together on the (never finished/used) ASF v2 spec for some time.
- GIF files:
The GIF format is a common format for web graphics that supports
animation. These are read through libungif or compatible library.
Variable frame delays are supported, but seeking is not supported.
Seeking will be supported once an index of gif frames can be built.
-228
View File
@@ -1,228 +0,0 @@
So, I'll describe how this stuff works.
The main modules:
1. stream.c: this is the input layer, this reads the input media (file, stdin,
vcd, dvd, network etc). what it has to know: appropriate buffering by
sector, seek, skip functions, reading by bytes, or blocks with any size.
The stream_t (stream.h) structure describes the input stream, file/device.
There is a stream cache layer (cache2.c), it's a wrapper for the stream
API. It does fork(), then emulates stream driver in the parent process,
and stream user in the child process, while proxying between them using
preallocated big memory chunk for FIFO buffer.
2. demuxer.c: this does the demultiplexing (separating) of the input to
audio, video or dvdsub channels, and their reading by buffered packages.
The demuxer.c is basically a framework, which is the same for all the
input formats, and there are parsers for each of them (mpeg-es,
mpeg-ps, avi, avi-ni, asf), these are in the demux_*.c files.
The structure is the demuxer_t. There is only one demuxer.
2.a. demux_packet_t, that is DP.
Contains one chunk (avi) or packet (asf,mpg). They are stored in memory as
in linked list, cause of their different size.
2.b. demuxer stream, that is DS.
Struct: demux_stream_t
Every channel (a/v/s) has one. This contains the packets for the stream
(see 2.a). For now, there can be 3 for each demuxer :
- audio (d_audio)
- video (d_video)
- DVD subtitle (d_dvdsub)
2.c. stream header. There are 2 types (for now): sh_audio_t and sh_video_t
This contains every parameter essential for decoding, such as input/output
buffers, chosen codec, fps, etc. There are each for every stream in
the file. At least one for video, if sound is present then another,
but if there are more, then there'll be one structure for each.
These are filled according to the header (avi/asf), or demux_mpg.c
does it (mpg) if it founds a new stream. If a new stream is found,
the ====> Found audio/video stream: <id> messages is displayed.
The chosen stream header and its demuxer are connected together
(ds->sh and sh->ds) to simplify the usage. So it's enough to pass the
ds or the sh, depending on the function.
For example: we have an asf file, 6 streams inside it, 1 audio, 5
video. During the reading of the header, 6 sh structs are created, 1
audio and 5 video. When it starts reading the packet, it chooses the
stream for the first found audio & video packet, and sets the sh
pointers of d_audio and d_video according to them. So later it reads
only these streams. Of course the user can force choosing a specific
stream with
-vid and -aid switches.
A good example for this is the DVD, where the english stream is not
always the first, so every VOB has different language :)
That's when we have to use for example the -aid 128 switch.
Now, how this reading works?
- demuxer.c/demux_read_data() is called, it gets how many bytes,
and where (memory address), would we like to read, and from which
DS. The codecs call this.
- this checks if the given DS's buffer contains something, if so, it
reads from there as much as needed. If there isn't enough, it calls
ds_fill_buffer(), which:
- checks if the given DS has buffered packages (DP's), if so, it moves
the oldest to the buffer, and reads on. If the list is empty, it
calls demux_fill_buffer() :
- this calls the parser for the input format, which reads the file
onward, and moves the found packages to their buffers.
Well it we'd like an audio package, but only a bunch of video
packages are available, then sooner or later the:
DEMUXER: Too many (%d in %d bytes) audio packets in the buffer
error shows up.
2.d. video.c: this file/function handle the reading and assembling of the
video frames. each call to video_read_frame() should read and return a
single video frame, and it's duration in seconds (float).
The implementation is splitted to 2 big parts - reading from mpeg-like
streams and reading from one-frame-per-chunk files (avi, asf, mov).
Then it calculates duration, either from fixed FPS value, or from the
PTS difference between and after reading the frame.
2.e. other utility functions: there are some useful code there, like
AVI muxer, or mp3 header parser, but leave them for now.
So everything is ok 'till now. It can be found in libmpdemux/ library.
It should compile outside of mplayer tree, you just have to implement few
simple functions, like mp_msg() to print messages, etc.
See libmpdemux/test.c for example.
See also formats.txt, for description of common media file formats and their
implementation details in libmpdemux.
Now, go on:
3. mplayer.c - ooh, he's the boss :)
Its main purpose is connecting the other modules, and maintaining A/V
sync.
The given stream's actual position is in the 'timer' field of the
corresponding stream header (sh_audio / sh_video).
The structure of the playing loop :
while(not EOF) {
fill audio buffer (read & decode audio) + increase a_frame
read & decode a single video frame + increase v_frame
sleep (wait until a_frame>=v_frame)
display the frame
apply A-V PTS correction to a_frame
handle events (keys,lirc etc) -> pause,seek,...
}
When playing (a/v), it increases the variables by the duration of the
played a/v.
- with audio this is played bytes / sh_audio->o_bps
Note: i_bps = number of compressed bytes for one second of audio
o_bps = number of uncompressed bytes for one second of audio
(this is = bps*samplerate*channels)
- with video this is usually == 1.0/fps, but I have to note that
fps doesn't really matters at video, for example asf doesn't have that,
instead there is "duration" and it can change per frame.
MPEG2 has "repeat_count" which delays the frame by 1-2.5 ...
Maybe only AVI and MPEG1 has fixed fps.
So everything works right until the audio and video are in perfect
synchronity, since the audio goes, it gives the timing, and if the
time of a frame passed, the next frame is displayed.
But what if these two aren't synchronized in the input file?
PTS correction kicks in. The input demuxers read the PTS (presentation
timestamp) of the packages, and with it we can see if the streams
are synchronized. Then MPlayer can correct the a_frame, within
a given maximal bounder (see -mc option). The summary of the
corrections can be found in c_total .
Of course this is not everything, several things suck.
For example the soundcards delay, which has to be corrected by
MPlayer! The audio delay is the sum of all these:
- bytes read since the last timestamp:
t1 = d_audio->pts_bytes/sh_audio->i_bps
- if Win32/ACM then the bytes stored in audio input buffer
t2 = a_in_buffer_len/sh_audio->i_bps
- uncompressed bytes in audio out buffer
t3 = a_buffer_len/sh_audio->o_bps
- not yet played bytes stored in the soundcard's (or DMA's) buffer
t4 = get_audio_delay()/sh_audio->o_bps
From this we can calculate what PTS we need for the just played
audio, then after we compare this with the video's PTS, we have
the difference!
Life didn't get simpler with AVI. There's the "official" timing
method, the BPS-based, so the header contains how many compressed
audio bytes or chunks belong to one second of frames.
In the AVI stream header there are 2 important fields, the
dwSampleSize, and dwRate/dwScale pairs:
- If the dwSampleSize is 0, then it's VBR stream, so its bitrate
isn't constant. It means that 1 chunk stores 1 sample, and
dwRate/dwScale gives the chunks/sec value.
- If the dwSampleSize is >0, then it's constant bitrate, and the
time can be measured this way: time = (bytepos/dwSampleSize) /
(dwRate/dwScale) (so the sample's number is divided with the
samplerate). Now the audio can be handled as a stream, which can
be cut to chunks, but can be one chunk also.
The other method can be used only for interleaved files: from
the order of the chunks, a timestamp (PTS) value can be calculated.
The PTS of the video chunks are simple: chunk number * fps
The audio is the same as the previous video chunk was.
We have to pay attention to the so called "audio preload", that is,
there is a delay between the audio and video streams. This is
usually 0.5-1.0 sec, but can be totally different.
The exact value was measured until now, but now the demux_avi.c
handles it: at the audio chunk after the first video, it calculates
the A/V difference, and take this as a measure for audio preload.
3.a. audio playback:
Some words on audio playback:
Not the playing is hard, but:
1. knowing when to write into the buffer, without blocking
2. knowing how much was played of what we wrote into
The first is needed for audio decoding, and to keep the buffer
full (so the audio will never skip). And the second is needed for
correct timing, because some soundcards delay even 3-7 seconds,
which can't be forgotten about.
To solve this, the OSS gives several possibilities:
- ioctl(SNDCTL_DSP_GETODELAY): tells how many unplayed bytes are in
the soundcard's buffer -> perfect for timing, but not all drivers
support it :(
- ioctl(SNDCTL_DSP_GETOSPACE): tells how much can we write into the
soundcard's buffer, without blocking. If the driver doesn't
support GETODELAY, we can use this to know how much the delay is.
- select(): should tell if we can write into the buffer without
blocking. Unfortunately it doesn't say how much we could :((
Also, doesn't/badly works with some drivers.
Only used if none of the above works.
4. Codecs. Consists of libmpcodecs/* and separate files or libs,
for example libmpeg2, loader, mp3lib.
mplayer.c doesn't call them directly, but through the dec_audio.c and
dec_video.c files, so the mplayer.c doesn't have to know anything about
the codecs.
libmpcodecs contains wrapper for every codecs, some of them include the
codec function implementation, some calls functions from other files
included with mplayer, some calls optional external libraries.
file naming convention in libmpcodecs:
ad_*.c - audio decoder (called through dec_audio.c)
vd_*.c - video decoder (called through dec_video.c)
ve_*.c - video encoder (used by mencoder)
vf_*.c - video filter (see option -vf)
On this topic, see also:
libmpcodecs.txt - The structure of the codec-filter path, with explanation
dr-methods.txt - Direct rendering, MPI buffer management for video codecs
codecs.conf.txt - How to write/edit codec configuration file (codecs.conf)
codec-devel.txt - Mike's hints about codec development - a bit OUTDATED
hwac3.txt - about SP/DIF audio passthrough
5. libvo: this displays the frame.
for details on this, read libvo.txt
6. libao2: this control audio playing
6.a audio plugins
for details on this, read libao2.txt
-145
View File
@@ -1,145 +0,0 @@
mails by A'rpi and Marcus Blomenkamp <Marcus.Blomenkamp@epost.de>
describing how this ac3-passtrough hack work under linux and mplayer...
-----------------------------------------------------------------------
Hi,
> I received the following patch from Steven Brookes <stevenjb@mda.co.uk>.
> He is working on fixing the digital audio output of the dxr3 driver and
> told me he fixed some bugs in mplayer along the way. I don't know shit
> about hwac3 output so all I did was to make sure the patch applied
> against latest cvs.
> This is from his e-mail to me:
>
> "Secondly there is a patch to dec_audio.c and
> ac3-iec958 to fix the -ac hwac3 codec stuff and to use liba52 to sync it.
> Seems to work for everything I've thrown at and maintains sync for all audio
> types through the DXR3."
patch applied (with some comments added and an unwanted change (in software
a52 decoder) removed)
now i understand how this whole hwac3 mess work.
it's very very tricky. it virtually decodes ac3 to LPCM packets, but really
it keeps the original compressed data padded by zeros. this way it's
constant bitrate, and sync is calculated just like for stereo PCM.
(so it bypass LPCM-capable media converters...)
so, every ac3 frame is translated to 6144 byte long tricky LPCM packet.
6144 = 4*(6*256) = 4 * samples_per_ac3_frame = LPCM size of uncompressed ac3
frame.
i wanna know if it works for sblive and other ac3-capable cards too?
(i can't test it, lack of ac3 decoder)
A'rpi / Astral & ESP-team
-----------------------------------------------------------------------
Hi folks.
I spend some time fiddling with ac3 passthrough in mplayer. The
traditional way of setting the output format to AFMT_AC3 was no ideal
solution since not all digital io cards/drivers supported this format or
honoured it to set the spdif non-audio bit. To make it short, it only
worked with oss sblive driver IIRC.
Inspired by alsa's ac3dec program I found an alternative way by
inspecting to which format the alsa device had been set. Suprise: it was
simple 16bit_le 2_channel pcm. So setting the non-audio bit doesn't
necessarily mean the point. The only important thing seems to be
bit-identical output at the correct samplerate. Modern AV-Receivers seem
to be quite tolerant/compatible.
So I changed the output format of hwac3 from
AFMT_AC3 channels=1
to
AFMT_S16_LE channels=2
and corrected the absolute time calculation. That was all to get it
running for me.
-----------------------------------------------------------------------
Hi there.
Perhaps I can clear up some mystification about AC3 passthrough in
general and mplayer in special:
To get the external decoder solution working, it must be fed with data
which is bitidentical to the chunks in the source ac3 file (compressed
data is very picky about bit errors). Additionally - or better to say
'historically' - the non-audio bit should be set in the spdif status
fields to prevent old spdif hardware from reproducing ugly scratchy
noise. Note: for current decoders (probably those with DTS capability)
this safety bit isn't needed anymore. At least I can state that for my
Sherwood RVD-6095RDS. I think it is due to DTS because DTS sound can
reside on a ordinary AudioCD and an ordinary AudioCD-Player will always
have it's audio-bit set.
The sample format of the data must be 2channel 16bit (little endian
IIRC). Samplerates are 48kHz - although my receiver also accepts
44100Hz. I do not know if this is due to an over-compatability of my
receiver or if 44100 is also possible in the ac3 specs. For safety's
sake lets keep this at 48000Hz. AC3 data chunks are inserted into the
stream every 0x1600 bytes (don't bite me on that, look into
'ac3-iec958.c': 'ac3_iec958_build_burst').
To come back to the problem: data must be played bit-identically through
the soundcard at the correct samplerate and should optionally have it's
non-audio bit set. There are two ways to accomplish this:
1) Some OSS guy invented the format AFMT_AC3. Soundcard drivers
implementing this format should therefore adjust it's mixers and
switches to produce the desired output. Unfortunately some soundcard
drivers do not support this format correctly and most do not even
support it at all (including ALSA).
2) The alternative approach currently in mplayer CVS is to simply set
the output format to 48kHz16bitLE and rely on the user to have the
soundcard mixers adjusted properly.
I do have two soundcards with digital IO facilities (CMI8738 and
Trident4DWaveNX based) plus the mentioned decoder. I'm currently running
Linux-2.4.17. Following configurations are happily running here:
1. Trident with ALSA drivers (OSS does not support Hoontech's dig. IO)
2. CMI with ALSA drivers
3. CMI with OSS drivers
For Linux I'd suggest using ALSA because of it's cleaner architecture
and more consitent user interface. Not to mention that it'll be the
standard sound support in Linux soon.
For those who want to stick to OSS drivers: The CMI8738 drivers works
out-of-the-box, if the PCM/Wave mixer is set to 100%.
For ALSA I'd suggest using its OSS emulation. More on that later.
ALSA-0.9 invented the idea of cards, devices and dubdevices. You can
reach the digital interface of all supported cards consitently by using
the device 'hw:x,2' (x counting from 0 is the number of your soundcard).
So most people would end up at 'hw:0,2'. This device can only be opened
in sample formats and rates which are directly supported in hardware
hence no samplerate conversion is done keeping the stream as-is. However
most consumer soundcards do not support 44kHz so it would definitively
be a bad idea to use this as your standard device if you wanted to
listen to some mp3s (most of them are 44kHz due to CD source). Here the
OSS comes to play again. You can configure which OSS device (/dev/dsp
and /dev/adsp) uses which ALSA device. So I'd suggest pointing the
standard '/dev/dsp' to standard 'hw:0,0' which suports mixing and
samplerate conversion. No further reconfiguration would be needed for
your sound apps. For movies I'd point '/dev/adsp' to 'hw:0,2' and
configure mplayer to use adsp instead of dsp. The samplerate constrain
is no big deal here since movies usually are in 48Khz anyway. The
configuration in '/etc/modules.conf' is no big deal also:
alias snd-card-0 snd-card-cmipci # insert your card here
alias snd-card-1 snd-pcm-oss # load OSS emulation
options snd-pcm-oss snd_dsp_map=0 snd_adsp_map=2 # do the mapping
This works flawlessly in combination with alsa's native
SysVrc-init-script 'alsasound'. Be sure to disable any distribution
dependent script (e.g. Mandrake-8.1 has an 'alsa' script which depends
on ALSA-0.5).
Sorry for you *BSD'lers out there. I have no grasp on sound support there.
HTH Marcus
-56
View File
@@ -1,56 +0,0 @@
6. libao2: this control audio playing
As in libvo (see 5.) also here are some drivers, based on the same API:
static int control(int cmd, int arg);
This is for reading/setting driver-specific and other special parameters.
Not really used for now.
static int init(int rate,int channels,int format,int flags);
The init of driver, opens device, sets sample rate, channels, sample format
parameters.
Sample format: usually AFMT_S16_LE or AFMT_U8, for more definitions see
dec_audio.c and linux/soundcards.h files!
static void uninit(void);
Guess what.
Ok I help: closes the device, not (yet) called when exit.
static void reset(void);
Resets device. To be exact, it's for deleting buffers' contents,
so after reset() the previously received stuff won't be output.
(called if pause or seek)
static int get_space(void);
Returns how many bytes can be written into the audio buffer without
blocking (making caller process wait). MPlayer occasionally checks the
remaining space and tries to fill the buffer with play() if there's free
space. The buffer size used should be sane; a buffer that is too small
could run empty before MPlayer tries filling it again (normally once per
video frame), a buffer that is too big would force MPlayer decode the file
far ahead trying to find enough audio data to fill it.
static int play(void* data,int len,int flags);
Plays a bit of audio, which is received throught the "data" memory area, with
a size of "len". It has to copy the data, because they can be overwritten
after the call is made. Doesn't have to use all the bytes; it has to
return the number of bytes used used (copied to buffer). If
flags|AOPLAY_FINAL_CHUNK is true then this is the last audio in the file.
The purpose of this flag is to tell aos that round down the audio played
from "len" to a multiple of some chunksize that this "len" should not be
rounded down to 0 or the data will never be played (as MPlayer will never
call play() with a larger len).
static float get_delay(void);
Returns how long time it will take to play the data currently in the
output buffer. Be exact, if possible, since the whole timing depends
on this! In the worst case, return the maximum delay.
!!! Because the video is synchronized to the audio (card), it's very important
!!! that the get_delay function is correctly implemented!
static void audio_pause(void);
Pause playing but do not delete buffered data if possible.
static void audio_resume(void);
Continue playing after audio_pause().
-173
View File
@@ -1,173 +0,0 @@
libvo --- the library to handle video output by A'rpi, 2002.04
============================================
Note: before start on this, read colorspaces.txt !
The constants for different pixelformats are defined in img_format.h,
their usage is mandatory.
WARNING: Please keep in mind that some of this information may be out-dated,
so if you are working on a new vo, consider submitting preliminary patches
very early on. Currently vo_gl is one of the more up-to-date VOs to use
as reference if you are unsure about something and do not want to ask on the
list.
vo_vdpau and vo_direct3d may be a good choice, too, they use different
approaches closer to the sometimes convoluted way DirectX works.
Each vo driver _has_ to implement these:
preinit():
init the video system (to support querying for supported formats)
uninit():
Uninit the whole system, this is on the same "level" as preinit.
control():
Current controls (VOCTRL_QUERY_FORMAT must be implemented,
VOCTRL_DRAW_IMAGE, VOCTRL_FULLSCREEN, VOCTRL_UPDATE_SCREENINFO
should be implemented):
VOCTRL_QUERY_FORMAT - queries if a given pixelformat is supported.
It also returns various flags decsirbing the capabilities
of the driver with teh given mode. for the flags, see
file vfcaps.h !
the most important flags, every driver must properly report
these:
0x1 - supported (with or without conversion)
0x2 - supported without conversion (define 0x1 too!)
0x100 - driver/hardware handles timing (blocking)
also SET sw/hw scaling and osd support flags, and flip,
and accept_stride if you implement VOCTRL_DRAW_IMAGE (see bellow)
NOTE: VOCTRL_QUERY_FORMAT may be called _before_ first config()
but is always called between preinit() and uninit()
VOCTRL_GET_IMAGE
libmpcodecs Direct Rendering interface
You need to update mpi (mp_image.h) structure, for example,
look at vo_x11, vo_sdl, vo_xv or mga_common.
VOCTRL_DRAW_IMAGE
replacement for the current draw_slice/draw_frame way of
passing video frames. by implementing SET_IMAGE, you'll get
image in mp_image struct instead of by calling draw_*.
unless you return VO_TRUE for VOCTRL_DRAW_IMAGE call, the
old-style draw_* functils will be called!
Note: draw_slice is still mandatory, for per-slice rendering!
VOCTRL_RESET - reset the video device
This is sent on seeking and similar and is useful if you are
using a device which prebuffers frames that need to flush them
before refilling audio/video buffers.
VOCTRL_PAUSE
VOCTRL_RESUME
VOCTRL_GUISUPPORT
return true only if driver supports co-operation with
MPlayer's GUI (not yet used by GUI)
VOCTRL_SET_EQUALIZER
set the video equalizer to the given values
two arguments are provided: item and value
item is a string, the possible values are (currently):
brightness, contrast, saturation, hue
VOCTRL_GET_EQUALIZER
get the current video equalizer values
two arguments are provided: item and value
item is a string, the possible values are (currently):
brightness, contrast, saturation, hue
VOCTRL_ONTOP
Makes the player window stay-on-top. Only supported (currently)
by drivers which use X11, except SDL, as well as directx and
gl2 under Windows.
VOCTRL_BORDER
Makes the player window borderless.
VOCTRL_FULLSCREEN
Switch from and to fullscreen mode
VOCTRL_GET_PANSCAN
VOCTRL_SET_PANSCAN
Needed to implement pan-scan support ('w' and 'e' keys during
playback in fullscreen mode)
VOCTRL_START_SLICE
Called before the first draw_slice of each frame, useful if
you need to do some set-up work.
VOCTRL_DRAW_EOSD
Required for EOSD (ASS subtitle) support. Provides all
information necessary to draw the EOSD for the current video
frame.
VOCTRL_GET_EOSD_RES
Required for EOSD (ASS subtitle) support. Informs the ASS
renderer about the properties of the drawing area (size,
borders).
VOCTRL_SET_DEINTERLACE
VOCTRL_GET_DEINTERLACE
Get or set deinterlacing status for VOs that support some kind
of deinterlacing.
VOCTRL_UPDATE_SCREENINFO
Should set the xinerama_x, xinerama_y, vo_screenwidth and
vo_screenheight appropriately for the currently used
monitor and -xineramascreen option.
Usually should simply call the w32_update_xinerama_info or
update_xinerama_info function.
By supporting this, the VO also requests the newer API
that sets vo_dx, vo_dy etc. appropriately before config()
is called.
config():
Set up the video system. You get the dimensions and flags.
width, height: size of the source image
d_width, d_height: wanted scaled/display size (it's a hint)
Flags:
0x01 - force fullscreen (-fs)
0x02 - allow mode switching (-vm)
0x04 - allow software scaling (-zoom)
0x08 - flipping (-flip)
They're defined as VOFLAG_* (see libvo/video_out.h)
IMPORTANT NOTE: config() may be called 0 (zero), 1 or more (2,3...)
times between preinit() and uninit() calls. You MUST handle it, and
you shouldn't crash at second config() call or at uninit() without
any config() call! To make your life easier, vo_config_count is
set to the number of previous config() call, counted from preinit().
It's set by the caller (vf_vo.c), you don't have to increase it!
So, you can check for vo_config_count>0 in uninit() when freeing
resources allocated in config() to avoid crash!
You should implement VOCTRL_UPDATE_SCREENINFO so that vo_dx, vo_dy,
vo_dwidth and vo_dheight are already pre-set to values that take
aspect and -geometry into account. It is also necessary to properly
support multi-monitor setups (if based on x11_common, w32_common).
draw_slice(): this displays YV12 pictures (3 planes, one full sized that
contains brightness (Y), and 2 quarter-sized which the colour-info
(U,V). MPEG codecs (libmpeg2, opendivx) use this. This doesn't have
to display the whole frame, only update small parts of it.
If this is not supported, it must be signaled in QUERY_FORMAT with
VOCAP_NOSLICES.
draw_frame(): this is the older interface, this displays only complete
frames, and can do only packed format (YUY2, RGB/BGR).
Win32 codecs use this (DivX, Indeo, etc).
If you implement VOCTRL_DRAW_IMAGE, you do not need to implement draw_frame.
draw_osd(): this displays subtitles and OSD.
It's a bit tricky to use it, since it's a callback-style stuff.
It should call vo_draw_text() with screen dimension and your
draw_alpha implementation for the pixelformat (function pointer).
The vo_draw_text() checks the characters to draw, and calls
draw_alpha() for each. As a help, osd.c contains draw_alpha for
each pixelformats, use this if possible!
Note that if you do not draw directly onto the video you should
use vo_draw_text_ext() which allows you to specify the border
values etc. needed to draw DVD menu highlights at the correct place.
If you do not want to implement this, you can still use -vf
expand=osd=1 to draw the OSD, or even implement code to insert
this filter automatically.
Make sure you set VFCAP_OSD depending on whether you implemented it
or not.
NOTE: This one will be obsolete soon! But it's still useful when
you want to do tricks, like rendering osd _after_ hardware scaling
(tdfxfb) or render subtitles under of the image (vo_mpegpes, sdl)
NOTE2: above NOTE is probably wrong, there are currently no plans to
obsolete draw_osd, though there is the more advanced EOSD support for
ASS subtitles.
flip_page(): this is called after each frame, this displays the buffer for
real. This is 'swapbuffers' when doublebuffering.
Try to do as little work here as possible, since that affect jitter/
A-V sync.
-100
View File
@@ -1,100 +0,0 @@
TITLE=Weird Al Yankovic - The Saga Begins (clip)
# just to be informative (maybe future
# use?)
FILE=14233792,7972c637f619e01854ecb453b7339e3f # size,md5
AUTHOR=Gabucino
TYPE=VIDEO # maybe AUDIO in future (for displaying
# mp3 lyrics while playing or whatever)
FORMAT=TIME # this file contains measures based on
# TIME, not frames.
# if FORMAT is a number, then it's frame based, i.e.:
# FORMAT=25
NOTE=MPlayerSub test file v0.1
# first number : wait this much after previous subtitle disappeared
# second number : display the current subtitle for this many seconds
15 3
A long, long time ago...
0 3
in a galaxy far away...
0 3
Naboo was under an attack.
1 2.5
And I thought me and
Qui-Gon Jinn could
0 2.5
talk the Federation into
0 4
...maybe cutting them a
little slack.
2 3
But their response, it
didn't thrill us,
0 3
They locked the doors,
and tried to kill us.
0 2.5
We escaped from that gas,
0 3.5
then met Jar-jar and
Boss-Nass.
1 6
We took a bongo from the
scene and we went to
Theed to see the Queen.
0 5
We all wound' up on
Tatooine.
0 6
That's where, we've found
this boy.
0 4
Oh my, my this here
Anakin guy,
0 5
maybe Vader someday
later now he's just
a small fry.
0 4
And he left his home and
kissed his mommy goodbye,
0 5
singing "Soon I'm gonna be
a Jedi!"
6 6
Did you know this junkyard
slave isn't even old enough
to shave,
0 3
but he can use the Force,
they say.
1 6
Ahh, do you see him hitting
on the queen though he's
just nine and she's fourteen
0 6
yeah, he's probably gonna
marry her, someday!
-19
View File
@@ -1,19 +0,0 @@
software scaler filter docs
-ssf cgb=<float> chrominance gaussian blur
useful for videos with some chroma (color) noise (TV captures, VHS, ...)
-ssf lgb=<float> -> luminance gaussian blur
hmm, mostly special effect, could be used as lame noise reducer though
-ssf chs=<int> -> shift chrominance horizontally
-ssf cvs=<int> -> shift chrominance vertically
useful if the luma & chroma are not aligned exactly
-ssf cs=<float> -> chrominance sharpen
-ssf ls=<float> -> luminance sharpen
simple sharpening filter
note: these will only work if the swscaler is used at all (use -vf scale)
example: mplayer foobar.avi -vf scale -ssf lgb=3.0
-68
View File
@@ -1,68 +0,0 @@
artifact types:
---------------------------------------------------------------------
ringing
wave or noise like patterns around sharp edges
bad: sinc, lanczos (with high filter length)
acceptable: lanczos (with low filter length), cubic, spline
ok: area, (fast)blinear, gauss, point
blur
loss of detail / high frequency
bad: gauss with high variance
acceptable: (fast)bilinear, area
ok: others
aliasing (only downscale)
straight lines look like staircases
areas of high detail look worse
regular patterns turn into a funny looking mess (moire patterns)
bad: fast bilinear, point, gauss with low variance
acceptable: area
ok: others
blocky (upscale only)
looks like the image is made of rectangular blocks like a mosaic
bad: point
ok: others
recommendations: (based upon my personal opinion many ppl might disagree ...)
---------------------------------------------------------------------
the recommended scalers for upscaling:
fast_bilinear, point if speed is important
cubic, spline, lanczos if quality is important
the recommended scalers for downscaling:
fast_bilinear, point if speed is important
gauss, bilinear if quality is important
cubic, spline, lanczos if a sharper picture is important
note: when encoding at a limited amount of bits (not constant quantizer)
then a slightly blurred input might look better after decoding than a slightly
sharpened one, especially for lower bitrates
sws numbers / names / artifact types
-------------------------------------------------------------------------
r ringing
b blurry
a aliasing (downscale only)
m mosaic (blocky) (upscale only)
-sws 0 fast bilinear bA
-sws 1 bilinear b
-sws 2 bicubic high sharpness r
low sharpness b
-sws 3 experimental ????
-sws 4 nearest neighbour AM
-sws 5 area ba
-sws 6 luma bicubic / chroma bilinear r
-sws 7 gauss low sharpness B
high sharpness AM
-sws 8 sinc R
-sws 9 lanczos long filter R
short filter b
-sws 10 bicubic spline r
Notes:
area upscale is identical to bilinear
+42
View File
@@ -0,0 +1,42 @@
Introduction
============
This file lists all changes that can cause compatibility issues when using
mpv through the client API (libmpv and ``client.h``). Since the client API
interfaces to input handling (commands, properties) as well as command line
options, this list is interesting for other uses of mpv, such as the Lua
scripting interface, key bindings in ``input.rst``, or plain command line
usage.
Normally, changes to the C API that are incompatible to previous iterations
receive a major version bump (i.e. the first version number is increased),
while C API additions bump the minor version (i.e. the second number is
increased). Changes to properties/commands/options may also lead to a minor
version bump, in particular if they are incompatible.
The version number is the same as used for MPV_CLIENT_API_VERSION (see
``client.h`` how to convert between major/minor version numbers and the flat
32 bit integer).
Also, read the section ``Compatibility`` in ``client.h``.
API changes
===========
::
--- mpv 0.5.0 is released ---
1.3 - add MPV_MAKE_VERSION()
1.2 - remove "stream-time-pos" property (no replacement)
1.1 - remap dvdnav:// to dvd://
- add "--cache-file", "--cache-file-size"
- add "--colormatrix-primaries" (and property)
- add "primaries" sub-field to image format properties
- add "playback-time" property
- extend the "--start" option; a leading "+", which was previously
insignificant is now significant
- add "cache-free" and "cache-used" properties
- OSX: the "coreaudio" AO spdif code is split into a separate AO
--- mpv 0.4.0 is released ---
1.0 - the API is declared stable
+136
View File
@@ -0,0 +1,136 @@
// License: pick one of: public domain, WTFPL, ISC, Ms-PL, AGPLv3
// This example can be built with: qmake && make
#include <sstream>
#include <QFileDialog>
#include <QStatusBar>
#include <QMenuBar>
#include <QMenu>
#include <QGridLayout>
#include <QApplication>
#include "qtexample.h"
static void wakeup(void *ctx)
{
// This callback is invoked from any mpv thread (but possibly also
// recursively from a thread that is calling the mpv API). Just notify
// the Qt GUI thread to wake up (so that it can process events with
// mpv_wait_event()), and return as quickly as possible.
MainWindow *mainwindow = (MainWindow *)ctx;
QCoreApplication::postEvent(mainwindow, new QEvent(QEvent::User));
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
QMenu *menu = menuBar()->addMenu(tr("&File"));
QAction *on_open = new QAction(tr("&Open"), this);
on_open->setShortcuts(QKeySequence::Open);
on_open->setStatusTip(tr("Open a file"));
connect(on_open, SIGNAL(triggered()), this, SLOT(on_file_open()));
menu->addAction(on_open);
statusBar();
mpv = mpv_create();
if (!mpv)
throw "can't create mpv instance";
// Create a video child window. Force Qt to create a native window, and
// pass the window ID to the mpv wid option. This doesn't work on OSX,
// because Cocoa doesn't support this form of embedding.
mpv_container = new QWidget(this);
setCentralWidget(mpv_container);
mpv_container->setAttribute(Qt::WA_NativeWindow);
int64_t wid = mpv_container->winId();
mpv_set_option(mpv, "wid", MPV_FORMAT_INT64, &wid);
// Enable default bindings, because we're lazy. Normally, a player using
// mpv as backend would implement its own key bindings.
mpv_set_option_string(mpv, "input-default-bindings", "yes");
// Let us receive property change events with MPV_EVENT_PROPERTY_CHANGE if
// this property changes.
mpv_observe_property(mpv, 0, "time-pos", MPV_FORMAT_DOUBLE);
// From this point on, the wakeup function will be called. The callback
// can come from any thread, so we use the Qt QEvent mechanism to relay
// the wakeup in a thread-safe way.
mpv_set_wakeup_callback(mpv, wakeup, this);
if (mpv_initialize(mpv) < 0)
throw "mpv failed to initialize";
}
void MainWindow::handle_mpv_event(mpv_event *event)
{
switch (event->event_id) {
case MPV_EVENT_PROPERTY_CHANGE: {
mpv_event_property *prop = (mpv_event_property *)event->data;
if (strcmp(prop->name, "time-pos") == 0) {
if (prop->format == MPV_FORMAT_DOUBLE) {
double time = *(double *)prop->data;
std::stringstream ss;
ss << "At: " << time;
statusBar()->showMessage(QString::fromStdString(ss.str()));
} else if (prop->format == MPV_FORMAT_NONE) {
// The property is unavailable, which probably means playback
// was stopped.
statusBar()->showMessage("");
}
}
break;
}
case MPV_EVENT_SHUTDOWN: {
mpv_terminate_destroy(mpv);
mpv = NULL;
break;
}
default: ;
// Ignore uninteresting or unknown events.
}
}
bool MainWindow::event(QEvent *event)
{
// QEvent::User is sent by wakeup().
if (event->type() == QEvent::User) {
// Process all events, until the event queue is empty.
while (mpv) {
mpv_event *event = mpv_wait_event(mpv, 0);
if (event->event_id == MPV_EVENT_NONE)
break;
handle_mpv_event(event);
}
return true;
}
return QMainWindow::event(event);
}
void MainWindow::on_file_open()
{
QString filename = QFileDialog::getOpenFileName(this, "Open file");
if (mpv) {
const QByteArray c_filename = filename.toUtf8();
const char *args[] = {"loadfile", c_filename.data(), NULL};
mpv_command_async(mpv, 0, args);
}
}
MainWindow::~MainWindow()
{
if (mpv)
mpv_terminate_destroy(mpv);
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
+30
View File
@@ -0,0 +1,30 @@
#ifndef QTEXAMPLE_H
#define QTEXAMPLE_H
#include <QMainWindow>
#include <mpv/client.h>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
protected:
virtual bool event(QEvent *event);
private slots:
void on_file_open();
private:
QWidget *mpv_container;
mpv_handle *mpv;
void create_player();
void handle_mpv_event(mpv_event *event);
};
#endif // QTEXAMPLE_H
+12
View File
@@ -0,0 +1,12 @@
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = qtexample
TEMPLATE = app
CONFIG += link_pkgconfig
PKGCONFIG = mpv
SOURCES += qtexample.cpp
HEADERS += qtexample.h
+10
View File
@@ -0,0 +1,10 @@
#include <stdio.h>
#include <stdlib.h>
static inline void check_error(int status)
{
if (status < 0) {
printf("mpv API error: %s\n", mpv_error_string(status));
exit(1);
}
}
+44
View File
@@ -0,0 +1,44 @@
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include "libmpv/client.h"
#include "shared.h"
int main(int argc, char *argv[])
{
if (argc != 2) {
printf("pass a single media file as argument\n");
return 1;
}
mpv_handle *ctx = mpv_create();
if (!ctx) {
printf("failed creating context\n");
return 1;
}
// Enable default key bindings, so the user can actually interact with
// the player (and e.g. close the window).
check_error(mpv_set_option_string(ctx, "input-default-bindings", "yes"));
int val = 1;
check_error(mpv_set_option(ctx, "osc", MPV_FORMAT_FLAG, &val));
// Done setting up options.
check_error(mpv_initialize(ctx));
// Play this file.
const char *cmd[] = {"loadfile", argv[1], NULL};
check_error(mpv_command(ctx, cmd));
// Let it play, and wait until the user quits.
while (1) {
mpv_event *event = mpv_wait_event(ctx, 10000);
printf("event: %s\n", mpv_event_name(event->event_id));
if (event->event_id == MPV_EVENT_SHUTDOWN)
break;
}
mpv_terminate_destroy(ctx);
return 0;
}
+147
View File
@@ -0,0 +1,147 @@
How to contribute
=================
General
-------
The main contact for mpv development is IRC, specifically #mpv-player and
#mpv-player-dev on Freenode.
Sending patches
---------------
- Make a github pull request, or send a link to a plaintext patch created with
``git format-patch``. diffs posted as pastebins (especially if the http link
returns HTML) just cause extra work for everyone, because they lack commit
message and authorship information.
- Write informative commit messages. Use present tense to describe the
situation with the patch applied, and past tense for the situation before
the change.
- The subject line (the first line in a commit message) should contain a
prefix identifying the sub system, followed by a short description what
impact this commit has. This subject line shouldn't be longer than 72
characters, because it messes up the output of many git tools otherwise.
For example, you fixed a crash in af_volume.c:
Bad: ``fixed the bug (wtf?)``
Good: ``af_volume: fix crash due to null pointer access``
Having a prefix gives context, and is especially useful when trying to find
a specific change by looking at the history, or when running ``git blame``.
- The body of the commit message (everything else after the subject line) should
be as informative as possible and contain everything that isn't obvious. Don't
hesitate to dump as much information as you can - it doesn't cost you
anything. Put some effort into it. If someone finds a bug months or years
later, and finds that it's caused by your commit (even though your commit was
supposed to fix another bug), it would be bad if there wasn't enough
information to test the original bug. The old bug might be reintroduced while
fixing the new bug.
The commit message should be wrapped on 72 characters per line, because git
tools usually do not break text automatically. On the other hand, you do not
need to break text that would be unnatural to break (like data for test cases,
or long URLs).
Important: put an empty line between the subject line and the commit message.
If this is missing, it will break display in common git tools.
- Try to separate cosmetic and functional changes. It's ok to make a few
additional cosmetic changes in the same file you're working on. But don't do
something like reformatting a whole file, and hiding an actual functional
change in the same commit.
- If you add a new command line option, document it in options.rst. If you
add a new input property, document it in input.rst.
Code formatting
---------------
mpv uses C99 with K&R formatting, with some exceptions.
- Use the K&R indent style.
- Use 4 spaces of indentation, never use tabs (except in Makefiles).
- Add a single space between keywords and binary operators. There are some other
cases where spaces should be added. Example:
```C
if ((a * b) > c) {
// code
some_function(a, b, c);
}
```
- Break lines on 80 columns. There is a hard limit of 85 columns. You may ignore
this limit if there's a strong case that not breaking the line will increase
readability. Going over 85 columns might provoke endless discussions about
whether such a limit is needed or not, so avoid it.
- If the body of an if/for/while statement has more than 1 physical lines, then
always add braces, even if they're technically redundant.
Bad:
```C
if (a)
// do something if b
if (b)
do_something();
```
Good:
```C
if (a) {
// do something if b
if (b)
do_something();
}
```
- If the body of an if statement uses braces, the else branch should also
use braces (and reverse).
Example:
```C
if (a) {
// do something
something();
something_else();
} else {
one_line();
}
```
- If an if condition spans multiple physical lines, then put the opening brace
for the if body on the next physical line. (Also, preferably always add a
brace, even if technically none is needed.)
Example:
```C
if (very_long_condition_a &&
very_long_condition_b)
{
code();
}
```
- Remove any trailing whitespace.
- If the file you're editing uses formatting different from from what is
described here, it's probably an old file from times when nobody followed a
consistent style. You're free to use the existing style, or the new style, or
to send a patch to reformat the file to the new style before making functional
changes.
General coding
--------------
- Use C99. Also freely make use of C99 features if it's appropriate, such as
stdbool.h.
- Don't use GNU-only features. In some cases they may be warranted, if they
are optional (such as attributes enabling printf-like format string checks).
But in general, standard C99 should be used.
- The same applies to libc functions. We have to be Windows-compatible too. Use
functions guaranteed by C99 or POSIX only, unless your use is guarded by a
configure check.
- Prefer fusing declaration and initialization, rather than putting declarations
on the top of a block. Obvious data flow is more important than avoiding
mixing declarations and statements, which is just a C90 artifact.
- tech-overview.txt might help to get an overview how mpv is structured.
- If you add features that require intrusive changes, discuss them on the dev
channel first. There might be a better way to add a feature and it can avoid
wasted work.
+74
View File
@@ -0,0 +1,74 @@
Cross Compiling to Windows
==========================
Cross compiling mpv to Windows is supported with MinGW-w64. This can be used to
produce both 32 bit and 64 bit executables. MinGW-w64 is available from
http://mingw-w64.sourceforge.net.
You have to run mpv's configure with these arguments:
```bash
DEST_OS=win32 TARGET=i686-w64-mingw32 ./waf configure
```
While building a complete MinGW-w64 toolchain yourself is possible, people have
created scripts to help ease the process. These are the two recommended methods:
- Using [mingw-w64-cmake](https://github.com/lachs0r/mingw-w64-cmake) to setup
a MinGW-w64 environment. We recommend you to try this first before MXE.
mingw-w64-cmake will also build mpv and its dependencies.
- Alternatively, you can use MXE: http://mxe.cc. With MXE, you have to manually
set the target to MinGW-w64 (even if you compile to 32 bit). A working example
below.
**Warning**: the original MinGW (http://www.mingw.org) is unsupported.
Note that MinGW environments included in Linux distributions are often broken,
outdated and useless, and usually don't use MinGW-w64.
Example with MXE
----------------
```bash
# Download MXE. Note that compiling the required packages requires about 1.4 GB
# or more!
cd /opt
git clone https://github.com/mxe/mxe mingw
cd mingw
# Set build options.
# The JOBS environment variable controls threads to use when building. DO NOT
# use the regular `make -j4` option with MXE as it will slow down the build.
# Alternatively, you can set this in the make command by appending "JOBS=4"
# to the end of command:
echo "JOBS := 4" >> settings.mk
# The MXE_TARGET environment variable builds MinGW-w64 for 32 bit targets.
# Alternatively, you can specify this in the make command by appending
# "MXE_TARGETS=i686-w64-mingw32" to the end of command:
echo "MXE_TARGETS := i686-w64-mingw32" >> settings.mk
# If you want to build 64 bit version, use this:
# echo "MXE_TARGETS := x86_64-w64-mingw32" >> settings.mk
# Build required packages. The following provide a minimum required to build
# mpv.
make gcc ffmpeg libass jpeg pthreads
# Add MXE binaries to $PATH
export PATH=/opt/mingw/usr/bin/:$PATH
# Build mpv. The target will be used to automatically select the name of the
# build tools involved (e.g. it will use i686-w64-mingw32-gcc).
cd ..
git clone https://github.com/mpv-player/mpv.git
cd mpv
DEST_OS=win32 TARGET=i686-w64-mingw32 ./waf configure
# Or, if 64 bit version,
# DEST_OS=win32 TARGET=x86_64-w64-mingw32 ./waf configure
./waf build
```
-52
View File
@@ -1,52 +0,0 @@
Cross compiling mpv to Windows is supported with MinGW-w64. This can be used to
produce both 32 bit and 64 bit executables. MinGW-w64 is available from
http://mingw-w64.sourceforge.net.
You have to run mpv's configure with these arguments:
DEST_OS=win32 TARGET=i686-w64-mingw32 ./waf configure
Using mingw-w64-cmake to setup a MinGW-w64 environment is recommended (this will
also build mpv and its dependencies): https://github.com/lachs0r/mingw-w64-cmake
Alternatively, use MXE: http://mxe.cc
Warning: the original MinGW (http://www.mingw.org) is unsupported.
Note that MinGW environments included in Linux distributions are often broken,
outdated and useless, and usually don't use MinGW-w64.
Example with MXE
================
# Download MXE. Note that compiling the required packages requires about 1 GB
# or more!
cd /opt
git clone https://github.com/mxe/mxe mingw
cd mingw
# Edit the MXE target, so that MinGW-w64 for 32 bit targets is built.
echo "MXE_TARGETS := i686-w64-mingw32" > settings.mk
# Build required packages. The following provide a minimum required to build
# mpv. (Not all of the following packages are strictly required.)
make gcc
make ffmpeg
make libass
make jpeg
make pthreads
# Build mpv. The target will be used to automatically select the name of the
# build tools involved (e.g. it will use i686-w64-mingw32-gcc).
git clone https://github.com/mpv-player/mpv.git
cd mpv
export PATH=/opt/mingw/usr/bin/:$PATH
DEST_OS=win32 TARGET=i686-w64-mingw32 ./waf configure
./waf build
# This should work. Note however that MXE’s ffmpeg package might be very old
# in order to avoid breaking e.g. xine-lib, so you might want to update that
# or build it manually as well.
+17 -1
View File
@@ -78,7 +78,7 @@ The parameter name defines the meaning of the parameter:
2) ``start``, a time value that specifies the start offset into the source file.
3) ``length``, a time value that specifies the length of the segment.
(Currently, time values are floating point values in seconds.)
See the section below for the format of timestamps.
Unnamed parameters carry implicit names. The parameter position determines
which of the parameters listed above is set. For example, the second parameter
@@ -95,6 +95,22 @@ to ``20``, ``param3`` to ``value,escaped``, ``param4`` to ``value2``.
Instead of line breaks, the character ``;`` can be used. Line feed bytes and
``;`` are treated equally.
Timestamp format
================
Currently, time values are floating point values in seconds.
As an extension, you can set the ``timestamps=chapters`` option. If this option
is set, timestamps have to be integers, and refer to chapter numbers, starting
with 0.
Example::
# mpv EDL v0
file.mkv,2,4,timestamps=chapters
Plays chapter 3 and ends with the start of chapter 7 (4 chapters later).
Syntax of EDL URIs
==================
+7 -2
View File
@@ -25,7 +25,7 @@ from the input video. Note that not all codecs and not all formats support VFR
encoding, and some which do have bugs when a target bitrate is specified - use
-ofps or -oautofps to force CFR encoding in these cases.
Of course, the options can be stored in a profile, like this .mpv/config
Of course, the options can be stored in a profile, like this .config/mpv/mpv.conf
section::
[myencprofile]
@@ -38,6 +38,11 @@ section::
oac = aac
oacopts-add = b=96k
It's also possible to define default encoding options by putting them into
the section named ``[encoding]``. (This behavior changed after mpv 0.3.x. In
mpv 0.3.x, config options in the default section / no section were applied
to encoding. This is not the case anymore.)
One can then encode using this profile using the command::
mpv infile -o outfile.mp4 -profile myencprofile
@@ -134,9 +139,9 @@ What works
* Deinterlacing/Inverse Telecine with any of mpv's filters for that
* Audio file converting: mpv -o outfile.mp3 infile.flac -no-video -oac
libmp3lame -oacopts ab=320k
* inverse telecine filters (confirmed working: detc, pullup, filmdint)
What does not work yet
======================
* 3-pass encoding (ensuring constant total size and bitrate constraints while
having VBR audio; mencoder calls this "frameno")
+29 -11
View File
@@ -147,7 +147,7 @@ Available filters are:
0 no matrix decoding (default)
==== ===================================
``equalizer=[g1:g2:g3:...:g10]``
``equalizer=g1:g2:g3:...:g10``
10 octave band graphic equalizer, implemented using 10 IIR band-pass
filters. This means that it works regardless of what type of audio is
being played back. The center frequencies for the 10 bands are:
@@ -241,7 +241,7 @@ Available filters are:
48000 for example.
``<channels>``
Force mixing to a specific channel layout. See ``--channels`` option
Force mixing to a specific channel layout. See ``--audio-channels`` option
for possible values.
``<out-format>``
@@ -250,8 +250,9 @@ Available filters are:
``<out-channels>``
See also ``--format``, ``--srate``, and ``--channels`` for related options.
Keep in mind that ``--channels`` does not actually force the number of
See also ``--audio-format``, ``--audio-samplerate``, and
``--audio-channels`` for related options. Keep in mind that
``--audio-channels`` does not actually force the number of
channels in most cases, while this filter can do this.
*NOTE*: this filter used to be named ``force``. Also, unlike the old
@@ -266,7 +267,7 @@ Available filters are:
Filter for internal use only. Converts between signed/unsigned formats
and formats with different endian.
``volume[=volumedb[:softclip[:s16]]]``
``volume[=<volumedb>[:...]]``
Implements software volume control. Use this filter with caution since it
can reduce the signal to noise ratio of the sound. In most cases it is
best to use the *Master* volume control of your sound card or the volume
@@ -279,16 +280,33 @@ Available filters are:
Sets the desired gain in dB for all channels in the stream from -200dB
to +60dB, where -200dB mutes the sound completely and +60dB equals a
gain of 1000 (default: 0).
``<softclip>``
``replaygain-track``
Adjust volume gain according to the track-gain replaygain value stored
in the file metadata.
``replaygain-album``
Like replaygain-track, but using the album-gain value instead.
``replaygain-preamp``
Pre-amplification gain in dB to apply to the selected replaygain gain
(default: 0).
``replaygain-clip=yes|no``
Prevent clipping caused by replaygain by automatically lowering the
gain (default). Use ``replaygain-clip=no`` to disable this.
``softclip``
Turns soft clipping on. Soft-clipping can make the
sound more smooth if very high volume levels are used. Enable this
option if the dynamic range of the loudspeakers is very low.
*WARNING*: This feature creates distortion and should be considered a
last resort.
``<s16>``
``s16``
Force S16 sample format if set. Lower quality, but might be faster
in some situations.
``detach``
Remove the filter if the volume is not changed at audio filter config
time. Useful with replaygain: if the current file has no replaygain
tags, then the filter will be removed if this option is enabled.
(If ``--softvol=yes`` is used and the player volume controls are used
during playback, a different volume filter will be inserted.)
.. admonition:: Example
@@ -296,7 +314,7 @@ Available filters are:
Would amplify the sound by 10.1dB and hard-clip if the sound level
is too high.
``pan=n[:<matrix>]``
``pan=n:[<matrix>]``
Mixes channels arbitrarily. Basically a combination of the volume and the
channels filter that can be used to down-mix many channels to only a few,
e.g. stereo to mono, or vary the "width" of the center speaker in a
@@ -333,7 +351,7 @@ Available filters are:
If you just want to force remixing to a certain output channel layout,
it is easier to use the ``format`` filter. For example,
``mpv '--af=format=channels=5.1' '--channels=5.1'`` would always force
``mpv '--af=format=channels=5.1' '--audio-channels=5.1'`` would always force
remixing audio to 5.1 and output it like this.
``sub[=fc:ch]``
@@ -362,7 +380,7 @@ Available filters are:
.. admonition:: Example
``mpv --af=sub=100:4 --channels=5 media.avi``
``mpv --af=sub=100:4 --audio-channels=5 media.avi``
Would add a subwoofer channel with a cutoff frequency of 100Hz to
output channel 4.
@@ -390,7 +408,7 @@ Available filters are:
.. admonition:: Example
``mpv --af=surround=15 --channels=4 media.avi``
``mpv --af=surround=15 --audio-channels=4 media.avi``
Would add surround sound decoding with 15ms delay for the sound to
the rear speakers.
+69 -8
View File
@@ -18,7 +18,12 @@ normal driver parameters.
.. note::
See ``--ao=help`` for a list of compiled-in audio output drivers.
See ``--ao=help`` for a list of compiled-in audio output drivers. The
driver ``--ao=alsa`` is preferred. ``--ao=pulse`` is preferred on systems
where PulseAudio is used. On Windows, ``--ao=wasapi`` is preferred,
though it might cause trouble sometimes, in which case ``--ao=dsound``
should be used. On BSD systems, ``--ao=oss`` or `--ao=sndio`` may work
(the latter being experimental). On OSX systems, use ``--ao=coreaudio``.
.. admonition:: Examples
@@ -31,14 +36,14 @@ Available audio output drivers are:
``alsa`` (Linux only)
ALSA audio output driver
``device=<device>``
Sets the device name. For ac3 output via S/PDIF, use an "iec958" or
"spdif" device, unless you really know how to set it correctly.
``no-block``
Sets noblock-mode.
``resample=yes``
Enable ALSA resampling plugin. (This is disabled by default, because
some drivers report incorrect audio delay in some cases.)
``device=<device>``
Sets the device name. For ac3 output via S/PDIF, use an "iec958" or
"spdif" device, unless you really know how to set it correctly.
``mixer-device=<device>``
Set the mixer device used with ``--no-softvol`` (default: ``default``).
``mixer-name=<name>``
@@ -48,6 +53,10 @@ Available audio output drivers are:
Set the index of the mixer channel (default: 0). Consider the output of
"``amixer scontrols``", then the index is the number that follows the
name of the element.
``non-interleaved``
Allow output of non-interleaved formats (if the audio decoder uses
this format). Currently disabled by default, because some popular
ALSA plugins are utterly broken with non-interleaved formats.
.. note::
@@ -81,9 +90,6 @@ Available audio output drivers are:
``name=<client>``
Client name that is passed to JACK (default: ``mpv``). Useful
if you want to have certain connections established automatically.
``(no-)estimate``
Estimate the audio delay, supposed to make the video playback smoother
(default: enabled).
``(no-)autostart``
Automatically start jackd if necessary (default: disabled). Note that
this tends to be unreliable and will flood stdout with server messages.
@@ -108,7 +114,19 @@ Available audio output drivers are:
with fixed setups.
``coreaudio`` (Mac OS X only)
Native Mac OS X audio output driver
Native Mac OS X audio output driver using the AudioUnits and the CoreAudio
sound server.
``device_id=<id>``
ID of output device to use (0 = default device)
``help``
List all available output devices with their IDs.
``coreaudio_device`` (Mac OS X only)
Native Mac OS X audio output driver using direct device access and
exclusive mode (bypasses the sound server).
Supports only compressed formats (AC3 and DTS).
``device_id=<id>``
ID of output device to use (0 = default device)
@@ -118,6 +136,9 @@ Available audio output drivers are:
``openal``
Experimental OpenAL audio output driver
.. note:: This driver is not very useful. Playing multi-channel audio with
it is slow.
``pulse``
PulseAudio audio output driver
@@ -126,10 +147,26 @@ Available audio output drivers are:
string uses a local connection, "localhost" uses network transfer
(most likely not what you want).
``buffer=<1-2000|native>``
Set the audio buffer size in milliseconds. A higher value buffers
more data, and has a lower probability of buffer underruns. A smaller
value makes the audio stream react faster, e.g. to playback speed
changes. Default: 250.
``latency-hacks=<yes|no>``
Enable hacks to workaround PulseAudio timing bugs (default: yes). If
enabled, mpv will do elaborate latency calculations on its own. If
disabled, it will use PulseAudio automatically updated timing
information. Disabling this might help with e.g. networked audio.
``portaudio``
PortAudio audio output driver. This works on all platforms, and has
extensive MS Windows support.
.. note:: This driver is not very useful. It was added in the hope of
providing portable audio API across all platforms, but turned
out semi-broken and underfeatured.
``device``
Specify the subdevice to use. Giving ``help`` as device name lists all
devices found by PortAudio. Devices can be given as numeric values,
@@ -138,6 +175,8 @@ Available audio output drivers are:
``dsound`` (Windows only)
DirectX DirectSound audio output driver
.. note:: This driver is for compatibility with old systems.
``device=<devicenum>``
Sets the device number to use. Playing a file with ``-v`` will show a
list of available devices.
@@ -147,6 +186,10 @@ Available audio output drivers are:
1.2, but may require the ``SDL_AUDIODRIVER`` environment variable to be set
appropriately for your system.
.. note:: This driver is for compatibility with extremely foreign
environments, such as systems where none of the other drivers
are available.
``buflen=<length>``
Sets the audio buffer length in seconds. Is used only as a hint by the
sound system. Playing a file with ``-v`` will show the requested and
@@ -172,6 +215,18 @@ Available audio output drivers are:
``outburst``
Simulated chunk size in samples.
``speed``
Simulated audio playback speed as a multiplier. Usually, a real audio
device will not go exactly as fast as the system clock. It will deviate
just a little, and this option helps simulating this.
``latency``
Simulated device latency. This is additional to EOF.
``broken-eof``
Simulate broken audio drivers, which always add the fixed device
latency to the reported audio playback position.
``pcm``
Raw PCM/WAVE file writer audio output
@@ -186,6 +241,10 @@ Available audio output drivers are:
``rsound``
Audio output to an RSound daemon
.. note:: Completely useless, unless you intend to run RSound. Not to be
confused with RoarAudio, which is something completely
different.
``host=<name/path>``
Set the address of the server (default: localhost). Can be either a
network hostname for TCP connections or a Unix domain socket path
@@ -197,6 +256,8 @@ Available audio output drivers are:
``sndio``
Audio output to the OpenBSD sndio sound system
.. note:: Experimental. There are known bugs and issues.
(Note: only supports mono, stereo, 4.0, 5.1 and 7.1 channel
layouts.)
+184 -94
View File
@@ -1,20 +1,30 @@
CHANGES FROM OTHER VERSIONS OF MPLAYER
======================================
**mpv** is based on mplayer2, which in turn is based on the original
MPlayer (also called mplayer, mplayer-svn, mplayer1). Many changes
have been made. Some changes are incompatible, or completely change how the
player behaves.
**mpv** is based on mplayer2, which in turn is based on the original MPlayer
(also called mplayer, mplayer-svn, mplayer1). Many changes have been made, a
large part of which is incompatible or completely changes how the player
behaves. Although there are still many similarities to its ancestors, **mpv**
should generally be treated as a completely different program.
General Changes for MPlayer to mplayer2
---------------------------------------
.. note::
These lists are incomplete.
* Removal of the internal GUI, MEncoder, OSD menu
General Changes for MPlayer to mpv
----------------------------------
* Switch to GPLv2+. (Technically speaking, MPlayer as a whole seems to be
GPLv2-only, while mplayer2 is GPLv3+ - see ``Copyright`` file for details.)
* Removal of the internal GUI, MEncoder, OSD menu, video kernel drivers for
Linux 2.4 (including VIDIX)
* Large internal cleanups
* Removal of support for dead platforms
* New buildsystem
* No embedded copy of ffmpeg and other libraries
* Better pause handling (do not unpause on a command)
* Better MKV support (such as ordered chapters)
* vo_vdpau improvements
* Precise seeking support
* No embedded copy of ffmpeg and other libraries
* Native OpenGL backend for OSX
* General OSX improvements
* Improvements in audio/video sync handling
@@ -30,18 +40,6 @@ General Changes for MPlayer to mplayer2
* Screenshot improvements (instant screenshots without 1-frame delay, allow
taking screenshots even with hardware decoding)
* Improved support for PulseAudio
* General code cleanups
* Many more changes
General Changes for mplayer2 to mpv
-----------------------------------
* Switch back to GPLv2+.
* Removal of lots of unneeded code to encourage developer activity (less
obscure scary zombie code that kills any desire for hacking the codebase)
* Removal of dust and dead bodies (code-wise), such as kernel drivers for
decades old hardware
* Removal of support for dead platforms
* Generally improved MS Windows support (dealing with unicode filenames,
improved ``--vo=direct3d``, improved window handling)
* Better OSD rendering (using libass). This has full unicode support, and
@@ -104,6 +102,9 @@ General Changes for mplayer2 to mpv
* OSX: VDA support using libavcodec hwaccel API insted of FFmpeg's decoder. Up
to 2-2.5x reduction in CPU usage.
* Make hardware decoding in general work with the ``opengl`` video output.
* Lua scripting (see `LUA SCRIPTING`_)
* A client API, that allows embedding **mpv** into applications
(see ``libmpv/client.h`` in the sources)
* General bug fixes and removal of long-standing issues
* General code cleanups (including refactoring or rewrites of many parts)
* Many more changes
@@ -120,66 +121,99 @@ Command Line Switches
* There is a new command line syntax, which is generally preferred over the old
syntax. ``-optname optvalue`` becomes ``--optname=optvalue``.
The old syntax will not be removed in the near future. However, the new
syntax is mentioned in all documentation and so on, so it is a good thing to
know about this change.
(The new syntax was introduced in mplayer2.)
The old syntax will not be removed. However, the new syntax is mentioned in
all documentation and so on, and unlike the old syntax is not ambiguous,
so it is a good thing to know about this change.
* In general, negating switches like ``-noopt`` now have to be written as
``-no-opt``, or better ``--no-opt``.
``-no-opt`` or ``--no-opt``.
* Per-file options are not the default anymore. You can explicitly specify
file-local options. See ``Usage`` section.
* Many options have been renamed, removed or changed semantics. Some options
that are required for a good playback experience with MPlayer are now
superfluous or even worse than the defaults, so make sure to read the manual
before trying to use your existing configuration with **mpv**.
* Table of renamed/replaced switches:
=========================== ========================================
Old New
=========================== ========================================
``-no<opt>`` ``--no-<opt>`` (add a dash)
``-nosound`` ``--no-audio``
``-use-filename-title`` ``--title='${filename}'``
``-loop 0`` ``--loop=inf``
``-hardframedrop`` ``--framedrop=hard``
``-osdlevel`` ``--osd-level``
``-delay`` ``--audio-delay``
``-subdelay`` ``--sub-delay``
``-subpos`` ``--sub-pos``
``-forcedsubsonly`` ``--sub-forced-only``
``-benchmark`` ``--untimed`` (no stats)
``-xineramascreen`` ``--screen`` (different values)
``-ss`` ``--start``
``-endpos`` ``--length``
``-cursor-autohide-delay`` ``--cursor-autohide``
``-sub-fuzziness`` ``--autosub-match``
``-subfont`` ``--sub-text-font``
``-font`` ``--osd-font``
``-subfont-*`` ``--sub-text-*``, ``--osd-*``
``-subfont-text-scale`` ``--sub-scale``
``-spugauss`` ``--sub-gauss``
``-vobsub`` ``--sub`` (pass the .idx file)
``-ass-bottom-margin`` ``--vf=sub=bottom:top``
``-vc ffh264vdpau`` (etc.) ``--hwdec=vdpau``
``-ac spdifac3`` ``--ad=spdif:ac3`` (see ``--ad=help``)
``-afm hwac3`` ``--ad=spdif:ac3,spdif:dts``
``-x W``, ``-y H`` ``--geometry=WxH`` + ``--no-keepaspect``
``-xy W`` ``--autofit=W``
``-a52drc level`` ``--ad-lavc-ac3drc=level``
``-dumpstream`` ``--stream-dump=<filename>``
``-ac spdifac3`` ``--ad=spdif:ac3`` (see ``--ad=help``)
``-af volnorm`` ``--af=drc`` (renamed)
``-afm hwac3`` ``--ad=spdif:ac3,spdif:dts``
``-ao alsa:device=hw=0.3`` ``--ao=alsa:device=[hw:0,3]``
``-aspect`` ``--video-aspect``
``-ass-bottom-margin`` ``--vf=sub=bottom:top``
``-ass`` ``--sub-ass``
``-audiofile-cache`` (removed; the main cache settings are used)
``-audiofile`` ``--audio-file``
``-benchmark`` ``--untimed`` (no stats)
``-capture`` ``--stream-capture=<filename>``
``-stop-xscreensaver`` ``--stop-screensaver``
``-subfile`` ``--sub``
``-channels`` ``--audio-channels`` (changed semantics)
``-cursor-autohide-delay`` ``--cursor-autohide``
``-delay`` ``--audio-delay``
``-dumpstream`` ``--stream-dump=<filename>``
``-dvdangle`` ``--dvd-angle``
``-endpos`` ``--length``
``-font`` ``--osd-font``
``-forcedsubsonly`` ``--sub-forced-only``
``-forceidx`` ``--index``
``-format`` ``--audio-format``
``-fsmode-dontuse`` (removed)
``-fstype`` ``--x11-netwm`` (changed semantics)
``-hardframedrop`` ``--framedrop=hard``
``-identify`` (removed; use TOOLS/mpv_identify.sh)
``-idx`` ``--index``
``-lavdopts ...`` ``--vd-lavc-...``
``-lavfdopts`` ``--demuxer-lavf-...``
``-rawaudio ...`` ``--demuxer-rawaudio-...``
``-rawvideo ...`` ``--demuxer-rawvideo-...``
``-mixer`` AO suboptions (``alsa``, ``oss``)
``-lircconf`` ``--input-lirc-conf``
``-loop 0`` ``--loop=inf``
``-mixer-channel`` AO suboptions (``alsa``, ``oss``)
``-ao alsa:device=hw=0.3`` ``--ao=alsa:device=[hw:0,3]``
``-af volnorm`` ``--af=drc`` (renamed)
``-zoom`` Inverse available as ``--video-unscaled``
``-mixer`` AO suboptions (``alsa``, ``oss``)
``-mouse-movements`` ``--input-cursor``
``-msgcolor`` ``--msg-color``
``-msglevel`` ``--msg-level`` (changed semantics)
``-msgmodule`` ``--msg-module``
``-name`` ``--x11-name``
``-noar`` ``--no-input-appleremote``
``-noautosub`` ``--no-sub-auto``
``-noconsolecontrols`` ``--no-input-terminal``
``-nojoystick`` ``--no-input-joystick``
``-nosound`` ``--no-audio``
``-osdlevel`` ``--osd-level``
``-panscanrange`` ``--video-zoom``, ``--video-pan-x/y``
``-playing-msg`` ``--term-playing-msg``
``-pp ...`` ``'--vf=pp=[...]'``
``-pphelp`` ``--vf=pp:help``
``-rawaudio ...`` ``--demuxer-rawaudio-...``
``-rawvideo ...`` ``--demuxer-rawvideo-...``
``-spugauss`` ``--sub-gauss``
``-srate`` ``--audio-samplerate``
``-ss`` ``--start``
``-ssf <sub>`` ``--sws-...``
``-stop-xscreensaver`` ``--stop-screensaver``
``-sub-fuzziness`` ``--sub-auto``
``-sub`` ``--sub-file``
``-subcp`` ``--sub-codepage``
``-subdelay`` ``--sub-delay``
``-subfile`` ``--sub-file``
``-subfont-*`` ``--sub-text-*``, ``--osd-*``
``-subfont-text-scale`` ``--sub-scale``
``-subfont`` ``--sub-text-font``
``-subfps`` ``--sub-fps``
``-subpos`` ``--sub-pos``
``-sws`` ``--sws-scaler``
``-tvscan`` ``--tv-scan``
``-use-filename-title`` ``--title='${filename}'``
``-vc ffh264vdpau`` (etc.) ``--hwdec=vdpau``
``-vobsub`` ``--sub-file`` (pass the .idx file)
``-x W``, ``-y H`` ``--geometry=WxH`` + ``--no-keepaspect``
``-xineramascreen`` ``--screen`` (different values)
``-xy W`` ``--autofit=W``
``-zoom`` Inverse available as ``--video-unscaled``
``dvdnav://`` ``dvdnav://menu``
``dvd://1`` ``dvd://0`` (0-based offset)
=========================== ========================================
.. note::
@@ -216,9 +250,9 @@ input.conf and Slave Commands
+--------------------------------+----------------------------------------+
| ``pt_step -1 [0|1]`` | ``playlist_prev [weak|force] (same)`` |
+--------------------------------+----------------------------------------+
| ``switch_ratio [<ratio>]`` | ``set aspect <ratio>`` |
| ``switch_ratio [<ratio>]`` | ``set video-aspect <ratio>`` |
| | |
| | ``set aspect 0`` (to reset aspect) |
| | ``set video-aspect 0`` (reset aspect) |
+--------------------------------+----------------------------------------+
| ``step_property_osd <prop>`` | ``cycle <prop> <step>`` (wraps), |
| ``<step> <dir>`` | ``add <prop> <step>`` (clamps). |
@@ -244,50 +278,106 @@ input.conf and Slave Commands
+--------------------------------+----------------------------------------+
| ``af_switch``, ``af_add``, ... | ``af set|add|...`` |
+--------------------------------+----------------------------------------+
| ``tv_start_scan`` | ``set tv-scan yes`` |
+--------------------------------+----------------------------------------+
| ``tv_set_channel <val>`` | ``set tv-channel <val>`` |
+--------------------------------+----------------------------------------+
| ``tv_step_channel`` | ``cycle tv-channel`` |
+--------------------------------+----------------------------------------+
| ``dvb_set_channel <v1> <v2>`` | ``set dvb-channel <v1>-<v2>`` |
+--------------------------------+----------------------------------------+
| ``dvb_step_channel`` | ``cycle dvb-channel`` |
+--------------------------------+----------------------------------------+
| ``tv_set_freq <val>`` | ``set tv-freq <val>`` |
+--------------------------------+----------------------------------------+
| ``tv_step_freq`` | ``cycle tv-freq`` |
+--------------------------------+----------------------------------------+
| ``tv_set_norm <norm>`` | ``set tv-norm <norm>`` |
+--------------------------------+----------------------------------------+
| ``tv_step_norm`` | ``cycle tv-norm`` |
+--------------------------------+----------------------------------------+
Other
~~~~~
.. note::
* The playtree has been removed. **mpv**'s internal playlist is a simple and
flat list now. This simplifies the code and makes **mpv** usage less
confusing.
* Slave mode is broken. This mode is entirely insane in the ``old`` versions of
MPlayer. A proper slave mode application needed tons of code and hacks to get
Due to lack of hardware and users using the TV/DVB/PVR features, and
due to the need to cleanup the related command code, it's possible
that the new commands are buggy or behave worse. This can be improved
if testers are available. Otherwise, some of the TV code will be
removed at some point.
Slave mode
~~~~~~~~~~
* Slave mode was removed. A proper slave mode application needed tons of code
and hacks to get
it right. The main problem is that slave mode is a bad and incomplete
interface, and to get around that, applications parsed output messages
intended for users. It is hard to know which messages exactly are parsed by
slave mode applications. This makes it virtually impossible to improve
terminal output intended for users without possibly breaking something.
This is absolutely insane, and **mpv** will not try to keep slave mode
compatible. If you are a developer of a slave mode application, contact us,
and a new and better protocol can be developed.
This is absolutely insane, and since initial improvements to **mpv** quickly
made slave mode incompatible to most applications, it was removed as useless
cruft. The client API (see below) is provided instead.
``--identify`` was replaced by the ``TOOLS/mpv_identify.sh`` wrapper script.
* For some time (until including release 0.4.x), mpv supported a
``--slave-broken`` option. The following options are equivalent:
::
--input-file=/dev/stdin --input-terminal=no
Assuming the system supports ``/dev/stdin``.
(The option was readded in 0.5.1 and sets exactly these options.)
* A JSON RPC protocol giving access to the client API is planned, but nothing
has emerged yet.
* **mpv** also provides a client API, which can be used to embed the player
by loading it as shared library. (See ``libmpv/client.h`` in the sources.)
It might also be possible to implement a custom slave mode-like protocol
using Lua scripting.
Policy for Removed Features
---------------------------
Features are a good thing, because they make users happy. As such, it is
attempted to preserve useful features as far as possible. But if a feature is
likely to be not used by many, and causes problems otherwise, it will be
removed. Developers should not be burdened with fixing or cleaning up code that
has no actual use.
**mpv** is in active development. If something is in the way of more important
development (such as fixing bugs or implementing new features), we sometimes
remove features. Usually this happens only with old features that either seem
to be useless, or are not used by anyone. Often these are obscure, or
"inherited", or were marked experimental, but never received any particular
praise by any users.
It is always possible to add back removed features. File a feature request if a
feature you relied on has been removed, and you want it back. Though it might be
rejected in the worst case, it is much more likely that it will be either added
back, or that a better solution will be implemented.
Sometimes, features are replaced by something new. The new code will be either
simpler or more powerful, but doesn't necessarily provide everything the old
feature did.
We can not exclude that we accidentally remove features that are actually
popular. Generally, we do not know how much a specific functionality is used.
If you miss a feature and think it should be re-added, please open an issue
on the mpv bug tracker. Hopefully, a solution can be found. Often, it turns
out that re-adding something is not much of a problem, or that there are
better alternatives.
Why this Fork?
--------------
* MPlayer wants to maintain old code, even if it is very bad code. It seems
mplayer2 was forked because MPlayer developers refused to get rid of all the
cruft. The mplayer2 and MPlayer codebases also deviated enough to make a
reunification unlikely.
* mplayer2 development is slow, and it is hard to get in changes. Details
withheld as to not turn this into a rant.
* MPlayer rarely merged from mplayer2, and mplayer2 practically stopped
merging from MPlayer (not even code cleanups or new features are merged)
* **mpv** intends to continuously merge from mplayer-svn and mplayer2, while
speeding up development. There is willingness for significant changes, even
if this means breaking compatibility.
mplayer2 is practically dead, and mpv started out as a branch containing
new/experimental development. (Some of it was merged right *after* the fork
was made public, seemingly as an acknowledgment that development, or at
least merging, should have been more active.)
MPlayer is focused on not breaking anything, but is stuck with a horrible
codebase resistant to cleanup. (Unless you do what mpv did - merciless and
consequent pruning of bad, old code.) Cleanup and keeping broken things
conflict, so the kind of development mpv strives for can't be done within
MPlayer due to clashing development policies.
Additionally, mplayer2 already had lots of changes over MPlayer, which would
have needed to be backported to the MPlayer codebase. This would not only
have been hard (several years of diverging development), but also would have
been impossible due to the aforementioned MPlayer development policy.
-19
View File
@@ -1,19 +0,0 @@
[latex2e writer]
use-latex-docinfo: yes
use-latex-toc: yes
hyperlink-color: Blue!30!RoyalPurple!70!Black
latex-preamble: \usepackage[usenames,dvipsnames]{xcolor}
\usepackage{fullpage}
\usepackage{graphicx}
\renewcommand{\familydefault}{\sfdefault}
\makeatletter
\renewcommand{\maketitle}{
\begin{center}
\vspace*{-1.5em}
\begin{Huge}
\@title
\end{Huge}
\end{center}
}
\makeatother
-701
View File
@@ -1,701 +0,0 @@
INPUT.CONF
==========
The input.conf file consists of a list of key bindings, for example::
s screenshot # take a screenshot with the s key
Each line maps a key to an input command. Keys are specified with their literal
value (upper case if combined with ``Shift``), or a name for special keys. For
example, ``a`` maps to the ``a`` key without shift, and ``A`` maps to ``a``
with shift.
A list of special keys can be obtained with
``mpv --input-keylist``
In general, keys can be combined with ``Shift``, ``Ctrl`` and ``Alt``::
ctrl+q quit
**mpv** can be started in input test mode, which displays key bindings and the
commands they're bound to on the OSD, instead of executing the commands::
mpv --input-test --demuxer=rawvideo --demuxer-rawvideo=w=1280:h=720 /dev/zero
(Commands which normally close the player will not work in this mode, and you
must kill **mpv** externally to make it exit.)
General Input Command Syntax
----------------------------
``[Shift+][Ctrl+][Alt+][Meta+]<key> [{<section>}] [<prefixes>] <command> (<argument>)* [; <command>]``
Note that by default, the right Alt key can be used to create special
characters, and thus does not register as a modifier. The option
``--no-right-alt-gr`` changes this behavior.
Newlines always start a new binding. ``#`` starts a comment (outside of quoted
string arguments). To bind commands to the ``#`` key, ``SHARP`` can be used.
``<key>`` is either the literal character the key produces (ASCII or Unicode
character), or a symbolic name (as printed by ``--input-keylist``).
``<section>`` (braced with ``{`` and ``}``) is the input section for this
command.
Arguments are separated by whitespace. This applies even to string arguments.
For this reason, string arguments should be quoted with ``"``. Inside quotes,
C-style escaping can be used.
You can bind multiple commands to one key. For example:
| a show_text "command 1" ; show_text "command 2"
Note that some magic is disabled for keys: seek commands inside lists are not
coalesced (seeking will appear slower), and no check is done for abort commands
(so these commands can't be used to abort playback if the network cache is
stuck).
List of Input Commands
----------------------
``ignore``
Use this to "block" keys that should be unbound, and do nothing. Useful for
disabling default bindings, without disabling all bindings with
``--no-input-default-bindings``.
``seek <seconds> [relative|absolute|absolute-percent|- [default-precise|exact|keyframes]]``
Change the playback position. By default, seeks by a relative amount of
seconds.
The second argument sets the seek mode:
relative (default)
Seek relative to current position (a negative value seeks backwards).
absolute
Seek to a given time.
absolute-percent
Seek to a given percent position.
The third argument defines how exact the seek is:
default-precise (default)
Follow the default behavior as set by ``--hr-seek``, which by default
does imprecise seeks (like ``keyframes``).
exact
Always do exact/hr/precise seeks (slow).
keyframes
Always restart playback at keyframe boundaries (fast).
``revert_seek``
Undoes the ``seek`` command, and some other commands that seek (but not
necessarily all of them). Calling this command once will jump to the
playback position before the seek. Calling it a second time undoes the
``revert_seek`` command itself.
``frame_step``
Play one frame, then pause.
``frame_back_step``
Go back by one frame, then pause. Note that this can be very slow (it tries
to be precise, not fast), and sometimes fails to behave as expected. How
well this works depends on whether precise seeking works correctly (e.g.
see the ``--hr-seek-demuxer-offset`` option). Video filters or other video
postprocessing that modifies timing of frames (e.g. deinterlacing) should
usually work, but might make backstepping silently behave incorrectly in
corner cases.
This does not work with audio-only playback.
``set <property> "<value>"``
Set the given property to the given value.
``add <property> [<value>]``
Add the given value to the property. On overflow or underflow, clamp the
property to the maximum. If ``<value>`` is omitted, assume ``1``.
``cycle <property> [up|down]``
Cycle the given property. ``up`` and ``down`` set the cycle direction. On
overflow, set the property back to the minimum, on underflow set it to the
maximum. If ``up`` or ``down`` is omitted, assume ``up``.
``multiply <property> <factor>``
Multiplies the value of a property with the numeric factor.
``screenshot [subtitles|video|window|- [single|each-frame]]``
Take a screenshot.
First argument:
<subtitles> (default)
Save the video image, in its original resolution, and with subtitles.
Some video outputs may still include the OSD in the output under certain
circumstances.
<video>
Like ``subtitles``, but typically without OSD or subtitles. The exact
behavior depends on the selected video output.
<window>
Save the contents of the mpv window. Typically scaled, with OSD and
subtitles. The exact behavior depends on the selected video output, and
if no support is available, this will act like ``video``.
Second argument:
<single> (default)
Take a single screenshot.
<each-frame>
Take a screenshot each frame. Issue this command again to stop taking
screenshots.
``screenshot_to_file "<filename>" [subtitles|video|window]``
Take a screenshot and save it to a given file. The format of the file will
be guessed by the extension (and ``--screenshot-format`` is ignored - the
behavior when the extension is missing or unknown is arbitrary).
The second argument is like the first argument to ``screenshot``.
This command tries to never overwrite files. If the file already exists,
it fails.
Like all input command parameters, the filename is subject to property
expansion as described in `Property Expansion`_.
``playlist_next [weak|force]``
Go to the next entry on the playlist.
weak (default)
If the last file on the playlist is currently played, do nothing.
force
Terminate playback if there are no more files on the playlist.
``playlist_prev [weak|force]``
Go to the previous entry on the playlist.
weak (default)
If the first file on the playlist is currently played, do nothing.
force
Terminate playback if the first file is being played.
``loadfile "<file>" [replace|append]``
Load the given file and play it.
Second argument:
<replace> (default)
Stop playback of the current file, and play the new file immediately.
<append>
Append the file to the playlist.
``loadlist "<playlist>" [replace|append]``
Load the given playlist file (like ``--playlist``).
``playlist_clear``
Clear the playlist, except the currently played file.
``playlist_remove current|<index>``
Remove the playlist entry at the given index. Index values start counting
with 0. The special value ``current`` removes the current entry. Note that
removing the current entry also stops playback and starts playing the next
entry.
``playlist_move <index1> <index2>``
Move the playlist entry at index1, so that it takes the place of the
entry index2. (Paradoxically, the moved playlist entry will not have
the index value index2 after moving if index1 was lower than index2,
because index2 refers to the target entry, not the index the entry
will have after moving.)
``run "command" "arg1" "arg2" ...``
(Unix only)
Run the given command. Unlike in MPlayer/mplayer2 and earlier versions of
mpv (0.2.x and older), this doesn't call the shell. Instead, the command
is run directly, with each argument passed separately. Each argument is
expanded like in `Property Expansion`_. Note that there is a static limit
of (as of this writing) 10 arguments (this limit could be raised on demand).
The program is run in a detached way. mpv doesn't wait until the command
is completed, but continues playback right after spawning it.
To get the old behavior, use ``/bin/sh`` and ``-c`` as the first two
arguments.
.. admonition:: Example
``run "/bin/sh" "-c" "echo ${title} > /tmp/playing"``
This is not a particularly good example, because it doesn't handle
escaping, and a specially prepared file might allow an attacker to
execute arbitrary shell commands. It is recommended to write a small
shell script, and call that with ``run``.
``quit [<code>]``
Exit the player using the given exit code.
``quit_watch_later``
Exit player, and store current playback position. Playing that file later
will seek to the previous position on start.
``sub_add "<file>"``
Load the given subtitle file. It is not selected as current subtitle after
loading.
``sub_remove [<id>]``
Remove the given subtitle track. If the ``id`` argument is missing, remove
the current track. (Works on external subtitle files only.)
``sub_reload [<id>]``
Reload the given subtitle tracks. If the ``id`` argument is missing, remove
the current track. (Works on external subtitle files only.)
This works by unloading and re-adding the subtitle track.
``sub_step <skip>``
Change subtitle timing such, that the subtitle event after the next
``<skip>`` subtitle events is displayed. ``<skip>`` can be negative to step
backwards.
``sub_seek <skip>``
Seek to the next (skip set to 1) or the previous (skip set to -1) subtitle.
This is similar to ``sub_step``, except that it seeks video and audio
instead of adjusting the subtitle delay.
Like with ``sub_step``, this works with external text subtitles only. For
embedded text subtitles (like with Matroska), this works only with subtitle
events that have already been displayed.
``osd [<level>]``
Toggle OSD level. If ``<level>`` is specified, set the OSD mode
(see ``--osd-level`` for valid values).
``print_text "<string>"``
Print text to stdout. The string can contain properties (see
`Property Expansion`_).
``show_text "<string>" [<duration>|- [<level>]]``
Show text on the OSD. The string can contain properties, which are expanded
as described in `Property Expansion`_. This can be used to show playback
time, filename, and so on.
<duration>
The time in ms to show the message for. By default, it uses the same
value as ``--osd-duration``.
<level>
The minimum OSD level to show the text at (see ``--osd-level``).
``show_progress``
Show the progress bar, the elapsed time and the total duration of the file
on the OSD.
Input Commands that are Possibly Subject to Change
--------------------------------------------------
``af set|add|toggle|del|clr "filter1=params,filter2,..."``
Change audio filter chain. See ``vf`` command.
``vf set|add|toggle|del|clr "filter1=params,filter2,..."``
Change video filter chain.
The first argument decides what happens:
set
Overwrite the previous filter chain with the new one.
add
Append the new filter chain to the previous one.
toggle
Check if the given filter (with the exact parameters) is already
in the video chain. If yes, remove the filter. If no, add the filter.
(If several filters are passed to the command, this is done for
each filter.)
del
Remove the given filters from the video chain. Unlike in the other
cases, the second parameter is a comma separated list of filter names
or integer indexes. ``0`` would denote the first filter. Negative
indexes start from the last filter, and ``-1`` denotes the last
filter.
clr
Remove all filters. Note that like the other sub-commands, this does
not control automatically inserted filters.
You can assign labels to filter by prefixing them with ``@name:`` (where
``name`` is a user-chosen arbitrary identifier). Labels can be used to
refer to filters by name in all of the filter chain modification commands.
For ``add``, using an already used label will replace the existing filter.
The ``vf`` command shows the list of requested filters on the OSD after
changing the filter chain. This is roughly equivalent to
``show_text ${vf}``. Note that auto-inserted filters for format conversion
are not shown on the list, only what was requested by the user.
.. admonition:: Example for input.conf
- ``a vf set flip`` turn video upside-down on the ``a`` key
- ``b vf set ""`` remove all video filters on ``b``
- ``c vf toggle lavfi=gradfun`` toggle debanding on ``c``
``cycle_values ["!reverse"] <property> "<value1>" "<value2>" ...``
Cycle through a list of values. Each invocation of the command will set the
given property to the next value in the list. The command maintains an
internal counter which value to pick next, and which is initially 0. It is
reset to 0 once the last value is reached.
The internal counter is associated using the property name and the value
list. If multiple commands (bound to different keys) use the same name
and value list, they will share the internal counter.
The special argument ``!reverse`` can be used to cycle the value list in
reverse. Compared with a command that just lists the value in reverse, this
command will actually share the internal counter with the forward-cycling
key binding.
Note that there is a static limit of (as of this writing) 10 arguments
(this limit could be raised on demand).
``enable_section "<section>" [default|exclusive]``
Enable all key bindings in the named input section.
The enabled input sections form a stack. Bindings in sections on the top of
the stack are preferred to lower sections. This command puts the section
on top of the stack. If the section was already on the stack, it is
implicitly removed beforehand. (A section cannot be on the stack more than
once.)
If ``exclusive`` is specified as second argument, all sections below the
newly enabled section are disabled. They will be re-enabled as soon as
all exclusive sections above them are removed.
``disable_section "<section>"``
Disable the named input section. Undoes ``enable_section``.
``overlay_add <id> <x> <y> "<file>" <offset> "<fmt>" <w> <h> <stride>``
Add an OSD overlay sourced from raw data. This might be useful for scripts
and applications controlling mpv, and which want to display things on top
of the video window.
Overlays are usually displayed in screen resolution, but with some VOs,
the resolution is reduced to that of the video's. You can read the
``osd-width`` and ``osd-height`` properties. At least with ``--vo-xv`` and
anamorphic video (such as DVD), ``osd-par`` should be read as well, and the
overlay should be aspect-compensated. (Future directions: maybe mpv should
take care of some of these things automatically, but it's hard to tell
where to draw the line.)
``id`` is an integer between 0 and 63 identifying the overlay element. The
ID can be used to add multiple overlay parts, update a part by using this
command with an already existing ID, or to remove a part with
``overlay_remove``. Using a previously unused ID will add a new overlay,
while reusing an ID will update it. (Future directions: there should be
something to ensure different programs wanting to create overlays don't
conflict with each others, should that ever be needed.)
``x`` and ``y`` specify the position where the OSD should be displayed.
``file`` specifies the file the raw image data is read from. It can be
either a numeric UNIX file descriptor prefixed with ``@`` (e.g. ``@4``),
or a filename. The file will be mapped into memory with ``mmap()``. Some VOs
will pass the mapped pointer directly to display APIs (e.g. opengl or
vdpau), so no actual copying is involved. Truncating the source file while
the overlay is active will crash the player. You shouldn't change the data
while the overlay is active, because the data is essentially accessed at
random points. Instead, call ``overlay_add`` again (preferably with a
different memory region to prevent tearing).
``offset`` is the offset of the first pixel in the source file. It is
passed directly to ``mmap`` and is subject to certain restrictions
(see ``man mmap`` for details). In particular, this value has to be a
multiple of the system's page size.
``fmt`` is a string identifying the image format. Currently, only ``bgra``
is defined. This format has 4 bytes per pixels, with 8 bits per component.
The least significant 8 bits are blue, and the most significant 8 bits
are alpha (in little endian, the components are B-G-R-A, with B as first
byte). This uses premultiplied alpha: every color component is already
multiplied with the alpha component. This means the numeric value of each
component is equal to or smaller than the alpha component. (Violating this
rule will lead to different results with different VOs: numeric overflows
resulting from blending broken alpha values is considered something that
shouldn't happen, and consequently implementations don't ensure that you
get predictable behavior in this case.)
``w``, ``h``, and ``stride`` specify the size of the overlay. ``w`` is the
visible width of the overlay, while ``stride`` gives the width in bytes in
memory. In the simple case, and with the ``bgra`` format, ``stride==4*w``.
In general, the total amount of memory accessed is ``stride * h``.
(Technically, the minimum size would be ``stride * (h - 1) + w * 4``, but
for simplicity, the player will access all ``stride * h`` bytes.)
.. admonition:: Warning
When updating the overlay, you should prepare a second shared memory
region (e.g. make use of the offset parameter) and add this as overlay,
instead of reusing the same memory every time. Otherwise, you might
get the equivalent of tearing, when your application and mpv write/read
the buffer at the same time. Also, keep in mind that mpv might access
an overlay's memory at random times whenever it feels the need to do
so, for example when redrawing the screen.
``overlay_remove <id>``
Remove an overlay added with ``overlay_add`` and the same ID. Does nothing
if no overlay with this ID exists.
Undocumented commands: ``tv_start_scan``, ``tv_step_channel``, ``tv_step_norm``,
``tv_step_chanlist``, ``tv_set_channel``, ``tv_last_channel``, ``tv_set_freq``,
``tv_step_freq``, ``tv_set_norm``, ``dvb_set_channel`` (all of these
should be replaced by properties), ``stop`` (questionable use), ``get_property``
(?), ``vo_cmdline`` (experimental).
Input Command Prefixes
----------------------
These prefixes are placed between key name and the actual command. Multiple
prefixes can be specified. They are separated by whitespace.
``osd-auto`` (default)
Use the default behavior for this command.
``no-osd``
Do not use any OSD for this command.
``osd-bar``
If possible, show a bar with this command. Seek commands will show the
progress bar, property changing commands may show the newly set value.
``osd-msg``
If possible, show an OSD message with this command. Seek command show
the current playback time, property changing commands show the newly set
value as text.
``osd-msg-bar``
Combine osd-bar and osd-msg.
``raw``
Do not expand properties in string arguments. (Like ``"${property-name}"``.)
``expand-properties`` (default)
All string arguments are expanded as described in `Property Expansion`_.
All of the osd prefixes are still overridden by the global ``--osd-level``
settings.
Undocumented prefixes: ``pausing``, ``pausing_keep``, ``pausing_toggle``,
``pausing_keep_force``. (Should these be made official?)
Input Sections
--------------
Input sections group a set of bindings, and enable or disable them at once.
In ``input.conf``, each key binding is assigned to an input section, rather
than actually having explicit text sections.
Also see ``enable_section`` and ``disable_section`` commands.
Predefined bindings:
``default``
Bindings without input section are implicitly assigned to this section. It
is enabled by default during normal playback.
``encode``
Section which is active in encoding mode. It is enabled exclusively, so
that bindings in the ``default`` sections are ignored.
Properties
----------
Properties are used to set mpv options during runtime, or to query arbitrary
information. They can be manipulated with the ``set``/``add``/``cycle``
commands, and retrieved with ``show_text``, or anything else that uses property
expansion. (See `Property Expansion`_.)
The ``W`` column indicates whether the property is generally writable. If an
option is referenced, the property should take/return exactly the same values
as the option.
=============================== = ==================================================
Name W Comment
=============================== = ==================================================
``osd-level`` x see ``--osd-level``
``osd-scale`` x osd font size multiplicator, see ``--osd-scale``
``loop`` x see ``--loop``
``speed`` x see ``--speed``
``filename`` currently played file (path stripped)
``path`` currently played file (full path)
``media-title`` filename, title tag, or libquvi ``QUVIPROP_PAGETITLE``
``demuxer``
``stream-path`` filename (full path) of stream layer filename
``stream-pos`` x byte position in source stream
``stream-start`` start byte offset in source stream
``stream-end`` end position in bytes in source stream
``stream-length`` length in bytes (``${stream-end} - ${stream-start}``)
``stream-time-pos`` x time position in source stream (also see ``time-pos``)
``length`` length of the current file in seconds
``avsync`` last A/V synchronization difference
``percent-pos`` x position in current file (0-100)
``ratio-pos`` x position in current file (0.0-1.0)
``time-pos`` x position in current file in seconds
``time-remaining`` estimated remaining length of the file in seconds
``playtime-remaining`` ``time-remaining`` scaled by the the current ``speed``
``chapter`` x current chapter number
``edition`` x current MKV edition number
``titles`` number of DVD titles
``chapters`` number of chapters
``editions`` number of MKV editions
``angle`` x current DVD angle
``metadata`` metadata key/value pairs
``metadata/<key>`` value of metadata entry ``<key>``
``chapter-metadata`` metadata of current chapter (works similar)
``pause`` x pause status (bool)
``cache`` network cache fill state (0-100)
``pts-association-mode`` x see ``--pts-association-mode``
``hr-seek`` x see ``--hr-seek``
``volume`` x current volume (0-100)
``mute`` x current mute status (bool)
``audio-delay`` x see ``--audio-delay``
``audio-format`` audio format (string)
``audio-codec`` audio codec selected for decoding
``audio-bitrate`` audio bitrate
``samplerate`` audio samplerate
``channels`` number of audio channels
``aid`` x current audio track (similar to ``--aid``)
``audio`` x alias for ``aid``
``balance`` x audio channel balance
``fullscreen`` x see ``--fullscreen``
``deinterlace`` x similar to ``--deinterlace``
``colormatrix`` x see ``--colormatrix``
``colormatrix-input-range`` x see ``--colormatrix-input-range``
``colormatrix-output-range`` x see ``--colormatrix-output-range``
``ontop`` x see ``--ontop``
``border`` x see ``--border``
``framedrop`` x see ``--framedrop``
``gamma`` x see ``--gamma``
``brightness`` x see ``--brightness``
``contrast`` x see ``--contrast``
``saturation`` x see ``--saturation``
``hue`` x see ``--hue``
``panscan`` x see ``--panscan``
``video-format`` video format (string)
``video-codec`` video codec selected for decoding
``video-bitrate`` video bitrate
``width`` video width (container or decoded size)
``height`` video height
``fps`` container FPS (may contain bogus values)
``dwidth`` video width (after filters and aspect scaling)
``dheight`` video height
``window-scale`` x window size multiplier (1 means video size)
``aspect`` x video aspect
``osd-width`` last known OSD width (can be 0)
``osd-height`` last known OSD height (can be 0)
``osd-par`` last known OSD display pixel aspect (can be 0)
``vid`` x current video track (similar to ``--vid``)
``video`` x alias for ``vid``
``video-align-x`` x see ``--video-align-x``
``video-align-y`` x see ``--video-align-y``
``video-pan-x`` x see ``--video-pan-x``
``video-pan-y`` x see ``--video-pan-y``
``video-zoom`` x see ``--video-zoom``
``video-unscaled`` x see ``--video-unscaled``
``program`` x switch TS program (write-only)
``sid`` x current subtitle track (similar to ``--sid``)
``secondary-sid`` x secondary subtitle track (``--secondary-sid``)
``sub`` x alias for ``sid``
``sub-delay`` x see ``--sub-delay``
``sub-pos`` x see ``--sub-pos``
``sub-visibility`` x see ``--sub-visibility``
``sub-forced-only`` x see ``--sub-forced-only``
``sub-scale`` x subtitle font size multiplicator
``ass-use-margins`` x see ``--ass-use-margins``
``ass-vsfilter-aspect-compat`` x see ``--ass-vsfilter-aspect-compat``
``ass-style-override`` x see ``--ass-style-override``
``stream-capture`` x a filename, see ``--capture``
``tv-brightness`` x
``tv-contrast`` x
``tv-saturation`` x
``tv-hue`` x
``playlist-pos`` current position on playlist
``playlist-count`` number of total playlist entries
``playlist`` playlist, current entry marked
``track-list`` list of audio/video/sub tracks, current entry marked
``chapter-list`` list of chapters, current entry marked
``quvi-format`` x see ``--quvi-format``
``af`` x see ``--af``
``vf`` x see ``--vf``
``options/name`` read-only access to value of option ``--name``
=============================== = ==================================================
Property Expansion
------------------
All string arguments to input commands as well as certain options (like
``--playing-msg``) are subject to property expansion.
.. admonition:: Example for input.conf
``i show_text "Filename: ${filename}"``
shows the filename of the current file when pressing the ``i`` key
Within ``input.conf``, property expansion can be inhibited by putting the
``raw`` prefix in front of commands.
The following expansions are supported:
``${NAME}``
Expands to the value of the property ``NAME``. If retrieving the property
fails, expand to an error string. (Use ``${NAME:}`` with a trailing
``:`` to expand to an empty string instead.)
If ``NAME`` is prefixed with ``=``, expand to the raw value of the property
(see section below).
``${NAME:STR}``
Expands to the value of the property ``NAME``, or ``STR`` if the
property cannot be retrieved. ``STR`` is expanded recursively.
``${?NAME:STR}``
Expands to ``STR`` (recursively) if the property ``NAME`` is available.
``${!NAME:STR}``
Expands to ``STR`` (recursively) if the property ``NAME`` cannot be
retrieved.
``${?NAME==VALUE:STR}``
Expands to ``STR`` (recursively) if the property ``NAME`` expands to a
string equal to ``VALUE``. You can prefix ``NAME`` with ``=`` in order to
compare the raw value of a property (see section below). If the property
is unavailable, or other errors happen when retrieving it, the value is
never considered equal.
Note that ``VALUE`` can't contain any of the characters ``:`` or ``}``.
Also, it is possible that escaping with ``"`` or ``%`` might be added in
the future, should the need arise.
``${!NAME==VALUE:STR}``
Same as with the ``?`` variant, but ``STR`` is expanded if the value is
not equal. (Using the same semantics as with ``?``.)
``$$``
Expands to ``$``.
``$}``
Expands to ``}``. (To produce this character inside recursive
expansion.)
``$>``
Disable property expansion and special handling of ``$`` for the rest
of the string.
In places where property expansion is allowed, C-style escapes are often
accepted as well. Example:
- ``\n`` becomes a newline character
- ``\\`` expands to ``\``
Raw and Formatted Properties
----------------------------
Normally, properties are formatted as human-readable text, meant to be
displayed on OSD or on the terminal. It is possible to retrieve an unformatted
(raw) value from a property by prefixing its name with ``=``. These raw values
can be parsed by other programs and follow the same conventions as the options
associated with the properties.
.. admonition:: Examples
- ``${time-pos}`` expands to ``00:14:23`` (if playback position is at 14
minutes 23 seconds)
- ``${=time-pos}`` expands to ``863.4`` (same time, plus 400 milliseconds -
milliseconds are normally not shown in the formatted case)
Sometimes, the difference in amount of information carried by raw and formatted
property values can be rather big. In some cases, raw values have more
information, like higher precision than seconds with ``time-pos``. Sometimes
it is the other way around, e.g. ``aid`` shows track title and language in the
formatted case, but only the track number if it is raw.
-18
View File
@@ -1,18 +0,0 @@
LUA SCRIPTING
=============
mpv can load Lua scripts. These scripts can be used to control mpv in a similar
way to slave mode. mpv provides the builtin module ``mp`` (can be loaded
with ``require 'mpv'``), which provides functions to send commands to the
mpv core and to retrieve information about playback state, user settings,
file information, and so on.
.. admonition:: Warning
Lua scripting is work in progress, and it's in a very early stage. When
writing scripts, rely only on the features and functions documented here.
Everything else is subject to change.
.. admonition:: Warning
Nothing is finished and documented yet.
@@ -3,7 +3,7 @@ ENCODING
You can encode files from one format/codec to another using this facility.
``-o <filename>``
``--o=<filename>``
Enables encoding mode and specifies the output file name.
``--of=<format>``
@@ -149,3 +149,7 @@ You can encode files from one format/codec to another using this facility.
container formats, e.g. AVI). In this mode, discontinuities are not fixed
and all pts are passed through as-is. Never seek backwards or use multiple
input files in this mode!
``--no-ometadata``
Turns off copying of metadata from input files to output files when
encoding (which is enabled by default).
+1353
View File
File diff suppressed because it is too large. Load diff
+651
View File
@@ -0,0 +1,651 @@
LUA SCRIPTING
=============
mpv can load Lua scripts. Scripts in ``~/.mpv/lua/`` will be loaded on program
start, or if passed to ``--lua``. mpv provides the builtin module ``mp``, which
provides functions to send commands to the mpv core and to retrieve information
about playback state, user settings, file information, and so on.
These scripts can be used to control mpv in a similar way to slave mode.
Technically, the Lua code uses the client API internally.
Example
-------
A script which leaves fullscreen mode when the player is paused:
::
function on_pause()
mp.set_property("fullscreen", "no")
end
mp.register_event("pause", on_pause)
This script provides a pretty weird feature, but Lua scripting was made to
allow users implement features which are not going to be added to the mpv core.
Mode of operation
-----------------
Your script will be loaded by the player at program start from ``~/.mpv/lua/``,
or ``--lua``, or in some cases, internally (like ``--osc``). Each script runs
in its own thread. Your script is first run "as is", and once that is done,
the event loop is entered. This event loop will dispatch events received by mpv
and call your own event handlers which you have registered with
``mp.register_event``, or timers added with ``mp.add_timeout`` or similar.
When the player quits, all scripts will be asked to terminate. This happens via
a ``shutdown`` event, which by default will make the event loop return. If your
script got into an endless loop, mpv will probably behave fine during playback
(unless the player is suspended, see ``mp.suspend``), but it won't terminate
when quitting, because it's waiting on your script.
Internally, the C code will call the Lua function ``mp_event_loop`` after
loading a Lua script. This function is normally defined by the default prelude
loaded before your script (see ``player/lua/defaults.lua`` in the mpv sources).
The event loop will wait for events and dispatch events registered with
``mp.register_event``. It will also handle timers added with ``mp.add_timeout``
and similar (by waiting with a timeout).
mp functions
------------
The ``mp`` module is preloaded, although it can be loaded manually with
``require 'mp'``. It provides the core client API.
``mp.command(string)``
Run the given command. This is similar to the commands used in input.conf.
See `List of Input Commands`_.
Returns ``true`` on success, or ``nil, error`` on error.
``mp.commandv(arg1, arg2, ...)``
Similar to ``mp.command``, but pass each command argument as separate
parameter. This has the advantage that you don't have to care about
quoting and escaping in some cases.
Example:
::
mp.command("loadfile " .. filename .. " append")
mp.commandv("loadfile", filename, "append")
These two commands are equivalent, except that the first version breaks
if the filename contains spaces or certain special characters.
Note that properties are *not* expanded. You can use either ``mp.command``,
the ``expand-properties`` prefix, or the ``mp.get_property`` family of
functions.
``mp.get_property(name [,def])``
Return the value of the given property as string. These are the same
properties as used in input.conf. See `Properties`_ for a list of
properties. The returned string is formatted similar to ``${=name}``
(see `Property Expansion`_).
Returns the string on success, or ``def, error`` on error. ``def`` is the
second parameter provided to the function, and is nil if it's missing.
``mp.get_property_osd(name [,def])``
Similar to ``mp.get_property``, but return the property value formatted for
OSD. This is the same string as printed with ``${name}`` when used in
input.conf.
Returns the string on success, or ``def, error`` on error. ``def`` is the
second parameter provided to the function, and is an empty string if it's
missing. Unlike ``get_property()``, assigning the return value to a variable
will always result in a string.
``mp.get_property_bool(name [,def])``
Similar to ``mp.get_property``, but return the property value as boolean.
Returns a boolean on success, or ``def, error`` on error.
``mp.get_property_number(name [,def])``
Similar to ``mp.get_property``, but return the property value as number.
Note that while Lua does not distinguish between integers and floats,
mpv internals do. This function simply request a double float from mpv,
and mpv will usually convert integer property values to float.
Returns a number on success, or ``def, error`` on error.
``mp.get_property_native(name [,def])``
Similar to ``mp.get_property``, but return the property value using the best
Lua type for the property. Most time, this will return a string, boolean,
or number. Some properties (for example ``chapter-list``) are returned as
tables.
Returns a value on success, or ``def, error`` on error. Note that ``nil``
might be a possible, valid value too in some corner cases.
``mp.set_property(name, value)``
Set the given property to the given string value. See ``mp.get_property``
and `Properties`_ for more information about properties.
Returns true on success, or ``nil, error`` on error.
``mp.set_property_bool(name, value)``
Similar to ``mp.set_property``, but set the given property to the given
boolean value.
``mp.set_property_number(name, value)``
Similar to ``mp.set_property``, but set the given property to the given
numeric value.
Note that while Lua does not distinguish between integers and floats,
mpv internals do. This function will test whether the number can be
represented as integer, and if so, it will pass an integer value to mpv,
otherwise a double float.
``mp.set_property_native(name, value)``
Similar to ``mp.set_property``, but set the given property using its native
type.
Since there are several data types which can not represented natively in
Lua, this might not always work as expected. For example, while the Lua
wrapper can do some guesswork to decide whether a Lua table is an array
or a map, this would fail with empty tables. Also, there are not many
properties for which it makes sense to use this, instead of
``set_property``, ``set_property_bool``, ``set_property_number``.
For these reasons, this function should probably be avoided for now, except
for properties that use tables natively.
``mp.get_time()``
Return the current mpv internal time in seconds as a number. This is
basically the system time, with an arbitrary offset.
``mp.add_key_binding(key, name|fn [,fn])``
Register callback to be run on a key binding. The binding will be mapped to
the given ``key``, which is a string describing the physical key. This uses
the same key names as in input.conf, and also allows combinations
(e.g. ``ctrl+a``).
After calling this function, key presses will cause the function ``fn`` to
be called (unless the user overmapped the key with another binding).
The ``name`` argument should be a short symbolic string. It allows the user
to remap the key binding via input.conf using the ``script_message``
command, and the name of the key binding (see below for
an example). The name should be unique across other bindings in the same
script - if not, the previous binding with the same name will be
overwritten. You can omit the name, in which case a random name is generated
internally.
Internally, key bindings are dispatched via the ``script_message_to`` input
command and ``mp.register_script_message``.
Trying to map multiple commands to a key will essentially prefer a random
binding, while the other bindings are not called. It is guaranteed that
user defined bindings in the central input.conf are preferred over bindings
added with this function (but see ``mp.add_forced_key_binding``).
Example:
::
function something_handler()
print("the key was pressed")
end
mp.add_key_binding("x", "something", something_handler)
This will print the message ``the key was pressed`` when ``x`` was pressed.
The user can remap these key bindings. Then the user has to put the
following into his input.conf to remap the command to the ``y`` key:
::
y script_message something
This will print the message when the key ``y`` is pressed. (``x`` will
still work, unless the user overmaps it.)
You can also explicitly send a message to a named script only. Assume the
above script was using the filename ``fooscript.lua``:
::
y script_message_to fooscript something
``mp.add_forced_key_binding(...)``
This works almost the same as ``mp.add_key_binding``, but registers the
key binding in a way that will overwrite the user's custom bindings in his
input.conf. (``mp.add_key_binding`` overwrites default key bindings only,
but not those by the user's input.conf.)
``mp.remove_key_binding(name)``
Remove a key binding added with ``mp.add_key_binding`` or
``mp.add_forced_key_binding``. Use the same name as you used when adding
the bindings. It's not possible to remove bindings for which you omitted
the name.
``mp.register_event(name, fn)``
Call a specific function when an event happens. The event name is a string,
and the function fn is a Lua function value.
Some events have associated data. This is put into a Lua table and passed
as argument to fn. The Lua table by default contains a ``name`` field,
which is a string containing the event name. If the event has an error
associated, the ``error`` field is set to a string describing the error,
on success it's not set.
If multiple functions are registered for the same event, they are run in
registration order, which the first registered function running before all
the other ones.
Returns true if such an event exists, false otherwise.
See `Events`_ and `List of events`_ for details.
``mp.unregister_event(fn)``
Undo ``mp.register_event(..., fn)``. This removes all event handlers that
are equal to the ``fn`` parameter. This uses normal Lua ``==`` comparison,
so be careful when dealing with closures.
``mp.observe_property(name, type, fn)``
Watch a property for changes. If the property ``name`` is changed, then
the function ``fn(name)`` will be called. ``type`` can be ``nil``, or be
set to one of ``none``, ``native``, ``bool``, ``string``, or ``number``.
``none`` is the same as ``nil``. For all other values, the new value of
the property will be passed as second argument to ``fn``, using
``mp.get_property_<type>`` to retrieve it. This means if ``type`` is for
example ``string``, ``fn`` is roughly called as in
``fn(name, mp.get_property_string(name))``.
If possible, change events are coalesced. If a property is changed a bunch
of times in a row, only the last change triggers the change function. (The
exact behavior depends on timing and other things.)
In some cases the function is not called even if the property changes.
Whether this can happen depends on the property.
If the ``type`` is ``none`` or ``nil``, sporadic property change events are
possible. This means the change function ``fn`` can be called even if the
property doesn't actually change.
``mp.unobserve_property(fn)``
Undo ``mp.observe_property(..., fn)``. This removes all property handlers
that are equal to the ``fn`` parameter. This uses normal Lua ``==``
comparison, so be careful when dealing with closures.
``mp.add_timeout(seconds, fn)``
Call the given function fn when the given number of seconds has elapsed.
Note that the number of seconds can be fractional. For now, the timer's
resolution may be as low as 50 ms, although this will be improved in the
future.
This is a one-shot timer: it will be removed when it's fired.
Returns a timer object. See ``mp.add_periodic_timer`` for details.
``mp.add_periodic_timer(seconds, fn)``
Call the given function periodically. This is like ``mp.add_timeout``, but
the timer is re-added after the function fn is run.
Returns a timer object. The timer object provides the following methods:
``stop()``
Disable the timer. Does nothing if the timer is already disabled.
This will remember the current elapsed time when stopping, so that
``resume()`` essentially unpauses the timer.
``kill()``
Disable the timer. Resets the elapsed time. ``resume()`` will
restart the timer.
``resume()``
Restart the timer. If the timer was disabled with ``stop()``, this
will resume at the time it was stopped. If the timer was disabled
with ``kill()``, or if it's a previously fired one-shot timer (added
with ``add_timeout()``), this starts the timer from the beginning,
using the initially configured timeout.
``timeout`` (RW)
This field contains the current timeout period. This value is not
updated as time progresses. It's only used to calculate when the
timer should fire next when the timer expires.
If you write this, you can call ``t:kill() ; t:resume()`` to reset
the current timeout to the new one. (``t:stop()`` won't use the
new timeout.)
``oneshot`` (RW)
Whether the timer is periodic (``false``) or fires just once
(``true``). This value is used when the timer expires (but before
the timer calback function fn is run).
``mp.get_opt(key)``
Return a setting from the ``--lua-opts`` option. It's up to the user and
the script how this mechanism is used. Currently, all scripts can access
this equally, so you should be careful about collisions.
``mp.get_script_name()``
Return the name of the current script. The name is usually made of the
filename of the script, with directory and file extension removed. If
there are several script which would have the same name, it's made unique
by appending a number.
.. admonition:: Example
The script ``/path/to/fooscript.lua`` becomes ``fooscript``.
``mp.osd_message(text [,duration])``
Show an OSD message on the screen. ``duration`` is in seconds, and is
optional (uses ``--osd-duration`` by default).
Advanced mp functions
---------------------
These also live in the ``mp`` module, but are documented separately as they
are useful only in special situations.
``mp.suspend()``
Suspend the mpv main loop. There is a long-winded explanation of this in
the C API function ``mpv_suspend()``. In short, this prevents the player
from displaying the next video frame, so that you don't get blocked when
trying to access the player.
This is automatically called by the event handler.
``mp.resume()``
Undo one ``mp.suspend()`` call. ``mp.suspend()`` increments an internal
counter, and ``mp.resume()`` decrements it. When 0 is reached, the player
is actually resumed.
``mp.resume_all()``
This resets the internal suspend counter and resumes the player. (It's
like calling ``mp.resume()`` until the player is actually resumed.)
You might want to call this if you're about to do something that takes a
long time, but doesn't really need access to the player (like a network
operation). Note that you still can access the player at any time.
``mp.get_wakeup_pipe()``
Calls ``mpv_get_wakeup_pipe()`` and returns the read end of the wakeup
pipe. (See ``client.h`` for details.)
``mp.get_next_timeout()``
Return the relative time in seconds when the next timer (``mp.add_timeout``
and similar) expires. If there is no timer, return ``nil``.
``mp.dispatch_events([allow_wait])``
This can be used to run custom event loops. If you want to have direct
control what the Lua script does (instead of being called by the default
event loop), you can set the global variable ``mp_event_loop`` to your
own function running the event loop. From your event loop, you should call
``mp.dispatch_events()`` to unqueue and dispatch mpv events.
If the ``allow_wait`` parameter is set to ``true``, the function will block
until the next event is received or the next timer expires. Otherwise (and
this is the default behavior), it returns as soon as the event loop is
emptied. It's strongly recommended to use ``mp.get_next_timeout()`` and
``mp.get_wakeup_pipe()`` if you're interested in properly working
notification of new events and working timers.
This function calls ``mp.suspend()`` and ``mp.resume_all()`` on its own.
``mp.enable_messages(level)``
Set the minimum log level of which mpv message output to receive. These
messages are normally printed to the terminal. By calling this function,
you can set the minimum log level of messages which should be received with
the ``log-message`` event. See the description of this event for details.
The level is a string, see ``msg.log`` for allowed log levels.
``mp.register_script_message(name, fn)``
This is a helper to dispatch ``script_message`` or ``script_message_to``
invocations to Lua functions. ``fn`` is called if ``script_message`` or
``script_message_to`` (with this script as destination) is run
with ``name`` as first parameter. The other parameters are passed to ``fn``.
If a message with the given name is already registered, it's overwritten.
Used by ``mp.add_key_binding``, so be careful about name collisions.
``mp.unregister_script_message(name)``
Undo a previous registration with ``mp.register_script_message``. Does
nothing if the ``name`` wasn't registered.
mp.msg functions
----------------
This module allows outputting messages to the terminal, and can be loaded
with ``require 'mp.msg'``.
``msg.log(level, ...)``
The level parameter is the message priority. It's a string and one of
``fatal``, ``error``, ``warn``, ``info``, ``v``, ``debug``. The user's
settings will determine which of these messages will be visible. Normally,
all messages are visible, except ``v`` and ``debug``.
The parameters after that are all converted to strings. Spaces are inserted
to separate multiple parameters.
You don't need to add newlines.
``msg.fatal(...)``, ``msg.error(...)``, ``msg.warn(...)``, ``msg.info(...)``, ``msg.verbose(...)``, ``msg.debug(...)``
All of these are shortcuts and equivalent to the corresponding
``msg.log(level, ...)`` call.
mp.options functions
--------------------
mpv comes with a built-in module to manage options from config-files and the
command-line. All you have to do is to supply a table with default options to
the read_options function. The function will overwrite the default values
with values found in the config-file and the command-line (in that order).
``options.read_options(table [, identifier])``
A ``table`` with key-value pairs. The type of the default values is
important for converting the values read from the config file or
command-line back. Do not use ``nil`` as a default value!
The ``identifier`` is used to identify the config-file and the command-line
options. These needs to unique to avoid collisions with other scripts.
Defaults to ``mp.get_script_name()``.
Example implementation::
require 'mp.options'
local options = {
optionA = "defaultvalueA",
optionB = -0.5,
optionC = true,
}
options.read_options(options, "myscript")
print(option.optionA)
The config file will be stored in ``lua-settings/identifier.conf`` in mpv's user
folder. Comment lines can be started with # and stray spaces are not removed.
Boolean values will be represented with yes/no.
Example config::
# comment
optionA=Hello World
optionB=9999
optionC=no
Command-line options are read from the ``--lua-opts`` parameter. To avoid
collisions, all keys have to be prefixed with ``identifier-``.
Example command-line::
--lua-opts=myscript-optionA=TEST:myscript-optionB=0:myscript-optionC=yes
mp.utils options
----------------
This built-in module provides generic helper functions for Lua, and have
strictly speaking nothing to do with mpv or video/audio playback. They are
provided for convenience. Most compensate for Lua's scarce standard library.
``utils.readdir(path [, filter])``
Enumerate all entries at the given path on the filesystem, and return them
as array. Each entry is a directory entry (without the path).
The list is unsorted (in whatever order the operating system returns it).
If the ``filter`` argument is given, it must be one of the following
strings:
``files``
List regular files only. This excludes directories, special files
(like UNIX device files or FIFOs), and dead symlinks. It includes
UNIX symlinks to regular files.
``dirs``
List directories only, or symlinks to directories. ``.`` and ``..``
are not included.
``normal``
Include the results of both ``files`` and ``dirs``. (This is the
default.)
``all``
List all entries, even device files, dead symlinks, FIFOs, and the
``.`` and ``..`` entries.
On error, ``nil, error`` is returned.
``utils.split_path(path)``
Split a path into directory component and filename component, and return
them. The first return value is always the directory. The second return
value is the trailing part of the path, the directory entry.
``utils.join_path(p1, p2)``
Return the concatenation of the 2 paths. Tries to be clever. For example,
if ```p2`` is an absolute path, p2 is returned without change.
Events
------
Events are notifications from player core to scripts. You can register an
event handler with ``mp.register_event``.
Note that all scripts (and other parts of the player) receive events equally,
and there's no such thing as blocking other scripts from receiving events.
Example:
::
function my_fn(event)
print("start of playback!")
end
mp.register_event("playback-start", my_fn)
List of events
--------------
``start-file``
Happens right before a new file is loaded. When you receive this, the
player is loading the file (or possibly already done with it).
``end-file``
Happens after a file was unloaded. Typically, the player will load the
next file right away, or quit if this was the last file.
``file-loaded``
Happens after a file was loaded and begins playback.
``seek``
Happens on seeking (including ordered chapter segment changes).
``playback-restart``
Start of playback after seek or after file was loaded.
``tracks-changed``
The list of video/audio/sub tracks was updated. (This happens on playback
start, and very rarely during playback.)
``track-switched``
A video/audio/subtitle track was switched on or off. This usually happens
when the user (or a script) changes the subtitle track and so on.
``idle``
Idle mode is entered. This happens when playback ended, and the player was
started with ``--idle`` or ``--force-window``. This mode is implicitly ended
when the ``start-file`` or ``shutdown`` events happen.
``pause``
Playback was paused. This also happens when for example the player is
paused on low network cache. Then the event type indicates the pause state
(like the property "pause" as opposed to the "core-idle" property), and you
might receive multiple ``pause`` events in a row.
``unpause``
Playback was unpaused. See above for details.
``tick``
Called after a video frame was displayed. This is a hack, and you should
avoid using it. Use timers instead and maybe watch pausing/unpausing events
to avoid wasting CPU when the player is paused.
``shutdown``
Sent when the player quits, and the script should terminate. Normally
handled automatically. See `Mode of operation`_.
``log-message``
Receives messages enabled with ``mp.enable_messages``. The message data
is contained in the table passed as first parameter to the event handler.
The table contains, in addition to the default event fields, the following
fields:
``prefix``
The module prefix, identifies the sender of the message. This is what
the terminal player puts in front of the message text when using the
``--v`` option, and is also what is used for ``--msg-level``.
``level``
The log level as string. See ``msg.log`` for possible log level names.
Note that later versions of mpv might add new levels or remove
(undocumented) existing ones.
``text``
The log message. Note that this is the direct output of a printf()
style output API. The text will contain embedded newlines, and it's
possible that a single message contains multiple lines, or that a
message contains a partial line.
It's safe to display messages only if they end with a newline character,
and to buffer them otherwise.
Keep in mind that these messages are meant to be hints for humans. You
should not parse them, and prefix/level/text of messages might change
any time.
``get-property-reply``
Undocumented (not useful for Lua scripts).
``set-property-reply``
Undocumented (not useful for Lua scripts).
``command-reply``
Undocumented (not useful for Lua scripts).
``script-input-dispatch``
Undocumented (used internally).
``client-message``
Undocumented (used internally).
``video-reconfig``
Happens on video output or filter reconfig.
``audio-reconfig``
Happens on audio output or filter reconfig.
``metadata-update``
Metadata (like file tags) was updated.
``chapter-change``
The current chapter possibly changed.
+128 -81
View File
@@ -2,44 +2,24 @@ mpv
###
##############
a movie player
a media player
##############
:Author: wm4
:Copyright: GPLv2+
:Manual section: 1
:Manual group: multimedia
.. raw:: latex
\tableofcontents
\pagebreak
SYNOPSIS
========
| **mpv** [options] [file|URL|-]
| **mpv** [options] --playlist=PLAYLIST
| **mpv** [options] files
| **mpv** [options] {group of files and options}
| **mpv** [bd]://[title][/device] [options]
| **mpv** dvd://[title|[start\_title]-end\_title][/device] [options]
| **mpv** dvdnav://[longest|menu|title][/device] [options]
| **mpv** \vcd://[/device]
| **mpv** \tv://[channel][/input_id] [options]
| **mpv** radio://[channel|frequency][/capture] [options]
| **mpv** \pvr:// [options]
| **mpv** \dvb://[card\_number@]channel [options]
| **mpv** \mf://[filemask|\@listfile] [-mf options] [options]
| **mpv** cdda://track[-endtrack][:speed][/device] [options]
| **mpv** [file|mms[t]|http|httpproxy|rt[s]p|ftp|udp|smb]://[user:pass\@]URL[:port] [options]
| **mpv** edl://[edl specification as in edl-mpv.rst]
DESCRIPTION
===========
**mpv** is a movie player based on MPlayer and mplayer2. It supports a wide variety of video
**mpv** is a media player based on MPlayer and mplayer2. It supports a wide variety of video
file formats, audio and video codecs, and subtitle types. Special input URL
types are available to read input from a variety of sources other than disk
files. Depending on platform, a variety of different video and audio output
@@ -60,16 +40,13 @@ Keyboard Control
----------------
LEFT and RIGHT
Seek backward/forward 10 seconds. Shift+arrow does a 1 second exact seek
Seek backward/forward 5 seconds. Shift+arrow does a 1 second exact seek
(see ``--hr-seek``).
UP and DOWN
Seek forward/backward 1 minute. Shift+arrow does a 5 second exact seek (see
``--hr-seek``).
PGUP and PGDWN
Seek forward/backward 10 minutes.
[ and ]
Decrease/increase current playback speed by 10%.
@@ -89,11 +66,11 @@ p / SPACE
Pause (pressing again unpauses).
\.
Step forward. Pressing once will pause movie, every consecutive press will
Step forward. Pressing once will pause, every consecutive press will
play one frame and then go into pause mode again.
,
Step backward. Pressing once will pause movie, every consecutive press will
Step backward. Pressing once will pause, every consecutive press will
play one frame in reverse and then go into pause mode again.
q / ESC
@@ -103,21 +80,12 @@ Q
Like ``q``, but store the current playback position. Playing the same file
later will resume at the old playback position if possible.
U
Stop playing (and quit if ``--idle`` is not used).
\+ and -
Adjust audio delay by +/- 0.1 seconds.
/ and *
Decrease/increase volume.
9 and 0
Decrease/increase volume.
( and )
Adjust audio balance in favor of left/right channel.
m
Mute sound.
@@ -127,9 +95,6 @@ m
\#
Cycle through the available audio tracks.
TAB (MPEG-TS and libavformat only)
Cycle through the available programs.
f
Toggle fullscreen (see also ``--fs``).
@@ -139,7 +104,10 @@ T
w and e
Decrease/increase pan-and-scan range.
o
o (also P)
Show progression bar, elapsed time and total duration on the OSD.
O
Toggle OSD states: none / seek / seek + timer / seek + timer + total time.
d
@@ -152,9 +120,6 @@ v
j and J
Cycle through the available subtitles.
F
Toggle displaying "forced subtitles".
x and z
Adjust subtitle delay by +/- 0.1 seconds.
@@ -175,23 +140,14 @@ S
I
Show filename on the OSD.
P
Show progression bar, elapsed time and total duration on the OSD.
! and @
PGUP and PGDWN
Seek to the beginning of the previous/next chapter. In most cases,
"previous" will actually go to the beginning of the current chapter; see
``--chapter-seek-threshold``.
D (``--vo=vdpau``, ``--vf=yadif`` only)
D
Activate/deactivate deinterlacer.
A
Cycle through the available DVD angles.
c
Change YUV colorspace.
(The following keys are valid only when using a video output that supports the
corresponding adjustment, or the software equalizer (``--vf=eq``).)
@@ -210,19 +166,21 @@ corresponding adjustment, or the software equalizer (``--vf=eq``).)
(The following keys are valid only on OSX.)
command + 0
Resize movie window to half its original size.
Resize video window to half its original size.
(On other platforms, you can bind keys to change the ``window-scale``
property.)
command + 1
Resize movie window to its original size.
Resize video window to its original size.
command + 2
Resize movie window to double its original size.
Resize video window to double its original size.
command + f
Toggle fullscreen (see also ``--fs``).
command + [ and command + ]
Set movie window alpha.
Set video window alpha.
(The following keys are valid if you have a keyboard with multimedia keys.)
@@ -241,12 +199,6 @@ support.)
h and k
Select previous/next channel.
n
Change norm.
u
Change channel list.
Mouse Control
-------------
@@ -356,7 +308,7 @@ Location and Syntax
You can put all of the options in configuration files which will be read every
time mpv is run. The system-wide configuration file 'mpv.conf' is in your
configuration directory (e.g. ``/etc/mpv`` or ``/usr/local/etc/mpv``), the
user-specific one is ``~/.mpv/config``.
user-specific one is ``~/.config/mpv/mpv.conf``.
User-specific options override system-wide options and options given on the
command line override either. The syntax of the configuration files is
``option=<value>``; everything after a *#* is considered a comment. Options
@@ -391,8 +343,8 @@ File-specific Configuration Files
---------------------------------
You can also write file-specific configuration files. If you wish to have a
configuration file for a file called 'movie.avi', create a file named
'movie.avi.conf' with the file-specific options in it and put it in
configuration file for a file called 'video.avi', create a file named
'video.avi.conf' with the file-specific options in it and put it in
``~/.mpv/``. You can also put the configuration file in the same directory
as the file to be played, as long as you give the ``--use-filedir-conf``
option (either on the command line or in your global config file). If a
@@ -452,6 +404,85 @@ taking screenshots is handled by the VOs, and adding the screenshot filter will
break hardware decoding. (The filter may still be useful for taking screenshots
at a certain point within the video chain when using multiple video filters.)
PROTOCOLS
=========
``http://...``, ``https://``, ...
Many network protocols are supported, but the protocol prefix must always
be specified. mpv will never attempt to guess whether a filename is
actually a network address. A protocol prefix is always required.
``-``
Play data from stdin.
``smb://PATH``
Play a path from Samba share.
``bd://[title][/device]`` ``--bluray-device=PATH``
Play a Blu-Ray disc. Currently, this does not accept iso files. Instead,
you must mount the iso file as filesystem, and point ``--bluray-device``
to the mounted directly.
``bdnav://[title][/device]``
Play a Blu-Ray disc, with navigation features enabled. This feature is
permanently experimental.
``dvd://[title|[starttitle]-endtitle][/device]`` ``--dvd-device=PATH``
Play a DVD. If you want dvdnav menus, use ``dvd://menu``. If no title
is given, the longest title is auto-selected.
``dvdnav://`` is an old alias for ``dvd://`` and does exactly the same
thing.
``dvdread://...:``
Play a DVD using the old libdvdread code. This is what MPlayer and older
mpv versions use for ``dvd://``. Use is discouraged. It's provided only
for compatibility and for transition.
``tv://[channel][/input_id]`` ``--tv-...``
Analogue TV via V4L. Also useful for webcams. (Linux only.)
``pvr://`` ``--pvr-...``
PVR. (Linux only.)
``dvb://[cardnumber@]channel`` ``--dvbin-...``
Digital TV via DVB. (Linux only.)
``mf://[filemask|@listfile]`` ``--mf-...``
Play a series of images as video.
``cdda://track[-endtrack][:speed][/device]`` ``--cdrom-device=PATH`` ``--cdda-...``
Play CD.
``lavf://...``
Access any FFmpeg/Libav libavformat protocol. Basically, this passed the
string after the ``//`` directly to libavformat.
``av://type:options``
This is intended for using libavdevice inputs. ``type`` is the libavdevice
demuxer name, and ``options`` is the (pseudo-)filename passed to the
demuxer.
For example, ``mpv av://lavfi:mandelbrot`` makes use of the libavfilter
wrapper included in libavdevice, and will use the ``mandelbrot`` source
filter to generate input data.
``avdevice://`` is an alias.
``file://PATH``
A local path as URL. Might be useful in some special use-cases. Note that
``PATH`` itself should start with a third ``/`` to make the path an
absolute path.
``edl://[edl specification as in edl-mpv.rst]``
Stitch together parts of multiple files and play them.
``null://``
Simulate an empty file.
``memory://data``
Use the ``data`` part as source data.
.. include:: options.rst
.. include:: ao.rst
@@ -478,23 +509,28 @@ ENVIRONMENT VARIABLES
There are a number of environment variables that can be used to control the
behavior of mpv.
``HOME``
Used to determine mpv config directory: ``$HOME/.mpv``
``HOME``, ``XDG_CONFIG_HOME``
Used to determine mpv config directory. If ``XDG_CONFIG_HOME`` is not set,
``$HOME/.config/mpv`` is used.
``$HOME/.mpv`` is always added to the list of config search paths with a
lower priority.
``XDG_CONFIG_DIRS``
If set, XDG-style system configuration directories are used. Otherwise,
the UNIX convention (``PREFIX/etc/mpv/``) is used.
``TERM``
Used to determine terminal type.
``MPV_HOME``
Directory where mpv looks for user settings. Overrides ``HOME``, and mpv
will try to load the config file as ``$MPV_HOME/config``.
will try to load the config file as ``$MPV_HOME/mpv.conf``.
``MPV_LOCALEDIR``
Directory where mpv looks for gettext translation files (if enabled).
``MPV_VERBOSE`` (see also ``-v`` and ``--msglevel``)
``MPV_VERBOSE`` (see also ``-v`` and ``--msg-level``)
Set the initial verbosity level across all message modules (default: 0).
The resulting verbosity corresponds to that of ``--msglevel=5`` plus the
value of ``MPV_VERBOSE``.
This is an integer, and the resulting verbosity corresponds to the number
of ``--v`` options passed to the command line.
``MPV_LEAK_REPORT``
If set to ``1``, enable internal talloc leak reporting. Note that this can
@@ -602,12 +638,23 @@ FILES
``/usr/local/etc/mpv/mpv.conf``
mpv system-wide settings (depends on ``--prefix`` passed to configure)
``~/.mpv/config``
``~/.config/mpv/mpv.conf``
mpv user settings
``~/.mpv/input.conf``
input bindings (see ``--input-keylist`` for the full list)
``~/.config/mpv/input.conf``
key bindings (see `INPUT.CONF`_ section)
``~/.config/mpv/lua/``
All files in this directly are loaded as if they were passed to the
``--lua`` option. They are loaded in alphabetical order, and sub-directories
and files with no ``.lua`` extension are ignored. The ``--load-scripts=no``
option disables loading these files.
Note that the environment variables ``$XDG_CONFIG_HOME`` and ``$MPV_HOME`` can
override the standard directory ``~/.config/mpv/``.
Also, the old config location at ``~/.mpv/`` is still read, and if the XDG
variant does not exist, will still be preferred.
EXAMPLES OF MPV USAGE
=====================
@@ -626,7 +673,7 @@ Play only titles 5, 6, 7:
``mpv dvd://5-7``
Play a multiangle DVD:
``mpv dvd://1 --dvdangle=2``
``mpv dvd://1 --dvd-angle=2``
Play from a different DVD device:
``mpv dvd://1 --dvd-device=/dev/dvd2``
File diff suppressed because it is too large. Load diff
+57 -7
View File
@@ -122,12 +122,24 @@ time remaining
left-click toggle between total and remaining time
============= ================================================
Keybindings
~~~~~~~~~~~
These keybindings are active by default if nothing else is already bound to
these keys. In case of collosision, the function needs to be bound to a
different key. See `Script Commands`_ section.
============= ================================================
del Hide the OSC permanently until mpv is restarted.
============= ================================================
Configuration
-------------
The OSC offers limited configuration through a config file ``plugin_osc.conf``
placed in mpv's user dir.
The OSC offers limited configuration through a config file
``lua-settings/osc.conf`` placed in mpv's user dir and through the
``--lua-opts`` command-line option. Options provided through the command-line
will override those from the config file.
Config Syntax
~~~~~~~~~~~~~
@@ -135,14 +147,25 @@ Config Syntax
The config file must exactly follow the following syntax::
# this is a comment
parameter1=value1
parameter2=value2
optionA=value1
optionB=value2
``#`` can only be used at the beginning of a line and there may be no
spaces around the ``=`` or anywhere else.
Configurable parameters
~~~~~~~~~~~~~~~~~~~~~~~
Command-line Syntax
~~~~~~~~~~~~~~~~~~~
To avoid collisions with other scripts, all options need to be prefixed with
``osc-``.
Example::
--lua-opts=osc-optionA=value1:osc-optionB=value2
Configurable Options
~~~~~~~~~~~~~~~~~~~~
``showwindowed``
| Default: yes
@@ -193,10 +216,37 @@ Configurable parameters
| Default: 0
| Size of the deadzone. The deadzone is an area that makes the mouse act
like leaving the window. Movement there won't make the OSC show up and
it will hide immediately if the mouse enters it.
it will hide immediately if the mouse enters it. The deadzone starts
at the window border opposite to the OSC and the size controls how much
of the window it will span. Values between 0 and 1.
``minmousemove``
| Default: 3
| Minimum amount of pixels the mouse has to move between ticks to make
the OSC show up
``seektooltip``
| Default: yes
| Display a tooltip over the seekbar indicating time at mouse position.
Script Commands
~~~~~~~~~~~~~~~
The OSC script listens to certain script commands. These commands can bound
in ``input.conf``, or sent by other scripts.
``enable-osc``
Undoes ``disable-osc`` or the effect of the ``del`` key.
``disable-osc``
Hide the OSC permanently. This is also what the ``del`` key does.
Example
You could put this into ``input.conf`` to hide the OSC with the ``a`` key and
to unhide it with ``b``::
a script_message disable-osc
b script_message enable-osc
+138 -29
View File
@@ -47,7 +47,7 @@ Available filters are:
``crop[=w:h:x:y]``
Crops the given part of the image and discards the rest. Useful to remove
black bands from widescreen movies.
black bands from widescreen videos.
``<w>,<h>``
Cropped width and height, defaults to original width and height.
@@ -55,7 +55,7 @@ Available filters are:
Position of the cropped picture, defaults to center.
``expand[=w:h:x:y:aspect:round]``
Expands (not scales) movie resolution to the given value and places the
Expands (not scales) video resolution to the given value and places the
unscaled original at coordinates x, y.
``<w>,<h>``
@@ -88,20 +88,15 @@ Available filters are:
``mirror``
Mirrors the image on the Y axis.
``rotate[=<0-7>]``
Rotates the image by 90 degrees and optionally flips it. For values
between 4-7 rotation is only done if the movie geometry is portrait and
not landscape.
``rotate[=0|90|180|270]``
Rotates the image by a multiple of 90 degrees clock-wise.
:0: Rotate by 90 degrees clockwise and flip (default).
:1: Rotate by 90 degrees clockwise.
:2: Rotate by 90 degrees counterclockwise.
:3: Rotate by 90 degrees counterclockwise and flip.
``scale[=w:h[:interlaced[:chr_drop[:par[:par2[:noup[:arnd]]]]]]]``
``scale[=w:h:param:param2:chr-drop:noup:arnd``
Scales the image with the software scaler (slow) and performs a YUV<->RGB
colorspace conversion (see also ``--sws``).
All parameters are optional.
``<w>,<h>``
scaled width/height (default: original width/height)
@@ -114,15 +109,7 @@ Available filters are:
:-(n+8): Like -n above, but rounding the dimension to the closest
multiple of 16.
``<chr_drop>``
chroma skipping
:0: Use all available input lines for chroma.
:1: Use only every 2. input line for chroma.
:2: Use only every 4. input line for chroma.
:3: Use only every 8. input line for chroma.
``<par>[:<par2>]`` (see also ``--sws``)
``<param>[:<param2>]`` (see also ``--sws``)
Set some scaling parameters depending on the type of scaler selected
with ``--sws``::
@@ -137,6 +124,14 @@ Available filters are:
--sws=9 (lanczos): filter length (1-10)
``<chr-drop>``
chroma skipping
:0: Use all available input lines for chroma (default).
:1: Use only every 2. input line for chroma.
:2: Use only every 4. input line for chroma.
:3: Use only every 8. input line for chroma.
``<noup>``
Disallow upscaling past the original dimensions.
@@ -429,7 +424,7 @@ Available filters are:
``'--vf=lavfi=yadif:o="threads=2,thread_type=slice"'``
forces a specific threading configuration.
``noise[=<strength>[:average][:pattern][:temporal][:uniform][:hq]``
``noise[=<strength>[:averaged][:pattern][:temporal][:uniform][:hq]``
Adds noise.
``strength``
@@ -438,7 +433,7 @@ Available filters are:
(using ``--vf=lavfi=[noise=...]``), or tell the libavfilter developers
to stop being stupid.
``average``
``averaged``
averaged temporal noise (smoother, but a lot slower)
``pattern``
@@ -622,7 +617,7 @@ Available filters are:
``phase[=t|b|p|a|u|T|B|A|U][:v]``
Delay interlaced video by one field time so that the field order changes.
The intended use is to fix PAL movies that have been captured with the
The intended use is to fix PAL videos that have been captured with the
opposite field order to the film-to-video transfer. The options are:
``t``
@@ -712,11 +707,6 @@ Available filters are:
Thickness of the fuzzy edge of the rectangle (added to ``w`` and
``h``). When set to -1, a green rectangle is drawn on the screen to
simplify finding the right ``x``,``y``,``w``,``h`` parameters.
``file=<file>``
You can specify a text file to load the coordinates from. Each line
must have a timestamp (in seconds, and in ascending order) and the
``x:y:w:h:t`` coordinates (``t`` can be omitted).
(Not supported when using libavfilter.)
``show``
Draw a rectangle showing the area defined by x/y/w/h.
@@ -850,6 +840,70 @@ Available filters are:
``a3=<string>``
Specify the fourth parameter to pass to the library.
``vapoursynth=file:buffered-frames:concurrent-frames``
Loads a VapourSynth filter script. This is intended for streamed
processing: mpv actually provides a source filter, instead of using a
native VapourSynth video source. The mpv source will answer frame
requests only within a small window of frames (the size of this window
is controlled with the ``buffered-frames`` parameter), and requests outside
of that will return errors. As such, you can't use the full power of
VapourSynth, but you can use certain filters.
If you just want to play video generated by a VapourSynth (i.e. using
a native VapourSynth video source), it's better to use ``vspipe`` and a
FIFO to feed the video to mpv. The same applies if the filter script
requires random frame access (see ``buffered-frames`` parameter).
This filter is experimental. If it turns out that it works well and is
used, it will be ported to libavfilter. Otherwise, it will be just removed.
``file``
Filename of the script source. Currently, this is always a python
script. The variable ``video_in`` is set to the mpv video source,
and it is expected that the script reads video from it. (Otherwise,
mpv will decode no video, and the video packet queue will overflow,
eventually leading to audio being stopped.) The script is also
expected to pass through timestamps using the ``_DurationNum`` and
``_DurationDen`` frame properties.
.. admonition:: Example:
::
import vapoursynth as vs
core = vs.get_core()
core.std.AddBorders(video_in, 10, 10, 20, 20).set_output()
.. warning::
The script will be reloaded on every seek. This is done to reset
the filter properly on discontinuities.
``buffered-frames``
Maximum number of decoded video frames that should be buffered before
the filter (default: 4). This specifies the maximum number of frames
the script can requests backwards. E.g. if ``buffered-frames=5``, and
the script just requested frame 15, it can still request frame 10, but
frame 9 is not available anymore. If it requests frame 30, mpv will
decode 15 more frames, and keep only frames 25-30.
The actual number of buffered frames also depends on the value of the
``concurrent-frames`` option. Currently, both option values are
multiplied to get the final buffer size.
(Normally, VapourSynth source filters must provide random access, but
mpv was made for playback, and does not provide frame-exact random
access. The way this video filter works is a compromise to make simple
filters work anyway.)
``concurrent-frames``
Number of frames that should be requested in parallel (default: 2). The
level of concurrency depends on the filter and how quickly mpv can
decode video to feed the filter. This value should probably be
proportional to the number of cores on your machine. Most time,
making it higher than the number of cores can actually make it
slower.
``vavpp``
VA-AP-API video post processing. Works with ``--vo=vaapi`` and ``--vo=opengl``
only. Currently deinterlaces. This filter is automatically inserted if
@@ -866,3 +920,58 @@ Available filters are:
bob
bob deinterlacing (default).
``vdpaupp``
VDPAU video post processing. Works with ``--vo=vdpau`` and ``--vo=opengl``
only. This filter is automatically inserted if deinterlacing is requested
(either using the ``D`` key, by default mapped to the command
``cycle deinterlace``, or the ``--deinterlace`` option). When enabling
deinterlacing, it is always preferred over software deinterlacer filters
if the ``vdpau`` VO is used, and also if ``opengl`` is used and hardware
decoding was activated at least once (i.e. vdpau was loaded).
``sharpen=<-1-1>``
For positive values, apply a sharpening algorithm to the video, for
negative values a blurring algorithm (default: 0).
``denoise=<0-1>``
Apply a noise reduction algorithm to the video (default: 0; no noise
reduction).
``deint=<yes|no>``
Whether deinterlacing is enabled (default: no). If enabled, it will use
the mode selected with ``deint-mode``.
``deint-mode=<first-field|bob|temporal|temporal-spatial>``
Select deinterlacing mode (default: temporal).
All modes respect ``--field-dominance``.
Note that there's currently a mechanism that allows the ``vdpau`` VO to
change the ``deint-mode`` of auto-inserted ``vdpaupp`` filters. To avoid
confusion, it's recommended not to use the ``--vo=vdpau`` suboptions
related to filtering.
first-field
Show only first field.
bob
Bob deinterlacing.
temporal
Motion-adaptive temporal deinterlacing. May lead to A/V desync
with slow video hardware and/or high resolution.
temporal-spatial
Motion-adaptive temporal deinterlacing with edge-guided spatial
interpolation. Needs fast video hardware.
``chroma-deint``
Makes temporal deinterlacers operate both on luma and chroma (default).
Use no-chroma-deint to solely use luma and speed up advanced
deinterlacing. Useful with slow video memory.
``pullup``
Try to apply inverse telecine, needs motion adaptive temporal
deinterlacing.
``hqscaling=<0-9>``
0
Use default VDPAU scaling (default).
1-9
Apply high quality VDPAU scaling (needs capable hardware).
``buffer=<num>``
Buffer ``<num>`` frames in the filter chain. This filter is probably pretty
useless, except for debugging. (Note that this won't help smoothing out
latencies with decoding, because the filter will never output a frame if
the buffer isn't full, except on EOF.)
+115 -30
View File
@@ -20,6 +20,9 @@ normal driver parameters.
See ``--vo=help`` for a list of compiled-in video output drivers.
The recommended output drivers are ``--vo=vdpau`` and ``--vo=opengl-hq``.
All other drivers are just for compatibility or special purposes.
.. admonition:: Example
``--vo=opengl,xv,``
@@ -32,6 +35,8 @@ Available video output drivers are:
the most compatible VO on X, but may be low-quality, and has issues with
OSD and subtitle display.
.. note:: This driver is for compatibility with old systems.
``adaptor=<number>``
Select a specific XVideo adaptor (check xvinfo results).
``port=<number>``
@@ -74,21 +79,36 @@ Available video output drivers are:
Uses the VDPAU interface to display and optionally also decode video.
Hardware decoding is used with ``--hwdec=vdpau``.
.. note::
Earlier versions of mpv (and MPlayer, mplayer2) provided sub-options
to tune vdpau postprocessing, like ``deint``, ``sharpen``, ``denoise``,
``chroma-deint``, ``pullup``, ``hqscaling``. These sub-options are
deprecated, and you should use the ``vdpaupp`` video filter instead.
``sharpen=<-1-1>``
(Deprecated. See note about ``vdpaupp``.)
For positive values, apply a sharpening algorithm to the video, for
negative values a blurring algorithm (default: 0).
``denoise=<0-1>``
(Deprecated. See note about ``vdpaupp``.)
Apply a noise reduction algorithm to the video (default: 0; no noise
reduction).
``deint=<-4-4>``
Select deinterlacing mode (default: -3). Positive values choose mode
and enable deinterlacing. Corresponding negative values select the
same deinterlacing mode, but do not enable deinterlacing on startup
(useful in configuration files to specify which mode will be enabled by
the "D" key). All modes respect ``--field-dominance``.
(Deprecated. See note about ``vdpaupp``.)
Select deinterlacing mode (default: 0). In older versions (as well as
MPlayer/mplayer2) you could use this option to enable deinterlacing.
This doesn't work anymore, and deinterlacing is enabled with either
the ``D`` key (by default mapped to the command ``cycle deinterlace``),
or the ``--deinterlace`` option. Also, to select the default deint mode,
you should use something like ``--vf-defaults=vdpaupp:deint-mode=temporal``
instead of this sub-option.
0
Same as -3.
Pick the ``vdpaupp`` video filter default, which corresponds to 3.
1
Show only first field.
2
@@ -100,13 +120,19 @@ Available video output drivers are:
Motion-adaptive temporal deinterlacing with edge-guided spatial
interpolation. Needs fast video hardware.
``chroma-deint``
(Deprecated. See note about ``vdpaupp``.)
Makes temporal deinterlacers operate both on luma and chroma (default).
Use no-chroma-deint to solely use luma and speed up advanced
deinterlacing. Useful with slow video memory.
``pullup``
(Deprecated. See note about ``vdpaupp``.)
Try to apply inverse telecine, needs motion adaptive temporal
deinterlacing.
``hqscaling=<0-9>``
(Deprecated. See note about ``vdpaupp``.)
0
Use default VDPAU scaling (default).
1-9
@@ -172,6 +198,9 @@ Available video output drivers are:
``direct3d_shaders`` (Windows only)
Video output driver that uses the Direct3D interface.
.. note:: This driver is for compatibility with systems that don't provide
proper OpenGL drivers.
``prefer-stretchrect``
Use ``IDirect3DDevice9::StretchRect`` over other methods if possible.
@@ -228,11 +257,15 @@ Available video output drivers are:
Same as ``direct3d_shaders``, but with the options ``disable-textures``
and ``disable-shaders`` forced.
.. note:: This driver is for compatibility with old systems.
``corevideo`` (Mac OS X 10.6 and later)
Mac OS X CoreVideo video output driver. Uses the CoreVideo APIs to fill
PixelBuffers and generate OpenGL textures from them (useful as a fallback
for ``opengl``).
.. note:: This driver is for compatibility with old systems.
``opengl``
OpenGL video output driver. It supports extended scaling methods, dithering
and color management.
@@ -260,11 +293,13 @@ Available video output drivers are:
``lanczos2``
Lanczos scaling with radius=2. Provides good quality and speed.
This is the default when using ``opengl-hq``.
``lanczos3``
Lanczos with radius=3.
``spline36``
This is the default when using ``opengl-hq``.
``bicubic_fast``
Bicubic filter. Has a blurring effect on the image, even if no
scaling is done.
@@ -303,8 +338,9 @@ Available video output drivers are:
disabled.
``stereo=<value>``
Select a method for stereo display. You may have to use ``--aspect`` to
fix the aspect value. Experimental, do not expect too much from it.
Select a method for stereo display. You may have to use
``--video-aspect`` to fix the aspect value. Experimental, do not expect
too much from it.
no
Normal 2D display
@@ -317,18 +353,20 @@ Available video output drivers are:
by very few OpenGL cards.
``srgb``
Enable gamma-correct scaling by working in linear light. This
makes use of sRGB textures and framebuffers.
This option forces the options ``indirect`` and ``gamma``.
Convert and color correct the output to sRGB before displaying it on
the screen. This option enables linear light scaling. It also forces
the options ``indirect`` and ``gamma``.
.. note::
This option is equivalent to using ``icc-profile`` with an sRGB ICC
profile, but it is implemented without a 3DLUT and does not require
LittleCMS 2. If both ``srgb`` and ``icc-profile`` are present, the
latter takes precedence, as they are somewhat redundant.
for YUV colorspaces, gamma 1/0.45 (2.222) is assumed. RGB input is
always assumed to be in sRGB.
This option is not really useful, as gamma-correct scaling has not much
influence on typical video playback. Most visible effect comes from
slightly different gamma.
Note: When playing back BT.2020 content with this option enabled, out
of gamut colors will be numerically clipped, which can potentially
change the hue and/or luminance. If this is not desired, it is
recommended to use ``icc-profile`` with an sRGB ICC profile instead,
when playing back wide-gamut BT.2020 content.
``pbo``
Enable use of PBOs. This is slightly faster, but can sometimes lead to
@@ -439,12 +477,26 @@ Available video output drivers are:
rgb32f, rgba12, rgba16, rgba16f, rgba32f.
Default: rgb.
``gamma``
Always enable gamma control. (Disables delayed enabling.)
``gamma=<0.0..10.0>``
Set a gamma value. If gamma is adjusted in other ways (like with
the ``--gamma`` option or keybindings and the ``gamma`` property), the
value is multiplied with the other gamma value.
Setting this value to 1.0 can be used to always enable gamma control.
(Disables delayed enabling.)
``icc-profile=<file>``
Load an ICC profile and use it to transform linear RGB to screen output.
Needs LittleCMS2 support compiled in.
Needs LittleCMS2 support compiled in. This option overrides the ``srgb``
property, as using both is somewhat redundant. It also enables linear
light scaling.
``icc-profile-auto``
Automatically select the ICC display profile currently specified by
the display settings of the operating system.
NOTE: Only implemented on OS X with Cocoa.
``icc-cache=<file>``
Store and load the 3D LUT created from the ICC profile in this file.
@@ -453,19 +505,33 @@ Available video output drivers are:
Its size depends on the ``3dlut-size``, and can be very big.
``icc-intent=<value>``
Specifies the ICC Intent used for transformations between colorspaces.
This affects the rendering when using ``icc-profile`` or ``srgb`` and
also affects the way DCP XYZ content gets converted to RGB.
0
perceptual
1
relative colorimetric
relative colorimetric (default)
2
saturation
3
absolute colorimetric (default)
absolute colorimetric
``approx-gamma``
Approximate the actual gamma function as a pure power curve of
1.95. A number of video editing programs and studios apparently use this
for mastering instead of the true curve. Most notably, anything in the
Apple ecosystem uses this approximation - including all programs
compatible with it. It's a sound idea to try enabling this flag first
when watching videos and shows to see if things look better that way.
This only affects the output when using either ``icc-profile`` or ``srgb``.
``3dlut-size=<r>x<g>x<b>``
Size of the 3D LUT generated from the ICC profile in each dimension.
Default is 128x256x64.
Sizes must be a power of two, and 256 at most.
Sizes must be a power of two, and 512 at most.
``alpha=<blend|yes|no>``
Decides what to do if the input has an alpha component (default: blend).
@@ -496,7 +562,7 @@ Available video output drivers are:
This is equivalent to::
--vo=opengl:lscale=lanczos2:dither-depth=auto:fbo-format=rgb16
--vo=opengl:lscale=spline36:dither-depth=auto:fbo-format=rgba16
Note that some cheaper LCDs do dithering that gravely interferes with
``opengl``'s dithering. Disabling dithering with ``dither-depth=no`` helps.
@@ -519,6 +585,8 @@ Available video output drivers are:
implementation, even if you do not get any error message. Use ``glxinfo``
or a similar tool to display the supported OpenGL extensions.
.. note:: This driver is for compatibility with old systems.
``(no-)ati-hack``
ATI drivers may give a corrupted image when PBOs are used (when using
``force-pbo``). This option fixes this, at the expense of using a bit
@@ -627,8 +695,9 @@ Available video output drivers are:
Set the effect strength for the ``lscale``/``cscale`` filters that
support it.
``stereo=<value>``
Select a method for stereo display. You may have to use ``--aspect`` to
fix the aspect value. Experimental, do not expect too much from it.
Select a method for stereo display. You may have to use
``--video-aspect`` to fix the aspect value. Experimental, do not expect
too much from it.
0
Normal 2D display
@@ -692,6 +761,9 @@ Available video output drivers are:
hardware acceleration. Should work on all platforms supported by SDL 2.0.
For tuning, refer to your copy of the file ``SDL_hints.h``.
.. note:: This driver is for compatibility with systems that don't provide
proper graphics drivers, or which support GLES only.
``sw``
Continue even if a software renderer is detected.
@@ -704,6 +776,9 @@ Available video output drivers are:
hardware decoding to save power on laptops, or possibly preventing video
tearing with some setups.
.. note:: This driver is for compatibility with crappy systems. You can
use vaapi hardware decoding with ``--vo=opengl`` too.
``scaling=<algorithm>``
default
Driver default (mpv default as well).
@@ -744,6 +819,8 @@ Available video output drivers are:
``caca``
Color ASCII art video output driver that works on a text console.
.. note:: This driver is a joke.
``image``
Output each frame into an image file in the current directory. Each file
takes the frame number padded with leading zeros as name.
@@ -789,9 +866,17 @@ Available video output drivers are:
``wayland`` (Wayland only)
Wayland shared memory video output as fallback for ``opengl``.
``default-format``
Use the default RGB32 format instead of an auto-detected one.
.. note:: This driver is for compatibility with systems that don't provide
working OpenGL drivers.
``alpha``
Use a buffer format that supports videos and images with alpha
information
``rgb565``
Use RGB565 as buffer format. This format is implemented on most
platforms, especially on embedded where it is far more efficient then
RGB8888.
``triple-buffering``
Use 3 buffers instead of 2. This can lead to more fluid playback, but
uses more memory.
+71
View File
@@ -0,0 +1,71 @@
Release Policy
==============
Every few months, a new release is cut off of the master branch and is assigned
a 0.X.0 version number.
As part of the maintenance process, minor releases are made, which are assigned
0.X.Y version numbers. Minor releases contain bug fixes only. They never merge
the master branch, and no features are added to it. Only the latest release is
maintained.
The goal of releases is to provide stability and an unchanged base for the sake
of Linux distributions. If you want the newest features, just use the master
branch, which is stable most of the time, except sometimes, when it's not.
Releases other than the latest release are unsupported and unmaintained.
Release procedure
-----------------
- Create branch release/0.X or cherry-pick commits to the relevant branch.
- Create and/or update the ``RELEASE_NOTES`` file.
- Create and/or update the ``VERSION`` file.
- Update ``DOCS/client-api-changes.rst`` (on major releases).
- Create tag v0.X.Y.
- Push branch and tag to GitHub.
- Create a new GitHub release using the content of ``RELEASE_NOTES`` related to
the new version.
Release notes template
----------------------
Here is a template that can be used for writing the ``RELEASE_NOTES`` file.
```markdown
Release 0.X.Y
=============
Changes
-------
- List of changes.
Bug fixes
---------
- List of bug fixes.
New features
------------
- List of new features.
This listing is not complete. There are many more bug fixes and changes. The
complete change log can be viewed by running ``git log <start>..<end>`` in
the git repository.
```
Note that the "Release 0.X.Y" title should be removed when creating a new GitHub
release.
When creating a new point release its changes should be added on top of the
``RELEASE_NOTES`` file (with the appropriate title) so that all the changes in
the current 0.X branch will be included. This way the ``RELEASE_NOTES`` file
can be used by distributors as changelog for point releases too.
+14 -16
View File
@@ -1,6 +1,4 @@
NOTE: DOCS/OUTDATED-tech/* may contain more detailed information, but most of it
is possibly or definitely outdated. This file intends to give a big
picture of how mpv is structured.
This file intends to give a big picture of how mpv is structured.
player/*.c:
Essentially makes up the player applications, including the main() function
@@ -19,12 +17,12 @@ player/*.c:
* check help options etc. (call handle_help_options()), possibly exit
* call play_files() function that works down the playlist:
* run idle loop (idle_loop()), until there are files in the
playlist or an exit command was given (slave mode only)
playlist or an exit command was given (only if --idle it set)
* actually load and play a file in play_current_file():
* run all the dozens of functions to load the file and
initialize playback
* run a small loop that does normal playback, until the file is
done or a slave command terminates playback
done or a command terminates playback
(on each iteration, run_playloop() is called, which is rather
big and complicated - it decodes some audio and video on
each frame, waits for input, etc.)
@@ -84,7 +82,7 @@ talloc.h & talloc.c:
(See ta/README for details.)
player/command.c:
This contains the implementation for slave commands and properties.
This contains the implementation for client API commands and properties.
Properties are essentially dynamic variables changed by certain commands.
This is basically responsible for all user commands, like initiating
seeking, switching tracks, etc. It calls into other player/*.c files,
@@ -94,9 +92,10 @@ player/core.h:
Data structures and function prototypes for most of player/*.c. They are
usually not accessed by other parts of mpv for the sake of modularization.
Note that there are lots of global variables floating around everywhere
else. This is an ongoing transition, and eventually there should be no
global variables anymore.
player/client.c:
This implements the client API (libmpv/client.h). For the most part, this
just calls into other parts of the player. This also manages a ringbuffer
of events from player to clients.
options/options.h, options/options.c
options.h contains the global option struct MPOpts. The option declarations
@@ -113,15 +112,14 @@ options/options.h, options/options.c
input/input.c:
This translates keyboard input comming from libvo and other sources (such
as remote control devices like Apple IR or slave mode commands) to the
as remote control devices like Apple IR or client API commands) to the
key bindings listed in the user's (or the builtin) input.conf and turns
them into items of type struct mp_cmd. These commands are queued, and read
by playloop.c. They get pushed with run_command() to command.c.
Note that keyboard input and slave mode input are essentially the same
things. Just looking at input.conf should make this clear. (The other
direction of slave mode communication, mpv to application, consists of
random mp_msg() calls all over the code in all parts of the player.)
Note that keyboard input and commands used by the client API are the same.
The client API only uses the command parser though, and has its own queue
of input commands somewhere else.
common/msg.h:
All terminal output should go through mp_msg().
@@ -215,7 +213,7 @@ audio/out/:
sub/:
Contains subtitle and OSD rendering.
sub.c/.h is actually the OSD code. It queries dec_sub.c to retrieve
osd.c/.h is actually the OSD code. It queries dec_sub.c to retrieve
decoded/rendered subtitles. osd_libass.c is the actual implementation of
the OSD text renderer (which uses libass, and takes care of all the tricky
fontconfig/freetype API usage and text layouting).
@@ -224,7 +222,7 @@ sub/:
.ass subtitles via libass. demux_lavf.c loads most subtitle types via
FFmpeg. demux_subreader.c is the old MPlayer code. It's used as last
fallback, or to handle some text subtitle types on Libav. (It also can
load UTF-16 encoded subtitles without requiring the use of -subcp.)
load UTF-16 encoded subtitles without requiring the use of -sub-codepage.)
demux_subreader.c should eventually go away (maybe).
The subtitles are passed to dec_sub.c and the subtitle decoders in sd_*.c
+1 -1
View File
@@ -45,7 +45,7 @@ mpv's custom configure step on top of waf
To some extents mpv has a custom build system written on top of waf. This
document will not go over the standard waf behaviour as that is documented in
the ``Waf book``.
the `Waf book <http://docs.waf.googlecode.com/git/book_17/single.html>`_.
All of the configuration process is handled with a declarative approach. Lists
of dictionaries define the checks, and some custom Python code traverses these
+38 -7
View File
@@ -45,13 +45,23 @@ Essential dependencies (incomplete list):
- gcc or clang
- X development headers (xlib, X extensions, libvdpau, libGL, libXv, ...)
- Audio output development headers (libasound, pulseaudio)
- fribidi, freetype, fontconfig development headers (for libass)
- libass
- FFmpeg libraries (libavutil libavcodec libavformat libswscale libpostproc)
- libjpeg
- FFmpeg libraries (libavutil libavcodec libavformat libswscale libavresample)
At least FFmpeg 2.1.4 or Libav 10 is required.
- libjpeg (for screenshots)
- libquvi if you want to play Youtube videos directly
Libass dependencies:
- gcc or clang, yasm on x86 and x86_64
- fribidi, freetype, fontconfig development headers (for libass)
FFmpeg dependencies:
- gcc or clang, yasm on x86 and x86_64
- OpenSSL (has to be explicitly enabled when compiling ffmpeg)
- libx264/libmp3lame/libfdk-aac if you want to use encoding (has to be
explicitly enabled when compiling ffmpeg)
- Libav also works, but some features will not work. (See section below.)
Most of the above libraries are available in suitable versions on normal
Linux distributions. However FFmpeg is an exception (distro versions may be
@@ -71,6 +81,26 @@ Generally, mpv should work with the latest release as well as the git version
of both FFmpeg and Libav. But FFmpeg is preferred, and some mpv features work
with FFmpeg only. See the [wiki article][ffmpeg_vs_libav] about the issue.
Release cycle
-------------
Every few months, a new release is cut off of the master branch and is assigned
a 0.X.0 version number.
As part of the maintenance process, minor releases are made, which are assigned
0.X.Y version numbers. Minor releases contain bug fixes only. They never merge
the master branch, and no features are added to it. Only the latest release is
maintained.
The goal of releases is to provide stability and an unchanged base for the sake
of Linux distributions. If you want the newest features, just use the master
branch, which is stable most of the time, except sometimes, when it's not.
Releases other than the latest release are unsupported and unmaintained.
See the [release policy document][release-policy] for more information.
Bug reports
-----------
@@ -84,8 +114,8 @@ For small changes you can just send us pull requests through GitHub. For bigger
changes come and talk to us on IRC before you start working on them. It will
make code review easier for both parties later on.
Contacts
--------
Contact
-------
These forms of contact are meant to ask questions about mpv usage, give
feedback on mpv and discuss it's development.
@@ -99,10 +129,11 @@ instead.
To contact the `mpv` team in private write to `mpv-team@googlegroups.com`.
[changes]: https://github.com/mpv-player/mpv/blob/master/DOCS/man/en/changes.rst
[changes]: https://github.com/mpv-player/mpv/blob/master/DOCS/man/changes.rst
[mpv-build]: https://github.com/mpv-player/mpv-build
[homebrew-mpv]: https://github.com/mpv-player/homebrew-mpv
[issue-tracker]: https://github.com/mpv-player/mpv/issues
[mpv-users]: https://groups.google.com/forum/?hl=en#!forum/mpv-users
[mpv-devel]: https://groups.google.com/forum/?hl=en#!forum/mpv-devel
[ffmpeg_vs_libav]: https://github.com/mpv-player/mpv/wiki/FFmpeg-versus-Libav
[release-policy]: https://github.com/mpv-player/mpv/blob/master/DOCS/release-policy.md
+114
View File
@@ -0,0 +1,114 @@
Release 0.5.1
=============
Changes
-------
- Add audio/flac to the MIME type list in mpv.desktop.
- The --slave-broken option has been reintroduced and is equivalent to using
--input-file=/dev/stdin and --input-terminal=no.
Bug fixes
---------
- Fix screenshots with anamorphic videos in the vdpau vo.
- Fix a crash happening when mpv fails to create a vdpau mixer in the vdpau vo.
- Don't quit when the --loop-file option is used.
- Always load the cursor theme in the wayland vo (this fixes a crash caused by
moving the mouse cursor over the video).
- Properly return non-zero from the zsh completion script when no matches are
found (this fixes the use of user-defined zsh completion matchers).
- Fix the description of the opengl-hq vo default options in the manpage.
- Remove duplicated content from the manpage that was accidentally added in the
manpage reorganization from the previous release.
- Avoid clobbering playback position on video end (when both audio and video
streams reached the end, the playback poisition was briefly set at 0).
- Avoid overwriting user input in the coreaudio_device ao.
This listing is not complete. There are many more bug fixes and changes. The
complete change log can be viewed by running ``git log 6729e39..fdd648b`` in
the git repository.
Release 0.5.0
=============
Changes
-------
- Support setting the start time relative to the start PTS with --start.
- Use /dev/sr0 as default cdrom/dvd device on Linux.
- Change "cache" property representation to float.
- Split the ao_coreaudio audio output into ao_coreaudio (which uses the
AudioUnits and the CoreAudio sound server) and ao_coreaudio_device (which uses
direct device access).
- Complete supported URL schemes in the zsh completion script.
- Enable compiler optimizations (-O2) during build.
- Allow precise seeking with percent-based seeks too.
- Do precise seeks when clicking on the OSC seekbar.
- Remove support for older VDA hwaccel versions on Mac OS X (requires recent
versions of ffmpeg/libav).
- Remove the last remains of slave mode (--slave-broken option). Support for
reading input commands from stdin can be emulated using: --input-terminal=no
--input-file=/dev/stdin.
- Some key binding were remapped or removed:
+ "LEFT" and "RIGHT" have been remapped to seek 5 seconds instead of 10.
+ "c" for changing the YUV color space was unmapped.
+ OSD level cycling has been remapped from "o" to "O".
+ "o" is now mapped to the show_progress command (like "P").
+ "PGUP" and "PGDWN" have been remapped to chapter-based seeks (the old
bindings "@" and "!" are still available). The old behvaiour has been
remapped to "Shift+PGUP" and "Shift+PGDWM".
+ Increasing/decreasing audio delay have been remapped from "+" and "-" to
"Ctrl++" and "Ctrl+-".
+ "(" and ")" for adjusting audio balance have been unmapped.
+ "F" for toggling the "sub-forced-only" option has been unmapped.
+ "TAB" for cycling TS programs has been unmapped.
+ "A" for cycling DVD angle has been unmapped.
+ "U" for stopping playback has been unmapped.
+ "l" and "L" for cycling quvi format have been unmapped.
- Make it possible to build the client API (libmpv) on Mac OS X.
- Do necessary checks for nested Wayland compositors which only have limited
interfaces.
- The options in the manpage have been re-organized into sections and ordered by
usage to make it easier to navigate.
- The "hard" framedrop mode has been removed (this behaviour is still available
via the --vd-lavc-framedrop option).
- Show the basename of a subtitle file only (without the directory part).
Bug fixes
---------
- Use a default color space for files with no video (this fixes color managed
OSD messages when no video channel is present).
- Fix key equivalent dispatching for Cocoa on Mac OS X.
- Disable non-interleaved audio formats by default with ao_alsa, since some
ALSA plugins don't cope well with them (non-interleaved formats can still be
enabled using the "non-interleaved" ao_alsa option).
- Fix deadlock in the client API when calling mpv_terminate_destroy() before
mpv_initialize().
- Fix flushing of filter chain (this fixes a bug where the last frames would get
dropped on EOF, if buffered by filters).
- Actually use the channels.conf configuration file for DVB.
- Restore the --dvbin-file option.
- Fix off by one error in the command parser which caused a segfault when using
the mp.commandv() Lua function with 10 or more arguments.
New features
------------
- Search for config files in $XDG_CONFIG_HOME and $XDG_CONFIG_DIRS in addition
to ~/.mpv. The config file has also been renamed to mpv.conf (although the
old file still works and will be loaded even if the new one exists).
- Add "playback-time" property that returns the current playback time always
starting at 0. This is now used to show the playback time in the OSD and the
status line, fixing the shown playback time for transport streams that start
at a completely random timestamp.
- Add cache-related "cache-free", "cache-used" and "cache-idle" properties.
- Add option to list supported protocols (--list-protocols).
- Allow setting libavformat stream options with the --stream-lavf-o option.
- Support running the demuxer in a separate thread and prefetch packets (this
can be enabled using the --demuxer-thread option).
This listing is not complete. There are many more bug fixes and changes. The
complete change log can be viewed by running ``git log cb250d4..52f2f67`` in
the git repository.
+93
View File
@@ -0,0 +1,93 @@
#!/usr/bin/env python
import re
import os
import sys
import shutil
import subprocess
from functools import partial
sys_re = re.compile("^/System")
usr_re = re.compile("^/usr/lib/")
exe_re = re.compile("@executable_path")
def is_user_lib(objfile, libname):
return not sys_re.match(libname) and \
not usr_re.match(libname) and \
not exe_re.match(libname) and \
not "libobjc." in libname and \
not "libSystem." in libname and \
not "libc." in libname and \
not "libgcc." in libname and \
not os.path.basename(objfile) in libname
def otool(objfile):
command = "otool -L %s | grep -e '\t' | awk '{ print $1 }'" % objfile
output = subprocess.check_output(command, shell = True)
return filter(partial(is_user_lib, objfile), output.split())
def install_name_tool_change(old, new, objfile):
subprocess.call(["install_name_tool", "-change", old, new, objfile])
def install_name_tool_id(name, objfile):
subprocess.call(["install_name_tool", "-id", name, objfile])
def libraries(objfile, result = dict()):
libs_list = otool(objfile)
result[objfile] = set(libs_list)
for lib in libs_list:
if lib not in result:
libraries(lib, result)
return result
def leafs(libs_dict, processed = []):
result = []
processed = set(processed)
for objfile, libs in libs_dict.items():
if libs <= processed:
result.append(objfile)
return result
def lib_path(binary):
return os.path.join(os.path.dirname(binary), 'lib')
def lib_name(lib):
return os.path.join("@executable_path", "lib", os.path.basename(lib))
def process_libraries(libs_dict, binary, processed = []):
ls = leafs(libs_dict, processed)
diff = set(ls) - set(processed)
if diff == set([binary]):
return
for src in diff:
name = lib_name(src)
dst = os.path.join(lib_path(binary), os.path.basename(src))
shutil.copy(src, dst)
os.chmod(dst, 0o755)
install_name_tool_id(name, dst)
if src in libs_dict[binary]:
install_name_tool_change(src, name, binary)
for p in processed:
if p in libs_dict[src]:
install_name_tool_change(p, lib_name(p), dst)
process_libraries(libs_dict, binary, ls)
def main():
binary = os.path.abspath(sys.argv[1])
if not os.path.exists(lib_path(binary)):
os.makedirs(lib_path(binary))
libs = libraries(binary)
print(libs)
process_libraries(libs, binary)
if __name__ == "__main__":
main()
Executable
+161
View File
@@ -0,0 +1,161 @@
#!/bin/sh
case "$0" in
*/*)
MYDIR=${0%/*}
;;
*)
MYDIR=.
;;
esac
: ${MPV:=mpv}
: ${ILDETECT_MPV:=$MPV}
: ${ILDETECT_MPV:=$MPV}
: ${ILDETECT_MPVFLAGS:=--start=35% --length=35}
: ${ILDETECT_DRY_RUN:=}
: ${ILDETECT_QUIET:=}
: ${ILDETECT_RUN_INTERLACED_ONLY:=}
: ${ILDETECT_FORCE_RUN:=}
: ${MAKE:=make}
# exit status:
# 0 progressive
# 1 telecine
# 2 interlaced
# 8 unknown
# 16 detect fail
# 17+ mpv's status | 16
testfun()
{
$ILDETECT_MPV "$@" \
--vf-add=lavfi="[idet]" --msg-level ffmpeg=v \
--o= --vo=null --no-audio --untimed \
$ILDETECT_MPVFLAGS \
| { if [ -n "$ILDETECT_QUIET" ]; then cat; else tee /dev/stderr; fi } \
| grep "Parsed_idet_0: Multi frame detection: " | tail -n 1
}
judge()
{
out=`testfun "$@"`
tff=${out##* TFF:}; tff=${tff%% *}
bff=${out##* BFF:}; bff=${bff%% *}
progressive=${out##* Progressive:}; progressive=${progressive%% *}
undetermined=${out##* Undetermined:}; undetermined=${undetermined%% *}
case "$tff$bff$progressive$undetermined" in
*[!0-9]*)
echo >&2 "ERROR: Unrecognized idet output: $out"
exit 16
;;
esac
interlaced=$((bff + tff))
determined=$((interlaced + progressive))
if [ $undetermined -gt $determined ] || [ $determined -lt 250 ]; then
echo >&2 "ERROR: Less than 50% or 250 frames are determined."
[ -n "$ILDETECT_FORCE_RUN" ] || exit 8
echo >&2 "Assuming interlacing."
if [ $tff -gt $((bff * 10)) ]; then
verdict=interlaced-tff
elif [ $bff -gt $((tff * 10)) ]; then
verdict=interlaced-bff
else
verdict=interlaced
fi
elif [ $((interlaced * 20)) -gt $progressive ]; then
# At least 5% of the frames are interlaced!
if [ $tff -gt $((bff * 10)) ]; then
verdict=interlaced-tff
elif [ $bff -gt $((tff * 10)) ]; then
verdict=interlaced-bff
else
echo >&2 "ERROR: Content is interlaced, but can't determine field order."
[ -n "$ILDETECT_FORCE_RUN" ] || exit 8
echo >&2 "Assuming interlacing with default field order."
verdict=interlaced
fi
else
# Likely progrssive.
verdict=progressive
fi
echo "$verdict"
}
judge "$@" --vf-clr
case "$verdict" in
progressive)
[ -n "$ILDETECT_DRY_RUN" ] || \
[ -n "$ILDETECT_RUN_INTERLACED_ONLY" ] || \
$ILDETECT_MPV "$@"
r=$?
[ $r -eq 0 ] || exit $(($r | 16))
exit 0
;;
interlaced-tff)
judge "$@" --vf-clr --vf-pre=pullup --field-dominance=top
case "$verdict" in
progressive)
[ -n "$ILDETECT_DRY_RUN" ] || \
$ILDETECT_MPV "$@" --vf-pre=pullup --field-dominance=top
r=$?
[ $r -eq 0 ] || exit $(($r | 16))
exit 1
;;
*)
[ -n "$ILDETECT_DRY_RUN" ] || \
$ILDETECT_MPV "$@" --vf-pre=yadif --field-dominance=top
r=$?
[ $r -eq 0 ] || exit $(($r | 16))
exit 2
;;
esac
;;
interlaced-bff)
judge "$@" --vf-clr --vf-pre=pullup --field-dominance=bottom
case "$verdict" in
progressive)
[ -n "$ILDETECT_DRY_RUN" ] || \
$ILDETECT_MPV "$@" --vf-pre=pullup --field-dominance=bottom
r=$?
[ $r -eq 0 ] || exit $(($r | 16))
exit 1
;;
*)
[ -n "$ILDETECT_DRY_RUN" ] || \
$ILDETECT_MPV "$@" --vf-pre=yadif --field-dominance=bottom
r=$?
[ $r -eq 0 ] || exit $(($r | 16))
exit 2
;;
esac
;;
interlaced)
judge "$@" --vf-clr --vf-pre=pullup
case "$verdict" in
progressive)
[ -n "$ILDETECT_DRY_RUN" ] || \
$ILDETECT_MPV "$@" --vf-pre=pullup
r=$?
[ $r -eq 0 ] || exit $(($r | 16))
exit 1
;;
*)
[ -n "$ILDETECT_DRY_RUN" ] || \
$ILDETECT_MPV "$@" --vf-pre=yadif
r=$?
[ $r -eq 0 ] || exit $(($r | 16))
exit 2
;;
esac
;;
*)
echo >&2 "ERROR: Internal error."
exit 16
;;
esac
+20 -17
View File
@@ -132,7 +132,8 @@ sub _bin2int($) {
# creates a floating-point number with the given mantissa and exponent
sub _ldexp {
my ($mantissa, $exponent) = @_;
return $mantissa * Math::BigRat->new(2)**$exponent;
my $r = new Math::BigRat($mantissa);
return $r * Math::BigRat->new(2)**$exponent;
}
# NOTE: the read_* functions are hard to read because they're ports
@@ -252,25 +253,27 @@ bytes from the internal filehandle.
Only lengths C<4> and C<8> are supported (C C<float> and C<double>).
=cut
sub read_float {
my ($self, $length) = @_;
my $i = $self->read_uint($length);
my $f;
{
my $b1 = new Math::BigInt 1;
use bigrat try => BIGINT_TRY;
sub read_float {
my ($self, $length) = @_;
my $i = new Math::BigInt $self->read_uint($length)->bstr;
my $f;
# These evil expressions reinterpret an unsigned int as IEEE binary floats
if ($length == 4) {
$f = _ldexp(($i & (1<<23 - 1)) + (1<<23), ($i>>23 & (1<<8 - 1)) - 150);
$f = -$f if $i & (1<<31);
} elsif ($length == 8) {
$f = _ldexp(($i & (1<<52 - 1)) + (1<<52), ($i>>52 & (1<<12 - 1)) - 1075);
$f = -$f if $i & (1<<63);
} else {
croak "Matroska Syntax error: unsupported IEEE float byte size $length";
# These evil expressions reinterpret an unsigned int as IEEE binary floats
if ($length == 4) {
$f = _ldexp(($i & ((1<<23) - 1)) + (1<<23), ($i>>23 & ((1<<8) - 1)) - 150);
$f = -$f if $i & ($b1<<31);
} elsif ($length == 8) {
$f = _ldexp(($i & (($b1<<52) - 1)) + ($b1<<52), ($i>>52 & ((1<<12) - 1)) - 1075);
$f = -$f if $i & ($b1<<63);
} else {
croak "Matroska Syntax error: unsupported IEEE float byte size $length";
}
return $f;
}
return $f;
}
=method read_ebml_id($length)
+19
View File
@@ -0,0 +1,19 @@
mpv lua scripts
===============
The lua scripts in this folder can be loaded on a one-time basis by
adding the option
--lua=/path/to/script.lua
to mpv's command line.
Unless otherwise specified, they are also suitable for inclusion in
the `~/.mpv/lua` directory where they will be loaded every time mpv
starts, obviating the need to load them with the above `--lua=...`
argument. This is acceptable as they do only basic argument parsing
and key-binding registration, until those bound keys are actually
pressed. They should therefore not interfere with normal playback
(unless you have a conflicting user-defined key-binding, in which
case, you may want to modify either the `mp.add_key_binding()` calls
in the scripts, or your keybinding).
+113
View File
@@ -0,0 +1,113 @@
-- This script uses the lavfi cropdetect filter to automatically
-- insert a crop filter with appropriate parameters for the currently
-- playing video.
--
-- It registers the key-binding "C" (shift+c), which when pressed,
-- inserts the filter vf=lavfi=cropdetect. After 1 second, it then
-- inserts the filter vf=crop=w:h:x:y, where w,h,x,y are determined
-- from the vf-metadata gathered by cropdetect. The cropdetect filter
-- is removed immediately after the crop filter is inserted as it is
-- no longer needed.
--
-- If the "C" key is pressed again, the crop filter is removed
-- restoring playback to its original state.
--
-- Since the crop parameters are determined from the 1 second of video
-- between inserting the cropdetect and crop filters, the "C" key
-- should be pressed at a position in the video where the crop region
-- is unambiguous (i.e., not a black frame, black background title
-- card, or dark scene).
--
-- The default delay between insertion of the cropdetect and
-- crop filters may be overridden by adding
--
-- --lua-opts=autocrop.detect_seconds=<number of seconds>
--
-- to mpv's arguments. This may be desirable to allow cropdetect more
-- time to collect data.
require "mp.msg"
script_name = mp.get_script_name()
cropdetect_label = string.format("%s-cropdetect", script_name)
crop_label = string.format("%s-crop", script_name)
-- number of seconds to gather cropdetect data
detect_seconds = tonumber(mp.get_opt(string.format("%s.detect_seconds", script_name)))
if not detect_seconds then
detect_seconds = 1
end
function del_filter_if_present(label)
-- necessary because mp.command('vf del @label:filter') raises an
-- error if the filter doesn't exist
local vfs = mp.get_property_native("vf")
for i,vf in pairs(vfs) do
if vf["label"] == label then
table.remove(vfs, i)
mp.set_property_native("vf", vfs)
return true
end
end
return false
end
function autocrop_start()
-- exit if cropdetection is already in progress
if timer then
mp.msg.warn("already cropdetecting!")
return
end
-- if there's a crop filter, remove it and exit
if del_filter_if_present(crop_label) then
return
end
-- insert the cropdetect filter
ret=mp.command(
string.format(
'vf add @%s:lavfi=graph="cropdetect=limit=24:round=2:reset=0"',
cropdetect_label
)
)
-- wait to gather data
timer=mp.add_timeout(detect_seconds, do_crop)
end
function do_crop()
-- get the metadata
local cropdetect_metadata = mp.get_property_native(
string.format("vf-metadata/%s", cropdetect_label)
)
-- use it to crop if its valid
if cropdetect_metadata then
if cropdetect_metadata["lavfi.cropdetect.w"]
and cropdetect_metadata["lavfi.cropdetect.h"]
and cropdetect_metadata["lavfi.cropdetect.x"]
and cropdetect_metadata["lavfi.cropdetect.y"]
then
mp.command(string.format("vf add @%s:crop=%s:%s:%s:%s",
crop_label,
cropdetect_metadata["lavfi.cropdetect.w"],
cropdetect_metadata["lavfi.cropdetect.h"],
cropdetect_metadata["lavfi.cropdetect.x"],
cropdetect_metadata["lavfi.cropdetect.y"]))
else
mp.msg.error(
"Got empty crop data. You might need to increase detect_seconds."
)
end
else
mp.msg.error(
"No crop data. Was the cropdetect filter successfully inserted?"
)
mp.msg.error(
"Does your version of ffmpeg/libav support AVFrame metadata?"
)
end
-- remove the cropdetect filter
del_filter_if_present(cropdetect_label)
timer=nil
end
mp.add_key_binding("C", "auto_crop", autocrop_start)
+71
View File
@@ -0,0 +1,71 @@
-- This script automatically loads playlist entries before and after the
-- the currently played file. It does so by scanning the directory a file is
-- located in when starting playback. It sorts the directory entries
-- alphabetically, and adds entries before and after the current file to
-- the internal playlist. (It stops if the it would add an already existing
-- playlist entry at the same position - this makes it "stable".)
-- Add at most 5 * 2 files when starting a file (before + after).
MAXENTRIES = 5
mputils = require 'mp.utils'
function add_files_at(index, files)
index = index - 1
local oldcount = mp.get_property_number("playlist-count", 1)
for i = 1, #files do
mp.commandv("loadfile", files[i], "append")
mp.commandv("playlist_move", oldcount + i - 1, index + i - 1)
end
end
function find_and_add_entries()
local path = mp.get_property("path", "")
local dir, filename = mputils.split_path(path)
if #dir == 0 then
return
end
local files = mputils.readdir(dir, "files")
table.sort(files)
local pl = mp.get_property_native("playlist", {})
local pl_current = mp.get_property_number("playlist-pos", 0) + 1
-- Find the current pl entry (dir+"/"+filename) in the sorted dir list
local current
for i = 1, #files do
if files[i] == filename then
current = i
break
end
end
if current == nil then
return
end
local append = {[-1] = {}, [1] = {}}
for dir = -1, 1, 2 do -- 2 iterations, with dir = -1 and +1
for i = 1, MAXENTRIES do
local file = files[current + i * dir]
local pl_e = pl[pl_current + i * dir]
if file == nil or file[1] == "." then
break
end
if pl_e then
-- If there's a playlist entry, and it's the same file, stop.
if pl_e.filename == file then
break
end
end
if dir == -1 then
if pl_current == 1 then -- never add additional entries in the middle
mp.msg.info("Prepending " .. file)
table.insert(append[-1], 1, file)
end
else
mp.msg.info("Adding " .. file)
table.insert(append[1], file)
end
end
end
add_files_at(pl_current + 1, append[1])
add_files_at(pl_current, append[-1])
end
mp.register_event("start-file", find_and_add_entries)
+56
View File
@@ -0,0 +1,56 @@
-- This script cycles between deinterlacing, pullup (inverse
-- telecine), and both filters off. It uses the "deinterlace" property
-- so that a hardware deinterlacer will be used if available.
--
-- It overrides the default deinterlace toggle keybinding "D"
-- (shift+d), so that rather than merely cycling the "deinterlace" property
-- between on and off, it adds a "pullup" step to the cycle.
--
-- It provides OSD feedback as to the actual state of the two filters
-- after each cycle step/keypress.
--
-- Note: if hardware decoding is enabled, pullup filter will likely
-- fail to insert.
--
-- TODO: It might make sense to use hardware assisted vdpaupp=pullup,
-- if available, but I don't have hardware to test it. Patch welcome.
script_name = mp.get_script_name()
pullup_label = string.format("%s-pullup", script_name)
function pullup_on()
for i,vf in pairs(mp.get_property_native('vf')) do
if vf['label'] == pullup_label then
return "yes"
end
end
return "no"
end
function do_cycle()
if pullup_on() == "yes" then
-- if pullup is on remove it
mp.command(string.format("vf del @%s:pullup", pullup_label))
return
elseif mp.get_property("deinterlace") == "yes" then
-- if deinterlace is on, turn it off and insert pullup filter
mp.set_property("deinterlace", "no")
mp.command(string.format("vf add @%s:pullup", pullup_label))
return
else
-- if neither is on, turn on deinterlace
mp.set_property("deinterlace", "yes")
return
end
end
function cycle_deinterlace_pullup_handler()
do_cycle()
-- independently determine current state and give user feedback
mp.osd_message(string.format("deinterlace: %s\n"..
"pullup: %s",
mp.get_property("deinterlace"),
pullup_on()))
end
mp.add_key_binding("D", "cycle-deinterlace-pullup", cycle_deinterlace_pullup_handler)
+99
View File
@@ -0,0 +1,99 @@
-- This script enables live control of the dynamic range compression
-- (drc) audio filter while the video is playing back. This can be
-- useful to avoid having to stop and restart mpv to adjust filter
-- parameters. See the entry for "drc" under the "AUDIO FILTERS"
-- section of the man page for a complete description of the filter.
--
-- This script registers the key-binding "\" to toggle the filter between
--
-- * off
-- * method=1 (single-sample smoothing)
-- * method=2 (multi-sample smoothing)
--
-- It registers the keybindings ctrl+9/ctrl+0 to decrease/increase the
-- target ampltiude. These keys will insert the filter at the default
-- target amplitude of 0.25 if it was not previously present.
--
-- OSD feedback of the current filter state is displayed on pressing
-- each bound key.
script_name = mp.get_script_name()
function print_state(params)
if params then
mp.osd_message(script_name..":\n"
.."method = "..params["method"].."\n"
.."target = "..params["target"])
else
mp.osd_message(script_name..":\noff")
end
end
function get_index_of_drc(afs)
for i,af in pairs(afs) do
if af["label"] == script_name then
return i
end
end
end
function append_drc(afs)
afs[#afs+1] = {
name = "drc",
label = script_name,
params = {
method = "1",
target = "0.25"
}
}
print_state(afs[#afs]["params"])
end
function modify_or_create_af(fun)
afs = mp.get_property_native("af")
i = get_index_of_drc(afs)
if not i then
append_drc(afs)
else
fun(afs, i)
end
mp.set_property_native("af", afs)
end
function drc_toggle_method_handler()
modify_or_create_af(
function (afs, i)
new_method=(afs[i]["params"]["method"]+1)%3
if new_method == 0 then
table.remove(afs, i)
print_state(nil)
else
afs[i]["params"]["method"] = tostring((afs[i]["params"]["method"])%2+1)
print_state(afs[i]["params"])
end
end
)
end
function drc_scale_target(factor)
modify_or_create_af(
function (afs)
afs[i]["params"]["target"] = tostring(afs[i]["params"]["target"]*factor)
print_state(afs[i]["params"])
end
)
end
function drc_louder_handler()
drc_scale_target(2.0)
end
function drc_quieter_handler()
drc_scale_target(0.5)
end
-- toggle between off, method 1 and method 2
mp.add_key_binding("\\", "drc_toggle_method", drc_toggle_method_handler)
-- increase or decrease target volume
mp.add_key_binding("ctrl+9", "drc_quieter", drc_quieter_handler)
mp.add_key_binding("ctrl+0", "drc_louder", drc_louder_handler)
+16
View File
@@ -0,0 +1,16 @@
-- Test script for property change notification mechanism.
function format_property_val(v)
if type(v) == "table" then
return mp.format_table(v) -- undocumented function; might be removed
else
return tostring(v)
end
end
for i,name in ipairs(mp.get_property_native("property-list")) do
mp.observe_property(name, "native", function(name, val)
print("property '" .. name .. "' changed to '" ..
format_property_val(val) .. "'")
end)
end
+69
View File
@@ -0,0 +1,69 @@
-- Rebuild the terminal status line as a lua script
-- Be aware that this will require more cpu power!
-- Add a string to the status line
function atsl(s)
newStatus = newStatus .. s
end
function update_status_line()
-- Reset the status line
newStatus = ""
if mp.get_property_bool("pause") then
atsl("(Paused) ")
elseif mp.get_property_bool("paused-for-cache") then
atsl("(Buffering) ")
end
if mp.get_property("vid") ~= "no" then
atsl("A")
end
if mp.get_property("aid") ~= "no" then
atsl("V")
end
atsl(": ")
atsl(mp.get_property_osd("time-pos"))
atsl(" / ");
atsl(mp.get_property_osd("length"));
atsl(" (")
atsl(mp.get_property_osd("percent-pos", -1))
atsl("%)")
local r = mp.get_property_number("speed", -1)
if r ~= 1 then
atsl(string.format(" x%4.2f", r))
end
r = mp.get_property_number("avsync", nil)
if r ~= nil then
atsl(string.format(" A-V: %7.3f", r))
end
r = mp.get_property("total-avsync-change", 0)
if math.abs(r) > 0.05 then
atsl(string.format(" ct:%7.3f", r))
end
r = mp.get_property_number("drop-frame-count", -1)
if r > 0 then
atsl(" Late: ")
atsl(r)
end
r = mp.get_property_number("cache", 0)
if r > 0 then
atsl(string.format(" Cache: %d%% ", r))
end
-- Set the new status line
mp.set_property("options/term-status-msg", newStatus)
end
-- Register the event
mp.register_event("tick", update_status_line)
+2 -2
View File
@@ -86,7 +86,7 @@ __midentify__allprops="
video-bitrate
video-codec
video-format
aspect
video-aspect
fps
width
height
@@ -104,7 +104,7 @@ for __midentify__key in $__midentify__allprops; do
eval unset $__midentify__nextprefix$__midentify__key
done
__midentify__output=`$MPV --playing-msg="$__midentify__propstr" --vo=null --ao=null --frames=1 --quiet --no-cache --no-config "$@"`
__midentify__output=`$MPV --term-playing-msg="$__midentify__propstr" --vo=null --ao=null --frames=1 --quiet --no-cache --no-config "$@"`
__midentify__fileindex=0
__midentify__prefix=
while :; do
+1 -66
View File
@@ -1,35 +1,13 @@
#!/usr/bin/env python
import os
import re
import shutil
import sys
from optparse import OptionParser
from textwrap import dedent
def sh(command):
return os.popen(command).read()
def dylib_lst(input_file):
return sh("otool -L %s | grep -e '\t' | awk '{ print $1 }'" % input_file)
sys_re = re.compile("/System")
exe_re = re.compile("@executable_path")
binary_name = sys.argv[1]
def is_user_lib(libname, input_file):
return not sys_re.match(libname) and \
not exe_re.match(libname) and \
not "libobjc" in libname and \
not "libSystem" in libname and \
not "libgcc" in libname and \
not os.path.basename(input_file) in libname and \
not libname == ''
def user_dylib_lst(input_file):
return [lib for lib in dylib_lst(input_file).split("\n") if
is_user_lib(lib, input_file)]
def bundle_path(binary_name):
return "%s.app" % binary_name
@@ -56,52 +34,9 @@ def copy_bundle(binary_name):
def copy_binary(binary_name):
shutil.copy(binary_name, target_binary(binary_name))
def run_install_name_tool(target_file, dylib_path, dest_dir, root=True):
new_dylib_path = os.path.join("@executable_path", "lib",
os.path.basename(dylib_path))
sh("install_name_tool -change %s %s %s" % \
(dylib_path, new_dylib_path, target_file))
if root:
sh("install_name_tool -id %s %s" % \
(new_dylib_path, os.path.join(dest_dir,
os.path.basename(dylib_path))))
def cp_dylibs(target_file, dest_dir):
for dylib_path in user_dylib_lst(target_file):
dylib_dest_path = os.path.join(dest_dir, os.path.basename(dylib_path))
try:
shutil.copy(dylib_path, dylib_dest_path)
except IOError:
if re.match("dylib$", target_file):
reinstall_what = target_file
else:
reinstall_what = dylib_path
sys.exit(dedent("""\
%s uses library %s which is not available anymore.
This is most likely because you uninstalled %s.
Please reinstall %s to fix it's dependencies.""" % \
(target_file, dylib_path, dylib_path, reinstall_what) ))
os.chmod(dylib_dest_path, 0o755)
cp_dylibs(dylib_dest_path, dest_dir)
def fix_dylibs_paths(target_file, dest_dir, root=True):
for dylib_path in user_dylib_lst(target_file):
dylib_dest_path = os.path.join(dest_dir, os.path.basename(dylib_path))
run_install_name_tool(target_file, dylib_path, dest_dir, root)
fix_dylibs_paths(dylib_dest_path, dest_dir, False)
def apply_plist_template(plist_file, version):
sh("sed -i -e 's/${VERSION}/%s/g' %s" % (version, plist_file))
def bundle_dependencies(binary_name):
lib_bundle_directory = os.path.join(target_directory(binary_name), "lib")
cp_dylibs(binary_name, lib_bundle_directory)
fix_dylibs_paths(target_binary(binary_name), lib_bundle_directory)
def main():
version = sh("./version.sh --print").strip()
@@ -128,7 +63,7 @@ def main():
if options.deps:
print("> bundling dependencies")
bundle_dependencies(binary_name)
sh(" ".join(["TOOLS/dylib-unhell.py", target_binary(binary_name)]))
print("done.")
+588 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
@@ -230,5 +230,592 @@
</array>
</dict>
</array>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.audio</string>
</array>
<key>UTTypeDescription</key>
<string>AC3 Audio</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.ac3</string>
<key>UTTypeReferenceURL</key>
<string>http://wiki.multimedia.cx/index.php?title=AC3</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>ac3</string>
<string>a52</string>
<string>eac3</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.audio</string>
</array>
<key>UTTypeDescription</key>
<string>DTS Audio</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.dts</string>
<key>UTTypeReferenceURL</key>
<string>http://wiki.multimedia.cx/index.php?title=DTS</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>dts</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.audio</string>
</array>
<key>UTTypeDescription</key>
<string>Free Lossless Audio Codec</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.flac</string>
<key>UTTypeReferenceURL</key>
<string>http://flac.sourceforge.net/format.html</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>flac</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.audio</string>
</array>
<key>UTTypeDescription</key>
<string>Matroska Audio</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.mka</string>
<key>UTTypeReferenceURL</key>
<string>http://www.matroska.org</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>mka</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.audio</string>
</array>
<key>UTTypeDescription</key>
<string>Ogg Audio</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.ogg-audio</string>
<key>UTTypeReferenceURL</key>
<string>http://xiph.org/ogg</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>ogg</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.audio</string>
</array>
<key>UTTypeDescription</key>
<string>PCM Audio</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.pcm</string>
<key>UTTypeReferenceURL</key>
<string>http://en.wikipedia.org/wiki/Pulse-code_modulation</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>pcm</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.audio</string>
</array>
<key>UTTypeDescription</key>
<string>Windows Media Audio</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.wma</string>
<key>UTTypeReferenceURL</key>
<string>http://en.wikipedia.org/wiki/Windows_Media_Audio</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>wma</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.movie</string>
</array>
<key>UTTypeDescription</key>
<string>Audio Video Interleave</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.avi</string>
<key>UTTypeReferenceURL</key>
<string>http://www.the-labs.com/Video/odmlff2-avidef.pdf</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>avi</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.movie</string>
</array>
<key>UTTypeDescription</key>
<string>DIVX Video</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.divx</string>
<key>UTTypeReferenceURL</key>
<string>http://www.divx.com</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>divx</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.movie</string>
</array>
<key>UTTypeDescription</key>
<string>DV Video</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.dv</string>
<key>UTTypeReferenceURL</key>
<string>http://en.wikipedia.org/wiki/DV</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>dv</string>
<string>hdv</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.movie</string>
</array>
<key>UTTypeDescription</key>
<string>Flash Video</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.flv</string>
<key>UTTypeReferenceURL</key>
<string>http://en.wikipedia.org/wiki/Flash_Video</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>flv</string>
<string>f4v</string>
<string>f4p</string>
<string>swf</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.movie</string>
</array>
<key>UTTypeDescription</key>
<string>MPEG-2 Transport Stream</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.mts</string>
<key>UTTypeReferenceURL</key>
<string>http://en.wikipedia.org/wiki/.m2ts</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>trp</string>
<string>m2t</string>
<string>m2ts</string>
<string>mts</string>
<string>mtv</string>
<string>ts</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.movie</string>
</array>
<key>UTTypeDescription</key>
<string>Matroska Video</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.mkv</string>
<key>UTTypeReferenceURL</key>
<string>http://www.matroska.org</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>mkv</string>
<string>webm</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.movie</string>
</array>
<key>UTTypeDescription</key>
<string>Ogg Video</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.ogv</string>
<key>UTTypeReferenceURL</key>
<string>http://xiph.org/ogg</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>ogm</string>
<string>ogv</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.movie</string>
</array>
<key>UTTypeDescription</key>
<string>Real Media</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.rmvb</string>
<key>UTTypeReferenceURL</key>
<string>http://www.real.com</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>rmvb</string>
<string>rm</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.movie</string>
</array>
<key>UTTypeDescription</key>
<string>Video Object</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.vob</string>
<key>UTTypeReferenceURL</key>
<string>http://en.wikipedia.org/wiki/VOB</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>vob</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.movie</string>
</array>
<key>UTTypeDescription</key>
<string>Windows Media Video</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.wmv</string>
<key>UTTypeReferenceURL</key>
<string>http://en.wikipedia.org/wiki/Windows_Media_Video</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>wmv</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.movie</string>
</array>
<key>UTTypeDescription</key>
<string>XVID Video</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.xvid</string>
<key>UTTypeReferenceURL</key>
<string>http://www.xvid.org</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>xvid</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.movie</string>
</array>
<key>UTTypeDescription</key>
<string>AVC raw stream</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.h264</string>
<key>UTTypeReferenceURL</key>
<string>http://www.itu.int/rec/T-REC-H.264</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>264</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.movie</string>
</array>
<key>UTTypeDescription</key>
<string>HEVC raw stream</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.hevc</string>
<key>UTTypeReferenceURL</key>
<string>http://hevc.info</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>hevc</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.movie</string>
</array>
<key>UTTypeDescription</key>
<string>YUV stream</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.yuv</string>
<key>UTTypeReferenceURL</key>
<string>http://en.wikipedia.org/wiki/YUV</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>yuv</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.movie</string>
</array>
<key>UTTypeDescription</key>
<string>YUV4MPEG2 stream</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.y4m</string>
<key>UTTypeReferenceURL</key>
<string>http://wiki.multimedia.cx/index.php?title=YUV4MPEG2</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>y4m</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.plain-text</string>
</array>
<key>UTTypeDescription</key>
<string>SubRip Subtitle</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.subrip</string>
<key>UTTypeReferenceURL</key>
<string>http://en.wikipedia.org/wiki/SubRip</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>srt</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.plain-text</string>
</array>
<key>UTTypeDescription</key>
<string>MicroDVD Subtitle</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.sub</string>
<key>UTTypeReferenceURL</key>
<string>http://en.wikipedia.org/wiki/MicroDVD</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>sub</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.plain-text</string>
</array>
<key>UTTypeDescription</key>
<string>SubStation Alpha Subtitle</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.ass</string>
<key>UTTypeReferenceURL</key>
<string>https://github.com/libass/libass</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>ass</string>
<string>ssa</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>VobSub Subtitle</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.vobsub</string>
<key>UTTypeReferenceURL</key>
<string>http://en.wikipedia.org/wiki/DirectVobSub</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>idx</string>
<string>sub</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.plain-text</string>
</array>
<key>UTTypeDescription</key>
<string>SAMI Subtitle</string>
<key>UTTypeIconFile</key>
<string>document.icns</string>
<key>UTTypeIdentifier</key>
<string>io.mpv.smi</string>
<key>UTTypeReferenceURL</key>
<string>http://en.wikipedia.org/wiki/SAMI</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>smi</string>
<string>smil</string>
</array>
</dict>
</dict>
</array>
</dict>
</plist>
+96
View File
@@ -0,0 +1,96 @@
#!/usr/bin/env python3
import matplotlib.pyplot as plot
import sys
filename = sys.argv[1]
"""
This script is meant to display stats written by mpv --dump-stats=filename.
In general, each line in that file is an event of the form:
<timestamp in microseconds> <text> '#' <comment>
e.g.:
10474959 start flip #cplayer
<text> is what MP_STATS(log, "...") writes. The rest is added by msg.c.
Currently, the following event types are supported:
'start' <name> start of the named event
'end' <name> end of the named event
'value' <float> <name> a normal value (as opposed to event)
<event> singular event
"""
class G:
events = {}
sevents = [] # events, deterministically sorted
start = None
class Event:
pass
def get_event(event):
if event not in G.events:
e = Event()
G.events[event] = e
e.name = event
e.vals = []
e.type = "unknown"
G.sevents = list(G.events.values())
G.sevents.sort(key=lambda x: x.name)
return G.events[event]
for line in [line.split("#")[0].strip() for line in open(filename, "r")]:
line = line.strip()
if not line:
continue
ts, event = line.split(" ", 1)
ts = int(ts) / 1000 # milliseconds
if G.start is None:
G.start = ts
ts = ts - G.start
if event.startswith("start "):
e = get_event(event[6:])
e.type = "event"
e.vals.append((ts, 0))
e.vals.append((ts, 1))
elif event.startswith("end "):
e = get_event(event[4:])
e.type = "event"
e.vals.append((ts, 1))
e.vals.append((ts, 0))
elif event.startswith("value "):
_, val, name = event.split(" ", 2)
val = float(val)
e = get_event(name)
e.type = "value"
e.vals.append((ts, val))
else:
e = get_event(event)
e.type = "event-signal"
e.vals.append((ts, 1))
ao_events = ["ao fill", "audio wait"]
for e in G.sevents:
if e.name in ao_events:
e.vals = [(x, y * 0.5) for (x, y) in e.vals]
plot.hold(True)
mainpl = plot.subplot(2, 1, 1)
legend = []
for e in G.sevents:
if e.type == "value":
plot.subplot(2, 1, 2, sharex=mainpl)
else:
plot.subplot(2, 1, 1)
pl, = plot.plot([x for x,y in e.vals], [y for x,y in e.vals], label=e.name)
if e.type == "event-signal":
plot.setp(pl, marker = "o", linestyle = "None")
legend.append(pl)
plot.subplot(2, 1, 1)
plot.legend(legend, [pl.get_label() for pl in legend])
plot.show()
+48 -17
View File
@@ -3,20 +3,18 @@
"""
This script emulates "unique application" functionality on Linux. When starting
playback with this script, it will try to reuse an already running instance of
mpv (but only if that was started with umpv).
mpv (but only if that was started with umpv). Other mpv instances (not started
by umpv) are ignored, and the script doesn't know about them.
This script only uses mpv instances started with umpv. Other instances are
ignored, and don't exist for the script.
This only takes filenames as arguments. If mpv is already running, they are
appended to mpv's internal playlist. If the file does not exist or is otherwise
not playable, mpv will skip the playlist entry when attempting to play it (from
the GUI perspective, it's silently ignored).
This only takes filenames as arguments. Custom options can't be used; the script
interprets them as filenames. If mpv is already running, the files passed to
umpv are appended to mpv's internal playlist. If a file does not exist or is
otherwise not playable, mpv will skip the playlist entry when attempting to
play it (from the GUI perspective, it's silently ignored).
If mpv isn't running yet, this script will start mpv and let it control the
current terminal. If you play an audio-only file, mpv will not open a window
(that is its normal behavior; but it might not be what a user expects if this
script is used in a GUI setting).
current terminal. It will not write output to stdout/stderr, because this
will typically just fill ~/.xsession-errors with garbage.
mpv will terminate if there are no more files to play, and running the umpv
script after that will start a new mpv instance.
@@ -25,10 +23,18 @@ Note that you can control the mpv instance by writing to the command fifo:
echo "cycle fullscreen" > /tmp/umpv-fifo-*
Note: you can supply custom options with the UMPV_OPTIONS environment variable.
The environment variable will be split on whitespace, and each item is
passed as option to mpv _if_ the script starts mpv. If mpv is not started
by the script (i.e. mpv is already running), the options will be ignored.
Warning:
The script attempts to make sure the FIFO is safely created (i.e. not world-
readable, not trying to open a bogus
writable), and checks that it's really a FIFO. This is important for security,
because the FIFO allows anyone with write access to run arbitrary commands
in mpv's context using the "run" input command. If you are worried about
security, you should verify that the code handles these concerns correctly.
"""
import sys
@@ -37,13 +43,33 @@ import errno
import subprocess
import fcntl
import stat
import string
if len(sys.argv) < 2:
print("error: needs at least one file as argument.")
if len(sys.argv) < 1:
sys.exit(1)
files = sys.argv[1:]
# this is about the same method mpv uses to decide this
def is_url(filename):
parts = filename.split(":", 1)
if len(parts) < 2:
return False
# protocol prefix has no special characters => it's an URL
prefix = parts[0]
for c in prefix:
if string.ascii_letters.find(c) < 0:
return False
return True
# make them absolute; also makes them safe against interpretation as options
files = [os.path.abspath(f) for f in files]
def make_abs(filename):
if not is_url(filename):
return os.path.abspath(filename)
return filename
files = [make_abs(f) for f in files]
opts_env = os.getenv("UMPV_OPTIONS")
opts_env = opts_env.split() if opts_env else []
FIFO = "/tmp/umpv-fifo-" + os.getenv("USER")
@@ -86,6 +112,11 @@ else:
pass
else:
raise e
os.mkfifo(FIFO, 0600)
os.mkfifo(FIFO, int("0600", 8))
subprocess.check_call(["mpv", "--input-file=" + FIFO] + files)
opts = ["mpv", "--no-terminal", "--force-window", "--input-file=" + FIFO]
opts.extend(opts_env)
opts.append("--")
opts.extend(files)
subprocess.check_call(opts)
+2 -2
View File
@@ -32,11 +32,11 @@
/*
* frame stepping filter
*
* usage: -vf dlopen=./framestep.so:5
* usage: --vf=dlopen=/path/to/framestep.so:5
*
* outputs every 5th frame
*
* usage: -vf dlopen=./framestep.so:5:3
* usage: --vf=dlopen=/path/to/framestep.so:5:3
*
* outputs every 5th frame, starting with frame index 3 (default: 0)
*/
+1 -1
View File
@@ -284,7 +284,7 @@ int vf_dlopen_getcontext(struct vf_dlopen_context *ctx, int argc, const char **a
il->tc_decision_threshold = A(10, 0.2);
static struct vf_dlopen_formatpair map[] = {
{ "y8", "y8" },
{ "gray", "gray" },
{ NULL, NULL }
};
ctx->format_mapping = map;
+2 -2
View File
@@ -35,7 +35,7 @@
/*
* rectangle
*
* usage: -vf dlopen=./rectangle.so
* usage: --vf=dlopen=/path/to/rectangle.so
*
* provides an editable rectangle
* NOTE: unix only, and requires xterm to be installed. Don't ask.
@@ -345,7 +345,7 @@ int vf_dlopen_getcontext(struct vf_dlopen_context *ctx, int argc, const char **a
(void) argc;
(void) argv;
static struct vf_dlopen_formatpair map[] = {
{ "yv12", "yv12" },
{ "yuv420p", "yuv420p" },
{ NULL, NULL }
};
privdata *priv = malloc(sizeof(privdata));
+2 -2
View File
@@ -29,7 +29,7 @@
/*
* qscale visualizer
*
* usage: -vf dlopen=./showqscale.so
* usage: --vf=dlopen=/path/to/showqscale.so
*
* uses reddish colors for high QPs, and greenish colors for low QPs
*/
@@ -111,7 +111,7 @@ int vf_dlopen_getcontext(struct vf_dlopen_context *ctx, int argc, const char **a
(void) argc;
(void) argv;
static struct vf_dlopen_formatpair map[] = {
{ "yv12", "yv12" },
{ "yuv420p", "yuv420p" },
{ NULL, NULL }
};
ctx->format_mapping = map;
+1 -1
View File
@@ -32,7 +32,7 @@
/*
* telecine filter
*
* usage: -vf dlopen=./telecine.so:t:23
* usage: --vf=dlopen=/path/to/telecine.so:t:23
*
* Parameter: first parameter is "t" for top field first, "b" for bottom field first
* then digits (0-9) for how many fields a frame is to be displayed
+5 -5
View File
@@ -30,17 +30,17 @@
/*
* tile filter
*
* usage: -vf dlopen=./tile.so:4:3
* usage: --vf=dlopen=/path/to/tile.so:4:3
*
* only supports rgb24 and yv12 for now
* only supports rgb24 and yuv420p for now
* in theory can support any format where rows are a multiple of bytes, and the
* multiple is known
*/
#define ALLFORMATS \
/* format bytes xmul ymul */ \
FORMAT("rgb24", 3, 1, 1) \
FORMAT("yv12", 1, 2, 2)
/* format bytes xmul ymul */ \
FORMAT("rgb24" , 3, 1, 1) \
FORMAT("yuv420p", 1, 2, 2)
typedef struct {
int rows, cols;
+23
View File
@@ -0,0 +1,23 @@
#!/bin/sh
# Example of script for using mpv with youtube-dl
set -e
cookies_dir="$(mktemp -d /tmp/youtube-dl_mpv.XXXX)"
cookies_file="${cookies_dir}/cookies"
user_agent="$(youtube-dl --dump-user-agent)" # or set whatever you want
video_url="$(youtube-dl \
--user-agent="$user_agent" \
--cookies="$cookies_file" \
--get-url \
"$1")"
shift
mpv \
--cookies \
--cookies-file="$cookies_file" \
--user-agent="$user_agent" \
"$@" -- $video_url
rm -rf "$cookies_dir"
Executable
+159
View File
@@ -0,0 +1,159 @@
#!/usr/bin/perl
# Generate ZSH completion
use strict;
use warnings;
my $mpv = $ARGV[0] || 'mpv';
my @opts = parse_opts("$mpv --list-options", '^ (\-\-[^\s\*]*)\*?\s*(.*)', 1);
my @ao = parse_opts("$mpv --ao=help", '^ ([^\s\:]*)\s*: (.*)');
my @vo = parse_opts("$mpv --vo=help", '^ ([^\s\:]*)\s*: (.*)');
my @af = parse_opts("$mpv --af=help", '^ ([^\s\:]*)\s*: (.*)');
my @vf = parse_opts("$mpv --vf=help", '^ ([^\s\:]*)\s*: (.*)');
my @protos = parse_opts("$mpv --list-protocols", '^ ([^\s]*)');
my ($opts_str, $ao_str, $vo_str, $af_str, $vf_str, $protos_str);
$opts_str .= qq{ '$_' \\\n} foreach (@opts);
chomp $opts_str;
$ao_str .= qq{ '$_' \\\n} foreach (@ao);
chomp $ao_str;
$vo_str .= qq{ '$_' \\\n} foreach (@vo);
chomp $vo_str;
$af_str .= qq{ '$_' \\\n} foreach (@af);
chomp $af_str;
$vf_str .= qq{ '$_' \\\n} foreach (@vf);
chomp $vf_str;
$protos_str .= qq{$_ } foreach (@protos);
chomp $protos_str;
my $tmpl = <<"EOS";
#compdef mpv
# mpv zsh completion
local curcontext="\$curcontext" state state_descr line
typeset -A opt_args
local rc=1
_arguments -C -S \\
$opts_str
'*:files:->mfiles' && rc=0
case \$state in
ao)
local -a values
values=(
$ao_str
)
_describe -t values 'audio outputs' values && rc=0
;;
vo)
local -a values
values=(
$vo_str
)
_describe -t values 'video outputs' values && rc=0
;;
af)
local -a values
values=(
$af_str
)
_describe -t values 'audio filters' values && rc=0
;;
vf)
local -a values
values=(
$vf_str
)
_describe -t values 'video filters' values && rc=0
;;
mfiles)
local expl
_tags files urls
while _tags; do
_requested files expl 'media file' _files -g \\
"*.(#i)(asf|asx|avi|flac|flv|m1v|m2p|m2v|m4v|mjpg|mka|mkv|mov|mp3|mp4|mpe|mpeg|mpg|ogg|ogm|ogv|qt|rm|ts|vob|wav|webm|wma|wmv)(-.)" && rc=0
if _requested urls; then
while _next_label urls expl URL; do
_urls "\$expl[@]" && rc=0
compadd -S '' "\$expl[@]" $protos_str && rc=0
done
fi
(( rc )) || return 0
done
;;
esac
return rc
EOS
print $tmpl;
sub parse_opts {
my ($cmd, $regex, $parsing_main_options) = @_;
my @list;
my @lines = split /\n/, `$cmd`;
foreach my $line (@lines) {
if ($line !~ /^$regex/) {
next;
}
my $entry = $1;
if ($parsing_main_options) {
$entry .= '=-';
}
if (defined $2) {
my $desc = $2;
$desc =~ s/\:/\\:/g;
$entry .= ':' . $desc;
}
if ($parsing_main_options) {
$entry .= ':';
$entry .= '->ao' if ($1 eq '--ao');
$entry .= '->vo' if ($1 eq '--vo');
$entry .= '->af' if ($1 eq '--af');
$entry .= '->vf' if ($1 eq '--vf');
}
push @list, $entry
}
if ($parsing_main_options) {
@list = sort {
$a =~ /(.*?)\:/; my $ma = $1;
$b =~ /(.*?)\:/; my $mb = $1;
length($mb) <=> length($ma)
} @list;
}
return @list;
}
+1
View File
@@ -0,0 +1 @@
0.5.1
+13 -3
View File
@@ -15,6 +15,9 @@
* with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <limits.h>
#include <stdlib.h>
#include <assert.h>
#include <libavutil/mem.h>
@@ -28,7 +31,7 @@ static void update_redundant_info(struct mp_audio *mpa)
assert(mp_chmap_is_empty(&mpa->channels) ||
mp_chmap_is_valid(&mpa->channels));
mpa->nch = mpa->channels.num;
mpa->bps = af_fmt2bits(mpa->format) / 8;
mpa->bps = af_fmt2bps(mpa->format);
if (af_fmt_is_planar(mpa->format)) {
mpa->spf = 1;
mpa->num_planes = mpa->nch;
@@ -145,6 +148,8 @@ static void mp_audio_destructor(void *ptr)
void mp_audio_realloc(struct mp_audio *mpa, int samples)
{
assert(samples >= 0);
if (samples >= INT_MAX / mpa->sstride)
abort(); // oom
int size = MPMAX(samples * mpa->sstride, 1);
for (int n = 0; n < mpa->num_planes; n++) {
if (size != mpa->allocated[n]) {
@@ -168,10 +173,15 @@ void mp_audio_realloc(struct mp_audio *mpa, int samples)
}
// Like mp_audio_realloc(), but only reallocate if the audio grows in size.
// If the buffer is reallocated, also preallocate.
void mp_audio_realloc_min(struct mp_audio *mpa, int samples)
{
if (samples > mp_audio_get_allocated_size(mpa))
mp_audio_realloc(mpa, samples);
if (samples > mp_audio_get_allocated_size(mpa)) {
size_t alloc = ta_calc_prealloc_elems(samples);
if (alloc > INT_MAX)
abort(); // oom
mp_audio_realloc(mpa, alloc);
}
}
/* Get the size allocated for the data, in number of samples. If the allocated
+1 -1
View File
@@ -35,7 +35,7 @@ struct mp_audio {
int nch; // number of channels (redundant with chmap)
int spf; // sub-samples per sample on each plane
int num_planes; // number of planes
int bps; // size of sub-samples (af_fmt2bits(format) / 8)
int bps; // size of sub-samples (af_fmt2bps(format))
// private
int allocated[MP_NUM_CHANNELS]; // use mp_audio_get_allocated_size()
+4 -4
View File
@@ -23,7 +23,7 @@
// Names taken from libavutil/channel_layout.c (Not accessible by API.)
// Use of these names is hard-coded in some places (e.g. ao_alsa.c)
static const char *speaker_names[MP_SPEAKER_ID_COUNT][2] = {
static const char *const speaker_names[MP_SPEAKER_ID_COUNT][2] = {
[MP_SPEAKER_ID_FL] = {"fl", "front left"},
[MP_SPEAKER_ID_FR] = {"fr", "front right"},
[MP_SPEAKER_ID_FC] = {"fc", "front center"},
@@ -53,7 +53,7 @@ static const char *speaker_names[MP_SPEAKER_ID_COUNT][2] = {
// Names taken from libavutil/channel_layout.c (Not accessible by API.)
// Channel order corresponds to lavc/waveex, except for the alsa entries.
static const char *std_layout_names[][2] = {
static const char *const std_layout_names[][2] = {
{"empty", ""}, // not in lavc
{"mono", "fc"},
{"stereo", "fl-fr"},
@@ -105,7 +105,7 @@ static const struct mp_chmap default_layouts[MP_NUM_CHANNELS + 1] = {
// channels. 3 and 7 channels were likely undefined (no ALSA support).
// I'm not sure about the 4 channel case: ALSA uses "quad", while the ffmpeg
// default layout is "4.0".
static const char *mplayer_layouts[MP_NUM_CHANNELS + 1] = {
static const char *const mplayer_layouts[MP_NUM_CHANNELS + 1] = {
[1] = "mono",
[2] = "stereo",
[4] = "quad",
@@ -485,5 +485,5 @@ void mp_chmap_print_help(struct mp_log *log)
std_layout_names[n][0], std_layout_names[n][1]);
}
for (int n = 0; n < MP_NUM_CHANNELS; n++)
mp_info(log, " unknown%d\n", n);
mp_info(log, " unknown%d\n", n + 1);
}
+1 -1
View File
@@ -27,7 +27,7 @@
// Speaker a channel can be assigned to.
// This corresponds to WAVEFORMATEXTENSIBLE channel mask bit indexes.
// E.g. channel_mask = (1 << MP_SPEAKER_ID_FL) | ...
enum {
enum mp_speaker_id {
// Official WAVEFORMATEXTENSIBLE (shortened names)
MP_SPEAKER_ID_FL = 0, // FRONT_LEFT
MP_SPEAKER_ID_FR, // FRONT_RIGHT
+21 -16
View File
@@ -18,21 +18,21 @@
#include <stdlib.h>
#include <assert.h>
#include "common/common.h"
#include "chmap_sel.h"
// 5.1 and 5.1(side) are practically the same. It doesn't make much sense to
// reject either of them.
static const int replaceable_speakers[][2] = {
{MP_SPEAKER_ID_SL, MP_SPEAKER_ID_BL},
{MP_SPEAKER_ID_SR, MP_SPEAKER_ID_BR},
{-1},
static const struct mp_chmap speaker_replacements[][2] = {
// 5.1 <-> 5.1 (side)
{ MP_CHMAP2(SL, SR), MP_CHMAP2(BL, BR) },
// 7.1 <-> 7.1 (rear ext)
{ MP_CHMAP2(SL, SR), MP_CHMAP2(SDL, SDR) },
};
// list[] contains a list of speaker pairs, with each pair indicating how
// a speaker can be swapped for another speaker. Try to replace speakers from
// the left of the list with the ones on the right, or the other way around.
static bool replace_speakers(struct mp_chmap *map, const int list[][2])
// Try to replace speakers from the left of the list with the ones on the
// right, or the other way around.
static bool replace_speakers(struct mp_chmap *map, struct mp_chmap list[2])
{
assert(list[0].num == list[1].num);
if (!mp_chmap_is_valid(map))
return false;
for (int dir = 0; dir < 2; dir++) {
@@ -41,9 +41,9 @@ static bool replace_speakers(struct mp_chmap *map, const int list[][2])
bool replaced = false;
struct mp_chmap t = *map;
for (int n = 0; n < t.num; n++) {
for (int i = 0; list[i][0] != -1; i++) {
if (t.speaker[n] == list[i][from]) {
t.speaker[n] = list[i][to];
for (int i = 0; i < list[0].num; i++) {
if (t.speaker[n] == list[from].speaker[i]) {
t.speaker[n] = list[to].speaker[i];
replaced = true;
break;
}
@@ -168,9 +168,14 @@ bool mp_chmap_sel_adjust(const struct mp_chmap_sel *s, struct mp_chmap *map)
return true;
}
}
// 5.1 <-> 5.1(side)
if (replace_speakers(map, replaceable_speakers) && test_layout(s, map))
return true;
for (int i = 0; i < MP_ARRAY_SIZE(speaker_replacements); i++) {
struct mp_chmap t = *map;
struct mp_chmap *r = (struct mp_chmap *)speaker_replacements[i];
if (replace_speakers(&t, r) && test_layout(s, &t)) {
*map = t;
return true;
}
}
// Fallback to mono/stereo as last resort
if (map->num == 1) {
*map = (struct mp_chmap) MP_CHMAP_INIT_MONO;
+1 -1
View File
@@ -36,7 +36,7 @@ struct ad_functions {
int (*init)(struct dec_audio *da, const char *decoder);
void (*uninit)(struct dec_audio *da);
int (*control)(struct dec_audio *da, int cmd, void *arg);
int (*decode_audio)(struct dec_audio *da, struct mp_audio *buffer, int maxlen);
int (*decode_packet)(struct dec_audio *da);
};
enum ad_ctrl {
+55 -100
View File
@@ -33,7 +33,6 @@
#include "common/codecs.h"
#include "common/msg.h"
#include "options/options.h"
#include "common/av_opts.h"
#include "ad.h"
#include "audio/fmt-conversion.h"
@@ -49,16 +48,29 @@ struct priv {
};
static void uninit(struct dec_audio *da);
static int decode_new_packet(struct dec_audio *da);
#define OPT_BASE_STRUCT struct MPOpts
#define OPT_BASE_STRUCT struct ad_lavc_params
struct ad_lavc_params {
float ac3drc;
int downmix;
int threads;
char **avopts;
};
const m_option_t ad_lavc_decode_opts_conf[] = {
OPT_FLOATRANGE("ac3drc", ad_lavc_param.ac3drc, 0, 0, 2),
OPT_FLAG("downmix", ad_lavc_param.downmix, 0),
OPT_INTRANGE("threads", ad_lavc_param.threads, 0, 1, 16),
OPT_STRING("o", ad_lavc_param.avopt, 0),
{0}
const struct m_sub_options ad_lavc_conf = {
.opts = (const m_option_t[]) {
OPT_FLOATRANGE("ac3drc", ac3drc, 0, 0, 2),
OPT_FLAG("downmix", downmix, 0),
OPT_INTRANGE("threads", threads, 0, 1, 16),
OPT_KEYVALUELIST("o", avopts, 0),
{0}
},
.size = sizeof(struct ad_lavc_params),
.defaults = &(const struct ad_lavc_params){
.ac3drc = 1.,
.downmix = 1,
.threads = 1,
},
};
struct pcm_map
@@ -129,11 +141,10 @@ static const char *find_pcm_decoder(const struct pcm_map *map, int format,
return NULL;
}
static int setup_format(struct dec_audio *da)
static void set_data_from_avframe(struct dec_audio *da)
{
struct priv *priv = da->priv;
AVCodecContext *lavc_context = priv->avctx;
struct sh_audio *sh_audio = da->header->audio;
// Note: invalid parameters are rejected by dec_audio.c
@@ -143,12 +154,6 @@ static int setup_format(struct dec_audio *da)
MP_FATAL(da, "unsupported lavc format %s", av_get_sample_fmt_name(fmt));
da->decoded.rate = lavc_context->sample_rate;
if (!da->decoded.rate && sh_audio->wf) {
// If not set, try container samplerate.
// (Maybe this can't happen, and it's an artifact from the past.)
da->decoded.rate = sh_audio->wf->nSamplesPerSec;
MP_WARN(da, "using container rate.\n");
}
struct mp_chmap lavc_chmap;
mp_chmap_from_lavc(&lavc_chmap, lavc_context->channel_layout);
@@ -156,12 +161,15 @@ static int setup_format(struct dec_audio *da)
if (lavc_chmap.num != lavc_context->channels)
mp_chmap_from_channels(&lavc_chmap, lavc_context->channels);
if (priv->force_channel_map) {
struct sh_audio *sh_audio = da->header->audio;
if (lavc_chmap.num == sh_audio->channels.num)
lavc_chmap = sh_audio->channels;
}
mp_audio_set_channels(&da->decoded, &lavc_chmap);
return 0;
da->decoded.samples = priv->avframe->nb_samples;
for (int n = 0; n < da->decoded.num_planes; n++)
da->decoded.planes[n] = priv->avframe->data[n];
}
static void set_from_wf(AVCodecContext *avctx, MP_WAVEFORMATEX *wf)
@@ -172,17 +180,14 @@ static void set_from_wf(AVCodecContext *avctx, MP_WAVEFORMATEX *wf)
avctx->block_align = wf->nBlockAlign;
avctx->bits_per_coded_sample = wf->wBitsPerSample;
if (wf->cbSize > 0) {
avctx->extradata = av_mallocz(wf->cbSize + FF_INPUT_BUFFER_PADDING_SIZE);
avctx->extradata_size = wf->cbSize;
memcpy(avctx->extradata, wf + 1, avctx->extradata_size);
}
if (wf->cbSize > 0)
mp_lavc_set_extradata(avctx, wf + 1, wf->cbSize);
}
static int init(struct dec_audio *da, const char *decoder)
{
struct MPOpts *mpopts = da->opts;
struct ad_lavc_param *opts = &mpopts->ad_lavc_param;
struct ad_lavc_params *opts = mpopts->ad_lavc_params;
AVCodecContext *lavc_context;
AVCodec *lavc_codec;
struct sh_stream *sh = da->header;
@@ -208,34 +213,25 @@ static int init(struct dec_audio *da, const char *decoder)
lavc_context = avcodec_alloc_context3(lavc_codec);
ctx->avctx = lavc_context;
ctx->avframe = avcodec_alloc_frame();
ctx->avframe = av_frame_alloc();
lavc_context->refcounted_frames = 1;
lavc_context->codec_type = AVMEDIA_TYPE_AUDIO;
lavc_context->codec_id = lavc_codec->id;
if (opts->downmix) {
lavc_context->request_channel_layout =
mp_chmap_to_lavc(&mpopts->audio_output_channels);
// Compatibility for Libav 9
av_opt_set_int(lavc_context, "request_channels",
mpopts->audio_output_channels.num,
AV_OPT_SEARCH_CHILDREN);
}
// Always try to set - option only exists for AC3 at the moment
av_opt_set_double(lavc_context, "drc_scale", opts->ac3drc,
AV_OPT_SEARCH_CHILDREN);
if (opts->avopt) {
if (parse_avopts(lavc_context, opts->avopt) < 0) {
MP_ERR(da, "setting AVOptions '%s' failed.\n", opts->avopt);
uninit(da);
return 0;
}
}
mp_set_avopts(da->log, lavc_context, opts->avopts);
lavc_context->codec_tag = sh->format;
lavc_context->sample_rate = sh_audio->samplerate;
lavc_context->bit_rate = sh_audio->i_bps * 8;
lavc_context->bit_rate = sh_audio->bitrate;
lavc_context->channel_layout = mp_chmap_to_lavc(&sh_audio->channels);
if (sh_audio->wf)
@@ -244,11 +240,8 @@ static int init(struct dec_audio *da, const char *decoder)
// demux_mkv, demux_mpg
if (sh_audio->codecdata_len && sh_audio->codecdata &&
!lavc_context->extradata) {
lavc_context->extradata = av_malloc(sh_audio->codecdata_len +
FF_INPUT_BUFFER_PADDING_SIZE);
lavc_context->extradata_size = sh_audio->codecdata_len;
memcpy(lavc_context->extradata, (char *)sh_audio->codecdata,
lavc_context->extradata_size);
mp_lavc_set_extradata(lavc_context, sh_audio->codecdata,
sh_audio->codecdata_len);
}
if (sh->lav_headers)
@@ -262,26 +255,11 @@ static int init(struct dec_audio *da, const char *decoder)
uninit(da);
return 0;
}
MP_VERBOSE(da, "INFO: libavcodec \"%s\" init OK!\n",
lavc_codec->name);
// Decode at least 1 sample: (to get header filled)
for (int tries = 1; ; tries++) {
int x = decode_new_packet(da);
if (x >= 0 && ctx->frame.samples > 0) {
MP_VERBOSE(da, "Initial decode succeeded after %d packets.\n", tries);
break;
}
if (tries >= 50) {
MP_ERR(da, "initial decode failed\n");
uninit(da);
return 0;
}
}
da->i_bps = lavc_context->bit_rate / 8;
if (sh_audio->wf && sh_audio->wf->nAvgBytesPerSec)
da->i_bps = sh_audio->wf->nAvgBytesPerSec;
if (lavc_context->bit_rate != 0)
da->bitrate = lavc_context->bit_rate;
else if (sh_audio->wf && sh_audio->wf->nAvgBytesPerSec)
da->bitrate = sh_audio->wf->nAvgBytesPerSec * 8;
return 1;
}
@@ -299,7 +277,7 @@ static void uninit(struct dec_audio *da)
av_freep(&lavc_context->extradata);
av_freep(&lavc_context);
}
avcodec_free_frame(&ctx->avframe);
av_frame_free(&ctx->avframe);
}
static int control(struct dec_audio *da, int cmd, void *arg)
@@ -308,7 +286,7 @@ static int control(struct dec_audio *da, int cmd, void *arg)
switch (cmd) {
case ADCTRL_RESET:
avcodec_flush_buffers(ctx->avctx);
ctx->frame.samples = 0;
mp_audio_set_null_data(&da->decoded);
talloc_free(ctx->packet);
ctx->packet = NULL;
return CONTROL_TRUE;
@@ -316,16 +294,18 @@ static int control(struct dec_audio *da, int cmd, void *arg)
return CONTROL_UNKNOWN;
}
static int decode_new_packet(struct dec_audio *da)
static int decode_packet(struct dec_audio *da)
{
struct priv *priv = da->priv;
AVCodecContext *avctx = priv->avctx;
priv->frame.samples = 0;
mp_audio_set_null_data(&da->decoded);
struct demux_packet *mpkt = priv->packet;
if (!mpkt)
mpkt = demux_read_packet(da->header);
if (!mpkt) {
if (demux_read_packet_async(da->header, &mpkt) == 0)
return AD_WAIT;
}
priv->packet = talloc_steal(priv, mpkt);
@@ -341,6 +321,7 @@ static int decode_new_packet(struct dec_audio *da)
}
int got_frame = 0;
av_frame_unref(priv->avframe);
int ret = avcodec_decode_audio4(avctx, priv->avframe, &got_frame, &pkt);
if (mpkt) {
// At least "shorten" decodes sub-frames, instead of the whole packet.
@@ -357,22 +338,16 @@ static int decode_new_packet(struct dec_audio *da)
}
// LATM may need many packets to find mux info
if (ret == AVERROR(EAGAIN))
return 0;
return AD_OK;
}
if (ret < 0) {
MP_VERBOSE(da, "lavc_audio: error\n");
return -1;
MP_ERR(da, "Error decoding audio.\n");
return AD_ERR;
}
if (!got_frame)
return mpkt ? 0 : -1; // -1: eof
return mpkt ? AD_OK : AD_EOF;
if (setup_format(da) < 0)
return -1;
priv->frame.samples = priv->avframe->nb_samples;
mp_audio_copy_config(&priv->frame, &da->decoded);
for (int n = 0; n < priv->frame.num_planes; n++)
priv->frame.planes[n] = priv->avframe->data[n];
set_data_from_avframe(da);
double out_pts = mp_pts_from_av(priv->avframe->pkt_pts, NULL);
if (out_pts != MP_NOPTS_VALUE) {
@@ -380,27 +355,7 @@ static int decode_new_packet(struct dec_audio *da)
da->pts_offset = 0;
}
MP_DBG(da, "Decoded %d -> %d samples\n", in_len,
priv->frame.samples);
return 0;
}
static int decode_audio(struct dec_audio *da, struct mp_audio *buffer, int maxlen)
{
struct priv *priv = da->priv;
if (!priv->frame.samples) {
if (decode_new_packet(da) < 0)
return -1;
}
if (!mp_audio_config_equals(buffer, &priv->frame))
return 0;
buffer->samples = MPMIN(priv->frame.samples, maxlen);
mp_audio_copy(buffer, 0, &priv->frame, 0, buffer->samples);
mp_audio_skip_samples(&priv->frame, buffer->samples);
da->pts_offset += buffer->samples;
MP_DBG(da, "Decoded %d -> %d samples\n", in_len, da->decoded.samples);
return 0;
}
@@ -417,5 +372,5 @@ const struct ad_functions ad_lavc = {
.init = init,
.uninit = uninit,
.control = control,
.decode_audio = decode_audio,
.decode_packet = decode_packet,
};
+85 -157
View File
@@ -35,9 +35,7 @@
struct ad_mpg123_context {
mpg123_handle *handle;
bool new_format;
int sample_size;
bool need_data;
/* Running mean for bit rate, stream length estimation. */
float mean_rate;
unsigned int mean_count;
@@ -58,7 +56,7 @@ static void uninit(struct dec_audio *da)
/* This initializes libmpg123 and prepares the handle, including funky
* parameters. */
static int preinit(struct dec_audio *da)
static int init(struct dec_audio *da, const char *decoder)
{
int err;
struct ad_mpg123_context *con;
@@ -111,15 +109,18 @@ static int preinit(struct dec_audio *da)
* We need at least 1152 samples. dec_audio.c normally guarantees this. */
mpg123_param(con->handle, MPG123_REMOVE_FLAGS, MPG123_AUTO_RESAMPLE, 0.);
err = mpg123_open_feed(con->handle);
if (err != MPG123_OK)
goto bad_end;
return 1;
bad_end:
if (!con->handle)
MP_ERR(da, "mpg123 preinit error: %s\n",
mpg123_plain_strerror(err));
else
MP_ERR(da, "mpg123 preinit error: %s\n",
mpg123_strerror(con->handle));
if (!con->handle) {
MP_ERR(da, "mpg123 preinit error: %s\n", mpg123_plain_strerror(err));
} else {
MP_ERR(da, "mpg123 preinit error: %s\n", mpg123_strerror(con->handle));
}
uninit(da);
return 0;
@@ -140,6 +141,51 @@ static int mpg123_format_to_af(int mpg123_encoding)
return 0;
}
/* Compute bitrate from frame size. */
static int compute_bitrate(struct mpg123_frameinfo *i)
{
static const int samples_per_frame[4][4] = {
{-1, 384, 1152, 1152}, /* MPEG 1 */
{-1, 384, 1152, 576}, /* MPEG 2 */
{-1, 384, 1152, 576}, /* MPEG 2.5 */
{-1, -1, -1, -1}, /* Unknown */
};
return (int) ((i->framesize + 4) * 8 * i->rate /
samples_per_frame[i->version][i->layer] + 0.5);
}
/* Update mean bitrate. This could be dropped if accurate time display
* on audio file playback is not desired. */
static void update_info(struct dec_audio *da)
{
struct ad_mpg123_context *con = da->priv;
struct mpg123_frameinfo finfo;
if (mpg123_info(con->handle, &finfo) != MPG123_OK)
return;
/* finfo.bitrate is expressed in kilobits */
const int bitrate = finfo.bitrate * 1000;
if (finfo.vbr != MPG123_CBR) {
if (--con->delay < 1) {
if (++con->mean_count > ((unsigned int) -1) / 2)
con->mean_count = ((unsigned int) -1) / 4;
/* Might not be numerically optimal, but works fine enough. */
con->mean_rate = ((con->mean_count - 1) * con->mean_rate +
bitrate) / con->mean_count;
da->bitrate = (int) (con->mean_rate + 0.5);
con->delay = 10;
}
} else {
da->bitrate = bitrate ? bitrate : compute_bitrate(&finfo);
con->delay = 1;
con->mean_rate = 0.;
con->mean_count = 0;
}
}
/* libmpg123 has a new format ready; query and store, return return value
of mpg123_getformat() */
static int set_format(struct dec_audio *da)
@@ -160,20 +206,23 @@ static int set_format(struct dec_audio *da)
return MPG123_ERR;
}
mp_audio_set_format(&da->decoded, af);
con->sample_size = channels * (af_fmt2bits(af) / 8);
con->new_format = 0;
con->sample_size = channels * af_fmt2bps(af);
}
return ret;
}
static int feed_new_packet(struct dec_audio *da)
static int decode_packet(struct dec_audio *da)
{
struct ad_mpg123_context *con = da->priv;
int ret;
struct demux_packet *pkt = demux_read_packet(da->header);
mp_audio_set_null_data(&da->decoded);
struct demux_packet *pkt;
if (demux_read_packet_async(da->header, &pkt) == 0)
return AD_WAIT;
if (!pkt)
return -1; /* EOF. */
return AD_EOF;
/* Next bytes from that presentation time. */
if (pkt->pts != MP_NOPTS_VALUE) {
@@ -185,160 +234,38 @@ static int feed_new_packet(struct dec_audio *da)
ret = mpg123_feed(con->handle, pkt->buffer, pkt->len);
talloc_free(pkt);
if (ret == MPG123_ERR)
return -1;
if (ret == MPG123_NEW_FORMAT)
con->new_format = 1;
return 0;
}
/* Now we really start accessing some data and determining file format.
* Format now is allowed to change on-the-fly. Here is the only point
* that has MPlayer react to errors. We have to pray that exceptional
* erros in other places simply cannot occur. */
static int init(struct dec_audio *da, const char *decoder)
{
if (!preinit(da))
return 0;
struct ad_mpg123_context *con = da->priv;
int ret;
ret = mpg123_open_feed(con->handle);
if (ret != MPG123_OK)
goto fail;
for (int n = 0; ; n++) {
if (feed_new_packet(da) < 0) {
ret = MPG123_NEED_MORE;
goto fail;
}
size_t got_now = 0;
ret = mpg123_decode_frame(con->handle, NULL, NULL, &got_now);
if (ret == MPG123_OK || ret == MPG123_NEW_FORMAT) {
ret = set_format(da);
if (ret == MPG123_OK)
break;
}
if (ret != MPG123_NEED_MORE)
goto fail;
// max. 16 retries (randomly chosen number)
if (n > 16) {
ret = MPG123_NEED_MORE;
goto fail;
}
}
return 1;
fail:
if (ret == MPG123_NEED_MORE) {
MP_ERR(da, "Could not find mp3 stream.\n");
} else {
MP_ERR(da, "mpg123 init error: %s\n",
mpg123_strerror(con->handle));
}
uninit(da);
return 0;
}
/* Compute bitrate from frame size. */
static int compute_bitrate(struct mpg123_frameinfo *i)
{
static const int samples_per_frame[4][4] = {
{-1, 384, 1152, 1152}, /* MPEG 1 */
{-1, 384, 1152, 576}, /* MPEG 2 */
{-1, 384, 1152, 576}, /* MPEG 2.5 */
{-1, -1, -1, -1}, /* Unknown */
};
return (int) ((i->framesize + 4) * 8 * i->rate * 0.001 /
samples_per_frame[i->version][i->layer] + 0.5);
}
/* Update mean bitrate. This could be dropped if accurate time display
* on audio file playback is not desired. */
static void update_info(struct dec_audio *da)
{
struct ad_mpg123_context *con = da->priv;
struct mpg123_frameinfo finfo;
if (mpg123_info(con->handle, &finfo) != MPG123_OK)
return;
if (finfo.vbr != MPG123_CBR) {
if (--con->delay < 1) {
if (++con->mean_count > ((unsigned int) -1) / 2)
con->mean_count = ((unsigned int) -1) / 4;
/* Might not be numerically optimal, but works fine enough. */
con->mean_rate = ((con->mean_count - 1) * con->mean_rate +
finfo.bitrate) / con->mean_count;
da->i_bps = (int) (con->mean_rate * 1000 / 8);
con->delay = 10;
}
} else {
da->i_bps = (finfo.bitrate ? finfo.bitrate : compute_bitrate(&finfo))
* 1000 / 8;
con->delay = 1;
con->mean_rate = 0.;
con->mean_count = 0;
}
}
static int decode_audio(struct dec_audio *da, struct mp_audio *buffer, int maxlen)
{
struct ad_mpg123_context *con = da->priv;
void *buf = buffer->planes[0];
int ret;
if (con->new_format) {
ret = set_format(da);
if (ret == MPG123_OK) {
return 0; // let caller handle format change
} else if (ret == MPG123_NEED_MORE) {
con->need_data = true;
} else {
goto mpg123_fail;
}
}
if (con->need_data) {
if (feed_new_packet(da) < 0)
return -1;
}
if (!mp_audio_config_equals(&da->decoded, buffer))
return 0;
size_t got_now = 0;
ret = mpg123_replace_buffer(con->handle, buf, maxlen * con->sample_size);
if (ret != MPG123_OK)
goto mpg123_fail;
ret = mpg123_decode_frame(con->handle, NULL, NULL, &got_now);
unsigned char *audio = NULL;
size_t bytes = 0;
ret = mpg123_decode_frame(con->handle, NULL, &audio, &bytes);
int got_samples = got_now / con->sample_size;
buffer->samples += got_samples;
da->pts_offset += got_samples;
if (ret == MPG123_NEED_MORE)
return 0;
if (ret == MPG123_NEW_FORMAT) {
con->new_format = true;
} else if (ret == MPG123_NEED_MORE) {
con->need_data = true;
} else if (ret != MPG123_OK && ret != MPG123_DONE) {
if (ret != MPG123_OK && ret != MPG123_DONE && ret != MPG123_NEW_FORMAT)
goto mpg123_fail;
ret = set_format(da);
if (ret != MPG123_OK)
goto mpg123_fail;
if (con->sample_size < 1) {
MP_ERR(da, "no sample size\n");
return AD_ERR;
}
int got_samples = bytes / con->sample_size;
da->decoded.planes[0] = audio;
da->decoded.samples = got_samples;
update_info(da);
return 0;
mpg123_fail:
MP_ERR(da, "mpg123 decoding error: %s\n",
mpg123_strerror(con->handle));
return -1;
MP_ERR(da, "mpg123 decoding error: %s\n", mpg123_strerror(con->handle));
return AD_ERR;
}
static int control(struct dec_audio *da, int cmd, void *arg)
@@ -347,6 +274,7 @@ static int control(struct dec_audio *da, int cmd, void *arg)
switch (cmd) {
case ADCTRL_RESET:
mp_audio_set_null_data(&da->decoded);
mpg123_close(con->handle);
if (mpg123_open_feed(con->handle) != MPG123_OK) {
@@ -371,5 +299,5 @@ const struct ad_functions ad_mpg123 = {
.init = init,
.uninit = uninit,
.control = control,
.decode_audio = decode_audio,
.decode_packet = decode_packet,
};
+15 -18
View File
@@ -38,8 +38,7 @@ struct spdifContext {
AVFormatContext *lavf_ctx;
int iec61937_packet_size;
int out_buffer_len;
int out_buffer_size;
uint8_t *out_buffer;
uint8_t out_buffer[OUTBUF_SIZE];
bool need_close;
};
@@ -47,7 +46,7 @@ static int write_packet(void *p, uint8_t *buf, int buf_size)
{
struct spdifContext *ctx = p;
int buffer_left = ctx->out_buffer_size - ctx->out_buffer_len;
int buffer_left = OUTBUF_SIZE - ctx->out_buffer_len;
if (buf_size > buffer_left) {
MP_ERR(ctx, "spdif packet too large.\n");
buf_size = buffer_left;
@@ -183,24 +182,21 @@ fail:
return 0;
}
static int decode_audio(struct dec_audio *da, struct mp_audio *buffer, int maxlen)
static int decode_packet(struct dec_audio *da)
{
struct spdifContext *spdif_ctx = da->priv;
AVFormatContext *lavf_ctx = spdif_ctx->lavf_ctx;
int sstride = 2 * da->decoded.channels.num;
assert(sstride == buffer->sstride);
if (maxlen * sstride < spdif_ctx->iec61937_packet_size)
return 0;
mp_audio_set_null_data(&da->decoded);
spdif_ctx->out_buffer_len = 0;
spdif_ctx->out_buffer_size = maxlen * sstride;
spdif_ctx->out_buffer = buffer->planes[0];
struct demux_packet *mpkt = demux_read_packet(da->header);
struct demux_packet *mpkt;
if (demux_read_packet_async(da->header, &mpkt) == 0)
return AD_WAIT;
if (!mpkt)
return -1;
return AD_EOF;
AVPacket pkt;
mp_set_av_packet(&pkt, mpkt, NULL);
@@ -211,12 +207,13 @@ static int decode_audio(struct dec_audio *da, struct mp_audio *buffer, int maxle
da->pts_offset = 0;
}
int ret = av_write_frame(lavf_ctx, &pkt);
avio_flush(lavf_ctx->pb);
buffer->samples = spdif_ctx->out_buffer_len / sstride;
da->pts_offset += buffer->samples;
talloc_free(mpkt);
avio_flush(lavf_ctx->pb);
if (ret < 0)
return -1;
return AD_ERR;
da->decoded.planes[0] = spdif_ctx->out_buffer;
da->decoded.samples = spdif_ctx->out_buffer_len / da->decoded.sstride;
return 0;
}
@@ -253,5 +250,5 @@ const struct ad_functions ad_spdif = {
.init = init,
.uninit = uninit,
.control = control,
.decode_audio = decode_audio,
.decode_packet = decode_packet,
};
+63 -59
View File
@@ -56,13 +56,6 @@ static const struct ad_functions * const ad_drivers[] = {
NULL
};
// ad_mpg123 needs to be able to decode 1152 samples at once
// ad_spdif needs up to 8192
#define DECODE_MAX_UNIT MPMAX(8192, 1152)
// At least 8192 samples, plus hack for ad_mpg123 and ad_spdif
#define DECODE_BUFFER_SAMPLES (8192 + DECODE_MAX_UNIT)
// Drop audio buffer and reinit it (after format change)
// Returns whether the format was valid at all.
static bool reinit_audio_buffer(struct dec_audio *da)
@@ -73,7 +66,6 @@ static bool reinit_audio_buffer(struct dec_audio *da)
return false;
}
mp_audio_buffer_reinit(da->decode_buffer, &da->decoded);
mp_audio_buffer_preallocate_min(da->decode_buffer, DECODE_BUFFER_SAMPLES);
return true;
}
@@ -98,11 +90,6 @@ static int init_audio_codec(struct dec_audio *d_audio, const char *decoder)
}
d_audio->decode_buffer = mp_audio_buffer_create(NULL);
if (!reinit_audio_buffer(d_audio)) {
uninit_decoder(d_audio);
return 0;
}
return 1;
}
@@ -163,14 +150,7 @@ int audio_init_best_codec(struct dec_audio *d_audio, char *audio_decoders)
d_audio->decoder_desc =
talloc_asprintf(d_audio, "%s [%s:%s]", decoder->desc, decoder->family,
decoder->decoder);
MP_INFO(d_audio, "Selected audio codec: %s\n",
d_audio->decoder_desc);
MP_VERBOSE(d_audio, "AUDIO: %d Hz, %d ch, %s\n",
d_audio->decoded.rate, d_audio->decoded.channels.num,
af_fmt_to_str(d_audio->decoded.format));
MP_SMODE(d_audio, "ID_AUDIO_BITRATE=%d\nID_AUDIO_RATE=%d\n" "ID_AUDIO_NCH=%d\n",
d_audio->i_bps * 8, d_audio->decoded.rate,
d_audio->decoded.channels.num);
MP_VERBOSE(d_audio, "Selected audio codec: %s\n", d_audio->decoder_desc);
} else {
MP_ERR(d_audio, "Failed to initialize an audio decoder for codec '%s'.\n",
d_audio->header->codec ? d_audio->header->codec : "<unknown>");
@@ -213,6 +193,8 @@ int audio_init_filters(struct dec_audio *d_audio, int in_samplerate,
mp_audio_set_channels(&afs->output, out_channels);
mp_audio_set_format(&afs->output, *out_format);
afs->replaygain_data = d_audio->replaygain_data;
char *s_from = mp_audio_config_to_str(&afs->input);
char *s_to = mp_audio_config_to_str(&afs->output);
MP_VERBOSE(d_audio, "Building audio filter chain for %s -> %s...\n", s_from, s_to);
@@ -233,61 +215,82 @@ int audio_init_filters(struct dec_audio *d_audio, int in_samplerate,
return 1;
}
/* Decode packets until we know the audio format. Then reinit the buffer.
* Returns AD_OK on success, negative AD_* code otherwise.
* Also returns AD_OK if already initialized (and does nothing).
*/
int initial_audio_decode(struct dec_audio *da)
{
while (!mp_audio_config_valid(&da->decoded)) {
if (da->decoded.samples > 0)
return AD_ERR; // invalid format, rather than uninitialized
int ret = da->ad_driver->decode_packet(da);
if (ret < 0)
return ret;
}
if (mp_audio_buffer_samples(da->decode_buffer) > 0) // avoid accidental flush
return AD_OK;
return reinit_audio_buffer(da) ? AD_OK : AD_ERR;
}
// Filter len bytes of input, put result into outbuf.
static int filter_n_bytes(struct dec_audio *da, struct mp_audio_buffer *outbuf,
int len)
{
bool format_change = false;
int error = 0;
struct mp_audio config;
mp_audio_buffer_get_format(da->decode_buffer, &config);
assert(len > 0); // would break EOF logic below
while (mp_audio_buffer_samples(da->decode_buffer) < len) {
int maxlen = mp_audio_buffer_get_write_available(da->decode_buffer);
if (maxlen < DECODE_MAX_UNIT)
break;
struct mp_audio buffer;
mp_audio_buffer_get_write_buffer(da->decode_buffer, maxlen, &buffer);
buffer.samples = 0;
error = da->ad_driver->decode_audio(da, &buffer, maxlen);
if (error < 0)
break;
// Commit the data just read as valid data
mp_audio_buffer_finish_write(da->decode_buffer, buffer.samples);
// Format change
if (!mp_audio_config_equals(&da->decoded, &config)) {
// If there are still samples left in the buffer, let them drain
// first, and don't signal a format change to the caller yet.
if (mp_audio_buffer_samples(da->decode_buffer) > 0)
break;
error = -2;
// Check for a format change
struct mp_audio config;
mp_audio_buffer_get_format(da->decode_buffer, &config);
format_change = !mp_audio_config_equals(&da->decoded, &config);
if (format_change) {
error = AD_EOF; // drain remaining data left in the current buffer
break;
}
if (da->decoded.samples > 0) {
int copy = MPMIN(da->decoded.samples, len);
struct mp_audio append = da->decoded;
append.samples = copy;
mp_audio_buffer_append(da->decode_buffer, &append);
mp_audio_skip_samples(&da->decoded, copy);
da->pts_offset += copy;
continue;
}
error = da->ad_driver->decode_packet(da);
if (error < 0)
break;
}
if (error == AD_WAIT)
return error;
// Filter
struct mp_audio filter_data;
mp_audio_buffer_peek(da->decode_buffer, &filter_data);
filter_data.rate = da->afilter->input.rate; // due to playback speed change
len = MPMIN(filter_data.samples, len);
filter_data.samples = len;
bool eof = filter_data.samples == 0 && error < 0;
bool eof = error == AD_EOF && filter_data.samples == 0;
if (af_filter(da->afilter, &filter_data, eof ? AF_FILTER_FLAG_EOF : 0) < 0)
return -1;
return AD_ERR;
mp_audio_buffer_append(outbuf, &filter_data);
if (eof && filter_data.samples > 0)
if (error == AD_EOF && filter_data.samples > 0)
error = 0; // don't end playback yet
// remove processed data from decoder buffer:
mp_audio_buffer_skip(da->decode_buffer, len);
// Assume the filter chain is drained from old data at this point.
// (If not, the remaining old data is discarded.)
if (error == -2) {
// if format was changed, and all data was drained, execute the format change
if (format_change && eof) {
error = AD_NEW_FMT;
if (!reinit_audio_buffer(da))
error = -1; // switch to invalid format
error = AD_ERR; // switch to invalid format
}
return error;
@@ -295,17 +298,17 @@ static int filter_n_bytes(struct dec_audio *da, struct mp_audio_buffer *outbuf,
/* Try to get at least minsamples decoded+filtered samples in outbuf
* (total length including possible existing data).
* Return 0 on success, -1 on error/EOF (not distinguidaed).
* Return 0 on success, or negative AD_* error code.
* In the former case outbuf has at least minsamples buffered on return.
* In case of EOF/error it might or might not be. */
int audio_decode(struct dec_audio *d_audio, struct mp_audio_buffer *outbuf,
int minsamples)
{
if (!d_audio->afilter)
return AD_ERR;
// Indicates that a filter seems to be buffering large amounts of data
int huge_filter_buffer = 0;
// Decoded audio must be cut at boundaries of this many samples
// (Note: the reason for this is unknown, possibly a refactoring artifact)
int unitsize = 16;
/* Filter output size will be about filter_multiplier times input size.
* If some filter buffers audio in big blocks this might only hold
@@ -313,15 +316,17 @@ int audio_decode(struct dec_audio *d_audio, struct mp_audio_buffer *outbuf,
double filter_multiplier = af_calc_filter_multiplier(d_audio->afilter);
int prev_buffered = -1;
while (minsamples >= 0) {
int res = 0;
MP_STATS(d_audio, "start audio");
while (res >= 0 && minsamples >= 0) {
int buffered = mp_audio_buffer_samples(outbuf);
if (minsamples < buffered || buffered == prev_buffered)
break;
prev_buffered = buffered;
int decsamples = (minsamples - buffered) / filter_multiplier;
// + some extra for possible filter buffering
decsamples += unitsize << 5;
// + some extra for possible filter buffering, and avoid 0
decsamples += 512;
if (huge_filter_buffer) {
/* Some filter must be doing significant buffering if the estimated
@@ -339,11 +344,10 @@ int audio_decode(struct dec_audio *d_audio, struct mp_audio_buffer *outbuf,
* of buffering in filters */
huge_filter_buffer = 1;
int res = filter_n_bytes(d_audio, outbuf, decsamples);
if (res < 0)
return res;
res = filter_n_bytes(d_audio, outbuf, decsamples);
}
return 0;
MP_STATS(d_audio, "end audio");
return res;
}
void audio_reset_decoding(struct dec_audio *d_audio)
+14 -4
View File
@@ -21,6 +21,7 @@
#include "audio/chmap.h"
#include "audio/audio.h"
#include "demux/demux.h"
#include "demux/stheader.h"
struct mp_audio_buffer;
@@ -35,11 +36,11 @@ struct dec_audio {
struct mp_audio_buffer *decode_buffer;
struct af_stream *afilter;
char *decoder_desc;
struct replaygain_data *replaygain_data;
int init_retries;
// set by decoder
struct mp_audio decoded; // format of decoded audio (no data, temporarily
// different from decode_buffer during format
// changes)
int i_bps; // input bitrate, can change with VBR sources
struct mp_audio decoded; // decoded audio set by last decode_packet() call
int bitrate; // input bitrate, can change with VBR sources
// last known pts value in output from decoder
double pts;
// number of samples output by decoder after last known pts
@@ -48,10 +49,19 @@ struct dec_audio {
void *priv;
};
enum {
AD_OK = 0,
AD_ERR = -1,
AD_EOF = -2,
AD_NEW_FMT = -3,
AD_WAIT = -4,
};
struct mp_decoder_list *audio_decoder_list(void);
int audio_init_best_codec(struct dec_audio *d_audio, char *audio_decoders);
int audio_decode(struct dec_audio *d_audio, struct mp_audio_buffer *outbuf,
int minsamples);
int initial_audio_decode(struct dec_audio *d_audio);
void audio_reset_decoding(struct dec_audio *d_audio);
void audio_uninit(struct dec_audio *d_audio);
+56 -55
View File
@@ -31,34 +31,34 @@
#include "af.h"
// Static list of filters
extern struct af_info af_info_dummy;
extern struct af_info af_info_delay;
extern struct af_info af_info_channels;
extern struct af_info af_info_format;
extern struct af_info af_info_force;
extern struct af_info af_info_volume;
extern struct af_info af_info_equalizer;
extern struct af_info af_info_pan;
extern struct af_info af_info_surround;
extern struct af_info af_info_sub;
extern struct af_info af_info_export;
extern struct af_info af_info_drc;
extern struct af_info af_info_extrastereo;
extern struct af_info af_info_lavcac3enc;
extern struct af_info af_info_lavrresample;
extern struct af_info af_info_sweep;
extern struct af_info af_info_hrtf;
extern struct af_info af_info_ladspa;
extern struct af_info af_info_center;
extern struct af_info af_info_sinesuppress;
extern struct af_info af_info_karaoke;
extern struct af_info af_info_scaletempo;
extern struct af_info af_info_bs2b;
extern struct af_info af_info_lavfi;
extern struct af_info af_info_convert24;
extern struct af_info af_info_convertsignendian;
extern const struct af_info af_info_dummy;
extern const struct af_info af_info_delay;
extern const struct af_info af_info_channels;
extern const struct af_info af_info_format;
extern const struct af_info af_info_force;
extern const struct af_info af_info_volume;
extern const struct af_info af_info_equalizer;
extern const struct af_info af_info_pan;
extern const struct af_info af_info_surround;
extern const struct af_info af_info_sub;
extern const struct af_info af_info_export;
extern const struct af_info af_info_drc;
extern const struct af_info af_info_extrastereo;
extern const struct af_info af_info_lavcac3enc;
extern const struct af_info af_info_lavrresample;
extern const struct af_info af_info_sweep;
extern const struct af_info af_info_hrtf;
extern const struct af_info af_info_ladspa;
extern const struct af_info af_info_center;
extern const struct af_info af_info_sinesuppress;
extern const struct af_info af_info_karaoke;
extern const struct af_info af_info_scaletempo;
extern const struct af_info af_info_bs2b;
extern const struct af_info af_info_lavfi;
extern const struct af_info af_info_convert24;
extern const struct af_info af_info_convertsignendian;
static struct af_info* filter_list[] = {
static const struct af_info *const filter_list[] = {
&af_info_dummy,
&af_info_delay,
&af_info_channels,
@@ -87,7 +87,7 @@ static struct af_info* filter_list[] = {
#if HAVE_LIBBS2B
&af_info_bs2b,
#endif
#if HAVE_AF_LAVFI
#if HAVE_LIBAVFILTER
&af_info_lavfi,
#endif
// Must come last, because they're fallback format conversion filter
@@ -204,6 +204,7 @@ static struct af_instance *af_create(struct af_stream *s, char *name,
.mul = 1,
.data = talloc_zero(af, struct mp_audio),
.log = mp_log_new(af, s->log, name),
.replaygain_data = s->replaygain_data,
};
struct m_config *config = m_config_from_obj_desc(af, s->log, &desc);
if (m_config_apply_defaults(config, name, s->opts->af_defs) < 0)
@@ -309,22 +310,22 @@ static void af_print_filter_chain(struct af_stream *s, struct af_instance *at,
struct af_instance *af = s->first;
while (af) {
MP_MSG(s, msg_level, " [%s] ", af->info->name);
char b[128] = {0};
mp_snprintf_cat(b, sizeof(b), " [%s] ", af->info->name);
if (af->data) {
char *info = mp_audio_config_to_str(af->data);
MP_MSG(s, msg_level, "%s", info);
mp_snprintf_cat(b, sizeof(b), "%s", info);
talloc_free(info);
}
if (af == at)
MP_MSG(s, msg_level, " <-");
MP_MSG(s, msg_level, "\n");
mp_snprintf_cat(b, sizeof(b), " <-");
MP_MSG(s, msg_level, "%s\n", b);
af = af->next;
}
MP_MSG(s, msg_level, " [ao] ");
char *info = mp_audio_config_to_str(&s->output);
MP_MSG(s, msg_level, "%s\n", info);
MP_MSG(s, msg_level, " [ao] %s\n", info);
talloc_free(info);
}
@@ -345,26 +346,28 @@ static int af_count_filters(struct af_stream *s)
// (So we know what conversion filter with what format to insert next.)
static char *af_find_conversion_filter(int srcfmt, int *dstfmt)
{
#define NUM_FMT 64
#define NUM_FILT 32
#define NUM_NODES (NUM_FMT * NUM_FILT)
#define MAX_NODES (64 * 32)
int num_fmt = 0, num_filt = 0;
for (int n = 0; filter_list[n]; n++)
assert(n < NUM_FILT);
num_filt = n + 1;
for (int n = 0; af_fmtstr_table[n].format; n++)
assert(n < NUM_FMT);
num_fmt = n + 1;
bool visited[NUM_NODES] = {0};
unsigned char distance[NUM_NODES];
short previous[NUM_NODES] = {0};
for (int n = 0; n < NUM_NODES; n++) {
int num_nodes = num_fmt * num_filt;
assert(num_nodes < MAX_NODES);
bool visited[MAX_NODES] = {0};
unsigned char distance[MAX_NODES];
short previous[MAX_NODES] = {0};
for (int n = 0; n < num_nodes; n++) {
distance[n] = 255;
if (af_fmtstr_table[n % NUM_FMT].format == srcfmt)
if (af_fmtstr_table[n % num_fmt].format == srcfmt)
distance[n] = 0;
}
while (1) {
int next = -1;
for (int n = 0; n < NUM_NODES; n++) {
for (int n = 0; n < num_nodes; n++) {
if (!visited[n] && (next < 0 || (distance[n] < distance[next])))
next = n;
}
@@ -372,27 +375,27 @@ static char *af_find_conversion_filter(int srcfmt, int *dstfmt)
return NULL;
visited[next] = true;
int fmt = next % NUM_FMT;
int fmt = next % num_fmt;
if (af_fmtstr_table[fmt].format == *dstfmt) {
// Best match found
for (int cur = next; cur >= 0; cur = previous[cur] - 1) {
if (distance[cur] == 1) {
*dstfmt = af_fmtstr_table[cur % NUM_FMT].format;
return (char *)filter_list[cur / NUM_FMT]->name;
*dstfmt = af_fmtstr_table[cur % num_fmt].format;
return (char *)filter_list[cur / num_fmt]->name;
}
}
return NULL;
}
for (int n = 0; filter_list[n]; n++) {
struct af_info *af = filter_list[n];
const struct af_info *af = filter_list[n];
if (!af->test_conversion)
continue;
for (int i = 0; af_fmtstr_table[i].format; i++) {
if (i != fmt && af->test_conversion(af_fmtstr_table[fmt].format,
af_fmtstr_table[i].format))
{
int other = n * NUM_FMT + i;
int other = n * num_fmt + i;
int ndist = distance[next] + 1;
if (ndist < distance[other]) {
distance[other] = ndist;
@@ -403,9 +406,7 @@ static char *af_find_conversion_filter(int srcfmt, int *dstfmt)
}
}
assert(0);
#undef NUM_FMT
#undef NUM_FILT
#undef NODE_N
#undef MAX_NODES
}
static bool af_is_conversion_filter(struct af_instance *af)
@@ -587,7 +588,7 @@ void af_uninit(struct af_stream *s)
struct af_stream *af_new(struct mpv_global *global)
{
struct af_stream *s = talloc_zero(NULL, struct af_stream);
static struct af_info in = { .name = "in" };
static const struct af_info in = { .name = "in" };
s->first = talloc(s, struct af_instance);
*s->first = (struct af_instance) {
.info = &in,
@@ -597,7 +598,7 @@ struct af_stream *af_new(struct mpv_global *global)
.data = &s->input,
.mul = 1.0,
};
static struct af_info out = { .name = "out" };
static const struct af_info out = { .name = "out" };
s->last = talloc(s, struct af_instance);
*s->last = (struct af_instance) {
.info = &out,
+2
View File
@@ -59,6 +59,7 @@ struct af_info {
struct af_instance {
const struct af_info *info;
struct mp_log *log;
struct replaygain_data *replaygain_data;
int (*control)(struct af_instance *af, int cmd, void *arg);
void (*uninit)(struct af_instance *af);
/* flags is a bit mask of AF_FILTER_FLAG_* values
@@ -90,6 +91,7 @@ struct af_stream {
struct mp_log *log;
struct MPOpts *opts;
struct replaygain_data *replaygain_data;
};
// Return values
+4 -4
View File
@@ -142,12 +142,12 @@ static int control(struct af_instance *af, int cmd, void *arg)
// bs2b have srate limits, try to resample if needed
if (af->data->rate > BS2B_MAXSRATE || af->data->rate < BS2B_MINSRATE) {
af->data->rate = BS2B_DEFAULT_SRATE;
MP_WARN(af, "[bs2b] Requested sample rate %d Hz is out of bounds [%d..%d] Hz.\n"
"[bs2b] Trying to resample to %d Hz.\n",
MP_WARN(af, "Requested sample rate %d Hz is out of bounds [%d..%d] Hz.\n"
"Trying to resample to %d Hz.\n",
af->data->rate, BS2B_MINSRATE, BS2B_MAXSRATE, BS2B_DEFAULT_SRATE);
}
bs2b_set_srate(s->filter, (long)af->data->rate);
MP_VERBOSE(af, "[bs2b] using format %s\n",
MP_VERBOSE(af, "using format %s\n",
af_fmt_to_str(af->data->format));
return af_test_output(af,(struct mp_audio*)arg);
@@ -189,7 +189,7 @@ static int af_open(struct af_instance *af)
#define OPT_BASE_STRUCT struct af_bs2b
/// Description of this filter
struct af_info af_info_bs2b = {
const struct af_info af_info_bs2b = {
.info = "Bauer stereophonic-to-binaural audio filter",
.name = "bs2b",
.open = af_open,
+7 -7
View File
@@ -35,7 +35,7 @@
// Data for specific instances of this filter
typedef struct af_center_s
{
int ch; // Channel number which to insert the filtered data
int ch; // Channel number which to insert the filtered data
}af_center_t;
// Initialization and runtime control
@@ -61,12 +61,12 @@ static int control(struct af_instance* af, int cmd, void* arg)
// Filter data through filter
static int filter(struct af_instance* af, struct mp_audio* data, int flags)
{
struct mp_audio* c = data; // Current working data
struct mp_audio* c = data; // Current working data
af_center_t* s = af->priv; // Setup for this instance
float* a = c->planes[0]; // Audio data
int nch = c->nch; // Number of channels
int len = c->samples*c->nch; // Number of samples in current audio block
int ch = s->ch; // Channel in which to insert the center audio
float* a = c->planes[0]; // Audio data
int nch = c->nch; // Number of channels
int len = c->samples*c->nch; // Number of samples in current audio block
int ch = s->ch; // Channel in which to insert the center audio
register int i;
// Run filter
@@ -86,7 +86,7 @@ static int af_open(struct af_instance* af){
}
#define OPT_BASE_STRUCT af_center_t
struct af_info af_info_center = {
const struct af_info af_info_center = {
.info = "Audio filter for adding a center channel",
.name = "center",
.flags = AF_FLAGS_NOT_REENTRANT,
+22 -22
View File
@@ -114,7 +114,7 @@ static void copy(struct af_instance *af, void* in, void* out,
}
default:
MP_ERR(af, "Unsupported number of bytes/sample: %i"
" please report this error on the MPlayer mailing list. \n",bps);
" please report this error on the MPlayer mailing list. \n",bps);
}
}
@@ -124,14 +124,14 @@ static int check_routes(struct af_instance *af, int nin, int nout)
af_channels_t* s = af->priv;
int i;
if((s->nr < 1) || (s->nr > AF_NCH)){
MP_ERR(af, "[channels] The number of routing pairs must be"
" between 1 and %i. Current value is %i\n",AF_NCH,s->nr);
MP_ERR(af, "The number of routing pairs must be"
" between 1 and %i. Current value is %i\n",AF_NCH,s->nr);
return AF_ERROR;
}
for(i=0;i<s->nr;i++){
if((s->route[i][FR] >= nin) || (s->route[i][TO] >= nout)){
MP_ERR(af, "[channels] Invalid routing in pair nr. %i.\n", i);
MP_ERR(af, "Invalid routing in pair nr. %i.\n", i);
return AF_ERROR;
}
}
@@ -154,22 +154,22 @@ static int control(struct af_instance* af, int cmd, void* arg)
int i;
// Make sure this filter isn't redundant
if(af->data->nch == ((struct mp_audio*)arg)->nch)
return AF_DETACH;
return AF_DETACH;
// If mono: fake stereo
if(((struct mp_audio*)arg)->nch == 1){
s->nr = MPMIN(af->data->nch,2);
for(i=0;i<s->nr;i++){
s->route[i][FR] = 0;
s->route[i][TO] = i;
}
s->nr = MPMIN(af->data->nch,2);
for(i=0;i<s->nr;i++){
s->route[i][FR] = 0;
s->route[i][TO] = i;
}
}
else{
s->nr = MPMIN(af->data->nch, ((struct mp_audio*)arg)->nch);
for(i=0;i<s->nr;i++){
s->route[i][FR] = i;
s->route[i][TO] = i;
}
s->nr = MPMIN(af->data->nch, ((struct mp_audio*)arg)->nch);
for(i=0;i<s->nr;i++){
s->route[i][FR] = i;
s->route[i][TO] = i;
}
}
}
@@ -184,10 +184,10 @@ static int control(struct af_instance* af, int cmd, void* arg)
// Filter data through filter
static int filter(struct af_instance* af, struct mp_audio* data, int flags)
{
struct mp_audio* c = data; // Current working data
struct mp_audio* l = af->data; // Local data
struct mp_audio* c = data; // Current working data
struct mp_audio* l = af->data; // Local data
af_channels_t* s = af->priv;
int i;
int i;
mp_audio_realloc_min(af->data, data->samples);
@@ -197,7 +197,7 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags)
if(AF_OK == check_routes(af,c->nch,l->nch))
for(i=0;i<s->nr;i++)
copy(af, c->planes[0],l->planes[0],c->nch,s->route[i][FR],
l->nch,s->route[i][TO],mp_audio_psize(c),c->bps);
l->nch,s->route[i][TO],mp_audio_psize(c),c->bps);
// Set output data
c->planes[0] = l->planes[0];
@@ -220,11 +220,11 @@ static int af_open(struct af_instance* af){
do {
int n = 0;
if (ch >= AF_NCH) {
MP_FATAL(af, "[channels] Can't have more than %d routes.\n", AF_NCH);
MP_FATAL(af, "Can't have more than %d routes.\n", AF_NCH);
return AF_ERROR;
}
sscanf(cp, "%i-%i%n" ,&s->route[ch][FR], &s->route[ch][TO], &n);
MP_VERBOSE(af, "[channels] Routing from channel %i to"
MP_VERBOSE(af, "Routing from channel %i to"
" channel %i\n",s->route[ch][FR],s->route[ch][TO]);
cp = &cp[n];
ch++;
@@ -238,7 +238,7 @@ static int af_open(struct af_instance* af){
}
#define OPT_BASE_STRUCT af_channels_t
struct af_info af_info_channels = {
const struct af_info af_info_channels = {
.info = "Insert or remove channels",
.name = "channels",
.open = af_open,
+1 -1
View File
@@ -108,7 +108,7 @@ static int af_open(struct af_instance *af)
return AF_OK;
}
struct af_info af_info_convert24 = {
const struct af_info af_info_convert24 = {
.info = "Convert between 24 and 32 bit sample format",
.name = "convert24",
.open = af_open,
+1 -1
View File
@@ -123,7 +123,7 @@ static int af_open(struct af_instance *af)
return AF_OK;
}
struct af_info af_info_convertsignendian = {
const struct af_info af_info_convertsignendian = {
.info = "Convert between sample format sign/endian",
.name = "convertsignendian",
.open = af_open,
+27 -27
View File
@@ -37,10 +37,10 @@
// Data for specific instances of this filter
typedef struct af_delay_s
{
void* q[AF_NCH]; // Circular queues used for delaying audio signal
int wi[AF_NCH]; // Write index
int ri; // Read index
float d[AF_NCH]; // Delay [ms]
void* q[AF_NCH]; // Circular queues used for delaying audio signal
int wi[AF_NCH]; // Write index
int ri; // Read index
float d[AF_NCH]; // Delay [ms]
char *delaystr;
}af_delay_t;
@@ -54,7 +54,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
struct mp_audio *in = arg;
if (in->bps != 1 && in->bps != 2 && in->bps != 4) {
MP_FATAL(af, "[delay] Sample format not supported\n");
MP_FATAL(af, "Sample format not supported\n");
return AF_ERROR;
}
@@ -69,16 +69,16 @@ static int control(struct af_instance* af, int cmd, void* arg)
for(i=0;i<af->data->nch;i++){
s->q[i] = calloc(L,af->data->bps);
if(NULL == s->q[i])
MP_FATAL(af, "[delay] Out of memory\n");
MP_FATAL(af, "Out of memory\n");
}
if(AF_OK != af_from_ms(AF_NCH, s->d, s->wi, af->data->rate, 0.0, 1000.0))
return AF_ERROR;
s->ri = 0;
for(i=0;i<AF_NCH;i++){
MP_DBG(af, "[delay] Channel %i delayed by %0.3fms\n",
MP_DBG(af, "Channel %i delayed by %0.3fms\n",
i,MPCLAMP(s->d[i],0.0,1000.0));
MP_TRACE(af, "[delay] Channel %i delayed by %i samples\n",
MP_TRACE(af, "Channel %i delayed by %i samples\n",
i,s->wi[i]);
}
return AF_OK;
@@ -99,12 +99,12 @@ static void uninit(struct af_instance* af)
// Filter data through filter
static int filter(struct af_instance* af, struct mp_audio* data, int flags)
{
struct mp_audio* c = data; // Current working data
af_delay_t* s = af->priv; // Setup for this instance
int nch = c->nch; // Number of channels
int len = mp_audio_psize(c)/c->bps; // Number of sample in data chunk
int ri = 0;
int ch,i;
struct mp_audio* c = data; // Current working data
af_delay_t* s = af->priv; // Setup for this instance
int nch = c->nch; // Number of channels
int len = mp_audio_psize(c)/c->bps; // Number of sample in data chunk
int ri = 0;
int ch,i;
for(ch=0;ch<nch;ch++){
switch(c->bps){
case 1:{
@@ -113,10 +113,10 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags)
int wi = s->wi[ch];
ri = s->ri;
for(i=ch;i<len;i+=nch){
q[wi] = a[i];
a[i] = q[ri];
UPDATEQI(wi);
UPDATEQI(ri);
q[wi] = a[i];
a[i] = q[ri];
UPDATEQI(wi);
UPDATEQI(ri);
}
s->wi[ch] = wi;
break;
@@ -127,10 +127,10 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags)
int wi = s->wi[ch];
ri = s->ri;
for(i=ch;i<len;i+=nch){
q[wi] = a[i];
a[i] = q[ri];
UPDATEQI(wi);
UPDATEQI(ri);
q[wi] = a[i];
a[i] = q[ri];
UPDATEQI(wi);
UPDATEQI(ri);
}
s->wi[ch] = wi;
break;
@@ -141,10 +141,10 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags)
int wi = s->wi[ch];
ri = s->ri;
for(i=ch;i<len;i+=nch){
q[wi] = a[i];
a[i] = q[ri];
UPDATEQI(wi);
UPDATEQI(ri);
q[wi] = a[i];
a[i] = q[ri];
UPDATEQI(wi);
UPDATEQI(ri);
}
s->wi[ch] = wi;
break;
@@ -178,7 +178,7 @@ static int af_open(struct af_instance* af){
}
#define OPT_BASE_STRUCT af_delay_t
struct af_info af_info_delay = {
const struct af_info af_info_delay = {
.info = "Delay audio filter",
.name = "delay",
.open = af_open,
+19 -19
View File
@@ -70,8 +70,8 @@ typedef struct af_volume_s
// method 2
int idx;
struct {
float avg; // average level of the sample
int len; // sample size (weight)
float avg; // average level of the sample
int len; // sample size (weight)
} mem[NSAMPLES];
// "Ideal" level
float mid_s16;
@@ -100,8 +100,8 @@ static int control(struct af_instance* af, int cmd, void* arg)
static void method1_int16(af_drc_t *s, struct mp_audio *c)
{
register int i = 0;
int16_t *data = (int16_t*)c->planes[0]; // Audio data
int len = c->samples*c->nch; // Number of samples
int16_t *data = (int16_t*)c->planes[0]; // Audio data
int len = c->samples*c->nch; // Number of samples
float curavg = 0.0, newavg, neededmul;
int tmp;
@@ -142,8 +142,8 @@ static void method1_int16(af_drc_t *s, struct mp_audio *c)
static void method1_float(af_drc_t *s, struct mp_audio *c)
{
register int i = 0;
float *data = (float*)c->planes[0]; // Audio data
int len = c->samples*c->nch; // Number of samples
float *data = (float*)c->planes[0]; // Audio data
int len = c->samples*c->nch; // Number of samples
float curavg = 0.0, newavg, neededmul, tmp;
for (i = 0; i < len; i++)
@@ -179,8 +179,8 @@ static void method1_float(af_drc_t *s, struct mp_audio *c)
static void method2_int16(af_drc_t *s, struct mp_audio *c)
{
register int i = 0;
int16_t *data = (int16_t*)c->planes[0]; // Audio data
int len = c->samples*c->nch; // Number of samples
int16_t *data = (int16_t*)c->planes[0]; // Audio data
int len = c->samples*c->nch; // Number of samples
float curavg = 0.0, newavg, avg = 0.0;
int tmp, totallen = 0;
@@ -204,8 +204,8 @@ static void method2_int16(af_drc_t *s, struct mp_audio *c)
avg /= (float)totallen;
if (avg >= SIL_S16)
{
s->mul = s->mid_s16 / avg;
s->mul = MPCLAMP(s->mul, MUL_MIN, MUL_MAX);
s->mul = s->mid_s16 / avg;
s->mul = MPCLAMP(s->mul, MUL_MIN, MUL_MAX);
}
}
@@ -229,8 +229,8 @@ static void method2_int16(af_drc_t *s, struct mp_audio *c)
static void method2_float(af_drc_t *s, struct mp_audio *c)
{
register int i = 0;
float *data = (float*)c->planes[0]; // Audio data
int len = c->samples*c->nch; // Number of samples
float *data = (float*)c->planes[0]; // Audio data
int len = c->samples*c->nch; // Number of samples
float curavg = 0.0, newavg, avg = 0.0, tmp;
int totallen = 0;
@@ -254,8 +254,8 @@ static void method2_float(af_drc_t *s, struct mp_audio *c)
avg /= (float)totallen;
if (avg >= SIL_FLOAT)
{
s->mul = s->mid_float / avg;
s->mul = MPCLAMP(s->mul, MUL_MIN, MUL_MAX);
s->mul = s->mid_float / avg;
s->mul = MPCLAMP(s->mul, MUL_MIN, MUL_MAX);
}
}
@@ -279,16 +279,16 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags)
if(af->data->format == (AF_FORMAT_S16))
{
if (s->method == 2)
method2_int16(s, data);
method2_int16(s, data);
else
method1_int16(s, data);
method1_int16(s, data);
}
else if(af->data->format == (AF_FORMAT_FLOAT))
{
if (s->method == 2)
method2_float(s, data);
method2_float(s, data);
else
method1_float(s, data);
method1_float(s, data);
}
return 0;
}
@@ -313,7 +313,7 @@ static int af_open(struct af_instance* af){
}
#define OPT_BASE_STRUCT af_drc_t
struct af_info af_info_drc = {
const struct af_info af_info_drc = {
.info = "Dynamic range compression filter",
.name = "drc",
.flags = AF_FLAGS_NOT_REENTRANT,
+3 -3
View File
@@ -33,8 +33,8 @@ static int control(struct af_instance* af, int cmd, void* arg)
switch(cmd){
case AF_CONTROL_REINIT: ;
*af->data = *(struct mp_audio*)arg;
MP_VERBOSE(af, "[dummy] Was reinitialized: %iHz/%ich/%s\n",
af->data->rate,af->data->nch,af_fmt_to_str(af->data->format));
MP_VERBOSE(af, "Was reinitialized: %iHz/%ich/%s\n",
af->data->rate,af->data->nch,af_fmt_to_str(af->data->format));
return AF_OK;
}
return AF_UNKNOWN;
@@ -54,7 +54,7 @@ static int af_open(struct af_instance* af){
}
// Description of this filter
struct af_info af_info_dummy = {
const struct af_info af_info_dummy = {
.info = "dummy",
.name = "dummy",
.open = af_open,
+45 -45
View File
@@ -32,41 +32,41 @@
#include "common/common.h"
#include "af.h"
#define L 2 // Storage for filter taps
#define KM 10 // Max number of bands
#define L 2 // Storage for filter taps
#define KM 10 // Max number of bands
#define Q 1.2247449 /* Q value for band-pass filters 1.2247=(3/2)^(1/2)
gives 4dB suppression @ Fc*2 and Fc/2 */
gives 4dB suppression @ Fc*2 and Fc/2 */
/* Center frequencies for band-pass filters
The different frequency bands are:
nr. center frequency
0 31.25 Hz
1 62.50 Hz
2 125.0 Hz
3 250.0 Hz
4 500.0 Hz
5 1.000 kHz
6 2.000 kHz
7 4.000 kHz
8 8.000 kHz
9 16.00 kHz
nr. center frequency
0 31.25 Hz
1 62.50 Hz
2 125.0 Hz
3 250.0 Hz
4 500.0 Hz
5 1.000 kHz
6 2.000 kHz
7 4.000 kHz
8 8.000 kHz
9 16.00 kHz
*/
#define CF {31.25,62.5,125,250,500,1000,2000,4000,8000,16000}
#define CF {31.25,62.5,125,250,500,1000,2000,4000,8000,16000}
// Maximum and minimum gain for the bands
#define G_MAX +12.0
#define G_MIN -12.0
#define G_MAX +12.0
#define G_MIN -12.0
// Data for specific instances of this filter
typedef struct af_equalizer_s
{
float a[KM][L]; // A weights
float b[KM][L]; // B weights
float wq[AF_NCH][KM][L]; // Circular buffer for W data
float g[AF_NCH][KM]; // Gain factor for each channel and band
int K; // Number of used eq bands
int channels; // Number of channels
float a[KM][L]; // A weights
float b[KM][L]; // B weights
float wq[AF_NCH][KM][L]; // Circular buffer for W data
float g[AF_NCH][KM]; // Gain factor for each channel and band
int K; // Number of used eq bands
int channels; // Number of channels
float gain_factor; // applied at output to avoid clipping
double p[KM];
} af_equalizer_t;
@@ -107,8 +107,8 @@ static int control(struct af_instance* af, int cmd, void* arg)
s->K--;
if(s->K != KM)
MP_INFO(af, "[equalizer] Limiting the number of filters to"
" %i due to low sample rate.\n",s->K);
MP_INFO(af, "Limiting the number of filters to"
" %i due to low sample rate.\n",s->K);
// Generate filter taps
for(k=0;k<s->K;k++)
@@ -144,33 +144,33 @@ static int control(struct af_instance* af, int cmd, void* arg)
// Filter data through filter
static int filter(struct af_instance* af, struct mp_audio* data, int flags)
{
struct mp_audio* c = data; // Current working data
af_equalizer_t* s = (af_equalizer_t*)af->priv; // Setup
uint32_t ci = af->data->nch; // Index for channels
uint32_t nch = af->data->nch; // Number of channels
struct mp_audio* c = data; // Current working data
af_equalizer_t* s = (af_equalizer_t*)af->priv; // Setup
uint32_t ci = af->data->nch; // Index for channels
uint32_t nch = af->data->nch; // Number of channels
while(ci--){
float* g = s->g[ci]; // Gain factor
float* in = ((float*)c->planes[0])+ci;
float* out = ((float*)c->planes[0])+ci;
float* end = in + c->samples*c->nch; // Block loop end
float* g = s->g[ci]; // Gain factor
float* in = ((float*)c->planes[0])+ci;
float* out = ((float*)c->planes[0])+ci;
float* end = in + c->samples*c->nch; // Block loop end
while(in < end){
register int k = 0; // Frequency band index
register float yt = *in; // Current input sample
register int k = 0; // Frequency band index
register float yt = *in; // Current input sample
in+=nch;
// Run the filters
for(;k<s->K;k++){
// Pointer to circular buffer wq
register float* wq = s->wq[ci][k];
// Calculate output from AR part of current filter
register float w=yt*s->b[k][0] + wq[0]*s->a[k][0] + wq[1]*s->a[k][1];
// Calculate output form MA part of current filter
yt+=(w + wq[1]*s->b[k][1])*g[k];
// Update circular buffer
wq[1] = wq[0];
wq[0] = w;
// Pointer to circular buffer wq
register float* wq = s->wq[ci][k];
// Calculate output from AR part of current filter
register float w=yt*s->b[k][0] + wq[0]*s->a[k][0] + wq[1]*s->a[k][1];
// Calculate output form MA part of current filter
yt+=(w + wq[1]*s->b[k][1])*g[k];
// Update circular buffer
wq[1] = wq[0];
wq[0] = w;
}
// Calculate output
*out=yt*s->gain_factor;
@@ -194,7 +194,7 @@ static int af_open(struct af_instance* af){
}
#define OPT_BASE_STRUCT af_equalizer_t
struct af_info af_info_equalizer = {
const struct af_info af_info_equalizer = {
.info = "Equalizer audio filter",
.name = "equalizer",
.flags = AF_FLAGS_NOT_REENTRANT,
+29 -29
View File
@@ -47,7 +47,7 @@
#define DEF_SZ 512 // default buffer size (in samples)
#define SHARED_FILE "mpv-af_export" /* default file name
(relative to ~/.mpv/ */
(relative to ~/.mpv/ */
#define SIZE_HEADER (2 * sizeof(int) + sizeof(unsigned long long))
@@ -55,12 +55,12 @@
typedef struct af_export_s
{
unsigned long long count; // Used for sync
void* buf[AF_NCH]; // Buffers for storing the data before it is exported
int sz; // Size of buffer in samples
int wi; // Write index
int fd; // File descriptor to shared memory area
char* filename; // File to export data
uint8_t *mmap_area; // MMap shared area
void* buf[AF_NCH]; // Buffers for storing the data before it is exported
int sz; // Size of buffer in samples
int wi; // Write index
int fd; // File descriptor to shared memory area
char* filename; // File to export data
uint8_t *mmap_area; // MMap shared area
} af_export_t;
@@ -95,21 +95,21 @@ static int control(struct af_instance* af, int cmd, void* arg)
// Allocate new buffers (as one continuous block)
s->buf[0] = calloc(s->sz*af->data->nch, af->data->bps);
if(NULL == s->buf[0])
MP_FATAL(af, "[export] Out of memory\n");
MP_FATAL(af, "Out of memory\n");
for(i = 1; i < af->data->nch; i++)
s->buf[i] = (uint8_t *)s->buf[0] + i*s->sz*af->data->bps;
if (!s->filename) {
MP_FATAL(af, "[export] No filename set.\n");
MP_FATAL(af, "No filename set.\n");
return AF_ERROR;
}
// Init memory mapping
s->fd = open(s->filename, O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0640);
MP_INFO(af, "[export] Exporting to file: %s\n", s->filename);
MP_INFO(af, "Exporting to file: %s\n", s->filename);
if(s->fd < 0) {
MP_FATAL(af, "[export] Could not open/create file: %s\n",
s->filename);
MP_FATAL(af, "Could not open/create file: %s\n",
s->filename);
return AF_ERROR;
}
@@ -125,9 +125,9 @@ static int control(struct af_instance* af, int cmd, void* arg)
// mmap size
s->mmap_area = mmap(0, mapsize, PROT_READ|PROT_WRITE,MAP_SHARED, s->fd, 0);
if(s->mmap_area == NULL)
MP_FATAL(af, "[export] Could not mmap file %s\n", s->filename);
MP_INFO(af, "[export] Memory mapped to file: %s (%p)\n",
s->filename, s->mmap_area);
MP_FATAL(af, "Could not mmap file %s\n", s->filename);
MP_INFO(af, "Memory mapped to file: %s (%p)\n",
s->filename, s->mmap_area);
// Initialize header
*((int*)s->mmap_area) = af->data->nch;
@@ -164,27 +164,27 @@ static void uninit( struct af_instance* af )
*/
static int filter( struct af_instance* af, struct mp_audio* data, int flags)
{
struct mp_audio* c = data; // Current working data
af_export_t* s = af->priv; // Setup for this instance
int16_t* a = c->planes[0]; // Incomming sound
int nch = c->nch; // Number of channels
int len = c->samples*c->nch; // Number of sample in data chunk
int sz = s->sz; // buffer size (in samples)
int flag = 0; // Set to 1 if buffer is filled
struct mp_audio* c = data; // Current working data
af_export_t* s = af->priv; // Setup for this instance
int16_t* a = c->planes[0]; // Incomming sound
int nch = c->nch; // Number of channels
int len = c->samples*c->nch; // Number of sample in data chunk
int sz = s->sz; // buffer size (in samples)
int flag = 0; // Set to 1 if buffer is filled
int ch, i;
int ch, i;
// Fill all buffers
for(ch = 0; ch < nch; ch++){
int wi = s->wi; // Reset write index
int16_t* b = s->buf[ch]; // Current buffer
int wi = s->wi; // Reset write index
int16_t* b = s->buf[ch]; // Current buffer
// Copy data to export buffers
for(i = ch; i < len; i += nch){
b[wi++] = a[i];
if(wi >= sz){ // Don't write outside the end of the buffer
flag = 1;
break;
flag = 1;
break;
}
}
s->wi = wi % s->sz;
@@ -196,7 +196,7 @@ static int filter( struct af_instance* af, struct mp_audio* data, int flags)
memcpy(s->mmap_area + SIZE_HEADER, s->buf[0], sz * c->bps * nch);
s->count++; // increment counter (to sync)
memcpy(s->mmap_area + SIZE_HEADER - sizeof(s->count),
&(s->count), sizeof(s->count));
&(s->count), sizeof(s->count));
}
return 0;
@@ -222,7 +222,7 @@ static int af_open( struct af_instance* af )
}
#define OPT_BASE_STRUCT af_export_t
struct af_info af_info_export = {
const struct af_info af_info_export = {
.info = "Sound export filter",
.name = "export",
.open = af_open,
+7 -7
View File
@@ -51,11 +51,11 @@ static int control(struct af_instance* af, int cmd, void* arg)
mp_audio_set_num_channels(af->data, 2);
if (af->data->format == AF_FORMAT_FLOAT)
{
af->filter = play_float;
af->filter = play_float;
}// else
{
mp_audio_set_format(af->data, AF_FORMAT_S16);
af->filter = play_s16;
af->filter = play_s16;
}
return af_test_output(af,(struct mp_audio*)arg);
@@ -69,8 +69,8 @@ static int play_s16(struct af_instance* af, struct mp_audio* data, int f)
{
af_extrastereo_t *s = af->priv;
register int i = 0;
int16_t *a = (int16_t*)data->planes[0]; // Audio data
int len = data->samples*data->nch; // Number of samples
int16_t *a = (int16_t*)data->planes[0]; // Audio data
int len = data->samples*data->nch; // Number of samples
int avg, l, r;
for (i = 0; i < len; i+=2)
@@ -91,8 +91,8 @@ static int play_float(struct af_instance* af, struct mp_audio* data, int f)
{
af_extrastereo_t *s = af->priv;
register int i = 0;
float *a = (float*)data->planes[0]; // Audio data
int len = data->samples * data->nch; // Number of samples
float *a = (float*)data->planes[0]; // Audio data
int len = data->samples * data->nch; // Number of samples
float avg, l, r;
for (i = 0; i < len; i+=2)
@@ -118,7 +118,7 @@ static int af_open(struct af_instance* af){
}
#define OPT_BASE_STRUCT af_extrastereo_t
struct af_info af_info_extrastereo = {
const struct af_info af_info_extrastereo = {
.info = "Increase difference between audio channels",
.name = "extrastereo",
.flags = AF_FLAGS_NOT_REENTRANT,
+1 -1
View File
@@ -114,7 +114,7 @@ static int af_open(struct af_instance *af)
#define OPT_BASE_STRUCT struct priv
struct af_info af_info_format = {
const struct af_info af_info_format = {
.info = "Force audio format",
.name = "format",
.open = af_open,
+219 -219
View File
@@ -75,23 +75,23 @@ typedef struct af_hrtf_s {
} af_hrtf_t;
/* Convolution on a ring buffer
* nx: length of the ring buffer
* nk: length of the convolution kernel
* sx: ring buffer
* sk: convolution kernel
* offset: offset on the ring buffer, can be
* nx: length of the ring buffer
* nk: length of the convolution kernel
* sx: ring buffer
* sk: convolution kernel
* offset: offset on the ring buffer, can be
*/
static float conv(const int nx, const int nk, const float *sx, const float *sk,
const int offset)
const int offset)
{
/* k = reminder of offset / nx */
int k = offset >= 0 ? offset % nx : nx + (offset % nx);
if(nk + k <= nx)
return af_filter_fir(nk, sx + k, sk);
return af_filter_fir(nk, sx + k, sk);
else
return af_filter_fir(nk + k - nx, sx, sk + nx - k) +
af_filter_fir(nx - k, sx + k, sk);
return af_filter_fir(nk + k - nx, sx, sk + nx - k) +
af_filter_fir(nx - k, sx + k, sk);
}
/* Detect when the impulse response starts (significantly) */
@@ -104,8 +104,8 @@ static int pulse_detect(const float *sx)
int i;
for(i = 0; i < nmax; i++)
if(fabs(sx[i]) > thresh)
return i;
if(fabs(sx[i]) > thresh)
return i;
return 0;
}
@@ -122,14 +122,14 @@ static inline float passive_lock(float x)
/* Unified active matrix decoder for 2 channel matrix encoded surround
sources */
static inline void matrix_decode(short *in, const int k, const int il,
const int ir, const int decode_rear,
const int dlbuflen,
float l_fwr, float r_fwr,
float lpr_fwr, float lmr_fwr,
float *adapt_l_gain, float *adapt_r_gain,
float *adapt_lpr_gain, float *adapt_lmr_gain,
float *lf, float *rf, float *lr,
float *rr, float *cf)
const int ir, const int decode_rear,
const int dlbuflen,
float l_fwr, float r_fwr,
float lpr_fwr, float lmr_fwr,
float *adapt_l_gain, float *adapt_r_gain,
float *adapt_lpr_gain, float *adapt_lmr_gain,
float *lf, float *rf, float *lr,
float *rr, float *cf)
{
const int kr = (k + MATREARDELAY) % dlbuflen;
float l_gain = (l_fwr + r_fwr) /
@@ -161,13 +161,13 @@ static inline void matrix_decode(short *in, const int k, const int il,
fp_out = fopen("af_hrtf.log", "w");
if(counter % 240 == 0)
fprintf(fp_out, "%g %g %g %g %g ", counter * (1.0 / 48000),
l_gain, r_gain, lpr_gain, lmr_gain);
l_gain, r_gain, lpr_gain, lmr_gain);
#endif
/*** AXIS NO. 1: (Lt, Rt) -> (C, Ls, Rs) ***/
/* AGC adaption */
d_gain = (fabs(l_gain - *adapt_l_gain) +
fabs(r_gain - *adapt_r_gain)) * 0.5;
fabs(r_gain - *adapt_r_gain)) * 0.5;
f = d_gain * (1.0 / MATAGCTRIG);
f = MATAGCDECAY - MATAGCDECAY / (1 + f * f);
*adapt_l_gain = (1 - f) * *adapt_l_gain + f * l_gain;
@@ -179,12 +179,12 @@ static inline void matrix_decode(short *in, const int k, const int il,
if(decode_rear) {
lr[kr] = rr[kr] = (l_agc - r_agc) * M_SQRT1_2;
/* Stereo rear channel is steered with the same AGC steering as
the decoding matrix. Note this requires a fast updating AGC
at the order of 20 ms (which is the case here). */
the decoding matrix. Note this requires a fast updating AGC
at the order of 20 ms (which is the case here). */
lr[kr] *= (l_fwr + l_fwr) /
(1 + l_fwr + r_fwr);
(1 + l_fwr + r_fwr);
rr[kr] *= (r_fwr + r_fwr) /
(1 + l_fwr + r_fwr);
(1 + l_fwr + r_fwr);
}
/*** AXIS NO. 2: (Lt + Rt, Lt - Rt) -> (L, R) ***/
@@ -221,9 +221,9 @@ static inline void matrix_decode(short *in, const int k, const int il,
#if 0
if(counter % 240 == 0)
fprintf(fp_out, "%g %g %g %g %g\n",
*adapt_l_gain, *adapt_r_gain,
*adapt_lpr_gain, *adapt_lmr_gain,
c_gain);
*adapt_l_gain, *adapt_r_gain,
*adapt_lpr_gain, *adapt_lmr_gain,
c_gain);
counter++;
#endif
}
@@ -237,18 +237,18 @@ static inline void update_ch(af_hrtf_t *s, short *in, const int k)
s->l_fwr += abs(in[0]) - fabs(s->fwrbuf_l[fwr_pos]);
s->r_fwr += abs(in[1]) - fabs(s->fwrbuf_r[fwr_pos]);
s->lpr_fwr += abs(in[0] + in[1]) -
fabs(s->fwrbuf_l[fwr_pos] + s->fwrbuf_r[fwr_pos]);
fabs(s->fwrbuf_l[fwr_pos] + s->fwrbuf_r[fwr_pos]);
s->lmr_fwr += abs(in[0] - in[1]) -
fabs(s->fwrbuf_l[fwr_pos] - s->fwrbuf_r[fwr_pos]);
fabs(s->fwrbuf_l[fwr_pos] - s->fwrbuf_r[fwr_pos]);
}
/* Rear matrix decoder */
if(s->matrix_mode) {
s->lr_fwr += abs(in[2]) - fabs(s->fwrbuf_lr[fwr_pos]);
s->rr_fwr += abs(in[3]) - fabs(s->fwrbuf_rr[fwr_pos]);
s->lrprr_fwr += abs(in[2] + in[3]) -
fabs(s->fwrbuf_lr[fwr_pos] + s->fwrbuf_rr[fwr_pos]);
fabs(s->fwrbuf_lr[fwr_pos] + s->fwrbuf_rr[fwr_pos]);
s->lrmrr_fwr += abs(in[2] - in[3]) -
fabs(s->fwrbuf_lr[fwr_pos] - s->fwrbuf_rr[fwr_pos]);
fabs(s->fwrbuf_lr[fwr_pos] - s->fwrbuf_rr[fwr_pos]);
}
switch (s->decode_mode) {
@@ -265,11 +265,11 @@ static inline void update_ch(af_hrtf_t *s, short *in, const int k)
s->fwrbuf_l[k] = in[0];
s->fwrbuf_r[k] = in[1];
matrix_decode(in, k, 0, 1, 1, s->dlbuflen,
s->l_fwr, s->r_fwr,
s->lpr_fwr, s->lmr_fwr,
&(s->adapt_l_gain), &(s->adapt_r_gain),
&(s->adapt_lpr_gain), &(s->adapt_lmr_gain),
s->lf, s->rf, s->lr, s->rr, s->cf);
s->l_fwr, s->r_fwr,
s->lpr_fwr, s->lmr_fwr,
&(s->adapt_l_gain), &(s->adapt_r_gain),
&(s->adapt_lpr_gain), &(s->adapt_lmr_gain),
s->lf, s->rf, s->lr, s->rr, s->cf);
break;
case HRTF_MIX_STEREO:
/* Stereo sources */
@@ -292,30 +292,30 @@ static int control(struct af_instance *af, int cmd, void* arg)
switch(cmd) {
case AF_CONTROL_REINIT:
af->data->rate = ((struct mp_audio*)arg)->rate;
if(af->data->rate != 48000) {
// automatic samplerate adjustment in the filter chain
// is not yet supported.
MP_ERR(af, "[hrtf] ERROR: Sampling rate is not 48000 Hz (%d)!\n",
af->data->rate);
return AF_ERROR;
}
mp_audio_set_channels_old(af->data, ((struct mp_audio*)arg)->nch);
if(af->data->nch == 2) {
/* 2 channel input */
if(s->decode_mode != HRTF_MIX_MATRIX2CH) {
/* Default behavior is stereo mixing. */
s->decode_mode = HRTF_MIX_STEREO;
}
}
else if (af->data->nch < 5)
mp_audio_set_channels_old(af->data, 5);
af->data->rate = ((struct mp_audio*)arg)->rate;
if(af->data->rate != 48000) {
// automatic samplerate adjustment in the filter chain
// is not yet supported.
MP_ERR(af, "ERROR: Sampling rate is not 48000 Hz (%d)!\n",
af->data->rate);
return AF_ERROR;
}
mp_audio_set_channels_old(af->data, ((struct mp_audio*)arg)->nch);
if(af->data->nch == 2) {
/* 2 channel input */
if(s->decode_mode != HRTF_MIX_MATRIX2CH) {
/* Default behavior is stereo mixing. */
s->decode_mode = HRTF_MIX_STEREO;
}
}
else if (af->data->nch < 5)
mp_audio_set_channels_old(af->data, 5);
mp_audio_set_format(af->data, AF_FORMAT_S16);
test_output_res = af_test_output(af, (struct mp_audio*)arg);
// after testing input set the real output format
test_output_res = af_test_output(af, (struct mp_audio*)arg);
// after testing input set the real output format
mp_audio_set_num_channels(af->data, 2);
s->print_flag = 1;
return test_output_res;
s->print_flag = 1;
return test_output_res;
}
return AF_UNKNOWN;
@@ -324,21 +324,21 @@ static int control(struct af_instance *af, int cmd, void* arg)
/* Deallocate memory */
static void uninit(struct af_instance *af)
{
af_hrtf_t *s = af->priv;
af_hrtf_t *s = af->priv;
free(s->lf);
free(s->rf);
free(s->lr);
free(s->rr);
free(s->cf);
free(s->cr);
free(s->ba_l);
free(s->ba_r);
free(s->ba_ir);
free(s->fwrbuf_l);
free(s->fwrbuf_r);
free(s->fwrbuf_lr);
free(s->fwrbuf_rr);
free(s->lf);
free(s->rf);
free(s->lr);
free(s->rr);
free(s->cf);
free(s->cr);
free(s->ba_l);
free(s->ba_r);
free(s->ba_ir);
free(s->fwrbuf_l);
free(s->fwrbuf_r);
free(s->fwrbuf_lr);
free(s->fwrbuf_rr);
}
/* Filter data through filter
@@ -364,29 +364,29 @@ static int filter(struct af_instance *af, struct mp_audio *data, int flags)
mp_audio_realloc_min(af->data, data->samples);
if(s->print_flag) {
s->print_flag = 0;
switch (s->decode_mode) {
case HRTF_MIX_51:
MP_INFO(af, "[hrtf] Using HRTF to mix %s discrete surround into "
"L, R channels\n", s->matrix_mode ? "5+1" : "5");
break;
case HRTF_MIX_STEREO:
MP_INFO(af, "[hrtf] Using HRTF to mix stereo into "
"L, R channels\n");
break;
case HRTF_MIX_MATRIX2CH:
MP_INFO(af, "[hrtf] Using active matrix to decode 2 channel "
"input, HRTF to mix %s matrix surround into "
"L, R channels\n", "3/2");
break;
default:
MP_WARN(af, "[hrtf] bogus decode_mode: %d\n", s->decode_mode);
break;
}
s->print_flag = 0;
switch (s->decode_mode) {
case HRTF_MIX_51:
MP_INFO(af, "Using HRTF to mix %s discrete surround into "
"L, R channels\n", s->matrix_mode ? "5+1" : "5");
break;
case HRTF_MIX_STEREO:
MP_INFO(af, "Using HRTF to mix stereo into "
"L, R channels\n");
break;
case HRTF_MIX_MATRIX2CH:
MP_INFO(af, "Using active matrix to decode 2 channel "
"input, HRTF to mix %s matrix surround into "
"L, R channels\n", "3/2");
break;
default:
MP_WARN(af, "bogus decode_mode: %d\n", s->decode_mode);
break;
}
if(s->matrix_mode)
MP_INFO(af, "[hrtf] Using active matrix to decode rear center "
"channel\n");
MP_INFO(af, "Using active matrix to decode rear center "
"channel\n");
}
out = af->data->planes[0];
@@ -410,122 +410,122 @@ static int filter(struct af_instance *af, struct mp_audio *data, int flags)
*/
while(in < end) {
const int k = s->cyc_pos;
const int k = s->cyc_pos;
update_ch(s, in, k);
update_ch(s, in, k);
/* Simulate a 7.5 ms -20 dB echo of the center channel in the
front channels (like reflection from a room wall) - a kind of
psycho-acoustically "cheating" to focus the center front
channel, which is normally hard to be perceived as front */
s->lf[k] += CFECHOAMPL * s->cf[(k + CFECHODELAY) % s->dlbuflen];
s->rf[k] += CFECHOAMPL * s->cf[(k + CFECHODELAY) % s->dlbuflen];
/* Simulate a 7.5 ms -20 dB echo of the center channel in the
front channels (like reflection from a room wall) - a kind of
psycho-acoustically "cheating" to focus the center front
channel, which is normally hard to be perceived as front */
s->lf[k] += CFECHOAMPL * s->cf[(k + CFECHODELAY) % s->dlbuflen];
s->rf[k] += CFECHOAMPL * s->cf[(k + CFECHODELAY) % s->dlbuflen];
switch (s->decode_mode) {
case HRTF_MIX_51:
case HRTF_MIX_MATRIX2CH:
/* Mixer filter matrix */
common = conv(dblen, hlen, s->cf, s->cf_ir, k + s->cf_o);
if(s->matrix_mode) {
/* In matrix decoding mode, the rear channel gain must be
renormalized, as there is an additional channel. */
matrix_decode(in, k, 2, 3, 0, s->dlbuflen,
s->lr_fwr, s->rr_fwr,
s->lrprr_fwr, s->lrmrr_fwr,
&(s->adapt_lr_gain), &(s->adapt_rr_gain),
&(s->adapt_lrprr_gain), &(s->adapt_lrmrr_gain),
s->lr, s->rr, NULL, NULL, s->cr);
common +=
conv(dblen, hlen, s->cr, s->cr_ir, k + s->cr_o) *
M1_76DB;
left =
( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o) +
(conv(dblen, hlen, s->lr, s->ar_ir, k + s->ar_o) +
conv(dblen, hlen, s->rr, s->or_ir, k + s->or_o)) *
M1_76DB + common);
right =
( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o) +
(conv(dblen, hlen, s->rr, s->ar_ir, k + s->ar_o) +
conv(dblen, hlen, s->lr, s->or_ir, k + s->or_o)) *
M1_76DB + common);
} else {
left =
( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o) +
conv(dblen, hlen, s->lr, s->ar_ir, k + s->ar_o) +
conv(dblen, hlen, s->rr, s->or_ir, k + s->or_o) +
common);
right =
( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o) +
conv(dblen, hlen, s->rr, s->ar_ir, k + s->ar_o) +
conv(dblen, hlen, s->lr, s->or_ir, k + s->or_o) +
common);
}
break;
case HRTF_MIX_STEREO:
left =
( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o));
right =
( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o));
break;
default:
/* make gcc happy */
left = 0.0;
right = 0.0;
break;
}
switch (s->decode_mode) {
case HRTF_MIX_51:
case HRTF_MIX_MATRIX2CH:
/* Mixer filter matrix */
common = conv(dblen, hlen, s->cf, s->cf_ir, k + s->cf_o);
if(s->matrix_mode) {
/* In matrix decoding mode, the rear channel gain must be
renormalized, as there is an additional channel. */
matrix_decode(in, k, 2, 3, 0, s->dlbuflen,
s->lr_fwr, s->rr_fwr,
s->lrprr_fwr, s->lrmrr_fwr,
&(s->adapt_lr_gain), &(s->adapt_rr_gain),
&(s->adapt_lrprr_gain), &(s->adapt_lrmrr_gain),
s->lr, s->rr, NULL, NULL, s->cr);
common +=
conv(dblen, hlen, s->cr, s->cr_ir, k + s->cr_o) *
M1_76DB;
left =
( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o) +
(conv(dblen, hlen, s->lr, s->ar_ir, k + s->ar_o) +
conv(dblen, hlen, s->rr, s->or_ir, k + s->or_o)) *
M1_76DB + common);
right =
( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o) +
(conv(dblen, hlen, s->rr, s->ar_ir, k + s->ar_o) +
conv(dblen, hlen, s->lr, s->or_ir, k + s->or_o)) *
M1_76DB + common);
} else {
left =
( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o) +
conv(dblen, hlen, s->lr, s->ar_ir, k + s->ar_o) +
conv(dblen, hlen, s->rr, s->or_ir, k + s->or_o) +
common);
right =
( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o) +
conv(dblen, hlen, s->rr, s->ar_ir, k + s->ar_o) +
conv(dblen, hlen, s->lr, s->or_ir, k + s->or_o) +
common);
}
break;
case HRTF_MIX_STEREO:
left =
( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o));
right =
( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) +
conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o));
break;
default:
/* make gcc happy */
left = 0.0;
right = 0.0;
break;
}
/* Bass compensation for the lower frequency cut of the HRTF. A
cross talk of the left and right channel is introduced to
match the directional characteristics of higher frequencies.
The bass will not have any real 3D perception, but that is
OK (note at 180 Hz, the wavelength is about 2 m, and any
spatial perception is impossible). */
left_b = conv(dblen, blen, s->ba_l, s->ba_ir, k);
right_b = conv(dblen, blen, s->ba_r, s->ba_ir, k);
left += (1 - BASSCROSS) * left_b + BASSCROSS * right_b;
right += (1 - BASSCROSS) * right_b + BASSCROSS * left_b;
/* Also mix the LFE channel (if available) */
if(data->nch >= 6) {
left += in[5] * M3_01DB;
right += in[5] * M3_01DB;
}
/* Bass compensation for the lower frequency cut of the HRTF. A
cross talk of the left and right channel is introduced to
match the directional characteristics of higher frequencies.
The bass will not have any real 3D perception, but that is
OK (note at 180 Hz, the wavelength is about 2 m, and any
spatial perception is impossible). */
left_b = conv(dblen, blen, s->ba_l, s->ba_ir, k);
right_b = conv(dblen, blen, s->ba_r, s->ba_ir, k);
left += (1 - BASSCROSS) * left_b + BASSCROSS * right_b;
right += (1 - BASSCROSS) * right_b + BASSCROSS * left_b;
/* Also mix the LFE channel (if available) */
if(data->nch >= 6) {
left += in[5] * M3_01DB;
right += in[5] * M3_01DB;
}
/* Amplitude renormalization. */
left *= AMPLNORM;
right *= AMPLNORM;
/* Amplitude renormalization. */
left *= AMPLNORM;
right *= AMPLNORM;
switch (s->decode_mode) {
case HRTF_MIX_51:
case HRTF_MIX_STEREO:
/* "Cheating": linear stereo expansion to amplify the 3D
perception. Note: Too much will destroy the acoustic space
and may even result in headaches. */
diff = STEXPAND2 * (left - right);
out[0] = av_clip_int16(left + diff);
out[1] = av_clip_int16(right - diff);
break;
case HRTF_MIX_MATRIX2CH:
/* Do attempt any stereo expansion with matrix encoded
sources. The L, R channels are already stereo expanded
by the steering, any further stereo expansion will sound
very unnatural. */
out[0] = av_clip_int16(left);
out[1] = av_clip_int16(right);
break;
}
switch (s->decode_mode) {
case HRTF_MIX_51:
case HRTF_MIX_STEREO:
/* "Cheating": linear stereo expansion to amplify the 3D
perception. Note: Too much will destroy the acoustic space
and may even result in headaches. */
diff = STEXPAND2 * (left - right);
out[0] = av_clip_int16(left + diff);
out[1] = av_clip_int16(right - diff);
break;
case HRTF_MIX_MATRIX2CH:
/* Do attempt any stereo expansion with matrix encoded
sources. The L, R channels are already stereo expanded
by the steering, any further stereo expansion will sound
very unnatural. */
out[0] = av_clip_int16(left);
out[1] = av_clip_int16(right);
break;
}
/* Next sample... */
in = &in[data->nch];
out = &out[af->data->nch];
(s->cyc_pos)--;
if(s->cyc_pos < 0)
s->cyc_pos += dblen;
/* Next sample... */
in = &in[data->nch];
out = &out[af->data->nch];
(s->cyc_pos)--;
if(s->cyc_pos < 0)
s->cyc_pos += dblen;
}
/* Set output data */
@@ -546,13 +546,13 @@ static int allocate(af_hrtf_t *s)
if ((s->ba_l = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
if ((s->ba_r = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
if ((s->fwrbuf_l =
malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
if ((s->fwrbuf_r =
malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
if ((s->fwrbuf_lr =
malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
if ((s->fwrbuf_rr =
malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
return 0;
}
@@ -595,16 +595,16 @@ static int af_open(struct af_instance* af)
s->print_flag = 1;
if (allocate(s) != 0) {
MP_ERR(af, "[hrtf] Memory allocation error.\n");
return AF_ERROR;
MP_ERR(af, "Memory allocation error.\n");
return AF_ERROR;
}
for(i = 0; i < s->dlbuflen; i++)
s->lf[i] = s->rf[i] = s->lr[i] = s->rr[i] = s->cf[i] =
s->cr[i] = 0;
s->lf[i] = s->rf[i] = s->lr[i] = s->rr[i] = s->cf[i] =
s->cr[i] = 0;
s->lr_fwr =
s->rr_fwr = 0;
s->rr_fwr = 0;
s->cf_ir = cf_filt + (s->cf_o = pulse_detect(cf_filt));
s->af_ir = af_filt + (s->af_o = pulse_detect(af_filt));
@@ -614,24 +614,24 @@ static int af_open(struct af_instance* af)
s->cr_ir = cr_filt + (s->cr_o = pulse_detect(cr_filt));
if((s->ba_ir = malloc(s->basslen * sizeof(float))) == NULL) {
MP_ERR(af, "[hrtf] Memory allocation error.\n");
return AF_ERROR;
MP_ERR(af, "Memory allocation error.\n");
return AF_ERROR;
}
fc = 2.0 * BASSFILTFREQ / (float)af->data->rate;
if(af_filter_design_fir(s->basslen, s->ba_ir, &fc, LP | KAISER, 4 * M_PI) ==
-1) {
MP_ERR(af, "[hrtf] Unable to design low-pass "
"filter.\n");
return AF_ERROR;
MP_ERR(af, "Unable to design low-pass "
"filter.\n");
return AF_ERROR;
}
for(i = 0; i < s->basslen; i++)
s->ba_ir[i] *= BASSGAIN;
s->ba_ir[i] *= BASSGAIN;
return AF_OK;
}
#define OPT_BASE_STRUCT af_hrtf_t
struct af_info af_info_hrtf = {
const struct af_info af_info_hrtf = {
.info = "HRTF Headphone",
.name = "hrtf",
.open = af_open,
+25 -25
View File
@@ -24,38 +24,38 @@
#define HRTF_MIX_MATRIX2CH 2
/* Amplitude scaling factors */
#define M17_0DB 0.1414213562
#define M9_03DB 0.3535533906
#define M6_99DB 0.4472135955
#define M4_77DB 0.5773502692
#define M3_01DB 0.7071067812
#define M1_76DB 0.8164965809
#define M17_0DB 0.1414213562
#define M9_03DB 0.3535533906
#define M6_99DB 0.4472135955
#define M4_77DB 0.5773502692
#define M3_01DB 0.7071067812
#define M1_76DB 0.8164965809
#define DELAYBUFLEN 1024 /* Length of the delay buffer */
#define HRTFFILTLEN 64 /* HRTF filter length */
#define IRTHRESH 0.001 /* Impulse response pruning thresh. */
#define DELAYBUFLEN 1024 /* Length of the delay buffer */
#define HRTFFILTLEN 64 /* HRTF filter length */
#define IRTHRESH 0.001 /* Impulse response pruning thresh. */
#define AMPLNORM M6_99DB /* Overall amplitude renormalization */
#define AMPLNORM M6_99DB /* Overall amplitude renormalization */
#define BASSFILTFREQ 180 /* Bass compensation filter cut (Hz) */
#define BASSFILTLEN 193 /* Bass compensation filter length */
#define BASSGAIN M_SQRT2 /* Bass compensation gain */
#define BASSCROSS 0.35 /* Bass cross talk */
#define BASSFILTFREQ 180 /* Bass compensation filter cut (Hz) */
#define BASSFILTLEN 193 /* Bass compensation filter length */
#define BASSGAIN M_SQRT2 /* Bass compensation gain */
#define BASSCROSS 0.35 /* Bass cross talk */
#define FWRDURATION 240 /* FWR average duration (samples) */
#define MATREARDELAY 720 /* Matrix mode rear delay (samples) */
#define FWRDURATION 240 /* FWR average duration (samples) */
#define MATREARDELAY 720 /* Matrix mode rear delay (samples) */
#define MATAGCTRIG 8.0 /* (Fuzzy) AGC trigger */
#define MATAGCDECAY 1.0 /* AGC baseline decay rate (1/samp.) */
#define MATAGCLOCK 0.2 /* AGC range (around 1) where the
matrix behaves passively */
#define MATCOMPGAIN 0.37 /* Cross talk compensation gain,
0.50 - 0.55 is full cancellation. */
#define MATAGCTRIG 8.0 /* (Fuzzy) AGC trigger */
#define MATAGCDECAY 1.0 /* AGC baseline decay rate (1/samp.) */
#define MATAGCLOCK 0.2 /* AGC range (around 1) where the
matrix behaves passively */
#define MATCOMPGAIN 0.37 /* Cross talk compensation gain,
0.50 - 0.55 is full cancellation. */
#define CFECHODELAY 360 /* Center front echo delay (samples) */
#define CFECHOAMPL M17_0DB /* Center front echo amplitude */
#define CFECHODELAY 360 /* Center front echo delay (samples) */
#define CFECHOAMPL M17_0DB /* Center front echo amplitude */
#define STEXPAND2 0.07 /* Stereo expansion / 2 */
#define STEXPAND2 0.07 /* Stereo expansion / 2 */
/* Head related impulse response (HRIR) derived from KEMAR measurement
data by Bill Gardner <billg@media.mit.edu> and Keith Martin
+29 -29
View File
@@ -32,50 +32,50 @@
// Initialization and runtime control
static int control(struct af_instance* af, int cmd, void* arg)
{
switch(cmd){
case AF_CONTROL_REINIT:
switch(cmd){
case AF_CONTROL_REINIT:
mp_audio_copy_config(af->data, (struct mp_audio*)arg);
mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
return af_test_output(af,(struct mp_audio*)arg);
}
return AF_UNKNOWN;
return af_test_output(af,(struct mp_audio*)arg);
}
return AF_UNKNOWN;
}
// Filter data through filter
static int play(struct af_instance* af, struct mp_audio* data, int flags)
{
struct mp_audio* c = data; // Current working data
float* a = c->planes[0]; // Audio data
int nch = c->nch; // Number of channels
int len = c->samples*nch; // Number of samples in current audio block
register int i;
struct mp_audio* c = data; // Current working data
float* a = c->planes[0]; // Audio data
int nch = c->nch; // Number of channels
int len = c->samples*nch; // Number of samples in current audio block
register int i;
/*
FIXME1 add a low band pass filter to avoid suppressing
centered bass/drums
FIXME2 better calculated* attenuation factor
*/
/*
FIXME1 add a low band pass filter to avoid suppressing
centered bass/drums
FIXME2 better calculated* attenuation factor
*/
for(i=0;i<len;i+=nch)
{
a[i] = (a[i] - a[i+1]) * 0.7;
a[i+1]=a[i];
}
for(i=0;i<len;i+=nch)
{
a[i] = (a[i] - a[i+1]) * 0.7;
a[i+1]=a[i];
}
return 0;
return 0;
}
// Allocate memory and set function pointers
static int af_open(struct af_instance* af){
af->control = control;
af->filter = play;
return AF_OK;
af->control = control;
af->filter = play;
return AF_OK;
}
// Description of this filter
struct af_info af_info_karaoke = {
.info = "Simple karaoke/voice-removal audio filter",
.name = "karaoke",
.flags = AF_FLAGS_NOT_REENTRANT,
.open = af_open,
const struct af_info af_info_karaoke = {
.info = "Simple karaoke/voice-removal audio filter",
.name = "karaoke",
.flags = AF_FLAGS_NOT_REENTRANT,
.open = af_open,
};
+1 -1
View File
@@ -104,7 +104,7 @@ static int af_ladspa_malloc_failed(char*);
/* ------------------------------------------------------------------------- */
#define OPT_BASE_STRUCT af_ladspa_t
struct af_info af_info_ladspa = {
const struct af_info af_info_ladspa = {
.info = "LADSPA plugin loader",
.name = "ladspa",
.open = af_open,
+7 -7
View File
@@ -74,7 +74,7 @@ static int control(struct af_instance *af, int cmd, void *arg)
struct mp_audio *in = arg;
struct mp_audio orig_in = *in;
if (AF_FORMAT_IS_AC3(in->format) || in->nch < s->cfg_min_channel_num)
if (AF_FORMAT_IS_SPECIAL(in->format) || in->nch < s->cfg_min_channel_num)
return AF_DETACH;
mp_audio_set_format(in, s->in_sampleformat);
@@ -185,28 +185,28 @@ static int filter(struct af_instance* af, struct mp_audio* audio, int flags)
}
in_frame.samples = s->in_samples;
AVFrame *frame = avcodec_alloc_frame();
AVFrame *frame = av_frame_alloc();
if (!frame) {
MP_FATAL(af, "[libaf] Could not allocate memory \n");
MP_FATAL(af, "Could not allocate memory \n");
return -1;
}
frame->nb_samples = s->in_samples;
frame->format = s->lavc_actx->sample_fmt;
frame->channel_layout = s->lavc_actx->channel_layout;
assert(in_frame.num_planes <= AV_NUM_DATA_POINTERS);
frame->extended_data = frame->data;
for (int n = 0; n < in_frame.num_planes; n++)
frame->data[n] = in_frame.planes[n];
frame->linesize[0] = s->in_samples * audio->sstride;
int ok;
ret = avcodec_encode_audio2(s->lavc_actx, &s->pkt, frame, &ok);
av_frame_free(&frame);
if (ret < 0 || !ok) {
MP_FATAL(af, "[lavac3enc] Encode failed.\n");
MP_FATAL(af, "Encode failed.\n");
return -1;
}
avcodec_free_frame(&frame);
mp_audio_buffer_skip(s->pending, consumed_pending);
MP_DBG(af, "avcodec_encode_audio got %d, pending %d.\n",
@@ -305,7 +305,7 @@ static int af_open(struct af_instance* af){
#define OPT_BASE_STRUCT struct af_ac3enc_s
struct af_info af_info_lavcac3enc = {
const struct af_info af_info_lavcac3enc = {
.info = "runtime encode to ac3 using libavcodec",
.name = "lavcac3enc",
.open = af_open,
+39 -35
View File
@@ -38,19 +38,18 @@
#include "audio/fmt-conversion.h"
#include "af.h"
#include "options/m_option.h"
#include "common/av_opts.h"
#include "common/av_common.h"
#define IS_LIBAV_FORK (LIBAVFILTER_VERSION_MICRO < 100)
#include "options/m_option.h"
// FFmpeg and Libav have slightly different APIs, just enough to cause us
// unnecessary pain. <Expletive deleted.>
#if IS_LIBAV_FORK
#if LIBAVFILTER_VERSION_MICRO < 100
#define graph_parse(graph, filters, inputs, outputs, log_ctx) \
avfilter_graph_parse(graph, filters, inputs, outputs, log_ctx)
#else
#define graph_parse(graph, filters, inputs, outputs, log_ctx) \
avfilter_graph_parse(graph, filters, &(inputs), &(outputs), log_ctx)
avfilter_graph_parse_ptr(graph, filters, &(inputs), &(outputs), log_ctx)
#endif
struct priv {
@@ -64,7 +63,7 @@ struct priv {
// options
char *cfg_graph;
char *cfg_avopts;
char **cfg_avopts;
};
static void destroy_graph(struct af_instance *af)
@@ -78,8 +77,7 @@ static bool recreate_graph(struct af_instance *af, struct mp_audio *config)
{
void *tmp = talloc_new(NULL);
struct priv *p = af->priv;
AVFilterContext *in = NULL, *out = NULL;
int r;
AVFilterContext *in = NULL, *out = NULL, *f_format = NULL;
if (bstr0(p->cfg_graph).len == 0) {
MP_FATAL(af, "lavfi: no filter graph set\n");
@@ -93,23 +91,37 @@ static bool recreate_graph(struct af_instance *af, struct mp_audio *config)
if (!graph)
goto error;
if (parse_avopts(graph, p->cfg_avopts) < 0) {
MP_FATAL(af, "lavfi: could not set opts: '%s'\n",
p->cfg_avopts);
if (mp_set_avopts(af->log, graph, p->cfg_avopts) < 0)
goto error;
}
AVFilterInOut *outputs = avfilter_inout_alloc();
AVFilterInOut *inputs = avfilter_inout_alloc();
if (!outputs || !inputs)
goto error;
// Build list of acceptable output sample formats. libavfilter will insert
// conversion filters if needed.
static const enum AVSampleFormat sample_fmts[] = {
AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32,
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL,
AV_SAMPLE_FMT_U8P, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S32P,
AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP,
AV_SAMPLE_FMT_NONE
};
char *fmtstr = talloc_strdup(tmp, "");
for (int n = 0; sample_fmts[n] != AV_SAMPLE_FMT_NONE; n++) {
const char *name = av_get_sample_fmt_name(sample_fmts[n]);
if (name) {
const char *s = fmtstr[0] ? "|" : "";
fmtstr = talloc_asprintf_append_buffer(fmtstr, "%s%s", s, name);
}
}
char *src_args = talloc_asprintf(tmp,
"sample_rate=%d:sample_fmt=%s:channels=%d:time_base=%d/%d:"
"sample_rate=%d:sample_fmt=%s:time_base=%d/%d:"
"channel_layout=0x%"PRIx64, config->rate,
av_get_sample_fmt_name(af_to_avformat(config->format)),
config->channels.num, 1, config->rate,
mp_chmap_to_lavc(&config->channels));
1, config->rate, mp_chmap_to_lavc(&config->channels));
if (avfilter_graph_create_filter(&in, avfilter_get_by_name("abuffer"),
"src", src_args, NULL, graph) < 0)
@@ -119,27 +131,18 @@ static bool recreate_graph(struct af_instance *af, struct mp_audio *config)
"out", NULL, NULL, graph) < 0)
goto error;
static const enum AVSampleFormat sample_fmts[] = {
AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32,
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL,
AV_SAMPLE_FMT_U8P, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S32P,
AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP,
AV_SAMPLE_FMT_NONE
};
r = av_opt_set_int_list(out, "sample_fmts", sample_fmts,
AV_SAMPLE_FMT_NONE, AV_OPT_SEARCH_CHILDREN);
if (r < 0)
if (avfilter_graph_create_filter(&f_format, avfilter_get_by_name("aformat"),
"format", fmtstr, NULL, graph) < 0)
goto error;
r = av_opt_set_int(out, "all_channel_counts", 1, AV_OPT_SEARCH_CHILDREN);
if (r < 0)
if (avfilter_link(f_format, 0, out, 0) < 0)
goto error;
outputs->name = av_strdup("in");
outputs->filter_ctx = in;
inputs->name = av_strdup("out");
inputs->filter_ctx = out;
inputs->filter_ctx = f_format;
if (graph_parse(graph, p->cfg_graph, inputs, outputs, NULL) < 0)
goto error;
@@ -191,8 +194,6 @@ static int control(struct af_instance *af, int cmd, void *arg)
struct mp_chmap out_cm;
mp_chmap_from_lavc(&out_cm, l_out->channel_layout);
if (!out_cm.num || out_cm.num != l_out->channels)
mp_chmap_from_channels(&out_cm, l_out->channels);
mp_audio_set_channels(out, &out_cm);
if (!mp_audio_config_valid(out))
@@ -223,9 +224,12 @@ static int filter(struct af_instance *af, struct mp_audio *data, int flags)
// Timebase is 1/sample_rate
frame->pts = p->samples_in;
av_frame_set_channels(frame, l_in->channels);
av_frame_set_channel_layout(frame, l_in->channel_layout);
av_frame_set_sample_rate(frame, l_in->sample_rate);
frame->channel_layout = l_in->channel_layout;
frame->sample_rate = l_in->sample_rate;
#if LIBAVFILTER_VERSION_MICRO >= 100
// FFmpeg being a stupid POS
frame->channels = l_in->channels;
#endif
frame->extended_data = frame->data;
for (int n = 0; n < data->num_planes; n++)
@@ -293,14 +297,14 @@ static int af_open(struct af_instance *af)
#define OPT_BASE_STRUCT struct priv
struct af_info af_info_lavfi = {
const struct af_info af_info_lavfi = {
.info = "libavfilter bridge",
.name = "lavfi",
.open = af_open,
.priv_size = sizeof(struct priv),
.options = (const struct m_option[]) {
OPT_STRING("graph", cfg_graph, 0),
OPT_STRING("o", cfg_avopts, 0),
OPT_KEYVALUELIST("o", cfg_avopts, 0),
{0}
},
};
+7 -33
View File
@@ -37,7 +37,6 @@
#if HAVE_LIBAVRESAMPLE
#include <libavresample/avresample.h>
#define USE_SET_CHANNEL_MAPPING HAVE_AVRESAMPLE_SET_CHANNEL_MAPPING
#elif HAVE_LIBSWRESAMPLE
#include <libswresample/swresample.h>
#define AVAudioResampleContext SwrContext
@@ -49,17 +48,15 @@
#define avresample_convert(ctx, out, out_planesize, out_samples, in, in_planesize, in_samples) \
swr_convert(ctx, out, out_samples, (const uint8_t**)(in), in_samples)
#define avresample_set_channel_mapping swr_set_channel_mapping
#define USE_SET_CHANNEL_MAPPING 1
#else
#error "config.h broken or no resampler found"
#endif
#include "common/av_common.h"
#include "common/msg.h"
#include "options/m_option.h"
#include "common/av_opts.h"
#include "audio/filter/af.h"
#include "audio/fmt-conversion.h"
#include "audio/reorder_ch.h"
struct af_resample_opts {
int filter_size;
@@ -77,7 +74,7 @@ struct af_resample_opts {
struct af_resample {
int allow_detach;
char *avopts;
char **avopts;
struct AVAudioResampleContext *avrctx;
struct AVAudioResampleContext *avrctx_out; // for output channel reordering
struct af_resample_opts ctx; // opts in the context
@@ -167,10 +164,8 @@ static int configure_lavrr(struct af_instance *af, struct mp_audio *in,
av_opt_set_double(s->avrctx, "cutoff", s->ctx.cutoff, 0);
if (parse_avopts(s->avrctx, s->avopts) < 0) {
MP_FATAL(af, "af_lavrresample: could not set opts: '%s'\n", s->avopts);
if (mp_set_avopts(af->log, s->avrctx, s->avopts) < 0)
return AF_ERROR;
}
struct mp_chmap map_in = in->channels;
struct mp_chmap map_out = out->channels;
@@ -210,18 +205,16 @@ static int configure_lavrr(struct af_instance *af, struct mp_audio *in,
av_opt_set_int(s->avrctx_out, "in_sample_rate", s->ctx.out_rate, 0);
av_opt_set_int(s->avrctx_out, "out_sample_rate", s->ctx.out_rate, 0);
#if USE_SET_CHANNEL_MAPPING
// API has weird requirements, quoting avresample.h:
// * This function can only be called when the allocated context is not open.
// * Also, the input channel layout must have already been set.
avresample_set_channel_mapping(s->avrctx, s->reorder_in);
avresample_set_channel_mapping(s->avrctx_out, s->reorder_out);
#endif
if (avresample_open(s->avrctx) < 0 ||
avresample_open(s->avrctx_out) < 0)
{
MP_ERR(af, "[lavrresample] Cannot open "
MP_ERR(af, "Cannot open "
"Libavresample Context. \n");
return AF_ERROR;
}
@@ -319,17 +312,6 @@ static void reorder_planes(struct mp_audio *mpa, int *reorder)
}
}
#if !USE_SET_CHANNEL_MAPPING
static void do_reorder(struct mp_audio *mpa, int *reorder)
{
if (af_fmt_is_planar(mpa->format)) {
reorder_planes(mpa, reorder);
} else {
reorder_channels(mpa->planes[0], reorder, mpa->bps, mpa->nch, mpa->samples);
}
}
#endif
static int filter(struct af_instance *af, struct mp_audio *data, int flags)
{
struct af_resample *s = af->priv;
@@ -344,10 +326,6 @@ static int filter(struct af_instance *af, struct mp_audio *data, int flags)
af->delay = get_delay(s) / (double)s->ctx.in_rate;
#if !USE_SET_CHANNEL_MAPPING
do_reorder(in, s->reorder_in);
#endif
if (out->samples) {
out->samples = avresample_convert(s->avrctx,
(uint8_t **) out->planes, out->samples * out->sstride, out->samples,
@@ -358,7 +336,6 @@ static int filter(struct af_instance *af, struct mp_audio *data, int flags)
*data = *out;
#if USE_SET_CHANNEL_MAPPING
if (needs_reorder(s->reorder_out, out->nch)) {
if (af_fmt_is_planar(out->format)) {
reorder_planes(data, s->reorder_out);
@@ -373,9 +350,6 @@ static int filter(struct af_instance *af, struct mp_audio *data, int flags)
assert(out_samples == data->samples);
}
}
#else
do_reorder(data, s->reorder_out);
#endif
return 0;
}
@@ -397,7 +371,7 @@ static int af_open(struct af_instance *af)
if (s->avrctx && s->avrctx_out) {
return AF_OK;
} else {
MP_ERR(af, "[lavrresample] Cannot initialize "
MP_ERR(af, "Cannot initialize "
"Libavresample Context. \n");
uninit(af);
return AF_ERROR;
@@ -406,7 +380,7 @@ static int af_open(struct af_instance *af)
#define OPT_BASE_STRUCT struct af_resample
struct af_info af_info_lavrresample = {
const struct af_info af_info_lavrresample = {
.info = "Sample frequency conversion using libavresample",
.name = "lavrresample",
.open = af_open,
@@ -426,7 +400,7 @@ struct af_info af_info_lavrresample = {
OPT_FLAG("linear", opts.linear, 0),
OPT_DOUBLE("cutoff", opts.cutoff, M_OPT_RANGE, .min = 0, .max = 1),
OPT_FLAG("detach", allow_detach, 0),
OPT_STRING("o", avopts, 0),
OPT_KEYVALUELIST("o", avopts, 0),
{0}
},
};
+15 -15
View File
@@ -32,7 +32,7 @@
typedef struct af_pan_s
{
int nch; // Number of output channels; zero means same as input
float level[AF_NCH][AF_NCH]; // Gain level for each channel
float level[AF_NCH][AF_NCH]; // Gain level for each channel
char *matrixstr;
}af_pan_t;
@@ -80,7 +80,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
// Sanity check
if(((int*)arg)[0] <= 0 || ((int*)arg)[0] > AF_NCH){
MP_ERR(af, "[pan] The number of output channels must be"
MP_ERR(af, "The number of output channels must be"
" between 1 and %i. Current value is %i\n",AF_NCH,((int*)arg)[0]);
return AF_ERROR;
}
@@ -110,14 +110,14 @@ static int control(struct af_instance* af, int cmd, void* arg)
// Filter data through filter
static int filter(struct af_instance* af, struct mp_audio* data, int flags)
{
struct mp_audio* c = data; // Current working data
struct mp_audio* l = af->data; // Local data
af_pan_t* s = af->priv; // Setup for this instance
float* in = c->planes[0]; // Input audio data
float* out = NULL; // Output audio data
float* end = in+c->samples*c->nch; // End of loop
int nchi = c->nch; // Number of input channels
int ncho = l->nch; // Number of output channels
struct mp_audio* c = data; // Current working data
struct mp_audio* l = af->data; // Local data
af_pan_t* s = af->priv; // Setup for this instance
float* in = c->planes[0]; // Input audio data
float* out = NULL; // Output audio data
float* end = in+c->samples*c->nch; // End of loop
int nchi = c->nch; // Number of input channels
int ncho = l->nch; // Number of output channels
register int j,k;
mp_audio_realloc_min(af->data, data->samples);
@@ -130,7 +130,7 @@ static int filter(struct af_instance* af, struct mp_audio* data, int flags)
register float x = 0.0;
register float* tin = in;
for(k=0;k<nchi;k++)
x += tin[k] * s->level[j][k];
x += tin[k] * s->level[j][k];
out[j] = x;
}
out+= ncho;
@@ -153,15 +153,15 @@ static int af_open(struct af_instance* af){
int j,k;
int nch = s->nch;
if(AF_OK != control(af,AF_CONTROL_SET_PAN_NOUT, &nch))
if(nch && AF_OK != control(af,AF_CONTROL_SET_PAN_NOUT, &nch))
return AF_ERROR;
// Read pan values
char *cp = s->matrixstr;
j = 0; k = 0;
while(k < AF_NCH){
while(cp && k < AF_NCH){
sscanf(cp, "%f%n" , &s->level[j][k], &n);
MP_VERBOSE(af, "[pan] Pan level from channel %i to"
MP_VERBOSE(af, "Pan level from channel %i to"
" channel %i = %f\n",k,j,s->level[j][k]);
cp =&cp[n];
j++;
@@ -177,7 +177,7 @@ static int af_open(struct af_instance* af){
}
#define OPT_BASE_STRUCT af_pan_t
struct af_info af_info_pan = {
const struct af_info af_info_pan = {
.info = "Panning audio filter",
.name = "pan",
.open = af_open,
+7 -7
View File
@@ -275,7 +275,7 @@ static int control(struct af_instance *af, int cmd, void *arg)
int nch = data->nch;
int use_int = 0;
MP_VERBOSE(af, "[scaletempo] %.3f speed * %.3f scale_nominal = %.3f\n",
MP_VERBOSE(af, "%.3f speed * %.3f scale_nominal = %.3f\n",
s->speed, s->scale_nominal, s->scale);
mp_audio_force_interleaved_format(data);
@@ -317,7 +317,7 @@ static int control(struct af_instance *af, int cmd, void *arg)
s->buf_overlap = realloc(s->buf_overlap, s->bytes_overlap);
s->table_blend = realloc(s->table_blend, s->bytes_overlap * 4);
if (!s->buf_overlap || !s->table_blend) {
MP_FATAL(af, "[scaletempo] Out of memory\n");
MP_FATAL(af, "Out of memory\n");
return AF_ERROR;
}
memset(s->buf_overlap, 0, s->bytes_overlap);
@@ -354,7 +354,7 @@ static int control(struct af_instance *af, int cmd, void *arg)
s->table_window = realloc(s->table_window,
s->bytes_overlap * 2 - nch * bps * 2);
if (!s->buf_pre_corr || !s->table_window) {
MP_FATAL(af, "[scaletempo] Out of memory\n");
MP_FATAL(af, "Out of memory\n");
return AF_ERROR;
}
memset((char *)s->buf_pre_corr + s->bytes_overlap * 2, 0,
@@ -371,7 +371,7 @@ static int control(struct af_instance *af, int cmd, void *arg)
s->table_window = realloc(s->table_window,
s->bytes_overlap - nch * bps);
if (!s->buf_pre_corr || !s->table_window) {
MP_FATAL(af, "[scaletempo] Out of memory\n");
MP_FATAL(af, "Out of memory\n");
return AF_ERROR;
}
float *pw = s->table_window;
@@ -391,14 +391,14 @@ static int control(struct af_instance *af, int cmd, void *arg)
* bps * nch;
s->buf_queue = realloc(s->buf_queue, s->bytes_queue + UNROLL_PADDING);
if (!s->buf_queue) {
MP_FATAL(af, "[scaletempo] Out of memory\n");
MP_FATAL(af, "Out of memory\n");
return AF_ERROR;
}
s->bytes_queued = 0;
s->bytes_to_slide = 0;
MP_DBG(af, "[scaletempo] "
MP_DBG(af, ""
"%.2f stride_in, %i stride_out, %i standing, "
"%i overlap, %i search, %i queue, %s mode\n",
s->frames_stride_scaled,
@@ -467,7 +467,7 @@ static int af_open(struct af_instance *af)
#define OPT_BASE_STRUCT af_scaletempo_t
struct af_info af_info_scaletempo = {
const struct af_info af_info_scaletempo = {
.info = "Scale audio tempo while maintaining pitch",
.name = "scaletempo",
.open = af_open,
+10 -10
View File
@@ -57,14 +57,14 @@ static int control(struct af_instance* af, int cmd, void* arg)
#if 0
if (((struct mp_audio*)arg)->format == AF_FORMAT_FLOAT)
{
af->data->format = AF_FORMAT_FLOAT;
af->data->bps = 4;
af->play = play_float;
af->data->format = AF_FORMAT_FLOAT;
af->data->bps = 4;
af->play = play_float;
}// else
#endif
{
mp_audio_set_format(af->data, AF_FORMAT_S16);
af->filter = play_s16;
af->filter = play_s16;
}
return af_test_output(af,(struct mp_audio*)arg);
@@ -78,8 +78,8 @@ static int play_s16(struct af_instance* af, struct mp_audio* data, int f)
{
af_sinesuppress_t *s = af->priv;
register int i = 0;
int16_t *a = (int16_t*)data->planes[0]; // Audio data
int len = data->samples*data->nch; // Number of samples
int16_t *a = (int16_t*)data->planes[0]; // Audio data
int len = data->samples*data->nch; // Number of samples
for (i = 0; i < len; i++)
{
@@ -99,7 +99,7 @@ static int play_s16(struct af_instance* af, struct mp_audio* data, int f)
s->pos += 2 * M_PI * s->freq / data->rate;
}
MP_VERBOSE(af, "[sinesuppress] f:%8.2f: amp:%8.2f\n", s->freq, sqrt(s->real*s->real + s->imag*s->imag) / s->ref);
MP_VERBOSE(af, "f:%8.2f: amp:%8.2f\n", s->freq, sqrt(s->real*s->real + s->imag*s->imag) / s->ref);
return 0;
}
@@ -109,8 +109,8 @@ static struct mp_audio* play_float(struct af_instance* af, struct mp_audio* data
{
af_sinesuppress_t *s = af->setup;
register int i = 0;
float *a = (float*)data->audio; // Audio data
int len = data->len/4; // Number of samples
float *a = (float*)data->audio; // Audio data
int len = data->len/4; // Number of samples
float avg, l, r;
for (i = 0; i < len; i+=2)
@@ -136,7 +136,7 @@ static int af_open(struct af_instance* af){
}
#define OPT_BASE_STRUCT af_sinesuppress_t
struct af_info af_info_sinesuppress = {
const struct af_info af_info_sinesuppress = {
.info = "Sine Suppress",
.name = "sinesuppress",
.open = af_open,
+17 -17
View File
@@ -41,22 +41,22 @@
// Analog domain biquad section
typedef struct{
float a[3]; // Numerator coefficients
float b[3]; // Denominator coefficients
float a[3]; // Numerator coefficients
float b[3]; // Denominator coefficients
} biquad_t;
// S-parameters for designing 4th order Butterworth filter
static biquad_t sp[2] = {{{1.0,0.0,0.0},{1.0,0.765367,1.0}},
{{1.0,0.0,0.0},{1.0,1.847759,1.0}}};
static const biquad_t sp[2] = {{{1.0,0.0,0.0},{1.0,0.765367,1.0}},
{{1.0,0.0,0.0},{1.0,1.847759,1.0}}};
// Data for specific instances of this filter
typedef struct af_sub_s
{
float w[2][4]; // Filter taps for low-pass filter
float q[2][2]; // Circular queues
float fc; // Cutoff frequency [Hz] for low-pass filter
float k; // Filter gain;
int ch; // Channel number which to insert the filtered data
float w[2][4]; // Filter taps for low-pass filter
float q[2][2]; // Circular queues
float fc; // Cutoff frequency [Hz] for low-pass filter
float k; // Filter gain;
int ch; // Channel number which to insert the filtered data
}af_sub_t;
@@ -92,7 +92,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
float h0 = (q)[0]; \
float h1 = (q)[1]; \
float hn = (in) - h0 * (w)[0] - h1 * (w)[1]; \
out = hn + h0 * (w)[2] + h1 * (w)[3]; \
out = hn + h0 * (w)[2] + h1 * (w)[3]; \
(q)[1] = h0; \
(q)[0] = hn; \
}
@@ -101,12 +101,12 @@ static int control(struct af_instance* af, int cmd, void* arg)
// Filter data through filter
static int filter(struct af_instance* af, struct mp_audio* data, int flags)
{
struct mp_audio* c = data; // Current working data
af_sub_t* s = af->priv; // Setup for this instance
float* a = c->planes[0]; // Audio data
int len = c->samples*c->nch; // Number of samples in current audio block
int nch = c->nch; // Number of channels
int ch = s->ch; // Channel in which to insert the sub audio
struct mp_audio* c = data; // Current working data
af_sub_t* s = af->priv; // Setup for this instance
float* a = c->planes[0]; // Audio data
int len = c->samples*c->nch; // Number of samples in current audio block
int nch = c->nch; // Number of channels
int ch = s->ch; // Channel in which to insert the sub audio
register int i;
// Run filter
@@ -128,7 +128,7 @@ static int af_open(struct af_instance* af){
}
#define OPT_BASE_STRUCT af_sub_t
struct af_info af_info_sub = {
const struct af_info af_info_sub = {
.info = "Audio filter for adding a sub-base channel",
.name = "sub",
.flags = AF_FLAGS_NOT_REENTRANT,
Loaded 100 of 502 files, more files were not shown because too many files have changed in this diff. Show more