[vlc-commits] packetizer: h264: add h264_get_chroma_luma

Francois Cartegnie git at videolan.org
Fri May 27 12:02:00 CEST 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri May 27 10:10:32 2016 +0200| [69feb2de89e4d5096df320604493022721a2847f] | committer: Francois Cartegnie

packetizer: h264: add h264_get_chroma_luma

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=69feb2de89e4d5096df320604493022721a2847f
---

 modules/packetizer/h264_nal.c |   21 ++++++++++++++++-----
 modules/packetizer/h264_nal.h |    8 ++++++++
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/modules/packetizer/h264_nal.c b/modules/packetizer/h264_nal.c
index 8c14f08..b092573 100644
--- a/modules/packetizer/h264_nal.c
+++ b/modules/packetizer/h264_nal.c
@@ -273,20 +273,20 @@ static bool h264_parse_sequence_parameter_set_rbsp( bs_t *p_bs,
         i_profile_idc == PROFILE_H264_MFC_HIGH )
     {
         /* chroma_format_idc */
-        const int i_chroma_format_idc = bs_read_ue( p_bs );
-        if( i_chroma_format_idc == 3 )
+        p_sps->i_chroma_idc = bs_read_ue( p_bs );
+        if( p_sps->i_chroma_idc == 3 )
             bs_skip( p_bs, 1 ); /* separate_colour_plane_flag */
         /* bit_depth_luma_minus8 */
-        bs_read_ue( p_bs );
+        p_sps->i_bit_depth_luma = bs_read_ue( p_bs ) + 8;
         /* bit_depth_chroma_minus8 */
-        bs_read_ue( p_bs );
+        p_sps->i_bit_depth_chroma = bs_read_ue( p_bs ) + 8;
         /* qpprime_y_zero_transform_bypass_flag */
         bs_skip( p_bs, 1 );
         /* seq_scaling_matrix_present_flag */
         i_tmp = bs_read( p_bs, 1 );
         if( i_tmp )
         {
-            for( int i = 0; i < ((3 != i_chroma_format_idc) ? 8 : 12); i++ )
+            for( int i = 0; i < ((3 != p_sps->i_chroma_idc) ? 8 : 12); i++ )
             {
                 /* seq_scaling_list_present_flag[i] */
                 i_tmp = bs_read( p_bs, 1 );
@@ -606,6 +606,17 @@ bool h264_get_picture_size( const h264_sequence_parameter_set_t *p_sps, unsigned
     return true;
 }
 
+bool h264_get_chroma_luma( const h264_sequence_parameter_set_t *p_sps, uint8_t *pi_chroma_format,
+                           uint8_t *pi_depth_luma, uint8_t *pi_depth_chroma )
+{
+    if( p_sps->i_bit_depth_luma == 0 )
+        return false;
+    *pi_chroma_format = p_sps->i_chroma_idc;
+    *pi_depth_luma = p_sps->i_bit_depth_luma;
+    *pi_depth_chroma = p_sps->i_bit_depth_chroma;
+    return true;
+}
+
 bool h264_get_profile_level(const es_format_t *p_fmt, size_t *p_profile,
                             size_t *p_level, uint8_t *pi_nal_length_size)
 {
diff --git a/modules/packetizer/h264_nal.h b/modules/packetizer/h264_nal.h
index f8f55c6..ea06ff0 100644
--- a/modules/packetizer/h264_nal.h
+++ b/modules/packetizer/h264_nal.h
@@ -94,6 +94,11 @@ struct h264_sequence_parameter_set_t
 {
     int i_id;
     int i_profile, i_profile_compatibility, i_level;
+    /* according to avcC, 3 bits max for those */
+    uint8_t i_chroma_idc;
+    uint8_t i_bit_depth_luma;
+    uint8_t i_bit_depth_chroma;
+
     uint32_t pic_width_in_mbs_minus1;
     uint32_t pic_height_in_map_units_minus1;
     struct
@@ -170,6 +175,9 @@ uint8_t * h264_avcC_to_AnnexB_NAL( const uint8_t *p_buf, size_t i_buf,
 
 bool h264_get_picture_size( const h264_sequence_parameter_set_t *, unsigned *p_w, unsigned *p_h,
                             unsigned *p_vw, unsigned *p_vh );
+bool h264_get_chroma_luma( const h264_sequence_parameter_set_t *, uint8_t *pi_chroma_format,
+                           uint8_t *pi_depth_luma, uint8_t *pi_depth_chroma );
+
 /* Get level and Profile */
 bool h264_get_profile_level(const es_format_t *p_fmt, size_t *p_profile,
                             size_t *p_level, uint8_t *p_nal_length_size);



More information about the vlc-commits mailing list