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 D359B465CB for ; Mon, 22 May 2023 13:26:32 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 557C468C08B; Mon, 22 May 2023 16:26:29 +0300 (EEST) Received: from out203-205-251-27.mail.qq.com (out203-205-251-27.mail.qq.com [203.205.251.27]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 18C6A68B004 for ; Mon, 22 May 2023 16:26:20 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1684761972; bh=pSEiQ1/8WTidVw7rtjw1jBcoFwE99biVyhkNesK2tz8=; h=From:To:Cc:Subject:Date; b=JQ+EG5TnsHYTQ9YTggW8uUjedW9R+p+heOUSLCUGapphgSDVR39/oRQ6iwOoAowjS QWmyfVq7S5KK6LMRDFO/Sct1QbaApEcg45QgCVJEJUD4KBYNL8PLDyuxMrqqasWLRc NodINP2k6rvOt7La1X+futbys0jXDr3tOVPvUGkM= Received: from ZHILIZHAO-MB2.tencent.com ([113.108.77.71]) by newxmesmtplogicsvrszc2-1.qq.com (NewEsmtp) with SMTP id 6831BC61; Mon, 22 May 2023 21:26:03 +0800 X-QQ-mid: xmsmtpt1684761963tqpn1ksnc Message-ID: X-QQ-XMAILINFO: NioaTWkRhWwaGhGWnHXl9SYOvUHdHvsvK1EwtIjE+xyl6dci0cvkZ0xLeUhym5 VQKhd/kfZNuaCu3594CaEDZcsFKW8nYjhmFu6yWpZjL5U12+P2QD1/z2lPxZ5u1Nt9HQwmE/6T8E RuEyxSWn+zsU2e1+FCvdEFI5MhaNqT79fDjgEWqde3n8eRZORxUNY441T8YlDDroaUYJpKB3G9JQ OshY0yn05olhuGQFHCuhST6FFU3ku7mD5GEFoZ4SW2Su9f2I7pRuA/V81sBopTOqc1hGxav9hxLZ ChQv1b6mGUQTUoAL8y9/BtIfyOYA3LHp2k1gu2KwcRq7kNcK0zoiXilLyWiYdIDsXGZNYUVlERUf /W9M3zmBBSdhOwgXv/MmlTVmSj+MmT8cOzwz2IpDs9YO4opvA5vKG6AC2YM4n9C4PbBSBcbTlhy1 Rvg1UN4PUavf+7MqnD1XCxBHTSt/m2ZNkzygUST6ofVSCfkxIN+LuG08QsYlglXBV7ndUOfCw0Am SioXDfNzzj1NwxEyTim+6oxxxPOOyPyWpM6FYvKzge3XtKgdkAAAX2ayugHCcgvbArX92rWNvuDH eRaj3KrHsKD3hYKAJdCI7Fc8ZppyL2hUZwD6XGgSwo8hJUfe7hQe1K40ppbzGX8nil3y6Z9Gx4dn pe1qzbCwYBvDWwIQwYJ6Q0MTi9exAo7UQPO3J78z8JazGIzVg9L7qXMPLv0/akpfMomyIOvXPcV5 NnPgMYzzqasOVL0Wdhi1bCRXuNGhNCITgTIbParvI9GYc1naaxdzPivGdhDly2RmzutHG+lTqcyN 1c8OQJTpfp3AZWENoVtsN/40dTpPtMEWOHFwDTn+CAJH3m+uHbmrFxpyIR/Jn5ALY6lHyD3ecUSy 4IHY9dC+OQj+XRgVsu6NNCGIwpZyRJl3d6lKtckMgSA0DovVwpooBcugtAlZ0SlkTMlpOfDBYEwZ zj3xU7eJrSqQw+5QpRAPXmtkTU17O4r7idVbSFNKFo4o5Jfumhxg== From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 May 2023 21:26:02 +0800 X-OQ-MSGID: <20230522132602.17170-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3] avfilter/vf_subtitles: add wrap_unicode option 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 Cc: Zhao Zhili Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Zhao Zhili So CJK can be wrapped automatically. Signed-off-by: Zhao Zhili --- v3: Fix build error with older libass v2: Don't overwrite wrap automatically for native ASS libavfilter/version.h | 2 +- libavfilter/vf_subtitles.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libavfilter/version.h b/libavfilter/version.h index ba8a6fdab2..08779130f5 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -32,7 +32,7 @@ #include "version_major.h" #define LIBAVFILTER_VERSION_MINOR 8 -#define LIBAVFILTER_VERSION_MICRO 100 +#define LIBAVFILTER_VERSION_MICRO 101 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c index 82e140e986..3e5a19e715 100644 --- a/libavfilter/vf_subtitles.c +++ b/libavfilter/vf_subtitles.c @@ -45,6 +45,8 @@ #include "formats.h" #include "video.h" +#define FF_ASS_FEATURE_WRAP_UNICODE (LIBASS_VERSION >= 0x01600010) + typedef struct AssContext { const AVClass *class; ASS_Library *library; @@ -61,6 +63,7 @@ typedef struct AssContext { int original_w, original_h; int shaping; FFDrawContext draw; + int wrap_unicode; } AssContext; #define OFFSET(x) offsetof(AssContext, x) @@ -271,6 +274,9 @@ static const AVOption subtitles_options[] = { {"stream_index", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS}, {"si", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS}, {"force_style", "force subtitle style", OFFSET(force_style), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS}, +#if FF_ASS_FEATURE_WRAP_UNICODE + {"wrap_unicode", "break lines according to the Unicode Line Breaking Algorithm", OFFSET(wrap_unicode), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, FLAGS }, +#endif {NULL}, }; @@ -432,6 +438,18 @@ static av_cold int init_subtitles(AVFilterContext *ctx) if (ret < 0) goto end; +#if FF_ASS_FEATURE_WRAP_UNICODE + /* Don't overwrite wrap automatically for native ASS */ + if (ass->wrap_unicode == -1) + ass->wrap_unicode = st->codecpar->codec_id != AV_CODEC_ID_ASS; + if (ass->wrap_unicode) { + ret = ass_track_set_feature(ass->track, ASS_FEATURE_WRAP_UNICODE, 1); + if (ret < 0) + av_log(ctx, AV_LOG_WARNING, + "libass wasn't built with ASS_FEATURE_WRAP_UNICODE support\n"); + } +#endif + if (ass->force_style) { char **list = NULL; char *temp = NULL; -- 2.34.1 _______________________________________________ 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".