]> git.sesse.net Git - vlc/blobdiff - modules/codec/subtitles/subsusf.c
Removed fake decoder.
[vlc] / modules / codec / subtitles / subsusf.c
index 717f8da1272fa517d270a0d7c036781d8f531ff7..0c5b773553edd806f898742257ff343b9488ecff 100644 (file)
@@ -40,8 +40,8 @@ static int           ParseImageAttachments( decoder_t *p_dec );
 
 static subpicture_t        *ParseText     ( decoder_t *, block_t * );
 static void                 ParseUSFHeader( decoder_t * );
-static subpicture_region_t *ParseUSFString( decoder_t *, char *, subpicture_t * );
-static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec, subpicture_t *p_spu, const char *psz_filename, int i_transparent_color );
+static subpicture_region_t *ParseUSFString( decoder_t *, char * );
+static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec, const char *psz_filename, int i_transparent_color );
 
 /*****************************************************************************
  * Module descriptor.
@@ -68,7 +68,7 @@ static int OpenDecoder( vlc_object_t *p_this )
     decoder_t     *p_dec = (decoder_t*)p_this;
     decoder_sys_t *p_sys;
 
-    if( p_dec->fmt_in.i_codec != VLC_FOURCC('u','s','f',' ') )
+    if( p_dec->fmt_in.i_codec != VLC_CODEC_USF )
         return VLC_EGENERIC;
 
     /* Allocate the memory needed to store the decoder's structure */
@@ -182,7 +182,7 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
     char *psz_subtitle = NULL;
 
     /* We cannot display a subpicture with no date */
-    if( p_block->i_pts == 0 )
+    if( p_block->i_pts <= VLC_TS_INVALID )
     {
         msg_Warn( p_dec, "subtitle without a date" );
         return NULL;
@@ -211,7 +211,7 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
     }
 
     /* Create the subpicture unit */
-    p_spu = decoder_NewSubpicture( p_dec );
+    p_spu = decoder_NewSubpicture( p_dec, NULL );
     if( !p_spu )
     {
         msg_Warn( p_dec, "can't get spu buffer" );
@@ -220,7 +220,7 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
     }
 
     /* Decode USF strings */
-    p_spu->p_region = ParseUSFString( p_dec, psz_subtitle, p_spu );
+    p_spu->p_region = ParseUSFString( p_dec, psz_subtitle );
 
     p_spu->i_start = p_block->i_pts;
     p_spu->i_stop = p_block->i_pts + p_block->i_length;
@@ -372,7 +372,6 @@ static void SetupPositions( subpicture_region_t *p_region, char *psz_subtitle )
 }
 
 static subpicture_region_t *CreateTextRegion( decoder_t *p_dec,
-                                              subpicture_t *p_spu,
                                               char *psz_subtitle,
                                               int i_len,
                                               int i_sys_align )
