bool FrTextSpans::addMetaData(const FrStruct *meta) { bool success = false ; if (meta) { FrList *fields = meta->fieldNames() ; while (fields) { FrSymbol *key = (FrSymbol*)poplist(fields) ; addMetaData(key,meta->get(key)) ; success = true ; } } return success ; }
bool FrTextSpan::updateMetaData(const FrStruct *meta) { bool changed = false ; if (meta) { FrList *fields = meta->fieldNames() ; while (fields) { FrSymbol *field = (FrSymbol*)poplist(fields) ; FrObject *value = meta->get(field) ; if (value &&addMetaData(field,value)) changed = true ; } } return changed ; }
void CModel::mergeMetaData(_In_ CModel * pSourceModel) { if (pSourceModel == nullptr) throw CNMRException(NMR_ERROR_INVALIDPARAM); nfUint32 nCount = pSourceModel->getMetaDataCount(); nfUint32 nIndex; for (nIndex = 0; nIndex < nCount; nIndex++) { std::wstring sName; std::wstring sValue; pSourceModel->getMetaData(nIndex, sName, sValue); addMetaData(sName, sValue); } }
void FrTextSpans::makeWordSpans(const FrList *defn) { FrString *concat = new FrString(defn) ; m_text = FrDupString(concat->stringValue()) ; free_object(concat) ; if (setPositionMap()) { m_spancount = defn->simplelistlength() ; m_spans = FrNewN(FrTextSpan,m_spancount) ; if (!m_spans) { m_spancount = 0 ; return ; } size_t spannum = 0 ; size_t start = 0 ; size_t end = 0 ; for ( ; defn ; defn = defn->rest()) { FrObject *def = defn->first() ; if (def && def->structp()) { addMetaData((FrStruct*)def) ; continue ; } const char *item = FrPrintableName(def) ; if (!item) item = "" ; for (const char *i = item ; *i ; i++) { if (!Fr_isspace(*i)) end++ ; } if (end > 0) m_spans[spannum++].init(start,end-1,DEFAULT_SCORE,DEFAULT_WEIGHT, item,this) ; m_sorted = false ; start = end ; } m_spancount = spannum ; } return ; }
void FrTextSpans::parseSpans(const FrList *spans, size_t numstrings) { for (const FrList *sp = spans ; sp ; sp = sp->rest()) { const FrObject *item = sp->first() ; if (item && (item->stringp() || item->symbolp())) { m_text = FrDupString(FrPrintableName(item)) ; if (m_text && setPositionMap()) break ; return ; } } m_spancount = spans->simplelistlength() - numstrings ; m_spans = FrNewN(FrTextSpan,m_spancount) ; if (!m_spans) { m_spancount = 0 ; return ; } size_t count = 0 ; for ( ; spans ; spans = spans->rest()) { FrList *span = (FrList*)spans->first() ; if (!span) continue ; if (span->consp() && m_spans[count].parse(span,this)) { count++ ; m_sorted = false ; } else if (span->structp()) { FrStruct *meta = (FrStruct*)span ; if (meta->typeName() && Fr_stricmp(FrPrintableName(meta->typeName()),"META") == 0) addMetaData(meta) ; } } m_spancount = count ; return ; }
void PtexWriterBase::writeMeta(const char* key, const double* value, int count) { addMetaData(key, mdt_double, value, count*sizeof(double)); }
void PtexWriterBase::writeMeta(const char* key, const float* value, int count) { addMetaData(key, mdt_float, value, count*sizeof(float)); }
void PtexWriterBase::writeMeta(const char* key, const int32_t* value, int count) { addMetaData(key, mdt_int32, value, count*sizeof(int32_t)); }
void PtexWriterBase::writeMeta(const char* key, const int8_t* value, int count) { addMetaData(key, mdt_int8, value, count); }
void PtexWriterBase::writeMeta(const char* key, const char* value) { addMetaData(key, mdt_string, value, int(strlen(value)+1)); }
bool FrTextSpans::copyMetaData(const FrTextSpans *other) { return other ? addMetaData(&other->m_metadata) : false ; }
bool DecoderMPG123::initialize() { if (input()->isSequential ()) //for streams only { TagExtractor extractor(input()); if(!extractor.id3v2tag().isEmpty()) addMetaData(extractor.id3v2tag()); } int err = mpg123_init(); if(err != MPG123_OK) { qWarning("DecoderMPG123: basic setup goes wrong: %s", mpg123_plain_strerror(err)); return false; } int channels = 0; if(!(m_handle = mpg123_new(0, &err))) { qWarning("DecoderMPG123: basic setup goes wrong: %s", mpg123_plain_strerror(err)); return false; } mpg123_param (m_handle, MPG123_ADD_FLAGS, MPG123_SEEKBUFFER | MPG123_FUZZY, 0); if((err = mpg123_replace_reader_handle(m_handle, mpg123_read_cb, mpg123_seek_cb, 0)) != MPG123_OK) { qWarning("DecoderMPG123: mpg123 error: %s", mpg123_plain_strerror(err)); cleanup(m_handle); m_handle = 0; return false; } setMPG123Format(MPG123_ENC_FLOAT_32); if((err = mpg123_open_handle(m_handle, this)) != MPG123_OK) { qWarning("DecoderMPG123: mpg123 error: %s", mpg123_plain_strerror(err)); cleanup(m_handle); m_handle = 0; return false; } if((err = mpg123_getformat(m_handle, &m_rate, &channels, &m_mpg123_encoding)) != MPG123_OK) { qWarning("DecoderMPG123: mpg123 error: %s", mpg123_plain_strerror(err)); cleanup(m_handle); m_handle = 0; return false; } //check format if(m_mpg123_encoding != MPG123_ENC_FLOAT_32) { cleanup(m_handle); qWarning("DecoderMPG123: bad encoding: 0x%x!\n", m_mpg123_encoding); m_handle = 0; return false; } if(!input()->isSequential()) { if((err = mpg123_scan(m_handle)) != MPG123_OK) qWarning("DecoderMPG123: mpg123 error: %s", mpg123_plain_strerror(err)); //duration m_totalTime = (qint64) mpg123_length(m_handle) * 1000 / m_rate; } else m_totalTime = 0; configure(m_rate, channels, Qmmp::PCM_FLOAT); return true; }