本文整理汇总了C++中writeU32函数的典型用法代码示例。如果您正苦于以下问题:C++ writeU32函数的具体用法?C++ writeU32怎么用?C++ writeU32使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了writeU32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeU8
void ToolCapabilities::serialize(std::ostream &os, u16 protocol_version) const
{
if(protocol_version <= 17)
writeU8(os, 1); // version
else
writeU8(os, 2); // version
writeF1000(os, full_punch_interval);
writeS16(os, max_drop_level);
writeU32(os, groupcaps.size());
for(std::map<std::string, ToolGroupCap>::const_iterator
i = groupcaps.begin(); i != groupcaps.end(); i++){
const std::string *name = &i->first;
const ToolGroupCap *cap = &i->second;
os<<serializeString(*name);
writeS16(os, cap->uses);
writeS16(os, cap->maxlevel);
writeU32(os, cap->times.size());
for(std::map<int, float>::const_iterator
i = cap->times.begin(); i != cap->times.end(); i++){
writeS16(os, i->first);
writeF1000(os, i->second);
}
}
if(protocol_version > 17){
writeU32(os, damageGroups.size());
for(std::map<std::string, s16>::const_iterator
i = damageGroups.begin(); i != damageGroups.end(); i++){
os<<serializeString(i->first);
writeS16(os, i->second);
}
}
}
示例2: writeU32
void U3DBitStreamWriter::writeCompressedU32(MLuint32 context, MLuint32 uValue)
{
if (context == U3DContext_StaticFull) // In this case a division by zero might occur in _writeSymbol() so we capture it here
{
writeU32(uValue);
}
else
{
_compressed = true;
bool escape = false;
if((context != 0) && (context < U3D_MaxRange))
{
writeSymbol(context, uValue, escape);
if(escape == true)
{
writeU32(uValue);
_contextManager.addSymbol(context, uValue + 1U);
}
}
else
{
writeU32(uValue);
}
}
}
示例3: getTrack
status WAVEFile::writeFrameCount()
{
uint32_t factSize = 4;
uint32_t totalFrameCount;
Track *track = getTrack();
/* Omit the fact chunk only for uncompressed integer audio formats. */
if (track->f.compressionType == AF_COMPRESSION_NONE &&
(track->f.sampleFormat == AF_SAMPFMT_TWOSCOMP ||
track->f.sampleFormat == AF_SAMPFMT_UNSIGNED))
return AF_SUCCEED;
/*
If the offset for the fact chunk hasn't been set yet,
set it to the file's current position.
*/
if (factOffset == 0)
factOffset = fh->tell();
else
fh->seek(factOffset, File::SeekFromBeginning);
fh->write("fact", 4);
writeU32(&factSize);
totalFrameCount = track->totalfframes;
writeU32(&totalFrameCount);
return AF_SUCCEED;
}
示例4: getTrack
status CAFFile::writeDescription()
{
Track *track = getTrack();
Tag desc("desc");
int64_t chunkLength = 32;
double sampleRate = track->f.sampleRate;
Tag formatID("lpcm");
uint32_t formatFlags = 0;
if (track->f.byteOrder == AF_BYTEORDER_LITTLEENDIAN)
formatFlags |= kCAFLinearPCMFormatFlagIsLittleEndian;
if (track->f.isFloat())
formatFlags |= kCAFLinearPCMFormatFlagIsFloat;
uint32_t bytesPerPacket = track->f.bytesPerFrame(false);
uint32_t framesPerPacket = 1;
uint32_t channelsPerFrame = track->f.channelCount;
uint32_t bitsPerChannel = track->f.sampleWidth;
if (track->f.compressionType == AF_COMPRESSION_G711_ULAW)
{
formatID = "ulaw";
formatFlags = 0;
bytesPerPacket = channelsPerFrame;
bitsPerChannel = 8;
}
else if (track->f.compressionType == AF_COMPRESSION_G711_ALAW)
{
formatID = "alaw";
formatFlags = 0;
bytesPerPacket = channelsPerFrame;
bitsPerChannel = 8;
}
else if (track->f.compressionType == AF_COMPRESSION_IMA)
{
formatID = "ima4";
formatFlags = 0;
bytesPerPacket = track->f.bytesPerPacket;
framesPerPacket = track->f.framesPerPacket;
bitsPerChannel = 16;
}
if (!writeTag(&desc) ||
!writeS64(&chunkLength) ||
!writeDouble(&sampleRate) ||
!writeTag(&formatID) ||
!writeU32(&formatFlags) ||
!writeU32(&bytesPerPacket) ||
!writeU32(&framesPerPacket) ||
!writeU32(&channelsPerFrame) ||
!writeU32(&bitsPerChannel))
return AF_FAIL;
return AF_SUCCEED;
}
示例5: getTrack
status VOCFile::writeSoundData()
{
if (m_soundDataOffset == -1)
m_soundDataOffset = m_fh->tell();
else
m_fh->seek(m_soundDataOffset, File::SeekFromBeginning);
Track *track = getTrack();
assert((track->f.isSigned() && track->f.sampleWidth == 16) ||
(track->f.isUnsigned() && track->f.sampleWidth == 8));
uint8_t blockType = kVOCSoundDataNew;
uint32_t blockSize = 12 + track->data_size;
uint32_t blockHeader = blockSize << 8 | blockType;
if (!writeU32(&blockHeader))
return AF_FAIL;
uint32_t sampleRate = track->f.sampleRate;
uint8_t bitsPerSample = track->f.sampleWidth;
uint8_t channels = track->f.channelCount;
uint16_t format;
if (track->f.compressionType == AF_COMPRESSION_G711_ULAW)
{
format = kVOCFormatUlaw;
bitsPerSample = 8;
}
else if (track->f.compressionType == AF_COMPRESSION_G711_ALAW)
{
format = kVOCFormatAlaw;
bitsPerSample = 8;
}
else if (track->f.compressionType == AF_COMPRESSION_NONE)
{
if (track->f.isUnsigned())
format = kVOCFormatU8;
else
format = kVOCFormatS16;
}
uint32_t pad = 0;
if (!writeU32(&sampleRate) ||
!writeU8(&bitsPerSample) ||
!writeU8(&channels) ||
!writeU16(&format) ||
!writeU32(&pad))
return AF_FAIL;
if (track->fpos_first_frame == 0)
track->fpos_first_frame = m_fh->tell();
return AF_SUCCEED;
}
示例6: writeU32
status SampleVisionFile::writeLoops()
{
for (int i=0; i<8; i++)
{
uint32_t startFrame = kSMPInvalidSamplePosition, endFrame = 0;
uint8_t type = 0;
uint16_t count = 0;
writeU32(&startFrame);
writeU32(&endFrame);
writeU8(&type);
writeU16(&count);
}
return AF_SUCCEED;
}
示例7: getTrack
status IFFFile::writeVHDR()
{
uint32_t chunkSize;
uint32_t oneShotSamples, repeatSamples, samplesPerRepeat;
uint16_t sampleRate;
uint8_t octaves, compression;
uint32_t volume;
/*
If VHDR_offset hasn't been set yet, set it to the
current offset.
*/
if (m_VHDR_offset == 0)
m_VHDR_offset = m_fh->tell();
else
m_fh->seek(m_VHDR_offset, File::SeekFromBeginning);
Track *track = getTrack();
m_fh->write("VHDR", 4);
chunkSize = 20;
writeU32(&chunkSize);
/*
IFF/8SVX files have only one audio channel, so the
number of samples is equal to the number of frames.
*/
oneShotSamples = track->totalfframes;
writeU32(&oneShotSamples);
repeatSamples = 0;
writeU32(&repeatSamples);
samplesPerRepeat = 0;
writeU32(&samplesPerRepeat);
sampleRate = track->f.sampleRate;
writeU16(&sampleRate);
octaves = 0;
compression = 0;
writeU8(&octaves);
writeU8(&compression);
/* Volume is in fixed-point notation; 65536 means gain of 1.0. */
volume = 65536;
writeU32(&volume);
return AF_SUCCEED;
}
示例8: writeU16
void MapBlock::serializeDiskExtra(std::ostream &os, u8 version)
{
// Versions up from 9 have block objects. (DEPRECATED)
if(version >= 9)
{
// count=0
writeU16(os, 0);
}
// Versions up from 15 have static objects.
if(version >= 15)
{
m_static_objects.serialize(os);
}
// Timestamp
if(version >= 17)
{
writeU32(os, getTimestamp());
}
// Scan and write node definition id mapping
if(version >= 21){
NameIdMapping nimap;
getBlockNodeIdMapping(&nimap, this, m_gamedef->ndef());
nimap.serialize(os);
}
}
示例9: occurance
/*
Minetest Schematic File Format
All values are stored in big-endian byte order.
[u32] signature: 'MTSM'
[u16] version: 3
[u16] size X
[u16] size Y
[u16] size Z
For each Y:
[u8] slice probability value
[Name-ID table] Name ID Mapping Table
[u16] name-id count
For each name-id mapping:
[u16] name length
[u8[]] name
ZLib deflated {
For each node in schematic: (for z, y, x)
[u16] content
For each node in schematic:
[u8] probability of occurance (param1)
For each node in schematic:
[u8] param2
}
Version changes:
1 - Initial version
2 - Fixed messy never/always place; 0 probability is now never, 0xFF is always
3 - Added y-slice probabilities; this allows for variable height structures
*/
void DecoSchematic::saveSchematicFile(INodeDefManager *ndef) {
std::ostringstream ss(std::ios_base::binary);
writeU32(ss, MTSCHEM_FILE_SIGNATURE); // signature
writeU16(ss, MTSCHEM_FILE_VER_HIGHEST_WRITE); // version
writeV3S16(ss, size); // schematic size
for (int y = 0; y != size.Y; y++) // Y slice probabilities
writeU8(ss, slice_probs[y]);
std::vector<content_t> usednodes;
int nodecount = size.X * size.Y * size.Z;
build_nnlist_and_update_ids(schematic, nodecount, &usednodes);
u16 numids = usednodes.size();
writeU16(ss, numids); // name count
for (int i = 0; i != numids; i++)
ss << serializeString(ndef->get(usednodes[i]).name); // node names
// compressed bulk node data
MapNode::serializeBulk(ss, SER_FMT_VER_HIGHEST_WRITE, schematic,
nodecount, 2, 2, true);
fs::safeWriteToFile(filename, ss.str());
}
示例10: serializeOld
void ContentFeatures::serialize(std::ostream &os, u16 protocol_version)
{
if(protocol_version < 14){
serializeOld(os, protocol_version);
return;
}
writeU8(os, 6); // version
os<<serializeString(name);
writeU16(os, groups.size());
for(ItemGroupList::const_iterator
i = groups.begin(); i != groups.end(); i++){
os<<serializeString(i->first);
writeS16(os, i->second);
}
writeU8(os, drawtype);
writeF1000(os, visual_scale);
writeU8(os, 6);
for(u32 i=0; i<6; i++)
tiledef[i].serialize(os, protocol_version);
writeU8(os, CF_SPECIAL_COUNT);
for(u32 i=0; i<CF_SPECIAL_COUNT; i++){
tiledef_special[i].serialize(os, protocol_version);
}
writeU8(os, alpha);
writeU8(os, post_effect_color.getAlpha());
writeU8(os, post_effect_color.getRed());
writeU8(os, post_effect_color.getGreen());
writeU8(os, post_effect_color.getBlue());
writeU8(os, param_type);
writeU8(os, param_type_2);
writeU8(os, is_ground_content);
writeU8(os, light_propagates);
writeU8(os, sunlight_propagates);
writeU8(os, walkable);
writeU8(os, pointable);
writeU8(os, diggable);
writeU8(os, climbable);
writeU8(os, buildable_to);
os<<serializeString(""); // legacy: used to be metadata_name
writeU8(os, liquid_type);
os<<serializeString(liquid_alternative_flowing);
os<<serializeString(liquid_alternative_source);
writeU8(os, liquid_viscosity);
writeU8(os, liquid_renewable);
writeU8(os, light_source);
writeU32(os, damage_per_second);
node_box.serialize(os);
selection_box.serialize(os);
writeU8(os, legacy_facedir_simple);
writeU8(os, legacy_wallmounted);
serializeSimpleSoundSpec(sound_footstep, os);
serializeSimpleSoundSpec(sound_dig, os);
serializeSimpleSoundSpec(sound_dug, os);
writeU8(os, rightclickable);
// Stuff below should be moved to correct place in a version that otherwise changes
// the protocol version
writeU8(os, drowning);
}
示例11: writeString
static void writeString(const plString& v, unsigned char*& buffer, size_t& size) {
plString::Wide ws = v.wstr();
size_t len = (ws.len() + 1) * sizeof(pl_wchar_t);
writeU32(len, buffer, size);
memcpy(buffer, ws.data(), len); // Includes the '\0'
buffer += len;
size -= len;
}
示例12: writeU32
U32 PGRFAttrSetResPkt::serialize( S8 * buf, S32 offset ) const
{
U32 cur_pos = PPacketBase::serialize(buf, offset);
S8 * buff = buf + offset;
writeU32(buff + cur_pos, m_event);
cur_pos += sizeof(U32);
writeU32(buff + cur_pos, m_iHandle);
cur_pos += sizeof(U32);
writeB8(buff + cur_pos, m_bOk);
cur_pos += sizeof(B8);
//cur_pos += m_oAddr.serialize(buff + cur_pos,0);
return cur_pos;
}
示例13: writeU32
U32 PGRFCloseReqPkt::serialize( S8 * buf, S32 offset ) const
{
U32 cur_pos = PPacketBase::serialize(buf, offset);
S8 * buff = buf + offset;
writeU32(buff + cur_pos, m_event);
cur_pos += sizeof(U32);
writeU32(buff + cur_pos, m_iSessionID);
cur_pos += sizeof(U32);
writeU32(buff + cur_pos, m_iHandle);
cur_pos += sizeof(U32);
//cur_pos += m_oAddr.serialize(buff + cur_pos,0);
return cur_pos;
}
示例14: getTrack
status SampleVisionFile::update()
{
m_fh->seek(m_frameCountOffset, File::SeekFromBeginning);
Track *track = getTrack();
uint32_t frameCount = track->totalfframes;
writeU32(&frameCount);
writeTrailer();
return AF_SUCCEED;
}
示例15: writeU8
void ContentFeatures::serializeOld(std::ostream &os, u16 protocol_version)
{
if(protocol_version == 13)
{
writeU8(os, 5); // version
os<<serializeString(name);
writeU16(os, groups.size());
for(ItemGroupList::const_iterator
i = groups.begin(); i != groups.end(); i++){
os<<serializeString(i->first);
writeS16(os, i->second);
}
writeU8(os, drawtype);
writeF1000(os, visual_scale);
writeU8(os, 6);
for(u32 i=0; i<6; i++)
tiledef[i].serialize(os, protocol_version);
writeU8(os, CF_SPECIAL_COUNT);
for(u32 i=0; i<CF_SPECIAL_COUNT; i++){
tiledef_special[i].serialize(os, protocol_version);
}
writeU8(os, alpha);
writeU8(os, post_effect_color.getAlpha());
writeU8(os, post_effect_color.getRed());
writeU8(os, post_effect_color.getGreen());
writeU8(os, post_effect_color.getBlue());
writeU8(os, param_type);
writeU8(os, param_type_2);
writeU8(os, is_ground_content);
writeU8(os, light_propagates);
writeU8(os, sunlight_propagates);
writeU8(os, walkable);
writeU8(os, pointable);
writeU8(os, diggable);
writeU8(os, climbable);
writeU8(os, buildable_to);
os<<serializeString(""); // legacy: used to be metadata_name
writeU8(os, liquid_type);
os<<serializeString(liquid_alternative_flowing);
os<<serializeString(liquid_alternative_source);
writeU8(os, liquid_viscosity);
writeU8(os, light_source);
writeU32(os, damage_per_second);
node_box.serialize(os, protocol_version);
selection_box.serialize(os, protocol_version);
writeU8(os, legacy_facedir_simple);
writeU8(os, legacy_wallmounted);
serializeSimpleSoundSpec(sound_footstep, os);
serializeSimpleSoundSpec(sound_dig, os);
serializeSimpleSoundSpec(sound_dug, os);
}
else
{
throw SerializationError("ContentFeatures::serialize(): Unsupported version requested");
}
}