@@ -383,8 +382,7 @@ static subpicture_region_t *CreateTextRegion( decoder_t *p_dec,
 
     /* Create a new subpicture region */
     memset( &fmt, 0, sizeof(video_format_t) );
-    fmt.i_chroma = VLC_FOURCC('T','E','X','T');
-    fmt.i_aspect = 0;
+    fmt.i_chroma = VLC_CODEC_TEXT;
     fmt.i_width = fmt.i_height = 0;
     fmt.i_x_offset = fmt.i_y_offset = 0;
     p_text_region = subpicture_region_New( &fmt );
@@ -488,7 +486,7 @@ static int ParseImageAttachments( decoder_t *p_dec )
                     memset( &fmt_out, 0, sizeof( video_format_t));
 
                     fmt_in.i_chroma  = type;
-                    fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
+                    fmt_out.i_chroma = VLC_CODEC_YUVA;
 
                     /* Find a suitable decoder module */
                     if( module_exists( "sdl_image" ) )
@@ -830,11 +828,9 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
 
 
 static subpicture_region_t *ParseUSFString( decoder_t *p_dec,
-                                            char *psz_subtitle,
-                                            subpicture_t *p_spu_in )
+                                            char *psz_subtitle )
 {
     decoder_sys_t        *p_sys = p_dec->p_sys;
-    subpicture_t         *p_spu = p_spu_in;
     subpicture_region_t  *p_region_first = NULL;
     subpicture_region_t  *p_region_upto  = p_region_first;
 
@@ -856,7 +852,6 @@ static subpicture_region_t *ParseUSFString( decoder_t *p_dec,
                     psz_end += strcspn( psz_end, ">" ) + 1;
 
                     p_text_region = CreateTextRegion( p_dec,
-                                                      p_spu,
                                                       psz_subtitle,
                                                       psz_end - psz_subtitle,
                                                       p_sys->i_align );
@@ -895,7 +890,6 @@ static subpicture_region_t *ParseUSFString( decoder_t *p_dec,
                     psz_end += strcspn( psz_end, ">" ) + 1;
 
                     p_text_region = CreateTextRegion( p_dec,
-                                                      p_spu,
                                                       psz_subtitle,
                                                       psz_end - psz_subtitle,
                                                       p_sys->i_align );
@@ -949,7 +943,7 @@ static subpicture_region_t *ParseUSFString( decoder_t *p_dec,
                     char *psz_filename = strndup( &psz_content[1], psz_end - &psz_content[1] );
                     if( psz_filename )
                     {
-                        p_image_region = LoadEmbeddedImage( p_dec, p_spu,
+                        p_image_region = LoadEmbeddedImage( p_dec,
                                             psz_filename, i_transparent );
                         free( psz_filename );
                     }
@@ -1090,7 +1084,9 @@ static char *StripTags( char *psz_subtitle )
         psz_subtitle++;
     }
     *psz_text = '\0';
-    psz_text_start = realloc( psz_text_start, strlen( psz_text_start ) + 1 );
+
+    char *psz = realloc( psz_text_start, strlen( psz_text_start ) + 1 );
+    if( psz ) psz_text_start = psz;
 
     return psz_text_start;
 }
@@ -1138,17 +1134,15 @@ static char *CreatePlainText( char *psz_subtitle )
  * download and resize image located at psz_url
  ***************************************************************************/
 static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec,
-                                               subpicture_t *p_spu,
                                                const char *psz_filename,
                                                int i_transparent_color )
 {
     decoder_sys_t         *p_sys = p_dec->p_sys;
     subpicture_region_t   *p_region;
     video_format_t         fmt_out;
-    int                    k;
     picture_t             *p_pic = NULL;
 
-    for( k = 0; k < p_sys->i_images; k++ )
+    for( int k = 0; k < p_sys->i_images; k++ )
     {
         if( p_sys->pp_images &&
             !strcmp( p_sys->pp_images[k]->psz_filename, psz_filename ) )
@@ -1167,8 +1161,7 @@ static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec,
     /* Display the feed's image */
     memset( &fmt_out, 0, sizeof( video_format_t));
 
-    fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
-    fmt_out.i_aspect = VOUT_ASPECT_FACTOR;
+    fmt_out.i_chroma = VLC_CODEC_YUVA;
     fmt_out.i_sar_num = fmt_out.i_sar_den = 1;
     fmt_out.i_width =
         fmt_out.i_visible_width = p_pic->format.i_visible_width;
@@ -1181,7 +1174,7 @@ static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec,
         msg_Err( p_dec, "cannot allocate SPU region" );
         return NULL;
     }
-    assert( p_pic->format.i_chroma == VLC_FOURCC('Y','U','V','A') );
+    assert( p_pic->format.i_chroma == VLC_CODEC_YUVA );
     /* FIXME the copy is probably not needed anymore */
     picture_CopyPixels( p_region->p_picture, p_pic );
 
@@ -1201,7 +1194,7 @@ static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec,
         int i_u =   ( ( -38 * i_r -  74 * i_g + 112 * i_b + 128 ) >> 8 ) + 128 ;
         int i_v =   ( ( 112 * i_r -  94 * i_g -  18 * i_b + 128 ) >> 8 ) + 128 ;
 
-        assert( p_region->fmt.i_chroma == VLC_FOURCC('Y','U','V','A') );
+        assert( p_region->fmt.i_chroma == VLC_CODEC_YUVA );
         for( unsigned int y = 0; y < p_region->fmt.i_height; y++ )
         {
             for( unsigned int x = 0; x < p_region->fmt.i_width; x++ )