[vlc-devel] [RFC PATCH 2/2] decoder: restart module if fmt_in is changed by the packetizer

Thomas Guillem thomas at gllm.fr
Mon Sep 7 14:48:45 CEST 2015


---
 src/input/decoder.c | 56 ++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 36 insertions(+), 20 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 49f67c9..b8899a1 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -1063,24 +1063,25 @@ static void DecoderProcessVideo( decoder_t *p_dec, block_t *p_block, bool b_flus
         while( (p_packetized_block =
                 p_packetizer->pf_packetize( p_packetizer, p_block ? &p_block : NULL )) )
         {
-            if( p_packetizer->fmt_out.i_extra && !p_dec->fmt_in.i_extra )
+            if( !es_format_IsSimilar( &p_dec->fmt_in, &p_packetizer->fmt_out ) )
             {
-                es_format_Clean( &p_dec->fmt_in );
-                es_format_Copy( &p_dec->fmt_in, &p_packetizer->fmt_out );
-            }
-
-            /* If the packetizer provides aspect ratio information, pass it
-             * to the decoder as a hint if the decoder itself can't provide
-             * it. Copy it regardless of the current value of the decoder input
-             * format aspect ratio, to properly propagate changes in aspect
-             * ratio. */
-            if( p_packetizer->fmt_out.video.i_sar_num > 0 &&
-                    p_packetizer->fmt_out.video.i_sar_den > 0)
-            {
-                p_dec->fmt_in.video.i_sar_num =
-                    p_packetizer->fmt_out.video.i_sar_num;
-                p_dec->fmt_in.video.i_sar_den=
-                    p_packetizer->fmt_out.video.i_sar_den;
+                msg_Dbg( p_dec, "restarting module due to input format change");
+
+                UnloadDecoder( p_dec );
+                LoadDecoder( p_dec, false, &p_packetizer->fmt_out );
+                if( !p_dec->p_module )
+                {
+                    p_dec->b_error = true;
+                    block_ChainRelease( p_packetized_block );
+                    return;
+                }
+
+                if( !p_dec->b_need_packetized && p_owner->p_packetizer )
+                {
+                    UnloadPacketizer( p_dec );
+                    block_ChainRelease( p_packetized_block );
+                    break;
+                }
             }
 
             if( p_packetizer->pf_get_cc )
@@ -1243,10 +1244,25 @@ static void DecoderProcessAudio( decoder_t *p_dec, block_t *p_block, bool b_flus
         while( (p_packetized_block =
                 p_packetizer->pf_packetize( p_packetizer, p_block ? &p_block : NULL )) )
         {
-            if( p_packetizer->fmt_out.i_extra && !p_dec->fmt_in.i_extra )
+            if( !es_format_IsSimilar( &p_dec->fmt_in, &p_packetizer->fmt_out ) )
             {
-                es_format_Clean( &p_dec->fmt_in );
-                es_format_Copy( &p_dec->fmt_in, &p_packetizer->fmt_out );
+                msg_Dbg( p_dec, "restarting module due to input format change");
+
+                UnloadDecoder( p_dec );
+                LoadDecoder( p_dec, false, &p_packetizer->fmt_out );
+                if( !p_dec->p_module )
+                {
+                    p_dec->b_error = true;
+                    block_ChainRelease( p_packetized_block );
+                    return;
+                }
+
+                if( !p_dec->b_need_packetized && p_owner->p_packetizer )
+                {
+                    UnloadPacketizer( p_dec );
+                    block_ChainRelease( p_packetized_block );
+                    break;
+                }
             }
 
             while( p_packetized_block )
-- 
2.1.4



More information about the vlc-devel mailing list