[vlc-commits] [Git][videolan/vlc][master] 19 commits: modules: assume sizeof(uint8_t) is 1

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Jul 13 06:56:01 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
a7614763 by Steve Lhomme at 2023-07-13T06:40:42+00:00
modules: assume sizeof(uint8_t) is 1

>From C11 7.20.1.1:
The typedef name uintN_t designates an unsigned integer type with width N and no padding bits.

- - - - -
d6e9e7a9 by Steve Lhomme at 2023-07-13T06:40:42+00:00
demux: mp4: use the size of the variable for memcpy

They will always match.

- - - - -
fe0cd5ed by Steve Lhomme at 2023-07-13T06:40:42+00:00
i420_rgb: assume sizeof(uint16_t) is 2

>From C11 7.20.1.1:
The typedef name uintN_t designates an unsigned integer type with width N and no padding bits.

- - - - -
8b2d42c4 by Steve Lhomme at 2023-07-13T06:40:42+00:00
modules: allocate with the table type size

So there can be no mismatch.

- - - - -
48f51105 by Steve Lhomme at 2023-07-13T06:40:42+00:00
asf: fix size check logic

We have to read 16 bytes (GUID), then 2 (number of streams) then at least
one entry (2 bytes).

In the end 2*2 = 2+2, but the multiplier is incorrect in this case.

We don't need to use sizeof(uint16_t) as we actually read with a number of
bytes (2).

- - - - -
a7c77cf4 by Steve Lhomme at 2023-07-13T06:40:42+00:00
asf: use the table size to check if the number of streams can fit

This is more logical. The #if check should also use that, but we can't use
sizeof() here.

- - - - -
68ca3574 by Steve Lhomme at 2023-07-13T06:40:42+00:00
asfpacket: check we have 2 bytes to read explicitly

We use 2 bytes, no uint16_t is involved. The code around already
use some hardcoded sizes.

- - - - -
083f8ce3 by Steve Lhomme at 2023-07-13T06:40:42+00:00
substx3g: use byte size for the 2 bytes read at the start

GetWBE() reads exactly 2 bytes. We don't need a sizeof for that.

- - - - -
de9cb1ae by Steve Lhomme at 2023-07-13T06:40:42+00:00
substx3g: simplify the mp4 box init

p_buf is effectively p_block->p_buffer + 2U + i_psz_bytelength, ie the
buffer after the subtitle text.

The use of i_psz_bytelength after that seems suspicious.

- - - - -
ac391f3d by Steve Lhomme at 2023-07-13T06:40:42+00:00
tospdif: assume sizeof(uint16_t) is 2

We write 16 bits anyway.

>From C11 7.20.1.1:
The typedef name uintN_t designates an unsigned integer type with width N and no padding bits.

- - - - -
12aeff83 by Steve Lhomme at 2023-07-13T06:40:42+00:00
dvdread: make i_title_blocks a uint32_t

It's initialized to 0 and incremented with uint32_t values. It can never
exceed 32-bit values.

- - - - -
4ce260e9 by Steve Lhomme at 2023-07-13T06:40:42+00:00
dvdread: use the size of the vobu_start_sectors to get the count

It's better than assuming it's a uint32_t. We don't need to know its type.

- - - - -
1645d54f by Steve Lhomme at 2023-07-13T06:40:42+00:00
textst: initialize the internal with its size

- - - - -
1963e4db by Steve Lhomme at 2023-07-13T06:40:42+00:00
tta: use the actual size of pi_seektable elements rather than uint32_t

We don't have to have the same storage as the source.

- - - - -
e746a6b7 by Steve Lhomme at 2023-07-13T06:40:42+00:00
asfpacket: check we have 4 bytes to read explicitly

We use 4 bytes, no uint32_t is involved. The code around already
use some hardcoded sizes.

- - - - -
48161409 by Steve Lhomme at 2023-07-13T06:40:42+00:00
video_filter: ball: allocate buffers using their size

We may want to change the size. This should be kept coherent.

- - - - -
6fee783d by Steve Lhomme at 2023-07-13T06:40:42+00:00
video_filter: gradient: allocate buffers using their size

We may want to change the size. This should be kept coherent.

- - - - -
1a520a5f by Steve Lhomme at 2023-07-13T06:40:42+00:00
i420_rgb: assume sizeof(uint32_t) is 4

>From C11 7.20.1.1:
The typedef name uintN_t designates an unsigned integer type with width N and no padding bits.

- - - - -
b69a256f by Steve Lhomme at 2023-07-13T06:40:42+00:00
hds: assume sizeof(uint32_t) is 4

We read 32 bits, we skip exactly 8 bytes. We don't need to know
the storage size where we put the value.

>From C11 7.20.1.1:
The typedef name uintN_t designates an unsigned integer type with width N and no padding bits.

