Commit Graph

216 Commits

Author SHA1 Message Date
wm4 6b3e7740f1 osd: add --osd-status-msg option for custom OSD status 2013-02-16 22:31:29 +01:00
wm4 bd835cdeea mplayer: use talloc instead of malloc for status line 2013-02-16 22:04:43 +01:00
wm4 6d7e044ead osd: add --no-osd-bar option to disable the OSD bar
In addition to disabling the OSD bar physically, also add some fallbacks
to OSD text in places the OSD bar would have been used.
2013-02-16 21:41:24 +01:00
wm4 f897138c2d osd: always update already visible OSD bar on seeks
Seeks can be performed with OSD bar invisible (e.g. "osd-msg seek ..."
command), and then an already visible bar won't be updated. But the bar
will stick around until the OSD text is hidden. This is confusing, so
change it that the bar is updated. (Making the bar disappear on such
seeks would require much more changes, so we're lazy and go with this
commit.)
2013-02-16 20:50:05 +01:00
wm4 f9a259e5d5 mplayer: fix seek display during seeking when playing ordered chapters
The seek bar appeared to be "stuck" to the start of the current chapter.
This is a regression from 630a2b1. This commit assumed that hrseek_pts
would always contain the hrseek target time (when hrseek_active==true).
But this is not always the case: when playing timeline stuff (e.g.
ordered chapters), hrseek framedropping is abused to handle an obscure
corner case, and then hrseek_pts contains something completely unrelated
to the current playback time. See the added comment in mplayer.c and
commit c1232c9.

Fix this by trying something else to get a correct time "during"
hr-seeks. mpctx->restart_playback looks ideal, because it's set while
audio is being synced / audio buffers being filled, so we know that the
audio time is probably bogus while it is set. Let's hope this is
correct.
2013-02-13 13:22:12 +01:00
wm4 a0987186b9 demux_lavf: remove code duplication
Also move the lang field into the general stream header. (SH_COMMON is
an old hack to "share" code between audio/video/sub headers.)

There should be no functional changes, other than not printing stream
info in verbose mode or with slave mode. (The frontend already prints
stream info, and this is just a leftover when individual demuxers did
this, and slave mode remains broken.)
2013-02-10 17:25:57 +01:00
wm4 4d016a92c8 core: redo how codecs are mapped, remove codecs.conf
Use codec names instead of FourCCs to identify codecs. Rewrite how
codecs are selected and initialized. Now each decoder exports a list
of decoders (and the codec it supports) via add_decoders(). The order
matters, and the first decoder for a given decoder is preferred over
the other decoders. E.g. all ad_mpg123 decoders are preferred over
ad_lavc, because it comes first in the mpcodecs_ad_drivers array.
Likewise, decoders within ad_lavc that are enumerated first by
libavcodec (using av_codec_next()) are preferred. (This is actually
critical to select h264 software decoding by default instead of vdpau.
libavcodec and ffmpeg/avconv use the same method to select decoders by
default, so we hope this is sane.)

The codec names follow libavcodec's codec names as defined by
AVCodecDescriptor.name (see libavcodec/codec_desc.c). Some decoders
have names different from the canonical codec name. The AVCodecDescriptor
API is relatively new, so we need a compatibility layer for older
libavcodec versions for codec names that are referenced internally,
and which are different from the decoder name. (Add a configure check
for that, because checking versions is getting way too messy.)

