vlc | branch: master | Francois Cartegnie <[email protected]> | Wed Dec 16 17:45:57 2015 +0100| [c2a21b270617c229d29645fdfb43990b762f08c1] | committer: Francois Cartegnie
packetizer: hxxx_nal: startcode simplication > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c2a21b270617c229d29645fdfb43990b762f08c1 --- modules/packetizer/hxxx_nal.h | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/modules/packetizer/hxxx_nal.h b/modules/packetizer/hxxx_nal.h index 8e116e5..39557d5 100644 --- a/modules/packetizer/hxxx_nal.h +++ b/modules/packetizer/hxxx_nal.h @@ -29,27 +29,30 @@ static const uint8_t annexb_startcode4[] = { 0x00, 0x00, 0x00, 0x01 }; #define annexb_startcode3 (&annexb_startcode4[1]) +/* strips any AnnexB startcode [0] 0 0 1 */ static inline bool hxxx_strip_AnnexB_startcode( const uint8_t **pp_data, size_t *pi_data ) { + unsigned bitflow = 0; const uint8_t *p_data = *pp_data; - if(*pi_data < 4 || p_data[0]) - return false; + size_t i_data = *pi_data; - /* Skip 4 bytes startcode */ - if( !memcmp(&p_data[1], &annexb_startcode4[1], 3) ) + while( i_data && p_data[0] <= 1 ) { - *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; + bitflow = (bitflow << 1) | (!p_data[0]); + p_data++; + i_data--; + if( !(bitflow & 0x01) ) + { + if( (bitflow & 0x06) == 0x06 ) /* there was at least 2 leading zeros */ + { + *pi_data = i_data; + *pp_data = p_data; + return true; + } + return false; + } } - else - return false; - return true; + return false; } /* Discards emulation prevention three bytes */ _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
