From 4997b22f84307521a62838f874928bf56cd3423c Mon Sep 17 00:00:00 2001 From: thestig Date: Tue, 7 Jun 2016 10:46:22 -0700 Subject: Get rid of NULLs in core/ Review-Url: https://codereview.chromium.org/2032613003 --- core/fxcodec/codec/fx_codec.cpp | 6 +- core/fxcodec/codec/fx_codec_bmp.cpp | 4 +- core/fxcodec/codec/fx_codec_fax.cpp | 2 +- core/fxcodec/codec/fx_codec_flate.cpp | 15 +- core/fxcodec/codec/fx_codec_gif.cpp | 4 +- core/fxcodec/codec/fx_codec_icc.cpp | 56 +++--- core/fxcodec/codec/fx_codec_jbig.cpp | 6 +- core/fxcodec/codec/fx_codec_jpeg.cpp | 7 +- core/fxcodec/codec/fx_codec_jpx_opj.cpp | 20 +- core/fxcodec/codec/fx_codec_png.cpp | 22 +- core/fxcodec/codec/fx_codec_progress.cpp | 221 ++++++++++----------- core/fxcodec/codec/fx_codec_tiff.cpp | 32 ++- .../codec/include/ccodec_progressivedecoder.h | 6 +- 13 files changed, 194 insertions(+), 207 deletions(-) (limited to 'core/fxcodec/codec') diff --git a/core/fxcodec/codec/fx_codec.cpp b/core/fxcodec/codec/fx_codec.cpp index 6a45737b10..55cb6ee7fb 100644 --- a/core/fxcodec/codec/fx_codec.cpp +++ b/core/fxcodec/codec/fx_codec.cpp @@ -127,8 +127,8 @@ class CCodec_RLScanlineDecoder : public CCodec_ScanlineDecoder { uint8_t m_Operator; }; CCodec_RLScanlineDecoder::CCodec_RLScanlineDecoder() - : m_pScanline(NULL), - m_pSrcBuf(NULL), + : m_pScanline(nullptr), + m_pSrcBuf(nullptr), m_SrcSize(0), m_dwLineBytes(0), m_SrcOffset(0), @@ -206,7 +206,7 @@ uint8_t* CCodec_RLScanlineDecoder::v_GetNextLine() { GetNextOperator(); } else { if (m_bEOD) { - return NULL; + return nullptr; } } FXSYS_memset(m_pScanline, 0, m_Pitch); diff --git a/core/fxcodec/codec/fx_codec_bmp.cpp b/core/fxcodec/codec/fx_codec_bmp.cpp index 03390cfea3..beda53c05b 100644 --- a/core/fxcodec/codec/fx_codec_bmp.cpp +++ b/core/fxcodec/codec/fx_codec_bmp.cpp @@ -113,8 +113,8 @@ int32_t CCodec_BmpModule::LoadImage(FXBMP_Context* ctx) { } uint32_t CCodec_BmpModule::GetAvailInput(FXBMP_Context* ctx, - uint8_t** avial_buf_ptr) { - return bmp_get_avail_input(ctx->bmp_ptr, avial_buf_ptr); + uint8_t** avail_buf_ptr) { + return bmp_get_avail_input(ctx->bmp_ptr, avail_buf_ptr); } void CCodec_BmpModule::Input(FXBMP_Context* ctx, diff --git a/core/fxcodec/codec/fx_codec_fax.cpp b/core/fxcodec/codec/fx_codec_fax.cpp index 90d3b24cab..c0202829ee 100644 --- a/core/fxcodec/codec/fx_codec_fax.cpp +++ b/core/fxcodec/codec/fx_codec_fax.cpp @@ -537,7 +537,7 @@ uint8_t* CCodec_FaxDecoder::v_GetNextLine() { int bitsize = m_SrcSize * 8; FaxSkipEOL(m_pSrcBuf, bitsize, bitpos); if (bitpos >= bitsize) { - return NULL; + return nullptr; } FXSYS_memset(m_pScanlineBuf, 0xff, m_Pitch); if (m_Encoding < 0) { diff --git a/core/fxcodec/codec/fx_codec_flate.cpp b/core/fxcodec/codec/fx_codec_flate.cpp index cd24b6624c..d32a8a13ba 100644 --- a/core/fxcodec/codec/fx_codec_flate.cpp +++ b/core/fxcodec/codec/fx_codec_flate.cpp @@ -648,11 +648,11 @@ class CCodec_FlateScanlineDecoder : public CCodec_ScanlineDecoder { }; CCodec_FlateScanlineDecoder::CCodec_FlateScanlineDecoder() { - m_pFlate = NULL; - m_pScanline = NULL; - m_pLastLine = NULL; - m_pPredictBuffer = NULL; - m_pPredictRaw = NULL; + m_pFlate = nullptr; + m_pScanline = nullptr; + m_pLastLine = nullptr; + m_pPredictBuffer = nullptr; + m_pPredictRaw = nullptr; m_LeftOver = 0; } CCodec_FlateScanlineDecoder::~CCodec_FlateScanlineDecoder() { @@ -799,7 +799,7 @@ uint32_t CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, uint32_t estimated_size, uint8_t*& dest_buf, uint32_t& dest_size) { - dest_buf = NULL; + dest_buf = nullptr; uint32_t offset = 0; int predictor_type = 0; if (predictor) { @@ -814,7 +814,8 @@ uint32_t CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, std::unique_ptr decoder(new CLZWDecoder); dest_size = (uint32_t)-1; offset = src_size; - int err = decoder->Decode(NULL, dest_size, src_buf, offset, bEarlyChange); + int err = + decoder->Decode(nullptr, dest_size, src_buf, offset, bEarlyChange); if (err || dest_size == 0 || dest_size + 1 < dest_size) { return FX_INVALID_OFFSET; } diff --git a/core/fxcodec/codec/fx_codec_gif.cpp b/core/fxcodec/codec/fx_codec_gif.cpp index 13576412c2..f04192ebef 100644 --- a/core/fxcodec/codec/fx_codec_gif.cpp +++ b/core/fxcodec/codec/fx_codec_gif.cpp @@ -175,8 +175,8 @@ int32_t CCodec_GifModule::LoadFrame(FXGIF_Context* ctx, } uint32_t CCodec_GifModule::GetAvailInput(FXGIF_Context* ctx, - uint8_t** avial_buf_ptr) { - return gif_get_avail_input(ctx->gif_ptr, avial_buf_ptr); + uint8_t** avail_buf_ptr) { + return gif_get_avail_input(ctx->gif_ptr, avail_buf_ptr); } void CCodec_GifModule::Input(FXGIF_Context* ctx, diff --git a/core/fxcodec/codec/fx_codec_icc.cpp b/core/fxcodec/codec/fx_codec_icc.cpp index 876297fd40..4903c24715 100644 --- a/core/fxcodec/codec/fx_codec_icc.cpp +++ b/core/fxcodec/codec/fx_codec_icc.cpp @@ -98,15 +98,13 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, int intent, uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT, uint32_t dwDstFormat = Icc_FORMAT_DEFAULT) { - cmsHPROFILE srcProfile = NULL; - cmsHPROFILE dstProfile = NULL; - cmsHTRANSFORM hTransform = NULL; - CLcmsCmm* pCmm = NULL; nSrcComponents = 0; - srcProfile = cmsOpenProfileFromMem((void*)pSrcProfileData, dwSrcProfileSize); - if (!srcProfile) { - return NULL; - } + cmsHPROFILE srcProfile = + cmsOpenProfileFromMem((void*)pSrcProfileData, dwSrcProfileSize); + if (!srcProfile) + return nullptr; + + cmsHPROFILE dstProfile; if (!pDstProfileData && dwDstProfileSize == 0 && nDstComponents == 3) { dstProfile = cmsCreate_sRGBProfile(); } else { @@ -115,7 +113,7 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, } if (!dstProfile) { cmsCloseProfile(srcProfile); - return NULL; + return nullptr; } int srcFormat; FX_BOOL bLab = FALSE; @@ -136,8 +134,10 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, if (!CheckComponents(dstCS, nDstComponents, TRUE)) { cmsCloseProfile(srcProfile); cmsCloseProfile(dstProfile); - return NULL; + return nullptr; } + + cmsHTRANSFORM hTransform = nullptr; switch (dstCS) { case cmsSigGrayData: hTransform = cmsCreateTransform(srcProfile, srcFormat, dstProfile, @@ -158,9 +158,9 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, if (!hTransform) { cmsCloseProfile(srcProfile); cmsCloseProfile(dstProfile); - return NULL; + return nullptr; } - pCmm = new CLcmsCmm; + CLcmsCmm* pCmm = new CLcmsCmm; pCmm->m_nSrcComponents = nSrcComponents; pCmm->m_nDstComponents = nDstComponents; pCmm->m_hTransform = hTransform; @@ -174,8 +174,8 @@ void* IccLib_CreateTransform_sRGB(const unsigned char* pProfileData, uint32_t& nComponents, int32_t intent, uint32_t dwSrcFormat) { - return IccLib_CreateTransform(pProfileData, dwProfileSize, nComponents, NULL, - 0, 3, intent, dwSrcFormat); + return IccLib_CreateTransform(pProfileData, dwProfileSize, nComponents, + nullptr, 0, 3, intent, dwSrcFormat); } void IccLib_DestroyTransform(void* pTransform) { if (!pTransform) { @@ -241,11 +241,11 @@ void IccLib_TranslateImage(void* pTransform, void* CreateProfile_Gray(double gamma) { cmsCIExyY* D50 = (cmsCIExyY*)cmsD50_xyY(); if (!cmsWhitePointFromTemp(D50, 6504)) { - return NULL; + return nullptr; } - cmsToneCurve* curve = cmsBuildGamma(NULL, gamma); + cmsToneCurve* curve = cmsBuildGamma(nullptr, gamma); if (!curve) { - return NULL; + return nullptr; } void* profile = cmsCreateGrayProfile(D50, curve); cmsFreeToneCurve(curve); @@ -365,7 +365,7 @@ class CFX_IccProfileCache { void Purge(); }; CFX_IccProfileCache::CFX_IccProfileCache() { - m_pProfile = NULL; + m_pProfile = nullptr; m_dwRate = 1; } CFX_IccProfileCache::~CFX_IccProfileCache() { @@ -376,7 +376,7 @@ CFX_IccProfileCache::~CFX_IccProfileCache() { void CFX_IccProfileCache::Purge() {} class CFX_IccTransformCache { public: - CFX_IccTransformCache(CLcmsCmm* pCmm = NULL); + CFX_IccTransformCache(CLcmsCmm* pCmm = nullptr); ~CFX_IccTransformCache(); void* m_pIccTransform; uint32_t m_dwRate; @@ -386,7 +386,7 @@ class CFX_IccTransformCache { void Purge(); }; CFX_IccTransformCache::CFX_IccTransformCache(CLcmsCmm* pCmm) { - m_pIccTransform = NULL; + m_pIccTransform = nullptr; m_dwRate = 1; m_pCmm = pCmm; } @@ -409,14 +409,14 @@ CFX_ByteStringKey& CFX_ByteStringKey::operator<<(uint32_t i) { void* CCodec_IccModule::CreateProfile(CCodec_IccModule::IccParam* pIccParam, Icc_CLASS ic, CFX_BinaryBuf* pTransformKey) { - CFX_IccProfileCache* pCache = NULL; + CFX_IccProfileCache* pCache = nullptr; CFX_ByteStringKey key; CFX_ByteString text; key << pIccParam->ColorSpace << (pIccParam->dwProfileType | ic << 8); uint8_t ID[16]; switch (pIccParam->dwProfileType) { case Icc_PARAMTYPE_NONE: - return NULL; + return nullptr; case Icc_PARAMTYPE_BUFFER: MD5ComputeID(pIccParam->pProfileData, pIccParam->dwProfileSize, ID); break; @@ -476,30 +476,30 @@ void* CCodec_IccModule::CreateTransform( uint32_t dwFlag, uint32_t dwPrfIntent, uint32_t dwPrfFlag) { - CLcmsCmm* pCmm = NULL; + CLcmsCmm* pCmm = nullptr; ASSERT(pInputParam && pOutputParam); CFX_ByteStringKey key; void* pInputProfile = CreateProfile(pInputParam, Icc_CLASS_INPUT, &key); if (!pInputProfile) { - return NULL; + return nullptr; } void* pOutputProfile = CreateProfile(pOutputParam, Icc_CLASS_OUTPUT, &key); if (!pOutputProfile) { - return NULL; + return nullptr; } uint32_t dwInputProfileType = TransferProfileType(pInputProfile, pInputParam->dwFormat); uint32_t dwOutputProfileType = TransferProfileType(pOutputProfile, pOutputParam->dwFormat); if (dwInputProfileType == 0 || dwOutputProfileType == 0) { - return NULL; + return nullptr; } - void* pProofProfile = NULL; + void* pProofProfile = nullptr; if (pProofParam) { pProofProfile = CreateProfile(pProofParam, Icc_CLASS_PROOF, &key); } key << dwInputProfileType << dwOutputProfileType << dwIntent << dwFlag - << (pProofProfile != NULL) << dwPrfIntent << dwPrfFlag; + << !!pProofProfile << dwPrfIntent << dwPrfFlag; CFX_ByteString TransformKey(key.GetBuffer(), key.GetSize()); CFX_IccTransformCache* pTransformCache; auto it = m_MapTranform.find(TransformKey); diff --git a/core/fxcodec/codec/fx_codec_jbig.cpp b/core/fxcodec/codec/fx_codec_jbig.cpp index 2b0be1070e..30798fe361 100644 --- a/core/fxcodec/codec/fx_codec_jbig.cpp +++ b/core/fxcodec/codec/fx_codec_jbig.cpp @@ -68,7 +68,7 @@ void CCodec_Jbig2Module::DestroyJbig2Context(void* pJbig2Content) { ((CCodec_Jbig2Context*)pJbig2Content)->m_pContext); delete (CCodec_Jbig2Context*)pJbig2Content; } - pJbig2Content = NULL; + pJbig2Content = nullptr; } FXCODEC_STATUS CCodec_Jbig2Module::StartDecode( void* pJbig2Context, @@ -105,7 +105,7 @@ FXCODEC_STATUS CCodec_Jbig2Module::StartDecode( if (m_pJbig2Context->m_pContext->GetProcessingStatus() == FXCODEC_STATUS_DECODE_FINISH) { CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); - m_pJbig2Context->m_pContext = NULL; + m_pJbig2Context->m_pContext = nullptr; if (ret != JBIG2_SUCCESS) { return FXCODEC_STATUS_ERROR; } @@ -127,7 +127,7 @@ FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context, return m_pJbig2Context->m_pContext->GetProcessingStatus(); } CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); - m_pJbig2Context->m_pContext = NULL; + m_pJbig2Context->m_pContext = nullptr; if (ret != JBIG2_SUCCESS) { return FXCODEC_STATUS_ERROR; } diff --git a/core/fxcodec/codec/fx_codec_jpeg.cpp b/core/fxcodec/codec/fx_codec_jpeg.cpp index cbfea59329..c2814a4b4c 100644 --- a/core/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/fxcodec/codec/fx_codec_jpeg.cpp @@ -78,11 +78,10 @@ static void _error_do_nothing2(j_common_ptr cinfo, char*) {} #define JPEG_MARKER_ICC (JPEG_APP0 + 2) #define JPEG_MARKER_MAXSIZE 0xFFFF - #ifdef PDF_ENABLE_XFA static void JpegLoadAttribute(struct jpeg_decompress_struct* pInfo, CFX_DIBAttribute* pAttribute) { - if (!pInfo || !pAttribute) + if (!pAttribute) return; pAttribute->m_nXDPI = pInfo->X_density; @@ -178,7 +177,7 @@ class CCodec_JpegDecoder : public CCodec_ScanlineDecoder { }; CCodec_JpegDecoder::CCodec_JpegDecoder() { - m_pScanlineBuf = NULL; + m_pScanlineBuf = nullptr; m_bStarted = FALSE; m_bInited = FALSE; FXSYS_memset(&cinfo, 0, sizeof(cinfo)); @@ -470,7 +469,7 @@ FX_BOOL CCodec_JpegModule::ReadScanline(FXJPEG_Context* ctx, uint32_t CCodec_JpegModule::GetAvailInput(FXJPEG_Context* ctx, uint8_t** avail_buf_ptr) { if (avail_buf_ptr) { - *avail_buf_ptr = NULL; + *avail_buf_ptr = nullptr; if (ctx->m_SrcMgr.bytes_in_buffer > 0) { *avail_buf_ptr = (uint8_t*)ctx->m_SrcMgr.next_input_byte; } diff --git a/core/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/fxcodec/codec/fx_codec_jpx_opj.cpp index a0f2e65c75..9e72c509d7 100644 --- a/core/fxcodec/codec/fx_codec_jpx_opj.cpp +++ b/core/fxcodec/codec/fx_codec_jpx_opj.cpp @@ -122,13 +122,13 @@ opj_stream_t* fx_opj_stream_create_memory_stream(DecodeData* data, OPJ_BOOL p_is_read_stream) { opj_stream_t* l_stream = 00; if (!data || !data->src_data || data->src_size <= 0) { - return NULL; + return nullptr; } l_stream = opj_stream_create(p_size, p_is_read_stream); if (!l_stream) { - return NULL; + return nullptr; } - opj_stream_set_user_data(l_stream, data, NULL); + opj_stream_set_user_data(l_stream, data, nullptr); opj_stream_set_user_data_length(l_stream, data->src_size); opj_stream_set_read_function(l_stream, opj_read_from_memory); opj_stream_set_write_function(l_stream, opj_write_from_memory); @@ -611,7 +611,7 @@ void color_apply_conversion(opj_image_t* image) { cmsHTRANSFORM transform; cmsUInt16Number RGB[3]; cmsCIELab Lab; - in = cmsCreateLab4Profile(NULL); + in = cmsCreateLab4Profile(nullptr); out = cmsCreate_sRGBProfile(); transform = cmsCreateTransform(in, TYPE_Lab_DBL, out, TYPE_RGB_16, INTENT_PERCEPTUAL, 0); @@ -718,7 +718,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) { if (!src_data || src_size < sizeof(szJP2Header)) return FALSE; - image = NULL; + image = nullptr; m_SrcData = src_data; m_SrcSize = src_size; DecodeData srcData(const_cast(src_data), src_size); @@ -749,7 +749,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) { return FALSE; } if (!opj_read_header(l_stream, l_codec, &image)) { - image = NULL; + image = nullptr; return FALSE; } image->pdfium_use_colorspace = !!m_ColorSpace; @@ -758,13 +758,13 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) { if (!opj_set_decode_area(l_codec, image, parameters.DA_x0, parameters.DA_y0, parameters.DA_x1, parameters.DA_y1)) { opj_image_destroy(image); - image = NULL; + image = nullptr; return FALSE; } if (!(opj_decode(l_codec, l_stream, image) && opj_end_decompress(l_codec, l_stream))) { opj_image_destroy(image); - image = NULL; + image = nullptr; return FALSE; } } else { @@ -774,7 +774,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) { } } opj_stream_destroy(l_stream); - l_stream = NULL; + l_stream = nullptr; if (image->color_space != OPJ_CLRSPC_SYCC && image->numcomps == 3 && image->comps[0].dx == image->comps[0].dy && image->comps[1].dx != 1) { image->color_space = OPJ_CLRSPC_SYCC; @@ -786,7 +786,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, uint32_t src_size) { } if (image->icc_profile_buf) { FX_Free(image->icc_profile_buf); - image->icc_profile_buf = NULL; + image->icc_profile_buf = nullptr; image->icc_profile_len = 0; } if (!image) { diff --git a/core/fxcodec/codec/fx_codec_png.cpp b/core/fxcodec/codec/fx_codec_png.cpp index f7b922973e..9f7faa68e0 100644 --- a/core/fxcodec/codec/fx_codec_png.cpp +++ b/core/fxcodec/codec/fx_codec_png.cpp @@ -51,7 +51,7 @@ static void _png_load_bmp_attribute(png_structp png_ptr, #endif int bTime = 0; #if defined(PNG_tIME_SUPPORTED) - png_timep t = NULL; + png_timep t = nullptr; png_get_tIME(png_ptr, info_ptr, &t); if (t) { FXSYS_memset(pAttribute->m_strTime, 0, sizeof(pAttribute->m_strTime)); @@ -67,7 +67,7 @@ static void _png_load_bmp_attribute(png_structp png_ptr, FX_STRSIZE len; const FX_CHAR* buf; int num_text; - png_textp text = NULL; + png_textp text = nullptr; png_get_text(png_ptr, info_ptr, &text, &num_text); for (i = 0; i < num_text; i++) { len = FXSYS_strlen(text[i].key); @@ -110,18 +110,18 @@ static void _png_free_func(void* p) { }; static void _png_get_header_func(png_structp png_ptr, png_infop info_ptr) { FXPNG_Context* p = (FXPNG_Context*)png_get_progressive_ptr(png_ptr); - if (p == NULL) { + if (!p) return; - } + CCodec_PngModule* pModule = (CCodec_PngModule*)p->parent_ptr; - if (pModule == NULL) { + if (!pModule) return; - } + png_uint_32 width = 0, height = 0; int bpc = 0, color_type = 0, color_type1 = 0, pass = 0; double gamma = 1.0; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bpc, &color_type, NULL, - NULL, NULL); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bpc, &color_type, nullptr, + nullptr, nullptr); color_type1 = color_type; if (bpc > 8) { png_set_strip_16(png_ptr); @@ -182,11 +182,11 @@ static void _png_get_row_func(png_structp png_ptr, png_uint_32 row_num, int pass) { FXPNG_Context* p = (FXPNG_Context*)png_get_progressive_ptr(png_ptr); - if (p == NULL) { + if (!p) return; - } + CCodec_PngModule* pModule = (CCodec_PngModule*)p->parent_ptr; - uint8_t* src_buf = NULL; + uint8_t* src_buf = nullptr; if (!pModule->AskScanlineBufCallback(p->child_ptr, row_num, src_buf)) { png_error(png_ptr, "Ask Scanline buffer Callback Error"); } diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp index 95a90b3e68..ec3347cdaa 100644 --- a/core/fxcodec/codec/fx_codec_progress.cpp +++ b/core/fxcodec/codec/fx_codec_progress.cpp @@ -39,9 +39,6 @@ void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len, sizeof(int) * (FXSYS_ceil(FXSYS_fabs((FX_FLOAT)scale)) + 1)); m_DestMin = dest_min; m_pWeightTables = FX_Alloc(uint8_t, (dest_max - dest_min) * m_ItemSize + 4); - if (m_pWeightTables == NULL) { - return; - } if (FXSYS_fabs((FX_FLOAT)scale) < 1.0f) { for (int dest_pixel = dest_min; dest_pixel < dest_max; dest_pixel++) { PixelWeight& pixel_weights = *GetPixelWeight(dest_pixel); @@ -131,9 +128,6 @@ void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len, m_ItemSize = sizeof(int) * 4; int size = dest_len * m_ItemSize + 4; m_pWeightTables = FX_Alloc(uint8_t, size); - if (m_pWeightTables == NULL) { - return; - } FXSYS_memset(m_pWeightTables, 0, size); if (scale > 1) { int pre_des_col = 0; @@ -192,9 +186,6 @@ void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len, m_ItemSize = sizeof(int) * 4; int size = dest_len * m_ItemSize + 4; m_pWeightTables = FX_Alloc(uint8_t, size); - if (m_pWeightTables == NULL) { - return; - } FXSYS_memset(m_pWeightTables, 0, size); if (scale > 1) { double step = 0.0; @@ -247,17 +238,17 @@ void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len, } CCodec_ProgressiveDecoder::CCodec_ProgressiveDecoder( CCodec_ModuleMgr* pCodecMgr) { - m_pFile = NULL; - m_pJpegContext = NULL; - m_pPngContext = NULL; - m_pGifContext = NULL; - m_pBmpContext = NULL; - m_pTiffContext = NULL; - m_pCodecMgr = NULL; - m_pSrcBuf = NULL; - m_pDecodeBuf = NULL; - m_pDeviceBitmap = NULL; - m_pSrcPalette = NULL; + m_pFile = nullptr; + m_pJpegContext = nullptr; + m_pPngContext = nullptr; + m_pGifContext = nullptr; + m_pBmpContext = nullptr; + m_pTiffContext = nullptr; + m_pCodecMgr = nullptr; + m_pSrcBuf = nullptr; + m_pDecodeBuf = nullptr; + m_pDeviceBitmap = nullptr; + m_pSrcPalette = nullptr; m_pCodecMgr = pCodecMgr; m_offSet = 0; m_SrcSize = 0; @@ -278,13 +269,13 @@ CCodec_ProgressiveDecoder::CCodec_ProgressiveDecoder( m_SrcPaletteNumber = 0; m_GifPltNumber = 0; m_GifBgIndex = 0; - m_pGifPalette = NULL; + m_pGifPalette = nullptr; m_GifTransIndex = -1; m_GifFrameRect = FX_RECT(0, 0, 0, 0); m_BmpIsTopBottom = FALSE; } CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() { - m_pFile = NULL; + m_pFile = nullptr; if (m_pJpegContext) { m_pCodecMgr->GetJpegModule()->Finish(m_pJpegContext); } @@ -312,7 +303,7 @@ FX_BOOL CCodec_ProgressiveDecoder::JpegReadMoreData( return FALSE; } dwSize = dwSize - m_offSet; - uint32_t dwAvail = pJpegModule->GetAvailInput(m_pJpegContext, NULL); + uint32_t dwAvail = pJpegModule->GetAvailInput(m_pJpegContext, nullptr); if (dwAvail == m_SrcSize) { if (dwSize > FXCODEC_BLOCK_SIZE) { dwSize = FXCODEC_BLOCK_SIZE; @@ -349,7 +340,7 @@ FX_BOOL CCodec_ProgressiveDecoder::PngReadHeaderFunc(void* pModule, int* color_type, double* gamma) { CCodec_ProgressiveDecoder* pCodec = (CCodec_ProgressiveDecoder*)pModule; - if (pCodec->m_pDeviceBitmap == NULL) { + if (!pCodec->m_pDeviceBitmap) { pCodec->m_SrcWidth = width; pCodec->m_SrcHeight = height; pCodec->m_SrcBPC = bpc; @@ -570,7 +561,7 @@ FX_BOOL CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule, return FALSE; } dwSize = dwSize - m_offSet; - uint32_t dwAvail = pGifModule->GetAvailInput(m_pGifContext, NULL); + uint32_t dwAvail = pGifModule->GetAvailInput(m_pGifContext, nullptr); if (dwAvail == m_SrcSize) { if (dwSize > FXCODEC_BLOCK_SIZE) { dwSize = FXCODEC_BLOCK_SIZE; @@ -631,21 +622,21 @@ FX_BOOL CCodec_ProgressiveDecoder::GifInputRecordPositionBufCallback( error_status)) { return FALSE; } - uint8_t* pPalette = NULL; + uint8_t* pPalette = nullptr; if (pal_num != 0 && pal_ptr) { pPalette = (uint8_t*)pal_ptr; } else { pal_num = pCodec->m_GifPltNumber; pPalette = pCodec->m_pGifPalette; } - if (pCodec->m_pSrcPalette == NULL) { + if (!pCodec->m_pSrcPalette) { pCodec->m_pSrcPalette = FX_Alloc(FX_ARGB, pal_num); } else if (pal_num > pCodec->m_SrcPaletteNumber) { pCodec->m_pSrcPalette = FX_Realloc(FX_ARGB, pCodec->m_pSrcPalette, pal_num); } - if (pCodec->m_pSrcPalette == NULL) { + if (!pCodec->m_pSrcPalette) return FALSE; - } + pCodec->m_SrcPaletteNumber = pal_num; for (int i = 0; i < pal_num; i++) { uint32_t j = i * 3; @@ -852,7 +843,7 @@ FX_BOOL CCodec_ProgressiveDecoder::BmpReadMoreData(CCodec_BmpModule* pBmpModule, return FALSE; } dwSize = dwSize - m_offSet; - uint32_t dwAvail = pBmpModule->GetAvailInput(m_pBmpContext, NULL); + uint32_t dwAvail = pBmpModule->GetAvailInput(m_pBmpContext, nullptr); if (dwAvail == m_SrcSize) { if (dwSize > FXCODEC_BLOCK_SIZE) { dwSize = FXCODEC_BLOCK_SIZE; @@ -1020,7 +1011,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( switch (imageType) { case FXCODEC_IMAGE_BMP: { CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); - if (pBmpModule == NULL) { + if (!pBmpModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; } @@ -1028,7 +1019,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( BmpInputImagePositionBufCallback; pBmpModule->ReadScanlineCallback = BmpReadScanlineCallback; m_pBmpContext = pBmpModule->Start((void*)this); - if (m_pBmpContext == NULL) { + if (!m_pBmpContext) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; } @@ -1039,7 +1030,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( } m_offSet += size; pBmpModule->Input(m_pBmpContext, m_pSrcBuf, size); - uint32_t* pPalette = NULL; + uint32_t* pPalette = nullptr; int32_t readResult = pBmpModule->ReadHeader( m_pBmpContext, &m_SrcWidth, &m_SrcHeight, &m_BmpIsTopBottom, &m_SrcComponents, &m_SrcPaletteNumber, &pPalette, pAttribute); @@ -1068,19 +1059,19 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( } if (m_pBmpContext) { pBmpModule->Finish(m_pBmpContext); - m_pBmpContext = NULL; + m_pBmpContext = nullptr; } m_status = FXCODEC_STATUS_ERR_FORMAT; return FALSE; } break; case FXCODEC_IMAGE_JPG: { CCodec_JpegModule* pJpegModule = m_pCodecMgr->GetJpegModule(); - if (pJpegModule == NULL) { + if (!pJpegModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; } m_pJpegContext = pJpegModule->Start(); - if (m_pJpegContext == NULL) { + if (!m_pJpegContext) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; } @@ -1111,14 +1102,14 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( } if (m_pJpegContext) { pJpegModule->Finish(m_pJpegContext); - m_pJpegContext = NULL; + m_pJpegContext = nullptr; } m_status = FXCODEC_STATUS_ERR_FORMAT; return FALSE; } break; case FXCODEC_IMAGE_PNG: { CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); - if (pPngModule == NULL) { + if (!pPngModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; } @@ -1129,7 +1120,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( pPngModule->FillScanlineBufCompletedCallback = CCodec_ProgressiveDecoder::PngFillScanlineBufCompletedFunc; m_pPngContext = pPngModule->Start((void*)this); - if (m_pPngContext == NULL) { + if (!m_pPngContext) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; } @@ -1148,7 +1139,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( if (m_pPngContext) { pPngModule->Finish(m_pPngContext); } - m_pPngContext = NULL; + m_pPngContext = nullptr; m_status = FXCODEC_STATUS_ERR_FORMAT; return FALSE; } @@ -1170,7 +1161,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( ASSERT(!bResult); if (m_pPngContext) { pPngModule->Finish(m_pPngContext); - m_pPngContext = NULL; + m_pPngContext = nullptr; } if (m_SrcPassNumber == 0) { m_status = FXCODEC_STATUS_ERR_FORMAT; @@ -1179,7 +1170,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( } break; case FXCODEC_IMAGE_GIF: { CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); - if (pGifModule == NULL) { + if (!pGifModule) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; } @@ -1192,7 +1183,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( pGifModule->ReadScanlineCallback = CCodec_ProgressiveDecoder::GifReadScanlineCallback; m_pGifContext = pGifModule->Start((void*)this); - if (m_pGifContext == NULL) { + if (!m_pGifContext) { m_status = FXCODEC_STATUS_ERR_MEMORY; return FALSE; } @@ -1224,19 +1215,19 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( } if (m_pGifContext) { pGifModule->Finish(m_pGifContext); - m_pGifContext = NULL; + m_pGifContext = nullptr; } m_status = FXCODEC_STATUS_ERR_FORMAT; return FALSE; } break; case FXCODEC_IMAGE_TIF: { CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule(); - if (pTiffModule == NULL) { + if (!pTiffModule) { m_status = FXCODEC_STATUS_ERR_FORMAT; return FALSE; } m_pTiffContext = pTiffModule->CreateDecoder(m_pFile); - if (m_pTiffContext == NULL) { + if (!m_pTiffContext) { m_status = FXCODEC_STATUS_ERR_FORMAT; return FALSE; } @@ -1250,7 +1241,7 @@ FX_BOOL CCodec_ProgressiveDecoder::DetectImageType( m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight); if (!ret) { pTiffModule->DestroyDecoder(m_pTiffContext); - (m_pTiffContext = NULL); + (m_pTiffContext = nullptr); (m_status = FXCODEC_STATUS_ERR_FORMAT); return FALSE; } @@ -1274,9 +1265,9 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo( default: break; } - if (pFile == NULL) { + if (!pFile) { m_status = FXCODEC_STATUS_ERR_PARAMS; - m_pFile = NULL; + m_pFile = nullptr; return m_status; } m_pFile = pFile; @@ -1301,7 +1292,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo( } } m_status = FXCODEC_STATUS_ERR_FORMAT; - m_pFile = NULL; + m_pFile = nullptr; return m_status; } void CCodec_ProgressiveDecoder::SetClipBox(FX_RECT* clip) { @@ -1830,7 +1821,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::GetFrames(int32_t& frames, } if (m_pGifContext) { pGifModule->Finish(m_pGifContext); - m_pGifContext = NULL; + m_pGifContext = nullptr; } return m_status = FXCODEC_STATUS_ERROR; } @@ -1847,10 +1838,10 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, int size_y, int32_t frames, FX_BOOL bInterpol) { - if (m_status != FXCODEC_STATUS_DECODE_READY) { + if (m_status != FXCODEC_STATUS_DECODE_READY) return FXCODEC_STATUS_ERROR; - } - if (pDIBitmap == NULL || pDIBitmap->GetBPP() < 8 || frames < 0 || + + if (!pDIBitmap || pDIBitmap->GetBPP() < 8 || frames < 0 || frames >= m_FrameNumber) { return FXCODEC_STATUS_ERR_PARAMS; } @@ -1906,8 +1897,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, while (!bStart) { FXCODEC_STATUS error_status = FXCODEC_STATUS_ERROR; if (!JpegReadMoreData(pJpegModule, error_status)) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = error_status; } bStart = pJpegModule->StartScanline(m_pJpegContext, down_scale); @@ -1936,19 +1927,19 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, } break; case FXCODEC_IMAGE_PNG: { CCodec_PngModule* pPngModule = m_pCodecMgr->GetPngModule(); - if (pPngModule == NULL) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + if (!pPngModule) { + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_MEMORY; } if (m_pPngContext) { pPngModule->Finish(m_pPngContext); - m_pPngContext = NULL; + m_pPngContext = nullptr; } m_pPngContext = pPngModule->Start((void*)this); - if (m_pPngContext == NULL) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + if (!m_pPngContext) { + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_MEMORY; } m_offSet = 0; @@ -1968,8 +1959,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, m_SrcFormat = FXCodec_Argb; break; default: { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_PARAMS; } } @@ -1984,9 +1975,9 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, } break; case FXCODEC_IMAGE_GIF: { CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); - if (pGifModule == NULL) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + if (!pGifModule) { + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_MEMORY; } m_SrcFormat = FXCodec_8bppRgb; @@ -2003,9 +1994,9 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, } break; case FXCODEC_IMAGE_BMP: { CCodec_BmpModule* pBmpModule = m_pCodecMgr->GetBmpModule(); - if (pBmpModule == NULL) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + if (!pBmpModule) { + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_MEMORY; } switch (m_SrcComponents) { @@ -2049,8 +2040,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { while (!readRes) { FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH; if (!JpegReadMoreData(pJpegModule, error_status)) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = error_status; } readRes = pJpegModule->ReadScanline(m_pJpegContext, m_pDecodeBuf); @@ -2060,8 +2051,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { _RGB2BGR(m_pDecodeBuf + m_clipBox.left * src_Bpp, m_clipBox.Width()); } if (m_SrcRow >= m_clipBox.bottom) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_DECODE_FINISH; } Resample(m_pDeviceBitmap, m_SrcRow, m_pDecodeBuf, m_SrcFormat); @@ -2081,9 +2072,9 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { if (m_pPngContext) { pPngModule->Finish(m_pPngContext); } - m_pPngContext = NULL; - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pPngContext = nullptr; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_DECODE_FINISH; } if (m_pSrcBuf && input_size > m_SrcSize) { @@ -2094,16 +2085,16 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { } FX_BOOL bResult = m_pFile->ReadBlock(m_pSrcBuf, m_offSet, input_size); if (!bResult) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_READ; } m_offSet += input_size; bResult = pPngModule->Input(m_pPngContext, m_pSrcBuf, input_size, nullptr); if (!bResult) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERROR; } if (pPause && pPause->NeedToPauseNow()) { @@ -2119,8 +2110,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { while (readRes == 2) { FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH; if (!GifReadMoreData(pGifModule, error_status)) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = error_status; } if (pPause && pPause->NeedToPauseNow()) { @@ -2129,12 +2120,12 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { readRes = pGifModule->LoadFrame(m_pGifContext, m_FrameCur, nullptr); } if (readRes == 1) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_DECODE_FINISH; } - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERROR; } } break; @@ -2145,8 +2136,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { while (readRes == 2) { FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH; if (!BmpReadMoreData(pBmpModule, error_status)) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = error_status; } if (pPause && pPause->NeedToPauseNow()) { @@ -2155,12 +2146,12 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { readRes = pBmpModule->LoadImage(m_pBmpContext); } if (readRes == 1) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_DECODE_FINISH; } - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERROR; } } break; @@ -2174,8 +2165,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { m_clipBox.left == 0 && m_clipBox.top == 0 && m_clipBox.right == m_SrcWidth && m_clipBox.bottom == m_SrcHeight) { ret = pTiffModule->Decode(m_pTiffContext, m_pDeviceBitmap); - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; if (!ret) { return m_status = FXCODEC_STATUS_ERROR; } @@ -2183,17 +2174,17 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { } else { CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; pDIBitmap->Create(m_SrcWidth, m_SrcHeight, FXDIB_Argb); - if (pDIBitmap->GetBuffer() == NULL) { + if (!pDIBitmap->GetBuffer()) { delete pDIBitmap; - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_MEMORY; } ret = pTiffModule->Decode(m_pTiffContext, pDIBitmap); if (!ret) { delete pDIBitmap; - m_pDeviceBitmap = NULL; - m_pFile = NULL; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERROR; } CFX_DIBitmap* pClipBitmap = @@ -2204,12 +2195,12 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { if (pDIBitmap != pClipBitmap) { delete pDIBitmap; } - if (pClipBitmap == NULL) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + if (!pClipBitmap) { + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_MEMORY; } - CFX_DIBitmap* pFormatBitmap = NULL; + CFX_DIBitmap* pFormatBitmap = nullptr; switch (m_pDeviceBitmap->GetFormat()) { case FXDIB_8bppRgb: pFormatBitmap = new CFX_DIBitmap; @@ -2279,26 +2270,26 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode(IFX_Pause* pPause) { if (pClipBitmap != pFormatBitmap) { delete pClipBitmap; } - if (pFormatBitmap == NULL) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + if (!pFormatBitmap) { + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_MEMORY; } CFX_DIBitmap* pStrechBitmap = pFormatBitmap->StretchTo( m_sizeX, m_sizeY, m_bInterpol ? FXDIB_INTERPOL : FXDIB_DOWNSAMPLE); delete pFormatBitmap; - pFormatBitmap = NULL; - if (pStrechBitmap == NULL) { - m_pDeviceBitmap = NULL; - m_pFile = NULL; + pFormatBitmap = nullptr; + if (!pStrechBitmap) { + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_ERR_MEMORY; } m_pDeviceBitmap->TransferBitmap(m_startX, m_startY, m_sizeX, m_sizeY, pStrechBitmap, 0, 0); delete pStrechBitmap; - pStrechBitmap = NULL; - m_pDeviceBitmap = NULL; - m_pFile = NULL; + pStrechBitmap = nullptr; + m_pDeviceBitmap = nullptr; + m_pFile = nullptr; return m_status = FXCODEC_STATUS_DECODE_FINISH; } } break; diff --git a/core/fxcodec/codec/fx_codec_tiff.cpp b/core/fxcodec/codec/fx_codec_tiff.cpp index d4dc139265..c8c94dbcdb 100644 --- a/core/fxcodec/codec/fx_codec_tiff.cpp +++ b/core/fxcodec/codec/fx_codec_tiff.cpp @@ -73,15 +73,15 @@ CCodec_TiffContext::CCodec_TiffContext() { offset = 0; frame_num = 0; frame_cur = 0; - io.in = NULL; - tif_ctx = NULL; - icc_ctx = NULL; + io.in = nullptr; + tif_ctx = nullptr; + icc_ctx = nullptr; isDecoder = TRUE; } CCodec_TiffContext::~CCodec_TiffContext() { if (icc_ctx) { IccLib_DestroyTransform(icc_ctx); - icc_ctx = NULL; + icc_ctx = nullptr; } if (tif_ctx) { TIFFClose(tif_ctx); @@ -193,9 +193,9 @@ int TIFFCmyk2Rgb(thandle_t context, uint8* r, uint8* g, uint8* b) { - if (context == NULL) { + if (!context) return 0; - } + CCodec_TiffContext* p = (CCodec_TiffContext*)context; if (p->icc_ctx) { unsigned char cmyk[4], bgr[3]; @@ -209,11 +209,7 @@ int TIFFCmyk2Rgb(thandle_t context, } FX_BOOL CCodec_TiffContext::InitDecoder(IFX_FileRead* file_ptr) { io.in = file_ptr; - tif_ctx = _tiff_open(this, "r"); - if (tif_ctx == NULL) { - return FALSE; - } - return TRUE; + return !!_tiff_open(this, "r"); } void CCodec_TiffContext::GetFrames(int32_t& frames) { frames = frame_num = TIFFNumberOfDirectories(tif_ctx); @@ -231,11 +227,11 @@ void CCodec_TiffContext::GetFrames(int32_t& frames) { } \ } \ } \ - (key) = NULL; + (key) = nullptr; #define TIFF_EXIF_GETSTRINGINFO(key, tag) \ { \ uint32_t size = 0; \ - uint8_t* buf = NULL; \ + uint8_t* buf = nullptr; \ TIFFGetField(tif_ctx, tag, &size, &buf); \ if (size && buf) { \ (key) = FX_Alloc(uint8_t, size); \ @@ -245,7 +241,7 @@ void CCodec_TiffContext::GetFrames(int32_t& frames) { } \ } \ } \ - (key) = NULL; + (key) = nullptr; namespace { @@ -287,7 +283,7 @@ FX_BOOL CCodec_TiffContext::LoadFrameInfo(int32_t frame, } uint16_t tif_cs; uint32_t tif_icc_size = 0; - uint8_t* tif_icc_buf = NULL; + uint8_t* tif_icc_buf = nullptr; uint16_t tif_bpc = 0; uint16_t tif_cps; uint32_t tif_rps; @@ -399,7 +395,7 @@ FX_BOOL CCodec_TiffContext::Decode1bppRGB(CFX_DIBitmap* pDIBitmap, SetPalette(pDIBitmap, bps); int32_t size = (int32_t)TIFFScanlineSize(tif_ctx); uint8_t* buf = (uint8_t*)_TIFFmalloc(size); - if (buf == NULL) { + if (!buf) { TIFFError(TIFFFileName(tif_ctx), "No space for scanline buffer"); return FALSE; } @@ -426,7 +422,7 @@ FX_BOOL CCodec_TiffContext::Decode8bppRGB(CFX_DIBitmap* pDIBitmap, SetPalette(pDIBitmap, bps); int32_t size = (int32_t)TIFFScanlineSize(tif_ctx); uint8_t* buf = (uint8_t*)_TIFFmalloc(size); - if (buf == NULL) { + if (!buf) { TIFFError(TIFFFileName(tif_ctx), "No space for scanline buffer"); return FALSE; } @@ -459,7 +455,7 @@ FX_BOOL CCodec_TiffContext::Decode24bppRGB(CFX_DIBitmap* pDIBitmap, } int32_t size = (int32_t)TIFFScanlineSize(tif_ctx); uint8_t* buf = (uint8_t*)_TIFFmalloc(size); - if (buf == NULL) { + if (!buf) { TIFFError(TIFFFileName(tif_ctx), "No space for scanline buffer"); return FALSE; } diff --git a/core/fxcodec/codec/include/ccodec_progressivedecoder.h b/core/fxcodec/codec/include/ccodec_progressivedecoder.h index 83b73e1ba7..5421d73494 100644 --- a/core/fxcodec/codec/include/ccodec_progressivedecoder.h +++ b/core/fxcodec/codec/include/ccodec_progressivedecoder.h @@ -73,7 +73,7 @@ class CCodec_ProgressiveDecoder { class CFXCODEC_WeightTable { public: - CFXCODEC_WeightTable() { m_pWeightTables = NULL; } + CFXCODEC_WeightTable() { m_pWeightTables = nullptr; } ~CFXCODEC_WeightTable() { FX_Free(m_pWeightTables); } void Calc(int dest_len, @@ -93,7 +93,7 @@ class CCodec_ProgressiveDecoder { class CFXCODEC_HorzTable { public: - CFXCODEC_HorzTable() { m_pWeightTables = NULL; } + CFXCODEC_HorzTable() { m_pWeightTables = nullptr; } ~CFXCODEC_HorzTable() { FX_Free(m_pWeightTables); } void Calc(int dest_len, int src_len, FX_BOOL bInterpol); @@ -107,7 +107,7 @@ class CCodec_ProgressiveDecoder { class CFXCODEC_VertTable { public: - CFXCODEC_VertTable() { m_pWeightTables = NULL; } + CFXCODEC_VertTable() { m_pWeightTables = nullptr; } ~CFXCODEC_VertTable() { FX_Free(m_pWeightTables); } void Calc(int dest_len, int src_len); PixelWeight* GetPixelWeight(int pixel) { -- cgit v1.2.3