[vlc-commits] avcodec: Fix unprotected accesses to pts

Hugo Beauzée-Luyssen git at videolan.org
Wed Oct 9 15:31:24 CEST 2019


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Wed Oct  2 11:44:53 2019 +0200| [ff21ec7f178dc02625b1bf3a9d753eb742fd77de] | committer: Hugo Beauzée-Luyssen

avcodec: Fix unprotected accesses to pts

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

 modules/codec/avcodec/video.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index b9fa684290..0b51cd940b 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -702,7 +702,6 @@ static void Flush( decoder_t *p_dec )
     decoder_sys_t *p_sys = p_dec->p_sys;
     AVCodecContext *p_context = p_sys->p_context;
 
-    date_Set(&p_sys->pts, VLC_TICK_INVALID); /* To make sure we recover properly */
     p_sys->i_late_frames = 0;
     p_sys->framedrop = FRAMEDROP_NONE;
     cc_Flush( &p_sys->cc );
@@ -716,6 +715,8 @@ static void Flush( decoder_t *p_dec )
     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 );
 }
@@ -759,7 +760,9 @@ static block_t * filter_earlydropped_blocks( decoder_t *p_dec, block_t *block )
                             "dropping frame (computer too slow ?)",
                      p_sys->p_context->reordered_opaque - p_sys->i_last_output_frame );
 
+            vlc_mutex_lock(&p_sys->lock);
             date_Set( &p_sys->pts, VLC_TICK_INVALID ); /* To make sure we recover properly */
+            vlc_mutex_unlock(&p_sys->lock);
             block_Release( block );
             p_sys->i_late_frames--;
             return NULL;
@@ -1339,7 +1342,10 @@ static int DecodeVideo( decoder_t *p_dec, block_t *p_block )
         p_sys->i_last_output_frame = -1;
         p_sys->framedrop = FRAMEDROP_NONE;
 
+        vlc_mutex_lock(&p_sys->lock);
         date_Set( &p_sys->pts, VLC_TICK_INVALID ); /* To make sure we recover properly */
+        vlc_mutex_unlock(&p_sys->lock);
+
         cc_Flush( &p_sys->cc );
 
         if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )



More information about the vlc-commits mailing list