Commit e56293ea authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

decoder: remove vout_FixLeaks()

This function was intended to work around a certain class of bugs
inside video decoders whereby the a reference picture was never
dereferenced, i.e. missing decoder_UnlinkPicture() call.

There are however some situations where this hack would release a
still referenced picture:

- If the video output or decoder has a high latency or if a video
  filter holds pictures (deinterlace), there may be zero free pictures
  even though the total number of pictures is sufficient overall.
  In that case, waiting for a picture buffer to be released normally
  is the right and safe approach.

- If the byte stream is invalid or corrupt such that the number of
  required pictures (DPB size) is underestimated, dropping frames is
  acceptable. Frames would be corrupt anyway due to missing references.
  (This case could be better worked around by allocating extra
   pictures on-the-fly, though this would require memory copying in the
   video output.)

- Even if the decoder indeed leaks pictures, the oldest referenced
  picture is not necessarily among those leaked.

If the picture was not truly leaked, vout_FixLeaks() would cause an
extraneous picture release. This should lead to an assertion failure in
picture_Release(). Without assertions, it would lead to undefined
behaviour, especially invalid pointer use in case of hardware surfaces.

In any case, picture leaks are still recovered when resetting the video
output with vout_Reset(), after the decoder is destroyed. That might
turn out to be a problem too though.
parent fe07f7db
...@@ -443,9 +443,6 @@ static picture_t *vout_new_buffer( decoder_t *p_dec ) ...@@ -443,9 +443,6 @@ static picture_t *vout_new_buffer( decoder_t *p_dec )
} }
vlc_mutex_unlock( &p_owner->lock ); vlc_mutex_unlock( &p_owner->lock );
/* Check the decoder doesn't leak pictures */
vout_FixLeaks( p_owner->p_vout );
/* FIXME add a vout_WaitPictureAvailable (timedwait) */ /* FIXME add a vout_WaitPictureAvailable (timedwait) */
msleep( VOUT_OUTMEM_SLEEP ); msleep( VOUT_OUTMEM_SLEEP );
} }
......
...@@ -335,27 +335,6 @@ bool vout_IsEmpty(vout_thread_t *vout) ...@@ -335,27 +335,6 @@ bool vout_IsEmpty(vout_thread_t *vout)
return !picture; return !picture;
} }
void vout_FixLeaks( vout_thread_t *vout )
{
picture_t *picture = picture_fifo_Peek(vout->p->decoder_fifo);
if (picture != NULL) {
picture_Release(picture);
return; /* Not all pictures has been displayed yet */
}
picture = picture_pool_Get(vout->p->decoder_pool);
if (picture != NULL)
picture_Release(picture); /* Not all pictures are referenced */
else {
/* There are no reasons that no pictures are available, force one
* from the pool, be careful with it though */
msg_Err(vout, "pictures leaked, trying to workaround");
picture_pool_NonEmpty(vout->p->decoder_pool);
}
}
void vout_NextPicture(vout_thread_t *vout, mtime_t *duration) void vout_NextPicture(vout_thread_t *vout, mtime_t *duration)
{ {
vout_control_cmd_t cmd; vout_control_cmd_t cmd;
......
...@@ -47,14 +47,6 @@ void vout_GetResetStatistic( vout_thread_t *p_vout, int *pi_displayed, int *pi_l ...@@ -47,14 +47,6 @@ void vout_GetResetStatistic( vout_thread_t *p_vout, int *pi_displayed, int *pi_l
*/ */
void vout_Flush( vout_thread_t *p_vout, mtime_t i_date ); void vout_Flush( vout_thread_t *p_vout, mtime_t i_date );
/**
* This function will try to detect if pictures are being leaked. If so it
* will release them.
*
* XXX This function is there to workaround bugs in decoder
*/
void vout_FixLeaks( vout_thread_t *p_vout );
/* /*
* Reset the states of the vout. * Reset the states of the vout.
*/ */
......
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