76 #include "jpc_mqcod.h"
85 #define JPC_NMSEDEC_BITS 7
86 #define JPC_NMSEDEC_FRACBITS (JPC_NMSEDEC_BITS - 1)
118 #define JPC_NESIG 0x0001
120 #define JPC_SESIG 0x0002
122 #define JPC_SWSIG 0x0004
124 #define JPC_NWSIG 0x0008
126 #define JPC_NSIG 0x0010
128 #define JPC_ESIG 0x0020
130 #define JPC_SSIG 0x0040
132 #define JPC_WSIG 0x0080
134 #define JPC_OTHSIGMSK \
135 (JPC_NSIG | JPC_NESIG | JPC_ESIG | JPC_SESIG | JPC_SSIG | JPC_SWSIG | JPC_WSIG | JPC_NWSIG)
137 #define JPC_PRIMSIGMSK (JPC_NSIG | JPC_ESIG | JPC_SSIG | JPC_WSIG)
140 #define JPC_NSGN 0x0100
142 #define JPC_ESGN 0x0200
144 #define JPC_SSGN 0x0400
146 #define JPC_WSGN 0x0800
148 #define JPC_SGNMSK (JPC_NSGN | JPC_ESGN | JPC_SSGN | JPC_WSGN)
151 #define JPC_SIG 0x1000
153 #define JPC_REFINE 0x2000
155 #define JPC_VISIT 0x4000
158 #define JPC_NUMAGGCTXS 1
160 #define JPC_NUMZCCTXS 9
162 #define JPC_NUMMAGCTXS 3
164 #define JPC_NUMSCCTXS 5
166 #define JPC_NUMUCTXS 1
169 #define JPC_AGGCTXNO 0
171 #define JPC_ZCCTXNO (JPC_AGGCTXNO + JPC_NUMAGGCTXS)
173 #define JPC_MAGCTXNO (JPC_ZCCTXNO + JPC_NUMZCCTXS)
175 #define JPC_SCCTXNO (JPC_MAGCTXNO + JPC_NUMMAGCTXS)
177 #define JPC_UCTXNO (JPC_SCCTXNO + JPC_NUMSCCTXS)
179 #define JPC_NUMCTXS (JPC_UCTXNO + JPC_NUMUCTXS)
187 extern uint_least8_t jpc_zcctxnolut[];
188 extern bool jpc_spblut[];
189 extern uint_least8_t jpc_scctxnolut[];
190 extern uint_least8_t jpc_magctxnolut[];
191 extern jpc_fix_t jpc_refnmsedec[];
192 extern jpc_fix_t jpc_signmsedec[];
193 extern jpc_fix_t jpc_refnmsedec0[];
194 extern jpc_fix_t jpc_signmsedec0[];
197 extern jpc_mqctx_t jpc_mqctxs[];
205 static inline jpc_fix_t JPC_ASR(jpc_fix_t x,
int n)
214 static inline uint_least8_t JPC_GETZCCTXNO(
unsigned f,
enum jpc_tsfb_orient orient)
216 return jpc_zcctxnolut[((unsigned)orient << 8) | (f & JPC_OTHSIGMSK)];
221 static inline bool JPC_GETSPB(
unsigned f)
223 return jpc_spblut[(f & (JPC_PRIMSIGMSK | JPC_SGNMSK)) >> 4];
228 static inline uint_least8_t JPC_GETSCCTXNO(
unsigned f)
230 return jpc_scctxnolut[(f & (JPC_PRIMSIGMSK | JPC_SGNMSK)) >> 4];
235 static inline uint_least8_t JPC_GETMAGCTXNO(
unsigned f)
237 return jpc_magctxnolut[(f & JPC_OTHSIGMSK) | (((f & JPC_REFINE) != 0) << 11)];
242 static inline jpc_fix_t JPC_GETSIGNMSEDEC(jpc_fix_t x,
int bitpos)
244 return bitpos > JPC_NMSEDEC_FRACBITS
245 ? jpc_signmsedec[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)]
246 : jpc_signmsedec0[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)];
251 static inline jpc_fix_t JPC_GETREFNMSEDEC(jpc_fix_t x,
int bitpos)
253 return bitpos > JPC_NMSEDEC_FRACBITS
254 ? jpc_refnmsedec[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)]
255 : jpc_refnmsedec0[JPC_ASR(x, bitpos - JPC_NMSEDEC_FRACBITS) & JAS_ONES(JPC_NMSEDEC_BITS)];
259 static inline void JPC_UPDATEFLAGS4(jpc_fix_t *fp,
unsigned rowstep,
bool s,
bool vcausalflag)
261 jpc_fix_t *np = fp - rowstep;
262 jpc_fix_t *sp = fp + rowstep;
267 *sp |= JPC_NSIG | JPC_NSGN;
268 fp[-1] |= JPC_ESIG | JPC_ESGN;
269 fp[1] |= JPC_WSIG | JPC_WSGN;
281 *np |= JPC_SSIG | JPC_SSGN;
282 *sp |= JPC_NSIG | JPC_NSGN;
283 fp[-1] |= JPC_ESIG | JPC_ESGN;
284 fp[1] |= JPC_WSIG | JPC_WSGN;
295 void jpc_initluts(
void);
299 unsigned JPC_NOMINALGAIN(
unsigned qmfbid,
unsigned numlvls,
unsigned lvlno,
enum jpc_tsfb_orient orient);
303 enum jpc_passtype JPC_PASSTYPE(
unsigned passno);
307 enum jpc_segtype JPC_SEGTYPE(
unsigned passno,
unsigned firstpassno,
bool bypass);
311 unsigned JPC_SEGPASSCNT(
unsigned passno,
unsigned firstpassno,
unsigned numpasses,
bool bypass,
316 bool JPC_ISTERMINATED(
unsigned passno,
unsigned firstpassno,
unsigned numpasses,
bool termall,