mirror of
https://github.com/openharmony/multimedia_video_processing_engine.git
synced 2026-07-01 06:41:58 -04:00
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+2
-2
@@ -30,13 +30,13 @@ enum QualityLevel : i32 {
|
||||
|
||||
interface ImageProcessor {
|
||||
@overload("enhanceDetail")
|
||||
@promise EnhanceDetailWithRes(sourceImage: PixelMap, with: i32, height: i32, level: Optional<QualityLevel>): PixelMap;
|
||||
@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, with: i32, height: i32, level: Optional<QualityLevel>): PixelMap;
|
||||
EnhanceDetailSyncWithRes(sourceImage: PixelMap, width: i32, height: i32, level: Optional<QualityLevel>): PixelMap;
|
||||
|
||||
@overload("enhanceDetailSync")
|
||||
EnhanceDetailSyncWithRatio(sourceImage: PixelMap, scale: f64, level: Optional<QualityLevel>): PixelMap;
|
||||
@@ -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<taiheVpe::QualityLevel> level);
|
||||
taihe::PixelMap EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, double scale,
|
||||
taiheImage::PixelMap EnhanceDetailWithRatio(taiheImage::weak::PixelMap sourceImage, double scale,
|
||||
optional_view<taiheVpe::QualityLevel> 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<taiheVpe::QualityLevel> level);
|
||||
taihe::PixelMap EnhanceDetailWithRes(taiheImage::weak::PixelMap sourceImage, double scale,
|
||||
taiheImage::PixelMap EnhanceDetailSyncWithRatio(taiheImage::weak::PixelMap sourceImage, double scale,
|
||||
optional_view<taiheVpe::QualityLevel> level);
|
||||
};
|
||||
|
||||
@@ -53,8 +53,8 @@ private:
|
||||
double xArg{};
|
||||
double yArg{};
|
||||
int32_t qualityLevel{};
|
||||
std::shared_ptr<PixelMap> inputPixelMap;
|
||||
std::shared_ptr<PixelMap> outputPixelMap;
|
||||
std::shared_ptr<PixelMap> inputPixelMap{};
|
||||
std::shared_ptr<PixelMap> outputPixelMap{};
|
||||
}
|
||||
|
||||
void ParseDetailEnhanceParameter(std::unique_ptr<DetailEnhanceContext>& detailContext,
|
||||
@@ -64,7 +64,8 @@ private:
|
||||
void ParseDetailEnhanceParameter(std::unique_ptr<DetailEnhanceContext>& detailContext,
|
||||
taiheImage::weak::PixelMap sourceImage, double scale, optional_view<taiheVpe::QualityLevel> level);
|
||||
std::shared_ptr<PixelMap> DetailEnhanceImpl(DetailEnhanceContext* context);
|
||||
|
||||
std::shared_ptr<OHOS::Media::PixelMap> EnhanceDetailImpl(std::unique_ptr<DetailEnhanceContext>& detailContext);
|
||||
std::shared_ptr<OHOS::Media::PixelMap DetailEnhanceImpl(DetailEnhanceContext* context);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "ohos.multimedia.videoProcessingEngine.ani.hpp"
|
||||
#if __has_include(<ani.h>)
|
||||
#include <ani.h>
|
||||
#elif __has__include(<ani/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."
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<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)
|
||||
{
|
||||
@@ -45,7 +56,7 @@ void ImageProcessorImpl::ParseDetailEnhanceParameter(std::unique_ptr<DetailEnhan
|
||||
VPE_LOGE("detailContext == nullptr");
|
||||
return;
|
||||
}
|
||||
ANI::Image:PixelMapImp* pixelMapImpl = reinterpret_cast<ANI::Image::PixelMapImpl*>(sourceImage->GetImplPtr());
|
||||
ANI::Image::PixelMapImpl* pixelMapImpl = reinterpret_cast<ANI::Image::PixelMapImpl*>(sourceImage->GetImplPtr());
|
||||
detailContext->xArg = width;
|
||||
detailContext->yArg = height;
|
||||
if (level.has_value()) {
|
||||
@@ -61,7 +72,8 @@ void ImageProcessorImpl::ParseDetailEnhanceParameter(std::unique_ptr<DetailEnhan
|
||||
VPE_LOGE("detailContext == nullptr");
|
||||
return;
|
||||
}
|
||||
ANI::Image:PixelMapImp* pixelMapImpl = reinterpret_cast<ANI::Image::PixelMapImpl*>(sourceImage->GetImplPtr());
|
||||
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()) {
|
||||
@@ -70,8 +82,8 @@ void ImageProcessorImpl::ParseDetailEnhanceParameter(std::unique_ptr<DetailEnhan
|
||||
detailContext->inputPixelMap = pixelMapImpl->GetNativePtr();
|
||||
}
|
||||
|
||||
void ImageProcessorImpl::ParseDetailEnhanceParameter(std::unique_ptr<DetailEnhanceContext>& detailContext,
|
||||
taiheImage::weak::PixelMap sourceImage, double scale, optional_view<taiheVpe::QualityLevel> level)
|
||||
std::shared_ptr<OHOS::Media::PixelMap> ImageProcessorImpl::EnhanceDetailImpl(
|
||||
std::unique_ptr<DetailEnhanceContext>& detailContext)
|
||||
{
|
||||
std::shared_ptr<OHOS::Media::PixelMap> outputPixelMap = DetailEnhanceImpl(detailContext.get());
|
||||
detailContext->inputPixelMap = nullptr; // 解引用防止内存泄漏
|
||||
@@ -82,7 +94,7 @@ void ImageProcessorImpl::ParseDetailEnhanceParameter(std::unique_ptr<DetailEnhan
|
||||
return outputPixelMap;
|
||||
}
|
||||
|
||||
std::shared_ptr<PixelMap> ImageProcessorImpl::DetailEnhanceImpl(DetailEnhanceContext* context)
|
||||
std::shared_ptr<OHOS::Media::PixelMap ImageProcessorImpl::DetailEnhanceImpl(DetailEnhanceContext* context)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
@@ -94,7 +106,7 @@ taiheImage::PixelMap ImageProcessorImpl::EnhanceDetailWithRes(taiheImage::weak::
|
||||
std::lock_guard<std::mutext> lock(g_detailTaskLock);
|
||||
std::unique_ptr<DetailEnhanceContext> detailContext = std::make_unique<DetailEnhanceContext>();
|
||||
ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level);
|
||||
return make_holder<ANI::Image::PixelMapImp, taiheImage::PixelMap>(EnhanceDetailImpl(detailContext));
|
||||
return make_holder<ANI::Image::PixelMapImpl, taiheImage::PixelMap>(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<std::mutext> lock(g_detailTaskLock);
|
||||
std::unique_ptr<DetailEnhanceContext> detailContext = std::make_unique<DetailEnhanceContext>();
|
||||
ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level);
|
||||
return make_holder<ANI::Image::PixelMapImp, taiheImage::PixelMap>(EnhanceDetailImpl(detailContext));
|
||||
ParseDetailEnhanceParameter(detailContext, sourceImage, scale, level);
|
||||
return make_holder<ANI::Image::PixelMapImpl, taiheImage::PixelMap>(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<std::mutext> lock(g_detailTaskLock);
|
||||
std::unique_ptr<DetailEnhanceContext> detailContext = std::make_unique<DetailEnhanceContext>();
|
||||
ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level);
|
||||
return make_holder<ANI::Image::PixelMapImp, taiheImage::PixelMap>(EnhanceDetailImpl(detailContext));
|
||||
return make_holder<ANI::Image::PixelMapImpl, taiheImage::PixelMap>(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<std::mutext> lock(g_detailTaskLock);
|
||||
std::unique_ptr<DetailEnhanceContext> detailContext = std::make_unique<DetailEnhanceContext>();
|
||||
ParseDetailEnhanceParameter(detailContext, sourceImage, width, height, level);
|
||||
return make_holder<ANI::Image::PixelMapImp, taiheImage::PixelMap>(EnhanceDetailImpl(detailContext));
|
||||
ParseDetailEnhanceParameter(detailContext, sourceImage, scale, level);
|
||||
return make_holder<ANI::Image::PixelMapImpl, taiheImage::PixelMap>(EnhanceDetailImpl(detailContext));
|
||||
}
|
||||
|
||||
// NOLINTBEGIN
|
||||
TH_EXPORT_CPP_API_InitializeEnvironment(InitializeEnvironment);
|
||||
TH_EXPORT_CPP_API_DeinitializeEnvironment(DeinitializeEnvironment);
|
||||
TH_EXPORT_CPP_API_create(create);
|
||||
// NOLINTEND
|
||||
}
|
||||
// NOLINTEND
|
||||
Reference in New Issue
Block a user