コード例 #1
0
ファイル: FileWriterSync.cpp プロジェクト: windyuuy/opera
void FileWriterSync::seek(long long position, ExceptionCode& ec)
{
    ASSERT(writer());
    ASSERT(m_complete);
    ec = 0;
    seekInternal(position);
}
コード例 #2
0
ファイル: ScaleSliderQWidget.cpp プロジェクト: gobomus/Natron
void
ScaleSliderQWidget::mouseMoveEvent(QMouseEvent* e)
{
    if (!_imp->readOnly) {
        QPoint newClick =  e->pos();
        QPointF newClick_opengl = _imp->zoomCtx.toZoomCoordinates( newClick.x(),newClick.y() );
        double v = _imp->dataType == eDataTypeInt ? std::floor(newClick_opengl.x() + 0.5) : newClick_opengl.x();
        seekInternal(v);
    }
}
コード例 #3
0
void FileWriter::seek(long long position, ExceptionCode& ec)
{
    ASSERT(writer());
    if (m_readyState == WRITING) {
        setError(FileError::INVALID_STATE_ERR, ec);
        return;
    }

    ASSERT(m_truncateLength == -1);
    ASSERT(m_queuedOperation == OperationNone);
    seekInternal(position);
}
コード例 #4
0
ファイル: FileWriter.cpp プロジェクト: Xertz/EAWebKit
void FileWriter::seek(long long position, ExceptionCode& ec)
{
    ASSERT(writer());
    if (m_readyState == WRITING) {
        setError(FileError::INVALID_STATE_ERR, ec);
        return;
    }

    m_bytesWritten = 0;
    m_bytesToWrite = 0;
    seekInternal(position);
}
コード例 #5
0
ファイル: IndexInput.cpp プロジェクト: Afreeca/qt
 void BufferedIndexInput::seek(const int64_t pos) {
   if ( pos < 0 )
     _CLTHROWA(CL_ERR_IO, "IO Argument Error. Value must be a positive value.");
   if (pos >= bufferStart && pos < (bufferStart + bufferLength))
     bufferPosition = (int32_t)(pos - bufferStart);  // seek within buffer
   else {
     bufferStart = pos;
     bufferPosition = 0;
     bufferLength = 0;				  // trigger refill() on read()
     seekInternal(pos);
   }
 }
コード例 #6
0
ファイル: ScaleSliderQWidget.cpp プロジェクト: haebler/Natron
void
ScaleSliderQWidget::mouseMoveEvent(QMouseEvent* e)
{
    if (!_imp->readOnly) {
        QPoint newClick =  e->pos();
        QPointF newClick_opengl = _imp->zoomCtx.toZoomCoordinates( newClick.x(), newClick.y() );
        double v = _imp->dataType == eDataTypeInt ? std::floor(newClick_opengl.x() + 0.5) : newClick_opengl.x();
        if (_imp->gui && _imp->allowDraftModeSetting) {
            _imp->gui->setDraftRenderEnabled(true);
        }
        seekInternal(v);
    }
}
コード例 #7
0
ファイル: IndexInput.cpp プロジェクト: Afreeca/qt
  void BufferedIndexInput::readBytes(uint8_t* b, const int32_t len){
    if (len < bufferSize) {
      for (int32_t i = 0; i < len; ++i)		  // read byte-by-byte
        b[i] = readByte();
    } else {					  // read all-at-once
      int64_t start = getFilePointer();
      seekInternal(start);
      readInternal(b, len);

      bufferStart = start + len;		  // adjust stream variables
      bufferPosition = 0;
      bufferLength = 0;				  // trigger refill() on read
    }
  }
