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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 {0x5601, 0, &mqc_states[92], &mqc_states[92]}, | 195 {0x5601, 0, &mqc_states[92], &mqc_states[92]}, |
196 {0x5601, 1, &mqc_states[93], &mqc_states[93]}, | 196 {0x5601, 1, &mqc_states[93], &mqc_states[93]}, |
197 }; | 197 }; |
198 | 198 |
199 /* | 199 /* |
200 ========================================================== | 200 ========================================================== |
201 local functions | 201 local functions |
202 ========================================================== | 202 ========================================================== |
203 */ | 203 */ |
204 | 204 |
205 void opj_mqc_byteout(opj_mqc_t *mqc) { | 205 static void opj_mqc_byteout(opj_mqc_t *mqc) { |
206 if (*mqc->bp == 0xff) { | 206 if (*mqc->bp == 0xff) { |
207 mqc->bp++; | 207 mqc->bp++; |
208 *mqc->bp = (OPJ_BYTE)(mqc->c >> 20); | 208 *mqc->bp = (OPJ_BYTE)(mqc->c >> 20); |
209 mqc->c &= 0xfffff; | 209 mqc->c &= 0xfffff; |
210 mqc->ct = 7; | 210 mqc->ct = 7; |
211 } else { | 211 } else { |
212 if ((mqc->c & 0x8000000) == 0) { /* ((mqc->c&0x8000000)==
0) CHANGE */ | 212 if ((mqc->c & 0x8000000) == 0) { /* ((mqc->c&0x8000000)==
0) CHANGE */ |
213 mqc->bp++; | 213 mqc->bp++; |
214 *mqc->bp = (OPJ_BYTE)(mqc->c >> 19); | 214 *mqc->bp = (OPJ_BYTE)(mqc->c >> 19); |
215 mqc->c &= 0x7ffff; | 215 mqc->c &= 0x7ffff; |
216 mqc->ct = 8; | 216 mqc->ct = 8; |
217 } else { | 217 } else { |
218 (*mqc->bp)++; | 218 (*mqc->bp)++; |
219 if (*mqc->bp == 0xff) { | 219 if (*mqc->bp == 0xff) { |
220 mqc->c &= 0x7ffffff; | 220 mqc->c &= 0x7ffffff; |
221 mqc->bp++; | 221 mqc->bp++; |
222 *mqc->bp = (OPJ_BYTE)(mqc->c >> 20); | 222 *mqc->bp = (OPJ_BYTE)(mqc->c >> 20); |
223 mqc->c &= 0xfffff; | 223 mqc->c &= 0xfffff; |
224 mqc->ct = 7; | 224 mqc->ct = 7; |
225 } else { | 225 } else { |
226 mqc->bp++; | 226 mqc->bp++; |
227 *mqc->bp = (OPJ_BYTE)(mqc->c >> 19); | 227 *mqc->bp = (OPJ_BYTE)(mqc->c >> 19); |
228 mqc->c &= 0x7ffff; | 228 mqc->c &= 0x7ffff; |
229 mqc->ct = 8; | 229 mqc->ct = 8; |
230 } | 230 } |
231 } | 231 } |
232 } | 232 } |
233 } | 233 } |
234 | 234 |
235 void opj_mqc_renorme(opj_mqc_t *mqc) { | 235 static void opj_mqc_renorme(opj_mqc_t *mqc) { |
236 do { | 236 do { |
237 mqc->a <<= 1; | 237 mqc->a <<= 1; |
238 mqc->c <<= 1; | 238 mqc->c <<= 1; |
239 mqc->ct--; | 239 mqc->ct--; |
240 if (mqc->ct == 0) { | 240 if (mqc->ct == 0) { |
241 opj_mqc_byteout(mqc); | 241 opj_mqc_byteout(mqc); |
242 } | 242 } |
243 } while ((mqc->a & 0x8000) == 0); | 243 } while ((mqc->a & 0x8000) == 0); |
244 } | 244 } |
245 | 245 |
246 void opj_mqc_codemps(opj_mqc_t *mqc) { | 246 static void opj_mqc_codemps(opj_mqc_t *mqc) { |
247 mqc->a -= (*mqc->curctx)->qeval; | 247 mqc->a -= (*mqc->curctx)->qeval; |
248 if ((mqc->a & 0x8000) == 0) { | 248 if ((mqc->a & 0x8000) == 0) { |
249 if (mqc->a < (*mqc->curctx)->qeval) { | 249 if (mqc->a < (*mqc->curctx)->qeval) { |
250 mqc->a = (*mqc->curctx)->qeval; | 250 mqc->a = (*mqc->curctx)->qeval; |
251 } else { | 251 } else { |
252 mqc->c += (*mqc->curctx)->qeval; | 252 mqc->c += (*mqc->curctx)->qeval; |
253 } | 253 } |
254 *mqc->curctx = (*mqc->curctx)->nmps; | 254 *mqc->curctx = (*mqc->curctx)->nmps; |
255 opj_mqc_renorme(mqc); | 255 opj_mqc_renorme(mqc); |
256 } else { | 256 } else { |
257 mqc->c += (*mqc->curctx)->qeval; | 257 mqc->c += (*mqc->curctx)->qeval; |
258 } | 258 } |
259 } | 259 } |
260 | 260 |
261 void opj_mqc_codelps(opj_mqc_t *mqc) { | 261 static void opj_mqc_codelps(opj_mqc_t *mqc) { |
262 mqc->a -= (*mqc->curctx)->qeval; | 262 mqc->a -= (*mqc->curctx)->qeval; |
263 if (mqc->a < (*mqc->curctx)->qeval) { | 263 if (mqc->a < (*mqc->curctx)->qeval) { |
264 mqc->c += (*mqc->curctx)->qeval; | 264 mqc->c += (*mqc->curctx)->qeval; |
265 } else { | 265 } else { |
266 mqc->a = (*mqc->curctx)->qeval; | 266 mqc->a = (*mqc->curctx)->qeval; |
267 } | 267 } |
268 *mqc->curctx = (*mqc->curctx)->nlps; | 268 *mqc->curctx = (*mqc->curctx)->nlps; |
269 opj_mqc_renorme(mqc); | 269 opj_mqc_renorme(mqc); |
270 } | 270 } |
271 | 271 |
272 void opj_mqc_setbits(opj_mqc_t *mqc) { | 272 static void opj_mqc_setbits(opj_mqc_t *mqc) { |
273 OPJ_UINT32 tempc = mqc->c + mqc->a; | 273 OPJ_UINT32 tempc = mqc->c + mqc->a; |
274 mqc->c |= 0xffff; | 274 mqc->c |= 0xffff; |
275 if (mqc->c >= tempc) { | 275 if (mqc->c >= tempc) { |
276 mqc->c -= 0x8000; | 276 mqc->c -= 0x8000; |
277 } | 277 } |
278 } | 278 } |
279 | 279 |
280 static INLINE OPJ_INT32 opj_mqc_mpsexchange(opj_mqc_t *const mqc) { | 280 static INLINE OPJ_INT32 opj_mqc_mpsexchange(opj_mqc_t *const mqc) { |
281 OPJ_INT32 d; | 281 OPJ_INT32 d; |
282 if (mqc->a < (*mqc->curctx)->qeval) { | 282 if (mqc->a < (*mqc->curctx)->qeval) { |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 for (i = 0; i < MQC_NUMCTXS; i++) { | 605 for (i = 0; i < MQC_NUMCTXS; i++) { |
606 mqc->ctxs[i] = mqc_states; | 606 mqc->ctxs[i] = mqc_states; |
607 } | 607 } |
608 } | 608 } |
609 | 609 |
610 void opj_mqc_setstate(opj_mqc_t *mqc, OPJ_UINT32 ctxno, OPJ_UINT32 msb, OPJ_INT3
2 prob) { | 610 void opj_mqc_setstate(opj_mqc_t *mqc, OPJ_UINT32 ctxno, OPJ_UINT32 msb, OPJ_INT3
2 prob) { |
611 mqc->ctxs[ctxno] = &mqc_states[msb + (OPJ_UINT32)(prob << 1)]; | 611 mqc->ctxs[ctxno] = &mqc_states[msb + (OPJ_UINT32)(prob << 1)]; |
612 } | 612 } |
613 | 613 |
614 | 614 |
OLD | NEW |