]> git.sesse.net Git - vlc/blobdiff - modules/mux/mpeg/pes.c
Use vlc_memset/vlc_memcpy
[vlc] / modules / mux / mpeg / pes.c
index 3691c894c70a9e975eb2b51247d32a771b489479..e7e64864c7eef264cf0b34102e3a129c47c25c1b 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * pes.c: PES packetizer used by the MPEG multiplexers
  *****************************************************************************
- * Copyright (C) 2001, 2002 VideoLAN (Centrale Réseaux) and its contributors
+ * Copyright (C) 2001, 2002 the VideoLAN team
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <string.h>
 #include <errno.h>
 #include <fcntl.h>
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
-#include <vlc/input.h>
-#include <vlc/sout.h>
+#include <vlc_sout.h>
+#include <vlc_block.h>
 
 #ifdef HAVE_UNISTD_H
 #   include <unistd.h>
 #endif
 
-#include "codecs.h"
+#include <vlc_codecs.h>
 #include "pes.h"
 #include "bits.h"
 
 static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
                              int i_es_size, es_format_t *p_fmt,
                              int i_stream_id, int i_private_id,
-                             vlc_bool_t b_mpeg2, vlc_bool_t b_data_alignment,
+                             bool b_mpeg2, bool b_data_alignment,
                              int i_header_size )
 {
     bits_buffer_t bits;
@@ -65,7 +67,6 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
         }
     }
 
-
     bits_initwrite( &bits, 50, p_hdr );
 
     /* add start code */
@@ -125,7 +126,7 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
                 bits_write( &bits, 1, 0x00 ); // dsm trick mode flag
                 bits_write( &bits, 1, 0x00 ); // additional copy info flag
                 bits_write( &bits, 1, 0x00 ); // pes crc flag
-                bits_write( &bits, 1, 0x00 ); // pes extention flags
+                bits_write( &bits, 1, 0x00 ); // pes extension flags
                 bits_write( &bits, 8, i_header_size ); // header size -> pts and dts
 
                 /* write pts */
@@ -272,6 +273,10 @@ int E_( EStoPES )( sout_instance_t *p_sout, block_t **pp_pes, block_t *p_es,
 
     *pp_pes = p_pes = NULL;
 
+#ifndef NDEBUG
+    memset( header, 0, 50 );
+#endif
+
     do
     {
         i_pes_payload = __MIN( i_size, (i_max_pes_size ?
@@ -285,6 +290,7 @@ int E_( EStoPES )( sout_instance_t *p_sout, block_t **pp_pes, block_t *p_es,
         if( p_es )
         {
             p_es = block_Realloc( p_es, i_pes_header, p_es->i_buffer );
+            p_data = p_es->p_buffer+i_pes_header;
             /* reuse p_es for first frame */
             *pp_pes = p_pes = p_es;
             /* don't touch i_dts, i_pts, i_length as are already set :) */
@@ -300,8 +306,8 @@ int E_( EStoPES )( sout_instance_t *p_sout, block_t **pp_pes, block_t *p_es,
             p_pes->i_length = 0;
             if( i_pes_payload > 0 )
             {
-                p_sout->p_vlc->pf_memcpy( p_pes->p_buffer + i_pes_header,
-                                          p_data, i_pes_payload );
+                vlc_memcpy( p_pes->p_buffer + i_pes_header, p_data,
+                            i_pes_payload );
             }
             i_pes_count++;
         }