Commit Graph

25 Commits

Author SHA1 Message Date
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 4d11f32162 VO, sub: refactor
Remove VFCTRL_DRAW_OSD, VFCAP_EOSD_FILTER, VFCAP_EOSD_RGBA, VFCAP_EOSD,
VOCTRL_DRAW_EOSD, VOCTRL_GET_EOSD_RES, VOCTRL_QUERY_EOSD_FORMAT.

Remove draw_osd_with_eosd(), which rendered the OSD by calling
VOCTRL_DRAW_EOSD. Change VOs to call osd_draw() directly, which takes
a callback as argument. (This basically works like the old OSD API,
except multiple OSD bitmap formats are supported and caching is
possible.)

Remove all mentions of "eosd". It's simply "osd" now.

Make OSD size per-OSD-object, as they can be different when using
vf_sub. Include display_par/video_par in resolution change detection.

Fix the issue with margin borders in vo_corevideo.
2012-10-24 21:56:34 +02:00
wm4 98f74335d5 sub: fix text subtitle aspect ratio with vo_xv and vo_lavc, refactor
This fixes that vo_xv didn't display text subtitles correctly when
using anamorphic video. It didn't pass the aspect information to the
subtitle renderer. Also, try to render OSD correctly with respect to
aspect ratio settings: on vo_xv, the OSD is rendered into the video,
and needs to be "stretched" too when playing anamorphic video. When
the -monitorpixelaspect option is used, even with VOs such as vo_opengl
the OSD has to be rendered with that aspect ratio.

As preparation for future commits, replace the weird vsfilter_scale
value with a somewhat more sensible video_par member.

Also, struct mp_eosd_res is a better place for the aspect ratio
parameters, as OSD needs this too.

Use osd_draw_on_image() directly in vo_lavc, which fixes aspect ratio
issues as well.
2012-10-24 21:56:33 +02:00
wm4 4e89851aa1 Merge branch 'master' into osd_changes
Conflicts:
	Makefile
	command.c
	libvo/gl_common.c
	libvo/vo_corevideo.m
	libvo/vo_opengl.c
	libvo/vo_opengl_old.c
	libvo/vo_opengl_shaders.glsl
	sub/ass_mp.c
	sub/osd_libass.c
	sub/sd_ass.c
2012-10-16 07:30:30 +02:00
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 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 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 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
wm4 c9df2c8bd8 sub: add --ass-style-override option to disable style overrides
There are a number of options which modify ASS subtitle rendering. Most
of these do things that can interfere with the styling done by subtitle
scripts, resulting in incorrect rendering. Add the --ass-style-override
option to make it easy to disable all overrides. This helps trouble-
shooting, and makes it more practical to use the override features. (You
can simply toggle the ass-style-override property at runtime, should
one of the style override options break subtitle rendering at a certain
point.)

This mainly affects whether most --ass-* options are applied, as well
as --sub-pos. Some things, like explicit style overrides loaded with
--ass-force-style, can't be changed at runtime using the
ass-style-override property.
2012-10-12 10:13:42 +02:00
Uoti Urpala 1959ba006c subs, vo_vdpau: support RGBA color for PGS subtitles
Support passing bitmap subtitles to VOs in full RGBA color, and
implement this for libavcodec-decoded subtitle formats on decoding
side and vo_vdpau on display side. Currently this is enabled for PGS
(blu-ray) and DVB subtitles.

VDPAU seems to have sampling issues similar to known GL ones when
drawing a sub-rectangle from a larger texture with scaling, where
adjacent pixels outside the specified source rectangle affect the
result. As the bitmap subtitles may be scaled, add padding support to
the bitmap packer code.

In principle, this could be used for colored DVD subtitles too.
However, the libavcodec DVD decoder lacks parts of the resolution and
palette handling that are present in spudec.c.

Conflicts:
	libvo/vo_gl.c
	sub/dec_sub.h
	sub/sd_lavc.c
2012-09-18 21:07:30 +02:00
wm4 b554a59b58 subs: restore support for sub_step command with libass
This was destroyed by Uoti Urpala in commit "subs: always use sub...".
Features should be either kept working or completely removed, but not
just crippled, which only inflates the code and frustrates users.
2012-09-18 21:04:46 +02:00
Uoti Urpala fd52cb65f4 subs, vo: do sub bitmap change detection by comparing IDs
vo_vdpau and vo_gl cache the last subtitle bitmaps uploaded to video
card in case they stay the same over multiple frames. Detecting
whether the bitmaps have changed and should be re-uploaded was
somewhat fragile. Change the VO API to provide a bitmap ID which can
be compared with what the VO has to determine whether a new upload of
the bitmaps is needed.

Conflicts:
	libvo/vo_gl.c

Note: the changes for vo_gl.c were not merged. Instead, eosd_packer is
modified to use the new way of detecting EOSD changes. This takes care
of vo_gl, vo_gl3 and vo_direct3d, which all render EOSD. They don't
need to be updated in turn.
2012-09-18 21:04:46 +02:00
Uoti Urpala 89a5714893 subs: always use sub decoder framework for libass rendering
Remove subtitle selection code setting osd->ass_track directly and
vf_ass/vf_vo code rendering the track directly with libass. Instead,
do track selection and rendering with dec_sub.c functions.

Before, mpctx->set_of_ass_tracks[] contained bare libass tracks
generated from external subtitle files. For use with dec_sub.c, it now
contains struct sh_sub instances with decoder already initialized.

This commit breaks the sub_step command ('g' and 'y' keys) for
libass-rendered subtitles. It could be fixed, but it's so useless -
especially as with the existing implementation there's no practical
way to get subtitle delay back to normal after using it - that I
didn't bother.

Conflicts:
	command.c
	mp_core.h
	mplayer.c
2012-09-18 21:04:46 +02:00
Uoti Urpala 9bb03b7db4 subs: libass: use a single persistent renderer for subtitles
To draw libass subtitles, the code used ASS_Renderer objects created
in vf_vo (VO rendering) or vf_ass. They were destroyed and recreated
together with the video filter  chain. Change the code to use a single
persistent renderer instance stored in the main osd_state struct.
Because libass seems to misbehave if fonts are changed while a
renderer exists (even if ass_set_fonts() is called on the renderer
afterwards), the renderer is recreated after adding embedded fonts.

The known benefits are simpler code and avoiding delays when switching
between timeline parts from different files (libass fontconfig
initialization, needed when creating a new renderer, can take a long
time in some cases; switching between files rebuilds the video filter
chain, and this required recreating the renderers). On the other hand,
I'm not sure whether this could cause inefficient bitmap caching in
libass; explicitly resetting the renderer in some cases could be
beneficial. The new code does not keep the distinction of separate
renderers for vsfilter munged aspect vs normal; this means that
changing subtitle tracks can lose cache for the previous track.

The new code always sets some libass parameters on each rendering
call, which were previously only set if they had potentially changed.
This should be harmless as libass itself has checks to see if the
values differ from previous ones.

Conflicts:
	command.c
	libmpcodecs/vf_ass.c
	libmpcodecs/vf_vo.c
	mplayer.c
	sub/ass_mp.c
2012-09-18 21:04:46 +02:00
Uoti Urpala 44d8ec9272 sd_lavc: use subtitle framework for former av_sub.c code
Change libavcodec subtitle decoding code (used for some bitmap
subtitle types) to use the same decoding framework as sd_ass. The
functionality that was previously in av_sub.c and was directly called
from mplayer.c is now in sd_lavc.c.

Conflicts:
	mplayer.c
	sub/av_sub.h
	sub/sd_lavc.c

