From 1f8196f3b45dd418fa0d40827cbb563ee568c622 Mon Sep 17 00:00:00 2001 From: fanzhihao8 Date: Tue, 29 Jul 2025 18:48:15 +0800 Subject: [PATCH 1/7] fix for warnings Signed-off-by: fanzhihao8 --- .../libs/image/libextplugin/src/ext_decoder.cpp | 8 ++++---- .../libs/image/libextplugin/src/ext_encoder.cpp | 2 +- .../libs/image/libjpegplugin/include/jpeg_utils.h | 2 +- .../libs/image/libjpegplugin/src/jpeg_decoder.cpp | 12 ++++++------ .../libs/image/libjpegplugin/src/jpeg_encoder.cpp | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp b/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp index 919f6677b..dd2b07312 100644 --- a/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp +++ b/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp @@ -978,14 +978,14 @@ void ExtDecoder::FillYuvInfo(DecodeContext &context, SkImageInfo &dstInfo) { if (context.allocatorType == AllocatorType::SHARE_MEM_ALLOC) { context.yuvInfo.imageSize = {dstInfo.width(), dstInfo.height()}; - context.yuvInfo.yWidth = dstInfo.width(); - context.yuvInfo.yHeight = dstInfo.height(); + context.yuvInfo.yWidth = static_cast(dstInfo.width()); + context.yuvInfo.yHeight = static_cast(dstInfo.height()); context.yuvInfo.uvWidth = static_cast((dstInfo.width() + 1) / BYTES_PER_YUV_SAMPLE); context.yuvInfo.uvHeight = static_cast((dstInfo.height() + 1) / BYTES_PER_YUV_SAMPLE); - context.yuvInfo.yStride = dstInfo.width(); + context.yuvInfo.yStride = static_cast(dstInfo.width()); context.yuvInfo.uvStride = context.yuvInfo.uvWidth + context.yuvInfo.uvWidth; context.yuvInfo.yOffset = 0; - context.yuvInfo.uvOffset = dstInfo.width() * dstInfo.height(); + context.yuvInfo.uvOffset = static_cast(dstInfo.width() * dstInfo.height()); } } diff --git a/plugins/common/libs/image/libextplugin/src/ext_encoder.cpp b/plugins/common/libs/image/libextplugin/src/ext_encoder.cpp index a64b200fd..167ce5642 100644 --- a/plugins/common/libs/image/libextplugin/src/ext_encoder.cpp +++ b/plugins/common/libs/image/libextplugin/src/ext_encoder.cpp @@ -919,7 +919,7 @@ uint32_t ExtEncoder::EncodeImageBySurfaceBuffer(sptr& surfaceBuff pixels = dstData.get(); rowStride = info.minRowBytes64(); } else { - rowStride = surfaceBuffer->GetStride(); + rowStride = static_cast(surfaceBuffer->GetStride()); } cond = !bitmap.installPixels(info, pixels, rowStride); CHECK_ERROR_RETURN_RET_LOG(cond, ERR_IMAGE_ENCODE_FAILED, diff --git a/plugins/common/libs/image/libjpegplugin/include/jpeg_utils.h b/plugins/common/libs/image/libjpegplugin/include/jpeg_utils.h index 49f2efe4c..9d1f2f8e7 100644 --- a/plugins/common/libs/image/libjpegplugin/include/jpeg_utils.h +++ b/plugins/common/libs/image/libjpegplugin/include/jpeg_utils.h @@ -41,7 +41,7 @@ struct ErrorMgr : jpeg_error_mgr { #ifdef _WIN32 jmp_buf setjmp_buffer = {{0}}; // for return to caller #else - jmp_buf setjmp_buffer; // for return to caller + jmp_buf setjmp_buffer = {{0}}; // for return to caller #endif }; diff --git a/plugins/common/libs/image/libjpegplugin/src/jpeg_decoder.cpp b/plugins/common/libs/image/libjpegplugin/src/jpeg_decoder.cpp index 8eb0b9e15..f0c38bc5c 100644 --- a/plugins/common/libs/image/libjpegplugin/src/jpeg_decoder.cpp +++ b/plugins/common/libs/image/libjpegplugin/src/jpeg_decoder.cpp @@ -193,8 +193,8 @@ uint32_t JpegDecoder::GetImageSize(uint32_t index, Size &size) return ERR_MEDIA_INVALID_OPERATION; } if (state_ >= JpegDecodingState::BASE_INFO_PARSED) { - size.width = decodeInfo_.image_width; - size.height = decodeInfo_.image_height; + size.width = static_cast(decodeInfo_.image_width); + size.height = static_cast(decodeInfo_.image_height); return Media::SUCCESS; } // only state JpegDecodingState::SOURCE_INITED and JpegDecodingState::BASE_INFO_PARSING can go here. @@ -204,8 +204,8 @@ uint32_t JpegDecoder::GetImageSize(uint32_t index, Size &size) state_ = JpegDecodingState::BASE_INFO_PARSING; return ret; } - size.width = decodeInfo_.image_width; - size.height = decodeInfo_.image_height; + size.width = static_cast(decodeInfo_.image_width); + size.height = static_cast(decodeInfo_.image_height); state_ = JpegDecodingState::BASE_INFO_PARSED; return Media::SUCCESS; } @@ -336,8 +336,8 @@ uint32_t JpegDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions return ret; } info.pixelFormat = outputFormat_; - info.size.width = decodeInfo_.output_width; - info.size.height = decodeInfo_.output_height; + info.size.width = static_cast(decodeInfo_.output_width); + info.size.height = static_cast(decodeInfo_.output_height); info.alphaType = AlphaType::IMAGE_ALPHA_TYPE_OPAQUE; opts_ = opts; state_ = JpegDecodingState::IMAGE_DECODING; diff --git a/plugins/common/libs/image/libjpegplugin/src/jpeg_encoder.cpp b/plugins/common/libs/image/libjpegplugin/src/jpeg_encoder.cpp index 15cb5c69a..146b567d7 100644 --- a/plugins/common/libs/image/libjpegplugin/src/jpeg_encoder.cpp +++ b/plugins/common/libs/image/libjpegplugin/src/jpeg_encoder.cpp @@ -195,8 +195,8 @@ uint32_t JpegEncoder::SetCommonConfig() "encode image failed, pixel map is null."); CHECK_ERROR_RETURN_RET_LOG(setjmp(jerr_.setjmp_buffer), ERR_IMAGE_ENCODE_FAILED, "encode image error, set config failed."); - encodeInfo_.image_width = pixelMaps_[0]->GetWidth(); - encodeInfo_.image_height = pixelMaps_[0]->GetHeight(); + encodeInfo_.image_width = static_cast(pixelMaps_[0]->GetWidth()); + encodeInfo_.image_height = static_cast(pixelMaps_[0]->GetHeight()); PixelFormat pixelFormat = pixelMaps_[0]->GetPixelFormat(); encodeInfo_.in_color_space = GetEncodeFormat(pixelFormat, encodeInfo_.input_components); if (encodeInfo_.in_color_space == JCS_UNKNOWN) { @@ -337,7 +337,7 @@ uint32_t JpegEncoder::RGBAF16Encoder(const uint8_t *data) CHECK_ERROR_RETURN_RET_LOG(setjmp(jerr_.setjmp_buffer), ERR_IMAGE_ENCODE_FAILED, "encode image error."); jpeg_start_compress(&encodeInfo_, TRUE); uint8_t *base = const_cast(data); - uint32_t rowStride = encodeInfo_.image_width * encodeInfo_.input_components; + uint32_t rowStride = encodeInfo_.image_width * (uint32_t)encodeInfo_.input_components; uint32_t orgRowStride = encodeInfo_.image_width * PIXEL_SIZE_RGBA_F16; uint8_t *buffer = nullptr; auto rowBuffer = std::make_unique(rowStride); -- Gitee From 3c103193736d322b3f36c4b0d815f98a1eca5b4e Mon Sep 17 00:00:00 2001 From: fanzhihao8 Date: Tue, 29 Jul 2025 21:35:24 +0800 Subject: [PATCH 2/7] fix for warnings Signed-off-by: fanzhihao8 --- .../innerkitsimpl/common/src/native_image.cpp | 18 ++++++++++++++---- .../jpeg_yuv_decoder/jpeg_yuv_decoder_test.cpp | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/frameworks/innerkitsimpl/common/src/native_image.cpp b/frameworks/innerkitsimpl/common/src/native_image.cpp index 201420ced..83095cff4 100644 --- a/frameworks/innerkitsimpl/common/src/native_image.cpp +++ b/frameworks/innerkitsimpl/common/src/native_image.cpp @@ -180,6 +180,19 @@ int32_t NativeImage::CombineYUVComponents() return SUCCESS; } + uint8_t* buffer = GetSurfaceBufferAddr(); + if (buffer == nullptr) { + IMAGE_LOGE("SurfaceBuffer viraddr is nullptr"); + return ERR_MEDIA_NULL_POINTER; + } + + uint64_t bufferSize = NUM_0; + res = GetDataSize(bufferSize); + if (res != SUCCESS || bufferSize == NUM_0) { + IMAGE_LOGE("bufferSize is 0"); + return ERR_MEDIA_DATA_UNSUPPORT; + } + auto y = GetComponent(int32_t(ComponentType::YUV_Y)); auto u = GetComponent(int32_t(ComponentType::YUV_U)); auto v = GetComponent(int32_t(ComponentType::YUV_V)); @@ -192,10 +205,7 @@ int32_t NativeImage::CombineYUVComponents() data.u = u->raw; data.v = v->raw; - uint64_t bufferSize = NUM_0; - GetDataSize(bufferSize); - - YUV422SPDataCopy(GetSurfaceBufferAddr(), bufferSize, data, true); + YUV422SPDataCopy(buffer, bufferSize, data, true); return SUCCESS; } diff --git a/frameworks/innerkitsimpl/test/unittest/jpeg_yuv_decoder/jpeg_yuv_decoder_test.cpp b/frameworks/innerkitsimpl/test/unittest/jpeg_yuv_decoder/jpeg_yuv_decoder_test.cpp index 805ada8bd..bd048c8ec 100644 --- a/frameworks/innerkitsimpl/test/unittest/jpeg_yuv_decoder/jpeg_yuv_decoder_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/jpeg_yuv_decoder/jpeg_yuv_decoder_test.cpp @@ -56,27 +56,38 @@ bool JpgYuvDecoderTest::ReadImageData(std::string jpgpath, uint8_t*& jpegBuffer, } int ret = fseek(jpgFile, 0, SEEK_END); if (ret != 0) { + fclose(jpgFile); return false; } - jpegBufferSize = static_cast(ftell(jpgFile)); + jpegBufferSize = static_cast(ftell(jpgFile)); ret = fseek(jpgFile, 0, SEEK_SET); if (ret != 0) { + fclose(jpgFile); return false; } if (jpegBufferSize == 0 || jpegBufferSize > PIXEL_MAP_MAX_RAM_SIZE) { + fclose(jpgFile); return false; } else { jpegBuffer = new uint8_t[jpegBufferSize]; } if (jpegBuffer == nullptr) { + fclose(jpgFile); return false; } - jpegBufferSize = fread(jpegBuffer, 1, jpegBufferSize, jpgFile); - if (jpegBufferSize == 0) { + uint32_t readSize = fread(jpegBuffer, 1, jpegBufferSize, jpgFile); + if (readSize == 0) { + delete[] jpegBuffer; + jpegBuffer = nullptr; + fclose(jpgFile); return false; } + jpegBufferSize = readSize; + ret = fclose(jpgFile); if (ret != 0) { + delete[] jpegBuffer; + jpegBuffer = nullptr; return false; } return true; -- Gitee From ef3728838216475cbf9db4ac32d05e0a47e5e467 Mon Sep 17 00:00:00 2001 From: fanzhihao8 Date: Tue, 29 Jul 2025 22:02:11 +0800 Subject: [PATCH 3/7] fix for warnings Signed-off-by: fanzhihao8 --- plugins/common/libs/image/libjpegplugin/include/jpeg_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/common/libs/image/libjpegplugin/include/jpeg_utils.h b/plugins/common/libs/image/libjpegplugin/include/jpeg_utils.h index 9d1f2f8e7..e610d9276 100644 --- a/plugins/common/libs/image/libjpegplugin/include/jpeg_utils.h +++ b/plugins/common/libs/image/libjpegplugin/include/jpeg_utils.h @@ -41,7 +41,7 @@ struct ErrorMgr : jpeg_error_mgr { #ifdef _WIN32 jmp_buf setjmp_buffer = {{0}}; // for return to caller #else - jmp_buf setjmp_buffer = {{0}}; // for return to caller + jmp_buf setjmp_buffer = {}; // for return to caller #endif }; -- Gitee From e6458a26def906e7abee831d601ecfbe42989ddf Mon Sep 17 00:00:00 2001 From: fanzhihao8 Date: Wed, 30 Jul 2025 10:17:38 +0800 Subject: [PATCH 4/7] fix for warnings Signed-off-by: fanzhihao8 --- .../common/ndk/image_receiver_native.cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/frameworks/kits/native/common/ndk/image_receiver_native.cpp b/frameworks/kits/native/common/ndk/image_receiver_native.cpp index fc9a52e0d..654ef2ac7 100644 --- a/frameworks/kits/native/common/ndk/image_receiver_native.cpp +++ b/frameworks/kits/native/common/ndk/image_receiver_native.cpp @@ -86,6 +86,10 @@ Image_ErrorCode OH_ImageReceiverOptions_Create(OH_ImageReceiverOptions** options MIDK_EXPORT Image_ErrorCode OH_ImageReceiverOptions_GetSize(OH_ImageReceiverOptions* options, Image_Size* size) { + if (nullptr == size) { + IMAGE_LOGE("Invalid parameter: size=null."); + return IMAGE_BAD_PARAMETER; + } if (nullptr == options) { IMAGE_LOGE("Invalid parameter: options=null."); return IMAGE_BAD_PARAMETER; @@ -110,6 +114,10 @@ Image_ErrorCode OH_ImageReceiverOptions_SetSize(OH_ImageReceiverOptions* options MIDK_EXPORT Image_ErrorCode OH_ImageReceiverOptions_GetCapacity(OH_ImageReceiverOptions* options, int32_t* capacity) { + if (nullptr == capacity) { + IMAGE_LOGE("Invalid parameter: capacity=null."); + return IMAGE_BAD_PARAMETER; + } if (nullptr == options) { IMAGE_LOGE("Invalid parameter: options=null."); return IMAGE_BAD_PARAMETER; @@ -176,6 +184,10 @@ static bool ConvertToUint64(const std::string& str, uint64_t& value) MIDK_EXPORT Image_ErrorCode OH_ImageReceiverNative_GetReceivingSurfaceId(OH_ImageReceiverNative* receiver, uint64_t* surfaceId) { + if (nullptr == surfaceId) { + IMAGE_LOGE("Invalid parameter: surfaceId=null."); + return IMAGE_BAD_PARAMETER; + } if (nullptr == receiver) { IMAGE_LOGE("Invalid parameter: receiver=null."); return IMAGE_BAD_PARAMETER; @@ -202,6 +214,10 @@ Image_ErrorCode OH_ImageReceiverNative_GetReceivingSurfaceId(OH_ImageReceiverNat MIDK_EXPORT Image_ErrorCode OH_ImageReceiverNative_ReadLatestImage(OH_ImageReceiverNative* receiver, OH_ImageNative** image) { + if (nullptr == image) { + IMAGE_LOGE("Invalid parameter: image=null."); + return IMAGE_BAD_PARAMETER; + } if (nullptr == receiver) { IMAGE_LOGE("Invalid parameter: receiver=null."); return IMAGE_BAD_PARAMETER; @@ -245,6 +261,10 @@ Image_ErrorCode OH_ImageReceiverNative_ReadLatestImage(OH_ImageReceiverNative* r MIDK_EXPORT Image_ErrorCode OH_ImageReceiverNative_ReadNextImage(OH_ImageReceiverNative* receiver, OH_ImageNative** image) { + if (nullptr == image) { + IMAGE_LOGE("Invalid parameter: image=null."); + return IMAGE_BAD_PARAMETER; + } if (nullptr == receiver) { IMAGE_LOGE("Invalid parameter: receiver=null."); return IMAGE_BAD_PARAMETER; -- Gitee From 2b22a224081b3c9bb5ae27886c69afb92b6b8caa Mon Sep 17 00:00:00 2001 From: fanzhihao8 Date: Wed, 30 Jul 2025 11:31:32 +0800 Subject: [PATCH 5/7] fix for warnings Signed-off-by: fanzhihao8 --- .../common/libs/image/libextplugin/src/ext_decoder.cpp | 8 ++++---- .../common/libs/image/libjpegplugin/src/jpeg_encoder.cpp | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp b/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp index dd2b07312..4cb6891b3 100644 --- a/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp +++ b/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp @@ -641,8 +641,8 @@ uint32_t ExtDecoder::GetImageSize(uint32_t index, Size &size) // Info has been get in check process, or empty on get failed. CHECK_ERROR_RETURN_RET_LOG(info_.isEmpty(), ERR_IMAGE_DECODE_HEAD_ABNORMAL, "GetImageSize failed, decode header failed."); - size.width = static_cast(info_.width()); - size.height = static_cast(info_.height()); + size.width = info_.width(); + size.height = info_.height(); return SUCCESS; } @@ -785,8 +785,8 @@ uint32_t ExtDecoder::SetDecodeOptions(uint32_t index, const PixelDecodeOptions & getDesiredColorSpace(info_, opts)); } - info.size.width = static_cast(dstInfo_.width()); - info.size.height = static_cast(dstInfo_.height()); + info.size.width = dstInfo_.width(); + info.size.height = dstInfo_.height(); reusePixelmap_ = opts.plReusePixelmap; return SUCCESS; } diff --git a/plugins/common/libs/image/libjpegplugin/src/jpeg_encoder.cpp b/plugins/common/libs/image/libjpegplugin/src/jpeg_encoder.cpp index 146b567d7..d74f9de2f 100644 --- a/plugins/common/libs/image/libjpegplugin/src/jpeg_encoder.cpp +++ b/plugins/common/libs/image/libjpegplugin/src/jpeg_encoder.cpp @@ -239,7 +239,7 @@ uint32_t JpegEncoder::SequenceEncoder(const uint8_t *data) #endif uint8_t *base = const_cast(data); - uint32_t rowStride = encodeInfo_.image_width * (uint32_t)encodeInfo_.input_components; + uint32_t rowStride = encodeInfo_.image_width * static_cast(encodeInfo_.input_components); uint8_t *buffer = nullptr; while (encodeInfo_.next_scanline < encodeInfo_.image_height) { buffer = base + encodeInfo_.next_scanline * rowStride; @@ -337,7 +337,7 @@ uint32_t JpegEncoder::RGBAF16Encoder(const uint8_t *data) CHECK_ERROR_RETURN_RET_LOG(setjmp(jerr_.setjmp_buffer), ERR_IMAGE_ENCODE_FAILED, "encode image error."); jpeg_start_compress(&encodeInfo_, TRUE); uint8_t *base = const_cast(data); - uint32_t rowStride = encodeInfo_.image_width * (uint32_t)encodeInfo_.input_components; + uint32_t rowStride = encodeInfo_.image_width * static_cast(encodeInfo_.input_components); uint32_t orgRowStride = encodeInfo_.image_width * PIXEL_SIZE_RGBA_F16; uint8_t *buffer = nullptr; auto rowBuffer = std::make_unique(rowStride); @@ -366,7 +366,7 @@ uint32_t JpegEncoder::RGB565Encoder(const uint8_t *data) uint32_t orgRowStride = encodeInfo_.image_width * PIXEL_SIZE_RGB565; uint8_t *orgRowBuffer = nullptr; - uint32_t outRowStride = encodeInfo_.image_width * encodeInfo_.input_components; + uint32_t outRowStride = encodeInfo_.image_width * static_cast(encodeInfo_.input_components); auto outRowBuffer = std::make_unique(outRowStride); while (encodeInfo_.next_scanline < encodeInfo_.image_height) { -- Gitee From c077067d5e3bf8fee1b27d2ec5f07d03079a372e Mon Sep 17 00:00:00 2001 From: fanzhihao8 Date: Wed, 30 Jul 2025 15:55:38 +0800 Subject: [PATCH 6/7] fix for warnings Signed-off-by: fanzhihao8 --- .../image/libextplugin/src/ext_decoder.cpp | 6 +++--- .../image/libjpegplugin/src/jpeg_decoder.cpp | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp b/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp index 4cb6891b3..04db7addf 100644 --- a/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp +++ b/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp @@ -1582,11 +1582,11 @@ uint32_t ExtDecoder::AllocOutputBuffer(DecodeContext &context, "Alloc OutputBuffer failed, context is null"); BufferHandle *handle = (static_cast(context.pixelsBuffer.context))->GetBufferHandle(); if (outputColorFmt_ == V1_2::PIXEL_FMT_RGBA_8888) { - outputBufferSize_.width = static_cast(handle->stride) / NUM_4; + outputBufferSize_.width = handle->stride / NUM_4; } else { - outputBufferSize_.width = static_cast(handle->stride); + outputBufferSize_.width = handle->stride; } - outputBufferSize_.height = static_cast(handle->height); + outputBufferSize_.height = handle->height; outputBuffer.buffer = new NativeBuffer(handle); outputBuffer.fenceFd = -1; return SUCCESS; diff --git a/plugins/common/libs/image/libjpegplugin/src/jpeg_decoder.cpp b/plugins/common/libs/image/libjpegplugin/src/jpeg_decoder.cpp index f0c38bc5c..9bb9c148b 100644 --- a/plugins/common/libs/image/libjpegplugin/src/jpeg_decoder.cpp +++ b/plugins/common/libs/image/libjpegplugin/src/jpeg_decoder.cpp @@ -255,18 +255,18 @@ J_COLOR_SPACE JpegDecoder::GetDecodeFormat(PixelFormat format, PixelFormat &outp static int CalculateInSampleSize(const jpeg_decompress_struct &dInfo, const PixelDecodeOptions &opts) { - int inSampleSize = 1; + unsigned int inSampleSize = 1; // Input height and width of image - int width = dInfo.image_width; - int height = dInfo.image_height; + unsigned int width = dInfo.image_width; + unsigned int height = dInfo.image_height; if (opts.desiredSize.height > 0 && opts.desiredSize.width > 0) { - int reqHeight = opts.desiredSize.height; - int reqWidth = opts.desiredSize.width; + unsigned int reqHeight = static_cast(opts.desiredSize.height); + unsigned int reqWidth = static_cast(opts.desiredSize.width); if (height > reqHeight || width > reqWidth) { - const int halfHeight = height >> 1; - const int halfWidth = width >> 1; + const unsigned int halfHeight = height >> 1; + const unsigned int halfWidth = width >> 1; // Calculate the largest inSampleSize value that is a power of 2 and keeps both // height and width larger than the requested height and width. @@ -275,7 +275,7 @@ static int CalculateInSampleSize(const jpeg_decompress_struct &dInfo, const Pixe } } } - return inSampleSize; + return static_cast(inSampleSize); } /* @@ -473,7 +473,7 @@ uint32_t JpegDecoder::DoSwDecode(DecodeContext &context) __attribute__((no_sanit #if !defined(ANDROID_PLATFORM) && !defined(IOS_PLATFORM) if (context.allocatorType == Media::AllocatorType::DMA_ALLOC) { SurfaceBuffer* sbBuffer = reinterpret_cast (context.pixelsBuffer.context); - rowStride = sbBuffer->GetStride(); + rowStride = static_cast(sbBuffer->GetStride()); } #endif while (decodeInfo_.output_scanline < decodeInfo_.output_height) { -- Gitee From b0f4eb572ff2ba6dc97a6f76557261d4069f16fb Mon Sep 17 00:00:00 2001 From: fanzhihao8 Date: Wed, 30 Jul 2025 20:10:15 +0800 Subject: [PATCH 7/7] fix for warnings Signed-off-by: fanzhihao8 --- .../libextplugin/include/hardware/jpeg_hw_decoder.h | 10 +++++----- .../common/libs/image/libextplugin/src/ext_decoder.cpp | 3 ++- .../libextplugin/src/hardware/jpeg_hw_decoder.cpp | 10 +++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/plugins/common/libs/image/libextplugin/include/hardware/jpeg_hw_decoder.h b/plugins/common/libs/image/libextplugin/include/hardware/jpeg_hw_decoder.h index 9e184857e..acecbac3d 100644 --- a/plugins/common/libs/image/libextplugin/include/hardware/jpeg_hw_decoder.h +++ b/plugins/common/libs/image/libextplugin/include/hardware/jpeg_hw_decoder.h @@ -126,11 +126,11 @@ private: OHOS::HDI::Display::Buffer::V1_0::IDisplayBuffer* bufferMgr_; OHOS::HDI::Codec::Image::V2_1::CodecImageBuffer inputBuffer_; OHOS::HDI::Codec::Image::V2_1::CodecJpegDecInfo decodeInfo_; - uint32_t compressDataPos_; - uint32_t compressDataSize_; - bool useDmaPool_; - uint32_t usedSizeInPool_; - uint32_t usedOffsetInPool_; + uint32_t compressDataPos_ {0}; + uint32_t compressDataSize_ {0}; + bool useDmaPool_ {false}; + uint32_t usedSizeInPool_ {0}; + uint32_t usedOffsetInPool_ {0}; }; } // namespace ImagePlugin } // namespace OHOS diff --git a/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp b/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp index 04db7addf..c52458ae7 100644 --- a/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp +++ b/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp @@ -1554,7 +1554,8 @@ void ExtDecoder::ReportImageType(SkEncodedImageFormat skEncodeFormat) "PVERSIONID", DEFAULT_VERSION_ID, "IMAGE_TYPE", GetFormatStr(skEncodeFormat) ); - CHECK_DEBUG_RETURN_LOG(SUCCESS != ret, "ExtDecoder::ReportImageType failed, ret = %{public}d", ret); + uint32_t tmpRet = static_cast(ret); + CHECK_DEBUG_RETURN_LOG(SUCCESS != tmpRet, "ExtDecoder::ReportImageType failed, ret = %{public}d", ret); #endif IMAGE_LOGD("ExtDecoder::ReportImageType format %{public}d success", skEncodeFormat); } diff --git a/plugins/common/libs/image/libextplugin/src/hardware/jpeg_hw_decoder.cpp b/plugins/common/libs/image/libextplugin/src/hardware/jpeg_hw_decoder.cpp index 45629d4a3..8be3101ca 100644 --- a/plugins/common/libs/image/libextplugin/src/hardware/jpeg_hw_decoder.cpp +++ b/plugins/common/libs/image/libextplugin/src/hardware/jpeg_hw_decoder.cpp @@ -236,7 +236,7 @@ bool JpegHardwareDecoder::AssembleComponentInfo(jpeg_decompress_struct* jpegComp JPEG_HW_LOGE("unsupported component number: %{public}d!", jpegCompressInfo->num_components); return false; } - decodeInfo_.numComponents = jpegCompressInfo->num_components; + decodeInfo_.numComponents = static_cast(jpegCompressInfo->num_components); for (int i = 0; i < jpegCompressInfo->num_components; ++i) { decodeInfo_.compInfo.emplace_back(CodecJpegCompInfo { .componentId = jpegCompressInfo->comp_info[i].component_id, @@ -316,7 +316,7 @@ bool JpegHardwareDecoder::AssembleJpegImgHeader(jpeg_decompress_struct* jpegComp { decodeInfo_.imageWidth = jpegCompressInfo->image_width; decodeInfo_.imageHeight = jpegCompressInfo->image_height; - decodeInfo_.dataPrecision = jpegCompressInfo->data_precision; + decodeInfo_.dataPrecision = static_cast(jpegCompressInfo->data_precision); decodeInfo_.restartInterval = jpegCompressInfo->restart_interval; decodeInfo_.arithCode = jpegCompressInfo->arith_code; decodeInfo_.progressiveMode = jpegCompressInfo->progressive_mode; @@ -522,9 +522,9 @@ bool JpegHardwareDecoder::PackingInputBufferHandle(BufferHandle* inputBufferHand return false; } curHandle->fd = inputBufferHandle->fd; - curHandle->size = usedSizeInPool_; - curHandle->width = usedSizeInPool_; - curHandle->stride = usedSizeInPool_; + curHandle->size = static_cast(usedSizeInPool_); + curHandle->width = static_cast(usedSizeInPool_); + curHandle->stride = static_cast(usedSizeInPool_); curHandle->height = 1; curHandle->reserveFds = 0; curHandle->reserveInts = 0; -- Gitee