demux/codec_tags.c is generated from the former codecs.conf (minus
"special" decoders like vdpau, and excluding the mappings that are the
same as the mappings libavformat's exported RIFF tables). It contains
all the mappings from FourCCs to codec name. This is needed for
demux_mkv, demux_mpg, demux_avi and demux_asf. demux_lavf will set the
codec as determined by libavformat, while the other demuxers have to do
this on their own, using the mp_set_audio/video_codec_from_tag()
functions. Note that the sh_audio/video->format members don't uniquely
identify the codec anymore, and sh->codec takes over this role.

Replace the --ac/--vc/--afm/--vfm with new --vd/--ad options, which
provide cover the functionality of the removed switched.

Note: there's no CODECS_FLAG_FLIP flag anymore. This means some obscure
container/video combinations (e.g. the sample Film_200_zygo_pro.mov)
are played flipped. ffplay/avplay doesn't handle this properly either,
so we don't care and blame ffmeg/libav instead.
2013-02-10 17:25:56 +01:00
wm4 a1be0e1aec options: change --no-config option, make it apply to input.conf as well
Simplify --no-config and make it a normal flag option, and doesn't take
an argument anymore. You can get the same behavior by using --no-config
and then --include to explicitly load a certain config file.

Make --no-config work for input.conf as well. Make it so that
--input:conf=file still works in this case. As a  technically unrelated
change, the file argument now works as one would expect, instead of
making it relatively to "~/.mpv/". This makes for simpler code and
easier to understand option semantics. We can also print better error
messages.
2013-02-09 00:21:18 +01:00
wm4 a36e03781c mplayer: remove seconds/centiseconds display from terminal status line
Doesn't have much of a purpose for normal playback. You can get
milliseconds display with --osd-fractions. It's also possible to build
a custom status line with --status-msg.

This gives more space on the status line and, in my opinion, is a bit
less annoying.
2013-02-09 00:21:17 +01:00
wm4 c5340512dd core: remove --edlout functionality
This could write .edl files in MPlayer's format. Support for playing
these files has been removed from mplayer2 quite a while ago. (mplayer2
can play its own, "new" .edl format, but does not support writing it.)

Since this is a rather obscure functionality, and it's not really clear
how it should behave (e.g. what should it do if a new file is played),
and wasn't all that great to begin with (what if you made a mistake?
the "edl_mark" command sucks for editing), get rid of it.

Suggestions how to reimplement this in a nicer way are welcome. If it's
just about retrieving timecodes, this in input.conf will do:

    KEY print_text "position: ${=time-pos}"
2013-02-06 23:03:39 +01:00
wm4 630a2b195a mplayer: don't show bogus audio PTS during hr-seek
This fixes a problem that happened with syncplay.pl [1] when ad_mpg123
was in use, and get_current_time() returning a bogus time position.
This only happens during seeking; the reported time is correct after the
seek is done.