Merged from mplayer2. The remaining use of is_av_sub() is replaced by
a check whether a subtitle decoder is active, which should give the
same results.
2012-09-18 21:04:46 +02:00
Uoti Urpala 0383070588 sd_ass.c: set event->Style to fix --ass-styles
Set the "Style" attribute for subtitle events created in sd_ass to
match the "default_style" attribute of the track. This is required to
make --ass-styles work with recent libass versions (otherwise the
event would use style 0, which is a fallback style added by libass
now).

Commit 378ada847c ("sub/ass: use default
style, not first style unconditionally") fixed the same issue for
external subtitles converted with mp_ass_read_subdata(); this commit
fixes it for muxed ones.
2011-09-23 13:57:11 +03:00
Uoti Urpala 83fc5b6004 options: move libass-related options to struct 2011-09-03 14:26:14 +03:00
Uoti Urpala b2e213d889 aviheader.h: avoid including demuxer.h
Remove unnecessary demuxer.h include from aviheader.h. Through
stheader.h aviheader.h is included in a lot of files. Add missing
mp_msg.h includes to av_sub.c and sd_ass.c (previously hidden by
indirect inclusion through demuxer.h and stream.h).
2011-08-19 21:37:16 +03:00
Uoti Urpala 91d6bca695 cleanup: subs: remove global ass_library variable 2011-07-23 01:55:13 +03:00
Uoti Urpala c9026cb321 sub/OSD: move some related files to sub/ 2011-01-26 20:39:05 +02:00
Uoti Urpala a248c2c7a1 cleanup: rename ass_* functions to mp_ass_*
The various ass_* functions were created when libass was part of the
MPlayer tree and the distinction between MPlayer-specific and other
functions was less clear. Now that libass is a clearly separate
library, using the same ass_* namespace for player functions is ugly.
Rename the functions to use mp_ass_ prefix instead.
2011-01-26 20:39:04 +02:00
Uoti Urpala 966340b31a subs: use correct font aspect ratio for libass + converted subs
Rendering of ASS subtitles tries to be bug compatible with VSFilter
and stretches fonts when the video is anamorphic (some scripts try to
compensate for this VSFilter behavior, so trying to render them
"correctly" would give the wrong result). However this behavior is not
appropriate for subtitles we converted to ASS format ourselves for
libass rendering, as they certainly don't have VSFilter bug
workarounds. Change the code to use different behavior for "native"
ASS tracks and converted ones. It's questionable whether the
VSFilter-compatible behavior is appropriate for external .ass files
either, as there could be anamorphic and non-anamorphic versions of
the same video and the bug-compatible behavior can only be correct for
one alternative at most. However it's probably better to keep it as a
default at least, so that extracting a muxed subtitle track and using
that does not give behavior different from the original muxed one.

The aspect ratio setting is per ASS_Renderer, and changing it resets
libass caches. For that reason this commit adds separate renderer
instances to use for the "correct" and "VSFilter bug compatible"
cases.
2011-01-26 20:38:53 +02:00
Uoti Urpala 7bb10e7ce2 sd_ass: remove subreader use, support plaintext markup
Originally, when rendering plaintext subs with libass, the subtitles
were first converted to the "struct subtitle" form with sub_add_text()
and then from that to libass events. Change sd_ass to convert the
subtitles directly to libass events without using the old sub
machinery. The new conversion at least fixes some timing issues. Also
use the markup support added in the previous commit, so that
HTML-style markup is also supported in "plaintext" subs rendered with
libass.
2011-01-18 15:33:36 +02:00
Uoti Urpala e990fb2ffe subtitles: add framework for subtitle decoders
Add a framework for subtitle decoder modules that work more like
audio/video decoders do, and change libass rendering of demuxed
subtitles to use the new framework.

The old subtitle code is messy, with details specific to handling
particular subtitle types spread over high-level code. This should
make it easier to clean things up and fix some bugs/limitations.
2011-01-18 14:58:09 +02:00