コード例 #1
0
ファイル: CBotStack.cpp プロジェクト: PaweX/colobot
bool CBotVarClass::Save1State(FILE* pf)
{
    if ( !WriteType(pf, m_type) ) return false;
    if ( !WriteLong(pf, m_ItemIdent) ) return false;

    return SaveVar(pf, m_pVar);                                // content of the object
}
コード例 #2
0
ファイル: moov.cpp プロジェクト: SteveShaw/povray
/*
void ReadAtomHeader(IStream *file, Type& type, POV_LONG& size)
{
    ReadInt4(file, size);

    if(size == 0) // atom goes up to end of file
    {
        ReadType(file, type);

        POV_LONG t = file->tellg();
        file->seekg(0, IOBase::SEEK_END);
        size = file->tellg() - t + 8;
        file->seekg(t, IOBase::SEEK_SET);
    }
    else if(size == 1) // atom sizes is outside 32-bit range
    {
        ReadType(file, type);

        ReadInt8(file, size);
    }
    else
        ReadType(file, type);
}
*/
void WriteAtomHeader(OStream *file, Type type, POV_LONG size)
{
    if(size < 0) // temporary size - always assume 64-bit size
    {
        WriteInt4(file, 1);
        WriteType(file, type);
        WriteInt8(file, 0);
    }
    else if(size > UINT_MAX) // size outside 32-bit range
    {
        WriteInt4(file, 1);
        WriteType(file, type);
        WriteInt8(file, size);
    }
    else // size within 32-bit range
    {
        WriteType(file, type);
        WriteInt4(file, size);
    }
}
コード例 #3
0
// Write a CString
//
void CConnexionSocket::WriteType( CString Str )
{
	short Len = Str.GetLength();
	WriteType( Len );
	m_BufferSendSize += Str.GetLength();
	char* pStr = GetAsciiString( Str );
	if( m_BufferSend )
	{
		char* pBuffer = (char*) malloc( m_BufferSendSize );
		memcpy( pBuffer, m_BufferSend, m_BufferSendSize-Str.GetLength() );
		free( m_BufferSend );
		m_BufferSend = pBuffer;
	}
	else
	{
		m_BufferSend = (char*) malloc( m_BufferSendSize );
	}
	memcpy( m_BufferSend+m_BufferSendSize-Str.GetLength(), pStr, Str.GetLength() );
	free( pStr );
}
コード例 #4
0
ファイル: moov.cpp プロジェクト: SteveShaw/povray
void FinishWriteFile(OStream *file, const Animation::WriteOptions& options, vector<string>& warnings, void *state)
{
    PrivateData *pd = reinterpret_cast<PrivateData *>(state);

    if(pd == NULL)
        throw POV_EXCEPTION_CODE(kNullPointerErr);

    POV_LONG stsz_size = 20 + (pd->imagesizes.size() * 4);
    POV_LONG stsc_size = 28;
    POV_LONG stts_size = 32;
    POV_LONG stsd_size = 102;
    POV_LONG stbl_size = 8 + stsd_size + stts_size + stsc_size + stsz_size;
    POV_LONG vmhd_size = 20;
    POV_LONG minf_size = 8 + vmhd_size + stbl_size;
    POV_LONG hdlr_size = 32;
    POV_LONG mdhd_size = 32;
    POV_LONG mdia_size = 8 + mdhd_size + hdlr_size + minf_size;
    POV_LONG tkhd_size = 112;
    POV_LONG trak_size = 8 + tkhd_size + mdia_size;
    POV_LONG mvhd_size = 108;
    POV_LONG moov_size = 8 + mvhd_size + trak_size;

    int duration = pd->frameduration * pd->imagesizes.size();

    // write movie atom

    WriteAtomHeader(file, 'moov', moov_size);

    // write movie header atom

    WriteAtomHeader(file, 'mvhd', mvhd_size);

    WriteInt4(file, 0); // version and flags
    WriteInt4(file, 0); // creation time
    WriteInt4(file, 0); // modification time
    WriteInt4(file, pd->timescale); // time scale
    WriteInt4(file, duration); // duration
    WriteInt4(file, 1 << 16); // preferred playback rate
    WriteInt2(file, 1 << 8); // preferred sound volume
    WriteN(file, 10, 0); // ten reserved bytes
    WriteInt4(file, 1 << 16); // matrix a
    WriteInt4(file, 0); // matrix b
    WriteInt4(file, 0); // matrix u
    WriteInt4(file, 0); // matrix c
    WriteInt4(file, 1 << 16); // matrix d
    WriteInt4(file, 0); // matrix v
    WriteInt4(file, 0); // matrix tx
    WriteInt4(file, 0); // matrix ty
    WriteInt4(file, 1 << 30); // matrix w
    WriteInt4(file, 0); // preview time
    WriteInt4(file, 0); // preview duration
    WriteInt4(file, 0); // poster time
    WriteInt4(file, 0); // selection time
    WriteInt4(file, 0); // selection duration
    WriteInt4(file, 0); // current time
    WriteInt4(file, 2); // next track id (this code uses track 1)

    // write track atom

    WriteAtomHeader(file, 'trak', trak_size);

    // write track header atom

    WriteAtomHeader(file, 'tkhd', tkhd_size);

    WriteInt4(file, 0); // version and flags
    WriteInt4(file, 0); // creation time
    WriteInt4(file, 0); // modification time
    WriteInt4(file, 1); // track id
    WriteN(file, 4, 0); // four reserved bytes
    WriteInt4(file, duration); // duration
    WriteN(file, 8, 0); // eight reserved bytes
    WriteInt2(file, 1); // layer
    WriteInt2(file, 0); // alternate group
    WriteInt2(file, 1 << 8); // sound volume
    WriteN(file, 2, 0); // two reserved bytes
    WriteInt4(file, 1 << 16); // matrix a
    WriteInt4(file, 0); // matrix b
    WriteInt4(file, 0); // matrix u
    WriteInt4(file, 0); // matrix c
    WriteInt4(file, 1 << 16); // matrix d
    WriteInt4(file, 0); // matrix v
    WriteInt4(file, 0); // matrix tx
    WriteInt4(file, 0); // matrix ty
    WriteInt4(file, 1 << 30); // matrix w
    WriteInt4(file, pd->width << 16); // track width
    WriteInt4(file, pd->height << 16); // track height

    // write media atom

    WriteAtomHeader(file, 'mdia', mdia_size);

    // write header media atom

    WriteAtomHeader(file, 'mdhd', mdhd_size);

    WriteInt4(file, 0); // version and flags
    WriteInt4(file, 0); // creation time
    WriteInt4(file, 0); // modification time
    WriteInt4(file, pd->timescale); // time scale
    WriteInt4(file, duration); // duration
    WriteInt2(file, 0); // language
    WriteInt2(file, 0); // quality

    // write handler atom

    WriteAtomHeader(file, 'hdlr', hdlr_size);

    WriteInt4(file, 0); // version and flags
    WriteType(file, pd->componenttype); // component type
    WriteType(file, 'vide'); // component subtype (this media is video)
    WriteInt4(file, 0); // reserved
    WriteInt4(file, 0); // reserved
    WriteInt4(file, 0); // reserved

    // write media information atom

    WriteAtomHeader(file, 'minf', minf_size);

    // write video media information header atom

    WriteAtomHeader(file, 'vmhd', vmhd_size);

    WriteInt4(file, 0); // version and flags
    WriteInt2(file, 0); // graphics mode
    WriteInt2(file, 0); // opcolor red
    WriteInt2(file, 0); // opcolor green
    WriteInt2(file, 0); // opcolor blue

    // write sample table atom

    WriteAtomHeader(file, 'stbl', stbl_size);

    // write sample description atom

    WriteAtomHeader(file, 'stsd', stsd_size);

    WriteInt4(file, 0); // version and flags
    WriteInt4(file, 1); // number of entries (this code only needs one entry)
    WriteInt4(file, 86); // description size
    WriteType(file, pd->componenttype); // data format
    WriteInt4(file, 0); // reserved
    WriteInt2(file, 0); // reserved
    WriteInt2(file, 0); // data reference index
    WriteInt2(file, 0); // version
    WriteInt2(file, 0); // revision level
    WriteType(file, 'appl'); // vendor
    WriteInt4(file, 0); // temporal quality
    WriteInt4(file, 512); // spacial quality
    WriteInt2(file, pd->width); // width
    WriteInt2(file, pd->height); // height
    WriteInt4(file, 72 << 16); // horizontal resolution
    WriteInt4(file, 72 << 16); // vertical resolution
    WriteInt4(file, 0); // data size (required to be zero according to Apple documentation)
    WriteInt4(file, 1); // frame count
    WriteN(file, 1, 4); // name (32-byte Pascal string, so first byte is length!)
    WriteType(file, pd->componenttype); // name (continued, uses codec type for simplicity)
    WriteN(file, 27, 0); // name (continued, unused)
    WriteInt2(file, options.bpcc * (3 + (pd->alphachannel ? 1 : 0))); // depth
    WriteInt2(file, -1); // color table id

    // write time-to-sample atom

    WriteAtomHeader(file, 'stts', stts_size);

    WriteInt4(file, 0); // version and flags
    WriteInt4(file, 1); // number of entries (this code only needs one entry)
    WriteInt4(file, pd->imagesizes.size()); // sample count
    WriteInt4(file, pd->frameduration); // sample duration

    // write sample-to-chunk atom

    WriteAtomHeader(file, 'stsc', stsc_size);

    WriteInt4(file, 0); // version and flags
    WriteInt4(file, 1); // number of entries (this code only needs one entry)
    WriteInt4(file, 1); // first chunk
    WriteInt4(file, pd->imagesizes.size()); // samples per chunk
    WriteInt4(file, 1); // sample description id

    // write sample size atom

    WriteAtomHeader(file, 'stsz', stsz_size);

    WriteInt4(file, 0); // version and flags
    WriteInt4(file, 0); // sample size (all samples have different sizes, so this needs to be zero)
    WriteInt4(file, pd->imagesizes.size()); // number of entries

    for(vector<int>::const_iterator i = pd->imagesizes.begin(); i != pd->imagesizes.end(); i++)
        WriteInt4(file, *i); // sample size entry

    delete pd;
}
コード例 #5
0
ファイル: CBotVarArray.cpp プロジェクト: CHmSID/colobot
bool CBotVarArray::Save1State(FILE* pf)
{
    if ( !WriteType(pf, m_type) ) return false;
    return SaveVars(pf, m_pInstance);                        // saves the instance that manages the table
}