* subsdec.c : SPU decoder thread
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
- * $Id: subsdec.c,v 1.4 2003/07/25 01:11:32 hartman Exp $
+ * $Id: subsdec.c,v 1.5 2003/08/10 10:22:52 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
* Samuel Hocevar <sam@zoy.org>
"Georgian-Academy", "Georgian-PS", "TIS-620", "MuleLao-1", "VISCII", "TCVN",
"HPROMAN8", "NEXTSTEP", NULL };
-#define ENCODING_TEXT N_("subtitle text encoding")
-#define ENCODING_LONGTEXT N_("change the encoding used in text subtitles")
+#define ENCODING_TEXT N_("Subtitles text encoding")
+#define ENCODING_LONGTEXT N_("Change the encoding used in text subtitles")
+#define ALIGN_TEXT N_("Subtitles justification")
+#define ALIGN_LONGTEXT N_("Change the justification of substitles (0=center, 1=left, 2=right)")
vlc_module_begin();
set_description( _("file subtitles decoder") );
set_callbacks( OpenDecoder, NULL );
add_category_hint( N_("Subtitles"), NULL, VLC_FALSE );
+ add_integer( "subsdec-align", 0, NULL, ALIGN_TEXT, ALIGN_LONGTEXT, VLC_TRUE );
#if defined(HAVE_ICONV)
- add_string_from_list( "subsdec-encoding", "ISO-8859-1", ppsz_encodings, NULL,
- ENCODING_TEXT, ENCODING_LONGTEXT, VLC_FALSE );
+ add_string_from_list( "subsdec-encoding", "ISO-8859-1", ppsz_encodings, NULL, ENCODING_TEXT, ENCODING_LONGTEXT, VLC_FALSE );
#endif
vlc_module_end();
p_fifo->pf_run = RunDecoder;
+ var_Create( p_this, "subsdec-align", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
#if defined(HAVE_ICONV)
var_Create( p_this, "subsdec-encoding", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
#endif
#if defined(HAVE_ICONV)
p_subsdec->iconv_handle = (iconv_t)-1;
#endif
+ var_Get( p_subsdec->p_fifo, "subsdec-align", &val );
+ p_subsdec->i_align = val.i_int;
/*
* Initialize thread and free configuration
{
/* Here we are dealing with text subtitles */
#if defined(HAVE_ICONV)
- var_Get( p_subsdec->p_fifo, "subsdec-encoding", &val );
- p_subsdec->iconv_handle = iconv_open( "UTF-8", val.psz_string);
- if( p_subsdec->iconv_handle == (iconv_t)-1 )
- {
- msg_Warn( p_subsdec->p_fifo, "Unable to do requested conversion" );
- }
+ var_Get( p_subsdec->p_fifo, "subsdec-encoding", &val );
+ p_subsdec->iconv_handle = iconv_open( "UTF-8", val.psz_string);
+ if( p_subsdec->iconv_handle == (iconv_t)-1 )
+ {
+ msg_Warn( p_subsdec->p_fifo, "Unable to do requested conversion" );
+ }
free( val.psz_string);
#endif
while( (!p_subsdec->p_fifo->b_die) && (!p_subsdec->p_fifo->b_error) )
#if defined(HAVE_ICONV)
if( p_subsdec->iconv_handle != (iconv_t)-1 )
{
- iconv_close( p_subsdec->iconv_handle );
+ iconv_close( p_subsdec->iconv_handle );
}
#endif
CloseBitstream( &p_subsdec->bit_stream );
if( psz_subtitle[0] != '\0' )
{
#if defined(HAVE_ICONV)
- char *psz_new_subtitle, *psz_convert_buffer_out, *psz_convert_buffer_in;
- size_t ret, inbytes_left, outbytes_left;
-
- psz_new_subtitle = malloc( 6 * strlen( psz_subtitle ) * sizeof(char) );
- psz_convert_buffer_out = psz_new_subtitle;
- psz_convert_buffer_in = psz_subtitle;
- inbytes_left = strlen( psz_subtitle );
- outbytes_left = 6 * inbytes_left;
- ret = iconv( p_subsdec->iconv_handle, &psz_convert_buffer_in,
+ char *psz_new_subtitle, *psz_convert_buffer_out, *psz_convert_buffer_in;
+ size_t ret, inbytes_left, outbytes_left;
+
+ psz_new_subtitle = malloc( 6 * strlen( psz_subtitle ) * sizeof(char) );
+ psz_convert_buffer_out = psz_new_subtitle;
+ psz_convert_buffer_in = psz_subtitle;
+ inbytes_left = strlen( psz_subtitle );
+ outbytes_left = 6 * inbytes_left;
+ ret = iconv( p_subsdec->iconv_handle, &psz_convert_buffer_in,
&inbytes_left, &psz_convert_buffer_out, &outbytes_left );
- *psz_convert_buffer_out = '\0';
-
- if( inbytes_left )
- {
- msg_Warn( p_subsdec->p_fifo, "Something fishy happened during conversion" );
- }
- else
- {
- msg_Dbg( p_subsdec->p_fifo, "reencoded \"%s\" into \"%s\"", psz_subtitle, psz_new_subtitle );
+ *psz_convert_buffer_out = '\0';
+
+ if( inbytes_left )
+ {
+ msg_Warn( p_subsdec->p_fifo, "Something fishy happened during conversion" );
+ }
+ else
+ {
+ msg_Dbg( p_subsdec->p_fifo, "reencoded \"%s\" into \"%s\"", psz_subtitle, psz_new_subtitle );
psz_subtitle = psz_new_subtitle;
- }
+ }
#endif
- vout_ShowTextAbsolute( p_subsdec->p_vout, psz_subtitle, NULL,
- OSD_ALIGN_BOTTOM|OSD_ALIGN_LEFT, 20, 20,
- i_pts, i_dts );
+ vout_ShowTextAbsolute( p_subsdec->p_vout, psz_subtitle, NULL,
+ OSD_ALIGN_BOTTOM | p_subsdec->i_align,
+ p_subsdec->i_align ? 20 : 0, 10,
+ i_pts, i_dts );
#if defined(HAVE_ICONV)
free( psz_new_subtitle );
#endif
* freetype.c : Put text on the video, using freetype2
*****************************************************************************
* Copyright (C) 2002, 2003 VideoLAN
- * $Id: freetype.c,v 1.16 2003/08/04 23:31:53 gbazin Exp $
+ * $Id: freetype.c,v 1.17 2003/08/10 10:22:52 gbazin Exp $
*
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
*
pen_x = i_pitch - p_line->i_width
- p_string->i_x_margin;
}
- else
+ else if ( p_string->i_flags & OSD_ALIGN_LEFT )
{
pen_x = p_string->i_x_margin;
}
+ else
+ {
+ pen_x = i_pitch / 2 - p_line->i_width / 2
+ + p_string->i_x_margin;
+ }
for( i = 0; p_line->pp_glyphs[i] != NULL; i++ )
{
pen_x = i_pitch - ( p_line->i_width >> 1 )
- ( p_string->i_x_margin >> 1 );
}
- else
+ else if ( p_string->i_flags & OSD_ALIGN_LEFT )
{
pen_x = p_string->i_x_margin >> 1;
}
+ else
+ {
+ pen_x = i_pitch / 2 - p_line->i_width / 4
+ + p_string->i_x_margin / 2;
+ }
for( i = 0; p_line->pp_glyphs[i] != NULL; i++ )
{
pen_x = i_pitch - p_line->i_width
- p_string->i_x_margin;
}
- else
+ else if ( p_string->i_flags & OSD_ALIGN_LEFT )
{
pen_x = p_string->i_x_margin;
}
+ else
+ {
+ pen_x = i_pitch / 2 - p_line->i_width / 2 + p_string->i_x_margin;
+ }
for( i = 0; p_line->pp_glyphs[i] != NULL; i++ )
{