[FFmpeg-devel] [PATCH] lavf/mpl2dec: skip BOM

Clément Bœsch u at pkh.me
Fri Apr 15 15:01:23 CEST 2016


On Fri, Apr 15, 2016 at 02:58:00PM +0200, wm4 wrote:
> Stolen from microdvddec.c.
> 
> Fixes ticket #5442.
> ---
>  libavformat/mpl2dec.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/libavformat/mpl2dec.c b/libavformat/mpl2dec.c
> index 59589d5..2a0cb28 100644
> --- a/libavformat/mpl2dec.c
> +++ b/libavformat/mpl2dec.c
> @@ -26,6 +26,7 @@
>  #include "avformat.h"
>  #include "internal.h"
>  #include "subtitles.h"
> +#include "libavutil/intreadwrite.h"
>  
>  typedef struct {
>      FFDemuxSubtitlesQueue q;
> @@ -39,6 +40,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;  /* skip UTF-8 BOM */
> +
>      for (i = 0; i < 2; i++) {
>          if (sscanf(ptr, "[%"SCNd64"][%"SCNd64"]%c", &start, &end, &c) != 3 &&
>              sscanf(ptr, "[%"SCNd64"][]%c",          &start,       &c) != 2)

make sure you don't need it in the read_header() callback too.

BTW, as a side note, it will be appropriate to s/if/while/, I have a few
samples with more than one bom... IIRC only in ASS files but we probably
to have it uniformly across sub text decoder. It's fine to keep it
consistent with a single if for now.

thanks

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160415/d3892b57/attachment.sig>


More information about the ffmpeg-devel mailing list