VIDEO: Prefer Surface::create taking a PixelFormat over the one taking a byte depth.

Certain codecs seem to use a Surface with Bpp 2, but do not have any proper
format description. Whoever is maintaining these should check this commit and
fix the format properly.
This commit is contained in:
Johannes Schickel 2011-04-17 16:35:12 +02:00
parent 2329a00873
commit 5e279996eb
14 changed files with 17 additions and 15 deletions

View file

@ -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);

View file

@ -89,7 +89,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.

View file

@ -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();

View file

@ -53,7 +53,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);

View file

@ -32,7 +32,7 @@ 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;
}

View file

@ -38,7 +38,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;
}

View file

@ -48,7 +48,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) \

View file

@ -44,7 +44,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() {

View file

@ -49,7 +49,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() {

View file

@ -92,7 +92,8 @@ TrueMotion1Decoder::TrueMotion1Decoder(uint16 width, uint16 height) {
_width = width;
_height = height;
_surface->create(width, height, 2);
// TODO: Use correct PixelFormat
_surface->create(width, height, Graphics::PixelFormat(2, 0, 0, 0, 0, 0, 0, 0, 0));
// there is a vertical predictor for each pixel in a line; each vertical
// predictor is 0 to start with

View file

@ -127,7 +127,7 @@ void CoktelDecoder::createSurface() {
return;
if ((_width > 0) && (_height > 0))
_surface.create(_width, _height, getPixelFormat().bytesPerPixel);
_surface.create(_width, _height, getPixelFormat());
_ownSurface = true;
}

View file

@ -79,7 +79,7 @@ bool FlicDecoder::loadStream(Common::SeekableReadStream *stream) {
_offsetFrame2 = _fileStream->readUint32LE();
_surface = new Graphics::Surface();
_surface->create(width, height, 1);
_surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
_palette = (byte *)malloc(3 * 256);
memset(_palette, 0, 3 * 256);
_paletteChanged = false;
@ -226,7 +226,7 @@ const Graphics::Surface *FlicDecoder::decodeNextFrame() {
_surface->free();
delete _surface;
_surface = new Graphics::Surface();
_surface->create(newWidth, newHeight, 1);
_surface->create(newWidth, newHeight, Graphics::PixelFormat::createFormatCLUT8());
}
}
break;

View file

@ -526,7 +526,7 @@ void QuickTimeDecoder::init() {
if (getScaleFactorX() != 1 || getScaleFactorY() != 1) {
// We have to initialize the scaled surface
_scaledSurface = new Graphics::Surface();
_scaledSurface->create(getWidth(), getHeight(), getPixelFormat().bytesPerPixel);
_scaledSurface->create(getWidth(), getHeight(), getPixelFormat());
}
}
}

View file

@ -483,7 +483,7 @@ bool SmackerDecoder::loadStream(Common::SeekableReadStream *stream) {
_surface = new Graphics::Surface();
// Height needs to be doubled if we have flags (Y-interlaced or Y-doubled)
_surface->create(width, height * (_header.flags ? 2 : 1), 1);
_surface->create(width, height * (_header.flags ? 2 : 1), Graphics::PixelFormat::createFormatCLUT8());
memset(_palette, 0, 3 * 256);
return true;