diff options
Diffstat (limited to 'video/codecs')
-rw-r--r-- | video/codecs/cdtoons.cpp | 22 | ||||
-rw-r--r-- | video/codecs/cinepak.cpp | 8 | ||||
-rw-r--r-- | video/codecs/cinepak.h | 10 | ||||
-rw-r--r-- | video/codecs/indeo3.cpp | 14 | ||||
-rw-r--r-- | video/codecs/mjpeg.cpp | 10 | ||||
-rw-r--r-- | video/codecs/mjpeg.h | 12 | ||||
-rw-r--r-- | video/codecs/msrle.cpp | 3 | ||||
-rw-r--r-- | video/codecs/msvideo1.cpp | 4 | ||||
-rw-r--r-- | video/codecs/qdm2.cpp | 31 | ||||
-rw-r--r-- | video/codecs/qdm2.h | 4 | ||||
-rw-r--r-- | video/codecs/qtrle.cpp | 4 | ||||
-rw-r--r-- | video/codecs/rpza.cpp | 4 | ||||
-rw-r--r-- | video/codecs/smc.cpp | 3 | ||||
-rw-r--r-- | video/codecs/truemotion1.cpp | 10 |
14 files changed, 85 insertions, 54 deletions
diff --git a/video/codecs/cdtoons.cpp b/video/codecs/cdtoons.cpp index eaa8f53602..51e3c23eaa 100644 --- a/video/codecs/cdtoons.cpp +++ b/video/codecs/cdtoons.cpp @@ -24,9 +24,9 @@ */ #include "video/codecs/cdtoons.h" +#include "common/rect.h" #include "common/stream.h" - -#include "common/system.h" +#include "common/textconsole.h" namespace Video { @@ -54,7 +54,7 @@ CDToonsDecoder::CDToonsDecoder(uint16 width, uint16 height) { debugN(5, "CDToons: width %d, height %d\n", width, height); _surface = new Graphics::Surface(); - _surface->create(width, height, 1); + _surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8()); _currentPaletteId = 0; memset(_palette, 0, 256 * 3); @@ -75,7 +75,7 @@ Graphics::Surface *CDToonsDecoder::decodeImage(Common::SeekableReadStream *strea uint16 blocksValidUntil = stream->readUint16BE(); byte u6 = stream->readByte(); byte backgroundColor = stream->readByte(); - debugN(5, "CDToons frame %d, size %d, unknown %04x (at 0), blocks valid until %d, unknown 6 is %02x, bkg colour is %02x\n", + debugN(5, "CDToons frame %d, size %d, unknown %04x (at 0), blocks valid until %d, unknown 6 is %02x, bkg color is %02x\n", frameId, stream->size(), u0, blocksValidUntil, u6, backgroundColor); Common::Rect clipRect = readRect(stream); @@ -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/cinepak.cpp b/video/codecs/cinepak.cpp index 2f5cb73561..2a782dbafe 100644 --- a/video/codecs/cinepak.cpp +++ b/video/codecs/cinepak.cpp @@ -25,7 +25,13 @@ #include "video/codecs/cinepak.h" +#include "common/debug.h" +#include "common/stream.h" #include "common/system.h" +#include "common/textconsole.h" +#include "common/util.h" + +#include "graphics/surface.h" // Code here partially based off of ffmpeg ;) @@ -89,7 +95,7 @@ const Graphics::Surface *CinepakDecoder::decodeImage(Common::SeekableReadStream if (!_curFrame.surface) { _curFrame.surface = new Graphics::Surface(); - _curFrame.surface->create(_curFrame.width, _curFrame.height, _pixelFormat.bytesPerPixel); + _curFrame.surface->create(_curFrame.width, _curFrame.height, _pixelFormat); } // Reset the y variable. diff --git a/video/codecs/cinepak.h b/video/codecs/cinepak.h index 8b4c0216a3..34e4fe98eb 100644 --- a/video/codecs/cinepak.h +++ b/video/codecs/cinepak.h @@ -27,13 +27,19 @@ #define VIDEO_CODECS_CINEPAK_H #include "common/scummsys.h" -#include "common/stream.h" #include "common/rect.h" -#include "graphics/surface.h" #include "graphics/pixelformat.h" #include "video/codecs/codec.h" +namespace Common { +class SeekableReadStream; +} + +namespace Graphics { +struct Surface; +} + namespace Video { struct CinepakCodebook { diff --git a/video/codecs/indeo3.cpp b/video/codecs/indeo3.cpp index d9dde1e8e5..b4f6c6ffe3 100644 --- a/video/codecs/indeo3.cpp +++ b/video/codecs/indeo3.cpp @@ -35,8 +35,8 @@ #include "common/system.h" #include "common/endian.h" -#include "common/frac.h" -#include "common/file.h" +#include "common/stream.h" +#include "common/textconsole.h" #include "graphics/conversion.h" @@ -51,7 +51,7 @@ Indeo3Decoder::Indeo3Decoder(uint16 width, uint16 height) : _ModPred(0), _correc _pixelFormat = g_system->getScreenFormat(); _surface = new Graphics::Surface; - _surface->create(width, height, _pixelFormat.bytesPerPixel); + _surface->create(width, height, _pixelFormat); buildModPred(); allocFrames(); @@ -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; @@ -322,10 +322,10 @@ const Graphics::Surface *Indeo3Decoder::decodeImage(Common::SeekableReadStream * const uint32 color = _pixelFormat.RGBToColor(r, g, b); - for (uint32 sW = 0; sW < scaleWidth; sW++, rowDest += _surface->bytesPerPixel) { - if (_surface->bytesPerPixel == 1) + for (uint32 sW = 0; sW < scaleWidth; sW++, rowDest += _surface->format.bytesPerPixel) { + if (_surface->format.bytesPerPixel == 1) *((uint8 *)rowDest) = (uint8)color; - else if (_surface->bytesPerPixel == 2) + else if (_surface->format.bytesPerPixel == 2) *((uint16 *)rowDest) = (uint16)color; } } diff --git a/video/codecs/mjpeg.cpp b/video/codecs/mjpeg.cpp index d6ec391a84..2ef854039b 100644 --- a/video/codecs/mjpeg.cpp +++ b/video/codecs/mjpeg.cpp @@ -24,10 +24,16 @@ */ #include "common/system.h" -#include "graphics/conversion.h" // For YUV2RGB +#include "common/textconsole.h" +#include "graphics/jpeg.h" +#include "graphics/surface.h" #include "video/codecs/mjpeg.h" +namespace Common { +class SeekableReadStream; +} + namespace Video { JPEGDecoder::JPEGDecoder() : Codec() { @@ -53,7 +59,7 @@ const Graphics::Surface *JPEGDecoder::decodeImage(Common::SeekableReadStream* st if (!_surface) { _surface = new Graphics::Surface(); - _surface->create(_jpeg->getWidth(), _jpeg->getHeight(), _pixelFormat.bytesPerPixel); + _surface->create(_jpeg->getWidth(), _jpeg->getHeight(), _pixelFormat); } Graphics::Surface *frame = _jpeg->getSurface(_pixelFormat); diff --git a/video/codecs/mjpeg.h b/video/codecs/mjpeg.h index c9f931f091..d1395a8248 100644 --- a/video/codecs/mjpeg.h +++ b/video/codecs/mjpeg.h @@ -26,12 +26,18 @@ #ifndef VIDEO_CODECS_MJPEG_H #define VIDEO_CODECS_MJPEG_H -#include "common/scummsys.h" - #include "video/codecs/codec.h" -#include "graphics/jpeg.h" #include "graphics/pixelformat.h" +namespace Common { +class SeekableReadStream; +} + +namespace Graphics { +class JPEG; +struct Surface; +} + namespace Video { // Motion JPEG Decoder diff --git a/video/codecs/msrle.cpp b/video/codecs/msrle.cpp index 46158c49d7..19309bc7aa 100644 --- a/video/codecs/msrle.cpp +++ b/video/codecs/msrle.cpp @@ -27,12 +27,13 @@ #include "video/codecs/msrle.h" #include "common/stream.h" +#include "common/textconsole.h" namespace Video { MSRLEDecoder::MSRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel) { _surface = new Graphics::Surface(); - _surface->create(width, height, 1); + _surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8()); _bitsPerPixel = bitsPerPixel; } diff --git a/video/codecs/msvideo1.cpp b/video/codecs/msvideo1.cpp index 2075d7f013..93e9aaae64 100644 --- a/video/codecs/msvideo1.cpp +++ b/video/codecs/msvideo1.cpp @@ -27,6 +27,7 @@ #include "video/codecs/msvideo1.h" #include "common/stream.h" +#include "common/textconsole.h" namespace Video { @@ -38,7 +39,8 @@ namespace Video { MSVideo1Decoder::MSVideo1Decoder(uint16 width, uint16 height, byte bitsPerPixel) : Codec() { _surface = new Graphics::Surface(); - _surface->create(width, height, (bitsPerPixel == 8) ? 1 : 2); + // TODO: Specify the correct pixel format for 2Bpp mode. + _surface->create(width, height, (bitsPerPixel == 8) ? Graphics::PixelFormat::createFormatCLUT8() : Graphics::PixelFormat(2, 0, 0, 0, 0, 0, 0, 0, 0)); _bitsPerPixel = bitsPerPixel; } diff --git a/video/codecs/qdm2.cpp b/video/codecs/qdm2.cpp index d592548580..8126b57a95 100644 --- a/video/codecs/qdm2.cpp +++ b/video/codecs/qdm2.cpp @@ -34,8 +34,9 @@ #include "video/codecs/qdm2data.h" #include "common/array.h" +#include "common/debug.h" #include "common/stream.h" -#include "common/system.h" +#include "common/textconsole.h" namespace Video { @@ -376,13 +377,7 @@ static inline unsigned int getBits(GetBitContext *s, int n) { } static inline void skipBits(GetBitContext *s, int n) { - int reIndex, reCache; - - reIndex = s->index; - reCache = 0; - - reCache = READ_LE_UINT32((const uint8 *)s->buffer + (reIndex >> 3)) >> (reIndex & 0x07); - s->index = reIndex + n; + s->index += n; } #define BITS_LEFT(length, gb) ((length) - getBitsCount((gb))) @@ -448,7 +443,7 @@ float *ff_cos_tabs[] = { void initCosineTables(int index) { int m = 1 << index; - double freq = 2 * PI / m; + double freq = 2 * M_PI / m; float *tab = ff_cos_tabs[index]; for (int i = 0; i <= m / 4; i++) @@ -776,7 +771,7 @@ int fftInit(FFTContext *s, int nbits, int inverse) { s->tmpBuf = (FFTComplex *)malloc(n * sizeof(FFTComplex)); } else { for (i = 0; i < n / 2; i++) { - alpha = 2 * PI * (float)i / (float)n; + alpha = 2 * M_PI * (float)i / (float)n; c1 = cos(alpha); s1 = sin(alpha) * s2; s->exptab[i].re = c1; @@ -814,7 +809,7 @@ int fftInit(FFTContext *s, int nbits, int inverse) { */ int rdftInit(RDFTContext *s, int nbits, RDFTransformType trans) { int n = 1 << nbits; - const double theta = (trans == RDFT || trans == IRIDFT ? -1 : 1) * 2 * PI / n; + const double theta = (trans == RDFT || trans == IRIDFT ? -1 : 1) * 2 * M_PI / n; s->nbits = nbits; s->inverse = trans == IRDFT || trans == IRIDFT; @@ -1775,14 +1770,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(); @@ -1792,7 +1787,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) @@ -1824,7 +1819,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) @@ -3009,7 +3004,7 @@ void QDM2Stream::qdm2_fft_generate_tone(FFTTone *tone) float level, f[6]; int i; QDM2Complex c; - const double iscale = 2.0 * PI / 512.0; + const double iscale = 2.0 * M_PI / 512.0; tone->phase += tone->phase_shift; @@ -3050,7 +3045,7 @@ void QDM2Stream::qdm2_fft_generate_tone(FFTTone *tone) void QDM2Stream::qdm2_fft_tone_synthesizer(uint8 sub_packet) { int i, j, ch; - const double iscale = 0.25 * PI; + const double iscale = 0.25 * M_PI; for (ch = 0; ch < _channels; ch++) { memset(_fft.complex[ch], 0, _frameSize * sizeof(QDM2Complex)); diff --git a/video/codecs/qdm2.h b/video/codecs/qdm2.h index a6acf3a83e..b224e801a6 100644 --- a/video/codecs/qdm2.h +++ b/video/codecs/qdm2.h @@ -30,11 +30,11 @@ #define VIDEO_CODECS_QDM2_H namespace Common { - class SeekableReadStream; +class SeekableReadStream; } namespace Audio { - class AudioStream; +class AudioStream; } namespace Video { diff --git a/video/codecs/qtrle.cpp b/video/codecs/qtrle.cpp index 26b2f02ce1..0ae27f6284 100644 --- a/video/codecs/qtrle.cpp +++ b/video/codecs/qtrle.cpp @@ -28,9 +28,11 @@ #include "video/codecs/qtrle.h" +#include "common/debug.h" #include "common/scummsys.h" #include "common/stream.h" #include "common/system.h" +#include "common/textconsole.h" #include "graphics/colormasks.h" #include "graphics/surface.h" @@ -48,7 +50,7 @@ QTRLEDecoder::QTRLEDecoder(uint16 width, uint16 height, byte bitsPerPixel) : Cod debug(2, "QTRLE corrected width: %d", width); _surface = new Graphics::Surface(); - _surface->create(width, height, _bitsPerPixel <= 8 ? 1 : _pixelFormat.bytesPerPixel); + _surface->create(width, height, _bitsPerPixel <= 8 ? Graphics::PixelFormat::createFormatCLUT8() : _pixelFormat); } #define CHECK_STREAM_PTR(n) \ diff --git a/video/codecs/rpza.cpp b/video/codecs/rpza.cpp index cc9739b673..0c06661c50 100644 --- a/video/codecs/rpza.cpp +++ b/video/codecs/rpza.cpp @@ -27,8 +27,10 @@ #include "video/codecs/rpza.h" +#include "common/debug.h" #include "common/system.h" #include "common/stream.h" +#include "common/textconsole.h" #include "graphics/colormasks.h" namespace Video { @@ -44,7 +46,7 @@ RPZADecoder::RPZADecoder(uint16 width, uint16 height) : Codec() { debug(2, "RPZA corrected width: %d", width); _surface = new Graphics::Surface(); - _surface->create(width, height, _pixelFormat.bytesPerPixel); + _surface->create(width, height, _pixelFormat); } RPZADecoder::~RPZADecoder() { diff --git a/video/codecs/smc.cpp b/video/codecs/smc.cpp index d03c60490f..bbd6073497 100644 --- a/video/codecs/smc.cpp +++ b/video/codecs/smc.cpp @@ -27,6 +27,7 @@ #include "video/codecs/smc.h" #include "common/stream.h" +#include "common/textconsole.h" namespace Video { @@ -49,7 +50,7 @@ namespace Video { SMCDecoder::SMCDecoder(uint16 width, uint16 height) { _surface = new Graphics::Surface(); - _surface->create(width, height, 1); + _surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8()); } SMCDecoder::~SMCDecoder() { diff --git a/video/codecs/truemotion1.cpp b/video/codecs/truemotion1.cpp index a0456869ab..b7d1f406d7 100644 --- a/video/codecs/truemotion1.cpp +++ b/video/codecs/truemotion1.cpp @@ -32,6 +32,8 @@ #include "video/codecs/truemotion1data.h" #include "common/stream.h" +#include "common/textconsole.h" +#include "common/util.h" namespace Video { @@ -58,12 +60,14 @@ enum { }; // { valid for metatype }, algorithm, num of deltas, vert res, horiz res -struct { +struct CompressionType { int algorithm; int blockWidth; // vres int blockHeight; // hres int blockType; -} static const compressionTypes[17] = { +}; + +static const CompressionType compressionTypes[17] = { { ALGO_NOP, 0, 0, 0 }, { ALGO_RGB16V, 4, 4, BLOCK_4x4 }, @@ -92,7 +96,7 @@ TrueMotion1Decoder::TrueMotion1Decoder(uint16 width, uint16 height) { _width = width; _height = height; - _surface->create(width, height, 2); + _surface->create(width, height, getPixelFormat()); // there is a vertical predictor for each pixel in a line; each vertical // predictor is 0 to start with |