The audio PTS as returned by playing_audio_pts() is simply bogus during
hr-seek. With ad_ffmpeg, it was actually set to MP_NOPTS_VALUE during
seeking, so get_current_time() did a fallback to the video PTS. However,
ad_mpg123 is different and explicitly decodes some audio when resetting
on seek (reasons why it does this unknown and uninvestigated; apparently
it's to reinit libmpg123). As a result, the audio PTS was set to the
start position of the seek (or something similar), which could be very
different from the seek target time.

This confused syncplay. It got the bogus time because it spams the
player with read commands to the "time-pos" property, so this corner
case was hit.

Fix this by making get_current_time() return the seek target time if
hr-seek is active. This should make behavior the same as before commit
3f949cf "mplayer: prefer audio PTS over video PTS for status line".

[1] http://syncplay.pl
2013-02-05 18:32:26 +01:00
wm4 cd08785aab mplayer: properly handle framestep when showing last video frame
When doing a framestep while there is no more video, nothing happened,
and audio continued to play. When advancing to the next file, the player
was paused. Fix it so that it always pauses (except on very low frame
rate video, which is yet another corner case).

We also change the meaning of framestepping a bit: in audio only mode,
framstepping unpauses for a single playloop iteration. This is probably
not useful at all, but makes the code a bit more simpler/uniform.

Just like the previous commit, this matters most for audio files with
cover art, for which this special case is the normal case.
2013-02-03 21:08:26 +01:00
wm4 d302ac285f mplayer: reset audio/video delay if there's no next video frame
mpctx->delay is used to control audio/video sync. If more audio than
video has been played, it grows larger, meaning A/V desync is happening.

This logic is a bit broken when video has ended, and audio is still
playing. In that case, it tries to read additional video frames from the
video decoder (because even if you don't feed new packets to the
decoder, it could still return delayed frames). For that, the code to
determine whether frames should be dropped is invoked
(check_framedrop()). This function detects that video is behind audio (mpctx-
>delay growing big),
and attempts to issue a framedrop.

Reset mpctx->delay if there's no more video.

This fixes the the frame drop display "counting up" on each playloop
iteration when playing audio files with cover art. These files are
basically audio+video files with a single video frame. When playing
these files the the corner case of having run out of video while audio
is still playing is the normal case.

Also reset mpctx->last_av_difference. This is not updated anymore if
video ends (since update_avsync() sets it, but it's not called if
video_left is false). This removes the "stuck" A/V sync value when video
ends. With audio files containing cover art we would display a
meaningless value over the duration of the whole file otherwise.
2013-02-03 21:08:26 +01:00
wm4 5f28c34962 mplayer: make advancing the playlist respect looping
Explicitly advancing the playlist with input commands ("playlist_next")
didn't jump back to the first file, if the current file was the last on
the playlist and looping was enabled.

Fix this and make the behavior with explicit input and playback EOF the
same.

Also add a minor feature: if looping is enabled, and the current file is
the first on the playlist, going back one entry jumps to the last
playlist entry (without changing loop count).

Fixes #22.
2013-02-03 16:52:48 +01:00
wm4 3b37fadc5d demux_lavf: remove weird stream auto-selection
Should be dead code. Stream selection is handled either during
demuxer initialization, or via DEMUXER_CTRL_SWITCH_*.
(If there were actually situations where this code did something, it
was probably broken anyway.)
2013-02-03 16:51:13 +01:00
wm4 cfc3f10bda mplayer: add newline for --print-msg 2013-01-30 01:04:25 +01:00
wm4 a243acb1de x11: cleanup, refactor
Move things that are used by vo_xv only into vo_xv, same for vo_x11.

Rename some functions exported by x11_common, like vo_init to
vo_x11_common. Make functions not used outsode of x11_common.c private
to that file. Eliminate all global variables defined by x11_common
(except error handler and colormap stuff).

There shouldn't be any functional changes, and only code is moved
around. There are some minor simplifications in the X11 init code, as
we completely remove the ability to initialize X11 and X11+VO
separately (see commit b4d9647 "mplayer: do not create X11 state in player frontend"),
and the respective functions are conflated into vo_x11_init() and
vo_x11_uninit().
2013-01-27 13:30:53 +01:00
wm4 64b0395e21 sub: add stupid hack for vobsub decoding with Libav
If we detect Libav, always use the old builtin vobsub decoder (in
spudec.c). Note that we do not want to use it for newer ffmpeg, as
spudec.c can't handle the vobsub packets as generated by the .idx
demuxer, and we want to get rid of spudec.c in general anyway.
2013-01-24 12:41:44 +01:00
wm4 326820b0ff video: reset filters on seek
Drop queued frames on seek. Reset the internal state of some filters
that seem to need it as well: at least vf_divtc still produced some
frames using the previous PTS.

This fixes weird behavior with some filters on seeking. In particular,
this could lead to A/V desync or apparent lockups due to the PTS of
filtered frames being too far away from audio PTS.

This commit does only the minimally required work to fix these PTS
related issues. Some filters have state dependent on previously filtered
frames, and these are not automatically reset with this commit (even
vf_divtc and vf_softpulldown reset the PTS info only). Filters that
actually require a full reset can implement VFCTRL_SEEK_RESET.
2013-01-20 03:25:44 +01:00
Rudolf Polzer f7d96fe032 core: make gapless-audio also apply to format changes within a file
Format changes within a file can e.g. happen in MPEG-TS streams. This
fix also fixes encoding of such files, because ao_lavc is not capable of
reconfiguring the audio stream.
2013-01-18 15:09:19 +01:00
wm4 b7cacf9165 video/out: replace VFCAP_TIMER with vo->untimed, fix vo_image and vo_lavc
VFCAP_TIMER disables any additional waiting done by mpv in the
playloop. Remove VFCAP_TIMER, but re-use the idea for vo_image and
vo_lavc.

This means --untimed doesn't have to be passed when using --vo=image.
2013-01-13 20:04:10 +01:00
wm4 c54fc507da video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().

Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).

Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.

Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2013-01-13 20:04:10 +01:00
Uoti Urpala c1232c9a01 core: timeline: prevent inaccurate seeks outside timeline
Ensure that even if a seek is inaccurate it will not show video from
outside the defined timeline. Previously, seeking to the beginning of
a segment could show frames from before the start of the segment if
the seek was done in inaccurate mode and the demuxer seeked to an
earlier position. Now hr-seek machinery is used to skip at least the
frames that should not be part of playback timeline at all.
2013-01-13 13:25:50 +01:00
wm4 46f8429794 sub: do not apply timeline offset to external subtitles
Now external subtitles essentially use the playback time, instead of
the segment time.

This is more useful when using external subtitles with mkv ordered
chapters. The previous behavior is not necessarily incorrect, and e.g.
makes it easier to use subtitles directly extracted from ordered
chapters segments. But we consider the new behavior more useful.

Also see commit 06e3dc8.
2013-01-12 00:52:27 +01:00
wm4 f96dd88b41 mplayer: make --loop loop the playlist instead of each playlist entry
This is simpler and more useful. We could add a new switch for the old
functionality, but that would probably be more confusing than helpful.
When passing only a single file to the command line, this commit
shouldn't change behavior.

(Classic mplayer provided both features by duplicating the loop
functionality in the "playtree".)
2013-01-09 01:48:40 +01:00
wm4 c45132cb92 mplayer: keep pause state when frame stepping in last frame
When the last frame is displayed, and a frame step command is issued,
playback ands and advances to the next file. But before this commit,
the next file was played unpause. Fix this, and make sure pause is
kept.
2013-01-09 01:16:15 +01:00
wm4 5b56864ff0 sub: use correct fallback font for subtitles
Accidentally still used the OSD font.
2013-01-06 16:06:34 +01:00
wm4 f394a25e7b Update copyright year 2013-01-04 15:23:23 +01:00
wm4 56382c91e4 core: fix crash if VO init fails 2012-12-28 14:21:25 +01:00
Rudolf Polzer 7d0a20954f core: make WAKEUP_PERIOD overridable by the vo
This is better than having just the operating system type decide the
wakeup period, as e.g. when compiling for Win32/cygwin, a wakeup period
of 0.5 would work perfectly fine.

Instead, the default wakeup period is now only decided by availability
of a working select() system call (which is the case on cygwin but not
mingw and MSVC) AND a vo that can provide an event file descriptor or a
similar hack (vo_corevideo). vos that cannot do either need polling for
event handling and now can set the wakeup period to 0.02 in the vo code.
2012-12-19 12:58:52 +01:00
Stefano Pigozzi fab9febdc3 path: add mp_find_config_file and reorganize some of the code
Add `mp_find_config_file` to search different known paths and use that in
ass_mp to look for the fontconfig configuration file.

Some incidental changes spawned by this feature where:

 * Buffer allocation for the strings containing the paths is now performed
   with talloc. All of the allocations are done on a NULL context, but it still
   improves readability of the code.
 * Move the OSX function for lookup inside of a bundle: this code path was
   currently not used by the bundle generated with `make osxbundle`. The plan
   is to use it again in a future commit to get a fontconfig config file.
