[vlc-commits] [Git][videolan/vlc][master] mpeg4video: guarantee aspect_ratio_idc is 4bits

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Aug 5 06:41:21 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
8851a72b by Alexandre Janniaux at 2024-08-05T06:27:18+00:00
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;
          |                         ^~

- - - - -


1 changed file:

- modules/packetizer/mpeg4video.c


Changes:

=====================================
modules/packetizer/mpeg4video.c
=====================================
@@ -390,7 +390,7 @@ static int ParseVOL( decoder_t *p_dec, es_format_t *fmt,
     {
         i_vo_ver_id = 1;
     }
-    ar.aspect_ratio_idc = bs_read( &s, 4 );
+    ar.aspect_ratio_idc = bs_read( &s, 4 ) & 0xf;
     if( ar.aspect_ratio_idc == 0xf )
     {
         ar.aspect_ratio_idc = 0xff; // was only coded on 4 bits in MPEG4



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8851a72b3b81582eb8107026f87c4e3f5190d127

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8851a72b3b81582eb8107026f87c4e3f5190d127
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