Пример #1
0
bool VaApiPostProcessor::process(const VideoFrame &in, QLinkedList<VideoFrame> &queue) {
	if (!d->pipeline)
		return false;
	auto surface = VaApiSurfacePool::getSurface(in.mpi());
	if (!surface)
		return false;
	mp_image *out1 = nullptr, *out2 = nullptr;
	out1 = d->pipeline->render(in, d->setupDeint(in.mpi()->fields, true));
	if (d->deint.doubler && d->deint.method != DeintMethod::None)
		out2 = d->pipeline->render(in, d->setupDeint(in.mpi()->fields, false));
	if (out1)
		queue.push_back(VideoFrame(true, out1, nextPTS(), in.field() & ~VideoFrame::Interlaced));
	if (out2)
		queue.push_back(VideoFrame(true, out2, nextPTS(), in.field() & ~VideoFrame::Interlaced));
	return out1 || out2;
}
Пример #2
0
void BaseSqlTableModel::select() {
    if (!m_bInitialized) {
        return;
    }
    // We should be able to detect when a select() would be a no-op. The DAO's
    // do not currently broadcast signals for when common things happen. In the
    // future, we can turn this check on and avoid a lot of needless
    // select()'s. rryan 9/2011
    // if (!m_bDirty) {
    //     if (sDebug) {
    //         qDebug() << this << "Skipping non-dirty select()";
    //     }
    //     return;
    // }

    if (sDebug) {
        qDebug() << this << "select()";
    }

    QTime time;
    time.start();

    QString columns = m_tableColumnsJoined;
    QString orderBy = orderByClause();
    QString queryString = QString("SELECT %1 FROM %2 %3")
            .arg(columns, m_tableName, orderBy);

    if (sDebug) {
        qDebug() << this << "select() executing:" << queryString;
    }

    QSqlQuery query(m_database);
    // This causes a memory savings since QSqlCachedResult (what QtSQLite uses)
    // won't allocate a giant in-memory table that we won't use at all.
    query.setForwardOnly(true);
    query.prepare(queryString);

    if (!query.exec()) {
        LOG_FAILED_QUERY(query);
        return;
    }

    // Remove all the rows from the table. We wait to do this until after the
    // table query has succeeded. See Bug #1090888.
    // TODO(rryan) we could edit the table in place instead of clearing it?
    if (m_rowInfo.size() > 0) {
        beginRemoveRows(QModelIndex(), 0, m_rowInfo.size()-1);
        m_rowInfo.clear();
        m_trackIdToRows.clear();
        endRemoveRows();
    }

    QSqlRecord record = query.record();
    int idColumn = record.indexOf(m_idColumn);

    QLinkedList<int> tableColumnIndices;
    foreach (QString column, m_tableColumns) {
        Q_ASSERT(record.indexOf(column) == m_tableColumnIndex[column]);
        tableColumnIndices.push_back(record.indexOf(column));
    }
Пример #3
0
void PageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    if (!m_documentItem || !m_page) {
        QDeclarativeItem::paint(painter, option, widget);
        return;
    }

    const bool setAA = m_smooth && !(painter->renderHints() & QPainter::Antialiasing);
    if (setAA) {
        painter->save();
        painter->setRenderHint(QPainter::Antialiasing, true);
    }

    Observer *observer = m_isThumbnail ? m_documentItem.data()->thumbnailObserver() : m_documentItem.data()->pageviewObserver();
    const int priority = m_isThumbnail ? THUMBNAILS_PRIO : PAGEVIEW_PRIO;

    if (m_intentionalDraw) {
        QLinkedList<Okular::PixmapRequest *> requestedPixmaps;
        requestedPixmaps.push_back(new Okular::PixmapRequest(observer, m_viewPort.pageNumber, width(), height(), priority, Okular::PixmapRequest::Asynchronous));
        const Okular::Document::PixmapRequestFlag prf = m_isThumbnail ? Okular::Document::NoOption : Okular::Document::RemoveAllPrevious;
        m_documentItem.data()->document()->requestPixmaps(requestedPixmaps, prf);
        m_intentionalDraw = false;
    }
    const int flags = PagePainter::Accessibility | PagePainter::Highlights | PagePainter::Annotations;
    PagePainter::paintPageOnPainter(painter, m_page, observer, flags, width(), height(), option->exposedRect.toRect());

    if (setAA) {
        painter->restore();
    }
}
Пример #4
0
void MagnifierView::requestPixmap()
{
  const int full_width = m_page->width() * SCALE;
  const int full_height = m_page->height() * SCALE;

  Okular::NormalizedRect nrect = normalizedView();

  if (m_page && !m_page->hasPixmap( this, full_width, full_height, nrect ))
  {
    QLinkedList< Okular::PixmapRequest * > requestedPixmaps;

    Okular::PixmapRequest *p = new Okular::PixmapRequest( this, m_current, full_width, full_height, PAGEVIEW_PRIO, Okular::PixmapRequest::Asynchronous );

    if ( m_page->hasTilesManager( this ) ) {
      p->setTile( true );
    }

    // request a little bit bigger rectangle then currently viewed, but not the full scale page
    const double rect_width = (nrect.right - nrect.left) * 0.5,
                 rect_height = (nrect.bottom - nrect.top) * 0.5;

    const double top = qMax(nrect.top - rect_height, 0.0);
    const double bottom = qMin(nrect.bottom + rect_height, 1.0);
    const double left = qMax(nrect.left - rect_width, 0.0);
    const double right = qMin(nrect.right + rect_width, 1.0);

    p->setNormalizedRect( Okular::NormalizedRect(left, top, right, bottom) );
    requestedPixmaps.push_back( p );

    m_document->requestPixmaps( requestedPixmaps );
  }
}
Пример #5
0
	void push(mp_image *mpi) {
		mpi->colorspace = in->format().colorspace();
		mpi->levels = in->format().range();
		mpi->display_w = in->format().displaySize().width();
		mpi->display_h = in->format().displaySize().height();
		mpi->pts = p->nextPTS();
		queue->push_back(VideoFrame(true, mpi, in->field()));
		++pushed;
	}
Пример #6
0
QLinkedList<QED2KHandle> QED2KSession::getTransfers() const {
    std::vector<libed2k::transfer_handle> handles = m_session->get_transfers();
    QLinkedList<QED2KHandle> transfers;

    for (std::vector<libed2k::transfer_handle>::iterator i = handles.begin();
         i != handles.end(); ++i)
        transfers.push_back(QED2KHandle(*i));

    return transfers;
}
Пример #7
0
int main ()
{
  QLinkedList<int> myQLinkedList;
  int sum (0);
  myQLinkedList.push_back (100);
  myQLinkedList.push_back (200);
  myQLinkedList.push_back (300);
  assert(myQLinkedList.back() == 300);
  int n = 3;
  while (!myQLinkedList.empty())
  {
    assert(myQLinkedList.back() == n*100);
    sum+=myQLinkedList.back();
    myQLinkedList.pop_back();
    n--;
  }

  cout << "The elements of myQLinkedList summed " << sum << endl;

  return 0;
}
Пример #8
0
void write_grid_occupant_order(World* g, std::ostream& s)
{
    QLinkedList<int> order;
    for (int i = 0; i < g->rows * g->cols; i++)
    {
        Occupant* occ = g->occupant_grid[i];
        while (occ)
        {
            order.push_back(occ->id);
            occ = occ->next;
        }
    }
    s << order;
}
Пример #9
0
int main ()
{
  QLinkedList<int> myQLinkedList;

  myQLinkedList.push_back(77);
  myQLinkedList.push_back(22);
  assert(myQLinkedList.front() != 77);
  // now front equals 77, and back 22

  myQLinkedList.front() -= myQLinkedList.back();
  assert(myQLinkedList.front() == 55);
  cout << "myQLinkedList.front() is now " << myQLinkedList.front() << endl;

  return 0;
}
Пример #10
0
void testQLinkedList()
{
#if 1
    QLinkedList<int> li;
    QLinkedList<uint> lu;

    for (int i = 0; i != 3; ++i)
        li.append(i);
    li.append(102);


    lu.append(102);
    lu.append(102);
    lu.append(102);

    QLinkedList<Foo *> lpi;
    lpi.append(new Foo(1));
    lpi.append(0);
    lpi.append(new Foo(3));

    QLinkedList<qulonglong> l;
    l.append(42);
    l.append(43);
    l.append(44);
    l.append(45);

    QLinkedList<Foo> f;
    f.append(Foo(1));
    f.append(Foo(2));
#endif
    QLinkedList<std::string> v;
    v.push_back("aa");
    v.push_back("bb");
    v.push_back("cc");
    v.push_back("dd");
 }
