Commit Graph

1227 Commits

Author SHA1 Message Date
wm4 e18ffd6b99 Merge branch 'remove_old_demuxers'
The merged branch doesn't actually just remove old demuxers, but also
includes a branch of cleanups and some refactoring.

Conflicts:
	stream/stream.c
2013-07-14 17:59:26 +02:00
wm4 cfa571253a demux_rawvideo/demux_rawaudio: move both demuxers to demux_raw.c
This allows them to share some trivial code. Both demuxers are still
separate from user perspective.
2013-07-12 23:06:53 +02:00
wm4 3269bd1780 demux: rewrite probing and demuxer initialization
Get rid of the strange and messy reliance on DEMUXER_TYPE_ constants.
Instead of having two open functions for the demuxer callbacks (which
somehow are both optional, but you can also decide to implement both...),
just have one function. This function takes a parameter that tells the
demuxer how strictly it should check for the file headers. This is a
nice simplification and allows more flexibility.

Remove the file extension code. This literally did nothing (anymore).

Change demux_lavf so that we check our other builtin demuxers first
before libavformat tries to guess by file extension.
2013-07-12 22:16:26 +02:00
wm4 dc95504a52 build: change vf_dlopen test
Didn't work on Windows. Apparently, WIN32 is not set in the Makefile.
2013-07-12 18:33:39 +02:00
wm4 186f6021b1 core: move code from demux/video.c to mplayer.c
Although I don't like putting even more crap into mplayer.c, this is a
bit better, especially with coming cleanups in mind.
2013-07-10 02:07:26 +02:00
Rudolf Polzer 1d48b11478 configure: add libdl detection to ladspa, vf_dlopen 2013-07-09 09:28:42 +02:00
wm4 af0c41e162 Remove old demuxers
Delete demux_avi, demux_asf, demux_mpg, demux_ts. libavformat does
better than them (except in rare corner cases), and the demuxers have
a bad influence on the rest of the code. Often they don't output
proper packets, and require additional audio and video parsing. Most
work only in --no-correct-pts mode.

Remove them to facilitate further cleanups.
2013-07-07 23:54:11 +02:00
wm4 659a314a19 osdep: remove unused mmap compatibility hacks
Not sure how this worked. Only af_export.c and tvi_v4l2.c were
using mmap, but they didn't include osdep/mmap.h or mmap_anon.h. In
any case, we trust that the target system is sufficiently POSIX
compliant if mmap is actually defined (as checked by configure).
2013-07-07 21:44:37 +02:00
wm4 4caa3356b2 Remove some leftovers from network removal
stream_vstream.c in particular was actually dependent on the network
code, and didn't compile anymore.

Cleanup the protocol list in mpv.rst, and add some missing ones
supported by libavformat to stream_lavf.c.
2013-07-07 21:10:44 +02:00
wm4 854303ad49 Remove internal network support
This commit removes the "old" networking code in favor of libavformat's
code.

The code was still used for mp_http, udp, ftp, cddb. http has been
mapped to libavformat's http support since approximately 6 months ago.
udp and ftp have support in ffmpeg (though ftp was added only last
month). cddb support is removed with this commit - it's probably not
important and rarely used if at all, so we don't care about it.
2013-07-07 19:42:38 +02:00
wm4 70a8079c8e core: remove mp_fifo indirection
For some reason mp_fifo specifically handled double clicks, and other
than that was a pointless wrapper around input.c functionality.

Move the double click handling into input.c, and get rid of mp_fifo. Add
some compatibility wrappers, because so much VO code uses these
functions. Where struct mp_fifo is still used it's just a casted
struct input_ctx.
2013-07-02 14:00:24 +02:00
wm4 5f664d78e6 core: add libquvi 0.9 support
This adds support for libquvi 0.9.x, and these features:
- start time (part of youtube URL)
- youtube subtitles
- alternative source switching ('l' and 'L' keys)
- youtube playlists

