diff options
author | Matthew Hoops | 2011-05-17 18:05:40 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-05-18 10:05:13 -0400 |
commit | 0addffbfd3952f766e7f839c210465c9c34b94bd (patch) | |
tree | 57946b9b2e22a3f62786d7152a73cd7b10d45ae0 /engines/sword25/fmv | |
parent | f559741bfc0024b772724201b7e764441fee13c2 (diff) | |
download | scummvm-rg350-0addffbfd3952f766e7f839c210465c9c34b94bd.tar.gz scummvm-rg350-0addffbfd3952f766e7f839c210465c9c34b94bd.tar.bz2 scummvm-rg350-0addffbfd3952f766e7f839c210465c9c34b94bd.zip |
GRAPHICS: Add a YUV to RGB table lookup for use with Theora
Based on the video/mpeg_player.* one, which is based on lots of other things (too many to name, go see the file)
Diffstat (limited to 'engines/sword25/fmv')
-rw-r--r-- | engines/sword25/fmv/theora_decoder.cpp | 48 |
1 files changed, 3 insertions, 45 deletions
diff --git a/engines/sword25/fmv/theora_decoder.cpp b/engines/sword25/fmv/theora_decoder.cpp index 4f5a006770..9aa7ead385 100644 --- a/engines/sword25/fmv/theora_decoder.cpp +++ b/engines/sword25/fmv/theora_decoder.cpp @@ -39,7 +39,8 @@ #ifdef USE_THEORADEC #include "common/system.h" #include "common/textconsole.h" -#include "graphics/conversion.h" +#include "common/util.h" +#include "graphics/yuv_to_rgb.h" #include "audio/decoders/raw.h" #include "sword25/kernel/common.h" @@ -508,16 +509,6 @@ uint32 TheoraDecoder::getElapsedTime() const { return VideoDecoder::getElapsedTime(); } -static void convertYUVtoBGRA(int y, int u, int v, byte *dst, Graphics::PixelFormat format) { - byte r, g, b; - Graphics::YUV2RGB(y, u, v, r, g, b); - - if (format.bytesPerPixel == 2) - *((uint16 *)dst) = format.RGBToColor(r, g, b); - else - *((uint32 *)dst) = format.RGBToColor(r, g, b); -} - enum TheoraYUVBuffers { kBufferY = 0, kBufferU = 1, @@ -537,40 +528,7 @@ void TheoraDecoder::translateYUVtoRGBA(th_ycbcr_buffer &YUVBuffer) { assert(YUVBuffer[kBufferU].height == YUVBuffer[kBufferY].height >> 1); assert(YUVBuffer[kBufferV].height == YUVBuffer[kBufferY].height >> 1); - const byte *ySrc = YUVBuffer[kBufferY].data; - const byte *uSrc = YUVBuffer[kBufferU].data; - const byte *vSrc = YUVBuffer[kBufferV].data; - byte *dst = (byte *)_surface->pixels; - int u = 0, v = 0; - - const int blockSize = YUVBuffer[kBufferY].width * getPixelFormat().bytesPerPixel; - const int halfHeight = YUVBuffer[kBufferY].height >> 1; - const int halfWidth = YUVBuffer[kBufferY].width >> 1; - const int yStep = (YUVBuffer[kBufferY].stride << 1) - YUVBuffer[kBufferY].width; - // The UV step is usually 0, since in most cases stride == width. - // The asserts at the top ensure that the U and V steps are equal - // (and they must always be equal) - const int uvStep = YUVBuffer[kBufferU].stride - YUVBuffer[kBufferU].width; - const int stride = YUVBuffer[kBufferY].stride; - - for (int h = 0; h < halfHeight; ++h) { - for (int w = 0; w < halfWidth; ++w) { - u = *uSrc++; - v = *vSrc++; - - for (int i = 0; i <= 1; i++) { - convertYUVtoBGRA(*ySrc, u, v, dst, getPixelFormat()); - convertYUVtoBGRA(*(ySrc + stride), u, v, dst + blockSize, getPixelFormat()); - ySrc++; - dst += 4; // BGRA - } - } - - dst += blockSize; - ySrc += yStep; - uSrc += uvStep; - vSrc += uvStep; - } + Graphics::convertYUV420ToRGB(_surface, YUVBuffer[kBufferY].data, YUVBuffer[kBufferU].data, YUVBuffer[kBufferV].data, YUVBuffer[kBufferY].width, YUVBuffer[kBufferY].height, YUVBuffer[kBufferY].stride, YUVBuffer[kBufferU].stride); } } // End of namespace Sword25 |