| OLD | NEW |
| 1 /* | 1 /* |
| 2 * The copyright in this software is being made available under the 2-clauses | 2 * The copyright in this software is being made available under the 2-clauses |
| 3 * BSD License, included below. This software may be subject to other third | 3 * BSD License, included below. This software may be subject to other third |
| 4 * party and contributor rights, including patent rights, and no such rights | 4 * party and contributor rights, including patent rights, and no such rights |
| 5 * are granted under this license. | 5 * are granted under this license. |
| 6 * | 6 * |
| 7 * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium | 7 * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium |
| 8 * Copyright (c) 2002-2014, Professor Benoit Macq | 8 * Copyright (c) 2002-2014, Professor Benoit Macq |
| 9 * Copyright (c) 2001-2003, David Janssens | 9 * Copyright (c) 2001-2003, David Janssens |
| 10 * Copyright (c) 2002-2003, Yannick Verschueren | 10 * Copyright (c) 2002-2003, Yannick Verschueren |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 /* | 75 /* |
| 76 ========================================================== | 76 ========================================================== |
| 77 local functions | 77 local functions |
| 78 ========================================================== | 78 ========================================================== |
| 79 */ | 79 */ |
| 80 | 80 |
| 81 OPJ_BOOL opj_bio_byteout(opj_bio_t *bio) { | 81 OPJ_BOOL opj_bio_byteout(opj_bio_t *bio) { |
| 82 bio->buf = (bio->buf << 8) & 0xffff; | 82 bio->buf = (bio->buf << 8) & 0xffff; |
| 83 bio->ct = bio->buf == 0xff00 ? 7 : 8; | 83 bio->ct = bio->buf == 0xff00 ? 7 : 8; |
| 84 » if (bio->bp >= bio->end) { | 84 » if ((OPJ_SIZE_T)bio->bp >= (OPJ_SIZE_T)bio->end) { |
| 85 return OPJ_FALSE; | 85 return OPJ_FALSE; |
| 86 } | 86 } |
| 87 *bio->bp++ = (OPJ_BYTE)(bio->buf >> 8); | 87 *bio->bp++ = (OPJ_BYTE)(bio->buf >> 8); |
| 88 return OPJ_TRUE; | 88 return OPJ_TRUE; |
| 89 } | 89 } |
| 90 | 90 |
| 91 OPJ_BOOL opj_bio_bytein(opj_bio_t *bio) { | 91 OPJ_BOOL opj_bio_bytein(opj_bio_t *bio) { |
| 92 bio->buf = (bio->buf << 8) & 0xffff; | 92 bio->buf = (bio->buf << 8) & 0xffff; |
| 93 bio->ct = bio->buf == 0xff00 ? 7 : 8; | 93 bio->ct = bio->buf == 0xff00 ? 7 : 8; |
| 94 » if (bio->bp >= bio->end) { | 94 » if ((OPJ_SIZE_T)bio->bp >= (OPJ_SIZE_T)bio->end) { |
| 95 return OPJ_FALSE; | 95 return OPJ_FALSE; |
| 96 } | 96 } |
| 97 bio->buf |= *bio->bp++; | 97 bio->buf |= *bio->bp++; |
| 98 return OPJ_TRUE; | 98 return OPJ_TRUE; |
| 99 } | 99 } |
| 100 | 100 |
| 101 void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b) { | 101 void opj_bio_putbit(opj_bio_t *bio, OPJ_UINT32 b) { |
| 102 if (bio->ct == 0) { | 102 if (bio->ct == 0) { |
| 103 opj_bio_byteout(bio); /* MSD: why not check the return value of
this function ? */ | 103 opj_bio_byteout(bio); /* MSD: why not check the return value of
this function ? */ |
| 104 } | 104 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 OPJ_UINT32 i; | 162 OPJ_UINT32 i; |
| 163 OPJ_UINT32 v; | 163 OPJ_UINT32 v; |
| 164 v = 0; | 164 v = 0; |
| 165 for (i = n - 1; i < n; i--) { | 165 for (i = n - 1; i < n; i--) { |
| 166 v += opj_bio_getbit(bio) << i; | 166 v += opj_bio_getbit(bio) << i; |
| 167 } | 167 } |
| 168 return v; | 168 return v; |
| 169 } | 169 } |
| 170 | 170 |
| 171 OPJ_BOOL opj_bio_flush(opj_bio_t *bio) { | 171 OPJ_BOOL opj_bio_flush(opj_bio_t *bio) { |
| 172 bio->ct = 0; | |
| 173 if (! opj_bio_byteout(bio)) { | 172 if (! opj_bio_byteout(bio)) { |
| 174 return OPJ_FALSE; | 173 return OPJ_FALSE; |
| 175 } | 174 } |
| 176 if (bio->ct == 7) { | 175 if (bio->ct == 7) { |
| 177 bio->ct = 0; | |
| 178 if (! opj_bio_byteout(bio)) { | 176 if (! opj_bio_byteout(bio)) { |
| 179 return OPJ_FALSE; | 177 return OPJ_FALSE; |
| 180 } | 178 } |
| 181 } | 179 } |
| 182 return OPJ_TRUE; | 180 return OPJ_TRUE; |
| 183 } | 181 } |
| 184 | 182 |
| 185 OPJ_BOOL opj_bio_inalign(opj_bio_t *bio) { | 183 OPJ_BOOL opj_bio_inalign(opj_bio_t *bio) { |
| 186 bio->ct = 0; | |
| 187 if ((bio->buf & 0xff) == 0xff) { | 184 if ((bio->buf & 0xff) == 0xff) { |
| 188 if (! opj_bio_bytein(bio)) { | 185 if (! opj_bio_bytein(bio)) { |
| 189 return OPJ_FALSE; | 186 return OPJ_FALSE; |
| 190 } | 187 } |
| 191 bio->ct = 0; | |
| 192 } | 188 } |
| 189 bio->ct = 0; |
| 193 return OPJ_TRUE; | 190 return OPJ_TRUE; |
| 194 } | 191 } |
| OLD | NEW |