Return exact frame rate in Smacker player, and minor cleanup.
svn-id: r35458
This commit is contained in:
parent
76624fc69c
commit
587e70809a
5 changed files with 39 additions and 11 deletions
|
@ -312,7 +312,7 @@ void MoviePlayerDXA::startSound() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoviePlayerDXA::nextFrame() {
|
void MoviePlayerDXA::nextFrame() {
|
||||||
if (_vm->_mixer->isSoundHandleActive(_bgSound) && (_vm->_mixer->getSoundElapsedTime(_bgSound) * _framesPerSec) / 1000 < _frameNum) {
|
if (_vm->_mixer->isSoundHandleActive(_bgSound) && (_vm->_mixer->getSoundElapsedTime(_bgSound) * getFrameRate()) / 1000 < _frameNum) {
|
||||||
copyFrameToBuffer(_vm->getBackBuf(), 465, 222, _vm->_screenWidth);
|
copyFrameToBuffer(_vm->getBackBuf(), 465, 222, _vm->_screenWidth);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -353,15 +353,15 @@ bool MoviePlayerDXA::processFrame() {
|
||||||
copyFrameToBuffer((byte *)screen->pixels, (_vm->_screenWidth - _width) / 2, (_vm->_screenHeight - _height) / 2, _vm->_screenWidth);
|
copyFrameToBuffer((byte *)screen->pixels, (_vm->_screenWidth - _width) / 2, (_vm->_screenHeight - _height) / 2, _vm->_screenWidth);
|
||||||
_vm->_system->unlockScreen();
|
_vm->_system->unlockScreen();
|
||||||
|
|
||||||
if ((_bgSoundStream == NULL) || ((int)(_mixer->getSoundElapsedTime(_bgSound) * _framesPerSec) / 1000 < _frameNum + 1) ||
|
if ((_bgSoundStream == NULL) || ((int)(_mixer->getSoundElapsedTime(_bgSound) * getFrameRate()) / 1000 < _frameNum + 1) ||
|
||||||
_frameSkipped > _framesPerSec) {
|
_frameSkipped > getFrameRate()) {
|
||||||
if (_frameSkipped > _framesPerSec) {
|
if (_frameSkipped > getFrameRate()) {
|
||||||
warning("force frame %i redraw", _frameNum);
|
warning("force frame %i redraw", _frameNum);
|
||||||
_frameSkipped = 0;
|
_frameSkipped = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_bgSoundStream && _mixer->isSoundHandleActive(_bgSound)) {
|
if (_bgSoundStream && _mixer->isSoundHandleActive(_bgSound)) {
|
||||||
while (_mixer->isSoundHandleActive(_bgSound) && (_mixer->getSoundElapsedTime(_bgSound) * _framesPerSec) / 1000 < _frameNum) {
|
while (_mixer->isSoundHandleActive(_bgSound) && (_mixer->getSoundElapsedTime(_bgSound) * getFrameRate()) / 1000 < _frameNum) {
|
||||||
_vm->_system->delayMillis(10);
|
_vm->_system->delayMillis(10);
|
||||||
}
|
}
|
||||||
// In case the background sound ends prematurely, update
|
// In case the background sound ends prematurely, update
|
||||||
|
@ -369,7 +369,7 @@ bool MoviePlayerDXA::processFrame() {
|
||||||
// sync case for the subsequent frames.
|
// sync case for the subsequent frames.
|
||||||
_ticks = _vm->_system->getMillis();
|
_ticks = _vm->_system->getMillis();
|
||||||
} else {
|
} else {
|
||||||
_ticks += _frameTicks;
|
_ticks += getFrameDelay();
|
||||||
while (_vm->_system->getMillis() < _ticks)
|
while (_vm->_system->getMillis() < _ticks)
|
||||||
_vm->_system->delayMillis(10);
|
_vm->_system->delayMillis(10);
|
||||||
}
|
}
|
||||||
|
@ -463,7 +463,7 @@ bool MoviePlayerSMK::processFrame() {
|
||||||
copyFrameToBuffer((byte *)screen->pixels, (_vm->_screenWidth - getWidth()) / 2, (_vm->_screenHeight - getHeight()) / 2, _vm->_screenWidth);
|
copyFrameToBuffer((byte *)screen->pixels, (_vm->_screenWidth - getWidth()) / 2, (_vm->_screenHeight - getHeight()) / 2, _vm->_screenWidth);
|
||||||
_vm->_system->unlockScreen();
|
_vm->_system->unlockScreen();
|
||||||
|
|
||||||
if (!getAudioLag() || getAudioLag() > 0 || _frameSkipped > getFrameRate()) {
|
if (!getAudioLag() || getFrameWaitTime() || _frameSkipped > getFrameRate()) {
|
||||||
if (_frameSkipped > getFrameRate()) {
|
if (_frameSkipped > getFrameRate()) {
|
||||||
warning("force frame %i redraw", getCurFrame());
|
warning("force frame %i redraw", getCurFrame());
|
||||||
_frameSkipped = 0;
|
_frameSkipped = 0;
|
||||||
|
|
|
@ -88,6 +88,19 @@ int DXAPlayer::getFrameCount() {
|
||||||
return _framesCount;
|
return _framesCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DXAPlayer::getFrameRate() {
|
||||||
|
if (!_fileStream)
|
||||||
|
return 0;
|
||||||
|
return _framesPerSec;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 DXAPlayer::getFrameDelay() {
|
||||||
|
if (!_fileStream)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return _frameTicks;
|
||||||
|
}
|
||||||
|
|
||||||
bool DXAPlayer::loadFile(const char *fileName) {
|
bool DXAPlayer::loadFile(const char *fileName) {
|
||||||
uint32 tag;
|
uint32 tag;
|
||||||
int32 frameRate;
|
int32 frameRate;
|
||||||
|
|
|
@ -84,6 +84,18 @@ public:
|
||||||
*/
|
*/
|
||||||
int getFrameCount();
|
int getFrameCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the frame rate of the video
|
||||||
|
* @return the frame rate of the video
|
||||||
|
*/
|
||||||
|
int32 getFrameRate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the time to wait for each frame in 1/100 ms
|
||||||
|
* @return the time to wait for each frame in 1/100 ms
|
||||||
|
*/
|
||||||
|
int32 getFrameDelay();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a DXA encoded video file
|
* Load a DXA encoded video file
|
||||||
* @param filename the filename to load
|
* @param filename the filename to load
|
||||||
|
|
|
@ -348,7 +348,13 @@ int32 SMKPlayer::getFrameCount() {
|
||||||
int32 SMKPlayer::getFrameRate() {
|
int32 SMKPlayer::getFrameRate() {
|
||||||
if (!_fileStream)
|
if (!_fileStream)
|
||||||
return 0;
|
return 0;
|
||||||
return _header.frameRate;
|
|
||||||
|
if (_header.frameRate > 0)
|
||||||
|
return 1000 / _header.frameRate;
|
||||||
|
else if (_header.frameRate < 0)
|
||||||
|
return 100000 / (-_header.frameRate);
|
||||||
|
else
|
||||||
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 SMKPlayer::getFrameDelay() {
|
int32 SMKPlayer::getFrameDelay() {
|
||||||
|
|
|
@ -75,9 +75,6 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the frame rate of the video
|
* Returns the frame rate of the video
|
||||||
* If > 0, fps are 1000 / FrameRate
|
|
||||||
* If < 0, fps are 100000 / (-FrameRate)
|
|
||||||
* If 0, fps are 10
|
|
||||||
* @return the frame rate of the video
|
* @return the frame rate of the video
|
||||||
*/
|
*/
|
||||||
int32 getFrameRate();
|
int32 getFrameRate();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue