[vlc-commits] decoder: make decoder_Clean() public

Steve Lhomme git at videolan.org
Mon Feb 18 17:02:50 CET 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Feb 18 15:02:10 2019 +0100| [16c9f7b5d737a78d7cdb0ef3f7e7911307c12242] | committer: Steve Lhomme

decoder: make decoder_Clean() public

The decoder and decoder tests actually load/unload decoders without resetting
the whole structure.

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

 include/vlc_codec.h         |  7 +++++++
 src/input/decoder.c         | 32 +++++---------------------------
 src/input/decoder_helpers.c |  2 +-
 src/libvlccore.sym          |  1 +
 test/src/input/decoder.c    | 20 ++------------------
 5 files changed, 16 insertions(+), 46 deletions(-)

diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index 43d3a6d4f7..f8d8948e3e 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -327,6 +327,13 @@ VLC_API void decoder_Init( decoder_t *dec, const es_format_t * );
 VLC_API void decoder_Destroy( decoder_t *p_dec );
 
 /**
+ * Unload a decoder module and reset the input/output formats.
+ *
+ * To be used by decoder owners.
+ */
+VLC_API void decoder_Clean( decoder_t *p_dec );
+
+/**
  * This function queues a single picture to the video output.
  *
  * \note
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 2269985eff..93d49a9289 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -189,38 +189,16 @@ static int LoadDecoder( decoder_t *p_dec, bool b_packetizer,
 
     if( !p_dec->p_module )
     {
-        es_format_Clean( &p_dec->fmt_in );
+        decoder_Clean( p_dec );
         return -1;
     }
-    else
-        return 0;
-}
-
-/**
- * Unload a decoder module
- */
-static void UnloadDecoder( decoder_t *p_dec )
-{
-    if( p_dec->p_module )
-    {
-        module_unneed( p_dec, p_dec->p_module );
-        p_dec->p_module = NULL;
-    }
-
-    if( p_dec->p_description )
-    {
-        vlc_meta_Delete( p_dec->p_description );
-        p_dec->p_description = NULL;
-    }
-
-    es_format_Clean( &p_dec->fmt_in );
-    es_format_Clean( &p_dec->fmt_out );
+    return 0;
 }
 
 static int ReloadDecoder( decoder_t *p_dec, bool b_packetizer,
                           const es_format_t *restrict p_fmt, enum reload reload )
 {
-    /* Copy p_fmt since it can be destroyed by UnloadDecoder */
+    /* Copy p_fmt since it can be destroyed by decoder_Clean */
     struct decoder_owner *p_owner = dec_get_owner( p_dec );
     es_format_t fmt_in;
     if( es_format_Copy( &fmt_in, p_fmt ) != VLC_SUCCESS )
@@ -230,7 +208,7 @@ static int ReloadDecoder( decoder_t *p_dec, bool b_packetizer,
     }
 
     /* Restart the decoder module */
-    UnloadDecoder( p_dec );
+    decoder_Clean( p_dec );
     p_owner->error = false;
 
     if( reload == RELOAD_DECODER_AOUT )
@@ -1974,7 +1952,7 @@ static void DeleteDecoder( decoder_t * p_dec )
              (char*)&p_dec->fmt_in.i_codec );
 
     const enum es_format_category_e i_cat =p_dec->fmt_in.i_cat;
-    UnloadDecoder( p_dec );
+    decoder_Clean( p_dec );
 
     /* Free all packets still in the decoder fifo. */
     block_FifoRelease( p_owner->p_fifo );
diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c
index 90abcb0c6e..91bdf6a123 100644
--- a/src/input/decoder_helpers.c
+++ b/src/input/decoder_helpers.c
@@ -46,7 +46,7 @@ void decoder_Init( decoder_t *p_dec, const es_format_t *restrict p_fmt )
     es_format_Init( &p_dec->fmt_out, p_fmt->i_cat, 0 );
 }
 
-static void decoder_Clean( decoder_t *p_dec )
+void decoder_Clean( decoder_t *p_dec )
 {
     es_format_Clean( &p_dec->fmt_in );
     es_format_Clean( &p_dec->fmt_out );
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 906a449f2b..d2d1dac6fb 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -74,6 +74,7 @@ date_Decrement
 date_Increment
 date_Init
 decoder_Init
+decoder_Clean
 decoder_Destroy
 decoder_AbortPictures
 decoder_NewAudioBuffer
diff --git a/test/src/input/decoder.c b/test/src/input/decoder.c
index b140d89110..0825befdd0 100644
--- a/test/src/input/decoder.c
+++ b/test/src/input/decoder.c
@@ -106,28 +106,12 @@ static int decoder_load(decoder_t *decoder, bool is_packetizer,
 
     if (!decoder->p_module)
     {
-        es_format_Clean(&decoder->fmt_in);
+        decoder_Clean( decoder );
         return VLC_EGENERIC;
     }
     return VLC_SUCCESS;
 }
 
-static void decoder_unload(decoder_t *decoder)
-{
-    if (decoder->p_module != NULL)
-    {
-        module_unneed(decoder, decoder->p_module);
-        decoder->p_module = NULL;
-        es_format_Clean(&decoder->fmt_out);
-    }
-    es_format_Clean(&decoder->fmt_in);
-    if (decoder->p_description)
-    {
-        vlc_meta_Delete(decoder->p_description);
-        decoder->p_description = NULL;
-    }
-}
-
 void test_decoder_destroy(decoder_t *decoder)
 {
     struct decoder_owner *owner = dec_get_owner(decoder);
@@ -237,7 +221,7 @@ int test_decoder_process(decoder_t *decoder, block_t *p_block)
             decoder->pf_decode(decoder, NULL);
 
             /* Reload decoder */
-            decoder_unload(decoder);
+            decoder_Clean(decoder);
             if (decoder_load(decoder, false, &packetizer->fmt_out) != VLC_SUCCESS)
             {
                 block_ChainRelease(p_packetized_block);



More information about the vlc-commits mailing list