diff --git a/frameworks/innerkitsimpl/test/fuzztest/BUILD.gn b/frameworks/innerkitsimpl/test/fuzztest/BUILD.gn index ff4d013c41fa5a6e41f6b44fac1622769e9ce3c2..f6ed4b391c46926df8d1cedadbc214f1e25cb865 100644 --- a/frameworks/innerkitsimpl/test/fuzztest/BUILD.gn +++ b/frameworks/innerkitsimpl/test/fuzztest/BUILD.gn @@ -44,7 +44,6 @@ group("fuzztest") { "imagepixelmaptlv2_fuzzer:ImagePixelmaptlv2FuzzTest", "imagepixelmapsetalpha_fuzzer:ImagePixelmapSetAlphaFuzzTest", "imagepixelmapsetalpha2_fuzzer:ImagePixelmapsetalpha2FuzzTest", - "imageplugin_fuzzer:ImagePluginFuzzTest", "imageplugin2_fuzzer:ImagePlugin2FuzzTest", "imagepngplugin_fuzzer:ImagePngPluginFuzzTest", "imagepngplugin2_fuzzer:ImagePngPlugin2FuzzTest", diff --git a/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertp010yuv2rgb_fuzzer/BUILD.gn b/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertp010yuv2rgb_fuzzer/BUILD.gn deleted file mode 100644 index e8218f42d975d04129b2d413006b9b8c55f6c0ce..0000000000000000000000000000000000000000 --- a/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertp010yuv2rgb_fuzzer/BUILD.gn +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/test.gni") -import("//foundation/multimedia/image_framework/ide/image_decode_config.gni") - -ohos_fuzztest("ImageFwkConvertP010Yuv2RgbFuzzTest") { - module_out_path = "image_framework/image_framework" - fuzz_config_file = "$image_subsystem/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertp010yuv2rgb_fuzzer" - resource_config_file = "$image_subsystem/test/resource/image/ohos_test.xml" - - include_dirs = [ - "./include", - "$image_subsystem/interfaces/innerkits/include", - "$image_subsystem/frameworks/innerkitsimpl/converter/include", - ] - - sources = [ "src/image_fwk_convert_p010yuv2rgb_fuzzer.cpp" ] - - defines = [ "EXT_PIXEL" ] - - deps = [ "$image_subsystem/interfaces/innerkits:image_native" ] - - external_deps = [ - "c_utils:utils", - "hilog:libhilog", - "ipc:ipc_core", - ] -} diff --git a/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertp010yuv2rgb_fuzzer/include/image_fwk_convert_p010yuv2rgb_fuzzer.h b/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertp010yuv2rgb_fuzzer/include/image_fwk_convert_p010yuv2rgb_fuzzer.h deleted file mode 100644 index 4fcfc9d51c3b7734501c43398d009a30aaafad0a..0000000000000000000000000000000000000000 --- a/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertp010yuv2rgb_fuzzer/include/image_fwk_convert_p010yuv2rgb_fuzzer.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef IMAGE_FWK_CONVERT_P010YUV2RGB_FUZZER_H -#define IMAGE_FWK_CONVERT_P010YUV2RGB_FUZZER_H - -#define FUZZ_PROJECT_NAME "image_fwk_convert_p010yuv2rgb_fuzzer" -#endif \ No newline at end of file diff --git a/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertp010yuv2rgb_fuzzer/project.xml b/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertp010yuv2rgb_fuzzer/project.xml deleted file mode 100644 index 8b63c0e579ed4235d4d1d440b94ecb78aac04050..0000000000000000000000000000000000000000 --- a/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertp010yuv2rgb_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 52428800 - - 300 - - 4096 - - diff --git a/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertp010yuv2rgb_fuzzer/src/image_fwk_convert_p010yuv2rgb_fuzzer.cpp b/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertp010yuv2rgb_fuzzer/src/image_fwk_convert_p010yuv2rgb_fuzzer.cpp deleted file mode 100644 index 41d91103ab574287c962dc2636a2a95b8d522524..0000000000000000000000000000000000000000 --- a/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertp010yuv2rgb_fuzzer/src/image_fwk_convert_p010yuv2rgb_fuzzer.cpp +++ /dev/null @@ -1,372 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define private public -#include "image_fwk_convert_p010yuv2rgb_fuzzer.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "buffer_packer_stream.h" -#include "image_format_convert.h" -#include "image_format_convert_utils.h" -#include "image_log.h" -#include "image_source.h" -#include "image_type.h" -#include "image_utils.h" -#include "media_errors.h" -#include "pixel_map.h" -#include "message_parcel.h" - -namespace OHOS { -namespace Media { - -constexpr int32_t P010_ORIGINAL_WIDTH = 1920; -constexpr int32_t P010_ORIGINAL_HEIGHT = 1080; -constexpr uint32_t BYTES_PER_PIXEL_RGB565 = 2; -constexpr uint32_t BYTES_PER_PIXEL_RGB = 3; -constexpr uint32_t BYTES_PER_PIXEL_RGBA = 4; -constexpr uint32_t BYTES_PER_PIXEL_BGRA = 4; -constexpr uint32_t EVEN_ODD_DIVISOR = 2; -constexpr uint32_t TWO_SLICES = 2; -constexpr int32_t NUM_2 = 2; - -struct ImageSize { - int32_t width = 0; - int32_t height = 0; - float dstWidth = 0; - float dstHeight = 0; - const uint32_t color = 0; - uint32_t dst = 0; -}; - -static const std::string IMAGE_INPUT_YUV_PATH3 = "/data/local/tmp/P010.yuv"; - -bool ReadFile(void *chOrg, std::string path, int32_t totalsize, int32_t srcNum) -{ - FILE* const fileOrg = fopen(path.c_str(), "rb"); - if (fileOrg == nullptr) { - return false; - } - if (srcNum == 0) { - size_t bytesOrg = fread(chOrg, sizeof(uint8_t), static_cast(totalsize), fileOrg); - if (bytesOrg < static_cast(totalsize)) { - fclose(fileOrg); - return false; - } - } else { - size_t bytesOrg = fread(chOrg, sizeof(uint16_t), static_cast(totalsize), fileOrg); - if (bytesOrg < static_cast(totalsize)) { - fclose(fileOrg); - return false; - } - } - fclose(fileOrg); - return true; -} - -void YuvP010ConvertToRgb(PixelFormat &srcFormat, PixelFormat &destFormat, Size &srcSize, - uint32_t destBuffersize) -{ - IMAGE_LOGI("YuvP010ConvertToRgb: start"); - ImageSize imageSize; - imageSize.width = srcSize.width; - imageSize.height = srcSize.height; - int32_t ySize = imageSize.width * imageSize.height; - int32_t uvSize = ((imageSize.width + 1) / NUM_2) * ((imageSize.height + 1) / NUM_2); - const size_t totalSize = (ySize + NUM_2 * uvSize); - uint16_t* const chOrg = new uint16_t[totalSize]; - bool result = ReadFile(chOrg, IMAGE_INPUT_YUV_PATH3, totalSize, 1); - if (!result) { - delete[] chOrg; - return; - } - const uint32_t dataLength = totalSize * NUM_2; - uint32_t *data = reinterpret_cast(chOrg); - InitializationOptions opts; - opts.srcPixelFormat = srcFormat; - opts.pixelFormat = srcFormat; - opts.alphaType = AlphaType::IMAGE_ALPHA_TYPE_OPAQUE; - opts.size.width = imageSize.width; - opts.size.height = imageSize.height; - std::unique_ptr pixelMap = PixelMap::Create(data, dataLength, opts); - if (pixelMap.get() == nullptr) { - delete[] chOrg; - return; - } - delete[] chOrg; - std::shared_ptr srcPixelMap = std::move(pixelMap); - uint32_t ret = ImageFormatConvert::ConvertImageFormat(srcPixelMap, destFormat); - if (ret != SUCCESS || srcPixelMap->GetPixelFormat() != destFormat) { - srcPixelMap->FreePixelMap(); - IMAGE_LOGE("YuvP010ConvertToRgb: CreatePixelMap fail"); - return; - } - srcPixelMap->FreePixelMap(); - IMAGE_LOGI("YuvP010ConvertToRgb: succ"); -} - -void NV12P010ToNV12FuzzTest003() -{ - IMAGE_LOGI("NV12P010ToNV12FuzzTest003: start"); - PixelFormat srcFormat = PixelFormat::YCBCR_P010; - PixelFormat destFormat = PixelFormat::NV12; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height + ((srcSize.width + 1) / EVEN_ODD_DIVISOR) * - ((srcSize.height + 1) / EVEN_ODD_DIVISOR) * TWO_SLICES; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV12P010ToNV12FuzzTest003: end"); -} - -void NV12P010ToNV21FuzzTest003() -{ - IMAGE_LOGI("NV12P010ToNV21FuzzTest003: start"); - PixelFormat srcFormat = PixelFormat::YCBCR_P010; - PixelFormat destFormat = PixelFormat::NV21; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height + ((srcSize.width + 1) / EVEN_ODD_DIVISOR) * - ((srcSize.height + 1) / EVEN_ODD_DIVISOR) * TWO_SLICES; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV12P010ToNV21FuzzTest003: end"); -} - -void NV12P010ToNV21P010FuzzTest003() -{ - IMAGE_LOGI("NV12P010ToNV21P010FuzzTest003: start"); - PixelFormat srcFormat = PixelFormat::YCBCR_P010; - PixelFormat destFormat = PixelFormat::YCRCB_P010; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = (srcSize.width * srcSize.height + ((srcSize.width + 1) / EVEN_ODD_DIVISOR) * - ((srcSize.height + 1) / EVEN_ODD_DIVISOR) * TWO_SLICES) * TWO_SLICES; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV12P010ToNV21P010FuzzTest003: end"); -} - -void NV12P010ToRGB565FuzzTest003() -{ - IMAGE_LOGI("NV12P010ToRGB565FuzzTest003: start"); - PixelFormat srcFormat = PixelFormat::YCBCR_P010; - PixelFormat destFormat = PixelFormat::RGB_565; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height * BYTES_PER_PIXEL_RGB565; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV12P010ToRGB565FuzzTest003: end"); -} - -void NV12P010ToRGBAFuzzTest003() -{ - IMAGE_LOGI("NV12P010ToRGBAFuzzTest003: start"); - PixelFormat srcFormat = PixelFormat::YCBCR_P010; - PixelFormat destFormat = PixelFormat::RGBA_8888; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height * BYTES_PER_PIXEL_RGBA; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV12P010ToRGBAFuzzTest003: end"); -} - -void NV12P010ToBGRAFuzzTest003() -{ - IMAGE_LOGI("NV12P010ToBGRAFuzzTest003: start"); - PixelFormat srcFormat = PixelFormat::YCBCR_P010; - PixelFormat destFormat = PixelFormat::BGRA_8888; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height * BYTES_PER_PIXEL_BGRA; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV12P010ToBGRAFuzzTest003: end"); -} - -void NV12P010ToRGBFuzzTest003() -{ - IMAGE_LOGI("NV12P010ToRGBFuzzTest003: start"); - PixelFormat srcFormat = PixelFormat::YCBCR_P010; - PixelFormat destFormat = PixelFormat::RGB_888; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height * BYTES_PER_PIXEL_RGB; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV12P010ToRGBFuzzTest003: end"); -} - -void NV12P010ToRGBAF16FuzzTest003() -{ - IMAGE_LOGI("NV12P010ToRGBAF16FuzzTest003: start"); - PixelFormat srcFormat = PixelFormat::YCBCR_P010; - PixelFormat destFormat = PixelFormat::RGBA_F16; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height * sizeof(uint64_t); - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV12P010ToRGBAF16FuzzTest003: end"); -} - -void NV21P010ToNV21FuzzTest003() -{ - IMAGE_LOGI("NV21P010ToNV21FuzzTest003: start"); - PixelFormat srcFormat = PixelFormat::YCRCB_P010; - PixelFormat destFormat = PixelFormat::NV21; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height + ((srcSize.width + 1) / EVEN_ODD_DIVISOR) * - ((srcSize.height + 1) / EVEN_ODD_DIVISOR) * TWO_SLICES; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV21P010ToNV21FuzzTest003: end"); -} - -void NV12P010ToNV12P010FuzzTest003() -{ - IMAGE_LOGI("NV12P010ToNV12P010FuzzTest003: start"); - PixelFormat srcFormat = PixelFormat::YCRCB_P010; - PixelFormat destFormat = PixelFormat::YCBCR_P010; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = (srcSize.width * srcSize.height + ((srcSize.width + 1) / EVEN_ODD_DIVISOR) * - ((srcSize.height + 1) / EVEN_ODD_DIVISOR) * TWO_SLICES) * TWO_SLICES; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV12P010ToNV12P010FuzzTest003: end"); -} - -void NV21P010ToRGB565FuzzTest003() -{ - IMAGE_LOGI("NV21P010ToRGB565FuzzTest003: start"); - PixelFormat srcFormat = PixelFormat::YCRCB_P010; - PixelFormat destFormat = PixelFormat::RGB_565; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height * BYTES_PER_PIXEL_RGB565; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV21P010ToRGB565FuzzTest003: end"); -} - -void NV21P010ToRGBAFuzzTest003() -{ - IMAGE_LOGI("NV21P010ToRGBAFuzzTest003: start"); - PixelFormat srcFormat = PixelFormat::YCRCB_P010; - PixelFormat destFormat = PixelFormat::RGBA_8888; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height * BYTES_PER_PIXEL_RGBA; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV21P010ToRGBAFuzzTest003: end"); -} - -void NV21P010ToBGRAFuzzTest003() -{ - IMAGE_LOGI("NV21P010ToBGRAFuzzTest003: start"); - PixelFormat srcFormat = PixelFormat::YCRCB_P010; - PixelFormat destFormat = PixelFormat::BGRA_8888; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height * BYTES_PER_PIXEL_BGRA; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV21P010ToBGRAFuzzTest003: end"); -} - -void NV21P010ToRGBFuzzTest003() -{ - IMAGE_LOGI("NV21P010ToRGBFuzzTest003: start"); - PixelFormat srcFormat = PixelFormat::YCRCB_P010; - PixelFormat destFormat = PixelFormat::RGB_888; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height * BYTES_PER_PIXEL_RGB; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV21P010ToRGBFuzzTest003: end"); -} - -void NV21P010ToRGBAF16FuzzTest003() -{ - IMAGE_LOGI("NV21P010ToRGBAF16FuzzTest003: start"); - PixelFormat srcFormat = PixelFormat::YCRCB_P010; - PixelFormat destFormat = PixelFormat::RGBA_F16; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height * sizeof(uint64_t); - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV21P010ToRGBAF16FuzzTest003: end"); -} - -void NV12P010ToRGBA1010102FuzzTest004() -{ - IMAGE_LOGI("NV12P010ToRGBA_1010102FuzzTest004: start"); - PixelFormat srcFormat = PixelFormat::YCBCR_P010; - PixelFormat destFormat = PixelFormat::RGBA_1010102; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height * BYTES_PER_PIXEL_RGBA; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV12P010ToRGBA_1010102FuzzTest004: end"); -} - -void NV21P010ToRGBA1010102FuzzTest004() -{ - IMAGE_LOGI("NV21P010ToRGBA_1010102FuzzTest004: start"); - PixelFormat srcFormat = PixelFormat::YCRCB_P010; - PixelFormat destFormat = PixelFormat::RGBA_1010102; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height * BYTES_PER_PIXEL_RGBA; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV21P010ToRGBA_1010102FuzzTest004: end"); -} - -void NV21P010ToNV12FuzzTest003() -{ - IMAGE_LOGI("NV21P010ToNV12FuzzTest003: start"); - PixelFormat srcFormat = PixelFormat::YCRCB_P010; - PixelFormat destFormat = PixelFormat::NV12; - Size srcSize = { P010_ORIGINAL_WIDTH, P010_ORIGINAL_HEIGHT }; - uint32_t destBuffersize = srcSize.width * srcSize.height + ((srcSize.width + 1) / EVEN_ODD_DIVISOR) * - ((srcSize.height + 1) / EVEN_ODD_DIVISOR) * TWO_SLICES; - YuvP010ConvertToRgb(srcFormat, destFormat, srcSize, destBuffersize); - IMAGE_LOGI("NV21P010ToNV12FuzzTest003: end"); -} - -void YuvP010ToRgbFuzzTest001() -{ - IMAGE_LOGI("YuvP010ToRgbTest001: start"); - NV12P010ToNV12FuzzTest003(); - NV12P010ToNV21FuzzTest003(); - NV12P010ToNV21P010FuzzTest003(); - NV12P010ToRGB565FuzzTest003(); - NV12P010ToRGBAFuzzTest003(); - NV12P010ToBGRAFuzzTest003(); - NV12P010ToRGBFuzzTest003(); - NV12P010ToRGBAF16FuzzTest003(); - NV21P010ToNV12FuzzTest003(); - NV21P010ToNV21FuzzTest003(); - NV12P010ToNV12P010FuzzTest003(); - NV21P010ToRGB565FuzzTest003(); - NV21P010ToRGBAFuzzTest003(); - NV21P010ToBGRAFuzzTest003(); - NV21P010ToRGBFuzzTest003(); - NV21P010ToRGBAF16FuzzTest003(); - NV12P010ToRGBA1010102FuzzTest004(); - NV21P010ToRGBA1010102FuzzTest004(); - IMAGE_LOGI("YuvP010ToRgbTest001: end"); -} -} // namespace Media -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - /* Run your code on data */ - int fd = open(OHOS::Media::IMAGE_INPUT_YUV_PATH3.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); - if (write(fd, data, size) != (ssize_t)size) { - close(fd); - IMAGE_LOGE("Fuzzer copy data fail"); - return 0; - } - close(fd); - OHOS::Media::YuvP010ToRgbFuzzTest001(); - return 0; -} \ No newline at end of file diff --git a/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertrgb2yuvp010_fuzzer/src/image_fwk_convert_rgb2yuvp010_fuzzer.cpp b/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertrgb2yuvp010_fuzzer/src/image_fwk_convert_rgb2yuvp010_fuzzer.cpp index 76cfbf8bfa453b6997b34eddf97e52bdb1d4fbd1..7ef8849bd6782db14597d1a994596765e0c580ff 100644 --- a/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertrgb2yuvp010_fuzzer/src/image_fwk_convert_rgb2yuvp010_fuzzer.cpp +++ b/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertrgb2yuvp010_fuzzer/src/image_fwk_convert_rgb2yuvp010_fuzzer.cpp @@ -79,15 +79,6 @@ void RGB565ToNV12P010FuzzTest001() IMAGE_LOGI("RGB565ToNV12P010FuzzTest001: end"); } -void RGB565ToNV12P010FuzzTest002() -{ - IMAGE_LOGI("RGB565ToNV12P010FuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::RGB_565; - PixelFormat destFormat = PixelFormat::YCBCR_P010; - RgbConvertToYuvP010(srcFormat, destFormat); - IMAGE_LOGI("RGB565ToNV12P010FuzzTest002: end"); -} - void RGB565ToNV21P010FuzzTest001() { IMAGE_LOGI("RGB565ToNV21P010FuzzTest001: start"); @@ -97,15 +88,6 @@ void RGB565ToNV21P010FuzzTest001() IMAGE_LOGI("RGB565ToNV21P010FuzzTest001: end"); } -void RGB565ToNV21P010FuzzTest002() -{ - IMAGE_LOGI("RGB565ToNV21P010FuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::RGB_565; - PixelFormat destFormat = PixelFormat::YCRCB_P010; - RgbConvertToYuvP010(srcFormat, destFormat); - IMAGE_LOGI("RGB565ToNV21P010FuzzTest002: end"); -} - void BGRAToNV12P010FuzzTest001() { IMAGE_LOGI("BGRAToNV12P010FuzzTest001: start"); @@ -115,15 +97,6 @@ void BGRAToNV12P010FuzzTest001() IMAGE_LOGI("BGRAToNV12P010FuzzTest001: end"); } -void BGRAToNV12P010FuzzTest002() -{ - IMAGE_LOGI("BGRAToNV12P010FuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::BGRA_8888; - PixelFormat destFormat = PixelFormat::YCBCR_P010; - RgbConvertToYuvP010(srcFormat, destFormat); - IMAGE_LOGI("BGRAToNV12P010FuzzTest002: end"); -} - void BGRAToNV21P010FuzzTest001() { IMAGE_LOGI("BGRAToNV21P010FuzzTest001: start"); @@ -133,15 +106,6 @@ void BGRAToNV21P010FuzzTest001() IMAGE_LOGI("BGRAToNV21P010FuzzTest001: end"); } -void BGRAToNV21P010FuzzTest002() -{ - IMAGE_LOGI("BGRAToNV21P010FuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::BGRA_8888; - PixelFormat destFormat = PixelFormat::YCRCB_P010; - RgbConvertToYuvP010(srcFormat, destFormat); - IMAGE_LOGI("BGRAToNV21P010FuzzTest002: end"); -} - void RgbConvertToYuvP010ByPixelMap(PixelFormat &tempFormat, PixelFormat &srcFormat, PixelFormat &destFormat) { @@ -190,16 +154,6 @@ void RGBAToNV12P010FuzzTest001() IMAGE_LOGI("RGBAToNV12P010FuzzTest001: end"); } -void RGBAToNV12P010FuzzTest002() -{ - IMAGE_LOGI("RGBAToNV12P010FuzzTest002: start"); - PixelFormat tempFormat = PixelFormat::NV12; - PixelFormat srcFormat = PixelFormat::RGBA_8888; - PixelFormat destFormat = PixelFormat::YCBCR_P010; - RgbConvertToYuvP010ByPixelMap(tempFormat, srcFormat, destFormat); - IMAGE_LOGI("RGBAToNV12P010FuzzTest002: end"); -} - void RGBAToNV21P010FuzzTest001() { IMAGE_LOGI("RGBAToNV21P010FuzzTest001: start"); @@ -210,16 +164,6 @@ void RGBAToNV21P010FuzzTest001() IMAGE_LOGI("RGBAToNV21P010FuzzTest001: end"); } -void RGBAToNV21P010FuzzTest002() -{ - IMAGE_LOGI("RGBAToNV21P010FuzzTest002: start"); - PixelFormat tempFormat = PixelFormat::NV21; - PixelFormat srcFormat = PixelFormat::RGBA_8888; - PixelFormat destFormat = PixelFormat::YCRCB_P010; - RgbConvertToYuvP010ByPixelMap(tempFormat, srcFormat, destFormat); - IMAGE_LOGI("RGBAToNV21P010FuzzTest002: end"); -} - void RGBToNV12P010FuzzTest001() { IMAGE_LOGI("RGBToNV12P010FuzzTest001: start"); @@ -230,16 +174,6 @@ void RGBToNV12P010FuzzTest001() IMAGE_LOGI("RGBToNV12P010FuzzTest001: end"); } -void RGBToNV12P010FuzzTest002() -{ - IMAGE_LOGI("RGBToNV12P010FuzzTest002: start"); - PixelFormat tempFormat = PixelFormat::NV12; - PixelFormat srcFormat = PixelFormat::RGB_888; - PixelFormat destFormat = PixelFormat::YCBCR_P010; - RgbConvertToYuvP010ByPixelMap(tempFormat, srcFormat, destFormat); - IMAGE_LOGI("RGBToNV12P010FuzzTest002: end"); -} - void RGBToNV21P010FuzzTest001() { IMAGE_LOGI("RGBToNV21P010FuzzTest001: start"); @@ -250,16 +184,6 @@ void RGBToNV21P010FuzzTest001() IMAGE_LOGI("RGBToNV21P010FuzzTest001: end"); } -void RGBToNV21P010FuzzTest002() -{ - IMAGE_LOGI("RGBToNV21P010FuzzTest002: start"); - PixelFormat tempFormat = PixelFormat::NV21; - PixelFormat srcFormat = PixelFormat::RGB_888; - PixelFormat destFormat = PixelFormat::YCRCB_P010; - RgbConvertToYuvP010ByPixelMap(tempFormat, srcFormat, destFormat); - IMAGE_LOGI("RGBToNV21P010FuzzTest002: end"); -} - void RGBAF16ToNV12P010FuzzTest001() { IMAGE_LOGI("RGBAF16ToNV12P010FuzzTest001: start"); @@ -270,16 +194,6 @@ void RGBAF16ToNV12P010FuzzTest001() IMAGE_LOGI("RGBAF16ToNV12P010FuzzTest001: end"); } -void RGBAF16ToNV12P010FuzzTest002() -{ - IMAGE_LOGI("RGBAF16ToNV12P010FuzzTest002: start"); - PixelFormat tempFormat = PixelFormat::NV12; - PixelFormat srcFormat = PixelFormat::RGBA_F16; - PixelFormat destFormat = PixelFormat::YCBCR_P010; - RgbConvertToYuvP010ByPixelMap(tempFormat, srcFormat, destFormat); - IMAGE_LOGI("RGBAF16ToNV12P010FuzzTest002: end"); -} - void RGBAF16ToNV21P010FuzzTest001() { IMAGE_LOGI("RGBAF16ToNV21P010FuzzTest001: start"); @@ -290,28 +204,14 @@ void RGBAF16ToNV21P010FuzzTest001() IMAGE_LOGI("RGBAF16ToNV21P010FuzzTest001: end"); } -void RGBAF16ToNV21P010FuzzTest002() -{ - IMAGE_LOGI("RGBAF16ToNV21P010FuzzTest002: start"); - PixelFormat tempFormat = PixelFormat::NV21; - PixelFormat srcFormat = PixelFormat::RGBA_F16; - PixelFormat destFormat = PixelFormat::YCRCB_P010; - RgbConvertToYuvP010ByPixelMap(tempFormat, srcFormat, destFormat); - IMAGE_LOGI("RGBAF16ToNV21P010FuzzTest002: end"); -} - void RgbToYuvP010FuzzTest001() { IMAGE_LOGI("YuvP010ToRgbTest001: start"); RGB565ToNV12P010FuzzTest001(); - RGB565ToNV12P010FuzzTest002(); RGB565ToNV21P010FuzzTest001(); - RGB565ToNV21P010FuzzTest002(); BGRAToNV12P010FuzzTest001(); - BGRAToNV12P010FuzzTest002(); BGRAToNV21P010FuzzTest001(); - BGRAToNV21P010FuzzTest002(); IMAGE_LOGI("YuvP010ToRgbTest001: end"); } @@ -319,17 +219,11 @@ void RgbToYuvP010ByPixelMapFuzzTest001() { IMAGE_LOGI("RgbToYuvP010ByPixelMapTest001: start"); RGBAToNV12P010FuzzTest001(); - RGBAToNV12P010FuzzTest002(); RGBAToNV21P010FuzzTest001(); - RGBAToNV21P010FuzzTest002(); RGBToNV12P010FuzzTest001(); - RGBToNV12P010FuzzTest002(); RGBToNV21P010FuzzTest001(); - RGBToNV21P010FuzzTest002(); RGBAF16ToNV12P010FuzzTest001(); - RGBAF16ToNV12P010FuzzTest002(); RGBAF16ToNV21P010FuzzTest001(); - RGBAF16ToNV21P010FuzzTest002(); IMAGE_LOGI("RgbToYuvP010ByPixelMapTest001: end"); } diff --git a/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertyuv2rgb_fuzzer/src/image_fwk_convert_yuv2rgb_fuzzer.cpp b/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertyuv2rgb_fuzzer/src/image_fwk_convert_yuv2rgb_fuzzer.cpp index a452acfc1b8cce63324b4314c6624661e5f063bd..eb6926f9f8c376b5e3ea4a0fa7b013ee458b28ef 100644 --- a/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertyuv2rgb_fuzzer/src/image_fwk_convert_yuv2rgb_fuzzer.cpp +++ b/frameworks/innerkitsimpl/test/fuzztest/imagefwkconvertyuv2rgb_fuzzer/src/image_fwk_convert_yuv2rgb_fuzzer.cpp @@ -81,15 +81,6 @@ void NV21ToRGBFuzzTest001() IMAGE_LOGI("NV21ToRGBFuzzTest001: end"); } -void NV21ToRGBFuzzTest002() -{ - IMAGE_LOGI("NV21ToRGBFuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::NV21; - PixelFormat destFormat = PixelFormat::RGB_888; - YuvConvertToRgb(srcFormat, destFormat); - IMAGE_LOGI("NV21ToRGBFuzzTest002: end"); -} - void NV21ToRGBAFuzzTest001() { IMAGE_LOGI("NV21ToRGBAFuzzTest001: start"); @@ -99,15 +90,6 @@ void NV21ToRGBAFuzzTest001() IMAGE_LOGI("NV21ToRGBAFuzzTest001: end"); } -void NV21ToRGBAFuzzTest002() -{ - IMAGE_LOGI("NV21ToRGBAFuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::NV21; - PixelFormat destFormat = PixelFormat::RGBA_8888; - YuvConvertToRgb(srcFormat, destFormat); - IMAGE_LOGI("NV21ToRGBAFuzzTest002: end"); -} - void NV21ToBGRAFuzzTest001() { IMAGE_LOGI("NV21ToBGRAFuzzTest001: start"); @@ -117,15 +99,6 @@ void NV21ToBGRAFuzzTest001() IMAGE_LOGI("NV21ToBGRAFuzzTest001: end"); } -void NV21ToBGRAFuzzTest002() -{ - IMAGE_LOGI("NV21ToBGRAFuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::NV21; - PixelFormat destFormat = PixelFormat::BGRA_8888; - YuvConvertToRgb(srcFormat, destFormat); - IMAGE_LOGI("NV21ToBGRAFuzzTest002: end"); -} - void NV21ToRGB565FuzzTest001() { IMAGE_LOGI("NV21ToRGB565FuzzTest001: start"); @@ -135,15 +108,6 @@ void NV21ToRGB565FuzzTest001() IMAGE_LOGI("NV21ToRGB565FuzzTest001: end"); } -void NV21ToRGB565FuzzTest002() -{ - IMAGE_LOGI("NV21ToRGB565FuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::NV21; - PixelFormat destFormat = PixelFormat::RGB_565; - YuvConvertToRgb(srcFormat, destFormat); - IMAGE_LOGI("NV21ToRGB565FuzzTest002: end"); -} - void NV21ToNV12FuzzTest001() { IMAGE_LOGI("NV21ToNV12FuzzTest001: start"); @@ -153,15 +117,6 @@ void NV21ToNV12FuzzTest001() IMAGE_LOGI("NV21ToNV12FuzzTest001: end"); } -void NV21ToNV12FuzzTest002() -{ - IMAGE_LOGI("NV21ToNV12FuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::NV21; - PixelFormat destFormat = PixelFormat::NV12; - YuvConvertToRgb(srcFormat, destFormat); - IMAGE_LOGI("NV21ToNV12FuzzTest002: end"); -} - void NV12ToNV21FuzzTest001() { IMAGE_LOGI("NV12ToNV21FuzzTest001: start"); @@ -171,15 +126,6 @@ void NV12ToNV21FuzzTest001() IMAGE_LOGI("NV12ToNV21FuzzTest001: end"); } -void NV12ToNV21FuzzTest002() -{ - IMAGE_LOGI("NV12ToNV21FuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::NV12; - PixelFormat destFormat = PixelFormat::NV21; - YuvConvertToRgb(srcFormat, destFormat); - IMAGE_LOGI("NV12ToNV21FuzzTest002: end"); -} - void NV12ToRGB565FuzzTest001() { IMAGE_LOGI("NV12ToRGB565FuzzTest001: start"); @@ -189,15 +135,6 @@ void NV12ToRGB565FuzzTest001() IMAGE_LOGI("NV12ToRGB565FuzzTest001: end"); } -void NV12ToRGB565FuzzTest002() -{ - IMAGE_LOGI("NV12ToRGB565FuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::NV12; - PixelFormat destFormat = PixelFormat::RGB_565; - YuvConvertToRgb(srcFormat, destFormat); - IMAGE_LOGI("NV12ToRGB565FuzzTest002: end"); -} - void NV12ToRGBAFuzzTest001() { IMAGE_LOGI("NV12ToRGBAFuzzTest001: start"); @@ -207,15 +144,6 @@ void NV12ToRGBAFuzzTest001() IMAGE_LOGI("NV12ToRGBAFuzzTest001: end"); } -void NV12ToRGBAFuzzTest002() -{ - IMAGE_LOGI("NV12ToRGBAFuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::NV12; - PixelFormat destFormat = PixelFormat::RGBA_8888; - YuvConvertToRgb(srcFormat, destFormat); - IMAGE_LOGI("NV12ToRGBAFuzzTest002: end"); -} - void NV12ToBGRAFuzzTest001() { IMAGE_LOGI("NV12ToBGRAFuzzTest001: start"); @@ -225,15 +153,6 @@ void NV12ToBGRAFuzzTest001() IMAGE_LOGI("NV12ToBGRAFuzzTest001: end"); } -void NV12ToBGRAFuzzTest002() -{ - IMAGE_LOGI("NV12ToBGRAFuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::NV12; - PixelFormat destFormat = PixelFormat::BGRA_8888; - YuvConvertToRgb(srcFormat, destFormat); - IMAGE_LOGI("NV12ToBGRAFuzzTest002: end"); -} - void NV12ToRGBFuzzTest001() { IMAGE_LOGI("NV12ToRGBFuzzTest001: start"); @@ -243,15 +162,6 @@ void NV12ToRGBFuzzTest001() IMAGE_LOGI("NV12ToRGBFuzzTest001: end"); } -void NV12ToRGBFuzzTest002() -{ - IMAGE_LOGI("NV12ToRGBFuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::NV12; - PixelFormat destFormat = PixelFormat::RGB_888; - YuvConvertToRgb(srcFormat, destFormat); - IMAGE_LOGI("NV12ToRGBFuzzTest002: end"); -} - void NV21ToNV12P010FuzzTest001() { IMAGE_LOGI("NV21ToNV12P010FuzzTest001: start"); @@ -261,15 +171,6 @@ void NV21ToNV12P010FuzzTest001() IMAGE_LOGI("NV21ToNV12P010FuzzTest001: end"); } -void NV21ToNV12P010FuzzTest002() -{ - IMAGE_LOGI("NV21ToNV12P010FuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::NV21; - PixelFormat destFormat = PixelFormat::YCBCR_P010; - YuvConvertToRgb(srcFormat, destFormat); - IMAGE_LOGI("NV21ToNV12P010FuzzTest002: end"); -} - void NV12ToNV12P010FuzzTest001() { IMAGE_LOGI("NV12ToNV12P010FuzzTest001: start"); @@ -279,15 +180,6 @@ void NV12ToNV12P010FuzzTest001() IMAGE_LOGI("NV12ToNV12P010FuzzTest001: end"); } -void NV12ToNV12P010FuzzTest002() -{ - IMAGE_LOGI("NV12ToNV12P010FuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::NV12; - PixelFormat destFormat = PixelFormat::YCBCR_P010; - YuvConvertToRgb(srcFormat, destFormat); - IMAGE_LOGI("NV12ToNV12P010FuzzTest002: end"); -} - void NV21ToRGBAF16FuzzTest001() { IMAGE_LOGI("NV21ToRGBAF16FuzzTest001: start"); @@ -297,15 +189,6 @@ void NV21ToRGBAF16FuzzTest001() IMAGE_LOGI("NV21ToRGBAF16FuzzTest001: end"); } -void NV21ToRGBAF16FuzzTest002() -{ - IMAGE_LOGI("NV21ToRGBAF16FuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::NV21; - PixelFormat destFormat = PixelFormat::RGBA_F16; - YuvConvertToRgb(srcFormat, destFormat); - IMAGE_LOGI("NV21ToRGBAF16FuzzTest002: end"); -} - void NV12ToRGBAF16FuzzTest001() { IMAGE_LOGI("NV12ToRGBAF16FuzzTest001: start"); @@ -315,15 +198,6 @@ void NV12ToRGBAF16FuzzTest001() IMAGE_LOGI("NV12ToRGBAF16FuzzTest001: end"); } -void NV12ToRGBAF16FuzzTest002() -{ - IMAGE_LOGI("NV12ToRGBAF16FuzzTest002: start"); - PixelFormat srcFormat = PixelFormat::NV12; - PixelFormat destFormat = PixelFormat::RGBA_F16; - YuvConvertToRgb(srcFormat, destFormat); - IMAGE_LOGI("NV12ToRGBAF16FuzzTest002: end"); -} - void NV21ToNV21P010FuzzTest003() { IMAGE_LOGI("NV21ToNV21P010FuzzTest003: start"); @@ -364,33 +238,19 @@ void YuvToRgbFuzzTest001() { IMAGE_LOGI("YuvToRgbFuzzTest001: start"); NV21ToRGBFuzzTest001(); - NV21ToRGBFuzzTest002(); NV21ToRGBAFuzzTest001(); - NV21ToRGBAFuzzTest002(); NV21ToBGRAFuzzTest001(); - NV21ToBGRAFuzzTest002(); NV21ToRGB565FuzzTest001(); - NV21ToRGB565FuzzTest002(); NV21ToNV12FuzzTest001(); - NV21ToNV12FuzzTest002(); NV12ToNV21FuzzTest001(); - NV12ToNV21FuzzTest002(); NV12ToRGB565FuzzTest001(); - NV12ToRGB565FuzzTest002(); NV12ToRGBAFuzzTest001(); - NV12ToRGBAFuzzTest002(); NV12ToBGRAFuzzTest001(); - NV12ToBGRAFuzzTest002(); NV12ToRGBFuzzTest001(); - NV12ToRGBFuzzTest002(); NV21ToNV12P010FuzzTest001(); - NV21ToNV12P010FuzzTest002(); NV12ToNV12P010FuzzTest001(); - NV12ToNV12P010FuzzTest002(); NV21ToRGBAF16FuzzTest001(); - NV21ToRGBAF16FuzzTest002(); NV12ToRGBAF16FuzzTest001(); - NV12ToRGBAF16FuzzTest002(); NV21ToNV21P010FuzzTest003(); NV12ToNV21P010FuzzTest003(); NV12ToRGBA1010102FuzzTest003(); diff --git a/frameworks/innerkitsimpl/test/fuzztest/imageplugin_fuzzer/BUILD.gn b/frameworks/innerkitsimpl/test/fuzztest/imageplugin_fuzzer/BUILD.gn deleted file mode 100644 index 1ca339b83c53674874d75949556df9ef5d165163..0000000000000000000000000000000000000000 --- a/frameworks/innerkitsimpl/test/fuzztest/imageplugin_fuzzer/BUILD.gn +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/test.gni") -import("//foundation/multimedia/image_framework/ide/image_decode_config.gni") - -ohos_fuzztest("ImagePluginFuzzTest") { - module_out_path = "image_framework/image_framework" - fuzz_config_file = "$image_subsystem/frameworks/innerkitsimpl/test/fuzztest/imageplugin_fuzzer" - resource_config_file = "$image_subsystem/test/resource/image/ohos_test.xml" - - cflags = [ "-DIMAGE_COLORSPACE_FLAG" ] - - include_dirs = [ - "./include", - "$image_subsystem/interfaces/innerkits/include", - "$image_subsystem/frameworks/innerkitsimpl/test/fuzztest/common/include", - "$image_subsystem/plugins/common/libs/image/libextplugin/include", - "$image_subsystem/plugins/common/libs/image/libextplugin/include/jpeg_yuv_decoder", - "$image_subsystem/plugins/common/libs/image/libsvgplugin/include", - ] - - defines = [ - "JPEG_HW_DECODE_ENABLE", - "HEIF_HW_DECODE_ENABLE", - ] - - sources = [ - "$image_subsystem/frameworks/innerkitsimpl/test/fuzztest/common/src/common_fuzztest_function.cpp", - "src/image_plugin_fuzz.cpp", - ] - - deps = [ - "$image_subsystem/interfaces/innerkits:image_native", - "$image_subsystem/plugins/common/libs/image/libextplugin:extplugin", - "$image_subsystem/plugins/common/libs/image/libsvgplugin:svgplugin", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_codec:libimage_proxy_2.1", - "drivers_interface_display:libdisplay_buffer_hdi_impl", - "drivers_interface_display:libdisplay_buffer_proxy_1.0", - "drivers_interface_display:libdisplay_composer_hdi_impl_1.2", - "drivers_interface_display:libdisplay_composer_proxy_1.0", - "graphic_2d:color_manager", - "graphic_surface:surface", - "hilog:libhilog", - "libexif:libexif", - "libjpeg-turbo:turbojpeg", - "ipc:ipc_single", - ] -} diff --git a/frameworks/innerkitsimpl/test/fuzztest/imageplugin_fuzzer/corpus/init b/frameworks/innerkitsimpl/test/fuzztest/imageplugin_fuzzer/corpus/init deleted file mode 100644 index 6198079a28e860189d4294f6598f8ac6804c0dff..0000000000000000000000000000000000000000 --- a/frameworks/innerkitsimpl/test/fuzztest/imageplugin_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -FUZZ \ No newline at end of file diff --git a/frameworks/innerkitsimpl/test/fuzztest/imageplugin_fuzzer/include/image_plugin_fuzz.h b/frameworks/innerkitsimpl/test/fuzztest/imageplugin_fuzzer/include/image_plugin_fuzz.h deleted file mode 100644 index a0bc3c5c8f856ad2f823486499641428f950428b..0000000000000000000000000000000000000000 --- a/frameworks/innerkitsimpl/test/fuzztest/imageplugin_fuzzer/include/image_plugin_fuzz.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef IMAGE_PLUGIN_FUZZ_H -#define IMAGE_PLUGIN_FUZZ_H - -#define FUZZ_PROJECT_NAME "image_plugin_fuzzer" -#endif \ No newline at end of file diff --git a/frameworks/innerkitsimpl/test/fuzztest/imageplugin_fuzzer/project.xml b/frameworks/innerkitsimpl/test/fuzztest/imageplugin_fuzzer/project.xml deleted file mode 100644 index 1defdcf3bb408a21a7c70b9f3ec28d2d7096b705..0000000000000000000000000000000000000000 --- a/frameworks/innerkitsimpl/test/fuzztest/imageplugin_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 52428800 - - 300 - - 6144 - - diff --git a/frameworks/innerkitsimpl/test/fuzztest/imageplugin_fuzzer/src/image_plugin_fuzz.cpp b/frameworks/innerkitsimpl/test/fuzztest/imageplugin_fuzzer/src/image_plugin_fuzz.cpp deleted file mode 100644 index d2291ee29c53f771876e661c2e654b2e3fce9990..0000000000000000000000000000000000000000 --- a/frameworks/innerkitsimpl/test/fuzztest/imageplugin_fuzzer/src/image_plugin_fuzz.cpp +++ /dev/null @@ -1,466 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "image_plugin_fuzz.h" - -#define private public -#define protected public -#include -#include -#include -#include -#include - -#include "common_fuzztest_function.h" -#include "image_source.h" -#include "ext_decoder.h" -#include "svg_decoder.h" -#include "image_log.h" -#include "ext_wstream.h" -#include "hdr_helper.h" - -#undef LOG_DOMAIN -#define LOG_DOMAIN LOG_TAG_DOMAIN_ID_IMAGE - -#undef LOG_TAG -#define LOG_TAG "PLUGIN_FUZZ" - -namespace OHOS { -namespace Media { -using namespace OHOS::ImagePlugin; -namespace { - const uint8_t* g_data = nullptr; - size_t g_size = 0; - size_t g_pos = 0; -} // namespace - -static const std::string JPEG_HW_PATH = "/data/local/tmp/test_hw.jpg"; -static const std::string JPEG_SW_PATH = "/data/local/tmp/test-tree-420.jpg"; -static const std::string HEIF_HW_PATH = "/data/local/tmp/test_hw.heic"; -static const std::string HDR_PATH = "/data/local/tmp/HEIFISOMultiChannelBaseColor0512V12.heic"; -static const std::string WEBP_PATH = "/data/local/tmp/test.webp"; -static const std::string GIF_PATH = "/data/local/tmp/test.gif"; -constexpr uint8_t ITUT35_TAG_SIZE = 6; - -/* - * describe: get data from outside untrusted data(g_data) which size is according to sizeof(T) - * tips: only support basic type - */ -template -T GetData() -{ - T object {}; - size_t objectSize = sizeof(object); - if (g_data == nullptr || objectSize > g_size - g_pos) { - return object; - } - errno_t ret = memcpy_s(&object, objectSize, g_data + g_pos, objectSize); - if (ret != EOK) { - return {}; - } - g_pos += objectSize; - return object; -} - -void ExtDecoderFuncTest001(const std::string& filename) -{ - IMAGE_LOGI("%{public}s IN path: %{public}s", __func__, filename.c_str()); - SourceOptions srcOpts; - uint32_t errorCode; - auto imageSource = ImageSource::CreateImageSource(filename, srcOpts, errorCode); - if (imageSource == nullptr) { - return; - } - Media::DecodeOptions dopts; - auto pixelMap = imageSource->CreatePixelMap(dopts, errorCode); - if (pixelMap == nullptr || errorCode != SUCCESS) { - return; - } - auto extDecoder = static_cast((imageSource->mainDecoder_).get()); - if (extDecoder == nullptr || !extDecoder->DecodeHeader()) { - return; - } - DecodeContext context; - SkImageInfo heifInfo; - extDecoder->HeifYUVMemAlloc(context, heifInfo); - int dWidth; - int dHeight; - float scale; - extDecoder->GetScaledSize(dWidth, dHeight, scale); - extDecoder->GetHardwareScaledSize(dWidth, dHeight, scale); - extDecoder->IsSupportScaleOnDecode(); - PixelDecodeOptions plOpts; - PlImageInfo plInfo; - extDecoder->SetDecodeOptions(0, plOpts, plInfo); - PixelFormat dstFormat = PixelFormat::UNKNOWN; - extDecoder->PreDecodeCheckYuv(0, dstFormat); - extDecoder->DoHardWareDecode(context); - extDecoder->GetJpegYuvOutFmt(dstFormat); - extDecoder->DecodeToYuv420(0, context); - extDecoder->CheckContext(context); - extDecoder->HardWareDecode(context); - SkAlphaType alphaType; - AlphaType outputType; - extDecoder->ConvertInfoToAlphaType(alphaType, outputType); - SkColorType format; - PixelFormat outputFormat; - extDecoder->ConvertInfoToColorType(format, outputFormat); - std::string key = "ImageWidth"; - std::string value = "500"; - int32_t valInt = 0; - extDecoder->GetImagePropertyInt(0, key, valInt); - extDecoder->GetImagePropertyString(0, key, value); - extDecoder->GetMakerImagePropertyString(key, value); - extDecoder->DoHeifToYuvDecode(context); - IMAGE_LOGI("%{public}s SUCCESS", __func__); -} - -void SvgDecoderFuncTest001(const std::string& filename) -{ - IMAGE_LOGI("%{public}s IN", __func__); - SourceOptions srcOpts; - uint32_t errorCode; - auto imageSource = ImageSource::CreateImageSource(filename, srcOpts, errorCode); - if (imageSource == nullptr) { - return; - } - - imageSource->sourceInfo_.encodedFormat = "image/svg+xml"; - Media::DecodeOptions dopts; - auto pixelMap = imageSource->CreatePixelMap(dopts, errorCode); - if (pixelMap == nullptr || errorCode != SUCCESS) { - return; - } - auto svgDecoder = static_cast(imageSource->CreateDecoder(errorCode)); - PixelDecodeOptions plOpts; - PlImageInfo plInfo; - svgDecoder->SetDecodeOptions(0, plOpts, plInfo); - DecodeContext context; - svgDecoder->Decode(0, context); - uint32_t num; - svgDecoder->GetTopLevelImageNum(num); - context.allocatorType = AllocatorType::SHARE_MEM_ALLOC; - svgDecoder->AllocBuffer(context); - context.allocatorType = AllocatorType::DMA_ALLOC; - svgDecoder->AllocBuffer(context); - context.allocatorType = AllocatorType::HEAP_ALLOC; - svgDecoder->AllocBuffer(context); - svgDecoder->DoSetDecodeOptions(0, plOpts, plInfo); - Size plSize; - svgDecoder->DoGetImageSize(0, plSize); - svgDecoder->DoDecode(0, context); - - DecodeOptions dstOpts; - imageSource = ImageSource::CreateImageSource(filename, srcOpts, errorCode); - imageSource->CreatePixelMap(0, dstOpts, errorCode); - imageSource->Reset(); - IMAGE_LOGI("%{public}s SUCCESS", __func__); -} - -void ExtDecoderRegionFuncTest001(const std::string& filename) -{ - IMAGE_LOGI("%{public}s IN path: %{public}s", __func__, filename.c_str()); - SourceOptions srcOpts; - uint32_t errorCode; - auto imageSource = ImageSource::CreateImageSource(filename, srcOpts, errorCode); - if (imageSource == nullptr) { - return; - } - int32_t x = GetData(); - int32_t y = GetData(); - int32_t width = GetData(); - int32_t height = GetData(); - Media::DecodeOptions dopts; - dopts.desiredRegion.left = x; - dopts.desiredRegion.top = y; - dopts.desiredRegion.width = width; - dopts.desiredRegion.height = height; - dopts.cropAndScaleStrategy = CropAndScaleStrategy::CROP_FIRST; - auto pixelMap = imageSource->CreatePixelMap(dopts, errorCode); - if (pixelMap == nullptr || errorCode != SUCCESS) { - return; - } - auto extDecoder = static_cast((imageSource->mainDecoder_).get()); - if (extDecoder == nullptr || !extDecoder->DecodeHeader()) { - return; - } - DecodeContext context; - SkImageInfo heifInfo; - extDecoder->HeifYUVMemAlloc(context, heifInfo); - int dWidth; - int dHeight; - float scale; - extDecoder->GetScaledSize(dWidth, dHeight, scale); - extDecoder->GetHardwareScaledSize(dWidth, dHeight, scale); - extDecoder->IsSupportScaleOnDecode(); - PixelDecodeOptions plOpts; - PlImageInfo plInfo; - extDecoder->SetDecodeOptions(0, plOpts, plInfo); - PixelFormat dstFormat = PixelFormat::UNKNOWN; - extDecoder->PreDecodeCheckYuv(0, dstFormat); - extDecoder->DoHardWareDecode(context); - extDecoder->GetJpegYuvOutFmt(dstFormat); - extDecoder->DecodeToYuv420(0, context); - extDecoder->CheckContext(context); - extDecoder->HardWareDecode(context); - SkAlphaType alphaType; - AlphaType outputType; - extDecoder->ConvertInfoToAlphaType(alphaType, outputType); - SkColorType format; - PixelFormat outputFormat; - extDecoder->ConvertInfoToColorType(format, outputFormat); - IMAGE_LOGI("%{public}s SUCCESS", __func__); -} - - -void PixelMapTest001(PixelMap* pixelMap) -{ - IMAGE_LOGI("%{public}s IN", __func__); - pixelMap->SetTransformered(pixelMap->isTransformered_); - ImageInfo info; - pixelMap->GetYUVByteCount(info); - pixelMap->GetAllocatedByteCount(info); - InitializationOptions initOpts; - initOpts.size = {pixelMap->GetWidth(), pixelMap->GetHeight()}; - initOpts.editable = true; - auto emptyPixelMap = PixelMap::Create(initOpts); - Rect srcRect; - int32_t errorCode; - PixelMap::Create(*(emptyPixelMap.get()), srcRect, initOpts, errorCode); - pixelMap->resize(1, 1); - pixelMap->CopyPixelMap(*pixelMap, *(emptyPixelMap.get())); - PixelFormat fromat = PixelFormat::RGBA_8888; - pixelMap->GetPixelFormatDetail(fromat); - fromat = PixelFormat::RGBA_1010102; - pixelMap->GetPixelFormatDetail(fromat); - fromat = PixelFormat::BGRA_8888; - pixelMap->GetPixelFormatDetail(fromat); - fromat = PixelFormat::ARGB_8888; - pixelMap->GetPixelFormatDetail(fromat); - fromat = PixelFormat::ALPHA_8; - pixelMap->GetPixelFormatDetail(fromat); - fromat = PixelFormat::RGB_565; - pixelMap->GetPixelFormatDetail(fromat); - fromat = PixelFormat::RGB_888; - pixelMap->GetPixelFormatDetail(fromat); - fromat = PixelFormat::NV21; - pixelMap->GetPixelFormatDetail(fromat); - fromat = PixelFormat::YCRCB_P010; - pixelMap->GetPixelFormatDetail(fromat); - fromat = PixelFormat::CMYK; - pixelMap->GetPixelFormatDetail(fromat); - fromat = PixelFormat::RGBA_F16; - pixelMap->GetPixelFormatDetail(fromat); - fromat = PixelFormat::ASTC_4x4; - pixelMap->GetPixelFormatDetail(fromat); - pixelMap->GetPixel8(0, 0); - pixelMap->GetPixel16(0, 0); - pixelMap->GetPixel32(0, 0); - pixelMap->GetPixel(0, 0); - uint32_t color = 0; - pixelMap->GetARGB32Color(0, 0, color); - IMAGE_LOGI("%{public}s SUCCESS", __func__); -} - -void PixelMapTest002(PixelMap* pixelMap) -{ - IMAGE_LOGI("%{public}s IN", __func__); - pixelMap->GetPixelBytes(); - pixelMap->GetRowBytes(); - pixelMap->GetByteCount(); - pixelMap->GetWidth(); - pixelMap->GetHeight(); - TransformData transformData; - pixelMap->GetTransformData(transformData); - pixelMap->SetTransformData(transformData); - pixelMap->GetBaseDensity(); - ImageInfo imageInfo; - pixelMap->GetImageInfo(imageInfo); - pixelMap->GetPixelFormat(); - pixelMap->GetColorSpace(); - pixelMap->GetAlphaType(); - pixelMap->GetPixels(); - pixelMap->IsHdr(); - uint32_t color = 0; - pixelMap->GetARGB32ColorA(color); - pixelMap->GetARGB32ColorR(color); - pixelMap->GetARGB32ColorG(color); - pixelMap->GetARGB32ColorB(color); - pixelMap->IsStrideAlignment(); - pixelMap->GetAllocatorType(); - pixelMap->GetFd(); -#ifdef IMAGE_COLORSPACE_FLAG - OHOS::ColorManager::ColorSpace grColorSpace(OHOS::ColorManager::ColorSpaceName::SRGB); - pixelMap->ApplyColorSpace(grColorSpace); -#endif - pixelMap->ResetConfig(pixelMap->imageInfo_.size, pixelMap->imageInfo_.pixelFormat); - IMAGE_LOGI("%{public}s SUCCESS", __func__); -} - -void PixelMapTest(PixelMap* pixelMap) -{ - IMAGE_LOGI("%{public}s IN", __func__); - PixelMapTest001(pixelMap); - PixelMapTest002(pixelMap); - IMAGE_LOGI("%{public}s SUCCESS", __func__); -} - -void JpegHardwareTest001() -{ - IMAGE_LOGI("%{public}s IN", __func__); - SourceOptions srcOpts; - uint32_t errorCode; - auto imageSource = ImageSource::CreateImageSource(JPEG_HW_PATH, srcOpts, errorCode); - if (imageSource == nullptr) { - return ; - } - DecodeOptions decodeOpts; - auto pixelMap = imageSource->CreatePixelMapEx(0, decodeOpts, errorCode); - PixelMapTest(pixelMap.get()); - decodeOpts.desiredPixelFormat = PixelFormat::NV21; - auto pixelMap2 = imageSource->CreatePixelMapEx(0, decodeOpts, errorCode); - PixelMapTest(pixelMap2.get()); - IMAGE_LOGI("%{public}s SUCCESS", __func__); -} - -void JpegSoftTest001() -{ - IMAGE_LOGI("%{public}s IN", __func__); - SourceOptions srcOpts; - uint32_t errorCode; - auto imageSource = ImageSource::CreateImageSource(JPEG_SW_PATH, srcOpts, errorCode); - if (imageSource == nullptr) { - return ; - } - DecodeOptions decodeOpts; - auto pixelMap = imageSource->CreatePixelMapEx(0, decodeOpts, errorCode); - PixelMapTest(pixelMap.get()); - decodeOpts.desiredPixelFormat = PixelFormat::NV12; - auto pixelMap2 = imageSource->CreatePixelMapEx(0, decodeOpts, errorCode); - PixelMapTest(pixelMap2.get()); - IMAGE_LOGI("%{public}s SUCCESS", __func__); -} - -void HeifHardwareTest001() -{ - IMAGE_LOGI("%{public}s IN", __func__); - SourceOptions srcOpts; - uint32_t errorCode; - auto imageSource = ImageSource::CreateImageSource(HEIF_HW_PATH, srcOpts, errorCode); - if (imageSource == nullptr) { - return ; - } - DecodeOptions decodeOpts; - auto pixelMap = imageSource->CreatePixelMapEx(0, decodeOpts, errorCode); - IMAGE_LOGI("%{public}s SUCCESS", __func__); -} - -void HdrTest001() -{ - IMAGE_LOGI("%{public}s IN", __func__); - SourceOptions srcOpts; - uint32_t errorCode; - auto imageSource = ImageSource::CreateImageSource(HDR_PATH, srcOpts, errorCode); - if (imageSource == nullptr) { - return ; - } - ImageInfo imageInfo; - imageSource->GetImageInfo(0, imageInfo); - if (!imageSource->IsHdrImage()) { - IMAGE_LOGE("%{public}s %{public}s is not hdr", __func__, HDR_PATH.c_str()); - return; - } - DecodeContext gainMapCtx; - if (imageSource->mainDecoder_->DecodeHeifGainMap(gainMapCtx)) { - IMAGE_LOGI("%{public}s DecodeHeifGainMap SUCCESS, %{public}s", __func__, HDR_PATH.c_str()); - imageSource->mainDecoder_->GetHdrMetadata(imageSource->mainDecoder_->CheckHdrType()); - } else { - IMAGE_LOGE("%{public}s DecodeHeifGainMap failed, %{public}s", __func__, HDR_PATH.c_str()); - } - IMAGE_LOGI("%{public}s SUCCESS", __func__); -} - -void HdrHelperFucTest() -{ - HdrMetadata metadataOne; - metadataOne.extendMeta.baseColorMeta.baseMappingFlag = ITUT35_TAG_SIZE; - metadataOne.extendMeta.gainmapColorMeta.combineMappingFlag = ITUT35_TAG_SIZE; - ImagePlugin::HdrJpegPackerHelper::PackVividMetadataMarker(metadataOne); - - HdrMetadata metadataTwo; - metadataTwo.extendMeta.baseColorMeta.baseMappingFlag = ITUT35_TAG_SIZE; - metadataTwo.extendMeta.gainmapColorMeta.combineMappingFlag = ITUT35_TAG_SIZE; - ImagePlugin::HdrJpegPackerHelper::PackISOMetadataMarker(metadataTwo); - - HdrMetadata metadataThree; - metadataThree.extendMeta.baseColorMeta.baseMappingFlag = ITUT35_TAG_SIZE; - metadataThree.extendMeta.gainmapColorMeta.combineMappingFlag = ITUT35_TAG_SIZE; - sk_sp baseImageData; - sk_sp gainMapImageData; - ExtWStream extWStream(nullptr); - ImagePlugin::HdrJpegPackerHelper::SpliceHdrStream(baseImageData, gainMapImageData, extWStream, metadataThree); - - HdrMetadata metadataFour; - metadataFour.extendMeta.baseColorMeta.baseMappingFlag = ITUT35_TAG_SIZE; - metadataFour.extendMeta.gainmapColorMeta.combineMappingFlag = ITUT35_TAG_SIZE; - std::vector it35Info; - ImagePlugin::HdrHeifPackerHelper::PackIT35Info(metadataFour, it35Info); -} - -void GifTest001(const std::string& pathName) -{ - IMAGE_LOGI("%{public}s IN", __func__); - SourceOptions srcOpts; - uint32_t errorCode; - auto imageSource = ImageSource::CreateImageSource(pathName, srcOpts, errorCode); - if (imageSource == nullptr) { - return ; - } - for (uint32_t index = 0; index < imageSource->GetFrameCount(errorCode); ++index) { - DecodeOptions decodeOpts; - auto pixelMap = imageSource->CreatePixelMapEx(0, decodeOpts, errorCode); - IMAGE_LOGI("%{public}s gif decode SUCCESS", __func__); - } - IMAGE_LOGI("%{public}s SUCCESS", __func__); -} - -void ImagePluginFuzzTest001(const uint8_t* data, size_t size) -{ - std::string filename = "/data/local/tmp/test_decode_ext.jpg"; - if (!WriteDataToFile(data, size, filename)) { - IMAGE_LOGE("WriteDataToFile failed"); - return; - } - ExtDecoderFuncTest001(filename); - SvgDecoderFuncTest001(filename); - JpegHardwareTest001(); - JpegSoftTest001(); - HeifHardwareTest001(); - GifTest001(GIF_PATH); - GifTest001(WEBP_PATH); - HdrTest001(); - ExtDecoderRegionFuncTest001(filename); - HdrHelperFucTest(); -} -} // namespace Media -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - /* Run your code on data */ - OHOS::Media::ImagePluginFuzzTest001(data, size); - return 0; -} \ No newline at end of file