[vlc-devel] [PATCH 1/2] avcodec: do not cancel the pending picture requests on Flush
Steve Lhomme
robux4 at ycbcr.xyz
Thu Jul 9 11:56:29 CEST 2020
avcodec_flush_buffers() is already not "protected" on close or drain.
The comment mentions some deadlock but when it was introduced there was a
semaphore around the call (3532e72eb51586fd61b97faae1efc96a39c79b4d). There's
no such thread protection anymore,. libavcodec must handle its threads flushing
internally (see ff_thread_flush() in pthread_frame.c)
With canceled pictures/surfaces, before the flush is received it may still
try to get a picture after the previous call returned NULL and so on.
Without canceled pictures/surfaces, the threads waiting for a picture/surface
will keep waiting but their "context" is reset. Either they will receive a
picture from the pending call for a previous frame but the flush should discard
it. Either the picture will be used for a fresh picture to decode and we don't
need to care at all.
---
modules/codec/avcodec/video.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index d89635dbe8f..4c5943d22ea 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -718,19 +718,11 @@ static void Flush( decoder_t *p_dec )
p_sys->framedrop = FRAMEDROP_NONE;
cc_Flush( &p_sys->cc );
- /* Abort pictures in order to unblock all avcodec workers threads waiting
- * for a picture. This will avoid a deadlock between avcodec_flush_buffers
- * and workers threads */
- decoder_AbortPictures( p_dec, true );
-
/* do not flush buffers if codec hasn't been opened (theora/vorbis/VC1) */
if( avcodec_is_open( p_context ) )
avcodec_flush_buffers( p_context );
date_Set(&p_sys->pts, VLC_TICK_INVALID); /* To make sure we recover properly */
-
- /* Reset cancel state to false */
- decoder_AbortPictures( p_dec, false );
}
static block_t * filter_earlydropped_blocks( decoder_t *p_dec, block_t *block )
--
2.26.2
More information about the vlc-devel
mailing list