void GifImage::readMetadata() { #ifdef DEBUG std::cerr << "Exiv2::GifImage::readMetadata: Reading GIF file " << io_->path() << "\n"; #endif if (io_->open() != 0) { throw Error(9, io_->path(), strError()); } IoCloser closer(*io_); // Ensure that this is the correct image type if (!isGifType(*io_, true)) { if (io_->error() || io_->eof()) throw Error(14); throw Error(3, "GIF"); } clearMetadata(); byte buf[4]; if (io_->read(buf, sizeof(buf)) == sizeof(buf)) { pixelWidth_ = getShort(buf, littleEndian); pixelHeight_ = getShort(buf + 2, littleEndian); } } // GifImage::readMetadata
TiffEntryBE::TiffEntryBE(FileMap* f, uint32 offset) : mDataSwapped(false) { type = TIFF_UNDEFINED; // We set type to undefined to avoid debug assertion errors. data = f->getDataWrt(offset); tag = (TiffTag)getShort(); data += 2; TiffDataType _type = (TiffDataType)getShort(); data += 2; count = getInt(); type = _type; //Now we can set it to the proper type if (type > 13) ThrowTPE("Error reading TIFF structure. Unknown Type 0x%x encountered.", type); uint32 bytesize = count << datashifts[type]; if (bytesize <= 4) { data = f->getDataWrt(offset + 8); } else { // offset data = f->getDataWrt(offset + 8); data_offset = (unsigned int)data[0] << 24 | (unsigned int)data[1] << 16 | (unsigned int)data[2] << 8 | (unsigned int)data[3]; CHECKSIZE(data_offset + bytesize); data = f->getDataWrt(data_offset); } #ifdef _DEBUG debug_intVal = 0xC0CAC01A; debug_floatVal = sqrtf(-1); if (type == TIFF_LONG || type == TIFF_SHORT) debug_intVal = getInt(); if (type == TIFF_FLOAT || type == TIFF_DOUBLE) debug_floatVal = getFloat(); #endif }
AXStructPrm AXLexer::getSTRUCTPRM(){ AXStructPrm structPrm; structPrm.mpType = getShort(); structPrm.subId = getShort(); structPrm.offset = getInt(); return structPrm; }
AXHpiDat AXLexer::getHPIDAT(){ AXHpiDat hpiDat; hpiDat.flag = getShort(); hpiDat.option = getShort(); hpiDat.libName = getInt(); hpiDat.funcName = getInt(); hpiDat.libPtr = (void *)getInt(); return hpiDat; }
int PixelMap:: readBMPFile(string fname) { // Read into memory an Pixel image from an uncompressed BMP file. // return 0 on failure, 1 on success inf.open(fname.c_str(), ios::in|ios::binary); //must read raw binary char's. if(!inf){ cout << " can't open file: " << fname << endl; return 0;} int k, row, col, numPadBytes, nBytesInRow; // read header information char ch1, ch2; inf.get(ch1); inf.get(ch2); // type is always 'BM' //cout << "file type = " << ch1 << ch2 << endl; ulong fileSize = getLong(); ushort reserved1 = getShort(); // always 0 ushort reserved2= getShort(); // always 0 ulong offBits = getLong(); // offset to image - unreliable ulong headerSize = getLong(); // always 40 ulong numCols = getLong(); // number of columns in image ulong numRows = getLong(); // number of rows in image ushort planes= getShort(); // always 1 ushort bitsPerPix = getShort(); // 8 or 24;only 24 bit case done ulong compression = getLong(); // must be 0 for umcompressed ulong imageSize = getLong(); // total bytes in image ulong xPels = getLong(); // always 0 ulong yPels = getLong(); // always 0 ulong numLUTentries = getLong(); // 256 for 8 bit, otherwise 0 ulong impColors = getLong(); // always 0 if(bitsPerPix != 24) {cout << "not a 24 bit/pixelimage!\n"; inf.close(); return 0;}; // error! // in BMP file, pad bytes inserted at end of each row so total number is a mult. of 4 nBytesInRow = ((3 * numCols + 3)/4) * 4; // round up 3*numCols to next mult. of 4 numPadBytes = nBytesInRow - 3 * numCols; // need this many m_rows = numRows; // set class's data members m_cols = numCols; cout << "numRows,numCols = " << numRows << "," << numCols << endl; cout.flush(); m_pixel = new Pixel[m_rows * m_cols]; //space for array in memory if(!m_pixel) return 0; // out of memory! long count = 0; char dum,r,g,b; for(row = 0; row < m_rows; row++) // read pixel values { for(col = 0; col < m_cols; col++) { inf.get(b); inf.get(g); inf.get(r); // funny color order in BMP file m_pixel[count].set_r(r); m_pixel[count].set_g(g); m_pixel[count++].set_b(b); } for(k = 0; k < numPadBytes ; k++) //skip over padding bytes at row's end inf >> dum; } inf.close(); return 1; // success }
AXStructDat AXLexer::getSTRUCTDAT(){ AXStructDat structDat; structDat.index = getShort(); structDat.subId = getShort(); structDat.prmIndex = getInt(); structDat.prmMax = getInt(); structDat.nameIndex = getInt(); structDat.size = getInt(); structDat.OTIndex = getInt(); structDat.proc = (void *)getInt(); return structDat; }
int32_t CompositeChannelBuffer::getInt(int index) const { int componentId = getComponentId(index); if (index + 4 <= indices[componentId + 1]) { return components[componentId]->getInt(index - indices[componentId]); } else if (order() == ByteOrder::BIG) { return ((getShort(index) & 0xffff) << 16) | (getShort(index + 2) & 0xffff); } else { return (getShort(index) & 0xFFFF) | ((getShort(index + 2) & 0xFFFF) << 16); } }
int createInlineCacheEntry(cell* contents, BYTE* originalCode) { ICACHE thisICache; int index; /* Check first if inline cache is already full */ if (InlineCacheAreaFull) { releaseInlineCacheEntry(InlineCachePointer); } /* Allocate new entry / reallocate old one */ thisICache = &InlineCache[InlineCachePointer]; index = InlineCachePointer++; /* Check whether the icache area is full now */ if (InlineCachePointer == INLINECACHESIZE) { InlineCacheAreaFull = TRUE; InlineCachePointer = 0; } /* Initialize icache values */ thisICache->contents = contents; thisICache->codeLoc = originalCode; thisICache->origInst = *originalCode; thisICache->origParam = getShort(originalCode+1); return index; }
void DataWatcher::write(PacketBuffer &buffer) { for (byte_t index = 0; index < 23; ++index) { if (type[index] == NONE) continue; buffer.putByte(type[index] << 5 | (index & 0x1f)); switch (type[index]) { case BYTE: buffer.putByte(getByte(index)); break; case SHORT: buffer.putShort(getShort(index)); break; case INT: buffer.putInt(getInt(index)); break; case FLOAT: buffer.putFloat(getFloat(index)); break; case STRING: buffer.putString(getString(index)); break; case ITEMSTACK: buffer.putItemStack(getItemStack(index)); break; } } buffer.putByte(0x7f); }
unsigned int TiffEntryBE::getInt() { if (!(type == TIFF_LONG || type == TIFF_SHORT || type == TIFF_UNDEFINED)) ThrowTPE("TIFF, getInt: Wrong type 0x%x encountered. Expected Int", type); if (type == TIFF_SHORT) return getShort(); return (unsigned int)data[0] << 24 | (unsigned int)data[1] << 16 | (unsigned int)data[2] << 8 | (unsigned int)data[3]; }
void TgaImage::readMetadata() { #ifdef DEBUG std::cerr << "Exiv2::TgaImage::readMetadata: Reading TARGA file " << io_->path() << "\n"; #endif if (io_->open() != 0) { throw Error(9, io_->path(), strError()); } IoCloser closer(*io_); // Ensure that this is the correct image type if (!isTgaType(*io_, false)) { if (io_->error() || io_->eof()) throw Error(14); throw Error(3, "TGA"); } clearMetadata(); /* The TARGA header goes as follows -- all numbers are in little-endian byte order: offset length name description ====== ======= ======================= =========== 0 1 byte ID length length of image ID (0 to 255) 1 1 byte color map type 0 = no color map; 1 = color map included 2 1 byte image type 0 = no image; 1 = uncompressed color-mapped; 2 = uncompressed true-color; 3 = uncompressed black-and-white; 9 = RLE-encoded color mapped; 10 = RLE-encoded true-color; 11 = RLE-encoded black-and-white 3 5 bytes color map specification 8 2 bytes x-origin of image 10 2 bytes y-origin of image 12 2 bytes image width 14 2 bytes image height 16 1 byte pixel depth 17 1 byte image descriptor */ byte buf[18]; if (io_->read(buf, sizeof(buf)) == sizeof(buf)) { pixelWidth_ = getShort(buf + 12, littleEndian); pixelHeight_ = getShort(buf + 14, littleEndian); } } // TgaImage::readMetadata
// ---------------------------------------------------------------------------- std::vector<std::string> STVRMessage::getStringVector() { std::vector<std::string> vs; vs.resize(getShort()); for(unsigned int i=0; i<vs.size(); i++) vs[i]=getString(); return vs; } // getStringVector
static void setShort(const int offset, const int value) { if (isOutOfBounds(offset)) return; uint16_t *ptr = (uint16_t *) (&((char *) engineConfiguration)[offset]); *ptr = (uint16_t) value; getShort(offset); incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_F); }
uint16_t net_buffer_getShort(struct net_buffer * buf) { if (!buf) return -1; if ((buf->buf_ptr + sizeof(uint16_t)) > buf->buf+buf->size) return -1; uint16_t target = getShort(buf->buf_ptr); buf->buf_ptr += sizeof(uint16_t); return target; }
unsigned int TiffEntry::getInt() { if (!(type == TIFF_LONG || type == TIFF_SHORT || type == TIFF_BYTE || type == TIFF_OFFSET)) ThrowTPE("TIFF, getInt: Wrong type 0x%x encountered. Expected Long, Short or Byte", type); if (type == TIFF_BYTE) return getByte(); if (type == TIFF_SHORT) return getShort(); return (uint32)data[3] << 24 | (uint32)data[2] << 16 | (uint32)data[1] << 8 | (uint32)data[0]; }
int TdApi::reqUserLogin(dict req) { DFITCUserLoginField myreq = DFITCUserLoginField(); memset(&myreq, 0, sizeof(myreq)); getString(req, "passwd", myreq.passwd); getLong(req, "lRequestID", &myreq.lRequestID); getShort(req, "companyID", &myreq.companyID); getString(req, "accountID", myreq.accountID); int i = this->api->ReqUserLogin(&myreq); return i; };
void SGASpecificConfig::process(){ frameLengthFlag = getByte(1); dependsOnCoreCoder = getByte(1); if(dependsOnCoreCoder){ coreCoderDelay = getShort(14); } extensionFlag = getByte(1); if(channelConfiguration){ programConfigElement = new SProgramConfigElement(getReader()); } if(audioObjectType == 6 || audioObjectType == 20 ){ layerNr = getByte(3); } if(extensionFlag && audioObjectType==22){ numOfSubFrame = getByte(5); layer_length = getShort(11); } if(extensionFlag && (audioObjectType == 17 || audioObjectType == 19 || audioObjectType == 20 || audioObjectType ==23)){ aacSectionDataResilienceFlag = getByte(1); aacScalefactorDataResilienceFlag = getByte(1); aacSpectralDataResilienceFlag = getByte(1); } extensionFlag3 = getByte(1); if(extensionFlag3){ //............... } }
TiffEntryBE::TiffEntryBE(FileMap* f, uint32 offset, uint32 up_offset) { own_data = NULL; empty_data = 0; file = f; parent_offset = up_offset; type = TIFF_UNDEFINED; // We set type to undefined to avoid debug assertion errors. data = f->getDataWrt(offset, 8); tag = (TiffTag)getShort(); data += 2; TiffDataType _type = (TiffDataType)getShort(); data += 2; count = getInt(); type = _type; //Now we can set it to the proper type if (type > 13) ThrowTPE("Error reading TIFF structure. Unknown Type 0x%x encountered.", type); uint64 bytesize = (uint64)count << datashifts[type]; if (bytesize > UINT32_MAX) ThrowTPE("TIFF entry is supposedly %llu bytes", bytesize); if (bytesize == 0) // Better return empty than NULL-dereference later data = (uchar8 *) &empty_data; else if (bytesize <= 4) data = f->getDataWrt(offset + 8, bytesize); else { // it's an offset data = f->getDataWrt(offset + 8, 4); data_offset = (unsigned int)data[0] << 24 | (unsigned int)data[1] << 16 | (unsigned int)data[2] << 8 | (unsigned int)data[3]; data = f->getDataWrt(data_offset, bytesize); } #ifdef _DEBUG debug_intVal = 0xC0CAC01A; debug_floatVal = sqrtf(-1); if (type == TIFF_LONG || type == TIFF_SHORT) debug_intVal = getInt(); if (type == TIFF_FLOAT || type == TIFF_DOUBLE) debug_floatVal = getFloat(); #endif }
int TdApi::reqQryQuoteOrderInfo(dict req) { DFITCQuoteOrderField myreq = DFITCQuoteOrderField(); memset(&myreq, 0, sizeof(myreq)); getString(req, "instrumentID", myreq.instrumentID); getString(req, "exchangeID", myreq.exchangeID); getLong(req, "localOrderID", &myreq.localOrderID); getLong(req, "lRequestID", &myreq.lRequestID); getShort(req, "orderStatus", &myreq.orderStatus); getLong(req, "spdOrderID", &myreq.spdOrderID); getString(req, "accountID", myreq.accountID); int i = this->api->ReqQryQuoteOrderInfo(&myreq); return i; };
AXHeader AXLexer::getHeader(){ AXHeader header; src->read(header.magic, 4); header.version = getInt(); header.maxVal = getInt(); header.size = getInt(); header.pCS = getInt(); header.maxCS = getInt(); header.pDS = getInt(); header.maxDS = getInt(); header.pOT = getInt(); header.maxOT = getInt(); header.pDINFO = getInt(); header.maxDINFO = getInt(); header.pLINFO = getInt(); header.maxLINFO = getInt(); header.pFINFO = getInt(); header.maxFINFO = getInt(); header.pMINFO = getInt(); header.maxMINFO = getInt(); header.pFINFO2 = getInt(); header.maxFINFO2 = getInt(); header.pHPIDAT = getInt(); header.maxHPIDAT = getShort(); header.maxVARHPI = getShort(); header.bootOption = getInt(); header.runtime = getInt(); return header; }
int TdApi::reqQryOrderInfo(dict req) { DFITCOrderField myreq = DFITCOrderField(); memset(&myreq, 0, sizeof(myreq)); getString(req, "instrumentID", myreq.instrumentID); getLong(req, "localOrderID", &myreq.localOrderID); getInt(req, "orderType", &myreq.orderType); getLong(req, "lRequestID", &myreq.lRequestID); getShort(req, "orderStatus", &myreq.orderStatus); getString(req, "customCategory", myreq.customCategory); getLong(req, "spdOrderID", &myreq.spdOrderID); getInt(req, "instrumentType", &myreq.instrumentType); getString(req, "accountID", myreq.accountID); int i = this->api->ReqQryOrderInfo(&myreq); return i; };
// // readPGM16AsciiData() - this function reads the data of 16-bit-pixel // ascii format pgm file into the provided buffer // static bool readPGM16AsciiData(FILE* stream, int nrows, int ncols, unsigned short* data ) { for ( int row = 0; row < nrows; row++ ) { for ( int col = 0; col < ncols; col++ ) { if( !getShort( stream, data ) ) { return false; } } } return true; }
void cUOTxShardList::addServer( Q_UINT16 serverIndex, QString serverName, Q_UINT8 serverFull, Q_INT8 serverTimeZone, Q_UINT32 serverIp ) { // Increase the server-count // Offset: 4 setShort( 4, getShort( 4 ) + 1 ); Q_INT32 offset = rawPacket.count(); rawPacket.resize( rawPacket.count() + 40 ); // 40 byte per server setShort( 1, rawPacket.count() ); setShort( offset, serverIndex ); if( serverName.length() > 31 ) serverName = serverName.left( 31 ); strcpy( &rawPacket.data()[ offset + 2 ], serverName.latin1() ); rawPacket[ offset + 34 ] = serverFull; rawPacket[ offset + 35 ] = serverTimeZone; setInt( offset + 36, serverIp ); }
int TdApi::reqInsertOrder(dict req) { DFITCInsertOrderField myreq = DFITCInsertOrderField(); memset(&myreq, 0, sizeof(myreq)); getString(req, "instrumentID", myreq.instrumentID); getInt(req, "openCloseType", &myreq.openCloseType); getLong(req, "localOrderID", &myreq.localOrderID); getDouble(req, "insertPrice", &myreq.insertPrice); getChar(req, "orderProperty", myreq.orderProperty); getShort(req, "buySellType", &myreq.buySellType); getInt(req, "orderType", &myreq.orderType); getLong(req, "minMatchAmount", &myreq.minMatchAmount); getInt(req, "speculator", &myreq.speculator); getLong(req, "lRequestID", &myreq.lRequestID); getInt(req, "reservedType2", &myreq.reservedType2); getInt(req, "insertType", &myreq.insertType); getLong(req, "orderAmount", &myreq.orderAmount); getDouble(req, "profitLossPrice", &myreq.profitLossPrice); getString(req, "customCategory", myreq.customCategory); getInt(req, "instrumentType", &myreq.instrumentType); getString(req, "accountID", myreq.accountID); int i = this->api->ReqInsertOrder(&myreq); return i; };
/* * Format the specified option so that a human can easily read it. */ char * pretty_print_option(unsigned int code, unsigned char *data, int len, int emit_commas, int emit_quotes) { static char optbuf[32768]; /* XXX */ int hunksize = 0, numhunk = -1, numelem = 0; char fmtbuf[32], *op = optbuf; int i, j, k, opleft = sizeof(optbuf); unsigned char *dp = data; struct in_addr foo; char comma; /* Code should be between 0 and 255. */ if (code > 255) error("pretty_print_option: bad code %d", code); if (emit_commas) comma = ','; else comma = ' '; /* Figure out the size of the data. */ for (i = 0; dhcp_options[code].format[i]; i++) { if (!numhunk) { warning("%s: Excess information in format string: %s", dhcp_options[code].name, &(dhcp_options[code].format[i])); break; } numelem++; fmtbuf[i] = dhcp_options[code].format[i]; switch (dhcp_options[code].format[i]) { case 'A': --numelem; fmtbuf[i] = 0; numhunk = 0; break; case 'X': for (k = 0; k < len; k++) if (!isascii(data[k]) || !isprint(data[k])) break; if (k == len) { fmtbuf[i] = 't'; numhunk = -2; } else { fmtbuf[i] = 'x'; hunksize++; comma = ':'; numhunk = 0; } fmtbuf[i + 1] = 0; break; case 't': fmtbuf[i] = 't'; fmtbuf[i + 1] = 0; numhunk = -2; break; case 'I': case 'l': case 'L': hunksize += 4; break; case 's': case 'S': hunksize += 2; break; case 'b': case 'B': case 'f': hunksize++; break; case 'e': break; default: warning("%s: garbage in format string: %s", dhcp_options[code].name, &(dhcp_options[code].format[i])); break; } } /* Check for too few bytes... */ if (hunksize > len) { warning("%s: expecting at least %d bytes; got %d", dhcp_options[code].name, hunksize, len); return ("<error>"); } /* Check for too many bytes... */ if (numhunk == -1 && hunksize < len) warning("%s: %d extra bytes", dhcp_options[code].name, len - hunksize); /* If this is an array, compute its size. */ if (!numhunk) numhunk = len / hunksize; /* See if we got an exact number of hunks. */ if (numhunk > 0 && numhunk * hunksize < len) warning("%s: %d extra bytes at end of array", dhcp_options[code].name, len - numhunk * hunksize); /* A one-hunk array prints the same as a single hunk. */ if (numhunk < 0) numhunk = 1; /* Cycle through the array (or hunk) printing the data. */ for (i = 0; i < numhunk; i++) { for (j = 0; j < numelem; j++) { int opcount; switch (fmtbuf[j]) { case 't': if (emit_quotes) { *op++ = '"'; opleft--; } for (; dp < data + len; dp++) { if (!isascii(*dp) || !isprint(*dp)) { if (dp + 1 != data + len || *dp != 0) { snprintf(op, opleft, "\\%03o", *dp); op += 4; opleft -= 4; } } else if (*dp == '"' || *dp == '\'' || *dp == '$' || *dp == '`' || *dp == '\\') { *op++ = '\\'; *op++ = *dp; opleft -= 2; } else { *op++ = *dp; opleft--; } } if (emit_quotes) { *op++ = '"'; opleft--; } *op = 0; break; case 'I': foo.s_addr = htonl(getULong(dp)); opcount = strlcpy(op, inet_ntoa(foo), opleft); if (opcount >= opleft) goto toobig; opleft -= opcount; dp += 4; break; case 'l': opcount = snprintf(op, opleft, "%ld", (long)getLong(dp)); if (opcount >= opleft || opcount == -1) goto toobig; opleft -= opcount; dp += 4; break; case 'L': opcount = snprintf(op, opleft, "%ld", (unsigned long)getULong(dp)); if (opcount >= opleft || opcount == -1) goto toobig; opleft -= opcount; dp += 4; break; case 's': opcount = snprintf(op, opleft, "%d", getShort(dp)); if (opcount >= opleft || opcount == -1) goto toobig; opleft -= opcount; dp += 2; break; case 'S': opcount = snprintf(op, opleft, "%d", getUShort(dp)); if (opcount >= opleft || opcount == -1) goto toobig; opleft -= opcount; dp += 2; break; case 'b': opcount = snprintf(op, opleft, "%d", *(char *)dp++); if (opcount >= opleft || opcount == -1) goto toobig; opleft -= opcount; break; case 'B': opcount = snprintf(op, opleft, "%d", *dp++); if (opcount >= opleft || opcount == -1) goto toobig; opleft -= opcount; break; case 'x': opcount = snprintf(op, opleft, "%x", *dp++); if (opcount >= opleft || opcount == -1) goto toobig; opleft -= opcount; break; case 'f': opcount = strlcpy(op, *dp++ ? "true" : "false", opleft); if (opcount >= opleft) goto toobig; opleft -= opcount; break; default: warning("Unexpected format code %c", fmtbuf[j]); } op += strlen(op); opleft -= strlen(op); if (opleft < 1) goto toobig; if (j + 1 < numelem && comma != ':') { *op++ = ' '; opleft--; } } if (i + 1 < numhunk) { *op++ = comma; opleft--; } if (opleft < 1) goto toobig; } return (optbuf); toobig: warning("dhcp option too large"); return ("<error>"); }
void BinarySwapComposer::composeViewport(ViewportPtr port) { // setup viewport GLint pl=port->getPixelLeft(), pr=port->getPixelRight(), pb=port->getPixelBottom(), pt=port->getPixelTop(); GLint pw=pr-pl+1,ph=pt-pb+1; bool full = port->isFullWindow(); glViewport(pl, pb, pw, ph); glScissor(pl, pb, pw, ph); if(! full) glEnable(GL_SCISSOR_TEST); GLboolean depth = glIsEnabled(GL_DEPTH_TEST); GLboolean blend = glIsEnabled(GL_BLEND); glDisable(GL_DEPTH_TEST); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, port->getPixelWidth(), 0, port->getPixelHeight(),-1,1); // printf("max %x,%x\n",_intDepthMax,_shortDepthMax); if(getAlpha()) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } _tilesX = port->getPixelWidth() / getTileSize() + 1; _tilesY = port->getPixelHeight() / getTileSize() + 1; _tileBufferSize = getTileSize()*getTileSize()*8+sizeof(TileBuffer); _readTile.resize(_tileBufferSize); _statistics.bytesIn = 0; _statistics.bytesOut = 0; if(isClient()) { if(getShort()) { UInt16 colorDummy; UInt32 depthDummy; recvFromServers(depthDummy,colorDummy, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, port); } else { if(getAlpha()) { UInt32 colorDummy; UInt32 depthDummy; recvFromServers(depthDummy,colorDummy, GL_RGBA, GL_UNSIGNED_BYTE, port); } else { RGBValue colorDummy; UInt32 depthDummy; recvFromServers(depthDummy,colorDummy, GL_RGB, GL_UNSIGNED_BYTE, port); } } if(getStatistics()) { UInt32 maxIn = _statistics.bytesIn; UInt32 maxOut = _statistics.bytesOut; UInt32 maxIO = maxIn + maxOut; UInt32 sumOut = _statistics.bytesOut; UInt32 missing = _usableServers; double composeTime = 1e32; Connection *server; Statistics statistics; for(UInt32 i=0 ; i<_usableServers ;++i) { server = clusterWindow()->getNetwork()->getConnection(i); server->selectChannel(); server->get(&statistics,sizeof(Statistics)); sumOut += statistics.bytesOut; if(statistics.composeTime < composeTime) composeTime = statistics.composeTime; if(statistics.bytesOut > maxOut) maxOut = statistics.bytesOut; if(statistics.bytesIn > maxIn) maxIn = statistics.bytesIn; if(statistics.bytesIn + statistics.bytesOut > maxIO) maxIO = statistics.bytesIn + statistics.bytesOut; missing--; } printf("compose Time : %1.5lf\n",composeTime); printf("Transfered bytes : %10d\n",sumOut); printf("Max out : %10d\n",maxOut); printf("Max in : %10d\n",maxIn); printf("Max io : %10d\n",maxIO); } } else { if(clusterId() < _usableServers) { _statistics.composeTime = -getSystemTime(); _tile.resize(_tileBufferSize * _tilesX * _tilesY); if(getShort()) { UInt16 colorDummy; UInt32 depthDummy=_shortDepthMax; // UInt32 depthDummy=_intDepthMax; startReader(depthDummy,colorDummy, // GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, port); } else { if(getAlpha()) { UInt32 colorDummy; UInt32 depthDummy=_intDepthMax; startReader(depthDummy,colorDummy, GL_UNSIGNED_INT, GL_RGBA, GL_UNSIGNED_BYTE, port); } else { RGBValue colorDummy; UInt32 depthDummy=_intDepthMax; startReader(depthDummy,colorDummy, GL_UNSIGNED_INT, GL_RGB, GL_UNSIGNED_BYTE, port); } } _statistics.composeTime += getSystemTime(); if(getStatistics()) { Connection *client = clusterWindow()->getNetwork()->getConnection(serverCount()); client->put(&_statistics,sizeof(Statistics)); client->flush(); } } /* // max depth value !! find a better way glClear(GL_DEPTH_BUFFER_BIT); glReadPixels(0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, &_intDepthMax); glReadPixels(0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, &_shortDepthMax); */ } glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glEnable(GL_DEPTH_TEST); // reset state if(depth && !glIsEnabled(GL_DEPTH_TEST)) glEnable(GL_DEPTH_TEST); if(!blend && glIsEnabled(GL_BLEND)) glDisable(GL_BLEND); }
void Jp2Image::readMetadata() { #ifdef DEBUG std::cerr << "Exiv2::Jp2Image::readMetadata: Reading JPEG-2000 file " << io_->path() << "\n"; #endif if (io_->open() != 0) { throw Error(9, io_->path(), strError()); } IoCloser closer(*io_); // Ensure that this is the correct image type if (!isJp2Type(*io_, true)) { if (io_->error() || io_->eof()) throw Error(14); throw Error(3, "JPEG-2000"); } long position = 0; Jp2BoxHeader box = {0,0}; Jp2BoxHeader subBox = {0,0}; Jp2ImageHeaderBox ihdr = {0,0,0,0,0,0,0,0}; Jp2UuidBox uuid = {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; while (io_->read((byte*)&box, sizeof(box)) == sizeof(box)) { position = io_->tell(); box.boxLength = getLong((byte*)&box.boxLength, bigEndian); #ifdef DEBUG std::cout << "Exiv2::Jp2Image::readMetadata: Position: " << position << "\n"; std::cout << "Exiv2::Jp2Image::readMetadata: Find box type: " << std::string((const char*)&box.boxType) << " lenght: " << box.boxLength << "\n"; #endif box.boxType = getLong((byte*)&box.boxType, bigEndian); if (box.boxLength == 0) { #ifdef DEBUG std::cout << "Exiv2::Jp2Image::readMetadata: Null Box size has been found. " "This is the last box of file.\n"; #endif return; } if (box.boxLength == 1) { // FIXME. Special case. the real box size is given in another place. } switch(box.boxType) { case kJp2BoxTypeJp2Header: { #ifdef DEBUG std::cout << "Exiv2::Jp2Image::readMetadata: JP2Header box found\n"; #endif if (io_->read((byte*)&subBox, sizeof(subBox)) == sizeof(subBox)) { subBox.boxLength = getLong((byte*)&subBox.boxLength, bigEndian); subBox.boxType = getLong((byte*)&subBox.boxType, bigEndian); if((subBox.boxType == kJp2BoxTypeImageHeader) && (io_->read((byte*)&ihdr, sizeof(ihdr)) == sizeof(ihdr))) { #ifdef DEBUG std::cout << "Exiv2::Jp2Image::readMetadata: Ihdr data found\n"; #endif ihdr.imageHeight = getLong((byte*)&ihdr.imageHeight, bigEndian); ihdr.imageWidth = getLong((byte*)&ihdr.imageWidth, bigEndian); ihdr.componentCount = getShort((byte*)&ihdr.componentCount, bigEndian); ihdr.compressionTypeProfile = getShort((byte*)&ihdr.compressionTypeProfile, bigEndian); pixelWidth_ = ihdr.imageWidth; pixelHeight_ = ihdr.imageHeight; } } break; } case kJp2BoxTypeUuid: { #ifdef DEBUG std::cout << "Exiv2::Jp2Image::readMetadata: UUID box found\n"; #endif if (io_->read((byte*)&uuid, sizeof(uuid)) == sizeof(uuid)) { DataBuf rawData; long bufRead; if(memcmp(uuid.uuid, kJp2UuidExif, sizeof(uuid)) == 0) { #ifdef DEBUG std::cout << "Exiv2::Jp2Image::readMetadata: Exif data found\n"; #endif // we've hit an embedded Exif block rawData.alloc(box.boxLength - (sizeof(box) + sizeof(uuid))); bufRead = io_->read(rawData.pData_, rawData.size_); if (io_->error()) throw Error(14); if (bufRead != rawData.size_) throw Error(20); if (rawData.size_ > 0) { // Find the position of Exif header in bytes array. const byte exifHeader[] = { 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 }; long pos = -1; for (long i=0 ; i < rawData.size_-(long)sizeof(exifHeader) ; i++) { if (memcmp(exifHeader, &rawData.pData_[i], sizeof(exifHeader)) == 0) { pos = i; break; } } // If found it, store only these data at from this place. if (pos !=-1) { #ifdef DEBUG std::cout << "Exiv2::Jp2Image::readMetadata: Exif header found at position " << pos << "\n"; #endif pos = pos + sizeof(exifHeader); ByteOrder bo = TiffParser::decode(exifData(), iptcData(), xmpData(), rawData.pData_ + pos, rawData.size_ - pos); setByteOrder(bo); } } else { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Failed to decode Exif metadata.\n"; #endif exifData_.clear(); } } else if(memcmp(uuid.uuid, kJp2UuidIptc, sizeof(uuid)) == 0) { // we've hit an embedded IPTC block #ifdef DEBUG std::cout << "Exiv2::Jp2Image::readMetadata: Iptc data found\n"; #endif rawData.alloc(box.boxLength - (sizeof(box) + sizeof(uuid))); bufRead = io_->read(rawData.pData_, rawData.size_); if (io_->error()) throw Error(14); if (bufRead != rawData.size_) throw Error(20); if (IptcParser::decode(iptcData_, rawData.pData_, rawData.size_)) { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Failed to decode IPTC metadata.\n"; #endif iptcData_.clear(); } } else if(memcmp(uuid.uuid, kJp2UuidXmp, sizeof(uuid)) == 0) { // we've hit an embedded XMP block #ifdef DEBUG std::cout << "Exiv2::Jp2Image::readMetadata: Xmp data found\n"; #endif rawData.alloc(box.boxLength - (sizeof(box) + sizeof(uuid))); bufRead = io_->read(rawData.pData_, rawData.size_); if (io_->error()) throw Error(14); if (bufRead != rawData.size_) throw Error(20); xmpPacket_.assign(reinterpret_cast<char *>(rawData.pData_), rawData.size_); std::string::size_type idx = xmpPacket_.find_first_of('<'); if (idx != std::string::npos && idx > 0) { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Removing " << static_cast<uint32_t>(idx) << " characters from the beginning of the XMP packet\n"; #endif xmpPacket_ = xmpPacket_.substr(idx); } if (xmpPacket_.size() > 0 && XmpParser::decode(xmpData_, xmpPacket_)) { #ifndef SUPPRESS_WARNINGS EXV_WARNING << "Failed to decode XMP metadata.\n"; #endif } } } break; } default: { break; } } // Move to the next box. io_->seek(static_cast<long>(position - sizeof(box) + box.boxLength), BasicIo::beg); if (io_->error() || io_->eof()) throw Error(14); } } // Jp2Image::readMetadata
inline int16_t getValue(const byte* buf, ByteOrder byteOrder) { return getShort(buf, byteOrder); }
short PvObject::getShort() const { std::string key = PyPvDataUtility::getValueOrSingleFieldName(pvStructurePtr); return getShort(key); }
void getShorts(std::vector<short> &vec, size_t size) { vec.resize(size); for(size_t i = 0;i < vec.size();i++) vec[i] = getShort(); }