diff options
author | RichieSams | 2013-09-29 18:04:53 -0500 |
---|---|---|
committer | RichieSams | 2013-09-29 18:04:53 -0500 |
commit | 49d67caa31583478b1b58df19b5739f42d5a4573 (patch) | |
tree | faa9ee3e3e9346eedccaf44bbfeb054164223e0a /graphics/decoders/jpeg.h | |
parent | 07c32312146bb7fe5adec41f03a2463893756361 (diff) | |
parent | 1c3202794ad71e59e9496b94ac51f102f8210b54 (diff) | |
download | scummvm-rg350-49d67caa31583478b1b58df19b5739f42d5a4573.tar.gz scummvm-rg350-49d67caa31583478b1b58df19b5739f42d5a4573.tar.bz2 scummvm-rg350-49d67caa31583478b1b58df19b5739f42d5a4573.zip |
Merge branch 'master' into zvision
Diffstat (limited to 'graphics/decoders/jpeg.h')
-rw-r--r-- | graphics/decoders/jpeg.h | 124 |
1 files changed, 39 insertions, 85 deletions
diff --git a/graphics/decoders/jpeg.h b/graphics/decoders/jpeg.h index d59b72adf4..8460bc2698 100644 --- a/graphics/decoders/jpeg.h +++ b/graphics/decoders/jpeg.h @@ -40,100 +40,54 @@ class SeekableReadStream; namespace Graphics { -struct PixelFormat; - -#define JPEG_MAX_QUANT_TABLES 4 -#define JPEG_MAX_HUFF_TABLES 2 - class JPEGDecoder : public ImageDecoder { public: JPEGDecoder(); ~JPEGDecoder(); // ImageDecoder API - void destroy(); - bool loadStream(Common::SeekableReadStream &str); - const Surface *getSurface() const; - - bool isLoaded() const { return _numComp && _w && _h; } - uint16 getWidth() const { return _w; } - uint16 getHeight() const { return _h; } - const Surface *getComponent(uint c) const; - -private: - Common::SeekableReadStream *_stream; - uint16 _w, _h; - uint16 _restartInterval; - - // mutable so that we can convert to RGB only during - // a getSurface() call while still upholding the - // const requirement in other ImageDecoders - mutable Graphics::Surface *_rgbSurface; - - // Image components - uint8 _numComp; - struct Component { - // Global values - uint8 id; - uint8 factorH; - uint8 factorV; - uint8 quantTableSelector; - - // Scan specific values - uint8 DCentropyTableSelector; - uint8 ACentropyTableSelector; - int16 DCpredictor; - - // Result image for this component - Surface surface; + virtual void destroy(); + virtual bool loadStream(Common::SeekableReadStream &str); + virtual const Surface *getSurface() const; + + // Special API for JPEG + enum ColorSpace { + /** + * Output 32bit RGBA data. + * + * This is the default output. + */ + kColorSpaceRGBA, + + /** + * Output (interleaved) YUV data. + * + * Be aware that some images cannot be output in YUV mode. + * These are (non-standard) JPEG images which are in RGB colorspace. + * + * The resulting Surface will have a PixelFormat with 3 bytes per + * pixel and the remaining entries are completely zeroed. This works + * around the fact that PixelFormat can only describe RGB formats. + * + * You should only use this when you are really aware of what you are + * doing! + */ + kColorSpaceYUV }; - Component *_components; + /** + * Request the output color space. This can be used to obtain raw YUV + * data from the JPEG file. But this might not work for all files! + * + * The decoder itself defaults to RGBA. + * + * @param outSpace The color space to output. + */ + void setOutputColorSpace(ColorSpace outSpace) { _colorSpace = outSpace; } - // Scan components - uint8 _numScanComp; - Component **_scanComp; - Component *_currentComp; - - // Maximum sampling factors, used to calculate the interleaving of the MCU - uint8 _maxFactorV; - uint8 _maxFactorH; - - // Quantization tables - uint16 *_quant[JPEG_MAX_QUANT_TABLES]; - - // Huffman tables - struct HuffmanTable { - uint8 count; - uint8 *values; - uint8 *sizes; - uint16 *codes; - } _huff[2 * JPEG_MAX_HUFF_TABLES]; - - // Marker read functions - bool readJFIF(); - bool readSOF0(); - bool readDHT(); - bool readSOS(); - bool readDQT(); - bool readDRI(); - - // Helper functions - bool readMCU(uint16 xMCU, uint16 yMCU); - bool readDataUnit(uint16 x, uint16 y); - int16 readDC(); - void readAC(int16 *out); - int16 readSignedBits(uint8 numBits); - - // Huffman decoding - uint8 readHuff(uint8 table); - uint8 readBit(); - uint8 _bitsData; - uint8 _bitsNumber; - - // Inverse Discrete Cosine Transformation - static void idct1D8x8(int32 src[8], int32 dest[64], int32 ps, int32 half); - static void idct2D8x8(int32 block[64]); +private: + Graphics::Surface _surface; + ColorSpace _colorSpace; }; } // End of Graphics namespace |