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 @@
* osd.h : Constants for use with osd modules
*****************************************************************************
* 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>
*
......@@ -21,10 +21,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#define OSD_ALIGN_LEFT 0
#define OSD_ALIGN_RIGHT 0x1
#define OSD_ALIGN_TOP 0
#define OSD_ALIGN_BOTTOM 0x2
#define OSD_ALIGN_LEFT 0x1
#define OSD_ALIGN_RIGHT 0x2
#define OSD_ALIGN_TOP 0x4
#define OSD_ALIGN_BOTTOM 0x8
struct text_style_t
{
int i_size;
......
......@@ -2,7 +2,7 @@
* 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>
......@@ -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",
"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") );
......@@ -74,9 +76,9 @@ vlc_module_begin();
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();
......@@ -97,6 +99,7 @@ static int OpenDecoder( vlc_object_t *p_this )
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
......@@ -129,6 +132,8 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
#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
......@@ -143,12 +148,12 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
{
/* 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) )
......@@ -273,7 +278,7 @@ static void EndThread( subsdec_thread_t *p_subsdec )
#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 );
......@@ -315,31 +320,32 @@ void E_(ParseText)( subsdec_thread_t *p_subsdec )
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
......
......@@ -3,7 +3,7 @@
* subsdec.h : sub picture unit decoder thread interface
*****************************************************************************
* 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>
*
......@@ -34,11 +34,6 @@ typedef struct subsdec_thread_t subsdec_thread_t;
*****************************************************************************/
struct subsdec_thread_t
{
/*
* Thread properties and locks
*/
vlc_thread_t thread_id; /* id for thread functions */
/*
* Input properties
*/
......@@ -54,6 +49,7 @@ struct subsdec_thread_t
/*
* Private properties
*/
int i_align;
#if defined(HAVE_ICONV)
iconv_t iconv_handle; /* handle to iconv instance */
#endif
......
......@@ -2,7 +2,7 @@
* subtitles.cpp : wxWindows plugin for vlc
*****************************************************************************
* 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>
*
......@@ -124,7 +124,7 @@ SubsFileDialog::SubsFileDialog( intf_thread_t *_p_intf, wxWindow* _p_parent ):
wxStaticBoxSizer *enc_sizer = new wxStaticBoxSizer( enc_box,
wxHORIZONTAL );
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),
wxDefaultPosition, wxDefaultSize,
0, NULL, wxCB_READONLY | wxCB_SORT );
......
......@@ -2,7 +2,7 @@
* 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>
*
......@@ -321,10 +321,15 @@ static void RenderI420( vout_thread_t *p_vout, picture_t *p_pic,
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++ )
{
......@@ -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 )
- ( 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++ )
{
......@@ -420,10 +430,14 @@ static void RenderYUY2( vout_thread_t *p_vout, picture_t *p_pic,
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++ )
{
......
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