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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 | 489 |
490 *nmsedec = 0; | 490 *nmsedec = 0; |
491 one = 1 << (bpno + T1_NMSEDEC_FRACBITS); | 491 one = 1 << (bpno + T1_NMSEDEC_FRACBITS); |
492 for (k = 0; k < t1->h; k += 4) { | 492 for (k = 0; k < t1->h; k += 4) { |
493 for (i = 0; i < t1->w; ++i) { | 493 for (i = 0; i < t1->w; ++i) { |
494 for (j = k; j < k + 4 && j < t1->h; ++j) { | 494 for (j = k; j < k + 4 && j < t1->h; ++j) { |
495 vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j ==
k + 3 || j == t1->h - 1)) ? 1 : 0; | 495 vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j ==
k + 3 || j == t1->h - 1)) ? 1 : 0; |
496 opj_t1_enc_sigpass_step( | 496 opj_t1_enc_sigpass_step( |
497 t1, | 497 t1, |
498 &t1->flags[((j+1) * t1->flags_st
ride) + i + 1], | 498 &t1->flags[((j+1) * t1->flags_st
ride) + i + 1], |
499 » » » » » » &t1->data[(j * t1->w) + i], | 499 » » » » » » &t1->data[(j * t1->data_stride)
+ i], |
500 orient, | 500 orient, |
501 bpno, | 501 bpno, |
502 one, | 502 one, |
503 nmsedec, | 503 nmsedec, |
504 type, | 504 type, |
505 vsc); | 505 vsc); |
506 } | 506 } |
507 } | 507 } |
508 } | 508 } |
509 } | 509 } |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 | 711 |
712 *nmsedec = 0; | 712 *nmsedec = 0; |
713 one = 1 << (bpno + T1_NMSEDEC_FRACBITS); | 713 one = 1 << (bpno + T1_NMSEDEC_FRACBITS); |
714 for (k = 0; k < t1->h; k += 4) { | 714 for (k = 0; k < t1->h; k += 4) { |
715 for (i = 0; i < t1->w; ++i) { | 715 for (i = 0; i < t1->w; ++i) { |
716 for (j = k; j < k + 4 && j < t1->h; ++j) { | 716 for (j = k; j < k + 4 && j < t1->h; ++j) { |
717 vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j ==
k + 3 || j == t1->h - 1)) ? 1 : 0; | 717 vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j ==
k + 3 || j == t1->h - 1)) ? 1 : 0; |
718 opj_t1_enc_refpass_step( | 718 opj_t1_enc_refpass_step( |
719 t1, | 719 t1, |
720 &t1->flags[((j+1) * t1->flags_st
ride) + i + 1], | 720 &t1->flags[((j+1) * t1->flags_st
ride) + i + 1], |
721 » » » » » » &t1->data[(j * t1->w) + i], | 721 » » » » » » &t1->data[(j * t1->data_stride)
+ i], |
722 bpno, | 722 bpno, |
723 one, | 723 one, |
724 nmsedec, | 724 nmsedec, |
725 type, | 725 type, |
726 vsc); | 726 vsc); |
727 } | 727 } |
728 } | 728 } |
729 } | 729 } |
730 } | 730 } |
731 | 731 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 agg = !(MACRO_t1_flags(1 + k,1 + i) & (T
1_SIG | T1_VISIT | T1_SIG_OTH) | 963 agg = !(MACRO_t1_flags(1 + k,1 + i) & (T
1_SIG | T1_VISIT | T1_SIG_OTH) |
964 || MACRO_t1_flags(1 + k + 1,1 +
i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) | 964 || MACRO_t1_flags(1 + k + 1,1 +
i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) |
965 || MACRO_t1_flags(1 + k + 2,1 +
i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) | 965 || MACRO_t1_flags(1 + k + 2,1 +
i) & (T1_SIG | T1_VISIT | T1_SIG_OTH) |
966 || MACRO_t1_flags(1 + k + 3,1 +
i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)); | 966 || MACRO_t1_flags(1 + k + 3,1 +
i) & (T1_SIG | T1_VISIT | T1_SIG_OTH)); |
967 } | 967 } |
968 } else { | 968 } else { |
969 agg = 0; | 969 agg = 0; |
970 } | 970 } |
971 if (agg) { | 971 if (agg) { |
972 for (runlen = 0; runlen < 4; ++runlen) { | 972 for (runlen = 0; runlen < 4; ++runlen) { |
973 » » » » » if (opj_int_abs(t1->data[((k + runlen)*t
1->w) + i]) & one) | 973 » » » » » if (opj_int_abs(t1->data[((k + runlen)*t
1->data_stride) + i]) & one) |
974 break; | 974 break; |
975 } | 975 } |
976 opj_mqc_setcurctx(mqc, T1_CTXNO_AGG); | 976 opj_mqc_setcurctx(mqc, T1_CTXNO_AGG); |
977 opj_mqc_encode(mqc, runlen != 4); | 977 opj_mqc_encode(mqc, runlen != 4); |
978 if (runlen == 4) { | 978 if (runlen == 4) { |
979 continue; | 979 continue; |
980 } | 980 } |
981 opj_mqc_setcurctx(mqc, T1_CTXNO_UNI); | 981 opj_mqc_setcurctx(mqc, T1_CTXNO_UNI); |
982 opj_mqc_encode(mqc, runlen >> 1); | 982 opj_mqc_encode(mqc, runlen >> 1); |
983 opj_mqc_encode(mqc, runlen & 1); | 983 opj_mqc_encode(mqc, runlen & 1); |
984 } else { | 984 } else { |
985 runlen = 0; | 985 runlen = 0; |
986 } | 986 } |
987 for (j = k + runlen; j < k + 4 && j < t1->h; ++j) { | 987 for (j = k + runlen; j < k + 4 && j < t1->h; ++j) { |
988 vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j ==
k + 3 || j == t1->h - 1)) ? 1 : 0; | 988 vsc = ((cblksty & J2K_CCP_CBLKSTY_VSC) && (j ==
k + 3 || j == t1->h - 1)) ? 1 : 0; |
989 opj_t1_enc_clnpass_step( | 989 opj_t1_enc_clnpass_step( |
990 t1, | 990 t1, |
991 &t1->flags[((j+1) * t1->flags_st
ride) + i + 1], | 991 &t1->flags[((j+1) * t1->flags_st
ride) + i + 1], |
992 » » » » » » &t1->data[(j * t1->w) + i], | 992 » » » » » » &t1->data[(j * t1->data_stride)
+ i], |
993 orient, | 993 orient, |
994 bpno, | 994 bpno, |
995 one, | 995 one, |
996 nmsedec, | 996 nmsedec, |
997 agg && (j == k + runlen), | 997 agg && (j == k + runlen), |
998 vsc); | 998 vsc); |
999 } | 999 } |
1000 } | 1000 } |
1001 } | 1001 } |
1002 } | 1002 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 } | 1159 } |
1160 | 1160 |
1161 OPJ_BOOL opj_t1_allocate_buffers( | 1161 OPJ_BOOL opj_t1_allocate_buffers( |
1162 opj_t1_t *t1, | 1162 opj_t1_t *t1, |
1163 OPJ_UINT32 w, | 1163 OPJ_UINT32 w, |
1164 OPJ_UINT32 h) | 1164 OPJ_UINT32 h) |
1165 { | 1165 { |
1166 OPJ_UINT32 datasize=w * h; | 1166 OPJ_UINT32 datasize=w * h; |
1167 OPJ_UINT32 flagssize; | 1167 OPJ_UINT32 flagssize; |
1168 | 1168 |
1169 » if(datasize > t1->datasize){ | 1169 » /* encoder uses tile buffer, so no need to allocate */ |
1170 » » opj_aligned_free(t1->data); | 1170 » if (!t1->encoder) { |
1171 » » t1->data = (OPJ_INT32*) opj_aligned_malloc(datasize * sizeof(OPJ
_INT32)); | 1171 » » if(datasize > t1->datasize){ |
1172 » » if(!t1->data){ | 1172 » » » opj_aligned_free(t1->data); |
1173 » » » /* FIXME event manager error callback */ | 1173 » » » t1->data = (OPJ_INT32*) opj_aligned_malloc(datasize * si
zeof(OPJ_INT32)); |
1174 » » » return OPJ_FALSE; | 1174 » » » if(!t1->data){ |
| 1175 » » » » /* FIXME event manager error callback */ |
| 1176 » » » » return OPJ_FALSE; |
| 1177 » » » } |
| 1178 » » » t1->datasize=datasize; |
1175 } | 1179 } |
1176 » » t1->datasize=datasize; | 1180 » » memset(t1->data,0,datasize * sizeof(OPJ_INT32)); |
1177 } | 1181 } |
1178 memset(t1->data,0,datasize * sizeof(OPJ_INT32)); | |
1179 | |
1180 t1->flags_stride=w+2; | 1182 t1->flags_stride=w+2; |
1181 flagssize=t1->flags_stride * (h+2); | 1183 flagssize=t1->flags_stride * (h+2); |
1182 | 1184 |
1183 if(flagssize > t1->flagssize){ | 1185 if(flagssize > t1->flagssize){ |
1184 opj_aligned_free(t1->flags); | 1186 opj_aligned_free(t1->flags); |
1185 t1->flags = (opj_flag_t*) opj_aligned_malloc(flagssize * sizeof(
opj_flag_t)); | 1187 t1->flags = (opj_flag_t*) opj_aligned_malloc(flagssize * sizeof(
opj_flag_t)); |
1186 if(!t1->flags){ | 1188 if(!t1->flags){ |
1187 /* FIXME event manager error callback */ | 1189 /* FIXME event manager error callback */ |
1188 return OPJ_FALSE; | 1190 return OPJ_FALSE; |
1189 } | 1191 } |
1190 t1->flagssize=flagssize; | 1192 t1->flagssize=flagssize; |
1191 } | 1193 } |
1192 memset(t1->flags,0,flagssize * sizeof(opj_flag_t)); | 1194 memset(t1->flags,0,flagssize * sizeof(opj_flag_t)); |
1193 | 1195 |
1194 t1->w=w; | 1196 t1->w=w; |
1195 t1->h=h; | 1197 t1->h=h; |
1196 | 1198 |
1197 return OPJ_TRUE; | 1199 return OPJ_TRUE; |
1198 } | 1200 } |
1199 | 1201 |
1200 /* ----------------------------------------------------------------------- */ | 1202 /* ----------------------------------------------------------------------- */ |
1201 | 1203 |
1202 /* ----------------------------------------------------------------------- */ | 1204 /* ----------------------------------------------------------------------- */ |
1203 /** | 1205 /** |
1204 * Creates a new Tier 1 handle | 1206 * Creates a new Tier 1 handle |
1205 * and initializes the look-up tables of the Tier-1 coder/decoder | 1207 * and initializes the look-up tables of the Tier-1 coder/decoder |
1206 * @return a new T1 handle if successful, returns NULL otherwise | 1208 * @return a new T1 handle if successful, returns NULL otherwise |
1207 */ | 1209 */ |
1208 opj_t1_t* opj_t1_create() | 1210 opj_t1_t* opj_t1_create(OPJ_BOOL isEncoder) |
1209 { | 1211 { |
1210 opj_t1_t *l_t1 = 00; | 1212 opj_t1_t *l_t1 = 00; |
1211 | 1213 |
1212 l_t1 = (opj_t1_t*) opj_calloc(1,sizeof(opj_t1_t)); | 1214 l_t1 = (opj_t1_t*) opj_calloc(1,sizeof(opj_t1_t)); |
1213 if (!l_t1) { | 1215 if (!l_t1) { |
1214 return 00; | 1216 return 00; |
1215 } | 1217 } |
1216 | 1218 |
1217 /* create MQC and RAW handles */ | 1219 /* create MQC and RAW handles */ |
1218 l_t1->mqc = opj_mqc_create(); | 1220 l_t1->mqc = opj_mqc_create(); |
1219 if (! l_t1->mqc) { | 1221 if (! l_t1->mqc) { |
1220 opj_t1_destroy(l_t1); | 1222 opj_t1_destroy(l_t1); |
1221 return 00; | 1223 return 00; |
1222 } | 1224 } |
1223 | 1225 |
1224 l_t1->raw = opj_raw_create(); | 1226 l_t1->raw = opj_raw_create(); |
1225 if (! l_t1->raw) { | 1227 if (! l_t1->raw) { |
1226 opj_t1_destroy(l_t1); | 1228 opj_t1_destroy(l_t1); |
1227 return 00; | 1229 return 00; |
1228 } | 1230 } |
| 1231 l_t1->encoder = isEncoder; |
1229 | 1232 |
1230 return l_t1; | 1233 return l_t1; |
1231 } | 1234 } |
1232 | 1235 |
1233 | 1236 |
1234 /** | 1237 /** |
1235 * Destroys a previously created T1 handle | 1238 * Destroys a previously created T1 handle |
1236 * | 1239 * |
1237 * @param p_t1 Tier 1 handle to destroy | 1240 * @param p_t1 Tier 1 handle to destroy |
1238 */ | 1241 */ |
1239 void opj_t1_destroy(opj_t1_t *p_t1) | 1242 void opj_t1_destroy(opj_t1_t *p_t1) |
1240 { | 1243 { |
1241 if (! p_t1) { | 1244 if (! p_t1) { |
1242 return; | 1245 return; |
1243 } | 1246 } |
1244 | 1247 |
1245 /* destroy MQC and RAW handles */ | 1248 /* destroy MQC and RAW handles */ |
1246 opj_mqc_destroy(p_t1->mqc); | 1249 opj_mqc_destroy(p_t1->mqc); |
1247 p_t1->mqc = 00; | 1250 p_t1->mqc = 00; |
1248 opj_raw_destroy(p_t1->raw); | 1251 opj_raw_destroy(p_t1->raw); |
1249 p_t1->raw = 00; | 1252 p_t1->raw = 00; |
1250 | 1253 |
1251 if (p_t1->data) { | 1254 » /* encoder uses tile buffer, so no need to free */ |
| 1255 » if (!p_t1->encoder && p_t1->data) { |
1252 opj_aligned_free(p_t1->data); | 1256 opj_aligned_free(p_t1->data); |
1253 p_t1->data = 00; | 1257 p_t1->data = 00; |
1254 } | 1258 } |
1255 | 1259 |
1256 if (p_t1->flags) { | 1260 if (p_t1->flags) { |
1257 opj_aligned_free(p_t1->flags); | 1261 opj_aligned_free(p_t1->flags); |
1258 p_t1->flags = 00; | 1262 p_t1->flags = 00; |
1259 } | 1263 } |
1260 | 1264 |
1261 opj_free(p_t1); | 1265 opj_free(p_t1); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 | 1479 |
1476 for (bandno = 0; bandno < res->numbands; ++bandno) { | 1480 for (bandno = 0; bandno < res->numbands; ++bandno) { |
1477 opj_tcd_band_t* restrict band = &res->bands[band
no]; | 1481 opj_tcd_band_t* restrict band = &res->bands[band
no]; |
1478 OPJ_INT32 bandconst = 8192 * 8192 / ((OPJ_INT32) floor(band->ste
psize * 8192)); | 1482 OPJ_INT32 bandconst = 8192 * 8192 / ((OPJ_INT32) floor(band->ste
psize * 8192)); |
1479 | 1483 |
1480 for (precno = 0; precno < res->pw * res->ph; ++p
recno) { | 1484 for (precno = 0; precno < res->pw * res->ph; ++p
recno) { |
1481 opj_tcd_precinct_t *prc = &band->precinc
ts[precno]; | 1485 opj_tcd_precinct_t *prc = &band->precinc
ts[precno]; |
1482 | 1486 |
1483 for (cblkno = 0; cblkno < prc->cw * prc-
>ch; ++cblkno) { | 1487 for (cblkno = 0; cblkno < prc->cw * prc-
>ch; ++cblkno) { |
1484 opj_tcd_cblk_enc_t* cblk = &prc-
>cblks.enc[cblkno]; | 1488 opj_tcd_cblk_enc_t* cblk = &prc-
>cblks.enc[cblkno]; |
1485 OPJ_INT32 * restrict datap; | |
1486 OPJ_INT32* restrict tiledp; | 1489 OPJ_INT32* restrict tiledp; |
1487 OPJ_UINT32 cblk_w; | 1490 OPJ_UINT32 cblk_w; |
1488 OPJ_UINT32 cblk_h; | 1491 OPJ_UINT32 cblk_h; |
1489 » » » » » » OPJ_UINT32 i, j; | 1492 » » » » » » OPJ_UINT32 i, j, tileIndex=0, ti
leLineAdvance; |
1490 | 1493 |
1491 OPJ_INT32 x = cblk->x0 - band->x
0; | 1494 OPJ_INT32 x = cblk->x0 - band->x
0; |
1492 OPJ_INT32 y = cblk->y0 - band->y
0; | 1495 OPJ_INT32 y = cblk->y0 - band->y
0; |
1493 if (band->bandno & 1) { | 1496 if (band->bandno & 1) { |
1494 opj_tcd_resolution_t *pr
es = &tilec->resolutions[resno - 1]; | 1497 opj_tcd_resolution_t *pr
es = &tilec->resolutions[resno - 1]; |
1495 x += pres->x1 - pres->x0
; | 1498 x += pres->x1 - pres->x0
; |
1496 } | 1499 } |
1497 if (band->bandno & 2) { | 1500 if (band->bandno & 2) { |
1498 opj_tcd_resolution_t *pr
es = &tilec->resolutions[resno - 1]; | 1501 opj_tcd_resolution_t *pr
es = &tilec->resolutions[resno - 1]; |
1499 y += pres->y1 - pres->y0
; | 1502 y += pres->y1 - pres->y0
; |
1500 } | 1503 } |
1501 | 1504 |
1502 if(!opj_t1_allocate_buffers( | 1505 if(!opj_t1_allocate_buffers( |
1503 t1, | 1506 t1, |
1504 (OPJ_UIN
T32)(cblk->x1 - cblk->x0), | 1507 (OPJ_UIN
T32)(cblk->x1 - cblk->x0), |
1505 (OPJ_UIN
T32)(cblk->y1 - cblk->y0))) | 1508 (OPJ_UIN
T32)(cblk->y1 - cblk->y0))) |
1506 { | 1509 { |
1507 return OPJ_FALSE; | 1510 return OPJ_FALSE; |
1508 } | 1511 } |
1509 | 1512 |
1510 datap=t1->data; | |
1511 cblk_w = t1->w; | 1513 cblk_w = t1->w; |
1512 cblk_h = t1->h; | 1514 cblk_h = t1->h; |
| 1515 tileLineAdvance = tile_w - cblk_
w; |
1513 | 1516 |
1514 tiledp=&tilec->data[(OPJ_UINT32)
y * tile_w + (OPJ_UINT32)x]; | 1517 tiledp=&tilec->data[(OPJ_UINT32)
y * tile_w + (OPJ_UINT32)x]; |
| 1518 t1->data = tiledp; |
| 1519 t1->data_stride = tile_w; |
1515 if (tccp->qmfbid == 1) { | 1520 if (tccp->qmfbid == 1) { |
1516 for (j = 0; j < cblk_h;
++j) { | 1521 for (j = 0; j < cblk_h;
++j) { |
1517 for (i = 0; i <
cblk_w; ++i) { | 1522 for (i = 0; i <
cblk_w; ++i) { |
1518 » » » » » » » » » OPJ_INT3
2 tmp = tiledp[(j * tile_w) + i]; | 1523 » » » » » » » » » tiledp[t
ileIndex] <<= T1_NMSEDEC_FRACBITS; |
1519 » » » » » » » » » datap[(j
* cblk_w) + i] = tmp << T1_NMSEDEC_FRACBITS; | 1524 » » » » » » » » » tileInde
x++; |
1520 } | 1525 } |
| 1526 tileIndex += til
eLineAdvance; |
1521 } | 1527 } |
1522 } else { /* if (t
ccp->qmfbid == 0) */ | 1528 } else { /* if (t
ccp->qmfbid == 0) */ |
1523 for (j = 0; j < cblk_h;
++j) { | 1529 for (j = 0; j < cblk_h;
++j) { |
1524 for (i = 0; i <
cblk_w; ++i) { | 1530 for (i = 0; i <
cblk_w; ++i) { |
1525 » » » » » » » » » OPJ_INT3
2 tmp = tiledp[(j * tile_w) + i]; | 1531 » » » » » » » » » OPJ_INT3
2 tmp = tiledp[tileIndex]; |
1526 » » » » » » » » » datap[(j
* cblk_w) + i] = | 1532 » » » » » » » » » tiledp[t
ileIndex] = |
1527
opj_int_fix_mul( | 1533
opj_int_fix_mul( |
1528
tmp, | 1534
tmp, |
1529
bandconst) >> (11 - T1_NMSEDEC_FRACBITS); | 1535
bandconst) >> (11 - T1_NMSEDEC_FRACBITS); |
| 1536 tileInde
x++; |
1530 } | 1537 } |
| 1538 tileIndex += til
eLineAdvance; |
1531 } | 1539 } |
1532 } | 1540 } |
1533 | 1541 |
1534 opj_t1_encode_cblk( | 1542 opj_t1_encode_cblk( |
1535 t1, | 1543 t1, |
1536 cblk, | 1544 cblk, |
1537 band->bandno, | 1545 band->bandno, |
1538 compno, | 1546 compno, |
1539 tilec->numresolu
tions - 1 - resno, | 1547 tilec->numresolu
tions - 1 - resno, |
1540 tccp->qmfbid, | 1548 tccp->qmfbid, |
(...skipping 26 matching lines...) Expand all Loading... |
1567 { | 1575 { |
1568 OPJ_FLOAT64 cumwmsedec = 0.0; | 1576 OPJ_FLOAT64 cumwmsedec = 0.0; |
1569 | 1577 |
1570 opj_mqc_t *mqc = t1->mqc; /* MQC component */ | 1578 opj_mqc_t *mqc = t1->mqc; /* MQC component */ |
1571 | 1579 |
1572 OPJ_UINT32 passno; | 1580 OPJ_UINT32 passno; |
1573 OPJ_INT32 bpno; | 1581 OPJ_INT32 bpno; |
1574 OPJ_UINT32 passtype; | 1582 OPJ_UINT32 passtype; |
1575 OPJ_INT32 nmsedec = 0; | 1583 OPJ_INT32 nmsedec = 0; |
1576 OPJ_INT32 max; | 1584 OPJ_INT32 max; |
1577 » OPJ_UINT32 i; | 1585 » OPJ_UINT32 i, j; |
1578 OPJ_BYTE type = T1_TYPE_MQ; | 1586 OPJ_BYTE type = T1_TYPE_MQ; |
1579 OPJ_FLOAT64 tempwmsedec; | 1587 OPJ_FLOAT64 tempwmsedec; |
1580 | 1588 |
1581 max = 0; | 1589 max = 0; |
1582 » for (i = 0; i < t1->w * t1->h; ++i) { | 1590 » for (i = 0; i < t1->w; ++i) { |
1583 » » OPJ_INT32 tmp = abs(t1->data[i]); | 1591 » » for (j = 0; j < t1->h; ++j) { |
1584 » » max = opj_int_max(max, tmp); | 1592 » » » OPJ_INT32 tmp = abs(t1->data[i + j*t1->data_stride]); |
| 1593 » » » max = opj_int_max(max, tmp); |
| 1594 » » } |
1585 } | 1595 } |
1586 | 1596 |
1587 cblk->numbps = max ? (OPJ_UINT32)((opj_int_floorlog2(max) + 1) - T1_NMSE
DEC_FRACBITS) : 0; | 1597 cblk->numbps = max ? (OPJ_UINT32)((opj_int_floorlog2(max) + 1) - T1_NMSE
DEC_FRACBITS) : 0; |
1588 | 1598 |
1589 bpno = (OPJ_INT32)(cblk->numbps - 1); | 1599 bpno = (OPJ_INT32)(cblk->numbps - 1); |
1590 passtype = 2; | 1600 passtype = 2; |
1591 | 1601 |
1592 opj_mqc_resetstates(mqc); | 1602 opj_mqc_resetstates(mqc); |
1593 opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46); | 1603 opj_mqc_setstate(mqc, T1_CTXNO_UNI, 0, 46); |
1594 opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3); | 1604 opj_mqc_setstate(mqc, T1_CTXNO_AGG, 0, 3); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1749 opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag))
; | 1759 opj_mqc_setcurctx(mqc, opj_t1_getctxno_sc(flag))
; |
1750 v = opj_mqc_decode(mqc) ^ opj_t1_getspb(flag); | 1760 v = opj_mqc_decode(mqc) ^ opj_t1_getspb(flag); |
1751 *datap = v ? -oneplushalf : oneplushalf; | 1761 *datap = v ? -oneplushalf : oneplushalf; |
1752 opj_t1_updateflags(flagsp, v, t1->flags_stride); | 1762 opj_t1_updateflags(flagsp, v, t1->flags_stride); |
1753 } | 1763 } |
1754 } | 1764 } |
1755 *flagsp |= T1_VISIT; | 1765 *flagsp |= T1_VISIT; |
1756 } | 1766 } |
1757 } /* VSC and BYPASS by Antonin */ | 1767 } /* VSC and BYPASS by Antonin */ |
1758 #endif | 1768 #endif |
OLD | NEW |