Commit fabf2399 authored by Laurent Aimar's avatar Laurent Aimar

Fixed some corner case errors with SPU.

They were introduced by [9b8c543c].
For example: the PiP for a snapshot was not shown when the stream
was paused.
parent b5bcf711
...@@ -115,7 +115,7 @@ VLC_EXPORT( void, spu_DisplaySubpicture, ( spu_t *, subpicture_t * ) ); ...@@ -115,7 +115,7 @@ VLC_EXPORT( void, spu_DisplaySubpicture, ( spu_t *, subpicture_t * ) );
* *
* The returned list can only be used by spu_RenderSubpictures. * The returned list can only be used by spu_RenderSubpictures.
*/ */
VLC_EXPORT( subpicture_t *, spu_SortSubpictures, ( spu_t *, mtime_t render_date, bool b_subtitle_only ) ); VLC_EXPORT( subpicture_t *, spu_SortSubpictures, ( spu_t *, mtime_t render_subtitle_date, bool b_subtitle_only ) );
/** /**
* This function renders a list of subpicture_t on the provided picture. * This function renders a list of subpicture_t on the provided picture.
...@@ -123,7 +123,7 @@ VLC_EXPORT( subpicture_t *, spu_SortSubpictures, ( spu_t *, mtime_t render_date, ...@@ -123,7 +123,7 @@ VLC_EXPORT( subpicture_t *, spu_SortSubpictures, ( spu_t *, mtime_t render_date,
* \param p_fmt_dst is the format of the destination picture. * \param p_fmt_dst is the format of the destination picture.
* \param p_fmt_src is the format of the original(source) video. * \param p_fmt_src is the format of the original(source) video.
*/ */
VLC_EXPORT( void, spu_RenderSubpictures, ( spu_t *, picture_t *, const video_format_t *p_fmt_dst, subpicture_t *p_list, const video_format_t *p_fmt_src, mtime_t render_date ) ); VLC_EXPORT( void, spu_RenderSubpictures, ( spu_t *, picture_t *, const video_format_t *p_fmt_dst, subpicture_t *p_list, const video_format_t *p_fmt_src, mtime_t render_subtitle_date ) );
/** @}*/ /** @}*/
......
...@@ -1180,14 +1180,14 @@ static void* RunThread( void *p_this ) ...@@ -1180,14 +1180,14 @@ static void* RunThread( void *p_this )
mtime_t spu_render_time; mtime_t spu_render_time;
if( p_vout->p->b_paused ) if( p_vout->p->b_paused )
spu_render_time = p_vout->p->i_pause_date; spu_render_time = p_vout->p->i_pause_date;
else if( p_picture )
spu_render_time = p_picture->date > 1 ? p_picture->date : mdate();
else else
spu_render_time = p_picture ? p_picture->date : mdate(); spu_render_time = 0;
subpicture_t *p_subpic = NULL;
if( spu_render_time > 1 )
p_subpic = spu_SortSubpictures( p_vout->p_spu,
spu_render_time, b_snapshot );
subpicture_t *p_subpic = spu_SortSubpictures( p_vout->p_spu,
spu_render_time,
b_snapshot );
/* /*
* Perform rendering * Perform rendering
*/ */
......
...@@ -353,11 +353,11 @@ void spu_RenderSubpictures( spu_t *p_spu, ...@@ -353,11 +353,11 @@ void spu_RenderSubpictures( spu_t *p_spu,
picture_t *p_pic_dst, const video_format_t *p_fmt_dst, picture_t *p_pic_dst, const video_format_t *p_fmt_dst,
subpicture_t *p_subpic_list, subpicture_t *p_subpic_list,
const video_format_t *p_fmt_src, const video_format_t *p_fmt_src,
mtime_t render_date ) mtime_t render_subtitle_date )
{ {
spu_private_t *p_sys = p_spu->p; spu_private_t *p_sys = p_spu->p;
const mtime_t system_date = mdate(); const mtime_t render_osd_date = mdate();
const int i_source_video_width = p_fmt_src->i_width; const int i_source_video_width = p_fmt_src->i_width;
const int i_source_video_height = p_fmt_src->i_height; const int i_source_video_height = p_fmt_src->i_height;
...@@ -388,7 +388,7 @@ void spu_RenderSubpictures( spu_t *p_spu, ...@@ -388,7 +388,7 @@ void spu_RenderSubpictures( spu_t *p_spu,
fmt_org.i_visible_height = i_source_video_height; fmt_org.i_visible_height = i_source_video_height;
p_subpic->pf_update_regions( p_spu, p_subpic, &fmt_org, p_subpic->pf_update_regions( p_spu, p_subpic, &fmt_org,
p_subpic->b_subtitle ? render_date : system_date ); p_subpic->b_subtitle ? render_subtitle_date : render_osd_date );
} }
/* */ /* */
...@@ -507,7 +507,7 @@ void spu_RenderSubpictures( spu_t *p_spu, ...@@ -507,7 +507,7 @@ void spu_RenderSubpictures( spu_t *p_spu,
SpuRenderRegion( p_spu, p_pic_dst, &area, SpuRenderRegion( p_spu, p_pic_dst, &area,
p_subpic, p_region, scale, p_fmt_dst, p_subpic, p_region, scale, p_fmt_dst,
p_subtitle_area, i_subtitle_area, p_subtitle_area, i_subtitle_area,
p_subpic->b_subtitle ? render_date : system_date ); p_subpic->b_subtitle ? render_subtitle_date : render_osd_date );
if( p_subpic->b_subtitle ) if( p_subpic->b_subtitle )
{ {
...@@ -542,13 +542,13 @@ void spu_RenderSubpictures( spu_t *p_spu, ...@@ -542,13 +542,13 @@ void spu_RenderSubpictures( spu_t *p_spu,
* to be removed if a newer one is available), which makes it a lot * 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. * more difficult to guess if a subpicture has to be rendered or not.
*****************************************************************************/ *****************************************************************************/
subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_date, subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_subtitle_date,
bool b_subtitle_only ) bool b_subtitle_only )
{ {
spu_private_t *p_sys = p_spu->p; spu_private_t *p_sys = p_spu->p;
int i_channel; int i_channel;
subpicture_t *p_subpic = NULL; subpicture_t *p_subpic = NULL;
const mtime_t system_date = mdate(); const mtime_t render_osd_date = mdate();
/* Update sub-filter chain */ /* Update sub-filter chain */
vlc_mutex_lock( &p_sys->lock ); vlc_mutex_lock( &p_sys->lock );
...@@ -566,7 +566,7 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_date, ...@@ -566,7 +566,7 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_date,
} }
/* Run subpicture filters */ /* Run subpicture filters */
filter_chain_SubFilter( p_sys->p_chain, render_date ); filter_chain_SubFilter( p_sys->p_chain, render_osd_date );
vlc_mutex_lock( &p_sys->lock ); vlc_mutex_lock( &p_sys->lock );
...@@ -578,9 +578,9 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_date, ...@@ -578,9 +578,9 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_date,
bool pb_available_late[VOUT_MAX_SUBPICTURES]; bool pb_available_late[VOUT_MAX_SUBPICTURES];
int i_available = 0; int i_available = 0;
mtime_t start_date = render_date; mtime_t start_date = render_subtitle_date;
mtime_t ephemer_subtitle_date = 0; mtime_t ephemer_subtitle_date = 0;
mtime_t ephemer_system_date = 0; mtime_t ephemer_osd_date = 0;
int64_t i_ephemer_subtitle_order = INT64_MIN; int64_t i_ephemer_subtitle_order = INT64_MIN;
int64_t i_ephemer_system_order = INT64_MIN; int64_t i_ephemer_system_order = INT64_MIN;
int i_index; int i_index;
...@@ -605,6 +605,7 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_date, ...@@ -605,6 +605,7 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_date,
{ {
continue; continue;
} }
const mtime_t render_date = p_current->b_subtitle ? render_subtitle_date : render_osd_date;
if( render_date && if( render_date &&
render_date < p_current->i_start ) render_date < p_current->i_start )
{ {
...@@ -612,7 +613,7 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_date, ...@@ -612,7 +613,7 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_date,
continue; continue;
} }
mtime_t *pi_ephemer_date = p_current->b_subtitle ? &ephemer_subtitle_date : &ephemer_system_date; mtime_t *pi_ephemer_date = p_current->b_subtitle ? &ephemer_subtitle_date : &ephemer_osd_date;
int64_t *pi_ephemer_order = p_current->b_subtitle ? &i_ephemer_subtitle_order : &i_ephemer_system_order; int64_t *pi_ephemer_order = p_current->b_subtitle ? &i_ephemer_subtitle_order : &i_ephemer_system_order;
if( p_current->i_start >= *pi_ephemer_date ) if( p_current->i_start >= *pi_ephemer_date )
{ {
...@@ -623,7 +624,7 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_date, ...@@ -623,7 +624,7 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_date,
b_stop_valid = !p_current->b_ephemer || p_current->i_stop > p_current->i_start; b_stop_valid = !p_current->b_ephemer || p_current->i_stop > p_current->i_start;
b_late = b_stop_valid && p_current->i_stop <= p_current->b_subtitle ? render_date : system_date; b_late = b_stop_valid && p_current->i_stop <= render_date;
/* start_date will be used for correct automatic overlap support /* start_date will be used for correct automatic overlap support
* in case picture that should not be displayed anymore (display_time) * in case picture that should not be displayed anymore (display_time)
...@@ -649,8 +650,8 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_date, ...@@ -649,8 +650,8 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_date,
subpicture_t *p_current = p_available_subpic[i_index]; subpicture_t *p_current = p_available_subpic[i_index];
bool b_late = pb_available_late[i_index]; bool b_late = pb_available_late[i_index];
const mtime_t stop_date = p_current->b_subtitle ? __MAX( start_date, p_sys->i_last_sort_date ) : system_date; const mtime_t stop_date = p_current->b_subtitle ? __MAX( start_date, p_sys->i_last_sort_date ) : render_osd_date;
const mtime_t ephemer_date = p_current->b_subtitle ? ephemer_subtitle_date : ephemer_system_date; const mtime_t ephemer_date = p_current->b_subtitle ? ephemer_subtitle_date : ephemer_osd_date;
const int64_t i_ephemer_order = p_current->b_subtitle ? i_ephemer_subtitle_order : i_ephemer_system_order; const int64_t i_ephemer_order = p_current->b_subtitle ? i_ephemer_subtitle_order : i_ephemer_system_order;
/* Destroy late and obsolete ephemer subpictures */ /* Destroy late and obsolete ephemer subpictures */
...@@ -671,7 +672,7 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_date, ...@@ -671,7 +672,7 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_date,
} }
} }
p_sys->i_last_sort_date = render_date; p_sys->i_last_sort_date = render_subtitle_date;
vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_unlock( &p_sys->lock );
return p_subpic; return p_subpic;
......
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