From 0ce2ca4e006a70d787481040fa844c85aac43222 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 12 Apr 2011 16:53:15 +0200 Subject: COMMON: Replace MKID_BE by MKTAG MKID_BE relied on unspecified behavior of the C++ compiler, and as such was always a bit unsafe. The new MKTAG macro is slightly less elegant, but does no longer depend on the behavior of the compiler. Inspired by FFmpeg, which has an almost identical macro. --- video/avi_decoder.h | 54 ++++++++++++------------ video/codecs/cdtoons.cpp | 14 +++---- video/codecs/indeo3.cpp | 2 +- video/codecs/qdm2.cpp | 10 ++--- video/coktel_decoder.cpp | 2 +- video/dxa_decoder.cpp | 8 ++-- video/qt_decoder.cpp | 104 +++++++++++++++++++++++------------------------ video/smk_decoder.cpp | 6 +-- 8 files changed, 100 insertions(+), 100 deletions(-) (limited to 'video') diff --git a/video/avi_decoder.h b/video/avi_decoder.h index c2551454db..33189910c7 100644 --- a/video/avi_decoder.h +++ b/video/avi_decoder.h @@ -37,35 +37,35 @@ namespace Video { // IDs used throughout the AVI files // that will be handled by this player -#define ID_RIFF MKID_BE('RIFF') -#define ID_AVI MKID_BE('AVI ') -#define ID_LIST MKID_BE('LIST') -#define ID_HDRL MKID_BE('hdrl') -#define ID_AVIH MKID_BE('avih') -#define ID_STRL MKID_BE('strl') -#define ID_STRH MKID_BE('strh') -#define ID_VIDS MKID_BE('vids') -#define ID_AUDS MKID_BE('auds') -#define ID_MIDS MKID_BE('mids') -#define ID_TXTS MKID_BE('txts') -#define ID_JUNK MKID_BE('JUNK') -#define ID_STRF MKID_BE('strf') -#define ID_MOVI MKID_BE('movi') -#define ID_REC MKID_BE('rec ') -#define ID_VEDT MKID_BE('vedt') -#define ID_IDX1 MKID_BE('idx1') -#define ID_STRD MKID_BE('strd') -#define ID_00AM MKID_BE('00AM') -//#define ID_INFO MKID_BE('INFO') +#define ID_RIFF MKTAG('R','I','F','F') +#define ID_AVI MKTAG('A','V','I',' ') +#define ID_LIST MKTAG('L','I','S','T') +#define ID_HDRL MKTAG('h','d','r','l') +#define ID_AVIH MKTAG('a','v','i','h') +#define ID_STRL MKTAG('s','t','r','l') +#define ID_STRH MKTAG('s','t','r','h') +#define ID_VIDS MKTAG('v','i','d','s') +#define ID_AUDS MKTAG('a','u','d','s') +#define ID_MIDS MKTAG('m','i','d','s') +#define ID_TXTS MKTAG('t','x','t','s') +#define ID_JUNK MKTAG('J','U','N','K') +#define ID_STRF MKTAG('s','t','r','f') +#define ID_MOVI MKTAG('m','o','v','i') +#define ID_REC MKTAG('r','e','c',' ') +#define ID_VEDT MKTAG('v','e','d','t') +#define ID_IDX1 MKTAG('i','d','x','1') +#define ID_STRD MKTAG('s','t','r','d') +#define ID_00AM MKTAG('0','0','A','M') +//#define ID_INFO MKTAG('I','N','F','O') // Codec tags -#define ID_RLE MKID_BE('RLE ') -#define ID_CRAM MKID_BE('CRAM') -#define ID_MSVC MKID_BE('msvc') -#define ID_WHAM MKID_BE('WHAM') -#define ID_CVID MKID_BE('cvid') -#define ID_IV32 MKID_BE('iv32') -#define ID_DUCK MKID_BE('DUCK') +#define ID_RLE MKTAG('R','L','E',' ') +#define ID_CRAM MKTAG('C','R','A','M') +#define ID_MSVC MKTAG('m','s','v','c') +#define ID_WHAM MKTAG('W','H','A','M') +#define ID_CVID MKTAG('c','v','i','d') +#define ID_IV32 MKTAG('i','v','3','2') +#define ID_DUCK MKTAG('D','U','C','K') struct BITMAPINFOHEADER { uint32 size; diff --git a/video/codecs/cdtoons.cpp b/video/codecs/cdtoons.cpp index eaa8f53602..bdca5f9c80 100644 --- a/video/codecs/cdtoons.cpp +++ b/video/codecs/cdtoons.cpp @@ -170,7 +170,7 @@ Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *strea nextPos += size; switch (tag) { - case MKID_BE('Diff'): + case MKTAG('D','i','f','f'): { debugN(5, "CDToons: Diff\n"); uint16 count = stream->readUint16BE(); @@ -206,7 +206,7 @@ Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *strea } } break; - case MKID_BE('XFrm'): + case MKTAG('X','F','r','m'): { debugN(5, "CDToons: XFrm\n"); if (!(flags & 0x10)) @@ -229,7 +229,7 @@ Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *strea dirtyRect2XFrm.left, dirtyRect2XFrm.top, dirtyRect2XFrm.right, dirtyRect2XFrm.bottom); } break; - case MKID_BE('Mrks'): + case MKTAG('M','r','k','s'): debugN(5, "CDToons: Mrks\n"); if (!(flags & 0x2)) error("CDToons: useless Mrks?"); @@ -237,14 +237,14 @@ Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *strea // TODO warning("CDToons: encountered Mrks, not implemented yet"); break; - case MKID_BE('Scal'): + case MKTAG('S','c','a','l'): // TODO warning("CDToons: encountered Scal, not implemented yet"); break; - case MKID_BE('WrMp'): + case MKTAG('W','r','M','p'): warning("CDToons: encountered WrMp, ignoring"); break; - case MKID_BE('FrtR'): + case MKTAG('F','r','t','R'): { debugN(5, "CDToons: FrtR\n"); if (!(flags & 0x40)) @@ -259,7 +259,7 @@ Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *strea } } break; - case MKID_BE('BckR'): + case MKTAG('B','c','k','R'): { debugN(5, "CDToons: BckR\n"); if (!(flags & 0x20)) diff --git a/video/codecs/indeo3.cpp b/video/codecs/indeo3.cpp index d9dde1e8e5..e7f470bd3a 100644 --- a/video/codecs/indeo3.cpp +++ b/video/codecs/indeo3.cpp @@ -85,7 +85,7 @@ bool Indeo3Decoder::isIndeo3(Common::SeekableReadStream &stream) { return false; // These 4 uint32s XOR'd need to spell "FRMH" - if ((id0 ^ id1 ^ id2 ^ id3) != MKID_BE('FRMH')) + if ((id0 ^ id1 ^ id2 ^ id3) != MKTAG('F','R','M','H')) return false; return true; diff --git a/video/codecs/qdm2.cpp b/video/codecs/qdm2.cpp index 762f56b3d7..61e59c8aba 100644 --- a/video/codecs/qdm2.cpp +++ b/video/codecs/qdm2.cpp @@ -1769,14 +1769,14 @@ QDM2Stream::QDM2Stream(Common::SeekableReadStream *stream, Common::SeekableReadS tmp = extraData->readUint32BE(); debug(1, "QDM2Stream::QDM2Stream() extraTag: %d", tmp); - if (tmp != MKID_BE('frma')) + if (tmp != MKTAG('f','r','m','a')) warning("QDM2Stream::QDM2Stream() extraTag mismatch"); tmp = extraData->readUint32BE(); debug(1, "QDM2Stream::QDM2Stream() extraType: %d", tmp); - if (tmp == MKID_BE('QDMC')) + if (tmp == MKTAG('Q','D','M','C')) warning("QDM2Stream::QDM2Stream() QDMC stream type not supported"); - else if (tmp != MKID_BE('QDM2')) + else if (tmp != MKTAG('Q','D','M','2')) error("QDM2Stream::QDM2Stream() Unsupported stream type"); tmp_s = extraData->readSint32BE(); @@ -1786,7 +1786,7 @@ QDM2Stream::QDM2Stream(Common::SeekableReadStream *stream, Common::SeekableReadS tmp = extraData->readUint32BE(); debug(1, "QDM2Stream::QDM2Stream() extraTag2: %d", tmp); - if (tmp != MKID_BE('QDCA')) + if (tmp != MKTAG('Q','D','C','A')) warning("QDM2Stream::QDM2Stream() extraTag2 mismatch"); if (extraData->readUint32BE() != 1) @@ -1818,7 +1818,7 @@ QDM2Stream::QDM2Stream(Common::SeekableReadStream *stream, Common::SeekableReadS tmp = extraData->readUint32BE(); debug(1, "QDM2Stream::QDM2Stream() extraTag3: %d", tmp); - if (tmp != MKID_BE('QDCP')) + if (tmp != MKTAG('Q','D','C','P')) warning("QDM2Stream::QDM2Stream() extraTag3 mismatch"); if ((float)extraData->readUint32BE() != 1.0) diff --git a/video/coktel_decoder.cpp b/video/coktel_decoder.cpp index b2d64bfb3c..a755d18bb0 100644 --- a/video/coktel_decoder.cpp +++ b/video/coktel_decoder.cpp @@ -36,7 +36,7 @@ #include "audio/decoders/raw.h" #include "common/memstream.h" -static const uint32 kVideoCodecIndeo3 = MKID_BE('iv32'); +static const uint32 kVideoCodecIndeo3 = MKTAG('i','v','3','2'); namespace Video { diff --git a/video/dxa_decoder.cpp b/video/dxa_decoder.cpp index 62c2622437..a64b8f6fee 100644 --- a/video/dxa_decoder.cpp +++ b/video/dxa_decoder.cpp @@ -73,7 +73,7 @@ bool DXADecoder::loadStream(Common::SeekableReadStream *stream) { _fileStream = stream; uint32 tag = _fileStream->readUint32BE(); - assert(tag == MKID_BE('DEXA')); + assert(tag == MKTAG('D','E','X','A')); uint8 flags = _fileStream->readByte(); _frameCount = _fileStream->readUint16BE(); @@ -136,7 +136,7 @@ bool DXADecoder::loadStream(Common::SeekableReadStream *stream) { switch (tag) { case 0: // No more tags break; - case MKID_BE('MAXD'): + case MKTAG('M','A','X','D'): assert(size == 4); _decompBufferSize = _fileStream->readUint32BE(); break; @@ -479,13 +479,13 @@ void DXADecoder::decode13(int size) { const Graphics::Surface *DXADecoder::decodeNextFrame() { uint32 tag = _fileStream->readUint32BE(); - if (tag == MKID_BE('CMAP')) { + if (tag == MKTAG('C','M','A','P')) { _fileStream->read(_palette, 256 * 3); _dirtyPalette = true; } tag = _fileStream->readUint32BE(); - if (tag == MKID_BE('FRAM')) { + if (tag == MKTAG('F','R','A','M')) { byte type = _fileStream->readByte(); uint32 size = _fileStream->readUint32BE(); if ((_inBuffer == NULL) || (_inBufferSize < size)) { diff --git a/video/qt_decoder.cpp b/video/qt_decoder.cpp index a277d6bbde..826b7bfcaf 100644 --- a/video/qt_decoder.cpp +++ b/video/qt_decoder.cpp @@ -267,28 +267,28 @@ void QuickTimeDecoder::seekToTime(Audio::Timestamp time) { } Codec *QuickTimeDecoder::createCodec(uint32 codecTag, byte bitsPerPixel) { - if (codecTag == MKID_BE('cvid')) { + if (codecTag == MKTAG('c','v','i','d')) { // Cinepak: As used by most Myst and all Riven videos as well as some Myst ME videos. "The Chief" videos also use this. return new CinepakDecoder(bitsPerPixel); - } else if (codecTag == MKID_BE('rpza')) { + } else if (codecTag == MKTAG('r','p','z','a')) { // Apple Video ("Road Pizza"): Used by some Myst videos. return new RPZADecoder(getWidth(), getHeight()); - } else if (codecTag == MKID_BE('rle ')) { + } else if (codecTag == MKTAG('r','l','e',' ')) { // QuickTime RLE: Used by some Myst ME videos. return new QTRLEDecoder(getWidth(), getHeight(), bitsPerPixel); - } else if (codecTag == MKID_BE('smc ')) { + } else if (codecTag == MKTAG('s','m','c',' ')) { // Apple SMC: Used by some Myst videos. return new SMCDecoder(getWidth(), getHeight()); - } else if (codecTag == MKID_BE('SVQ1')) { + } else if (codecTag == MKTAG('S','V','Q','1')) { // Sorenson Video 1: Used by some Myst ME videos. warning("Sorenson Video 1 not yet supported"); - } else if (codecTag == MKID_BE('SVQ3')) { + } else if (codecTag == MKTAG('S','V','Q','3')) { // Sorenson Video 3: Used by some Myst ME videos. warning("Sorenson Video 3 not yet supported"); - } else if (codecTag == MKID_BE('jpeg')) { + } else if (codecTag == MKTAG('j','p','e','g')) { // Motion JPEG: Used by some Myst ME 10th Anniversary videos. return new JPEGDecoder(); - } else if (codecTag == MKID_BE('QkBk')) { + } else if (codecTag == MKTAG('Q','k','B','k')) { // CDToons: Used by most of the Broderbund games. return new CDToonsDecoder(getWidth(), getHeight()); } else { @@ -424,10 +424,10 @@ bool QuickTimeDecoder::loadFile(const Common::String &filename) { if (_resFork->hasResFork()) { // Search for a 'moov' resource - Common::MacResIDArray idArray = _resFork->getResIDArray(MKID_BE('moov')); + Common::MacResIDArray idArray = _resFork->getResIDArray(MKTAG('m','o','o','v')); if (!idArray.empty()) - _fd = _resFork->getResource(MKID_BE('moov'), idArray[0]); + _fd = _resFork->getResource(MKTAG('m','o','o','v'), idArray[0]); if (_fd) { atom.size = _fd->size(); @@ -507,7 +507,7 @@ void QuickTimeDecoder::init() { _curAudioChunk = 0; // Make sure the bits per sample transfers to the sample size - if (entry->codecTag == MKID_BE('raw ') || entry->codecTag == MKID_BE('twos')) + if (entry->codecTag == MKTAG('r','a','w',' ') || entry->codecTag == MKTAG('t','w','o','s')) _streams[_audioStreamIndex]->sample_size = (entry->bitsPerSample / 8) * entry->channels; startAudio(); @@ -533,31 +533,31 @@ void QuickTimeDecoder::init() { void QuickTimeDecoder::initParseTable() { static const ParseTable p[] = { - { &QuickTimeDecoder::readDefault, MKID_BE('dinf') }, - { &QuickTimeDecoder::readLeaf, MKID_BE('dref') }, - { &QuickTimeDecoder::readDefault, MKID_BE('edts') }, - { &QuickTimeDecoder::readELST, MKID_BE('elst') }, - { &QuickTimeDecoder::readHDLR, MKID_BE('hdlr') }, - { &QuickTimeDecoder::readDefault, MKID_BE('mdat') }, - { &QuickTimeDecoder::readMDHD, MKID_BE('mdhd') }, - { &QuickTimeDecoder::readDefault, MKID_BE('mdia') }, - { &QuickTimeDecoder::readDefault, MKID_BE('minf') }, - { &QuickTimeDecoder::readMOOV, MKID_BE('moov') }, - { &QuickTimeDecoder::readMVHD, MKID_BE('mvhd') }, - { &QuickTimeDecoder::readLeaf, MKID_BE('smhd') }, - { &QuickTimeDecoder::readDefault, MKID_BE('stbl') }, - { &QuickTimeDecoder::readSTCO, MKID_BE('stco') }, - { &QuickTimeDecoder::readSTSC, MKID_BE('stsc') }, - { &QuickTimeDecoder::readSTSD, MKID_BE('stsd') }, - { &QuickTimeDecoder::readSTSS, MKID_BE('stss') }, - { &QuickTimeDecoder::readSTSZ, MKID_BE('stsz') }, - { &QuickTimeDecoder::readSTTS, MKID_BE('stts') }, - { &QuickTimeDecoder::readTKHD, MKID_BE('tkhd') }, - { &QuickTimeDecoder::readTRAK, MKID_BE('trak') }, - { &QuickTimeDecoder::readLeaf, MKID_BE('udta') }, - { &QuickTimeDecoder::readLeaf, MKID_BE('vmhd') }, - { &QuickTimeDecoder::readCMOV, MKID_BE('cmov') }, - { &QuickTimeDecoder::readWAVE, MKID_BE('wave') }, + { &QuickTimeDecoder::readDefault, MKTAG('d','i','n','f') }, + { &QuickTimeDecoder::readLeaf, MKTAG('d','r','e','f') }, + { &QuickTimeDecoder::readDefault, MKTAG('e','d','t','s') }, + { &QuickTimeDecoder::readELST, MKTAG('e','l','s','t') }, + { &QuickTimeDecoder::readHDLR, MKTAG('h','d','l','r') }, + { &QuickTimeDecoder::readDefault, MKTAG('m','d','a','t') }, + { &QuickTimeDecoder::readMDHD, MKTAG('m','d','h','d') }, + { &QuickTimeDecoder::readDefault, MKTAG('m','d','i','a') }, + { &QuickTimeDecoder::readDefault, MKTAG('m','i','n','f') }, + { &QuickTimeDecoder::readMOOV, MKTAG('m','o','o','v') }, + { &QuickTimeDecoder::readMVHD, MKTAG('m','v','h','d') }, + { &QuickTimeDecoder::readLeaf, MKTAG('s','m','h','d') }, + { &QuickTimeDecoder::readDefault, MKTAG('s','t','b','l') }, + { &QuickTimeDecoder::readSTCO, MKTAG('s','t','c','o') }, + { &QuickTimeDecoder::readSTSC, MKTAG('s','t','s','c') }, + { &QuickTimeDecoder::readSTSD, MKTAG('s','t','s','d') }, + { &QuickTimeDecoder::readSTSS, MKTAG('s','t','s','s') }, + { &QuickTimeDecoder::readSTSZ, MKTAG('s','t','s','z') }, + { &QuickTimeDecoder::readSTTS, MKTAG('s','t','t','s') }, + { &QuickTimeDecoder::readTKHD, MKTAG('t','k','h','d') }, + { &QuickTimeDecoder::readTRAK, MKTAG('t','r','a','k') }, + { &QuickTimeDecoder::readLeaf, MKTAG('u','d','t','a') }, + { &QuickTimeDecoder::readLeaf, MKTAG('v','m','h','d') }, + { &QuickTimeDecoder::readCMOV, MKTAG('c','m','o','v') }, + { &QuickTimeDecoder::readWAVE, MKTAG('w','a','v','e') }, { 0, 0 } }; @@ -581,7 +581,7 @@ int QuickTimeDecoder::readDefault(MOVatom atom) { // Some QuickTime videos with resource forks have mdat chunks // that are of size 0. Adjust it so it's the correct size. - if (a.type == MKID_BE('mdat') && a.size == 0) + if (a.type == MKTAG('m','d','a','t') && a.size == 0) a.size = _fd->size(); } @@ -654,16 +654,16 @@ int QuickTimeDecoder::readCMOV(MOVatom atom) { #ifdef USE_ZLIB // Read in the dcom atom _fd->readUint32BE(); - if (_fd->readUint32BE() != MKID_BE('dcom')) + if (_fd->readUint32BE() != MKTAG('d','c','o','m')) return -1; - if (_fd->readUint32BE() != MKID_BE('zlib')) { + if (_fd->readUint32BE() != MKTAG('z','l','i','b')) { warning("Unknown cmov compression type"); return -1; } // Read in the cmvd atom uint32 compressedSize = _fd->readUint32BE() - 12; - if (_fd->readUint32BE() != MKID_BE('cmvd')) + if (_fd->readUint32BE() != MKTAG('c','m','v','d')) return -1; uint32 uncompressedSize = _fd->readUint32BE(); @@ -688,7 +688,7 @@ int QuickTimeDecoder::readCMOV(MOVatom atom) { _fd = new Common::MemoryReadStream(uncompressedData, uncompressedSize, DisposeAfterUse::YES); // Read the contents of the uncompressed data - MOVatom a = { MKID_BE('moov'), 0, uncompressedSize }; + MOVatom a = { MKTAG('m','o','o','v'), 0, uncompressedSize }; int err = readDefault(a); // Assign the file handle back to the original handle @@ -857,16 +857,16 @@ int QuickTimeDecoder::readHDLR(MOVatom atom) { debug(0, "ctype= %s (0x%08lx)", tag2str(ctype), (long)ctype); debug(0, "stype= %s", tag2str(type)); - if(ctype == MKID_BE('mhlr')) // MOV + if(ctype == MKTAG('m','h','l','r')) // MOV debug(0, "MOV detected"); else if(ctype == 0) { warning("MP4 streams are not supported"); return -1; } - if (type == MKID_BE('vide')) + if (type == MKTAG('v','i','d','e')) st->codec_type = CODEC_TYPE_VIDEO; - else if (type == MKID_BE('soun')) + else if (type == MKTAG('s','o','u','n')) st->codec_type = CODEC_TYPE_AUDIO; _fd->readUint32BE(); // component manufacture @@ -1058,7 +1058,7 @@ int QuickTimeDecoder::readSTSD(MOVatom atom) { // Version 0 videos (such as the Riven ones) don't have this set, // but we need it later on. Add it in here. - if (format == MKID_BE('ima4')) { + if (format == MKTAG('i','m','a','4')) { entry->samplesPerFrame = 64; entry->bytesPerFrame = 34 * entry->channels; } @@ -1231,7 +1231,7 @@ int QuickTimeDecoder::readWAVE(MOVatom atom) { if (atom.size > (1 << 30)) return -1; - if (st->stsdEntries[0].codecTag == MKID_BE('QDM2')) // Read extradata for QDM2 + if (st->stsdEntries[0].codecTag == MKTAG('Q','D','M','2')) // Read extradata for QDM2 st->extradata = _fd->readStream(atom.size - 8); else if (atom.size > 8) return readDefault(atom); @@ -1318,11 +1318,11 @@ Common::SeekableReadStream *QuickTimeDecoder::getNextFramePacket(uint32 &descId) bool QuickTimeDecoder::checkAudioCodecSupport(uint32 tag) { // Check if the codec is a supported codec - if (tag == MKID_BE('twos') || tag == MKID_BE('raw ') || tag == MKID_BE('ima4')) + if (tag == MKTAG('t','w','o','s') || tag == MKTAG('r','a','w',' ') || tag == MKTAG('i','m','a','4')) return true; #ifdef VIDEO_CODECS_QDM2_H - if (tag == MKID_BE('QDM2')) + if (tag == MKTAG('Q','D','M','2')) return true; #endif @@ -1337,10 +1337,10 @@ Audio::AudioStream *QuickTimeDecoder::createAudioStream(Common::SeekableReadStre STSDEntry *entry = &_streams[_audioStreamIndex]->stsdEntries[0]; - if (entry->codecTag == MKID_BE('twos') || entry->codecTag == MKID_BE('raw ')) { + if (entry->codecTag == MKTAG('t','w','o','s') || entry->codecTag == MKTAG('r','a','w',' ')) { // Fortunately, most of the audio used in Myst videos is raw... uint16 flags = 0; - if (entry->codecTag == MKID_BE('raw ')) + if (entry->codecTag == MKTAG('r','a','w',' ')) flags |= Audio::FLAG_UNSIGNED; if (entry->channels == 2) flags |= Audio::FLAG_STEREO; @@ -1351,11 +1351,11 @@ Audio::AudioStream *QuickTimeDecoder::createAudioStream(Common::SeekableReadStre stream->read(data, dataSize); delete stream; return Audio::makeRawStream(data, dataSize, entry->sampleRate, flags); - } else if (entry->codecTag == MKID_BE('ima4')) { + } else if (entry->codecTag == MKTAG('i','m','a','4')) { // Riven uses this codec (as do some Myst ME videos) return Audio::makeADPCMStream(stream, DisposeAfterUse::YES, stream->size(), Audio::kADPCMApple, entry->sampleRate, entry->channels, 34); #ifdef VIDEO_CODECS_QDM2_H - } else if (entry->codecTag == MKID_BE('QDM2')) { + } else if (entry->codecTag == MKTAG('Q','D','M','2')) { // Several Myst ME videos use this codec return makeQDM2Stream(stream, _streams[_audioStreamIndex]->extradata); #endif diff --git a/video/smk_decoder.cpp b/video/smk_decoder.cpp index a9f2eeeb5b..760d0045d9 100644 --- a/video/smk_decoder.cpp +++ b/video/smk_decoder.cpp @@ -379,13 +379,13 @@ bool SmackerDecoder::loadStream(Common::SeekableReadStream *stream) { _header.signature = _fileStream->readUint32BE(); // No BINK support available - if (_header.signature == MKID_BE('BIKi')) { + if (_header.signature == MKTAG('B','I','K','i')) { delete _fileStream; _fileStream = 0; return false; } - assert(_header.signature == MKID_BE('SMK2') || _header.signature == MKID_BE('SMK4')); + assert(_header.signature == MKTAG('S','M','K','2') || _header.signature == MKTAG('S','M','K','4')); uint32 width = _fileStream->readUint32LE(); uint32 height = _fileStream->readUint32LE(); @@ -615,7 +615,7 @@ const Graphics::Surface *SmackerDecoder::decodeNextFrame() { break; case SMK_BLOCK_FULL: // Smacker v2 has one mode, Smacker v4 has three - if (_header.signature == MKID_BE('SMK2')) { + if (_header.signature == MKTAG('S','M','K','2')) { mode = 0; } else { // 00 - mode 0 -- cgit v1.2.3 From 8f70e089ac721176fb543b88f00b4c97ac945b14 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 13 Apr 2011 12:48:37 +0200 Subject: VIDEO: Use shared ADPCM data tables in VMDDecoder --- video/coktel_decoder.cpp | 27 ++++----------------------- video/coktel_decoder.h | 2 -- 2 files changed, 4 insertions(+), 25 deletions(-) (limited to 'video') diff --git a/video/coktel_decoder.cpp b/video/coktel_decoder.cpp index a755d18bb0..0ab12e91cc 100644 --- a/video/coktel_decoder.cpp +++ b/video/coktel_decoder.cpp @@ -34,6 +34,7 @@ #include "audio/audiostream.h" #include "audio/decoders/raw.h" +#include "audio/decoders/adpcm_intern.h" #include "common/memstream.h" static const uint32 kVideoCodecIndeo3 = MKTAG('i','v','3','2'); @@ -1516,26 +1517,6 @@ const uint16 VMDDecoder::_tableDPCM[128] = { 0x0F00, 0x1000, 0x1400, 0x1800, 0x1C00, 0x2000, 0x3000, 0x4000 }; -const int32 VMDDecoder::_tableADPCM[] = { - 7, 8, 9, 10, 11, 12, 13, 14, - 16, 17, 19, 21, 23, 25, 28, 31, - 34, 37, 41, 45, 50, 55, 60, 66, - 73, 80, 88, 97, 107, 118, 130, 143, - 157, 173, 190, 209, 230, 253, 279, 307, - 337, 371, 408, 449, 494, 544, 598, 658, - 724, 796, 876, 963, 1060, 1166, 1282, 1411, - 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, - 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, - 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, - 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, - 32767, 0 -}; - -const int32 VMDDecoder::_tableADPCMStep[] = { - -1, -1, -1, -1, 2, 4, 6, 8, - -1, -1, -1, -1, 2, 4, 6, 8 -}; - VMDDecoder::VMDDecoder(Audio::Mixer *mixer, Audio::Mixer::SoundType soundType) : CoktelDecoder(mixer, soundType), _stream(0), _version(0), _flags(0), _frameInfoOffset(0), _partsPerFrame(0), _frames(0), _soundFlags(0), _soundFreq(0), _soundSliceSize(0), _soundSlicesCount(0), @@ -2617,7 +2598,7 @@ byte *VMDDecoder::deADPCM(const byte *data, uint32 &size, int32 init, int32 inde index = CLIP(index, 0, 88); - int32 predictor = _tableADPCM[index]; + int32 predictor = Audio::Ima_ADPCMStream::_imaTable[index]; uint32 dataByte = 0; bool newByte = true; @@ -2634,7 +2615,7 @@ byte *VMDDecoder::deADPCM(const byte *data, uint32 &size, int32 init, int32 inde newByte = !newByte; - index += _tableADPCMStep[code]; + index += Audio::ADPCMStream::_stepAdjustTable[code]; index = CLIP(index, 0, 88); int32 value = predictor / 8; @@ -2653,7 +2634,7 @@ byte *VMDDecoder::deADPCM(const byte *data, uint32 &size, int32 init, int32 inde init = CLIP(init, -32768, 32767); - predictor = _tableADPCM[index]; + predictor = Audio::Ima_ADPCMStream::_imaTable[index]; *out++ = TO_BE_16(init); } diff --git a/video/coktel_decoder.h b/video/coktel_decoder.h index 9c8263be9d..e83e1d29ed 100644 --- a/video/coktel_decoder.h +++ b/video/coktel_decoder.h @@ -431,8 +431,6 @@ private: // Tables for the audio decompressors static const uint16 _tableDPCM[128]; - static const int32 _tableADPCM[]; - static const int32 _tableADPCMStep[]; Common::SeekableReadStream *_stream; -- cgit v1.2.3