Index: core/src/fxcodec/codec/fx_codec_jpx_opj.cpp |
diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp |
index e1b9d255dee625a5dcce55b821c82fb72fef38ad..e278cef043ee3752983b844a6e708a6272315aa4 100644 |
--- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp |
+++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp |
@@ -616,13 +616,9 @@ class CJPX_Decoder { |
CJPX_Decoder(); |
~CJPX_Decoder(); |
FX_BOOL Init(const unsigned char* src_data, int src_size); |
- void GetInfo(FX_DWORD& width, |
- FX_DWORD& height, |
- FX_DWORD& codestream_nComps, |
- FX_DWORD& output_nComps); |
+ void GetInfo(FX_DWORD* width, FX_DWORD* height, FX_DWORD* components); |
FX_BOOL Decode(uint8_t* dest_buf, |
int pitch, |
- FX_BOOL bTranslateColor, |
uint8_t* offsets); |
const uint8_t* m_SrcData; |
int m_SrcSize; |
@@ -633,6 +629,7 @@ class CJPX_Decoder { |
}; |
CJPX_Decoder::CJPX_Decoder() |
: image(NULL), l_codec(NULL), l_stream(NULL), m_useColorSpace(FALSE) {} |
+ |
CJPX_Decoder::~CJPX_Decoder() { |
if (l_codec) { |
opj_destroy_codec(l_codec); |
@@ -644,6 +641,7 @@ CJPX_Decoder::~CJPX_Decoder() { |
opj_image_destroy(image); |
} |
} |
+ |
FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, int src_size) { |
static const unsigned char szJP2Header[] = { |
0x00, 0x00, 0x00, 0x0c, 0x6a, 0x50, 0x20, 0x20, 0x0d, 0x0a, 0x87, 0x0a}; |
@@ -722,17 +720,17 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, int src_size) { |
} |
return TRUE; |
} |
-void CJPX_Decoder::GetInfo(FX_DWORD& width, |
- FX_DWORD& height, |
- FX_DWORD& codestream_nComps, |
- FX_DWORD& output_nComps) { |
- width = (FX_DWORD)image->x1; |
- height = (FX_DWORD)image->y1; |
- output_nComps = codestream_nComps = (FX_DWORD)image->numcomps; |
+ |
+void CJPX_Decoder::GetInfo(FX_DWORD* width, |
+ FX_DWORD* height, |
+ FX_DWORD* components) { |
+ *width = (FX_DWORD)image->x1; |
+ *height = (FX_DWORD)image->y1; |
+ *components = (FX_DWORD)image->numcomps; |
Tom Sepez
2015/09/01 21:43:37
nevermind.
|
} |
+ |
FX_BOOL CJPX_Decoder::Decode(uint8_t* dest_buf, |
int pitch, |
- FX_BOOL bTranslateColor, |
uint8_t* offsets) { |
int i, wid, hei, row, col, channel, src; |
uint8_t* pChannel; |
@@ -815,37 +813,39 @@ done: |
FX_Free(adjust_comps); |
return result; |
} |
+ |
void initialize_transition_table(); |
void initialize_significance_luts(); |
void initialize_sign_lut(); |
+ |
CCodec_JpxModule::CCodec_JpxModule() {} |
+CCodec_JpxModule::~CCodec_JpxModule() { |
+} |
+ |
void* CCodec_JpxModule::CreateDecoder(const uint8_t* src_buf, |
FX_DWORD src_size, |
FX_BOOL useColorSpace) { |
- CJPX_Decoder* pDecoder = new CJPX_Decoder; |
- pDecoder->m_useColorSpace = useColorSpace; |
- if (!pDecoder->Init(src_buf, src_size)) { |
- delete pDecoder; |
- return NULL; |
- } |
- return pDecoder; |
+ nonstd::unique_ptr<CJPX_Decoder> decoder(new CJPX_Decoder); |
+ decoder->m_useColorSpace = useColorSpace; |
+ return decoder->Init(src_buf, src_size) ? decoder.release() : nullptr; |
} |
+ |
void CCodec_JpxModule::GetImageInfo(void* ctx, |
- FX_DWORD& width, |
- FX_DWORD& height, |
- FX_DWORD& codestream_nComps, |
- FX_DWORD& output_nComps) { |
+ FX_DWORD* width, |
+ FX_DWORD* height, |
+ FX_DWORD* components) { |
CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; |
Tom Sepez
2015/09/01 21:43:37
nit: can we use an CJPX_Decoder as an incomplete t
Lei Zhang
2015/09/01 22:06:27
Probably. I'll wait for your comment and do this i
|
- pDecoder->GetInfo(width, height, codestream_nComps, output_nComps); |
+ pDecoder->GetInfo(width, height, components); |
} |
+ |
FX_BOOL CCodec_JpxModule::Decode(void* ctx, |
uint8_t* dest_data, |
int pitch, |
- FX_BOOL bTranslateColor, |
uint8_t* offsets) { |
CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; |
- return pDecoder->Decode(dest_data, pitch, bTranslateColor, offsets); |
+ return pDecoder->Decode(dest_data, pitch, offsets); |
} |
+ |
void CCodec_JpxModule::DestroyDecoder(void* ctx) { |
CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; |
delete pDecoder; |