[vlc-devel] commit: Added support for alignment in subsdec (subrip). (Laurent Aimar )

git version control git at videolan.org
Wed Sep 10 00:22:32 CEST 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Wed Sep 10 00:19:34 2008 +0200| [db9ea591bed954daeb421153b72b830b90a7a00c] | committer: Laurent Aimar 

Added support for alignment in subsdec (subrip).

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

 modules/codec/subtitles/subsdec.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/modules/codec/subtitles/subsdec.c b/modules/codec/subtitles/subsdec.c
index 37ae32f..724b783 100644
--- a/modules/codec/subtitles/subsdec.c
+++ b/modules/codec/subtitles/subsdec.c
@@ -43,7 +43,7 @@ static void CloseDecoder  ( vlc_object_t * );
 static subpicture_t   *DecodeBlock   ( decoder_t *, block_t ** );
 static subpicture_t   *ParseText     ( decoder_t *, block_t * );
 static char           *StripTags      ( char * );
-static char           *CreateHtmlSubtitle ( char * );
+static char           *CreateHtmlSubtitle( int *pi_align, char * );
 
 
 /*****************************************************************************
@@ -437,7 +437,7 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
         p_spu->p_region->psz_text = StripTags( psz_subtitle );
         if( var_CreateGetBool( p_dec, "subsdec-formatted" ) )
         {
-            p_spu->p_region->psz_html = CreateHtmlSubtitle( psz_subtitle );
+            p_spu->p_region->psz_html = CreateHtmlSubtitle( &p_spu->p_region->i_align, psz_subtitle );
         }
 
         p_spu->i_start = p_block->i_pts;
@@ -595,7 +595,7 @@ static void HtmlCopy( char **ppsz_html, char **ppsz_subtitle, const char *psz_te
     *ppsz_subtitle += strlen(psz_text);
 }
 
-static char *CreateHtmlSubtitle( char *psz_subtitle )
+static char *CreateHtmlSubtitle( int *pi_align, char *psz_subtitle )
 {
     char   *psz_tag = malloc( ( strlen( psz_subtitle ) / 3 ) + 1 );
     if( !psz_tag ) return NULL;
@@ -615,6 +615,19 @@ static char *CreateHtmlSubtitle( char *psz_subtitle )
     strcpy( psz_html, "<text>" );
     psz_html += 6;
 
+    /* Check for forced alignment */
+    if( !strncmp( psz_subtitle, "{\\an", 4 ) && psz_subtitle[4] >= '1' && psz_subtitle[4] <= '9' && psz_subtitle[5] == '}' )
+    {
+        static const pi_vertical[3] = { SUBPICTURE_ALIGN_BOTTOM, 0, SUBPICTURE_ALIGN_TOP };
+        static const pi_horizontal[3] = { SUBPICTURE_ALIGN_LEFT, 0, SUBPICTURE_ALIGN_RIGHT };
+        const int i_id = psz_subtitle[4] - '1';
+
+        *pi_align = pi_vertical[i_id/3] | pi_horizontal[i_id%3];
+
+        psz_subtitle += 6;
+    }
+
+    /* */
     while( *psz_subtitle )
     {
         if( *psz_subtitle == '\n' )




More information about the vlc-devel mailing list