X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fmisc%2Fsvg.c;h=7c5ad64b8912b575280e0413673cea83d72c4e09;hb=158be7e57ecb0967c9de12022a478690bf39f84f;hp=afaa6f7ea182dac4876c3b66b1c1695f0d87b571;hpb=a7317a9af7b0a8a0e6581444b13ce6b06157b61c;p=vlc diff --git a/modules/misc/svg.c b/modules/misc/svg.c index afaa6f7ea1..7c5ad64b89 100644 --- a/modules/misc/svg.c +++ b/modules/misc/svg.c @@ -31,15 +31,13 @@ #include #include -#include +#include #include #include #include #include -#ifdef HAVE_SYS_TYPES_H -# include -#endif +#include #ifdef HAVE_UNISTD_H # include @@ -72,12 +70,12 @@ static char *svg_GetTemplate( vlc_object_t *p_this ); "for automatic string conversion" ) vlc_module_begin () - set_category( CAT_INPUT) - set_category( SUBCAT_INPUT_SCODEC ) - set_capability( "text renderer", 99 ) - add_shortcut( "svg" ) - add_string( "svg-template-file", "", NULL, TEMPLATE_TEXT, TEMPLATE_LONGTEXT, true ) - set_callbacks( Create, Destroy ) + set_category( CAT_INPUT ) + set_category( SUBCAT_INPUT_SCODEC ) + set_capability( "text renderer", 99 ) + add_shortcut( "svg" ) + add_string( "svg-template-file", "", NULL, TEMPLATE_TEXT, TEMPLATE_LONGTEXT, true ) + set_callbacks( Create, Destroy ) vlc_module_end () /** @@ -115,7 +113,6 @@ struct filter_sys_t /* Default size for rendering. Initialized to the output size. */ int i_width; int i_height; - vlc_mutex_t *lock; }; /***************************************************************************** @@ -161,7 +158,7 @@ static char *svg_GetTemplate( vlc_object_t *p_this ) char *psz_template; FILE *file; - psz_filename = config_GetPsz( p_filter, "svg-template-file" ); + psz_filename = var_InheritString( p_filter, "svg-template-file" ); if( !psz_filename || (psz_filename[0] == 0) ) { /* No filename. Use a default value. */ @@ -170,7 +167,7 @@ static char *svg_GetTemplate( vlc_object_t *p_this ) else { /* Read the template */ - file = utf8_fopen( psz_filename, "rt" ); + file = vlc_fopen( psz_filename, "rt" ); if( !file ) { msg_Warn( p_this, "SVG template file %s does not exist.", @@ -198,14 +195,13 @@ static char *svg_GetTemplate( vlc_object_t *p_this ) msg_Dbg( p_this, "reading %ld bytes from template %s", (unsigned long)s.st_size, psz_filename ); - psz_template = malloc( s.st_size + 42 ); + psz_template = calloc( 1, s.st_size + 42 ); if( !psz_template ) { fclose( file ); free( psz_filename ); return NULL; } - memset( psz_template, 0, s.st_size + 1 ); if(! fread( psz_template, s.st_size, 1, file ) ) { msg_Dbg( p_this, "No data read from template." ); @@ -278,13 +274,14 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region, /* Create a new subpicture region */ memset( &fmt, 0, sizeof( video_format_t ) ); - fmt.i_chroma = VLC_FOURCC( 'Y','U','V','A' ); - fmt.i_aspect = VOUT_ASPECT_FACTOR; + fmt.i_chroma = VLC_CODEC_YUVA; fmt.i_width = fmt.i_visible_width = i_width; fmt.i_height = fmt.i_visible_height = i_height; fmt.i_x_offset = fmt.i_y_offset = 0; + fmt.i_sar_num = 1; + fmt.i_sar_den = 1; - p_region->p_picture = picture_New( fmt.i_chroma, fmt.i_width, fmt.i_height, fmt.i_aspect ); + p_region->p_picture = picture_NewFromFormat( &fmt ); if( !p_region->p_picture ) return VLC_EGENERIC; p_region->fmt = fmt; @@ -405,7 +402,7 @@ static void svg_RenderPicture( filter_t *p_filter, if( !p_handle ) { - msg_Err( p_filter, "Error creating SVG reader: %s", error->message ); + msg_Err( p_filter, "Error creating SVG reader" ); return; } @@ -415,14 +412,14 @@ static void svg_RenderPicture( filter_t *p_filter, ( guchar* )p_svg->psz_text, strlen( p_svg->psz_text ), &error ) ) { - msg_Err( p_filter, "error while rendering SVG: %s\n", error->message ); + msg_Err( p_filter, "error while rendering SVG: %s", error->message ); g_object_unref( G_OBJECT( p_handle ) ); return; } if( ! rsvg_handle_close( p_handle, &error ) ) { - msg_Err( p_filter, "error while rendering SVG (close): %s\n", error->message ); + msg_Err( p_filter, "error while rendering SVG (close): %s", error->message ); g_object_unref( G_OBJECT( p_handle ) ); return; } @@ -445,7 +442,7 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out, psz_string = p_region_in->psz_text; if( !psz_string || !*psz_string ) return VLC_EGENERIC; - p_svg = ( svg_rendition_t * )malloc( sizeof( svg_rendition_t ) ); + p_svg = malloc( sizeof( svg_rendition_t ) ); if( !p_svg ) return VLC_ENOMEM; @@ -471,18 +468,17 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out, int length; char* psz_template = p_sys->psz_template; length = strlen( psz_string ) + strlen( psz_template ) + 42; - p_svg->psz_text = malloc( length + 1 ); + p_svg->psz_text = calloc( 1, length + 1 ); if( !p_svg->psz_text ) { free( p_svg ); return VLC_ENOMEM; } - memset( p_svg->psz_text, 0, length + 1 ); snprintf( p_svg->psz_text, length, psz_template, psz_string ); } p_svg->i_width = p_sys->i_width; p_svg->i_height = p_sys->i_height; - p_svg->i_chroma = VLC_FOURCC( 'Y','U','V','A' ); + p_svg->i_chroma = VLC_CODEC_YUVA; /* Render the SVG. The input data is stored in the p_string structure,