Ejemplo n.º 1
0
 double MovieDecoderBase::getMovieTime(double theSystemTime) {
     DB(AC_TRACE << "getMovieTime start: _myMovieTime: " << _myMovieTime
             << ", theSystemTime: " << theSystemTime << ", _myLastSystemTime: "
             << _myLastSystemTime);
     if (theSystemTime <= _myLastSystemTime) {
         return _myMovieTime;
     }
     float myPlaySpeed = _myMovie->get<PlaySpeedTag>();
     if (_myLastSystemTime >= 0) {
         _myMovieTime += (theSystemTime - _myLastSystemTime) * myPlaySpeed;
         // if difference between last system time and current system time is bigger than movie duration
         if (getFrameCount() != -1 && _myMovieTime * getFrameRate() > getFrameCount()) {
             _myMovieTime = getFrameCount() / getFrameRate();
         }
         // Calculate the wraparaound for reverse playback
         if (_myMovieTime < 0) {
             unsigned myFrameCount = getFrameCount();
             if (myFrameCount == static_cast<unsigned>(-1) || myFrameCount == 0) {
                 AC_WARNING << "Movie cannot play backwards, because its framecount is unknown (framecount="
                            << myFrameCount << ")";
                 _myMovieTime = 0;
             } else {
                 double myIncrement = getFrameCount() / getFrameRate();
                 while (_myMovieTime < 0) {
                     _myMovieTime += myIncrement;
                 }
             }
         }
     }
     _myLastSystemTime = theSystemTime;
     DB(AC_TRACE << "getMovieTime end: _myMovieTime: " << _myMovieTime
             << ", theSystemTime: " << theSystemTime << ", _myLastSystemTime: "
             << _myLastSystemTime);
     return _myMovieTime;
 }
