Commit Graph

35364 Commits

Author SHA1 Message Date
wm4 bbc865a4da gl_video: add some debug code for testing texture depth
This probes and prints the depth of some texture formats with the help
of a FBO. By default it tests the format used for scaling, as well as
the format used for dithering and the 3D LUT (if any of these are
enabled).

The output is visible only with -v. Some representative values are
probed, and the difference of input and output value is printed as hex-
float. Hex-floats are used because they make the implied precision more
obvious. Originally I wanted to do some more sophisticated guessing of
the implied depth/precision for more user-friendly reporting, but then
I decided that printing raw data is better for debugging, especially if
things go wrong.

This does not try to disable any functionality and does not print any
warnings if the depth is lower than what it should be.
2013-05-30 15:55:41 +02:00
wm4 5d0c4b6ac3 gl_video: change a GLSL statement
This might be better with dumb shader compilers, which won't vectorize
this to a single vector-division, assuming the hardware does have such
an instruction. Affects "bicubic_fast" scale mode only.
2013-05-30 15:40:55 +02:00
wm4 e08bf272ee gl_video: fix some dithering bugs
The internal texture format GL_RED is typically 8 bit, which is clearly
not good enough for the new dither matrix. The idea was to use a float
texture format, but this was somehow "forgotten". Use GL_R16, since
16 bit textures are more robust, and provide more precision for the
same memory usage.

Change how the offset for centering the dither matrix is applied. This
is needed for making it possible to round up values to the target depth.
Before this commit, this changed the output even if the input was exact
and input and output depth were the same, which is not really what you
want. Now it doesn't do that anymore.
2013-05-30 15:38:07 +02:00
wm4 6bfbca9912 core: avoid deselecting and reselecting stream needlessly
The core deselected all streams on initialization, and then selected the
streams it actually wanted. This was no problem for
demux_mkv/demux_lavf, but old demuxers (like demux_asf) could lose some
packets. The problem is that these demuxers can buffer some data on
initialization, which then is flushed on track switching. Fix this by
explicitly avoiding deselecting a wanted stream.
2013-05-29 14:57:05 +02:00
wm4 fa75ae96e1 demux_asf: fix after commit 5165e19
This demuxer reallocated packets on its own, instead of using the
demux.c functions, which clashed with a recent change.
2013-05-29 14:57:05 +02:00
wm4 a21cfddaab options: remove some questionable -lavdopts suboptions
Most of these are rather questionable, the rest you rarely need to set
manually. You still can set all of them with -lavdopts-o (because
libavcodec has AVOptions for them).
2013-05-29 14:57:05 +02:00
wm4 362e0aa7d5 mplayer: fix volume setting with --gapless-audio
Playing something with "mpv f1.mkv f2.mkv --gapless-audio --volume=20"
caused the volume to be reset when playing a new file. Normally, the
volume should not be reset (unless explicitly requested with per-file
options), and without either --gapless-audio or --volume it works as
expected.

The underlying problem is that volume was saved only when the AO was
uninitialized, and also the volume was always set when starting a file.
Fix this by saving the volume when playback ends, and when the audio
is reinitialized. To make sure the volume is never restored twice or
saved in the wrong situation, introduce INITIALIZED_VOL.

Also note that this volume saving and restoring only happens if the
--volume option is used. mixer.c does its own bookkeeping of volume.
The main reason for this is that the volume option could be reset by
per-file options (see manpage), and mixer.c doesn't know anything
about this stuff. This is probably dumb, and maybe some things could
be simplified. But for now this will work.
2013-05-29 14:56:35 +02:00
wm4 a9892f901f manpage: fix typo 2013-05-27 23:41:37 +02:00
wm4 cc1b1f773f demuxer_lavf: use audio/mpeg mime type for mp3
Basically, add exactly the same hacks for mp3 as we did for AAC. Should
make starting mp3 streams much faster.
2013-05-27 23:27:59 +02:00
wm4 8cfb87d200 demux_lavf: minimal probing and reduced analyzeduration for AAC over HTTP
When AAC is streamed over HTTP, using libavformat defaults is
pathetically slow. One solution for that is skipping probing and using
the mimetype to identify that it's AAC instead. This is what we did
before this commit (and ffmpeg does it too, but their logic is too
"inaccessible" for mpv).

This is still pretty fragile though. Make it a bit more robust by
requiring minimal probing. A probescore of 25 is reached after feeding
2 KB to libavformat (instead of > 500 KB for the normal probescore), so
use that. This is done only when streaming AAC from HTTP to reduce the
possibility of weird breakages for other formats.

Also reduce analyzeduration. The default analyzeduration will make
libavformat read lots of data, which makes playback start slow. So we
set analyzeduration to a low value. On the other hand, doing that for
other formats is risky, because there are unspecified effects with
certain "strange" formats (like transport streams). So we do this only
if we're streaming AAC from HTTP as well.

tl;dr libavformat is shit for media players
2013-05-27 23:26:22 +02:00
wm4 f05ec1c738 options: add allow-mimetype suboption for demux_lavf
This can control whether demux_lavf should use the HTTP mime type to
determine the format, instead of probing the data with the libavformat
API. Do this to allow easier debugging in case the mimetype is
incorrect. (This is done only for AAC streams right now.)
2013-05-27 22:48:04 +02:00
wm4 7ea5d085f9 mplayer: output status line normally with --no-consolecontrols
In commit 0e07189, I made the status line always print a newline,
instead of cutting the output at 80 columns (or if stderr is a terminal,
whatever width the terminal reports). This is better in the case the
output goes into a log file or a pipe.

This caused problems for people who want to pipe raw video to mpv, so
change it again. (Not sure why they won't use FIFOs instead.)

Now output untrimmed lines if the slave mode flag is set, which makes
sense to do, too. The current slave mode is still on life support,
though.
2013-05-27 22:28:03 +02:00
Stefano Pigozzi 41e6c922a5 macosx_application: fix menu 'ghosting'
This fixes a bug that caused the application to never leave it's frontmost
position.

The idea is stolen from @donmelton who used it in MPlayerShell. Thanks!
2013-05-26 23:46:50 +02:00
wm4 953b0eca3b manpage: fix typo 2013-05-26 19:37:59 +02:00
wm4 9a2a410d3f manpage: mark some filters as deprecated in favor of libavfilter
This is basically a "do not use" label. We don't remove them yet,
because we still support FFmpeg releases where we can not use
libavfilter for various reasons. Also, Libav causes pain as usual
due to the lack of ported mplayer filters in its codebase, so not
all filters will be available there.
2013-05-26 17:31:21 +02:00
wm4 f3f77c6e31 vo_opengl: remove most of the "inline" documentation
There's no point duplicating all the text that is already in the man
pages, and synchronizing them is a pain. Place a link to the github
generated pages instead.

Unfortunately, the anchor '#vo-opengl' does not work. Maybe github's
rst converter just sucks, as the actually generated HTML contains
links using that anchor too, but does not generate the anchor itself.
Too bad.
2013-05-26 17:20:01 +02:00
wm4 3edb8fb71c vf_delogo: copy in non-direct case, fix double-free
If the image is not writeable, the image actually has to be copied
beforehand. This was overlooked when converting the video chain to
reference counted images.

Fix a double free issue. This was overlooked when vf.c was changed to
free filter priv data automatically.
2013-05-26 17:13:09 +02:00
wm4 f55f99ce19 stream: kill STREAM_CTRL_RESET
Was unused.
2013-05-26 17:13:09 +02:00
wm4 3d6b4ea4b6 stream: kill memory streams
These are unused by now, and it relied on some assumptions that have
been broken by now.
2013-05-26 17:13:09 +02:00
wm4 3face4300e demux_lavf: print how many bytes are read by avformat_find_stream_info()
Can be helpful for debugging slow stream startup.

Also add a comment about BIO_BUFFER_SIZE.
2013-05-26 17:01:54 +02:00
wm4 137c1032fa stream: de-inline some larger functions
Tests with demux_mkv show that the speed doesn't change (or actually,
it seems to be faster after this change). In any case, there is not
the slightest reason why these should be inline. Functions for which
this will (probably) actually matter, like stream_read_char, are
still left inline.

