Commit Graph

92 Commits

Author SHA1 Message Date
wm4 696a8c5609 osd_libass: add "Default" dummy style
This is pretty much a hack for the OSC. It will allow it to rely on a
somewhat predictable style, instead of having to overwrite all user
OSD settings manually with override tags.
2013-09-26 17:49:54 +02:00
wm4 6048f87e3c Add initial Lua scripting support
This is preliminary. There are still tons of issues, and any aspect
of scripting may change in the future. I decided to merge this
(preliminary) work now because it makes it easier to develop it, not
because it's done. lua.rst is clear enough about it (plus some
sarcasm).

This requires linking to Lua. Lua has no official pkg-config file, but
there are distribution specific .pc files, all with different names.
Adding a non-pkg-config based configure test was considered, but we'd
rather not.

One major complication is that libquvi links against Lua too, and if
the Lua version is different from mpv's, you will get a crash as soon
as libquvi uses Lua. (libquvi by design always runs when a file is
opened.) I would consider this the problem of distros and whoever
builds mpv, but to make things easier for users, we add a terrible
runtime test to the configure script, which probes whether libquvi
will crash. This is disabled when cross-compiling, but in that case
we hope the user knows what he is doing.
2013-09-26 01:28:58 +02:00
ChrisK2 7f398f833e osc: rename osd_font, add some glyphs
Cherry picked from various commits in lua_experiment by ChrisK2.

