Commit b9d7a754 authored by Francois Cartegnie's avatar Francois Cartegnie

packetizer: hevc: add NALType and hvcC nal length helpers

parent bc2c083d
......@@ -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 */
......
......@@ -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)
......
......@@ -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 */
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment