Commit af37ba18 authored by Laurent Aimar's avatar Laurent Aimar

Added new picture helpers (picture_Yield, picture_Release,

picture_CopyProperties) and use them inside vlc core.
parent efa30ea7
...@@ -115,6 +115,39 @@ struct picture_t ...@@ -115,6 +115,39 @@ struct picture_t
struct picture_t *p_next; struct picture_t *p_next;
}; };
/**
* This function will increase the picture reference count.
* It will not have any effect on picture obtained from vout
*/
static inline void picture_Yield( picture_t *p_picture )
{
if( p_picture->pf_release )
p_picture->i_refcount++;
}
/**
* This function will release a picture.
* It will not have any effect on picture obtained from vout
*/
static inline void picture_Release( picture_t *p_picture )
{
/* FIXME why do we let pf_release handle the i_refcount ? */
if( p_picture->pf_release )
p_picture->pf_release( p_picture );
}
/**
* This function will copy all picture dynamic properties.
*/
static inline void picture_CopyProperties( picture_t *p_dst, const picture_t *p_src )
{
p_dst->date = p_src->date;
p_dst->b_force = p_src->b_force;
p_dst->b_progressive = p_src->b_progressive;
p_dst->i_nb_fields = p_src->i_nb_fields;
p_dst->b_top_field_first = p_src->b_top_field_first;
}
/** /**
* Video picture heap, either render (to store pictures used * Video picture heap, either render (to store pictures used
* by the decoder) or output (to store pictures displayed by the vout plugin) * by the decoder) or output (to store pictures displayed by the vout plugin)
......
...@@ -139,8 +139,8 @@ static picture_t *ImageRead( image_handler_t *p_image, block_t *p_block, ...@@ -139,8 +139,8 @@ static picture_t *ImageRead( image_handler_t *p_image, block_t *p_block,
while( (p_tmp = p_image->p_dec->pf_decode_video( p_image->p_dec, &p_block )) while( (p_tmp = p_image->p_dec->pf_decode_video( p_image->p_dec, &p_block ))
!= NULL ) != NULL )
{ {
if ( p_pic != NULL ) if( p_pic != NULL )
p_pic->pf_release( p_pic ); picture_Release( p_pic );
p_pic = p_tmp; p_pic = p_tmp;
} }
...@@ -188,7 +188,7 @@ static picture_t *ImageRead( image_handler_t *p_image, block_t *p_block, ...@@ -188,7 +188,7 @@ static picture_t *ImageRead( image_handler_t *p_image, block_t *p_block,
if( !p_image->p_filter ) if( !p_image->p_filter )
{ {
p_pic->pf_release( p_pic ); picture_Release( p_pic );
return NULL; return NULL;
} }
} }
...@@ -316,8 +316,8 @@ static block_t *ImageWrite( image_handler_t *p_image, picture_t *p_pic, ...@@ -316,8 +316,8 @@ static block_t *ImageWrite( image_handler_t *p_image, picture_t *p_pic,
p_image->p_filter->fmt_out.video = p_image->p_enc->fmt_in.video; p_image->p_filter->fmt_out.video = p_image->p_enc->fmt_in.video;
} }
if( p_pic->pf_release ) picture_Yield( p_pic );
p_pic->i_refcount++;
p_tmp_pic = p_tmp_pic =
p_image->p_filter->pf_video_filter( p_image->p_filter, p_pic ); p_image->p_filter->pf_video_filter( p_image->p_filter, p_pic );
...@@ -446,8 +446,8 @@ static picture_t *ImageConvert( image_handler_t *p_image, picture_t *p_pic, ...@@ -446,8 +446,8 @@ static picture_t *ImageConvert( image_handler_t *p_image, picture_t *p_pic,
p_image->p_filter->fmt_out.video = *p_fmt_out; p_image->p_filter->fmt_out.video = *p_fmt_out;
} }
if( p_pic->pf_release ) picture_Yield( p_pic );
p_pic->i_refcount++;
p_pif = p_image->p_filter->pf_video_filter( p_image->p_filter, p_pic ); p_pif = p_image->p_filter->pf_video_filter( p_image->p_filter, p_pic );
if( p_fmt_in->i_chroma == p_fmt_out->i_chroma && if( p_fmt_in->i_chroma == p_fmt_out->i_chroma &&
...@@ -455,7 +455,7 @@ static picture_t *ImageConvert( image_handler_t *p_image, picture_t *p_pic, ...@@ -455,7 +455,7 @@ static picture_t *ImageConvert( image_handler_t *p_image, picture_t *p_pic,
p_fmt_in->i_height == p_fmt_out->i_height ) p_fmt_in->i_height == p_fmt_out->i_height )
{ {
/* Duplicate image */ /* Duplicate image */
p_pif->pf_release( p_pif ); /* XXX: Better fix must be possible */ picture_Release( p_pif ); /* XXX: Better fix must be possible */
p_pif = p_image->p_filter->pf_vout_buffer_new( p_image->p_filter ); p_pif = p_image->p_filter->pf_vout_buffer_new( p_image->p_filter );
if( p_pif ) vout_CopyPicture( p_image->p_parent, p_pif, p_pic ); if( p_pif ) vout_CopyPicture( p_image->p_parent, p_pif, p_pic );
} }
...@@ -493,8 +493,8 @@ static picture_t *ImageFilter( image_handler_t *p_image, picture_t *p_pic, ...@@ -493,8 +493,8 @@ static picture_t *ImageFilter( image_handler_t *p_image, picture_t *p_pic,
p_image->p_filter->fmt_out.video = *p_fmt; p_image->p_filter->fmt_out.video = *p_fmt;
} }
if( p_pic->pf_release ) picture_Yield( p_pic );
p_pic->i_refcount++;
return p_image->p_filter->pf_video_filter( p_image->p_filter, p_pic ); return p_image->p_filter->pf_video_filter( p_image->p_filter, p_pic );
} }
...@@ -611,13 +611,13 @@ static void video_del_buffer( decoder_t *p_dec, picture_t *p_pic ) ...@@ -611,13 +611,13 @@ static void video_del_buffer( decoder_t *p_dec, picture_t *p_pic )
static void video_link_picture( decoder_t *p_dec, picture_t *p_pic ) static void video_link_picture( decoder_t *p_dec, picture_t *p_pic )
{ {
(void)p_dec; (void)p_dec;
p_pic->i_refcount++; picture_Yield( p_pic );
} }
static void video_unlink_picture( decoder_t *p_dec, picture_t *p_pic ) static void video_unlink_picture( decoder_t *p_dec, picture_t *p_pic )
{ {
(void)p_dec; (void)p_pic; (void)p_dec;
video_release_buffer( p_pic ); picture_Release( p_pic );
} }
static decoder_t *CreateDecoder( vlc_object_t *p_this, video_format_t *fmt ) static decoder_t *CreateDecoder( vlc_object_t *p_this, video_format_t *fmt )
......
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