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-03-22 05:26:37 +00:00
|
|
|
/*
|
2015-04-13 07:36:54 +00:00
|
|
|
* This file is part of mpv.
|
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-03-22 05:26:37 +00:00
|
|
|
*
|
Relicense some non-MPlayer source files to LGPL 2.1 or later
This covers source files which were added in mplayer2 and mpv times
only, and where all code is covered by LGPL relicensing agreements.
There are probably more files to which this applies, but I'm being
conservative here.
A file named ao_sdl.c exists in MPlayer too, but the mpv one is a
complete rewrite, and was added some time after the original ao_sdl.c
was removed. The same applies to vo_sdl.c, for which the SDL2 API is
radically different in addition (MPlayer supports SDL 1.2 only).
common.c contains only code written by me. But common.h is a strange
case: although it originally was named mp_common.h and exists in MPlayer
too, by now it contains only definitions written by uau and me. The
exceptions are the CONTROL_ defines - thus not changing the license of
common.h yet.
codec_tags.c contained once large tables generated from MPlayer's
codecs.conf, but all of these tables were removed.
From demux_playlist.c I'm removing a code fragment from someone who was
not asked; this probably could be done later (see commit 15dccc37).
misc.c is a bit complicated to reason about (it was split off mplayer.c
and thus contains random functions out of this file), but actually all
functions have been added post-MPlayer. Except get_relative_time(),
which was written by uau, but looks similar to 3 different versions of
something similar in each of the Unix/win32/OSX timer source files. I'm
not sure what that means in regards to copyright, so I've just moved it
into another still-GPL source file for now.
screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but
they're all gone.
2016-01-19 17:36:06 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
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-03-22 05:26:37 +00:00
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
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-03-22 05:26:37 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Relicense some non-MPlayer source files to LGPL 2.1 or later
This covers source files which were added in mplayer2 and mpv times
only, and where all code is covered by LGPL relicensing agreements.
There are probably more files to which this applies, but I'm being
conservative here.
A file named ao_sdl.c exists in MPlayer too, but the mpv one is a
complete rewrite, and was added some time after the original ao_sdl.c
was removed. The same applies to vo_sdl.c, for which the SDL2 API is
radically different in addition (MPlayer supports SDL 1.2 only).
common.c contains only code written by me. But common.h is a strange
case: although it originally was named mp_common.h and exists in MPlayer
too, by now it contains only definitions written by uau and me. The
exceptions are the CONTROL_ defines - thus not changing the license of
common.h yet.
codec_tags.c contained once large tables generated from MPlayer's
codecs.conf, but all of these tables were removed.
From demux_playlist.c I'm removing a code fragment from someone who was
not asked; this probably could be done later (see commit 15dccc37).
misc.c is a bit complicated to reason about (it was split off mplayer.c
and thus contains random functions out of this file), but actually all
functions have been added post-MPlayer. Except get_relative_time(),
which was written by uau, but looks similar to 3 different versions of
something similar in each of the Unix/win32/OSX timer source files. I'm
not sure what that means in regards to copyright, so I've just moved it
into another still-GPL source file for now.
screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but
they're all gone.
2016-01-19 17:36:06 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
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-03-22 05:26:37 +00:00
|
|
|
*
|
Relicense some non-MPlayer source files to LGPL 2.1 or later
This covers source files which were added in mplayer2 and mpv times
only, and where all code is covered by LGPL relicensing agreements.
There are probably more files to which this applies, but I'm being
conservative here.
A file named ao_sdl.c exists in MPlayer too, but the mpv one is a
complete rewrite, and was added some time after the original ao_sdl.c
was removed. The same applies to vo_sdl.c, for which the SDL2 API is
radically different in addition (MPlayer supports SDL 1.2 only).
common.c contains only code written by me. But common.h is a strange
case: although it originally was named mp_common.h and exists in MPlayer
too, by now it contains only definitions written by uau and me. The
exceptions are the CONTROL_ defines - thus not changing the license of
common.h yet.
codec_tags.c contained once large tables generated from MPlayer's
codecs.conf, but all of these tables were removed.
From demux_playlist.c I'm removing a code fragment from someone who was
not asked; this probably could be done later (see commit 15dccc37).
misc.c is a bit complicated to reason about (it was split off mplayer.c
and thus contains random functions out of this file), but actually all
functions have been added post-MPlayer. Except get_relative_time(),
which was written by uau, but looks similar to 3 different versions of
something similar in each of the Unix/win32/OSX timer source files. I'm
not sure what that means in regards to copyright, so I've just moved it
into another still-GPL source file for now.
screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but
they're all gone.
2016-01-19 17:36:06 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
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-03-22 05:26:37 +00:00
|
|
|
*/
|
|
|
|
|
2019-10-31 10:24:20 +00:00
|
|
|
#include <math.h>
|
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-03-22 05:26:37 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
2016-01-11 18:03:40 +00:00
|
|
|
#include "mpv_talloc.h"
|
2014-08-29 10:09:04 +00:00
|
|
|
#include "misc/bstr.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/common.h"
|
|
|
|
#include "common/msg.h"
|
2013-11-24 11:58:06 +00:00
|
|
|
#include "osd.h"
|
2014-01-18 00:19:20 +00:00
|
|
|
#include "osd_state.h"
|
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-03-22 05:26:37 +00:00
|
|
|
|
2012-07-28 21:03:19 +00:00
|
|
|
static const char osd_font_pfb[] =
|
2023-07-23 22:54:35 +00:00
|
|
|
#include "sub/osd_font.otf.inc"
|
2012-07-28 21:03:19 +00:00
|
|
|
;
|
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-03-22 05:26:37 +00:00
|
|
|
|
|
|
|
#include "sub/ass_mp.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/options.h"
|
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-03-22 05:26:37 +00:00
|
|
|
|
|
|
|
|
2013-05-14 17:14:09 +00:00
|
|
|
#define ASS_USE_OSD_FONT "{\\fnmpv-osd-symbols}"
|
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-03-22 05:26:37 +00:00
|
|
|
|
2020-03-06 17:20:11 +00:00
|
|
|
static void append_ass(struct ass_state *ass, struct mp_osd_res *res,
|
|
|
|
ASS_Image **img_list, bool *changed);
|
|
|
|
|
2016-03-08 20:29:29 +00:00
|
|
|
static void create_ass_renderer(struct osd_state *osd, struct ass_state *ass)
|
2013-12-15 14:04:49 +00:00
|
|
|
{
|
2016-03-08 20:29:29 +00:00
|
|
|
if (ass->render)
|
2013-12-15 14:04:49 +00:00
|
|
|
return;
|
|
|
|
|
2016-03-08 20:29:29 +00:00
|
|
|
ass->log = mp_log_new(NULL, osd->log, "libass");
|
2022-02-11 02:36:34 +00:00
|
|
|
ass->library = mp_ass_init(osd->global, osd->opts->osd_style, ass->log);
|
2016-03-08 20:29:29 +00:00
|
|
|
ass_add_font(ass->library, "mpv-osd-symbols", (void *)osd_font_pfb,
|
2012-07-28 21:03:19 +00:00
|
|
|
sizeof(osd_font_pfb) - 1);
|
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-03-22 05:26:37 +00:00
|
|
|
|
2016-03-08 20:29:29 +00:00
|
|
|
ass->render = ass_renderer_init(ass->library);
|
|
|
|
if (!ass->render)
|
2013-12-15 14:04:49 +00:00
|
|
|
abort();
|
|
|
|
|
2016-03-08 20:29:29 +00:00
|
|
|
mp_ass_configure_fonts(ass->render, osd->opts->osd_style,
|
|
|
|
osd->global, ass->log);
|
2020-08-28 13:55:20 +00:00
|
|
|
ass_set_pixel_aspect(ass->render, 1.0);
|
2016-03-08 20:29:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void destroy_ass_renderer(struct ass_state *ass)
|
|
|
|
{
|
|
|
|
if (ass->track)
|
|
|
|
ass_free_track(ass->track);
|
|
|
|
ass->track = NULL;
|
|
|
|
if (ass->render)
|
|
|
|
ass_renderer_done(ass->render);
|
|
|
|
ass->render = NULL;
|
|
|
|
if (ass->library)
|
|
|
|
ass_library_done(ass->library);
|
|
|
|
ass->library = NULL;
|
|
|
|
talloc_free(ass->log);
|
|
|
|
ass->log = NULL;
|
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-03-22 05:26:37 +00:00
|
|
|
}
|
|
|
|
|
2016-03-08 20:42:08 +00:00
|
|
|
static void destroy_external(struct osd_external *ext)
|
|
|
|
{
|
|
|
|
destroy_ass_renderer(&ext->ass);
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
talloc_free(ext);
|
2016-03-08 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
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-03-22 05:26:37 +00:00
|
|
|
void osd_destroy_backend(struct osd_state *osd)
|
|
|
|
{
|
2013-04-12 17:02:58 +00:00
|
|
|
for (int n = 0; n < MAX_OSD_PARTS; n++) {
|
|
|
|
struct osd_object *obj = osd->objs[n];
|
2016-03-08 20:29:29 +00:00
|
|
|
destroy_ass_renderer(&obj->ass);
|
2016-03-08 20:42:08 +00:00
|
|
|
for (int i = 0; i < obj->num_externals; i++)
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
destroy_external(obj->externals[i]);
|
2016-03-08 20:42:08 +00:00
|
|
|
obj->num_externals = 0;
|
2013-04-12 17:02:58 +00:00
|
|
|
}
|
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-03-22 05:26:37 +00:00
|
|
|
}
|
|
|
|
|
2017-07-16 11:33:19 +00:00
|
|
|
static void update_playres(struct ass_state *ass, struct mp_osd_res *vo_res)
|
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-03-22 05:26:37 +00:00
|
|
|
{
|
2016-03-08 20:29:29 +00:00
|
|
|
ASS_Track *track = ass->track;
|
2013-12-15 14:04:49 +00:00
|
|
|
int old_res_x = track->PlayResX;
|
|
|
|
int old_res_y = track->PlayResY;
|
2013-03-30 19:08:56 +00:00
|
|
|
|
2020-03-06 17:20:11 +00:00
|
|
|
ass->vo_res = *vo_res;
|
|
|
|
|
2017-07-16 11:33:19 +00:00
|
|
|
double aspect = 1.0 * vo_res->w / MPMAX(vo_res->h, 1);
|
|
|
|
if (vo_res->display_par > 0)
|
|
|
|
aspect = aspect / vo_res->display_par;
|
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-03-22 05:26:37 +00:00
|
|
|
|
2017-07-16 11:33:19 +00:00
|
|
|
track->PlayResY = ass->res_y ? ass->res_y : MP_ASS_FONT_PLAYRESY;
|
|
|
|
track->PlayResX = ass->res_x ? ass->res_x : track->PlayResY * aspect;
|
2012-11-17 19:56:45 +00:00
|
|
|
|
2013-12-15 14:04:49 +00:00
|
|
|
// Force libass to clear its internal cache - it doesn't check for
|
|
|
|
// PlayRes changes itself.
|
|
|
|
if (old_res_x != track->PlayResX || old_res_y != track->PlayResY)
|
2016-03-08 20:29:29 +00:00
|
|
|
ass_set_frame_size(ass->render, 1, 1);
|
2017-07-16 11:33:19 +00:00
|
|
|
}
|
2013-12-15 14:04:49 +00:00
|
|
|
|
2017-07-16 11:33:19 +00:00
|
|
|
static void create_ass_track(struct osd_state *osd, struct osd_object *obj,
|
|
|
|
struct ass_state *ass)
|
|
|
|
{
|
|
|
|
create_ass_renderer(osd, ass);
|
|
|
|
|
|
|
|
ASS_Track *track = ass->track;
|
|
|
|
if (!track)
|
|
|
|
track = ass->track = ass_new_track(ass->library);
|
|
|
|
|
|
|
|
track->track_type = TRACK_TYPE_ASS;
|
|
|
|
track->Timer = 100.;
|
|
|
|
track->WrapStyle = 1; // end-of-line wrapping instead of smart wrapping
|
|
|
|
track->Kerning = true;
|
2020-07-11 18:06:48 +00:00
|
|
|
track->ScaledBorderAndShadow = true;
|
2022-08-31 13:46:17 +00:00
|
|
|
#if LIBASS_VERSION >= 0x01600010
|
|
|
|
ass_track_set_feature(track, ASS_FEATURE_WRAP_UNICODE, 1);
|
|
|
|
#endif
|
2017-07-16 11:33:19 +00:00
|
|
|
update_playres(ass, &obj->vo_res);
|
2015-11-29 12:50:51 +00:00
|
|
|
}
|
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-03-22 05:26:37 +00:00
|
|
|
|
2015-11-29 12:50:51 +00:00
|
|
|
static int find_style(ASS_Track *track, const char *name, int def)
|
|
|
|
{
|
|
|
|
for (int n = 0; n < track->n_styles; n++) {
|
|
|
|
if (track->styles[n].Name && strcmp(track->styles[n].Name, name) == 0)
|
|
|
|
return n;
|
2015-11-28 18:24:31 +00:00
|
|
|
}
|
2015-11-29 12:50:51 +00:00
|
|
|
return def;
|
|
|
|
}
|
2013-12-15 16:38:48 +00:00
|
|
|
|
2015-11-29 12:50:51 +00:00
|
|
|
// Find a given style, or add it if it's missing.
|
2016-03-08 20:29:29 +00:00
|
|
|
static ASS_Style *get_style(struct ass_state *ass, char *name)
|
2015-11-29 12:50:51 +00:00
|
|
|
{
|
2016-03-08 20:29:29 +00:00
|
|
|
ASS_Track *track = ass->track;
|
2015-11-29 12:50:51 +00:00
|
|
|
if (!track)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
int sid = find_style(track, name, -1);
|
|
|
|
if (sid >= 0)
|
|
|
|
return &track->styles[sid];
|
|
|
|
|
|
|
|
sid = ass_alloc_style(track);
|
|
|
|
ASS_Style *style = &track->styles[sid];
|
|
|
|
style->Name = strdup(name);
|
|
|
|
// Set to neutral base direction, as opposed to VSFilter LTR default
|
|
|
|
style->Encoding = -1;
|
|
|
|
return style;
|
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-03-22 05:26:37 +00:00
|
|
|
}
|
|
|
|
|
2015-11-29 12:50:51 +00:00
|
|
|
static ASS_Event *add_osd_ass_event(ASS_Track *track, const char *style,
|
|
|
|
const char *text)
|
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-03-22 05:26:37 +00:00
|
|
|
{
|
2013-03-30 19:08:56 +00:00
|
|
|
int n = ass_alloc_event(track);
|
|
|
|
ASS_Event *event = track->events + n;
|
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-03-22 05:26:37 +00:00
|
|
|
event->Start = 0;
|
|
|
|
event->Duration = 100;
|
2015-11-29 12:50:51 +00:00
|
|
|
event->Style = find_style(track, style, 0);
|
2013-05-10 17:45:38 +00:00
|
|
|
event->ReadOrder = n;
|
2012-09-28 19:38:52 +00:00
|
|
|
assert(event->Text == NULL);
|
2013-03-30 19:08:56 +00:00
|
|
|
if (text)
|
|
|
|
event->Text = strdup(text);
|
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-03-22 05:26:37 +00:00
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:29:29 +00:00
|
|
|
static void clear_ass(struct ass_state *ass)
|
2012-09-28 19:38:52 +00:00
|
|
|
{
|
2016-03-08 20:29:29 +00:00
|
|
|
if (ass->track)
|
|
|
|
ass_flush_events(ass->track);
|
2012-09-28 19:38:52 +00:00
|
|
|
}
|
|
|
|
|
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-03-22 05:26:37 +00:00
|
|
|
void osd_get_function_sym(char *buffer, size_t buffer_size, int osd_function)
|
|
|
|
{
|
|
|
|
// 0xFF is never valid UTF-8, so we can use it to escape OSD symbols.
|
2016-05-03 20:29:12 +00:00
|
|
|
// (Same trick as OSD_ASS_0/OSD_ASS_1.)
|
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-03-22 05:26:37 +00:00
|
|
|
snprintf(buffer, buffer_size, "\xFF%c", osd_function);
|
|
|
|
}
|
|
|
|
|
2022-05-01 05:29:32 +00:00
|
|
|
void osd_mangle_ass(bstr *dst, const char *in, bool replace_newlines)
|
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-03-22 05:26:37 +00:00
|
|
|
{
|
2017-10-30 20:15:09 +00:00
|
|
|
const char *start = in;
|
2014-09-17 22:49:55 +00:00
|
|
|
bool escape_ass = true;
|
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-03-22 05:26:37 +00:00
|
|
|
while (*in) {
|
|
|
|
// As used by osd_get_function_sym().
|
2012-10-20 18:58:46 +00:00
|
|
|
if (in[0] == '\xFF' && in[1]) {
|
2013-12-30 21:44:25 +00:00
|
|
|
bstr_xappend(NULL, dst, bstr0(ASS_USE_OSD_FONT));
|
|
|
|
mp_append_utf8_bstr(NULL, dst, OSD_CODEPOINTS + in[1]);
|
|
|
|
bstr_xappend(NULL, dst, bstr0("{\\r}"));
|
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-03-22 05:26:37 +00:00
|
|
|
in += 2;
|
|
|
|
continue;
|
|
|
|
}
|
2016-05-03 20:29:12 +00:00
|
|
|
if (*in == OSD_ASS_0[0] || *in == OSD_ASS_1[0]) {
|
|
|
|
escape_ass = *in == OSD_ASS_1[0];
|
2014-09-17 22:49:55 +00:00
|
|
|
in += 1;
|
|
|
|
continue;
|
|
|
|
}
|
2024-09-23 00:13:17 +00:00
|
|
|
if (*in == TERM_MSG_0[0]) {
|
|
|
|
in += 1;
|
|
|
|
continue;
|
|
|
|
}
|
2014-09-17 22:49:55 +00:00
|
|
|
if (escape_ass && *in == '{')
|
2013-12-30 21:44:25 +00:00
|
|
|
bstr_xappend(NULL, dst, bstr0("\\"));
|
2022-05-01 05:29:32 +00:00
|
|
|
// Replace newlines with \N for escape-ass. This is necessary to apply
|
|
|
|
// ASS tags past newlines and to preserve consecutive newlines with
|
|
|
|
// osd-overlay because update_external() adds a ASS event per line.
|
|
|
|
if (replace_newlines && *in == '\n') {
|
|
|
|
bstr_xappend(NULL, dst, bstr0("\\N"));
|
|
|
|
in += 1;
|
|
|
|
continue;
|
|
|
|
}
|
2017-10-30 20:15:09 +00:00
|
|
|
// Libass will strip leading whitespace
|
2017-11-02 15:46:09 +00:00
|
|
|
if (in[0] == ' ' && (in == start || in[-1] == '\n')) {
|
2017-10-30 20:15:09 +00:00
|
|
|
bstr_xappend(NULL, dst, bstr0("\\h"));
|
|
|
|
in += 1;
|
|
|
|
continue;
|
|
|
|
}
|
2013-12-30 21:44:25 +00:00
|
|
|
bstr_xappend(NULL, dst, (bstr){(char *)in, 1});
|
2012-10-13 19:09:34 +00:00
|
|
|
// Break ASS escapes with U+2060 WORD JOINER
|
2014-09-17 22:49:55 +00:00
|
|
|
if (escape_ass && *in == '\\')
|
2013-12-30 21:44:25 +00:00
|
|
|
mp_append_utf8_bstr(NULL, dst, 0x2060);
|
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-03-22 05:26:37 +00:00
|
|
|
in++;
|
|
|
|
}
|
2013-12-30 21:44:25 +00:00
|
|
|
}
|
|
|
|
|
2015-11-29 12:50:51 +00:00
|
|
|
static ASS_Event *add_osd_ass_event_escaped(ASS_Track *track, const char *style,
|
|
|
|
const char *text)
|
2013-12-30 21:44:25 +00:00
|
|
|
{
|
|
|
|
bstr buf = {0};
|
2022-05-01 05:29:32 +00:00
|
|
|
osd_mangle_ass(&buf, text, false);
|
2015-11-29 12:50:51 +00:00
|
|
|
ASS_Event *e = add_osd_ass_event(track, style, buf.start);
|
2013-12-30 21:44:25 +00:00
|
|
|
talloc_free(buf.start);
|
2015-11-28 18:24:31 +00:00
|
|
|
return e;
|
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-03-22 05:26:37 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 17:24:53 +00:00
|
|
|
static ASS_Style *prepare_osd_ass(struct osd_state *osd, struct osd_object *obj)
|
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-03-22 05:26:37 +00:00
|
|
|
{
|
2017-12-29 16:19:25 +00:00
|
|
|
struct mp_osd_render_opts *opts = osd->opts;
|
2013-05-14 12:10:27 +00:00
|
|
|
|
2017-07-16 11:33:19 +00:00
|
|
|
create_ass_track(osd, obj, &obj->ass);
|
2015-09-07 12:26:01 +00:00
|
|
|
|
2013-05-14 12:10:27 +00:00
|
|
|
struct osd_style_opts font = *opts->osd_style;
|
|
|
|
font.font_size *= opts->osd_scale;
|
|
|
|
|
2016-03-08 20:29:29 +00:00
|
|
|
double playresy = obj->ass.track->PlayResY;
|
2013-12-10 18:58:57 +00:00
|
|
|
// Compensate for libass and mp_ass_set_style scaling the font etc.
|
2024-10-12 20:59:59 +00:00
|
|
|
if (!opts->osd_scale_by_window && obj->vo_res.h)
|
2013-12-10 18:58:57 +00:00
|
|
|
playresy *= 720.0 / obj->vo_res.h;
|
|
|
|
|
2017-01-26 17:24:53 +00:00
|
|
|
ASS_Style *style = get_style(&obj->ass, "OSD");
|
|
|
|
mp_ass_set_style(style, playresy, &font);
|
|
|
|
return style;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void update_osd_text(struct osd_state *osd, struct osd_object *obj)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!obj->text[0])
|
|
|
|
return;
|
|
|
|
|
|
|
|
prepare_osd_ass(osd, obj);
|
2016-03-08 20:29:29 +00:00
|
|
|
add_osd_ass_event_escaped(obj->ass.track, "OSD", obj->text);
|
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-03-22 05:26:37 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 17:24:53 +00:00
|
|
|
void osd_get_text_size(struct osd_state *osd, int *out_screen_h, int *out_font_h)
|
|
|
|
{
|
2023-10-21 02:55:41 +00:00
|
|
|
mp_mutex_lock(&osd->lock);
|
2017-01-26 17:24:53 +00:00
|
|
|
struct osd_object *obj = osd->objs[OSDTYPE_OSD];
|
|
|
|
ASS_Style *style = prepare_osd_ass(osd, obj);
|
|
|
|
*out_screen_h = obj->ass.track->PlayResY - style->MarginV;
|
|
|
|
*out_font_h = style->FontSize;
|
2023-10-21 02:55:41 +00:00
|
|
|
mp_mutex_unlock(&osd->lock);
|
2017-01-26 17:24:53 +00:00
|
|
|
}
|
|
|
|
|
2013-03-30 19:08:56 +00:00
|
|
|
// align: -1 .. +1
|
|
|
|
// frame: size of the containing area
|
|
|
|
// obj: size of the object that should be positioned inside the area
|
|
|
|
// margin: min. distance from object to frame (as long as -1 <= align <= +1)
|
|
|
|
static float get_align(float align, float frame, float obj, float margin)
|
2013-02-14 19:43:00 +00:00
|
|
|
{
|
2013-03-30 19:08:56 +00:00
|
|
|
frame -= margin * 2;
|
|
|
|
return margin + frame / 2 - obj / 2 + (frame - obj) / 2 * align;
|
2013-02-14 19:43:00 +00:00
|
|
|
}
|
|
|
|
|
2013-03-30 19:08:56 +00:00
|
|
|
struct ass_draw {
|
|
|
|
int scale;
|
|
|
|
char *text;
|
|
|
|
};
|
2013-02-14 19:43:00 +00:00
|
|
|
|
2013-03-30 19:08:56 +00:00
|
|
|
static void ass_draw_start(struct ass_draw *d)
|
|
|
|
{
|
2019-10-31 10:24:20 +00:00
|
|
|
d->scale = MPMAX(d->scale, 1);
|
2013-03-30 19:08:56 +00:00
|
|
|
d->text = talloc_asprintf_append(d->text, "{\\p%d}", d->scale);
|
|
|
|
}
|
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-03-22 05:26:37 +00:00
|
|
|
|
2013-03-30 19:08:56 +00:00
|
|
|
static void ass_draw_stop(struct ass_draw *d)
|
|
|
|
{
|
|
|
|
d->text = talloc_strdup_append(d->text, "{\\p0}");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ass_draw_c(struct ass_draw *d, float x, float y)
|
|
|
|
{
|
|
|
|
int ix = round(x * (1 << (d->scale - 1)));
|
|
|
|
int iy = round(y * (1 << (d->scale - 1)));
|
|
|
|
d->text = talloc_asprintf_append(d->text, " %d %d", ix, iy);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ass_draw_append(struct ass_draw *d, const char *t)
|
|
|
|
{
|
|
|
|
d->text = talloc_strdup_append(d->text, t);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ass_draw_move_to(struct ass_draw *d, float x, float y)
|
|
|
|
{
|
|
|
|
ass_draw_append(d, " m");
|
|
|
|
ass_draw_c(d, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ass_draw_line_to(struct ass_draw *d, float x, float y)
|
|
|
|
{
|
|
|
|
ass_draw_append(d, " l");
|
|
|
|
ass_draw_c(d, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ass_draw_rect_ccw(struct ass_draw *d, float x0, float y0,
|
|
|
|
float x1, float y1)
|
|
|
|
{
|
|
|
|
ass_draw_move_to(d, x0, y0);
|
|
|
|
ass_draw_line_to(d, x0, y1);
|
|
|
|
ass_draw_line_to(d, x1, y1);
|
|
|
|
ass_draw_line_to(d, x1, y0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ass_draw_rect_cw(struct ass_draw *d, float x0, float y0,
|
|
|
|
float x1, float y1)
|
|
|
|
{
|
|
|
|
ass_draw_move_to(d, x0, y0);
|
|
|
|
ass_draw_line_to(d, x1, y0);
|
|
|
|
ass_draw_line_to(d, x1, y1);
|
|
|
|
ass_draw_line_to(d, x0, y1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ass_draw_reset(struct ass_draw *d)
|
|
|
|
{
|
|
|
|
talloc_free(d->text);
|
|
|
|
d->text = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void get_osd_bar_box(struct osd_state *osd, struct osd_object *obj,
|
|
|
|
float *o_x, float *o_y, float *o_w, float *o_h,
|
|
|
|
float *o_border)
|
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-03-22 05:26:37 +00:00
|
|
|
{
|
2017-12-29 16:19:25 +00:00
|
|
|
struct mp_osd_render_opts *opts = osd->opts;
|
2013-02-14 19:43:00 +00:00
|
|
|
|
2017-07-16 11:33:19 +00:00
|
|
|
create_ass_track(osd, obj, &obj->ass);
|
2016-03-08 20:29:29 +00:00
|
|
|
ASS_Track *track = obj->ass.track;
|
2015-11-29 12:50:51 +00:00
|
|
|
|
2016-03-08 20:29:29 +00:00
|
|
|
ASS_Style *style = get_style(&obj->ass, "progbar");
|
2015-11-29 12:50:51 +00:00
|
|
|
if (!style) {
|
|
|
|
*o_x = *o_y = *o_w = *o_h = *o_border = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mp_ass_set_style(style, track->PlayResY, opts->osd_style);
|
2013-03-30 19:08:56 +00:00
|
|
|
|
2024-05-21 03:15:23 +00:00
|
|
|
// override the default osd opaque-box into plain outline. Otherwise
|
|
|
|
// the opaque box is not aligned with the bar (even without shadow),
|
|
|
|
// and each bar ass event gets its own opaque box - breaking the bar.
|
|
|
|
style->BorderStyle = 1; // outline
|
2021-08-18 13:20:34 +00:00
|
|
|
|
2013-03-30 19:08:56 +00:00
|
|
|
*o_w = track->PlayResX * (opts->osd_bar_w / 100.0);
|
|
|
|
*o_h = track->PlayResY * (opts->osd_bar_h / 100.0);
|
|
|
|
|
2024-05-21 03:15:23 +00:00
|
|
|
style->Outline = opts->osd_bar_outline_size;
|
2015-02-24 13:36:14 +00:00
|
|
|
// Rendering with shadow is broken (because there's more than one shape)
|
|
|
|
style->Shadow = 0;
|
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-03-22 05:26:37 +00:00
|
|
|
|
2015-02-24 13:40:06 +00:00
|
|
|
style->Alignment = 5;
|
|
|
|
|
2013-03-30 19:08:56 +00:00
|
|
|
*o_border = style->Outline;
|
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-03-22 05:26:37 +00:00
|
|
|
|
2013-03-30 19:08:56 +00:00
|
|
|
*o_x = get_align(opts->osd_bar_align_x, track->PlayResX, *o_w, *o_border);
|
|
|
|
*o_y = get_align(opts->osd_bar_align_y, track->PlayResY, *o_h, *o_border);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void update_progbar(struct osd_state *osd, struct osd_object *obj)
|
|
|
|
{
|
2014-01-18 00:19:20 +00:00
|
|
|
if (obj->progbar_state.type < 0)
|
2013-03-30 19:08:56 +00:00
|
|
|
return;
|
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-03-22 05:26:37 +00:00
|
|
|
|
2015-09-07 12:26:01 +00:00
|
|
|
float px, py, width, height, border;
|
|
|
|
get_osd_bar_box(osd, obj, &px, &py, &width, &height, &border);
|
|
|
|
|
2016-03-08 20:29:29 +00:00
|
|
|
ASS_Track *track = obj->ass.track;
|
|
|
|
|
2013-03-30 19:08:56 +00:00
|
|
|
float sx = px - border * 2 - height / 4; // includes additional spacing
|
|
|
|
float sy = py + height / 2;
|
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-03-22 05:26:37 +00:00
|
|
|
|
2013-12-30 21:44:25 +00:00
|
|
|
bstr buf = bstr0(talloc_asprintf(NULL, "{\\an6\\pos(%f,%f)}", sx, sy));
|
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-03-22 05:26:37 +00:00
|
|
|
|
2014-01-18 00:19:20 +00:00
|
|
|
if (obj->progbar_state.type == 0 || obj->progbar_state.type >= 256) {
|
2013-02-16 19:50:05 +00:00
|
|
|
// no sym
|
2014-01-18 00:19:20 +00:00
|
|
|
} else if (obj->progbar_state.type >= 32) {
|
|
|
|
mp_append_utf8_bstr(NULL, &buf, obj->progbar_state.type);
|
2013-02-16 19:50:05 +00:00
|
|
|
} else {
|
2013-12-30 21:44:25 +00:00
|
|
|
bstr_xappend(NULL, &buf, bstr0(ASS_USE_OSD_FONT));
|
2014-01-18 00:19:20 +00:00
|
|
|
mp_append_utf8_bstr(NULL, &buf, OSD_CODEPOINTS + obj->progbar_state.type);
|
2013-12-30 21:44:25 +00:00
|
|
|
bstr_xappend(NULL, &buf, bstr0("{\\r}"));
|
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-03-22 05:26:37 +00:00
|
|
|
}
|
|
|
|
|
2016-03-08 20:29:29 +00:00
|
|
|
add_osd_ass_event(track, "progbar", buf.start);
|
2013-12-30 21:44:25 +00:00
|
|
|
talloc_free(buf.start);
|
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-03-22 05:26:37 +00:00
|
|
|
|
2013-03-30 19:08:56 +00:00
|
|
|
struct ass_draw *d = &(struct ass_draw) { .scale = 4 };
|
2021-08-18 13:51:05 +00:00
|
|
|
|
2024-05-21 03:15:23 +00:00
|
|
|
if (osd->opts->osd_style->back_color.a && osd->opts->osd_style->border_style != 1) {
|
2021-08-18 13:51:05 +00:00
|
|
|
// the bar style always ignores the --osd-back-color config - it messes
|
|
|
|
// up the bar. draw an artificial box at the original back color.
|
|
|
|
struct m_color bc = osd->opts->osd_style->back_color;
|
|
|
|
d->text = talloc_asprintf_append(d->text,
|
|
|
|
"{\\pos(%f,%f)\\bord0\\1a&H%02X\\1c&H%02X%02X%02X&}",
|
|
|
|
px, py, 255 - bc.a, (int)bc.b, (int)bc.g, (int)bc.r);
|
|
|
|
|
|
|
|
ass_draw_start(d);
|
|
|
|
ass_draw_rect_cw(d, -border, -border, width + border, height + border);
|
|
|
|
ass_draw_stop(d);
|
|
|
|
add_osd_ass_event(track, "progbar", d->text);
|
|
|
|
ass_draw_reset(d);
|
|
|
|
}
|
|
|
|
|
2013-03-30 19:08:56 +00:00
|
|
|
// filled area
|
2013-03-31 19:12:53 +00:00
|
|
|
d->text = talloc_asprintf_append(d->text, "{\\bord0\\pos(%f,%f)}", px, py);
|
2013-03-30 19:08:56 +00:00
|
|
|
ass_draw_start(d);
|
2014-01-18 00:19:20 +00:00
|
|
|
float pos = obj->progbar_state.value * width - border / 2;
|
2013-03-30 19:08:56 +00:00
|
|
|
ass_draw_rect_cw(d, 0, 0, pos, height);
|
|
|
|
ass_draw_stop(d);
|
2016-03-08 20:29:29 +00:00
|
|
|
add_osd_ass_event(track, "progbar", d->text);
|
2013-03-30 19:08:56 +00:00
|
|
|
ass_draw_reset(d);
|
|
|
|
|
2013-04-01 23:53:33 +00:00
|
|
|
// position marker
|
|
|
|
d->text = talloc_asprintf_append(d->text, "{\\bord%f\\pos(%f,%f)}",
|
|
|
|
border / 2, px, py);
|
|
|
|
ass_draw_start(d);
|
|
|
|
ass_draw_move_to(d, pos + border / 2, 0);
|
|
|
|
ass_draw_line_to(d, pos + border / 2, height);
|
|
|
|
ass_draw_stop(d);
|
2016-03-08 20:29:29 +00:00
|
|
|
add_osd_ass_event(track, "progbar", d->text);
|
2013-04-01 23:53:33 +00:00
|
|
|
ass_draw_reset(d);
|
|
|
|
|
2013-03-30 19:08:56 +00:00
|
|
|
d->text = talloc_asprintf_append(d->text, "{\\pos(%f,%f)}", px, py);
|
|
|
|
ass_draw_start(d);
|
|
|
|
|
|
|
|
// the box
|
|
|
|
ass_draw_rect_cw(d, -border, -border, width + border, height + border);
|
|
|
|
|
|
|
|
// the "hole"
|
|
|
|
ass_draw_rect_ccw(d, 0, 0, width, height);
|
|
|
|
|
|
|
|
// chapter marks
|
2024-10-26 14:30:31 +00:00
|
|
|
if (osd->opts->osd_bar_marker_style) {
|
|
|
|
for (int n = 0; n < obj->progbar_state.num_stops; n++) {
|
|
|
|
float s = obj->progbar_state.stops[n] * width;
|
|
|
|
float size = MPMAX(border * osd->opts->osd_bar_marker_scale,
|
|
|
|
osd->opts->osd_bar_marker_min_size);
|
|
|
|
|
|
|
|
if (osd->opts->osd_bar_marker_style == 2 &&
|
|
|
|
s > size / 2 && s < width - size / 2)
|
|
|
|
{ // line
|
|
|
|
ass_draw_rect_cw(d, s - size / 2, 0, s + size / 2, height);
|
|
|
|
} else if (s > size && s < width - size) { //triangle
|
|
|
|
ass_draw_move_to(d, s + size, 0);
|
|
|
|
ass_draw_line_to(d, s, size);
|
|
|
|
ass_draw_line_to(d, s - size, 0);
|
|
|
|
|
|
|
|
ass_draw_move_to(d, s - size, height);
|
|
|
|
ass_draw_line_to(d, s, height - size);
|
|
|
|
ass_draw_line_to(d, s + size, height);
|
|
|
|
}
|
2013-03-30 19:08:56 +00:00
|
|
|
}
|
|
|
|
}
|
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-03-22 05:26:37 +00:00
|
|
|
|
2013-03-30 19:08:56 +00:00
|
|
|
ass_draw_stop(d);
|
2016-03-08 20:29:29 +00:00
|
|
|
add_osd_ass_event(track, "progbar", d->text);
|
2013-03-30 19:08:56 +00:00
|
|
|
ass_draw_reset(d);
|
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-03-22 05:26:37 +00:00
|
|
|
}
|
|
|
|
|
2015-11-28 18:24:31 +00:00
|
|
|
static void update_osd(struct osd_state *osd, struct osd_object *obj)
|
|
|
|
{
|
2016-09-16 15:17:32 +00:00
|
|
|
obj->osd_changed = false;
|
2016-03-08 20:29:29 +00:00
|
|
|
clear_ass(&obj->ass);
|
2015-11-28 18:24:31 +00:00
|
|
|
update_osd_text(osd, obj);
|
|
|
|
update_progbar(osd, obj);
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:42:08 +00:00
|
|
|
static void update_external(struct osd_state *osd, struct osd_object *obj,
|
|
|
|
struct osd_external *ext)
|
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-25 22:41:14 +00:00
|
|
|
{
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
bstr t = bstr0(ext->ov.data);
|
|
|
|
ext->ass.res_x = ext->ov.res_x;
|
|
|
|
ext->ass.res_y = ext->ov.res_y;
|
2017-07-16 11:33:19 +00:00
|
|
|
create_ass_track(osd, obj, &ext->ass);
|
2015-11-29 12:50:51 +00:00
|
|
|
|
2016-03-08 20:42:08 +00:00
|
|
|
clear_ass(&ext->ass);
|
2016-03-08 20:29:29 +00:00
|
|
|
|
2016-03-08 20:42:08 +00:00
|
|
|
int resy = ext->ass.track->PlayResY;
|
|
|
|
mp_ass_set_style(get_style(&ext->ass, "OSD"), resy, osd->opts->osd_style);
|
2015-11-29 12:50:51 +00:00
|
|
|
|
|
|
|
// Some scripts will reference this style name with \r tags.
|
|
|
|
const struct osd_style_opts *def = osd_style_conf.defaults;
|
2016-03-08 20:42:08 +00:00
|
|
|
mp_ass_set_style(get_style(&ext->ass, "Default"), resy, def);
|
2015-09-07 12:26:01 +00:00
|
|
|
|
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-25 22:41:14 +00:00
|
|
|
while (t.len) {
|
|
|
|
bstr line;
|
|
|
|
bstr_split_tok(t, "\n", &line, &t);
|
|
|
|
if (line.len) {
|
|
|
|
char *tmp = bstrdup0(NULL, line);
|
2016-03-08 20:42:08 +00:00
|
|
|
add_osd_ass_event(ext->ass.track, "OSD", tmp);
|
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-25 22:41:14 +00:00
|
|
|
talloc_free(tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
static int cmp_zorder(const void *pa, const void *pb)
|
|
|
|
{
|
|
|
|
const struct osd_external *a = *(struct osd_external **)pa;
|
|
|
|
const struct osd_external *b = *(struct osd_external **)pb;
|
|
|
|
return a->ov.z == b->ov.z ? 0 : (a->ov.z > b->ov.z ? 1 : -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void osd_set_external(struct osd_state *osd, struct osd_external_ass *ov)
|
2012-09-28 19:38:52 +00:00
|
|
|
{
|
2023-10-21 02:55:41 +00:00
|
|
|
mp_mutex_lock(&osd->lock);
|
2016-03-08 20:42:08 +00:00
|
|
|
struct osd_object *obj = osd->objs[OSDTYPE_EXTERNAL];
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
bool zorder_changed = false;
|
|
|
|
int index = -1;
|
|
|
|
|
2016-03-08 20:42:08 +00:00
|
|
|
for (int n = 0; n < obj->num_externals; n++) {
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
struct osd_external *e = obj->externals[n];
|
|
|
|
if (e->ov.id == ov->id && e->ov.owner == ov->owner) {
|
|
|
|
index = n;
|
2016-03-08 20:42:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
if (index < 0) {
|
|
|
|
if (!ov->format)
|
|
|
|
goto done;
|
|
|
|
struct osd_external *new = talloc_zero(NULL, struct osd_external);
|
|
|
|
new->ov.owner = ov->owner;
|
|
|
|
new->ov.id = ov->id;
|
2016-03-08 20:42:08 +00:00
|
|
|
MP_TARRAY_APPEND(obj, obj->externals, obj->num_externals, new);
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
index = obj->num_externals - 1;
|
|
|
|
zorder_changed = true;
|
2016-03-08 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
struct osd_external *entry = obj->externals[index];
|
|
|
|
|
|
|
|
if (!ov->format) {
|
2020-03-06 17:20:11 +00:00
|
|
|
if (!entry->ov.hidden) {
|
|
|
|
obj->changed = true;
|
|
|
|
osd->want_redraw_notification = true;
|
|
|
|
}
|
2016-03-08 20:42:08 +00:00
|
|
|
destroy_external(entry);
|
|
|
|
MP_TARRAY_REMOVE_AT(obj->externals, obj->num_externals, index);
|
|
|
|
goto done;
|
2012-09-28 19:38:52 +00:00
|
|
|
}
|
2016-03-08 20:42:08 +00:00
|
|
|
|
2023-02-07 18:06:22 +00:00
|
|
|
if (!entry->ov.hidden || !ov->hidden) {
|
|
|
|
obj->changed = true;
|
|
|
|
osd->want_redraw_notification = true;
|
|
|
|
}
|
|
|
|
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
entry->ov.format = ov->format;
|
|
|
|
if (!entry->ov.data)
|
|
|
|
entry->ov.data = talloc_strdup(entry, "");
|
|
|
|
entry->ov.data[0] = '\0'; // reuse memory allocation
|
|
|
|
entry->ov.data = talloc_strdup_append(entry->ov.data, ov->data);
|
|
|
|
entry->ov.res_x = ov->res_x;
|
|
|
|
entry->ov.res_y = ov->res_y;
|
|
|
|
zorder_changed |= entry->ov.z != ov->z;
|
|
|
|
entry->ov.z = ov->z;
|
2020-03-06 17:20:11 +00:00
|
|
|
entry->ov.hidden = ov->hidden;
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
|
|
|
|
update_external(osd, obj, entry);
|
|
|
|
|
|
|
|
if (zorder_changed) {
|
|
|
|
qsort(obj->externals, obj->num_externals, sizeof(obj->externals[0]),
|
|
|
|
cmp_zorder);
|
2016-03-08 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
2020-03-06 17:20:11 +00:00
|
|
|
if (ov->out_rc) {
|
|
|
|
struct mp_osd_res vo_res = entry->ass.vo_res;
|
|
|
|
// Defined fallback if VO has not drawn this yet
|
|
|
|
if (vo_res.w < 1 || vo_res.h < 1) {
|
|
|
|
vo_res = (struct mp_osd_res){
|
|
|
|
.w = entry->ov.res_x,
|
|
|
|
.h = entry->ov.res_y,
|
|
|
|
.display_par = 1,
|
|
|
|
};
|
|
|
|
// According to osd-overlay command description.
|
|
|
|
if (vo_res.w < 1)
|
|
|
|
vo_res.w = 1280;
|
|
|
|
if (vo_res.h < 1)
|
|
|
|
vo_res.h = 720;
|
|
|
|
}
|
|
|
|
|
|
|
|
ASS_Image *img_list = NULL;
|
|
|
|
append_ass(&entry->ass, &vo_res, &img_list, NULL);
|
|
|
|
|
|
|
|
mp_ass_get_bb(img_list, entry->ass.track, &vo_res, ov->out_rc);
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:42:08 +00:00
|
|
|
done:
|
2023-10-21 02:55:41 +00:00
|
|
|
mp_mutex_unlock(&osd->lock);
|
2012-09-28 19:38:52 +00:00
|
|
|
}
|
|
|
|
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
void osd_set_external_remove_owner(struct osd_state *osd, void *owner)
|
|
|
|
{
|
2023-10-21 02:55:41 +00:00
|
|
|
mp_mutex_lock(&osd->lock);
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
struct osd_object *obj = osd->objs[OSDTYPE_EXTERNAL];
|
|
|
|
for (int n = obj->num_externals - 1; n >= 0; n--) {
|
|
|
|
struct osd_external *e = obj->externals[n];
|
|
|
|
if (e->ov.owner == owner) {
|
|
|
|
destroy_external(e);
|
|
|
|
MP_TARRAY_REMOVE_AT(obj->externals, obj->num_externals, n);
|
|
|
|
obj->changed = true;
|
|
|
|
osd->want_redraw_notification = true;
|
|
|
|
}
|
|
|
|
}
|
2023-10-21 02:55:41 +00:00
|
|
|
mp_mutex_unlock(&osd->lock);
|
client API, lua: add new API for setting OSD overlays
Lua scripting has an undocumented mp.set_osd_ass() function, which is
used by osc.lua and console.lua. Apparently, 3rd party scripts also use
this. It's probably time to make this a public API.
The Lua implementation just bypassed the libmpv API. To make it usable
by any type of client, turn it into a command, "osd-overlay".
There's already a "overlay-add". Ignore it (although the manpage admits
guiltiness). I don't really want to deal with that old command. Its main
problem is that it uses global IDs, while I'd like to avoid that scripts
mess with each others overlays (whether that is accidentally or
intentionally). Maybe "overlay-add" can eventually be merged into
"osd-overlay", but I'm too lazy to do that now.
Scripting now uses the commands. There is a helper to manage OSD
overlays. The helper is very "thin"; I only want to force script authors
to use the ID allocation, which may help with putting multiple scripts
into a single .lua file without causing conflicts (basically, avoiding
singletons within a script's environment). The old set_osd_ass() is
emulated with the new API.
The JS scripting wrapper also provides a set_osd_ass() function, which
calls internal mpv API. Comment that part (to keep it compiling), but
I'm leaving it to @avih to finish the change.
2019-12-23 10:40:27 +00:00
|
|
|
}
|
|
|
|
|
2016-03-08 20:29:29 +00:00
|
|
|
static void append_ass(struct ass_state *ass, struct mp_osd_res *res,
|
2016-06-30 19:38:50 +00:00
|
|
|
ASS_Image **img_list, bool *changed)
|
2016-03-08 20:29:29 +00:00
|
|
|
{
|
2016-06-30 19:38:50 +00:00
|
|
|
if (!ass->render || !ass->track) {
|
|
|
|
*img_list = NULL;
|
2016-03-08 20:29:29 +00:00
|
|
|
return;
|
2016-06-30 19:38:50 +00:00
|
|
|
}
|
2016-03-08 20:29:29 +00:00
|
|
|
|
2017-07-16 11:33:19 +00:00
|
|
|
update_playres(ass, res);
|
|
|
|
|
2016-03-08 20:29:29 +00:00
|
|
|
ass_set_frame_size(ass->render, res->w, res->h);
|
2020-08-28 13:55:20 +00:00
|
|
|
ass_set_pixel_aspect(ass->render, res->display_par);
|
2016-06-30 19:38:50 +00:00
|
|
|
|
|
|
|
int ass_changed;
|
|
|
|
*img_list = ass_render_frame(ass->render, ass->track, 0, &ass_changed);
|
2020-03-06 17:20:11 +00:00
|
|
|
|
|
|
|
ass->changed |= ass_changed;
|
|
|
|
|
|
|
|
if (changed) {
|
|
|
|
*changed |= ass->changed;
|
|
|
|
ass->changed = false;
|
|
|
|
}
|
2016-03-08 20:29:29 +00:00
|
|
|
}
|
|
|
|
|
video: make OSD/subtitle bitmaps refcounted (sort of)
Making OSD/subtitle bitmaps refcounted was planend a longer time ago,
e.g. the sub_bitmaps.packed field (which refcounts the subtitle bitmap
data) was added in 2016. But nothing benefited much from it, because
struct sub_bitmaps was usually stack allocated, and there was this weird
callback stuff through osd_draw().
Make it possible to get actually refcounted subtitle bitmaps on the OSD
API level. For this, we just copy all subtitle data other than the
bitmaps with sub_bitmaps_copy(). At first, I had planned some fancy
refcount shit, but when that was a big mess and hard to debug and just
boiled to emulating malloc(), I made it a full allocation+copy. This
affects mostly the parts array. With crazy ASS subtitles, this parts
array can get pretty big (thousands of elements or more), in which case
the extra alloc/copy could become performance relevant. But then again
this is just pure bullshit, and I see no need to care. In practice, this
extra work most likely gets drowned out by libass murdering a single
core (while mpv is waiting for it) anyway. So fuck it.
I just wanted this so draw_bmp.c requires only a single call to render
everything. VOs also can benefit from this, because the weird callback
shit isn't necessary anymore (simpler code), but I haven't done anything
about it yet. In general I'd hope this will work towards simplifying the
OSD layer, which is prerequisite for making actual further improvements.
I haven't tested some cases such as the "overlay-add" command. Maybe it
crashes now? Who knows, who cares.
In addition, it might be worthwhile to reduce the code duplication
between all the things that output subtitle bitmaps (with repacking,
image allocation, etc.), but that's orthogonal.
2020-04-26 21:34:32 +00:00
|
|
|
struct sub_bitmaps *osd_object_get_bitmaps(struct osd_state *osd,
|
|
|
|
struct osd_object *obj, int format)
|
2012-09-28 19:38:52 +00:00
|
|
|
{
|
2016-09-16 15:17:32 +00:00
|
|
|
if (obj->type == OSDTYPE_OSD && obj->osd_changed)
|
2016-03-08 20:42:08 +00:00
|
|
|
update_osd(osd, obj);
|
2012-09-28 19:38:52 +00:00
|
|
|
|
2016-06-30 19:38:50 +00:00
|
|
|
if (!obj->ass_packer)
|
|
|
|
obj->ass_packer = mp_ass_packer_alloc(obj);
|
|
|
|
|
|
|
|
MP_TARRAY_GROW(obj, obj->ass_imgs, obj->num_externals + 1);
|
|
|
|
|
|
|
|
append_ass(&obj->ass, &obj->vo_res, &obj->ass_imgs[0], &obj->changed);
|
|
|
|
for (int n = 0; n < obj->num_externals; n++) {
|
2020-03-06 17:20:11 +00:00
|
|
|
if (obj->externals[n]->ov.hidden) {
|
|
|
|
update_playres(&obj->externals[n]->ass, &obj->vo_res);
|
|
|
|
obj->ass_imgs[n + 1] = NULL;
|
|
|
|
} else {
|
|
|
|
append_ass(&obj->externals[n]->ass, &obj->vo_res,
|
|
|
|
&obj->ass_imgs[n + 1], &obj->changed);
|
|
|
|
}
|
2016-06-30 19:38:50 +00:00
|
|
|
}
|
2016-03-08 20:29:29 +00:00
|
|
|
|
video: make OSD/subtitle bitmaps refcounted (sort of)
Making OSD/subtitle bitmaps refcounted was planend a longer time ago,
e.g. the sub_bitmaps.packed field (which refcounts the subtitle bitmap
data) was added in 2016. But nothing benefited much from it, because
struct sub_bitmaps was usually stack allocated, and there was this weird
callback stuff through osd_draw().
Make it possible to get actually refcounted subtitle bitmaps on the OSD
API level. For this, we just copy all subtitle data other than the
bitmaps with sub_bitmaps_copy(). At first, I had planned some fancy
refcount shit, but when that was a big mess and hard to debug and just
boiled to emulating malloc(), I made it a full allocation+copy. This
affects mostly the parts array. With crazy ASS subtitles, this parts
array can get pretty big (thousands of elements or more), in which case
the extra alloc/copy could become performance relevant. But then again
this is just pure bullshit, and I see no need to care. In practice, this
extra work most likely gets drowned out by libass murdering a single
core (while mpv is waiting for it) anyway. So fuck it.
I just wanted this so draw_bmp.c requires only a single call to render
everything. VOs also can benefit from this, because the weird callback
shit isn't necessary anymore (simpler code), but I haven't done anything
about it yet. In general I'd hope this will work towards simplifying the
OSD layer, which is prerequisite for making actual further improvements.
I haven't tested some cases such as the "overlay-add" command. Maybe it
crashes now? Who knows, who cares.
In addition, it might be worthwhile to reduce the code duplication
between all the things that output subtitle bitmaps (with repacking,
image allocation, etc.), but that's orthogonal.
2020-04-26 21:34:32 +00:00
|
|
|
struct sub_bitmaps out_imgs = {0};
|
2016-06-30 19:38:50 +00:00
|
|
|
mp_ass_packer_pack(obj->ass_packer, obj->ass_imgs, obj->num_externals + 1,
|
2024-02-27 01:12:46 +00:00
|
|
|
obj->changed, false, format, &out_imgs);
|
2012-09-28 19:38:52 +00:00
|
|
|
|
2016-06-30 19:38:50 +00:00
|
|
|
obj->changed = false;
|
video: make OSD/subtitle bitmaps refcounted (sort of)
Making OSD/subtitle bitmaps refcounted was planend a longer time ago,
e.g. the sub_bitmaps.packed field (which refcounts the subtitle bitmap
data) was added in 2016. But nothing benefited much from it, because
struct sub_bitmaps was usually stack allocated, and there was this weird
callback stuff through osd_draw().
Make it possible to get actually refcounted subtitle bitmaps on the OSD
API level. For this, we just copy all subtitle data other than the
bitmaps with sub_bitmaps_copy(). At first, I had planned some fancy
refcount shit, but when that was a big mess and hard to debug and just
boiled to emulating malloc(), I made it a full allocation+copy. This
affects mostly the parts array. With crazy ASS subtitles, this parts
array can get pretty big (thousands of elements or more), in which case
the extra alloc/copy could become performance relevant. But then again
this is just pure bullshit, and I see no need to care. In practice, this
extra work most likely gets drowned out by libass murdering a single
core (while mpv is waiting for it) anyway. So fuck it.
I just wanted this so draw_bmp.c requires only a single call to render
everything. VOs also can benefit from this, because the weird callback
shit isn't necessary anymore (simpler code), but I haven't done anything
about it yet. In general I'd hope this will work towards simplifying the
OSD layer, which is prerequisite for making actual further improvements.
I haven't tested some cases such as the "overlay-add" command. Maybe it
crashes now? Who knows, who cares.
In addition, it might be worthwhile to reduce the code duplication
between all the things that output subtitle bitmaps (with repacking,
image allocation, etc.), but that's orthogonal.
2020-04-26 21:34:32 +00:00
|
|
|
|
|
|
|
return sub_bitmaps_copy(&obj->copy_cache, &out_imgs);
|
2012-09-28 19:38:52 +00:00
|
|
|
}
|