status_t MyVorbisExtractor::init() { mMeta = new MetaData; mMeta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_VORBIS); MediaBuffer *packet; status_t err; if ((err = readNextPacket(&packet)) != OK) { return err; } ALOGV("read packet of size %d\n", packet->range_length()); err = verifyHeader(packet, 1); packet->release(); packet = NULL; if (err != OK) { return err; } if ((err = readNextPacket(&packet)) != OK) { return err; } ALOGV("read packet of size %d\n", packet->range_length()); err = verifyHeader(packet, 3); packet->release(); packet = NULL; if (err != OK) { return err; } if ((err = readNextPacket(&packet)) != OK) { return err; } ALOGV("read packet of size %d\n", packet->range_length()); err = verifyHeader(packet, 5); packet->release(); packet = NULL; if (err != OK) { return err; } mFirstDataOffset = mOffset + mCurrentPageSize; off64_t size; uint64_t lastGranulePosition; if (mSource->getSize(&size) == OK && findPrevGranulePosition(size, &lastGranulePosition) == OK) { // Let's assume it's cheap to seek to the end. // The granule position of the final page in the stream will // give us the exact duration of the content, something that // we can only approximate using avg. bitrate if seeking to // the end is too expensive or impossible (live streaming). int64_t durationUs = lastGranulePosition * 1000000ll / mVi.rate; mMeta->setInt64(kKeyDuration, durationUs); buildTableOfContents(); } return OK; }
bool GetSampleInfo( void ) /************************/ { if( !initCurrSIO() ) { return( false ); } if( !verifyHeader() ) { ClearSample( CurrSIOData ); return( false ); } if( !readSampleFile() ) { ClearSample( CurrSIOData ); return( false ); } /* there must be at least one address map for the first module, or */ /* we cannot resolve overlays and do mapping. Should generate an error*/ if( !LoadImageOverlays() ) { ClearSample( CurrSIOData ); return( false ); } close( CurrSIOData->fh ); /* do the SIOData sets near the end to make it easier to de-link */ /* the new data if we have an error */ if( SIOData == NULL ) { CurrSIOData->next = CurrSIOData; } else { CurrSIOData->next = SIOData->next; SIOData->next = CurrSIOData; } SIOData = CurrSIOData; SetSampleInfo( CurrSIOData ); SamplePath[0] = 0; return( true ); }
int showVerifyPackage(QVA_t qva, rpmts ts, Header h) { int ec = 0; int rc; if (qva->qva_flags & VERIFY_DEPS) { int save_noise = _rpmds_unspecified_epoch_noise; if (rpmIsVerbose()) _rpmds_unspecified_epoch_noise = 1; if ((rc = verifyDependencies(qva, ts, h)) != 0) ec = rc; _rpmds_unspecified_epoch_noise = save_noise; } if (qva->qva_flags & VERIFY_FILES) { if ((rc = verifyHeader(qva, ts, h)) != 0) ec = rc; } if ((qva->qva_flags & VERIFY_SCRIPT) && headerIsEntry(h, RPMTAG_VERIFYSCRIPT)) { FD_t fdo = fdDup(STDOUT_FILENO); if ((rc = rpmVerifyScript(qva, ts, h, fdo)) != 0) ec = rc; if (fdo != NULL) rc = Fclose(fdo); } return ec; }
status_t MyVorbisExtractor::init() { mMeta = new MetaData; mMeta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_VORBIS); MediaBuffer *packet; status_t err; if ((err = readNextPacket(&packet)) != OK) { return err; } LOGV("read packet of size %d\n", packet->range_length()); err = verifyHeader(packet, 1); packet->release(); packet = NULL; if (err != OK) { return err; } if ((err = readNextPacket(&packet)) != OK) { return err; } LOGV("read packet of size %d\n", packet->range_length()); err = verifyHeader(packet, 3); packet->release(); packet = NULL; if (err != OK) { return err; } if ((err = readNextPacket(&packet)) != OK) { return err; } LOGV("read packet of size %d\n", packet->range_length()); err = verifyHeader(packet, 5); packet->release(); packet = NULL; if (err != OK) { return err; } mFirstDataOffset = mOffset + mCurrentPageSize; return OK; }
int showVerifyPackage(QVA_t qva, rpmts ts, Header h) { int ec = 0; int rc; if (qva->qva_flags & VERIFY_DEPS) { if ((rc = verifyDependencies(ts, h)) != 0) ec = rc; } if (qva->qva_flags & VERIFY_FILES) { if ((rc = verifyHeader(ts, h, qva->qva_ofvattr, qva->qva_incattr, qva->qva_excattr)) != 0) ec = rc; } if (qva->qva_flags & VERIFY_SCRIPT) { if ((rc = rpmVerifyScript(ts, h)) != 0) ec = rc; } return ec; }
int showVerifyPackage(QVA_t qva, rpmts ts, Header h) { rpmVerifyAttrs omitMask = ((qva->qva_flags & VERIFY_ATTRS) ^ VERIFY_ATTRS); int ghosts = (qva->qva_fflags & RPMFILE_GHOST); int ec = 0; int rc; if (qva->qva_flags & VERIFY_DEPS) { if ((rc = verifyDependencies(ts, h)) != 0) ec = rc; } if (qva->qva_flags & VERIFY_FILES) { if ((rc = verifyHeader(ts, h, omitMask, ghosts)) != 0) ec = rc; } if (qva->qva_flags & VERIFY_SCRIPT) { if ((rc = rpmVerifyScript(ts, h)) != 0) ec = rc; } return ec; }
QFontEngineQPA::QFontEngineQPA(const QFontDef &def, const QByteArray &data) : fontData(reinterpret_cast<const uchar *>(data.constData())), dataSize(data.size()) { fontDef = def; cache_cost = 100; externalCMap = 0; cmapOffset = 0; cmapSize = 0; glyphMapOffset = 0; glyphMapEntries = 0; glyphDataOffset = 0; glyphDataSize = 0; kerning_pairs_loaded = false; readOnly = true; #if defined(DEBUG_FONTENGINE) qDebug() << "QFontEngineQPA::QFontEngineQPA( fd =" << fd << ", renderingFontEngine =" << renderingFontEngine << ')'; #endif if (!verifyHeader(fontData, dataSize)) { #if defined(DEBUG_FONTENGINE) qDebug() << "verifyHeader failed!"; #endif return; } const Header *header = reinterpret_cast<const Header *>(fontData); readOnly = (header->lock == 0xffffffff); const uchar *imgData = fontData + sizeof(Header) + qFromBigEndian<quint16>(header->dataSize); const uchar *endPtr = fontData + dataSize; while (imgData <= endPtr - 8) { quint16 blockTag = readValue<quint16>(imgData); imgData += 2; // skip padding quint32 blockSize = readValue<quint32>(imgData); if (blockTag == CMapBlock) { cmapOffset = imgData - fontData; cmapSize = blockSize; } else if (blockTag == GMapBlock) { glyphMapOffset = imgData - fontData; glyphMapEntries = blockSize / 4; } else if (blockTag == GlyphBlock) { glyphDataOffset = imgData - fontData; glyphDataSize = blockSize; } imgData += blockSize; } face_id.filename = QFile::encodeName(extractHeaderField(fontData, Tag_FileName).toString()); face_id.index = extractHeaderField(fontData, Tag_FileIndex).toInt(); // get the real cmap if (cmapOffset) { int tableSize = cmapSize; const uchar *cmapPtr = getCMap(fontData + cmapOffset, tableSize, &symbol, &cmapSize); if (cmapPtr) cmapOffset = cmapPtr - fontData; else cmapOffset = 0; } else if (externalCMap) { int tableSize = cmapSize; externalCMap = getCMap(externalCMap, tableSize, &symbol, &cmapSize); } // verify all the positions in the glyphMap if (glyphMapOffset) { const quint32 *gmapPtr = reinterpret_cast<const quint32 *>(fontData + glyphMapOffset); for (uint i = 0; i < glyphMapEntries; ++i) { quint32 glyphDataPos = qFromBigEndian<quint32>(gmapPtr[i]); if (glyphDataPos == 0xffffffff) continue; if (glyphDataPos >= glyphDataSize) { // error glyphMapOffset = 0; glyphMapEntries = 0; break; } } } #if defined(DEBUG_FONTENGINE) if (!isValid()) qDebug() << "fontData" << fontData << "dataSize" << dataSize << "externalCMap" << externalCMap << "cmapOffset" << cmapOffset << "glyphMapOffset" << glyphMapOffset << "glyphDataOffset" << glyphDataOffset << "fd" << fd << "glyphDataSize" << glyphDataSize; #endif }
void HttpClientImpl::onReplyHeader(http::Client& client) { verifyHeader(client.header()); }
QFontEngineQPF::QFontEngineQPF(const QFontDef &def, int fileDescriptor, QFontEngine *fontEngine) : fd(fileDescriptor), renderingFontEngine(fontEngine) { fontData = 0; dataSize = 0; fontDef = def; cache_cost = 100; freetype = 0; externalCMap = 0; cmapOffset = 0; cmapSize = 0; glyphMapOffset = 0; glyphMapEntries = 0; glyphDataOffset = 0; glyphDataSize = 0; kerning_pairs_loaded = false; readOnly = true; #if defined(DEBUG_FONTENGINE) qDebug() << "QFontEngineQPF::QFontEngineQPF( fd =" << fd << ", renderingFontEngine =" << renderingFontEngine << ")"; #endif if (fd < 0) { if (!renderingFontEngine) return; fileName = fontDef.family.toLower() + QLatin1String("_") + QString::number(fontDef.pixelSize) + QLatin1String("_") + QString::number(fontDef.weight) + (fontDef.style != QFont::StyleNormal ? QLatin1String("_italic") : QLatin1String("")) + QLatin1String(".qsf"); fileName.replace(QLatin1Char(' '), QLatin1Char('_')); fileName.prepend(qws_fontCacheDir()); const QByteArray encodedName = QFile::encodeName(fileName); if (::access(encodedName, F_OK) == 0) { #if defined(DEBUG_FONTENGINE) qDebug() << "found existing qpf:" << fileName; #endif if (::access(encodedName, W_OK | R_OK) == 0) fd = ::open(encodedName, O_RDWR); else if (::access(encodedName, R_OK) == 0) fd = ::open(encodedName, O_RDONLY); } else { #if defined(DEBUG_FONTENGINE) qDebug() << "creating qpf on the fly:" << fileName; #endif if (::access(QFile::encodeName(qws_fontCacheDir()), W_OK) == 0) { fd = ::open(encodedName, O_RDWR | O_EXCL | O_CREAT, 0644); QBuffer buffer; buffer.open(QIODevice::ReadWrite); QPFGenerator generator(&buffer, renderingFontEngine); generator.generate(); buffer.close(); const QByteArray &data = buffer.data(); ::write(fd, data.constData(), data.size()); } } } QT_STATBUF st; if (QT_FSTAT(fd, &st)) { #if defined(DEBUG_FONTENGINE) qDebug() << "stat failed!"; #endif return; } dataSize = st.st_size; fontData = (const uchar *)::mmap(0, st.st_size, PROT_READ | (renderingFontEngine ? PROT_WRITE : 0), MAP_SHARED, fd, 0); if (!fontData || fontData == (const uchar *)MAP_FAILED) { #if defined(DEBUG_FONTENGINE) perror("mmap failed"); #endif fontData = 0; return; } if (!verifyHeader(fontData, st.st_size)) { #if defined(DEBUG_FONTENGINE) qDebug() << "verifyHeader failed!"; #endif return; } const Header *header = reinterpret_cast<const Header *>(fontData); readOnly = (header->lock == 0xffffffff); const uchar *data = fontData + sizeof(Header) + qFromBigEndian<quint16>(header->dataSize); const uchar *endPtr = fontData + dataSize; while (data <= endPtr - 8) { quint16 blockTag = readValue<quint16>(data); data += 2; // skip padding quint32 blockSize = readValue<quint32>(data); if (blockTag == CMapBlock) { cmapOffset = data - fontData; cmapSize = blockSize; } else if (blockTag == GMapBlock) { glyphMapOffset = data - fontData; glyphMapEntries = blockSize / 4; } else if (blockTag == GlyphBlock) { glyphDataOffset = data - fontData; glyphDataSize = blockSize; } data += blockSize; } face_id.filename = QFile::encodeName(extractHeaderField(fontData, Tag_FileName).toString()); face_id.index = extractHeaderField(fontData, Tag_FileIndex).toInt(); #if !defined(QT_NO_FREETYPE) freetype = QFreetypeFace::getFace(face_id); if (!freetype) { QString newPath = #ifndef QT_NO_SETTINGS QLibraryInfo::location(QLibraryInfo::LibrariesPath) + #endif QLatin1String("/fonts/") + QFileInfo(QFile::decodeName(face_id.filename)).fileName(); face_id.filename = QFile::encodeName(newPath); freetype = QFreetypeFace::getFace(face_id); } if (freetype) { const quint32 qpfTtfRevision = extractHeaderField(fontData, Tag_FontRevision).toUInt(); uchar data[4]; uint length = 4; bool ok = freetype->getSfntTable(MAKE_TAG('h', 'e', 'a', 'd'), data, &length); if (!ok || length != 4 || qFromBigEndian<quint32>(data) != qpfTtfRevision) { freetype->release(face_id); freetype = 0; } } if (!cmapOffset && freetype) { freetypeCMapTable = getSfntTable(MAKE_TAG('c', 'm', 'a', 'p')); externalCMap = reinterpret_cast<const uchar *>(freetypeCMapTable.constData()); cmapSize = freetypeCMapTable.size(); } #endif // get the real cmap if (cmapOffset) { int tableSize = cmapSize; const uchar *cmapPtr = getCMap(fontData + cmapOffset, tableSize, &symbol, &cmapSize); if (cmapPtr) cmapOffset = cmapPtr - fontData; else cmapOffset = 0; } else if (externalCMap) { int tableSize = cmapSize; externalCMap = getCMap(externalCMap, tableSize, &symbol, &cmapSize); } // verify all the positions in the glyphMap if (glyphMapOffset) { const quint32 *gmapPtr = reinterpret_cast<const quint32 *>(fontData + glyphMapOffset); for (uint i = 0; i < glyphMapEntries; ++i) { quint32 glyphDataPos = qFromBigEndian<quint32>(gmapPtr[i]); if (glyphDataPos == 0xffffffff) continue; if (glyphDataPos >= glyphDataSize) { // error glyphMapOffset = 0; glyphMapEntries = 0; break; } } } #if defined(DEBUG_FONTENGINE) if (!isValid()) qDebug() << "fontData" << fontData << "dataSize" << dataSize << "externalCMap" << externalCMap << "cmapOffset" << cmapOffset << "glyphMapOffset" << glyphMapOffset << "glyphDataOffset" << glyphDataOffset << "fd" << fd << "glyphDataSize" << glyphDataSize; #endif #if defined(Q_WS_QWS) if (isValid() && renderingFontEngine) qt_fbdpy->sendFontCommand(QWSFontCommand::StartedUsingFont, QFile::encodeName(fileName)); #endif }