Commit 51f64595 authored by Francois Cartegnie's avatar Francois Cartegnie

hevc_nal: add is_hvcC helper

Tries strongest match against decoder record
parent e3ad8470
...@@ -592,7 +592,7 @@ static bo_t *GetHvcCTag(es_format_t *p_fmt) ...@@ -592,7 +592,7 @@ static bo_t *GetHvcCTag(es_format_t *p_fmt)
size_t i_buffer = p_fmt->i_extra; size_t i_buffer = p_fmt->i_extra;
/* Extradata is already an HEVCDecoderConfigurationRecord */ /* Extradata is already an HEVCDecoderConfigurationRecord */
if(i_buffer > 16 && p_buffer[0] == 0x01) if(hevc_ishvcC(p_buffer, i_buffer))
{ {
(void) bo_add_mem(hvcC, i_buffer, p_buffer); (void) bo_add_mem(hvcC, i_buffer, p_buffer);
return hvcC; return hvcC;
......
...@@ -63,6 +63,22 @@ enum hevc_nal_unit_type_e ...@@ -63,6 +63,22 @@ enum hevc_nal_unit_type_e
HEVC_NAL_UNKNOWN HEVC_NAL_UNKNOWN
}; };
#define HEVC_MIN_HVCC_SIZE 22
/* checks if data is an HEVCDecoderConfigurationRecord */
static inline bool hevc_ishvcC( const uint8_t *p_buf, size_t i_buf )
{
return ( i_buf >= HEVC_MIN_HVCC_SIZE &&
p_buf[0] == 0x01 &&
(p_buf[13] & 0xF0) == 0xF0 && /* Match all reserved bits */
(p_buf[15] & 0xFC) == 0xFC &&
(p_buf[16] & 0xFC) == 0xFC &&
(p_buf[17] & 0xF8) == 0xF8 &&
(p_buf[18] & 0xF8) == 0xF8 &&
(p_buf[21] & 0x03) != 0x02
);
}
/* Converts HEVCDecoderConfigurationRecord to Annex B format */ /* Converts HEVCDecoderConfigurationRecord to Annex B format */
int hevc_hvcC_to_AnnexB_NAL( decoder_t *p_dec, const uint8_t *p_buf, int hevc_hvcC_to_AnnexB_NAL( decoder_t *p_dec, const uint8_t *p_buf,
uint32_t i_buf_size, uint8_t *p_out_buf, uint32_t i_buf_size, uint8_t *p_out_buf,
......
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