]> git.sesse.net Git - vlc/blobdiff - modules/packetizer/mpeg4video.c
Fixed extra data parsing with some VC1 streams.
[vlc] / modules / packetizer / mpeg4video.c
index c9b11733755bcd6a83cb1841389f660286afe740..06e5f4eb6dc4a6c9b713d48fd81d2c24a8386c01 100644 (file)
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_sout.h>
 #include <vlc_codec.h>
 #include <vlc_block.h>
-#include <vlc_input.h>                  /* hmmm, just for INPUT_RATE_DEFAULT */
 
 #include "vlc_bits.h"
 #include "vlc_block_helper.h"
 static int  Open ( vlc_object_t * );
 static void Close( vlc_object_t * );
 
-vlc_module_begin();
-    set_category( CAT_SOUT );
-    set_subcategory( SUBCAT_SOUT_PACKETIZER );
-    set_description( _("MPEG4 video packetizer") );
-    set_capability( "packetizer", 50 );
-    set_callbacks( Open, Close );
-vlc_module_end();
+vlc_module_begin ()
+    set_category( CAT_SOUT )
+    set_subcategory( SUBCAT_SOUT_PACKETIZER )
+    set_description( N_("MPEG4 video packetizer") )
+    set_capability( "packetizer", 50 )
+    set_callbacks( Open, Close )
+vlc_module_end ()
 
 /****************************************************************************
  * Local prototypes
@@ -87,7 +87,7 @@ struct decoder_sys_t
     int         i_last_incr;
     int         i_last_incr_diff;
 
-    vlc_bool_t  b_frame;
+    bool  b_frame;
 
     /* Current frame being built */
     block_t    *p_frame;
@@ -159,10 +159,7 @@ static int Open( vlc_object_t *p_this )
 
     /* Allocate the memory needed to store the decoder's structure */
     if( ( p_dec->p_sys = p_sys = malloc( sizeof(decoder_sys_t) ) ) == NULL )
-    {
-        msg_Err( p_dec, "out of memory" );
-        return VLC_EGENERIC;
-    }
+        return VLC_ENOMEM;
     memset( p_sys, 0, sizeof(decoder_sys_t) );
 
     /* Misc init */
@@ -232,20 +229,20 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
         if( (*pp_block)->i_flags&BLOCK_FLAG_CORRUPTED )
         {
             p_sys->i_state = STATE_NOSYNC;
-            block_BytestreamFlush( &p_sys->bytestream );
+            block_BytestreamEmpty( &p_sys->bytestream );
 
             if( p_sys->p_frame )
                 block_ChainRelease( p_sys->p_frame );
             p_sys->p_frame = NULL;
             p_sys->pp_last = &p_sys->p_frame;
         }
-//        p_sys->i_interpolated_pts =
-//        p_sys->i_interpolated_dts =
-//        p_sys->i_last_ref_pts =
-//        p_sys->i_last_time_ref =
-//        p_sys->i_time_ref =
-//        p_sys->i_last_time =
-//        p_sys->i_last_timeincr = 0;
+        p_sys->i_interpolated_pts =
+        p_sys->i_interpolated_dts =
+        p_sys->i_last_ref_pts =
+        p_sys->i_last_time_ref =
+        p_sys->i_time_ref =
+        p_sys->i_last_time =
+        p_sys->i_last_timeincr = 0;
 
         block_Release( *pp_block );
         return NULL;
@@ -297,7 +294,6 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
             block_BytestreamFlush( &p_sys->bytestream );
             p_pic->i_pts = i_pts = p_sys->bytestream.p_block->i_pts;
             p_pic->i_dts = i_dts = p_sys->bytestream.p_block->i_dts;
-            p_pic->i_rate = p_sys->bytestream.p_block->i_rate;
 
             block_GetBytes( &p_sys->bytestream, p_pic->p_buffer,
                             p_pic->i_buffer );
@@ -405,6 +401,7 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
     {
         /* We are dealing with a VOP */
         p_pic = block_ChainGather( p_sys->p_frame );
+        p_pic->i_flags = p_sys->i_flags;
         p_pic->i_pts = p_sys->i_interpolated_pts;
         p_pic->i_dts = p_sys->i_interpolated_dts;
 
@@ -530,7 +527,7 @@ static int ParseVOP( decoder_t *p_dec, block_t *p_vop )
         break;
     case 2:
         p_sys->i_flags = BLOCK_FLAG_TYPE_B;
-        p_sys->b_frame = VLC_TRUE;
+        p_sys->b_frame = true;
         break;
     case 3: /* gni ? */
         p_sys->i_flags = BLOCK_FLAG_TYPE_PB;
@@ -569,16 +566,14 @@ static int ParseVOP( decoder_t *p_dec, block_t *p_vop )
         p_dec->fmt_in.video.i_frame_rate > 0 &&
         p_dec->fmt_in.video.i_frame_rate_base > 0 )
     {
-        p_sys->i_interpolated_pts += I64C(1000000) *
-        p_dec->fmt_in.video.i_frame_rate_base *
-        p_vop->i_rate / INPUT_RATE_DEFAULT /
+        p_sys->i_interpolated_pts += INT64_C(1000000) *
+        p_dec->fmt_in.video.i_frame_rate_base /
         p_dec->fmt_in.video.i_frame_rate;
     }
     else if( p_dec->p_sys->i_fps_num )
         p_sys->i_interpolated_pts +=
-            ( I64C(1000000) * (i_time_ref + i_time_increment -
-              p_sys->i_last_time - p_sys->i_last_timeincr) *
-              p_vop->i_rate / INPUT_RATE_DEFAULT /
+            ( INT64_C(1000000) * (i_time_ref + i_time_increment -
+              p_sys->i_last_time - p_sys->i_last_timeincr) /
               p_dec->p_sys->i_fps_num );
 
     p_sys->i_last_time = i_time_ref;