Commit Graph

462 Commits

Author SHA1 Message Date
wm4 18b6c01d92 video: redo how colorspaces are handled
Instead of handling colorspaces with VFCTRLs/VOCTRLs, make them part of
the normal video format negotiation. The colorspace is passed down like
other video params with config/reconfig calls.

Forcing colorspaces (via the --colormatrix options and properties) is
handled differently too: if it's changed, completely reinit the video
chain. This is slower and requires a precise seek to the same position
to perform an update, but it's simpler and less bug-prone. Considering
switching the colorspace at runtime by user-interaction is a rather
obscure feature, this is a good change.

The colorspace VFCTRLs and VOCTRLs are still kept. The VOs rely on it,
and would have to be changed to get rid of them. We'll do that later,
and convert them incrementally instead of in one go.

Note that controlling the output range now always works on VO level.
Basically, this means you can't get vf_scale to output full-range YUV
for whatever reason. If that is really wanted, it should be a vf_scale
option. the previous behavior didn't make too much sense anyway.

This commit fixes a few bugs (such as playing RGB video and converting
that to YUV with vf_scale - a recent commit broke this and forced the
VO to display YUV as RGB if possible), and might introduce some new
ones.
2013-07-16 23:22:55 +02:00
wm4 a98aad61f8 core: move video refresh function to mplayer.c 2013-07-16 23:14:55 +02:00
wm4 f77d243a68 mp_common: add MPMAX/MPMIN macros
From now on, usage of these macros is encouraged over using FFMAX and
FFMIN. FFMAX and FFMIN are perfectly fine, and the added macros are
actually exactly the same as the FFMAX and FFMIN definitions. But they
require including libavutil headers, and certain differences between
Libav and FFmpeg very often introduced breakages if these macros were
somehow not defined because a header was not recursively included.
Defining this macro on our own is the best way to escape from this
annoying issue.
2013-07-15 23:53:58 +02:00
wm4 978831c8e3 Fix build on Libav
Sigh, why does this happen all the time...
2013-07-15 02:28:46 +02:00
wm4 169b3abd78 sd_ass: scale blur by original video size if requested 2013-07-15 02:01:37 +02:00
wm4 af55db654b sd_add: add terrible hack for (xy-)vsfilter compatibility
Much has been said about this topic, we don't need to say even more.

See additions to options.rst.
2013-07-15 02:01:37 +02:00
wm4 65d8709152 demux_lavf: add terrible hack to make DVD playback just work
DVD playback had some trouble with PTS resets: libavformat's genpts
feature would try reading until EOF (worst case) to find a new usable
PTS in case a packet's PTS is not set correctly. Especially with slow
DVD access, this would make the player to appear frozen.

Reimplement it partially in demux_lavf.c, and use that code in the DVD
case. This is heavily "inspired" by the code in av_read_frame from
libavformat/utils.c. The difference is that we stop reading if no PTS
has been found after 50 packets (consider this a heuristic). Also, we
don't bother with the PTS wrapping and last-frame-before-EOF handling.
Even with normal PTS wraps, the player frontend will go to hell for the
duration of a frame anyway, and should recover quickly after that.

The terribleness of this commit is mostly that we duplicate libavformat
functionality, and that we suddenly need a packet queue.
2013-07-14 23:44:50 +02:00
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 4b1ce17e23 input: never wait if there are new events in the input queue
Move the reading loop from read_all_fd_events to read_events. If
got_new_events is set when calling read_events, don't actually wait
and set the timeout to 0.

(Note that not waiting is sort of transparent to the caller: the caller
is just supposed to execute the event loop again, and then it will
actually wait. mplayer.c handles this correctly.)

