From patchwork Sat Jul 29 19:27:48 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: 4509 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.85 with SMTP id 82csp601476vsb; Sat, 29 Jul 2017 12:28:14 -0700 (PDT) X-Received: by 10.28.17.145 with SMTP id 139mr3568471wmr.38.1501356494846; Sat, 29 Jul 2017 12:28:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501356494; cv=none; d=google.com; s=arc-20160816; b=jzZK8WgEcADLqMQEiIHECKXYfba9OVOYN+n1jhFQREE3PRihV9zrUSRLwmi7PLs9tm M7mQiG03XoyOHQMSSOpOIGbX/KevzbWFaArixkR5FMBwCyIOlQe2G33FPmQVAX4a2TAZ gEiVwx8vKMDP+MmjwORbRUQK2DxFsTIbPj7skQoXo+I1Swg5JDmFQwX9iQGnbWVqYKf8 G/ncHu5PdEuIGouaxkmcOvwmqVNPRPRMFZ6kSkeAf0fEvmX1npYJ8jeBAyBU76si9ABk 89L/+McO20KHYxAI83RcHfinFjW4l8GFcAUtIMcRgEAxGFALd8i1bmtPCxjol7ik4zx0 Tj3A== 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=34gR1sRAMvxz7pdwx9pDpGqRqQOW69WXtDrq8L77o/A=; b=VQpJ7/kjwHYnsFtjS0sxgAXBKMlVpJKf5gATErVU863Ide8tooPwbmGkk4R3yvWegd HKM35CqDS2fJ627WTQqjsF0BM0C+Zkodp72Vx0BkDM1+PAuPee0cc8ibxdkzpvqVIzwR eO/2SQ7n6le5aa4WRGSImYs7m3DQS6H8lUu8NJyKNGr/0hZNQH0wJp9RnNjMGTCCE8fp uLq03x031IsWdg+2N/jjPyWMO/eAMrRey4SMb6TCeuuXfvxgXaFpoAsudWBY/FOTg2xW R8kIoE3egELBxgI9t3j2JqNtqPb9bfqpNzL8HLFVUjwEF0zz5U0bvxT+qlc7JVhevJtE FLtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@pkh.me header.b=W4Sojqjc; 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 p15si9645201wrd.117.2017.07.29.12.28.14; Sat, 29 Jul 2017 12:28:14 -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=W4Sojqjc; 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 A88DB689D78; Sat, 29 Jul 2017 22:28:04 +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 F0A56689D78 for ; Sat, 29 Jul 2017 22:27:57 +0300 (EEST) Received: from golem.pkh.me (localhost.localdomain [127.0.0.1]) by golem.pkh.me (OpenSMTPD) with ESMTP id 107470b0 for ; Sat, 29 Jul 2017 19:27:54 +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=vTkd3EBw4p0PMygOHFmGcU2kHJE=; b=W4SojqjcSlp6GZmYhYlLHdb91WY9 9FMAd9SfdOW6lcMFkZr6F20ZYTDZSk3oDEKUCyYiaHqCEw9gfcq9snWZRczln9b0 Sq0AyuSaoaXvfh++g0z6JMBzEWqK7UDRX4sAG8nsD3sgkMt6rQxzD3y82t1bqtPE Bg6EmaV9mPA1pDAmxjbEte9s5VXaLVzjMQq4qHAGwaw+l0nKc1lXbVJ/0advCIHO 4qwWT/mAIoCGuVTh8dmCOiGHx4aZ2Cdys6xiJ04zUjhVNZLf2YblQeQrMo93y50L Re8IKExZCAQHTxOZpY/yIKhRGmeTwqa3MXxAWf+mzgHUeDY0xLkDNy6+Qg== 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=K dZ8DN0WD4xbh1eykH94C4xB1jvo9vRPZ/YkoCUjCoZ0v2wskfDe3GgJz4lgchuBo rhw52+u5SrEQXps3VtenJVK3GLBT5W+ubhdeyK0zzoSjQK78+0qxW7nQtr4oDD7n BMylUvCAvjyW5zUg8WPEOoYGaNBuTxkXPfYEDQSo9KYsUYRpCPfbnCSGXElBPa6T wReOXrI1M+9m0v1ounYgl9T7tZVDuJc/BIb7lKYCI4DfikQAV6wyalg56PrpJzlU JiB0rc9fy66QGl8LtGwAqF9QCmDkFED2O5350Uh0/z6UvpEZfjPW8wCUyOhgVRow reuqsYc6HhskZ5MorFtaQ== Received: from localhost (golem.pkh.me [local]) by golem.pkh.me (OpenSMTPD) with ESMTPA id d91b8274; Sat, 29 Jul 2017 19:27:53 +0000 (UTC) From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= To: ffmpeg-devel@ffmpeg.org Date: Sat, 29 Jul 2017 21:27:48 +0200 Message-Id: <20170729192751.26379-2-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 2/5] lavc/tests: add htmlsubtitles 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/Makefile | 1 + libavcodec/tests/.gitignore | 1 + libavcodec/tests/htmlsubtitles.c | 49 +++++++++++++++++++++++++++++++++ tests/fate/libavcodec.mak | 4 +++ tests/ref/fate/libavcodec-htmlsubtitles | 7 +++++ 5 files changed, 62 insertions(+) create mode 100644 libavcodec/tests/htmlsubtitles.c create mode 100644 tests/ref/fate/libavcodec-htmlsubtitles diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 357fa1a361..161b446a3d 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1041,6 +1041,7 @@ SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vda_vt_internal.h TESTPROGS = avpacket \ celp_math \ + htmlsubtitles \ imgconvert \ jpeg2000dwt \ mathops \ diff --git a/libavcodec/tests/.gitignore b/libavcodec/tests/.gitignore index f22ac821cb..31947bf9bb 100644 --- a/libavcodec/tests/.gitignore +++ b/libavcodec/tests/.gitignore @@ -6,6 +6,7 @@ /fft-fixed /fft-fixed32 /golomb +/htmlsubtitles /iirfilter /imgconvert /jpeg2000dwt diff --git a/libavcodec/tests/htmlsubtitles.c b/libavcodec/tests/htmlsubtitles.c new file mode 100644 index 0000000000..d0b55a45d3 --- /dev/null +++ b/libavcodec/tests/htmlsubtitles.c @@ -0,0 +1,49 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/common.h" +#include "libavcodec/htmlsubtitles.c" + +static const char * const test_cases[] = { + /* latin guillemets and other < > garbage */ + "<>", // guillemets + "<<hello>>", // guillemets + tags + "< hello < 2000 > world >", // unlikely tags due to spaces + "

