Commit Graph

33870 Commits

Author SHA1 Message Date
wm4 cc05910f16 sub: cosmetics: move things around
Move sub-bitmap definitions from dec_sub.h to sub.h. While it's a bit
odd that OSD data structures are in a file named sub.h, it's definitely
way too strange to have them in a file about subtitle decoding. (Maybe
sub.h/.c and the sub/ directory should be split out and renamed "osd"
at a later point.)

Remove including ass_mp.h (and the libass headers) where possible.

Remove typedefs for mp_eosd_res and sub_bitmaps structs.

Store a mp_eosd_res struct in osd_state instead of just w/h. Note that
sbtitles might be rendered using different sizes/margins when filters
are involved (the subtitle renderer is not supposed to use the OSD res
directly, and the "dim" member removed in the previous commit is
something different).
2012-10-16 07:26:32 +02:00
wm4 05f4f00e24 sub: cleanup: don't pass parameters via global variables
Passing parameters from caller to subtitle renderer was done by
temporarily setting certain members in the osd_state struct (which for
all practical purposes are as good as global variables). This was the
only purpose of these members.

Rather than using such a messy way to pass parameter, put these into a
struct sub_render_params. The struct was already introduced in earlier
commits, and this commit just removes the parameter passing hack.
2012-10-16 07:26:32 +02:00
wm4 17f5019b46 sub: always go through sub.c for OSD rendering
Before this commit, vf_vo.c and vf_ass.c were manually calling the
subtitle decoder to retrieve images to render. In particular, this
circumvented the sub-bitmap conversion & caching layer in sub.c.

Change this so that subtitle decoding isn't special anymore, and draws
all subtitles with the normal OSD drawing API.

This is also a step towards removing the need for vf_ass auto-insertion.
In fact, if auto-insertion would be disabled now, VOs with "old" OSD
rendering could still render ASS subtitles in monochrome, because
there is still ASS -> old-OSD bitmap conversion in the sub.c mechanism.

The code is written with the assumption that the subtitle rendering
filter (vf_ass) can render all subtitle formats. Since vf_ass knows the
ASS format only, rendering image subs (i.e. RGBA subs) with it simply
fails. This means that with vo_xv (vf_ass auto-inserted), image subs
wouldn't be rendered. Use a dumb hack to disable rendering subs with a
filter, if we detect that the subs are not in ASS format. (Trying to
render the subs first would probably result in purging the conversion
cache on every frame.)
2012-10-16 07:26:31 +02:00
wm4 34b3a9c5e9 sub, VO: remove vo_osd_resized() function
VOs which could render the OSD in window size (as opposed to video size,
like vo_xv) and which could cache the OSD called this when the window
size changed. This was needed, because VOs used another OSD function to
check whether the OSD changed before passing the new window size to the
OSD code.

This was really just an artifact of OSD change detection, and now that
the affected VOs use the new OSD rendering API, it's done automatically.
2012-10-16 07:26:31 +02:00
wm4 2db0d229ef libvo: remove eosd_packer.c
This contains about the same code as bitmap_packer.c. eosd_packer.c was
added first, and then not merged for a year - then it was added as
bitmap_packer.c with slightly different and incompatible interface. Now
replacing eosd_packer.c with bitmap_packer.c is finally done. So much
wasted work...
2012-10-16 07:26:31 +02:00
wm4 ffd6219ecd vo_direct3d: use new OSD API 2012-10-16 07:26:31 +02:00
wm4 7463cff747 vo_corevideo: add EOSD
Completely untested.
2012-10-16 07:26:31 +02:00
wm4 637f1a4dc6 vo_gl: use gl_osd.c
Side effect: no direct support for old OSD format anymore. Instead,
sub.c converts sub-images in that format to the packed, alpha-inverted
version.

osd-color suboption is broken.
2012-10-16 07:26:31 +02:00
wm4 cadff3eec7 vo_gl3: move OSD code to gl_osd.c
Other OpenGL-using VOs can use this.

