SphinxBase 5prealpha
bitarr.h
Go to the documentation of this file.
1/* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/* ====================================================================
3 * Copyright (c) 2015 Carnegie Mellon University. All rights
4 * reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 *
18 * This work was supported in part by funding from the Defense Advanced
19 * Research Projects Agency and the National Science Foundation of the
20 * United States of America, and the CMU Sphinx Speech Consortium.
21 *
22 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
23 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
26 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 * ====================================================================
35 *
36 */
37
38#ifndef _LIBUTIL_BITARR_H_
39#define _LIBUTIL_BITARR_H_
40
41#include <string.h>
42
44/* Win32/WinCE DLL gunk */
45#include <sphinxbase/sphinxbase_export.h>
46
54#ifdef __cplusplus
55extern "C" {
56#endif
57#if 0
58/* Fool Emacs. */
59}
60#endif
61
65typedef struct bitarr_mask_s {
66 uint8 bits;
67 uint32 mask;
69
73typedef struct bitarr_address_s {
74 void *base;
75 uint32 offset;
77
86SPHINXBASE_EXPORT
87uint64 bitarr_read_int57(bitarr_address_t address, uint8 length, uint64 mask);
88
97SPHINXBASE_EXPORT
98void bitarr_write_int57(bitarr_address_t address, uint8 length, uint64 value);
99
108SPHINXBASE_EXPORT
109uint32 bitarr_read_int25(bitarr_address_t address, uint8 length, uint32 mask);
110
119SPHINXBASE_EXPORT
120void bitarr_write_int25(bitarr_address_t address, uint8 length, uint32 value);
121
127SPHINXBASE_EXPORT
128void bitarr_mask_from_max(bitarr_mask_t *bit_mask, uint32 max_value);
129
135SPHINXBASE_EXPORT
136uint8 bitarr_required_bits(uint32 max_value);
137
138#ifdef __cplusplus
139}
140#endif
141
142#endif /* _LIBUTIL_BITARR_H_ */
struct bitarr_address_s bitarr_address_t
Structure that stores address of certain value in bit array.
SPHINXBASE_EXPORT void bitarr_write_int57(bitarr_address_t address, uint8 length, uint64 value)
Write specified value into bit array.
Definition: bitarr.c:87
SPHINXBASE_EXPORT uint8 bitarr_required_bits(uint32 max_value)
Computes amount of bits required ti store integers upto value provided.
Definition: bitarr.c:131
SPHINXBASE_EXPORT uint64 bitarr_read_int57(bitarr_address_t address, uint8 length, uint64 mask)
Read uint64 value from bit array.
Definition: bitarr.c:82
SPHINXBASE_EXPORT uint32 bitarr_read_int25(bitarr_address_t address, uint8 length, uint32 mask)
Read uint32 value from bit array.
Definition: bitarr.c:100
struct bitarr_mask_s bitarr_mask_t
Structure that specifies bits required to efficiently store certain data.
SPHINXBASE_EXPORT void bitarr_write_int25(bitarr_address_t address, uint8 length, uint32 value)
Write specified value into bit array.
Definition: bitarr.c:112
SPHINXBASE_EXPORT void bitarr_mask_from_max(bitarr_mask_t *bit_mask, uint32 max_value)
Fills mask for certain int range according to provided max value.
Definition: bitarr.c:125
Basic type definitions used in Sphinx.
Structure that stores address of certain value in bit array.
Definition: bitarr.h:73
Structure that specifies bits required to efficiently store certain data.
Definition: bitarr.h:65