[FFmpeg-devel] [PATCH 1/4] mpl2dec: handle files with CRLF linebreaks correctly

Clément Bœsch ubitux at gmail.com
Thu Aug 8 07:12:52 CEST 2013


On Thu, Aug 08, 2013 at 01:04:36AM +0200, wm4 wrote:
> Skip the "\r" as normal text. Otherwise it will be the first character
> of the string passed to sscanf(), which then fill fail to match the
> timestamps.
> 
> The change in mpl2_read_header() will handle "\r" like srtdec.c does.
> ---
>  libavformat/mpl2dec.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/mpl2dec.c b/libavformat/mpl2dec.c
> index b152cc8..844a38b 100644
> --- a/libavformat/mpl2dec.c
> +++ b/libavformat/mpl2dec.c
> @@ -43,7 +43,7 @@ static int mpl2_probe(AVProbeData *p)
>          if (sscanf(ptr, "[%"SCNd64"][%"SCNd64"]%c", &start, &end, &c) != 3 &&
>              sscanf(ptr, "[%"SCNd64"][]%c",          &start,       &c) != 2)
>              return 0;
> -        ptr += strcspn(ptr, "\r\n") + 1;
> +        ptr += strcspn(ptr, "\n") + 1;

This chunk looks correct

>          if (ptr >= ptr_end)
>              return 0;
>      }
> @@ -94,7 +94,7 @@ static int mpl2_read_header(AVFormatContext *s)
>          if (!len)
>              break;
>  
> -        line[strcspn(line, "\r\n")] = 0;
> +        line[strcspn(line, "\n")] = 0;
>  

This one doesn't thought: line will end up with a \r in it.

>          if (!read_ts(&p, &pts_start, &duration)) {
>              AVPacket *sub;

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


More information about the ffmpeg-devel mailing list