From 86f24e46a0aeda78b3bf165765a1357c50fd266d Mon Sep 17 00:00:00 2001 From: pxh123456 Date: Thu, 22 Jan 2026 21:04:21 +0800 Subject: [PATCH 01/12] vpe ani code Signed-off-by: pxh123456 --- bundle.json | 5 +- framework/BUILD.gn | 4 +- interfaces/kits/taihe/BUILD.gn | 155 ++++++++++++++++++ ...hos.multimedia.videoProcessingEngine.taihe | 48 ++++++ .../include/video_processing_engine_taihe.h | 52 ++++++ interfaces/kits/taihe/src/ani_constructor.cpp | 37 +++++ .../src/video_processing_engine_taihe.cpp | 86 ++++++++++ 7 files changed, 384 insertions(+), 3 deletions(-) create mode 100644 interfaces/kits/taihe/BUILD.gn create mode 100644 interfaces/kits/taihe/idl/hos.multimedia.videoProcessingEngine.taihe create mode 100644 interfaces/kits/taihe/include/video_processing_engine_taihe.h create mode 100644 interfaces/kits/taihe/src/ani_constructor.cpp create mode 100644 interfaces/kits/taihe/src/video_processing_engine_taihe.cpp diff --git a/bundle.json b/bundle.json index e79f618..83f79dc 100644 --- a/bundle.json +++ b/bundle.json @@ -35,6 +35,7 @@ "media_foundation", "napi", "ipc", + "runtime_core", "safwk", "samgr", "eventhandler", @@ -51,7 +52,9 @@ "build": { "sub_component": [ "//foundation/multimedia/video_processing_engine/framework:videoprocessingengine", - "//foundation/multimedia/video_processing_engine/services:video_processing_service_group" + "//foundation/multimedia/video_processing_engine/services:video_processing_service_group", + "//foundation/multimedia/video_processing_engine/interfaces/kits/taihe:video_processing_engine_taihe_gen_only", + "//foundation/multimedia/video_processing_engine/interfaces/kits/taihe:video_processing_engine_taihe_group" ], "inner_kits": [ { diff --git a/framework/BUILD.gn b/framework/BUILD.gn index be44261..7793340 100644 --- a/framework/BUILD.gn +++ b/framework/BUILD.gn @@ -438,7 +438,7 @@ ohos_shared_library("video_processing") { subsystem_name = "multimedia" part_name = "video_processing_engine" } - +image.image ohos_shared_library("detailEnhancer") { sanitize = { cfi = true @@ -465,7 +465,7 @@ ohos_shared_library("detailEnhancer") { ] cflags = VIDEO_PROCESSING_ENGINE_CFLAGS - external_deps = [ + external_image.imagedeps = [ "c_utils:utils", "graphic_surface:surface", "hilog:libhilog", diff --git a/interfaces/kits/taihe/BUILD.gn b/interfaces/kits/taihe/BUILD.gn new file mode 100644 index 0000000..f5fa090 --- /dev/null +++ b/interfaces/kits/taihe/BUILD.gn @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2026 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/config/components/ets_frontend/ets2abc_config.gni") +import("//build/ohos.gni") +import("//build/ohos/taihe_idl/taihe.gni") +import("//foundation/multimedia/video_processing_engine/config.gni") + +subsystem_name = "multimedia" +part_name = "image_framework" +taihe_generated_file_path = "$taihe_file_path/out/$subsystem_name/$part_name" + +config("video_processing_engine_taihe_config") { + visibility = [ ":*" ] + include_dirs = [ "include" ] +} + +copy_taihe_idl("copy_video_processing_engine_taihe") { + sources = [ + "${INTERFACES_DIR/kits/taihe/idl/ohos.multimedia.videoProcessingEngine.taihe", + ] + + external_deps = [ + "image_framework:copy_image_taihe" + ] +} + +ohos_taihe("run_taihe") { + taihe_generated_file_path = "$taihe_generated_file_path" + deps = [ ":copy_video_processing_engine_taihe" ] + outputs = [ + "$taihe_generated_file_path/src/ohos.multimedia.videoProcessingEngine.ani.cpp", + "$taihe_generated_file_path/src/ohos.multimedia.videoProcessingEngine.abi.c", + ] +} + +generate_static_abc("video_processing_engine_taihe_abc") { + base_url = "$taihe_generated_file_path" + files = [ "$taihe_generated_file_path/@ohos.multimedia.videoProcessingEngine.ets" ] + is_boot_abc = "True" + device_dst_file = "/system/framework/video_processing_engine_taihe_abc.abc" + dependencies = [ ":run_taihe" ] +} + +ohos_prebuilt_etc("video_processing_engine_etc") { + source = "$target_out_dir/video_processing_engine_taihe_abc.abc" + module_install_dir = "framework" + part_name = "$part_name" + subsystem_name = "$subsystem_name" + deps = [ ":video_processing_engine_taihe_abc" ] +} + +group("video_processing_engine_taihe_group") { + deps = [ + ":video_processing_engine_etc", + ":video_processing_engine_taihe_core", + ] +} + +group("image_framework_taihe_gen_only") { + deps = [ ":run_taihe" ] +} + +taihe_shared_library("video_processing_engine_taihe") { + taihe_generated_file_path = "$taihe_generated_file_path" + subsystem_name = "$subsystem_name" + part_name = "$part_name" + + public_configs = [ ":video_processing_engine_taihe_config" ] + + include_dirs = [ + "include/video_processing_engine_taihe.h", + "$DFX_DIR/include", + "$INTERFACES_DIR/kits/js", + "$INTERFACES_INNER_API_DIR", + "$CAPI_DIR/image_processing/include/", + "$ALGORITHM_COMMON_DIR/include/", + "$INTERFACES_CAPI_DIR", + ] + + sources = get_target_outputs(":run_taihe") + sources += [ + "src/video_processing_engine_taihe.cpp", + "CAPI_DIR/image_processing/detail_enhance_napi_utils.cpp", + ] + + deps = [ + ":run_taihe", + "$VIDEO_PROCESSING_ENGINE_ROOT_DIR/framework:videoprocessingengine", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_display:libdisplay_commontype_proxy_2.1", + "graphic_surface:surface", + "hilog:libhilog", + "hitrace:hitrace_meter", + "image_framework:image_utils", + "image_framework:image_native", + "image_framework:pixelmap", + "image_framework:image", + "image_framework:image_taihe", + "ipc:ipc_napi", + "media_foundation:native_media_core", + "media_foundation:media_foundation", + "runtime_core:ani_helpers", + ] + + cflags = [ + "-DIMAGE_DEBUG_FLAG", + "-DIMAGE_COLORSPACE_FLAG", + ] + + sanitize = { + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + integer_overflow = true + ubsan = true + debug = false + } +} + +taihe_shared_library("video_processing_engine_taihe_core") { + taihe_generated_file_path = "$taihe_generated_file_path" + subsystem_name = "$subsystem_name" + part_name = "$part_name" + shlib_type = "ani" + + sources = [ "src/ani_constructor.cpp" ] + deps = [ ":video_processing_engine_taihe" ] + + sanitize = { + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + integer_overflow = true + ubsan = true + debug = false + } +} + + diff --git a/interfaces/kits/taihe/idl/hos.multimedia.videoProcessingEngine.taihe b/interfaces/kits/taihe/idl/hos.multimedia.videoProcessingEngine.taihe new file mode 100644 index 0000000..6d1307a --- /dev/null +++ b/interfaces/kits/taihe/idl/hos.multimedia.videoProcessingEngine.taihe @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2026 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. + */ + +@!namespace("@ohos.multimedia.videoProcessingEngine", "videoProcessingEngine") +@!sts_export_default +@!sts_inject(""" +static { loadLibraryWithPermissionCheck("video_processing_engine_taihe_core.z", "@ohos.multimedia.videoProcessingEngine"); } +""") + +from ohos.multimedia.image.image use PixelMap; + +enum QualityLevel : i32 { + NONE = 0, + LOW = 1, + MEDIUM = 2, + HIGH = 3 +} + +interface ImageProcessor { +@overload("enhanceDetail") +@promise EnhanceDetailWithRes(sourceImage: PixelMap, with: i32, height: i32, level: Optional): PixelMap; + +@overload("enhanceDetail") +@promise EnhanceDetailWithRatio(sourceImage: PixelMap, scale: f64, level: Optional): PixelMap; + +@overload("enhanceDetailSync") +EnhanceDetailSyncWithRes(sourceImage: PixelMap, with: i32, height: i32, level: Optional): PixelMap; + +@overload("enhanceDetailSync") +EnhanceDetailSyncWithRatio(sourceImage: PixelMap, scale: f64, level: Optional): PixelMap; +} + +@promise function InitializeEnvironment(): void; +@promise function DeinitializeEnvironment(): void; + +function create(): ImageProcessor; \ No newline at end of file diff --git a/interfaces/kits/taihe/include/video_processing_engine_taihe.h b/interfaces/kits/taihe/include/video_processing_engine_taihe.h new file mode 100644 index 0000000..d8e7fb8 --- /dev/null +++ b/interfaces/kits/taihe/include/video_processing_engine_taihe.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2026 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 FRAMEWORKS_KITS_TAIHE_INCLUDE_VIDEO_PROCESSING_ENGINE_TAIHE_H +#define FRAMEWORKS_KITS_TAIHE_INCLUDE_VIDEO_PROCESSING_ENGINE_TAIHE_H + +#include "ohos.multimedia.videoProcessingEngine.impl.hpp" +#include "ohos.multimedia.videoProcessingEngine.proj.hpp" + +#include "detail_enhancer_image.h" +#include "image_type.h" +#include "image_processing_types.h" +#include "pixel_map.h" + +#include "taihe/runtime.hpp" +#include "pixel_map_taihe.h" + +namespace ANI:Vpe { +using namespace taihe; +using namespace OHOS; +using namespace OHOS::Media; +using namespace OHOS::Media::VideoProcessingEngine; +namespace taiheVpe = ::ohos::multimedia::videoProcessingEngine; +namespace taiheImage = ::ohos::multimedia::image::image; + +class ImageProcessorImpl { +public: + ImageProcessorImpl() = default; + taihe::PixelMap EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, int width, int height, + optional_view level); + taihe::PixelMap EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, double scale, + optional_view level); + taihe::PixelMap EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, int width, int height, + optional_view level); + taihe::PixelMap EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, double scale, + optional_view level); +}; +} + +#endif \ No newline at end of file diff --git a/interfaces/kits/taihe/src/ani_constructor.cpp b/interfaces/kits/taihe/src/ani_constructor.cpp new file mode 100644 index 0000000..13a6288 --- /dev/null +++ b/interfaces/kits/taihe/src/ani_constructor.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2026 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 "ohos.multimedia.videoProcessingEngine.ani.hpp" +#if __has_include() +#include +#elif __has__include() +#include +#else +#error "ani.h not found. Please ensure the Ani SDK is correctly installed." +#endif + +ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) +{ + ani_env *env; + if (ANI_OK != vm->GetEnv(ANI_VERSION_1, &env)) { + return ANI_ERROR; + } + if (ANI_OK != ohos::multimedia::videoProcessingEngine::ANIRegister(env)) { + std::cerr << "Error from ohos::multimedia::videoProcessingEngine::ANIRegister" << std::endl; + return ANI_ERROR; + } + *result = ANI_VERSION_1; + return ANI_OK; +} diff --git a/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp new file mode 100644 index 0000000..d1c2fd0 --- /dev/null +++ b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2026 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 "video_processing_engine_taihe.h" + +#include "detail_enhance_napi_formal.h" +#include "detail_enhance_napi_utils.h" + +#include +#include + +#include "image_napi_utils.h" +#include "media_errors.h" +#include "memory_manager.h" +#include "nativ_avformat.h" +#include "pixelmap_native_impl.h" +#include "pixelmap_native.h" +#include "surface_buffer.h" + +#include "detail_enhancer_common.h" +#include "vpe_log.h" +#include "vpe_trace.h" +#include "vpe_utils.h" + +namespace ANI::Vpe { +void InitializeEnvironment() {} +void DeinitializeEnvironment() {} + +taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, int width, + int height, optional_view level) +{ + VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessRes"); + std::lock_guard lock(g_detailTaskLock); + std::unique_ptr detailContext = std::make_unique(); + ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level); + return make_holder(EnhanceDetailImpl(detailContext)); +} + +taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailWithRatio(taiheImage::weak::PixelMap sourceImage, double scale, + optional_view level) +{ + VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessRatio"); + std::lock_guard lock(g_detailTaskLock); + std::unique_ptr detailContext = std::make_unique(); + ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level); + return make_holder(EnhanceDetailImpl(detailContext)); +} + +taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailSyncWithRes(taiheImage::weak::PixelMap sourceImage, int width, + int height, optional_view level) +{ + VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessSyncRes"); + std::lock_guard lock(g_detailTaskLock); + std::unique_ptr detailContext = std::make_unique(); + ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level); + return make_holder(EnhanceDetailImpl(detailContext)); +} + +taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailSyncWithRatio(taiheImage::weak::PixelMap sourceImage, + double scale, optional_view level) +{ + VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessSyncRatio"); + std::lock_guard lock(g_detailTaskLock); + std::unique_ptr detailContext = std::make_unique(); + ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level); + return make_holder(EnhanceDetailImpl(detailContext)); +} + +// NOLINTBEGIN +TH_EXPORT_CPP_API_InitializeEnvironment(InitializeEnvironment); +TH_EXPORT_CPP_API_DeinitializeEnvironment(DeinitializeEnvironment); +TH_EXPORT_CPP_API_create(create); +// NOLINTEND +} \ No newline at end of file From 52388914b59e21dc29a330f28c251a10955d7e5e Mon Sep 17 00:00:00 2001 From: pxh123456 Date: Thu, 22 Jan 2026 21:19:21 +0800 Subject: [PATCH 02/12] vpe ani code Signed-off-by: pxh123456 --- .../include/video_processing_engine_taihe.h | 18 +++++++ .../src/video_processing_engine_taihe.cpp | 49 +++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/interfaces/kits/taihe/include/video_processing_engine_taihe.h b/interfaces/kits/taihe/include/video_processing_engine_taihe.h index d8e7fb8..7a64c32 100644 --- a/interfaces/kits/taihe/include/video_processing_engine_taihe.h +++ b/interfaces/kits/taihe/include/video_processing_engine_taihe.h @@ -47,6 +47,24 @@ public: taihe::PixelMap EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, double scale, optional_view level); }; + +private: + struct DetailEnhanceContext { + double xArg{}; + double yArg{}; + int32_t qualityLevel{}; + std::shared_ptr inputPixelMap; + std::shared_ptr outputPixelMap; + } + + void ParseDetailEnhanceParameter(std::unique_ptr& detailContext, + taiheImage::weak::PixelMap sourceImage, int width, int height, optional_view level); + void ParseDetailEnhanceParameter(std::unique_ptr& detailContext, + taiheImage::weak::PixelMap sourceImage, double scale, optional_view level); + void ParseDetailEnhanceParameter(std::unique_ptr& detailContext, + taiheImage::weak::PixelMap sourceImage, double scale, optional_view level); + std::shared_ptr DetailEnhanceImpl(DetailEnhanceContext* context); + } #endif \ No newline at end of file diff --git a/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp index d1c2fd0..481e175 100644 --- a/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp +++ b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp @@ -38,6 +38,55 @@ namespace ANI::Vpe { void InitializeEnvironment() {} void DeinitializeEnvironment() {} +void ImageProcessorImpl::ParseDetailEnhanceParameter(std::unique_ptr& detailContext, + taiheImage::weak::PixelMap sourceImage, int width, int height, optional_view level) +{ + if (detailContext == nullptr) { + VPE_LOGE("detailContext == nullptr"); + return; + } + ANI::Image:PixelMapImp* pixelMapImpl = reinterpret_cast(sourceImage->GetImplPtr()); + detailContext->xArg = width; + detailContext->yArg = height; + if (level.has_value()) { + detailContext->qualityLevel = level.value(); + } + detailContext->inputPixelMap = pixelMapImpl->GetNativePtr(); +} + +void ImageProcessorImpl::ParseDetailEnhanceParameter(std::unique_ptr& detailContext, + taiheImage::weak::PixelMap sourceImage, double scale, optional_view level) +{ + if (detailContext == nullptr) { + VPE_LOGE("detailContext == nullptr"); + return; + } + ANI::Image:PixelMapImp* pixelMapImpl = reinterpret_cast(sourceImage->GetImplPtr()); + detailContext->xArg = inputPixelMap->GetWidth() * scale; + detailContext->yArg = inputPixelMap->GetHeight() * scale; + if (level.has_value()) { + detailContext->qualityLevel = level.value(); + } + detailContext->inputPixelMap = pixelMapImpl->GetNativePtr(); +} + +void ImageProcessorImpl::ParseDetailEnhanceParameter(std::unique_ptr& detailContext, + taiheImage::weak::PixelMap sourceImage, double scale, optional_view level) +{ + std::shared_ptr outputPixelMap = DetailEnhanceImpl(detailContext.get()); + detailContext->inputPixelMap = nullptr; // 解引用防止内存泄漏 + if (outputPixelMap == nullptr) { + VPE_LOGE("DetailEnhanceImpl processed failed"); + return nullptr; + } + return outputPixelMap; +} + +std::shared_ptr ImageProcessorImpl::DetailEnhanceImpl(DetailEnhanceContext* context) +{ + return nullptr; +} + taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, int width, int height, optional_view level) { From 405c4fb3fe35dada35537343ccf299421e6e0985 Mon Sep 17 00:00:00 2001 From: pxh123456 Date: Thu, 22 Jan 2026 21:45:03 +0800 Subject: [PATCH 03/12] vpe ani code Signed-off-by: pxh123456 --- interfaces/kits/taihe/BUILD.gn | 12 +++--- ...os.multimedia.videoProcessingEngine.taihe} | 4 +- .../include/video_processing_engine_taihe.h | 17 ++++---- interfaces/kits/taihe/src/ani_constructor.cpp | 7 ++-- .../src/video_processing_engine_taihe.cpp | 39 ++++++++++++------- 5 files changed, 45 insertions(+), 34 deletions(-) rename interfaces/kits/taihe/idl/{hos.multimedia.videoProcessingEngine.taihe => ohos.multimedia.videoProcessingEngine.taihe} (86%) diff --git a/interfaces/kits/taihe/BUILD.gn b/interfaces/kits/taihe/BUILD.gn index f5fa090..0d41848 100644 --- a/interfaces/kits/taihe/BUILD.gn +++ b/interfaces/kits/taihe/BUILD.gn @@ -19,7 +19,7 @@ import("//build/ohos/taihe_idl/taihe.gni") import("//foundation/multimedia/video_processing_engine/config.gni") subsystem_name = "multimedia" -part_name = "image_framework" +part_name = "video_processing_engine" taihe_generated_file_path = "$taihe_file_path/out/$subsystem_name/$part_name" config("video_processing_engine_taihe_config") { @@ -29,7 +29,7 @@ config("video_processing_engine_taihe_config") { copy_taihe_idl("copy_video_processing_engine_taihe") { sources = [ - "${INTERFACES_DIR/kits/taihe/idl/ohos.multimedia.videoProcessingEngine.taihe", + "$INTERFACES_DIR/kits/taihe/idl/ohos.multimedia.videoProcessingEngine.taihe", ] external_deps = [ @@ -69,7 +69,7 @@ group("video_processing_engine_taihe_group") { ] } -group("image_framework_taihe_gen_only") { +group("video_processing_engine_taihe_gen_only") { deps = [ ":run_taihe" ] } @@ -93,7 +93,7 @@ taihe_shared_library("video_processing_engine_taihe") { sources = get_target_outputs(":run_taihe") sources += [ "src/video_processing_engine_taihe.cpp", - "CAPI_DIR/image_processing/detail_enhance_napi_utils.cpp", + "$CAPI_DIR/image_processing/detail_enhance_napi_utils.cpp", ] deps = [ @@ -150,6 +150,4 @@ taihe_shared_library("video_processing_engine_taihe_core") { ubsan = true debug = false } -} - - +} \ No newline at end of file diff --git a/interfaces/kits/taihe/idl/hos.multimedia.videoProcessingEngine.taihe b/interfaces/kits/taihe/idl/ohos.multimedia.videoProcessingEngine.taihe similarity index 86% rename from interfaces/kits/taihe/idl/hos.multimedia.videoProcessingEngine.taihe rename to interfaces/kits/taihe/idl/ohos.multimedia.videoProcessingEngine.taihe index 6d1307a..b97d6fa 100644 --- a/interfaces/kits/taihe/idl/hos.multimedia.videoProcessingEngine.taihe +++ b/interfaces/kits/taihe/idl/ohos.multimedia.videoProcessingEngine.taihe @@ -30,13 +30,13 @@ enum QualityLevel : i32 { interface ImageProcessor { @overload("enhanceDetail") -@promise EnhanceDetailWithRes(sourceImage: PixelMap, with: i32, height: i32, level: Optional): PixelMap; +@promise EnhanceDetailWithRes(sourceImage: PixelMap, width: i32, height: i32, level: Optional): PixelMap; @overload("enhanceDetail") @promise EnhanceDetailWithRatio(sourceImage: PixelMap, scale: f64, level: Optional): PixelMap; @overload("enhanceDetailSync") -EnhanceDetailSyncWithRes(sourceImage: PixelMap, with: i32, height: i32, level: Optional): PixelMap; +EnhanceDetailSyncWithRes(sourceImage: PixelMap, width: i32, height: i32, level: Optional): PixelMap; @overload("enhanceDetailSync") EnhanceDetailSyncWithRatio(sourceImage: PixelMap, scale: f64, level: Optional): PixelMap; diff --git a/interfaces/kits/taihe/include/video_processing_engine_taihe.h b/interfaces/kits/taihe/include/video_processing_engine_taihe.h index 7a64c32..1259786 100644 --- a/interfaces/kits/taihe/include/video_processing_engine_taihe.h +++ b/interfaces/kits/taihe/include/video_processing_engine_taihe.h @@ -27,7 +27,7 @@ #include "taihe/runtime.hpp" #include "pixel_map_taihe.h" -namespace ANI:Vpe { +namespace ANI::Vpe { using namespace taihe; using namespace OHOS; using namespace OHOS::Media; @@ -38,13 +38,13 @@ namespace taiheImage = ::ohos::multimedia::image::image; class ImageProcessorImpl { public: ImageProcessorImpl() = default; - taihe::PixelMap EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, int width, int height, + taiheImage::PixelMap EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, int width, int height, optional_view level); - taihe::PixelMap EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, double scale, + taiheImage::PixelMap EnhanceDetailWithRatio(taiheImage::weak::PixelMap sourceImage, double scale, optional_view level); - taihe::PixelMap EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, int width, int height, + taiheImage::PixelMap EnhanceDetailSyncWithRes(taiheImage::weak::PixelMap sourceImage, int width, int height, optional_view level); - taihe::PixelMap EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, double scale, + taiheImage::PixelMap EnhanceDetailSyncWithRatio(taiheImage::weak::PixelMap sourceImage, double scale, optional_view level); }; @@ -53,8 +53,8 @@ private: double xArg{}; double yArg{}; int32_t qualityLevel{}; - std::shared_ptr inputPixelMap; - std::shared_ptr outputPixelMap; + std::shared_ptr inputPixelMap{}; + std::shared_ptr outputPixelMap{}; } void ParseDetailEnhanceParameter(std::unique_ptr& detailContext, @@ -64,7 +64,8 @@ private: void ParseDetailEnhanceParameter(std::unique_ptr& detailContext, taiheImage::weak::PixelMap sourceImage, double scale, optional_view level); std::shared_ptr DetailEnhanceImpl(DetailEnhanceContext* context); - + std::shared_ptr EnhanceDetailImpl(std::unique_ptr& detailContext); + std::shared_ptr) #include -#elif __has__include() +#elif __has_include() #include #else #error "ani.h not found. Please ensure the Ani SDK is correctly installed." @@ -28,10 +28,11 @@ ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) if (ANI_OK != vm->GetEnv(ANI_VERSION_1, &env)) { return ANI_ERROR; } + ani_status status = ANI_OK; if (ANI_OK != ohos::multimedia::videoProcessingEngine::ANIRegister(env)) { std::cerr << "Error from ohos::multimedia::videoProcessingEngine::ANIRegister" << std::endl; - return ANI_ERROR; + status = ANI_ERROR; } *result = ANI_VERSION_1; - return ANI_OK; + return status; } diff --git a/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp index 481e175..58ef04d 100644 --- a/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp +++ b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp @@ -24,7 +24,7 @@ #include "image_napi_utils.h" #include "media_errors.h" #include "memory_manager.h" -#include "nativ_avformat.h" +#include "native_avformat.h" #include "pixelmap_native_impl.h" #include "pixelmap_native.h" #include "surface_buffer.h" @@ -34,10 +34,21 @@ #include "vpe_trace.h" #include "vpe_utils.h" +using namespace OHOS::Media; +using namespace VideoProcessingEngine; +using namespace ANI; +using namespace ANI::Vpe; + namespace ANI::Vpe { void InitializeEnvironment() {} void DeinitializeEnvironment() {} +taiheVpe::ImageProcessor create() +{ + return make_holder(); +} +} // namespace + void ImageProcessorImpl::ParseDetailEnhanceParameter(std::unique_ptr& detailContext, taiheImage::weak::PixelMap sourceImage, int width, int height, optional_view level) { @@ -45,7 +56,7 @@ void ImageProcessorImpl::ParseDetailEnhanceParameter(std::unique_ptr(sourceImage->GetImplPtr()); + ANI::Image::PixelMapImpl* pixelMapImpl = reinterpret_cast(sourceImage->GetImplPtr()); detailContext->xArg = width; detailContext->yArg = height; if (level.has_value()) { @@ -61,7 +72,8 @@ void ImageProcessorImpl::ParseDetailEnhanceParameter(std::unique_ptr(sourceImage->GetImplPtr()); + ANI::Image::PixelMapImpl* pixelMapImpl = reinterpret_cast(sourceImage->GetImplPtr()); + std::shared_ptr inputPixelMap = pixelMapImpl->GetNativePtr(); detailContext->xArg = inputPixelMap->GetWidth() * scale; detailContext->yArg = inputPixelMap->GetHeight() * scale; if (level.has_value()) { @@ -70,8 +82,8 @@ void ImageProcessorImpl::ParseDetailEnhanceParameter(std::unique_ptrinputPixelMap = pixelMapImpl->GetNativePtr(); } -void ImageProcessorImpl::ParseDetailEnhanceParameter(std::unique_ptr& detailContext, - taiheImage::weak::PixelMap sourceImage, double scale, optional_view level) +std::shared_ptr ImageProcessorImpl::EnhanceDetailImpl( + std::unique_ptr& detailContext) { std::shared_ptr outputPixelMap = DetailEnhanceImpl(detailContext.get()); detailContext->inputPixelMap = nullptr; // 解引用防止内存泄漏 @@ -82,7 +94,7 @@ void ImageProcessorImpl::ParseDetailEnhanceParameter(std::unique_ptr ImageProcessorImpl::DetailEnhanceImpl(DetailEnhanceContext* context) +std::shared_ptr lock(g_detailTaskLock); std::unique_ptr detailContext = std::make_unique(); ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level); - return make_holder(EnhanceDetailImpl(detailContext)); + return make_holder(EnhanceDetailImpl(detailContext)); } taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailWithRatio(taiheImage::weak::PixelMap sourceImage, double scale, @@ -103,8 +115,8 @@ taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailWithRatio(taiheImage::weak VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessRatio"); std::lock_guard lock(g_detailTaskLock); std::unique_ptr detailContext = std::make_unique(); - ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level); - return make_holder(EnhanceDetailImpl(detailContext)); + ParseDetailEnhanceParameter(detailContext, sourceImage, scale, level); + return make_holder(EnhanceDetailImpl(detailContext)); } taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailSyncWithRes(taiheImage::weak::PixelMap sourceImage, int width, @@ -114,7 +126,7 @@ taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailSyncWithRes(taiheImage::we std::lock_guard lock(g_detailTaskLock); std::unique_ptr detailContext = std::make_unique(); ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level); - return make_holder(EnhanceDetailImpl(detailContext)); + return make_holder(EnhanceDetailImpl(detailContext)); } taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailSyncWithRatio(taiheImage::weak::PixelMap sourceImage, @@ -123,13 +135,12 @@ taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailSyncWithRatio(taiheImage:: VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessSyncRatio"); std::lock_guard lock(g_detailTaskLock); std::unique_ptr detailContext = std::make_unique(); - ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level); - return make_holder(EnhanceDetailImpl(detailContext)); + ParseDetailEnhanceParameter(detailContext, sourceImage, scale, level); + return make_holder(EnhanceDetailImpl(detailContext)); } // NOLINTBEGIN TH_EXPORT_CPP_API_InitializeEnvironment(InitializeEnvironment); TH_EXPORT_CPP_API_DeinitializeEnvironment(DeinitializeEnvironment); TH_EXPORT_CPP_API_create(create); -// NOLINTEND -} \ No newline at end of file +// NOLINTEND \ No newline at end of file From 7983b40505bf3bb66ac8632c07dae717b9693363 Mon Sep 17 00:00:00 2001 From: pxh123456 Date: Thu, 22 Jan 2026 21:54:29 +0800 Subject: [PATCH 04/12] vpe ani code Signed-off-by: pxh123456 --- framework/BUILD.gn | 4 ++-- .../taihe/include/video_processing_engine_taihe.h | 5 ++--- .../kits/taihe/src/video_processing_engine_taihe.cpp | 12 ++++++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/framework/BUILD.gn b/framework/BUILD.gn index 7793340..be44261 100644 --- a/framework/BUILD.gn +++ b/framework/BUILD.gn @@ -438,7 +438,7 @@ ohos_shared_library("video_processing") { subsystem_name = "multimedia" part_name = "video_processing_engine" } -image.image + ohos_shared_library("detailEnhancer") { sanitize = { cfi = true @@ -465,7 +465,7 @@ ohos_shared_library("detailEnhancer") { ] cflags = VIDEO_PROCESSING_ENGINE_CFLAGS - external_image.imagedeps = [ + external_deps = [ "c_utils:utils", "graphic_surface:surface", "hilog:libhilog", diff --git a/interfaces/kits/taihe/include/video_processing_engine_taihe.h b/interfaces/kits/taihe/include/video_processing_engine_taihe.h index 1259786..bf88706 100644 --- a/interfaces/kits/taihe/include/video_processing_engine_taihe.h +++ b/interfaces/kits/taihe/include/video_processing_engine_taihe.h @@ -46,7 +46,6 @@ public: optional_view level); taiheImage::PixelMap EnhanceDetailSyncWithRatio(taiheImage::weak::PixelMap sourceImage, double scale, optional_view level); -}; private: struct DetailEnhanceContext { @@ -55,7 +54,7 @@ private: int32_t qualityLevel{}; std::shared_ptr inputPixelMap{}; std::shared_ptr outputPixelMap{}; - } + }; void ParseDetailEnhanceParameter(std::unique_ptr& detailContext, taiheImage::weak::PixelMap sourceImage, int width, int height, optional_view level); @@ -66,6 +65,6 @@ private: std::shared_ptr DetailEnhanceImpl(DetailEnhanceContext* context); std::shared_ptr EnhanceDetailImpl(std::unique_ptr& detailContext); std::shared_ptr level) { VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessRes"); - std::lock_guard lock(g_detailTaskLock); + std::lock_guard lock(g_detailTaskLock); std::unique_ptr detailContext = std::make_unique(); ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level); return make_holder(EnhanceDetailImpl(detailContext)); @@ -113,7 +117,7 @@ taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailWithRatio(taiheImage::weak optional_view level) { VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessRatio"); - std::lock_guard lock(g_detailTaskLock); + std::lock_guard lock(g_detailTaskLock); std::unique_ptr detailContext = std::make_unique(); ParseDetailEnhanceParameter(detailContext, sourceImage, scale, level); return make_holder(EnhanceDetailImpl(detailContext)); @@ -123,7 +127,7 @@ taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailSyncWithRes(taiheImage::we int height, optional_view level) { VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessSyncRes"); - std::lock_guard lock(g_detailTaskLock); + std::lock_guard lock(g_detailTaskLock); std::unique_ptr detailContext = std::make_unique(); ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level); return make_holder(EnhanceDetailImpl(detailContext)); @@ -133,7 +137,7 @@ taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailSyncWithRatio(taiheImage:: double scale, optional_view level) { VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessSyncRatio"); - std::lock_guard lock(g_detailTaskLock); + std::lock_guard lock(g_detailTaskLock); std::unique_ptr detailContext = std::make_unique(); ParseDetailEnhanceParameter(detailContext, sourceImage, scale, level); return make_holder(EnhanceDetailImpl(detailContext)); From 5652fc48f748c8141048d4ddbb7330371db2baf0 Mon Sep 17 00:00:00 2001 From: pxh123456 Date: Thu, 22 Jan 2026 22:01:03 +0800 Subject: [PATCH 05/12] vpe ani code Signed-off-by: pxh123456 --- .../kits/taihe/include/video_processing_engine_taihe.h | 5 +---- .../kits/taihe/src/video_processing_engine_taihe.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/interfaces/kits/taihe/include/video_processing_engine_taihe.h b/interfaces/kits/taihe/include/video_processing_engine_taihe.h index bf88706..2552912 100644 --- a/interfaces/kits/taihe/include/video_processing_engine_taihe.h +++ b/interfaces/kits/taihe/include/video_processing_engine_taihe.h @@ -60,11 +60,8 @@ private: taiheImage::weak::PixelMap sourceImage, int width, int height, optional_view level); void ParseDetailEnhanceParameter(std::unique_ptr& detailContext, taiheImage::weak::PixelMap sourceImage, double scale, optional_view level); - void ParseDetailEnhanceParameter(std::unique_ptr& detailContext, - taiheImage::weak::PixelMap sourceImage, double scale, optional_view level); - std::shared_ptr DetailEnhanceImpl(DetailEnhanceContext* context); std::shared_ptr EnhanceDetailImpl(std::unique_ptr& detailContext); - std::shared_ptr DetailEnhanceImpl(DetailEnhanceContext* context); }; } #endif \ No newline at end of file diff --git a/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp index 390ccaa..3323d24 100644 --- a/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp +++ b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp @@ -34,15 +34,15 @@ #include "vpe_trace.h" #include "vpe_utils.h" +namespace { + static std::mutex g_detailTaskLock{std::mutex()}; +} + using namespace OHOS::Media; using namespace VideoProcessingEngine; using namespace ANI; using namespace ANI::Vpe; -namespace { - static std::mutex g_detailTaskLock{std::mutex()}; -} - namespace ANI::Vpe { void InitializeEnvironment() {} void DeinitializeEnvironment() {} From 67ab7e225f572c72bbb4c1e2614384dda283c1f6 Mon Sep 17 00:00:00 2001 From: pxh123456 Date: Thu, 22 Jan 2026 22:24:43 +0800 Subject: [PATCH 06/12] vpe ani code Signed-off-by: pxh123456 --- interfaces/kits/taihe/src/video_processing_engine_taihe.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp index 3323d24..a2b8714 100644 --- a/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp +++ b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp @@ -98,7 +98,7 @@ std::shared_ptr ImageProcessorImpl::EnhanceDetailImpl( return outputPixelMap; } -std::shared_ptr ImageProcessorImpl::DetailEnhanceImpl(DetailEnhanceContext* context) { return nullptr; } From 982fe7005462ab23ce2046699e451df25e8dd09a Mon Sep 17 00:00:00 2001 From: pxh123456 Date: Fri, 23 Jan 2026 09:15:46 +0800 Subject: [PATCH 07/12] vpe ani code Signed-off-by: pxh123456 --- interfaces/kits/taihe/BUILD.gn | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/interfaces/kits/taihe/BUILD.gn b/interfaces/kits/taihe/BUILD.gn index 0d41848..71a93b0 100644 --- a/interfaces/kits/taihe/BUILD.gn +++ b/interfaces/kits/taihe/BUILD.gn @@ -1,17 +1,15 @@ -/* - * Copyright (C) 2026 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. - */ +# Copyright (c) 2026 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/config/components/ets_frontend/ets2abc_config.gni") import("//build/ohos.gni") From 9a5a4d7377a967ff4d6ecf38930dc44523b4533d Mon Sep 17 00:00:00 2001 From: pxh123456 Date: Fri, 23 Jan 2026 11:54:47 +0800 Subject: [PATCH 08/12] vpe ani code Signed-off-by: pxh123456 --- interfaces/kits/taihe/BUILD.gn | 1 - interfaces/kits/taihe/src/video_processing_engine_taihe.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/interfaces/kits/taihe/BUILD.gn b/interfaces/kits/taihe/BUILD.gn index 71a93b0..8e50e5a 100644 --- a/interfaces/kits/taihe/BUILD.gn +++ b/interfaces/kits/taihe/BUILD.gn @@ -91,7 +91,6 @@ taihe_shared_library("video_processing_engine_taihe") { sources = get_target_outputs(":run_taihe") sources += [ "src/video_processing_engine_taihe.cpp", - "$CAPI_DIR/image_processing/detail_enhance_napi_utils.cpp", ] deps = [ diff --git a/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp index a2b8714..c6c1d48 100644 --- a/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp +++ b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp @@ -16,7 +16,6 @@ #include "video_processing_engine_taihe.h" #include "detail_enhance_napi_formal.h" -#include "detail_enhance_napi_utils.h" #include #include From 145a9ccf26ddbcdae46054caacaaf651d08680ff Mon Sep 17 00:00:00 2001 From: pxh123456 Date: Fri, 23 Jan 2026 16:15:22 +0800 Subject: [PATCH 09/12] vpe ani code Signed-off-by: pxh123456 --- framework/BUILD.gn | 1 - 1 file changed, 1 deletion(-) diff --git a/framework/BUILD.gn b/framework/BUILD.gn index be44261..97cee84 100644 --- a/framework/BUILD.gn +++ b/framework/BUILD.gn @@ -457,7 +457,6 @@ ohos_shared_library("detailEnhancer") { ] sources = [ "//foundation/multimedia/video_processing_engine/framework/capi/image_processing/detail_enhance_napi.cpp", - "//foundation/multimedia/image_framework/frameworks/innerkitsimpl/common/src/memory_manager.cpp", ] deps = [ From f7fc42b56739ac3cc61e0b6e419f0000eec3dfeb Mon Sep 17 00:00:00 2001 From: pxh123456 Date: Fri, 23 Jan 2026 17:58:42 +0800 Subject: [PATCH 10/12] vpe ani code Signed-off-by: pxh123456 --- .../include/video_processing_engine_taihe.h | 25 ++++++------ interfaces/kits/taihe/src/ani_constructor.cpp | 4 +- .../src/video_processing_engine_taihe.cpp | 40 +++++++++++++------ 3 files changed, 42 insertions(+), 27 deletions(-) diff --git a/interfaces/kits/taihe/include/video_processing_engine_taihe.h b/interfaces/kits/taihe/include/video_processing_engine_taihe.h index 2552912..98476d9 100644 --- a/interfaces/kits/taihe/include/video_processing_engine_taihe.h +++ b/interfaces/kits/taihe/include/video_processing_engine_taihe.h @@ -29,39 +29,38 @@ namespace ANI::Vpe { using namespace taihe; -using namespace OHOS; -using namespace OHOS::Media; -using namespace OHOS::Media::VideoProcessingEngine; namespace taiheVpe = ::ohos::multimedia::videoProcessingEngine; namespace taiheImage = ::ohos::multimedia::image::image; class ImageProcessorImpl { public: ImageProcessorImpl() = default; + ~PixelMapImpl() = default; taiheImage::PixelMap EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, int width, int height, - optional_view level); + taihe::optional_view level); taiheImage::PixelMap EnhanceDetailWithRatio(taiheImage::weak::PixelMap sourceImage, double scale, - optional_view level); + taihe::optional_view level); taiheImage::PixelMap EnhanceDetailSyncWithRes(taiheImage::weak::PixelMap sourceImage, int width, int height, - optional_view level); + taihe::optional_view level); taiheImage::PixelMap EnhanceDetailSyncWithRatio(taiheImage::weak::PixelMap sourceImage, double scale, - optional_view level); + taihe::optional_view level); private: struct DetailEnhanceContext { double xArg{}; double yArg{}; int32_t qualityLevel{}; - std::shared_ptr inputPixelMap{}; - std::shared_ptr outputPixelMap{}; + std::shared_ptr inputPixelMap{}; + std::shared_ptr outputPixelMap{}; }; void ParseDetailEnhanceParameter(std::unique_ptr& detailContext, - taiheImage::weak::PixelMap sourceImage, int width, int height, optional_view level); + taiheImage::weak::PixelMap sourceImage, int width, int height, + taihe::optional_view level); void ParseDetailEnhanceParameter(std::unique_ptr& detailContext, - taiheImage::weak::PixelMap sourceImage, double scale, optional_view level); - std::shared_ptr EnhanceDetailImpl(std::unique_ptr& detailContext); - std::shared_ptr DetailEnhanceImpl(DetailEnhanceContext* context); + taiheImage::weak::PixelMap sourceImage, double scale, taihe::optional_view level); + std::shared_ptr EnhanceDetail(std::unique_ptr& detailContext); + std::shared_ptr EnhanceDetailImpl(std::unique_ptr& context); }; } #endif \ No newline at end of file diff --git a/interfaces/kits/taihe/src/ani_constructor.cpp b/interfaces/kits/taihe/src/ani_constructor.cpp index 217c3c8..9c2b0a1 100644 --- a/interfaces/kits/taihe/src/ani_constructor.cpp +++ b/interfaces/kits/taihe/src/ani_constructor.cpp @@ -22,9 +22,9 @@ #error "ani.h not found. Please ensure the Ani SDK is correctly installed." #endif -ANI_EXPORT ani_status ANI_Constructor(ani_vm *vm, uint32_t *result) +ANI_EXPORT ani_status ANI_Constructor(ani_vm* vm, uint32_t* result) { - ani_env *env; + ani_env* env; if (ANI_OK != vm->GetEnv(ANI_VERSION_1, &env)) { return ANI_ERROR; } diff --git a/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp index c6c1d48..bdb3022 100644 --- a/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp +++ b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp @@ -34,9 +34,10 @@ #include "vpe_utils.h" namespace { - static std::mutex g_detailTaskLock{std::mutex()}; +static std::mutex g_detailTaskLock{std::mutex()}; } +using namespace taihe; using namespace OHOS::Media; using namespace VideoProcessingEngine; using namespace ANI; @@ -85,19 +86,20 @@ void ImageProcessorImpl::ParseDetailEnhanceParameter(std::unique_ptrinputPixelMap = pixelMapImpl->GetNativePtr(); } -std::shared_ptr ImageProcessorImpl::EnhanceDetailImpl( +std::shared_ptr ImageProcessorImpl::EnhanceDetail( std::unique_ptr& detailContext) { - std::shared_ptr outputPixelMap = DetailEnhanceImpl(detailContext.get()); - detailContext->inputPixelMap = nullptr; // 解引用防止内存泄漏 + std::shared_ptr outputPixelMap = EnhanceDetailImpl(detailContext.get()); + detailContext->inputPixelMap = nullptr; // Dereferencing prevents memory leaks if (outputPixelMap == nullptr) { - VPE_LOGE("DetailEnhanceImpl processed failed"); + VPE_LOGE("DetailEnhance processed failed"); return nullptr; } return outputPixelMap; } -std::shared_ptr ImageProcessorImpl::DetailEnhanceImpl(DetailEnhanceContext* context) +std::shared_ptr ImageProcessorImpl::DEnhanceDetailImpl( + std::unique_ptr& detailContext) { return nullptr; } @@ -106,20 +108,26 @@ taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailWithRes(taiheImage::weak:: int height, optional_view level) { VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessRes"); - std::lock_guard lock(g_detailTaskLock); std::unique_ptr detailContext = std::make_unique(); + if (detailContext == nullptr) { + VPE_LOGE("invalid context"); + return make_holder(); + } ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level); - return make_holder(EnhanceDetailImpl(detailContext)); + return make_holder(EnhanceDetail(detailContext)); } taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailWithRatio(taiheImage::weak::PixelMap sourceImage, double scale, optional_view level) { VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessRatio"); - std::lock_guard lock(g_detailTaskLock); std::unique_ptr detailContext = std::make_unique(); + if (detailContext == nullptr) { + VPE_LOGE("invalid context"); + return make_holder(); + } ParseDetailEnhanceParameter(detailContext, sourceImage, scale, level); - return make_holder(EnhanceDetailImpl(detailContext)); + return make_holder(EnhanceDetail(detailContext)); } taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailSyncWithRes(taiheImage::weak::PixelMap sourceImage, int width, @@ -128,8 +136,12 @@ taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailSyncWithRes(taiheImage::we VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessSyncRes"); std::lock_guard lock(g_detailTaskLock); std::unique_ptr detailContext = std::make_unique(); + if (detailContext == nullptr) { + VPE_LOGE("invalid context"); + return make_holder(); + } ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level); - return make_holder(EnhanceDetailImpl(detailContext)); + return make_holder(EnhanceDetail(detailContext)); } taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailSyncWithRatio(taiheImage::weak::PixelMap sourceImage, @@ -138,8 +150,12 @@ taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailSyncWithRatio(taiheImage:: VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessSyncRatio"); std::lock_guard lock(g_detailTaskLock); std::unique_ptr detailContext = std::make_unique(); + if (detailContext == nullptr) { + VPE_LOGE("invalid context"); + return make_holder(); + } ParseDetailEnhanceParameter(detailContext, sourceImage, scale, level); - return make_holder(EnhanceDetailImpl(detailContext)); + return make_holder(EnhanceDetail(detailContext)); } // NOLINTBEGIN From cb94750a17f54eec789df25c90dbd4a93a8d9679 Mon Sep 17 00:00:00 2001 From: pxh123456 Date: Fri, 23 Jan 2026 18:03:30 +0800 Subject: [PATCH 11/12] vpe ani code Signed-off-by: pxh123456 --- interfaces/kits/taihe/include/video_processing_engine_taihe.h | 2 +- interfaces/kits/taihe/src/video_processing_engine_taihe.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interfaces/kits/taihe/include/video_processing_engine_taihe.h b/interfaces/kits/taihe/include/video_processing_engine_taihe.h index 98476d9..d3c2b61 100644 --- a/interfaces/kits/taihe/include/video_processing_engine_taihe.h +++ b/interfaces/kits/taihe/include/video_processing_engine_taihe.h @@ -35,7 +35,7 @@ namespace taiheImage = ::ohos::multimedia::image::image; class ImageProcessorImpl { public: ImageProcessorImpl() = default; - ~PixelMapImpl() = default; + ~ImageProcessorImpl() = default; taiheImage::PixelMap EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, int width, int height, taihe::optional_view level); taiheImage::PixelMap EnhanceDetailWithRatio(taiheImage::weak::PixelMap sourceImage, double scale, diff --git a/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp index bdb3022..fcd3804 100644 --- a/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp +++ b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp @@ -89,7 +89,7 @@ void ImageProcessorImpl::ParseDetailEnhanceParameter(std::unique_ptr ImageProcessorImpl::EnhanceDetail( std::unique_ptr& detailContext) { - std::shared_ptr outputPixelMap = EnhanceDetailImpl(detailContext.get()); + std::shared_ptr outputPixelMap = EnhanceDetailImpl(detailContext); detailContext->inputPixelMap = nullptr; // Dereferencing prevents memory leaks if (outputPixelMap == nullptr) { VPE_LOGE("DetailEnhance processed failed"); @@ -98,7 +98,7 @@ std::shared_ptr ImageProcessorImpl::EnhanceDetail( return outputPixelMap; } -std::shared_ptr ImageProcessorImpl::DEnhanceDetailImpl( +std::shared_ptr ImageProcessorImpl::EnhanceDetailImpl( std::unique_ptr& detailContext) { return nullptr; From 50242f720aeacff4a58202ed8a0480744105a942 Mon Sep 17 00:00:00 2001 From: pxh123456 Date: Fri, 23 Jan 2026 18:24:18 +0800 Subject: [PATCH 12/12] vpe ani code Signed-off-by: pxh123456 --- interfaces/kits/taihe/src/video_processing_engine_taihe.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp index fcd3804..2888e7c 100644 --- a/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp +++ b/interfaces/kits/taihe/src/video_processing_engine_taihe.cpp @@ -90,7 +90,7 @@ std::shared_ptr ImageProcessorImpl::EnhanceDetail( std::unique_ptr& detailContext) { std::shared_ptr outputPixelMap = EnhanceDetailImpl(detailContext); - detailContext->inputPixelMap = nullptr; // Dereferencing prevents memory leaks + detailContext->inputPixelMap = nullptr; // Dereferencing prevents memory leaks if (outputPixelMap == nullptr) { VPE_LOGE("DetailEnhance processed failed"); return nullptr;