[FFmpeg-devel] [PATCHv2] lavf/srtdec: rewrite parsing logic

Clément Bœsch u at pkh.me
Fri Jan 1 18:42:09 CET 2016


On Sat, Dec 26, 2015 at 06:51:00PM +0100, Clément Bœsch wrote:
> Fixes Ticket #5032
> 
> The samples in Ticket #5032 is using \r\r\n as line breaks.  Since we
> already are handling \r, or \n, or \r\n as line breaks, \r\n\n will be
> considered as a double line breaks. This is an issue because
> ff_subtitles_read_text_chunk() will as a result stop extracting a chunk
> after just one line.
> 
> So instead of parsing the SRT by "chunks" (which means splitting every
> double LB), this new parser is detecting timing lines, and split the
> events on this basis. While this sounds safe and simple, it needs to
> take into account the event number preceding the timing line while
> handling situations such as:
> 
>  - event number starting at 0 or actually any number instead of 1
>  - event numbers not being ordered at all
>  - event number being followed by text garbage (this really happened,
>    see Ticket #4898)
>  - event payload containing one or multiple number (a protagonist saying
>    a count-down, a date or whatever) which could be confused with a
>    chapter number
>  - event number being empty (see Ticket #2167)
>  - all kind of weird line breaks can appear randomly like wild pokémons
>  - untrustable line breaks (Ticket #5032)
> 
> The sample madness.srt tries to sum up most of this into one sample,
> ticket5032-rrn.srt is the file containing \r\r\n line breaks. and
> empty-events-2167.srt contains empty events.
> ---
> Now handling empty events, and with a new FATE test
> ---
>  libavformat/srtdec.c                     |  164 ++-
>  tests/fate/subtitles.mak                 |    9 +
>  tests/ref/fate/sub-srt-empty-events      |   24 +
>  tests/ref/fate/sub-srt-madness-timeshift |   36 +
>  tests/ref/fate/sub-srt-rrn-remux         | 2113 ++++++++++++++++++++++++++++++
>  5 files changed, 2296 insertions(+), 50 deletions(-)
>  create mode 100644 tests/ref/fate/sub-srt-empty-events
>  create mode 100644 tests/ref/fate/sub-srt-madness-timeshift
>  create mode 100644 tests/ref/fate/sub-srt-rrn-remux
> 

Applied.

[...]

-- 
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/20160101/280dbadc/attachment.sig>


More information about the ffmpeg-devel mailing list