[vlc-commits] Used decoder_NewSubpictureText to render SRT subtitles.

Laurent Aimar git at videolan.org
Wed Apr 27 21:10:50 CEST 2011


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Wed Apr 27 20:53:25 2011 +0200| [093db7f8bead81dcb98733fd6d7f180f558c1ed9] | committer: Laurent Aimar

Used decoder_NewSubpictureText to render SRT subtitles.

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

 modules/codec/Modules.am |    2 +-
 modules/codec/subsdec.c  |   42 +++++++++++-------------------------------
 2 files changed, 12 insertions(+), 32 deletions(-)

diff --git a/modules/codec/Modules.am b/modules/codec/Modules.am
index 365af78..74d4caf 100644
--- a/modules/codec/Modules.am
+++ b/modules/codec/Modules.am
@@ -33,7 +33,7 @@ SOURCES_kate = kate.c
 SOURCES_schroedinger = schroedinger.c
 SOURCES_libass = libass.c
 SOURCES_aes3 = aes3.c
-SOURCES_subsdec = subsdec.c
+SOURCES_subsdec = subsdec.c substext.h
 SOURCES_subsusf = subsusf.c
 SOURCES_t140 = t140.c
 SOURCES_crystalhd = crystalhd.c
diff --git a/modules/codec/subsdec.c b/modules/codec/subsdec.c
index ba7d2f1..48abf5e 100644
--- a/modules/codec/subsdec.c
+++ b/modules/codec/subsdec.c
@@ -36,6 +36,8 @@
 #include <vlc_codec.h>
 #include <vlc_charset.h>
 
+#include "substext.h"
+
 /*****************************************************************************
  * Module descriptor.
  *****************************************************************************/
@@ -370,7 +372,6 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
     decoder_sys_t *p_sys = p_dec->p_sys;
     subpicture_t *p_spu = NULL;
     char *psz_subtitle = NULL;
-    video_format_t fmt;
 
     /* We cannot display a subpicture with no date */
     if( p_block->i_pts <= VLC_TS_INVALID )
@@ -449,45 +450,24 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
     }
 
     /* Create the subpicture unit */
-    p_spu = decoder_NewSubpicture( p_dec, NULL );
+    p_spu = decoder_NewSubpictureText( p_dec );
     if( !p_spu )
     {
-        msg_Warn( p_dec, "can't get spu buffer" );
-        free( psz_subtitle );
-        return NULL;
-    }
-
-    /* Create a new subpicture region */
-    memset( &fmt, 0, sizeof(video_format_t) );
-    fmt.i_chroma = VLC_CODEC_TEXT;
-    fmt.i_width = fmt.i_height = 0;
-    fmt.i_x_offset = fmt.i_y_offset = 0;
-    p_spu->p_region = subpicture_region_New( &fmt );
-    if( !p_spu->p_region )
-    {
-        msg_Err( p_dec, "cannot allocate SPU region" );
         free( psz_subtitle );
-        decoder_DeleteSubpicture( p_dec, p_spu );
         return NULL;
     }
+    p_spu->i_start    = p_block->i_pts;
+    p_spu->i_stop     = p_block->i_pts + p_block->i_length;
+    p_spu->b_ephemer  = (p_block->i_length == 0);
+    p_spu->b_absolute = false;
 
-    /* Normal text subs, easy markup */
-    p_spu->p_region->i_align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align;
-    p_spu->p_region->i_x = p_sys->i_align ? 20 : 0;
-    p_spu->p_region->i_y = 10;
-
-    /* Remove formatting from string */
+    subpicture_updater_sys_t *p_spu_sys = p_spu->updater.p_sys;
 
-    p_spu->p_region->psz_text = StripTags( psz_subtitle );
+    p_spu_sys->align = SUBPICTURE_ALIGN_BOTTOM | p_sys->i_align;
+    p_spu_sys->text  = StripTags( psz_subtitle );
     if( var_InheritBool( p_dec, "subsdec-formatted" ) )
-    {
-        p_spu->p_region->psz_html = CreateHtmlSubtitle( &p_spu->p_region->i_align, psz_subtitle );
-    }
+        p_spu_sys->html = CreateHtmlSubtitle( &p_spu_sys->align, psz_subtitle );
 
-    p_spu->i_start = p_block->i_pts;
-    p_spu->i_stop = p_block->i_pts + p_block->i_length;
-    p_spu->b_ephemer = (p_block->i_length == 0);
-    p_spu->b_absolute = false;
     free( psz_subtitle );
 
     return p_spu;



More information about the vlc-commits mailing list