void next_akk(int inNumSamples) { float newQ = in0(2); float newHPCutoff = in0(3); if (q != newQ) set_q(newQ); if (newHPCutoff != hpCutoff) setFeedbackHPF(newHPCutoff * sampleDur()); const float * inSig = zin(0); const float * inFreq = zin(1); float * outSig = zout(0); double z0 = z[0]; double z1 = z[1]; double z2 = z[2]; double z3 = z[3]; double z4 = z[4]; for (int i = 0; i != inNumSamples; ++i) { double freq = ZXP(inFreq); double a, a_inv, a2, b, b2, c, g, g0; calcFilterCoefficients(freq, a, a2, a_inv, b, b2, c, g, g0); double x = ZXP(inSig); ZXP(outSig) = tick(x, a, a2, a_inv, b, b2, c, g, g0, z0, z1, z2, z3, z4); } z[0] = z0; z[1] = z1; z[2] = z2; z[3] = z3; z[4] = z4; }
CNcbiIstream* CLDS2_UrlHandler_GZipFile::OpenStream(const SLDS2_File& file_info, Int8 stream_pos, CLDS2_Database* db) { auto_ptr<CNcbiIfstream> in( new CNcbiIfstream(file_info.name.c_str(), ios::binary)); if ( !in->is_open() ) { return NULL; } if ( db ) { // Try to use chunks information to optimize loading SLDS2_Chunk chunk; if ( db->FindChunk(file_info, chunk, stream_pos) ) { if (chunk.raw_pos > 0) { in->seekg(NcbiInt8ToStreampos(chunk.raw_pos)); } stream_pos -= chunk.stream_pos; } } auto_ptr<CCompressionIStream> zin( new CCompressionIStream( *in.release(), new CZipStreamDecompressor(CZipCompression::fGZip), CCompressionStream::fOwnAll)); zin->ignore(NcbiInt8ToStreampos(stream_pos)); return zin.release(); }
OSG_USING_NAMESPACE int main (int argc, char **argv) { std::stringstream compressed(std::stringstream::in | std::stringstream::out); // with false we add no gzip header and footer. zip_ostream zout(compressed, false); zout << std::string("Begin") << " " << Int32(123456789) << " " << Real32(1.41232) << " " << std::string("End"); // this flushes the stream and adds the gzip footer, this is // done automatically in the zip_ostream destructor, but in this // case we need to call it directly! zout.finished(); std::cout << "Compressed : " << "'" << compressed.str() << "' (" << compressed.str().size() << ")" << std::endl; std::string str1; Int32 v1 = 0; Real32 v2 = 0.0f; std::string str2; zip_istream zin(compressed); zin >> str1 >> v1 >> v2 >> str2; std::cout << "Uncompressed: " << "'" << str1 << "' " << v1 << " " << v2 << " '" << str2 << "'" << std::endl; return 0; }
static u32 zpeekl(struct zatm_dev *zatm_dev,u32 addr) { zwait; zout(uPD98401_IND_ACC | uPD98401_IA_BALL | uPD98401_IA_RW | (uPD98401_IA_TGT_CM << uPD98401_IA_TGT_SHIFT) | addr,CMR); zwait; return zin(CER); }
void XYView::save(ostream& o) { PrintableWindow* w; if (!canvas_) { if (!parent() || !parent()->has_window()) { return; } w = parent()->window(); } else { w = (PrintableWindow*)canvas()->window(); } char buf[256]; Coord x1, y1, x2, y2; zin(x1, y1, x2, y2); sprintf(buf, "{save_window_.view(%g, %g, %g, %g, %g, %g, %g, %g)}", x1, y1, x2 - x1, y2 - y1, w->save_left(), w->save_bottom(), xsize_, ysize_ ); o << buf << endl; }
static void poll_rx(struct atm_dev *dev,int mbx) { struct zatm_dev *zatm_dev; unsigned long pos; u32 x; int error; EVENT("poll_rx\n",0,0); zatm_dev = ZATM_DEV(dev); pos = (zatm_dev->mbx_start[mbx] & ~0xffffUL) | zin(MTA(mbx)); while (x = zin(MWA(mbx)), (pos & 0xffff) != x) { u32 *here; struct sk_buff *skb; struct atm_vcc *vcc; int cells,size,chan; EVENT("MBX: host 0x%lx, nic 0x%x\n",pos,x); here = (u32 *) pos; if (((pos += 16) & 0xffff) == zatm_dev->mbx_end[mbx]) pos = zatm_dev->mbx_start[mbx]; cells = here[0] & uPD98401_AAL5_SIZE; #if 0 printk("RX IND: 0x%x, 0x%x, 0x%x, 0x%x\n",here[0],here[1],here[2],here[3]); { unsigned long *x; printk("POOL: 0x%08x, 0x%08x\n",zpeekl(zatm_dev, zatm_dev->pool_base), zpeekl(zatm_dev,zatm_dev->pool_base+1)); x = (unsigned long *) here[2]; printk("[0..3] = 0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx\n", x[0],x[1],x[2],x[3]); } #endif error = 0; if (here[3] & uPD98401_AAL5_ERR) { error = (here[3] & uPD98401_AAL5_ES) >> uPD98401_AAL5_ES_SHIFT; if (error == uPD98401_AAL5_ES_DEACT || error == uPD98401_AAL5_ES_FREE) continue; } EVENT("error code 0x%x/0x%x\n",(here[3] & uPD98401_AAL5_ES) >> uPD98401_AAL5_ES_SHIFT,error); skb = ((struct rx_buffer_head *) bus_to_virt(here[2]))->skb; __net_timestamp(skb); #if 0 printk("[-3..0] 0x%08lx 0x%08lx 0x%08lx 0x%08lx\n",((unsigned *) skb->data)[-3], ((unsigned *) skb->data)[-2],((unsigned *) skb->data)[-1], ((unsigned *) skb->data)[0]); #endif EVENT("skb 0x%lx, here 0x%lx\n",(unsigned long) skb, (unsigned long) here); #if 0 printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]); #endif size = error ? 0 : ntohs(((__be16 *) skb->data)[cells* ATM_CELL_PAYLOAD/sizeof(u16)-3]); EVENT("got skb 0x%lx, size %d\n",(unsigned long) skb,size); chan = (here[3] & uPD98401_AAL5_CHAN) >> uPD98401_AAL5_CHAN_SHIFT; if (chan < zatm_dev->chans && zatm_dev->rx_map[chan]) { int pos; vcc = zatm_dev->rx_map[chan]; pos = ZATM_VCC(vcc)->pool; if (skb == zatm_dev->last_free[pos]) zatm_dev->last_free[pos] = NULL; skb_unlink(skb, zatm_dev->pool + pos); } else { printk(KERN_ERR DEV_LABEL "(itf %d): RX indication " "for non-existing channel\n",dev->number); size = 0; vcc = NULL; event_dump(); } if (error) { static unsigned long silence = 0; static int last_error = 0; if (error != last_error || time_after(jiffies, silence) || silence == 0){ printk(KERN_WARNING DEV_LABEL "(itf %d): " "chan %d error %s\n",dev->number,chan, err_txt[error]); last_error = error; silence = (jiffies+2*HZ)|1; } size = 0; } if (size && (size > cells*ATM_CELL_PAYLOAD-ATM_AAL5_TRAILER || size <= (cells-1)*ATM_CELL_PAYLOAD-ATM_AAL5_TRAILER)) { printk(KERN_ERR DEV_LABEL "(itf %d): size %d with %d " "cells\n",dev->number,size,cells); size = 0; event_dump(); } if (size > ATM_MAX_AAL5_PDU) { printk(KERN_ERR DEV_LABEL "(itf %d): size too big " "(%d)\n",dev->number,size); size = 0; event_dump(); } if (!size) { dev_kfree_skb_irq(skb); if (vcc) atomic_inc(&vcc->stats->rx_err); continue; } if (!atm_charge(vcc,skb->truesize)) { dev_kfree_skb_irq(skb); continue; } skb->len = size; ATM_SKB(skb)->vcc = vcc; vcc->push(vcc,skb); atomic_inc(&vcc->stats->rx); }
bool wxPdfFontDataTrueTypeUnicode::LoadFontMetrics(wxXmlNode* root) { bool bName = false, bDesc = false, bFile = true, bSize = true, bWidth = false; wxString value; long number; wxXmlNode *child = root->GetChildren(); while (child) { // parse the children if (child->GetName() == wxT("font-name")) { m_name = GetNodeContent(child); m_style = FindStyleFromName(m_name); bName = m_name.Length() > 0; } else if (child->GetName() == wxT("encoding")) { m_enc = GetNodeContent(child); } else if (child->GetName() == wxT("description")) { bDesc = GetFontDescription(child, m_desc); } else if (child->GetName() == wxT("diff")) { m_diffs = GetNodeContent(child); } else if (child->GetName() == wxT("file")) { #if wxCHECK_VERSION(2,9,0) value = child->GetAttribute(wxT("ctg"), wxT("")); #else value = child->GetPropVal(wxT("ctg"), wxT("")); #endif if (value.Length() > 0) { bFile = true; m_ctg = value; #if wxCHECK_VERSION(2,9,0) value = child->GetAttribute(wxT("name"), wxT("")); #else value = child->GetPropVal(wxT("name"), wxT("")); #endif if (value.Length() > 0) { m_file = value; #if wxCHECK_VERSION(2,9,0) value = child->GetAttribute(wxT("originalsize"), wxT("")); #else value = child->GetPropVal(wxT("originalsize"), wxT("")); #endif if (value.Length() > 0 && value.ToLong(&number)) { bFile = true; m_size1 = number; } else { bFile = false; m_file = wxT(""); } } } else { bFile = false; m_file = wxT(""); m_ctg = wxT(""); } } else if (child->GetName() == wxT("widths")) { bWidth = true; m_cw = new wxPdfGlyphWidthMap(); const wxXmlNode *charNode = child->GetChildren(); while (charNode) { wxString strId, strWidth; long charId, charWidth; if (charNode->GetName() == wxT("char")) { #if wxCHECK_VERSION(2,9,0) strId = charNode->GetAttribute(wxT("id"), wxT("")); strWidth = charNode->GetAttribute(wxT("width"), wxT("")); #else strId = charNode->GetPropVal(wxT("id"), wxT("")); strWidth = charNode->GetPropVal(wxT("width"), wxT("")); #endif if (strId.Length() > 0 && strId.ToLong(&charId) && strWidth.Length() > 0 && strWidth.ToLong(&charWidth)) { (*m_cw)[charId] = charWidth; } } charNode = charNode->GetNext(); } } else if (child->GetName() == wxT("volt")) { m_volt = new wxPdfVolt(); m_volt->LoadVoltData(child); } child = child->GetNext(); } CreateDefaultEncodingConv(); m_initialized = (bName && bDesc && bFile && bSize && bWidth); if (m_initialized) { wxFileName fileName(m_file); m_initialized = fileName.MakeAbsolute(m_path) && fileName.FileExists() && fileName.IsFileReadable(); if (m_initialized) { fileName.Assign(m_ctg); m_initialized = fileName.MakeAbsolute(m_path) && fileName.FileExists() && fileName.IsFileReadable(); } } if (m_initialized && m_gn == NULL) { // We now always need a cid to gid mapping whether subsetting is enabled or not // So we read the CTG file produced by MakeFont and create the map bool compressed = m_ctg.Lower().Right(2) == wxT(".z"); wxFileName fileName(m_ctg); fileName.MakeAbsolute(m_path); wxFileSystem fs; wxFSFile* ctgFile = fs.OpenFile(wxFileSystem::FileNameToURL(fileName)); wxInputStream* ctgStream = NULL; if (ctgFile) { ctgStream = ctgFile->GetStream(); } else { m_initialized = false; // usually this should not happen since file accessability was already checked wxLogError(wxString(wxT("wxPdfFontDataTrueTypeUnicode::LoadFontMetrics: ")) + wxString::Format(_("CTG file '%s' not found."), fileName.GetFullPath().c_str())); } if (ctgStream) { size_t ctgLen; unsigned char* cc2gn = NULL; if (compressed) { wxZlibInputStream zin(*ctgStream); wxMemoryOutputStream zout; zout.Write(zin); zout.Close(); wxMemoryInputStream cid2gidStream(zout); ctgLen = cid2gidStream.GetSize(); cc2gn = new unsigned char[ctgLen]; cid2gidStream.Read(cc2gn, ctgLen); } else { ctgLen = ctgStream->GetSize(); cc2gn = new unsigned char[ctgLen]; ctgStream->Read(cc2gn, ctgLen); } delete ctgFile; // Create the cid to gid mapping m_gn = new wxPdfChar2GlyphMap(); size_t charId; for (charId = 0; charId < 0xFFFF; ++charId) { int glyph = (cc2gn[2*charId] << 8) + cc2gn[2*charId+1]; if (glyph != 0) { (*m_gn)[charId] = glyph; } } delete [] cc2gn; } } return m_initialized; }