- - - - -


23 changed files:

- modules/access/dvdread.c
- modules/access_output/livehttp.c
- modules/audio_filter/converter/tospdif.c
- modules/codec/libmpeg2.c
- modules/codec/substx3g.c
- modules/codec/textst.c
- modules/demux/asf/asf.c
- modules/demux/asf/asfpacket.c
- modules/demux/asf/libasf.c
- modules/demux/mp4/essetup.c
- modules/demux/mp4/heif.c
- modules/demux/mp4/libmp4.c
- modules/demux/tta.c
- modules/lua/extension.c
- modules/lua/libs/httpd.c
- modules/mux/ogg.c
- modules/stream_filter/hds/hds.c
- modules/video_chroma/i420_rgb.c
- modules/video_filter/ball.c
- modules/video_filter/bluescreen.c
- modules/video_filter/gradient.c
- modules/video_filter/oldmovie.c
- modules/video_filter/vhs.c


Changes:

=====================================
modules/access/dvdread.c
=====================================
@@ -123,7 +123,7 @@ typedef struct
     /* Current title start/end blocks */
     int i_title_start_block;
     int i_title_end_block;
-    int i_title_blocks;
+    uint32_t i_title_blocks;
     int i_title_offset;
 
     int i_title_start_cell;
@@ -153,7 +153,7 @@ static void DemuxTitles( demux_t *, int * );
 static void ESNew( demux_t *, int, int );
 
 static int  DvdReadSetArea  ( demux_t *, int, int, int );
-static int  DvdReadSeek     ( demux_t *, int );
+static int  DvdReadSeek     ( demux_t *, uint32_t );
 static void DvdReadHandleDSI( demux_t *, uint8_t * );
 static void DvdReadFindCell ( demux_t * );
 
@@ -362,7 +362,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         {
             pf = va_arg( args, double * );
 
-            if( p_sys->i_title_blocks > 0 )
+            if( p_sys->i_title_blocks )
                 *pf = (double)p_sys->i_title_offset / p_sys->i_title_blocks;
             else
                 *pf = 0.0;
@@ -829,13 +829,13 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter,
             const uint32_t cell_blocks = p_pgc->cell_playback[i].last_sector -
                                          p_pgc->cell_playback[i].first_sector + 1;
             if(unlikely( cell_blocks == 0 || cell_blocks > INT_MAX ||
-                 INT_MAX - p_sys->i_title_blocks < (int)cell_blocks ))
+                 INT_MAX - p_sys->i_title_blocks < cell_blocks ))
                 return VLC_EGENERIC;
             p_sys->i_title_blocks += cell_blocks;
         }
 
         msg_Dbg( p_demux, "title %d vts_title %d pgc %d pgn %d "
-                 "start %d end %d blocks: %d",
+                 "start %d end %d blocks: %u",
                  i_title + 1, p_sys->i_ttn, pgc_id, pgn,
                  p_sys->i_title_start_block, p_sys->i_title_end_block,
                  p_sys->i_title_blocks );
@@ -1090,12 +1090,12 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter,
  * This one is used by the input and translate chronological position from
  * input to logical position on the device.
  *****************************************************************************/
-static int DvdReadSeek( demux_t *p_demux, int i_block_offset )
+static int DvdReadSeek( demux_t *p_demux, uint32_t i_block_offset )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     int i_chapter = 0;
     int i_cell = 0;
-    int i_block;
+    uint32_t i_block;
     const pgc_t *p_pgc = p_sys->p_cur_pgc;
     const ifo_handle_t *p_vts = p_sys->p_vts_file;
 
@@ -1104,15 +1104,15 @@ static int DvdReadSeek( demux_t *p_demux, int i_block_offset )
     for( i_cell = p_sys->i_title_start_cell;
          i_cell <= p_sys->i_title_end_cell; i_cell++ )
     {
-        if( i_block < (int)p_pgc->cell_playback[i_cell].last_sector -
-            (int)p_pgc->cell_playback[i_cell].first_sector + 1 ) break;
+        if( i_block < p_pgc->cell_playback[i_cell].last_sector -
+            p_pgc->cell_playback[i_cell].first_sector + 1 ) break;
 
         i_block -= (p_pgc->cell_playback[i_cell].last_sector -
             p_pgc->cell_playback[i_cell].first_sector + 1);
     }
     if( i_cell > p_sys->i_title_end_cell )
     {
-        msg_Err( p_demux, "couldn't find cell for block %i", i_block_offset );
+        msg_Err( p_demux, "couldn't find cell for block %u", i_block_offset );
         return VLC_EGENERIC;
     }
     i_block += p_pgc->cell_playback[i_cell].first_sector;