This might reduce latency with some input sources.
2013-07-14 15:52:32 +02:00
wm4 38ce825091 input: invert negated boolean field 2013-07-14 15:38:04 +02:00
wm4 b2cbcbfc16 input: use only one array for input sources
Removes some code duplication. Also restructure the input waiting code
a bit: split the select() loop into a input_wait_read() function. On
systems which do not have POSIX select(), this function has an alternate
implementation, which waits unconditionally.
2013-07-14 15:27:55 +02:00
James Ross-Gowan ea7e54cb34 w32: silence some warnings 2013-07-13 14:43:54 +02:00
Stefano Pigozzi 58c92bce69 mp_ring: improve documentation
This improves some lacking areas of the documentation based on some remarks
and questions I got on IRC from @jon-y.
2013-07-13 10:33:07 +02:00
Stefano Pigozzi 9d9bcfa4f3 mp_ring: make mp_ring_read_cb provide an exact amount of bytes
The previous code would pass down `len` instead of `read_len` which, in theory,
could be more than what was available in the buffer.
2013-07-13 10:25:39 +02:00
wm4 666cb2dac2 mplayer: remove generic duration calculation
This was useless for anything but the raw demuxers. In most cases, this
would most likely lead to display of bogus duration values, because the
bitrates used are per-track, not the total file bitrate. There was
actually no case left where this code was helpful.

Note that demux_lavf has its own code for this using the total file
bitrate. Also, mplayer.c can calculate the playback percentage from
current file position / current file size. This is not removed.
2013-07-12 23:11:04 +02:00
wm4 879c7a101b demux: assume correct-pts mode by default
All demuxers make a reasonable effort to set packet timestamps, and thus
support correct-pts mode. This commit also implicitly switches
demux_rawvideo to correct-pts mode.

We still allow demuxers to disable correct-pts mode in theory.
2013-07-12 22:16:27 +02:00
wm4 cb45b1c65b Cleanup some include statements 2013-07-12 22:16:26 +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 311d2f199a mplayer: minor memory leak in error handling code 2013-07-12 21:57:27 +02:00
wm4 52c3eb6976 core: change open_stream and demux_open signature
This removes the dependency on DEMUXER_TYPE_* and the file_format
parameter from the stream open functions.

Remove some of the playlist handling code. It looks like this was
needed only for loading linked mov files with demux_mov (which was
removed long ago).

Delete a minor bit of dead network-related code from stream.c as well.
2013-07-12 21:56:40 +02:00
wm4 9dfc7daf79 m_struct: try to be more standard C
The main problem is that this m_struct stuff uses pointers for offsets
(why...), so we mangle it by intptr_t. This stuff really should use ints
(or in theory ptrdiff_t) for offsets, but changing it would be too much
effort, and hopefully this m_struct stuff will go away and replaced by
the common option parser mechanism instead.

Shuts up warnings on Windows.

Patch suggested by jon_y and rossy on IRC.
2013-07-12 18:40:08 +02:00
wm4 4cda1d113e core: completely change handling of attached picture pseudo video
Before this commit, we tried to play along with libavformat and tried
to pretend that attached pictures are video streams with a single
frame, and that the frame magically appeared at the seek position when
seeking. The playback core would then switch to a mode where the video
has ended, and the "remaining" audio is played.

This didn't work very well:
- we needed a hack in demux.c, because we tried to read more packets in
  order to find the "next" video frame (libavformat doesn't tell us if
  a stream has ended)
- switching the video stream didn't work, because we can't tell
  libavformat to send the packet again
- seeking and resuming after was hacky (for some reason libavformat sets
  the returned packet's PTS to that of the previously returned audio
  packet in generic code not related to attached pictures, and this
  happened to work)
- if the user did something stupid and e.g. inserted a deinterlacer by
  default, a picture was never displayed, only an inactive VO window)
- same when using a command that reconfigured the VO (like switching
  aspect or video filters)
- hr-seek didn't work

For this reason, handle attached pictures as separate case with a
separate video decoding function, which doesn't read packets. Also,
do not synchronize audio to video start in this case.
2013-07-11 19:23:56 +02:00
wm4 e5544e2da3 demux: improve DVD sub auto-selection hack
The code touched by this commit makes sure that DVD subtitle tracks
known by libdvdread but not known by demux_lavf can be selected and
displayed properly. These subtitle tracks have the first packet
some time late in the packet stream, so that libavformat won't
immediately recognize them, and will add the track as soon as the
first packet is seen during normal demuxing.

