예제 #1
0
//---------------------------------------------------------------------------
void File_Dts::Data_Parse_Fill()
{
    Stream_Prepare(Stream_General);
    Fill("Format", "DTS");
    Stream_Prepare(Stream_Audio);

    if (DTS_HD_Unknown_Size==0) //DTS-HD, TODO : Find a better way
        Fill("Codec", "DTS");
    else
        Fill("Codec", "DTS-HD");

    if (ExtendedCoding && (ExtensionAudioDescriptor==2 || ExtensionAudioDescriptor==3))
        Fill("SamplingRate", 96000);
    else
        Fill("SamplingRate", DTS_SamplingRate[sample_frequency]);
    if (DTS_HD_Unknown_Size==0 && bit_rate<29)
        Fill("BitRate", DTS_BitRate[bit_rate]);
    else if (bit_rate==29)
        Fill("BitRate", "Open");
    else if (bit_rate==30)
        Fill("BitRate", "Variable");
    else if (bit_rate==31)
        Fill("BitRate", "LossLess");
    if (ExtendedCoding && (ExtensionAudioDescriptor==0 || ExtensionAudioDescriptor==3))
    {
    }
    else
    {
        int8u Channels;
        Ztring ChannelPositions;
        if (channel_arrangement<16)
        {
            Channels=DTS_Channels[channel_arrangement]+(lfe_effects?1:0);
            ChannelPositions.From_Local(DTS_ChannelPositions[channel_arrangement]);
        }
        else
        {
            Channels=8;
            ChannelPositions.From_Local("User defined");
        }
        if (lfe_effects)
            ChannelPositions+=_T(", LFE");
        Fill("Channel(s)", Channels);
        Fill("ChannelPositions", ChannelPositions);
    }
    Fill("Resolution", DTS_Resolution[bits_per_sample]);

    if (File_Offset+Buffer_Size<File_Size)
    {
        Info("DTS, Jumping to end of file");
        Finnished();
    }
}
예제 #2
0
//---------------------------------------------------------------------------
// Load CSV
bool ZtringListListF::CSV_Charger ()
{
    //Read file
    File F;
    if (!F.Open(Name))
        return false;

    int8u* Buffer=new int8u[(size_t)F.Size_Get()+1];
    size_t BytesCount=F.Read(Buffer, (size_t)F.Size_Get());
    F.Close();
    if (BytesCount==Error)
    {
        delete[] Buffer; //Buffer=NULL;
        return false;
    }
    Buffer[(int32u)BytesCount]=(int8u)'\0';

    //Convert file in UTF-8 or Local
    Ztring File;
    if (!Local)
    {
        //UTF-8
        File.From_UTF8((char*)Buffer, 0, BytesCount);
        #ifdef _DEBUG
        if (File.size()==0)
             File.From_Local((char*)Buffer, 0, BytesCount);
        #endif //_DEBUG
    }
    if (File.size()==0)
        //Local of UTF-8 failed
        File.From_Local((char*)Buffer, 0, BytesCount);

    //Separators
    if (Separator[0]==__T("(Default)"))
            Separator[0]=EOL;
    Ztring SeparatorT=Separator[1];
    Separator[1]=__T(";");

    //Writing
    Write(File);

    //Separators
    Separator[1]=SeparatorT;

    delete[] Buffer; //Buffer=NULL;
    return true;
}
예제 #3
0
//---------------------------------------------------------------------------
// Open a file
ZenLib::Ztring Enums_Create_Load(Ztring FileName, Ztring &Contents)
{
    wxFile F;
    if (F.Open(FileName.c_str(), wxFile::read)==false)
    {
        Ztring ToReturn=L"Problems to open ";
        ToReturn+=FileName;
        ToReturn+=L"\r\n";
        return ToReturn;
    }

    char C[FILE_MAX];
    size_t Size=F.Read(C, FILE_MAX-1);
    Contents.From_Local(C, Size);
    return L"";
}
예제 #4
0
int Test_Version(char* FileName_, char* Begin, char* End)
{
    wxString FileName=Ztring().From_Local(FileName_).c_str();
    //Opening File
    F.Open(FileName);
    I=F.Read(C, 1000000);
    if (!I)
    {
        ToShow+=__T("Error opening ")+FileName;
        return -1;
    }

    //Getting information
    C[I]=0;
    Z.From_Local(C);
    Z=Z.SubString(Ztring().From_Local(Begin), Ztring().From_Local(End));

    //deleting extra bytes
    if (Z[Z.size()-1]=='\n')
        Z.resize(Z.size()-1);
    if (Z[Z.size()-1]=='\r')
        Z.resize(Z.size()-1);

    //Testing validity
    if (Z.size()!=3 && Z.size()!=7) //non long, no short
    {
        ToShow+=__T("Error reading ")+FileName;
        return -2;
    }

    //Reformtation information
    Z.FindAndReplace(__T(","), __T("."), 0, Ztring_Recursive);

    if (Z!=Version && Z!=Version_Short)
    {
        ToShow+=FileName;
        ToShow+=__T(" is not good : version is marked ");
        ToShow+=Z;
        ToShow+=__T("\r\n");
    }
    return 0;
}
예제 #5
0
//---------------------------------------------------------------------------
Ztring HTTP_Client::Read ()
{
    if (Handle==0)
        return Ztring();

    char* Buffer=new char[16384];
    int32u Size=0;

    int32u ReturnValue=HTTPClientReadData(Handle, Buffer, 16384, 0, &Size);
    if (ReturnValue!=0 && ReturnValue!=1000) //End of stream
    {
        Close();
        delete[] Buffer;
        return Ztring();
    }

    Ztring ToReturn; ToReturn.From_Local(Buffer, Size);
    delete[] Buffer;
    return ToReturn;
}
예제 #6
0
void File_OtherText::Read_Buffer_Continue()
{
    if (Buffer_Size<0x200)
    {
        Element_WaitForMoreData();
        return;
    }

    Element_Offset=File_Size-(File_Offset+Buffer_Offset);

    Ztring Format, FormatMore, Codec;
    Ztring File;
    ZtringList Lines;

    //Feed File and Lines
    File.From_UTF8((const char*)Buffer, Buffer_Size>65536?65536:Buffer_Size);
    if (File.empty())
        File.From_Local((const char*)Buffer, Buffer_Size>65536?65536:Buffer_Size); // Trying from local code page
    if (File.size()<0x100)
    {
        File.From_Unicode((wchar_t*)Buffer, 0, Buffer_Size/sizeof(wchar_t)); //Unicode with BOM
        //TODO: Order of bytes (big or Little endian)
        if (File.size()<0x100)
        {
            Reject("Other text");
            return;
        }
    }
    if (File.size()>0x1000)
        File.resize(0x1000); //Do not work on too big
    File.FindAndReplace(__T("\r\n"), __T("\n"), 0, Ztring_Recursive);
    File.FindAndReplace(__T("\r"), __T("\n"), 0, Ztring_Recursive);
    Lines.Separator_Set(0, __T("\n"));
    Lines.Write(File);
    Lines.resize(0x20);

         if (Lines[0]==__T("[Script Info]")
          && (Lines.Find(__T("ScriptType: v4.00"))!=Error || Lines.Find(__T("Script Type: V4.00"))!=Error)
          && Lines.Find(__T("[V4 Styles]"))!=Error
          )
    {
       Format=__T("SSA");
       FormatMore=__T("SubStation Alpha");
       Codec=__T("SSA");
    }
    else if (Lines[0]==__T("[Script Info]")
          && (Lines.Find(__T("ScriptType: v4.00+"))!=Error || Lines.Find(__T("Script Type: V4.00+"))!=Error)
          && Lines.Find(__T("[V4+ Styles]"))!=Error
          )
    {
       Format=__T("ASS");
       FormatMore=__T("Advanced SubStation Alpha");
       Codec=__T("ASS");
    }
    else if (Lines[0].size()>24
          && Lines[0][ 0]==__T('0') && Lines[0][ 1]==__T('0')
          && Lines[0][ 2]==__T(':') && Lines[0][ 5]==__T(':') && Lines[0][ 8]==__T(':')
          && Lines[0][11]==__T(' ')
          && Lines[0][12]==__T('0') && Lines[0][13]==__T('0')
          && Lines[0][14]==__T(':') && Lines[0][17]==__T(':') && Lines[0][20]==__T(':')
          && Lines[0][23]==__T(' ')
          )
    {
       Format=__T("Adobe encore DVD");
       Codec=__T("Adobe");
    }
    else if (Lines[0].size()==11
          && Lines[0][0]==__T('-') && Lines[0][1]==__T('-') && Lines[0][2]==__T('>') && Lines[0][3]==__T('>') && Lines[0][4]==__T(' ')
          && Lines[0][5]==__T('0')
          && Lines[1].empty()!=true
          )
    {
       Format=__T("AQTitle");
       Codec=__T("AQTitle");
    }
    else if (Lines[0].size()>28
          && Lines[0][ 0]==__T('0') && Lines[0][ 1]==__T('0')
          && Lines[0][ 2]==__T(':') && Lines[0][ 5]==__T(':') && Lines[0][ 8]==__T(':')
          && Lines[0][11]==__T(' ') && Lines[0][12]==__T(',') && Lines[0][13]==__T(' ')
          && Lines[0][14]==__T('0') && Lines[0][15]==__T('0')
          && Lines[0][16]==__T(':') && Lines[0][19]==__T(':') && Lines[0][22]==__T(':')
          && Lines[0][25]==__T(' ') && Lines[0][16]==__T(',') && Lines[0][27]==__T(' ')
          )
    {
       Format=__T("Captions 32");
       Codec=__T("Caption 32");
    }
    else if (Lines[0].size()==23
          && Lines[0]==__T("*Timecode type: PAL/EBU")
          && Lines[1].empty()
          && Lines[2].size()==23
          && Lines[2][ 0]==__T('0') && Lines[2][ 1]==__T('0')
          && Lines[2][ 2]==__T(':') && Lines[2][ 5]==__T(':') && Lines[2][ 8]==__T(':')
          && Lines[2][11]==__T(' ')
          && Lines[2][12]==__T('0') && Lines[2][13]==__T('0')
          && Lines[2][14]==__T(':') && Lines[2][17]==__T(':') && Lines[2][20]==__T(':')
          && Lines[2].size()>0
          )
    {
       Format=__T("Captions Inc");
       Codec=__T("Captions inc");
    }
    else if (Lines[0].size()>1
          && Lines[0][0]==__T('*')
          && Lines.Find(__T("** Caption Number 1"))!=Error
    )
    {
       Format=__T("Cheeta");
    }
    else if (Lines[0].size()>10
          && Lines[0][0]==__T('~') && Lines[0][1]==__T('C') && Lines[0][2]==__T('P') && Lines[0][3]==__T('C') && Lines[0][9]==__T('~')
          && Lines[1][ 0]==__T('0') && Lines[1][ 1]==__T('0')
          && Lines[1][ 2]==__T(':') && Lines[1][ 5]==__T(':') && Lines[1][ 8]==__T(':')
    )
    {
       Format=__T("CPC Captioning");
       Codec=__T("CPC Captioning");
    }
    else if (Lines[0].find(__T("<SAMI>"))==0)
    {
       Format=__T("SAMI");
    }
    else
        return;

    if (Format.empty())
        return;

    Accept("Other text");

    if (!IsSub)
    {
        Fill(Stream_General, 0, General_Format, Format);
        Fill(Stream_General, 0, General_Format_Info, FormatMore, true);
    }

    Stream_Prepare(Stream_Text);
    Fill(Stream_Text, 0, Text_Format, Format);
    Fill(Stream_Text, 0, Text_Codec, Codec);

    //No more need data
    Element_Begin1(Format);
    Element_End0();
    Finish("Other text");
}
예제 #7
0
//---------------------------------------------------------------------------
bool File_SubRip::FileHeader_Begin()
{
    if (!IsSub && (Buffer_Size<File_Size && Buffer_Size<65536))
    {
        Element_WaitForMoreData();
        return false;
    }

    ZtringListList List;
    List.Separator_Set(0, __T("\n\n"));
    List.Separator_Set(1, __T("\n"));

    if (Buffer[0]==0xEF
            && Buffer[1]==0xBB
            && Buffer[2]==0xBF)
        HasBOM=true;
    bool IsLocal=false;
    Ztring Temp;
    Temp.From_UTF8((const char*)Buffer+(HasBOM?3:0), (Buffer_Size>65536?65536:Buffer_Size)-(HasBOM?3:0));
    if (Temp.empty())
    {
        Temp.From_Local((const char*)Buffer+(HasBOM?3:0), (Buffer_Size>65536?65536:Buffer_Size)-(HasBOM?3:0)); // Trying from local code page
        IsLocal=true;
    }
    Temp.FindAndReplace(__T("\r\n"), __T("\n"), 0, Ztring_Recursive);
    Temp.FindAndReplace(__T("\r"), __T("\n"), 0, Ztring_Recursive);
    List.Write(Temp);

    if (List(0, 0)==__T("WEBVTT FILE") || List(0, 0)==__T("WEBVTT"))
        IsVTT=true;

    if (!IsVTT)
    {
        size_t IsOk=0;
        size_t IsNok=0;
        for (size_t Pos=0; Pos<List.size(); Pos++)
        {
            if (List(Pos, 0).To_int64u()==Pos+1)
                IsOk++;
            else
                IsNok++;

            if (List(Pos, 1).size()>22 && List(Pos, 1)[2]==__T(':') && List(Pos, 1)[5]==__T(':') && List(Pos, 1).find(__T(" --> "))!=string::npos)
                IsOk++;
            else
                IsNok++;
        }

        if (!IsOk || IsNok>IsOk/2)
        {
            Reject();
            return true;
        }
    }

    if (!IsSub && File_Size!=(int64u)-1 && Buffer_Size!=File_Size)
    {
        Element_WaitForMoreData();
        return false;
    }

    if (!Status[IsAccepted])
    {
        Accept();
        Fill(Stream_General, 0, General_Format, IsVTT?"WebVTT":"SubRip");
        Stream_Prepare(Stream_Text);
        Fill(Stream_Text, 0, "Format", IsVTT?"WebVTT":"SubRip");
        Fill(Stream_Text, 0, "Codec", IsVTT?"WebVTT":"SubRip");
    }

    if (IsLocal)
        Temp.From_Local((const char*)Buffer+(HasBOM?3:0), Buffer_Size-(HasBOM?3:0));
    else
        Temp.From_UTF8((const char*)Buffer+(HasBOM?3:0), Buffer_Size-(HasBOM?3:0));
    Temp.FindAndReplace(__T("\r\n"), __T("\n"), 0, Ztring_Recursive);
    Temp.FindAndReplace(__T("\r"), __T("\n"), 0, Ztring_Recursive);
    List.Write(Temp);

#if MEDIAINFO_DEMUX
    size_t Pos=0;
    for (;;)
    {
        if (Pos>=List.size())
            break;

        if (List[Pos].size()>=3 || (IsVTT && List[Pos].size()>=2))
        {
            Ztring PTS_Begin_String=List[Pos][IsVTT?0:1].SubString(Ztring(), __T(" --> "));
            Ztring PTS_End_String=List[Pos][IsVTT?0:1].SubString(__T(" --> "), Ztring());
            if (IsVTT)
            {
                size_t Extra_Pos=PTS_End_String.find(__T(' '));
                if (Extra_Pos!=string::npos)
                    PTS_End_String.resize(Extra_Pos); //Discarding positioning
            }
            item Item;
            Item.PTS_Begin=SubRip_str2timecode(PTS_Begin_String.To_UTF8().c_str());
            Item.PTS_End=SubRip_str2timecode(PTS_End_String.To_UTF8().c_str());
            for (size_t Pos2=IsVTT?1:2; Pos2<List[Pos].size(); Pos2++)
            {
                List[Pos][Pos2].Trim();
                Item.Content+=List[Pos][Pos2];
                if (Pos2+1<List[Pos].size())
                    Item.Content+=EOL;
            }
            Items.push_back(Item);
        }

        Pos++;
    }
#endif //MEDIAINFO_DEMUX

    return true;
}
예제 #8
0
//---------------------------------------------------------------------------
bool File_SubRip::FileHeader_Begin()
{
    if (!IsSub && (Buffer_Size<File_Size && Buffer_Size<65536))
    {
        Element_WaitForMoreData();
        return false;
    }

    ZtringListList List;
    List.Separator_Set(0, __T("\n\n"));
    List.Separator_Set(1, __T("\n"));

    if (Buffer_Size>=3
     && Buffer[0]==0xEF
     && Buffer[1]==0xBB
     && Buffer[2]==0xBF)
        HasBOM=true;
    bool IsLocal=false;
    Ztring Temp;
    Temp.From_UTF8((const char*)Buffer+(HasBOM?3:0), (Buffer_Size>65536?65536:Buffer_Size)-(HasBOM?3:0));
    if (Temp.empty())
    {
        #ifdef WINDOWS
        Temp.From_Local((const char*)Buffer+(HasBOM?3:0), (Buffer_Size>65536?65536:Buffer_Size)-(HasBOM?3:0)); // Trying from local code page
        #else //WINDOWS
        Temp.From_ISO_8859_1((const char*)Buffer+(HasBOM?3:0), (Buffer_Size>65536?65536:Buffer_Size)-(HasBOM?3:0));
        #endif //WINDOWS
        IsLocal=true;
    }
    Temp.FindAndReplace(__T("\r\n"), __T("\n"), 0, Ztring_Recursive);
    Temp.FindAndReplace(__T("\r"), __T("\n"), 0, Ztring_Recursive);
    List.Write(Temp);

    if (List(0, 0)==__T("WEBVTT FILE") || List(0, 0)==__T("WEBVTT"))
        IsVTT=true;

    if (!IsVTT)
    {
        size_t IsOk=0;
        size_t IsNok=0;
        for (size_t Pos=0; Pos<List.size(); Pos++)
        {
            if (List(Pos, 0).To_int64u()==Pos+1)
                IsOk++;
            else
                IsNok++;

            if (List(Pos, 1).size()>22 && List(Pos, 1)[2]==__T(':') && List(Pos, 1)[5]==__T(':') && List(Pos, 1).find(__T(" --> "))!=string::npos)
                IsOk++;
            else
                IsNok++;
        }

        if (!IsOk || IsNok>IsOk/2)
        {
            Reject();
            return true;
        }
    }

    if (!IsSub && File_Size!=(int64u)-1 && Buffer_Size!=File_Size)
    {
        Element_WaitForMoreData();
        return false;
    }

    if (!Status[IsAccepted])
    {
        Accept();
        Fill(Stream_General, 0, General_Format, IsVTT?"WebVTT":"SubRip");
        Stream_Prepare(Stream_Text);
        Fill(Stream_Text, 0, "Format", IsVTT?"WebVTT":"SubRip");
        Fill(Stream_Text, 0, "Codec", IsVTT?"WebVTT":"SubRip");
    }

    if (IsLocal)
        #ifdef WINDOWS
        Temp.From_Local((const char*)Buffer+(HasBOM?3:0), Buffer_Size-(HasBOM?3:0));
        #else //WINDOWS
        Temp.From_ISO_8859_1((const char*)Buffer+(HasBOM?3:0), Buffer_Size-(HasBOM?3:0));
        #endif //WINDOWS
    else
예제 #9
-1
Ztring OldFiles_Test ()
{
    //Checking version in Info_Version
    ToShow+=__T("Version checked : ");
    F.Open(__T("../Source/MediaInfo/MediaInfo_Config.cpp"));
    I=F.Read(C, 1000000);
    if (!I)
    {
        ToShow+=__T("Error opening ../Source/MediaInfo/MediaInfo_Config.cpp");
        return ToShow;
    }
    C[I]=0;
    Z.From_Local(C);
    Version=Z.SubString(__T("MediaInfoLib - v"), __T("\")"));
    if (Version.size()!=7)
    {
        ToShow+=__T("Error reading ../Source/MediaInfo/MediaInfo.cpp : \"MediaInfoLib - vX.X.X.X - \" not found");
        return ToShow;
    }
    Version_Short=Version; Version_Short.resize(3);
    ToShow+=Version+__T("\r\n");

    //Checking version in MediaInfo.h
    if (Test_Version("../Source/MediaInfo/MediaInfo.h", "@version ", "\n")) return ToShow;
    if (Test_Version("../Source/MediaInfo/MediaInfoList.h", "@version ", "\n")) return ToShow;
    if (Test_Version("../Project/MSVC/Dll/MediaInfo.rc", " FILEVERSION ", "\n")) return ToShow;
    if (Test_Version("../Project/MSVC/Dll/MediaInfo.rc", " PRODUCTVERSION ", "\n")) return ToShow;
    if (Test_Version("../Project/MSVC/Dll/MediaInfo.rc", "            VALUE \"FileVersion\", \"", "\"")) return ToShow;
    if (Test_Version("../Project/MSVC/Dll/MediaInfo.rc", "            VALUE \"ProductVersion\", \"", "\"")) return ToShow;
    if (Test_Version("../History.txt", "Version ", " ")) return ToShow;
    if (Test_Date(__T("MSVC/Library/MediaInfo.lib"))) return ToShow;
    if (Test_Date(__T("MSVC/Dll/MediaInfo.dll"))) return ToShow;

    return ToShow;
}