[vlc-commits] [Git][videolan/vlc][master] 7 commits: codec: x264: use ARRAY_SIZE

Tristan Matthews (@tmatth) gitlab at videolan.org
Wed Nov 19 17:42:28 UTC 2025



Tristan Matthews pushed to branch master at VideoLAN / VLC


Commits:
efebed82 by Tristan Matthews at 2025-11-19T17:27:23+00:00
codec: x264: use ARRAY_SIZE

- - - - -
bdb5e1ec by Tristan Matthews at 2025-11-19T17:27:23+00:00
demux: ogg: use ARRAY_SIZE

- - - - -
2c5a9619 by Tristan Matthews at 2025-11-19T17:27:23+00:00
demux: wav: use ARRAY_SIZE

- - - - -
dd60254b by Tristan Matthews at 2025-11-19T17:27:23+00:00
avcodec: encoder: use ARRAY_SIZE

- - - - -
2c871a9f by Tristan Matthews at 2025-11-19T17:27:23+00:00
codec: mpg123: use ARRAY_SIZE

- - - - -
46d6b0ca by Tristan Matthews at 2025-11-19T17:27:23+00:00
codec: uleaddvaudio: use ARRAY_SIZE

- - - - -
aac4b531 by Tristan Matthews at 2025-11-19T17:27:23+00:00
demux: playlist: dvb: use ARRAY_SIZE

- - - - -


7 changed files:

- modules/codec/avcodec/encoder.c
- modules/codec/mpg123.c
- modules/codec/uleaddvaudio.c
- modules/codec/x264.c
- modules/demux/ogg.c
- modules/demux/playlist/dvb.c
- modules/demux/wav.c


Changes:

=====================================
modules/codec/avcodec/encoder.c
=====================================
@@ -814,7 +814,7 @@ int InitVideoEnc( vlc_object_t *p_this )
         p_context->channel_layout = channel_mask[p_context->channels][1];
         uint64_t channel_mask = p_context->channel_layout;
 #endif