Ejemplo n.º 2
0
bool MoviePlayerDXA::processFrame() {
	Graphics::Surface *screen = _vm->_system->lockScreen();
	copyFrameToBuffer((byte *)screen->pixels, (_vm->_screenWidth - getWidth()) / 2, (_vm->_screenHeight - getHeight()) / 2, _vm->_screenWidth);
	_vm->_system->unlockScreen();

	Common::Rational soundTime(_mixer->getSoundElapsedTime(_bgSound), 1000);
	if ((_bgSoundStream == NULL) || ((soundTime * getFrameRate()).toInt() / 1000 < getCurFrame() + 1)) {

		if (_bgSoundStream && _mixer->isSoundHandleActive(_bgSound)) {
			while (_mixer->isSoundHandleActive(_bgSound) && (soundTime * getFrameRate()).toInt() < getCurFrame()) {
				_vm->_system->delayMillis(10);
				soundTime = Common::Rational(_mixer->getSoundElapsedTime(_bgSound), 1000);
			}
			// In case the background sound ends prematurely, update
			// _ticks so that we can still fall back on the no-sound
			// sync case for the subsequent frames.
			_ticks = _vm->_system->getMillis();
		} else {
			_ticks += getTimeToNextFrame();
			while (_vm->_system->getMillis() < _ticks)
				_vm->_system->delayMillis(10);
		}

		return true;
	}

	warning("dropped frame %i", getCurFrame());
	return false;
}
Ejemplo n.º 3
0
void SeekableBinkDecoder::seekToFrame(uint32 frame) {
	assert(frame < _frames.size());

	// Fast path
	if ((int32)frame == _curFrame + 1)
		return;

	// Stop all audio (for now)
	stopAudio();

	// Track down the keyframe
	_curFrame = findKeyFrame(frame) - 1;
	while (_curFrame < (int32)frame - 1)
		skipNextFrame();

	// Map out the starting point
	Common::Rational startTime = frame * 1000 / getFrameRate();
	_startTime = g_system->getMillis() - startTime.toInt();
	resetPauseStartTime();

	// Adjust the audio starting point
	if (_audioTrack < _audioTracks.size()) {
		Common::Rational audioStartTime = (frame + 1) * 1000 / getFrameRate();
		_audioStartOffset = audioStartTime.toInt();
	}

	// Restart the audio
	startAudio();
}
Ejemplo n.º 4
0
bool QCamVesta::updateFrame() {
   static int tmp;
   if (skippedFrame_ < multiplicateur_-1) {
      if (skippedFrame_ >= multiplicateur_ -3) {
         stopAccumulation();
      }
      if (QCamV4L2::dropFrame()) {
         skippedFrame_++;
         exposureTimeLeft_->setValue(skippedFrame_);
         tmp=0;
      }
      return false;
   } else {
      if (QCamV4L2::updateFrame()) {
         skippedFrame_=0;
         if (multiplicateur_ > 1) {
            startAccumulation();
            if (guiBuild()) exposureTimeLeft_->reset();
         }
         int tmpVal;
         setProperty("Gain",tmpVal=getGain(),false);
         emit gainChange(tmpVal);
         //emit exposureChange(getExposure());
         //setProperty("Gama",tmpVal=getGama());
         //emit gamaChange(tmpVal);
         //emit compressionChange(getCompression());
         /*
           setProperty("NoiseRemoval",tmpVal=getNoiseRemoval());
           emit noiseRemovalChange(tmpVal);
           setProperty("Sharpness",tmpVal=getSharpness());
           emit sharpnessChange(tmpVal);
         */
         setProperty("FrameRateSecond",(tmpVal=getFrameRate())/(double)multiplicateur_);
         emit frameRateChange(tmpVal);
         if (liveWhiteBalance_ || refreshGui_) {
            getWhiteBalance();
         }
         if (SCmodCtrl_) {
            setProperty("ExposureTime",multiplicateur_/(double)getFrameRate());
            emit frameRateMultiplicateurChange(multiplicateur_);
            emit exposureTime(multiplicateur_/(double)getFrameRate());
         } else {
            setProperty("ExposureTime",1/(double)getFrameRate());
         }
         refreshGui_=false;
         return true;
      } else {
         refreshGui_=false;
         return false;
      }
   }
}
Ejemplo n.º 5
0
Audio::Timestamp VideoDecoder::FixedRateVideoTrack::getDuration() const {
	// Since Audio::Timestamp doesn't support a fractional frame rate, we're currently
	// just converting to milliseconds.
	Common::Rational time = getFrameCount() * 1000;
	time /= getFrameRate();
	return time.toInt();
}
Ejemplo n.º 6
0
void CharacterGame::render(long elapsedTime)
{
    // Clear the color and depth buffers.
    clear(CLEAR_COLOR_DEPTH, Vector4(0.41f, 0.48f, 0.54f, 1.0f), 1.0f, 0);

    // Draw our scene
    _scene->visit(this, &CharacterGame::drawScene, (void*)0);
    _scene->visit(this, &CharacterGame::drawScene, (void*)1);

	switch (drawDebug)
	{
	case 1:
		Game::getInstance()->getPhysicsController()->drawDebug(_scene->getActiveCamera()->getViewProjectionMatrix());
		break;
	case 2:
		_scene->drawDebug(Scene::DEBUG_BOXES);
		break;
	case 3:
		_scene->drawDebug(Scene::DEBUG_SPHERES);
		break;
	}

    _font->begin();
    char fps[32];
    sprintf(fps, "%d", getFrameRate());
    _font->drawText(fps, 5, 5, Vector4(1,1,0,1), 20);
    _font->end();
}
Ejemplo n.º 7
0
void BillboardSample::render(float elapsedTime)
{
    // Clear the color and depth buffers
    clear(CLEAR_COLOR_DEPTH, Vector4::fromColor(0x355D90FF), 1.0f, 0);

	// Draw the ground
	_ground->draw();

	// Get the scene camera
	Camera* camera = _scene->getActiveCamera();

	for (unsigned int i = 0; i < BILLBOARD_COUNT; i++)
	{
		Node* node = _billboards[i];

		// Rotate the node x/z to face the camera
		Matrix m;
        Matrix::createBillboard(node->getTranslationWorld(), camera->getNode()->getTranslationWorld(), camera->getNode()->getUpVectorWorld(), &m);
		Quaternion q;
		m.getRotation(&q);
		node->setRotation(q);

		if (node->getBoundingSphere().intersects(camera->getFrustum()))
			node->getDrawable()->draw();
	}

    // draw the gamepad
    _gamepad->draw();

    // draw the frame rate
    drawFrameRate(_font, Vector4::one(), 5, 1, getFrameRate());
}
Ejemplo n.º 8
0
ActionInterval* Player::getRunActionsFromSprite(std::string &strPath, FigureStateType nType, FigureDirectionType nDir)
{
	//CCArray* array = CCArray::createWithCapacity(8);
	Vector<SpriteFrame*> array;
	int flag = 0;
	do
	{
		int dirType = nDir;
		if (8 > dirType && dirType > 4)
		{
			dirType = 8 - dirType;
		}

		auto string = String::createWithFormat("%s_%d_%d_%02d.png", strPath.c_str(), nType, dirType, flag);
		
		//std::string string;
		//sprintf(string, "%s_%d_%d_%02d.png", strPath.c_str(), nType, dirType, flag);
		auto spriteFrame = SpriteFrameCache::getInstance()->spriteFrameByName(string->getCString());
		CC_BREAK_IF(spriteFrame == NULL);
		array.pushBack(spriteFrame);
		flag++;
	} while (1);

	CCAnimation* movie = CCAnimation::createWithSpriteFrames(array,getFrameRate(nType,1));
	CCAnimate* animate = CCAnimate::create(movie);
	return animate;
}
Ejemplo n.º 9
0
void CharacterGame::render(long elapsedTime)
{
    // Clear the color and depth buffers.
    clear(CLEAR_COLOR_DEPTH, Vector4(0.41f, 0.48f, 0.54f, 1.0f), 1.0f, 0);

    // Draw our scene, with separate passes for opaque and transparent objects.
    _scene->visit(this, &CharacterGame::drawScene, false);
    _scene->visit(this, &CharacterGame::drawScene, true);

    // Draw debug info (physics bodies, bounds, etc).
    switch (_drawDebug)
    {
    case 1:
        Game::getInstance()->getPhysicsController()->drawDebug(_scene->getActiveCamera()->getViewProjectionMatrix());
        break;
    case 2:
        _scene->drawDebug(Scene::DEBUG_BOXES);
        break;
    case 3:
        _scene->drawDebug(Scene::DEBUG_SPHERES);
        break;
    }

    // Draw gamepad for touch devices.
    _gamepad->draw(Vector4(1.0f, 1.0f, 1.0f, 0.7f));

    // Draw FPS
    _font->begin();
    char fps[32];
    sprintf(fps, "%d", getFrameRate());
    _font->drawText(fps, 5, 5, Vector4(1,1,0,1), 20);
    _font->end();
}
Ejemplo n.º 10
0
/// Run the game
void Game::run()
{
  logi.log("Running game...");
  while ((!mainWindow->shouldClose()))
  {
    float ms = getFrameDiff();
    logFrame();
    float fps = getFrameRate();
    char buffer[80]; sprintf(buffer,"Project Magrathea III (%.2f FPS : %.0fms)",fps,ms*1000);
    mainWindow->setTitle(buffer);


    if (mouseCameraControl)
      camera->getInputFromWindow(mainWindow);
    if (keys['W'])
      camera->MoveForward(ms*50.f);
    if (keys['S'])
      camera->MoveForward(-ms*50.f);

    glfwPollEvents();
    mainWindow->setContext();
    renderMainWindow(ms);
    mainWindow->swapBuffers();
  }
  glfwTerminate();
}
Ejemplo n.º 11
0
/** 
 * setInput	-	set the name of the expected video file
 *
 * @param fileName	-	the name of the video file
 *
 * @return True if success. False otherwise
 */
