[FFmpeg-cvslog] avformat/subtitles: support standalone CR (MacOS).

Alexander Strasser eclipse7 at gmx.net
Sun Sep 8 22:21:05 CEST 2013


Hi Clément,

  nice to see further improvement of the subtitle code!

On 2013-09-08 18:56 +0200, Clément Bœsch wrote:
> ffmpeg | branch: master | Clément Bœsch <u at pkh.me> | Sun Sep  8 18:05:11 2013 +0200| [378a830e7b9a5e023c2f7eece6d7260016dfd13b] | committer: Clément Bœsch
> 
> avformat/subtitles: support standalone CR (MacOS).
> 
> Recent .srt files with CR only were found in the wild.
> 
> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=378a830e7b9a5e023c2f7eece6d7260016dfd13b
> ---
> 
>  libavformat/subtitles.c |    5 +++--
>  libavformat/subtitles.h |   13 +++++++++++--
>  2 files changed, 14 insertions(+), 4 deletions(-)
> 
[...]
> diff --git a/libavformat/subtitles.h b/libavformat/subtitles.h
> index 96de9fa..eced380 100644
> --- a/libavformat/subtitles.h
> +++ b/libavformat/subtitles.h
> @@ -99,11 +99,20 @@ void ff_subtitles_read_chunk(AVIOContext *pb, AVBPrint *buf);
>  /**
>   * Get the number of characters to increment to jump to the next line, or to
>   * the end of the string.
> + * The function handles the following line breaks schemes: LF (any sane
> + * system), CRLF (MS), or standalone CR (old MacOS).
>   */
>  static av_always_inline int ff_subtitles_next_line(const char *ptr)
>  {
> -    int n = strcspn(ptr, "\n");
> -    return n + !!*ptr;
                  ^^^^^^

> +    int n = strcspn(ptr, "\r\n");
> +    ptr += n;
       ^^^^^^^^

> +    if (*ptr == '\r') {
> +        ptr++;
> +        n++;
> +    }
> +    if (*ptr == '\n')
> +        n++;
> +    return n;

  If I am not mistaken this also fixes the regression introduced
by your previous commit. 

>  }
>  
>  #endif /* AVFORMAT_SUBTITLES_H */


  Alexander
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-cvslog/attachments/20130908/090e226c/attachment.asc>


More information about the ffmpeg-cvslog mailing list