diff mbox

[FFmpeg-devel] lavf/subviewerdec: Skip leading BOM

Message ID CAB0OVGq2-BhhnftoPQTqnZZBAknCr71qAMkQ8wnqEhPb8UyeGg@mail.gmail.com
State Accepted
Headers show

Commit Message

Carl Eugen Hoyos Jan. 23, 2019, 11:29 p.m. UTC
Hi!

Attached patch fixes ticket #7661 for me.

Please comment, Carl Eugen

Comments

Carl Eugen Hoyos Jan. 24, 2019, 12:15 p.m. UTC | #1
2019-01-24 0:29 GMT+01:00, Carl Eugen Hoyos <ceffmpeg@gmail.com>:

> Attached patch fixes ticket #7661 for me.

> +    if (avio_rb24(s->pb) != MKBETAG(0, 0xef, 0xbb, 0xbf))

Changed locally to:
+    if (avio_rb24(s->pb) != 0xefbbbf)

Carl Eugen
Carl Eugen Hoyos Jan. 25, 2019, 7:21 p.m. UTC | #2
2019-01-24 0:29 GMT+01:00, Carl Eugen Hoyos <ceffmpeg@gmail.com>:

> Attached patch fixes ticket #7661 for me.

Will commit tomorrow.

Carl Eugen
diff mbox

Patch

From aa9df8940056919ac7c4b65900a2dd43a76321d2 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Thu, 24 Jan 2019 00:22:47 +0100
Subject: [PATCH] lavf/subviewerdec: Skip leading BOM.

Fixes ticket #7661.
---
 libavformat/subviewerdec.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavformat/subviewerdec.c b/libavformat/subviewerdec.c
index af084f4..9023a05 100644
--- a/libavformat/subviewerdec.c
+++ b/libavformat/subviewerdec.c
@@ -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) != MKBETAG(0, 0xef, 0xbb, 0xbf))
+        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;
-- 
1.7.10.4