// Simplified transform when only in[0], in[1] and in[4] are non-zero static void TransformAC3(const int16_t* in, uint8_t* dst) { const int a = in[0] + 4; const int c4 = MUL(in[4], kC2); const int d4 = MUL(in[4], kC1); const int c1 = MUL(in[1], kC2); const int d1 = MUL(in[1], kC1); STORE2(0, a + d4, d1, c1); STORE2(1, a + c4, d1, c1); STORE2(2, a - c4, d1, c1); STORE2(3, a - d4, d1, c1); }
/* * NAME: make_grammar() * DESCRIPTION: create a pre-processed grammar string */ static string *make_grammar(rule *rgxlist, rule *strlist, rule *estrlist, rule *prodlist, int nrgx, int nstr, int nestr, int nprod, long size) { int start, prod1; string *gram; char *p, *q; rule *rl, *r; rulesym *rs; int n; gram = str_new((char *) NULL, size); /* header */ p = gram->text; *p++ = GRAM_VERSION; /* version number */ STORE2(p, -1); p += 2; /* whitespace rule */ STORE2(p, -1); p += 2; /* nomatch rule */ STORE2(p, nrgx); p += 4; /* # regular expression rules */ STORE2(p, nstr); p += 2; /* # string rules */ STORE2(p, nestr); p += 2; /* # escaped string rules */ nprod++; /* +1 for start rule */ STORE2(p, nprod); /* # production rules */ n = nrgx + nstr + nestr + nprod; prod1 = nrgx + nstr + nestr + 1; q = p + 4 + ((n + nstr) << 1); p = gram->text + size; /* determine production rule offsets */ for (rl = prodlist; rl != (rule *) NULL; rl = rl->next) { size -= (rl->num << 1) + rl->len + 2; p -= (rl->num << 1) + rl->len + 2; q -= 2; STORE2(q, size); STORE2(p, rl->num); rl->num = --n; rl->len = size; } /* start rule offset */ size -= 6; p -= 6; q -= 2; STORE2(q, size); --n; start = size; /* deal with strings */ for (rl = estrlist; rl != (rule *) NULL; rl = rl->next) { size -= rl->symb->len + 1; p -= rl->symb->len + 1; q -= 2; STORE2(q, size); rl->num = --n; *p = rl->symb->len; memcpy(p + 1, rl->symb->text, rl->symb->len); } for (rl = strlist; rl != (rule *) NULL; rl = rl->next) { *--q = rl->symb->len; q -= 3; STORE3(q, rl->len); rl->num = --n; } /* deal with regexps */ nrgx = 0; for (rl = rgxlist; rl != (rule *) NULL; rl = rl->next) { size -= rl->num + rl->len + 2; q -= 2; STORE2(q, size); p = gram->text + size; STORE2(p, rl->num); rl->num = --n; p += 2; for (r = rl; r != (rule *) NULL; r = r->alt) { if (r->u.rgx != (string *) NULL) { *p++ = r->u.rgx->len; memcpy(p, r->u.rgx->text, r->u.rgx->len); p += r->u.rgx->len; nrgx++; } else { /* nomatch */ STORE2(gram->text + 3, n); } } if (rl->symb->len == 10 && strcmp(rl->symb->text, "whitespace") == 0) { p = gram->text + 1; STORE2(p, n); } } p = gram->text + 7; STORE2(p, nrgx); /* total regular expressions */ /* fill in production rules */ nprod = 1; for (rl = prodlist; rl != (rule *) NULL; rl = rl->next) { q = gram->text + rl->len + 2; for (r = rl; r != (rule *) NULL; r = r->alt) { p = q + 2; n = 0; for (rs = r->u.syms; rs != (rulesym *) NULL; rs = rs->next) { STORE2(p, rs->rule->num); p += 2; n++; } if (r->func != (string *) NULL) { memcpy(p, r->func->text, r->func->len + 1); p += r->func->len + 1; } *q++ = n; *q = p - q - 1; q = p; nprod++; } } /* start rule */ p = gram->text + start; *p++ = 0; *p++ = 1; *p++ = 1; *p++ = 2; *p++ = prod1 >> 8; *p = prod1; p = gram->text + 15; STORE2(p, nprod); return gram; }
mlib_status mlib_c_conv2x2ext_u8( mlib_image *dst, const mlib_image *src, mlib_s32 dx_l, mlib_s32 dx_r, mlib_s32 dy_t, mlib_s32 dy_b, const mlib_s32 *kern, mlib_s32 scalef_expon, mlib_s32 cmask) { mlib_d64 buff_arr[4 * BUFF_LINE]; mlib_s32 *pbuff = (mlib_s32 *)buff_arr, *buff0, *buff1, *buff2, *buffT; DTYPE *adr_src, *sl, *sp, *sl1; DTYPE *adr_dst, *dl, *dp; mlib_d64 k0, k1, k2, k3, scalef = 1.0; mlib_d64 p00, p01, p02, p10, p11, p12; mlib_s32 wid, hgt, sll, dll, wid1; mlib_s32 nchannel, chan1, chan2; mlib_s32 i, j, c, swid; LOAD_KERNEL_INTO_DOUBLE(); GET_SRC_DST_PARAMETERS(DTYPE); vis_write_gsr(23 << 3); swid = wid + D_KER; wid1 = (swid + 1) & ~1; if (wid1 > BUFF_LINE) { pbuff = __mlib_malloc(4 * sizeof (mlib_s32) * wid1); if (pbuff == NULL) return (MLIB_FAILURE); } buff0 = pbuff; buff1 = buff0 + wid1; buff2 = buff1 + wid1; chan1 = nchannel; chan2 = chan1 + chan1; swid -= dx_r; for (c = 0; c < nchannel; c++) { if (!(cmask & (1 << (nchannel - 1 - c)))) continue; sl = adr_src + c; dl = adr_dst + c; if ((hgt - dy_b) > 0) sl1 = sl + sll; else sl1 = sl; #pragma pipeloop(0) for (i = 0; i < swid; i++) { buff0[i - 1] = (mlib_s32)sl[i * chan1]; buff1[i - 1] = (mlib_s32)sl1[i * chan1]; } if (dx_r != 0) { buff0[swid - 1] = buff0[swid - 2]; buff1[swid - 1] = buff1[swid - 2]; } if ((hgt - dy_b) > 1) sl = sl1 + sll; else sl = sl1; for (j = 0; j < hgt; j++) { sp = sl; dp = dl; buff2[-1] = (mlib_s32)sp[0]; sp += chan1; p02 = buff0[-1]; p12 = buff1[-1]; #pragma pipeloop(0) for (i = 0; i <= (wid - 2); i += 2) { d64_2x32 sd0, sd1; d64_2x32 dd0, dd1; p00 = p02; p10 = p12; sd0.d64 = *(TYPE_64BIT *) (buff0 + i); sd1.d64 = *(TYPE_64BIT *) (buff1 + i); p01 = (mlib_d64)sd0.i32s.i0; p02 = (mlib_d64)sd0.i32s.i1; p11 = (mlib_d64)sd1.i32s.i0; p12 = (mlib_d64)sd1.i32s.i1; LOAD_BUFF(buff2); dd0.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3); dd0.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3); dd1.d64 = vis_fpack32(dd1.d64, dd0.d64); STORE2(dd1.i32s.i0, dd1.i32s.i1); sp += chan2; dp += chan2; } for (; i < wid; i++) { d64_2x32 dd0, dd1; p00 = buff0[i - 1]; p10 = buff1[i - 1]; p01 = buff0[i]; p11 = buff1[i]; buff2[i] = (mlib_s32)sp[0]; dd0.i32s.i1 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3); dd1.d64 = vis_fpack32(dd1.d64, dd0.d64); dp[0] = dd1.i32s.i1; sp += chan1; dp += chan1; } if (dx_r != 0) buff2[swid - 1] = buff2[swid - 2]; if (j < hgt - dy_b - 2) sl += sll; dl += dll; buffT = buff0; buff0 = buff1; buff1 = buff2; buff2 = buffT; } } if (pbuff != (mlib_s32 *)buff_arr) __mlib_free(pbuff); return (MLIB_SUCCESS); }