Commit Graph

35367 Commits

Author SHA1 Message Date
wm4 1058d80a5e sd_ass: handle libavformat ASS comment packets as well
Currently, we are filtering libavformat style ASS packets by checking
whether they are prefixed "Dialogue: ". Unfortunately, comment packets
are demuxed too. These start with "Comment: ", so they are not caught.

Change the filtering, and use the codec ID instead. libavformat uses
"ssa" as codec ID for ASS subtitles, while mpv uses "ass". Also, at
least FFmpeg will change the ASS packet format to the same format mpv
and Matroska use, and identify these with "ass" as codec ID, so this is
works out nicely.
2013-06-23 22:34:00 +02:00
wm4 bd45eb468c subreader: remove overlap handling code
Some of this (fixing timing) is now done in dec_sub.c (although it's
not active for subreader.c code yet - this will be fixed when
subreader.c subs are read through a demuxer wrapper).

Another reason to remove this is that this code doesn't do much good
anymore. libass does handle overlap, and trying to fold overlapping
lines into single subtitle events will prevent libass from handling
this properly.
2013-06-23 22:34:00 +02:00
wm4 64b1374a44 sub: do some timing postprocessing on preloaded subs
This fixes the -subfps option (which unfortunately is still useful),
and fixes minor annoying timing errors (which unfortunately still
happen).

Note that none of these affect ASS or image subtitles. ASS is specially
handled: libass loads subtitles as ASS_Track. There are no actual
packets passed around, and sd_ass just uses the ASS_Track.

Disable the --sub-no-text-pp option. It's misleading now and always was
completely useless.
2013-06-23 22:33:59 +02:00
wm4 a70d575291 sub: preload external text subtitles
If a subtitle is external, read it completely and add all subtitle
events in advance when the subtitle track is selected. This is done
for text subtitles only. (Note that subreader.c and subtitles loaded
with libass are different and don't have anything to do with this
commit.)
2013-06-23 22:33:59 +02:00
wm4 a792f0d628 sub: remove redundant condition 2013-06-23 22:33:59 +02:00
wm4 4f5e12136d stream: remove padding parameter from stream_read_complete()
Seems like a completely unnecessary complication. Instead, always add a
1 byte padding (could be extended if a caller needs it), and clear it.

Also add some documentation. There was some, but it was outdated and
incomplete.
2013-06-23 22:33:59 +02:00
wm4 d064c69e1c demux: don't require fill_buffer callback 2013-06-23 22:33:58 +02:00
wm4 9a83d03c5d av_log: change how ffmpeg log messages are formatted
Don't print the ffmpeg context pointer as %p. This is usually useless
and confusing. Prefix all messages with "ffmpeg" to make clear that
ffmpeg is printing these messages, and not us.

If libavcodec is from Libav, use "libav" as prefix instead. (In theory,
FFmpeg/Libav libraries could be mixed, but I don't think that is
actually possible in practice.)
2013-06-22 20:34:47 +02:00
Stefano Pigozzi 97f38de07a configure: cocoa: link to libarclite
libarclite provides method stubs for the Subscripting headers added in
0407869ae3. This allows to correclty build mpv on OSX 10.7 (I had tested that
commit with OSX 10.8 running 10.7 SDK).

It seems on 10.8 this option does't make any difference in the linked libraries
(checked with otool -L) so I just add it unconditionally.

Warning: This doesn't mean mpv moved to ARC. To do that one would have to add
`-fobjc-arc` to the cflags.
2013-06-22 08:53:41 +02:00
Rudolf Polzer e7c372cb2f ildetect: $ILDETECT_RUN_INTERLACED_ONLY to only run the job if not progressive 2013-06-21 06:22:13 +02:00
Rudolf Polzer 1fc7dfe68f ildetect.sh: add a quiet mode; verify telecine decision
For quiet mode: ILDETECT_QUIET=1 ildetect.sh ...

