Commit f64bdcc0 authored by Gildas Bazin's avatar Gildas Bazin

* modules/codec/subsdec/subsdec.[c,h]: added --subsdec-align option to specify center, left or right alignment.
* include/osd.h, modules/misc/freetype.c: support for center alignment.
* modules/gui/wxwindows/subtitles.cpp: string change.
parent 49d00069
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* osd.h : Constants for use with osd modules * osd.h : Constants for use with osd modules
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: osd.h,v 1.2 2003/07/14 21:32:58 sigmunau Exp $ * $Id: osd.h,v 1.3 2003/08/10 10:22:52 gbazin Exp $
* *
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -21,10 +21,10 @@ ...@@ -21,10 +21,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/ *****************************************************************************/
#define OSD_ALIGN_LEFT 0 #define OSD_ALIGN_LEFT 0x1
#define OSD_ALIGN_RIGHT 0x1 #define OSD_ALIGN_RIGHT 0x2
#define OSD_ALIGN_TOP 0 #define OSD_ALIGN_TOP 0x4
#define OSD_ALIGN_BOTTOM 0x2 #define OSD_ALIGN_BOTTOM 0x8
struct text_style_t struct text_style_t
{ {
int i_size; int i_size;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* subsdec.c : SPU decoder thread * subsdec.c : SPU decoder thread
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * 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> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -65,8 +65,10 @@ static char *ppsz_encodings[] = { "ASCII", "ISO-8859-1", "ISO-8859-2", "ISO-8859 ...@@ -65,8 +65,10 @@ static char *ppsz_encodings[] = { "ASCII", "ISO-8859-1", "ISO-8859-2", "ISO-8859
"Georgian-Academy", "Georgian-PS", "TIS-620", "MuleLao-1", "VISCII", "TCVN", "Georgian-Academy", "Georgian-PS", "TIS-620", "MuleLao-1", "VISCII", "TCVN",
"HPROMAN8", "NEXTSTEP", NULL }; "HPROMAN8", "NEXTSTEP", NULL };
#define ENCODING_TEXT N_("subtitle text encoding") #define ENCODING_TEXT N_("Subtitles text encoding")
#define ENCODING_LONGTEXT N_("change the encoding used in text subtitles") #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(); vlc_module_begin();
set_description( _("file subtitles decoder") ); set_description( _("file subtitles decoder") );
...@@ -74,9 +76,9 @@ vlc_module_begin(); ...@@ -74,9 +76,9 @@ vlc_module_begin();
set_callbacks( OpenDecoder, NULL ); set_callbacks( OpenDecoder, NULL );
add_category_hint( N_("Subtitles"), NULL, VLC_FALSE ); add_category_hint( N_("Subtitles"), NULL, VLC_FALSE );
add_integer( "subsdec-align", 0, NULL, ALIGN_TEXT, ALIGN_LONGTEXT, VLC_TRUE );
#if defined(HAVE_ICONV) #if defined(HAVE_ICONV)
add_string_from_list( "subsdec-encoding", "ISO-8859-1", ppsz_encodings, NULL, add_string_from_list( "subsdec-encoding", "ISO-8859-1", ppsz_encodings, NULL, ENCODING_TEXT, ENCODING_LONGTEXT, VLC_FALSE );
ENCODING_TEXT, ENCODING_LONGTEXT, VLC_FALSE );
#endif #endif
vlc_module_end(); vlc_module_end();
...@@ -97,6 +99,7 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -97,6 +99,7 @@ static int OpenDecoder( vlc_object_t *p_this )
p_fifo->pf_run = RunDecoder; p_fifo->pf_run = RunDecoder;
var_Create( p_this, "subsdec-align", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
#if defined(HAVE_ICONV) #if defined(HAVE_ICONV)
var_Create( p_this, "subsdec-encoding", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_this, "subsdec-encoding", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
#endif #endif
...@@ -129,6 +132,8 @@ static int RunDecoder( decoder_fifo_t * p_fifo ) ...@@ -129,6 +132,8 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
#if defined(HAVE_ICONV) #if defined(HAVE_ICONV)
p_subsdec->iconv_handle = (iconv_t)-1; p_subsdec->iconv_handle = (iconv_t)-1;
#endif #endif
var_Get( p_subsdec->p_fifo, "subsdec-align", &val );
p_subsdec->i_align = val.i_int;
/* /*
* Initialize thread and free configuration * Initialize thread and free configuration
...@@ -143,12 +148,12 @@ static int RunDecoder( decoder_fifo_t * p_fifo ) ...@@ -143,12 +148,12 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
{ {
/* Here we are dealing with text subtitles */ /* Here we are dealing with text subtitles */
#if defined(HAVE_ICONV) #if defined(HAVE_ICONV)
var_Get( p_subsdec->p_fifo, "subsdec-encoding", &val ); var_Get( p_subsdec->p_fifo, "subsdec-encoding", &val );
p_subsdec->iconv_handle = iconv_open( "UTF-8", val.psz_string); p_subsdec->iconv_handle = iconv_open( "UTF-8", val.psz_string);
if( p_subsdec->iconv_handle == (iconv_t)-1 ) if( p_subsdec->iconv_handle == (iconv_t)-1 )
{ {
msg_Warn( p_subsdec->p_fifo, "Unable to do requested conversion" ); msg_Warn( p_subsdec->p_fifo, "Unable to do requested conversion" );
} }
free( val.psz_string); free( val.psz_string);
#endif #endif
while( (!p_subsdec->p_fifo->b_die) && (!p_subsdec->p_fifo->b_error) ) while( (!p_subsdec->p_fifo->b_die) && (!p_subsdec->p_fifo->b_error) )
...@@ -273,7 +278,7 @@ static void EndThread( subsdec_thread_t *p_subsdec ) ...@@ -273,7 +278,7 @@ static void EndThread( subsdec_thread_t *p_subsdec )
#if defined(HAVE_ICONV) #if defined(HAVE_ICONV)
if( p_subsdec->iconv_handle != (iconv_t)-1 ) if( p_subsdec->iconv_handle != (iconv_t)-1 )
{ {
iconv_close( p_subsdec->iconv_handle ); iconv_close( p_subsdec->iconv_handle );
} }
#endif #endif
CloseBitstream( &p_subsdec->bit_stream ); CloseBitstream( &p_subsdec->bit_stream );
...@@ -315,31 +320,32 @@ void E_(ParseText)( subsdec_thread_t *p_subsdec ) ...@@ -315,31 +320,32 @@ void E_(ParseText)( subsdec_thread_t *p_subsdec )
if( psz_subtitle[0] != '\0' ) if( psz_subtitle[0] != '\0' )
{ {
#if defined(HAVE_ICONV) #if defined(HAVE_ICONV)
char *psz_new_subtitle, *psz_convert_buffer_out, *psz_convert_buffer_in; char *psz_new_subtitle, *psz_convert_buffer_out, *psz_convert_buffer_in;
size_t ret, inbytes_left, outbytes_left; size_t ret, inbytes_left, outbytes_left;
psz_new_subtitle = malloc( 6 * strlen( psz_subtitle ) * sizeof(char) ); psz_new_subtitle = malloc( 6 * strlen( psz_subtitle ) * sizeof(char) );
psz_convert_buffer_out = psz_new_subtitle; psz_convert_buffer_out = psz_new_subtitle;
psz_convert_buffer_in = psz_subtitle; psz_convert_buffer_in = psz_subtitle;
inbytes_left = strlen( psz_subtitle ); inbytes_left = strlen( psz_subtitle );
outbytes_left = 6 * inbytes_left; outbytes_left = 6 * inbytes_left;
ret = iconv( p_subsdec->iconv_handle, &psz_convert_buffer_in, ret = iconv( p_subsdec->iconv_handle, &psz_convert_buffer_in,
&inbytes_left, &psz_convert_buffer_out, &outbytes_left ); &inbytes_left, &psz_convert_buffer_out, &outbytes_left );
*psz_convert_buffer_out = '\0'; *psz_convert_buffer_out = '\0';
if( inbytes_left ) if( inbytes_left )
{ {
msg_Warn( p_subsdec->p_fifo, "Something fishy happened during conversion" ); msg_Warn( p_subsdec->p_fifo, "Something fishy happened during conversion" );
} }
else else
{ {
msg_Dbg( p_subsdec->p_fifo, "reencoded \"%s\" into \"%s\"", psz_subtitle, psz_new_subtitle ); msg_Dbg( p_subsdec->p_fifo, "reencoded \"%s\" into \"%s\"", psz_subtitle, psz_new_subtitle );
psz_subtitle = psz_new_subtitle; psz_subtitle = psz_new_subtitle;
} }
#endif #endif
vout_ShowTextAbsolute( p_subsdec->p_vout, psz_subtitle, NULL, vout_ShowTextAbsolute( p_subsdec->p_vout, psz_subtitle, NULL,
OSD_ALIGN_BOTTOM|OSD_ALIGN_LEFT, 20, 20, OSD_ALIGN_BOTTOM | p_subsdec->i_align,
i_pts, i_dts ); p_subsdec->i_align ? 20 : 0, 10,
i_pts, i_dts );
#if defined(HAVE_ICONV) #if defined(HAVE_ICONV)
free( psz_new_subtitle ); free( psz_new_subtitle );
#endif #endif
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* subsdec.h : sub picture unit decoder thread interface * subsdec.h : sub picture unit decoder thread interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: subsdec.h,v 1.1 2003/07/22 20:49:10 hartman Exp $ * $Id: subsdec.h,v 1.2 2003/08/10 10:22:52 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -34,11 +34,6 @@ typedef struct subsdec_thread_t subsdec_thread_t; ...@@ -34,11 +34,6 @@ typedef struct subsdec_thread_t subsdec_thread_t;
*****************************************************************************/ *****************************************************************************/
struct subsdec_thread_t struct subsdec_thread_t
{ {
/*
* Thread properties and locks
*/
vlc_thread_t thread_id; /* id for thread functions */
/* /*
* Input properties * Input properties
*/ */
...@@ -54,6 +49,7 @@ struct subsdec_thread_t ...@@ -54,6 +49,7 @@ struct subsdec_thread_t
/* /*
* Private properties * Private properties
*/ */
int i_align;
#if defined(HAVE_ICONV) #if defined(HAVE_ICONV)
iconv_t iconv_handle; /* handle to iconv instance */ iconv_t iconv_handle; /* handle to iconv instance */
#endif #endif
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* subtitles.cpp : wxWindows plugin for vlc * subtitles.cpp : wxWindows plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: subtitles.cpp,v 1.3 2003/08/10 09:22:07 gbazin Exp $ * $Id: subtitles.cpp,v 1.4 2003/08/10 10:22:52 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -124,7 +124,7 @@ SubsFileDialog::SubsFileDialog( intf_thread_t *_p_intf, wxWindow* _p_parent ): ...@@ -124,7 +124,7 @@ SubsFileDialog::SubsFileDialog( intf_thread_t *_p_intf, wxWindow* _p_parent ):
wxStaticBoxSizer *enc_sizer = new wxStaticBoxSizer( enc_box, wxStaticBoxSizer *enc_sizer = new wxStaticBoxSizer( enc_box,
wxHORIZONTAL ); wxHORIZONTAL );
wxStaticText *label = wxStaticText *label =
new wxStaticText(panel, -1, wxU(_("Text encoding"))); new wxStaticText(panel, -1, wxU(p_item->psz_text));
encoding_combo = new wxComboBox( panel, -1, wxU(p_item->psz_value), encoding_combo = new wxComboBox( panel, -1, wxU(p_item->psz_value),
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
0, NULL, wxCB_READONLY | wxCB_SORT ); 0, NULL, wxCB_READONLY | wxCB_SORT );
......
...@@ -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.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> * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -321,10 +321,15 @@ static void RenderI420( vout_thread_t *p_vout, picture_t *p_pic, ...@@ -321,10 +321,15 @@ static void RenderI420( vout_thread_t *p_vout, picture_t *p_pic,
pen_x = i_pitch - p_line->i_width pen_x = i_pitch - p_line->i_width
- p_string->i_x_margin; - p_string->i_x_margin;
} }
else else if ( p_string->i_flags & OSD_ALIGN_LEFT )
{ {
pen_x = p_string->i_x_margin; 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++ ) for( i = 0; p_line->pp_glyphs[i] != NULL; i++ )
{ {
...@@ -360,10 +365,15 @@ static void RenderI420( vout_thread_t *p_vout, picture_t *p_pic, ...@@ -360,10 +365,15 @@ static void RenderI420( vout_thread_t *p_vout, picture_t *p_pic,
pen_x = i_pitch - ( p_line->i_width >> 1 ) pen_x = i_pitch - ( p_line->i_width >> 1 )
- ( p_string->i_x_margin >> 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; 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++ ) for( i = 0; p_line->pp_glyphs[i] != NULL; i++ )
{ {
...@@ -420,10 +430,14 @@ static void RenderYUY2( vout_thread_t *p_vout, picture_t *p_pic, ...@@ -420,10 +430,14 @@ static void RenderYUY2( vout_thread_t *p_vout, picture_t *p_pic,
pen_x = i_pitch - p_line->i_width pen_x = i_pitch - p_line->i_width
- p_string->i_x_margin; - p_string->i_x_margin;
} }
else else if ( p_string->i_flags & OSD_ALIGN_LEFT )
{ {
pen_x = p_string->i_x_margin; 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++ ) for( i = 0; p_line->pp_glyphs[i] != NULL; i++ )
{ {
......
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