gl_osd.c includes some code for vo_gl.c. The next commit actually
makes use of it.
2012-10-16 07:26:31 +02:00
wm4 8f8f6e6d9d sub: remove logic for disabling hinting on scaled EOSD
This was an extremely obscure setting, as it was used only with vo_gl
if its scaled-osd suboption was used. If you really want this, you can
set the desired ass-hinting value directly, and there will be literally
no loss in functionality.

Note that this didn't actually test whether the EOSD was scaled.
Basically, it only checked whether vo_gl had the scaled-osd suboption
set.
2012-10-16 07:26:31 +02:00
wm4 cf61928eec vo_gl, options: remove doublebuffering option (--double)
Useless. It complicated the code and caused flicker, and was useless
otherwise. The manpage describes this option as "should not normally
be used".

One possibly useful effect from the point of view of the user was that
vsync was disabled. You can do this with the --vsync option, or by
changing X/driver settings directly.
2012-10-16 07:26:31 +02:00
wm4 466fc6d4d1 sub: make it easier to set DVD sub decoding with sd_lavc
With this commit, the player will still use spudec.c (the "old" DVD sub
decoder), rather than ffmpeg. But it brings the changes needed to enable
this down to a single line change:

--- a/mplayer.c
+++ b/mplayer.c
@@ -1988,7 +1988,7 @@ static void reinit_subs(struct MPContext *mpctx)
 #endif
         vo_osd_changed(OSDTYPE_SUBTITLE);
     } else if (track->stream) {
-        if (mpctx->sh_sub->type == 'v')
+        if (mpctx->sh_sub->type == 'v' && false)
             init_vo_spudec(mpctx);
         else
             sub_init(mpctx->sh_sub, mpctx->osd);

Also, copy the DVD resolution heuristics from spudec.c (from the
spudec_new_scaled() function). I'm not sure if this is correct or even
needed, but the sd_lavc codd explicitly reverted back to spudec with
code carrying this comment:

    // Assume resolution heuristics only work for PGS and DVB

so it seems likely that the required heuristics were missing, and that
the spudec heuristics may make the DVD compatibility situation at least
as good as with spudec.

Note that it's unlikely that we enable sd_lavc for DVD subs by default,
as there are other problems in combination with direct DVD playback.
2012-10-16 07:26:31 +02:00
wm4 5357b38d40 osd_libass: set RTL base direction to neutral
We are using libass for OSD rendering. One problem with that is that
libass has to be bug-compatible to VSFilter. This includes the setting
for the default RTL base direction. Neutral would be most reasonable,
but VSFilter assumes LTR.

This commit forces the default to neutral.

Unconfirmed whether this actually works as intended.

See the following libass commits:

9dbd12d shaper: allow font encoding -1 for neutral base direction
a80c45c shaper: always use LTR base direction by default
2012-10-16 07:26:31 +02:00
wm4 42572fdcc0 sub, vo_gl3, vo_vdpau: exit early if there are no sub-images to draw
libass may always return a full change if no subtitle images are
rendered in some cases (empty tracks). Also, a full change despite empty
sub-images list may be reported on initialization. Avoid invoking odd
special cases in the VO code by always exiting early if the sub-image
list is empty.

Note that at least for OSD, the code in sub.c doesn't even send a
request VOCTRL_DRAW_EOSD if the image list is empty. But the subtitle
rendering code in vf_vo.c is independent from this (at least for now).
2012-10-16 07:26:31 +02:00
wm4 252ddcc014 sub: cleanup: remove vo_osd_probar_type/value global variables 2012-10-16 07:26:31 +02:00
wm4 e62b3a1750 sub: cosmetics: turn some defines into enums 2012-10-16 07:26:31 +02:00
wm4 ef43d7701d mplayer: reset subtitles handled by dec_sub.c on seek
This was somehow lost when merging this.
2012-10-16 07:26:31 +02:00
wm4 bef616ede9 vo_vdpau: use new EOSD for OSD, remove support for old OSD format
This allows vo_vdpau to render OSD directly, without the indirection
through the old OSD API, and without the additional conversions.

Remove support for the old OSD format. Only the mplayer DVD subtitle
decoder still generates this format. Although the new OSD interface does
support this format, remove it from vo_vdpau. It would be relatively
hard to support it in the EOSD code, as it requires two surfaces. (These
two surfaces are blended on top of each other to emulate the mplayer OSD
format.) The correct way to implement direct support for DVD subs would
consist of adding a paletted image format of some sort. But even sd_lavc
converts paletted subtitle images to RGBA, so doing something special
just for DVD subs is not worth it.

This means the frontend (sub.c) converts the subtitles to RGBA if it
detects that vo_vdpau does not support them natively.
2012-10-16 07:26:31 +02:00
wm4 18ab695a72 vo_vdpau: allow multiple EOSD renderers
Preparation for using new OSD rendering method.
2012-10-16 07:26:30 +02:00
wm4 5fc5ae752b sub: allow converting DVD subs to RGBA
The mplayer DVD sub decoder is the only remaining OSD image producer
that still requires the old mplayer OSD format (SUBBITMAP_OLD_PLANAR).

To make supporting this format optional in VOs, add a step that allows
converting these images to RGBA in case the VO doesn't have direct
support for it.

Note: the mplayer DVD sub decoder uses the old mplayer OSD format
(SUBBITMAP_OLD_PLANAR), which is assumed to use premultiplied alpha.
However, it seems DVDs allow only binary transparency, so the rendered
result will be the same.
2012-10-16 07:26:30 +02:00
wm4 3365514951 sub: allow rendering OSD in ASS image format directly, simplify
Before this commit, the OSD was drawn using libass, but the resulting
bitmaps were converted to the internal mplayer OSD format. We want to
get rid of the old OSD format, because it's monochrome, and can't even
be rendered directly using modern video output methods (like with
OpenGL/Direct3D/VDPAU).

Change it so that VOs can get the ASS images directly, without
additional conversions. (This also has the consequence that the OSD can
render colors now.) Currently, this is vo_gl3 only. The other VOs still
use the old method. Also, the old OSD format is still used for all VOs
with DVD subtitles (spudec).

Rewrite sub.c. Remove all the awkward flags and bounding boxes and
change detection things. It turns out that much of that isn't needed.

Move code related to converting subtitle images to img_convert.c. (It
has to be noted that all of these conversions were already done before
in some places, and that the new code actually makes less use of them.)
2012-10-16 07:26:30 +02:00
wm4 3099498154 vo_gl3: use old OSD using the emulation layer
This still renders the OSD using essentially the same mechanisms,
except that the EOSD code for texture handling and rendering is reused.
2012-10-16 07:26:30 +02:00
wm4 2a5fcd2801 sub: add preliminary emulation layer to draw OSD with EOSD
This basically pushes the old OSD bitmaps via VOCTRL_DRAW_EOSD to the
VO, instead of using the old callback-based interface.

Future commits will change the code such that sub.c pushes images
rendered by libass directly, rather than converting them to the old
OSD format first.
2012-10-16 07:26:30 +02:00
wm4 3c9c1790fe vo_gl3: support RGBA EOSD
This also adds support for multiple EOSD renderers. This capability is
unused yet, but important for the following commits.
2012-10-16 07:26:30 +02:00
wm4 ffb7a2fe17 sub: create sub_bitmap array even when using libass
One sub_bitmaps struct could contain either a libass ASS_Image list, or
a mplayer native list of sub-bitmaps. This caused code duplication in
vo_vdpau.c and bitmap_packer.c.

Avoid this by creating such a sub_bitmap array even with libass. This
basically copies the list and recreates it in mplayer's native format.
It gets rid of the code duplication, and will make implementing extended
subtitle and OSD rendering in other VOs easier.

Also do some cosmetic changes and other preparations for the following
commits.
2012-10-16 07:26:28 +02:00
Rudolf Polzer 65ea69f564 encoding examples: refuse upscaling when the target is an iPhone
This is ok, because the iPhone can handle any resolution. So there is no
need to waste space on upscaling the iPhone can do at playback time as
well.
2012-09-24 16:41:37 +02:00
Rudolf Polzer 5a3045f1a2 vf_scale: do the upscale detection AFTER calculating dimensions
Otherwise it heavily violates the manpage's description, and describing
what it did before in the documentation is something too complicated to
describe in the English language.
2012-09-24 16:41:12 +02:00
wm4 bcbc30e487 mp_msg: make MSGL_STATUS use the same color as MSGL_INFO
The green status line is annoying.
2012-09-23 15:25:01 +02:00
wm4 b2ba73c7b6 demuxer: fix crash with demux_rawvideo
rawvideo is a rather primitive demuxer that doesn't implement track
switching. The problem was that during track switching the demuxer
implementations normally set the stream IDs in order to do the switch,
and since rawvideo obviously didn't do that, so the current stream in
ds->sh / demuxer->video->sh was set to NULL. (The frontend always
assumes track switching is successful, which is a reasonable
assumption - failing due to missing video codecs etc. is in separate
codepaths.) Later, demux_rawvideo_fill_buffer() in demux_rawvideo.c
tried to dereference the NULL stream and crashed.

Other trivial single-stream demuxers worked fine, because they didn't
try to access ds->sh.
2012-09-23 15:15:43 +02:00
wm4 397eb9364b options: handle alias options differently
When setting an alias option, its value is not saved in the file-local
options case. The ensure_backup function in m_config.c exits if it
encounters an aliased option, because it should not be saved
additionally to the original option. However, the original option is
likely never saved in this case.

Change it so that ensure_backup always accesses the original option.
The original option is the one that first appears in the option list.
2012-09-23 14:58:56 +02:00
wm4 bfc3dbae88 options: simplify somewhat by introducing a union for option values
The m_option_value union is supposed to contain a field for each
possible option type (as long as it actually stores data). This helps
avoiding silly temporary memory alocations. Using a pointer to an union
and to a field of the union interchangeably should be allowed by
standard C.
2012-09-23 14:58:31 +02:00
wm4 7fe56f1602 options: accept "yes" and "no" only for flags
This removes the alternative values like "off", "0", "false" etc., and
also the non-English versions of these.

This is done for general consistency. It's better to have a single way
of doing things when multiple ways don't add singificant value.

Also update some choices for consistency.
2012-09-23 14:58:21 +02:00
wm4 f360f492d6 commands: fix parsing bug
When tabs are used as whitespace between command and the first string
parameter, the string is not correctly terminated.
2012-09-23 14:57:41 +02:00
wm4 85a64b76cc ao_pulse: extend maximum settable volume beyond 100%
The old maximum is 100%. Raise it to PA_VOLUME_UI_MAX, which is about
150%. PA_VOLUME_UI_MAX is the PulseAudio recommended UI-settable
maximum volume, so it seems to be a good idea to use that.
2012-09-23 14:57:37 +02:00
wm4 425ac31a3b softvol, ao_pulse: prefer ao_pulse volume control by default
--softvol is enabled by default. For most audio outputs, this is a good
thing, as they have either their own (bad) soft volume implementation,
or control the system mixer. With ao_pulse, the situation is a bit
different: it supports per-application volume (i.e. volume control is
not really global). More importantly, ao_pulse uses a rather large audio
buffer, and changing the volume with mplayer's volume filter has a large
delay. With the native ao_pulse volume control, it's instant, because
PulseAudio's audio filtering happens at a later stage in its processing
pipeline (inaccessible for mplayer).

This means native volume control should really be allowed for ao_pulse,
while it's the reverse for other audio outputs. Make --softvol a choice
option, and add a new "auto" choice. This is default and will use PA's
volume control with ao_pulse, and mplayer's volume filter otherwise
(i.e. the old softvol behavior).
2012-09-23 14:57:01 +02:00
wm4 c57883b71b configure: make --enable-openal use auto detection
OpenAL is disabled by default, because it supposedly inteferes with
some other configure tests and makes them fail silently.

Previously, --enable-openal followed configure's utterly braindead
semantics and disabled auto detection. However, since OpenAL was
disabled by default, there was no easy way to enable OpenAL at all,
even if it was explicitly requested. Solve this by making
--enable-openal use auto detection.
2012-09-23 14:56:49 +02:00
wm4 af14474879 options: make cache option always per-file
When playing a network stream, the cache is automatically enabled. We
don't want the cache to stay enabled when playback ends. (For example,
the next file to be played could be a local file, and even if that is
relatively contrieved, we want to do the right thing.)

