From patchwork Sat Jul 29 19:27:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgQsWTc2No?= X-Patchwork-Id: 4507 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.85 with SMTP id 82csp601769vsb; Sat, 29 Jul 2017 12:28:40 -0700 (PDT) X-Received: by 10.28.225.139 with SMTP id y133mr8038141wmg.41.1501356520598; Sat, 29 Jul 2017 12:28:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501356520; cv=none; d=google.com; s=arc-20160816; b=WC/rJgEea4kburk1Dw6uVAV7be0fELweeI8rf6Hu++My6JaBqT9yJuzfTSfm5HmJQ4 sPH4zxBN1jAmcmLRlEjhEunaUeh9dEkFvBy2Edp99DpgZCeVoB4rqIYS+Fbwdnzn2BfR DNv2ttOL8mWPV01zBMfIy5febLIG/xw206R2SjASZW/Hu4fmjAA68lpPzB2r/dpOXfmU CLpjvc5Qq9kJvqWUl90CLFEEYg75CiWpQgtzboti2raz4pfDhR1c/Mk1+X1OlSYglfji 727ZemJq4zJrSCc4InynvZ4FWnmWL91i+d4jDaCK6pl5aLQgXOpxoeLp0UNHFoyuQF8A fg2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:domainkey-signature:dkim-signature:delivered-to :arc-authentication-results; bh=KbmfFRsM4dwWT/2JUMGsCVovSzK/Y2hc8dWTWSVVB8U=; b=0xDEi4iw9MyHjFeWs0RNwwI9pxvyc1J9yWvqrj/TfICwvSR0fdJLiExqe/DMkEKLRz jHMFyqlGRBnUE7Cd7mwjedXSLAqZSDeXfo9I5lC6VRQ3sgCzxxKFpIq1pY5IUJxpmNrC ir3TKo6KvR/gkCc8bguSLf4yxpmxxF55aLuWhc9o3LvBPnI6OzhMz8bATVqcOa9ZmiYG Q1NKELVItk3u22tcVTIq/rNRuwXDY6dpEsPkDWVx9trfnROPP2bACCK6dNyNaEtWijYC /hnBA6QkAFMAPN+WVgfTNUFn98PkAureyZywg8bIeOVh4omwP6t32s4ITUswNz8xIIiv SJ5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@pkh.me header.b=Ytt3sXTh; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t109si10758127wrc.548.2017.07.29.12.28.40; Sat, 29 Jul 2017 12:28:40 -0700 (PDT) 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=@pkh.me header.b=Ytt3sXTh; 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 ED437689E3E; Sat, 29 Jul 2017 22:28:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from golem.pkh.me (LStLambert-657-1-117-164.w92-154.abo.wanadoo.fr [92.154.28.164]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4A790689E1B for ; Sat, 29 Jul 2017 22:28:07 +0300 (EEST) Received: from golem.pkh.me (localhost.localdomain [127.0.0.1]) by golem.pkh.me (OpenSMTPD) with ESMTP id 554f6d6b for ; Sat, 29 Jul 2017 19:27:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pkh.me; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=selector1; bh=QtA5aukKluwtZAbNjuFFHnH3jmE=; b=Ytt3sXThnyzwU6GY1OCIkulg6dWg EBxrNcKniewnSmdSvDqWZW3EIH22DTu0XrhngwM6zDYB0AWSZRV7TBGbnetNNTh+ rW3l48QwecJinIC/DaSo9Vq89JlSvn4MaL3sE2DomQifZHXxRGWISR+BvlfzXAuG Kjd2DN4tG5NE3cl5+GbTM0DoMA+cTyD/yZmBnwzOvEpyxVyhuIJoO+oE/PVQjeU3 IrSxZJ41lQ/StVmEX4rURu83dHYV/5ei92qpceH4I7Yid1z9kx3+j8HdXUVYUplA U9RCc9oh/AjJz3V356pBmCrQzepOg/UGxYIu+F/1VPFfY7Ig/sUBollV8w== DomainKey-Signature: a=rsa-sha1; c=nofws; d=pkh.me; h=from:to:cc:subject :date:message-id:in-reply-to:references; q=dns; s=selector1; b=C DJnP50DgWBcK3w9eB8BnjRJatXAIGHL5gCtUQaotI2xN9v1ICSBgapTDTIOYE2Sa 4rMnyIvZnJZ95r+I6d3TZEJobzV5xjvfT8IF4y17CM0vppw3/vQEN14ZnGRJQjvb c17LsYfNRNQoEN8YH6GQeWs5NRgxGb8SCoWdlOzfvAJCSf6DTgO3l6bynFtOLile kBQra+0pZdHyLj562AfW9qvIJA872CGCuCwES/xa8RjQveyNm7YUWZeH8ZR7yu2D kZq+5WmEjQGnT9B2tq52lyLtTI+DozvCYtJFytxswaOHQx4jmxN0+zSeggm9p8i1 J/2BBnazq5i4Ph8IJatBA== Received: from localhost (golem.pkh.me [local]) by golem.pkh.me (OpenSMTPD) with ESMTPA id 8a50c4f4; Sat, 29 Jul 2017 19:27:55 +0000 (UTC) From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= To: ffmpeg-devel@ffmpeg.org Date: Sat, 29 Jul 2017 21:27:51 +0200 Message-Id: <20170729192751.26379-5-u@pkh.me> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170729192751.26379-1-u@pkh.me> References: <20170729192751.26379-1-u@pkh.me> Subject: [FFmpeg-devel] [PATCH 5/5] lavc/htmlsubtitles: reindent after previous commits 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 Cc: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/htmlsubtitles.c | 76 ++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/libavcodec/htmlsubtitles.c b/libavcodec/htmlsubtitles.c index 2b47c426ee..f4501816e5 100644 --- a/libavcodec/htmlsubtitles.c +++ b/libavcodec/htmlsubtitles.c @@ -175,8 +175,6 @@ int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in) } } - // TODO: reindent - if (!av_strcasecmp(tagname, "font")) { if (tag_close && sptr > 0) { struct font_tag *cur_tag = &stack[sptr--]; @@ -207,48 +205,46 @@ int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in) *new_tag = stack[sptr++]; - while (param) { - if (!av_strncasecmp(param, "size=", 5)) { - param += 5 + (param[5] == '"'); - if (sscanf(param, "%u", &new_tag->size) == 1) - av_bprintf(dst, "{\\fs%u}", new_tag->size); - } else if (!av_strncasecmp(param, "color=", 6)) { - int color; - param += 6 + (param[6] == '"'); - color = html_color_parse(log_ctx, param); - if (color >= 0) { - new_tag->color = 0xff000000 | color; - av_bprintf(dst, "{\\c&H%X&}", new_tag->color & 0xffffff); - } - } else if (!av_strncasecmp(param, "face=", 5)) { - param += 5 + (param[5] == '"'); - len = strcspn(param, - param[-1] == '"' ? "\"" :" "); - av_strlcpy(new_tag->face, param, - FFMIN(sizeof(new_tag->face), len+1)); - param += len; - av_bprintf(dst, "{\\fn%s}", new_tag->face); + while (param) { + if (!av_strncasecmp(param, "size=", 5)) { + param += 5 + (param[5] == '"'); + if (sscanf(param, "%u", &new_tag->size) == 1) + av_bprintf(dst, "{\\fs%u}", new_tag->size); + } else if (!av_strncasecmp(param, "color=", 6)) { + int color; + param += 6 + (param[6] == '"'); + color = html_color_parse(log_ctx, param); + if (color >= 0) { + new_tag->color = 0xff000000 | color; + av_bprintf(dst, "{\\c&H%X&}", new_tag->color & 0xffffff); } - if ((param = strchr(param, ' '))) - param++; + } else if (!av_strncasecmp(param, "face=", 5)) { + param += 5 + (param[5] == '"'); + len = strcspn(param, + param[-1] == '"' ? "\"" :" "); + av_strlcpy(new_tag->face, param, + FFMIN(sizeof(new_tag->face), len+1)); + param += len; + av_bprintf(dst, "{\\fn%s}", new_tag->face); } + if ((param = strchr(param, ' '))) + param++; } - + } in += skip; - - } else if (tagname[0] && !tagname[1] && strchr("bisu", av_tolower(tagname[0]))) { - av_bprintf(dst, "{\\%c%d}", (char)av_tolower(tagname[0]), !tag_close); - in += skip; - } else if (!av_strncasecmp(tagname, "br", 2) && - (!tagname[2] || (tagname[2] == '/' && !tagname[3]))) { - av_bprintf(dst, "\\N"); - in += skip; - } else if (likely_a_tag) { - if (!tag_close) // warn only once - av_log(log_ctx, AV_LOG_WARNING, "Unrecognized tag %s\n", tagname); - in += skip; - } else { - av_bprint_chars(dst, '<', 1); + } else if (tagname[0] && !tagname[1] && strchr("bisu", av_tolower(tagname[0]))) { + av_bprintf(dst, "{\\%c%d}", (char)av_tolower(tagname[0]), !tag_close); + in += skip; + } else if (!av_strncasecmp(tagname, "br", 2) && + (!tagname[2] || (tagname[2] == '/' && !tagname[3]))) { + av_bprintf(dst, "\\N"); + in += skip; + } else if (likely_a_tag) { + if (!tag_close) // warn only once + av_log(log_ctx, AV_LOG_WARNING, "Unrecognized tag %s\n", tagname); + in += skip; + } else { + av_bprint_chars(dst, '<', 1); } } else { av_bprint_chars(dst, *in, 1);