]> git.sesse.net Git - vlc/blobdiff - modules/codec/avcodec/video.c
avcodec: free p_sys->p_ff_pic in some error paths
[vlc] / modules / codec / avcodec / video.c
index 0c2fab92a0ced6596c55077561c64fc4b96d3ee9..eb93e1f4f7128095a945887c698ec2f2cdafd239 100644 (file)
@@ -108,9 +108,10 @@ static int  ffmpeg_ReGetFrameBuf( struct AVCodecContext *, AVFrame * );
 static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *, AVFrame * );
 static void ffmpeg_NextPts( decoder_t * );
 
+#ifdef HAVE_AVCODEC_VAAPI
 static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *,
                                           const enum PixelFormat * );
-
+#endif
 
 static uint32_t ffmpeg_CodecTag( vlc_fourcc_t fcc )
 {
@@ -331,8 +332,10 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
     p_sys->p_context->release_buffer = ffmpeg_ReleaseFrameBuf;
     p_sys->p_context->opaque = p_dec;
 
+#ifdef HAVE_AVCODEC_VAAPI
     if( var_CreateGetBool( p_dec, "ffmpeg-hw" ) )
         p_sys->p_context->get_format = ffmpeg_GetFormat;
+#endif
 
     /* ***** misc init ***** */
     p_sys->input_pts = p_sys->input_dts = 0;
@@ -346,6 +349,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
     p_sys->p_buffer_orig = p_sys->p_buffer = malloc( p_sys->i_buffer_orig );
     if( !p_sys->p_buffer_orig )
     {
+        av_free( p_sys->p_ff_pic );
         free( p_sys );
         return VLC_ENOMEM;
     }
@@ -396,6 +400,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
     if( ffmpeg_OpenCodec( p_dec ) < 0 )
     {
         msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec );
+        av_free( p_sys->p_ff_pic );
         free( p_sys->p_buffer_orig );
         free( p_sys );
         return VLC_EGENERIC;
@@ -1120,6 +1125,7 @@ static void ffmpeg_NextPts( decoder_t *p_dec )
     }
 }
 
+#ifdef HAVE_AVCODEC_VAAPI
 static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_codec,
                                           const enum PixelFormat *pi_fmt )
 {
@@ -1168,4 +1174,5 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_codec,
     /* Fallback to default behaviour */
     return avcodec_default_get_format( p_codec, pi_fmt );
 }
+#endif