Commit 04372454 authored by Jean-Paul Saman's avatar Jean-Paul Saman Committed by Jean-Paul Saman

Added transparency to vbi pages and did some cleanup and fixed compiler warnings.

parent 63ec9720
......@@ -67,6 +67,10 @@ static subpicture_t *Decode( decoder_t *, block_t ** );
#define PAGE_LONGTEXT N_("Open the indicated Teletext page." \
"Default page is index 100")
#define OPAQUE_TEXT N_("Text is always opaque")
#define OPAQUE_LONGTEXT N_("Setting vbi-opaque to false " \
"makes the boxed text transparent." )
vlc_module_begin();
set_description( _("VBI and Teletext decoder") );
set_shortname( "VBI & Teletext" );
......@@ -77,6 +81,8 @@ vlc_module_begin();
add_integer( "vbi-page", 100, NULL,
PAGE_TEXT, PAGE_LONGTEXT, VLC_FALSE );
add_bool( "vbi-opaque", VLC_TRUE, NULL,
OPAQUE_TEXT, OPAQUE_LONGTEXT, VLC_FALSE );
vlc_module_end();
/****************************************************************************
......@@ -90,6 +96,7 @@ struct decoder_sys_t
unsigned int i_wanted_page;
unsigned int i_last_page;
vlc_bool_t b_update;
vlc_bool_t b_opaque;
};
static void event_handler(vbi_event *ev, void *user_data);
......@@ -138,6 +145,9 @@ static int Open( vlc_object_t *p_this )
p_sys->i_wanted_page = var_CreateGetInteger( p_dec->p_libvlc,
"vbi-page" );
var_AddCallback( p_dec->p_libvlc, "vbi-page", RequestPage, p_sys );
p_sys->b_opaque = var_CreateGetBool( p_dec, "vbi-opaque" );
return VLC_SUCCESS;
}
......@@ -169,6 +179,11 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
uint8_t *p_pos;
unsigned int i_left;
/* part of kludge */
uint32_t *p_begin, *p_end;
unsigned int x = 0, y = 0;
vbi_opacity opacity;
/* end part of kludge */
if( (pp_block == NULL) || (*pp_block == NULL) )
return NULL;
......@@ -191,7 +206,6 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
vbi_decode( p_sys->p_vbi_dec, p_sliced, i_lines, i_pts / 90000.0 );
}
stop_decode:
/* Try to see if the page we want is in the cache yet */
b_cached = vbi_fetch_vt_page( p_sys->p_vbi_dec, &p_page,
vbi_dec2bcd( p_sys->i_wanted_page ),
......@@ -254,24 +268,62 @@ stop_decode:
p_spu->p_region->picture.p->i_lines = p_page.rows * 10;
p_spu->p_region->picture.p->i_pitch = p_page.columns * 12 * 4;
/* Kludge since zvbi doesn't provide an option to specify opacity. */
p_begin = (uint32_t *)p_spu->p_region->picture.p->p_pixels;
p_end = (uint32_t *)p_spu->p_region->picture.p->p_pixels+(fmt.i_width * fmt.i_height);
for( ; p_begin < p_end; p_begin++ )
{
opacity = p_page.text[ y / 10 * p_page.columns + x / 12 ].opacity;
switch( opacity )
{
/* Show video instead of this character */
case VBI_TRANSPARENT_SPACE:
*p_begin = 0;
break;
/* To make the boxed text "closed captioning" transparent
* change VLC_TRUE to VLC_FALSE.
*/
case VBI_OPAQUE:
if( p_sys->b_opaque )
break;
/* Full text transparency. only foreground color is show */
case VBI_TRANSPARENT_FULL:
/* Transparency for boxed text */
case VBI_SEMI_TRANSPARENT:
if( (*p_begin & 0xffffff00) == 0xff )
*p_begin = 0;
break;
default:
break;
}
x++;
if( x >= fmt.i_width )
{
x = 0;
y++;
}
}
/* end of kludge */
#if 0
/* Separate subs and print as ASCII */
unsigned int i_total, i_textsize = 7000;
char p_text[7000];
i_total = vbi_print_page_region( &p_page, p_text, i_textsize, "ISO-8859-1", 0, 0, 0, 0, p_page.columns, p_page.rows );
i_total = vbi_print_page_region( &p_page, p_text, i_textsize,
"ISO-8859-1", 0, 0, 0, 0,
p_page.columns, p_page.rows );
p_text[i_total] = '\0';
msg_Dbg( p_dec, "page %x-%x\n%s", p_page.pgno, p_page.subno, p_text );
#endif
//if( p_page != NULL)
vbi_unref_page( &p_page );
vbi_unref_page( &p_page );
block_Release( p_block );
return p_spu;
error:
//if( p_page != NULL)
vbi_unref_page( &p_page );
vbi_unref_page( &p_page );
if ( p_spu != NULL )
{
p_dec->pf_spu_buffer_del( p_dec, p_spu );
......@@ -321,3 +373,4 @@ static int RequestPage( vlc_object_t *p_this, char const *psz_cmd,
return VLC_SUCCESS;
}
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