[vlc-devel] commit: Parsing of Phoenix Subtitles. (Jean-Baptiste Kempf )

git version control git at videolan.org
Fri May 2 09:37:06 CEST 2008


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri May  2 00:38:15 2008 -0700| [971d6b76b694c4ba78f8d94370e877c94545179f]

Parsing of Phoenix Subtitles.
Almost unused subtitle. No idea though if FPS or 1/10th of sec, Annodex and MPlayer disagree...

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

 modules/demux/subtitle.c |   45 ++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c
index 38fecc2..038006d 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -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;
+}
+




More information about the vlc-devel mailing list