[vlc-devel] commit: Added support for buggy SubRip files that use dot instead of comma. (Laurent Aimar )

git version control git at videolan.org
Mon Apr 13 17:03:04 CEST 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Mon Apr 13 16:16:34 2009 +0200| [0ea77dfd682d73ec7e1b0c089dc52d1de8e9e690] | committer: Laurent Aimar 

Added support for buggy SubRip files that use dot instead of comma.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0ea77dfd682d73ec7e1b0c089dc52d1de8e9e690
---

 modules/demux/subtitle.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c
index ab98521..426659c 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -98,6 +98,7 @@ enum
     SUB_TYPE_UNKNOWN = -1,
     SUB_TYPE_MICRODVD,
     SUB_TYPE_SUBRIP,
+    SUB_TYPE_SUBRIP_DOT, /* Invalid SubRip file (dot instead of comma) */
     SUB_TYPE_SSA1,
     SUB_TYPE_SSA2_4,
     SUB_TYPE_ASS,
@@ -172,6 +173,7 @@ struct demux_sys_t
 
 static int  ParseMicroDvd   ( demux_t *, subtitle_t *, int );
 static int  ParseSubRip     ( demux_t *, subtitle_t *, int );
+static int  ParseSubRipDot  ( demux_t *, subtitle_t *, int );
 static int  ParseSubViewer  ( demux_t *, subtitle_t *, int );
 static int  ParseSSA        ( demux_t *, subtitle_t *, int );
 static int  ParseVplayer    ( demux_t *, subtitle_t *, int );
@@ -197,6 +199,7 @@ static const struct
 {
     { "microdvd",   SUB_TYPE_MICRODVD,    "MicroDVD",    ParseMicroDvd },
     { "subrip",     SUB_TYPE_SUBRIP,      "SubRIP",      ParseSubRip },
+    { "subrip-dot", SUB_TYPE_SUBRIP_DOT,  "SubRIP(Dot)", ParseSubRipDot },
     { "subviewer",  SUB_TYPE_SUBVIEWER,   "SubViewer",   ParseSubViewer },
     { "ssa1",       SUB_TYPE_SSA1,        "SSA-1",       ParseSSA },
     { "ssa2-4",     SUB_TYPE_SSA2_4,      "SSA-2/3/4",   ParseSSA },
@@ -329,6 +332,15 @@ static int Open ( vlc_object_t *p_this )
                 p_sys->i_type = SUB_TYPE_SUBRIP;
                 break;
             }
+            else if( sscanf( s,
+                             "%d:%d:%d.%d --> %d:%d:%d.%d",
+                             &i_dummy,&i_dummy,&i_dummy,&i_dummy,
+                             &i_dummy,&i_dummy,&i_dummy,&i_dummy ) == 8 )
+            {
+                msg_Err( p_demux, "Detected invalid SubRip file, playing anyway" );
+                p_sys->i_type = SUB_TYPE_SUBRIP_DOT;
+                break;
+            }
             else if( !strncasecmp( s, "!: This is a Sub Station Alpha v1", 33 ) )
             {
                 p_sys->i_type = SUB_TYPE_SSA1;
@@ -947,6 +959,17 @@ static int  ParseSubRip( demux_t *p_demux, subtitle_t *p_subtitle,
                                  "%d:%d:%d,%d --> %d:%d:%d,%d",
                                  false );
 }
+/* ParseSubRipDot
+ * Special version for buggy file using '.' instead of ','
+ */
+static int  ParseSubRipDot( demux_t *p_demux, subtitle_t *p_subtitle,
+                            int i_idx )
+{
+    VLC_UNUSED( i_idx );
+    return ParseSubRipSubViewer( p_demux, p_subtitle,
+                                 "%d:%d:%d.%d --> %d:%d:%d.%d",
+                                 false );
+}
 /* ParseSubViewer
  */
 static int  ParseSubViewer( demux_t *p_demux, subtitle_t *p_subtitle,




More information about the vlc-devel mailing list