Note that libquvi 0.9 is still in development. Although this seems to
be API stable now, it looks like there will be a 1.0 release, which is
supposed to be the next stable release and the actual successor of
libquvi 0.4.x.
2013-06-28 15:47:35 +02:00
wm4 ac79eb7337 core: rename mplayer.h and quvi.c
mplayer.h used to be used for much more stuff, but all what is left are
quvi related definitions. Rename quvi.c as well to make its purpose
clearer.
2013-06-28 15:40:28 +02:00
wm4 1327eeb375 stream: redo memory streams
Make memory streams actual streams. This causes fewer weird corner cases
and actually allows using demuxers with them.
2013-06-28 15:40:15 +02:00
wm4 403a266d46 Merge branch 'sub_mess2'
...the return.
2013-06-25 00:43:04 +02:00
wm4 709389ce65 sub: add hack for Libav SRT demuxer
Before this commit, SRT demuxing and display actually happened to work
on Libav. But it was using the libavcodec srt converter (which is
essentially unmaintained in Libav), and timing postprocessing didn't
work. For some background explanations see sd_lavf_srt.c.
2013-06-25 00:11:57 +02:00
wm4 f735a03346 sub: add subtitle charset conversion
This code was once part of subreader.c, then traveled to libass, and now
made its way back to the fork of the fork of the original code, MPlayer.

It works pretty much the same as subreader.c, except that we have to
concatenate some packets to do auto-detection. This is rather annoying,
but for all we know the actual source file could be a binary format.

Unlike subreader.c, the iconv context is reopened on each packet. This
is simpler, and with respect to multibyte encodings, more robust.
Reopening is probably not a very fast, but I suspect subtitle charset
conversion is not an operation that happens often or has to be fast.

Also, this auto-detection is disabled for microdvd - this is the only
format we know that has binary data in its packets, but is actually
decoded to text. FFmpeg doesn't really allow us to solve this properly,
because a) the input packets can be binary, and b) the output will be
checked whether it's UTF-8, and if it's not, the output is thrown away
and an error message is printed. We could just recode the decoded
subtitles before sd_ass if it weren't for that.
2013-06-25 00:11:56 +02:00
wm4 cfa45c40dc sub: add demux_libass wrapper, drop old hacks
demux_libass.c allows us to make subtitle format detection part of the
normal file loading process. libass has no probe function, but trying to
load the start of a file (the first 4 KB) is good enough. Hope that
libass can even handle random binary input gracefully without printing
stupid log messages, and that the libass parser doesn't accept too many
non-ASS files as input.

This doesn't handle the -subcp option correctly yet. This will be fixed
later.
2013-06-25 00:11:56 +02:00
wm4 db2e1ef4d2 Move/rename subreader.c 2013-06-25 00:11:54 +02:00
Jonathan Yong a9f76c6d86 ao_wasapi0: add new wasapi event mode ao 2013-06-18 13:16:58 +02:00
wm4 171d1ef7fe osdep: remove shmem wrapper
This is unused now that the cache is always threaded.
2013-06-18 02:19:15 +02:00
wm4 d81b71c7f7 Merge branch 'cache_new' 2013-06-16 22:07:48 +02:00
Stefano Pigozzi bff03a181f core: add a spsc ringbuffer implementation
Currently every single AO was implementing it's own ringbuffer, many times
with slightly different semantics. This is an attempt to fix the problem.

I stole some good ideas from ao_portaudio's ringbuffer and went from there.
The main difference is this one stores wpos and rpos which are absolute
positions in an "infinite" buffer. To find the actual position for writing /
reading just apply modulo size.

The producer only modifies wpos while the consumer only modifies rpos. This
makes it pretty easy to reason about and make the operations thread safe by
using barriers (thread safety is guaranteed only in the Single-Producer/Single-
Consumer case).

Also adapted ao_coreaudio to use this ringbuffer.
2013-06-16 18:20:39 +02:00
Stefano Pigozzi a66041a332 ao_coreaudio: split ringbuffer in it's own file
This is hopefully the start of something good. ca_ringbuffer_read and
ca_ringbuffer_write can probably cleaned up from all the NULL checks once
ao_coreaudio.c gets simplyfied.

