From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id D3EEA47811 for ; Sat, 23 Sep 2023 02:15:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 952A168C964; Sat, 23 Sep 2023 05:15:50 +0300 (EEST) Received: from dmta0018.nifty.com (mta-snd00003.nifty.com [106.153.226.35]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0BA3968C5BF for ; Sat, 23 Sep 2023 05:15:41 +0300 (EEST) Received: from [192.168.0.9] by dmta0018.nifty.com with ESMTP id <20230923021538219.OHIT.73653.[192.168.0.9]@nifty.com> for ; Sat, 23 Sep 2023 11:15:38 +0900 Message-ID: <20b82004-7fa3-2587-c413-d5437b571e60@pc.nifty.jp> Date: Sat, 23 Sep 2023 11:15:34 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 From: TADANO Tokumei To: ffmpeg-devel@ffmpeg.org References: <20230923020023.9288-1-aimingoff@pc.nifty.jp> Content-Language: en-US In-Reply-To: <20230923020023.9288-1-aimingoff@pc.nifty.jp> Subject: Re: [FFmpeg-devel] [PATCH v2] lavc/libaribcaption.c: add MSZ characters related options X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This is updated patch to "[PATCH] lavc/libaribcaption.c: add -replace_fullwidth_japanese option" (Message-Id: <20230908130050.85688-1-aimingoff@pc.nifty.jp>). If specified fonts contain half-width glyphs, it make better rendering with `-replace_msz_ascii false -replace_msz_japanese false` option for bitmap sub_type. This patch also fix a bug in libaribcaption.c. I prefer to apply this ASAP. On 2023/09/23 11:00, TADANO Tokumei wrote: > This patch add MSZ (Middle Size; half width) characters related > options. > > * add `-replace_msz_japanese` option introduced in version 1.0.1 > of libaribcaption. > * add `-replace_msz_glyph` option introduced in version 1.1.0 > of libaribcaption. > * rename `-replace_fullwidth_ascii` option to `-replace_msz_ascii` > to clarify option meaning. > * FIX: change all the `bool` option variables in `ARIBCaptionContext` > to `int`. > On some environments, a `bool` variable is small space than `int`. > If a `bool` option was specified by command line, following > variables would be filled and destroyed. > --- > doc/decoders.texi | 28 ++++++++++++++++++++------ > libavcodec/libaribcaption.c | 40 ++++++++++++++++++++++++++++--------- > 2 files changed, 53 insertions(+), 15 deletions(-) > > diff --git a/doc/decoders.texi b/doc/decoders.texi > index 09b8314dd2..27b981b267 100644 > --- a/doc/decoders.texi > +++ b/doc/decoders.texi > @@ -427,12 +427,6 @@ If your player cannot handle AVSubtitles with multiple ASS rectangles properly, > set this option to @var{true} or define @env{ASS_SINGLE_RECT=1} to change > default behavior at compilation. > > -@item -replace_fullwidth_ascii @var{boolean} > -Specify whether to replace MSZ (Middle Size, half width) fullwidth > -alphanumerics with halfwidth alphanumerics. > - > -The default is @var{true}. > - > @item -force_outline_text @var{boolean} > Specify whether always render outline text for all characters regardless of > the indication by charactor style. > @@ -459,6 +453,28 @@ Specify whether to render replaced DRCS characters as Unicode characters. > > The default is @var{true}. > > +@item -replace_msz_ascii @var{boolean} > +Specify whether to replace MSZ (Middle Size, half width) fullwidth > +alphanumerics with halfwidth alphanumerics. > + > +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} > Specify the resolution of the canvas to render subtitles to; usually, this > should be frame size of input video. > diff --git a/libavcodec/libaribcaption.c b/libavcodec/libaribcaption.c > index 8a8c8f8cfd..ddff47633a 100644 > --- a/libavcodec/libaribcaption.c > +++ b/libavcodec/libaribcaption.c > @@ -68,14 +68,20 @@ typedef struct ARIBCaptionContext { > > int subtitle_type; > int encoding_scheme; > - bool ass_single_rect; > + int ass_single_rect; > char *font; > - bool replace_fullwidth_ascii; > - bool force_stroke_text; > - bool ignore_background; > - bool ignore_ruby; > + int force_stroke_text; > + int ignore_background; > + int ignore_ruby; > float stroke_width; > - bool replace_drcs; > + int replace_drcs; > + int replace_msz_ascii; > +#if defined(ARIBCC_VERSION) > + int replace_msz_japanese; > +# if AV_VERSION_INT(ARIBCC_VERSION_MAJOR, ARIBCC_VERSION_MINOR, ARIBCC_VERSION_PATCH) >= AV_VERSION_INT(1, 1, 0) > + int replace_msz_glyph; > +# endif > +#endif > > int64_t pts; > AVRational time_base; > @@ -1004,7 +1010,11 @@ static int aribcaption_init(AVCodecContext *avctx) > return AVERROR_EXTERNAL; > } > aribcc_decoder_set_replace_msz_fullwidth_ascii(ctx->decoder, > - ctx->replace_fullwidth_ascii); > + ctx->replace_msz_ascii); > +#if defined(ARIBCC_VERSION) > + aribcc_decoder_set_replace_msz_fullwidth_japanese(ctx->decoder, > + ctx->replace_msz_japanese); > +#endif > > /* Similar behavior as ffmpeg tool to set canvas size */ > if (ctx->canvas_width > 0 && ctx->canvas_height > 0 && > @@ -1057,6 +1067,10 @@ static int aribcaption_init(AVCodecContext *avctx) > 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_stroke_width(ctx->renderer, ctx->stroke_width); > +#if defined(ARIBCC_VERSION) && AV_VERSION_INT(ARIBCC_VERSION_MAJOR, ARIBCC_VERSION_MINOR, ARIBCC_VERSION_PATCH) >= AV_VERSION_INT(1, 1, 0) > + aribcc_renderer_set_replace_msz_halfwidth_glyph(ctx->renderer, > + ctx->replace_msz_glyph); > +#endif > if (ctx->font) { > int is_nomem = 0; > size_t count = 0; > @@ -1132,8 +1146,6 @@ static const AVOption options[] = { > OFFSET(ass_single_rect), AV_OPT_TYPE_BOOL, { .i64 = ASS_SINGLE_RECT }, 0, 1, SD }, > { "font", "comma-separated font family [ass, bitmap]", > OFFSET(font), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, SD }, > - { "replace_fullwidth_ascii", "replace MSZ fullwidth alphanumerics with halfwidth alphanumerics [ass, bitmap]", > - OFFSET(replace_fullwidth_ascii), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, SD }, > { "force_outline_text", "always render characters with outline [(ass), bitmap]", > OFFSET(force_stroke_text), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, SD }, > { "ignore_background", "ignore rendering caption background [(ass), bitmap]", > @@ -1144,6 +1156,16 @@ static const AVOption options[] = { > OFFSET(stroke_width), AV_OPT_TYPE_FLOAT, { .dbl = 1.5 }, 0.0, 3.0, SD }, > { "replace_drcs", "replace known DRCS [bitmap]", > OFFSET(replace_drcs), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, SD }, > + { "replace_msz_ascii", "replace MSZ fullwidth alphanumerics with halfwidth alphanumerics [ass, bitmap]", > + OFFSET(replace_msz_ascii), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, SD }, > +#if defined(ARIBCC_VERSION) > + { "replace_msz_japanese", "replace MSZ fullwidth Japanese with halfwidth [ass, bitmap]", > + OFFSET(replace_msz_japanese), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, SD }, > +# if AV_VERSION_INT(ARIBCC_VERSION_MAJOR, ARIBCC_VERSION_MINOR, ARIBCC_VERSION_PATCH) >= AV_VERSION_INT(1, 1, 0) > + { "replace_msz_glyph", "replace MSZ characters with halfwidth glyphs [bitmap]", > + OFFSET(replace_msz_glyph), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, SD }, > +# endif > +#endif > {"canvas_size", "set input video size (WxH or abbreviation) [bitmap]", > OFFSET(canvas_width), AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, INT_MAX, SD }, > { NULL } _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".