Introduced the flag M_OPT_LOCAL to force an option to be always file
local. This allows enabling the old mplayer semantics on a per option
basis.
2012-09-23 14:56:30 +02:00
wm4 5a617d02d9 mplayer: fix abort command handling
Now it actually aborts, even if the abort command is not the first
command.

Make a policy change: commands before the abort command are silently
thrown away. Previously, normal commands were run after the abort
command finished (so they were run out of order). I'm not sure which
way is the best, all things considered, but the new way is simpler.
2012-09-23 14:56:24 +02:00
Rudolf Polzer a70adbfe65 getch2: request at least 1 byte of input each read
fixes issue with | less, where mplayer broke less's terminal
expectations and made less quit

Note this means that read() will be blocking again. Should be ok, as we
always check via select() before reading.
2012-09-19 14:57:35 +02:00
Rudolf Polzer 020a954b60 mp_msg: use stdout for all output except status; put status on stderr
improves interaction with | less, | grep, ...
2012-09-19 14:57:32 +02:00
Rudolf Polzer 2f1bc6beb6 mp_msg: enable --msgcolor by default; force it off if stdout is no tty 2012-09-19 14:57:29 +02:00
wm4 65adad50ab mplayer: unbreak OSD with CONFIG_ENCODING undefined
Basically, the encoding code path wanted to set osdlevel=0 as default,
while normal playback needs osdlevel=1. For this purpose, osdlevel was
set to -1 (i.e. invalid) initially to detect whether the --osdlevel
option was explicitly set. When encoding was not configured
(CONFIG_ENCODING undefined), the osdlevel value was not set from
-1 to 1 properly, and the OSD remained invisible by default.

