1 /*****************************************************************************
2  * bits.h
3  *****************************************************************************
4  * Copyright (C) 2010-2017 L-SMASH project
5  *
6  * Authors: Takashi Hirata <silverfilain@gmail.com>
7  *
8  * Permission to use, copy, modify, and/or distribute this software for any
9  * purpose with or without fee is hereby granted, provided that the above
10  * copyright notice and this permission notice appear in all copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19  *****************************************************************************/
20 
21 /* This file is available under an ISC license. */
22 
23 typedef struct
24 {
25     lsmash_bs_t *bs;
26     uint8_t      store;
27     uint8_t      cache;
28 } lsmash_bits_t;
29 
30 void lsmash_bits_init( lsmash_bits_t* bits, lsmash_bs_t *bs );
31 lsmash_bits_t *lsmash_bits_create( lsmash_bs_t *bs );
32 void lsmash_bits_cleanup( lsmash_bits_t *bits );
33 void lsmash_bits_empty( lsmash_bits_t *bits );
34 void lsmash_bits_put_align( lsmash_bits_t *bits );
35 void lsmash_bits_get_align( lsmash_bits_t *bits );
36 void lsmash_bits_put( lsmash_bits_t *bits, uint32_t width, uint64_t value );
37 uint64_t lsmash_bits_get( lsmash_bits_t *bits, uint32_t width );
38 void *lsmash_bits_export_data( lsmash_bits_t *bits, uint32_t *length );
39 int lsmash_bits_import_data( lsmash_bits_t *bits, void *data, uint32_t length );
40 
41 lsmash_bits_t *lsmash_bits_adhoc_create();
42 void lsmash_bits_adhoc_cleanup( lsmash_bits_t *bits );
43