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 @@ ...@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions * Collection of useful common types and macros definitions
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * 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> * Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr> * Vincent Seguin <seguin@via.ecp.fr>
...@@ -103,6 +103,7 @@ typedef int ptrdiff_t; ...@@ -103,6 +103,7 @@ typedef int ptrdiff_t;
#if defined( WIN32 ) #if defined( WIN32 )
# include <malloc.h> # include <malloc.h>
#define PATH_MAX MAX_PATH
#endif #endif
#if defined( WIN32 ) || defined( UNDER_CE ) #if defined( WIN32 ) || defined( UNDER_CE )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* sub.c * sub.c
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -93,6 +93,28 @@ static int Open ( vlc_object_t *p_this ) ...@@ -93,6 +93,28 @@ static int Open ( vlc_object_t *p_this )
p_sub->pf_seek = sub_seek; p_sub->pf_seek = sub_seek;
p_sub->pf_close = sub_close; 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; return VLC_SUCCESS;
} }
#define MAX_TRY 256 #define MAX_TRY 256
...@@ -229,9 +251,9 @@ static int sub_open ( subtitle_demux_t *p_sub, ...@@ -229,9 +251,9 @@ static int sub_open ( subtitle_demux_t *p_sub,
mtime_t i_microsecperframe ) mtime_t i_microsecperframe )
{ {
text_t txt; text_t txt;
vlc_value_t val;
int i; int i;
char *psz_file_type;
int i_sub_type; int i_sub_type;
int i_max; int i_max;
int (*pf_read_subtitle)( text_t *, subtitle_t *, mtime_t ) = NULL; int (*pf_read_subtitle)( text_t *, subtitle_t *, mtime_t ) = NULL;
...@@ -244,11 +266,14 @@ static int sub_open ( subtitle_demux_t *p_sub, ...@@ -244,11 +266,14 @@ static int sub_open ( subtitle_demux_t *p_sub,
if( !psz_name || !*psz_name) if( !psz_name || !*psz_name)
{ {
psz_name = config_GetPsz( p_sub, "sub-file" ); var_Get( p_sub, "sub-file", &val );
if( !psz_name || !*psz_name ) if( !val.psz_string || !*val.psz_string )
{ {
if( val.psz_string) free( val.psz_string);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
psz_name = strdup( val.psz_string );
free( val.psz_string );
} }
else else
{ {
...@@ -265,19 +290,19 @@ static int sub_open ( subtitle_demux_t *p_sub, ...@@ -265,19 +290,19 @@ static int sub_open ( subtitle_demux_t *p_sub,
msg_Dbg( p_sub, "opened `%s'", psz_name ); msg_Dbg( p_sub, "opened `%s'", psz_name );
free( psz_name ); free( psz_name );
var_Get( p_sub, "sub-fps", &val );
if( config_GetFloat( p_sub, "sub-fps" ) >= 1.0 ) if( val.i_int >= 1.0 )
{ {
i_microsecperframe = (mtime_t)( (float)1000000 / var_Get( p_sub, "sub-fps", &val );
config_GetFloat( p_sub, "sub-fps" ) ); i_microsecperframe = (mtime_t)( (float)1000000 / val.f_float );
} }
else if( i_microsecperframe <= 0 ) else if( i_microsecperframe <= 0 )
{ {
i_microsecperframe = 40000; /* default: 25fps */ i_microsecperframe = 40000; /* default: 25fps */
} }
psz_file_type = config_GetPsz( p_sub, "sub-type" ); var_Get( p_sub, "sub-type", &val);
if( psz_file_type && *psz_file_type) if( val.psz_string && *val.psz_string )
{ {
int i; int i;
...@@ -289,7 +314,7 @@ static int sub_open ( subtitle_demux_t *p_sub, ...@@ -289,7 +314,7 @@ static int sub_open ( subtitle_demux_t *p_sub,
break; break;
} }
if( !strcmp( sub_read_subtitle_function[i].psz_type_name, 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; i_sub_type = sub_read_subtitle_function[i].i_type;
break; break;
...@@ -300,7 +325,7 @@ static int sub_open ( subtitle_demux_t *p_sub, ...@@ -300,7 +325,7 @@ static int sub_open ( subtitle_demux_t *p_sub,
{ {
i_sub_type = SUB_TYPE_UNKNOWN; i_sub_type = SUB_TYPE_UNKNOWN;
} }
FREE( psz_file_type ); FREE( val.psz_string );
/* *** Now try to autodetect subtitle format *** */ /* *** Now try to autodetect subtitle format *** */
if( i_sub_type == SUB_TYPE_UNKNOWN ) if( i_sub_type == SUB_TYPE_UNKNOWN )
...@@ -571,6 +596,7 @@ static void sub_fix( subtitle_demux_t *p_sub ) ...@@ -571,6 +596,7 @@ static void sub_fix( subtitle_demux_t *p_sub )
mtime_t i_delay; mtime_t i_delay;
int i_index; int i_index;
int i_done; int i_done;
vlc_value_t val;
/* *** fix order (to be sure...) *** */ /* *** fix order (to be sure...) *** */
/* We suppose that there are near in order and this durty bubble sort /* 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 ) ...@@ -600,7 +626,8 @@ static void sub_fix( subtitle_demux_t *p_sub )
} while( !i_done ); } while( !i_done );
/* *** and at the end add delay *** */ /* *** 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 ) if( i_delay != 0 )
{ {
for( i = 0; i < p_sub->i_subtitles; i++ ) for( i = 0; i < p_sub->i_subtitles; i++ )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* freetype.c : Put text on the video, using freetype2 * freetype.c : Put text on the video, using freetype2
***************************************************************************** *****************************************************************************
* Copyright (C) 2002, 2003 VideoLAN * 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> * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -122,6 +122,7 @@ static int Create( vlc_object_t *p_this ) ...@@ -122,6 +122,7 @@ static int Create( vlc_object_t *p_this )
char *psz_fontfile; char *psz_fontfile;
int i, i_error; int i, i_error;
double gamma_inv = 1.0f / gamma_value; double gamma_inv = 1.0f / gamma_value;
vlc_value_t val;
/* Allocate structure */ /* Allocate structure */
p_vout->p_text_renderer_data = malloc( sizeof( text_renderer_sys_t ) ); p_vout->p_text_renderer_data = malloc( sizeof( text_renderer_sys_t ) );
...@@ -136,17 +137,34 @@ static int Create( vlc_object_t *p_this ) ...@@ -136,17 +137,34 @@ static int Create( vlc_object_t *p_this )
(uint8_t)( pow( (double)i / 255.0f, gamma_inv) * 255.0f ); (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 */ /* Look what method was requested */
psz_fontfile = config_GetPsz( p_vout, "freetype-font" ); var_Get( p_vout, "freetype-font", &val );
#ifdef WIN32 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 || !*psz_fontfile )
{ {
if( psz_fontfile ) free( psz_fontfile ); if( psz_fontfile ) free( psz_fontfile );
psz_fontfile = (char *)malloc( MAX_PATH + 1 ); psz_fontfile = (char *)malloc( PATH_MAX + 1 );
GetWindowsDirectory( psz_fontfile, MAX_PATH + 1 ); #ifdef WIN32
GetWindowsDirectory( psz_fontfile, PATH_MAX + 1 );
strcat( psz_fontfile, "\\fonts\\arial.ttf" ); strcat( psz_fontfile, "\\fonts\\arial.ttf" );
} #elif SYS_DARWIN
strcat( psz_fontfile, DEFAULT_FONT );
#endif #endif
}
i_error = FT_Init_FreeType( &p_vout->p_text_renderer_data->p_library ); i_error = FT_Init_FreeType( &p_vout->p_text_renderer_data->p_library );
if( i_error ) if( i_error )
...@@ -190,13 +208,12 @@ static int Create( vlc_object_t *p_this ) ...@@ -190,13 +208,12 @@ static int Create( vlc_object_t *p_this )
p_vout->p_text_renderer_data->i_use_kerning = p_vout->p_text_renderer_data->i_use_kerning =
FT_HAS_KERNING(p_vout->p_text_renderer_data->p_face); 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, i_error = FT_Set_Pixel_Sizes( p_vout->p_text_renderer_data->p_face, 0, val.i_int );
config_GetInt( p_vout, "freetype-fontsize" ) );
if( i_error ) if( i_error )
{ {
msg_Err( p_vout, "couldn't set font size to %d", msg_Err( p_vout, "couldn't set font size to %d", val.i_int );
config_GetInt( p_vout, "osd-fontsize" ) );
free( p_vout->p_text_renderer_data ); free( p_vout->p_text_renderer_data );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -445,12 +462,12 @@ static int AddText ( vout_thread_t *p_vout, byte_t *psz_string, ...@@ -445,12 +462,12 @@ static int AddText ( vout_thread_t *p_vout, byte_t *psz_string,
{ {
i_pen_x = 0; i_pen_x = 0;
result.x = __MAX( result.x, line.xMax ); result.x = __MAX( result.x, line.xMax );
result.y += face->height >> 6; result.y += face->size->metrics.height / 26.6;
line.xMin = 0; line.xMin = 0;
line.xMax = 0; line.xMax = 0;
line.yMin = 0; line.yMin = 0;
line.yMax = 0; line.yMax = 0;
i_pen_y += face->height >> 6; i_pen_y += face->size->metrics.height / 26.6;
continue; continue;
} }
i_glyph_index = FT_Get_Char_Index( face, i_char ); 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