[vlc-commits] [Git][videolan/vlc][master] 4 commits: mux: mp4: always match the size check with the array we write into
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Sep 17 08:23:51 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
a53f6469 by Steve Lhomme at 2024-09-17T07:51:58+00:00
mux: mp4: always match the size check with the array we write into
We don't need to know what is the actual size.
- - - - -
5b7bb83e by Steve Lhomme at 2024-09-17T07:51:58+00:00
hxxx_helper: always match the size check with the array we write into
We don't need to know what is the actual size.
- - - - -
7ff50cc7 by Steve Lhomme at 2024-09-17T07:51:58+00:00
hxxx_helper: always match the size check with the AnnexB array we write into
We don't need to know what is the actual size.
- - - - -
e4dcadab by Steve Lhomme at 2024-09-17T07:51:58+00:00
hxxx_helper: use a macro to match the written NAL list with its array size
- - - - -
2 changed files:
- modules/codec/hxxx_helper.c
- modules/mux/mp4/libmp4mux.c
Changes:
=====================================
modules/codec/hxxx_helper.c
=====================================
@@ -111,6 +111,9 @@ hxxx_helper_clean(struct hxxx_helper *hh)
for (size_t ii = 0, i_nal_found = 0; ii < i_nal_max && i_nal_count > i_nal_found; ++ii) \
if (p_nal_list[ii].b != NULL && (it = &p_nal_list[ii]) && ++i_nal_found)
+#define HELPER_FOREACH_NAL_LIST(it, p_nal_list, i_nal_count) \
+ HELPER_FOREACH_NAL(it, p_nal_list, i_nal_count, ARRAY_SIZE(p_nal_list))
+
static int
helper_dup_buf(struct hxxx_helper_nal *p_nal,
const uint8_t *p_nal_buf, size_t i_nal_buf)
@@ -666,9 +669,10 @@ h264_helper_get_annexb_config(const struct hxxx_helper *hh)
const struct hxxx_helper_nal *pp_nal_lists[] = {
hh->h264.sps_list, hh->h264.pps_list, hh->h264.spsext_list };
const size_t p_nal_counts[] = { hh->h264.i_sps_count, hh->h264.i_pps_count, hh->h264.i_spsext_count };
- const size_t p_nal_maxs[] = { H264_SPS_ID_MAX+1, H264_PPS_ID_MAX+1, H264_SPSEXT_ID_MAX+1 };
+ const size_t p_nal_maxs[] = {
+ ARRAY_SIZE(hh->h264.sps_list), ARRAY_SIZE(hh->h264.pps_list), ARRAY_SIZE(hh->h264.spsext_list) };
- return hxxx_helper_get_annexb_config( pp_nal_lists, p_nal_counts, p_nal_maxs, 3 );
+ return hxxx_helper_get_annexb_config( pp_nal_lists, p_nal_counts, p_nal_maxs, ARRAY_SIZE(p_nal_counts) );
}
static block_t *
@@ -682,9 +686,10 @@ hevc_helper_get_annexb_config(const struct hxxx_helper *hh)
hh->hevc.vps_list, hh->hevc.sps_list, hh->hevc.pps_list };
const size_t p_nal_counts[] = { hh->hevc.i_vps_count, hh->hevc.i_sps_count,
hh->hevc.i_pps_count };
- const size_t p_nal_maxs[] = { HEVC_VPS_ID_MAX+1, HEVC_SPS_ID_MAX+1, HEVC_PPS_ID_MAX+1 };
+ const size_t p_nal_maxs[] = {
+ ARRAY_SIZE(hh->hevc.vps_list), ARRAY_SIZE(hh->hevc.sps_list), ARRAY_SIZE(hh->hevc.pps_list) };
- return hxxx_helper_get_annexb_config( pp_nal_lists, p_nal_counts, p_nal_maxs, 3 );
+ return hxxx_helper_get_annexb_config( pp_nal_lists, p_nal_counts, p_nal_maxs, ARRAY_SIZE(p_nal_counts) );
}
static block_t *
@@ -693,8 +698,7 @@ h264_helper_get_avcc_config(const struct hxxx_helper *hh)
const struct hxxx_helper_nal *p_nal;
const uint8_t *pp_sps_bufs[hh->h264.i_sps_count];
size_t p_sps_sizes[hh->h264.i_sps_count];
- HELPER_FOREACH_NAL(p_nal, hh->h264.sps_list, hh->h264.i_sps_count,
- H264_SPS_ID_MAX+1)
+ HELPER_FOREACH_NAL_LIST(p_nal, hh->h264.sps_list, hh->h264.i_sps_count)
{
pp_sps_bufs[i_nal_found - 1] = p_nal->b->p_buffer;
p_sps_sizes[i_nal_found - 1] = p_nal->b->i_buffer;
@@ -702,8 +706,7 @@ h264_helper_get_avcc_config(const struct hxxx_helper *hh)
const uint8_t *pp_pps_bufs[hh->h264.i_pps_count];
size_t p_pps_sizes[hh->h264.i_pps_count];
- HELPER_FOREACH_NAL(p_nal, hh->h264.pps_list, hh->h264.i_pps_count,
- H264_PPS_ID_MAX+1)
+ HELPER_FOREACH_NAL_LIST(p_nal, hh->h264.pps_list, hh->h264.i_pps_count)
{
pp_pps_bufs[i_nal_found - 1] = p_nal->b->p_buffer;
p_pps_sizes[i_nal_found - 1] = p_nal->b->i_buffer;
@@ -711,8 +714,7 @@ h264_helper_get_avcc_config(const struct hxxx_helper *hh)
const uint8_t *pp_spsext_bufs[hh->h264.i_spsext_count];
size_t p_spsext_sizes[hh->h264.i_spsext_count];
- HELPER_FOREACH_NAL(p_nal, hh->h264.spsext_list, hh->h264.i_spsext_count,
- H264_SPSEXT_ID_MAX+1)
+ HELPER_FOREACH_NAL_LIST(p_nal, hh->h264.spsext_list, hh->h264.i_spsext_count)
{
pp_spsext_bufs[i_nal_found - 1] = p_nal->b->p_buffer;
p_spsext_sizes[i_nal_found - 1] = p_nal->b->i_buffer;
@@ -729,29 +731,25 @@ hevc_helper_get_hvcc_config(const struct hxxx_helper *hh)
struct hevc_dcr_params params = { .i_vps_count = 0 };
const struct hxxx_helper_nal *p_nal;
- HELPER_FOREACH_NAL(p_nal, hh->hevc.vps_list, hh->hevc.i_vps_count,
- HEVC_VPS_ID_MAX+1)
+ HELPER_FOREACH_NAL_LIST(p_nal, hh->hevc.vps_list, hh->hevc.i_vps_count)
{
params.p_vps[params.i_vps_count] = p_nal->b->p_buffer;
params.rgi_vps[params.i_vps_count++] = p_nal->b->i_buffer;
}
- HELPER_FOREACH_NAL(p_nal, hh->hevc.sps_list, hh->hevc.i_sps_count,
- HEVC_SPS_ID_MAX+1)
+ HELPER_FOREACH_NAL_LIST(p_nal, hh->hevc.sps_list, hh->hevc.i_sps_count)
{
params.p_sps[params.i_sps_count] = p_nal->b->p_buffer;
params.rgi_sps[params.i_sps_count++] = p_nal->b->i_buffer;
}
- HELPER_FOREACH_NAL(p_nal, hh->hevc.pps_list, hh->hevc.i_pps_count,
- HEVC_PPS_ID_MAX+1)
+ HELPER_FOREACH_NAL_LIST(p_nal, hh->hevc.pps_list, hh->hevc.i_pps_count)
{
params.p_pps[params.i_pps_count] = p_nal->b->p_buffer;
params.rgi_pps[params.i_pps_count++] = p_nal->b->i_buffer;
}
- HELPER_FOREACH_NAL(p_nal, hh->hevc.sei_list, hh->hevc.i_sei_count,
- HEVC_DCR_SEI_COUNT)
+ HELPER_FOREACH_NAL_LIST(p_nal, hh->hevc.sei_list, hh->hevc.i_sei_count)
{
if (hevc_getNALType(p_nal->b->p_buffer) == HEVC_NAL_PREF_SEI)
{
=====================================
modules/mux/mp4/libmp4mux.c
=====================================
@@ -788,7 +788,7 @@ static bo_t *GetHvcCTag(const uint8_t *p_extra, size_t i_extra,
switch (hevc_getNALType(p_nal))
{
case HEVC_NAL_VPS:
- if(params.i_vps_count != HEVC_DCR_VPS_COUNT)
+ if(params.i_vps_count != ARRAY_SIZE(params.p_vps))
{
params.p_vps[params.i_vps_count] = p_nal;
params.rgi_vps[params.i_vps_count] = i_nal;
@@ -796,7 +796,7 @@ static bo_t *GetHvcCTag(const uint8_t *p_extra, size_t i_extra,
}
break;
case HEVC_NAL_SPS:
- if(params.i_sps_count != HEVC_DCR_SPS_COUNT)
+ if(params.i_sps_count != ARRAY_SIZE(params.p_sps))
{
params.p_sps[params.i_sps_count] = p_nal;
params.rgi_sps[params.i_sps_count] = i_nal;
@@ -804,7 +804,7 @@ static bo_t *GetHvcCTag(const uint8_t *p_extra, size_t i_extra,
}
break;
case HEVC_NAL_PPS:
- if(params.i_pps_count != HEVC_DCR_PPS_COUNT)
+ if(params.i_pps_count != ARRAY_SIZE(params.p_pps))
{
params.p_pps[params.i_pps_count] = p_nal;
params.rgi_pps[params.i_pps_count] = i_nal;
@@ -812,7 +812,7 @@ static bo_t *GetHvcCTag(const uint8_t *p_extra, size_t i_extra,
}
break;
case HEVC_NAL_PREF_SEI:
- if(params.i_seipref_count != HEVC_DCR_SEI_COUNT)
+ if(params.i_seipref_count != ARRAY_SIZE(params.p_seipref))
{
params.p_seipref[params.i_seipref_count] = p_nal;
params.rgi_seipref[params.i_seipref_count] = i_nal;
@@ -820,7 +820,7 @@ static bo_t *GetHvcCTag(const uint8_t *p_extra, size_t i_extra,
}
break;
case HEVC_NAL_SUFF_SEI:
- if(params.i_seisuff_count != HEVC_DCR_SEI_COUNT)
+ if(params.i_seisuff_count != ARRAY_SIZE(params.p_seisuff))
{
params.p_seisuff[params.i_seisuff_count] = p_nal;
params.rgi_seisuff[params.i_seisuff_count] = i_nal;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/cc638083ce4afd18d9f352516b6c20fdc4903d6b...e4dcadab16a4cc564ca0444fbc4a054a4e5c0dc0
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/cc638083ce4afd18d9f352516b6c20fdc4903d6b...e4dcadab16a4cc564ca0444fbc4a054a4e5c0dc0
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list