llimagej2c.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLIMAGEJ2C_H
00033 #define LL_LLIMAGEJ2C_H
00034 
00035 #include "llimage.h"
00036 #include "llassettype.h"
00037 
00038 class LLImageJ2CImpl;
00039 class LLImageJ2C : public LLImageFormatted
00040 {
00041 protected:
00042         virtual ~LLImageJ2C();
00043 
00044 public:
00045         LLImageJ2C();
00046 
00047         // Base class overrides
00048         /*virtual*/ BOOL updateData();
00049         /*virtual*/ BOOL decode(LLImageRaw *raw_imagep, F32 decode_time=0.0);
00050         /*virtual*/ BOOL decode(LLImageRaw *raw_imagep, F32 decode_time, S32 first_channel, S32 max_channel_count);
00051         /*virtual*/ BOOL encode(const LLImageRaw *raw_imagep, F32 encode_time=0.0);
00052         /*virtual*/ S32 calcHeaderSize();
00053         /*virtual*/ S32 calcDataSize(S32 discard_level = 0);
00054         /*virtual*/ S32 calcDiscardLevelBytes(S32 bytes);
00055         /*virtual*/ S8  getRawDiscardLevel();
00056         
00057         // Encode with comment text 
00058         BOOL encode(const LLImageRaw *raw_imagep, const char* comment_text, F32 encode_time=0.0);
00059 
00060         BOOL validate(U8 *data, U32 file_size);
00061         BOOL loadAndValidate(const LLString &filename);
00062 
00063         // Encode accessors
00064         void setReversible(const BOOL reversible); // Use non-lossy?
00065         void setRate(F32 rate);
00066         void setMaxBytes(S32 max_bytes);
00067         S32 getMaxBytes() const { return mMaxBytes; }
00068 
00069         static S32 calcHeaderSizeJ2C();
00070         static S32 calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 rate = 0.f);
00071 
00072         static void openDSO();
00073         static void closeDSO();
00074         static std::string getEngineInfo();
00075         
00076 protected:
00077         friend class LLImageJ2CImpl;
00078         friend class LLImageJ2COJ;
00079         friend class LLImageJ2CKDU;
00080         void decodeFailed();
00081         void updateRawDiscardLevel();
00082 
00083         S32 mMaxBytes; // Maximum number of bytes of data to use...
00084         S8  mRawDiscardLevel;
00085         F32 mRate;
00086         BOOL mReversible;
00087         LLImageJ2CImpl *mImpl;
00088 };
00089 
00090 // Derive from this class to implement JPEG2000 decoding
00091 class LLImageJ2CImpl
00092 {
00093 public:
00094         virtual ~LLImageJ2CImpl();
00095 protected:
00096         // Find out the image size and number of channels.
00097         // Return value:
00098         // true: image size and number of channels was determined
00099         // false: error on decode
00100         virtual BOOL getMetadata(LLImageJ2C &base) = 0;
00101         // Decode the raw image optionally aborting (to continue later) after
00102         // decode_time seconds.  Decode at most max_channel_count and start
00103         // decoding channel first_channel.
00104         // Return value:
00105         // true: decoding complete (even if it failed)
00106         // false: time expired while decoding
00107         virtual BOOL decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decode_time, S32 first_channel, S32 max_channel_count) = 0;
00108         virtual BOOL encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, const char* comment_text, F32 encode_time=0.0,
00109                                                         BOOL reversible=FALSE) = 0;
00110 
00111         friend class LLImageJ2C;
00112 };
00113 
00114 #define LINDEN_J2C_COMMENT_PREFIX "LL_"
00115 
00116 #endif

Generated on Thu Jul 1 06:08:44 2010 for Second Life Viewer by  doxygen 1.4.7