]> git.sesse.net Git - vlc/blobdiff - modules/codec/subtitles/subsusf.c
Fixed subtitle duration when rate != default.
[vlc] / modules / codec / subtitles / subsusf.c
index 88e1569dde880c277e62330eb856cfc3c6752512..6e074d712d0ca362fd15a06ade8cbb24201ced1c 100644 (file)
@@ -48,6 +48,8 @@ static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec, subpicture_t *p
 
 vlc_module_begin();
     set_capability( "decoder", 40 );
+    set_shortname( N_("USFSubs"));
+    set_description( N_("USF subtitles decoder") );
     set_callbacks( OpenDecoder, CloseDecoder );
     set_category( CAT_INPUT );
     set_subcategory( SUBCAT_INPUT_SCODEC );
@@ -77,7 +79,6 @@ static int OpenDecoder( vlc_object_t *p_this )
     if( ( p_dec->p_sys = p_sys =
           (decoder_sys_t *)calloc(1, sizeof(decoder_sys_t)) ) == NULL )
     {
-        msg_Err( p_dec, "out of memory" );
         return VLC_ENOMEM;
     }
 
@@ -117,13 +118,19 @@ static int OpenDecoder( vlc_object_t *p_this )
  ****************************************************************************/
 static subpicture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 {
-    subpicture_t *p_spu = NULL;
+    subpicture_t *p_spu;
+    block_t *p_block;
+
+    if( !pp_block || *pp_block == NULL )
+        return NULL;
 
-    if( !pp_block || *pp_block == NULL ) return NULL;
+    p_block = *pp_block;
+    if( p_block->i_rate != 0 )
+        p_block->i_length = p_block->i_length * p_block->i_rate / INPUT_RATE_DEFAULT;
 
-    p_spu = ParseText( p_dec, *pp_block );
+    p_spu = ParseText( p_dec, p_block );
 
-    block_Release( *pp_block );
+    block_Release( p_block );
     *pp_block = NULL;
 
     return p_spu;
@@ -160,7 +167,7 @@ static void CloseDecoder( vlc_object_t *p_this )
                 continue;
 
             if( p_sys->pp_images[i]->p_pic )
-                p_sys->pp_images[i]->p_pic->pf_release( p_sys->pp_images[i]->p_pic );
+                picture_Release( p_sys->pp_images[i]->p_pic );
             free( p_sys->pp_images[i]->psz_filename );
 
             free( p_sys->pp_images[i] );
@@ -398,7 +405,6 @@ static subpicture_region_t *CreateTextRegion( decoder_t *p_dec,
         p_text_region->psz_html = strndup( psz_subtitle, i_len );
         if( ! p_text_region->psz_html )
         {
-            msg_Err( p_dec, "out of memory" );
             p_spu->pf_destroy_region( VLC_OBJECT(p_dec), p_text_region );
             return NULL;
         }
@@ -647,7 +653,6 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
                     p_style = calloc( 1, sizeof(ssa_style_t) );
                     if( ! p_style )
                     {
-                        msg_Err( p_dec, "out of memory" );
                         free( psz_node );
                         break;
                     }