Fix this by getting rid of this logic. It shouldn't be needed, since
osdlevel=1 never shows any OSD messages without user interaction.
Should this ever change, we could still check whether encoding is in
progress, or add another option to allow OSD rendering during encoding.
2012-09-18 21:08:20 +02:00
wm4 f5f0c66d1f options: rename noconfig to no-config, nocache to no-cache
This how it's supposed to be. The manpage has the correct names.
2012-09-18 21:08:20 +02:00
Stefano Pigozzi 09c5324314 cocoa_common: make fullscreen menubar/dock hiding conditional
cocoa_common was hiding the dock and menubar unconditionally when
going fullscreen. This means they were hidden even if they weren't on
the screen mplayer2 was going fullscreen on, resulting in poor user
experience.

Change the fullscreen function in the cocoa backend to check that
mplayer2 is on the same screen as the menubar/dock before hiding them.
2012-09-18 21:08:20 +02:00
Rudolf Polzer f5b8b6ac12 encode: video encoding now supported using mencoder-like options 2012-09-18 21:08:20 +02:00
Rudolf Polzer 5617bf483e TOOLS: add a new file identifier tool
It can provide properties of a file to the user on stdout, or when sourced by a
script, put them into its variables.
2012-09-18 21:08:20 +02:00
wm4 b248692034 commands: allow printing raw properties
Extend m_properties_expand_string() so that it can print properties as
unformatted string. Normally, properties will be pretty-printed
(intended for OSD and user interface purposes). Add the '=' modifier to
the format string syntax that disables pretty-printing and returns them
"raw".

For example, "${=switch_audio}" will print the track number, instead of
returning an OSD friendly string containing additional information like
track title and language.
2012-09-18 21:08:20 +02:00
Rudolf Polzer 416c03417e vf_rectangle: remove as it is very dirty and we have a replacement now 2012-09-18 21:08:20 +02:00
Rudolf Polzer 6371787b89 vf_dlopen: vf_rectangle filter moved to dlopen (unix only)
It is unix only, because vf_dlopen filters have no way to receive input (yet)
2012-09-18 21:08:20 +02:00
Rudolf Polzer 9343c1d3ab vf_dlopen: improve performance for 1-frame-for-1-frame filters
This is done by requesting a buffer from the next filter in the chain, instead
of always allocating our own. This allows the next filter to e.g. ensure its
own preferred memory layout.
2012-09-18 21:08:20 +02:00