[vlc-commits] packetize: move annexb stripping to common helpers

Francois Cartegnie git at videolan.org
Sat Dec 12 23:20:16 CET 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Dec 11 18:32:47 2015 +0100| [b6d53048ed045afefa7cda06bd04f67afe6362b7] | committer: Francois Cartegnie

packetize: move annexb stripping to common helpers

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b6d53048ed045afefa7cda06bd04f67afe6362b7
---

 modules/packetizer/h264_nal.c |   25 ++-----------------------
 modules/packetizer/hxxx_nal.h |   23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/modules/packetizer/h264_nal.c b/modules/packetizer/h264_nal.c
index 39e5c57..e2bfdbb 100644
--- a/modules/packetizer/h264_nal.c
+++ b/modules/packetizer/h264_nal.c
@@ -39,27 +39,6 @@ bool h264_isavcC( const uint8_t *p_buf, size_t i_buf )
             (p_buf[5] & 0xE0) == 0xE0 );
 }
 
-static inline bool strip_AnnexB_startcode( const uint8_t **pp_data, size_t *pi_data )
-{
-    const uint8_t *p_data = *pp_data;
-    if(*pi_data < 4)
-    {
-        return false;
-    }
-    else if( p_data[0] == !!memcmp(&p_data[1], annexb_startcode3, 3) )
-    {
-        *pp_data += 4;
-        *pi_data -= 4;
-    }
-    else if( !memcmp(p_data, annexb_startcode4, 3) )
-    {
-        *pp_data += 3;
-        *pi_data -= 3;
-    }
-    else return false;
-    return true;
-}
-
 static size_t get_avcC_to_AnnexB_NAL_size( const uint8_t *p_buf, size_t i_buf )
 {
     size_t i_total = 0;
@@ -715,8 +694,8 @@ block_t *h264_AnnexB_NAL_to_avcC( uint8_t i_nal_length_size,
     if( i_pps_size > UINT16_MAX || i_sps_size > UINT16_MAX )
         return NULL;
 
-    if( !strip_AnnexB_startcode( &p_sps_buf, &i_sps_size ) ||
-        !strip_AnnexB_startcode( &p_pps_buf, &i_pps_size ) )
+    if( !hxxx_strip_AnnexB_startcode( &p_sps_buf, &i_sps_size ) ||
+        !hxxx_strip_AnnexB_startcode( &p_pps_buf, &i_pps_size ) )
         return NULL;
 
     /* The length of the NAL size is encoded using 1, 2 or 4 bytes */
diff --git a/modules/packetizer/hxxx_nal.h b/modules/packetizer/hxxx_nal.h
index a9665ab..b309b85 100644
--- a/modules/packetizer/hxxx_nal.h
+++ b/modules/packetizer/hxxx_nal.h
@@ -29,6 +29,29 @@
 static const uint8_t  annexb_startcode4[] = { 0x00, 0x00, 0x00, 0x01 };
 #define annexb_startcode3 (&annexb_startcode4[1])
 
+static inline bool hxxx_strip_AnnexB_startcode( const uint8_t **pp_data, size_t *pi_data )
+{
+    const uint8_t *p_data = *pp_data;
+    if(*pi_data < 4 || p_data[0])
+        return false;
+
+    /* Skip 4 bytes startcode */
+    if( !memcmp(&p_data[1], &annexb_startcode4[1], 3) )
+    {
+        *pp_data += 4;
+        *pi_data -= 4;
+    }
+    /* Skip 3 bytes startcode */
+    else if( !memcmp(&p_data[1], &annexb_startcode4[2], 2) )
+    {
+        *pp_data += 3;
+        *pi_data -= 3;
+    }
+    else
+        return false;
+    return true;
+}
+
 /* Discards emulation prevention three bytes */
 static inline uint8_t * hxxx_ep3b_to_rbsp(const uint8_t *p_src, size_t i_src, size_t *pi_ret)
 {



More information about the vlc-commits mailing list