OGRE-Next  3.0.0
Object-Oriented Graphics Rendering Engine
Ogre::Codec Class Referenceabstract

Abstract class that defines a 'codec'. More...

#include <OgreCodec.h>

+ Inheritance diagram for Ogre::Codec:

Classes

class  CodecData
 

Public Types

typedef SharedPtr< CodecDataCodecDataPtr
 
typedef ConstMapIterator< CodecList > CodecIterator
 
typedef std::pair< MemoryDataStreamPtr, CodecDataPtrDecodeResult
 Result of a decoding; both a decoded data stream and CodecData metadata. More...
 
enum  ValidationStatus { CodecValid , CodecInvalid , CodecUnknown }
 

Public Member Functions

virtual ~Codec ()
 
virtual DecodeResult decode (DataStreamPtr &input) const =0
 Codes the data from the input chunk into the output chunk. More...
 
virtual DataStreamPtr encode (MemoryDataStreamPtr &input, CodecDataPtr &pData) const =0
 Codes the data in the input stream and saves the result in the output stream. More...
 
virtual void encodeToFile (MemoryDataStreamPtr &input, const String &outFileName, CodecDataPtr &pData) const =0
 Codes the data in the input chunk and saves the result in the output filename provided. More...
 
virtual String getDataType () const =0
 Returns the type of the data that supported by this codec as a String. More...
 
virtual String getType () const =0
 Returns the type of the codec as a String. More...
 
virtual bool magicNumberMatch (const char *magicNumberPtr, size_t maxbytes) const
 Returns whether a magic number header matches this codec. More...
 
virtual String magicNumberToFileExt (const char *magicNumberPtr, size_t maxbytes) const =0
 Maps a magic number header to a file extension, if this codec recognises it. More...
 
virtual ValidationStatus validateMagicNumber (const char *magicNumberPtr, size_t maxbytes) const =0
 validateMagicNumber Returns whether a magic number header matches this codec. More...
 

Static Public Member Functions

static CodecgetCodec (char *magicNumberPtr, size_t maxbytes)
 Gets the codec that can handle the given 'magic' identifier. More...
 
static CodecgetCodec (const String &extension)
 Gets the codec registered for the passed in file extension. More...
 
static CodecIterator getCodecIterator ()
 Gets the iterator for the registered codecs. More...
 
static StringVector getExtensions ()
 Gets the file extension list for the registered codecs. More...
 
static bool isCodecRegistered (const String &codecType)
 Return whether a codec is registered already. More...
 
static void registerCodec (Codec *pCodec)
 Registers a new codec in the database. More...
 
static void unregisterCodec (Codec *pCodec)
 Unregisters a codec from the database. More...
 

Detailed Description

Abstract class that defines a 'codec'.

Remarks
A codec class works like a two-way filter for data - data entered on one end (the decode end) gets processed and transformed into easily usable data while data passed the other way around codes it back.
The codec concept is a pretty generic one - you can easily understand how it can be used for images, sounds, archives, even compressed data.

Member Typedef Documentation

◆ CodecDataPtr

◆ CodecIterator

◆ DecodeResult

Result of a decoding; both a decoded data stream and CodecData metadata.

Member Enumeration Documentation

◆ ValidationStatus

Enumerator
CodecValid 
CodecInvalid 

Magic number says this codec can open this stream.

CodecUnknown 

Magic number says this codec cannot open this stream.

Cannot be verified. File may or may not open.

Constructor & Destructor Documentation

◆ ~Codec()

virtual Ogre::Codec::~Codec ( )
virtual

Member Function Documentation

◆ decode()

virtual DecodeResult Ogre::Codec::decode ( DataStreamPtr input) const
pure virtual

Codes the data from the input chunk into the output chunk.

Parameters
inputStream containing the encoded data

Implemented in Ogre::STBIImageCodec, Ogre::PVRTCCodec, Ogre::OITDCodec, Ogre::FreeImageCodec2, Ogre::ETCCodec, Ogre::DDSCodec2, and Ogre::ASTCCodec.

◆ encode()

virtual DataStreamPtr Ogre::Codec::encode ( MemoryDataStreamPtr input,
CodecDataPtr pData 
) const
pure virtual

Codes the data in the input stream and saves the result in the output stream.

Implemented in Ogre::STBIImageCodec, Ogre::PVRTCCodec, Ogre::OITDCodec, Ogre::FreeImageCodec2, Ogre::ETCCodec, Ogre::DDSCodec2, and Ogre::ASTCCodec.

◆ encodeToFile()

virtual void Ogre::Codec::encodeToFile ( MemoryDataStreamPtr input,
const String outFileName,
CodecDataPtr pData 
) const
pure virtual

