[vlc-commits] hevc_nal: add is_hvcC helper
Francois Cartegnie
git at videolan.org
Tue Dec 8 23:10:07 CET 2015
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Dec 8 18:48:54 2015 +0100| [51f645956e2edfd3b42252191ca81a23e66c4c92] | committer: Francois Cartegnie
hevc_nal: add is_hvcC helper
Tries strongest match against decoder record
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=51f645956e2edfd3b42252191ca81a23e66c4c92
---
modules/mux/mp4/libmp4mux.c | 2 +-
modules/packetizer/hevc_nal.h | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/modules/mux/mp4/libmp4mux.c b/modules/mux/mp4/libmp4mux.c
index 2800079..ea54671 100644
--- a/modules/mux/mp4/libmp4mux.c
+++ b/modules/mux/mp4/libmp4mux.c
@@ -592,7 +592,7 @@ static bo_t *GetHvcCTag(es_format_t *p_fmt)
size_t i_buffer = p_fmt->i_extra;
/* 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);
return hvcC;
diff --git a/modules/packetizer/hevc_nal.h b/modules/packetizer/hevc_nal.h
index ad8fbd8..db13ed2 100644
--- a/modules/packetizer/hevc_nal.h
+++ b/modules/packetizer/hevc_nal.h
@@ -63,6 +63,22 @@ enum hevc_nal_unit_type_e
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 */
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,
More information about the vlc-commits
mailing list