[vlc-commits] avcodec: use picture_Clone() (fixes #18176)

Rémi Denis-Courmont git at videolan.org
Sat Nov 4 17:33:06 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Nov  4 18:20:55 2017 +0200| [9163a7fd036ab5955e263656e63b3d3c2ecf4360] | committer: Rémi Denis-Courmont

avcodec: use picture_Clone() (fixes #18176)

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

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

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 89e4464dc1..0c27ff72a2 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1166,7 +1166,17 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block, bool *error
         }
         else
         {
-            picture_Hold( p_pic );
+            /* Some codecs can return the same frame multiple times. By the
+             * time that the same frame is returned a second time, it will be
+             * too late to clone the underlying picture. So clone proactively.
+             * A single picture CANNOT be queued multiple times.
+             */
+            p_pic = picture_Clone( p_pic );
+            if( unlikely(p_pic == NULL) )
+            {
+                av_frame_free(&frame);
+                break;
+            }
         }
 
         if( !p_dec->fmt_in.video.i_sar_num || !p_dec->fmt_in.video.i_sar_den )



More information about the vlc-commits mailing list