[vlc-commits] packetizer: hevc: use helper to get pps/sps/vps

Francois Cartegnie git at videolan.org
Wed Mar 29 20:39:35 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Mar 29 19:00:05 2017 +0200| [143ae28f2b37e0a83302b645da7d82d6cfcd8d20] | committer: Francois Cartegnie

packetizer: hevc: use helper to get pps/sps/vps

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

 modules/packetizer/hevc.c     | 15 ++++++++++++++-
 modules/packetizer/hevc_nal.c | 26 +++++++++++++++-----------
 modules/packetizer/hevc_nal.h |  9 +++++++--
 3 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/modules/packetizer/hevc.c b/modules/packetizer/hevc.c
index 8392e64..390a16f 100644
--- a/modules/packetizer/hevc.c
+++ b/modules/packetizer/hevc.c
@@ -402,6 +402,19 @@ static bool XPSReady(decoder_sys_t *p_sys)
     return false;
 }
 
+static void GetXPSSet(uint8_t i_pps_id, void *priv,
+                      hevc_picture_parameter_set_t **pp_pps,
+                      hevc_sequence_parameter_set_t **pp_sps,
+                      hevc_video_parameter_set_t **pp_vps)
+{
+    decoder_sys_t *p_sys = priv;
+    *pp_sps = NULL;
+    *pp_vps = NULL;
+    if((*pp_pps = p_sys->rgi_p_decpps[i_pps_id]))
+        if((*pp_sps = p_sys->rgi_p_decsps[hevc_get_pps_sps_id(*pp_pps)]))
+            *pp_vps = p_sys->rgi_p_decvps[hevc_get_sps_vps_id(*pp_sps)];
+}
+
 static block_t *ParseVCL(decoder_t *p_dec, uint8_t i_nal_type, block_t *p_frag)
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
@@ -440,7 +453,7 @@ static block_t *ParseVCL(decoder_t *p_dec, uint8_t i_nal_type, block_t *p_frag)
             default:
             {
                 hevc_slice_segment_header_t *p_sli = hevc_decode_slice_header( p_buffer, i_buffer, true,
-                                                                               p_sys->rgi_p_decsps, p_sys->rgi_p_decpps );
+                                                                               GetXPSSet, p_sys );
                 if( p_sli )
                 {
                     enum hevc_slice_type_e type;
diff --git a/modules/packetizer/hevc_nal.c b/modules/packetizer/hevc_nal.c
index 435eb31..4772a28 100644
--- a/modules/packetizer/hevc_nal.c
+++ b/modules/packetizer/hevc_nal.c
@@ -1008,6 +1008,11 @@ uint8_t hevc_get_pps_sps_id( const hevc_picture_parameter_set_t *p_pps )
     return p_pps->pps_seq_parameter_set_id;
 }
 
