Commit 4cf8c490 authored by Rocky Bernstein's avatar Rocky Bernstein
Browse files

CVD subtitle selection works via front-end spu-es variable changes.

SVCD subtitles still can only be changed via --spu-channel. 

The video subtitle menu titles for both is a bit whacked out.
parent 406b8874
......@@ -1431,6 +1431,34 @@ E_(DebugCallback) ( vlc_object_t *p_this, const char *psz_name,
return VLC_SUCCESS;
}
/*
The front-ends change spu-es - which sort of represents a symbolic
name. Internally we use spu-channel which runs from 0..3.
So we add a callback to intercept changes to spu-es and change them
to updates to spu-channel. Ugly.
*/
static int
VCDSPUCallback( vlc_object_t *p_this, const char *psz_variable,
vlc_value_t old_val, vlc_value_t new_val, void *param)
{
input_thread_t *p_input = (input_thread_t *)p_this;
thread_vcd_data_t *p_vcd = (thread_vcd_data_t *)p_input->p_access_data;
vlc_value_t val;
dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EVENT), "old_val: %x, new_val %x",
old_val.i_int, new_val.i_int);
val.i_int = new_val.i_int;
var_Set( p_this, "spu-channel", val );
return VLC_SUCCESS;
}
/*****************************************************************************
Open: open VCD.
read in meta-information about VCD: the number of tracks, segments,
......@@ -1582,6 +1610,9 @@ E_(Open) ( vlc_object_t *p_this )
free( psz_source );
var_AddCallback( p_this, "spu-es", VCDSPUCallback, NULL );
return VLC_SUCCESS;
err_exit:
free( psz_source );
......@@ -1599,6 +1630,8 @@ E_(Close) ( vlc_object_t *p_this )
thread_vcd_data_t *p_vcd = (thread_vcd_data_t *)p_input->p_access_data;
dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT), "VCDClose" );
var_DelCallback( p_this, "spu-es", VCDSPUCallback, NULL );
vcdinfo_close( p_vcd->vcd );
free( p_vcd->p_entries );
......
......@@ -2,7 +2,7 @@
* cvd.c : CVD Subtitle decoder thread
*****************************************************************************
* Copyright (C) 2003, 2004 VideoLAN
* $Id: cvd.c,v 1.15 2004/01/25 19:27:09 rocky Exp $
* $Id$
*
* Authors: Rocky Bernstein
* based on code from:
......@@ -39,13 +39,13 @@
/*****************************************************************************
* Module descriptor.
*****************************************************************************/
static int DecoderOpen ( vlc_object_t * );
static int VCDSubOpen ( vlc_object_t * );
static int PacketizerOpen( vlc_object_t * );
vlc_module_begin();
set_description( _("CVD subtitle decoder") );
set_capability( "decoder", 50 );
set_callbacks( DecoderOpen, VCDSubClose );
set_callbacks( VCDSubOpen, VCDSubClose );
add_integer ( MODULE_STRING "-debug", 0, NULL,
DEBUG_TEXT, DEBUG_LONGTEXT, VLC_TRUE );
......@@ -80,13 +80,13 @@ static block_t *Packetize( decoder_t *, block_t ** );
/*****************************************************************************
* DecoderOpen
* VCDSubOpen
*****************************************************************************
* Tries to launch a decoder and return score so that the interface is able
* to chose.
*****************************************************************************/
static int
DecoderOpen( vlc_object_t *p_this )
VCDSubOpen( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys;
......@@ -128,7 +128,7 @@ static int PacketizerOpen( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t*)p_this;
if( DecoderOpen( p_this ) )
if( VCDSubOpen( p_this ) )
{
return VLC_EGENERIC;
}
......@@ -235,8 +235,27 @@ Reassemble( decoder_t *p_dec, block_t **pp_block )
p_buffer[5], p_buffer[6],
p_block->i_buffer);
if( config_GetInt( p_dec, "spu-channel" ) != p_buffer[0] )
return NULL;
/* Attach to our input thread and see if subtitle is selected. */
{
vlc_object_t * p_input;
vlc_value_t val;
p_input = vlc_object_find( p_dec, VLC_OBJECT_INPUT, FIND_PARENT );
if( !p_input ) return NULL;
if( var_Get( p_input, "spu-channel", &val ) ) return NULL;
/* Number could be 0bd, 1bd, 2bd, 3bd for 0..3. If so
reduce it to 0..3.
*/
if ( (val.i_int & 0xff) == 0xbd ) val.i_int >>= 8;
if( val.i_int == -1 || val.i_int != p_buffer[0] )
return NULL;
}
/* From the scant data on the format, there is only only way known
to detect the first packet in a subtitle. The first packet
......
......@@ -2,7 +2,7 @@
* ogt.c : Overlay Graphics Text (SVCD subtitles) decoder thread
*****************************************************************************
* Copyright (C) 2003, 2004 VideoLAN
* $Id: ogt.c,v 1.12 2004/01/25 19:27:09 rocky Exp $
* $Id$
*
* Author: Rocky Bernstein
* based on code from:
......@@ -39,13 +39,13 @@
/*****************************************************************************
* Module descriptor.
*****************************************************************************/
static int DecoderOpen ( vlc_object_t * );
static int VCDSubOpen ( vlc_object_t * );
static int PacketizerOpen( vlc_object_t * );
vlc_module_begin();
set_description( _("Philips OGT (SVCD subtitle) decoder") );
set_capability( "decoder", 50 );
set_callbacks( DecoderOpen, VCDSubClose );
set_callbacks( VCDSubOpen, VCDSubClose );
add_integer ( MODULE_STRING "-debug", 0, NULL,
DEBUG_TEXT, DEBUG_LONGTEXT, VLC_TRUE );
......@@ -80,13 +80,13 @@ static block_t *Packetize( decoder_t *, block_t ** );
/*****************************************************************************
* DecoderOpen
* VCDSubOpen
*****************************************************************************
* Tries to launch a decoder and return score so that the interface is able
* to chose.
*****************************************************************************/
static int
DecoderOpen( vlc_object_t *p_this )
VCDSubOpen( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys;
......@@ -128,7 +128,7 @@ static int PacketizerOpen( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t*)p_this;
if( DecoderOpen( p_this ) )
if( VCDSubOpen( p_this ) )
{
return VLC_EGENERIC;
}
......@@ -244,8 +244,25 @@ Reassemble( decoder_t *p_dec, block_t **pp_block )
p_buffer[1], p_buffer[2], p_buffer[3], p_buffer[4],
p_block->i_buffer);
#if 1
if( config_GetInt( p_dec, "spu-channel" ) != p_buffer[1] )
return NULL;
#else
/* Attach to our input thread and see if subtitle is selected. */
{
vlc_object_t * p_input;
vlc_value_t val;
p_input = vlc_object_find( p_dec, VLC_OBJECT_INPUT, FIND_PARENT );
if( !p_input ) return NULL;
if( var_Get( p_input, "spu-channel", &val ) ) return NULL;
if( val.i_int == -1 || val.i_int != p_buffer[1] )
return NULL;
}
#endif
if ( p_sys->state == SUBTITLE_BLOCK_EMPTY ) {
i_expected_image = p_sys->i_image+1;
......
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