Codes the data in the input chunk and saves the result in the output filename provided.

Provided for efficiency since coding to memory is progressive therefore memory required is unknown leading to reallocations.

Parameters
inputThe input data
outFileNameThe filename to write to
pDataExtra information to be passed to the codec (codec type specific)

Implemented in Ogre::STBIImageCodec, Ogre::PVRTCCodec, Ogre::OITDCodec, Ogre::FreeImageCodec2, Ogre::ETCCodec, Ogre::DDSCodec2, and Ogre::ASTCCodec.

◆ getCodec() [1/2]

static Codec* Ogre::Codec::getCodec ( char *  magicNumberPtr,
size_t  maxbytes 
)
static

Gets the codec that can handle the given 'magic' identifier.

Parameters
magicNumberPtrPointer to a stream of bytes which should identify the file. Note that this may be more than needed - each codec may be looking for a different size magic number.
maxbytesThe number of bytes passed

◆ getCodec() [2/2]

static Codec* Ogre::Codec::getCodec ( const String extension)
static

Gets the codec registered for the passed in file extension.

◆ getCodecIterator()

static CodecIterator Ogre::Codec::getCodecIterator ( )
inlinestatic

Gets the iterator for the registered codecs.

◆ getDataType()

virtual String Ogre::Codec::getDataType ( ) const
pure virtual

Returns the type of the data that supported by this codec as a String.

Implemented in Ogre::ImageCodec2.

◆ getExtensions()

static StringVector Ogre::Codec::getExtensions ( )
static

Gets the file extension list for the registered codecs.

◆ getType()

virtual String Ogre::Codec::getType ( ) const
pure virtual

Returns the type of the codec as a String.

Implemented in Ogre::STBIImageCodec, Ogre::PVRTCCodec, Ogre::OITDCodec, Ogre::FreeImageCodec2, Ogre::ETCCodec, Ogre::DDSCodec2, and Ogre::ASTCCodec.

Referenced by registerCodec(), and unregisterCodec().

◆ isCodecRegistered()

static bool Ogre::Codec::isCodecRegistered ( const String codecType)
inlinestatic

Return whether a codec is registered already.

◆ magicNumberMatch()

virtual bool Ogre::Codec::magicNumberMatch ( const char *  magicNumberPtr,
size_t  maxbytes 
) const
inlinevirtual

Returns whether a magic number header matches this codec.

Parameters
magicNumberPtrPointer to a stream of bytes which should identify the file. Note that this may be more than needed - each codec may be looking for a different size magic number.
Remarks
Deprecated. Use validateMagicNumber()
Parameters
maxbytesThe number of bytes passed

◆ magicNumberToFileExt()

virtual String Ogre::Codec::magicNumberToFileExt ( const char *  magicNumberPtr,
size_t  maxbytes 
) const
pure virtual

Maps a magic number header to a file extension, if this codec recognises it.

Parameters
magicNumberPtrPointer to a stream of bytes which should identify the file. Note that this may be more than needed - each codec may be looking for a different size magic number.
maxbytesThe number of bytes passed
Returns
A blank string if the magic number was unknown, or a file extension.

Implemented in Ogre::STBIImageCodec, Ogre::PVRTCCodec, Ogre::OITDCodec, Ogre::FreeImageCodec2, Ogre::ETCCodec, Ogre::DDSCodec2, and Ogre::ASTCCodec.

◆ registerCodec()

static void Ogre::Codec::registerCodec ( Codec pCodec)
inlinestatic

Registers a new codec in the database.

References Ogre::Exception::ERR_DUPLICATE_ITEM, getType(), and OGRE_EXCEPT.

◆ unregisterCodec()

static void Ogre::Codec::unregisterCodec ( Codec pCodec)
inlinestatic

Unregisters a codec from the database.

References getType().

◆ validateMagicNumber()

virtual ValidationStatus Ogre::Codec::validateMagicNumber ( const char *  magicNumberPtr,
size_t  maxbytes 
) const
pure virtual

validateMagicNumber Returns whether a magic number header matches this codec.

At least 4 bytes must be supplied.

Parameters
magicNumberPtrPointer to a stream of bytes which should identify the file. Note that this may be more than needed - each codec may be looking for a different size magic number.
maxbytesThe number of bytes passed
Returns
Validation status.

Implemented in Ogre::STBIImageCodec, Ogre::PVRTCCodec, Ogre::OITDCodec, Ogre::FreeImageCodec2, Ogre::ETCCodec, Ogre::DDSCodec2, and Ogre::ASTCCodec.


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