-        for( unsigned i = 0; i < sizeof(pi_channels_map)/sizeof(*pi_channels_map); i++ )
+        for( unsigned i = 0; i < ARRAY_SIZE(pi_channels_map); i++ )
         {
             if( channel_mask & pi_channels_map[i][0] )
             {
@@ -949,7 +949,7 @@ errmsg:
                 char txt[4];
             } fcc = { .value = p_enc->fmt_out.i_codec };
 
-            if (likely((unsigned)p_enc->fmt_in.i_cat < sizeof (types) / sizeof (types[0])))
+            if (likely((unsigned)p_enc->fmt_in.i_cat < ARRAY_SIZE(types)))
                 type = types[p_enc->fmt_in.i_cat];
             msg_Err( p_enc, "cannot open %4.4s %s encoder", fcc.txt, type );
             vlc_dialog_display_error( p_enc, _("Streaming / Transcoding failed"),


=====================================
modules/codec/mpg123.c
=====================================
@@ -111,9 +111,7 @@ static int MPG123Open( decoder_t *p_dec )
         static const long mp3_rates[] = {
             8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000,
         };
-        for( size_t i = 0;
-            i < sizeof(mp3_rates) / sizeof(*mp3_rates) && i_ret == MPG123_OK;
-            ++i )
+        for( size_t i = 0; i < ARRAY_SIZE(mp3_rates) && i_ret == MPG123_OK; ++i )
         {
             i_ret =  mpg123_format( p_sys->p_handle, mp3_rates[i],
                                     MPG123_MONO | MPG123_STEREO,


=====================================
modules/codec/uleaddvaudio.c
=====================================
@@ -153,7 +153,7 @@ static int Open(vlc_object_t *object)
 
     date_Init(&sys->end_date, dec->fmt_in->audio.i_rate, 1);
 
-    for (unsigned i = 0; i < sizeof(sys->shuffle) / sizeof(*sys->shuffle); i++) {
+    for (unsigned i = 0; i < ARRAY_SIZE(sys->shuffle); i++) {
         const unsigned a = sys->is_pal ? 18 : 15;
         const unsigned b = 3 * a;
         sys->shuffle[i] = 80 * ((21 * (i % 3) + 9 * (i / 3) + ((i / a) % 3)) % b) +


=====================================
modules/codec/x264.c
=====================================
@@ -507,7 +507,7 @@ vlc_module_begin ()
     add_string( SOUT_CFG_PREFIX "profile", "high", PROFILE_TEXT,
                PROFILE_LONGTEXT )
         vlc_config_set (VLC_CONFIG_LIST,
-            (sizeof(x264_profile_names) / sizeof (char*)) - 1,
+            ARRAY_SIZE(x264_profile_names) - 1,
             x264_profile_names, x264_profile_names);
 
 
@@ -523,7 +523,7 @@ vlc_module_begin ()
 
     add_string( SOUT_CFG_PREFIX "hrd", "none", HRD_TEXT, HRD_TEXT )
         vlc_config_set (VLC_CONFIG_LIST,
-            (sizeof(x264_nal_hrd_names) / sizeof (char*)) - 1,
+            ARRAY_SIZE(x264_nal_hrd_names) - 1,
             x264_nal_hrd_names, x264_nal_hrd_names);
 
 
@@ -705,11 +705,11 @@ vlc_module_begin ()
 
     add_string( SOUT_CFG_PREFIX "preset", NULL , PRESET_TEXT , NULL )
         vlc_config_set (VLC_CONFIG_LIST,
-            (sizeof(x264_preset_names) / sizeof (char*)) - 1,
+            ARRAY_SIZE(x264_preset_names) - 1,
             x264_preset_names, x264_preset_names);
     add_string( SOUT_CFG_PREFIX "tune", NULL , TUNE_TEXT, NULL )
         vlc_config_set (VLC_CONFIG_LIST,
-            (sizeof(x264_tune_names) / sizeof (char*)) - 1,
+            ARRAY_SIZE(x264_tune_names) - 1,
             x264_tune_names, x264_tune_names);
 
     add_string( SOUT_CFG_PREFIX "options", NULL, X264_OPTIONS_TEXT,


=====================================
modules/demux/ogg.c
=====================================
@@ -214,7 +214,7 @@ static void fill_channels_info(audio_format_t *audio)
     };
 
     unsigned chans = audio->i_channels;
-    if (chans < sizeof(pi_channels_map) / sizeof(pi_channels_map[0]))
+    if (chans < ARRAY_SIZE(pi_channels_map))
         audio->i_physical_channels = pi_channels_map[chans];
 }
 
@@ -3488,12 +3488,12 @@ static bool Ogg_ReadDiracHeader( logical_stream_t *p_stream,
         {24000,1001}, {24,1}, {25,1}, {30000,1001}, {30,1},
         {50,1}, {60000,1001}, {60,1}, {15000,1001}, {25,2},
     };
-    static const size_t u_dirac_frate_tbl = sizeof(p_dirac_frate_tbl)/sizeof(*p_dirac_frate_tbl);
+    static const size_t u_dirac_frate_tbl = ARRAY_SIZE(p_dirac_frate_tbl);
 
     static const uint32_t pu_dirac_vidfmt_frate[] = { /* table C.1 */
         1, 9, 10, 9, 10, 9, 10, 4, 3, 7, 6, 4, 3, 7, 6, 2, 2, 7, 6, 7, 6,
     };
-    static const size_t u_dirac_vidfmt_frate = sizeof(pu_dirac_vidfmt_frate)/sizeof(*pu_dirac_vidfmt_frate);
+    static const size_t u_dirac_vidfmt_frate = ARRAY_SIZE(pu_dirac_vidfmt_frate);
 
     bs_t bs;
 


=====================================
modules/demux/playlist/dvb.c
=====================================
@@ -116,7 +116,7 @@ static const char *ParseFEC(const char *str)
          return NULL;
      str += 4;
 
-     const struct fec *f = bsearch(str, tab, sizeof (tab) / sizeof(tab[0]),
+     const struct fec *f = bsearch(str, tab, ARRAY_SIZE(tab),
                                    sizeof (tab[0]), cmp);
      return (f != NULL) ? f->vlc : NULL;
 }
@@ -139,7 +139,7 @@ static const char *ParseModulation(const char *str)
      if( str == NULL )
          return NULL;
 
-     const struct mod *m = bsearch(str, tab, sizeof (tab) / sizeof(tab[0]),
+     const struct mod *m = bsearch(str, tab, ARRAY_SIZE(tab),
                                    sizeof (tab[0]), cmp);
      return (m != NULL) ? m->vlc : NULL;
 }
@@ -160,7 +160,7 @@ static const char *ParseGuard(const char *str)
          return NULL;
      str += 15;
 
-     const struct guard *g = bsearch(str, tab, sizeof (tab) / sizeof(tab[0]),
+     const struct guard *g = bsearch(str, tab, ARRAY_SIZE(tab),
                                      sizeof (tab[0]), cmp);
      return (g != NULL) ? g->vlc : NULL;
 }


=====================================
modules/demux/wav.c
=====================================
@@ -440,7 +440,7 @@ static int ChunkParseFmt( demux_t *p_demux, uint32_t i_size )
                                                       AOUT_CHAN_CENTER }; */
 
                 /* Try to complete with pair */
-                for( unsigned i = 0; i < sizeof(pi_pair)/sizeof(*pi_pair); i++ )
+                for( unsigned i = 0; i < ARRAY_SIZE(pi_pair); i++ )
                 {
                     if( i_missing >= 2 && !(p_sys->i_channel_mask & pi_pair[i] ) )
                     {
@@ -449,7 +449,7 @@ static int ChunkParseFmt( demux_t *p_demux, uint32_t i_size )
                     }
                 }
                 /* Well fill up with what we can */
-                for( unsigned i = 0; i < sizeof(pi_channels_aout)/sizeof(*pi_channels_aout) && i_missing > 0; i++ )
+                for( unsigned i = 0; i < ARRAY_SIZE(pi_channels_aout) && i_missing > 0; i++ )
                 {
                     if( !( p_sys->i_channel_mask & pi_channels_aout[i] ) )
                     {
@@ -486,7 +486,7 @@ static int ChunkParseFmt( demux_t *p_demux, uint32_t i_size )
             AOUT_CHAN_MIDDLELEFT, AOUT_CHAN_MIDDLERIGHT, AOUT_CHAN_REARCENTER };
 
         for( unsigned i = 0; i < p_sys->fmt.audio.i_channels &&
-             i < (sizeof(pi_default_channels) / sizeof(*pi_default_channels));
+             i < ARRAY_SIZE(pi_default_channels);
              i++ )
             p_sys->i_channel_mask |= pi_default_channels[i];
     }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/afd640e96ff2d0b8d8472d351d8adc7852828f0b...aac4b531297c809d63ecb6e685159f8ed583bc44

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/afd640e96ff2d0b8d8472d351d8adc7852828f0b...aac4b531297c809d63ecb6e685159f8ed583bc44
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