From 72d2a5b460bd6551a5a2e93216c63c12aba1aaee Mon Sep 17 00:00:00 2001 From: Antoine Cellerier Date: Sat, 2 Sep 2006 17:03:36 +0000 Subject: [PATCH] subpicture_t now has a b_pausable attribute. When set to VLC_TRUE (default value is VLC_FALSE), this will keep displaying the subpicture_t when the parent input is paused. This means that subtitles should now be paused when clicking on pause. (refs #29) --- include/vlc_spu.h | 2 +- include/vlc_symbols.h | 2 +- include/vlc_video.h | 2 ++ modules/codec/cvdsub.c | 2 ++ modules/codec/fake.c | 2 ++ modules/codec/spudec/parse.c | 2 ++ modules/codec/subsdec.c | 2 ++ modules/codec/svcdsub.c | 2 ++ modules/stream_out/transcode.c | 5 +++-- src/video_output/video_output.c | 8 +++++++- src/video_output/vout_intf.c | 2 +- src/video_output/vout_subpictures.c | 10 +++++++--- 12 files changed, 32 insertions(+), 9 deletions(-) diff --git a/include/vlc_spu.h b/include/vlc_spu.h index 774af69e72..4b6e9cbe5d 100644 --- a/include/vlc_spu.h +++ b/include/vlc_spu.h @@ -104,7 +104,7 @@ VLC_EXPORT( subpicture_region_t *,__spu_MakeRegion, ( vlc_object_t *, video_form #define spu_DestroyRegion(a,b) __spu_DestroyRegion(VLC_OBJECT(a),b) VLC_EXPORT( void, __spu_DestroyRegion, ( vlc_object_t *, subpicture_region_t * ) ); -VLC_EXPORT( subpicture_t *, spu_SortSubpictures, ( spu_t *, mtime_t ) ); +VLC_EXPORT( subpicture_t *, spu_SortSubpictures, ( spu_t *, mtime_t, vlc_bool_t ) ); VLC_EXPORT( void, spu_RenderSubpictures, ( spu_t *, video_format_t *, picture_t *, picture_t *, subpicture_t *, int, int ) ); /** @}*/ diff --git a/include/vlc_symbols.h b/include/vlc_symbols.h index a4c0669b15..3f5e8474ea 100644 --- a/include/vlc_symbols.h +++ b/include/vlc_symbols.h @@ -323,7 +323,7 @@ struct module_symbols_t subpicture_region_t * (*__spu_CreateRegion_inner) (vlc_object_t *, video_format_t *); subpicture_region_t * (*__spu_MakeRegion_inner) (vlc_object_t *, video_format_t *, picture_t *); void (*__spu_DestroyRegion_inner) (vlc_object_t *, subpicture_region_t *); - subpicture_t * (*spu_SortSubpictures_inner) (spu_t *, mtime_t); + subpicture_t * (*spu_SortSubpictures_inner) (spu_t *, mtime_t, vlc_bool_t); void (*spu_RenderSubpictures_inner) (spu_t *, video_format_t *, picture_t *, picture_t *, subpicture_t *, int, int); char * (*stream_ReadLine_inner) (stream_t *); stream_t * (*__stream_DemuxNew_inner) (vlc_object_t *p_obj, char *psz_demux, es_out_t *out); diff --git a/include/vlc_video.h b/include/vlc_video.h index 35f7351fe3..f4b8947c9c 100644 --- a/include/vlc_video.h +++ b/include/vlc_video.h @@ -246,6 +246,8 @@ struct subpicture_t vlc_bool_t b_ephemer; /**< If this flag is set to true the subtitle will be displayed untill the next one appear */ vlc_bool_t b_fade; /**< enable fading */ + vlc_bool_t b_pausable; /**< subpicture will be paused if + stream is paused */ /**@}*/ subpicture_region_t *p_region; /**< region list composing this subtitle */ diff --git a/modules/codec/cvdsub.c b/modules/codec/cvdsub.c index 23f6e679cd..6210af5ce2 100644 --- a/modules/codec/cvdsub.c +++ b/modules/codec/cvdsub.c @@ -496,6 +496,8 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data ) p_spu = p_dec->pf_spu_buffer_new( p_dec ); if( !p_spu ) return NULL; + p_spu->b_pausable = VLC_TRUE; + p_spu->i_x = p_sys->i_x_start; p_spu->i_x = p_spu->i_x * 3 / 4; /* FIXME: use aspect ratio for x? */ p_spu->i_y = p_sys->i_y_start; diff --git a/modules/codec/fake.c b/modules/codec/fake.c index be899579a2..473936c691 100644 --- a/modules/codec/fake.c +++ b/modules/codec/fake.c @@ -285,6 +285,8 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) picture_t *p_image = (picture_t *)p_dec->p_sys; picture_t *p_pic; + printf("pouet\n"); + if( pp_block == NULL || !*pp_block ) return NULL; p_pic = p_dec->pf_vout_buffer_new( p_dec ); if( p_pic == NULL ) diff --git a/modules/codec/spudec/parse.c b/modules/codec/spudec/parse.c index 6caebf6f0d..38289c0cc5 100644 --- a/modules/codec/spudec/parse.c +++ b/modules/codec/spudec/parse.c @@ -71,6 +71,8 @@ subpicture_t * E_(ParsePacket)( decoder_t *p_dec ) p_spu = p_dec->pf_spu_buffer_new( p_dec ); if( !p_spu ) return NULL; + p_spu->b_pausable = VLC_TRUE; + /* Rationale for the "p_spudec->i_rle_size * 4": we are going to * expand the RLE stuff so that we won't need to read nibbles later * on. This will speed things up a lot. Plus, we'll only need to do diff --git a/modules/codec/subsdec.c b/modules/codec/subsdec.c index 2d7a8b52f5..ee5ef44808 100644 --- a/modules/codec/subsdec.c +++ b/modules/codec/subsdec.c @@ -381,6 +381,8 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block ) return NULL; } + p_spu->b_pausable = VLC_TRUE; + /* Create a new subpicture region */ memset( &fmt, 0, sizeof(video_format_t) ); fmt.i_chroma = VLC_FOURCC('T','E','X','T'); diff --git a/modules/codec/svcdsub.c b/modules/codec/svcdsub.c index 67d97e71b4..b6135431d1 100644 --- a/modules/codec/svcdsub.c +++ b/modules/codec/svcdsub.c @@ -466,6 +466,8 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data ) p_spu = p_dec->pf_spu_buffer_new( p_dec ); if( !p_spu ) return NULL; + p_spu->b_pausable = VLC_TRUE; + p_spu->i_x = p_sys->i_x_start; p_spu->i_y = p_sys->i_y_start; p_spu->i_start = p_data->i_pts; diff --git a/modules/stream_out/transcode.c b/modules/stream_out/transcode.c index d16007c16b..89866cc3fe 100644 --- a/modules/stream_out/transcode.c +++ b/modules/stream_out/transcode.c @@ -2319,7 +2319,8 @@ static int transcode_video_process( sout_stream_t *p_stream, /* Check if we have a subpicture to overlay */ if( p_sys->p_spu ) { - p_subpic = spu_SortSubpictures( p_sys->p_spu, p_pic->date ); + p_subpic = spu_SortSubpictures( p_sys->p_spu, p_pic->date, + VLC_FALSE /* Fixme: check if stream is paused */ ); /* TODO: get another pic */ } @@ -2884,7 +2885,7 @@ static int transcode_osd_process( sout_stream_t *p_stream, /* Check if we have a subpicture to send */ if( p_sys->p_spu && in->i_dts > 0) { - p_subpic = spu_SortSubpictures( p_sys->p_spu, in->i_dts ); + p_subpic = spu_SortSubpictures( p_sys->p_spu, in->i_dts, VLC_FALSE ); } else { diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c index 50978dabfe..886dd4b2ea 100644 --- a/src/video_output/video_output.c +++ b/src/video_output/video_output.c @@ -780,6 +780,8 @@ static void RunThread( vout_thread_t *p_vout) display_date = 0; current_date = mdate(); + p_input = NULL; + i_loops++; if( i_loops % 20 == 0 ) { @@ -1042,7 +1044,11 @@ static void RunThread( vout_thread_t *p_vout) */ if( display_date > 0 ) { - p_subpic = spu_SortSubpictures( p_vout->p_spu, display_date ); + if( !p_input ) + p_input = vlc_object_find( p_vout, VLC_OBJECT_INPUT, + FIND_PARENT ); + p_subpic = spu_SortSubpictures( p_vout->p_spu, display_date, + p_input ? var_GetBool( p_input, "state" ) == PAUSE_S : VLC_FALSE ); } /* diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c index f9c1407a41..d1041be973 100644 --- a/src/video_output/vout_intf.c +++ b/src/video_output/vout_intf.c @@ -445,7 +445,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) picture_t *p_pif; vlc_value_t val, format; DIR *path; - + int i_ret; var_Get( p_vout, "snapshot-path", &val ); diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c index 5d1c19a755..912a9f4797 100644 --- a/src/video_output/vout_subpictures.c +++ b/src/video_output/vout_subpictures.c @@ -401,6 +401,7 @@ subpicture_t *spu_CreateSubpicture( spu_t *p_spu ) memset( p_subpic, 0, sizeof(subpicture_t) ); p_subpic->i_status = RESERVED_SUBPICTURE; p_subpic->b_absolute = VLC_TRUE; + p_subpic->b_pausable = VLC_FALSE; p_subpic->b_fade = VLC_FALSE; p_subpic->i_alpha = 0xFF; p_subpic->p_region = 0; @@ -412,7 +413,7 @@ subpicture_t *spu_CreateSubpicture( spu_t *p_spu ) p_subpic->pf_create_region = __spu_CreateRegion; p_subpic->pf_make_region = __spu_MakeRegion; p_subpic->pf_destroy_region = __spu_DestroyRegion; - + return p_subpic; } @@ -823,7 +824,8 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt, * to be removed if a newer one is available), which makes it a lot * more difficult to guess if a subpicture has to be rendered or not. *****************************************************************************/ -subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t display_date ) +subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t display_date, + vlc_bool_t b_paused ) { int i_index, i_channel; subpicture_t *p_subpic = NULL; @@ -869,7 +871,9 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t display_date ) if( display_date > p_spu->p_subpicture[i_index].i_stop && ( !p_spu->p_subpicture[i_index].b_ephemer || p_spu->p_subpicture[i_index].i_stop > - p_spu->p_subpicture[i_index].i_start ) ) + p_spu->p_subpicture[i_index].i_start ) && + !( p_spu->p_subpicture[i_index].b_pausable && + b_paused ) ) { /* Too late, destroy the subpic */ spu_DestroySubpicture( p_spu, &p_spu->p_subpicture[i_index] ); -- 2.39.2