-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from ossimlabs/OCS-2451
Ocs 2451
- Loading branch information
Showing
5 changed files
with
255 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
//---------------------------------------------------------------------------- | ||
// | ||
// License: LGPL | ||
// | ||
// See LICENSE.txt file in the top level directory for more details. | ||
// | ||
// Author: David Burken | ||
// | ||
// Description: Factory class definition for codec(encoder/decoder). | ||
// | ||
//---------------------------------------------------------------------------- | ||
// $Id$ | ||
|
||
#include "ossimKakaduCodecFactory.h" | ||
#include <ossim/base/ossimKeywordlist.h> | ||
#include <ossim/base/ossimKeywordNames.h> | ||
#include <ossim/base/ossimRefPtr.h> | ||
#include <ossim/base/ossimString.h> | ||
|
||
#include "ossimKakaduJ2kCodec.h" | ||
|
||
#include <string> | ||
|
||
ossimKakaduCodecFactory* ossimKakaduCodecFactory::theInstance = 0; | ||
|
||
static const std::string TYPE_KW = "type"; | ||
|
||
ossimKakaduCodecFactory::~ossimKakaduCodecFactory() | ||
{} | ||
|
||
ossimKakaduCodecFactory* ossimKakaduCodecFactory::instance() | ||
{ | ||
if ( !theInstance ) | ||
{ | ||
theInstance = new ossimKakaduCodecFactory(); | ||
} | ||
return theInstance; | ||
} | ||
ossimCodecBase* ossimKakaduCodecFactory::createCodec(const ossimString& type)const | ||
{ | ||
ossimRefPtr<ossimCodecBase> result; | ||
|
||
if((type.downcase() == "c8") ) | ||
{ | ||
result = new ossimKakaduJ2kCodec(); | ||
} | ||
|
||
return result.release(); | ||
} | ||
|
||
ossimCodecBase* ossimKakaduCodecFactory::createCodec(const ossimKeywordlist& kwl, const char* prefix)const | ||
{ | ||
ossimString type = kwl.find(prefix, ossimKeywordNames::TYPE_KW); | ||
ossimCodecBase* result = 0; | ||
if(!type.empty()) | ||
{ | ||
result = this->createCodec(type); | ||
if(result) | ||
{ | ||
result->loadState(kwl, prefix); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
void ossimKakaduCodecFactory::getTypeNameList(std::vector<ossimString>& typeNames)const | ||
{ | ||
typeNames.push_back("C8"); | ||
} | ||
|
||
ossimKakaduCodecFactory::ossimKakaduCodecFactory() | ||
{} | ||
|
||
ossimKakaduCodecFactory::ossimKakaduCodecFactory(const ossimKakaduCodecFactory& /* obj */ ) | ||
{} | ||
|
||
const ossimKakaduCodecFactory& ossimKakaduCodecFactory::operator=( | ||
const ossimKakaduCodecFactory& /* rhs */) | ||
{ | ||
return *this; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
//---------------------------------------------------------------------------- | ||
// | ||
// License: MIT | ||
// | ||
// See LICENSE.txt file in the top level directory for more details. | ||
// | ||
// Author: Garrett Potts | ||
// | ||
// Description: Factory class declaration for codec(encoder/decoder). | ||
// | ||
//---------------------------------------------------------------------------- | ||
// $Id$ | ||
#ifndef ossimKakaduCodecFactory_HEADER | ||
#define ossimKakaduCodecFactory_HEADER 1 | ||
|
||
#include <ossim/base/ossimConstants.h> | ||
#include <ossim/imaging/ossimCodecFactoryInterface.h> | ||
|
||
class ossimFilename; | ||
class ossimCodecBase; | ||
|
||
/** | ||
* @brief Codec factory. | ||
*/ | ||
class OSSIM_DLL ossimKakaduCodecFactory : public ossimCodecFactoryInterface | ||
{ | ||
public: | ||
|
||
/** virtual destructor */ | ||
virtual ~ossimKakaduCodecFactory(); | ||
|
||
/** | ||
* @return instance | ||
*/ | ||
static ossimKakaduCodecFactory* instance(); | ||
|
||
/** | ||
* createCodec takes a type and will return a new codec to encode decode image buffers | ||
* | ||
* @param in type. Type identifer used to allocate the proper codec. | ||
* @return ossimCodecBase type. | ||
*/ | ||
virtual ossimCodecBase* createCodec(const ossimString& type)const; | ||
|
||
|
||
/** | ||
* createCodec takes a type in the keywordlist and will return a new codec to encode decode image buffers | ||
* | ||
* @param in kwl. Type identifer used to allocate the proper codec. | ||
* @param in prefix. prefix used to prefix keywords during the construction | ||
* of the codec | ||
* @return ossimCodecBase type. | ||
*/ | ||
virtual ossimCodecBase* createCodec(const ossimKeywordlist& kwl, const char* prefix=0)const; | ||
|
||
virtual void getTypeNameList(std::vector<ossimString>& typeNames)const; | ||
|
||
private: | ||
|
||
/** hidden from use default constructor */ | ||
ossimKakaduCodecFactory(); | ||
|
||
/** hidden from use copy constructor */ | ||
ossimKakaduCodecFactory(const ossimKakaduCodecFactory& obj); | ||
|
||
/** hidden from use operator = */ | ||
const ossimKakaduCodecFactory& operator=(const ossimKakaduCodecFactory& rhs); | ||
|
||
/** The single instance of this class. */ | ||
static ossimKakaduCodecFactory* theInstance; | ||
}; | ||
|
||
#endif /* End of "#ifndef ossimKakaduCodecFactory_HEADER" */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "ossimKakaduJ2kCodec.h" | ||
|
||
ossimKakaduJ2kCodec::ossimKakaduJ2kCodec() | ||
: m_extension("jp2"), | ||
m_codecType("j2k") | ||
{ | ||
|
||
} | ||
|
||
ossimString ossimKakaduJ2kCodec::getCodecType() const | ||
{ | ||
return m_codecType; | ||
} | ||
|
||
bool ossimKakaduJ2kCodec::encode(const ossimRefPtr<ossimImageData> &in, | ||
std::vector<ossim_uint8> &out) const | ||
{ | ||
bool result = false; | ||
|
||
return false; | ||
} | ||
|
||
bool ossimKakaduJ2kCodec::decode(const std::vector<ossim_uint8> &in, | ||
ossimRefPtr<ossimImageData> &out) const | ||
{ | ||
bool result = false; | ||
|
||
return false; | ||
} | ||
|
||
const std::string &ossimKakaduJ2kCodec::getExtension() const | ||
{ | ||
return m_extension; | ||
} | ||
|
||
bool ossimKakaduJ2kCodec::loadState(const ossimKeywordlist &kwl, const char *prefix) | ||
{ | ||
std::cout << "LOADING AND INITIALIZING THE DECOMPRESSOR AND COMPRESSORS\n"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#ifndef ossimKakaduJ2kCodec_HEADER | ||
#define ossimKakaduJ2kCodec_HEADER 1 | ||
#include <ossim/imaging/ossimCodecBase.h> | ||
|
||
class ossimKakaduJ2kCodec : public ossimCodecBase | ||
{ | ||
public: | ||
ossimKakaduJ2kCodec(); | ||
|
||
/** | ||
* Will return the identifier used to identify the codec type. For example the Jpeg codec | ||
* will have "jpeg" as the identifier | ||
* | ||
* @return Codec identifier | ||
*/ | ||
virtual ossimString getCodecType() const; | ||
|
||
/** | ||
* @brief Encode method. | ||
* | ||
* | ||
* @param in Input data to encode. | ||
* | ||
* @param out Encoded output data. | ||
* | ||
* @return true on success, false on failure. | ||
*/ | ||
|
||
virtual bool encode(const ossimRefPtr<ossimImageData> &in, | ||
std::vector<ossim_uint8> &out) const; | ||
|
||
/** | ||
* @brief Decode method. | ||
* | ||
* @param in Input data to decode. | ||
* | ||
* @param out Output tile. If the pointer to ossimImageData is null | ||
* internally it will be created. For code loops it is better to pre | ||
* initialized to correct size. | ||
* | ||
* @note Caller should set "out's" image rectangle upon successful | ||
* decode. | ||
* | ||
* @return true on success, false on failure. | ||
*/ | ||
virtual bool decode(const std::vector<ossim_uint8> &in, | ||
ossimRefPtr<ossimImageData> &out) const; | ||
|
||
virtual const std::string &getExtension() const; | ||
|
||
virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0); | ||
protected: | ||
std::string m_extension; | ||
ossimString m_codecType; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters