[vlc-devel] [PATCH] avcodec: don't forward AVFrame coming from the internal va pool as a picture_t

Steve Lhomme robux4 at videolabs.io
Wed Apr 22 15:08:13 CEST 2015


The reference counting is not compatible.
The current code extracts a surface into a picture_t that holds the same surface and some allocated planes.
---
 modules/codec/avcodec/video.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 5ca424b..b9a69c0 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -788,8 +788,7 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
         if( p_pic == NULL )
         {
             /* Get a new picture */
-            if( p_sys->p_va == NULL )
-                p_pic = ffmpeg_NewPictBuf( p_dec, p_context );
+            p_pic = ffmpeg_NewPictBuf( p_dec, p_context );
             if( !p_pic )
             {
                 if( p_block )
@@ -798,12 +797,13 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
             }
 
             /* Fill picture_t from AVFrame */
-            lavc_CopyPicture(p_dec, p_pic, p_sys->p_ff_pic);
+            if( p_sys->p_va != NULL )
+                vlc_va_Extract( p_sys->p_va, p_pic, p_sys->p_ff_pic->data[3] );
+            else
+                lavc_CopyPicture(p_dec, p_pic, p_sys->p_ff_pic);
         }
         else
         {
-            if( p_sys->p_va != NULL )
-                vlc_va_Extract( p_sys->p_va, p_pic, p_sys->p_ff_pic->data[3] );
             picture_Hold( p_pic );
         }
 
@@ -990,7 +990,6 @@ static int lavc_va_GetFrame(struct AVCodecContext *ctx, AVFrame *frame,
         return -1;
     }
 
-    frame->opaque = pic;
     assert(frame->data[0] != NULL);
     (void) flags;
     return 0;
-- 
2.3.0




More information about the vlc-devel mailing list