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; | ^~
parent
8f513763
No related branches found
No related tags found
Please register or sign in to comment