MediaProcessors
bitparser.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, 2016, 2017, 2018 Rafael Antoniello
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of copyright holders nor the names of its
14  * contributors may be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS
21  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
36 #ifndef SPUTIL_SRC_BITPARSER_H_
37 #define SPUTIL_SRC_BITPARSER_H_
38 
39 #include <sys/types.h>
40 #include <inttypes.h>
41 #include "mem_utils.h"
42 
43 /* **** Definitions **** */
44 
49 #define LITTLEENDIAN
50 
51 typedef struct bitparser_ctx_s {
55  WORD_T *buf;
59  size_t buf_size;
63  WORD_T bcnt;
67  WORD_T word0;
71  WORD_T word1;
76  WORD_T top;
78 
79 /* **** Prototypes **** */
80 
91 
95 void bitparser_close(bitparser_ctx_t **ref_bitparser_ctx);
96 
102 void bitparser_flush(bitparser_ctx_t* bitparser_ctx, size_t n);
103 
112 WORD_T bitparser_get(bitparser_ctx_t* bitparser_ctx, size_t n);
113 
123 WORD_T bitparser_show(bitparser_ctx_t* bitparser_ctx, size_t n);
124 
135 void* bitparser_copy_bytes(bitparser_ctx_t* bitparser_ctx, size_t cnt);
136 
141 void bitparser_align_2byte(bitparser_ctx_t* bitparser_ctx);
142 
143 #endif /* SPUTIL_SRC_BITPARSER_H_ */
bitparser_ctx_t * bitparser_open(void *buf, size_t buf_size)
Definition: bitparser.c:82
WORD_T word0
Definition: bitparser.h:67
WORD_T bitparser_show(bitparser_ctx_t *bitparser_ctx, size_t n)
Definition: bitparser.c:175
size_t buf_size
Definition: bitparser.h:59
WORD_T bitparser_get(bitparser_ctx_t *bitparser_ctx, size_t n)
Definition: bitparser.c:163
void bitparser_flush(bitparser_ctx_t *bitparser_ctx, size_t n)
Definition: bitparser.c:129
WORD_T word1
Definition: bitparser.h:71
WORD_T * buf
Definition: bitparser.h:55
void bitparser_align_2byte(bitparser_ctx_t *bitparser_ctx)
Definition: bitparser.c:217
void bitparser_close(bitparser_ctx_t **ref_bitparser_ctx)
Definition: bitparser.c:115
void * bitparser_copy_bytes(bitparser_ctx_t *bitparser_ctx, size_t cnt)
Definition: bitparser.c:186