!47 merge master into master

vpe ani code

Created-by: pxh123456
Commit-by: pxh123456
Merged-by: openharmony_ci
Description: ### 一、内容说明(相关的Issue)

https://gitcode.com/openharmony/multimedia_video_processing_engine/issues/32

### 二、建议测试周期和提测地址  
  建议测试完成时间:2026.01.22  
  投产上线时间:2026.01.22
  提测地址:压测环境  
  测试账号:  

### 三、变更内容
  * 3.1 关联PR列表

  * 3.2 数据库和部署说明  
    1. 常规更新 

  * 3.4 其他技术优化内容(做了什么,变更了什么)
无


  * 3.5 废弃通知(什么字段、方法弃用?)



  * 3.6  后向不兼容变更(是否有无法向后兼容的变更?)
无

  
### 四、研发自测点(自测哪些?冒烟用例全部自测?)
  自测测试结论:通过


### 五、测试关注点(需要提醒QA重点关注的、可能会忽略的地方)
  检查点:缩放功能

  接口测试:pass

  性能测试:pass

  并发测试:pass

  其他:pass



See merge request: openharmony/multimedia_video_processing_engine!47
This commit is contained in:
openharmony_ci
2026-01-24 12:30:26 +08:00
7 changed files with 471 additions and 2 deletions
+4 -1
View File
@@ -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": [
{
-1
View File
@@ -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 = [
+150
View File
@@ -0,0 +1,150 @@
# 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 = "video_processing_engine"
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("video_processing_engine_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",
]
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
}
}
@@ -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, width: i32, height: i32, level: Optional<QualityLevel>): PixelMap;
@overload("enhanceDetail")
@promise EnhanceDetailWithRatio(sourceImage: PixelMap, scale: f64, level: Optional<QualityLevel>): PixelMap;
@overload("enhanceDetailSync")
EnhanceDetailSyncWithRes(sourceImage: PixelMap, width: i32, height: i32, level: Optional<QualityLevel>): PixelMap;
@overload("enhanceDetailSync")
EnhanceDetailSyncWithRatio(sourceImage: PixelMap, scale: f64, level: Optional<QualityLevel>): PixelMap;
}
@promise function InitializeEnvironment(): void;
@promise function DeinitializeEnvironment(): void;
function create(): ImageProcessor;
@@ -0,0 +1,66 @@
/*
* 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;
namespace taiheVpe = ::ohos::multimedia::videoProcessingEngine;
namespace taiheImage = ::ohos::multimedia::image::image;
class ImageProcessorImpl {
public:
ImageProcessorImpl() = default;
~ImageProcessorImpl() = default;
taiheImage::PixelMap EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, int width, int height,
taihe::optional_view<taiheVpe::QualityLevel> level);
taiheImage::PixelMap EnhanceDetailWithRatio(taiheImage::weak::PixelMap sourceImage, double scale,
taihe::optional_view<taiheVpe::QualityLevel> level);
taiheImage::PixelMap EnhanceDetailSyncWithRes(taiheImage::weak::PixelMap sourceImage, int width, int height,
taihe::optional_view<taiheVpe::QualityLevel> level);
taiheImage::PixelMap EnhanceDetailSyncWithRatio(taiheImage::weak::PixelMap sourceImage, double scale,
taihe::optional_view<taiheVpe::QualityLevel> level);
private:
struct DetailEnhanceContext {
double xArg{};
double yArg{};
int32_t qualityLevel{};
std::shared_ptr<OHOS::Media::PixelMap> inputPixelMap{};
std::shared_ptr<OHOS::Media::PixelMap> outputPixelMap{};
};
void ParseDetailEnhanceParameter(std::unique_ptr<DetailEnhanceContext>& detailContext,
taiheImage::weak::PixelMap sourceImage, int width, int height,
taihe::optional_view<taiheVpe::QualityLevel> level);
void ParseDetailEnhanceParameter(std::unique_ptr<DetailEnhanceContext>& detailContext,
taiheImage::weak::PixelMap sourceImage, double scale, taihe::optional_view<taiheVpe::QualityLevel> level);
std::shared_ptr<OHOS::Media::PixelMap> EnhanceDetail(std::unique_ptr<DetailEnhanceContext>& detailContext);
std::shared_ptr<OHOS::Media::PixelMap> EnhanceDetailImpl(std::unique_ptr<DetailEnhanceContext>& context);
};
}
#endif
@@ -0,0 +1,38 @@
/*
* 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(<ani.h>)
#include <ani.h>
#elif __has_include(<ani/ani.h>)
#include <ani/ani.h>
#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;
}
ani_status status = ANI_OK;
if (ANI_OK != ohos::multimedia::videoProcessingEngine::ANIRegister(env)) {
std::cerr << "Error from ohos::multimedia::videoProcessingEngine::ANIRegister" << std::endl;
status = ANI_ERROR;
}
*result = ANI_VERSION_1;
return status;
}
@@ -0,0 +1,165 @@
/*
* 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 <algorithm>
#include <unordered_set>
#include "image_napi_utils.h"
#include "media_errors.h"
#include "memory_manager.h"
#include "native_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 {
static std::mutex g_detailTaskLock{std::mutex()};
}
using namespace taihe;
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<ImageProcessorImpl, taiheVpe::ImageProcessor>();
}
} // namespace
void ImageProcessorImpl::ParseDetailEnhanceParameter(std::unique_ptr<DetailEnhanceContext>& detailContext,
taiheImage::weak::PixelMap sourceImage, int width, int height, optional_view<taiheVpe::QualityLevel> level)
{
if (detailContext == nullptr) {
VPE_LOGE("detailContext == nullptr");
return;
}
ANI::Image::PixelMapImpl* pixelMapImpl = reinterpret_cast<ANI::Image::PixelMapImpl*>(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<DetailEnhanceContext>& detailContext,
taiheImage::weak::PixelMap sourceImage, double scale, optional_view<taiheVpe::QualityLevel> level)
{
if (detailContext == nullptr) {
VPE_LOGE("detailContext == nullptr");
return;
}
ANI::Image::PixelMapImpl* pixelMapImpl = reinterpret_cast<ANI::Image::PixelMapImpl*>(sourceImage->GetImplPtr());
std::shared_ptr<Media::PixelMap> inputPixelMap = pixelMapImpl->GetNativePtr();
detailContext->xArg = inputPixelMap->GetWidth() * scale;
detailContext->yArg = inputPixelMap->GetHeight() * scale;
if (level.has_value()) {
detailContext->qualityLevel = level.value();
}
detailContext->inputPixelMap = pixelMapImpl->GetNativePtr();
}
std::shared_ptr<OHOS::Media::PixelMap> ImageProcessorImpl::EnhanceDetail(
std::unique_ptr<DetailEnhanceContext>& detailContext)
{
std::shared_ptr<OHOS::Media::PixelMap> outputPixelMap = EnhanceDetailImpl(detailContext);
detailContext->inputPixelMap = nullptr; // Dereferencing prevents memory leaks
if (outputPixelMap == nullptr) {
VPE_LOGE("DetailEnhance processed failed");
return nullptr;
}
return outputPixelMap;
}
std::shared_ptr<OHOS::Media::PixelMap> ImageProcessorImpl::EnhanceDetailImpl(
std::unique_ptr<DetailEnhanceContext>& detailContext)
{
return nullptr;
}
taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, int width,
int height, optional_view<taiheVpe::QualityLevel> level)
{
VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessRes");
std::unique_ptr<DetailEnhanceContext> detailContext = std::make_unique<DetailEnhanceContext>();
if (detailContext == nullptr) {
VPE_LOGE("invalid context");
return make_holder<ANI::Image::PixelMapImpl, taiheImage::PixelMap>();
}
ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level);
return make_holder<ANI::Image::PixelMapImpl, taiheImage::PixelMap>(EnhanceDetail(detailContext));
}
taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailWithRatio(taiheImage::weak::PixelMap sourceImage, double scale,
optional_view<taiheVpe::QualityLevel> level)
{
VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessRatio");
std::unique_ptr<DetailEnhanceContext> detailContext = std::make_unique<DetailEnhanceContext>();
if (detailContext == nullptr) {
VPE_LOGE("invalid context");
return make_holder<ANI::Image::PixelMapImpl, taiheImage::PixelMap>();
}
ParseDetailEnhanceParameter(detailContext, sourceImage, scale, level);
return make_holder<ANI::Image::PixelMapImpl, taiheImage::PixelMap>(EnhanceDetail(detailContext));
}
taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailSyncWithRes(taiheImage::weak::PixelMap sourceImage, int width,
int height, optional_view<taiheVpe::QualityLevel> level)
{
VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessSyncRes");
std::lock_guard<std::mutex> lock(g_detailTaskLock);
std::unique_ptr<DetailEnhanceContext> detailContext = std::make_unique<DetailEnhanceContext>();
if (detailContext == nullptr) {
VPE_LOGE("invalid context");
return make_holder<ANI::Image::PixelMapImpl, taiheImage::PixelMap>();
}
ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level);
return make_holder<ANI::Image::PixelMapImpl, taiheImage::PixelMap>(EnhanceDetail(detailContext));
}
taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailSyncWithRatio(taiheImage::weak::PixelMap sourceImage,
double scale, optional_view<taiheVpe::QualityLevel> level)
{
VPETrace vpeTrace("VpeAni::DeatailEnhanceProcessSyncRatio");
std::lock_guard<std::mutex> lock(g_detailTaskLock);
std::unique_ptr<DetailEnhanceContext> detailContext = std::make_unique<DetailEnhanceContext>();
if (detailContext == nullptr) {
VPE_LOGE("invalid context");
return make_holder<ANI::Image::PixelMapImpl, taiheImage::PixelMap>();
}
ParseDetailEnhanceParameter(detailContext, sourceImage, scale, level);
return make_holder<ANI::Image::PixelMapImpl, taiheImage::PixelMap>(EnhanceDetail(detailContext));
}
// NOLINTBEGIN
TH_EXPORT_CPP_API_InitializeEnvironment(InitializeEnvironment);
TH_EXPORT_CPP_API_DeinitializeEnvironment(DeinitializeEnvironment);
TH_EXPORT_CPP_API_create(create);
// NOLINTEND