From patchwork Tue Feb 14 07:02:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "su.gao" X-Patchwork-Id: 2545 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp1298895vsb; Mon, 13 Feb 2017 23:18:14 -0800 (PST) X-Received: by 10.223.163.75 with SMTP id d11mr23021879wrb.87.1487056694414; Mon, 13 Feb 2017 23:18:14 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id v30si16834594wra.229.2017.02.13.23.18.13; Mon, 13 Feb 2017 23:18:14 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@163.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9AAEE689210; Tue, 14 Feb 2017 09:18:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from m13-107.163.com (m13-107.163.com [220.181.13.107]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 29940680A51 for ; Tue, 14 Feb 2017 09:17:57 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:From:Subject:MIME-Version:Message-ID; bh=qBc85 /J40OWspYF2TUfpfyYoN7+nGQryE8gT71AGCKA=; b=l8ZwhnuumhDXVyORAULHY MDtc6YLSc8RAepN6Tdwe896dcPjQM3ciAd03qexN+6owFFTzK12Gb5QheHyn9i3o sqplb7BwpwNjrvGAli9w8bAQp8BCrYAmwe6BytDjtVUOahAhRs67PO3/lT+M1hIN 7zkuSBf5zOSh0FKgpaBPsE= Received: from sugao_cn$163.com ( [125.69.142.44] ) by ajax-webmail-wmsvr107 (Coremail) ; Tue, 14 Feb 2017 15:02:46 +0800 (CST) X-Originating-IP: [125.69.142.44] Date: Tue, 14 Feb 2017 15:02:46 +0800 (CST) From: "su.gao" To: "FFmpeg development discussions and patches" X-Priority: 3 X-Mailer: Coremail Webmail Server Version SP_ntes V3.5 build 20160729(86883.8884) Copyright (c) 2002-2017 www.mailtech.cn 163com In-Reply-To: <20170214030407.GH5776@nb4> References: <20170213124640.29060-1-michael@niedermayer.cc> <20170214030407.GH5776@nb4> X-CM-CTRLDATA: Uou7mWZvb3Rlcl9odG09NDIzNDo1Ng== MIME-Version: 1.0 Message-ID: <1ad965e0.8d0d.15a3b6e456d.Coremail.sugao_cn@163.com> X-Coremail-Locale: zh_CN X-CM-TRANSID: a8GowAA3XqmXq6JYIu_ZAA--.39568W X-CM-SenderInfo: 5vxjt0xbfqqiywtou0bp/1tbiWAl+D1UL-vgZYwACsA X-Coremail-Antispam: 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU== X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] vf_drawtext: add force_boxw_equl_textw 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" Add this option to force the box width equl text width: diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 0b94725..5b16cfa 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -164,6 +164,7 @@ typedef struct DrawTextContext { int use_kerning; ///< font kerning is used - true/false int tabsize; ///< tab size int fix_bounds; ///< do we let it go out of frame bounds - t/f + int force_boxw_equl_textw; ///< tab size FFDrawContext dc; FFDrawColor fontcolor; ///< foreground color @@ -209,6 +210,7 @@ static const AVOption drawtext_options[]= { {"bordercolor", "set border color", OFFSET(bordercolor.rgba), AV_OPT_TYPE_COLOR, {.str="black"}, CHAR_MIN, CHAR_MAX, FLAGS}, {"shadowcolor", "set shadow color", OFFSET(shadowcolor.rgba), AV_OPT_TYPE_COLOR, {.str="black"}, CHAR_MIN, CHAR_MAX, FLAGS}, {"box", "set box", OFFSET(draw_box), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 , FLAGS}, + {"force_boxw_equl_textw", "force the box width equl text width", OFFSET(force_boxw_equl_textw), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 , FLAGS}, {"boxborderw", "set box border width", OFFSET(boxborderw), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX , FLAGS}, {"line_spacing", "set line spacing in pixels", OFFSET(line_spacing), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX,FLAGS}, {"fontsize", "set font size", OFFSET(fontsize), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX , FLAGS}, @@ -1298,7 +1300,11 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame, update_color_with_alpha(s, &bordercolor, s->bordercolor); update_color_with_alpha(s, &boxcolor , s->boxcolor ); - box_w = FFMIN(width - 1 , max_text_line_w); + if(0==s->force_boxw_equl_textw){ + box_w = FFMIN(width - 1 , max_text_line_w); + }else{ + box_w = (int)s->var_values[VAR_TEXT_W]; + }