bool VideoProcessor::setInput(const std::string &fileName)
{
    fnumber = 0;
    tempFile = fileName;

    // In case a resource was already
    // associated with the VideoCapture instance
    if (isOpened()){
        capture.release();
    }

    // Open the video file
    if(capture.open(fileName)){
        // read parameters
        length = capture.get(CV_CAP_PROP_FRAME_COUNT);
        rate = getFrameRate();
        cv::Mat input;
        // show first frame
        getNextFrame(input);
        emit showFrame(input);
        emit updateBtn();
        return true;
    } else {
        return false;
    }
}
Ejemplo n.º 12
0
SoundSourceMediaFoundation::SoundSourceMediaFoundation(QUrl url)
        : SoundSourcePlugin(url, "m4a"),
          m_hrCoInitialize(E_FAIL),
          m_hrMFStartup(E_FAIL),
          m_pReader(NULL),
          m_pAudioType(NULL),
          m_wcFilename(NULL),
          m_nextFrame(0),
          m_leftoverBuffer(NULL),
          m_leftoverBufferSize(0),
          m_leftoverBufferLength(0),
          m_leftoverBufferPosition(0),
          m_mfDuration(0),
          m_iCurrentPosition(0),
          m_dead(false),
          m_seeking(false) {

    // these are always the same, might as well just stick them here
    // -bkgood
    // AudioSource properties
    setFrameRate(kSampleRate);

    // presentation attribute MF_PD_AUDIO_ENCODING_BITRATE only exists for
    // presentation descriptors, one of which MFSourceReader is not.
    // Therefore, we calculate it ourselves, assuming 16 bits per sample
    setBitrate((frames2samples(getFrameRate()) * kBitsPerSample) / 1000);
}
Ejemplo n.º 13
0
	AudioTrackImpl::AudioTrackImpl(Library *lib) :
		// By default, try to load Android 2.3 symbols
		mCtor(lib,"_ZN7android10AudioTrackC1EijiiijPFviPvS1_ES1_ii"),
		mDtor(lib,"_ZN7android10AudioTrackD1Ev"),
		mInitCheck(lib,"_ZNK7android10AudioTrack9initCheckEv"),
		mStop(lib,"_ZN7android10AudioTrack4stopEv"),
		mStart(lib,"_ZN7android10AudioTrack5startEv"),
		mStopped(lib,"_ZNK7android10AudioTrack7stoppedEv"),
		mFlush(lib,"_ZN7android10AudioTrack5flushEv"),
		mGetMinFrameCount(lib,"_ZN7android10AudioTrack16getMinFrameCountEPiij"),
		mLatency(lib,"_ZNK7android10AudioTrack7latencyEv"),
		mGetPosition(lib,"_ZN7android10AudioTrack11getPositionEPj"),
		mBeforeICS(false)
	{
		// Try some Android 2.2 symbols if not found
		if (!mCtor.isFound()) {
			mCtor.load(lib,"_ZN7android10AudioTrackC1EijiiijPFviPvS1_ES1_i");
		}

		// Then try some Android 4.1 symbols if still not found
		if (!mGetMinFrameCount.isFound()) {
			mGetMinFrameCount.load(lib,"_ZN7android10AudioTrack16getMinFrameCountEPi19audio_stream_type_tj");
		}

		// Dummy symbol loading to detect the Android version, this function did not exist before ICS,
		Function0<uint32_t> getFrameRate(lib,"_ZN7android10AudioTrack9setLoop_lEjji");
		if (!getFrameRate.isFound()) {
			mBeforeICS = true;
		}
	}
Ejemplo n.º 14
0
ffmpegFileInfo Ffmpeg::getInfo() {
  QString ffmpegCachePath = getFfmpegCache().getQString();
  QString tempPath = ffmpegCachePath + "//" + cleanPathSymbols() + ".txt";
  if (QFile::exists(tempPath)) {
    QFile infoText(tempPath);
    infoText.open(QIODevice::ReadOnly);
    QByteArray ba = infoText.readAll();
    infoText.close();
    QString text = QString::fromStdString(ba.toStdString());
    m_lx         = text.split(" ")[0].toInt();
    m_ly         = text.split(" ")[1].toInt();
    m_frameRate  = text.split(" ")[2].toDouble();
    m_frameCount = text.split(" ")[3].toInt();
  } else {
    QFile infoText(tempPath);
    getSize();
    getFrameRate();
    getFrameCount();
    infoText.open(QIODevice::WriteOnly);
    std::string infoToWrite =
        std::to_string(m_lx) + " " + std::to_string(m_ly) + " " +
        std::to_string(m_frameRate) + " " + std::to_string(m_frameCount);
    int infoLength = infoToWrite.length();
    infoText.write(infoToWrite.c_str(), infoLength);
    infoText.close();
  }
  ffmpegFileInfo info;
  info.m_lx         = m_lx;
  info.m_ly         = m_ly;
  info.m_frameRate  = m_frameRate;
  info.m_frameCount = m_frameCount;
  return info;
}
Ejemplo n.º 15
0
void Demo::printFramerate()
{
	_mainRender->writeText(10, 14, "Aika");

	String strFrameRate = String::intToStr((int)getFrameRate());
	strFrameRate.concat(" fps");
	_mainRender->writeText(10, 13, strFrameRate.getChars());
}
Ejemplo n.º 16
0
uint32 VideoDecoder::FixedRateVideoTrack::getNextFrameStartTime() const {
	if (endOfTrack() || getCurFrame() < 0)
		return 0;

	Common::Rational time = (getCurFrame() + 1) * 1000;
	time /= getFrameRate();
	return time.toInt();
}
Ejemplo n.º 17
0
void FontSample::render(float elapsedTime)
{
    // Clear the screen.
    clear(CLEAR_COLOR_DEPTH, Vector4(0, 0, 0, 1), 1.0f, 0);

    // Draw the frame rate.
    wchar_t fps[5];
    swprintf(fps, 5, L"%u", getFrameRate());

    _fonts[0]->start();

    _fonts[0]->drawText(fps, 245, 5, Vector4(0, 0.5f, 1, 1), _size);
    
    _form->draw();

    float size = (float)_font->getSize() * _size;
    if (_font != _fonts[1])
        _font->start();

    if (_simple)
    {
        // Sample simple versions of measureText, drawText.
        float w, h;
        _font->measureText(_sampleString.c_str(), _size, _textFlags, &w, &h);
        _font->drawText(_sampleString.c_str(), _viewport.x, _viewport.y, Vector4::fromColor(0xff0000ff), _size, _textFlags);
        _font->drawText(L"'", _viewport.x, _viewport.y, Vector4::fromColor(0x00ff00ff), _size);
        _font->drawText(L".", _viewport.x, _viewport.y + h, Vector4::fromColor(0x00ff00ff), _size);
        _font->drawText(L"'", _viewport.x + w, _viewport.y, Vector4::fromColor(0x00ff00ff), _size);
        _font->drawText(L".", _viewport.x + w, _viewport.y + h, Vector4::fromColor(0x00ff00ff), _size);
    }
    else
    {
        // Sample viewport versions.
        gameplay::Rectangle area;
        _font->measureText(_sampleString.c_str(), _viewport, _size, _textFlags, &area, _alignment, _wrap, _ignoreClip);

        _font->drawText(_sampleString.c_str(), _useViewport ? _viewport : area, Vector4::fromColor(0xffffffff), _size, _alignment, _wrap, _textFlags);
    
        _font->drawText(L"'", _viewport.x, _viewport.y, Vector4::fromColor(0x00ff00ff), _size);
        _font->drawText(L".", _viewport.x, _viewport.y + _viewport.height, Vector4::fromColor(0x00ff00ff), _size);
        _font->drawText(L"'", _viewport.x + _viewport.width, _viewport.y, Vector4::fromColor(0x00ff00ff), _size);
        _font->drawText(L".", _viewport.x + _viewport.width, _viewport.y + _viewport.height, Vector4::fromColor(0x00ff00ff), _size);

        _font->drawText(L"'", area.x, area.y, Vector4::fromColor(0x0000ffff), _size);
        _font->drawText(L".", area.x, area.y + area.height, Vector4::fromColor(0x0000ffff), _size);
        _font->drawText(L"'", area.x + area.width, area.y, Vector4::fromColor(0x0000ffff), _size);
        _font->drawText(L".", area.x + area.width, area.y + area.height, Vector4::fromColor(0x0000ffff), _size);
    }

    if (_font != _fonts[0])
    {
        _font->finish();
    }
    _fonts[0]->finish();

    _form->draw();
}
Ejemplo n.º 18
0
		// Runs update logic
		void DynamicsWorld::update()
		{

			// Get time since last frame, update
			double elapsedSeconds = getElapsedSeconds();
			double step = elapsedSeconds - mElapsedSeconds;
			mElapsedSeconds = elapsedSeconds;

			// Update Bullet world
			mDynamicsWorld->stepSimulation(1.0f, 10, 1.0f / math<float>::max(1.0f, getFrameRate()));

			// Get object counts
			uint32_t numObjects = mObjects.size();

			// Update bodies
			for (uint32_t i = 0; i < mObjects.size(); i++)
			{
				mObjects[i]->update(step);
				if (mObjects[i]->getLifespan() > 0.0 && mObjects[i]->getLifetime() > mObjects[i]->getLifespan())
					mObjects.erase(mObjects.begin() + i);
			}

			// Object count has changed
			if (numObjects != mObjects.size())
			{
	
				// Iterate through objects
				numObjects = mDynamicsWorld->getNumCollisionObjects();
				for (int32_t i = (int32_t)numObjects - 1; i >= 0 ; i--)
				{

					// Check range
					if (i >= 0)
					{

						// Activate object if it is a rigid or soft body
						btCollisionObject * collisionObject = mDynamicsWorld->getCollisionObjectArray()[i];
						btRigidBody * rigidBody = btRigidBody::upcast(collisionObject);
						if (rigidBody)
						{
							rigidBody->activate(true);
						}
						else
						{
							btSoftBody * softBody = btSoftBody::upcast(collisionObject);
							if (softBody)
								softBody->activate(true);
						}

					}

				}

			}

		}
