vlc | branch: master | Francois Cartegnie <[email protected]> | Fri Jan 15 16:08:47 2016 +0100| [b9d7a7540c67e804013151c1d2df62de4ad9d0af] | committer: Francois Cartegnie
packetizer: hevc: add NALType and hvcC nal length helpers > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b9d7a7540c67e804013151c1d2df62de4ad9d0af --- modules/demux/mpeg/h26x.c | 2 +- modules/mux/mp4/libmp4mux.c | 2 +- modules/packetizer/hevc.c | 2 +- modules/packetizer/hevc_nal.c | 6 +++--- modules/packetizer/hevc_nal.h | 10 ++++++++++ 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/demux/mpeg/h26x.c b/modules/demux/mpeg/h26x.c index 28654c9..bfea7b0 100644 --- a/modules/demux/mpeg/h26x.c +++ b/modules/demux/mpeg/h26x.c @@ -117,7 +117,7 @@ static int ProbeHEVC( const uint8_t *p_peek, size_t i_peek, void *p_priv ) if( p_peek[0] & 0x80 ) return -1; - const uint8_t i_type = (p_peek[0] & 0x7E) >> 1; + const uint8_t i_type = hevc_getNALType( p_peek ); const uint8_t i_layer = hevc_getNALLayer( p_peek ); if ( i_type == HEVC_NAL_VPS ) /* VPS */ diff --git a/modules/mux/mp4/libmp4mux.c b/modules/mux/mp4/libmp4mux.c index f7e940f..51f5c7f 100644 --- a/modules/mux/mp4/libmp4mux.c +++ b/modules/mux/mp4/libmp4mux.c @@ -620,7 +620,7 @@ static bo_t *GetHvcCTag(es_format_t *p_fmt, bool b_completeness) if (p_nal) p_nal->i_buffer = p_buffer - p_nal->p_buffer - ((i_buffer)?3:0); - switch ((*p_buffer & 0x7E) >> 1) { + switch (hevc_getNALType(p_buffer)) { case HEVC_NAL_VPS: if(i_vps == HEVC_VPS_MAX) diff --git a/modules/packetizer/hevc.c b/modules/packetizer/hevc.c index 124f17d..2c61627 100644 --- a/modules/packetizer/hevc.c +++ b/modules/packetizer/hevc.c @@ -421,7 +421,7 @@ static block_t *ParseNALBlock(decoder_t *p_dec, bool *pb_ts_used, block_t *p_fra } /* Get NALU type */ - uint8_t i_nal_type = ((p_frag->p_buffer[4] & 0x7E) >> 1); + uint8_t i_nal_type = hevc_getNALType(&p_frag->p_buffer[4]); if (i_nal_type < HEVC_NAL_VPS) { /* NAL is a VCL NAL */ diff --git a/modules/packetizer/hevc_nal.c b/modules/packetizer/hevc_nal.c index 24f12ff..2eb896c 100644 --- a/modules/packetizer/hevc_nal.c +++ b/modules/packetizer/hevc_nal.c @@ -364,7 +364,7 @@ uint8_t * hevc_hvcC_to_AnnexB_NAL( const uint8_t *p_buf, size_t i_buf, return NULL; if( pi_nal_length_size ) - *pi_nal_length_size = (p_buf[21] & 0x03) + 1; + *pi_nal_length_size = hevc_getNALLengthSize( p_buf ); uint8_t *p_ret; uint8_t *p_out_buf = p_ret = malloc( *pi_result ); @@ -504,7 +504,7 @@ bool hevc_get_xps_id(const uint8_t *p_buf, size_t i_buf, uint8_t *pi_id) if(unlikely(!hxxx_strip_AnnexB_startcode(&p_buf, &i_buf) || i_buf < 3)) return false; /* No need to lookup convert from emulation for that data */ - uint8_t i_nal_type = ((p_buf[0] & 0x7E) >> 1); + uint8_t i_nal_type = hevc_getNALType(p_buf); bs_t bs; bs_init(&bs, &p_buf[2], i_buf - 2); if(i_nal_type == HEVC_NAL_PPS) @@ -1114,7 +1114,7 @@ hevc_slice_segment_header_t * hevc_decode_slice_header( const uint8_t *p_buf, si hevc_slice_segment_header_t *p_sh = calloc(1, sizeof(hevc_slice_segment_header_t)); if(likely(p_sh)) { - uint8_t i_nal_type = ((p_buf[0] & 0x7E) >> 1); + uint8_t i_nal_type = hevc_getNALType(p_buf); bs_t bs; bs_init( &bs, p_buf, i_buf ); unsigned i_bitflow = 0; diff --git a/modules/packetizer/hevc_nal.h b/modules/packetizer/hevc_nal.h index f3abd54..3e857c0 100644 --- a/modules/packetizer/hevc_nal.h +++ b/modules/packetizer/hevc_nal.h @@ -135,6 +135,16 @@ static inline bool hevc_ishvcC( const uint8_t *p_buf, size_t i_buf ) ); } +static inline uint8_t hevc_getNALLengthSize( const uint8_t *p_hvcC ) +{ + return (p_hvcC[21] & 0x03) + 1; +} + +static inline uint8_t hevc_getNALType( const uint8_t *p_buf ) +{ + return ((p_buf[0] & 0x7E) >> 1); +} + static inline uint8_t hevc_getNALLayer( const uint8_t *p_buf ) { return ((p_buf[0] & 0x01) << 6) | (p_buf[1] >> 3); _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