Telecine decision (guess by ildetect.so) is verified by retrying the
ildetect run with the pullup filter inserted.
2013-06-20 19:21:49 +02:00
Rudolf Polzer c430d89adb ildetect.sh: skip needlessly going through vo_lavc
We can now turn off encoding mode by command line and use vo_null
instead.
2013-06-20 12:25:55 +02:00
Rudolf Polzer 7e88dca2db encoding: use --start for ratios, etc.
Note: this currently only works for formats without pts resets. Other
formats will ignore this code.
2013-06-20 12:15:36 +02:00
Rudolf Polzer 1e58ccaaf0 command line: allow --o= to disable encoding (i.e. empty string file name) 2013-06-20 12:15:02 +02:00
Rudolf Polzer 011f54c68b encode_lavc: simplify encoding status output; remove percentage 2013-06-20 11:17:13 +02:00
Rudolf Polzer 9137d86eda ildetect.sh: better interlace detection range 2013-06-20 10:13:12 +02:00
Rudolf Polzer 6b808ef8da ildetect.sh: env vars support 2013-06-20 09:14:27 +02:00
Stefano Pigozzi 0407869ae3 OSX: fix compilation with 10.7 SDK
Recent work in the OS X parts of the code started using clang's support for
Obj-C's support for Literals and Subscripting. These particular language
features remove a lot of boilerplate code and allow to interact with
collections as consicely as one would do in scripting languages like Ruby or
Python.

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

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

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

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

Fixes #117
2013-06-19 21:24:26 +02:00
Jonathan Yong a9f76c6d86 ao_wasapi0: add new wasapi event mode ao 2013-06-18 13:16:58 +02:00
wm4 656f9e1ba7 vo_lavc: remove unused variable 2013-06-18 12:22:25 +02:00
Jonathan Yong 8d83837cdb configure: remove redundant WINVER set 2013-06-18 12:19:52 +02:00
wm4 bcdb3c228e cache: fix stream_pts caching
Or rather, keep hacking it until it somehow works. The problem here was
that trying to avoid calling STREAM_CTRL_GET_CURRENT_TIME too often
didn't really work, so the cache sometimes returned incorrect times.

Also try to avoid the situation that looking up the time with an
advanced read position doesn't really work, as well as when trying to
look it up when EOF or cache end has been reached. In that case we have
read_filepos == max_filepos, which is "outside" of the cache, but
querying the time is still valid.

Should also fix the issue that demuxing streams with demux_lavf and if
STREAM_CTRL_GET_CURRENT_TIME is not supported messed up the reported
playback position.

This stuff is still not sane, but the way the player tries to fix the
playback time and how the DVD/BD stream inputs return the current time
based on the current byte position isn't sane to begin with. So, let's
leave it at bad hacks.

The two changes that touch s->eof are unrelated and basically of
cosmetic nature (separate commit would be too noisy.)
2013-06-18 02:19:15 +02:00
wm4 e8ae0b9852 sd_srt: handle '<font color="##FFA500">'
Wow this is stupid.
2013-06-18 02:19:15 +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 9bf9331426 cache: actually use time instead of retry count for slow cache warning
There's actually no reason to maintain a retry count, and this is more
robust against spurious wakeups.
2013-06-18 02:19:15 +02:00
Rudolf Polzer 66f09d7384 vo_lavc: do NOT fill pict_type from the mp_image
Doing this makes the encoder force the same pict type as original, which
is often not even possible. Rather let the codec decide!

As there is no documented value to mean "decoder shall pick", I rather
save/restore the default value filled by libavcodec.
2013-06-17 17:33:50 +02:00
Rudolf Polzer 1d75d01392 vo_lavc: use mp_image_copy_fields_to_av_frame 2013-06-17 08:56:55 +02:00
wm4 c412f7daf6 cache: fix build on OSX (again)
OSX doesn't support the POSIX API we were using.

We check for _POSIX_TIMERS. 0 or -1 means unsupported. See:
http://pubs.opengroup.org/onlinepubs/009696699/functions/clock_getres.html
http://pubs.opengroup.org/onlinepubs/009696699/basedefs/unistd.h.html

The workaround of using gettimeofday() is suggested by Apple:
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/pthread_cond_timedwait.3.html

Thanks to AStorm for providing help here.
2013-06-16 23:29:32 +02:00
wm4 fa30dc4154 cache: fix compilation on Libav
Appears Libav doesn't have av_clip64(). So implement our own.
2013-06-16 22:52:49 +02:00
wm4 0221f16b36 cache: use correct header for clock_gettime
Fixes compilation on OSX.
2013-06-16 22:29:23 +02:00
wm4 16211268b4 ao_dsound: fix compilation 2013-06-16 22:19:00 +02:00
wm4 819a368854 configure: make check for stream cache verbose
Also add a minor comment about the stream cache needing pthreads now
to DOCS/crosscompile-mingw.txt.
2013-06-16 22:12:56 +02:00
wm4 d81b71c7f7 Merge branch 'cache_new' 2013-06-16 22:07:48 +02:00
wm4 f794444309 stream: don't set sector size on cache
This is useless on the cache side. The sector is needed only to deal
with stream implementations which are not byte addressable, and the
cache is always byte addressable.

