[vlc-devel] [PATCH 04/12] image: use a function to release the decoder

Steve Lhomme robux4 at ycbcr.xyz
Mon Dec 2 14:26:11 CET 2019


We may have to release resources associated to the decoder, like the decoder
device.
---
 src/misc/image.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/misc/image.c b/src/misc/image.c
index c94ca6a04cc..9797a8c47cc 100644
--- a/src/misc/image.c
+++ b/src/misc/image.c
@@ -84,6 +84,11 @@ vlc_fourcc_t image_Type2Fourcc( const char * );
 vlc_fourcc_t image_Ext2Fourcc( const char * );
 /*static const char *Fourcc2Ext( vlc_fourcc_t );*/
 
+static void ReleaseDecoder(decoder_t *p_dec)
+{
+    decoder_Destroy( p_dec );
+}
+
 #undef image_HandlerCreate
 /**
  * Create an image_handler_t instance
@@ -116,7 +121,7 @@ void image_HandlerDelete( image_handler_t *p_image )
 {
     if( !p_image ) return;
 
-    decoder_Destroy( p_image->p_dec );
+    if ( p_image->p_dec ) ReleaseDecoder( p_image->p_dec );
     if( p_image->p_enc ) DeleteEncoder( p_image->p_enc );
     if( p_image->p_converter ) DeleteConverter( p_image->p_converter );
 
@@ -153,7 +158,7 @@ static picture_t *ImageRead( image_handler_t *p_image, block_t *p_block,
     if( p_image->p_dec &&
         p_image->p_dec->fmt_in.i_codec != p_es_in->video.i_chroma )
     {
-        decoder_Destroy( p_image->p_dec );
+        ReleaseDecoder( p_image->p_dec );
         p_image->p_dec = NULL;
     }
 
@@ -168,7 +173,7 @@ static picture_t *ImageRead( image_handler_t *p_image, block_t *p_block,
         }
         if( p_image->p_dec->fmt_out.i_cat != VIDEO_ES )
         {
-            decoder_Destroy( p_image->p_dec );
+            ReleaseDecoder( p_image->p_dec );
             p_image->p_dec = NULL;
             block_Release(p_block);
             return NULL;
@@ -685,7 +690,7 @@ static decoder_t *CreateDecoder( image_handler_t *p_image, const es_format_t *fm
                  "VLC probably does not support this image format.",
                  (char*)&p_dec->fmt_in.i_codec );
 
-        decoder_Destroy( p_dec );
+        ReleaseDecoder( p_dec );
         p_dec = NULL;
     }
 
-- 
2.17.1



More information about the vlc-devel mailing list