lavc/libaribcaption: add MSZ character related options

This patch adds two MSZ (Middle Size; half width) character
related options, mapping against newly added upstream
functionality:

* `replace_msz_japanese`, which was introduced in version 1.0.1
  of libaribcaption.
* `replace_msz_glyph`, which was introduced in version 1.1.0
  of libaribcaption.

The latter option improves bitmap type rendering if specified
fonts contain half-width glyphs (e.g., BIZ UDGothic), even
if both ASCII and Japanese MSZ replacement options are set
to false.

As these options require newer versions of libaribcaption, the
configure requirement has been bumped accordingly.

Signed-off-by: TADANO Tokumei <aimingoff@pc.nifty.jp>
(cherry picked from commit 21bfadd9b4)
pull/390/head
TADANO Tokumei 1 year ago committed by Jan Ekström
parent 48afb43549
commit 8ccd1593a4
  1. 2
      configure
  2. 16
      doc/decoders.texi
  3. 10
      libavcodec/libaribcaption.c
  4. 2
      libavcodec/version.h

2
configure vendored

@ -6677,7 +6677,7 @@ enabled libaom && require_pkg_config libaom "aom >= 1.0.0" aom/aom_co
enabled libaribb24 && { check_pkg_config libaribb24 "aribb24 > 1.0.3" "aribb24/aribb24.h" arib_instance_new || enabled libaribb24 && { check_pkg_config libaribb24 "aribb24 > 1.0.3" "aribb24/aribb24.h" arib_instance_new ||
{ enabled gpl && require_pkg_config libaribb24 aribb24 "aribb24/aribb24.h" arib_instance_new; } || { enabled gpl && require_pkg_config libaribb24 aribb24 "aribb24/aribb24.h" arib_instance_new; } ||
die "ERROR: libaribb24 requires version higher than 1.0.3 or --enable-gpl."; } die "ERROR: libaribb24 requires version higher than 1.0.3 or --enable-gpl."; }
enabled libaribcaption && require_pkg_config libaribcaption "libaribcaption >= 0.1.0" "aribcaption/aribcaption.h" aribcc_context_alloc enabled libaribcaption && require_pkg_config libaribcaption "libaribcaption >= 1.1.1" "aribcaption/aribcaption.h" aribcc_context_alloc
enabled lv2 && require_pkg_config lv2 lilv-0 "lilv/lilv.h" lilv_world_new enabled lv2 && require_pkg_config lv2 lilv-0 "lilv/lilv.h" lilv_world_new
enabled libiec61883 && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883 enabled libiec61883 && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883
enabled libass && require_pkg_config libass "libass >= 0.11.0" ass/ass.h ass_library_init enabled libass && require_pkg_config libass "libass >= 0.11.0" ass/ass.h ass_library_init

@ -459,6 +459,22 @@ Specify whether to render replaced DRCS characters as Unicode characters.
The default is @var{true}. The default is @var{true}.
@item -replace_msz_japanese @var{boolean}
Specify whether to replace some MSZ (Middle Size; half width) fullwidth
japanese special characters with halfwidth ones.
The default is @var{true}.
@item -replace_msz_glyph @var{boolean}
Specify whether to replace MSZ (Middle Size; half width) characters
with halfwidth glyphs if the fonts supports it.
This option works under FreeType or DirectWrite renderer
with Adobe-Japan1 compliant fonts.
e.g., IBM Plex Sans JP, Morisawa BIZ UDGothic, Morisawa BIZ UDMincho,
Yu Gothic, Yu Mincho, and Meiryo.
The default is @var{true}.
@item -canvas_size @var{image_size} @item -canvas_size @var{image_size}
Specify the resolution of the canvas to render subtitles to; usually, this Specify the resolution of the canvas to render subtitles to; usually, this
should be frame size of input video. should be frame size of input video.

@ -76,6 +76,8 @@ typedef struct ARIBCaptionContext {
int ignore_ruby; int ignore_ruby;
float stroke_width; float stroke_width;
int replace_drcs; int replace_drcs;
int replace_msz_japanese;
int replace_msz_glyph;
int64_t pts; int64_t pts;
AVRational time_base; AVRational time_base;
@ -1005,6 +1007,8 @@ static int aribcaption_init(AVCodecContext *avctx)
} }
aribcc_decoder_set_replace_msz_fullwidth_ascii(ctx->decoder, aribcc_decoder_set_replace_msz_fullwidth_ascii(ctx->decoder,
ctx->replace_fullwidth_ascii); ctx->replace_fullwidth_ascii);
aribcc_decoder_set_replace_msz_fullwidth_japanese(ctx->decoder,
ctx->replace_msz_japanese);
/* Similar behavior as ffmpeg tool to set canvas size */ /* Similar behavior as ffmpeg tool to set canvas size */
if (ctx->canvas_width > 0 && ctx->canvas_height > 0 && if (ctx->canvas_width > 0 && ctx->canvas_height > 0 &&
@ -1057,6 +1061,8 @@ static int aribcaption_init(AVCodecContext *avctx)
aribcc_renderer_set_force_no_background(ctx->renderer, ctx->ignore_background); aribcc_renderer_set_force_no_background(ctx->renderer, ctx->ignore_background);
aribcc_renderer_set_force_no_ruby(ctx->renderer, ctx->ignore_ruby); aribcc_renderer_set_force_no_ruby(ctx->renderer, ctx->ignore_ruby);
aribcc_renderer_set_stroke_width(ctx->renderer, ctx->stroke_width); aribcc_renderer_set_stroke_width(ctx->renderer, ctx->stroke_width);
aribcc_renderer_set_replace_msz_halfwidth_glyph(ctx->renderer,
ctx->replace_msz_glyph);
if (ctx->font) { if (ctx->font) {
int is_nomem = 0; int is_nomem = 0;
size_t count = 0; size_t count = 0;
@ -1144,6 +1150,10 @@ static const AVOption options[] = {
OFFSET(stroke_width), AV_OPT_TYPE_FLOAT, { .dbl = 1.5 }, 0.0, 3.0, SD }, OFFSET(stroke_width), AV_OPT_TYPE_FLOAT, { .dbl = 1.5 }, 0.0, 3.0, SD },
{ "replace_drcs", "replace known DRCS [bitmap]", { "replace_drcs", "replace known DRCS [bitmap]",
OFFSET(replace_drcs), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, SD }, OFFSET(replace_drcs), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, SD },
{ "replace_msz_japanese", "replace MSZ fullwidth Japanese with halfwidth [ass, bitmap]",
OFFSET(replace_msz_japanese), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, SD },
{ "replace_msz_glyph", "replace MSZ characters with halfwidth glyphs [bitmap]",
OFFSET(replace_msz_glyph), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, SD },
{"canvas_size", "set input video size (WxH or abbreviation) [bitmap]", {"canvas_size", "set input video size (WxH or abbreviation) [bitmap]",
OFFSET(canvas_width), AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, INT_MAX, SD }, OFFSET(canvas_width), AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, INT_MAX, SD },
{ NULL } { NULL }

@ -30,7 +30,7 @@
#include "version_major.h" #include "version_major.h"
#define LIBAVCODEC_VERSION_MINOR 31 #define LIBAVCODEC_VERSION_MINOR 31
#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \ LIBAVCODEC_VERSION_MINOR, \

Loading…
Cancel
Save