Ejemplo n.º 19
0
oneCame::oneCame(int id, FlyCapture2::BusManager &busMgr, cv::Mat* img):_cameraId(id), _imgOPENCV(img), _readyFlag(false)
{
	
	PGR_SAFE_CALL(busMgr.GetCameraFromIndex(_cameraId, &_guid));
	PGR_SAFE_CALL(_cam.Connect(&_guid));

	// restart cam:
	//restartCam();
	
	int centerX = 1328/2;
	int centerY = 1024/2;
	//_allImgs = new FlyCapture2::Image[_numOfCams];
    _fmt7ImageSettings.mode = FlyCapture2::MODE_7;;	  
	_fmt7ImageSettings.width = 800;   
	_fmt7ImageSettings.height = 600;
    _fmt7ImageSettings.offsetX = centerX - _fmt7ImageSettings.width /2;
    _fmt7ImageSettings.offsetY = centerY - _fmt7ImageSettings.height /2; 
    _fmt7ImageSettings.pixelFormat =  FlyCapture2::PIXEL_FORMAT_RGB8;
    // Validate the settings to make sure that they are valid
	bool valid;
	PGR_SAFE_CALL( _cam.ValidateFormat7Settings(&_fmt7ImageSettings,&valid, &_fmt7PacketInfo ));	
	PGR_SAFE_CALL( _cam.SetFormat7Configuration( &_fmt7ImageSettings, _fmt7PacketInfo.recommendedBytesPerPacket ));
	

	FlyCapture2::Property prop;
	// set gain
	prop.type = FlyCapture2::GAIN; prop.autoManualMode = false; prop.absControl = true; prop.absValue = 10; 
	PGR_SAFE_CALL(_cam.SetProperty( &prop ));
	// set shutter
	prop.type = FlyCapture2::SHUTTER; prop.autoManualMode = false; prop.onOff = true;
	prop.absControl = true; prop.absValue = 45; PGR_SAFE_CALL(_cam.SetProperty( &prop ));
	// set frame rate	
	prop.type = FlyCapture2::FRAME_RATE; prop.autoManualMode = false; prop.onOff = true;
	prop.absControl = true; prop.absValue = 20; PGR_SAFE_CALL(_cam.SetProperty( &prop ));
	// set auto white balance
	FlyCapture2::Property prop1;
	prop1.type = FlyCapture2::WHITE_BALANCE; prop1.onOff = true; prop1.autoManualMode = false;
	prop1.valueA = 490; prop1.valueB = 790; PGR_SAFE_CALL(_cam.SetProperty( &prop1 ));
	// disable sharpness
	FlyCapture2::Property sharpnessProp;
	sharpnessProp.type = FlyCapture2::SHARPNESS; sharpnessProp.onOff = false; PGR_SAFE_CALL(_cam.SetProperty( &sharpnessProp ));
	// diable gamma
	FlyCapture2::Property gammaProp;
	gammaProp.type = FlyCapture2::GAMMA; gammaProp.onOff = false; PGR_SAFE_CALL(_cam.SetProperty( &gammaProp ));


	// set trigger mode
	_triggerMode.onOff = true;
	_triggerMode.mode = 15;
	_triggerMode.parameter = 10;
	_triggerMode.source = 0;	 
	PGR_SAFE_CALL(_cam.SetTriggerMode( &_triggerMode));		

	std::cout<< getFrameRate() << std::endl;

}
Ejemplo n.º 20
0
uint VideoDecoder::FixedRateVideoTrack::getFrameAtTime(const Audio::Timestamp &time) const {
	Common::Rational frameRate = getFrameRate();

	// Easy conversion
	if (frameRate == time.framerate())
		return time.totalNumberOfFrames();

	// Default case
	return (time.totalNumberOfFrames() * frameRate / time.framerate()).toInt();
}
Ejemplo n.º 21
0
void CreateSceneSample::render(float elapsedTime)
{
    // Clear the color and depth buffers
    clear(CLEAR_COLOR_DEPTH, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0);

    // Visit all the nodes in the scene, drawing the models.
    _scene->visit(this, &CreateSceneSample::drawScene);

    drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate());
}
Ejemplo n.º 22
0
void TriangleSample::render(float elapsedTime)
{
    // Clear the color and depth buffers
    clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0);
    
    // Bind the view projection matrix to the model's parameter. This will transform the vertices when the model is drawn.
    _model->getMaterial()->getParameter("u_worldViewProjectionMatrix")->setValue(_worldViewProjectionMatrix);
    _model->draw();

    drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate());
}
Ejemplo n.º 23
0
void MeshGame::render(float elapsedTime)
{
    // Clear the color and depth buffers.
    clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0);
    
    // Visit all the nodes in the scene, drawing the models/mesh.
    _scene->visit(this, &MeshGame::drawScene);

    // Draw the fps
    drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate());
}
Ejemplo n.º 24
0
uint VideoDecoder::FixedRateVideoTrack::getFrameAtTime(const Audio::Timestamp &time) const {
	Common::Rational frameRate = getFrameRate();

	// Easy conversion
	if (frameRate == time.framerate())
		return time.totalNumberOfFrames();

	// Create the rational based on the time first to hopefully cancel out
	// *something* when multiplying by the frameRate (which can be large in
	// some AVI videos).
	return (Common::Rational(time.totalNumberOfFrames(), time.framerate()) * frameRate).toInt();
}
Ejemplo n.º 25
0
	void Sprite::updateSprite(float dt)
	{
		mAsset->processAnimation();

		if (mAsset->getTotalFrames() > 1)
		{
			if (getFrameRate() < 0.0001f && getFrameRate() > -0.0001f)
			{
				mCurrentTime = 0.0f;
			}
			else
			{
				mCurrentTime += dt * getFrameRate();
				float totalTime = static_cast<float>(mAsset->getTotalFrames());
				while (mCurrentTime > totalTime)
				{
					mCurrentTime -= totalTime;
				}
				while (mCurrentTime < 0.0f)
				{
					mCurrentTime += totalTime;
				}

				mCurrentFrame = static_cast<int>(mCurrentTime);
				if (mCurrentFrame >= mAsset->getTotalFrames())
				{
					mCurrentFrame = mAsset->getTotalFrames() - 1;
				}
				if (mCurrentFrame < 0)
				{
					mCurrentFrame = 0;
				}
			}
		}
		else
		{
			mCurrentFrame = 0;
			mCurrentTime = 0.0f;
		}
	}