The metrics of the OSD symbols change slightly, possibly due to the
font editor that was used, and the metrics were not correct to begin
with. (But the real reason seems unknown.) Remove the rescaling of
the OSD font in ASS_USE_OSD_FONT, because the height more or less fits
now. (This change wasn't in the lua_experiment branch.)
2013-09-08 03:35:04 +02:00
wm4 9a1978b2ee osd_libass: make sure Z-order is well defined for multiple events
Otherwise, events may overlap in arbitrary ways.
2013-09-08 03:20:38 +02:00
Stefano Pigozzi 406241005e core: move contents to mpvcore (2/2)
Followup commit. Fixes all the files references.
2013-08-06 22:52:31 +02:00
wm4 cb45b1c65b Cleanup some include statements 2013-07-12 22:16:26 +02:00
wm4 8c63b318dc ass_mp: provide function to add default styles 2013-06-03 22:40:07 +02:00
wm4 28116b8a79 sub: remove some global variables 2013-05-30 22:44:18 +02:00
wm4 b44202b69f sub: redo how -no-ass is handled
The -no-ass switch used to disable any use of libass for text subtitles.
This is not really the case anymore, because libass is now always
involved when rendering text. The only remaining use of -no-ass is
disabling styling or showing subtitles on the terminal. On the other
hand, the old subtitle rendering path is a big reason why the subtitle
code is still a big mess with an awful number of obscure special cases.

In order to simplify it, remove the old subtitle rendering code, and
always go through sd_ass.c. Basically, we use ASS_Track as central data
structure for storing text subtitles instead of struct sub_data. This
also makes libass mandatory for all text subs, even if they are printed
to the terminal in -no-video mode. (We could add something like sd_text
to avoid this, but it's not worth the trouble.)

struct sub_data and subreader.c are still around, even its ASS/SSA
reader. But struct sub_data is freed right after converting it to
ASS_Track. The internal ASS reader actually can handle some obscure
cases libass can't, like files encoded in UTF-16.
2013-05-30 22:20:02 +02:00
Paul B Mahol 83570fc0fb add osd-scale command
Signed-off-by: Paul B Mahol <onemda@gmail.com>

Modified to add docs for --osd-scale option, and adjusted to the
previous commit by wm4.
2013-05-14 23:32:07 +02:00
wm4 ad3dfa145b osd_libass: actually free ASS_Tracks
Not a real leak, just for getting clean valgrind reports on exit.
2013-04-12 19:02:58 +02:00
wm4 0bafdca476 osd: fix OSD bar position marker 2013-04-02 01:53:33 +02:00
wm4 6cdc604f59 osd: disable border for inner part of the OSD bar 2013-03-31 21:12:53 +02:00
wm4 ef3c0e6eda osd: draw the OSD bar with ASS vector drawings
Drawing the bar with vector drawings (instead with characters from the
OSD font) offers more flexibility and looks better. This also adds
chapter marks to the OSD bar, which are visible as small triangles on
the top and bottom inner border of the bar.

Change the default position of the OSD bar below the center of the
screen. This is less annoying than putting the bar directly into the
center of the view, where it obscures the video. The new position is
not quite on the bottom of the screen to avoid collisions with
subtitles.

The old centered position can be forced with ``--osd-bar-align-y=0``.

Also make it possible to change the OSD bar width/height with the new
--osd-bar-w and --osd-bar-h options.

It's possible that the new OSD bar renders much slower than the old
one. There are two reasons for this: 1. the character based bar
allowed libass to cache each character, while the vector drawing forces
it to redraw every time the bar position changes. 2., the bar position
is updated at a much higher granularity (the bar position is passed
along as float instead of as integer in the range 0-100, so the bar
will be updated on every single video frame).
2013-03-30 20:23:45 +01:00
wm4 80e9b3c0f2 cleanup: remove duplicated function, move escape parsing function 2013-02-16 23:24:46 +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 e8181ed9fb osd: add --osd-bar-align-x/y options to control OSD bar position 2013-02-14 20:45:44 +01:00
wm4 ca9c81b0d3 sub: add --sub-text-* options to unstyled text subtitles font
Before this commit, the --osd-* options (like --osd-font-size etc.)
configured both the OSD and subtitle font. Make them separate, and add
--sub-text-* options (like --sub-text-size etc.). Now --osd-* affects
the OSD font only, and --sub-text-* unstyled text subtitles only.
2013-01-05 14:11:56 +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 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 0e81d62c53 Merge branch 'master' into osd_changes
Conflicts:
	libvo/vo_xv.c
2012-10-24 22:38:45 +02:00
wm4 a8824f12dd options: remove --subfont-autoscale (changes default font scale)
The code for this option attempted to emulate the old as-documented
behavior. It wasn't very good at it, and now that the old OSD code has
been removed, it's entirely pointless.

This removes the factor 1.7 with which --subfont-text-scale was
multiplied.
2012-10-24 21:56:35 +02: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 a781fe14f7 osd_libass: increase robustness when handling internal OSD escapes
The \xFF escape is used internally to insert special OSD symbols (which
need a font change to the internal OSD font). There was potential for
breakage when \xFF was followed by \0, because then "in" would be
advanced past the string's end.

Normally this can't happen, as it would require invalid UTF-8 input
data. But we don't check input for UTF-8 validness, so there's a
potential issue here. Garbled output is ok on invalid UTF-8 input,
but crashing is not.

Make it more robust by checking for this.
2012-10-22 01:55:58 +02:00
wm4 7b65202e47 osd_libass: fix stupid dangling pointer crash
append_utf8_buffer() reallocates the buffer passed to it, and returns
the new pointer.

This bug was originally introduced in mplayer2 when that project merged
mpv's osd_libass.c. That merge changed some minor things, including ASS
escape handling. When mpv used this better method of escape handling too
(commit 0ff7dd992f), the bug was duplicated.
2012-10-22 01:55:55 +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 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 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 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 0ff7dd992f osd_libass: fix \n escapes
Apparently libass can't be made to not interpret "\n" as escape. That
means "\n" can't be printed literally. Use the same hack that was added
to mplayer2 when that project merged osd_libass.c: add an invisible
zero-width joiner character between "\" and "n". It seems U+FEFF is
deprecated, because it has been redefined as BOM mark. Use U+2060, which
seems to be the replacement.
2012-10-14 22:28:51 +02:00
wm4 2f6713bede sub: enable sub-pos with libass
The --sub-pos option and sub-pos property control the vertical position
of a subtitle.

Also change how sub-pos is handled in the old subtitle renderer (used
with -no-ass). The new behavior doesn't render subtitles out of the
screen if the subtitle is located near the top screen border and has
too many lines.
2012-10-12 10:13:42 +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
wm4 b65424f5c2 osd_libass: fix displaying empty text, fix API usage
If empty text is rendered, the bounding box is empty. Instead of
continuing with a bogus bounding box that would result in garbage
being rendered on screen, make the OSD image invisible.

This happened when playing demuxer SRT subtitles (e.g. SRT embedded in
MKV) with -no-ass at the moment a subtitle line disappeared.

Unrelated to this issue, fix libass API usage. Delete the event with
libass_flush_events(), instead of trying to reuse the previous event.

Based on a patch by uau.
2012-08-21 18:58:15 +02:00
wm4 fb563de255 sub: fix confusion of ass_library handles
Commit 7484ae8e2e attempted to introduce two ass_library handles
(as it was needed to deal with how ass_library manages fonts), but the
commit was completely bogus: it assumed osd_state->ass_library would be
used by osd_libass.c only, which is not the case. As result, some of the
subtitle code used the wrong ass_library handle.

We need two ass_library handles in osd_state. The one from the mplayer
core for subtitles (osd_state->ass_library), and one for OSD rendering
(osd_state->osd_ass_library).
2012-08-07 19:21:46 +02:00
wm4 7484ae8e2e osd_libass: allocate separate ASS_Library for OSD
osd_libass.c used the same ASS_Library object as the player core. This
caused a problem: when playing a new file, all fonts loaded by the
ASS_Library object were unloaded, including the OSD font. Parts of the
OSD would stop being rendered correctly.

Solve this by creating a separate ASS_Library, with its own set of
fonts.
2012-08-07 02:15:27 +02:00
wm4 ebaaa41f2a Remove teletext support
Teletext requires special OSD support. Because I can't even test
teletext, I can't restore support for it. Since teletext can be
considered ancient and obscure, and since it doesn't make sense to keep
the remaining teletext code without being able to use it, I'm removing
it.
2012-08-03 00:12:46 +02:00
wm4 71e51d948c osd: osd_font.h -> osd_font.pfb
osd_font.pfb is an actual font file extracted from osd_font.h.
file2string.py is used to turn it back into a header during the
build process.
2012-07-28 23:36:08 +02:00
wm4 85a3a0d5bc osd: remove freetype font rendering code
The previous commit made libass the default OSD renderer. This commit
removes the disabled freetype renderer completely. The commits were
done separately to make rolling back easier, because using libass for
OSD rendering is a risky choice.

Also remove freetype/fontconfig/fribidi code. This is all done by
libass now.

If mplayer is compiled without libass, no OSD is displayed.
2012-07-28 23:36:08 +02:00
wm4 74e7a1e937 osd: use libass for OSD rendering
The OSD will now be rendered with libass. The old rendering code, which
used freetype/fontconfig and did text layout manually, is disabled. To
re-enable the old code, use the --disable-libass-osd configure switch.

Some switches do nothing with the new code enabled, such as -subalign,
-sub-bg-alpha, -sub-bg-color, and many more. (The reason is mostly that
the code for rendering unstyled subtitles with libass doesn't make any
attempts to support them. Some of them could be supported in theory.)

Teletext rendering is not implemented in the new OSD rendering code. I
don't have any teletext sources for testing, and since teletext is
being phased out world-wide, the need for this is questionable.

Note that rendering is extremely inefficient, mostly because the libass
output is blended with the extremely strange mplayer OSD format. This
could be improved at a later point.

Remove most OSD rendering from vo_aa.c, because that was extremely
hacky, can't be made work with osd_libass, and didn't work anyway in
my tests.

Internally, some cleanup is done. Subtitle and OSD related variable
declarations were literally all over the place. Move them to sub.h and
sub.c, which were hoarding most of these declarations already. Make the
player core in mplayer.c free of concerns like bitmap font loading.

The old OSD rendering code has been moved to osd_ft.c. The font_load.c
and font_load_ft.c are only needed and compiled if the old OSD
rendering code is configured.
2012-07-28 23:36:07 +02:00