summaryrefslogtreecommitdiffstats
path: root/libhb/bits.h
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2012-05-18 06:54:25 +0000
committerjstebbins <[email protected]>2012-05-18 06:54:25 +0000
commit6a31263baa876f3cf0eba0aa88a7dbc69239b8ab (patch)
treeb08444c845d3cb2a9e4961f11f2f80969542b1f4 /libhb/bits.h
parent5a0673d1572fdfcd00063cfa9dffba907c808056 (diff)
Forgot to svn add some taskset files
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4686 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/bits.h')
-rw-r--r--libhb/bits.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/libhb/bits.h b/libhb/bits.h
new file mode 100644
index 000000000..6338edcf3
--- /dev/null
+++ b/libhb/bits.h
@@ -0,0 +1,87 @@
+/* $Id$
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr/>.
+ It may be used under the terms of the GNU General Public License. */
+
+#ifndef HB_BITS_H
+#define HB_BITS_H
+
+static inline int
+allbits_set(uint32_t *bitmap, int num_words)
+{
+ unsigned int i;
+ for( i = 0; i < num_words; i++ )
+ {
+ if( bitmap[i] != 0xFFFFFFFF )
+ return (0);
+ }
+ return (1);
+}
+
+static inline int
+bit_is_set( uint32_t *bit_map, int bit_pos )
+{
+ return( ( bit_map[bit_pos >> 5] & (0x1 << (bit_pos & 0x1F) ) ) != 0 );
+}
+
+static inline int
+bit_is_clear( uint32_t *bit_map, int bit_pos )
+{
+ return( ( bit_map[bit_pos >> 5] & ( 0x1 << (bit_pos & 0x1F) ) ) == 0 );
+}
+
+static inline void
+bit_set( uint32_t *bit_map, int bit_pos )
+{
+ bit_map[bit_pos >> 5] |= 0x1 << (bit_pos & 0x1F);
+}
+
+static inline void
+bit_clear(uint32_t *bit_map, int bit_pos)
+{
+ bit_map[bit_pos >> 5] &= ~( 0x1 << ( bit_pos & 0x1F ) );
+}
+
+static inline void
+bit_nclear(uint32_t *bit_map, int start_pos, int stop_pos)
+{
+ int start_word = start_pos >> 5;
+ int stop_word = stop_pos >> 5;
+
+ if ( start_word == stop_word )
+ {
+
+ bit_map[start_word] &= ( ( 0x7FFFFFFF >> ( 31 - (start_pos & 0x1F ) ) )
+ | ( 0xFFFFFFFE << ( stop_pos & 0x1F ) ) );
+ }
+ else
+ {
+ bit_map[start_word] &= ( 0x7FFFFFFF >> ( 31 - ( start_pos & 0x1F ) ) );
+ while (++start_word < stop_word)
+ bit_map[start_word] = 0;
+ bit_map[stop_word] &= 0xFFFFFFFE << ( stop_pos & 0x1F );
+ }
+}
+
+static inline void
+bit_nset(uint32_t *bit_map, int start_pos, int stop_pos)
+{
+ int start_word = start_pos >> 5;
+ int stop_word = stop_pos >> 5;
+
+ if ( start_word == stop_word )
+ {
+ bit_map[start_word] |= ( ( 0xFFFFFFFF << ( start_pos & 0x1F ) )
+ & ( 0xFFFFFFFF >> ( 31 - ( stop_pos & 0x1F ) ) ) );
+ }
+ else
+ {
+ bit_map[start_word] |= 0xFFFFFFFF << ( start_pos & 0x1F );
+ while (++start_word < stop_word)
+ bit_map[start_word] = 0xFFFFFFFF;
+ bit_map[stop_word] |= 0xFFFFFFFF >> ( 31 - ( stop_pos & 0x1F ) );
+ }
+}
+
+#endif /* HB_BITS_H */