Ejemplo n.º 26
0
void Audio3DTest::render(float elapsedTime)
{
    // Clear the color and depth buffers
    clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0);

    // Visit all the nodes in the scene for drawing
    _scene->visit(this, &Audio3DTest::drawScene);

    drawDebugText(0, _font->getSize());

    _gamepad->draw();
    drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate());
}
Ejemplo n.º 27
0
Audio::Timestamp VideoDecoder::FixedRateVideoTrack::getFrameTime(uint frame) const {
	// Try to get as accurate as possible, considering we have a fractional frame rate
	// (which Audio::Timestamp doesn't support).
	Common::Rational frameRate = getFrameRate();

	if (frameRate == frameRate.toInt()) // The nice case (a whole number)
		return Audio::Timestamp(0, frame, frameRate.toInt());

	// Just convert to milliseconds.
	Common::Rational time = frame * 1000;
	time /= frameRate;
	return Audio::Timestamp(time.toInt(), 1000);
}
Ejemplo n.º 28
0
void GamepadSample::render(float elapsedTime)
{
    clear(CLEAR_COLOR_DEPTH, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0);

    drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate());

    _font->start();
    _font->drawText(_status.c_str(), 7, 27, Vector4::one(), 22);
    _font->finish();


    _gamepad->draw();
}
Ejemplo n.º 29
0
Audio::Timestamp VideoDecoder::FixedRateVideoTrack::getFrameTime(uint frame) const {
	// Try to get as accurate as possible, considering we have a fractional frame rate
	// (which Audio::Timestamp doesn't support).
	Common::Rational frameRate = getFrameRate();

	// Try to keep it in terms of the frame rate, if the frame rate is a whole
	// number.
	if (frameRate.getDenominator() == 1)
		return Audio::Timestamp(0, frame, frameRate.toInt());

	// Convert as best as possible
	Common::Rational time = frameRate.getInverse() * frame;
	return Audio::Timestamp(0, time.getNumerator(), time.getDenominator());
}
bool VideoProcessor::setOutput(const std::string &filename, int codec=0, double framerate=0.0,bool isColor=true) {
	outputFile= filename;
//	extension.clear();
	if (framerate==0.0)
		framerate= getFrameRate(); // same as input
	
	char c[4];
	if (codec==0){
		codec= getCodec(c);	// use same codec as input
	}
printf("AAAAAAAAAAAAAAA\n");
	// Open output video
	return writer.open("outputFile.avi", codec, framerate, getFrameSize(), isColor);
}