Also set a default read_chunk value. (This value is never used unless
you chain multiple caches, but it's cleaner.)
2013-06-16 22:05:10 +02:00
wm4 48faa8c3a8 cache: attempt to improve slow cache warning
Still sucks. The old cache behavior (before removing the fork code)
wasn't great either, though.
2013-06-16 22:05:10 +02:00
wm4 a2212ed11e cache: report more precise stream time
DVD and bluray packet streams carry (essentially) random timestamps,
which don't start at 0, can wrap, etc. libdvdread and libbluray provide
a linear timestamp additionally. This timestamp can be retrieved with
STREAM_CTRL_GET_CURRENT_TIME.

The problem is that this timestamp is bound to the current raw file
position, and the stream cache can be ahead of playback by an arbitrary
amount. This is a big problem for the user, because the displayed
playback time and actual time don't match (depending on cache size),
and relative seeking is broken completely.

Attempt to fix this by saving the linear timestamp all N bytes (where
N = BYTE_META_CHUNK_SIZE = 16 KB). This is a rather crappy hack, but
also very effective.

A proper solution would probably try to offset the playback time with
the packet PTS, but that would require at least knowing how the PTS can
wrap (e.g. how many bits is the PTS comprised of, and what are the
maximum and reset values). Another solution would be putting the cache
between libdvdread and the filesystem/DVD device, but that can't be done
currently. (Also isn't that the operating system's responsibility?)
2013-06-16 22:05:10 +02:00
wm4 c90ddd4ec1 stream: don't align stream position if not needed
This is pointless, and just increases latency on seeking. For streams
that have a sector size set, this is still needed, though.
2013-06-16 22:05:10 +02:00
wm4 df09c1aa63 stream: don't adjust stream position if seek succeeds, but read fails
This was probably done this way to ensure that after a successful seek,
the reported stream position is the same as the requested seek position.
But it doesn't make too much sense, since both stream->pos and the
stream implementation's internal position will go out of sync.
2013-06-16 22:05:10 +02:00
wm4 5999efb964 stream: fix some aspects of EOF handling
The stream EOF flag should only be set when trying to read past the end
of the file (relatively similar to unix files). Always clear the EOF
flag on seeking. Trying to set it "properly" (depending whether data is
available at seek destination or not) might be an ok idea, but would
require attention to too many special cases. I suspect before this
commit (and in MPlayer etc. too), the EOF flag wasn't handled
consistently when the stream position was at the end of the file.

Fix one special case in ebml.c and stream_skip(): this function couldn't
distinguish between at-EOF and past-EOF either.
2013-06-16 22:05:10 +02:00
wm4 0d5e6084ae stream: don't set EOF flag in stream implementations
EOF should be set when reading more data fails. The stream
implementations have nothing to say here and should behave correctly
when trying to read when EOF was actually read.

Even when seeking, a correct EOF flag should be guaranteed. stream_seek()
(or actually stream_seek_long()) calls stream_fill_buffer() at least
once, which also updates the EOF flag.
2013-06-16 22:05:10 +02:00
wm4 1c35794efd stream: remove stream_reset()
This function was called in various places. Most time, it was used
before a seek. In other cases, the purpose was apparently resetting
the EOF flag. As far as I can see, this makes no sense anymore. At
least the stream_reset() calls paired with stream_seek() are completely
pointless. A seek will either seek inside the buffer (and reset the
EOF flag), or do an actual seek and reset all state.
2013-06-16 22:05:09 +02:00
wm4 7fefad7a8f stream: check for interruption when trying to reconnect stream
This happens with something like "mpv https://www.youtube.com/watch".
The URL is obviously not valid, but the stream layer tries to reconnect.
This commit at least allows to use the terminal to abort gracefully.
(Other than killing the process.)
2013-06-16 22:05:09 +02:00
wm4 6832bf3060 stream: cosmetics 2013-06-16 22:05:09 +02:00
wm4 c5fd3412b6 stream: reset buffer even on EOF/error
This probably didn't matter anywhere, but it's more proper.
2013-06-16 22:05:09 +02:00
wm4 236577af09 cache: use threads instead of fork()
Basically rewrite all the code supporting the cache (i.e. anything other
than the ringbuffer logic). The underlying design is untouched.

Note that the old cache2.c (on which this code is based) already had a
threading implementation. This was mostly unused on Linux, and had some
problems, such as using shared volatile variables for communication and
uninterruptible timeouts, instead of using locks for synchronization.

This commit does use proper locking, while still retaining the way the
old cache worked. It's basically a big refactor.

Simplify the code too. Since we don't need to copy stream ctrl args
anymore (we're always guaranteed a shared address space now), lots of
annoying code just goes away. Likewise, we don't need to care about
sector sizes. The cache uses the high-level stream API to read from
other streams, and sector sizes are handled transparently.
2013-06-16 22:05:09 +02:00
wm4 4abec2f7b2 stream: add partial read function
This is a nice way to avoid an additional copy of the data when reading
with stream_read().
2013-06-16 22:05:09 +02:00
wm4 34a383664a demux_lavf: change probing, use stream_unread_buffer()
This fixes a longstanding issue with demux_lavf probing.
See previous commit.
2013-06-16 22:05:09 +02:00
wm4 d5ad9a8f60 stream: add stream_unread_buffer()
demux_lavf probes up to 2 MB of data in the worst case. When the ffmpeg
demuxer is actually opened, the stream is seeked back to 0, and the
previously read data is thrown away.

This wasn't a problem for playback of local files, but it's less than
ideal for playing from slow media (like web streams), and breaks
completely if the media is not seekable (pipes, some web streams).

This new function is intended to allow fixing this. demux_lavf will use
it to put the read probe data back into the buffer.

The simplest way of implementing this function is by making it
transparently extend the normal stream buffer. This makes sure no
existing code is broken by new weird special cases. For simplicity
and to avoid possible performance loss due to extra dereferencing
when accessing the buffer, we just extend the static buffer from
8 KB to 2 MB. Normally, most of these 2 MB will stay uncommitted, so
there's no associated waste of memory. If demux_lavf really reads all
2 MB, the memory will be committed and stay unused, though.
2013-06-16 22:05:09 +02:00
wm4 7c4202b863 cache: make the stream cache a proper stream that wraps other streams
Before this commit, the cache was franken-hacked on top of the stream
API. You had to use special functions (like cache_stream_fill_buffer()
instead of stream_fill_buffer()), which would access the stream in a
cached manner.

The whole idea about the previous design was that the cache runs in a
thread or in a forked process, while the cache awa functions made sure
the stream instance looked consistent to the user. If you used the
normal functions instead of the special ones while the cache was
running, you were out of luck.

Make it a bit more reasonable by turning the cache into a stream on its
own. This makes it behave exactly like a normal stream. The stream
callbacks call into the original (uncached) stream to do work. No
special cache functions or redirections are needed. The only different
thing about cache streams is that they are created by special functions,
instead of being part of the auto_open_streams[] array.

To make things simpler, remove the threading implementation, which was
messed into the code. The threading code could perhaps be kept, but I
don't really want to have to worry about this special case. A proper
threaded implementation will be added later.

Remove the cache enabling code from stream_radio.c. Since enabling the
cache involves replacing the old stream with a new one, the code as-is
can't be kept. It would be easily possible to enable the cache by
requesting a cache size (which is also much simpler). But nobody uses
stream_radio.c and I can't even test this thing, and the cache is
probably not really important for it either.
2013-06-16 22:05:09 +02:00
wm4 4d3a2c7e0d audio/out: remove ao->outburst/buffersize fields
The core didn't use these fields, and use of them was inconsistent
accross AOs. Some didn't use them at all. Some only set them; the values
were completely unused by the core. Some made full use of them.

Remove these fields. In places where they are still needed, make them
private AO state.

Remove the --abs option. It set the buffer size for ao_oss and ao_dsound
(being ignored by all other AOs), and was already marked as obsolete. If
it turns out that it's still needed for ao_oss or ao_dsound, their
default buffer sizes could be adjusted, and if even that doesn't help,
AO suboptions could be added in these cases.
2013-06-16 19:36:56 +02:00