From patchwork Thu Mar 18 18:40:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yorwba X-Patchwork-Id: 26452 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id B655444ABE1 for ; Thu, 18 Mar 2021 22:22:12 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8E66C68A360; Thu, 18 Mar 2021 22:22:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D0494687FBB for ; Thu, 18 Mar 2021 22:22:06 +0200 (EET) Received: by mail-wr1-f52.google.com with SMTP id j18so6884693wra.2 for ; Thu, 18 Mar 2021 13:22:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=L4jant50DO+6L+qVq+xl69vg4ICxALwTd3jXxiA29G8=; b=DUrqtUdR0ZAca3eIPyreJka3vv8wcb0ntTiQgANEwj1xk06VKTvVSxVlonTT+W0kyH wEXUjUV5zHJ3p7w/F9rJooaF4gNcHNWQDYmInqfCxWc1knG8kYIWq5BKCDo0FIILsnBD /+Vhj1FXm5yq9kaPiEAVXZA0cIFxQWmVjG9Pauyg8R8ddjd23G31LlTwhd5Jv0D4dBQO 99BFTGfwK+pWrE06T2VD9tG3wvU6QuUBbF8vz68z7PUqk9xgq2uUoaM225jbFtBypEu3 Bk8molvNnbtZrSgv0vc2m7ZMM67W9CWXCVg/zgr/iRMCj4zX8Hgx2QJjmzRe3RP4Hhwf 3d+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=L4jant50DO+6L+qVq+xl69vg4ICxALwTd3jXxiA29G8=; b=rYuptO+vUgUEDtaUpXJW0CCVod/UrlGV3moMlGtVczKLyYoIIFIWeDD0yzeuIADv6Q FUTY0dA8AIX0+twWGDTsPm7TqIVmUXUNe38oy1RGT5+K7WEGXSQqm+vX2VsbaRrzWHL+ TnepYj841z27jtmBnBf1KDvEoOmiCTAu2K1w5FJSzel1F7PGHEBPzv2+SL1waR2eaKCy gwVJl9VrSlbhncqWMvtdoXC2aMc8vlGBaMN1iPKeRtjhC1XHU7pzo7ySmBJBnnNht6LP JL7NXlFUWzQhzZ+nSR60fcLPb75Hr2nlVAsOTnFtfCWe2hql3+K/tth2uWWjFbU+dlKx kArA== X-Gm-Message-State: AOAM5322T5vljRdYpPaEMlBpXRz32APGMRl7jIHazByM4r+4wEcjXZWQ +1L4lYlIet5PKbxFAc+1FfFG5ohTPC4= X-Google-Smtp-Source: ABdhPJzb1JlOJQrKGTa+5W/14/DVDa19YSxKG09iQlyeCgXjkHabLwe82Mam/w2+aPGy+4le0QsJGA== X-Received: by 2002:a17:906:358c:: with SMTP id o12mr43382600ejb.156.1616092823070; Thu, 18 Mar 2021 11:40:23 -0700 (PDT) Received: from ?IPv6:2001:16b8:46a6:cc00:f879:82ed:8f52:286f? (200116b846a6cc00f87982ed8f52286f.dip.versatel-1u1.de. [2001:16b8:46a6:cc00:f879:82ed:8f52:286f]) by smtp.googlemail.com with ESMTPSA id u16sm2865620edq.4.2021.03.18.11.40.22 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Mar 2021 11:40:22 -0700 (PDT) To: ffmpeg-devel@ffmpeg.org From: yorwba Message-ID: Date: Thu, 18 Mar 2021 19:40:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 Content-Language: en-US Subject: [FFmpeg-devel] [PATCH] Make font shaping a shared subtitle filter option X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Commit 4b58349bc8ff2ff5dfbc9eef1e5856fd16e1f517 introduced a new option for selecting the font shaping engine used for rendering ASS subtitles. However, the shaping value was used in code shared with the ordinary subtitles filter (config_input in vf_subtitles.c), where it is left uninitialized, as opposed to defaulting to -1. This means that the subtitles filter is forced to use the "simple" shaping engine instead of automatically selecting the best available option. As a result, Indic scripts requiring "complex" shaping are not rendered correctly. This was reported as bug #8738. (Aside: Thanks to cehoyos for pointing to the responsible commit on the bug tracker.) Because I don't see a reason why font shaping should be an ASS-only option (especially considering the implementation was already shared), I moved it into the common options. Signed-off-by: Yorwba --- doc/filters.texi | 35 +++++++++++++++-------------------- libavfilter/vf_subtitles.c | 8 ++++---- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 30dee5531d..36a9e7613a 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -7099,26 +7099,6 @@ Same as the @ref{subtitles} filter, except that it doesn't require libavcodec and libavformat to work. On the other hand, it is limited to ASS (Advanced Substation Alpha) subtitles files. -This filter accepts the following option in addition to the common options from -the @ref{subtitles} filter: - -@table @option -@item shaping -Set the shaping engine - -Available values are: -@table @samp -@item auto -The default libass shaping engine, which is the best available. -@item simple -Fast, font-agnostic shaper that can do only substitutions -@item complex -Slower shaper using OpenType for substitutions and positioning -@end table - -The default is @code{auto}. -@end table - @section atadenoise Apply an Adaptive Temporal Averaging Denoiser to the video input. @@ -19227,6 +19207,21 @@ These fonts will be used in addition to whatever the font provider uses. @item alpha Process alpha channel, by default alpha channel is untouched. +@item shaping +Set the shaping engine + +Available values are: +@table @samp +@item auto +The default libass shaping engine, which is the best available. +@item simple +Fast, font-agnostic shaper that can do only substitutions +@item complex +Slower shaper using OpenType for substitutions and positioning +@end table + +The default is @code{auto}. + @item charenc Set subtitles input character encoding. @code{subtitles} filter only. Only useful if not UTF-8. diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c index de74afa2b7..1c10bd6aad 100644 --- a/libavfilter/vf_subtitles.c +++ b/libavfilter/vf_subtitles.c @@ -71,6 +71,10 @@ typedef struct AssContext { {"original_size", "set the size of the original video (used to scale fonts)", OFFSET(original_w), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, FLAGS }, \ {"fontsdir", "set the directory containing the fonts to read", OFFSET(fontsdir), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS }, \ {"alpha", "enable processing of alpha channel", OFFSET(alpha), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, FLAGS }, \ + {"shaping", "set shaping engine", OFFSET(shaping), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 1, FLAGS, "shaping_mode"}, \ + {"auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, INT_MIN, INT_MAX, FLAGS, "shaping_mode"}, \ + {"simple", "simple shaping", 0, AV_OPT_TYPE_CONST, {.i64 = ASS_SHAPING_SIMPLE}, INT_MIN, INT_MAX, FLAGS, "shaping_mode"}, \ + {"complex", "complex shaping", 0, AV_OPT_TYPE_CONST, {.i64 = ASS_SHAPING_COMPLEX}, INT_MIN, INT_MAX, FLAGS, "shaping_mode"}, \ /* libass supports a log level ranging from 0 to 7 */ static const int ass_libavfilter_log_level_map[] = { @@ -216,10 +220,6 @@ static const AVFilterPad ass_outputs[] = { static const AVOption ass_options[] = { COMMON_OPTIONS - {"shaping", "set shaping engine", OFFSET(shaping), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, FLAGS, "shaping_mode"}, - {"auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, INT_MIN, INT_MAX, FLAGS, "shaping_mode"}, - {"simple", "simple shaping", 0, AV_OPT_TYPE_CONST, {.i64 = ASS_SHAPING_SIMPLE}, INT_MIN, INT_MAX, FLAGS, "shaping_mode"}, - {"complex", "complex shaping", 0, AV_OPT_TYPE_CONST, {.i64 = ASS_SHAPING_COMPLEX}, INT_MIN, INT_MAX, FLAGS, "shaping_mode"}, {NULL}, };