Commit 5b165b73 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* include/vlc_common.h: MAX_PATH PATH_MAX, we don't wanna bother and use the

  latter everywhere.
* modules/demux/util/sub.c: Bring the config options in here to the variable structure.
* modules/misc/freetype.c: Bring the config options in here to the variable structure.
  Fix the linespacing. Dnumgis, it works, just define another linespacing :)
parent 49913218
......@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vlc_common.h,v 1.68 2003/07/14 20:36:55 sigmunau Exp $
* $Id: vlc_common.h,v 1.69 2003/07/23 21:45:13 hartman Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -103,6 +103,7 @@ typedef int ptrdiff_t;
#if defined( WIN32 )
# include <malloc.h>
#define PATH_MAX MAX_PATH
#endif
#if defined( WIN32 ) || defined( UNDER_CE )
......
......@@ -2,7 +2,7 @@
* sub.c
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: sub.c,v 1.17 2003/07/14 21:32:59 sigmunau Exp $
* $Id: sub.c,v 1.18 2003/07/23 21:45:13 hartman Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -93,6 +93,28 @@ static int Open ( vlc_object_t *p_this )
p_sub->pf_seek = sub_seek;
p_sub->pf_close = sub_close;
/* Initialize the variables */
if( !var_Type( p_this, "sub-file" ) )
{
var_Create( p_this, "sub-file", VLC_VAR_STRING );
var_Change( p_this, "sub-file", VLC_VAR_INHERITVALUE, NULL, NULL );
}
if( !var_Type( p_this, "sub-fps" ) )
{
var_Create( p_this, "sub-fps", VLC_VAR_FLOAT );
var_Change( p_this, "sub-fps", VLC_VAR_INHERITVALUE, NULL, NULL );
}
if( !var_Type( p_this, "sub-delay" ) )
{
var_Create( p_this, "sub-delay", VLC_VAR_INTEGER );
var_Change( p_this, "sub-delay", VLC_VAR_INHERITVALUE, NULL, NULL );
}
if( !var_Type( p_this, "sub-type" ) )
{
var_Create( p_this, "sub-type", VLC_VAR_STRING );
var_Change( p_this, "sub-type", VLC_VAR_INHERITVALUE, NULL, NULL );
}
return VLC_SUCCESS;
}
#define MAX_TRY 256
......@@ -229,9 +251,9 @@ static int sub_open ( subtitle_demux_t *p_sub,
mtime_t i_microsecperframe )
{
text_t txt;
vlc_value_t val;
int i;
char *psz_file_type;
int i_sub_type;
int i_max;
int (*pf_read_subtitle)( text_t *, subtitle_t *, mtime_t ) = NULL;
......@@ -244,11 +266,14 @@ static int sub_open ( subtitle_demux_t *p_sub,
if( !psz_name || !*psz_name)
{
psz_name = config_GetPsz( p_sub, "sub-file" );
if( !psz_name || !*psz_name )
var_Get( p_sub, "sub-file", &val );
if( !val.psz_string || !*val.psz_string )
{
if( val.psz_string) free( val.psz_string);
return VLC_EGENERIC;
}
psz_name = strdup( val.psz_string );
free( val.psz_string );
}
else
{
......@@ -265,19 +290,19 @@ static int sub_open ( subtitle_demux_t *p_sub,
msg_Dbg( p_sub, "opened `%s'", psz_name );
free( psz_name );
if( config_GetFloat( p_sub, "sub-fps" ) >= 1.0 )
var_Get( p_sub, "sub-fps", &val );
if( val.i_int >= 1.0 )
{
i_microsecperframe = (mtime_t)( (float)1000000 /
config_GetFloat( p_sub, "sub-fps" ) );
var_Get( p_sub, "sub-fps", &val );
i_microsecperframe = (mtime_t)( (float)1000000 / val.f_float );
}
else if( i_microsecperframe <= 0 )
{
i_microsecperframe = 40000; /* default: 25fps */
}
psz_file_type = config_GetPsz( p_sub, "sub-type" );
if( psz_file_type && *psz_file_type)
var_Get( p_sub, "sub-type", &val);
if( val.psz_string && *val.psz_string )
{
int i;
......@@ -289,7 +314,7 @@ static int sub_open ( subtitle_demux_t *p_sub,
break;
}
if( !strcmp( sub_read_subtitle_function[i].psz_type_name,
psz_file_type ) )
val.psz_string ) )
{
i_sub_type = sub_read_subtitle_function[i].i_type;
break;
......@@ -300,7 +325,7 @@ static int sub_open ( subtitle_demux_t *p_sub,
{
i_sub_type = SUB_TYPE_UNKNOWN;
}
FREE( psz_file_type );
FREE( val.psz_string );
/* *** Now try to autodetect subtitle format *** */
if( i_sub_type == SUB_TYPE_UNKNOWN )
......@@ -571,6 +596,7 @@ static void sub_fix( subtitle_demux_t *p_sub )
mtime_t i_delay;
int i_index;
int i_done;
vlc_value_t val;
/* *** fix order (to be sure...) *** */
/* We suppose that there are near in order and this durty bubble sort
......@@ -600,7 +626,8 @@ static void sub_fix( subtitle_demux_t *p_sub )
} while( !i_done );
/* *** and at the end add delay *** */
i_delay = (mtime_t)config_GetInt( p_sub, "sub-delay" ) * 100000;
var_Get( p_sub, "sub-delay", &val );
i_delay = (mtime_t) val.i_int * 100000;
if( i_delay != 0 )
{
for( i = 0; i < p_sub->i_subtitles; i++ )
......
......@@ -2,7 +2,7 @@
* freetype.c : Put text on the video, using freetype2
*****************************************************************************
* Copyright (C) 2002, 2003 VideoLAN
* $Id: freetype.c,v 1.9 2003/07/23 19:11:08 titer Exp $
* $Id: freetype.c,v 1.10 2003/07/23 21:45:13 hartman Exp $
*
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
*
......@@ -122,6 +122,7 @@ static int Create( vlc_object_t *p_this )
char *psz_fontfile;
int i, i_error;
double gamma_inv = 1.0f / gamma_value;
vlc_value_t val;
/* Allocate structure */
p_vout->p_text_renderer_data = malloc( sizeof( text_renderer_sys_t ) );
......@@ -136,17 +137,34 @@ static int Create( vlc_object_t *p_this )
(uint8_t)( pow( (double)i / 255.0f, gamma_inv) * 255.0f );
}
if( !var_Type( p_vout, "freetype-font" ) )
{
var_Create( p_vout, "freetype-font", VLC_VAR_STRING );
var_Change( p_vout, "freetype-font", VLC_VAR_INHERITVALUE, NULL, NULL );
}
if( !var_Type( p_vout, "freetype-fontsize" ) )
{
var_Create( p_vout, "freetype-fontsize", VLC_VAR_INTEGER );
var_Change( p_vout, "freetype-fontsize", VLC_VAR_INHERITVALUE, NULL, NULL );
}
/* Look what method was requested */
psz_fontfile = config_GetPsz( p_vout, "freetype-font" );
#ifdef WIN32
var_Get( p_vout, "freetype-font", &val );
psz_fontfile = (char *)malloc( PATH_MAX + 1 );
strcat( psz_fontfile, val.psz_string );
free( val.psz_string);
if( !psz_fontfile || !*psz_fontfile )
{
if( psz_fontfile ) free( psz_fontfile );
psz_fontfile = (char *)malloc( MAX_PATH + 1 );
GetWindowsDirectory( psz_fontfile, MAX_PATH + 1 );
psz_fontfile = (char *)malloc( PATH_MAX + 1 );
#ifdef WIN32
GetWindowsDirectory( psz_fontfile, PATH_MAX + 1 );
strcat( psz_fontfile, "\\fonts\\arial.ttf" );
}
#elif SYS_DARWIN
strcat( psz_fontfile, DEFAULT_FONT );
#endif
}
i_error = FT_Init_FreeType( &p_vout->p_text_renderer_data->p_library );
if( i_error )
......@@ -190,13 +208,12 @@ static int Create( vlc_object_t *p_this )
p_vout->p_text_renderer_data->i_use_kerning =
FT_HAS_KERNING(p_vout->p_text_renderer_data->p_face);
var_Get( p_vout, "freetype-fontsize", &val );
i_error = FT_Set_Pixel_Sizes( p_vout->p_text_renderer_data->p_face, 0,
config_GetInt( p_vout, "freetype-fontsize" ) );
i_error = FT_Set_Pixel_Sizes( p_vout->p_text_renderer_data->p_face, 0, val.i_int );
if( i_error )
{
msg_Err( p_vout, "couldn't set font size to %d",
config_GetInt( p_vout, "osd-fontsize" ) );
msg_Err( p_vout, "couldn't set font size to %d", val.i_int );
free( p_vout->p_text_renderer_data );
return VLC_EGENERIC;
}
......@@ -445,12 +462,12 @@ static int AddText ( vout_thread_t *p_vout, byte_t *psz_string,
{
i_pen_x = 0;
result.x = __MAX( result.x, line.xMax );
result.y += face->height >> 6;
result.y += face->size->metrics.height / 26.6;
line.xMin = 0;
line.xMax = 0;
line.yMin = 0;
line.yMax = 0;
i_pen_y += face->height >> 6;
i_pen_y += face->size->metrics.height / 26.6;
continue;
}
i_glyph_index = FT_Get_Char_Index( face, i_char );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment