#include <vlc_common.h>
#include <vlc_plugin.h>
+#include <vlc_fs.h>
+#include <vlc_modules.h>
-#include <errno.h>
#include <stdlib.h> /* free() */
#include <string.h> /* strerror() */
#include <fcntl.h> /* open() */
int i_state;
/* Font style */
- text_style_t text_style; /* font control */
+ text_style_t* p_text_style; /* font control */
char *psz_string;
/* Position */
p_sys->i_alpha = var_CreateGetIntegerCommand( p_intf, "fbosd-alpha" );
var_AddCallback( p_intf, "fbosd-alpha", OverlayCallback, NULL );
+ /* Use PAL by default */
+ p_sys->i_width = p_sys->fmt_out.i_width = 704;
+ p_sys->i_height = p_sys->fmt_out.i_height = 576;
+
p_sys->i_aspect = -1;
psz_aspect =
var_CreateGetNonEmptyString( p_intf, "fbosd-aspect-ratio" );
*psz_parser++ = '\0';
p_sys->i_aspect = ( atoi( psz_aspect )
* VOUT_ASPECT_FACTOR ) / atoi( psz_parser );
- p_sys->fmt_out.i_aspect = p_sys->i_aspect;
+ p_sys->fmt_out.i_sar_num = p_sys->i_aspect * p_sys->i_height;
+ p_sys->fmt_out.i_sar_den = VOUT_ASPECT_FACTOR * p_sys->i_width;
}
msg_Dbg( p_intf, "using aspect ratio %d:%d",
atoi( psz_aspect ), atoi( psz_parser ) );
free( psz_aspect );
}
- /* Use PAL by default */
- p_sys->i_width = p_sys->fmt_out.i_width = 704;
- p_sys->i_height = p_sys->fmt_out.i_height = 576;
-
psz_tmp = var_CreateGetNonEmptyStringCommand( p_intf, "fbosd-image" );
var_AddCallback( p_intf, "fbosd-image", OverlayCallback, NULL );
if( psz_tmp && *psz_tmp )
var_AddCallback( p_intf, "fbosd-font-opacity", OverlayCallback, NULL );
for( i = 0; i < FBOSD_RENDER_MAX; i++ )
- {
- vlc_memcpy( &p_sys->render[i].text_style, &default_text_style,
- sizeof( text_style_t ) );
- }
+ p_sys->render[i].p_text_style = text_style_New();
p_sys->b_clear = var_CreateGetBoolCommand( p_intf, "fbosd-clear" );
p_sys->b_render = var_CreateGetBoolCommand( p_intf, "fbosd-render" );
{
free( p_sys->render[i].psz_string );
p_sys->render[i].i_state = FBOSD_STATE_FREE;
+ text_style_Delete( p_sys->render[i].p_text_style );
}
#if defined(FBOSD_BLENDING)
vlc_object_attach( p_intf->p_sys->p_blend, p_intf );
p_intf->p_sys->p_blend->fmt_out.video.i_x_offset =
p_intf->p_sys->p_blend->fmt_out.video.i_y_offset = 0;
- p_intf->p_sys->p_blend->fmt_out.video.i_aspect =
- p_intf->p_sys->fmt_out.i_aspect;
+ p_intf->p_sys->p_blend->fmt_out.video.i_sar_num =
+ p_intf->p_sys->fmt_out.i_sar_num;
+ p_intf->p_sys->p_blend->fmt_out.video.i_sar_den =
+ p_intf->p_sys->fmt_out.i_sar_den;
p_intf->p_sys->p_blend->fmt_out.video.i_chroma =
p_intf->p_sys->fmt_out.i_chroma;
- if( config_GetInt( p_intf, "freetype-yuvp" ) )
+ if( var_InheritBool( p_intf, "freetype-yuvp" ) )
p_intf->p_sys->p_blend->fmt_in.video.i_chroma =
- VLC_FOURCC('Y','U','V','P');
+ VLC_CODEC_YUVP;
else
p_intf->p_sys->p_blend->fmt_in.video.i_chroma =
- VLC_FOURCC('Y','U','V','A');
+ VLC_CODEC_YUVA;
p_intf->p_sys->p_blend->p_module =
module_need( p_intf->p_sys->p_blend, "video blending", NULL, false );
module_unneed( p_intf->p_sys->p_blend,
p_intf->p_sys->p_blend->p_module );
- vlc_object_detach( p_intf->p_sys->p_blend );
vlc_object_release( p_intf->p_sys->p_blend );
}
}
module_unneed( p_intf->p_sys->p_text,
p_intf->p_sys->p_text->p_module );
- vlc_object_detach( p_intf->p_sys->p_text );
vlc_object_release( p_intf->p_sys->p_text );
}
}
*****************************************************************************/
static picture_t *AllocatePicture( video_format_t *p_fmt )
{
- picture_t *p_picture = picture_New( p_fmt->i_chroma,
- p_fmt->i_width, p_fmt->i_height,
- p_fmt->i_aspect );
+ picture_t *p_picture = picture_NewFromFormat( p_fmt );
if( !p_picture )
return NULL;
if( !p_fmt->p_palette &&
- ( p_fmt->i_chroma == VLC_FOURCC('Y','U','V','P') ) )
+ ( p_fmt->i_chroma == VLC_CODEC_YUVP ) )
{
p_fmt->p_palette = malloc( sizeof(video_palette_t) );
if( !p_fmt->p_palette )
switch( fmt.i_chroma )
{
- case VLC_FOURCC('R','V','2','4'):
+ case VLC_CODEC_RGB24:
p_begin = (uint8_t *)(*p_pic)->p[Y_PLANE].p_pixels;
p_end = (uint8_t *)(*p_pic)->p[Y_PLANE].p_pixels +
( fmt.i_height * (*p_pic)->p[Y_PLANE].i_pitch );
i_skip = 3;
break;
- case VLC_FOURCC('R','V','3','2'):
+ case VLC_CODEC_RGB32:
p_begin = (uint8_t *)(*p_pic)->p[Y_PLANE].p_pixels;
p_end = (uint8_t *)(*p_pic)->p[Y_PLANE].p_pixels +
( fmt.i_height * (*p_pic)->p[Y_PLANE].i_pitch );
video_format_t fmt;
memset( &fmt, 0, sizeof(fmt) );
- fmt.i_chroma = VLC_FOURCC('T','E','X','T');
- fmt.i_aspect = 0;
+ fmt.i_chroma = VLC_CODEC_TEXT;
fmt.i_width = fmt.i_visible_width = 0;
fmt.i_height = fmt.i_visible_height = 0;
fmt.i_x_offset = 0;
return NULL;
}
p_region->p_style = text_style_Duplicate( p_style );
- p_region->i_align = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
+ p_region->i_align = SUBPICTURE_ALIGN_LEFT | SUBPICTURE_ALIGN_TOP;
if( p_sys->p_text->pf_render_text )
{
switch( p_sys->var_info.bits_per_pixel )
{
case 8: /* FIXME: set the palette */
- p_sys->fmt_out.i_chroma = VLC_FOURCC('R','G','B','2'); break;
+ p_sys->fmt_out.i_chroma = VLC_CODEC_RGB8; break;
case 15:
- p_sys->fmt_out.i_chroma = VLC_FOURCC('R','V','1','5'); break;
+ p_sys->fmt_out.i_chroma = VLC_CODEC_RGB15; break;
case 16:
- p_sys->fmt_out.i_chroma = VLC_FOURCC('R','V','1','6'); break;
+ p_sys->fmt_out.i_chroma = VLC_CODEC_RGB16; break;
case 24:
- p_sys->fmt_out.i_chroma = VLC_FOURCC('R','V','2','4'); break;
+ p_sys->fmt_out.i_chroma = VLC_CODEC_RGB24; break;
case 32:
- p_sys->fmt_out.i_chroma = VLC_FOURCC('R','V','3','2'); break;
+ p_sys->fmt_out.i_chroma = VLC_CODEC_RGB32; break;
default:
msg_Err( p_intf, "unknown screen depth %i",
p_sys->var_info.bits_per_pixel );
/* Assume we have square pixels */
if( p_sys->i_aspect < 0 )
{
- p_sys->fmt_out.i_aspect = ( p_sys->i_width
- * VOUT_ASPECT_FACTOR ) / p_sys->i_height;
+ p_sys->fmt_out.i_sar_num = 1;
+ p_sys->fmt_out.i_sar_den = 1;
+ }
+ else
+ {
+ p_sys->fmt_out.i_sar_num = p_sys->i_aspect * p_sys->i_height;
+ p_sys->fmt_out.i_sar_den = VOUT_ASPECT_FACTOR * p_sys->i_width;
}
- else p_sys->fmt_out.i_aspect = p_sys->i_aspect;
-
- p_sys->fmt_out.i_sar_num = p_sys->fmt_out.i_sar_den = 1;
/* Allocate overlay buffer */
p_sys->p_overlay = AllocatePicture( &p_sys->fmt_out );
struct fb_fix_screeninfo fix_info; /* framebuffer fix information */
/* Open framebuffer device */
- if( !(psz_device = config_GetPsz( p_intf, "fbosd-dev" )) )
+ if( !(psz_device = var_InheritString( p_intf, "fbosd-dev" )) )
{
msg_Err( p_intf, "don't know which fb osd/overlay device to open" );
return VLC_EGENERIC;
}
- p_sys->i_fd = open( psz_device, O_RDWR );
+ p_sys->i_fd = vlc_open( psz_device, O_RDWR );
if( p_sys->i_fd == -1 )
{
- msg_Err( p_intf, "cannot open %s (%s)", psz_device, strerror(errno) );
+ msg_Err( p_intf, "cannot open %s (%m)", psz_device );
free( psz_device );
return VLC_EGENERIC;
}
/* Get framebuffer device information */
if( ioctl( p_sys->i_fd, FBIOGET_VSCREENINFO, &p_sys->var_info ) )
{
- msg_Err( p_intf, "cannot get fb info (%s)", strerror(errno) );
+ msg_Err( p_intf, "cannot get fb info (%m)" );
close( p_sys->i_fd );
return VLC_EGENERIC;
}
#if defined(FBOSD_BLENDING)
video_format_t fmt_in;
memset( &fmt_in, 0, sizeof(video_format_t) );
- p_text = RenderText( p_intf, render->psz_string, &render->text_style,
+ p_text = RenderText( p_intf, render->psz_string, render->p_text_style,
&fmt_in );
if( p_text )
{
DeAllocatePicture( p_text, &fmt_in );
}
#else
- p_text = RenderText( p_intf, render->psz_string, &render->text_style,
+ p_text = RenderText( p_intf, render->psz_string, render->p_text_style,
&p_sys->fmt_out );
if( p_text )
{
{
intf_sys_t *p_sys = p_intf->p_sys;
- vlc_memcpy( &render->text_style, &default_text_style,
- sizeof( text_style_t ) );
+ text_style_Delete( render->p_text_style );
+ render->p_text_style = text_style_New();
free( render->psz_string );
render->psz_string = NULL;
}
else if( !strncmp( psz_cmd, "fbosd-font-size", 15 ) )
{
- p_sys->render[i].text_style.i_font_size = newval.i_int;
+ p_sys->render[i].p_text_style->i_font_size = newval.i_int;
}
else if( !strncmp( psz_cmd, "fbosd-font-color", 16 ) )
{
- p_sys->render[i].text_style.i_font_color = newval.i_int;
+ p_sys->render[i].p_text_style->i_font_color = newval.i_int;
}
else if( !strncmp( psz_cmd, "fbosd-font-opacity", 18 ) )
{
- p_sys->render[i].text_style.i_font_alpha = 255 - newval.i_int;
+ p_sys->render[i].p_text_style->i_font_alpha = 255 - newval.i_int;
}
else if( !strncmp( psz_cmd, "fbosd-alpha", 11 ) )
{