]> git.sesse.net Git - vlc/blobdiff - src/input/decoder.c
Removes trailing spaces. Removes tabs.
[vlc] / src / input / decoder.c
index 079b546acd5360ea56f505486d12828471aa764a..af31e71c74dbbd270b3c0639bda5ea773b4d5c2d 100644 (file)
@@ -26,7 +26,6 @@
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>
 #include <vlc/vlc.h>
 
 #include <vlc_block.h>
@@ -133,7 +132,7 @@ decoder_t *input_DecoderNew( input_thread_t *p_input,
         if( p_dec == NULL )
         {
             msg_Err( p_input, "could not create packetizer" );
-            intf_UserFatal( p_input, VLC_FALSE, _("Streaming / Transcoding failed"), 
+            intf_UserFatal( p_input, VLC_FALSE, _("Streaming / Transcoding failed"),
                             _("VLC could not open the packetizer module.") );
             return NULL;
         }
@@ -145,7 +144,7 @@ decoder_t *input_DecoderNew( input_thread_t *p_input,
         if( p_dec == NULL )
         {
             msg_Err( p_input, "could not create decoder" );
-            intf_UserFatal( p_input, VLC_FALSE, _("Streaming / Transcoding failed"), 
+            intf_UserFatal( p_input, VLC_FALSE, _("Streaming / Transcoding failed"),
                             _("VLC could not open the decoder module.") );
             return NULL;
         }
@@ -415,6 +414,24 @@ static decoder_t * CreateDecoder( input_thread_t *p_input,
         }
     }
 
+    /* Copy ourself the input replay gain */
+    if( fmt->i_cat == AUDIO_ES )
+    {
+        int i;
+        for( i = 0; i < AUDIO_REPLAY_GAIN_MAX; i++ )
+        {
+            if( !p_dec->fmt_out.audio_replay_gain.pb_peak[i] )
+            {
+                p_dec->fmt_out.audio_replay_gain.pb_peak[i] = fmt->audio_replay_gain.pb_peak[i];
+                p_dec->fmt_out.audio_replay_gain.pf_peak[i] = fmt->audio_replay_gain.pf_peak[i];
+            }
+            if( !p_dec->fmt_out.audio_replay_gain.pb_gain[i] )
+            {
+                p_dec->fmt_out.audio_replay_gain.pb_gain[i] = fmt->audio_replay_gain.pb_gain[i];
+                p_dec->fmt_out.audio_replay_gain.pf_gain[i] = fmt->audio_replay_gain.pf_gain[i];
+            }
+        }
+    }
     return p_dec;
 }
 
@@ -468,6 +485,7 @@ static inline void DecoderUpdatePreroll( int64_t *pi_preroll, const block_t *p )
 static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
 {
     input_thread_t *p_input = p_dec->p_owner->p_input;
+    const int i_rate = p_block->i_rate;
     aout_buffer_t *p_aout_buf;
 
     while( (p_aout_buf = p_dec->pf_decode_audio( p_dec, &p_block )) )
@@ -491,7 +509,7 @@ static void DecoderDecodeAudio( decoder_t *p_dec, block_t *p_block )
         }
         aout_DecPlay( p_dec->p_owner->p_aout,
                       p_dec->p_owner->p_aout_input,
-                      p_aout_buf );
+                      p_aout_buf, i_rate );
     }
 }
 static void VoutDisplayedPicture( vout_thread_t *p_vout, picture_t *p_pic )
@@ -523,7 +541,8 @@ static void VoutFlushPicture( vout_thread_t *p_vout )
     {
         picture_t *p_pic = p_vout->render.pp_picture[i];
 
-        if( p_pic->i_status != READY_PICTURE )
+        if( p_pic->i_status == READY_PICTURE ||
+            p_pic->i_status == DISPLAYED_PICTURE )
         {
             /* We cannot change picture status if it is in READY_PICTURE state,
              * Just make sure they won't be displayed */
@@ -573,6 +592,7 @@ static void DecoderDecodeVideo( decoder_t *p_dec, block_t *p_block )
  */
 static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
 {
+    decoder_owner_sys_t *p_sys = (decoder_owner_sys_t *)p_dec->p_owner;
     const int i_rate = p_block ? p_block->i_rate : INPUT_RATE_DEFAULT;
 
     if( p_block && p_block->i_buffer <= 0 )
@@ -734,19 +754,22 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
             stats_UpdateInteger( p_dec, p_input->p->counters.p_decoded_sub, 1, NULL );
             vlc_mutex_unlock( &p_input->p->counters.counters_lock );
 
-            if( p_spu->i_start < p_dec->p_owner->i_preroll_end &&
-                ( p_spu->i_stop <= 0 || p_spu->i_stop <= p_dec->p_owner->i_preroll_end ) )
+            p_vout = vlc_object_find( p_dec, VLC_OBJECT_VOUT, FIND_ANYWHERE );
+            if( p_vout && p_sys->p_spu_vout == p_vout )
             {
-                spu_DestroySubpicture( p_dec->p_owner->p_vout->p_spu, p_spu );
-                continue;
+                /* Prerool does not work very well with subtitle */
+                if( p_spu->i_start < p_dec->p_owner->i_preroll_end &&
+                    ( p_spu->i_stop <= 0 || p_spu->i_stop < p_dec->p_owner->i_preroll_end ) )
+                    spu_DestroySubpicture( p_vout->p_spu, p_spu );
+                else
+                    spu_DisplaySubpicture( p_vout->p_spu, p_spu );
             }
-
-            p_vout = vlc_object_find( p_dec, VLC_OBJECT_VOUT, FIND_ANYWHERE );
-            if( p_vout )
+            else
             {
-                spu_DisplaySubpicture( p_vout->p_spu, p_spu );
-                vlc_object_release( p_vout );
+                msg_Warn( p_dec, "no vout found, leaking subpicture" );
             }
+            if( p_vout )
+                vlc_object_release( p_vout );
         }
     }
     else
@@ -880,7 +903,7 @@ static aout_buffer_t *aout_new_buffer( decoder_t *p_dec, int i_samples )
         }
 
         p_sys->p_aout_input =
-            aout_DecNew( p_dec, &p_sys->p_aout, &format );
+            aout_DecNew( p_dec, &p_sys->p_aout, &format, &p_dec->fmt_out.audio_replay_gain );
         if( p_sys->p_aout_input == NULL )
         {
             msg_Err( p_dec, "failed to create audio output" );