[Scummvm-cvs-logs] SF.net SVN: scummvm:[53896] scummvm/branches/branch-1-2-0/graphics/video/ smk_decoder.cpp
athrxx at users.sourceforge.net
athrxx at users.sourceforge.net
Thu Oct 28 01:11:16 CEST 2010
Revision: 53896
http://scummvm.svn.sourceforge.net/scummvm/?rev=53896&view=rev
Author: athrxx
Date: 2010-10-27 23:11:15 +0000 (Wed, 27 Oct 2010)
Log Message:
-----------
VIDEO: partly revert last commit (fix compilation)
Modified Paths:
--------------
scummvm/branches/branch-1-2-0/graphics/video/smk_decoder.cpp
Modified: scummvm/branches/branch-1-2-0/graphics/video/smk_decoder.cpp
===================================================================
--- scummvm/branches/branch-1-2-0/graphics/video/smk_decoder.cpp 2010-10-27 22:52:02 UTC (rev 53895)
+++ scummvm/branches/branch-1-2-0/graphics/video/smk_decoder.cpp 2010-10-27 23:11:15 UTC (rev 53896)
@@ -392,13 +392,12 @@
_frameCount = _fileStream->readUint32LE();
int32 frameRate = _fileStream->readSint32LE();
- // framerate contains 2 digits after the comma, so 1497 is actually 14.97 fps
if (frameRate > 0)
_frameRate = Common::Rational(1000, frameRate);
else if (frameRate < 0)
_frameRate = Common::Rational(100000, -frameRate);
else
- _frameRate = 1000;
+ _frameRate = 10;
// Flags are determined by which bit is set, which can be one of the following:
// 0 - set to 1 if file contains a ring frame.
@@ -544,18 +543,53 @@
chunkSize = _fileStream->readUint32LE();
chunkSize -= 4; // subtract the first 4 bytes (chunk size)
- if (_header.audioInfo[i].compression == kCompressionNone) {
- dataSizeUnpacked = chunkSize;
- } else {
+ if (_header.audioInfo[i].compression != kCompressionNone) {
dataSizeUnpacked = _fileStream->readUint32LE();
chunkSize -= 4; // subtract the next 4 bytes (unpacked data size)
+ } else {
+ dataSizeUnpacked = 0;
}
- handleAudioTrack(i, chunkSize, dataSizeUnpacked);
+ if (_header.audioInfo[i].hasAudio && chunkSize > 0 && i == 0) {
+ // If it's track 0, play the audio data
+ byte *soundBuffer = (byte *)malloc(chunkSize);
+
+ _fileStream->read(soundBuffer, chunkSize);
+
+ if (_header.audioInfo[i].compression == kCompressionRDFT || _header.audioInfo[i].compression == kCompressionDCT) {
+ // TODO: Compressed audio (Bink RDFT/DCT encoded)
+ free(soundBuffer);
+ continue;
+ } else if (_header.audioInfo[i].compression == kCompressionDPCM) {
+ // Compressed audio (Huffman DPCM encoded)
+ queueCompressedBuffer(soundBuffer, chunkSize, dataSizeUnpacked, i);
+ free(soundBuffer);
+ } else {
+ // Uncompressed audio (PCM)
+ byte flags = 0;
+ if (_header.audioInfo[0].is16Bits)
+ flags = flags | Audio::FLAG_16BITS;
+ if (_header.audioInfo[0].isStereo)
+ flags = flags | Audio::FLAG_STEREO;
+
+ _audioStream->queueBuffer(soundBuffer, chunkSize, DisposeAfterUse::YES, flags);
+ // The sound buffer will be deleted by QueuingAudioStream
+ }
+
+ if (!_audioStarted) {
+ _mixer->playStream(_soundType, &_audioHandle, _audioStream, -1, 255);
+ _audioStarted = true;
+ }
+ } else {
+ // Ignore the rest of the audio tracks, if they exist
+ // TODO: Are there any Smacker videos with more than one audio stream?
+ // If yes, we should play the rest of the audio streams as well
+ if (chunkSize > 0)
+ _fileStream->skip(chunkSize);
+ }
}
uint32 frameSize = _frameSizes[_curFrame] & ~3;
-// uint32 remainder = _frameSizes[_curFrame] & 3;
if (_fileStream->pos() - startPos > frameSize)
error("Smacker actual frame size exceeds recorded frame size");
@@ -715,46 +749,6 @@
return _surface;
}
-void SmackerDecoder::handleAudioTrack(byte track, uint32 chunkSize, uint32 unpackedSize) {
- if (_header.audioInfo[track].hasAudio && chunkSize > 0 && track == 0) {
- // If it's track 0, play the audio data
- byte *soundBuffer = (byte *)malloc(chunkSize);
-
- _fileStream->read(soundBuffer, chunkSize);
-
- if (_header.audioInfo[track].compression == kCompressionRDFT || _header.audioInfo[track].compression == kCompressionDCT) {
- // TODO: Compressed audio (Bink RDFT/DCT encoded)
- free(soundBuffer);
- return;
- } else if (_header.audioInfo[track].compression == kCompressionDPCM) {
- // Compressed audio (Huffman DPCM encoded)
- queueCompressedBuffer(soundBuffer, chunkSize, unpackedSize, track);
- free(soundBuffer);
- } else {
- // Uncompressed audio (PCM)
- byte flags = 0;
- if (_header.audioInfo[track].is16Bits)
- flags = flags | Audio::FLAG_16BITS;
- if (_header.audioInfo[track].isStereo)
- flags = flags | Audio::FLAG_STEREO;
-
- _audioStream->queueBuffer(soundBuffer, chunkSize, DisposeAfterUse::YES, flags);
- // The sound buffer will be deleted by QueuingAudioStream
- }
-
- if (!_audioStarted) {
- _mixer->playStream(_soundType, &_audioHandle, _audioStream, -1, 255);
- _audioStarted = true;
- }
- } else {
- // Ignore the rest of the audio tracks, if they exist
- // TODO: Are there any Smacker videos with more than one audio stream?
- // If yes, we should play the rest of the audio streams as well
- if (chunkSize > 0)
- _fileStream->skip(chunkSize);
- }
-}
-
void SmackerDecoder::queueCompressedBuffer(byte *buffer, uint32 bufferSize,
uint32 unpackedSize, int streamNum) {
@@ -828,7 +822,7 @@
byte hi = audioTrees[k * 2 + 1]->getCode(audioBS);
bases[k] += (int16) (lo | (hi << 8));
- WRITE_BE_UINT16(curPointer, bases[k]);
+ WRITE_BE_UINT16(curPointer, CLIP<int32>(bases[k], -32768, 32767));
curPointer += 2;
curPos += 2;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list