76 #include "jpc_mqcod.h"
83 #define JPC_NMSEDEC_BITS 7
84 #define JPC_NMSEDEC_FRACBITS (JPC_NMSEDEC_BITS - 1)
91 #define JPC_SEG_INVALID 0
101 #define JPC_SIGPASS 0
102 #define JPC_REFPASS 1
103 #define JPC_CLNPASS 2
110 #define JPC_NESIG 0x0001
112 #define JPC_SESIG 0x0002
114 #define JPC_SWSIG 0x0004
116 #define JPC_NWSIG 0x0008
118 #define JPC_NSIG 0x0010
120 #define JPC_ESIG 0x0020
122 #define JPC_SSIG 0x0040
124 #define JPC_WSIG 0x0080
126 #define JPC_OTHSIGMSK \
127 (JPC_NSIG | JPC_NESIG | JPC_ESIG | JPC_SESIG | JPC_SSIG | JPC_SWSIG | JPC_WSIG | JPC_NWSIG)
129 #define JPC_PRIMSIGMSK (JPC_NSIG | JPC_ESIG | JPC_SSIG | JPC_WSIG)
132 #define JPC_NSGN 0x0100
134 #define JPC_ESGN 0x0200
136 #define JPC_SSGN 0x0400
138 #define JPC_WSGN 0x0800
140 #define JPC_SGNMSK (JPC_NSGN | JPC_ESGN | JPC_SSGN | JPC_WSGN)
143 #define JPC_SIG 0x1000
145 #define JPC_REFINE 0x2000
147 #define JPC_VISIT 0x4000
150 #define JPC_NUMAGGCTXS 1
152 #define JPC_NUMZCCTXS 9
154 #define JPC_NUMMAGCTXS 3
156 #define JPC_NUMSCCTXS 5
158 #define JPC_NUMUCTXS 1
161 #define JPC_AGGCTXNO 0
163 #define JPC_ZCCTXNO (JPC_AGGCTXNO + JPC_NUMAGGCTXS)
165 #define JPC_MAGCTXNO (JPC_ZCCTXNO + JPC_NUMZCCTXS)
167 #define JPC_SCCTXNO (JPC_MAGCTXNO + JPC_NUMMAGCTXS)
169 #define JPC_UCTXNO (JPC_SCCTXNO + JPC_NUMSCCTXS)
171 #define JPC_NUMCTXS (JPC_UCTXNO + JPC_NUMUCTXS)
179 extern uint_least8_t jpc_zcctxnolut[];
180 extern bool jpc_spblut[];
181 extern uint_least8_t jpc_scctxnolut[];
182 extern uint_least8_t jpc_magctxnolut[];
183 extern jpc_fix_t jpc_refnmsedec[];
184 extern jpc_fix_t jpc_signmsedec[];
185 extern jpc_fix_t jpc_refnmsedec0[];
186 extern jpc_fix_t jpc_signmsedec0[];
189 extern jpc_mqctx_t jpc_mqctxs[];
197 static inline jpc_fix_t JPC_ASR(jpc_fix_t x,
int n)
206 static inline uint_least8_t JPC_GETZCCTXNO(
unsigned f,
unsigned orient)
208 return jpc_zcctxnolut[(orient << 8) | (f & JPC_OTHSIGMSK)];
213 static inline bool JPC_GETSPB(
unsigned f)
215 return jpc_spblut[(f & (JPC_PRIMSIGMSK | JPC_SGNMSK)) >> 4];
220 static inline uint_least8_t JPC_GETSCCTXNO(
unsigned f)
222 return jpc_scctxnolut[(f & (JPC_PRIMSIGMSK | JPC_SGNMSK)) >> 4];
227 static inline uint_least8_t JPC_GETMAGCTXNO(
unsigned f)
229 return jpc_magctxnolut[(f & JPC_OTHSIGMSK) | (((f & JPC_REFINE) != 0) << 11)];
234 static inline jpc_fix_t JPC_GETSIGNMSEDEC(jpc_fix_t x,
int bitpos)
236 return bitpos > JPC_NMSEDEC_FRACBITS
237 ? jpc_signmsedec[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)]
238 : jpc_signmsedec0[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)];
243 static inline jpc_fix_t JPC_GETREFNMSEDEC(jpc_fix_t x,
int bitpos)
245 return bitpos > JPC_NMSEDEC_FRACBITS
246 ? jpc_refnmsedec[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)]
247 : jpc_refnmsedec0[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)];
251 static inline void JPC_UPDATEFLAGS4(jpc_fix_t *fp,
unsigned rowstep,
bool s,
bool vcausalflag)
253 jpc_fix_t *np = fp - rowstep;
254 jpc_fix_t *sp = fp + rowstep;
259 *sp |= JPC_NSIG | JPC_NSGN;
260 fp[-1] |= JPC_ESIG | JPC_ESGN;
261 fp[1] |= JPC_WSIG | JPC_WSGN;
273 *np |= JPC_SSIG | JPC_SSGN;
274 *sp |= JPC_NSIG | JPC_NSGN;
275 fp[-1] |= JPC_ESIG | JPC_ESGN;
276 fp[1] |= JPC_WSIG | JPC_WSGN;
287 void jpc_initluts(
void);
291 int JPC_NOMINALGAIN(
int qmfbid,
int numlvls,
int lvlno,
int orient);
295 int JPC_PASSTYPE(
int passno);
299 int JPC_SEGTYPE(
int passno,
int firstpassno,
int bypass);
303 int JPC_SEGPASSCNT(
int passno,
int firstpassno,
int numpasses,
int bypass,
308 int JPC_ISTERMINATED(
int passno,
int firstpassno,
int numpasses,
int termall,