Exemplo n.º 1
0
//---------------------------------------------------------------------------
// Little Endian - 128 bits
int128u LittleEndian2int128u(const char* Liste)
{
    int128u Retour;
    Retour.lo=LittleEndian2int64u(Liste);
    Retour.hi=LittleEndian2int64u(Liste+8);
    return Retour;
}
Exemplo n.º 2
0
//---------------------------------------------------------------------------
// Little Endian - float 80 bits
float80 LittleEndian2float80(const char* Liste)
{
    //sign          1 bit
    //exponent     15 bit
    //integer?      1 bit
    //significand  63 bit

    //Retrieving data
    int16u Integer1=LittleEndian2int16u(Liste);
    int64u Integer2=LittleEndian2int64u(Liste+2);

    //Retrieving elements
    bool   Sign    =(Integer1&0x8000)?true:false;
    int16u Exponent= Integer1&0x7FFF;
    int64u Mantissa= Integer2&0x7FFFFFFFFFFFFFFFLL; //Only 63 bits, 1 most significant bit is explicit
    //Some computing
    if (Exponent==0 || Exponent==0x7FFF)
        return 0; //These are denormalised numbers, NANs, and other horrible things
    Exponent-=0x3FFF; //Bias
    float80 Answer=(((float80)Mantissa)/9223372036854775808.0+1.0)*std::pow((float)2, (int)Exponent); //(1+Mantissa) * 2^Exponent
    if (Sign)
        Answer=-Answer;

    return (float80)Answer;
}
Exemplo n.º 3
0
bool File_Zip::Zip64_end_of_central_directory_record()
{
    if (Element_Offset+12>Element_Size) //Zip64_end_of_central_directory_record
        return false; //Not enough data

    //Retrieving complete Zip64_end_of_central_directory_record size
    int64u size_of_Zip64_end_of_central_directory_record=LittleEndian2int64u(Buffer+(size_t)Element_Offset+4);
    if (Element_Offset+12+size_of_Zip64_end_of_central_directory_record>Element_Size) //end_of_central_directory all included
        return false; //Not enough data

    //Parsing
    //~ int32u offset;
    int16u version_made_by;
    Element_Begin1("Zip64 End of central directory record");
    Skip_C4(                                                    "Zip64 end of central dir signature");
    Skip_L8(                                                    "size of zip64 end of central directory record");
    Get_L2 (version_made_by,                                    "version made by");
    Param_Info1((version_made_by>>8)>20?"unused":Zip_made_by[version_made_by>>8]);
    Skip_L2(                                                    "version needed to extract");
    Skip_L4(                                                    "number of this disk");
    Skip_L4(                                                    "number of the disk");// with the start of the central directory
    Skip_L8(                                                    "total number of entries on this disk");// in the central directory
    Skip_L8(                                                    "total number of entries");// in the central directory
    Skip_L8(                                                    "size of the central directory");
    Skip_L8(                                                    "offset of start of central directory"); //  with respect to the starting disk number
    Skip_XX(size_of_Zip64_end_of_central_directory_record-44,   "zip64 extensible data sector");
    Element_End0();
    
    return true;
}
//---------------------------------------------------------------------------
void Riff_AVI__hdrl_strl_indx::Modify_Internal ()
{
    //EntryCount
    int32u Entry_Count=LittleEndian2int32u(Chunk.Content.Buffer+4);

    bool IsChanged=false;
    Chunk.Content.Buffer_Offset=24;
    for (int32u Pos=0; Pos<Entry_Count; Pos++)
    {
        int64u Value=LittleEndian2int64u(Chunk.Content.Buffer+Chunk.Content.Buffer_Offset);
        /*
        for (std::set<void*>::iterator movi=Global->AVI__movi_Pointers.begin(); movi!=Global->AVI__movi_Pointers.end(); movi++)
            if (Value>=((Riff_AVI__movi*)(*movi))->Chunk.File_In_Position && Value<((Riff_AVI__movi*)(*movi))->Chunk.File_In_Position+((Riff_AVI__movi*)(*movi))->Chunk.Content.Size)
            {
                if (((Riff_AVI__movi*)(*movi))->Chunk.File_In_Position!=((Riff_AVI__movi*)(*movi))->Chunk.File_Out_Position)
                {
                    Value-=((Riff_AVI__movi*)(*movi))->Chunk.File_In_Position;
                    Value+=((Riff_AVI__movi*)(*movi))->Chunk.File_Out_Position;
                    int64u2LittleEndian(Chunk.Content.Buffer+Chunk.Content.Buffer_Offset, Value);
                    IsChanged=true;
                }
                break;
            }
        */
        for (std::set<void*>::iterator ix=Global->AVI__movi___ix_Pointers.begin(); ix!=Global->AVI__movi___ix_Pointers.end(); ix++)
            if (Value==((Riff_AVI__movi___ix*)(*ix))->Chunk.File_In_Position)
            {
                if (((Riff_AVI__movi___ix*)(*ix))->Chunk.File_Out_Position!=((Riff_AVI__movi___ix*)(*ix))->Chunk.File_In_Position)
                {
                    int64u2LittleEndian(Chunk.Content.Buffer+Chunk.Content.Buffer_Offset, ((Riff_AVI__movi___ix*)(*ix))->Chunk.File_Out_Position);
                    IsChanged=true;
                }
                break;
            }
        Chunk.Content.Buffer_Offset+=16;
    }

    if (IsChanged)
        Chunk.Content.IsModified=true;
    //Chunk.Content.Size_IsModified=true;
}
Exemplo n.º 5
0
//---------------------------------------------------------------------------
// Little Endian - float 64 bits
float64 LittleEndian2float64(const char* Liste)
{
    //sign          1 bit
    //exponent     11 bit
    //significand  52 bit

    //Retrieving data
    int64u Integer=LittleEndian2int64u(Liste);

    //Retrieving elements
    bool   Sign    =(Integer&0x8000000000000000LL)?true:false;
    int64u Exponent=(Integer>>52)&0x7FF;
    int64u Mantissa= Integer&0xFFFFFFFFFFFFFLL;

    //Some computing
    if (Exponent==0 || Exponent==0x7FF)
        return 0; //These are denormalised numbers, NANs, and other horrible things
    Exponent-=0x3FF; //Bias
    float64 Answer=(((float64)Mantissa)/4503599627370496.0+1.0)*std::pow((float64)2, (int)Exponent); //(1+Mantissa) * 2^Exponent
    if (Sign)
        Answer=-Answer;

    return (float64)Answer;
}