lavf/subviewerdec: Skip leading BOM.
authorCarl Eugen Hoyos <ceffmpeg@gmail.com>
Wed, 23 Jan 2019 23:22:47 +0000 (00:22 +0100)
committerCarl Eugen Hoyos <ceffmpeg@gmail.com>
Sun, 27 Jan 2019 13:25:53 +0000 (14:25 +0100)
Fixes ticket #7661.

libavformat/subviewerdec.c

index af084f4..61eb80a 100644 (file)
@@ -27,6 +27,7 @@
 #include "avformat.h"
 #include "internal.h"
 #include "subtitles.h"
+#include "avio_internal.h"
 #include "libavcodec/internal.h"
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
@@ -78,6 +79,11 @@ static int subviewer_read_header(AVFormatContext *s)
 
     if (!st)
         return AVERROR(ENOMEM);
+    res = ffio_ensure_seekback(s->pb, 3);
+    if (res < 0)
+        return res;
+    if (avio_rb24(s->pb) != 0xefbbbf)
+        avio_seek(s->pb, -3, SEEK_CUR);
     avpriv_set_pts_info(st, 64, 1, 100);
     st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
     st->codecpar->codec_id   = AV_CODEC_ID_SUBVIEWER;