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; }
uint32 VideoDecoder::FixedRateVideoTrack::getNextFrameStartTime() const { if (endOfTrack() || getCurFrame() < 0) return 0; Common::Rational time = (getCurFrame() + 1) * 1000; time /= getFrameRate(); return time.toInt(); }
Common::SeekableReadStream *QuickTimeDecoder::getNextFramePacket(uint32 &descId) { if (_videoTrackIndex < 0) return NULL; // First, we have to track down which chunk holds the sample and which sample in the chunk contains the frame we are looking for. int32 totalSampleCount = 0; int32 sampleInChunk = 0; int32 actualChunk = -1; for (uint32 i = 0; i < _tracks[_videoTrackIndex]->chunkCount; i++) { int32 sampleToChunkIndex = -1; for (uint32 j = 0; j < _tracks[_videoTrackIndex]->sampleToChunkCount; j++) if (i >= _tracks[_videoTrackIndex]->sampleToChunk[j].first) sampleToChunkIndex = j; if (sampleToChunkIndex < 0) error("This chunk (%d) is imaginary", sampleToChunkIndex); totalSampleCount += _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex].count; if (totalSampleCount > getCurFrame()) { actualChunk = i; descId = _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex].id; sampleInChunk = _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex].count - totalSampleCount + getCurFrame(); break; } } if (actualChunk < 0) { warning ("Could not find data for frame %d", getCurFrame()); return NULL; } // Next seek to that frame _fd->seek(_tracks[_videoTrackIndex]->chunkOffsets[actualChunk]); // Then, if the chunk holds more than one frame, seek to where the frame we want is located for (int32 i = getCurFrame() - sampleInChunk; i < getCurFrame(); i++) { if (_tracks[_videoTrackIndex]->sampleSize != 0) _fd->skip(_tracks[_videoTrackIndex]->sampleSize); else _fd->skip(_tracks[_videoTrackIndex]->sampleSizes[i]); } // Finally, read in the raw data for the frame //printf ("Frame Data[%d]: Offset = %d, Size = %d\n", getCurFrame(), _fd->pos(), _tracks[_videoTrackIndex]->sampleSizes[getCurFrame()]); if (_tracks[_videoTrackIndex]->sampleSize != 0) return _fd->readStream(_tracks[_videoTrackIndex]->sampleSize); return _fd->readStream(_tracks[_videoTrackIndex]->sampleSizes[getCurFrame()]); }
bool MoviePlayerDXA::processFrame() { Graphics::Surface *screen = _vm->_system->lockScreen(); copyFrameToBuffer((byte *)screen->getPixels(), (_vm->_screenWidth - getWidth()) / 2, (_vm->_screenHeight - getHeight()) / 2, screen->pitch); _vm->_system->unlockScreen(); uint32 soundTime = _mixer->getSoundElapsedTime(_bgSound); uint32 nextFrameStartTime = ((Video::VideoDecoder::VideoTrack *)getTrack(0))->getNextFrameStartTime(); if ((_bgSoundStream == NULL) || soundTime < nextFrameStartTime) { if (_bgSoundStream && _mixer->isSoundHandleActive(_bgSound)) { while (_mixer->isSoundHandleActive(_bgSound) && soundTime < nextFrameStartTime) { _vm->_system->delayMillis(10); soundTime = _mixer->getSoundElapsedTime(_bgSound); } // 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; }
void Enemy::update() { Animation::update(); SDL_Rect previousState = pos; if (!isPlaying)//If not going to die { pos.x += moveSpeed * direction.first; pos.y += moveSpeed * direction.second; } if (Physics::checkCollision(mms->curMap->mapCollider, pos)) { pos = previousState; direction.first = -direction.first; direction.second = -direction.second; } if ( mms->bomb != nullptr && mms->bomb->getInteraction(*this) == BombCharStatus::COLLISION ) { pos = previousState; direction.first = -direction.first; direction.second = -direction.second; } turnRandom(); if (getCurFrame() == noOfFrames - 1 ) { isDead = true; } }
const Graphics::Surface *AVIDecoder::decodeNextFrame() { AVIVideoTrack *track = nullptr; bool isReversed = false; int frameNum = 0; // Check whether the video is playing in revese for (int idx = _videoTracks.size() - 1; idx >= 0; --idx) { track = static_cast<AVIVideoTrack *>(_videoTracks[idx].track); isReversed |= track->isReversed(); } if (isReversed) { // For reverse mode we need to keep seeking to just before the // desired frame prior to actually decoding a frame frameNum = getCurFrame(); seekIntern(track->getFrameTime(frameNum)); } // Decode the next frame const Graphics::Surface *frame = VideoDecoder::decodeNextFrame(); if (isReversed) { // In reverse mode, set next frame to be the prior frame number for (int idx = _videoTracks.size() - 1; idx >= 0; --idx) { track = static_cast<AVIVideoTrack *>(_videoTracks[idx].track); track->setCurFrame(frameNum - 1); findNextVideoTrack(); } } return frame; }
bool MoviePlayerSMK::processFrame() { Graphics::Surface *screen = _vm->_system->lockScreen(); copyFrameToBuffer((byte *)screen->getPixels(), (_vm->_screenWidth - getWidth()) / 2, (_vm->_screenHeight - getHeight()) / 2, screen->pitch); _vm->_system->unlockScreen(); uint32 waitTime = getTimeToNextFrame(); if (!waitTime && !endOfVideoTracks()) { warning("dropped frame %i", getCurFrame()); return false; } _vm->_system->updateScreen(); // Wait before showing the next frame _vm->_system->delayMillis(waitTime); return true; }
uint32 VideoDecoder::FixedRateVideoTrack::getNextFrameStartTime() const { if (endOfTrack() || getCurFrame() < 0) return 0; return getFrameTime(getCurFrame() + 1).msecs(); }
bool VideoDecoder::VideoTrack::endOfTrack() const { return getCurFrame() >= (getFrameCount() - 1); }
bool FlicDecoder::FlicVideoTrack::endOfTrack() const { return getCurFrame() >= getFrameCount() - 1; }
bool VideoDecoder::endOfVideo() const { return !isVideoLoaded() || (getCurFrame() >= (int32)getFrameCount() - 1); }