2012-12-15 17:38:00 +01:00
wm4 b0558e48b1 cleanup: remove ao.brokenpts
This field was used by ao_v4l2, and is now unused.
2012-12-12 23:05:57 +01:00
wm4 962a97a2db sd_lavc: keep subs on subtitle track switching
Keep the currently displayed subtitles even when the user cycles through
subtitle tracks, and the subtitle is decoded by libavcodec (such as
vobsubs). Do this by not clearing the subtitles on reset(). reset() is
also called on seek, so check the start PTS whether the subtitle should
really be displayed (there's already an end PTS). Note that sd_ass does
essentially something similar.

The existing code has checks for whether the PTS reported by the demuxer
is invalid (MP_NOPTS_VALUE). I don't know under what circumstances this
can happens, so fall back to the old behavior if the PTS is invalid.
2012-12-12 22:56:41 +01:00
wm4 3f949cf50b mplayer: prefer audio PTS over video PTS for status line
This slightly improves display of the current playback time in files
with sparse video packets (like video tracks containing a slow MJPG
slideshows as in [1]), or audio files with cover art image attachments.
While the video PTS is always "stuck" at the last frame displayed or
the last seek, audio is usually continuous. Given sane samplerates and
working audio drivers (to query how much of the current audio buffer has
been played), the audio PTS should always be more reliable.

[1] http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/rtpodcast/Rooster_Teeth_Podcast_191.m4a
2012-12-11 00:37:55 +01:00
wm4 fdbf437055 core: allow disabling display of "album art" in audio files
ffmpeg pretends that image attachments (such as contained in ID3v2
metadata) are video streams. It injects the attached pictures as packets
into the packet stream received with av_read_frame().

Add the --audio-display option to allow configuring whether attached
pictures should be displayed. The default behavior doesn't change
(images are displayed).

Identify video streams, that are actually image attachments, with "[P]"
in the terminal output.

Modify the default stream selection such that real video streams are
preferred over attached pictures. (This is just for robustness; I do not
know of any samples where images are added before actual video streams
and could lead to bad default stream selection with the old code.)
2012-12-11 00:37:55 +01:00
wm4 58f3b75485 windows support: fix compilation with pthreads
This caused errors like:

    core/mplayer.c:4308:5: error: implicit declaration of function 'pthread_win32_thread_detach_np' [-Werror=implicit-function-declaration]

It turns out a pthread.h include was missing. It's not clear why this
used to work (or rather, why it happens only sometimes). Possibly some
libraries or system headers recursively include pthread.h under certain
circumstances or configurations.

Fix missing quoting in configure, which led to broken terminal output.

Closes #6.
2012-12-11 00:37:54 +01:00
wm4 ae9c03c1a9 mplayer: make --length work if --start is missing
In this case, --start should default to 0 obviously.
2012-12-11 00:37:54 +01:00
wm4 5bf8706d1f sub: remove vobsub reader in favor of ffmpeg vobsub demuxer
ffmpeg recently added a demuxer that can read vobsubs (pairs of .sub and
.idx files). Get rid of the internal vobsub reader, and use the ffmpeg
demuxer instead.

Sneak in an unrelated manpage change (autosub default).
2012-12-11 00:37:54 +01:00
wm4 b3fb7c2cad core: improve seeking in external files
This affects streams loaded with -subfile and -audiofile. They could get
out of sync when they were deselected, and the main file was seeked. Add
code to seek external files when they are selected (see
init_demux_stream()).

Use avformat_seek_file() under certain circumstances. Both av_seek_frame()
("old" API) and avformat_seek_file() ("new" API) seem to be broken with
some formats. At least the vobsub demuxer doesn't implement the old API
(and the old API doesn't fallback to the new API), while the fallback
from new API to old API gives bad results. For example, seeking forward
with small step sizes seems to fail with the new API (tested with
Matroska by trying to seek 1 second forward relative to priv->last_pts).
Since only subtitle demuxers implement the new API anyway, checking
whether iformat->read_seek2 is set to test whether the old API is not
supported gives best results. This is a hack at best, but makes things
work.

Remove backwards seeking on seek failure. This was annoying, and only
was there to compensate for obscure corner cases (see 1ad332). In
particular, files with completely broken seeking that used to skip back
to the start on every seek request may now terminate playback.
2012-12-11 00:36:42 +01:00
wm4 7288834a4c sub: use ffmpeg decoder for DVD subs
Do this only if demux_lavf is used. Using demux_mpg and the ffmpeg DVD
subtitle decoder doesn't work. The problem is probably that demux_mpg
doesn't join split sub packets, while demux_lavf does. The internal
DVD sub decoder (spudec.c) can, while ffmpeg's dvdsub can't. I do not
know whether this is the actual problem.

If DVD playback is used, create "fake" vobsub-style text extradata
(like .idx files) to pass resolution and palette information to the
ffmpeg decoder. We could use the "palette" AVOpt and avcodec_set_dimensions()
instead, but it's actually simpler this way. Note that the decoder
doesn't parse any other fields. Also note that DVD playback still uses
demux_mpg by default, so this code is inactive unless -demuxer lavf is
specified. This is mainly preparation for the case when we manage to get
rid of demux_mpg for DVD playback.
2012-12-10 23:27:46 +01:00
wm4 3486f59fe2 core: automatically pause on low cache
When the cache fill status goes below a certain threshold, automatically
pause the player. When the cache is filled again, unpause again.

This is intended to help with streaming from http. It's better to pause
a while, rather than exposing extremely crappy behavior when packet
reads during decoding block the entire player.

In theory, we should try to increase the cache if underruns happen too
often. Unfortunately, changing the cache implementation would be very
hard, because it's insane code (forks, uses shared memory and "volatile"
etc.). So for now, this just reduces the frequency of the stuttering if
the network is absolutely too slow to play the stream in realtime.
2012-12-03 21:08:52 +01:00
wm4 6294c78549 cache: simplify further
This commit is separate from the previous one to separate our own
changes from changes merged from mplayer2 (as far as that was possible).

Make it easier for stream implementations to request being cached. Set
a default cache size in stream.c, and remove them from various stream
implementations. Only MS streaming support sets a meaningful cache size.

Make querying cache size saner. This reduces the amount of #ifdefs
needed.
2012-12-03 21:08:51 +01:00
Uoti Urpala 2d58234c86 cache: refactor how cache enabling is done
Code enabling the cache by default for network streams did that by
modifying the value of the "cache" option. This wasn't sane, as
multiple streams may be created and all share the same options. Change
the code to not modify options but store data in the stream instance
instead.

Conflicts:
	core/mplayer.c
	demux/demux.c
	stream/cache2.c
	stream/network.c
	stream/network.h
	stream/pnm.c
	stream/stream.c
	stream/stream_rtp.c

Merged from mplayer2 commit e26070. Note that this doesn't solve any
actual bug, as the playlist crashing bug has been fixed before.

Since the global cache size option value is not overwritten anymore, the
option doesn't need to be restored on end of playback (M_OPT_LOCAL).
2012-12-03 21:08:51 +01:00
Stephen Hutchinson 54ce8af6e0 build: identify the build time of the binary in the versioning output
Based on a patch by qyot27. Add export LC_ALL=C on top of version.sh to
make the output locale independent.

Note that the build time will not be updated on every "make" invocation,
but only when the git revision is updated. This is a good thing, as
repeated make invocations should not rebuild the binary. (This would
break "sudo make install" too.)
2012-12-03 21:08:51 +01:00
wm4 2b728da8c8 mplayer: fix track language display
This caused e.g. "--alang=" (without anything following) to be printed
in the terminal output when the file specified no language for the
track. Introduced by commit 9085b8.
2012-11-25 23:40:07 +01:00
wm4 ef75d0ff26 core: minor cleanups
Enable printf format warnings for set_osd_[t]msg.
Remove the pointless assertion in mplayer.c (the assertion proved that
the following NULL check is probably pointless, but leave that check
anyway for robustness - it's not really clear whether it's needed).
2012-11-20 18:00:16 +01:00
wm4 2cdbaaf31c osd: fix OSD status symbol display in some cases
The playback status symbol in the OSD status display on video (such as
displayed when seeking or with the show_progress input command)
sometimes kept displaying the last seek, without resetting the symbol.
(For example: disable the OSD, seek, enable the OSD, run show_progress;
but also other cases.)

The main reason for that was the code clearing the OSD bar is also
responsible for clearing the osd_function (which stores the playback
symbol). If no OSD bar was set, the osd_function was never reset.

Fix by always setting the timer for clearing the OSD bar and the
osd_function whenever the osd_function is set. Clearing the OSD bar
when it wasn't set is OK. If the OSD bar is set some time after
osd_function is set, the timer is overwritten - that's a good thing,
as it makes both disappear from the screen at exactly the same time.

Always reset osd_function to 0 and determine the playback status
explicitly from mpctx->paused when displaying the status on screen.
2012-11-20 18:00:16 +01:00
wm4 77a77d8869 mplayer: disable auto-loading of external codecs.conf
Do not load codecs.conf files located in $PREFIX/etc/mpv/ or ~/.mpv/.
There really is no use for this, other than possibly breaking things.
It's still possible to use --codecs-file explicitly to load an external
config file, and this option can be used in ~/.mpv/config.

While we're at it, remove the global codecs_file variable, and another
unused variable.
2012-11-20 18:00:15 +01:00
wm4 80270218cb osd: make the OSD and sub font more customizable
Make more aspects of the OSD font customizable. This also affects the
font used for unstyled subtitles (such as SRT), or when using the
--no-ass option. This adds back some customizability that was lost with
commit 74e7a1 (osd: use libass for OSD rendering).

Removed options:
--ass-border-color
--ass-color
--font
--subfont
--subfont-text-scale

Added options:
--osd-color
--osd-border
--osd-back-color
--osd-shadow-color
--osd-font
--osd-font-size
--osd-border-size
--osd-margin-x
--osd-margin-y
--osd-shadow-offset
--osd-spacing
--sub-scale

The font size is now specified in pixels as it would be rendered on a
window with a height of 720 pixels. OSD and subtitles are always scaled
with the window height, so specifying or expecting an absolute font
size doesn't make sense.

Such scaled pixel units are used to specify font border etc. as well.

(Note: the font size is directly passed to libass. How the fonts are
actually rasterized is outside of our control, but in theory ASS font
sizes map to "script" pixels and then are scaled to screen size.)

The default settings should be about the same, with slight difference
due to rounding to the new scales.

The OSD and subtitle fonts are not separately configurable. It has
limited use and would double the number of newly added options, which
would be more confusing than helpful. It could be easily added later,
should the need arise.

Other small details that change:
- ASS_Style.Encoding is not set to -1 for subs anymore
  (assuming subs use VSFilter direction in -no-ass mode too)
- use a different WrapStyle for OSD
- ASS forced styles are not applied to OSD
2012-11-20 18:00:15 +01:00
wm4 2a353381f3 core: fix crash when video filter returns inf as PTS
When a video filter returned inf as PTS, the player crashed. One
reason for this was that decode_audio() was called with a negative
minlen parameter, which at some point caused it to call a memory
allocation function with a ridiculous value, triggering an out of
memory code path in talloc.c. (talloc.c has been modified to abort()
on out of memory situations.)

Fix this by sanity checking minlen in decode_audio(). (The check
against outbuf->len always succeeded, because it's an unsigned
comparison.)

Make an existing sanity check in mplayer.c more robust: check for NaN
too, which happens if the video PTS is inf.

This happened with "-vf pullup,softpulldown" (but is not triggered when
the following commit is applied).
2012-11-20 18:00:15 +01:00
wm4 6f6dfc5163 mplayer: fix potential issue when ao_play() fails
ao_play() can fail; in that case a negative error code is returned.
This error code is returned by write_to_ao() in turn. The function
fill_audio_out_buffers(), which calls write_to_ao(), doesn't check for
any error codes, and will likely trigger the assertion following the
function call. Change write_to_ao() to return 0 on failure to hopefully
prevent crashes when AOs fail.
2012-11-20 18:00:15 +01:00
wm4 9085b85729 stream: fix dvd:// + cache crashing
The language string was dynamically allocated, which completely fails
if the cache is forked (which it usually is). Change it back to a fixed
length string, like the original code had it.
2012-11-20 18:00:15 +01:00
wm4 ddffcce678 stream, demux: replace off_t with int64_t
On reasonable systems, these types were the same anyway. Even on
unreasonable systems (seriously, which?), this may reduce potential
breakage.
2012-11-20 18:00:15 +01:00
wm4 f5e2ee5138 options: support chapters for --start and --end
The --start and --end switch now accept a chapter number. The chapter
number is prefixed with '#', e.g. "--start=#2" jumps to chapter 2.

The chapter support might be able to replace --chapter completely, but
for now I am not sure how well this works out with e.g. DVDs and BDs,
and a separate --chapter option is useful interface-wise.

(This was supposed to be added in 51503a, but apparently the fixup
commit adding it was lost in a rebase. This might also be the reason
for the mess-up fixed in 394285.)
2012-11-20 18:00:11 +01:00
wm4 f7163c8065 subtitles: improve support for libavformat demuxed subtitles
Make demux_lavf not error out if no video or audio track is present.
This allows opening subtitle files with the demuxer.

Improve the test whether subtitles read from demuxers must do explicit
packet reads. (I'm not sure whether always doing these reads could have
bad effects, such as reading too many audio and video packets at once,
so be conservative.)
2012-11-16 21:21:16 +01:00
wm4 589bda26ce mplayer: refactor: move computation of a/v sync
The computation for the A/V sync value was inside print_status(). Move
it into its own function; this makes things simpler and gets rid of some
minor dead code.
2012-11-16 21:21:16 +01:00
wm4 f1175cd905 core: add --keep-open, which doesn't close the file on EOF
The --keep-open option causes mpv not to close the current file.
Instead, it will pause, and allow the user to seek around. When
seeking beyond the end of the file, mpv does a precise seek back to
the previous last known position that produced video output.

In some corner cases, mpv might not be able to produce video output at
all, despite having created a VO. (Possibly when only 1 frame could be
decoded, but the video filter chain queues frames. Then a VO would be
created, without sending an actual video frame to the VO.) In these
cases, the VO window will not redraw, not even OSD.

Based on a patch by coax [1].

[1] http://devel.mplayer2.org/ticket/210#comment:4
2012-11-16 21:21:15 +01:00
wm4 b7052b431c command: add sub_reload and sub_remove commands
sub_remove remove an external subtitle track, for whatever this may be
needed.

sub_reload removes and re-adds an external subtitle track.

Also rename sub_load to sub_add, because that seems to be more in line
with sub_remove.
2012-11-16 21:21:15 +01:00
wm4 dd7dc2ee3d subreader: replace sub_free() by talloc destructor
Makes it less annoying to free the sub_data.
2012-11-16 21:21:15 +01:00
wm4 25a098fe78 options: add --mute for setting initial audio mute status
Similar to --volume. Takes this as opportunity to move the variable
corresponding to --volume into MPOpts.
2012-11-16 21:21:15 +01:00
wm4 51503a0577 options: rename -ss and -endpos, allow relative times
Rename the -ss option to -start, and -endpos to -length. Add a -end
option. The -end option always specifies an absolute end time, as
opposed to -endpos/-length.

All these options (--start, --end, --length) now accept relative times.
Percent positions (e.g. "--start=30%") are interpreted as fractions of
the file duration. Negative times (e.g. "--start=-1:00) are interpreted
relative to the end of the file. Chapters (e.g. "--start=#3") yield the
chapter's time position.

The chapter support might be able to replace --chapter completely, but
for now I am not sure how well this works out with e.g. DVDs and BDs,
and a separate --chapter option is useful interface-wise.
2012-11-16 21:21:15 +01:00
wm4 50db7b7f75 mplayer: do not freeze when trying to loop an unseekable file
Using --loop=inf on an unseekable file would put mpv (and all other
mplayers as well) into an endless loop, trying to seek to the start of
the file on each playback loop iteration. When the seek fails, playback
simply remains in the at-end-of-file state, and tries to issue a new
seek command for looping.

Fix by checking if the seek command fails, and abort looping in this
case. For that, queue_seek() is replaced with seek(). Due to the
circumstances, these two calls happen to be equal in this case: the
seek is absolute (i.e. no seek coalescing done), and the execution of
queued seeks is right after the loop code anyway.
2012-11-14 13:46:40 +01:00
Stefano Pigozzi bec630c347 clang: fix all warnings except deprecations 2012-11-13 22:19:18 +01:00
wm4 5afacef0e4 Add MP_NORETURN and replace av_noreturn uses
av_noreturn is a rather recent addition to libavutil, and defining it
ourselves is trivial and makes playing compatibility games easier.
2012-11-12 20:10:23 +01:00
wm4 4873b32c59 Rename directories, move files (step 2 of 2)
Finish renaming directories and moving files. Adjust all include
statements to make the previous commit compile.

The two commits are separate, because git is bad at tracking renames
and content changes at the same time.

Also take this as an opportunity to remove the separation between
"common" and "mplayer" sources in the Makefile. ("common" used to be
shared between mplayer and mencoder.)
2012-11-12 20:08:18 +01:00
wm4 d4bdd0473d Rename directories, move files (step 1 of 2) (does not compile)
Tis drops the silly lib prefixes, and attempts to organize the tree in
a more logical way. Make the top-level directory less cluttered as
well.

Renames the following directories:
    libaf -> audio/filter
    libao2 -> audio/out
    libvo -> video/out
    libmpdemux -> demux

Split libmpcodecs:
    vf* -> video/filter
    vd*, dec_video.* -> video/decode
    mp_image*, img_format*, ... -> video/
    ad*, dec_audio.* -> audio/decode

libaf/format.* is moved to audio/ - this is similar to how mp_image.*
is located in video/.

Move most top-level .c/.h files to core. (talloc.c/.h is left on top-
level, because it's external.) Park some of the more annoying files
in compat/. Some of these are relicts from the time mplayer used
ffmpeg internals.

sub/ is not split, because it's too much of a mess (subtitle code is
mixed with OSD display and rendering).

Maybe the organization of core is not ideal: it mixes playback core
(like mplayer.c) and utility helpers (like bstr.c/h). Should the need
arise, the playback core will be moved somewhere else, while core
contains all helper and common code.
2012-11-12 20:06:14 +01:00