3 Copyright (c) 2003-2015 HandBrake Team
4 This file is part of the HandBrake source code
5 Homepage: <http://handbrake.fr/>.
6 It may be used under the terms of the GNU General Public License v2.
7 For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html
14 allbits_set(uint32_t *bitmap
, int num_words
)
17 for( i
= 0; i
< num_words
; i
++ )
19 if( bitmap
[i
] != 0xFFFFFFFF )
26 bit_is_set( uint32_t *bit_map
, int bit_pos
)
28 return( ( bit_map
[bit_pos
>> 5] & (0x1 << (bit_pos
& 0x1F) ) ) != 0 );
32 bit_is_clear( uint32_t *bit_map
, int bit_pos
)
34 return( ( bit_map
[bit_pos
>> 5] & ( 0x1 << (bit_pos
& 0x1F) ) ) == 0 );
38 bit_set( uint32_t *bit_map
, int bit_pos
)
40 bit_map
[bit_pos
>> 5] |= 0x1 << (bit_pos
& 0x1F);
44 bit_clear(uint32_t *bit_map
, int bit_pos
)
46 bit_map
[bit_pos
>> 5] &= ~( 0x1 << ( bit_pos
& 0x1F ) );
50 bit_nclear(uint32_t *bit_map
, int start_pos
, int stop_pos
)
52 int start_word
= start_pos
>> 5;
53 int stop_word
= stop_pos
>> 5;
55 if ( start_word
== stop_word
)
58 bit_map
[start_word
] &= ( ( 0x7FFFFFFF >> ( 31 - (start_pos
& 0x1F ) ) )
59 | ( 0xFFFFFFFE << ( stop_pos
& 0x1F ) ) );
63 bit_map
[start_word
] &= ( 0x7FFFFFFF >> ( 31 - ( start_pos
& 0x1F ) ) );
64 while (++start_word
< stop_word
)
65 bit_map
[start_word
] = 0;
66 bit_map
[stop_word
] &= 0xFFFFFFFE << ( stop_pos
& 0x1F );
71 bit_nset(uint32_t *bit_map
, int start_pos
, int stop_pos
)
73 int start_word
= start_pos
>> 5;
74 int stop_word
= stop_pos
>> 5;
76 if ( start_word
== stop_word
)
78 bit_map
[start_word
] |= ( ( 0xFFFFFFFF << ( start_pos
& 0x1F ) )
79 & ( 0xFFFFFFFF >> ( 31 - ( stop_pos
& 0x1F ) ) ) );
83 bit_map
[start_word
] |= 0xFFFFFFFF << ( start_pos
& 0x1F );
84 while (++start_word
< stop_word
)
85 bit_map
[start_word
] = 0xFFFFFFFF;
86 bit_map
[stop_word
] |= 0xFFFFFFFF >> ( 31 - ( stop_pos
& 0x1F ) );
90 #endif /* HB_BITS_H */