]> git.sesse.net Git - vlc/commitdiff
Added and used a packetizer_Header for packetizers.
authorLaurent Aimar <fenrir@videolan.org>
Tue, 28 Apr 2009 19:46:37 +0000 (21:46 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Tue, 28 Apr 2009 19:46:37 +0000 (21:46 +0200)
modules/packetizer/h264.c
modules/packetizer/packetizer_helper.h
modules/packetizer/vc1.c

index d1f7f882621f45738206c39d0538576737a932da..534ee7bcbe6f58954dea56a0eba722a09b851456 100644 (file)
@@ -355,19 +355,8 @@ static int Open( vlc_object_t *p_this )
 
         /* */
         if( p_dec->fmt_in.i_extra > 0 )
-        {
-            block_t *p_init = block_New( p_dec, p_dec->fmt_in.i_extra );
-            block_t *p_pic;
-
-            memcpy( p_init->p_buffer, p_dec->fmt_in.p_extra,
-                    p_dec->fmt_in.i_extra );
-
-            while( ( p_pic = Packetize( p_dec, &p_init ) ) )
-            {
-                /* Should not occur because we should only receive SPS/PPS */
-                block_Release( p_pic );
-            }
-        }
+            packetizer_Header( &p_sys->packetizer,
+                               p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra );
     }
 
     return VLC_SUCCESS;
index 33e9c77cda035d04d4a87797199d4da97201436d..1128a4dc0d52a67bcd0841858eb432e592beb7e4 100644 (file)
@@ -182,5 +182,19 @@ static inline block_t *packetizer_Packetize( packetizer_t *p_pack, block_t **pp_
     }
 }
 
+static inline void packetizer_Header( packetizer_t *p_pack,
+                                      const uint8_t *p_header, int i_header )
+{
+    block_t *p_init = block_Alloc( i_header );
+    if( !p_init )
+        return;
+
+    memcpy( p_init->p_buffer, p_header, i_header );
+
+    block_t *p_pic;
+    while( ( p_pic = packetizer_Packetize( p_pack, &p_init ) ) )
+        block_Release( p_pic ); /* Should not happen (only sequence header) */
+}
+
 #endif
 
index 2cd4bc8b71d819865f1c9667e1acf6a1f5a0ba04..f8edd3a64548e695236069b17125e08199f86dd0 100644 (file)
@@ -165,16 +165,8 @@ static int Open( vlc_object_t *p_this )
 
         /* */
         if( p_dec->fmt_out.i_extra > 0 )
-        {
-            block_t *p_init = block_New( p_dec, p_dec->fmt_out.i_extra );
-
-            memcpy( p_init->p_buffer, p_dec->fmt_out.p_extra,
-                    p_dec->fmt_out.i_extra );
-
-            block_t *p_pic;
-            while( ( p_pic = Packetize( p_dec, &p_init ) ) )
-                block_Release( p_pic ); /* Should not happen (only sequence header) */
-        }
+            packetizer_Header( &p_sys->packetizer,
+                               p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
     }
 
     return VLC_SUCCESS;