X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Ffbosd.c;h=8e63a9ed9be3bd0db191907b66c9ab1912ccc602;hb=8bd5461783c149200b3b2a7da15e02d14a612275;hp=3d4f8f4a52f181501132326a3d9793d6568ae3bb;hpb=62829b3b5eac81d4db269c6b1be7631e6a1f9beb;p=vlc diff --git a/modules/gui/fbosd.c b/modules/gui/fbosd.c index 3d4f8f4a52..8e63a9ed9b 100644 --- a/modules/gui/fbosd.c +++ b/modules/gui/fbosd.c @@ -30,6 +30,7 @@ #endif #include +#include #include #include /* free() */ @@ -188,12 +189,9 @@ vlc_module_begin(); add_string( "fbosd-text", NULL, NULL, FBOSD_TEXT, FBOSD_LONGTEXT, true ); -#if defined(FBOSD_BLENDING) add_integer_with_range( "fbosd-alpha", 255, 0, 255, NULL, ALPHA_TEXT, ALPHA_LONGTEXT, true ); -#endif - set_section( N_("Position"), NULL ); add_integer( "fbosd-x", 0, NULL, POSX_TEXT, POSX_LONGTEXT, false ); @@ -240,7 +238,7 @@ struct fbosd_render_t char *psz_string; /* Position */ - bool b_absolute; + bool b_absolute; int i_x; int i_y; int i_pos; @@ -310,17 +308,13 @@ static int Create( vlc_object_t *p_this ) /* Allocate instance and initialize some members */ p_intf->p_sys = p_sys = malloc( sizeof( intf_sys_t ) ); if( !p_intf->p_sys ) - { - msg_Err( p_intf, "out of memory" ); return VLC_ENOMEM; - }; memset( p_sys, 0, sizeof(intf_sys_t) ); p_sys->p_style = malloc( sizeof( text_style_t ) ); if( !p_sys->p_style ) { free( p_intf->p_sys ); - msg_Err( p_intf, "out of memory" ); return VLC_ENOMEM; } vlc_memcpy( p_sys->p_style, &default_text_style, sizeof( text_style_t ) ); @@ -332,16 +326,12 @@ static int Create( vlc_object_t *p_this ) { free( p_intf->p_sys->p_style ); free( p_intf->p_sys ); - msg_Err( p_intf, "out of memory" ); return VLC_ENOMEM; } -#if defined(FBOSD_BLENDING) p_sys->i_alpha = var_CreateGetIntegerCommand( p_intf, "fbosd-alpha" ); var_AddCallback( p_intf, "fbosd-alpha", OverlayCallback, NULL ); -#else - p_sys->i_alpha = 255; -#endif + p_sys->i_aspect = -1; psz_aspect = var_CreateGetNonEmptyString( p_intf, "fbosd-aspect-ratio" ); @@ -484,10 +474,8 @@ static void Destroy( vlc_object_t *p_this ) p_sys->b_render = false; p_sys->b_clear = false; -#if defined(FBOSD_BLENDING) var_DelCallback( p_intf, "fbosd-alpha", OverlayCallback, NULL ); var_Destroy( p_intf, "fbosd-alpha" ); -#endif var_DelCallback( p_intf, "fbosd-x", OverlayCallback, NULL ); var_DelCallback( p_intf, "fbosd-y", OverlayCallback, NULL ); @@ -679,6 +667,7 @@ static void DeAllocatePicture( vlc_object_t *p_this, picture_t *p_pic, { free( p_pic->p_data_orig ); if( p_pic->pf_release ) p_pic->pf_release( p_pic ); + else free( p_pic ); } if( p_fmt ) { @@ -706,9 +695,10 @@ static void SetOverlayTransparency( intf_thread_t *p_intf, { msg_Dbg( p_intf, "Make overlay %s", b_transparent ? "transparent" : "opaque" ); - memset( p_sys->p_overlay->p[0].p_pixels, 0x00, i_page_size ); if( b_transparent ) memset( p_sys->p_overlay->p[0].p_pixels, 0xFF, i_page_size ); + else + memset( p_sys->p_overlay->p[0].p_pixels, 0x00, i_page_size ); } } @@ -783,9 +773,9 @@ static int InvertAlpha( intf_thread_t *p_intf, picture_t **p_pic, video_format_t for( ; p_begin < p_end; p_begin += i_skip ) { - uint8_t i_opacity; + uint8_t i_opacity = 0; - if( i_opacity != 0xFF ) + if( *p_begin != 0xFF ) i_opacity = 255 - *p_begin; *p_begin = i_opacity; } @@ -803,6 +793,7 @@ static int RenderPicture( intf_thread_t *p_intf, int i_x_offset, int i_y_offset, picture_t *p_src, picture_t *p_dest ) { int i; + VLC_UNUSED( p_intf ); if( !p_dest && !p_src ) return VLC_EGENERIC; @@ -874,6 +865,11 @@ static picture_t *RenderText( intf_thread_t *p_intf, const char *psz_string, memset( p_region, 0, sizeof(subpicture_region_t) ); p_region->psz_text = strdup( psz_string ); + if( !p_region->psz_text ) + { + free( p_region ); + return NULL; + } p_region->p_style = p_style; p_region->fmt.i_chroma = VLC_FOURCC('T','E','X','T'); @@ -1059,7 +1055,8 @@ static void End( intf_thread_t *p_intf ) if( p_sys->p_overlay ) { int ret; - ret = write( p_sys->i_fd, p_sys->p_overlay->p[0].p_pixels, p_sys->i_page_size ); + ret = write( p_sys->i_fd, p_sys->p_overlay->p[0].p_pixels, + p_sys->i_page_size ); if( ret < 0 ) msg_Err( p_intf, "unable to clear overlay" ); } @@ -1271,7 +1268,7 @@ static bool isRendererReady( intf_thread_t *p_intf ) } /***************************************************************************** - * Run: rc thread + * Run: thread ***************************************************************************** * This part of the interface is in a separate thread so that we can call * exec() from within it without annoying the rest of the program. @@ -1433,12 +1430,10 @@ static int OverlayCallback( vlc_object_t *p_this, char const *psz_cmd, { p_sys->render[i].text_style.i_font_alpha = 255 - newval.i_int; } -#if defined(FBOSD_BLENDING) else if( !strncmp( psz_cmd, "fbosd-alpha", 11 ) ) { p_sys->render[i].i_alpha = newval.i_int; } -#endif } return VLC_SUCCESS; }