mpeg4video: guarantee aspect_ratio_idc is 4bits
There was no guarantee from bs_read() that the result could not return 0xff itself, which would be like the case 0xf but with ar.sar_width and ar.sar_height uninitialized. This tells the compiler that everything is fine.
The alternative solution is to patch the vlc_bits.h file adding a macro for bs_read() doing:
#define bs_read(s, count) (bs_read(s, count) &
(uint32_t)(((uint64_t)1 << (uint64_t)(count+1)) - 1))
Unfortunately, using count from the macro makes is expansion-unsafe and using this and-operation inside bs_read() is not enough for the compiler to ensure that there is no more bits that count, despite the function being inline.
Fixes the following warnings:
In file included from ../../modules/packetizer/mpeg4video.c:43:
In function ‘h26x_get_aspect_ratio’,
inlined from ‘ParseVOL.isra’ at ../../modules/packetizer/mpeg4video.c:403:9:
../../modules/packetizer/h26x_nal_common.h:117:18: warning: ‘ar.sar_width’ may be used uninitialized [-Wmaybe-uninitialized]
117 | *num = ar->sar_width;
| ~~^~~~~~~~~~~
../../modules/packetizer/mpeg4video.c: In function ‘ParseVOL.isra’:
../../modules/packetizer/mpeg4video.c:364:25: note: ‘ar.sar_width’ was declared here
364 | h26x_aspect_ratio_t ar;
| ^~
In function ‘h26x_get_aspect_ratio’,
inlined from ‘ParseVOL.isra’ at ../../modules/packetizer/mpeg4video.c:403:9:
../../modules/packetizer/h26x_nal_common.h:118:18: warning: ‘ar.sar_height’ may be used uninitialized [-Wmaybe-uninitialized]
118 | *den = ar->sar_height;
| ~~^~~~~~~~~~~~
../../modules/packetizer/mpeg4video.c: In function ‘ParseVOL.isra’:
../../modules/packetizer/mpeg4video.c:364:25: note: ‘ar.sar_height’ was declared here
364 | h26x_aspect_ratio_t ar;
| ^~
Merge request reports
Activity
added MRStatus::Reviewable label
added MRStatus::Accepted label and removed MRStatus::Reviewable label
MR Acceptance result
This MergeRequest has been Accepted! Congratulations.MR acceptance checks details:
-
MR should be considered mergeable by Gitlab -
Last pipeline should be successful -
MergeRequest should have at least one external review and/or vote -
All threads should be resolved, and score >= 0 -
MergeRequest should have no activity (threads/votes) for (24h/24h)
-
changed milestone to %4.0
added Component::Packetizers label
added 46 commits
-
e5f49301...8f513763 - 45 commits from branch
videolan:master
- 8851a72b - mpeg4video: guarantee aspect_ratio_idc is 4bits
-
e5f49301...8f513763 - 45 commits from branch
enabled an automatic merge when the pipeline for 8851a72b succeeds