本文整理汇总了C++中Stream类的典型用法代码示例。如果您正苦于以下问题:C++ Stream类的具体用法?C++ Stream怎么用?C++ Stream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Stream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
uint32_t audioServerID;
uint32_t commanderID;
int32_t ch;
char str[128];
uint8_t buf[65536];
MessageInfo msg;
FILE *fp;
monapi_cmemoryinfo *cmi;
connectToKeyboardServer();
// fp = fopen("/APPS/TEST.WAV", "r");
audioServerID = Message::lookupMainThread("AUDIO.EX5");
if( audioServerID == THREAD_UNKNOWN )
exit(printf("Couldn't find an audio server."));
dprintf("AUDIO.EX5 : %x\n", audioServerID);
Message::sendReceive(&msg, audioServerID, MSG_AUDIO_SERVER_COMMAND, GetThreadID, COMMAND_THREAD);
commanderID = msg.arg2;
dprintf("AUDIO.EX5 : %x\n", commanderID);
#if 1
Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, GetServerVersion);
printf("Server version: %x:%x\n", msg.arg2, msg.arg3);
Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, AllocateChannel);
ch = msg.arg2;
printf("Channel: %d\n", ch);
struct audio_server_channel_info ci;
ci.channel = ch;
ci.samplerate = 44100;
ci.bitspersample = 16;
ci.channels = 2;
memcpy(str, &ci, sizeof(ci));
Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, PrepareChannel, 0, 0, str);
printf("Result: %d\n", msg.arg2);
/*
struct audio_server_buffer_info bi;
cmi = monapi_cmemoryinfo_new();
monapi_cmemoryinfo_create(cmi, 0x10000, MONAPI_FALSE);
bi.channel = ch;
bi.handle = cmi->Handle;
bi.size = 0x10000;
makeWave(cmi, 200);
memcpy(str, &bi, sizeof(bi));
Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, RegisterTID);
Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, SetBuffer, 0, 0, str);
*/
Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, CreateStream, ch);
Stream *stream;
stream = Stream::FromHandle(msg.arg2);
makeWave(buf, 512, 200);
/*
int readsize;
fread(buf, 1, 65536, fp);
stream->write(buf, readsize);
*/
stream->write(buf, 512);
printf("Start\n");
Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, StartChannel, ch);
while(1)
{
/*
if( Message::receive(&msg) ) continue;
if( msg.header == MSG_AUDIO_SERVER_MESSAGE )
{
printf("BufferIsEmpty\n");
Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, SetBuffer, 0, 0, str);
}
*/
//int readsize = fread(buf, 1, 65536, fp);
stream->waitForWrite();
// stream->write(buf, readsize);
stream->write(buf, 512);
}
END:
Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, StopChannel, ch);
Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, ReleaseChannel, ch);
_printf("Channel was released.\n");
#else
Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, CreateChannelObject);
ch = msg.arg2;
Message::sendReceive(&msg, commanderID, MSG_AUDIO_SERVER_COMMAND, BindChannelObject, ch, 0, "es1370");
#endif
return 0;
}
示例2: pack
inline void pack( Stream& s, const fc::time_point_sec& tp )
{
uint32_t usec = tp.sec_since_epoch();
s.write( (const char*)&usec, sizeof(usec) );
}
示例3: read
bool CodeBlock::read(Stream &st)
{
assert(!m_loaded);
U32 globalSize, size, i;
version = stream_readi(st);
assert(version == 0x21);
size = stream_readi(st);
#ifdef VERBOSE_CODEBLOCK_READ
fprintf(stderr, "Reading %d bytes of globalStrings, currently at position 0x%X\n", size, (unsigned int)st.tellg());
#endif
if (size)
{
globalStrings = new char[size];
globalStringsMaxLen = size;
st.read(globalStrings, size);
}
globalSize = size;
size = stream_readi(st);
#ifdef VERBOSE_CODEBLOCK_READ
fprintf(stderr, "Reading %d bytes of globalFloats, currently at position 0x%X\n", size, (unsigned int)st.tellg());
#endif
if (size)
{
globalFloats = new F64[size];
for (U32 i = 0; i < size; i++)
globalFloats[i] = stream_readf(st);
}
size = stream_readi(st);
#ifdef VERBOSE_CODEBLOCK_READ
fprintf(stderr, "Reading %d bytes of functionStrings, currently at position 0x%X\n", size, (unsigned int)st.tellg());
#endif
if (size)
{
functionStrings = new char[size];
functionStringsMaxLen = size;
st.read(functionStrings, size);
}
size = stream_readi(st);
#ifdef VERBOSE_CODEBLOCK_READ
fprintf(stderr, "Reading %d bytes of functionFloats, currently at position 0x%X\n", size, (unsigned int)st.tellg());
#endif
if (size)
{
functionFloats = new F64[size];
for (U32 i = 0; i < size; i++)
functionFloats[i] = stream_readf(st);
}
U32 codeLength;
codeLength = stream_readi(st);
codeSize = codeLength;
lineBreakPairCount = stream_readi(st);
#ifdef VERBOSE_CODEBLOCK_READ
fprintf(stderr, "Currently at position 0x%X\n", (unsigned int)st.tellg());
#endif
U32 totSize = codeLength + lineBreakPairCount * 2;
#ifdef VERBOSE_CODEBLOCK_READ
fprintf(stderr, "Code length: %d Line Break count: %d totSize: %d\n", codeLength, lineBreakPairCount, totSize);
#endif
code = new U32[totSize];
for (i = 0; i < codeLength; i++)
{
U8 b;
st.read((char*)&b, 1);
if (b == 0xFF)
code[i] = stream_readi(st);
else
code[i] = b;
}
for (i = codeLength; i < totSize; i++)
code[i] = stream_readi(st);
lineBreakPairs = code + codeLength;
// StringTable-ize our identifiers.
U32 identCount;
identCount = stream_readi(st);
while (identCount--)
{
U32 offset;
offset = stream_readi(st);
/*StringTableEntry ste;
if (offset < globalSize)
ste = StringTable->insert(globalStrings + offset);
else
ste = StringTable->insert("");*/
char *ste;
if (offset < globalSize)
//.........这里部分代码省略.........
示例4: recv
void recv(Stream & stream, uint16_t len)override {
this->len = len;
this->WndSupportLevel = stream.in_uint32_le();
this->NumIconCaches = stream.in_uint8();
this->NumIconCacheEntries = stream.in_uint16_le();
}
示例5: void
void cv::gpu::BFMatcher_GPU::radiusMatchCollection(const GpuMat& query, GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance, GpuMat& nMatches,
float maxDistance, const vector<GpuMat>& masks, Stream& stream)
{
if (query.empty() || empty())
return;
using namespace cv::gpu::device::bf_radius_match;
typedef void (*caller_t)(const PtrStepSzb& query, const PtrStepSzb* trains, int n, float maxDistance, const PtrStepSzb* masks,
const PtrStepSzi& trainIdx, const PtrStepSzi& imgIdx, const PtrStepSzf& distance, const PtrStepSz<unsigned int>& nMatches,
int cc, cudaStream_t stream);
static const caller_t callersL1[] =
{
matchL1_gpu<unsigned char>, 0/*matchL1_gpu<signed char>*/,
matchL1_gpu<unsigned short>, matchL1_gpu<short>,
matchL1_gpu<int>, matchL1_gpu<float>
};
static const caller_t callersL2[] =
{
0/*matchL2_gpu<unsigned char>*/, 0/*matchL2_gpu<signed char>*/,
0/*matchL2_gpu<unsigned short>*/, 0/*matchL2_gpu<short>*/,
0/*matchL2_gpu<int>*/, matchL2_gpu<float>
};
static const caller_t callersHamming[] =
{
matchHamming_gpu<unsigned char>, 0/*matchHamming_gpu<signed char>*/,
matchHamming_gpu<unsigned short>, 0/*matchHamming_gpu<short>*/,
matchHamming_gpu<int>, 0/*matchHamming_gpu<float>*/
};
DeviceInfo info;
int cc = info.majorVersion() * 10 + info.minorVersion();
if (!TargetArchs::builtWith(GLOBAL_ATOMICS) || !DeviceInfo().supports(GLOBAL_ATOMICS))
CV_Error(CV_StsNotImplemented, "The device doesn't support global atomics");
const int nQuery = query.rows;
CV_Assert(query.channels() == 1 && query.depth() < CV_64F);
CV_Assert(trainIdx.empty() || (trainIdx.rows == nQuery && trainIdx.size() == distance.size() && trainIdx.size() == imgIdx.size()));
CV_Assert(norm == NORM_L1 || norm == NORM_L2 || norm == NORM_HAMMING);
const caller_t* callers = norm == NORM_L1 ? callersL1 : norm == NORM_L2 ? callersL2 : callersHamming;
ensureSizeIsEnough(1, nQuery, CV_32SC1, nMatches);
if (trainIdx.empty())
{
ensureSizeIsEnough(nQuery, std::max((nQuery / 100), 10), CV_32SC1, trainIdx);
ensureSizeIsEnough(nQuery, std::max((nQuery / 100), 10), CV_32SC1, imgIdx);
ensureSizeIsEnough(nQuery, std::max((nQuery / 100), 10), CV_32FC1, distance);
}
if (stream)
stream.enqueueMemSet(nMatches, Scalar::all(0));
else
nMatches.setTo(Scalar::all(0));
caller_t func = callers[query.depth()];
CV_Assert(func != 0);
vector<PtrStepSzb> trains_(trainDescCollection.begin(), trainDescCollection.end());
vector<PtrStepSzb> masks_(masks.begin(), masks.end());
func(query, &trains_[0], static_cast<int>(trains_.size()), maxDistance, masks_.size() == 0 ? 0 : &masks_[0],
trainIdx, imgIdx, distance, nMatches, cc, StreamAccessor::getStream(stream));
}
示例6: parser
parser(const Stream& iss)
{
parsed = 0;
iss_.str(iss.str());
}
示例7: front_out_gcc_conference_user_data_sc_sec1
static inline void front_out_gcc_conference_user_data_sc_sec1(Stream & stream,
int encryptionLevel,
uint8_t (&serverRandom)[32],
int rc4_key_size,
uint8_t (&pub_mod)[512],
uint8_t (&pri_exp)[512],
Random * gen)
{
Rsakeys rsa_keys(CFG_PATH "/" RSAKEYS_INI);
gen->random(serverRandom, 32);
uint8_t pub_sig[512];
memcpy(pub_mod, rsa_keys.pub_mod, 64);
memcpy(pub_sig, rsa_keys.pub_sig, 64);
memcpy(pri_exp, rsa_keys.pri_exp, 64);
stream.out_uint16_le(SC_SECURITY);
stream.out_uint16_le(236); // length, including tag and length fields
stream.out_uint32_le(rc4_key_size); // key len 1 = 40 bit 2 = 128 bit
// crypt level 1 = low 2 = medium, 3 = high
stream.out_uint32_le(encryptionLevel);
stream.out_uint32_le(32); // random len
stream.out_uint32_le(184); // len of rsa info(certificate)
stream.out_copy_bytes(serverRandom, 32);
/* here to end is certificate */
/* HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ */
/* TermService\Parameters\Certificate */
stream.out_uint32_le(1);
stream.out_uint32_le(1);
stream.out_uint32_le(1);
// 96 bytes long of sec_tag pubkey
stream.out_uint16_le(SEC_TAG_PUBKEY);
stream.out_uint16_le(92); // length
stream.out_uint32_le(SEC_RSA_MAGIC);
stream.out_uint32_le(72); /* 72 bytes modulus len */
stream.out_uint32_be(0x00020000);
stream.out_uint32_be(0x3f000000);
stream.out_copy_bytes(rsa_keys.pub_exp, 4); /* pub exp */
stream.out_copy_bytes(pub_mod, 64); /* pub mod */
stream.out_clear_bytes(8); /* pad */
// 76 bytes long of sec_tag_pub_sig
stream.out_uint16_le(SEC_TAG_KEYSIG);
stream.out_uint16_le(72); /* len */
stream.out_copy_bytes(pub_sig, 64); /* pub sig */
stream.out_clear_bytes(8); /* pad */
/* end certificate */
}
示例8: parse_mcs_data_sc_security
static inline void parse_mcs_data_sc_security(Stream & cr_stream,
CryptContext & encrypt,
CryptContext & decrypt,
uint32_t & server_public_key_len,
uint8_t (& client_crypt_random)[512],
int & encryptionLevel,
Random * gen)
{
LOG(LOG_INFO, "SC_SECURITY");
uint32_t encryptionMethod = cr_stream.in_uint32_le(); /* 1 = 40-bit, 2 = 128-bit */
LOG(LOG_INFO, "encryptionMethod = %u", encryptionMethod);
encryptionLevel = cr_stream.in_uint32_le(); /* 1 = low, 2 = medium, 3 = high */
LOG(LOG_INFO, "encryptionLevel = %u", encryptionLevel);
if (encryptionLevel == 0 && encryptionMethod == 0) { /* no encryption */
LOG(LOG_INFO, "No encryption");
return;
}
uint8_t modulus[SEC_MAX_MODULUS_SIZE];
uint8_t exponent[SEC_EXPONENT_SIZE];
memset(modulus, 0, sizeof(modulus));
memset(exponent, 0, sizeof(exponent));
ssllib ssl;
// serverRandomLen (4 bytes): A 32-bit, unsigned integer. The size in bytes of
// the serverRandom field. If the encryptionMethod and encryptionLevel fields
// are both set to 0 then the contents of this field MUST be ignored and the
// serverRandom field MUST NOT be present. Otherwise, this field MUST be set to
// 32 bytes.
uint32_t serverRandomLen = cr_stream.in_uint32_le();
LOG(LOG_INFO, "serverRandomLen = %u", serverRandomLen);
if (serverRandomLen != SEC_RANDOM_SIZE) {
LOG(LOG_ERR, "parse_crypt_info_error: serverRandomLen %d, expected %d", serverRandomLen, SEC_RANDOM_SIZE);
throw Error(ERR_SEC_PARSE_CRYPT_INFO_BAD_RANDOM_LEN);
}
// serverCertLen (4 bytes): A 32-bit, unsigned integer. The size in bytes of the
// serverCertificate field. If the encryptionMethod and encryptionLevel fields
// are both set to 0 then the contents of this field MUST be ignored and the
// serverCertificate field MUST NOT be present.
uint32_t serverCertLen = cr_stream.in_uint32_le();
LOG(LOG_INFO, "serverCertLen = %u", serverCertLen);
// serverRandom (variable): The variable-length server random value used to
// derive session keys (see sections 5.3.4 and 5.3.5). The length in bytes is
// given by the serverRandomLen field. If the encryptionMethod and
// encryptionLevel fields are both set to 0 then this field MUST NOT be present.
uint8_t serverRandom[SEC_RANDOM_SIZE] = {};
cr_stream.in_copy_bytes(serverRandom, serverRandomLen);
// serverCertificate (variable): The variable-length certificate containing the
// server's public key information. The length in bytes is given by the
// serverCertLen field. If the encryptionMethod and encryptionLevel fields are
// both set to 0 then this field MUST NOT be present.
/* RSA info */
uint8_t * end = cr_stream.p + serverCertLen;
if (end > cr_stream.end) {
LOG(LOG_ERR,
"serverCertLen outside of buffer (%u bytes, remains: %u)", serverCertLen, cr_stream.end - cr_stream.p);
throw Error(ERR_SEC_PARSE_CRYPT_INFO_BAD_RSA_LEN);
}
uint32_t dwVersion = cr_stream.in_uint32_le(); /* 1 = RDP4-style, 0x80000002 = X.509 */
LOG(LOG_INFO, "dwVersion = %x", dwVersion);
if (dwVersion & SCSecurityGccUserData::CERT_CHAIN_VERSION_1) {
LOG(LOG_DEBUG, "We're going for the RDP4-style encryption");
// dwSigAlgId (4 bytes): A 32-bit, unsigned integer. The signature algorithm
// identifier. This field MUST be set to SIGNATURE_ALG_RSA (0x00000001).
uint32_t dwSigAlgId = cr_stream.in_uint32_le();
LOG(LOG_DEBUG, "dwSigAlgId = %u", dwSigAlgId);
// dwKeyAlgId (4 bytes): A 32-bit, unsigned integer. The key algorithm
// identifier. This field MUST be set to KEY_EXCHANGE_ALG_RSA (0x00000001).
uint32_t dwKeyAlgId = cr_stream.in_uint32_le();
LOG(LOG_DEBUG, "dwKeyAlgId = %u", dwKeyAlgId);
LOG(LOG_DEBUG, "ReceivingPublic key, RDP4-style");
// wPublicKeyBlobType (2 bytes): A 16-bit, unsigned integer. The type of data
// in the PublicKeyBlob field. This field MUST be set to BB_RSA_KEY_BLOB
// (0x0006).
TODO("put assertion to check type and throw and error if not as expected");
uint16_t wPublicKeyBlobType = cr_stream.in_uint16_le();
LOG(LOG_DEBUG, "wPublicKeyBlobType = %u", wPublicKeyBlobType);
// wPublicKeyBlobLen (2 bytes): A 16-bit, unsigned integer. The size in bytes
// of the PublicKeyBlob field.
uint16_t wPublicKeyBlobLen = cr_stream.in_uint16_le();
LOG(LOG_DEBUG, "wPublicKeyBlobLen = %u", wPublicKeyBlobLen);
uint8_t * next_tag = cr_stream.p + wPublicKeyBlobLen;
// PublicKeyBlob (variable): Variable-length server public key bytes, formatted
// using the Rivest-Shamir-Adleman (RSA) Public Key structure (section
// 2.2.1.4.3.1.1.1). The length in bytes is given by the wPublicKeyBlobLen
//.........这里部分代码省略.........
示例9: emit
void emit(Stream & stream)
{
stream.out_uint16_le(this->userDataType);
stream.out_uint16_le(this->length);
}
示例10: if
//----------------------------------------------------------------------
// DumpCallback
//
// A callback function for the static DWARFDebugInfo::Parse() function
// that gets called each time a compile unit header or debug information
// entry is successfully parsed.
//
// This function dump DWARF information and obey recurse depth and
// whether a single DIE is to be dumped (or all of the data).
//----------------------------------------------------------------------
static dw_offset_t DumpCallback
(
SymbolFileDWARF* dwarf2Data,
DWARFCompileUnitSP& cu_sp,
DWARFDebugInfoEntry* die,
const dw_offset_t next_offset,
const uint32_t curr_depth,
void* userData
)
{
DumpInfo* dumpInfo = (DumpInfo*)userData;
const DWARFCompileUnit* cu = cu_sp.get();
Stream *s = dumpInfo->strm;
bool show_parents = s->GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowAncestors);
if (die)
{
// Are we dumping everything?
if (dumpInfo->die_offset == DW_INVALID_OFFSET)
{
// Yes we are dumping everything. Obey our recurse level though
if (curr_depth < dumpInfo->recurse_depth)
die->Dump(dwarf2Data, cu, *s, 0);
}
else
{
// We are dumping a specific DIE entry by offset
if (dumpInfo->die_offset == die->GetOffset())
{
// We found the DIE we were looking for, dump it!
if (show_parents)
{
s->SetIndentLevel(0);
const uint32_t num_ancestors = dumpInfo->ancestors.size();
if (num_ancestors > 0)
{
for (uint32_t i=0; i<num_ancestors-1; ++i)
{
dumpInfo->ancestors[i].Dump(dwarf2Data, cu, *s, 0);
s->IndentMore();
}
}
}
dumpInfo->found_depth = curr_depth;
die->Dump(dwarf2Data, cu, *s, 0);
// Note that we found the DIE we were looking for
dumpInfo->found_die = true;
// Since we are dumping a single DIE, if there are no children we are done!
if (!die->HasChildren() || dumpInfo->recurse_depth == 0)
return DW_INVALID_OFFSET; // Return an invalid address to end parsing
}
else if (dumpInfo->found_die)
{
// Are we done with all the children?
if (curr_depth <= dumpInfo->found_depth)
return DW_INVALID_OFFSET;
// We have already found our DIE and are printing it's children. Obey
// our recurse depth and return an invalid offset if we get done
// dumping all the the children
if (dumpInfo->recurse_depth == UINT32_MAX || curr_depth <= dumpInfo->found_depth + dumpInfo->recurse_depth)
die->Dump(dwarf2Data, cu, *s, 0);
}
else if (dumpInfo->die_offset > die->GetOffset())
{
if (show_parents)
dumpInfo->ancestors.back() = *die;
}
}
// Keep up with our indent level
if (die->IsNULL())
{
if (show_parents)
dumpInfo->ancestors.pop_back();
if (curr_depth <= 1)
return cu->GetNextCompileUnitOffset();
else
s->IndentLess();
}
else if (die->HasChildren())
{
if (show_parents)
//.........这里部分代码省略.........
示例11: data_recving
void data_recving (MYSQL* conn, char * tablename, int nr_be)
{
int nr_exited = 0;
int tag;
int count = 0;
// PacketPtr pack;
int rank, eid, tid, data, finish, nr_record, mpi_rank, type, src_rank, dst_rank, sendsize, sendtype, recvsize, recvtype;
int mpi_comm, mpi_tag;
MRN::Network * net = GetNetwork();
unsigned pid;
long long unsigned time;
unsigned long time_s, time_us;
char sql[2048];
char buffer[500];
char instance[40], metric[40];
char *ename = NULL;
char *hostname = NULL;
char *procdata = NULL;
Communicator *comm = net->get_BroadcastCommunicator();
Stream *stream = net->new_Stream( comm, TFILTER_NULL, SFILTER_DONTWAIT );
stream->send( PROT_DATA, "%d", 0 );
printf_d("[MRNFE] recieving data...nr_exited is %d nr_be is %d\n",nr_exited,nr_be);
if (mysql_autocommit (conn, 0) != 0)
printf_d ("[MRNFE] %s\n", mysql_error(conn));
while( nr_exited != nr_be )
{
PacketPtr pack;
stream->recv( &tag, pack );
count ++;
switch (tag)
{
case PROT_DATA:
pack->unpack("%d %d %d %uld %s %d %s",
&tid,
&pid,
&eid,
&time,
&hostname,
&finish,
&ename);
char *sql_tmp;
sql_tmp = (char *) calloc (sizeof (char *), 200);
snprintf_d(sql_tmp, 200, "CALL insertdata ( -1,%d, \"%s\" , %d, \"%s\", 7,\"FFFFFFFF\", '%llu', %d );"
, pid, hostname, eid, ename, time, finish);
if (mysql_query (conn, sql_tmp))
printf_d ("[MRNFE] %s\n", mysql_error(conn));
free (sql_tmp);
free (hostname);
free (ename);
hostname = NULL;
ename = NULL;
break;
case PROT_MPIDATA: /*MPI wrapper trace 数据*/
pack->unpack("%d %ud %s %d %s %d %d %d %d %d %d %d %d %d %uld %d",
&mpi_rank,
&pid,
&hostname,
&eid,
&ename,
&type,
&mpi_comm,
&mpi_tag,
&src_rank,
&dst_rank,
&sendsize,
&sendtype,
&recvsize,
&recvtype,
&time,
&finish);
#ifdef debug
printf_d ("[DEBUG]:\tRecv_Data: %d %u %s %d %s %d %x %d %d %d %d %d %d %d %llu %d\n",
mpi_rank,
pid,
hostname,
eid,
ename,
type,
mpi_comm,
mpi_tag,
src_rank,
dst_rank,
sendsize,
sendtype,
recvsize,
recvtype,
time,
finish);
//.........这里部分代码省略.........
示例12: read
bool Image::read(Stream stream)
{
BytesArray mem;
mem = stream.process();
if (!stream.ok())
return false;
FIMEMORY* fimem = FreeImage_OpenMemory(mem.raw(), mem.size());
if (!fimem)
return false;
FREE_IMAGE_FORMAT fiformat = FreeImage_GetFileTypeFromMemory(fimem);
FIBITMAP* fibit = FreeImage_LoadFromMemory(fiformat, fimem);
FreeImage_CloseMemory(fimem);
if (!fibit)
return false;
//FIBITMAP* fitmp = fibit;
//fibit = FreeImage_ConvertTo32Bits(fitmp);
//FreeImage_Unload(fitmp);
uint64 red_mask = FreeImage_GetRedMask(fibit);
uint64 green_mask = FreeImage_GetGreenMask(fibit);
uint64 blue_mask = FreeImage_GetBlueMask(fibit);
uint64 alpha_mask = 0;
PixelFormat tmpformat;
tmpformat.setDepthBits(0);
tmpformat.setStencilBits(0);
tmpformat.setColorBitsFromMasks(&red_mask, &green_mask, &blue_mask, &alpha_mask);
if (FreeImage_GetBPP(fibit) != tmpformat.bitsPerPixel())
{
alpha_mask = ~(uint32)(red_mask | green_mask | blue_mask);
tmpformat.setColorBitsFromMasks(&red_mask, &green_mask, &blue_mask, &alpha_mask);
}
format = TransferFormat(tmpformat.getRedBits(), tmpformat.getGreenBits(), tmpformat.getBlueBits(), tmpformat.getAlphaBits());
MIRROR_ASSERT(FreeImage_GetBPP(fibit) == format.bitsPerPixel(), "Conversion from FreeImage bitmap to Mirror bitmap failed!\nBits per pixel conversion from "
"FreeImage color masks probably returned bad bits-per-channel values respectivly for red, green and blue channel, as"
" stored inside PixelFormat structure - see PixelFormat::setColorBitsFromMasks for calculations!");
my_size = { FreeImage_GetWidth(fibit), FreeImage_GetHeight(fibit) };
uint32 req_bits = my_size.width()*my_size.height()*format.bitsPerPixel();
pixels.resize(PixelFormat::bitsToFullBytes(req_bits));
const uint32 pitch = FreeImage_GetPitch(fibit);
const uint32 lineSize = FreeImage_GetLine(fibit);
uint32 pixidx = 0;
BYTE* line = FreeImage_GetBits(fibit);
for (uint32 y = 0; y < my_size.height(); ++y, line += pitch)
for (BYTE* pixel = line; pixel < line + lineSize; pixel += format.bytesPerPixel())
{
pixels[pixidx++] = pixel[2]; //red
pixels[pixidx++] = pixel[1]; //green
pixels[pixidx++] = pixel[0]; //blue
if (alpha_mask)
pixels[pixidx++] = pixel[3]; //alpha
}
////transfer pixels from FreeImage to our buffer as raw bits, should be in RGBA order thanks to our new color masks
//FreeImage_ConvertToRawBits(pixels.raw(), fibit, format.bitsPerPixel()*my_size.width(), format.bitsPerPixel(), 0, 0, 0, TRUE);
FreeImage_Unload(fibit);
return true;
}
示例13: write
void SimPersistSet::write( Stream& stream, U32 tabStop, U32 flags )
{
if( ( flags & SelectedOnly ) && !isSelected() )
return;
// If the selection is transient, we cannot really save it.
// Just invoke the default SimObject::write and return.
if( !getCanSave() )
{
Con::errorf( "SimPersistSet::write - transient set being saved: %d:%s (%s)",
getId(), getClassName(), getName() );
Parent::write( stream, tabStop, flags );
return;
}
// If there are unresolved PIDs, give resolving them one last
// chance before writing out the set.
if( !mUnresolvedPIDs.empty() )
resolvePIDs();
// Write the set out.
stream.writeTabs( tabStop );
StringBuilder buffer;
buffer.format( "new %s(%s", getClassName(), getName() ? getName() : "" );
// Write the persistent IDs of all child objects into the set's
// object constructor so we see them passed back to us through
// processArguments when the object gets read in.
const U32 numChildren = size();
for( U32 i = 0; i < numChildren; ++ i )
{
SimObject* child = at( i );
SimPersistID* pid = child->getPersistentId();
AssertWarn( pid != NULL, "SimPersistSet::write - object without pid in persistent selection!" );
if( !pid )
continue;
buffer.append( ',' );
buffer.append( '"' );
buffer.append( pid->getUUID().toString() );
buffer.append( '"' );
}
buffer.append( ") {\r\n" );
stream.write( buffer.length(), buffer.data() );
// Write our object fields.
writeFields( stream, tabStop + 1 );
// Close our object definition.
stream.writeTabs( tabStop );
stream.write( 4, "};\r\n" );
}
示例14: write
void CompilerStringTable::write(Stream &st)
{
st.write(totalLen);
for(Entry *walk = list; walk; walk = walk->next)
st.write(walk->len, walk->string);
}
示例15: BigEndian32
ErrorCode InitialObjectDescriptor::Read(Stream& stream)
{
ULONG nRead;
uint32 verflags;
nRead = stream.Read(&verflags, 4);
verflags = BigEndian32(verflags);
uint8 version = (uint8)(verflags>>24);
BaseDescriptor descr;
descr.Descend(stream);
if (descr.m_tag == 0x01) // ObjectDescrTag
{
VERIFY(0);
}
else if (descr.m_tag == 0x02) // InitialObjectDescrTag
{
VERIFY(0);
}
else if (descr.m_tag == 0x10) // MP4_IOD_Tag
{
// System::IO::CBitStream bitstream(new System::IO::CByteStream(stream));
// System::IO::CBitStream32* pBitStream = &bitstream;
uint16 word = ReadByte(stream)<<8;
word |= ReadByte(stream);
// stream->Read(&word, 2);
// word = BigEndian16(word);
m_ObjectDescriptorID = word >> 6;//pBitStream->getnbits(10);
int bURLFlag = (word>>5) & 1;//pBitStream->getbit();// URL_Flag;
int includeInlineProfileLevelFlag = (word>>4) & 1;//pBitStream->getbit();
int reserved = word & 15;//pBitStream->getnbits(4); // reserved=0b1111;
ASSERT(reserved == 0xf);
if (bURLFlag)
{
uint8 URLlength;
//= pBitStream->getnbits(8);// URLlength;
//bit(8) URLstring[URLlength];
ASSERT(0);
}
else
{
uint8 ODProfileLevelIndication = ReadByte(stream);
uint8 sceneProfileLevelIndication = ReadByte(stream);
uint8 audioProfileLevelIndication = ReadByte(stream);
uint8 visualProfileLevelIndication = ReadByte(stream);
uint8 graphicsProfileLevelIndication = ReadByte(stream);
while (descr.More(stream))
{
BaseDescriptor descr2;
descr2.Descend(stream);
if (descr2.m_tag == 0x0E) // ES_ID_IncTag
{
uint32 Track_ID;
stream.Read(&Track_ID, 4);//= pBitStream->getnbits(32);
Track_ID = BigEndian32(Track_ID);
m_trackID.Add(Track_ID);
}
else
{
MessageBeep(-1);
}
descr2.Ascend(stream);
}
/*
ES_Descriptor esDescr[1 .. 255];
OCI_Descriptor ociDescr[0 .. 255];
IPMP_DescriptorPointer ipmpDescrPtr[0 .. 255];
*/
}
//ExtensionDescriptor extDescr[0 .. 255];
}