Conflicts:
	audio/out/ao_coreaudio.c
2013-06-16 18:20:39 +02:00
wm4 9788789530 stream: rename cache2.c to cache.c
I never found cache1.c (whatever it was named, if it ever existed).

cache2.h will be deleted later, so don't go through the trouble of
renaming it.
2013-06-09 22:04:56 +02:00
wm4 667c8352f3 core: make options.c compile standalone
This also removes the split between "mplayer" and "common" opts (common
opts used to be shared between mencoder and mplayer).
2013-06-08 17:08:20 +02:00
wm4 757c6d0394 core: merge defaultopts.c into cfg-mplayer.h
There isn't really any reason why this should be in a separate source
file.
2013-06-08 17:08:20 +02:00
wm4 92ae48db0f Merge branch 'sub_mess'
This branch heavily refactors the subtitle code (both loading and
rendering), and adds support for a few new formats through FFmpeg.

We don't remove any of the old code yet. There are still some subtleties
related to subreader.c to be resolved: code page detection & conversion,
timing post-processing, UTF-16 subtitle support, support for the -subfps
option. Also, SRT reading and loading ASS via libass should be turned
into proper demuxers. (SRT is needed because Libav's is gravely broken,
and we want ASS loading via libass to cover full libass format support.
Both should be demuxers which are probed _before_ libavformat, so that
all subtitles can be loaded through the demuxer infrastructure, and
libavformat subtitles don't need to be treated in a special way.)
2013-06-04 00:29:44 +02:00
wm4 b11bd1fe5e sub: make use of libavcodec subtitle converters
This allows using some formats that were not supported until now, like
WebVTT.

We still prefer the internal subtitle reader (subreader.c), because
1. Libav, and 2. random things which we probably want to keep, such as
control over formatting, codepage stuff, or various mysterious
postprecessing done in that code.
2013-06-03 22:40:06 +02:00
Stefano Pigozzi 72f2942dfa osx: add Apple Remote support
After killing the non functional AR support in c8fd9e5 I got much complaints so
this adds AR support back in (and it works). I am using the HIDRemote class by
Felix Schwarz and that part of the code is under the BSD license. I slightly
modified it replacing [NSApplication sharedApplication] with NSApp. The code
of the class is quite complex (probably because it had to deal with all the
edge cases with IOKit) but it works nicely as a black box.

In a later commit I'll remove the deprecation warnings caused by HIDRemote's
usage of Gestalt.

Check out `etc/input.conf` for the default bindings.

Apple Remote functionality is automatically compiled in when cocoa is enabled.
It can be disabled at runtime with the `--no-ar` option.
2013-06-03 22:35:47 +02:00
Stefano Pigozzi f13f0db33a osx: create macosx_events to deal with keyDown events
On OSX with Cocoa enabled keyDown events are now handled with
addLocalMonitorForEventsMatchingMask:handler:. This allows to respond to
events even when there is no VO initialized but the GUI is focused.
2013-06-03 22:31:13 +02:00
wm4 14dd951548 sub: split subassconvert.c into sd_microdvd.c and sd_srt.c 2013-06-03 02:09:07 +02:00
wm4 3000df35d3 sub: basic subtitle converters
Add a basic infrastructure for subtitle converters. These converters
work sort-of like decoders, except that they produce packets instead
of subtitle bitmaps. They are put in front of actual decoders.

Start with sd_movtext. 4 lines of code are blown up to a 55 lines file,
but fortunately this is not going to be that bad for the following
converters.
2013-06-03 02:09:07 +02:00
wm4 27d383918a core: add demux_sub pseudo demuxer
Subtitle files are opened in mplayer.c, not using the demuxer
infrastructure in general. Pretend that this is not the case (outside of
the loading code) by opening a pseudo demuxer that does nothing. One
advantage is that the initialization code is now the same, and there's
no confusion about what the difference between track->stream,
track->sh_sub and mpctx->sh_sub is supposed to be.

This is a bit stupid, and it would be much better if there were proper
subtitle demuxers (there are many in recent FFmpeg, but not Libav). So
for now this is just a transition to a more proper architecture. Look
at demux_sub like an artifical limb: it's ugly, but don't hate it - it
helps you to get on with your life.
2013-06-01 19:43:11 +02:00
Stefano Pigozzi 3396e0565b macosx_application: move escape_loadfile_name in this file
This allows to move back osx_common to raw C.
2013-05-30 23:01:12 +02:00
wm4 2684280643 sub: add sd_spu.c to wrap spudec, cleanup mplayer.c
This unifies the subtitle rendering path. Now all subtitle rendering
goes through sd_ass.c/sd_lavc.c/sd_spu.c.

Before that commit, the spudec.h functions were used directly in
mplayer.c, which introduced many special cases. Add sd_spu.c, which is
just a small wrapper connecting the new subtitle render API with the
dusty old vobsub decoder in spudec.c.

One detail that changes is that we always pass the palette as extra
data, instead of passing the libdvdread palette as pointer to spudec
directly. This is a bit roundabout, but actually makes the code simpler
and more elegant: the difference between DVD and non-DVD dvdsubs is
reduced.

Ideally, we would just delete spudec.c and use libavcodec's DVD sub
decoder. However, DVD playback with demux_mpg produces packets
incompatible to lavc. There are incompatibilities the other way around
as well: packets from libavformat's vobsub demuxer are incompatible to
spudec.c. So we define a new subtitle codec name for demux_mpg subs,
"dvd_subtitle_mpg", which only sd_spu can decode.

There is actually code in spudec.c to "assemble" fragments into complete
packets, but using the whole spudec.c is easier than trying to move this
code into demux_mpg to fix subtitle packets.

As additional complication, Libav 9.x can't decode DVD subs correctly,
so use sd_spu in that case as well.
2013-05-30 22:40:32 +02:00
wm4 b44202b69f sub: redo how -no-ass is handled
The -no-ass switch used to disable any use of libass for text subtitles.
This is not really the case anymore, because libass is now always
involved when rendering text. The only remaining use of -no-ass is
disabling styling or showing subtitles on the terminal. On the other
hand, the old subtitle rendering path is a big reason why the subtitle
code is still a big mess with an awful number of obscure special cases.

In order to simplify it, remove the old subtitle rendering code, and
always go through sd_ass.c. Basically, we use ASS_Track as central data
structure for storing text subtitles instead of struct sub_data. This
also makes libass mandatory for all text subs, even if they are printed
to the terminal in -no-video mode. (We could add something like sd_text
to avoid this, but it's not worth the trouble.)

struct sub_data and subreader.c are still around, even its ASS/SSA
reader. But struct sub_data is freed right after converting it to
ASS_Track. The internal ASS reader actually can handle some obscure
cases libass can't, like files encoded in UTF-16.
2013-05-30 22:20:02 +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 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
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 e6e5a7b221 Merge branch 'audio_changes'
Conflicts:
	audio/out/ao_lavc.c
2013-05-12 21:47:55 +02:00
wm4 ab8f28a672 audio: add channel map selection function
The point is selecting a minimal fallback. The AOs will call this
through the AO API, so it will be possible to add options affecting
the general channel layout selection.

It provides the following mechanism to AOs:
- forcing the correct channel order
- downmixing to stereo if no layout is available
- allow 5.1 <-> 5.1(side) fallback
- handling "unknown" channel layouts

This is quite weak and lots of code/complexity for little gain. All AOs
already made sure the channel order was correct, and the fallback is of
little value, and could perhaps be done in the frontend instead, like
stereo downmixing with --channels=2 is handled. But I'm not really sure
how this stuff should _really_ work, and the new code will hopefully
provides enough flexibility to make radical changes to channel layout
negotiation easier.
2013-05-12 21:24:57 +02:00
wm4 d9582ad0a4 audio/filters: add af_force
Its main purpose is for testing in case channel layout stuff breaks, in
particular in connection with old audio filters.
2013-05-12 21:24:56 +02:00
wm4 f7a427676c audio: add some setters for mp_audio, and require filters to use them
mp_audio has some redundant fields. Setters like mp_audio_set_format()
initialize these properly.

Also move the mp_audio struct to a the file audio.c.

We can remove a mysterious line of code from af.c:

    in.format |= af_bits2fmt(in.bps * 8);

I'm not sure if this was ever actually needed, or if it was some kind of
"make it work" quick-fix that works against the way things were supposed
to work. All filters etc. now set the format correctly, so if there ever
was a need for this code, it's definitely gone.
2013-05-12 21:24:54 +02:00
wm4 0042735d7a audio: add channel map API
Unused, will be used in the following commits.

Let chmap.h define the number of maximum channels, because that is most
convenient.
2013-05-12 21:24:54 +02:00
Stefano Pigozzi afdc9c4ae2 OSX: use native Cocoa's event loop
Schedule mpv's playloop as a high frequency timer inside the main Cocoa event
loop. This has the benefit to allow accessing menus as well as resizing the
window without the playback being blocked and allows to remove countless hacks
from the code that involved manually pumping the event loop as well simulating
manually some of the Cocoa default behaviours.

A huge improvement consists in removing NSApplicationLoad. This is a C function
defined in the Cocoa header and implements a minimal OSX application under ther
hood so that you can use the Cocoa GUI toolkit from C/C++ without having to
respect the Cocoa standards in terms of application initialization. This was
bad because the behaviour implemented by NSApplicationLoad was hard to customize
and had several gotchas especially in the menu department.

mpv was changed to be just a nib-less application. All the Cocoa part is still
generated in code but the event handling is now not dissimilar to what is
present in a stock Mac application.

As a part of reviewing the initialization process, I also removed all of
`osdep/macosx_finder_args`. The useful parts of the code were moved to
`osdep/macosx_appication` which has the broaded responsibility of managing the
full lifecycle of the Cocoa application. By consequence the
`--enable-macosx-finder` configure switch was killed as well, as this feature
is always enabled.

Another change the users will notice is that when using a bundle the `--quiet`
option will be inserted much earlier in the initializaion process. This results
in mpv not spamming mpv.log anymore with all the initialization outputs.
2013-05-12 15:27:54 +02:00
wm4 4982083b2b osd: convert OSD font to OpenType
The old OSD font was a PostScript Type 1 font. Convert it to OpenType
to work around a fontconfig bug [1]. OpenType is a more modern format,
and the font file is quite a bit smaller, so this is actually a nice
change.

The conversion was done by opening the font with fontforge and saving
it as OpenType (CFF). fontforge showed a warning when doing this:

    The font contains errors.
      Self Intersecting
      Bad Private Dictionary

These seem to be harmless.

[1] https://bugs.freedesktop.org/show_bug.cgi?id=63922
2013-04-27 18:03:19 +02:00
wm4 7979718159 vf_lavfi: add libavfilter bridge
Requires recent FFmpeg/Libav git versions. Earlier versions will not
be supported, as the API is different. (A libavfilter version that
uses AVFrame instead of AVFilterBuffer is needed.)

Note that this is sort of useless, because the option parser prevents
you from making use of the full libavfilter graph syntax. This has to be
fixed later.

Most of the filter creation code (half of the config() function) has
been taken from avplay.c.

This code is not based on MPlayer's vf_lavfi. The MPlayer code doesn't
compile as it hasn't been updated through multiple libavfilter API
changes, making it completely useless as a starting point.
2013-04-21 04:39:58 +02:00
Stefano Pigozzi cb0b0d99a4 ad_lavc: use fmt-conversion to map sample formats 2013-04-13 04:21:27 +02:00
Stefano Pigozzi ae9e7b5a4a make: add osxbundle-skip-deps
This adds a way to generate a Mac OS X application bundle without the bundled
dependencies.

fixes #57
2013-04-08 21:44:46 +02:00