scheme_language_rep::scheme_language_rep (string name): language_rep (name), colored ("") { eval ("(use-modules (utils misc tm-keywords))"); list<string> l= as_list_string (eval ("(map symbol->string highlight-any)")); while (!is_nil (l)) { colored (l->item)= decode_color ("scheme", encode_color ("keyword")); l= l->next; } }
string scheme_language_rep::get_color (tree t, int start, int end) { static string none= ""; if (start >= end) return none; string s= t->label; for (int i= max (0, start-1000); i <= start; i++) switch (s[i]) { case ';': if (i>1 && s[i-1] == '\\' && s[i-2] == '#') break; return decode_color ("scheme", encode_color ("comment")); case '\042': if (i>1 && s[i-1] == '\\' && s[i-2] == '#') break; i++; while (i <= start && s[i] != '\042') if (s[i] == '\\' && i < start) i += 2; else i++; if (i >= start) return decode_color ("scheme", encode_color ("constant_string")); break; } if (is_numeric (s[start])) return decode_color ("scheme", encode_color ("constant_number")); if (s[start] == '\042' || s[start] == '#') return decode_color ("scheme", encode_color ("constant_string")); if (s[start] == ':') return decode_color ("scheme", encode_color ("declare_category")); string r= s (start, end); if (!colored->contains (r)) { colored (r)= ""; if (as_bool (call ("defined?", symbol_object (tm_decode (r))))) colored (r)= decode_color ("scheme", encode_color ("variable_identifier")); } return colored[r]; }
/*XXX*/ int BvcEncoder::consume(const VideoFrame* vf) { if (!samesize(vf)) size(vf->width_, vf->height_); YuvFrame* p = (YuvFrame*)vf; tx_->flush(); int layer = p->layer_; u_char* frm = (u_char*)p->bp_; const u_char* chm = frm + framesize_; blkno_ = -1; pktbuf* pb = getpkt(p->ts_, layer); const u_int8_t* crv = p->crvec_; memset(&b, 0, sizeof(b)); #ifdef SBC_STAT if (f[0] == 0) { f[0] = fopen("sbc0", "w"); f[1] = fopen("sbc1", "w"); f[2] = fopen("sbc2", "w"); f[3] = fopen("sbc3", "w"); } #endif int cc = 0; int blkw = width_ >> 4; int blkh = height_ >> 4; int blkno = 0; for (int y = 0; y < blkh; ++y) { for (int x = 0; x < blkw; ++blkno, frm += 16, chm += 8, ++x, ++crv) { int s = crv[0]; if ((s & CR_SEND) == 0) continue; #define MAXMBSIZE (16*16+2*8*8+4) if (bs_ + MAXMBSIZE >= es_) { cc += flush(pb, 0); pb = getpkt(p->ts_, layer); } int dblk = blkno - blkno_; blkno_ = blkno; if (dblk <= 0) abort(); if (dblk == 1) { PUT_BITS(1, 1, nbb_, bb_, bs_); b.mba += 1; } else if (dblk <= 17) { PUT_BITS(0x10 | (dblk - 2), 6, nbb_, bb_, bs_); b.mba += 6; } else { PUT_BITS(dblk, 13, nbb_, bb_, bs_); b.mba += 13; } /* * Deal with boundaries of image. This is * simply ugly, but it's the price we have * to pay for using a four tap filter stage. * For the 1-3-3-1 filter set, we use symmetric * extension at both analysis and synthesis * to give perfect reconstruction. * If we're at the top of the image, we simply * copy the top row up (since the grabber's * reserve one line of extra space). Otherwise, * we save pixels, do the symmetrization, * encode the block, then restore the pixels. */ u_char ysave[16]; u_char xsave[16]; if (y == 0) memcpy(frm - width_, frm, 16); else if (y == blkh - 1) { u_char* p = frm + (width_ << 4); memcpy(ysave, p, 16); memcpy(p, p - width_, 16); } if (x == 0) { u_char* s = xsave; u_char* p = frm; for (int k = 0; k < 16; ++k) { *s++ = p[-1]; p[-1] = p[0]; p += width_; } } else if (x == blkw - 1) { u_char* s = xsave; u_char* p = frm + 16; for (int k = 0; k < 16; ++k) { *s++ = p[0]; p[0] = p[-1]; p += width_; } } encode_block(frm); encode_color(chm); encode_color(chm + (framesize_ >> 2)); /* * Now restore the pixels. We don't bother * with the "y = 0" case because the affected * memory will not be used. */ if (y == blkh - 1) { u_char* p = frm + (width_ << 4); memcpy(p, ysave, 16); } if (x == 0) { u_char* s = xsave; u_char* p = frm; for (int k = 0; k < 16; ++k) { p[-1] = *s++; p += width_; } } else if (x == blkw - 1) { u_char* s = xsave; u_char* p = frm + 16; for (int k = 0; k < 16; ++k) { p[0] = *s++; p += width_; } } } frm += 15 * width_; chm += 7 * (width_ >> 1); } #ifdef notdef double t = b.dc + b.mba; for (int i = 0; i < 4; ++i) t += b.zt[i] + b.sbc[i] + b.sbz[i]; printf("dc\t%.3f\n", b.dc / t); printf("mba\t%.3f\n", b.mba / t); for (i = 0; i < 4; ++i) { printf("sbc%d\t%.3f (%.3f)\n", i, (b.sbc[i] + b.sbz[i]) / t, b.sbz[i] / double(b.sbc[i] + b.sbz[i])); printf("zt%d\t%.3f\n", i, b.zt[i] / t); } #endif cc += flush(pb, 1); return (cc); }