Commit 41d576e2 authored by Antoine Cellerier's avatar Antoine Cellerier

Fix decoding of teletext in ps files (the zvbi decoder expects the full PES packet).

parent aa4bc80b
...@@ -189,16 +189,31 @@ static int Open( vlc_object_t *p_this ) ...@@ -189,16 +189,31 @@ static int Open( vlc_object_t *p_this )
#endif #endif
p_sys->b_update = VLC_FALSE; p_sys->b_update = VLC_FALSE;
p_sys->p_vbi_dec = vbi_decoder_new(); p_sys->p_vbi_dec = vbi_decoder_new();
if( p_sys->p_vbi_dec == NULL )
{
msg_Err( p_dec, "VBI decoder could not be created." );
Close( p_this );
return VLC_ENOMEM;
}
p_sys->p_dvb_demux = vbi_dvb_pes_demux_new( NULL, NULL ); p_sys->p_dvb_demux = vbi_dvb_pes_demux_new( NULL, NULL );
if( (p_sys->p_vbi_dec == NULL) || (p_sys->p_dvb_demux == NULL) ) if( p_sys->p_dvb_demux == NULL )
{ {
msg_Err( p_dec, "VBI decoder/demux could not be created." ); msg_Err( p_dec, "VBI demux could not be created." );
if( p_sys->p_vbi_dec ) vbi_decoder_delete( p_sys->p_vbi_dec );
Close( p_this ); Close( p_this );
return VLC_ENOMEM; return VLC_ENOMEM;
} }
#if 0
vbi_dvb_demux_set_log_fn( p_sys->p_dvb_demux, VBI_LOG_ERROR|VBI_LOG_WARNING|VBI_LOG_NOTICE|VBI_LOG_INFO|VBI_LOG_DEBUG|VBI_LOG_DRIVER/*|VBI_LOG_DEBUG2*/, vbi_log_on_stderr, NULL );
vbi_set_log_fn( VBI_LOG_ERROR|VBI_LOG_WARNING|VBI_LOG_NOTICE|VBI_LOG_INFO|VBI_LOG_DEBUG|VBI_LOG_DRIVER/*|VBI_LOG_DEBUG2*/, vbi_log_on_stderr, NULL );
#endif
vbi_event_handler_register( p_sys->p_vbi_dec, VBI_EVENT_TTX_PAGE | vbi_event_handler_register( p_sys->p_vbi_dec, VBI_EVENT_TTX_PAGE |
VBI_EVENT_CAPTION | VBI_EVENT_NETWORK | VBI_EVENT_CAPTION | VBI_EVENT_NETWORK |
VBI_EVENT_ASPECT | VBI_EVENT_PROG_INFO, VBI_EVENT_ASPECT | VBI_EVENT_PROG_INFO,
...@@ -284,6 +299,21 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block ) ...@@ -284,6 +299,21 @@ 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 ); vbi_decode( p_sys->p_vbi_dec, p_sliced, i_lines, i_pts / 90000.0 );
} }
#if 0
/* Hacky way to list available pages */
{
int i;
for( i = 0; i < 1000; i++ )
{
if( vbi_fetch_vt_page( p_sys->p_vbi_dec, &p_page,
vbi_dec2bcd( i ),
VBI_ANY_SUBNO, VBI_WST_LEVEL_3p5,
25, FALSE ) )
msg_Err( p_dec, "Got page %d\n", i);
}
}
#endif
/* Try to see if the page we want is in the cache yet */ /* 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, b_cached = vbi_fetch_vt_page( p_sys->p_vbi_dec, &p_page,
vbi_dec2bcd( p_sys->i_wanted_page ), vbi_dec2bcd( p_sys->i_wanted_page ),
...@@ -367,7 +397,8 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block ) ...@@ -367,7 +397,8 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
"UTF-8", 0, 0, 0, 0, p_page.columns, p_page.rows ); "UTF-8", 0, 0, 0, 0, p_page.columns, p_page.rows );
p_text[i_total] = '\0'; p_text[i_total] = '\0';
/* Strip off the pagenumber */ /* Strip off the pagenumber */
if( i_total <= 40 ) goto error; if( i_total <= 40 )
goto error;
p_spu->p_region->psz_text = strdup( &p_text[8] ); p_spu->p_region->psz_text = strdup( &p_text[8] );
p_spu->p_region->fmt.i_height = p_spu->p_region->fmt.i_visible_height = p_page.rows + 1; p_spu->p_region->fmt.i_height = p_spu->p_region->fmt.i_visible_height = p_page.rows + 1;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ps.c: Program Stream demux module for VLC. * ps.c: Program Stream demux module for VLC.
***************************************************************************** *****************************************************************************
* Copyright (C) 2004 the VideoLAN team * Copyright (C) 2004 the VideoLAN team
* $Id$ * $Id: 5abacc54974b475c8ab6764a1dbeb21f3ff289cd $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -125,7 +125,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -125,7 +125,7 @@ static int Open( vlc_object_t *p_this )
p_sys->i_length = -1; p_sys->i_length = -1;
p_sys->i_current_pts = (mtime_t) 0; p_sys->i_current_pts = (mtime_t) 0;
p_sys->i_time_track = -1; p_sys->i_time_track = -1;
p_sys->b_lost_sync = VLC_FALSE; p_sys->b_lost_sync = VLC_FALSE;
p_sys->b_have_pack = VLC_FALSE; p_sys->b_have_pack = VLC_FALSE;
p_sys->b_seekable = VLC_FALSE; p_sys->b_seekable = VLC_FALSE;
...@@ -252,7 +252,7 @@ static void FindLength( demux_t *p_demux ) ...@@ -252,7 +252,7 @@ static void FindLength( demux_t *p_demux )
i_size = stream_Size( p_demux->s ); i_size = stream_Size( p_demux->s );
i_end = __MAX( 0, __MIN( 200000, i_size ) ); i_end = __MAX( 0, __MIN( 200000, i_size ) );
stream_Seek( p_demux->s, i_size - i_end ); stream_Seek( p_demux->s, i_size - i_end );
while( !p_demux->b_die && Demux2( p_demux, VLC_TRUE ) > 0 ); while( !p_demux->b_die && Demux2( p_demux, VLC_TRUE ) > 0 );
if( i_current_pos >= 0 ) stream_Seek( p_demux->s, i_current_pos ); if( i_current_pos >= 0 ) stream_Seek( p_demux->s, i_current_pos );
} }
...@@ -386,7 +386,7 @@ static int Demux( demux_t *p_demux ) ...@@ -386,7 +386,7 @@ static int Demux( demux_t *p_demux )
p_sys->i_scr = -1; p_sys->i_scr = -1;
if( tk->b_seen && tk->es && if( tk->b_seen && tk->es &&
!ps_pkt_parse_pes( p_pkt, tk->i_skip ) ) (tk->fmt.i_codec == VLC_FOURCC('t','e','l','x') || !ps_pkt_parse_pes( p_pkt, tk->i_skip )) )
{ {
if( !b_new && !p_sys->b_have_pack && tk->fmt.i_cat == AUDIO_ES && p_pkt->i_pts > 0 ) if( !b_new && !p_sys->b_have_pack && tk->fmt.i_cat == AUDIO_ES && p_pkt->i_pts > 0 )
{ {
......
...@@ -393,7 +393,7 @@ static inline int ps_id_to_type( ps_psm_t *p_psm, int i_id ) ...@@ -393,7 +393,7 @@ static inline int ps_id_to_type( ps_psm_t *p_psm, int i_id )
int i; int i;
for( i = 0; p_psm && i < p_psm->i_es; i++ ) for( i = 0; p_psm && i < p_psm->i_es; i++ )
{ {
if( p_psm->es[i]->i_id == i_id ) return p_psm->es[i]->i_type; if( p_psm->es[i]->i_id == i_id ) return p_psm->es[i]->i_type;
} }
return 0; return 0;
} }
...@@ -403,7 +403,7 @@ static inline uint8_t *ps_id_to_lang( ps_psm_t *p_psm, int i_id ) ...@@ -403,7 +403,7 @@ static inline uint8_t *ps_id_to_lang( ps_psm_t *p_psm, int i_id )
int i; int i;
for( i = 0; p_psm && i < p_psm->i_es; i++ ) for( i = 0; p_psm && i < p_psm->i_es; i++ )
{ {
if( p_psm->es[i]->i_id == i_id ) return p_psm->es[i]->lang; if( p_psm->es[i]->i_id == i_id ) return p_psm->es[i]->lang;
} }
return 0; return 0;
} }
...@@ -499,7 +499,7 @@ static inline int ps_psm_fill( ps_psm_t *p_psm, block_t *p_pkt, ...@@ -499,7 +499,7 @@ static inline int ps_psm_fill( ps_psm_t *p_psm, block_t *p_pkt,
p_psm->es = realloc( p_psm->es, sizeof(ps_es_t *) * (p_psm->i_es+1) ); p_psm->es = realloc( p_psm->es, sizeof(ps_es_t *) * (p_psm->i_es+1) );
p_psm->es[p_psm->i_es] = malloc( sizeof(ps_es_t) ); p_psm->es[p_psm->i_es] = malloc( sizeof(ps_es_t) );
*p_psm->es[p_psm->i_es++] = es; *p_psm->es[p_psm->i_es++] = es;
i_es_base += 4 + i_info_length; i_es_base += 4 + i_info_length;
} }
/* TODO: CRC */ /* TODO: CRC */
......
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