Lines Matching refs:bio
51 static void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b);
57 static OPJ_UINT32 opj_bio_getbit(opj_bio_t *bio);
63 static OPJ_BOOL opj_bio_byteout(opj_bio_t *bio);
69 static OPJ_BOOL opj_bio_bytein(opj_bio_t *bio);
81 static OPJ_BOOL opj_bio_byteout(opj_bio_t *bio) in opj_bio_byteout() argument
83 bio->buf = (bio->buf << 8) & 0xffff; in opj_bio_byteout()
84 bio->ct = bio->buf == 0xff00 ? 7 : 8; in opj_bio_byteout()
85 if ((OPJ_SIZE_T)bio->bp >= (OPJ_SIZE_T)bio->end) { in opj_bio_byteout()
88 *bio->bp++ = (OPJ_BYTE)(bio->buf >> 8); in opj_bio_byteout()
92 static OPJ_BOOL opj_bio_bytein(opj_bio_t *bio) in opj_bio_bytein() argument
94 bio->buf = (bio->buf << 8) & 0xffff; in opj_bio_bytein()
95 bio->ct = bio->buf == 0xff00 ? 7 : 8; in opj_bio_bytein()
96 if ((OPJ_SIZE_T)bio->bp >= (OPJ_SIZE_T)bio->end) { in opj_bio_bytein()
99 bio->buf |= *bio->bp++; in opj_bio_bytein()
103 static void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b) in opj_bio_putbit() argument
105 if (bio->ct == 0) { in opj_bio_putbit()
107 bio); /* MSD: why not check the return value of this function ? */ in opj_bio_putbit()
109 bio->ct--; in opj_bio_putbit()
110 bio->buf |= b << bio->ct; in opj_bio_putbit()
113 static OPJ_UINT32 opj_bio_getbit(opj_bio_t *bio) in opj_bio_getbit() argument
115 if (bio->ct == 0) { in opj_bio_getbit()
117 bio); /* MSD: why not check the return value of this function ? */ in opj_bio_getbit()
119 bio->ct--; in opj_bio_getbit()
120 return (bio->buf >> bio->ct) & 1; in opj_bio_getbit()
131 opj_bio_t *bio = (opj_bio_t*)opj_malloc(sizeof(opj_bio_t)); in opj_bio_create() local
132 return bio; in opj_bio_create()
135 void opj_bio_destroy(opj_bio_t *bio) in opj_bio_destroy() argument
137 if (bio) { in opj_bio_destroy()
138 opj_free(bio); in opj_bio_destroy()
142 ptrdiff_t opj_bio_numbytes(opj_bio_t *bio) in opj_bio_numbytes() argument
144 return (bio->bp - bio->start); in opj_bio_numbytes()
147 void opj_bio_init_enc(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) in opj_bio_init_enc() argument
149 bio->start = bp; in opj_bio_init_enc()
150 bio->end = bp + len; in opj_bio_init_enc()
151 bio->bp = bp; in opj_bio_init_enc()
152 bio->buf = 0; in opj_bio_init_enc()
153 bio->ct = 8; in opj_bio_init_enc()
156 void opj_bio_init_dec(opj_bio_t *bio, OPJ_BYTE *bp, OPJ_UINT32 len) in opj_bio_init_dec() argument
158 bio->start = bp; in opj_bio_init_dec()
159 bio->end = bp + len; in opj_bio_init_dec()
160 bio->bp = bp; in opj_bio_init_dec()
161 bio->buf = 0; in opj_bio_init_dec()
162 bio->ct = 0; in opj_bio_init_dec()
165 void opj_bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n) in opj_bio_write() argument
171 opj_bio_putbit(bio, (v >> i) & 1); in opj_bio_write()
175 OPJ_UINT32 opj_bio_read(opj_bio_t *bio, OPJ_UINT32 n) in opj_bio_read() argument
189 v |= opj_bio_getbit(bio) << in opj_bio_read()
195 OPJ_BOOL opj_bio_flush(opj_bio_t *bio) in opj_bio_flush() argument
197 if (! opj_bio_byteout(bio)) { in opj_bio_flush()
200 if (bio->ct == 7) { in opj_bio_flush()
201 if (! opj_bio_byteout(bio)) { in opj_bio_flush()
208 OPJ_BOOL opj_bio_inalign(opj_bio_t *bio) in opj_bio_inalign() argument
210 if ((bio->buf & 0xff) == 0xff) { in opj_bio_inalign()
211 if (! opj_bio_bytein(bio)) { in opj_bio_inalign()
215 bio->ct = 0; in opj_bio_inalign()