aboutsummaryrefslogtreecommitdiff
path: root/video/coktel_decoder.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2011-04-17 17:25:08 +0200
committerJohannes Schickel2011-04-17 20:55:49 +0200
commitf90bbf9cfad20c6122b98d8b2f99c2cdaa5ce5d6 (patch)
treea570b11c0502999bf2f3b580cd496dc44b0f0478 /video/coktel_decoder.cpp
parent5e279996eb1f448712d1a6b64218a6cf65159a57 (diff)
downloadscummvm-rg350-f90bbf9cfad20c6122b98d8b2f99c2cdaa5ce5d6.tar.gz
scummvm-rg350-f90bbf9cfad20c6122b98d8b2f99c2cdaa5ce5d6.tar.bz2
scummvm-rg350-f90bbf9cfad20c6122b98d8b2f99c2cdaa5ce5d6.zip
VIDEO: Prefer Surface::format over Surface::bytesPerPixel.
Diffstat (limited to 'video/coktel_decoder.cpp')
-rw-r--r--video/coktel_decoder.cpp54
1 files changed, 29 insertions, 25 deletions
diff --git a/video/coktel_decoder.cpp b/video/coktel_decoder.cpp
index 1727fbc7be..bd907baf84 100644
--- a/video/coktel_decoder.cpp
+++ b/video/coktel_decoder.cpp
@@ -92,11 +92,13 @@ void CoktelDecoder::setSurfaceMemory(void *mem, uint16 width, uint16 height, uin
assert(bpp == getPixelFormat().bytesPerPixel);
// Create a surface over this memory
- _surface.w = width;
- _surface.h = height;
- _surface.pitch = width * bpp;
- _surface.pixels = mem;
+ _surface.w = width;
+ _surface.h = height;
+ _surface.pitch = width * bpp;
+ _surface.pixels = mem;
_surface.bytesPerPixel = bpp;
+ // TODO: Check whether it is fine to assume we want the setup PixelFormat.
+ _surface.format = getPixelFormat();
_ownSurface = false;
}
@@ -134,11 +136,12 @@ void CoktelDecoder::createSurface() {
void CoktelDecoder::freeSurface() {
if (!_ownSurface) {
- _surface.w = 0;
- _surface.h = 0;
- _surface.pitch = 0;
- _surface.pixels = 0;
+ _surface.w = 0;
+ _surface.h = 0;
+ _surface.pitch = 0;
+ _surface.pixels = 0;
_surface.bytesPerPixel = 0;
+ _surface.format = Graphics::PixelFormat();
} else
_surface.free();
@@ -449,11 +452,11 @@ void CoktelDecoder::renderBlockWhole(Graphics::Surface &dstSurf, const byte *src
rect.clip(dstSurf.w, dstSurf.h);
- byte *dst = (byte *)dstSurf.pixels + (rect.top * dstSurf.pitch) + rect.left * dstSurf.bytesPerPixel;
+ byte *dst = (byte *)dstSurf.pixels + (rect.top * dstSurf.pitch) + rect.left * dstSurf.format.bytesPerPixel;
for (int i = 0; i < rect.height(); i++) {
- memcpy(dst, src, rect.width() * dstSurf.bytesPerPixel);
+ memcpy(dst, src, rect.width() * dstSurf.format.bytesPerPixel);
- src += srcRect.width() * dstSurf.bytesPerPixel;
+ src += srcRect.width() * dstSurf.format.bytesPerPixel;
dst += dstSurf.pitch;
}
}
@@ -1375,12 +1378,12 @@ bool IMDDecoder::renderFrame(Common::Rect &rect) {
if ((type == 2) && (rect.width() == _surface.w) && (_x == 0)) {
// Directly uncompress onto the video surface
- const int offsetX = rect.left * _surface.bytesPerPixel;
+ const int offsetX = rect.left * _surface.format.bytesPerPixel;
const int offsetY = (_y + rect.top) * _surface.pitch;
const int offset = offsetX + offsetY;
if (deLZ77((byte *)_surface.pixels + offset, dataPtr, dataSize,
- _surface.w * _surface.h * _surface.bytesPerPixel - offset))
+ _surface.w * _surface.h * _surface.format.bytesPerPixel - offset))
return true;
}
@@ -1806,11 +1809,12 @@ bool VMDDecoder::assessVideoProperties() {
_videoBuffer[i] = new byte[_videoBufferSize];
memset(_videoBuffer[i], 0, _videoBufferSize);
- _8bppSurface[i].w = _width * _bytesPerPixel;
- _8bppSurface[i].h = _height;
- _8bppSurface[i].pitch = _width * _bytesPerPixel;
- _8bppSurface[i].pixels = _videoBuffer[i];
+ _8bppSurface[i].w = _width * _bytesPerPixel;
+ _8bppSurface[i].h = _height;
+ _8bppSurface[i].pitch = _width * _bytesPerPixel;
+ _8bppSurface[i].pixels = _videoBuffer[i];
_8bppSurface[i].bytesPerPixel = 1;
+ _8bppSurface[i].format = Graphics::PixelFormat::createFormatCLUT8();
}
}
@@ -2223,12 +2227,12 @@ bool VMDDecoder::renderFrame(Common::Rect &rect) {
if ((type == 2) && (rect.width() == _surface.w) && (_x == 0) && (_blitMode == 0)) {
// Directly uncompress onto the video surface
- const int offsetX = rect.left * _surface.bytesPerPixel;
+ const int offsetX = rect.left * _surface.format.bytesPerPixel;
const int offsetY = (_y + rect.top) * _surface.pitch;
const int offset = offsetX - offsetY;
if (deLZ77((byte *)_surface.pixels + offset, dataPtr, dataSize,
- _surface.w * _surface.h * _surface.bytesPerPixel - offset))
+ _surface.w * _surface.h * _surface.format.bytesPerPixel - offset))
return true;
}
@@ -2338,13 +2342,13 @@ void VMDDecoder::blit16(const Graphics::Surface &srcSurf, Common::Rect &rect) {
const byte *src = (byte *)srcSurf.pixels +
(srcRect.top * srcSurf.pitch) + srcRect.left * _bytesPerPixel;
byte *dst = (byte *)_surface.pixels +
- ((_y + rect.top) * _surface.pitch) + (_x + rect.left) * _surface.bytesPerPixel;
+ ((_y + rect.top) * _surface.pitch) + (_x + rect.left) * _surface.format.bytesPerPixel;
for (int i = 0; i < rect.height(); i++) {
const byte *srcRow = src;
byte *dstRow = dst;
- for (int j = 0; j < rect.width(); j++, srcRow += 2, dstRow += _surface.bytesPerPixel) {
+ for (int j = 0; j < rect.width(); j++, srcRow += 2, dstRow += _surface.format.bytesPerPixel) {
uint16 data = READ_LE_UINT16(srcRow);
byte r = ((data & 0x7C00) >> 10) << 3;
@@ -2355,7 +2359,7 @@ void VMDDecoder::blit16(const Graphics::Surface &srcSurf, Common::Rect &rect) {
if ((r == 0) && (g == 0) && (b == 0))
c = 0;
- if (_surface.bytesPerPixel == 2)
+ if (_surface.format.bytesPerPixel == 2)
*((uint16 *)dstRow) = (uint16) c;
}
@@ -2376,13 +2380,13 @@ void VMDDecoder::blit24(const Graphics::Surface &srcSurf, Common::Rect &rect) {
const byte *src = (byte *)srcSurf.pixels +
(srcRect.top * srcSurf.pitch) + srcRect.left * _bytesPerPixel;
byte *dst = (byte *)_surface.pixels +
- ((_y + rect.top) * _surface.pitch) + (_x + rect.left) * _surface.bytesPerPixel;
+ ((_y + rect.top) * _surface.pitch) + (_x + rect.left) * _surface.format.bytesPerPixel;
for (int i = 0; i < rect.height(); i++) {
const byte *srcRow = src;
byte *dstRow = dst;
- for (int j = 0; j < rect.width(); j++, srcRow += 3, dstRow += _surface.bytesPerPixel) {
+ for (int j = 0; j < rect.width(); j++, srcRow += 3, dstRow += _surface.format.bytesPerPixel) {
byte r = srcRow[2];
byte g = srcRow[1];
byte b = srcRow[0];
@@ -2391,7 +2395,7 @@ void VMDDecoder::blit24(const Graphics::Surface &srcSurf, Common::Rect &rect) {
if ((r == 0) && (g == 0) && (b == 0))
c = 0;
- if (_surface.bytesPerPixel == 2)
+ if (_surface.format.bytesPerPixel == 2)
*((uint16 *)dstRow) = (uint16) c;
}