/** @name Local static functions */
/*@{*/
-/**
-Write a bit
-@param bio BIO handle
-@param b Bit to write (0 or 1)
-*/
-static void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b);
/**
Read a bit
@param bio BIO handle
return OPJ_TRUE;
}
-static void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b)
-{
- if (bio->ct == 0) {
- opj_bio_byteout(
- bio); /* MSD: why not check the return value of this function ? */
- }
- bio->ct--;
- bio->buf |= b << bio->ct;
-}
-
static OPJ_UINT32 opj_bio_getbit(opj_bio_t *bio)
{
if (bio->ct == 0) {
bio->ct = 0;
}
+void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b)
+{
+ if (bio->ct == 0) {
+ opj_bio_byteout(
+ bio); /* MSD: why not check the return value of this function ? */
+ }
+ bio->ct--;
+ bio->buf |= b << bio->ct;
+}
+
void opj_bio_write(opj_bio_t *bio, OPJ_UINT32 v, OPJ_UINT32 n)
{
OPJ_INT32 i;
static void opj_t2_putcommacode(opj_bio_t *bio, OPJ_INT32 n)
{
while (--n >= 0) {
- opj_bio_write(bio, 1, 1);
+ opj_bio_putbit(bio, 1);
}
- opj_bio_write(bio, 0, 1);
+ opj_bio_putbit(bio, 0);
}
static OPJ_UINT32 opj_t2_getcommacode(opj_bio_t *bio)
static void opj_t2_putnumpasses(opj_bio_t *bio, OPJ_UINT32 n)
{
if (n == 1) {
- opj_bio_write(bio, 0, 1);
+ opj_bio_putbit(bio, 0);
} else if (n == 2) {
opj_bio_write(bio, 2, 2);
} else if (n <= 5) {
}
}
#endif
- opj_bio_write(bio, packet_empty ? 0 : 1, 1); /* Empty header bit */
+ opj_bio_putbit(bio, packet_empty ? 0 : 1); /* Empty header bit */
/* Writing Packet header */
band = res->bands;
if (!cblk->numpasses) {
opj_tgt_encode(bio, prc->incltree, cblkno, (OPJ_INT32)(layno + 1));
} else {
- opj_bio_write(bio, layer->numpasses != 0, 1);
+ opj_bio_putbit(bio, layer->numpasses != 0);
}
/* if cblk not included, go to the next cblk */
return OPJ_FALSE;
}
- memcpy(c, layer->data, layer->len);
+ if (p_t2_mode == FINAL_PASS) {
+ memcpy(c, layer->data, layer->len);
+ }
cblk->numpasses += layer->numpasses;
c += layer->len;
length -= layer->len;
while (low < threshold) {
if (low >= node->value) {
if (!node->known) {
- opj_bio_write(bio, 1, 1);
+ opj_bio_putbit(bio, 1);
node->known = 1;
}
break;
}
- opj_bio_write(bio, 0, 1);
+ opj_bio_putbit(bio, 0);
++low;
}