+uint8_t hevc_get_slice_pps_id( const hevc_slice_segment_header_t *p_slice )
+{
+    return p_slice->slice_pic_parameter_set_id;
+}
+
 bool hevc_get_sps_profile_tier_level( const hevc_sequence_parameter_set_t *p_sps,
                                       uint8_t *pi_profile, uint8_t *pi_level)
 {
@@ -1093,10 +1098,14 @@ bool hevc_get_colorimetry( const hevc_sequence_parameter_set_t *p_sps,
 
 static bool hevc_parse_slice_segment_header_rbsp( bs_t *p_bs,
                                                   uint8_t i_nal_type,
-                                                  hevc_sequence_parameter_set_t **pp_sps,
-                                                  hevc_picture_parameter_set_t **pp_pps,
+                                                  pf_get_matchedxps get_matchedxps,
+                                                  void *priv,
                                                   hevc_slice_segment_header_t *p_sl )
 {
+    hevc_sequence_parameter_set_t *p_sps;
+    hevc_picture_parameter_set_t *p_pps;
+    hevc_video_parameter_set_t *p_vps;
+
     if( bs_remain( p_bs ) < 3 )
         return false;
 
@@ -1107,8 +1116,8 @@ static bool hevc_parse_slice_segment_header_rbsp( bs_t *p_bs,
     if( p_sl->slice_pic_parameter_set_id > HEVC_PPS_ID_MAX || bs_remain( p_bs ) < 1 )
         return false;
 
-    const hevc_picture_parameter_set_t *p_pps = pp_pps[p_sl->slice_pic_parameter_set_id];
-    if(!p_pps)
+    get_matchedxps( p_sl->slice_pic_parameter_set_id, priv, &p_pps, &p_sps, &p_vps );
+    if(!p_sps || !p_pps)
         return false;
 
     if( !p_sl->first_slice_segment_in_pic_flag )
@@ -1116,7 +1125,6 @@ static bool hevc_parse_slice_segment_header_rbsp( bs_t *p_bs,
         if( p_pps->dependent_slice_segments_enabled_flag )
             p_sl->dependent_slice_segment_flag = bs_read1( p_bs );
 
-        const hevc_sequence_parameter_set_t *p_sps = pp_sps[p_pps->pps_seq_parameter_set_id];
         if( !p_sps )
             return false;
 
@@ -1165,12 +1173,8 @@ void hevc_rbsp_release_slice_header( hevc_slice_segment_header_t *p_sh )
 }
 
 hevc_slice_segment_header_t * hevc_decode_slice_header( const uint8_t *p_buf, size_t i_buf, bool b_escaped,
-                                                        hevc_sequence_parameter_set_t **pp_sps,
-                                                        hevc_picture_parameter_set_t **pp_pps )
+                                                        pf_get_matchedxps get_matchedxps, void *priv )
 {
-    if(!pp_sps || !pp_pps)
-        return NULL;
-
     hevc_slice_segment_header_t *p_sh = calloc(1, sizeof(hevc_slice_segment_header_t));
     if(likely(p_sh))
     {
@@ -1188,7 +1192,7 @@ hevc_slice_segment_header_t * hevc_decode_slice_header( const uint8_t *p_buf, si
         uint8_t i_nuh_layer_id = bs_read( &bs, 6 );
         bs_skip( &bs, 3 ); /* !nal_unit_header */
         if( i_nuh_layer_id > 62 ||
-           !hevc_parse_slice_segment_header_rbsp( &bs, i_nal_type, pp_sps, pp_pps, p_sh ) )
+           !hevc_parse_slice_segment_header_rbsp( &bs, i_nal_type, get_matchedxps, priv, p_sh ) )
         {
             hevc_rbsp_release_slice_header( p_sh );
             p_sh = NULL;
diff --git a/modules/packetizer/hevc_nal.h b/modules/packetizer/hevc_nal.h
index 9103869..14bb6ba 100644
--- a/modules/packetizer/hevc_nal.h
+++ b/modules/packetizer/hevc_nal.h
@@ -157,9 +157,13 @@ typedef struct hevc_slice_segment_header_t hevc_slice_segment_header_t;
 hevc_video_parameter_set_t *    hevc_decode_vps( const uint8_t *, size_t, bool );
 hevc_sequence_parameter_set_t * hevc_decode_sps( const uint8_t *, size_t, bool );
 hevc_picture_parameter_set_t *  hevc_decode_pps( const uint8_t *, size_t, bool );
+
+typedef void(*pf_get_matchedxps)(uint8_t i_pps_id, void *priv,
+                                 hevc_picture_parameter_set_t **,
+                                 hevc_sequence_parameter_set_t **,
+                                 hevc_video_parameter_set_t **);
 hevc_slice_segment_header_t *   hevc_decode_slice_header( const uint8_t *, size_t, bool,
-                                                  hevc_sequence_parameter_set_t **pp_sps/* HEVC_MAX_SPS */,
-                                                  hevc_picture_parameter_set_t **pp_pps /* HEVC_MAX_PPS */);
+                                                          pf_get_matchedxps, void *priv );
 
 void hevc_rbsp_release_vps( hevc_video_parameter_set_t * );
 void hevc_rbsp_release_sps( hevc_sequence_parameter_set_t * );
@@ -169,6 +173,7 @@ void hevc_rbsp_release_slice_header( hevc_slice_segment_header_t * );
 /* set specific */
 uint8_t hevc_get_sps_vps_id( const hevc_sequence_parameter_set_t * );
 uint8_t hevc_get_pps_sps_id( const hevc_picture_parameter_set_t * );
+uint8_t hevc_get_slice_pps_id( const hevc_slice_segment_header_t * );
 
 /* Converts HEVCDecoderConfigurationRecord to Annex B format */
 uint8_t * hevc_hvcC_to_AnnexB_NAL( const uint8_t *p_buf, size_t i_buf,



More information about the vlc-commits mailing list