void IFileContainer::write(Rels::File& rels, const CPath& curdir, const CPath& directory, ContentTypes::File& content) const
	{
		CAtlMap<CString, size_t> namepair;

		POSITION pos = m_container.GetStartPosition();
		while (NULL != pos)
		{
			const CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_container.GetNext(pos);
			
			smart_ptr<OOX::File> pFile		= pPair->m_value;
			smart_ptr<OOX::External> pExt	= pFile.smart_dynamic_cast<OOX::External>();

			if (!pExt.IsInit())
			{
				OOX::CPath defdir	= pFile->DefaultDirectory();
				OOX::CPath name		= pFile->DefaultFileName();

				CAtlMap<CString, size_t>::CPair* pNamePair = namepair.Lookup(name.m_strFilename);
				if (NULL == pNamePair)
					namepair.SetAt(name.m_strFilename, 1);
				else
					name = name + pNamePair->m_key;

				OOX::CSystemUtility::CreateDirectories(curdir / defdir);
				pFile->write(curdir / defdir / name, directory / defdir, content);
				rels.registration(pPair->m_key, pFile->type(), defdir / name);
			}
			else
			{
				
				
				rels.registration(pPair->m_key, pExt);
			}
		}
	}
	void IFileContainer::Commit(const CPath& path)
	{
		CAtlMap<CString, size_t> namepair;

		POSITION pos = m_container.GetStartPosition();
		while (NULL != pos)
		{
			CAtlMap<CString, smart_ptr<OOX::File>>::CPair* pPair = m_container.GetNext(pos);
			
			smart_ptr<OOX::File> pFile		= pPair->m_value;
			smart_ptr<OOX::External> pExt	= pFile.smart_dynamic_cast<OOX::External>();

			if (!pExt.IsInit())
			{
				OOX::CPath defdir	= pFile->DefaultDirectory();
				OOX::CPath name		= pFile->DefaultFileName();

				CAtlMap<CString, size_t>::CPair* pNamePair = namepair.Lookup(name.m_strFilename);
				if (NULL == pNamePair)
					namepair.SetAt(name.m_strFilename, 1);
				else
					name = name + pNamePair->m_key;

				OOX::CSystemUtility::CreateDirectories(path / defdir);
				
				smart_ptr<OOX::IFileBuilder> fileBuilder = pPair->m_value.smart_dynamic_cast<OOX::IFileBuilder>();
				if (fileBuilder.is_init())
					fileBuilder->Commit(path / defdir / name);
			}
		}
	}
