From patchwork Sat Oct 17 18:22:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23045 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 C5A3044B29E for ; Sat, 17 Oct 2020 21:23:27 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AEDF368BB2E; Sat, 17 Oct 2020 21:23:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B279168BAAD for ; Sat, 17 Oct 2020 21:23:19 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id k18so8756122wmj.5 for ; Sat, 17 Oct 2020 11:23:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5THTPmO/KU2WyJV72rlLIi0BPIx/eRJx6HoJ6lClaqs=; b=N7DX8CntQyBh7m/JB/lsSk0YOt4OQ/SXDUSgk61x9Ap83TWpbrLqbFY67sq4mLUN3x u5/s1GxjtG0R8b6I6OvqbgpZKx8OfoEDc6cWYXOFY9WhoO6vqRrIkM/0J8FLKGaVj3rX 7cby6aUJizUmv7FI/RPjNxcoKr2ol4C7lkCIRxUhQZ7ld+KiTBq6oWO7q5+c04GKcTS4 KcbbRtUViG7TdmMFT3U0PuuTAvvw2pek/4Z3mPSuWeHpR00SizP+iVRq6T+lGOLmYsx8 VdxS+/CTE4S7oEFuK5uCF4tdK/DIELULW2+DXsn8DEypRLMoF4mWjo0dQqYWI9puuXNV E1AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5THTPmO/KU2WyJV72rlLIi0BPIx/eRJx6HoJ6lClaqs=; b=tnyzFguK9noKAHxBBnBnVB6zQOAyWINdCuHlTS89rEtp8kNDilsYMEJIGdw8ncoHl3 38xyz8FG+9vMABJt8FQS2RO617z7hGmlpaSd3mt3a/KVPjgP2vMvxe2LVisl69TYxayD cMDUovyMEzMKLHzn8PaVtWVfb3ICj/gx+kNzdetD4ghGPXJIsqUBfe1LNWaPsn7P9EYu QzT04X5RgraGV2+QMro+l56H9N+hlxyriUNgO1yxFbofSb8/m4sMGu0PNakNaKfUCfh2 CGfy8Bm0IOnqaRvLl74QsPliWT1lYDv6+ie2XFoY95dvtZlfuHkBQtJYbLb0I9pxGpFn k1FQ== X-Gm-Message-State: AOAM5336VGUre0ScF48Jc/5tH5fr5J0nIzHQNNyLyOBFudp6jJpvTvDX apNZswQmoQMH4bNFQ3rQZwDZvh1qcxw= X-Google-Smtp-Source: ABdhPJxx5i6hDJhz111m2kG3N0TMv28Vyk+wP3fkiLyuUEhkvUw7RKFpbFcMwoIfUuu8YjuCITX/3Q== X-Received: by 2002:a1c:1f87:: with SMTP id f129mr9551057wmf.182.1602958998848; Sat, 17 Oct 2020 11:23:18 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id d20sm10440688wra.38.2020.10.17.11.23.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Oct 2020 11:23:18 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 17 Oct 2020 20:22:43 +0200 Message-Id: <20201017182248.577108-6-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201017182248.577108-1-andreas.rheinhardt@gmail.com> References: <20201017182248.577108-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/11] avcodec/movtextdec: Skip empty styles 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" They would either lead to unnecessary ASS tags being emitted (namely tags that are reset immediately thereafter) or would lead to problems when parsing: e.g. if a zero-length style immediately follows another style, the current code will end the preceding style and set the zero-length style as the next potentially active style, but it is only tested for activation when the next character is parsed at which point the current offset is already greater than both the starting as well as the end offset of the empty style. It will therefore neither be opened nor closed and all subsequent styles will be ignored. Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextdec.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index e9df979e92..d167eddea5 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -302,6 +302,14 @@ static int decode_styl(const uint8_t *tsmb, MovTextContext *m, AVPacket *avpkt) } tsmb += 2; + if (style->style_start == style->style_end) { + /* Skip this style as it applies to no character */ + tsmb += 8; + m->style_entries--; + i--; + continue; + } + style->style_fontID = AV_RB16(tsmb); tsmb += 2; style->style_flag = AV_RB8(tsmb);