@@ -1144,10 +1144,11 @@ static int DvdReadSeek( demux_t *p_demux, int i_block_offset )
     /* see ifo_read.c / ifoRead_VOBU_ADMAP_internal for index count */
     int i_vobu = 1;
     const size_t i_vobu_sect_index_count =
-            (p_vts->vts_vobu_admap->last_byte + 1 - VOBU_ADMAP_SIZE) / sizeof(uint32_t);
+            (p_vts->vts_vobu_admap->last_byte + 1 - VOBU_ADMAP_SIZE) /
+            sizeof(*p_vts->vts_vobu_admap->vobu_start_sectors);
     for( size_t i=0; i<i_vobu_sect_index_count; i++ )
     {
-        if( p_vts->vts_vobu_admap->vobu_start_sectors[i] > (uint32_t) i_block )
+        if( p_vts->vts_vobu_admap->vobu_start_sectors[i] > i_block )
             break;
         i_vobu = i + 1;
     }


=====================================
modules/access_output/livehttp.c
=====================================
@@ -371,7 +371,7 @@ static int CryptSetup( sout_access_out_t *p_access, char *key_file )
     }
 
     if( p_sys->b_generate_iv )
-        vlc_rand_bytes( p_sys->aes_ivs, sizeof(uint8_t)*16);
+        vlc_rand_bytes( p_sys->aes_ivs, 16);
 
     return VLC_SUCCESS;
 }
@@ -451,7 +451,7 @@ static int CryptKey( sout_access_out_t *p_access, uint32_t i_segment )
     if( !p_sys->b_generate_iv )
     {
         /* Use segment number as IV if randomIV isn't selected*/
-        memset( p_sys->aes_ivs, 0, 16 * sizeof(uint8_t));
+        memset( p_sys->aes_ivs, 0, 16);
         p_sys->aes_ivs[15] = i_segment & 0xff;
         p_sys->aes_ivs[14] = (i_segment >> 8 ) & 0xff;
         p_sys->aes_ivs[13] = (i_segment >> 16 ) & 0xff;
@@ -888,7 +888,7 @@ static ssize_t openNextFile( sout_access_out_t *p_access, sout_access_out_sys_t
         segment->psz_key_uri = strdup( p_sys->key_uri );
         CryptKey( p_access, i_newseg );
         if( p_sys->b_generate_iv )
-            memcpy( segment->aes_ivs, p_sys->aes_ivs, sizeof(uint8_t)*16 );
+            memcpy( segment->aes_ivs, p_sys->aes_ivs, 16 );
     }
     msg_Dbg( p_access, "Successfully opened livehttp file: %s (%"PRIu32")" , segment->psz_filename, i_newseg );
 


=====================================
modules/audio_filter/converter/tospdif.c
=====================================
@@ -115,10 +115,9 @@ static void write_16( filter_t *p_filter, uint16_t i_val )
     filter_sys_t *p_sys = p_filter->p_sys;
     assert( p_sys->p_out_buf != NULL );
 
-    assert( p_sys->p_out_buf->i_buffer - p_sys->i_out_offset
-            >= sizeof( uint16_t ) );
+    assert( p_sys->p_out_buf->i_buffer - p_sys->i_out_offset >= 2U );
     set_16( p_filter, &p_sys->p_out_buf->p_buffer[p_sys->i_out_offset], i_val );
-    p_sys->i_out_offset += sizeof( uint16_t );
+    p_sys->i_out_offset += 2U;
 }
 
 static void write_padding( filter_t *p_filter, size_t i_size )


