]> git.sesse.net Git - vlc/commitdiff
Parsing of Phoenix Subtitles.
authorJean-Baptiste Kempf <jb@videolan.org>
Fri, 2 May 2008 07:38:15 +0000 (00:38 -0700)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 2 May 2008 07:38:15 +0000 (00:38 -0700)
Almost unused subtitle. No idea though if FPS or 1/10th of sec, Annodex and MPlayer disagree...

modules/demux/subtitle.c

index 38fecc27bc33e6376eafcc0693b132d1b8fab842..038006d9c1a8aac99e4a9c26f4ada4930886e054 100644 (file)
@@ -100,7 +100,8 @@ enum
     SUB_TYPE_SUBVIEWER,
     SUB_TYPE_DVDSUBTITLE,
     SUB_TYPE_MPL2,
-    SUB_TYPE_AQT
+    SUB_TYPE_AQT,
+    SUB_TYPE_PJS
 };
 
 typedef struct
@@ -147,6 +148,7 @@ static int  ParseSami       ( demux_t *, subtitle_t *, int );
 static int  ParseDVDSubtitle( demux_t *, subtitle_t *, int );
 static int  ParseMPL2       ( demux_t *, subtitle_t *, int );
 static int  ParseAQT        ( demux_t *, subtitle_t *, int );
+static int  ParsePJS        ( demux_t *, subtitle_t *, int );
 
 static struct
 {
@@ -167,6 +169,7 @@ static struct
     { "dvdsubtitle",SUB_TYPE_DVDSUBTITLE, "DVDSubtitle", ParseDVDSubtitle },
     { "mpl2",       SUB_TYPE_MPL2,        "MPL2",        ParseMPL2 },
     { "aqt",        SUB_TYPE_AQT,         "AQTitle",     ParseAQT },
+    { "pjs",        SUB_TYPE_PJS,         "PhoenixSub",  ParsePJS },
     { NULL,         SUB_TYPE_UNKNOWN,     "Unknown",     NULL }
 };
 
@@ -320,10 +323,15 @@ static int Open ( vlc_object_t *p_this )
             {
                 p_sys->i_type = SUB_TYPE_MPL2;
                 break;
-            }else if( sscanf (s, "-->> %d", &i_dummy) == 1 )
+            }
+            else if( sscanf( s, "-->> %d", &i_dummy) == 1 )
             {
                 p_sys->i_type = SUB_TYPE_AQT;
             }
+            else if( sscanf( s, "%d,%d,", &i_dummy, &i_dummy ) == 2 )
+            {
+                p_sys->i_type = SUB_TYPE_PJS;
+            }
 
             free( s );
             s = NULL;
@@ -1216,9 +1224,9 @@ static int ParseMPL2( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
         free( psz_text );
     }
 
-    /* replace | by \n */
     for( i = 0; psz_text[i] != '\0'; )
     {
+        /* replace | by \n */
         if( psz_text[i] == '|' )
             psz_text[i] = '\n';
 
@@ -1284,3 +1292,34 @@ static int ParseAQT( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
     return VLC_SUCCESS;
 }
 
+static int ParsePJS( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
+{
+    demux_sys_t *p_sys = p_demux->p_sys;
+    text_t      *txt = &p_sys->txt;
+    char *psz_text;
+
+    for( ;; )
+    {
+        const char *s = TextGetLine( txt );
+        int t1, t2;
+
+        if( !s )
+            return VLC_EGENERIC;
+
+        psz_text = malloc( strlen(s) + 1 );
+
+        /* Data Lines */
+        if( sscanf (s, "%d,%d,%[^\n\r]", &t1, &t2, psz_text ) == 3 )
+        {
+            /* 1/10th of second ? Frame based ? FIXME */
+            p_subtitle->i_start = 10 * t1;
+            p_subtitle->i_stop = 10 * t2;
+
+            break;
+        }
+        free( psz_text );
+    }
+    p_subtitle->psz_text = psz_text;
+    return VLC_SUCCESS;
+}
+