[FFmpeg-devel] [PATCH] avformat/mpl2dec: skip BOM when probing

Paul B Mahol onemda at gmail.com
Sun Feb 12 14:10:06 EET 2017


On 2/12/17, Clement Boesch <u at pkh.me> wrote:
> On Sun, Feb 12, 2017 at 12:51:11PM +0100, Paul B Mahol wrote:
>> On 2/11/17, Clement Boesch <u at pkh.me> wrote:
>> > On Sat, Feb 11, 2017 at 11:56:07AM +0100, Paul B Mahol wrote:
>> >> Signed-off-by: Paul B Mahol <onemda at gmail.com>
>> >> ---
>> >>  libavformat/mpl2dec.c | 8 ++++++++
>> >>  1 file changed, 8 insertions(+)
>> >>
>> >> diff --git a/libavformat/mpl2dec.c b/libavformat/mpl2dec.c
>> >> index 59589d5..0e30cb0 100644
>> >> --- a/libavformat/mpl2dec.c
>> >> +++ b/libavformat/mpl2dec.c
>> >> @@ -23,6 +23,8 @@
>> >>   * MPL2 subtitles format demuxer
>> >>   */
>> >>
>> >> +#include "libavutil/intreadwrite.h"
>> >> +
>> >>  #include "avformat.h"
>> >>  #include "internal.h"
>> >>  #include "subtitles.h"
>> >> @@ -39,6 +41,9 @@ static int mpl2_probe(AVProbeData *p)
>> >>      const unsigned char *ptr = p->buf;
>> >>      const unsigned char *ptr_end = ptr + p->buf_size;
>> >>
>> >> +    if (AV_RB24(ptr) == 0xefbbbf)
>> >> +        ptr += 3;
>> >> +
>> >>      for (i = 0; i < 2; i++) {
>> >>          if (sscanf(ptr, "[%"SCNd64"][%"SCNd64"]%c", &start, &end, &c)
>> >> !=
>> >> 3 &&
>> >>              sscanf(ptr, "[%"SCNd64"][]%c",          &start,       &c)
>> >> !=
>> >> 2)
>> >> @@ -94,6 +99,9 @@ static int mpl2_read_header(AVFormatContext *s)
>> >>          if (!len)
>> >>              break;
>> >>
>> >> +        if (AV_RB24(p) == 0xefbbbf)
>> >> +            p += 3;
>> >> +
>> >
>> > The BOM is supposed to be at the beginning of the file, not at every
>> > line.
>> > The check should be outside the while loop.
>> >
>> > --
>> > Clement B.
>> >
>>
>> Removed check which was there, it appears to still work.
>
> Doesn't it skip the first event? Or maybe your libc skips it in sscanf?

Ah, first even is indeed skipped.


More information about the ffmpeg-devel mailing list