]> git.sesse.net Git - vlc/commitdiff
* modules/codec/dvbsub.c: don't render empty subtitles when we receive subtitles...
authorGildas Bazin <gbazin@videolan.org>
Thu, 27 Jan 2005 17:05:25 +0000 (17:05 +0000)
committerGildas Bazin <gbazin@videolan.org>
Thu, 27 Jan 2005 17:05:25 +0000 (17:05 +0000)
modules/codec/dvbsub.c

index 69c856f2c9e4aab4ea376f7d5fa285a7750cea58..93f6e25a4225cdb470162d26c09313f8bc48101b 100644 (file)
@@ -158,6 +158,7 @@ struct decoder_sys_t
     int             i_ancillary_id;
     mtime_t         i_pts;
 
+    vlc_bool_t      b_page;
     dvbsub_page_t   *p_page;
     dvbsub_region_t *p_regions;
     dvbsub_clut_t   *p_cluts;
@@ -229,6 +230,7 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_pts          = 0;
     p_sys->i_id           = p_dec->fmt_in.subs.dvb.i_id & 0xFFFF;
     p_sys->i_ancillary_id = p_dec->fmt_in.subs.dvb.i_id >> 16;
+
     p_sys->p_regions      = NULL;
     p_sys->p_cluts        = NULL;
     p_sys->p_page         = NULL;
@@ -297,6 +299,7 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
     msg_Dbg( p_dec, "subtitle packet received: "I64Fd, p_sys->i_pts );
 #endif
 
+    p_sys->b_page = VLC_FALSE;
     while( bs_show( &p_sys->bs, 8 ) == 0x0f ) /* Sync byte */
     {
         decode_segment( p_dec, &p_sys->bs );
@@ -310,7 +313,7 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
     }
 
     /* Check if the page is to be displayed */
-    if( p_sys->p_page ) p_spu = render( p_dec );
+    if( p_sys->p_page && p_sys->b_page ) p_spu = render( p_dec );
 
     block_Release( p_block );
 
@@ -411,6 +414,17 @@ static void decode_segment( decoder_t *p_dec, bs_t *s )
         return;
     }
 
+    if( p_sys->i_ancillary_id != p_sys->i_id &&
+        i_type == DVBSUB_ST_PAGE_COMPOSITION &&
+        i_page_id == p_sys->i_ancillary_id )
+    {
+#ifdef DEBUG_DVBSUB
+        msg_Dbg( p_dec, "skipped invalid ancillary subtitle packet" );
+#endif
+        bs_skip( s,  8 * ( 2 + i_size ) );
+        return;
+    }
+
 #ifdef DEBUG_DVBSUB
     if( i_page_id == p_sys->i_id )
         msg_Dbg( p_dec, "segment (id: %i)", i_page_id );
@@ -643,6 +657,7 @@ static void decode_page_composition( decoder_t *p_dec, bs_t *s )
 
     p_sys->p_page->i_version = i_version;
     p_sys->p_page->i_timeout = i_timeout;
+    p_sys->b_page = VLC_TRUE;
 
     /* Number of regions */
     p_sys->p_page->i_region_defs = (i_segment_length - 2) / 6;