Home | History | Annotate | Download | only in libopenjpeg20

Lines Matching defs:bio

40 /** @defgroup BIO BIO - Individual bit input-output stream */
48 @param bio BIO handle
51 static void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b);
54 @param bio BIO handle
57 static OPJ_UINT32 opj_bio_getbit(opj_bio_t *bio);
60 @param bio BIO handle
63 static OPJ_BOOL opj_bio_byteout(opj_bio_t *bio);
66 @param bio BIO handle
69 static OPJ_BOOL opj_bio_bytein(opj_bio_t *bio);
81 OPJ_BOOL opj_bio_byteout(opj_bio_t *bio) {
82 bio->buf = (bio->buf << 8) & 0xffff;
83 bio->ct = bio->buf == 0xff00 ? 7 : 8;
84 if (bio->bp >= bio->end) {
87 *bio->bp++ = (OPJ_BYTE)(bio->buf >> 8);
91 OPJ_BOOL opj_bio_bytein(opj_bio_t *bio) {
92 bio->buf = (bio->buf << 8) & 0xffff;
93 bio->ct = bio->buf == 0xff00 ? 7 : 8;
94 if (bio->bp >= bio->end) {
97 bio->buf |= *bio->bp++;
101 void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b) {
102 if (bio->ct == 0) {
103 opj_bio_byteout(bio); /* MSD: why not check the return value of this function ? */
105 bio->ct--;
106 bio->buf |= b << bio->ct;
109 OPJ_UINT32 opj_bio_getbit(opj_bio_t *bio) {
110 if (bio->ct == 0) {
111 opj_bio_bytein(bio); /* MSD: why not check the return value of this function ? */
113 bio->ct--;
114 return (bio->buf >> bio->ct) & 1;
124 opj_bio_t *bio = (opj_bio_t*)opj_malloc(sizeof(opj_bio_t));
125 return bio;
128 void opj_bio_destroy(opj_bio_t *bio) {
129 if(bio) {
130 opj_free(bio);
134 ptrdiff_t opj_bio_numbytes(opj_bio_t *bio) {
135 return (bio->bp - bio->start);
138 void opj_bio_init_enc(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) {
139 bio->start = bp;
140 bio->end = bp + len;
141 bio->bp = bp;
142 bio->buf = 0;
143 bio->ct = 8;
146 void opj_bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) {
147 bio->start = bp;
148 bio->end = bp + len;
149 bio->bp = bp;
150 bio->buf = 0;
151 bio->ct = 0;
154 void opj_bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n) {
157 opj_bio_putbit(bio, (v >> i) & 1);
161 OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n) {
166 v += opj_bio_getbit(bio) << i;
171 OPJ_BOOL opj_bio_flush(opj_bio_t *bio) {
172 bio->ct = 0;
173 if (! opj_bio_byteout(bio)) {
176 if (bio->ct == 7) {
177 bio->ct = 0;
178 if (! opj_bio_byteout(bio)) {
185 OPJ_BOOL opj_bio_inalign(opj_bio_t *bio) {
186 bio->ct = 0;
187 if ((bio->buf & 0xff) == 0xff) {
188 if (! opj_bio_bytein(bio)) {
191 bio->ct = 0;