This was tested with demux_mkv's indexing. For broken files without
index, demux_mkv creates an on-the-fly index. If you seek to a later
part of the file, all data has to be read and parsed until the wanted
position is found. This means demux_mkv will do mostly I/O, calling
stream_read_char() and stream_read(). This should be the most I/O
intensive non-deprecated part of mpv that uses the stream interface.
(demux_lavf has its own buffering.)
2013-05-26 16:55:20 +02:00
wm4 58a7d81dc5 gl_video: improve dithering
Use a different algorithm to generate the dithering matrix. This
looks much better than the previous ordered dither matrix with its
cross-hatch artifacts.

The matrix generation algorithm as well as its implementation was
contributed by Wessel Dankers aka Fruit. The code in dither.c is
his implementation, reformatted and with static global variables
removed by me.

The new matrix is uploaded as float texture - before this commit, it
was a normal integer fixed point matrix. This means dithering will
be disabled on systems without float textures.

The size of the dithering matrix can be configured, as the matrix is
generated at runtime. The generation of the matrix can take rather
long, and is already unacceptable with size 8. The default is at 6,
which takes about 100 ms on a Core2 Duo system with dither.c compiled
at -O2, which I consider just about acceptable.

The old ordered dithering is still available and can be selected by
putting the dither=ordered sub-option. The ordered dither matrix
generation code was moved to dither.c. This function was originally
written by Uoti Urpala.
2013-05-26 16:44:20 +02:00
wm4 39225ed196 gl_video: add scaler-resizes-only sub-option
This option disables the scaler set with lscale if the video image is
not resized.
2013-05-26 16:44:20 +02:00
wm4 f44a242258 Replace calls to usec_sleep()
This is just dumb sed replacement to mp_sleep_us().

Also remove the now unused usec_sleep() wrapper.
2013-05-26 16:44:20 +02:00
wm4 e56d8a200d Replace all calls to GetTimer()/GetTimerMS()
GetTimer() is generally replaced with mp_time_us(). Both calls return
microseconds, but the latter uses int64_t, us defined to never wrap,
and never returns 0 or negative values.

GetTimerMS() has no direct replacement. Instead the other functions are
used.

For some code, switch to mp_time_sec(), which returns the time as double
float value in seconds. The returned time is offset to program start
time, so there is enough precision left to deliver microsecond
resolution for at least 100 years. Unless it's casted to a float
(or the CPU reduces precision), which is why we still use mp_time_us()
out of paranoia in places where precision is clearly needed.

Always switch to the correct time. The whole point of the new timer
calls is that they don't wrap, and storing microseconds in unsigned int
variables would negate this.

In some cases, remove wrap-around handling for time values.
2013-05-26 16:44:20 +02:00
wm4 51254a678c vo: rip out VO timer wakeup mechanism again
This was used by some VOs to do timing of cursor autohiding, but we
recently moved that out of the VOs. Even though this mechanism might
be a good idea and could be needed again in future (but for what?),
it's unused now. So better just get rid of it.
2013-05-26 16:44:20 +02:00
wm4 561aab2d77 timer: use gettimeofday() on Windows
MinGW-w64 emulates this via GetSystemTimeAsFileTime(), which has
supposedly the best and most stable timer source out of most others.

http://mingw-w64.svn.sourceforge.net/viewvc/mingw-w64/trunk/mingw-w64-crt/misc/gettimeofday.c
2013-05-26 16:44:20 +02:00
wm4 81439c5f35 timer: refactor, add 64 bit timer function
Make OS specific timer code export a mp_raw_time_us() function, and
add generic implementations of GetTimer()/GetTimerMS() using this
function. New mpv code is supposed to call mp_time_us() in situations
where precision is absolutely needed, or mp_time_s() otherwise.

Make it so that mp_time_us() will return a value near program start.
We don't set it to 0 though to avoid confusion with relative vs.
absolute time. Instead, pick an arbitrary offset.