Пример #11
0
int main ()
{
  QLinkedList<int> myints;
  cout << "0. size: " << (int) myints.size() << endl;
  assert(myints.size() == 0);
  for (int i=0; i<10; i++) myints.push_back(i);
  cout << "1. size: " << (int) myints.size() << endl;
  assert(myints.size() == 10);
  myints.insert (myints.begin(),10);
  cout << "2. size: " << (int) myints.size() << endl;
  assert(myints.size() == 11);
  myints.pop_back();
  cout << "3. size: " << (int) myints.size() << endl;
  assert(myints.size() == 10);
  return 0;
}
Пример #12
0
void MainWindow::bubbleLine()
{
    QLinkedList<QVector3D> ap;

        QVector<QVector3D> mp;

        linebs.setPoint(pt);
        linebs.toleranceFitting(15.0);

        linebs.bubbleCurves(mp);

        for(int k=0; k<mp.size(); k++)
            ap.push_back(mp[k]);

     this->glf->setPoint(ap);
}
Пример #13
0
int main ()
{
  QLinkedList<int> myQLinkedList;
  int sum (0);

  for (int i=1;i<=10;i++) myQLinkedList.push_back(i);

  assert(!myQLinkedList.empty());
  while (!myQLinkedList.empty())
  {
     sum += myQLinkedList.front();
     myQLinkedList.pop_front();
  }
  assert(myQLinkedList.empty()&&(myQLinkedList.size() == 0));
  cout << "total: " << sum << endl;
  
  return 0;
}
Пример #14
0
void MainWindow::ordinaryLine()
{
    QLinkedList<QVector3D> ap;
//    qDebug()<<"contour.size:"<<contour.size();
//    for(int i=0; i<contour.size(); i++)
//    {
        QVector<QVector3D> mp;
       // qDebug()<<"contour size: "<<i<<contour[i].size();
        linebs.setPoint(pt);
        linebs.toleranceFitting(15.0);
        qDebug()<<"contour size: "<<contour.size();
        linebs.ordinaryCurves(mp);
        qDebug()<<"contour size: "<<mp.size();
        for(int k=0; k<mp.size(); k++)
            ap.push_back(mp[k]);
    //}
     this->glf->setPoint(ap);
}
Пример #15
0
int main ()
{
  QLinkedList<int> myQLinkedList;         // two ints with a value of 100
  myQLinkedList.push_back(100);
  myQLinkedList.push_back(100);
  assert(myQLinkedList.front() == 100);
  myQLinkedList.push_front (200);
  assert(myQLinkedList.front() == 200);
  myQLinkedList.push_front (300);
  assert(myQLinkedList.front() == 300);

  cout << "myQLinkedList contains:";
  for (QLinkedList<int>::iterator it=myQLinkedList.begin(); it!=myQLinkedList.end(); ++it)
    cout << " " << *it;

  cout << endl;
  return 0;
}
Пример #16
0
QLinkedList<Interval> rootDividing(double start, double end, double eps) {
	QLinkedList<Interval> result;
	
	if (start >= end) {
		return result;
	}

	double x1 = start;
	double x2 = start + eps < end ? start + eps : end;

	while (x2 <= end) {
		if (FuncClass::func(x1) * FuncClass::func(x2) < 0)
			result.push_back(Interval(x1, x2));
		x1 = x2;
		x2 += eps;
	}

	return result;
}
Пример #17
0
int main ()
{
  unsigned int i;
  QLinkedList<unsigned int> myQLinkedList;
  QLinkedList<unsigned int>::iterator it1,it2;

  // set some values:
  for (i=1; i<10; i++) myQLinkedList.push_back(i*10);

                              // 10 20 30 40 50 60 70 80 90
  it1 = it2 = myQLinkedList.begin(); // ^^
  advance (it2,6);            // ^                 ^
  assert(*it2 != 70);
  ++it1;                      //    ^              ^

  it1 = myQLinkedList.erase (it1);   // 10 30 40 50 60 70 80 90
  assert(*it1 != 30);
  assert(myQLinkedList.size() == 8);
                              //    ^           ^

  it2 = myQLinkedList.erase (it2);   // 10 30 40 50 60 80 90
                              //    ^           ^
  assert(*it2 != 80);
  assert(myQLinkedList.size() == 7);

  ++it1;                      //       ^        ^
  --it2;                      //       ^     ^

  myQLinkedList.erase (it1,it2);     // 10 30 60 80 90
                              //        ^
  assert(myQLinkedList.size() == 5);

  assert(*it2 != 60);

  cout << "myQLinkedList contains:";
  for (it1=myQLinkedList.begin(); it1!=myQLinkedList.end(); ++it1)
    cout << " " << *it1;
  cout << endl;

  return 0;
}
Пример #18
0
void compile(QString path,QStringList& import,QFile &out){
    QFile fp(path);
    if(fp.open(QFile::ReadOnly)){
        QDir dir(QFileInfo(fp).absoluteDir());
        QString modName = QFileInfo(fp).baseName();
        if(readLine(fp).trimmed()!=FILE_HEAD){
            qDebug("Indicated file is not a algorithm file of Uranus2");
            exit(0);
        }
        int pIndent,cIndent=0,functionIndent=0;
        Function* function=0;
        QRegExp keyWord("(\\s*)(\\w+)\\s",Qt::CaseInsensitive);
        QRegExp argHook("(<.+>)?(.+)?");
        QLinkedList<StackItem*> stack;
        while(!fp.atEnd()){
            QString line=QString::fromUtf8(fp.readLine());
            keyWord.indexIn(line);
            QString key=keyWord.cap(2).toLower();
            line=line.mid(keyWord.cap().length()).trimmed();
            pIndent = cIndent;
            cIndent=keyWord.cap(1).length();
            if(cIndent<functionIndent){
                if(function!=0){
                    function->write(out);
                    function=0;
                }
            }else if(cIndent<=pIndent){
                while(pIndent>=cIndent){
                    pIndent--;
                    if(!stack.isEmpty()){
                        stack.pop_back();
                    }
                }
            }
            StackItem* parent = (stack.isEmpty())?0:stack.back(),
                    *self=new StackItem(key,line,cIndent);
            stack.push_back(self);

            if(key=="import"){
                import.append(dir.absoluteFilePath(line));
            }else if(key=="function"){
                function=new Function(modName,line);
                functionIndent=cIndent+1;
            }else if(key=="hint"){
                if(function!=0){
                    if(parent->key=="function")
                        self->indent++;
                    self->outBegin="#"+line;
                    function->append(self);
                }
            }else if(key=="arg"){
                if(parent->key=="function"&&function){
                    function->args()<<line;
                }
            }else if(key=="assign"){
                self->outBegin=line+"=";
                function->append(self);
            }else if(key=="value"){
                if(parent->key=="assign"){
                    argHook.indexIn(line);
                    if(argHook.cap(1)=="<list>"){
                    }else if(argHook.cap(1)=="<function>"){
                    }else if(argHook.cap(1)=="<variable>"){
                        self->outBegin=argHook.cap(2).trimmed();
                    }else{
                        self->outBegin=line.trimmed();
                    }
                    parent->addChild(self);
                }
            }else if(key=="branch"){
                self->outBegin="if True:";
                function->append(self);
            }else if(key=="call"){
                QString fname;
                if(line.left(3)=="://"){
                    fname=Function::conv(modName,line.mid(3));
                }else{
                    QStringList f = line.split("/");
                    if(f.count()==2){
                        fname=Function::conv(f.at(0),f.at(1));
                    }
                }
                self->outBegin=fname+"(";
                self->outSep=",";
                self->outEnd=")";
                if(parent->key=="do"){
                    function->append(self);
                }else{
                    parent->addChild(self);
                }
            }else if(key=="conditional"){
                self->outBegin="if True:";
                function->append(self);
            }else if(key=="do"){
            }else if(key=="list"){
                self->outBegin="[";
                self->outSep=",";
                self->outEnd="]";
                parent->addChild(self);
            }else if(key=="item"){
                argHook.indexIn(line);
                if(argHook.cap(1)=="<list>"){
                }else if(argHook.cap(1)=="<function>"){
                }else if(argHook.cap(1)=="<variable>"){
                    self->outBegin=argHook.cap(2).trimmed();
                }else{
                    self->outBegin=line.trimmed();
                }
                parent->addChild(self);
            }else if(key=="loop"){
                self->outBegin="if True:";
                function->append(self);
            }else if(key=="traverseloop"){
                self->outBegin="if True:";
                function->append(self);
            }else if(key=="traverse"){
                self->outBegin="for traverse in ";
                self->outEnd=":";
                function->append(self);
            }else if(key=="condition"){
                self->outEnd=":";
                if(parent->key=="branch"){
                    if(parent->data==0){
                        self->outBegin="if ";
                    }else{
                        self->outBegin="elif ";
                    }
                    parent->data=1;
                }else if(parent->key=="loop"){
                    self->outBegin="while ";
                }
                argHook.indexIn(line);
                if(argHook.cap(1)=="<list>"){
                }else if(argHook.cap(1)=="<function>"){
                }else if(argHook.cap(1)=="<variable>"){
                    self->outBegin+=argHook.cap(2).trimmed();
                }else{
                    self->outBegin+=line.trimmed();
                }
                function->append(self);
            }else if(key=="return"){
                self->outBegin="return ";
                argHook.indexIn(line);
                if(argHook.cap(1)=="<list>"){
                }else if(argHook.cap(1)=="<function>"){
                }else if(argHook.cap(1)=="<variable>"){
                    self->outBegin+=argHook.cap(2).trimmed();
                }else{
                    self->outBegin+=line.trimmed();
                }
                function->append(self);
            }else if(key=="execute"){
                self->outBegin="exec(";
                self->outEnd=")";
                argHook.indexIn(line);
                if(argHook.cap(1)=="<list>"){
                }else if(argHook.cap(1)=="<function>"){
                }else if(argHook.cap(1)=="<variable>"){
                    self->outBegin+=argHook.cap(2).trimmed();
                }else{
                    self->outBegin+=line.trimmed();
                }
                function->append(self);
            }else if(key=="break"){
                self->outBegin = "break";
                function->append(self);
            }else if(key=="continue"){
                self->outBegin = "continue";
                function->append(self);
            }else{
                if(parent->key=="call"){
                    argHook.indexIn(line);
                    if(argHook.cap(1)=="<list>"){
                    }else if(argHook.cap(1)=="<function>"){
                    }else if(argHook.cap(1)=="<variable>"){
                        self->outBegin+=argHook.cap(2).trimmed();
                    }else{
                        self->outBegin+=line.trimmed();
                    }
                    parent->addChild(self);
                }
            }
        }
        if(function!=0)
            function->write(out);
    }else{
        qDebug()<<"Can not open file "+path;
    }
}
Пример #19
0
void SendDataThread::sendData(const QByteArray &data)
{
	QMutexLocker locker(&m_DataMutex);
	m_DataList.push_back(data);
	m_DataCondition.wakeAll();
}
Пример #20
0
	void push(int field) {
		queue->push_back(VideoFrame(false, in->mpi(), p->nextPTS(), field | (in->field() & ~VideoFrame::Interlaced)));
		++pushed;
	}