コード例 #8
0
ファイル: ScaleSliderQWidget.cpp プロジェクト: haebler/Natron
void
ScaleSliderQWidget::mousePressEvent(QMouseEvent* e)
{
    if (!_imp->readOnly) {
        if ( modifierHasControl(e) ) {
            Q_EMIT resetToDefaultRequested();
        } else {
            QPoint newClick =  e->pos();
            _imp->oldClick = newClick;
            QPointF newClick_opengl = _imp->zoomCtx.toZoomCoordinates( newClick.x(), newClick.y() );
            double v = _imp->dataType == eDataTypeInt ? std::floor(newClick_opengl.x() + 0.5) : newClick_opengl.x();
            seekInternal(v);
        }
    }
    QWidget::mousePressEvent(e);
}
コード例 #9
0
ファイル: IndexInput.cpp プロジェクト: boatgm/urchin
		/**
		* 读多个字节			 
		*/
		void CIndexInput::readBytes(byte* b,size_t len)
		{
			if (len < m_bufferSize)
			{
				for (size_t i = 0; i < len; i++)
					// read byte-by-byte
					b[i] = (byte) readByte();
			}
			else
			{
				// read all-at-once
				int64_t start = getFilePointer();
				seekInternal(start);
				readInternal((char*)b,len);

				m_bufferStart = start + len; // adjust stream variables
				m_bufferPosition = 0;
				m_bufferLength = 0; // trigger refill() on read
			}
		}
コード例 #10
0
	bool seek(double ts){
		// if the video is currently playing,
		// pause it temporarily during seeking so that
		// not frames aren't dropped because of lost time during seeking
		
		bool tmpPause = !timeHandler->GetPaused();

		if(tmpPause){
			audioDevice->SetPaused(true);
			timeHandler->Pause();
		}

		bool ret = seekInternal(ts, 0);

		if(tmpPause){
			audioDevice->SetPaused(false);
			timeHandler->Play();
		}

		return ret;
	}
コード例 #11
0
void FileWriterSync::seek(long long position, ExceptionState& exceptionState)
{
    ASSERT(writer());
    ASSERT(m_complete);
    seekInternal(position);
}
コード例 #12
0
	bool seekInternal(double t, int depth)
	{
		ResetRetries();
		emptyFrameQueue();
		audioHandler->clearQueue();

		int64_t firstTs = getFirstSeekTs();

		double backSeek = (double)depth * 2.0f + 1.0f;

		int64_t minTs = tsFromTime(t - backSeek - 2.5) + firstTs;
		int64_t ts = tsFromTime(t - backSeek) + firstTs;
		int64_t maxTs = tsFromTime(t - backSeek) + firstTs;

		// There is no discernible way to determine if negative timestamps are allowed
		// (or even required) to seek to low timestamps.
		// On some files you must seek to negative timestamps to be able to seek to 0
		// but on other files you get weird results from seeking to below 0.

		// So, every other try, we will allow seeking to negative timestamps.

		if((depth % 2) == 1){
			minTs = std::max((int64_t)0, minTs);
			ts = std::max((int64_t)0, minTs);
			maxTs = std::max((int64_t)0, minTs);
		}

		FlogD("Trying to seek to minTs: " << minTs << " ts: " << ts << " maxTs: " << maxTs << " with firsTs: " << firstTs);

		int flags = 0;
		
		if(ts < pFormatCtx->streams[videoStream]->cur_dts)
			flags |= AVSEEK_FLAG_BACKWARD;

		int seekRet = avformat_seek_file(pFormatCtx, videoStream, minTs, ts, maxTs, flags);

		if(seekRet > 0){
			FlogD("avformat_seek_file failed, returned " << seekRet);
			return false;
		}

		avcodec_flush_buffers(pCodecCtx);

		double newTime = t + timeFromTs(firstPts);
		double actualTime = skipToTs(newTime);

		// consider the seek failed and try again if the actual time diffs more than .5 seconds
		// from the desired new time. 
		
		FlogD("wanted to seek to " << newTime << " and ended up at " << actualTime);

		bool ret = true;

		if(fabsf(newTime - actualTime) > .5){
			if(depth < 5){
				FlogD("not good enough, trying again");
				return seekInternal(t, depth + 1);
			}
			else{
				ret = false;
				FlogW("seek failed, wanted to seek to " << newTime << " and ended up at " << actualTime);
			}
		}

		timeHandler->SetTime(actualTime);

		stepIntoQueue = true;

		audioHandler->onSeek();

		return ret;
	}