[vlc-commits] avcodec: do not cancel the pending picture requests on Flush

Steve Lhomme git at videolan.org
Wed Jul 15 08:11:09 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Jul  9 11:42:20 2020 +0200| [6fc5e2bc5f33c6c2ffef13fe6f8408e1c5877070] | committer: Steve Lhomme

avcodec: do not cancel the pending picture requests on Flush

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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6fc5e2bc5f33c6c2ffef13fe6f8408e1c5877070
---

 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 d89635dbe8..4c5943d22e 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 )



More information about the vlc-commits mailing list