Example #1
0
// -------------------------------------
// Initialization functions
//
Bool16 QTAtom_mdhd::Initialize()
{
    // Temporary vars
    UInt32      tempInt32;

    //
    // Parse this atom's fields.
    ReadInt32(mdhdPos_VersionFlags, &tempInt32);
    fVersion = (UInt8)((tempInt32 >> 24) & 0x000000ff);
    fFlags = tempInt32 & 0x00ffffff;

    if (0 == fVersion)
    {
        // Verify that this atom is the correct length.
        if( fTOCEntry.AtomDataLength != 24 )
        {
            DEEP_DEBUG_PRINT(("QTAtom_mdhd::Initialize failed. Expected AtomDataLength == 24 version: %d AtomDataLength: %" _64BITARG_ "u\n",fVersion, fTOCEntry.AtomDataLength));
            return false;
        }

        ReadInt32To64(mdhdPos_CreationTime, &fCreationTime);
        ReadInt32To64(mdhdPos_ModificationTime, &fModificationTime);
        ReadInt32(mdhdPos_TimeScale, &fTimeScale);
        ReadInt32To64(mdhdPos_Duration, &fDuration);
        ReadInt16(mdhdPos_Language, &fLanguage);
        ReadInt16(mdhdPos_Quality, &fQuality);
    }
    else if (1 == fVersion)
    {
        // Verify that this atom is the correct length.
        if( fTOCEntry.AtomDataLength != 36 )
        {
            DEEP_DEBUG_PRINT(("QTAtom_mdhd::Initialize failed. Expected AtomDataLength == 36 version: %d AtomDataLength: %" _64BITARG_ "u\n",fVersion, fTOCEntry.AtomDataLength));
            return false;
        }

        ReadInt64(mdhdPosV1_CreationTime, &fCreationTime);
        ReadInt64(mdhdPosV1_ModificationTime, &fModificationTime);
        ReadInt32(mdhdPosV1_TimeScale, &fTimeScale);
        ReadInt64(mdhdPosV1_Duration, &fDuration);
        ReadInt16(mdhdPosV1_Language, &fLanguage);
        ReadInt16(mdhdPosV1_Quality, &fQuality);
    }
    else
    {
        DEEP_DEBUG_PRINT(("QTAtom_mdhd::Initialize  failed. Version unsupported: %d\n",fVersion));
        return false;
    }

    //
    // Compute the reciprocal of the timescale.
    fTimeScaleRecip = 1 / (Float64)fTimeScale;
    
    //
    // This atom has been successfully read in.
    return true;
}
Example #2
0
bool DataIndex::DecodeFromString(const std::string &str) {
    if (!StringStartsWith(str, kIndexBlockMagic)) {
        LOG(ERROR)<< "invalid data index header";
        return false;
    }
    block_info_.clear();
    const char *begin = str.c_str() + kIndexBlockMagic.size();
    const char *end = str.c_str() + str.size();
    while (begin < end) {
        DataBlockInfo info;
        info.offset = ReadInt64(&begin);
        info.data_size = ReadInt32(&begin);
        int key_len = ReadVint(&begin, end);
        info.key = std::string(begin, key_len);
        begin += key_len;
        block_info_.push_back(info);
    }
    // Check if the content is overflow
    if (begin > end) {
        LOG(ERROR) << "incomplete file, "
        << StringPrint("begin: %p, end: %p", begin, end);
        return false;
    }
    return true;
}
double InteropInputStream::ReadDouble()
{
    BinaryInt64Double u;

    u.i = ReadInt64();

    return u.d;
}
void KRegistryKey::ReadInt64(const KString& ValueName, __int64& iRValue, __int64 iDefaultValue) const
{
	DEBUG_VERIFY_ALLOCATION;

	DEBUG_VERIFY(IsOpen());

	try
	{
		ReadInt64(ValueName, iRValue);
	}

	catch(...)
	{
		iRValue = iDefaultValue;
	}
}
Example #5
0
const wchar_t* SIMPLEAPI ParseInt64(const wchar_t* psz, int64_t* piValue)
{
	while (psz[0]==' ' || psz[0]=='\t')
		psz++;

	// Negative
	int64_t iNeg=1;
	if (psz[0]==L'-')
		{
		iNeg=-1;
		psz++;
		}

	// Read integer
	if (!ReadInt64(psz, piValue))
		return NULL;

	// Parse it
	*piValue*=iNeg;
	return psz;
}
Example #6
0
// -------------------------------------
// Initialization functions
//
Bool16 QTAtom_elst::Initialize()
{
	// Temporary vars
	UInt32      tempInt32;

	//
	// Parse this atom's fields.
	ReadInt32(elstPos_VersionFlags, &tempInt32);
	fVersion = (UInt8)((tempInt32 >> 24) & 0x000000ff);
	fFlags = tempInt32 & 0x00ffffff;

	if (fVersion > 1)
	{
		DEEP_DEBUG_PRINT(("QTAtom_elst::Initialize failed. Version unsupported: %d\n", fVersion));
		return false;
	}

	ReadInt32(elstPos_NumEdits, &fNumEdits);

	//
	// Read in all of the edits.
	if (fNumEdits > 0) {
		DEEP_DEBUG_PRINT(("QTAtom_elst::Initialize ..%"   _U32BITARG_   " edits found.\n", fNumEdits));

		//
		// Allocate our ref table.
		fEdits = NEW EditListEntry[fNumEdits];
		if (fEdits == NULL)
			return false;

		//
		// Read them all in..
		for (UInt32 CurEdit = 0; CurEdit < fNumEdits; CurEdit++)
		{

			if (0 == fVersion)
			{
				//
				// Get all of the data in this edit list entry.
				ReadInt32To64(elstPos_EditList + (CurEdit * 12) + elstEntryPos_Duration, &fEdits[CurEdit].EditDuration);
				ReadInt32To64Signed(elstPos_EditList + (CurEdit * 12) + elstEntryPos_MediaTime, &fEdits[CurEdit].StartingMediaTime);

				ReadInt32(elstPos_EditList + (CurEdit * 12) + elstEntryPos_MediaRate, &fEdits[CurEdit].EditMediaRate);

			}
			else if (1 == fVersion)
			{

				// Get all of the data in this edit list entry.
				ReadInt64(elstPos_EditList + (CurEdit * 20) + elstEntryPosV1_Duration, &fEdits[CurEdit].EditDuration);
				ReadInt64(elstPos_EditList + (CurEdit * 20) + elstEntryPosV1_MediaTime, (UInt64*)&fEdits[CurEdit].StartingMediaTime);

				ReadInt32(elstPos_EditList + (CurEdit * 20) + elstEntryPosV1_MediaRate, &fEdits[CurEdit].EditMediaRate);

			}

			DEEP_DEBUG_PRINT(("QTAtom_elst::Initialize ..Edit #%"   _U32BITARG_   ": Duration=%" _64BITARG_ "u; MediaTime=%" _64BITARG_ "d\n", CurEdit, fEdits[CurEdit].EditDuration, fEdits[CurEdit].StartingMediaTime));

			//
			// Adjust our starting media time.
			if (fEdits[CurEdit].StartingMediaTime == -1)
				fFirstEditMovieTime = fEdits[CurEdit].EditDuration;
		}
	}

	//
	// This atom has been successfully read in.
	return true;
}
Example #7
0
// -------------------------------------
// Initialization functions
//
Bool16 QTAtom_tkhd::Initialize(void)
{
    // Temporary vars
    UInt32      tempInt32;

    //
    // Parse this atom's fields.
    ReadInt32(tkhdPos_VersionFlags, &tempInt32);
    fVersion = (UInt8)((tempInt32 >> 24) & 0x000000ff);
    fFlags = tempInt32 & 0x00ffffff;

    if (0 == fVersion)
    {
       // Verify that this atom is the correct length.
        if( fTOCEntry.AtomDataLength != 84 )
        {
            DEEP_DEBUG_PRINT(("QTAtom_tkhd::Initialize failed. Expected AtomDataLength == 84 version: %d AtomDataLength: %"_64BITARG_"u\n",fVersion, fTOCEntry.AtomDataLength));
            return false;
        }

        ReadInt32To64(tkhdPos_CreationTime, &fCreationTime);
        ReadInt32To64(tkhdPos_ModificationTime, &fModificationTime);
        ReadInt32(tkhdPos_TrackID, &fTrackID);
        ReadInt32To64(tkhdPos_Duration, &fDuration);
        ReadInt16(tkhdPos_AlternateGroup, &fAlternateGroup);
        ReadInt16(tkhdPos_Volume, &fVolume);
    
        ReadInt32(tkhdPos_a, &fa);
        ReadInt32(tkhdPos_b, &fb);
        ReadInt32(tkhdPos_u, &fu);
        ReadInt32(tkhdPos_c, &fc);
        ReadInt32(tkhdPos_d, &fd);
        ReadInt32(tkhdPos_v, &fv);
        ReadInt32(tkhdPos_x, &fx);
        ReadInt32(tkhdPos_y, &fy);
        ReadInt32(tkhdPos_w, &fw);
    
        ReadInt32(tkhdPos_TrackWidth, &fTrackWidth);
        ReadInt32(tkhdPos_TrackHeight, &fTrackHeight);
    }
    else if (1 == fVersion)
    {   
       // Verify that this atom is the correct length.
        if (fTOCEntry.AtomDataLength != 96)
        {
            DEEP_DEBUG_PRINT(("QTAtom_tkhd::Initialize failed. Expected AtomDataLength == 96 version: %d AtomDataLength: %"_64BITARG_"u\n",fVersion, fTOCEntry.AtomDataLength));
            return false;
        }

        ReadInt64(tkhdPosV1_CreationTime, &fCreationTime);
        ReadInt64(tkhdPosV1_ModificationTime, &fModificationTime);
        ReadInt32(tkhdPosV1_TrackID, &fTrackID);
        ReadInt64(tkhdPosV1_Duration, &fDuration);
        ReadInt16(tkhdPosV1_AlternateGroup, &fAlternateGroup);
        ReadInt16(tkhdPosV1_Volume, &fVolume);
    
        ReadInt32(tkhdPosV1_a, &fa);
        ReadInt32(tkhdPosV1_b, &fb);
        ReadInt32(tkhdPosV1_u, &fu);
        ReadInt32(tkhdPosV1_c, &fc);
        ReadInt32(tkhdPosV1_d, &fd);
        ReadInt32(tkhdPosV1_v, &fv);
        ReadInt32(tkhdPosV1_x, &fx);
        ReadInt32(tkhdPosV1_y, &fy);
        ReadInt32(tkhdPosV1_w, &fw);
    
        ReadInt32(tkhdPosV1_TrackWidth, &fTrackWidth);
        ReadInt32(tkhdPosV1_TrackHeight, &fTrackHeight);
    }
    else 
    {
        DEEP_DEBUG_PRINT(("QTAtom_tkhd::Initialize failed. Version unsupported: %d",fVersion));
        return false;
    }


    //
    // This atom has been successfully read in.
    return true;
}
Example #8
0
// -------------------------------------
// Initialization functions
//
Bool16 QTAtom_mvhd::Initialize()
{
	// Temporary vars
	UInt32      tempInt32;

	//
	// Parse this atom's fields.
	ReadInt32(mvhdPos_VersionFlags, &tempInt32);
	fVersion = (UInt8)((tempInt32 >> 24) & 0x000000ff);
	fFlags = tempInt32 & 0x00ffffff;

	if (0 == fVersion)
	{
		// Verify that this atom is the correct length.
		if (fTOCEntry.AtomDataLength != 100)
		{
			DEEP_DEBUG_PRINT(("QTAtom_mvhd::Initialize failed. Expected AtomDataLength == 100 version: %d AtomDataLength: %" _64BITARG_ "u\n", fVersion, fTOCEntry.AtomDataLength));
			return false;
		}

		ReadInt32To64(mvhdPos_CreationTime, &fCreationTime);
		ReadInt32To64(mvhdPos_ModificationTime, &fModificationTime);
		ReadInt32(mvhdPos_TimeScale, &fTimeScale);
		ReadInt32To64(mvhdPos_Duration, &fDuration);

		ReadInt32(mvhdPos_PreferredRate, &fPreferredRate);
		ReadInt16(mvhdPos_PreferredVolume, &fPreferredVolume);

		ReadInt32(mvhdPos_a, &fa);
		ReadInt32(mvhdPos_b, &fb);
		ReadInt32(mvhdPos_u, &fu);
		ReadInt32(mvhdPos_c, &fc);
		ReadInt32(mvhdPos_d, &fd);
		ReadInt32(mvhdPos_v, &fv);
		ReadInt32(mvhdPos_x, &fx);
		ReadInt32(mvhdPos_y, &fy);
		ReadInt32(mvhdPos_w, &fw);

		ReadInt32(mvhdPos_PreviewTime, &fPreviewTime);
		ReadInt32(mvhdPos_PreviewDuration, &fPreviewDuration);
		ReadInt32(mvhdPos_PosterTime, &fPosterTime);
		ReadInt32(mvhdPos_SelectionTime, &fSelectionTime);
		ReadInt32(mvhdPos_SelectionDuration, &fSelectionDuration);
		ReadInt32(mvhdPos_CurrentTime, &fCurrentTime);
		ReadInt32(mvhdPos_NextTrackID, &fNextTrackID);
	}
	else if (1 == fVersion)
	{
		// Verify that this atom is the correct length.
		if (fTOCEntry.AtomDataLength != 112)
		{
			DEEP_DEBUG_PRINT(("QTAtom_mvhd::Initialize failed. Expected AtomDataLength = 112 version: %d AtomDataLength: %" _64BITARG_ "u\n", fVersion, fTOCEntry.AtomDataLength));
			return false;
		}

		ReadInt64(mvhdPosV1_CreationTime, &fCreationTime);
		ReadInt64(mvhdPosV1_ModificationTime, &fModificationTime);
		ReadInt32(mvhdPosV1_TimeScale, &fTimeScale);
		ReadInt64(mvhdPosV1_Duration, &fDuration);

		ReadInt32(mvhdPosV1_PreferredRate, &fPreferredRate);
		ReadInt16(mvhdPosV1_PreferredVolume, &fPreferredVolume);

		ReadInt32(mvhdPosV1_a, &fa);
		ReadInt32(mvhdPosV1_b, &fb);
		ReadInt32(mvhdPosV1_u, &fu);
		ReadInt32(mvhdPosV1_c, &fc);
		ReadInt32(mvhdPosV1_d, &fd);
		ReadInt32(mvhdPosV1_v, &fv);
		ReadInt32(mvhdPosV1_x, &fx);
		ReadInt32(mvhdPosV1_y, &fy);
		ReadInt32(mvhdPosV1_w, &fw);

		ReadInt32(mvhdPosV1_PreviewTime, &fPreviewTime);
		ReadInt32(mvhdPosV1_PreviewDuration, &fPreviewDuration);
		ReadInt32(mvhdPosV1_PosterTime, &fPosterTime);
		ReadInt32(mvhdPosV1_SelectionTime, &fSelectionTime);
		ReadInt32(mvhdPosV1_SelectionDuration, &fSelectionDuration);
		ReadInt32(mvhdPosV1_CurrentTime, &fCurrentTime);
		ReadInt32(mvhdPosV1_NextTrackID, &fNextTrackID);
	}
	else
	{
		DEEP_DEBUG_PRINT(("QTAtom_mvhd::Initialize failed. Version unsupported: %d\n", fVersion));
		return false;
	}


	//
	// This atom has been successfully read in.
	return true;
}
Example #9
0
int LuaPacket::Dump(lua_State* L)
{
    // Save old rpos and seek to the beginning (without the opcode)
    size_t oldrpos = rpos();
    rpos(sizeof(uint32_t));

    uint32_t pushed = 0;

    std::string value = lua_tostring(L, 1);
    std::vector<std::string> parts = Utils::Split(value, ' ');

    if (parts.size() < 1)
        return luaL_argerror(L, 1, "Invalid dump format");

    for (uint32_t i = 0; i < parts.size(); i++)
    {
        if (parts[i] == "int8")
        {
            ReadInt8(L);
            pushed++;
        }
        else if (parts[i] == "int16")
        {
            ReadInt16(L);
            pushed++;
        }
        else if (parts[i] == "int32")
        {
            ReadInt32(L);
            pushed++;
        }
        else if (parts[i] == "int64")
        {
            ReadInt64(L);
            pushed++;
        }
        else if (parts[i] == "int128")
        {
            ReadInt128(L);
            pushed++;
        }
        else if (parts[i] == "float")
        {
            ReadFloat(L);
            pushed++;
        }
        else if (parts[i] == "double")
        {
            ReadDouble(L);
            pushed++;
        }
        else if (parts[i] == "string")
        {
            ReadString(L);
            pushed++;
        }
        else if (parts[i] == "bit")
        {
            ReadBit(L);
            pushed++;
        }
    }

    // Restore rpos
    rpos(oldrpos);
    return pushed;
}
Example #10
0
Variant Deserializer::ReadVariant(VariantType type)
{
    switch (type)
    {
    case VAR_INT:
        return Variant(ReadInt());

    case VAR_INT64:
        return Variant(ReadInt64());

    case VAR_BOOL:
        return Variant(ReadBool());

    case VAR_FLOAT:
        return Variant(ReadFloat());

    case VAR_VECTOR2:
        return Variant(ReadVector2());

    case VAR_VECTOR3:
        return Variant(ReadVector3());

    case VAR_VECTOR4:
        return Variant(ReadVector4());

    case VAR_QUATERNION:
        return Variant(ReadQuaternion());

    case VAR_COLOR:
        return Variant(ReadColor());

    case VAR_STRING:
        return Variant(ReadString());

    case VAR_BUFFER:
        return Variant(ReadBuffer());

        // Deserializing pointers is not supported. Return null
    case VAR_VOIDPTR:
    case VAR_PTR:
        ReadUInt();
        return Variant((void*)0);

    case VAR_RESOURCEREF:
        return Variant(ReadResourceRef());

    case VAR_RESOURCEREFLIST:
        return Variant(ReadResourceRefList());

    case VAR_VARIANTVECTOR:
        return Variant(ReadVariantVector());

    case VAR_STRINGVECTOR:
        return Variant(ReadStringVector());

    case VAR_VARIANTMAP:
        return Variant(ReadVariantMap());

    case VAR_INTRECT:
        return Variant(ReadIntRect());

    case VAR_INTVECTOR2:
        return Variant(ReadIntVector2());

    case VAR_INTVECTOR3:
        return Variant(ReadIntVector3());

    case VAR_MATRIX3:
        return Variant(ReadMatrix3());

    case VAR_MATRIX3X4:
        return Variant(ReadMatrix3x4());

    case VAR_MATRIX4:
        return Variant(ReadMatrix4());

    case VAR_DOUBLE:
        return Variant(ReadDouble());

    default:
        return Variant();
    }
}