TITLE

", // likely unhandled tags + "< font color=red >red", // invalid format of valid tag + "Foo ", // not a tag (not alnum) + + " foo bar bla ", // broken nesting +}; + +int main(void) +{ + int i; + AVBPrint dst; + + av_bprint_init(&dst, 0, AV_BPRINT_SIZE_UNLIMITED); + for (i = 0; i < FF_ARRAY_ELEMS(test_cases); i++) { + int ret = ff_htmlmarkup_to_ass(NULL, &dst, test_cases[i]); + if (ret < 0) + return ret; + printf("%s --> %s\n", test_cases[i], dst.str); + av_bprint_clear(&dst); + } + av_bprint_finalize(&dst, NULL); + return 0; +} diff --git a/tests/fate/libavcodec.mak b/tests/fate/libavcodec.mak index b1e3446d68..fc8075c532 100644 --- a/tests/fate/libavcodec.mak +++ b/tests/fate/libavcodec.mak @@ -82,5 +82,9 @@ fate-libavcodec-huffman: CMD = run libavcodec/tests/mjpegenc_huffman fate-libavcodec-huffman: CMP = null fate-libavcodec-huffman: REF = /dev/null +FATE_LIBAVCODEC-yes += fate-libavcodec-htmlsubtitles +fate-libavcodec-htmlsubtitles: libavcodec/tests/htmlsubtitles$(EXESUF) +fate-libavcodec-htmlsubtitles: CMD = run libavcodec/tests/htmlsubtitles + FATE-$(CONFIG_AVCODEC) += $(FATE_LIBAVCODEC-yes) fate-libavcodec: $(FATE_LIBAVCODEC-yes) diff --git a/tests/ref/fate/libavcodec-htmlsubtitles b/tests/ref/fate/libavcodec-htmlsubtitles new file mode 100644 index 0000000000..702f0b7ea3 --- /dev/null +++ b/tests/ref/fate/libavcodec-htmlsubtitles @@ -0,0 +1,7 @@ +<> --> <> +<<hello>> --> <<{\b1}hello{\b0}>> +< hello < 2000 > world > --> < hello < 2000 > world > +

TITLE

--> TITLE +< font color=red >red --> {\c&HFF&}red{\c} +Foo --> Foo + foo bar bla --> {\b1} foo {\i1} bar {\b0} bla {\i0}