demux_mpg used to handle this elegantly: you just set the MPEG ID of
the stream you wanted. demux_lavf couldn't do this, so it was emulated
with a DEMUXER_CTRL. This commit changes it so that new streams are
selected by default (if autoselect is enabled), and the playloop
simply can take appropriate action before the lower layer throws away
the first packet.

This also changes the demux_lavf behavior that subtitle packets are
always demuxed, even if not needed. (They were immediately thrown away,
so there was no advantage to this.)

Further, this adds the ability to demux.c to deal with demuxing more
than one stream of a kind at once. (Though currently it's not useful.)
2013-07-11 19:22:24 +02:00
wm4 a6706c41d8 video: eliminate frametime variable 2013-07-11 19:21:45 +02:00
wm4 6ede485e4b core: don't access demux_stream outside of demux.c, make it private
Generally remove all accesses to demux_stream from all the code, except
inside of demux.c. Make it completely private to demux.c.

This simplifies the code because it removes an extra concept. In demux.c
it is reduced to a simple packet queue. There were other uses of
demux_stream, but they were removed or are removed with this commit.

Remove the extra "ds" argument to demux fill_buffer callback. It was
used by demux_avi and the TV pseudo-demuxer only.

Remove usage of d_video->last_pts from the no-correct-pts code. This
field contains the last PTS retrieved after a packet that is not NOPTS.
We can easily get this value manually because we read the packets
ourselves. Reuse sh_video->last_pts to store the packet PTS values. It
was used only by the correct-pts code before, and like d_video->last_pts,
it is reset on seek. The behavior should be exactly the same.
2013-07-11 19:17:51 +02:00
wm4 29cc249173 mplayer: invert negated boolean variable
Boolean variables shouldn't carry a negated meaning, so rename
non_interleaved to interleaved.
2013-07-11 19:16:25 +02:00
wm4 23e303859a mplayer: fix incorrect audio sync after format changes
This is not directly related to the handling of format changes itself,
but playing audio normally after the change. This was broken: the output
byte rate was not recalculated, so audio-video sync was simply broken.
Fix this by calculating the byte rate on the fly, instead of storing it
in sh_audio.

Format changes are relatively common (switches between stereo and 5.1
in TV recordings), so this fixes a somewhat critical bug.
2013-07-11 19:15:09 +02:00
wm4 995fe05254 mplayer: remove "old" audio PTS calculation code
Removing this code doesn't change anything. All remaining audio decoders
are well-behaved enough to not overwrite sh_audio->pts if they don't
know the PTS. And if they don't know the PTS, the d_audio->last_pts
field can't contain any usable value either, because both fields contain
theame value: the last known valid PTS found in an audio packet.
2013-07-11 19:13:44 +02:00
wm4 8a3615f2d8 mplayer: don't set bogus video pts after seek reset
As the comment n the removed code says, this was once needed for
something subtitle related. This code has been cleaned up long ago,
so at least the original reason for it is gone.
2013-07-11 19:13:22 +02:00
wm4 a522483629 demux: remove facility for partial packet reads
Partial packet reads were needed because the video/audio parsers were
working on top of them. So it could happen that a parser read a part of
a packet, and returned that to the decoder. With libavformat/libavcodec,
packets are already parsed, and everything is much simpler.

Most of the simplifications in ad_spdif could have been done earlier.
Remove some other stuff as well, like the questionable slave mode start
time reporting (could be replaced by proper code, but we don't bother).
Remove the unused skip_audio_frame() functionality as well (it was used
by old demuxers). Some functions become private to demux.c, like
demux_fill_buffer(). Introduce new packet read functions, which have
simpler semantics. Packets returned from them are owned by the caller,
and all packets in the demux.c packet queue are considered unread.
Remove special code that dropped subtitle packets with size 0. This
used to be needed because it caused special cases in the old code.
2013-07-11 19:10:33 +02:00
Stephen Hutchinson d176f9571f build: make the "built on" report opt-out 2013-07-11 09:27:01 +02:00
wm4 175cd3cb57 options: add --cache-default option
Add this option, which lets users set the cache size without forcing it
even when playing from the local filesystem.

Also document the default value explicitly.

The Matroska linked segments case is slightly simplified: they can
never come from network (mostly because it'd be insane, and we can't
even list files from network sources), so the cache will never be
enabled automatically.
2013-07-10 15:05:24 +02:00
wm4 07c5327fa0 core: remove demux_mpg subtitle PTS hack
This code used to be part of the demux_mpg and vobsub specific code
path. Then (just recently) the different code paths for subtitles were
merged, so this code became active even for demux_lavf and demux_mkv.
As far as I can tell, this code won't help much, and at least sd_lavc
(which will be used for DVD subs and other potentially weird things) can
deal with NOPTS values.
2013-07-10 02:09:10 +02:00
wm4 5ec611e7ba core: simplify some no-correct-pts code
Remove the special handling for mng/mkv. These don't profit at all from
no-correct-pts mode, and even removing the mkv specific code makes mkv
work better (wow!).

Don't check for (int)fps == 1000. I don't know where this value comes
from. Maybe it was once a special value which triggered certain
behavior, but the code for that must have gone away. The only way to
trigger this value would be by coincidence if two frames are 1 ms apart.

Otherwise, the behavior should be exactly the same, except for some
removed messages.
2013-07-10 02:07:47 +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
wm4 9200538b39 audio: remove decoder input buffer
This was unused.
2013-07-10 02:00:46 +02:00
wm4 9bb7935ce1 options: remove --ignore-start
This was used only with demux_avi.
2013-07-08 21:59:44 +02:00
wm4 31f685040b Merge branch 'master' into remove_old_demuxers
Conflicts:
	DOCS/man/en/changes.rst
	DOCS/man/en/options.rst
2013-07-08 21:55:44 +02:00
wm4 c460258f5a command: add screenshot_to_file command 2013-07-08 20:37:11 +02:00
wm4 0bb41524f0 input: actually copy sub commands
This was missing from the previous commit. It worked by luck, because
the sub-commands weren't freed either (as long as the original command
was around), but this is proper.

Also, set the original string for command lists (needed for input-test
only).
2013-07-08 20:37:11 +02:00
wm4 15a5422dd2 input: allow binding multiple commands to a key
Separate the commands with ';'.
2013-07-08 19:28:52 +02:00
wm4 73c76de91e demux: simplify demux_open() calls
The demux_open as well as demux_open_withparams calls don't use the
stream selection parameters anymore, so remove them everywhere.
Completes the previous commit.
2013-07-08 01:37:30 +02:00
wm4 05ae5afd62 demux: remove separate arrays for audio/video/sub streams, simplify
These separate arrays were used by the old demuxers and are not needed
anymore. We can simplify track switching as well.

One interesting thing is that stream/tv.c (which is a demuxer) won't
respect --no-audio anymore. It will probably work as expected, but it
will still open an audio device etc. - this is because track selection
is now always done with the runtime track switching mechanism. Maybe
the TV code could be updated to do proper runtime switching, but I
can't test this stuff.
2013-07-08 01:36:02 +02:00
wm4 90813f3402 demux: remove video_read_properties 2013-07-08 00:39:29 +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 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 feaa721916 core: make network options available even if old net code is disabled
Preparation for removing the old network code.
2013-07-07 19:40:35 +02:00
wm4 0d6f5fbe54 playlist: don't add entries in reverse
The entries were always added after the insertion point - but that
means the entries are appended in reverse order. So update the
insertion point on each entry.

Regression introduced by commit 5f664d7.
2013-07-05 14:07:56 +02:00
wm4 d084f72a6c core: remove mp_fifo leftovers 2013-07-04 17:53:30 +02:00
Stefano Pigozzi 8af51bd3fe cocoa: remove usage of mp_fifo
Update Cocoa parts to remove usage of the mp_fifo internal API to send events
to the core and use the input context directly. This is to follow commits the
work in commits 70a8079c and d603e73c.
2013-07-03 22:25:45 +02:00