Worldstone
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
WorldStone::DCC Class Reference

Decoder for the DCC image format. More...

#include <dcc.h>

Classes

struct  Direction
 
struct  DirectionHeader
 Represents a direction header. More...
 
struct  FrameHeader
 
struct  Header
 The header of the file, contains global information about the encoded image. More...
 

Public Member Functions

bool initDecoder (StreamPtr &&streamPtr)
 Start decoding the stream and preparing data. More...
 
void reset ()
 Resets the decoder and frees resources.
 
bool readDirection (Direction &outDir, uint32_t dirIndex, IImageProvider< uint8_t > &imgProvider)
 Decodes a direction of the file into memory. More...
 
const HeadergetHeader () const
 Returns the header of the file read by extractHeaderAndOffsets.
 

Static Public Attributes

static constexpr unsigned bitsWidthTable [16]
 An array that maps an encoded 4-bit size to the real size in bits. More...
 

Protected Member Functions

size_t getDirectionSize (uint32_t dirIndex)
 
bool extractHeaderAndOffsets ()
 

Protected Attributes

StreamPtr stream = nullptr
 
Header header
 
Vector< uint32_t > directionsOffsets
 Offset of each direction header in the file, follows the Header. More...
 
Vector< uint32_t > framePointers
 

Detailed Description

Decoder for the DCC image format.

The DCC format is a compressed sprite image format. It can store multiple directions and frames in a single file. A palette is used to generate the colors, but the file itself doesn't have any information about the palette to use, it is up to the user to know which one to use.

See Also
WorldStone::Palette

This format is usually used with COF files, which describe the animations and blending of multiple DCC files.

Layout of a DCC file:

Name Type Size in Bytes Offsets
header DCC::Header 15 0x00
directionsOffsets uint32_t[dirs] 4 * header.directions 0x0F
First Direction DCC::Direction directionsOffsets[1] - directionsOffsets[0] directionsOffsets[0]
***
Last Direction DCC::Direction filesize - directionsOffsets[directions-1] directionsOffsets[directions-1]

Direction layout:

Name Type Size
dirHeader[0] DCC::DirectionHeader 32 + 30 bits
frameHeader[0] DCC::FrameHeader Based on the DirectionHeader values
***
frameHeader[framesPerDir-1] DCC::FrameHeader Based on the DirectionHeader values
align (unused) Align to byte if any frame has additionnal data
Frame 0 additionnal data byte[] frameHeader[0].optionalBytes
***
Last frame additionnal data byte[] frameHeader[framesPerDir-1].optionalBytes
equalCellsBitStreamSize uint20_t 20 bits (only if compressEqualCells is true)
pixelMaskBitStreamSize uint20_t 20 bits
encodingTypeBitsreamSize uint20_t 20 bits (only if hasRawPixelEncoding is true)
rawPixelCodesBitStreamSize uint20_t 20 bits (only if hasRawPixelEncoding is true)
codeToPixelValue bitset<256> 256 bits
equalCellBitStream BitStream equalCellsBitStreamSize
pixelMaskBitStream BitStream pixelMaskBitStreamSize
rawPixelUsageBitStream BitStream encodingTypeBitsreamSize
rawPixelCodesBitStream BitStream rawPixelCodesBitStreamSize
pixelCodesDisplacementBitStream BitStream Until end of the direction
Tests:

DCC_BaalSpirit

DCC_CRHDBRVDTHTH

DCC_BloodSmall01

DCC_HZTRLITA1HTH

Definition at line 46 of file dcc.h.

Member Function Documentation

bool WorldStone::DCC::initDecoder ( StreamPtr &&  streamPtr)

Start decoding the stream and preparing data.

Returns
true on success

Prepares the decoder to read the frames using readDirection. Basically calls extractHeaderAndOffsets, so that you can call getHeader.

Definition at line 44 of file dcc.cpp.

bool WorldStone::DCC::readDirection ( Direction outDir,
uint32_t  dirIndex,
IImageProvider< uint8_t > &  imgProvider 
)

Decodes a direction of the file into memory.

Parameters
outDirWill hold the Direction information obtained during decoding.
dirIndexThe number of the direction in the file.
imgProviderThe image provider to be used when allocating frames data.
Returns
true on success

Use getHeader and the Header::directions member to know how many directions are in the file. The frames will be allocated+decoded in order, hence using the images allocated using the image provider will be in the order of the file.

Definition at line 618 of file dcc.cpp.

Member Data Documentation

constexpr unsigned WorldStone::DCC::bitsWidthTable
static
Initial value:
= {0, 1, 2, 4, 6, 8, 10, 12,
14, 16, 20, 24, 26, 28, 30, 32}

An array that maps an encoded 4-bit size to the real size in bits.

The values are { 0, 1, 2, 4, 6, 8, 10, 12, 14, 16, 20, 24, 26, 28, 30, 32 }

Definition at line 160 of file dcc.h.

Vector<uint32_t> WorldStone::DCC::directionsOffsets
protected

Offset of each direction header in the file, follows the Header.

Actually holds directions+1 values, the last one being the size of the file It lets us compute the size of a direction by substracting the next offset by the current one.

Definition at line 171 of file dcc.h.


The documentation for this class was generated from the following files: