diff --git a/modules/codec/hxxx_helper.h b/modules/codec/hxxx_helper.h index c16798dcab..b54023b5a4 100644 --- a/modules/codec/hxxx_helper.h +++ b/modules/codec/hxxx_helper.h @@ -63,9 +63,9 @@ struct hxxx_helper uint8_t i_spsext_count; } h264; struct { - struct hxxx_helper_nal sps_list[HEVC_SPS_ID_MAX + 1]; - struct hxxx_helper_nal pps_list[HEVC_PPS_ID_MAX + 1]; - struct hxxx_helper_nal vps_list[HEVC_VPS_ID_MAX + 1]; + struct hxxx_helper_nal sps_list[HEVC_MAX_NUM_SPS]; + struct hxxx_helper_nal pps_list[HEVC_MAX_NUM_PPS]; + struct hxxx_helper_nal vps_list[HEVC_MAX_NUM_VPS]; struct hxxx_helper_nal sei_list[HXXX_HELPER_SEI_COUNT]; uint8_t i_current_sps; uint8_t i_current_vps; diff --git a/modules/packetizer/hevc.c b/modules/packetizer/hevc.c index 8e1bd1706b..b1b8c5faa5 100644 --- a/modules/packetizer/hevc.c +++ b/modules/packetizer/hevc.c @@ -80,9 +80,9 @@ typedef struct uint8_t i_nal_length_size; - struct hevc_tuple_s rg_vps[HEVC_VPS_ID_MAX + 1], - rg_sps[HEVC_SPS_ID_MAX + 1], - rg_pps[HEVC_PPS_ID_MAX + 1]; + struct hevc_tuple_s rg_vps[HEVC_MAX_NUM_VPS], + rg_sps[HEVC_MAX_NUM_SPS], + rg_pps[HEVC_MAX_NUM_PPS]; const hevc_video_parameter_set_t *p_active_vps; const hevc_sequence_parameter_set_t *p_active_sps; @@ -296,7 +296,7 @@ static void Close(vlc_object_t *p_this) block_ChainRelease(p_sys->pre.p_chain); block_ChainRelease(p_sys->post.p_chain); - for(unsigned i=0;i<=HEVC_PPS_ID_MAX; i++) + for(unsigned i=0;irg_pps[i].p_decoded) hevc_rbsp_release_pps(p_sys->rg_pps[i].p_decoded); @@ -304,7 +304,7 @@ static void Close(vlc_object_t *p_this) block_Release(p_sys->rg_pps[i].p_nal); } - for(unsigned i=0;i<=HEVC_SPS_ID_MAX; i++) + for(unsigned i=0;irg_sps[i].p_decoded) hevc_rbsp_release_sps(p_sys->rg_sps[i].p_decoded); @@ -312,7 +312,7 @@ static void Close(vlc_object_t *p_this) block_Release(p_sys->rg_sps[i].p_nal); } - for(unsigned i=0;i<=HEVC_VPS_ID_MAX; i++) + for(unsigned i=0;irg_vps[i].p_decoded) hevc_rbsp_release_vps(p_sys->rg_vps[i].p_decoded); @@ -506,7 +506,7 @@ static block_t *GetXPSCopy(decoder_sys_t *p_sys) block_t *p_chain = NULL; block_t **pp_append = &p_chain; struct hevc_tuple_s *xpstype[3] = {p_sys->rg_vps, p_sys->rg_sps, p_sys->rg_pps}; - size_t xpsmax[3] = {HEVC_VPS_ID_MAX+1, HEVC_SPS_ID_MAX+1, HEVC_PPS_ID_MAX+1}; + size_t xpsmax[3] = {HEVC_MAX_NUM_VPS, HEVC_MAX_NUM_SPS, HEVC_MAX_NUM_PPS}; for(size_t i=0; i<3; i++) { struct hevc_tuple_s *xps = xpstype[i]; @@ -523,7 +523,7 @@ static block_t *GetXPSCopy(decoder_sys_t *p_sys) static bool XPSReady(decoder_sys_t *p_sys) { - for(unsigned i=0;i<=HEVC_PPS_ID_MAX; i++) + for(unsigned i=0;irg_pps[i].p_decoded; if (p_pps) @@ -557,8 +557,8 @@ static void AppendAsAnnexB(const block_t *p_block, } } -#define APPENDIF(idmax, set, rg, b) \ - for(size_t i=0; i<=idmax; i++)\ +#define APPENDIF(maxcount, set, rg, b) \ + for(size_t i=0; irg_vps, true); - APPENDIF(HEVC_VPS_ID_MAX, p_vps, p_sys->rg_vps, false); - APPENDIF(HEVC_SPS_ID_MAX, p_sps, p_sys->rg_sps, true); - APPENDIF(HEVC_SPS_ID_MAX, p_sps, p_sys->rg_sps, false); - APPENDIF(HEVC_PPS_ID_MAX, p_pps, p_sys->rg_pps, true); - APPENDIF(HEVC_PPS_ID_MAX, p_pps, p_sys->rg_pps, false); + APPENDIF(HEVC_MAX_NUM_VPS, p_vps, p_sys->rg_vps, true); + APPENDIF(HEVC_MAX_NUM_VPS, p_vps, p_sys->rg_vps, false); + APPENDIF(HEVC_MAX_NUM_SPS, p_sps, p_sys->rg_sps, true); + APPENDIF(HEVC_MAX_NUM_SPS, p_sps, p_sys->rg_sps, false); + APPENDIF(HEVC_MAX_NUM_PPS, p_pps, p_sys->rg_pps, true); + APPENDIF(HEVC_MAX_NUM_PPS, p_pps, p_sys->rg_pps, false); /* because we copy to i_extra :/ */ if(i_data <= INT_MAX) diff --git a/modules/packetizer/hevc_nal.h b/modules/packetizer/hevc_nal.h index 7283c17b92..a34ace959e 100644 --- a/modules/packetizer/hevc_nal.h +++ b/modules/packetizer/hevc_nal.h @@ -30,6 +30,9 @@ extern "C" { #define HEVC_VPS_ID_MAX 15 #define HEVC_SPS_ID_MAX 15 #define HEVC_PPS_ID_MAX 63 +#define HEVC_MAX_NUM_VPS (HEVC_VPS_ID_MAX + 1) +#define HEVC_MAX_NUM_SPS (HEVC_SPS_ID_MAX + 1) +#define HEVC_MAX_NUM_PPS (HEVC_PPS_ID_MAX + 1) enum hevc_general_profile_idc_e {