Ejemplo n.º 3
0
bool CPeerInfo::TryInsertPeerIDMessageID(unsigned int PeerID, unsigned MessageID)
{
	CAtlMap<unsigned int, void*> *MessageIDMap;
	if(PeerIDMessageIDMap.Lookup(PeerID, MessageIDMap) == false)
	{
		MessageIDMap = new CAtlMap<unsigned int, void*>();
		PeerIDMessageIDMap.SetAt(PeerID, MessageIDMap);
	}

	void *Temp;
	if(MessageIDMap->Lookup(MessageID, Temp) == true) return false;
	else
	{
		MessageIDMap->SetAt(MessageID, NULL);
		return true;
	}
}
Ejemplo n.º 4
0
void CFunctionManager::FillSpecFunctionArray()
{
	m_SelectedFunctions.RemoveAll();
	for (size_t i = 0;i < m_pClass->Parents.GetCount(); i++)
	{
		SpecFunctionParent SpecParent;
		if (m_sSpecFunctions.Lookup(m_pClass->Parents[i]->Name, SpecParent))
		{
			CAtlMap<int, bool> ConditionResult;
			bool bDefault = true;
			for (size_t i = 0; i < SpecParent.Conditions.GetCount(); i++)
			{
				bool bRes = CheckSpecialCondition(SpecParent.Conditions[i]);
				bDefault &= !bRes;
				ConditionResult.SetAt(SpecParent.Conditions[i], bRes);
			}
			if (SpecParent.Conditions.GetCount())
			{
				ConditionResult.SetAt(0, bDefault);
			}
			CSmartAtlArray<SpecFunctionStruct>& SpecFunctions = SpecParent.SpecFunctions;
			for (size_t i = 0; i < SpecFunctions.GetCount(); i++)
			{
				if (SpecFunctions[i].Condition == -1)
				{
					m_SelectedFunctions.Add(SpecFunctions[i]);
				}
				else
				{
					bool bRes;
					if (ConditionResult.Lookup(SpecFunctions[i].Condition, bRes))
					{
						if (bRes)
						{
							m_SelectedFunctions.Add(SpecFunctions[i]);
						}
					}
				}
			}
		}
	}
}
Ejemplo n.º 5
0
CString CMediaTypeEx::GetVideoCodecName(const GUID& subtype, DWORD biCompression)
{
    CString str;

    static CAtlMap<DWORD, CString> names;

    if (names.IsEmpty()) {
        names['WMV1'] = _T("Windows Media Video 7");
        names['WMV2'] = _T("Windows Media Video 8");
        names['WMV3'] = _T("Windows Media Video 9");
        names['DIV3'] = _T("DivX 3");
        names['DX50'] = _T("DivX 5");
        names['MP4V'] = _T("MPEG4 Video");
        names['AVC1'] = _T("MPEG4 Video (H264)");
        names['H264'] = _T("MPEG4 Video (H264)");
        names['RV10'] = _T("RealVideo 1");
        names['RV20'] = _T("RealVideo 2");
        names['RV30'] = _T("RealVideo 3");
        names['RV40'] = _T("RealVideo 4");
        names['FLV1'] = _T("Flash Video 1");
        // names[''] = _T("");
    }

    if (biCompression) {
        BYTE* b = (BYTE*)&biCompression;

        for (int i = 0; i < 4; i++)
            if (b[i] >= 'a' && b[i] <= 'z') {
                b[i] = toupper(b[i]);
            }

        if (!names.Lookup(MAKEFOURCC(b[3], b[2], b[1], b[0]), str)) {
            if (subtype == MEDIASUBTYPE_DiracVideo) { str = _T("Dirac Video"); }
            // else if(subtype == ) str = _T("");
            else if (biCompression < 256) { str.Format(_T("%d"), biCompression); }
            else { str.Format(_T("%4.4hs"), &biCompression); }
        }
    }

    return str;
}
Ejemplo n.º 6
0
CString CMediaTypeEx::GetSubtitleCodecName(const GUID& subtype)
{
	CString str;

	static CAtlMap<GUID, CString> names;

	if (names.IsEmpty()) {
		names[MEDIASUBTYPE_UTF8] = _T("UTF-8");
		names[MEDIASUBTYPE_SSA] = _T("SubStation Alpha");
		names[MEDIASUBTYPE_ASS] = _T("Advanced SubStation Alpha");
		names[MEDIASUBTYPE_ASS2] = _T("Advanced SubStation Alpha");
		names[MEDIASUBTYPE_USF] = _T("Universal Subtitle Format");
		names[MEDIASUBTYPE_VOBSUB] = _T("VobSub");
		// names[''] = _T("");
	}

	if (names.Lookup(subtype, str)) {

	}

	return str;
}
Ejemplo n.º 7
0
__int64 CDSMSplitterFile::FindSyncPoint(REFERENCE_TIME rt)
{
	if (/*!m_sps.IsEmpty()*/ m_sps.GetCount() > 1) {
		int i = range_bsearch(m_sps, m_rtFirst + rt);
		return i >= 0 ? m_sps[i].fp : 0;
	}

	if (m_rtDuration <= 0 || rt <= m_rtFirst) {
		return 0;
	}

	// ok, do the hard way then

	dsmp_t type;
	UINT64 syncpos, len;

	// 1. find some boundaries close to rt's position (minpos, maxpos)

	__int64 minpos = 0, maxpos = GetLength();

	for (int i = 0; i < 10 && (maxpos - minpos) >= 1024*1024; i++) {
		Seek((minpos + maxpos) / 2);

		while (GetPos() < maxpos) {
			if (!Sync(syncpos, type, len)) {
				continue;
			}

			__int64 pos = GetPos();

			if (type == DSMP_SAMPLE) {
				Packet p;
				if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
					REFERENCE_TIME dt = (p.rtStart -= m_rtFirst) - rt;
					if (dt >= 0) {
						maxpos = max((__int64)syncpos - 65536, minpos);
					} else {
						minpos = syncpos;
					}
					break;
				}
			}

			Seek(pos + len);
		}
	}

	// 2. find the first packet just after rt (maxpos)

	Seek(minpos);

	while (GetRemaining()) {
		if (!Sync(syncpos, type, len)) {
			continue;
		}

		__int64 pos = GetPos();

		if (type == DSMP_SAMPLE) {
			Packet p;
			if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME) {
				REFERENCE_TIME dt = (p.rtStart -= m_rtFirst) - rt;
				if (dt >= 0) {
					maxpos = (__int64)syncpos;
					break;
				}
			}
		}

		Seek(pos + len);
	}

	// 3. iterate backwards from maxpos and find at least one syncpoint for every stream, except for subtitle streams

	CAtlMap<BYTE,BYTE> ids;

	{
		POSITION pos = m_mts.GetStartPosition();
		while (pos) {
			BYTE id;
			CMediaType mt;
			m_mts.GetNextAssoc(pos, id, mt);
			if (mt.majortype != MEDIATYPE_Text && mt.majortype != MEDIATYPE_Subtitle) {
				ids[id] = 0;
			}
		}
	}

	__int64 ret = maxpos;

	while (maxpos > 0 && !ids.IsEmpty()) {
		minpos = max(0, maxpos - 65536);

		Seek(minpos);

		while (Sync(syncpos, type, len) && GetPos() < maxpos) {
			UINT64 pos = GetPos();

			if (type == DSMP_SAMPLE) {
				Packet p;
				if (Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME && p.bSyncPoint) {
					BYTE id = (BYTE)p.TrackNumber, tmp;
					if (ids.Lookup(id, tmp)) {
						ids.RemoveKey((BYTE)p.TrackNumber);
						ret = min(ret, (__int64)syncpos);
					}
				}
			}

			Seek(pos + len);
		}

		maxpos = minpos;
	}

	return ret;
}
Ejemplo n.º 8
0
CString CMediaTypeEx::GetAudioCodecName(const GUID& subtype, WORD wFormatTag)
{
	CString str;

	static CAtlMap<WORD, CString> names;

	if (names.IsEmpty()) {
		names[WAVE_FORMAT_PCM] = _T("PCM");
		names[WAVE_FORMAT_EXTENSIBLE] = _T("WAVE_FORMAT_EXTENSIBLE");
		names[WAVE_FORMAT_IEEE_FLOAT] = _T("IEEE Float");
		names[WAVE_FORMAT_ADPCM] = _T("MS ADPCM");
		names[WAVE_FORMAT_ALAW] = _T("aLaw");
		names[WAVE_FORMAT_MULAW] = _T("muLaw");
		names[WAVE_FORMAT_DRM] = _T("DRM");
		names[WAVE_FORMAT_OKI_ADPCM] = _T("OKI ADPCM");
		names[WAVE_FORMAT_DVI_ADPCM] = _T("DVI ADPCM");
		names[WAVE_FORMAT_IMA_ADPCM] = _T("IMA ADPCM");
		names[WAVE_FORMAT_MEDIASPACE_ADPCM] = _T("Mediaspace ADPCM");
		names[WAVE_FORMAT_SIERRA_ADPCM] = _T("Sierra ADPCM");
		names[WAVE_FORMAT_G723_ADPCM] = _T("G723 ADPCM");
		names[WAVE_FORMAT_DIALOGIC_OKI_ADPCM] = _T("Dialogic OKI ADPCM");
		names[WAVE_FORMAT_MEDIAVISION_ADPCM] = _T("Media Vision ADPCM");
		names[WAVE_FORMAT_YAMAHA_ADPCM] = _T("Yamaha ADPCM");
		names[WAVE_FORMAT_DSPGROUP_TRUESPEECH] = _T("DSP Group Truespeech");
		names[WAVE_FORMAT_DOLBY_AC2] = _T("Dolby AC2");
		names[WAVE_FORMAT_GSM610] = _T("GSM610");
		names[WAVE_FORMAT_MSNAUDIO] = _T("MSN Audio");
		names[WAVE_FORMAT_ANTEX_ADPCME] = _T("Antex ADPCME");
		names[WAVE_FORMAT_CS_IMAADPCM] = _T("Crystal Semiconductor IMA ADPCM");
		names[WAVE_FORMAT_ROCKWELL_ADPCM] = _T("Rockwell ADPCM");
		names[WAVE_FORMAT_ROCKWELL_DIGITALK] = _T("Rockwell Digitalk");
		names[WAVE_FORMAT_G721_ADPCM] = _T("G721");
		names[WAVE_FORMAT_G728_CELP] = _T("G728");
		names[WAVE_FORMAT_MSG723] = _T("MSG723");
		names[WAVE_FORMAT_MPEG] = _T("MPEG Audio");
		names[WAVE_FORMAT_MPEGLAYER3] = _T("MPEG Audio Layer 3");
		names[WAVE_FORMAT_LUCENT_G723] = _T("Lucent G723");
		names[WAVE_FORMAT_VOXWARE] = _T("Voxware");
		names[WAVE_FORMAT_G726_ADPCM] = _T("G726");
		names[WAVE_FORMAT_G722_ADPCM] = _T("G722");
		names[WAVE_FORMAT_G729A] = _T("G729A");
		names[WAVE_FORMAT_MEDIASONIC_G723] = _T("MediaSonic G723");
		names[WAVE_FORMAT_ZYXEL_ADPCM] = _T("ZyXEL ADPCM");
		names[WAVE_FORMAT_RHETOREX_ADPCM] = _T("Rhetorex ADPCM");
		names[WAVE_FORMAT_VIVO_G723] = _T("Vivo G723");
		names[WAVE_FORMAT_VIVO_SIREN] = _T("Vivo Siren");
		names[WAVE_FORMAT_DIGITAL_G723] = _T("Digital G723");
		names[WAVE_FORMAT_SANYO_LD_ADPCM] = _T("Sanyo LD ADPCM");
		names[WAVE_FORMAT_CREATIVE_ADPCM] = _T("Creative ADPCM");
		names[WAVE_FORMAT_CREATIVE_FASTSPEECH8] = _T("Creative Fastspeech 8");
		names[WAVE_FORMAT_CREATIVE_FASTSPEECH10] = _T("Creative Fastspeech 10");
		names[WAVE_FORMAT_UHER_ADPCM] = _T("UHER ADPCM");
		names[WAVE_FORMAT_DOLBY_AC3] = _T("Dolby AC3");
		names[WAVE_FORMAT_DVD_DTS] = _T("DTS");
		names[WAVE_FORMAT_AAC] = _T("AAC");
		names[WAVE_FORMAT_LATM_AAC] = _T("AAC(LATM)");
		names[WAVE_FORMAT_FLAC] = _T("FLAC");
		names[WAVE_FORMAT_TTA1] = _T("TTA");
		names[WAVE_FORMAT_14_4] = _T("RealAudio 14.4");
		names[WAVE_FORMAT_28_8] = _T("RealAudio 28.8");
		names[WAVE_FORMAT_ATRC] = _T("RealAudio ATRC");
		names[WAVE_FORMAT_COOK] = _T("RealAudio COOK");
		names[WAVE_FORMAT_DNET] = _T("RealAudio DNET");
		names[WAVE_FORMAT_RAAC] = _T("RealAudio RAAC");
		names[WAVE_FORMAT_RACP] = _T("RealAudio RACP");
		names[WAVE_FORMAT_SIPR] = _T("RealAudio SIPR");
		names[WAVE_FORMAT_PS2_PCM] = _T("PS2 PCM");
		names[WAVE_FORMAT_PS2_ADPCM] = _T("PS2 ADPCM");
		names[0x0160] = _T("Windows Media Audio");
		names[0x0161] = _T("Windows Media Audio");
		names[0x0162] = _T("Windows Media Audio");
		names[0x0163] = _T("Windows Media Audio");
		names[0x6173] = _T("AMR");
		// names[] = _T("");
	}

	if (!names.Lookup(wFormatTag, str)) {
		if (subtype == MEDIASUBTYPE_Vorbis) {
			str = _T("Vorbis (deprecated)");
		} else if (subtype == MEDIASUBTYPE_Vorbis2) {
			str = _T("Vorbis");
		} else if (subtype == MEDIASUBTYPE_MP4A) {
			str = _T("MPEG4 Audio");
		} else if (subtype == MEDIASUBTYPE_FLAC_FRAMED) {
			str = _T("FLAC (framed)");
		} else if (subtype == MEDIASUBTYPE_DOLBY_AC3) {
			str += _T("Dolby AC3");
		} else if (subtype == MEDIASUBTYPE_DTS) {
			str += _T("DTS");
		} else if (subtype == MEDIASUBTYPE_PCM_NONE || subtype == MEDIASUBTYPE_PCM_RAW ||
				   subtype == MEDIASUBTYPE_PCM_TWOS || subtype == MEDIASUBTYPE_PCM_SOWT ||
				   subtype == MEDIASUBTYPE_PCM_IN24 || subtype == MEDIASUBTYPE_PCM_IN32 ||
				   subtype == MEDIASUBTYPE_PCM_IN24_le || subtype == MEDIASUBTYPE_PCM_IN32_le ||
				   subtype == MEDIASUBTYPE_PCM_FL32 || subtype == MEDIASUBTYPE_PCM_FL32_le ||
				   subtype == MEDIASUBTYPE_PCM_FL64 || subtype == MEDIASUBTYPE_PCM_FL64_le) {
			str += _T("PCM");
		} else if (subtype == MEDIASUBTYPE_ADPCM_SWF || subtype == MEDIASUBTYPE_IMA4) {
			str += _T("ADPCM");
		} else if (subtype == MEDIASUBTYPE_ALAC) {
			str += _T("Alac");
		} else if (subtype == MEDIASUBTYPE_ALS) {
			str += _T("ALS");
		} else {
			str.Format(_T("0x%04x"), wFormatTag);
		}
	}

	if (wFormatTag == WAVE_FORMAT_PCM) {
		if (subtype == MEDIASUBTYPE_DOLBY_AC3) {
			str += _T(" (AC3)");
		} else if (subtype == MEDIASUBTYPE_DTS) {
			str += _T(" (DTS)");
		}
	}

	return str;
}
Ejemplo n.º 9
0
CString GetGUIDString(const GUID& guid)
{
	static CAtlMap<GUID, CString> DXVA_names;
	{
		DXVA_ModeNone;

		ADDENTRY(DXVA_ModeNone);
		ADDENTRY(DXVA_ModeH261_A);
		ADDENTRY(DXVA_ModeH261_B);

		ADDENTRY(DXVA_ModeH263_A);
		ADDENTRY(DXVA_ModeH263_B);
		ADDENTRY(DXVA_ModeH263_C);
		ADDENTRY(DXVA_ModeH263_D);
		ADDENTRY(DXVA_ModeH263_E);
		ADDENTRY(DXVA_ModeH263_F);

		ADDENTRY(DXVA_ModeMPEG1_A);

		ADDENTRY(DXVA_ModeMPEG2_A);
		ADDENTRY(DXVA_ModeMPEG2_B);
		ADDENTRY(DXVA_ModeMPEG2_C);
		ADDENTRY(DXVA_ModeMPEG2_D);
		ADDENTRY(DXVA2_ModeMPEG2_MoComp);
		ADDENTRY(DXVA2_ModeMPEG2_IDCT);
		ADDENTRY(DXVA2_ModeMPEG2_VLD);
		ADDENTRY(DXVA_ModeMPEG2and1_VLD);

		ADDENTRY(DXVA_ModeH264_A);
		ADDENTRY(DXVA_ModeH264_B);
		ADDENTRY(DXVA_ModeH264_C);
		ADDENTRY(DXVA_ModeH264_D);
		ADDENTRY(DXVA_ModeH264_E);
		ADDENTRY(DXVA_ModeH264_F);

		ADDENTRY(DXVA_ModeWMV8_A);
		ADDENTRY(DXVA_ModeWMV8_B);

		ADDENTRY(DXVA_ModeWMV9_A);
		ADDENTRY(DXVA_ModeWMV9_B);
		ADDENTRY(DXVA_ModeWMV9_C);

		ADDENTRY(DXVA_ModeVC1_A);
		ADDENTRY(DXVA_ModeVC1_B);
		ADDENTRY(DXVA_ModeVC1_C);
		ADDENTRY(DXVA_ModeVC1_D);
		ADDENTRY(DXVA2_ModeVC1_D2010);

		ADDENTRY(DXVA_Intel_H264_ClearVideo);
		ADDENTRY(DXVA_Intel_VC1_ClearVideo);
		ADDENTRY(DXVA_Intel_VC1_ClearVideo_2);
		ADDENTRY(DXVA_MPEG4_ASP);

		ADDENTRY(DXVA_ModeHEVC_VLD_Main);
		ADDENTRY(DXVA_ModeHEVC_VLD_Main10);

		ADDENTRY(DXVA_NoEncrypt);
	}

	// to prevent print TIME_FORMAT_NONE for GUID_NULL
	if (guid == GUID_NULL) {
		return _T("GUID_NULL");
	}

	CString guidStr = CString(GuidNames[guid]);
	if (guidStr == _T("Unknown GUID Name")) {
		guidStr = CString(m_GuidNames[guid]);
	}
	if (guidStr == _T("Unknown GUID Name")) {
		CString str;
		if (DXVA_names.Lookup(guid, str)) {
			guidStr = str;
		}
	}

	return guidStr;
}
Ejemplo n.º 10
0
CString CMediaTypeEx::GetAudioCodecName(const GUID& subtype, WORD wFormatTag)
{
	CString str;

	static CAtlMap<WORD, CString> names;
	if (names.IsEmpty()) {
		// MMReg.h
		names[WAVE_FORMAT_ADPCM]                 = _T("MS ADPCM");
		names[WAVE_FORMAT_IEEE_FLOAT]            = _T("IEEE Float");
		names[WAVE_FORMAT_ALAW]                  = _T("aLaw");
		names[WAVE_FORMAT_MULAW]                 = _T("muLaw");
		names[WAVE_FORMAT_DTS]                   = _T("DTS");
		names[WAVE_FORMAT_DRM]                   = _T("DRM");
		names[WAVE_FORMAT_WMAVOICE9]             = _T("WMA Voice");
		names[WAVE_FORMAT_WMAVOICE10]            = _T("WMA Voice");
		names[WAVE_FORMAT_OKI_ADPCM]             = _T("OKI ADPCM");
		names[WAVE_FORMAT_IMA_ADPCM]             = _T("IMA ADPCM");
		names[WAVE_FORMAT_MEDIASPACE_ADPCM]      = _T("Mediaspace ADPCM");
		names[WAVE_FORMAT_SIERRA_ADPCM]          = _T("Sierra ADPCM");
		names[WAVE_FORMAT_G723_ADPCM]            = _T("G723 ADPCM");
		names[WAVE_FORMAT_DIALOGIC_OKI_ADPCM]    = _T("Dialogic OKI ADPCM");
		names[WAVE_FORMAT_MEDIAVISION_ADPCM]     = _T("Media Vision ADPCM");
		names[WAVE_FORMAT_YAMAHA_ADPCM]          = _T("Yamaha ADPCM");
		names[WAVE_FORMAT_DSPGROUP_TRUESPEECH]   = _T("DSP Group Truespeech");
		names[WAVE_FORMAT_DOLBY_AC2]             = _T("Dolby AC2");
		names[WAVE_FORMAT_GSM610]                = _T("GSM610");
		names[WAVE_FORMAT_MSNAUDIO]              = _T("MSN Audio");
		names[WAVE_FORMAT_ANTEX_ADPCME]          = _T("Antex ADPCME");
		names[WAVE_FORMAT_CS_IMAADPCM]           = _T("Crystal Semiconductor IMA ADPCM");
		names[WAVE_FORMAT_ROCKWELL_ADPCM]        = _T("Rockwell ADPCM");
		names[WAVE_FORMAT_ROCKWELL_DIGITALK]     = _T("Rockwell Digitalk");
		names[WAVE_FORMAT_G721_ADPCM]            = _T("G721");
		names[WAVE_FORMAT_G728_CELP]             = _T("G728");
		names[WAVE_FORMAT_MSG723]                = _T("MSG723");
		names[WAVE_FORMAT_MPEG]                  = _T("MPEG Audio");
		names[WAVE_FORMAT_MPEGLAYER3]            = _T("MP3");
		names[WAVE_FORMAT_LUCENT_G723]           = _T("Lucent G723");
		names[WAVE_FORMAT_VOXWARE]               = _T("Voxware");
		names[WAVE_FORMAT_G726_ADPCM]            = _T("G726");
		names[WAVE_FORMAT_G722_ADPCM]            = _T("G722");
		names[WAVE_FORMAT_G729A]                 = _T("G729A");
		names[WAVE_FORMAT_MEDIASONIC_G723]       = _T("MediaSonic G723");
		names[WAVE_FORMAT_ZYXEL_ADPCM]           = _T("ZyXEL ADPCM");
		names[WAVE_FORMAT_RAW_AAC1]              = _T("AAC");
		names[WAVE_FORMAT_RHETOREX_ADPCM]        = _T("Rhetorex ADPCM");
		names[WAVE_FORMAT_VIVO_G723]             = _T("Vivo G723");
		names[WAVE_FORMAT_VIVO_SIREN]            = _T("Vivo Siren");
		names[WAVE_FORMAT_DIGITAL_G723]          = _T("Digital G723");
		names[WAVE_FORMAT_SANYO_LD_ADPCM]        = _T("Sanyo LD ADPCM");
		names[WAVE_FORMAT_MSAUDIO1]              = _T("WMA 1");
		names[WAVE_FORMAT_WMAUDIO2]              = _T("WMA 2");
		names[WAVE_FORMAT_WMAUDIO3]              = _T("WMA Pro");
		names[WAVE_FORMAT_WMAUDIO_LOSSLESS]      = _T("WMA Lossless");
		names[WAVE_FORMAT_CREATIVE_ADPCM]        = _T("Creative ADPCM");
		names[WAVE_FORMAT_CREATIVE_FASTSPEECH8]  = _T("Creative Fastspeech 8");
		names[WAVE_FORMAT_CREATIVE_FASTSPEECH10] = _T("Creative Fastspeech 10");
		names[WAVE_FORMAT_UHER_ADPCM]            = _T("UHER ADPCM");
		names[WAVE_FORMAT_DTS2]                  = _T("DTS");
		// other
		names[WAVE_FORMAT_DOLBY_AC3]             = _T("Dolby AC3");
		names[WAVE_FORMAT_LATM_AAC]              = _T("AAC(LATM)");
		names[WAVE_FORMAT_FLAC]                  = _T("FLAC");
		names[WAVE_FORMAT_TTA1]                  = _T("TTA");
		names[WAVE_FORMAT_WAVPACK4]              = _T("WavPack");
		names[WAVE_FORMAT_14_4]                  = _T("RealAudio 14.4");
		names[WAVE_FORMAT_28_8]                  = _T("RealAudio 28.8");
		names[WAVE_FORMAT_ATRC]                  = _T("RealAudio ATRC");
		names[WAVE_FORMAT_COOK]                  = _T("RealAudio COOK");
		names[WAVE_FORMAT_DNET]                  = _T("RealAudio DNET");
		names[WAVE_FORMAT_RAAC]                  = _T("RealAudio RAAC");
		names[WAVE_FORMAT_RACP]                  = _T("RealAudio RACP");
		names[WAVE_FORMAT_SIPR]                  = _T("RealAudio SIPR");
		names[WAVE_FORMAT_PS2_PCM]               = _T("PS2 PCM");
		names[WAVE_FORMAT_PS2_ADPCM]             = _T("PS2 ADPCM");
		names[WAVE_FORMAT_SPEEX]                 = _T("Speex");
		names[WAVE_FORMAT_ADX_ADPCM]             = _T("ADX ADPCM");
	}

	if (!names.Lookup(wFormatTag, str)) {
		// for wFormatTag equal to WAVE_FORMAT_UNKNOWN, WAVE_FORMAT_PCM, WAVE_FORMAT_EXTENSIBLE and other.
		if (subtype == MEDIASUBTYPE_PCM) {
			str = _T("PCM");
		} else if (subtype == MEDIASUBTYPE_IEEE_FLOAT) {
			str = _T("IEEE Float");
		} else if (subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO || subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
			str = _T("LPCM");
		} else if (subtype == MEDIASUBTYPE_Vorbis) {
			str = _T("Vorbis (deprecated)");
		} else if (subtype == MEDIASUBTYPE_Vorbis2) {
			str = _T("Vorbis");
		} else if (subtype == MEDIASUBTYPE_MP4A) {
			str = _T("MPEG4 Audio");
		} else if (subtype == MEDIASUBTYPE_FLAC_FRAMED) {
			str = _T("FLAC (framed)");
		} else if (subtype == MEDIASUBTYPE_DOLBY_AC3) {
			str = _T("Dolby AC3");
		} else if (subtype == MEDIASUBTYPE_DOLBY_DDPLUS) {
			str = _T("DD+");
		} else if (subtype == MEDIASUBTYPE_DOLBY_TRUEHD) {
			str = _T("TrueHD");
		} else if (subtype == MEDIASUBTYPE_DTS) {
			str = _T("DTS");
		} else if (subtype == MEDIASUBTYPE_MLP) {
			str = _T("MLP");
		} else if (subtype == MEDIASUBTYPE_PCM_NONE || subtype == MEDIASUBTYPE_PCM_RAW ||
				   subtype == MEDIASUBTYPE_PCM_TWOS || subtype == MEDIASUBTYPE_PCM_SOWT ||
				   subtype == MEDIASUBTYPE_PCM_IN24 || subtype == MEDIASUBTYPE_PCM_IN32 ||
				   subtype == MEDIASUBTYPE_PCM_FL32 || subtype == MEDIASUBTYPE_PCM_FL64) {
			str = _T("QT PCM");
		} else if (subtype == MEDIASUBTYPE_IMA4      ||
				   subtype == MEDIASUBTYPE_ADPCM_SWF ||
				   subtype == MEDIASUBTYPE_IMA_AMV) {
			str = _T("ADPCM");
		} else if (subtype == MEDIASUBTYPE_ALAC) {
			str = _T("ALAC");
		} else if (subtype == MEDIASUBTYPE_ALS) {
			str = _T("ALS");
		} else if (subtype == MEDIASUBTYPE_QDM2) {
			str = _T("QDM2");
		} else if (subtype == MEDIASUBTYPE_RoQA) {
			str += _T("ROQA");
		} else if (subtype == MEDIASUBTYPE_APE) {
			str += _T("APE");
		} else if (subtype == MEDIASUBTYPE_AMR  ||
				   subtype == MEDIASUBTYPE_SAMR ||
				   subtype == MEDIASUBTYPE_SAWB) {
			str = _T("AMR");
		} else if (subtype == MEDIASUBTYPE_OPUS) {
			str += _T("Opus");
		} else if (subtype == MEDIASUBTYPE_BINKA_DCT) {
			str += _T("BINK DCT");
		} else if (subtype == MEDIASUBTYPE_AAC_ADTS) {
			str += _T("AAC");
		} else {
			str.Format(_T("0x%04x"), wFormatTag);
		}
	}

	return str;
}
Ejemplo n.º 11
0
CString CMediaTypeEx::GetVideoCodecName(const GUID& subtype, DWORD biCompression)
{
	CString str;

	static CAtlMap<DWORD, CString> names;
	if (names.IsEmpty()) {
		names['WMV1'] = _T("Windows Media Video 7");
		names['WMV2'] = _T("Windows Media Video 8");
		names['WMV3'] = _T("Windows Media Video 9");
		names['DIV3'] = _T("DivX 3");
		names['MP43'] = _T("MSMPEG4v3");
		names['MP42'] = _T("MSMPEG4v2");
		names['MP41'] = _T("MSMPEG4v1");
		names['DX30'] = _T("DivX 3");
		names['DX50'] = _T("DivX 5");
		names['DIVX'] = _T("DivX 6");
		names['XVID'] = _T("Xvid");
		names['MP4V'] = _T("MPEG4 Video");
		names['AVC1'] = _T("MPEG4 Video (H264)");
		names['H264'] = _T("MPEG4 Video (H264)");
		names['RV10'] = _T("RealVideo 1");
		names['RV20'] = _T("RealVideo 2");
		names['RV30'] = _T("RealVideo 3");
		names['RV40'] = _T("RealVideo 4");
		names['FLV1'] = _T("Flash Video 1");
		names['FLV4'] = _T("Flash Video 4");
		names['VP50'] = _T("On2 VP5");
		names['VP60'] = _T("On2 VP6");
		names['SVQ3'] = _T("SVQ3");
		names['SVQ1'] = _T("SVQ1");
		names['H263'] = _T("H263");
		names['DRAC'] = _T("Dirac");
		names['WVC1'] = _T("VC-1");
		names['THEO'] = _T("Theora");
		names['HVC1'] = _T("HEVC");
		names['HM91'] = _T("HEVC(HM9.1)");
		names['HM10'] = _T("HEVC(HM10)");
		names['HM12'] = _T("HEVC(HM12)");
	}

	if (biCompression) {
		BYTE* b = (BYTE*)&biCompression;

		for (ptrdiff_t i = 0; i < 4; i++)
			if (b[i] >= 'a' && b[i] <= 'z') {
				b[i] = toupper(b[i]);
			}

		if (!names.Lookup(MAKEFOURCC(b[3], b[2], b[1], b[0]), str)) {
			if (subtype == MEDIASUBTYPE_DiracVideo) {
				str = _T("Dirac Video");
			} else if (subtype == MEDIASUBTYPE_apch ||
					   subtype == MEDIASUBTYPE_apcn ||
					   subtype == MEDIASUBTYPE_apcs ||
					   subtype == MEDIASUBTYPE_apco ||
					   subtype == MEDIASUBTYPE_ap4h) {
				str.Format(_T("ProRes Video (%4.4hs)"), &biCompression);
			} else if (biCompression < 256) {
				str.Format(_T("%u"), biCompression);
			} else {
				str.Format(_T("%4.4hs"), &biCompression);
			}
		}
	} else {
		if (subtype == MEDIASUBTYPE_RGB32)
			str = _T("RGB32");
		else if (subtype == MEDIASUBTYPE_RGB24)
			str = _T("RGB24");
		else if (subtype == MEDIASUBTYPE_RGB555)
			str = _T("RGB555");
		else if (subtype == MEDIASUBTYPE_RGB565)
			str = _T("RGB565");
        else if (subtype == MEDIASUBTYPE_ARGB32)
            str = _T("ARGB32");
	}

	return str;
}
Ejemplo n.º 12
0
int _tmain(int argc, _TCHAR* argv[])
{
	FT_Library pLibrary = NULL;
					
	//CString strFolder = _T("\\\\mediaserver\\Exchange\\Korshul\\Fonts");
	CString strFolder = _T("X:\\AVS\\Sources\\TeamlabOffice\\trunk\\ServerComponents\\DesktopEditor\\freetype_names\\FontsDictionaryFiles");
	CWinFontList* m_pList = NULL;

	if (!FT_Init_FreeType( &pLibrary ))
	{
		if (_T("") == strFolder)
			m_pList = new CWinFontList(pLibrary);
		else
			m_pList = new CWinFontList(pLibrary, strFolder);

		FT_Done_FreeType( pLibrary );
	}

	CString strFontDictionaryPath = _T("X:\\AVS\\Sources\\TeamlabOffice\\trunk\\ServerComponents\\DesktopEditor\\freetype_names\\FontMaps\\FontDictionary.h");

	int nCount = m_pList->GetFonts()->GetLength();

	// теперь строим массив всех шрифтов по имени
	CAtlMap<CString, CFontInfoJS> mapFonts;
	CAtlMap<CString, CFontInfoJS> mapFontsUnicodes;
	CAtlArray<CString> arrFonts;
	CAtlArray<CString> arrFontsUnicodes;

	int nError = 0;

	CAtlMap<CString, BOOL> mapMainAscii;
	for (int i = 0; i < nCount; ++i)
	{
		CWinFontInfo* pInfo = (CWinFontInfo*)m_pList->GetByIndex(i);
		CString strPath = (CString)pInfo->m_wsFontPath;
		CString strName = (CString)pInfo->m_wsFontName;

		LONG lFontIndex = 0;
		LONG lFaceIndex = 0;

		//CAtlMap<CString, LONG>::CPair* pPairFontFiles = mapFontFiles.Lookup(strPath);
		//lFontIndex = pPairFontFiles->m_value;
		lFontIndex = (LONG)i;

		if (pInfo->m_lIndex >= 0)
			lFaceIndex = pInfo->m_lIndex;

		mapMainAscii.SetAt(pInfo->m_wsFontName, TRUE);

		CAtlMap<CString, CFontInfoJS>::CPair* pPair = mapFonts.Lookup(pInfo->m_wsFontName);
		if (NULL != pPair)
		{
			pPair->m_value.m_sName = pInfo->m_wsFontName;

			if (pInfo->m_bBold && pInfo->m_bItalic)
			{
				if (-1 != pPair->m_value.m_lIndexBI)
					nError++;

				pPair->m_value.m_lIndexBI = lFontIndex;
				pPair->m_value.m_lFaceIndexBI = lFaceIndex;

				pPair->m_value.namesBI.RemoveAll();
				pPair->m_value.namesBI.Copy(pInfo->names);
			}
			else if (pInfo->m_bBold)
			{
				if (-1 != pPair->m_value.m_lIndexB)
					nError++;

				pPair->m_value.m_lIndexB = lFontIndex;
				pPair->m_value.m_lFaceIndexB = lFaceIndex;

				pPair->m_value.namesB.RemoveAll();
				pPair->m_value.namesB.Copy(pInfo->names);
			}
			else if (pInfo->m_bItalic)
			{
				if (-1 != pPair->m_value.m_lIndexI)
					nError++;

				pPair->m_value.m_lIndexI = lFontIndex;
				pPair->m_value.m_lFaceIndexI = lFaceIndex;

				pPair->m_value.namesI.RemoveAll();
				pPair->m_value.namesI.Copy(pInfo->names);
			}
			else
			{
				if (-1 != pPair->m_value.m_lIndexR)
					nError++;

				pPair->m_value.m_lIndexR = lFontIndex;
				pPair->m_value.m_lFaceIndexR = lFaceIndex;

				pPair->m_value.namesR.RemoveAll();
				pPair->m_value.namesR.Copy(pInfo->names);
			}
		}
		else
		{
			CFontInfoJS fontInfo;

			fontInfo.m_sName = pInfo->m_wsFontName;

			if (pInfo->m_bBold && pInfo->m_bItalic)
			{
				fontInfo.m_lIndexBI = lFontIndex;
				fontInfo.m_lFaceIndexBI = lFaceIndex;

				fontInfo.namesBI.RemoveAll();
				fontInfo.namesBI.Copy(pInfo->names);
			}
			else if (pInfo->m_bBold)
			{
				fontInfo.m_lIndexB = lFontIndex;
				fontInfo.m_lFaceIndexB = lFaceIndex;

				fontInfo.namesB.RemoveAll();
				fontInfo.namesB.Copy(pInfo->names);
			}
			else if (pInfo->m_bItalic)
			{
				fontInfo.m_lIndexI = lFontIndex;
				fontInfo.m_lFaceIndexI = lFaceIndex;

				fontInfo.namesI.RemoveAll();
				fontInfo.namesI.Copy(pInfo->names);
			}
			else
			{
				fontInfo.m_lIndexR = lFontIndex;
				fontInfo.m_lFaceIndexR = lFaceIndex;

				fontInfo.namesR.RemoveAll();
				fontInfo.namesR.Copy(pInfo->names);
			}

			mapFonts.SetAt(fontInfo.m_sName, fontInfo);
			arrFonts.Add(fontInfo.m_sName);
		}
	}

	// additional names
	for (int i = 0; i < nCount; ++i)
	{
		CWinFontInfo* pInfo = (CWinFontInfo*)m_pList->GetByIndex(i);
		CString strPath = (CString)pInfo->m_wsFontPath;
		CString strName = (CString)pInfo->m_wsFontName;

		LONG lFontIndex = 0;
		LONG lFaceIndex = 0;

		//CAtlMap<CString, LONG>::CPair* pPairFontFiles = mapFontFiles.Lookup(strPath);
		//lFontIndex = pPairFontFiles->m_value;
		lFontIndex = (LONG)i;

		if (pInfo->m_lIndex >= 0)
			lFaceIndex = pInfo->m_lIndex;

		int nNamesAdditional = pInfo->names.GetCount();
		for (int j = 0; j < nNamesAdditional; ++j)
		{
			CString strNameA = pInfo->names[j];

			CAtlMap<CString, BOOL>::CPair* pPairMain = mapMainAscii.Lookup(strNameA);
			if (NULL != pPairMain)
				continue;

			WCHAR* pBufferA = strNameA.GetBuffer();
			int len = strNameA.GetLength();
			
			CAtlMap<CString, CFontInfoJS>* pMap = &mapFonts;
			CAtlArray<CString>* pArrFonts = &arrFonts;

			for (int k = 0; k < len; ++k)
			{
				if (pBufferA[k] > 255)
				{
					pMap = &mapFontsUnicodes;
					pArrFonts = &arrFontsUnicodes;
					break;
				}
			}
			
			CAtlMap<CString, CFontInfoJS>::CPair* pPair = pMap->Lookup(strNameA);
			if (NULL != pPair)
			{
				pPair->m_value.m_sName = strNameA;

				if (pInfo->m_bBold && pInfo->m_bItalic)
				{
					if (-1 != pPair->m_value.m_lIndexBI)
						nError++;

					pPair->m_value.m_lIndexBI = lFontIndex;
					pPair->m_value.m_lFaceIndexBI = lFaceIndex;

					pPair->m_value.namesBI.RemoveAll();
					pPair->m_value.namesBI.Copy(pInfo->names);
				}
				else if (pInfo->m_bBold)
				{
					if (-1 != pPair->m_value.m_lIndexB)
						nError++;

					pPair->m_value.m_lIndexB = lFontIndex;
					pPair->m_value.m_lFaceIndexB = lFaceIndex;

					pPair->m_value.namesB.RemoveAll();
					pPair->m_value.namesB.Copy(pInfo->names);
				}
				else if (pInfo->m_bItalic)
				{
					if (-1 != pPair->m_value.m_lIndexI)
						nError++;

					pPair->m_value.m_lIndexI = lFontIndex;
					pPair->m_value.m_lFaceIndexI = lFaceIndex;

					pPair->m_value.namesI.RemoveAll();
					pPair->m_value.namesI.Copy(pInfo->names);
				}
				else
				{
					if (-1 != pPair->m_value.m_lIndexR)
						nError++;

					pPair->m_value.m_lIndexR = lFontIndex;
					pPair->m_value.m_lFaceIndexR = lFaceIndex;

					pPair->m_value.namesR.RemoveAll();
					pPair->m_value.namesR.Copy(pInfo->names);
				}
			}
			else
			{
				CFontInfoJS fontInfo;

				fontInfo.m_sName = strNameA;

				if (pInfo->m_bBold && pInfo->m_bItalic)
				{
					fontInfo.m_lIndexBI = lFontIndex;
					fontInfo.m_lFaceIndexBI = lFaceIndex;

					fontInfo.namesBI.RemoveAll();
					fontInfo.namesBI.Copy(pInfo->names);
				}
				else if (pInfo->m_bBold)
				{
					fontInfo.m_lIndexB = lFontIndex;
					fontInfo.m_lFaceIndexB = lFaceIndex;

					fontInfo.namesB.RemoveAll();
					fontInfo.namesB.Copy(pInfo->names);
				}
				else if (pInfo->m_bItalic)
				{
					fontInfo.m_lIndexI = lFontIndex;
					fontInfo.m_lFaceIndexI = lFaceIndex;

					fontInfo.namesI.RemoveAll();
					fontInfo.namesI.Copy(pInfo->names);
				}
				else
				{
					fontInfo.m_lIndexR = lFontIndex;
					fontInfo.m_lFaceIndexR = lFaceIndex;

					fontInfo.namesR.RemoveAll();
					fontInfo.namesR.Copy(pInfo->names);
				}

				pMap->SetAt(fontInfo.m_sName, fontInfo);
				pArrFonts->Add(fontInfo.m_sName);
			}
		}
	}
	// -------------------------------------------

	// теперь сортируем шрифты по имени ----------
	size_t nCountFonts = arrFonts.GetCount();
	for (size_t i = 0; i < nCountFonts; ++i)
	{
		for (size_t j = i + 1; j < nCountFonts; ++j)
		{
			if (arrFonts[i] > arrFonts[j])
			{
				CString temp = arrFonts[i];
				arrFonts[i] = arrFonts[j];
				arrFonts[j] = temp;
			}
		}
	}

	size_t nCountFontsU = arrFontsUnicodes.GetCount();
	for (size_t i = 0; i < nCountFontsU; ++i)
	{
		for (size_t j = i + 1; j < nCountFontsU; ++j)
		{
			if (arrFontsUnicodes[i] > arrFontsUnicodes[j])
			{
				CString temp = arrFontsUnicodes[i];
				arrFontsUnicodes[i] = arrFontsUnicodes[j];
				arrFontsUnicodes[j] = temp;
			}
		}
	}

#if 0
	CFile oFile;
	oFile.CreateFile(_T("c:\\fonts.txt"));

	BYTE bom[3];
	bom[0] = 0xEF;
	bom[1] = 0xBB;
	bom[2] = 0xBF;
	oFile.WriteFile((void*)&bom, 3);

	CString strInfos = _T("");
	
	for (int index = 0; index < nCountFonts; ++index)
	{
		const CAtlMap<CString, CFontInfoJS>::CPair* pPair = mapFonts.Lookup(arrFonts[index]);

		CString strFontInfo = pPair->m_value.m_sName + _T(": [");

		for (size_t i = 0; i < pPair->m_value.namesR.GetCount(); ++i)
		{
			strFontInfo += pPair->m_value.namesR[i];
			strFontInfo += _T(",");
		}
		strFontInfo += _T(";");

		for (size_t i = 0; i < pPair->m_value.namesI.GetCount(); ++i)
		{
			strFontInfo += pPair->m_value.namesI[i];
			strFontInfo += _T(",");
		}
		strFontInfo += _T(";");

		for (size_t i = 0; i < pPair->m_value.namesB.GetCount(); ++i)
		{
			strFontInfo += pPair->m_value.namesB[i];
			strFontInfo += _T(",");
		}
		strFontInfo += _T(";");

		for (size_t i = 0; i < pPair->m_value.namesBI.GetCount(); ++i)
		{
			strFontInfo += pPair->m_value.namesBI[i];
			strFontInfo += _T(",");
		}
		
		strFontInfo += _T("]\n");

		strInfos += strFontInfo;
	}

	oFile.WriteStringUTF8(strInfos);

	oFile.CloseFile();
#endif

	CFile oFileW;
	oFileW.CreateFile(strFontDictionaryPath);

	BYTE bom[3];
	bom[0] = 0xEF;
	bom[1] = 0xBB;
	bom[2] = 0xBF;
	oFileW.WriteFile((void*)&bom, 3);

	CString strAll = _T("");

	CString strConstant1 = _T("#ifndef _FONT_DICTIONARY_H\n\n\
typedef struct FD_FontMapRec_\n\
{\n\
	const char*		m_name;\n\
\n\
	int				m_index_r;\n\
	int				m_index_i;\n\
	int				m_index_b;\n\
	int				m_index_bi;\n\
} FD_FontMapRec;\n\n\
typedef struct FD_FontMapRecW_\n\
{\n\
	const wchar_t*	m_name;\n\
\n\
	int				m_index_r;\n\
	int				m_index_i;\n\
	int				m_index_b;\n\
	int				m_index_bi;\n\
} FD_FontMapRecW;\n\n");

	strAll += strConstant1;

	int nAsciiNamesCount = (int)arrFonts.GetCount();
	CString sAsciiNames = _T("");
	sAsciiNames.Format(_T("#define FONTS_DICT_ASCII_NAMES_COUNT %d\n"), nAsciiNamesCount);
	sAsciiNames += _T("static const FD_FontMapRec FD_Ascii_Names[FONTS_DICT_ASCII_NAMES_COUNT] = \n{\n");

	for (int k = 0; k < nAsciiNamesCount; ++k)
	{
		CAtlMap<CString, CFontInfoJS>::CPair* pPair = mapFonts.Lookup(arrFonts[k]);

		sAsciiNames += _T("\t{ \"");
		sAsciiNames += pPair->m_value.m_sName;
		sAsciiNames += _T("\", ");

		CString strP = _T("");

		if (k != (nAsciiNamesCount - 1))
		{
			strP.Format(_T("%d, %d, %d, %d },\n"), pPair->m_value.m_lIndexR,
				pPair->m_value.m_lIndexI, pPair->m_value.m_lIndexB, pPair->m_value.m_lIndexBI);
		}
		else
		{
			strP.Format(_T("%d, %d, %d, %d }\n"), pPair->m_value.m_lIndexR,
				pPair->m_value.m_lIndexI, pPair->m_value.m_lIndexB, pPair->m_value.m_lIndexBI);
		}

		sAsciiNames += strP;
	}

	sAsciiNames += _T("};\n\n");

	strAll += sAsciiNames;

	int _offsets[256];
	for (int t = 0; t < 256; ++t)
		_offsets[t] = -1;

	int nCurChar = -1;
	for (int k = 0; k < nAsciiNamesCount; ++k)
	{
		int nChar = (int)arrFonts[k].GetAt(0);
		nChar = max(0, min(nChar, 255));

		if (nChar != nCurChar)
		{
			_offsets[nChar] = k;
		}
		nCurChar = nChar;
	}

	CString strAsciiOffsets = _T("static const int FD_Ascii_Names_Offsets[256] =\n{\n");

	for (int k = 0; k < 256; ++k)
	{
		CString sMem = _T("");
		sMem.Format(_T("%d"), _offsets[k]);

		while (sMem.GetLength() < 4)
			sMem = (_T(" ") + sMem);
		
		if (0 == k % 32)
			sMem = _T("\t") + sMem;

		if (k != 255)
			sMem += _T(",");
		
		if (0 == (k + 1) % 32)
			sMem += _T("\n");

		strAsciiOffsets += sMem;
	}

	strAsciiOffsets += _T("};\n\n");

	strAll += strAsciiOffsets;

	int nUnicodeNamesCount = (int)arrFontsUnicodes.GetCount();
	CString sUnicodeNames = _T("");
	sUnicodeNames.Format(_T("#define FONTS_DICT_UNICODE_NAMES_COUNT %d\n"), nUnicodeNamesCount);
	sUnicodeNames += _T("static const FD_FontMapRecW FD_Unicode_Names[FONTS_DICT_UNICODE_NAMES_COUNT] = \n{\n");

	for (int k = 0; k < nUnicodeNamesCount; ++k)
	{
		CAtlMap<CString, CFontInfoJS>::CPair* pPair = mapFontsUnicodes.Lookup(arrFontsUnicodes[k]);

		sUnicodeNames += _T("\t{ L\"");
		sUnicodeNames += pPair->m_value.m_sName;
		sUnicodeNames += _T("\", ");

		CString strP = _T("");

		if (k != (nAsciiNamesCount - 1))
		{
			strP.Format(_T("%d, %d, %d, %d },\n"), pPair->m_value.m_lIndexR,
				pPair->m_value.m_lIndexI, pPair->m_value.m_lIndexB, pPair->m_value.m_lIndexBI);
		}
		else
		{
			strP.Format(_T("%d, %d, %d, %d }\n"), pPair->m_value.m_lIndexR,
				pPair->m_value.m_lIndexI, pPair->m_value.m_lIndexB, pPair->m_value.m_lIndexBI);
		}

		sUnicodeNames += strP;
	}

	sUnicodeNames += _T("};\n\n");

	strAll += sUnicodeNames;

	CString strConstant2 = _T("typedef struct FD_Font_Rec\n\
{\n\
	const char*		m_name;\n\
\n\
	long			m_lIndex;\n\
\n\
	unsigned char	m_bBold;\n\
	unsigned char	m_bItalic;\n\
	unsigned char	m_bIsFixed;\n\
\n\
	unsigned char	m_aPanose[10];\n\
	unsigned long	m_ulUnicodeRange1;\n\
	unsigned long	m_ulUnicodeRange2;\n\
	unsigned long	m_ulUnicodeRange3;\n\
	unsigned long	m_ulUnicodeRange4;\n\
\n\
	unsigned long	m_ulCodePageRange1;\n\
	unsigned long	m_ulCodePageRange2;\n\
\n\
	unsigned short	m_usWeigth;\n\
	unsigned short	m_usWidth;\n\
\n\
	short			m_sFamilyClass;\n\
	unsigned char	m_eFontFormat;\n\
\n\
	short			m_shAvgCharWidth;\n\
	short			m_shAscent;\n\
	short			m_shDescent;\n\
	short			m_shLineGap;\n\
	short			m_shXHeight;\n\
	short			m_shCapHeight;\n\
} FD_Font;\n\n");

	strAll += strConstant2;

	int nAllFontsCount = (int)nCount;
	CString sAllFontsNames = _T("");
	sAllFontsNames.Format(_T("#define FONTS_DICT_ASCII_FONTS_COUNT %d\n"), nCount);
	sAllFontsNames += _T("static const FD_Font FD_Ascii_Files[FONTS_DICT_ASCII_FONTS_COUNT] = \n{\n");

	for (int k = 0; k < nCount; ++k)
	{
		CWinFontInfo* pInfo = (CWinFontInfo*)m_pList->GetByIndex(k);

#if 1
		// CORRECT!!!
		if (pInfo->m_wsFontName == _T("Monotype Sorts"))
			pInfo->m_aPanose[0] = 5;
#endif
		
		CString sMem = _T("");
		sMem.Format(_T("\", %d, %d, %d, %d, { %d, %d, %d, %d, %d, %d, %d, %d, %d, %d }, %u, %u, %u, %u, %u, %u, %u, %u, %d, %d, %d, %d, %d, %d, %d, %d }"),
			pInfo->m_lIndex,
			pInfo->m_bBold,
			pInfo->m_bItalic,
			pInfo->m_bIsFixed,
			pInfo->m_aPanose[0],
			pInfo->m_aPanose[1],
			pInfo->m_aPanose[2],
			pInfo->m_aPanose[3],
			pInfo->m_aPanose[4],
			pInfo->m_aPanose[5],
			pInfo->m_aPanose[6],
			pInfo->m_aPanose[7],
			pInfo->m_aPanose[8],
			pInfo->m_aPanose[9],
			pInfo->m_ulUnicodeRange1,
			pInfo->m_ulUnicodeRange2,
			pInfo->m_ulUnicodeRange3,
			pInfo->m_ulUnicodeRange4,
			pInfo->m_ulCodePageRange1,
			pInfo->m_ulCodePageRange2,
			pInfo->m_usWeigth,
			pInfo->m_usWidth,
			pInfo->m_sFamilyClass,
			pInfo->m_eFontFormat,
			pInfo->m_shAvgCharWidth,
			pInfo->m_shAscent,
			pInfo->m_shDescent,
			pInfo->m_shLineGap,
			pInfo->m_shXHeight,
			pInfo->m_shCapHeight);

		sAllFontsNames += _T("\t{\"");
		sAllFontsNames += pInfo->m_wsFontName;
		sAllFontsNames += sMem;
		if (k != (nCount - 1))
			sAllFontsNames += _T(",\n");
		else
			sAllFontsNames += _T("\n");
	}

	sAllFontsNames += _T("};\n\n");

	strAll += sAllFontsNames;

	CString strError = _T("");
	strError.Format(_T("// error : %d\n\n"), nError);
	strAll += strError;

	strAll += _T("#endif /* _FONT_DICTIONARY_H */");

	oFileW.WriteStringUTF8(strAll);
	oFileW.CloseFile();

	if (NULL != m_pList)
		delete m_pList;

	return 0;
}