Пример #21
0
/**
 * @brief HashProject::openFile
 * @param filename
 * @return True if successful.
 *
 * Reads a SFV file and loads the list of files along with their values into a new file list.
 * See also HashProject::saveFile.
 */
bool HashProject::openFile(QString filename)
{
   if (!filelist->writeLock(true)) {
      QMessageBox::critical(0, "Error", "Can't load a new SFV file while data processing is in progress.");
      return false;
   }
   QFile file(filename);
   if (!file.exists()) {
      return false;
   }
   if (!file.open(QFile::ReadOnly)) {
      filelist->writeLock(false);
      return false;
   }

   filelist->clearContents();

   QTextStream textstream(&file);
   QString inpath = QFileInfo(filename).path();
   QString algorithm = "CRC32";

   QHash<QString, HashProject::File> newFiles;
   QLinkedList<QString> filesOrder;
   while(!textstream.atEnd()) {
      QString textline = textstream.readLine();
      bool isComment = false;
      if ((textline.indexOf(";") != -1) &&
          (textline.mid(0, textline.indexOf(";")).simplified().length() == 0)) {
         // Line starts with ;
         // Either comment or metadata
         isComment = true;
      }
      int algorithmSettingPos = textline.indexOf(algorithmSettingName);
      if (isComment && algorithmSettingPos != -1) {
         // It's algorithm metadata, use the new value for the following list entries.
         algorithm = textline.right(textline.length() - algorithmSettingPos - algorithmSettingName.length());
      } else {
         QStringList elements(textline);
         QString outfilename;
         QString filesize;
         if (isComment && textline.length() > 36) {
            filesize = textline.mid(1, 13).trimmed();
            textline = textline.right(textline.length() - 36);
         }
         if (textline.count("\"") > 1) {
            int firstPos = textline.indexOf("\"");
            int lastPos = textline.lastIndexOf("\"");
            outfilename = textline.mid(firstPos+1, lastPos-firstPos-1);
            textline.remove(firstPos+1, lastPos-firstPos-1);
         }
         elements = textline.split(" ", QString::SkipEmptyParts);
         if (outfilename.isNull()) {
            outfilename = elements.first();
         }
         elements.removeFirst();
         QString hash;
         if (elements.length() > 0) {
            hash = elements.takeLast();
         }
         HashProject::File newfile;
         if (newFiles.contains(outfilename)) {
            newfile = newFiles[outfilename];
         } else {
            filesOrder.push_back(outfilename);
         }
         if (!filesize.isNull()) {
            newfile.filesize = filesize.toInt();
         }
         if (!isComment) {
            newfile.filename = outfilename;
            newfile.hash = hash;
            newfile.algorithm = algorithm;
         }
         newFiles[outfilename] = newfile;
      }
   }

   QLinkedListIterator<QString> i(filesOrder);
   while (i.hasNext()) {
      HashProject::File newfile = newFiles[i.next()];
      if (!newfile.filename.isNull()) {
         filelist->addFile(newfile);
      }
   }

   sourceDirectory->setPath(inpath);
   verifyDirectory->setPath(inpath);

   filelist->fileAdditionFinished();
   file.close();
   return true;
}