packetizer: hevc: add get_profile_level
authorFrancois Cartegnie <fcvlcdev@free.fr>
Tue, 12 Jul 2016 08:16:53 +0000 (10:16 +0200)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Tue, 12 Jul 2016 08:18:54 +0000 (10:18 +0200)
modules/packetizer/hevc_nal.c
modules/packetizer/hevc_nal.h

index 8be77d9..7f89b6c 100644 (file)
@@ -1173,3 +1173,23 @@ bool hevc_get_slice_type( const hevc_slice_segment_header_t *p_sli, enum hevc_sl
     }
     return false;
 }
+
+bool hevc_get_profile_level(const es_format_t *p_fmt, uint8_t *pi_profile,
+                            uint8_t *pi_level, uint8_t *pi_nal_length_size)
+{
+    const uint8_t *p = (const uint8_t*)p_fmt->p_extra;
+    if(p_fmt->i_extra < 23 || p[0] != 1)
+        return false;
+
+    /* HEVCDecoderConfigurationRecord */
+    if(pi_profile)
+        *pi_profile = p[1] & 0x1F;
+
+    if(pi_level)
+        *pi_level = p[12];
+
+    if (pi_nal_length_size)
+        *pi_nal_length_size = 1 + (p[21]&0x03);
+
+    return true;
+}
index 2dca630..c8f1fbe 100644 (file)
@@ -182,4 +182,8 @@ bool hevc_get_colorimetry( const hevc_sequence_parameter_set_t *p_sps,
                            bool *p_full_range );
 bool hevc_get_slice_type( const hevc_slice_segment_header_t *, enum hevc_slice_type_e * );
 
+/* Get level and Profile from DecoderConfigurationRecord */
+bool hevc_get_profile_level(const es_format_t *p_fmt, uint8_t *pi_profile,
+                            uint8_t *pi_level, uint8_t *pi_nal_length_size);
+
 #endif /* HEVC_NAL_H */