Move the test program in timer-darwin.c to timer.c, and modify it to
work with the generic timer functions.
2013-05-26 16:44:20 +02:00
Stefano Pigozzi 25d66f526e cocoa_common: send mouse moved events to core when dragging
This change fixes mouse autohide when dragging mouse.
2013-05-26 16:44:20 +02:00
Alexander Preisinger 405182af46 wayland: use VOCTRL_SET_CURSOR_VISIBILITY 2013-05-26 16:44:19 +02:00
Alexander Preisinger bb9b6501fd wayland: introduce vo_wayland_config
This removes the need for exposing vo_wayland_fullscreen and other functions
also this will be usefull for other vos in the future.
2013-05-26 16:44:19 +02:00
Stefano Pigozzi e6a225d57a cocoa_common: implement VOCTRL_SET_CURSOR_VISIBILITY
Pass along cursor visibility hints to be more consistent with OSX's behaviour.
2013-05-26 16:44:19 +02:00
Stefano Pigozzi ea8a8af3ec cocoa_common: implement mouse movement notifications
Notify the core of mouse movement events. The coordinates are converted to a
coordinate system with the origin in upper left corner, since Cocoa has it in
the lower left corner.
2013-05-26 16:44:19 +02:00
wm4 8fe357380e w32: use VOCTRL_SET_CURSOR_VISIBILITY
This didn't even implement --cursor-autohide. Now it does, and the
behavior of the VOs under Windows change accordingly.
2013-05-26 16:44:19 +02:00
wm4 6ab719f698 vo_sdl: use VOCTRL_SET_CURSOR_VISIBILITY 2013-05-26 16:44:19 +02:00
wm4 c76c65441a x11: remove cursor hiding logic, use VOCTRL_SET_CURSOR_VISIBILITY 2013-05-26 16:44:19 +02:00
wm4 3c8f8b7714 core: do mouse cursor hiding business in frontend
Do this so that not every VO backend has to setup a timer for cursor
hiding and interpret the --cursor-autohide option.
2013-05-26 16:44:19 +02:00
wm4 8df780cb50 vo: remove vo.check_events callback
Use VOCTRL_CHECK_EVENTS instead. Change the remaining VOs to use it.
Only vo_sdl and vo_caca actually need this, and vo_null, vo_lavc, and
vo_image had stubs only.
2013-05-26 16:44:19 +02:00
wm4 526e969419 w32: use vo_w32_control() for all VOs 2013-05-26 16:44:19 +02:00
wm4 d5de75b340 x11: use vo_x11_control() for all VOs 2013-05-26 16:44:19 +02:00
wm4 bf10a4fdfa video/out: introduce vo_control for gl_common based VOs
Instead of having separate callbacks for each backend-handled feature
(like MPGLContext.fullscreen, MPGLContext.border, etc.), pass the
VOCTRL responsible for this directly to the backend. This allows
removing a bunch of callbacks, that currently must be set even for
optional/lesser features (like VOCTRL_BORDER).

This requires changes to all VOs using gl_common, as well as all
backends that support gl_common.

Also introduce VOCTRL_CHECK_EVENTS. vo.check_events is now optional.
VO backends can use VOCTRL_CHECK_EVENTS instead to implementing
check_events. This has the advantage that the event handling code in
VOs doesn't have to be duplicated if vo_control() is used.
2013-05-26 16:44:18 +02:00
wm4 c23bf5311f vf_lavfi: allow setting avopts 2013-05-26 16:44:18 +02:00
wm4 3546188a41 ao_alsa: always unset ALSA error handler, cleanup on init error
The ALSA device was not closed when initialization failed.

The ALSA error handler (set with snd_lib_error_set_handler()) was not
unset when closing ao_alsa. If this is not done, the handler will still
be called when other libraries using ALSA cause errors, even though
ao_alsa was long closed. Since these messages were prefixed with
"[AO_ALSA]", they were misleading and implying ao_alsa was still used.

For some reason, our error handler is still called even after doing
snd_lib_error_set_handler(NULL), which should be impossible. Checking
with the debuggers, inserting printf(), as well as the alsa-lib source
code all suggest our error handler should not be called, but it still
happens. It's a complete mystery.
2013-05-26 16:44:18 +02:00
Stefano Pigozzi 8db90e18d3 cocoa_common: authohide menu/dock in fullscreen
This simple fix makes it possible to access the MainManu and Dock when in
fullscreen when not using `--native-fs`.
2013-05-26 11:34:35 +02:00
Stefano Pigozzi 29f5429223 macosx_application: implement "Quit & remember position"
Add a menu item to quit and save the current playback position using the code
added with commit ce9a854.

Fixes #85
2013-05-23 20:07:14 +02:00
wm4 60a7f3b8bc af_lavfi: add libavfilter bridge
Mostly copied from vf_lavfi. The parts that could be shared are minor,
because most code is about setting up audio and video, which are too
different.

This won't work with Libav. I used ffplay.c as guide, and noticed too
late that their setup methods are incompatible with Libav's. Trying to
make it work with both would be too much effort. The configure test for
av_opt_set_int_list() should disable af_lavfi gracefully when compiling
with Libav.

Due to option parser chaos, you currently can't have a "," as part of
the filter graph string - not even with quoting or escaping. This will
probably be fixed later.

The audio filter chain is not PTS aware. So we have to do some hacks
to make up a fake PTS, and we have to map the output PTS back to the
filter chain's method of tracking PTS changes and buffering, by
adjusting af->delay.
2013-05-23 17:44:06 +02:00
wm4 5bdf9d01ca demux_mkv: defer reading of seek index until first seek
Playing Youtube videos often requires an additional seek to the end of
the file. This flushes the stream cache. The reason for the seek is
reading the cues (seek index). This poses the question why Google is
muxing its files in such a way, since nothing in Matroska mandates that
cues are located at the end of the file, but we want to handle this
situation better anyway.

The seek index is not needed for normal playback, only for seeking.
This commit changes header parsing such that the index is not read on
initialization in order to avoid the additional stream-level seek.
Instead, read the index on the first demuxer-level seek, when the seek
index is actually needed.

If the cues are at the beginning of the file, they are read immediately
as part of the normal header reading process. This commit changes
behavior only if cues are outside of the header (i.e. not in the area
between EBML header and clusters), and linked by a SeekHead. Other
level 1 elements linked by the SeekHead might still cause seeks to the
end of the file, although that seems to be rare.
2013-05-23 01:02:24 +02:00
wm4 1139eae082 demux_mkv: use a single flag to indicate whether cues have been read
Before this commit, the demuxer would in theory accept multiple cues
elements (and append its contents to the index in the order as
encountered during reading). According to the Matroska specification,
there can be only one cues element in the segment, so this seems like
an overcomplication.

Change it so that redundant elements are ignored, like with all other
unique header elements. This makes implementing deferred reading of the
cues element easier.
2013-05-23 01:02:24 +02:00
wm4 89b8154aad command: auto-insert yadif when switching deinterlacing
If VO deinterlacing is unavailable, try to insert vf_yadif.

If vf_lavfi is available, actually use vf_yadif from libavfilter. The
libavfilter version of this filter is faster, more correct, etc., so it
is preferred. Unfortunately vf_yadif obviously doesn't support
VFCTRL_GET/SET_DEINTERLACE, and with the current state of the
libavfilter API, it doesn't look like there is any simple way to
emulate it. Instead, we simply insert the filter with a specific label,
and if deinterlacing is to be disabled, the filter is removed again by
label.

This won't do the right thing if the user inserts any deinterlacing
filter manually (except native vf_yadif, which understands the VFCTRL).
For example, with '-vf lavfi=yadif', pressing 'D' (toggle deinterlacing)
will just insert a second deinterlacer filter. In these cases, the user
is supposed to map a command that toggles his own filter instead of
using 'D' and the deinterlace property.

The same applies if the user wants to pass different parameters to the
deinterlacer filters.
2013-05-23 01:02:24 +02:00
wm4 862989c011 m_option: allow removing filter entries by content with -vf-del
If a complete filter description is passed to -vf-del, search for an
existing filter with the same label or the same name/arguments, and
delete it. The rules for filter entry equality are the same as with
the -vf-toggle option.

E.g.

-vf-add gradfun=123:gradfun=456
-vf-del gradfun=456

does what you would expect.
2013-05-23 01:02:24 +02:00