]> git.sesse.net Git - vlc/commitdiff
avcodec: factor frame initialization code
authorRémi Denis-Courmont <remi@remlab.net>
Wed, 24 Jul 2013 15:41:55 +0000 (18:41 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Wed, 24 Jul 2013 15:41:55 +0000 (18:41 +0300)
modules/codec/avcodec/video.c

index 271f91edaad44ab3ad1fbfa978e6f63743bfb6dc..fe21d75b1b71b5dc5fb129c1705ba940655ab188 100644 (file)
@@ -996,8 +996,6 @@ static picture_t *lavc_dr_GetFrame(struct AVCodecContext *ctx,
     }
 
     /* Allocate buffer references */
-    for (unsigned i = 0; i < AV_NUM_DATA_POINTERS; i++)
-        frame->buf[i] = NULL;
     for (int i = 0; i < pic->i_planes; i++)
     {
         lavc_pic_ref_t *ref = malloc(sizeof (*ref));
@@ -1041,6 +1039,13 @@ static int lavc_GetFrame(struct AVCodecContext *ctx, AVFrame *frame, int flags)
     decoder_sys_t *sys = dec->p_sys;
     picture_t *pic;
 
+    for (unsigned i = 0; i < AV_NUM_DATA_POINTERS; i++)
+    {
+        frame->data[i] = NULL;
+        frame->linesize[i] = 0;
+        frame->buf[i] = NULL;
+    }
+
     if (sys->p_va != NULL)
         return lavc_va_GetFrame(ctx, frame);