Пример #1
0
unsigned short WrittenFontCFF::EncodeGlyph(unsigned int inGlyph,const ULongVector& inCharacters)
{
	// for the first time, add also 0,0 mapping
	if(mANSIRepresentation->mGlyphIDToEncodedChar.size() == 0)
		mANSIRepresentation->mGlyphIDToEncodedChar.insert(UIntToGlyphEncodingInfoMap::value_type(0,GlyphEncodingInfo(0,0)));

	UIntToGlyphEncodingInfoMap::iterator it = mANSIRepresentation->mGlyphIDToEncodedChar.find(inGlyph);

	if(it == mANSIRepresentation->mGlyphIDToEncodedChar.end())
	{
		// as a default position, i'm grabbing the ansi bits. this should display nice charachters, when possible
		unsigned char encoding;
		if(inCharacters.size() > 0)
			encoding = (unsigned char)(inCharacters.back() & 0xff);
		else
			encoding = (unsigned char)(inGlyph & 0xff);
		if(mAssignedPositions[encoding] == 0)
			RemoveFromFreeList(encoding);
		else
			encoding = AllocateFromFreeList(inGlyph);
		mAssignedPositions[encoding] = inGlyph;
		it = mANSIRepresentation->mGlyphIDToEncodedChar.insert(
				UIntToGlyphEncodingInfoMap::value_type(inGlyph,GlyphEncodingInfo(encoding,inCharacters))).first;			
		--mAvailablePositionsCount;
	}
	return it->second.mEncodedCharacter;
}
// Can use this function to get likelihood with a topgauss
double TopGauss::get(MixtureGD & UBM,FeatureServer &fs,String & featureFilename,Config & config){
	StatServer ss(config);
	String labelSelectedFrames =config.getParam("labelSelectedFrames");
	unsigned long begin=fs.getFirstFeatureIndexOfASource(featureFilename);
	fs.seekFeature(begin);
	SegServer segmentsServer;
	LabelServer labelServer;
	initializeClusters(featureFilename,segmentsServer,labelServer,config);
	//	__android_log_print(ANDROID_LOG_DEBUG, "TopGauss::get", " Feature file  %s  \n", featureFilename.c_str());

	verifyClusterFile(segmentsServer,fs,config);
	unsigned long codeSelectedFrame=labelServer.getLabelIndexByString(labelSelectedFrames);	
	SegCluster& selectedSegments=segmentsServer.getCluster(codeSelectedFrame);  
	MixtureGDStat &acc=ss.createAndStoreMixtureStat(UBM);
	
	Seg *seg;          // current selected segment
	selectedSegments.rewind();		
	unsigned long t=0; //cnt frames
	acc.resetLLK();
	unsigned long idxBegin=0;
	while((seg=selectedSegments.getSeg())!=NULL){  
		unsigned long begin=seg->begin()+fs.getFirstFeatureIndexOfASource(seg->sourceName()); 
		fs.seekFeature(begin);
		Feature f;
		idxBegin=this->frameToIdx(t);
		for (unsigned long idxFrame=0;idxFrame<seg->length();idxFrame++){
			fs.readFeature(f); 
			//unsigned long idx=this->frameToIdx(t);
			unsigned long nbg=_nbg[t];	
			ULongVector index;
			double sumNonSelectedWeights=_snsw[t];
			double sumNonSelectedLLK=_snsl[t];
			for (unsigned long i=0;i<nbg;i++) {
				index.addValue(_idx[idxBegin+i]);
			}		
			char c[100];
			sprintf(c,"%d",(int)index.size());
			config.setParam("topDistribsCount",c); // this should be high enough	
			if (t==0) {acc.computeAndAccumulateLLK(f,1.0,DETERMINE_TOP_DISTRIBS);acc.resetLLK();} // to remove in ALIZE, this is to init the LKvector
			ss.setTopDistribIndexVector(index, sumNonSelectedWeights, sumNonSelectedLLK);
			acc.computeAndAccumulateLLK(f,1.0,USE_TOP_DISTRIBS);
			idxBegin+=nbg;
			t++;
		}	
	}	
	//ss.deleteMixtureStat(acc);
	if (t!=_nt || idxBegin !=_nbgcnt) cout << "W: t("<<t<<") != _nt(" <<_nt<<")"<<"W: idxBegin("<<idxBegin<<") != _nbgcnt(" <<_nbgcnt<<")"<<endl;
return acc.getMeanLLK();
}
Пример #3
0
ULongVector srv_process_info::ExtractControlsAcceptedCode(unsigned long val)
{
	ULongVector vec;
	if((val & SERVICE_ACCEPT_NETBINDCHANGE) == SERVICE_ACCEPT_NETBINDCHANGE) vec.push_back(SERVICE_ACCEPT_NETBINDCHANGE);
	if((val & SERVICE_ACCEPT_PARAMCHANGE) == SERVICE_ACCEPT_PARAMCHANGE) vec.push_back(SERVICE_ACCEPT_PARAMCHANGE);
	if((val & SERVICE_ACCEPT_PAUSE_CONTINUE) == SERVICE_ACCEPT_PAUSE_CONTINUE) vec.push_back(SERVICE_ACCEPT_PAUSE_CONTINUE);
	if((val & SERVICE_ACCEPT_PRESHUTDOWN) == SERVICE_ACCEPT_PRESHUTDOWN) vec.push_back(SERVICE_ACCEPT_PRESHUTDOWN);
	if((val & SERVICE_ACCEPT_SHUTDOWN) == SERVICE_ACCEPT_SHUTDOWN) vec.push_back(SERVICE_ACCEPT_SHUTDOWN);
	if((val & SERVICE_ACCEPT_STOP) == SERVICE_ACCEPT_STOP) vec.push_back(SERVICE_ACCEPT_STOP);
	if((val & SERVICE_ACCEPT_HARDWAREPROFILECHANGE) == SERVICE_ACCEPT_HARDWAREPROFILECHANGE) vec.push_back(SERVICE_ACCEPT_HARDWAREPROFILECHANGE);
	if((val & SERVICE_ACCEPT_POWEREVENT) == SERVICE_ACCEPT_POWEREVENT) vec.push_back(SERVICE_ACCEPT_POWEREVENT);
	if((val & SERVICE_ACCEPT_SESSIONCHANGE) == SERVICE_ACCEPT_SESSIONCHANGE) vec.push_back(SERVICE_ACCEPT_SESSIONCHANGE);
	return vec;
}
//-------------------------------------------------------------------------
void S::setTopDistribIndexVector(const ULongVector& indexVect,
                                  real_t w, real_t l)
{
  unsigned long topDistribCount = indexVect.size();
  if (topDistribCount>_topDistribsVect.size()) // TODO gerer ce cas
    throw Exception("", __FILE__, __LINE__);
  LKVector::type* v = _topDistribsVect.getArray();
  for (unsigned long i=0; i<topDistribCount; i++)
    v[i].idx = indexVect[i];
  _topDistribsVect.sumNonTopDistribWeights = w;
  _topDistribsVect.sumNonTopDistribLK = l;
}
Пример #5
0
void CIDFontWriter::WriteGlyphEntry(IByteWriter* inWriter,unsigned short inEncodedCharacter,const ULongVector& inUnicodeValues)
{
	UnicodeString unicode;
	char formattingBuffer[17];
	ULongVector::const_iterator it = inUnicodeValues.begin();

	SAFE_SPRINTF_1(formattingBuffer,17,"<%04x> <",inEncodedCharacter);
	inWriter->Write((const Byte*)formattingBuffer,8);
	
	if(inUnicodeValues.size() == 0)
	{
		inWriter->Write(scAllZeros,4);
	}
	else
	{
		for(; it != inUnicodeValues.end(); ++it)
		{
			unicode.GetUnicodeList().push_back(*it);
			EStatusCodeAndUShortList utf16Result = unicode.ToUTF16UShort();
			unicode.GetUnicodeList().clear();

			if(utf16Result.second.size() == 2)
			{
				SAFE_SPRINTF_2(formattingBuffer,17,"%04x%04x",
																utf16Result.second.front(),
																utf16Result.second.back());
				inWriter->Write((const Byte*)formattingBuffer,8);
			}
			else // 1
			{
				SAFE_SPRINTF_1(formattingBuffer,17,"%04x",utf16Result.second.front());
				inWriter->Write((const Byte*)formattingBuffer,4);
			}
		}
	}
	inWriter->Write(scEntryEnding,2);
}
//-------------------------------------------------------------------------
unsigned long loadSymbol(const String &filename,const String &type,ULongVector & ret,Config &config){
 
  if (type=="ascii"){
    unsigned long nbSym=0;
    XList infile(filename,config);
    XLine list=infile.getAllElements();
    ret.setSize(list.getElementCount());
    nbSym=list.getElementCount();
    for (unsigned long i=0;i<nbSym;i++){
      String *tmp=list.getElement();
      if ((*tmp)!="oov")
	ret[i]=tmp->toLong();
      else ret[i]=OOV;
    }
    if (debug) cout << "nb sym:"<<nbSym<<endl;
    return nbSym;
  }
  else throw Exception(type+" file type non recognized for a symbol file"
        , __FILE__, __LINE__);
}