[FFmpeg-cvslog] avcodec/movtextdec: Skip empty styles

Andreas Rheinhardt git at videolan.org
Mon Oct 19 06:37:20 EEST 2020

ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sat Oct 17 17:48:54 2020 +0200| [40c16907bb69da6318917bbceac06f8325d361b6] | committer: Andreas Rheinhardt

avcodec/movtextdec: Skip empty styles

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.

Reviewed-by: Philip Langdale <philipl at overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=40c16907bb69da6318917bbceac06f8325d361b6

 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);

More information about the ffmpeg-cvslog mailing list