[vlc-devel] [PATCH] Rename popcount to vlc_popcount
Kamil Rytarowski
n54 at gmx.com
Mon Feb 26 09:19:23 CET 2018
Renaming parity, ctz and clz is not required for NetBSD.
If you think it's appropriate to keep this style, it's fine with me.
On 26.02.2018 09:11, Thomas Guillem wrote:
> Fine with me. Should the same be done for every builtin functions (parity,ctz,clz) ?
>
> On Mon, Feb 26, 2018, at 07:11, Kamil Rytarowski wrote:
>> This removes conflicts with the NetBSD headers and libc.
>> The conflicts caused fatal build errors.
>>
>> No functional change intended for other Operating Systems.
>> ---
>> include/vlc_aout.h | 2 +-
>> include/vlc_common.h | 36 +++++++++++++++---------------
>> modules/access/wasapi.c | 2 +-
>> modules/audio_filter/channel_mixer/remap.c | 2 +-
>> modules/audio_output/alsa.c | 6 ++---
>> modules/audio_output/directsound.c | 2 +-
>> modules/codec/faad.c | 4 ++--
>> modules/codec/flac.c | 4 ++--
>> modules/mux/mpeg/tables.c | 2 +-
>> modules/packetizer/a52.h | 4 ++--
>> modules/packetizer/dts.c | 2 +-
>> modules/packetizer/hxxx_nal.h | 2 +-
>> modules/video_output/xcb/xvideo.c | 2 +-
>> 13 files changed, 35 insertions(+), 35 deletions(-)
>>
>> diff --git a/include/vlc_aout.h b/include/vlc_aout.h
>> index 967b68ca10..9a888d54a2 100644
>> --- a/include/vlc_aout.h
>> +++ b/include/vlc_aout.h
>> @@ -281,7 +281,7 @@ VLC_API void aout_ChannelExtract( void *p_dst, int
>> i_dst_channels, const void *p
>> /* */
>> static inline unsigned aout_FormatNbChannels(const
>> audio_sample_format_t *fmt)
>> {
>> - return popcount(fmt->i_physical_channels);
>> + return vlc_popcount(fmt->i_physical_channels);
>> }
>>
>> VLC_API unsigned int aout_BitsPerSample( vlc_fourcc_t i_format ) VLC_USED;
>> diff --git a/include/vlc_common.h b/include/vlc_common.h
>> index 87196d295b..e641b4519f 100644
>> --- a/include/vlc_common.h
>> +++ b/include/vlc_common.h
>> @@ -605,7 +605,7 @@ static inline uint8_t clip_uint8_vlc( int32_t a )
>> unsigned long: __builtin_ctzl(x), \
>> unsigned long long: __builtin_ctzll(x))
>>
>> -# define popcount(x) \
>> +# define vlc_popcount(x) \
>> _Generic((x), \
>> unsigned char: __builtin_popcount(x), \
>> signed char: __builtin_popcount((unsigned char)(x)), \
>> @@ -647,27 +647,27 @@ VLC_USED static inline int ctz(unsigned long long x)
>> return __builtin_ctzll(x);
>> }
>>
>> -VLC_USED static inline int popcount(unsigned char x)
>> +VLC_USED static inline int vlc_popcount(unsigned char x)
>> {
>> return __builtin_popcount(x);
>> }
>>
>> -VLC_USED static inline int popcount(unsigned short x)
>> +VLC_USED static inline int vlc_popcount(unsigned short x)
>> {
>> return __builtin_popcount(x);
>> }
>>
>> -VLC_USED static inline int popcount(unsigned x)
>> +VLC_USED static inline int vlc_popcount(unsigned x)
>> {
>> return __builtin_popcount(x);
>> }
>>
>> -VLC_USED static inline int popcount(unsigned long x)
>> +VLC_USED static inline int vlc_popcount(unsigned long x)
>> {
>> return __builtin_popcountl(x);
>> }
>>
>> -VLC_USED static inline int popcount(unsigned long long x)
>> +VLC_USED static inline int vlc_popcount(unsigned long long x)
>> {
>> return __builtin_popcountll(x);
>> }
>> @@ -745,7 +745,7 @@ VLC_USED static inline int ctz(unsigned long long x)
>> return i;
>> }
>>
>> -VLC_USED static inline int popcount(unsigned long long x)
>> +VLC_USED static inline int vlc_popcount(unsigned long long x)
>> {
>> int count = 0;
>> while (x)
>> @@ -764,18 +764,18 @@ VLC_USED static inline int popcount(unsigned long long x)
>> *
>> * \return The count of non-zero bits.
>> */
>> -# define popcount(x) \
>> +# define vlc_popcount(x) \
>> _Generic((x), \
>> - unsigned char: popcount(x), \
>> - signed char: popcount((unsigned char)(x)), \
>> - unsigned short: popcount(x), \
>> - signed short: popcount((unsigned short)(x)), \
>> - unsigned int: popcount(x), \
>> - signed int: popcount((unsigned int)(x)), \
>> - unsigned long: popcount(x), \
>> - signed long: popcount((unsigned long)(x)), \
>> - unsigned long long: popcount(x), \
>> - signed long long: popcount(x))
>> + unsigned char: vlc_popcount(x), \
>> + signed char: vlc_popcount((unsigned char)(x)), \
>> + unsigned short: vlc_popcount(x), \
>> + signed short: vlc_popcount((unsigned short)(x)), \
>> + unsigned int: vlc_popcount(x), \
>> + signed int: vlc_popcount((unsigned int)(x)), \
>> + unsigned long: vlc_popcount(x), \
>> + signed long: vlc_popcount((unsigned long)(x)), \
>> + unsigned long long: vlc_popcount(x), \
>> + signed long long: vlc_popcount(x))
>> # endif
>>
>> /**
>> diff --git a/modules/access/wasapi.c b/modules/access/wasapi.c
>> index fe162c7909..bc320d9943 100644
>> --- a/modules/access/wasapi.c
>> +++ b/modules/access/wasapi.c
>> @@ -143,7 +143,7 @@ static int vlc_FromWave(const WAVEFORMATEX *restrict wf,
>> if (wfe->dwChannelMask & SPEAKER_LOW_FREQUENCY)
>> fmt->i_physical_channels |= AOUT_CHAN_LFE;
>>
>> - assert(popcount(wfe->dwChannelMask) == wf->nChannels);
>> + assert(vlc_popcount(wfe->dwChannelMask) == wf->nChannels);
>>
>> if (IsEqualIID(&wfe->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM))
>> {
>> diff --git a/modules/audio_filter/channel_mixer/remap.c b/modules/
>> audio_filter/channel_mixer/remap.c
>> index 98ec3463a1..aee515e625 100644
>> --- a/modules/audio_filter/channel_mixer/remap.c
>> +++ b/modules/audio_filter/channel_mixer/remap.c
>> @@ -321,7 +321,7 @@ static int OpenFilter( vlc_object_t *p_this )
>> }
>> i_output_physical = CanonicaliseChannels( i_output_physical );
>>
>> - unsigned i_channels = popcount(i_output_physical);
>> + unsigned i_channels = vlc_popcount(i_output_physical);
>>
>> /* condense out_channels */
>> uint8_t out_ch_sorted[ AOUT_CHAN_MAX ];
>> diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
>> index 7a363ce380..e54b55db5d 100644
>> --- a/modules/audio_output/alsa.c
>> +++ b/modules/audio_output/alsa.c
>> @@ -242,8 +242,8 @@ static unsigned SetupChannels (vlc_object_t *obj,
>> snd_pcm_t *pcm,
>> if (chans == -1)
>> continue;
>>
>> - unsigned score = (popcount (chans & *mask) << 8)
>> - | (255 - popcount (chans));
>> + unsigned score = (vlc_popcount (chans & *mask) << 8)
>> + | (255 - vlc_popcount (chans));
>> if (score > best_score)
>> {
>> best_offset = p - maps;
>> @@ -469,7 +469,7 @@ static int Start (audio_output_t *aout,
>> audio_sample_format_t *restrict fmt)
>> sys->chans_to_reorder = SetupChannels (VLC_OBJECT(aout), pcm,
>> &map,
>> sys->chans_table);
>> fmt->i_physical_channels = map;
>> - channels = popcount (map);
>> + channels = vlc_popcount (map);
>> }
>> else
>> {
>> diff --git a/modules/audio_output/directsound.c b/modules/audio_output/
>> directsound.c
>> index c3fa40b479..38d3e2927d 100644
>> --- a/modules/audio_output/directsound.c
>> +++ b/modules/audio_output/directsound.c
>> @@ -517,7 +517,7 @@ static HRESULT CreateDSBufferPCM( vlc_object_t *obj,
>> aout_stream_sys_t *sys,
>> int i_rate, bool b_probe )
>> {
>> HRESULT hr;
>> - unsigned i_nb_channels = popcount( i_channels );
>> + unsigned i_nb_channels = vlc_popcount( i_channels );
>>
>> if( var_GetBool( obj, "directx-audio-float32" ) )
>> {
>> diff --git a/modules/codec/faad.c b/modules/codec/faad.c
>> index cd415b6c5c..16d0b0c765 100644
>> --- a/modules/codec/faad.c
>> +++ b/modules/codec/faad.c
>> @@ -533,7 +533,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t
>> *p_block )
>> b_reorder =
>> aout_CheckChannelReorder( pi_faad_channels_positions, NULL,
>> p_dec->fmt_out.audio.i_physical_channels,
>> pi_neworder_table );
>>
>> - p_dec->fmt_out.audio.i_channels = popcount(p_dec-
>>> fmt_out.audio.i_physical_channels);
>> + p_dec->fmt_out.audio.i_channels = vlc_popcount(p_dec-
>>> fmt_out.audio.i_physical_channels);
>> }
>>
>> if( !decoder_UpdateAudioFormat( p_dec ) && p_dec-
>>> fmt_out.audio.i_channels > 0 )
>> @@ -549,7 +549,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t
>> *p_block )
>> if ( p_dec->fmt_out.audio.channel_type ==
>> AUDIO_CHANNEL_TYPE_BITMAP )
>> {
>> /* Don't kill speakers if some weird mapping does not
>> gets 1:1 */
>> - if( popcount(p_dec-
>>> fmt_out.audio.i_physical_channels) != frame.channels )
>> + if( vlc_popcount(p_dec-
>>> fmt_out.audio.i_physical_channels) != frame.channels )
>> memset( p_out->p_buffer, 0, p_out->i_buffer );
>> }
>>
>> diff --git a/modules/codec/flac.c b/modules/codec/flac.c
>> index b6fcac1481..03cdd55955 100644
>> --- a/modules/codec/flac.c
>> +++ b/modules/codec/flac.c
>> @@ -340,7 +340,7 @@ static void DecoderMetadataCallback( const
>> FLAC__StreamDecoder *decoder,
>> {
>> char *endptr = (char *) &comment->entry[34] +
>> comment->length;
>> const uint32_t i_wfxmask = strtoul( (char *)
>> &comment->entry[34], &endptr, 16 );
>> - const unsigned i_wfxchannels =
>> popcount( i_wfxmask );
>> + const unsigned i_wfxchannels =
>> vlc_popcount( i_wfxmask );
>> if( i_wfxchannels > 0 && i_wfxchannels <=
>> AOUT_CHAN_MAX )
>> {
>> /* Create the vlc bitmap from wfx channels */
>> @@ -356,7 +356,7 @@ static void DecoderMetadataCallback( const
>> FLAC__StreamDecoder *decoder,
>> }
>> }
>> /* Check if we have the 1 to 1 mapping */
>> - if( popcount(i_vlcmask) != i_wfxchannels )
>> + if( vlc_popcount(i_vlcmask) != i_wfxchannels )
>> {
>> msg_Warn( p_dec, "Unsupported channel mask
>> %x", i_wfxmask );
>> return;
>> diff --git a/modules/mux/mpeg/tables.c b/modules/mux/mpeg/tables.c
>> index ef46a42757..f6aa8be3a7 100644
>> --- a/modules/mux/mpeg/tables.c
>> +++ b/modules/mux/mpeg/tables.c
>> @@ -544,7 +544,7 @@ void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t
>> *p_object,
>> else if( p_stream->fmt->i_codec == VLC_CODEC_DTS )
>> {
>> /* DTS registration descriptor (ETSI TS 101 154 Annex F) */
>> - if(popcount(p_stream->fmt->audio.i_bytes_per_frame) == 1)
>> + if(vlc_popcount(p_stream->fmt->audio.i_bytes_per_frame) ==
>> 1)
>> {
>> uint8_t i_ver = ctz( p_stream->fmt-
>>> audio.i_bytes_per_frame >> 8 );
>> if(i_ver > 0 && i_ver < 4)
>> diff --git a/modules/packetizer/a52.h b/modules/packetizer/a52.h
>> index c46a0f2bb9..0965710d6f 100644
>> --- a/modules/packetizer/a52.h
>> +++ b/modules/packetizer/a52.h
>> @@ -163,7 +163,7 @@ static inline int
>> vlc_a52_header_ParseAc3( vlc_a52_header_t *p_header,
>> if( i_lfeon )
>> p_header->i_channels_conf |= AOUT_CHAN_LFE;
>>
>> - p_header->i_channels = popcount(p_header->i_channels_conf);
>> + p_header->i_channels = vlc_popcount(p_header->i_channels_conf);
>>
>> const unsigned i_rate_shift = VLC_CLIP(i_bsid, 8, 11) - 8;
>> p_header->i_bitrate = (pi_frmsizcod_bitrates[i_frmsizcod >> 1] *
>> 1000)
>> @@ -223,7 +223,7 @@ static inline int
>> vlc_a52_header_ParseEac3( vlc_a52_header_t *p_header,
>> p_header->i_chan_mode |= AOUT_CHANMODE_DUALMONO;
>> if( i_lfeon )
>> p_header->i_channels_conf |= AOUT_CHAN_LFE;
>> - p_header->i_channels = popcount( p_header->i_channels_conf );
>> + p_header->i_channels = vlc_popcount( p_header->i_channels_conf );
>> p_header->i_bitrate = 8 * p_header->i_size * p_header->i_rate
>> / (p_header->i_blocks_per_sync_frame * 256);
>> p_header->i_samples = p_header->i_blocks_per_sync_frame * 256;
>> diff --git a/modules/packetizer/dts.c b/modules/packetizer/dts.c
>> index c1a570c45b..e9ca41d267 100644
>> --- a/modules/packetizer/dts.c
>> +++ b/modules/packetizer/dts.c
>> @@ -105,7 +105,7 @@ static block_t *GetOutBuffer( decoder_t *p_dec )
>> p_dec->fmt_out.audio.i_chan_mode = p_sys->dts.i_chan_mode;
>> p_dec->fmt_out.audio.i_physical_channels = p_sys-
>>> dts.i_physical_channels;
>> p_dec->fmt_out.audio.i_channels =
>> - popcount( p_dec->fmt_out.audio.i_physical_channels );
>> + vlc_popcount( p_dec->fmt_out.audio.i_physical_channels );
>>
>> p_dec->fmt_out.i_bitrate = p_sys->dts.i_bitrate;
>>
>> diff --git a/modules/packetizer/hxxx_nal.h b/modules/packetizer/
>> hxxx_nal.h
>> index 947733fa21..6ba41ae3f0 100644
>> --- a/modules/packetizer/hxxx_nal.h
>> +++ b/modules/packetizer/hxxx_nal.h
>> @@ -266,7 +266,7 @@ static inline void
>> hxxx_iterator_init( hxxx_iterator_ctx_t *p_ctx, const uint8_t
>> {
>> p_ctx->p_head = p_data;
>> p_ctx->p_tail = p_data + i_data;
>> - if( popcount(i_nal_length_size) == 1 && i_nal_length_size <= 4 )
>> + if( vlc_popcount(i_nal_length_size) == 1 && i_nal_length_size <=
>> 4 )
>> p_ctx->i_nal_length_size = i_nal_length_size;
>> else
>> p_ctx->i_nal_length_size = 0;
>> diff --git a/modules/video_output/xcb/xvideo.c b/modules/video_output/
>> xcb/xvideo.c
>> index 5c82507521..6c587a808f 100644
>> --- a/modules/video_output/xcb/xvideo.c
>> +++ b/modules/video_output/xcb/xvideo.c
>> @@ -141,7 +141,7 @@ static vlc_fourcc_t ParseFormat (vlc_object_t *obj,
>> switch (f->num_planes)
>> {
>> case 1:
>> - switch (popcount (f->red_mask | f->green_mask | f-
>>> blue_mask))
>> + switch (vlc_popcount (f->red_mask | f->green_mask | f-
>>> blue_mask))
>> {
>> case 24:
>> if (f->bpp == 32 && f->depth == 32)
>> --
>> 2.16.1
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 850 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20180226/9acd11a4/attachment.sig>
More information about the vlc-devel
mailing list