X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fvideo_filter%2Fdynamicoverlay%2Fdynamicoverlay_commands.c;h=766c5c5bb3b173075ce6c03af8f30f386b89075b;hb=deca66fb30c2d05690b6bfb77c7281213965c4d7;hp=03e28b2fe602603f05a2d6cb8c9ea6f930a596c3;hpb=2f066806f4066261509bde9f84b9fba027d1e43e;p=vlc diff --git a/modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c b/modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c index 03e28b2fe6..766c5c5bb3 100644 --- a/modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c +++ b/modules/video_filter/dynamicoverlay/dynamicoverlay_commands.c @@ -4,7 +4,7 @@ * Copyright (C) 2008 the VideoLAN team * $Id$ * - * Author: Soren Bog + * Author: Søren Bøg * Jean-Paul Saman * * This program is free software; you can redistribute it and/or modify @@ -48,17 +48,16 @@ overlay_t *OverlayCreate( void ) { - overlay_t *p_ovl = malloc( sizeof( overlay_t ) ); + overlay_t *p_ovl = calloc( 1, sizeof( overlay_t ) ); if( p_ovl == NULL ) return NULL; - memset( p_ovl, 0, sizeof( overlay_t ) ); p_ovl->i_x = p_ovl->i_y = 0; p_ovl->i_alpha = 0xFF; p_ovl->b_active = false; - vout_InitFormat( &p_ovl->format, VLC_FOURCC( '\0','\0','\0','\0') , 0, 0, - VOUT_ASPECT_FACTOR ); - memcpy( &p_ovl->fontstyle, &default_text_style, sizeof(struct text_style_t) ); + video_format_Setup( &p_ovl->format, VLC_FOURCC( '\0','\0','\0','\0') , 0, 0, + 1, 1 ); + p_ovl->p_fontstyle = text_style_New(); p_ovl->data.p_text = NULL; return p_ovl; @@ -66,8 +65,8 @@ overlay_t *OverlayCreate( void ) int OverlayDestroy( overlay_t *p_ovl ) { - if( p_ovl->data.p_text != NULL ) - free( p_ovl->data.p_text ); + free( p_ovl->data.p_text ); + text_style_Delete( p_ovl->p_fontstyle ); return VLC_SUCCESS; } @@ -269,7 +268,7 @@ static int parser_SetTextColor( char *psz_command, char *psz_end, if( parse_digit( &psz_command, &b ) == VLC_EGENERIC ) return VLC_EGENERIC; } - p_params->fontstyle.i_font_color = (r<<24) | (g<<16) | (b<<8); + p_params->fontstyle.i_font_color = (r<<16) | (g<<8) | (b<<0); return VLC_SUCCESS; } @@ -372,15 +371,15 @@ static int unparse_GetTextAlpha( const commandparams_t *p_results, static int unparse_GetTextColor( const commandparams_t *p_results, buffer_t *p_output ) { - int ret = BufferPrintf( p_output, " %d", (p_results->fontstyle.i_font_color & 0xff0000)>>24 ); + int ret = BufferPrintf( p_output, " %d", (p_results->fontstyle.i_font_color & 0xff0000)>>16 ); if( ret != VLC_SUCCESS ) return ret; - ret = BufferPrintf( p_output, " %d", (p_results->fontstyle.i_font_color & 0x00ff00)>>16 ); + ret = BufferPrintf( p_output, " %d", (p_results->fontstyle.i_font_color & 0x00ff00)>>8 ); if( ret != VLC_SUCCESS ) return ret; - ret = BufferPrintf( p_output, " %d", (p_results->fontstyle.i_font_color & 0x0000ff)>>8 ); + ret = BufferPrintf( p_output, " %d", (p_results->fontstyle.i_font_color & 0x0000ff) ); if( ret != VLC_SUCCESS ) return ret; @@ -436,14 +435,14 @@ static int exec_DataSharedMem( filter_t *p_filter, } i_size = shminfo.shm_segsz; - if( p_params->fourcc == VLC_FOURCC('T','E','X','T') ) + if( p_params->fourcc == VLC_CODEC_TEXT ) { char *p_data; if( (p_params->i_height != 1) || (p_params->i_width < 1) ) { msg_Err( p_filter, - "Invalid width and/or height. when specifing text height " + "Invalid width and/or height. when specifying text height " "must be 1 and width the number of bytes in the string, " "including the null terminator" ); return VLC_EGENERIC; @@ -464,8 +463,8 @@ static int exec_DataSharedMem( filter_t *p_filter, return VLC_ENOMEM; } - vout_InitFormat( &p_ovl->format, VLC_FOURCC('T','E','X','T'), - 0, 0, 0 ); + video_format_Setup( &p_ovl->format, VLC_CODEC_TEXT, + 0, 0, 0, 1 ); p_data = shmat( p_params->i_shmid, NULL, SHM_RDONLY ); if( p_data == NULL ) @@ -488,12 +487,14 @@ static int exec_DataSharedMem( filter_t *p_filter, if( p_ovl->data.p_pic == NULL ) return VLC_ENOMEM; - vout_InitFormat( &p_ovl->format, p_params->fourcc, - p_params->i_width, p_params->i_height, - VOUT_ASPECT_FACTOR ); + video_format_Setup( &p_ovl->format, p_params->fourcc, + p_params->i_width, p_params->i_height, + 1, 1 ); if( vout_AllocatePicture( p_filter, p_ovl->data.p_pic, p_ovl->format.i_chroma, p_params->i_width, - p_params->i_height, p_ovl->format.i_aspect ) ) + p_params->i_height, + p_ovl->format.i_aspect * p_params->i_height, + VOUT_ASPECT_FACTOR * p_params->i_width ) ) { msg_Err( p_filter, "Unable to allocate picture" ); free( p_ovl->data.p_pic ); @@ -636,7 +637,7 @@ static int exec_GetTextAlpha( filter_t *p_filter, if( p_ovl == NULL ) return VLC_EGENERIC; - p_results->fontstyle.i_font_alpha = p_ovl->fontstyle.i_font_alpha; + p_results->fontstyle.i_font_alpha = p_ovl->p_fontstyle->i_font_alpha; return VLC_SUCCESS; } @@ -649,7 +650,7 @@ static int exec_GetTextColor( filter_t *p_filter, if( p_ovl == NULL ) return VLC_EGENERIC; - p_results->fontstyle.i_font_color = p_ovl->fontstyle.i_font_color; + p_results->fontstyle.i_font_color = p_ovl->p_fontstyle->i_font_color; return VLC_SUCCESS; } @@ -662,7 +663,7 @@ static int exec_GetTextSize( filter_t *p_filter, if( p_ovl == NULL ) return VLC_EGENERIC; - p_results->fontstyle.i_font_size = p_ovl->fontstyle.i_font_size; + p_results->fontstyle.i_font_size = p_ovl->p_fontstyle->i_font_size; return VLC_SUCCESS; } @@ -725,7 +726,7 @@ static int exec_SetTextAlpha( filter_t *p_filter, if( p_ovl == NULL ) return VLC_EGENERIC; - p_ovl->fontstyle.i_font_alpha = p_params->fontstyle.i_font_alpha; + p_ovl->p_fontstyle->i_font_alpha = p_params->fontstyle.i_font_alpha; p_sys->b_updated = p_ovl->b_active; return VLC_SUCCESS; } @@ -741,7 +742,7 @@ static int exec_SetTextColor( filter_t *p_filter, if( p_ovl == NULL ) return VLC_EGENERIC; - p_ovl->fontstyle.i_font_color = p_params->fontstyle.i_font_color; + p_ovl->p_fontstyle->i_font_color = p_params->fontstyle.i_font_color; p_sys->b_updated = p_ovl->b_active; return VLC_SUCCESS; } @@ -757,7 +758,7 @@ static int exec_SetTextSize( filter_t *p_filter, if( p_ovl == NULL ) return VLC_EGENERIC; - p_ovl->fontstyle.i_font_size = p_params->fontstyle.i_font_size; + p_ovl->p_fontstyle->i_font_size = p_params->fontstyle.i_font_size; p_sys->b_updated = p_ovl->b_active; return VLC_SUCCESS; } @@ -793,7 +794,7 @@ static int exec_StartAtomic( filter_t *p_filter, /***************************************************************************** * Command functions *****************************************************************************/ -static const commanddesc_t p_commands[] = +static const commanddesc_static_t p_commands[] = { { .psz_command = "DataSharedMem", .b_atomic = true,