=====================================
modules/codec/libmpeg2.c
=====================================
@@ -282,7 +282,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             if( p_sys->p_info->user_data_len > 2 )
             {
                 free( p_sys->p_gop_user_data );
-                p_sys->p_gop_user_data = calloc( p_sys->p_info->user_data_len, sizeof(uint8_t) );
+                p_sys->p_gop_user_data = calloc( p_sys->p_info->user_data_len, 1 );
                 if( p_sys->p_gop_user_data )
                 {
                     p_sys->i_gop_user_data = p_sys->p_info->user_data_len;


=====================================
modules/codec/substx3g.c
=====================================
@@ -302,23 +302,21 @@ static int Decode( decoder_t *p_dec, block_t *p_block )
         return VLCDEC_SUCCESS;
 
     if( ( p_block->i_flags & (BLOCK_FLAG_CORRUPTED) ) ||
-          p_block->i_buffer < sizeof(uint16_t) )
+          p_block->i_buffer < 2U )
     {
         block_Release( p_block );
         return VLCDEC_SUCCESS;
     }
 
-    uint8_t *p_buf = p_block->p_buffer;
-
     /* Read our raw string and create the styled segment for HTML */
-    uint16_t i_psz_bytelength = GetWBE( p_buf );
+    uint16_t i_psz_bytelength = GetWBE( p_block->p_buffer );
     if( p_block->i_buffer < i_psz_bytelength + 2U )
     {
         block_Release( p_block );
         return VLCDEC_SUCCESS;
     }
 
-    const uint8_t *p_pszstart = p_block->p_buffer + sizeof(uint16_t);
+    const uint8_t *p_pszstart = p_block->p_buffer + 2U;
     char *psz_subtitle;
     if ( i_psz_bytelength > 2 &&
          ( !memcmp( p_pszstart, "\xFE\xFF", 2 ) || !memcmp( p_pszstart, "\xFF\xFE", 2 ) )
@@ -334,7 +332,6 @@ static int Decode( decoder_t *p_dec, block_t *p_block )
         if ( !psz_subtitle )
             return VLCDEC_SUCCESS;
     }
-    p_buf += i_psz_bytelength + sizeof(uint16_t);
 
     for( uint16_t i=0; i < i_psz_bytelength; i++ )
      if ( psz_subtitle[i] == '\r' ) psz_subtitle[i] = '\n';
@@ -363,8 +360,8 @@ static int Decode( decoder_t *p_dec, block_t *p_block )
     const text_style_t *p_root_style = (text_style_t *) p_dec->p_sys;
 
     mp4_box_iterator_t it;
-    mp4_box_iterator_Init( &it, p_buf,
-                           p_block->i_buffer - (p_buf - p_block->p_buffer) );
+    mp4_box_iterator_Init( &it, p_block->p_buffer + 2U + i_psz_bytelength,
+                           p_block->i_buffer - (2U + i_psz_bytelength) );
     /* Parse our styles */
     if( p_dec->fmt_in->i_codec != VLC_CODEC_QTXT )
     while( mp4_box_iterator_Next( &it ) )


=====================================
modules/codec/textst.c
=====================================
@@ -267,7 +267,7 @@ static int Open(vlc_object_t *object)
     decoder_sys_t *p_sys = vlc_obj_malloc(object, sizeof(decoder_sys_t));
     if(!p_sys)
         return VLC_ENOMEM;
-    memset(p_sys->palette, 0xFF, 256 * sizeof(uint32_t));
+    memset(p_sys->palette, 0xFF, sizeof(p_sys->palette));
 
     p_dec->p_sys = p_sys;
     p_dec->pf_decode = Decode;


=====================================
modules/demux/asf/asf.c
=====================================
@@ -730,10 +730,10 @@ static void ASF_fillup_es_priorities_ex( demux_sys_t *p_sys, void *p_hdr,
     if (! p_mutex ) return;
 
 #if ( UINT_MAX > SIZE_MAX / 2 )
-    if ( p_sys->i_track > (size_t)SIZE_MAX / sizeof(uint16_t) )
+    if ( p_sys->i_track > (size_t)SIZE_MAX / sizeof(*p_prios->pi_stream_numbers) )
         return;
 #endif
-    p_prios->pi_stream_numbers = vlc_alloc( p_sys->i_track, sizeof(uint16_t) );
+    p_prios->pi_stream_numbers = vlc_alloc( p_sys->i_track, sizeof(*p_prios->pi_stream_numbers) );
     if ( !p_prios->pi_stream_numbers ) return;
 
     if ( p_mutex->i_stream_number_count )
@@ -757,10 +757,10 @@ static void ASF_fillup_es_bitrate_priorities_ex( demux_sys_t *p_sys, void *p_hdr
     if (! p_bitrate_mutex ) return;
 
 #if ( UINT_MAX > SIZE_MAX / 2 )
-    if ( p_sys->i_track > (size_t)SIZE_MAX / sizeof(uint16_t) )
+    if ( p_sys->i_track > (size_t)SIZE_MAX / sizeof(*p_prios->pi_stream_numbers) )
         return;
 #endif
-    p_prios->pi_stream_numbers = vlc_alloc( p_sys->i_track, sizeof( uint16_t ) );
+    p_prios->pi_stream_numbers = vlc_alloc( p_sys->i_track, sizeof(*p_prios->pi_stream_numbers) );
     if ( !p_prios->pi_stream_numbers ) return;
 
     if ( p_bitrate_mutex->i_stream_number_count )


=====================================
modules/demux/asf/asfpacket.c
=====================================
@@ -155,12 +155,12 @@ static void ParsePayloadExtensions( asf_packet_sys_t *p_packetsys,
 
         if ( guidcmp( &p_ext->i_extension_id, &mfasf_sampleextension_outputcleanpoint_guid ) )
         {
-            if ( i_payload_extensions_size != sizeof(uint8_t) ) goto sizeerror;
+            if ( i_payload_extensions_size != 1 ) goto sizeerror;
             *b_keyframe |= *p_data;
         }
         else if ( guidcmp( &p_ext->i_extension_id, &asf_dvr_sampleextension_videoframe_guid ) )
         {
-            if ( i_payload_extensions_size != sizeof(uint32_t) ) goto sizeerror;
+            if ( i_payload_extensions_size != 4U ) goto sizeerror;
 
             uint32_t i_val = GetDWLE( p_data );
             /* Valid keyframe must be a split frame start fragment */
@@ -175,7 +175,7 @@ static void ParsePayloadExtensions( asf_packet_sys_t *p_packetsys,
         else if ( guidcmp( &p_ext->i_extension_id, &mfasf_sampleextension_pixelaspectratio_guid ) &&
                   p_packetsys->pf_setaspectratio )
         {
-            if ( i_payload_extensions_size != sizeof(uint16_t) ) goto sizeerror;
+            if ( i_payload_extensions_size != 2U ) goto sizeerror;
 
             p_packetsys->pf_setaspectratio( p_packetsys, p_tkinfo->p_sp->i_stream_number,
                                             p_data[0], p_data[1] );


=====================================
modules/demux/asf/libasf.c
=====================================
@@ -957,9 +957,9 @@ static int ASF_ReadObject_extended_stream_properties( stream_t *s,
     p_data += 64;
 
     p_esp->pi_stream_name_language = calloc( p_esp->i_stream_name_count,
-                                             sizeof(uint16_t) );
+                                             sizeof(*p_esp->pi_stream_name_language) );
     p_esp->ppsz_stream_name = calloc( p_esp->i_stream_name_count,
-                                      sizeof(char*) );
+                                      sizeof(*p_esp->ppsz_stream_name) );
     if( !p_esp->pi_stream_name_language ||
         !p_esp->ppsz_stream_name )
     {
@@ -1071,7 +1071,7 @@ static int ASF_ReadObject_advanced_mutual_exclusion( stream_t *s,
 
     p_data = &p_peek[ASF_OBJECT_COMMON_SIZE];
 
-    if( !ASF_HAVE( 16 + 2 * sizeof(uint16_t) ) ) /* at least one entry */
+    if( !ASF_HAVE( 16 + 2 + 2 ) ) /* at least one entry */
         return VLC_EGENERIC;
 
     if ( guidcmp( (const vlc_guid_t *) p_data, &asf_guid_mutex_language ) )
@@ -1081,7 +1081,7 @@ static int ASF_ReadObject_advanced_mutual_exclusion( stream_t *s,
     ASF_SKIP( 16 );
 
     p_ae->i_stream_number_count = ASF_READ2();
-    p_ae->pi_stream_number = calloc( p_ae->i_stream_number_count, sizeof(uint16_t) );
+    p_ae->pi_stream_number = calloc( p_ae->i_stream_number_count, sizeof(*p_ae->pi_stream_number) );
     if ( !p_ae->pi_stream_number )
     {
         p_ae->i_stream_number_count = 0;
@@ -1134,9 +1134,10 @@ static int ASF_ReadObject_stream_prioritization( stream_t *s,
 
     p_sp->i_priority_count = ASF_READ2();
 
-    p_sp->pi_priority_flag = calloc( p_sp->i_priority_count, sizeof(uint16_t) );
-    p_sp->pi_priority_stream_number =
-                             calloc( p_sp->i_priority_count, sizeof(uint16_t) );
+    p_sp->pi_priority_flag = calloc( p_sp->i_priority_count,
+                                     sizeof(*p_sp->pi_priority_flag) );
+    p_sp->pi_priority_stream_number = calloc( p_sp->i_priority_count,
+                                              sizeof(*p_sp->pi_priority_stream_number) );
 
     if( !p_sp->pi_priority_flag || !p_sp->pi_priority_stream_number )
     {
@@ -1185,7 +1186,7 @@ static int ASF_ReadObject_bitrate_mutual_exclusion( stream_t *s, asf_object_t *p
 
     p_data = &p_peek[ASF_OBJECT_COMMON_SIZE];
 
-    if( !ASF_HAVE( 16 + 2 * sizeof(uint16_t) ) ) /* at least one entry */
+    if( !ASF_HAVE( 16 + 2 + 2 ) ) /* at least one entry */
         return VLC_EGENERIC;
 
     if ( guidcmp( (const vlc_guid_t *) p_data, &asf_guid_mutex_language ) )
@@ -1195,7 +1196,7 @@ static int ASF_ReadObject_bitrate_mutual_exclusion( stream_t *s, asf_object_t *p
     ASF_SKIP( 16 );
 
     p_ex->i_stream_number_count = ASF_READ2();
-    p_ex->pi_stream_numbers = calloc( p_ex->i_stream_number_count, sizeof(uint16_t) );
+    p_ex->pi_stream_numbers = calloc( p_ex->i_stream_number_count, sizeof(*p_ex->pi_stream_numbers) );
     if ( ! p_ex->pi_stream_numbers )
     {
         p_ex->i_stream_number_count = 0;


=====================================
modules/demux/mp4/essetup.c
=====================================
@@ -735,9 +735,9 @@ int SetupVideoES( demux_t *p_demux, const mp4_track_t *p_track, const MP4_Box_t
                 if( p_SmDm && BOXDATA(p_SmDm) )
                 {
                     memcpy( p_fmt->video.mastering.primaries,
-                            BOXDATA(p_SmDm)->primaries, sizeof(uint16_t) * 6 );
+                            BOXDATA(p_SmDm)->primaries, sizeof(p_fmt->video.mastering.primaries) );
                     memcpy( p_fmt->video.mastering.white_point,
-                            BOXDATA(p_SmDm)->white_point, sizeof(uint16_t) * 2 );
+                            BOXDATA(p_SmDm)->white_point, sizeof(p_fmt->video.mastering.white_point) );
                     p_fmt->video.mastering.max_luminance = BOXDATA(p_SmDm)->i_luminanceMax;
                     p_fmt->video.mastering.min_luminance = BOXDATA(p_SmDm)->i_luminanceMin;
                 }


=====================================
modules/demux/mp4/heif.c
=====================================
@@ -432,9 +432,9 @@ static int SetPictureProperties( demux_t *p_demux, uint32_t i_item_id,
                     break;
                 case ATOM_mdcv:
                     memcpy( fmt->video.mastering.primaries,
-                            p_prop->data.p_SmDm->primaries, sizeof(uint16_t) * 6 );
+                            p_prop->data.p_SmDm->primaries, sizeof(fmt->video.mastering.primaries) );
                     memcpy( fmt->video.mastering.white_point,
-                            p_prop->data.p_SmDm->white_point, sizeof(uint16_t) * 2 );
+                            p_prop->data.p_SmDm->white_point, sizeof(fmt->video.mastering.white_point) );
                     fmt->video.mastering.max_luminance = p_prop->data.p_SmDm->i_luminanceMax;
                     fmt->video.mastering.min_luminance = p_prop->data.p_SmDm->i_luminanceMin;
                     break;


=====================================
modules/demux/mp4/libmp4.c
=====================================
@@ -3279,7 +3279,7 @@ static int MP4_ReadBox_stdp( stream_t *p_stream, MP4_Box_t *p_box )
     MP4_GETVERSIONFLAGS( p_box->data.p_stdp );
 
     p_box->data.p_stdp->i_priority =
-        calloc( i_read / 2, sizeof(uint16_t) );
+        calloc( i_read / 2, sizeof(*p_box->data.p_stdp->i_priority) );
 
     if( unlikely( !p_box->data.p_stdp->i_priority ) )
         MP4_READBOX_EXIT( 0 );


=====================================
modules/demux/tta.c
=====================================
@@ -133,10 +133,10 @@ static int Open( vlc_object_t * p_this )
     p_sys->i_totalframes = p_sys->i_datalength / p_sys->i_framelength +
                           ((p_sys->i_datalength % p_sys->i_framelength) != 0);
     p_sys->i_currentframe = 0;
-    if( (INT_MAX - 22 - 4) / sizeof(uint32_t) < p_sys->i_totalframes )
+    if( (INT_MAX - 22 - 4) / sizeof(*p_sys->pi_seektable) < p_sys->i_totalframes )
         goto error;
 
-    i_seektable_size = sizeof(uint32_t)*p_sys->i_totalframes;
+    i_seektable_size = sizeof(*p_sys->pi_seektable)*p_sys->i_totalframes;
 
     /* Store the header and Seektable for avcodec */
     fmt.i_extra = 22 + i_seektable_size + 4;
@@ -153,7 +153,7 @@ static int Open( vlc_object_t * p_this )
              != i_seektable_size )
         goto error;
 
-    p_sys->pi_seektable = calloc( p_sys->i_totalframes, sizeof(uint32_t) );
+    p_sys->pi_seektable = calloc( p_sys->i_totalframes, sizeof(*p_sys->pi_seektable) );
     if( !p_sys->pi_seektable )
         goto error;
     for( uint32_t i = 0; i < p_sys->i_totalframes; i++ )


=====================================
modules/lua/extension.c
=====================================
@@ -678,8 +678,8 @@ static int GetMenuEntries( extensions_manager_t *p_mgr, extension_t *p_ext,
 
     /* Get table size */
     size_t i_size = lua_objlen( L, -1 );
-    *pppsz_titles = calloc(i_size+1, sizeof(char*));
-    *ppi_ids = calloc(i_size+1, sizeof(uint16_t));
+    *pppsz_titles = calloc(i_size+1, sizeof(**pppsz_titles));
+    *ppi_ids = calloc(i_size+1, sizeof(**ppi_ids));
 
     /* Walk table */
     size_t i_idx = 0;


=====================================
modules/lua/libs/httpd.c
=====================================
@@ -384,7 +384,7 @@ static uint8_t *vlclua_todata( lua_State *L, int narg, int *pi_data )
 {
     size_t i_data;
     const char *psz_data = lua_tolstring( L, narg, &i_data );
-    uint8_t *p_data = vlc_alloc( i_data, sizeof(uint8_t) );
+    uint8_t *p_data = malloc( i_data );
     *pi_data = (int)i_data;
     if( !p_data )
     {


=====================================
modules/mux/ogg.c
=====================================
@@ -712,7 +712,7 @@ static block_t *OggStreamPageOut( sout_mux_t *p_mux,
 
 static void OggGetSkeletonIndex( uint8_t **pp_buffer, long *pi_size, ogg_stream_t *p_stream )
 {
-    uint8_t *p_buffer = calloc( INDEX_BASE_SIZE + p_stream->skeleton.i_index_size, sizeof(uint8_t) );
+    uint8_t *p_buffer = calloc( INDEX_BASE_SIZE + p_stream->skeleton.i_index_size, 1 );
     if ( !p_buffer ) return;
     *pp_buffer = p_buffer;
 
@@ -814,7 +814,7 @@ static void OggGetSkeletonFisbone( uint8_t **pp_buffer, long *pi_size,
         }
     }
 
-    *pp_buffer = calloc( FISBONE_BASE_SIZE + headers.i_size, sizeof(uint8_t) );
+    *pp_buffer = calloc( FISBONE_BASE_SIZE + headers.i_size, 1 );
     if ( !*pp_buffer ) return;
     p_buffer = *pp_buffer;
 
@@ -1475,7 +1475,7 @@ static bool AllocateIndex( sout_mux_t *p_mux, sout_input_t *p_input )
     }
     i_size *= ( 8.0 / 7 ); /* 7bits encoding overhead */
     msg_Dbg( p_mux, "allocating %zu bytes for index", i_size );
-    p_stream->skeleton.p_index = calloc( i_size, sizeof(uint8_t) );
+    p_stream->skeleton.p_index = calloc( i_size, 1 );
     if ( !p_stream->skeleton.p_index ) return false;
     p_stream->skeleton.i_index_size = i_size;
     p_stream->skeleton.i_index_payload = 0;


=====================================
modules/stream_filter/hds/hds.c
=====================================
@@ -446,7 +446,7 @@ static uint8_t* parse_afrt( vlc_object_t* p_this,
     }
 
     uint32_t fragment_run_entry_count = U32_AT( data_p );
-    data_p += sizeof(uint32_t);
+    data_p += 4;
 
     while(fragment_run_entry_count-- > 0)
     {


=====================================
modules/video_chroma/i420_rgb.c
=====================================
@@ -236,14 +236,14 @@ static int Activate( filter_t *p_filter )
     switch( p_filter->fmt_out.video.i_chroma )
     {
     case VLC_CODEC_RGB8:
-        i_tables_size = sizeof( uint8_t ) * PALETTE_TABLE_SIZE;
+        i_tables_size = PALETTE_TABLE_SIZE;
         break;
     case VLC_CODEC_RGB15:
     case VLC_CODEC_RGB16:
-        i_tables_size = sizeof( uint16_t ) * RGB_TABLE_SIZE;
+        i_tables_size = 2 * RGB_TABLE_SIZE;
         break;
     default: /* RV24, RV32 */
-        i_tables_size = sizeof( uint32_t ) * RGB_TABLE_SIZE;
+        i_tables_size = 4 * RGB_TABLE_SIZE;
         break;
     }
 


=====================================
modules/video_filter/ball.c
=====================================
@@ -559,20 +559,17 @@ static void FilterBall( filter_t *p_filter, picture_t *p_inpic,
 
     if( !p_sys->p_smooth )
         p_sys->p_smooth =
-                (uint32_t *)vlc_alloc( i_numLines * i_numCols,
-                                       sizeof(uint32_t));
+                vlc_alloc( i_numLines * i_numCols, sizeof(*p_sys->p_smooth));
     p_smooth = p_sys->p_smooth;
 
     if( !p_sys->p_grad_x )
         p_sys->p_grad_x =
-                (int32_t *)vlc_alloc( i_numLines * i_numCols,
-                                      sizeof(int32_t));
+                vlc_alloc( i_numLines * i_numCols, sizeof(*p_sys->p_grad_x));
     p_grad_x = p_sys->p_grad_x;
 
     if( !p_sys->p_grad_y )
         p_sys->p_grad_y =
-                (int32_t *)vlc_alloc( i_numLines * i_numCols,
-                                      sizeof(int32_t));
+                vlc_alloc( i_numLines * i_numCols, sizeof(*p_sys->p_grad_y));
     p_grad_y = p_sys->p_grad_y;
 
     if( !p_smooth || !p_grad_x || !p_grad_y ) return;


=====================================
modules/video_filter/bluescreen.c
=====================================
@@ -183,8 +183,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
         return NULL;
     }
 
-    p_sys->p_at = xrealloc( p_sys->p_at,
-                            i_lines * i_pitch * sizeof( uint8_t ) );
+    p_sys->p_at = xrealloc( p_sys->p_at, i_lines * i_pitch );
     p_at = p_sys->p_at;
 
     vlc_mutex_lock( &p_sys->lock );


=====================================
modules/video_filter/gradient.c
=====================================
@@ -337,7 +337,7 @@ static void FilterGradient( filter_t *p_filter, picture_t *p_inpic,
     uint32_t *p_smooth;
     if( !p_sys->p_buf32 )
         p_sys->p_buf32 =
-            vlc_alloc( i_num_lines * i_src_visible, sizeof(uint32_t));
+            vlc_alloc( i_num_lines * i_src_visible, sizeof(*p_sys->p_buf32));
     p_smooth = p_sys->p_buf32;
 
     if( !p_smooth ) return;
@@ -461,17 +461,16 @@ static void FilterEdge( filter_t *p_filter, picture_t *p_inpic,
 
     if( !p_sys->p_buf32 )
         p_sys->p_buf32 =
-            vlc_alloc( i_num_lines * i_src_visible, sizeof(uint32_t));
+            vlc_alloc( i_num_lines * i_src_visible, sizeof(*p_sys->p_buf32));
     p_smooth = p_sys->p_buf32;
 
     if( !p_sys->p_buf32_bis )
         p_sys->p_buf32_bis =
-            vlc_alloc( i_num_lines * i_src_visible, sizeof(uint32_t));
+            vlc_alloc( i_num_lines * i_src_visible, sizeof(*p_sys->p_buf32_bis));
     p_grad = p_sys->p_buf32_bis;
 
     if( !p_sys->p_buf8 )
-        p_sys->p_buf8 =
-            vlc_alloc( i_num_lines * i_src_visible, sizeof(uint8_t));
+        p_sys->p_buf8 = vlc_alloc( i_num_lines * i_src_visible, 1);
     p_theta = p_sys->p_buf8;
 
     if( !p_smooth || !p_grad || !p_theta ) return;
@@ -625,7 +624,7 @@ static void FilterHough( filter_t *p_filter, picture_t *p_inpic,
     int *p_hough = vlc_alloc( i_diag * i_nb_steps, sizeof(int) );
     if( ! p_hough ) return;
 
-    p_smooth = vlc_alloc( i_num_lines * i_src_visible, sizeof(uint32_t));
+    p_smooth = vlc_alloc( i_num_lines * i_src_visible, sizeof(*p_smooth));
     if( !p_smooth )
     {
         free( p_hough );


=====================================
modules/video_filter/oldmovie.c
=====================================
@@ -482,7 +482,7 @@ static int oldmovie_sliding_offset_apply( filter_t *p_filter, picture_t *p_pic_o
     for ( size_t i_p = 0; i_p < i_planes; i_p++ ) {
         /* first allocate temporary buffer for swap operation */
         uint8_t *p_temp_buf = calloc( p_pic_out->p[i_p].i_lines * p_pic_out->p[i_p].i_pitch,
-                                      sizeof(uint8_t) );
+                                      1 );
         if ( unlikely( !p_temp_buf ) )
             return VLC_ENOMEM;
         memcpy( p_temp_buf,p_pic_out->p[i_p].p_pixels,


=====================================
modules/video_filter/vhs.c
=====================================
@@ -488,7 +488,7 @@ static int vhs_sliding_effect_apply( filter_t *p_filter, picture_t *p_pic_out )
         uint8_t *p_temp_buf;
         if ( !p_sys->i_sliding_type_duplicate ) {
             p_temp_buf= calloc( p_pic_out->p[i_p].i_lines
-                                * p_pic_out->p[i_p].i_pitch, sizeof(uint8_t) );
+                                * p_pic_out->p[i_p].i_pitch, 1 );
             if ( unlikely( !p_temp_buf ) )
                 return VLC_ENOMEM;
             memcpy( p_temp_buf, p_pic_out->p[i_p].p_pixels,



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/722a680e37305576a5e771c885f505015f235c7d...b69a256fb9e2019388df75e645e2973ae3d3b3f4

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