From e6dc107f6f6f808b438ad89ef532fead424fd6d4 Mon Sep 17 00:00:00 2001 From: xuedong Date: Wed, 5 Mar 2025 15:32:15 +0800 Subject: [PATCH] fix: fix bug of flush for AVPlayer and fix DT test fail and optimize lock & buffer queue for AVPlayer. Signed-off-by: xuedong --- .../algorithm/common/algorithm_video_impl.cpp | 103 ++++++++++--- .../detail_enhancer_video_impl.cpp | 5 + .../include/detail_enhancer_video_impl.h | 1 + .../detail_enhancer_video_unit_test.cpp | 142 ++++++++++-------- 4 files changed, 166 insertions(+), 85 deletions(-) diff --git a/framework/algorithm/common/algorithm_video_impl.cpp b/framework/algorithm/common/algorithm_video_impl.cpp index 86179de..f5b2dce 100644 --- a/framework/algorithm/common/algorithm_video_impl.cpp +++ b/framework/algorithm/common/algorithm_video_impl.cpp @@ -74,7 +74,12 @@ VPEAlgoErrCode VpeVideoImpl::SetOutputSurface(const sptr& surface) "Invalid input: surface is invalid!"); std::lock_guard lock(lock_); + std::lock_guard producerLock(producerLock_); if (producer_ == surface) { + if (producer_->GetUniqueId() == surface->GetUniqueId()) { + VPE_LOGD("Oops! The same surface!"); + return VPE_ALGO_ERR_OK; + } VPE_LOGD("Oops! The same surface!"); return VPE_ALGO_ERR_OK; } @@ -89,19 +94,57 @@ VPEAlgoErrCode VpeVideoImpl::SetOutputSurface(const sptr& surface) VPE_LOGI("Set output buffer queue size to %{public}u", BUFFER_QUEUE_SIZE); surface->SetQueueSize(BUFFER_QUEUE_SIZE); surface->Connect(); - AttachBuffers(surface); + surface->CleanCache(); + AttachAndRefreshProducerBuffers(surface); if (state_.load() != VPEState::IDLE) { cvTrigger_.notify_one(); } producer_ = surface; + VPEAlgoErrCode ret = VPE_ALGO_ERR_OK; if (isEnable_.load()) { ret = UpdateRequestCfg(surface, requestCfg_); } - VPE_LOGD("requestCfg_({ %{public}s })", ToString(requestCfg_).c_str()); + VPE_LOGD("requestCfg_({ %{public}s }) ret:%{public}d", ToString(requestCfg_).c_str(), ret); + + isForceUpdateProducer_ = true; + if (ret == VPE_ALGO_ERR_OK) { + if (consumer_ != nullptr) { + return UpdateProducerLocked(); + } + } return ret; } +VPEAlgoErrCode VpeVideoImpl::UpdateProducerLocked() +{ + auto transform = consumer_->GetTransform(); + GSError err; + if (isForceUpdateProducer_ || lastTransform_ != transform) { + err = producer_->SetTransform(transform); + CHECK_AND_RETURN_RET_LOG(err == GSERROR_OK, VPE_ALGO_ERR_UNKNOWN, + "Failed to SetTransform(%{public}d), ret:%{public}d!", transform, err); + lastTransform_ = transform; + VPE_LOGD("producer_->SetTransform(%{public}d) success.", transform); + } + if (lastConsumerBufferId_ == 0) { + return VPE_ALGO_ERR_OK; + } + ScalingMode scaleMode; + err = consumer_->GetScalingMode(lastConsumerBufferId_, scaleMode); + CHECK_AND_RETURN_RET_LOG(err == GSERROR_OK, VPE_ALGO_ERR_UNKNOWN, + "Failed to GetScalingMode(%{public}u), ret:%{public}d!", lastConsumerBufferId_, err); + if (isForceUpdateProducer_ || lastScalingMode_ != scaleMode) { + err = producer_->SetScalingMode(scaleMode); + CHECK_AND_RETURN_RET_LOG(err == GSERROR_OK, VPE_ALGO_ERR_UNKNOWN, + "Failed to SetScalingMode(%{public}d), ret:%{public}d!", scaleMode, err); + lastScalingMode_ = scaleMode; + VPE_LOGD("producer_->SetScalingMode(%{public}d) success.", scaleMode); + } + isForceUpdateProducer_ = false; + return VPE_ALGO_ERR_OK; +} + sptr VpeVideoImpl::GetInputSurface() { sptr producerSurface; @@ -118,10 +161,9 @@ VPEAlgoErrCode VpeVideoImpl::Start() { return ExecuteWhenIdle( [this]() { - if (consumer_ == nullptr || producer_ == nullptr || cb_ == nullptr) { - VPE_LOGE("The input surface, output surface or callback is NOT ready!"); - return VPE_ALGO_ERR_INVALID_OPERATION; - } + CHECK_AND_RETURN_RET_LOG(isInitialized_.load(), VPE_ALGO_ERR_INVALID_OPERATION, "NOT initialized!"); + CHECK_AND_RETURN_RET_LOG(consumer_ != nullptr && producer_ != nullptr && cb_ != nullptr, + VPE_ALGO_ERR_INVALID_OPERATION, "The input surface, output surface or callback is NOT ready!"); state_ = VPEState::RUNNING; OnStateLocked(VPEAlgoState::RUNNING); return VPE_ALGO_ERR_OK; @@ -145,22 +187,35 @@ VPEAlgoErrCode VpeVideoImpl::Release() VPEAlgoErrCode VpeVideoImpl::Flush() { - std::unique_lock lock(lock_); - cvDone_.wait(lock, [this]() { return !isProcessing_.load(); }); - std::queue tempQueue1; - std::queue tempQueue2; + VPE_LOGD("step in"); + std::lock_guard lock(lock_); { - std::lock_guard bufferLock(bufferLock_); - consumerBufferQueue_.swap(tempQueue1); - while (!renderBufferQueue_.empty()) { - producerBufferQueue_.push(renderBufferQueue_.front()); - renderBufferQueue_.pop(); + std::unique_lock lockTask(taskLock_); + cvDone_.wait(lock, [this]() { return !isProcessing_.load(); }); + } + + if (isEnable_.load()) { + std::queue tempQueue1; + std::queue tempQueue2; + { + std::lock_guard bufferLock(bufferLock_); + std::lock_guard consumerBufferLock(consumerBufferLock_); + consumerBufferQueue_.swap(tempQueue1); + for (auto& [index, bufferInfo] : renderBufferQueue_) { + producerBufferQueue_.push(bufferInfo); + } + renderBufferQueue_.clear(); + attachBufferQueue_.swap(tempQueue2); + attachBufferIDs_.clear(); } - attachBufferQueue_.swap(tempQueue2); - attachBufferIDs_.clear(); + ClearConsumerLocked(tempQueue1); + ClearConsumerLocked(tempQueue2); + } else { + producer_->CleanCache(false); + ClearBufferQueues(); } - ClearConsumerLocked(tempQueue1); - ClearConsumerLocked(tempQueue2); + VPE_LOGD("step out"); + return VPE_ALGO_ERR_OK; } @@ -203,7 +258,7 @@ VPEAlgoErrCode VpeVideoImpl::NotifyEos() return ExecuteWhenNotIdle( [this]() { { - std::lock_guard buffferlock(bufferLock_); + std::lock_guard consumerBufferLock(consumerBufferLock_); SurfaceBufferInfo bufferInfo{}; bufferInfo.bufferFlag = VPE_BUFFER_FLAG_EOS; consumerBufferQueue_.push(bufferInfo); @@ -215,16 +270,14 @@ VPEAlgoErrCode VpeVideoImpl::NotifyEos() VPEAlgoErrCode VpeVideoImpl::ReleaseOutputBuffer(uint32_t index, bool render) { - return ExecuteWhenNotIdle( - [this, index, render]() { return RenderOutputBufferLocked(index, -1, render); }, + CHECK_AND_RETURN_RET_LOG(state_.load() != VPEState::IDLE, VPE_ALGO_ERR_INVALID_OPERATION, "Release output buffer must be called during running!"); + return RenderOutputBuffer(index, -1, render); } VPEAlgoErrCode VpeVideoImpl::RenderOutputBufferAtTime(uint32_t index, int64_t renderTimestamp) { - return ExecuteWhenNotIdle( - [this, index, renderTimestamp]() { return RenderOutputBufferLocked(index, renderTimestamp, true); }, - "Render output buffer must be called during running!"); + } bool VpeVideoImpl::IsInitialized() const diff --git a/framework/algorithm/detail_enhancer_video/detail_enhancer_video_impl.cpp b/framework/algorithm/detail_enhancer_video/detail_enhancer_video_impl.cpp index b6978b4..e183e46 100644 --- a/framework/algorithm/detail_enhancer_video/detail_enhancer_video_impl.cpp +++ b/framework/algorithm/detail_enhancer_video/detail_enhancer_video_impl.cpp @@ -76,6 +76,11 @@ VPEAlgoErrCode DetailEnhancerVideoImpl::Stop() return detailEnhancerVideo_->Stop(); } +VPEAlgoErrCode DetailEnhancerVideoImpl::Release() +{ + return detailEnhancerVideo_->Release(); +} + VPEAlgoErrCode DetailEnhancerVideoImpl::RenderOutputBuffer([[maybe_unused]] uint32_t index) { return VPE_ALGO_ERR_OK; diff --git a/framework/algorithm/detail_enhancer_video/include/detail_enhancer_video_impl.h b/framework/algorithm/detail_enhancer_video/include/detail_enhancer_video_impl.h index 56c549c..19ac60c 100644 --- a/framework/algorithm/detail_enhancer_video/include/detail_enhancer_video_impl.h +++ b/framework/algorithm/detail_enhancer_video/include/detail_enhancer_video_impl.h @@ -40,6 +40,7 @@ public: VPEAlgoErrCode SetParameter(const DetailEnhancerParameters& parameter, SourceType type) override; VPEAlgoErrCode Start() override; VPEAlgoErrCode Stop() override; + VPEAlgoErrCode Release() override; VPEAlgoErrCode RenderOutputBuffer(uint32_t index) override; VPEAlgoErrCode ReleaseOutputBuffer(uint32_t index, bool render) override; diff --git a/test/unittest/detail_enhancer_video/detail_enhancer_video_unit_test.cpp b/test/unittest/detail_enhancer_video/detail_enhancer_video_unit_test.cpp index 7deb3a0..03a5e9c 100644 --- a/test/unittest/detail_enhancer_video/detail_enhancer_video_unit_test.cpp +++ b/test/unittest/detail_enhancer_video/detail_enhancer_video_unit_test.cpp @@ -51,7 +51,7 @@ public: DetailEnhancerVideoCallbackImpl& operator=(const DetailEnhancerVideoCallbackImpl&) = delete; DetailEnhancerVideoCallbackImpl(DetailEnhancerVideoCallbackImpl&&) = delete; DetailEnhancerVideoCallbackImpl& operator=(DetailEnhancerVideoCallbackImpl&&) = delete; - + void OnError(VPEAlgoErrCode errorCode) override; void OnState(VPEAlgoState state) override; void OnOutputBufferAvailable(uint32_t index, DetailEnhBufferFlag flag) override; @@ -143,6 +143,7 @@ HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_init_01, TestSize.Level1) { auto detailEnhVideo = DetailEnhancerVideo::Create(); EXPECT_NE(detailEnhVideo, nullptr); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_02, TestSize.Level1) @@ -151,6 +152,7 @@ HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_02, TestSize.Level1) std::shared_ptr cb = nullptr; auto ret = detailEnhVideo->RegisterCallback(cb); EXPECT_NE(ret, VPE_ALGO_ERR_OK); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_03, TestSize.Level1) @@ -162,6 +164,7 @@ HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_03, TestSize.Level1) }; auto ret = detailEnhVideo->SetParameter(param, VIDEO); EXPECT_EQ(ret, VPE_ALGO_ERR_OK); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_04, TestSize.Level1) @@ -173,6 +176,7 @@ HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_04, TestSize.Level1) }; auto ret = detailEnhVideo->SetParameter(param, VIDEO); EXPECT_EQ(ret, VPE_ALGO_ERR_OK); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_05, TestSize.Level1) @@ -191,6 +195,7 @@ HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_06, TestSize.Level1) auto detailEnhVideo = DetailEnhancerVideo::Create(); auto ret = detailEnhVideo->GetInputSurface(); EXPECT_NE(ret, nullptr); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_07, TestSize.Level1) @@ -199,6 +204,7 @@ HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_07, TestSize.Level1) auto ret = detailEnhVideo->GetInputSurface(); ret = detailEnhVideo->GetInputSurface(); EXPECT_EQ(ret, nullptr); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_08, TestSize.Level1) @@ -207,6 +213,7 @@ HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_08, TestSize.Level1) sptr surface = nullptr; auto ret = detailEnhVideo->SetOutputSurface(surface); EXPECT_NE(ret, VPE_ALGO_ERR_OK); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_09, TestSize.Level1) @@ -215,161 +222,173 @@ HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_09, TestSize.Level1) auto ret = detailEnhVideo->RenderOutputBuffer(0); EXPECT_EQ(ret, VPE_ALGO_ERR_OK); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_10, TestSize.Level1) { - auto detailEnh = DetailEnhancerVideo::Create(); - auto ret = detailEnh->NotifyEos(); + auto detailEnhVideo = DetailEnhancerVideo::Create(); + auto ret = detailEnhVideo->NotifyEos(); EXPECT_NE(ret, VPE_ALGO_ERR_OK); + detailEnhVideo->Release(); } // set parameter to midium HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_11, TestSize.Level1) { - auto detailEnh = DetailEnhancerVideo::Create(); + auto detailEnhVideo = DetailEnhancerVideo::Create(); DetailEnhancerParameters param { .uri = "", .level = DETAIL_ENH_LEVEL_MEDIUM, }; - auto res = detailEnh->SetParameter(param, VIDEO); + auto res = detailEnhVideo->SetParameter(param, VIDEO); EXPECT_EQ(res, VPE_ALGO_ERR_OK); + detailEnhVideo->Release(); } // set parameter to low HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_12, TestSize.Level1) { - auto detailEnh = DetailEnhancerVideo::Create(); + auto detailEnhVideo = DetailEnhancerVideo::Create(); DetailEnhancerParameters param { .uri = "", .level = DETAIL_ENH_LEVEL_LOW, }; - auto res = detailEnh->SetParameter(param, VIDEO); + auto res = detailEnhVideo->SetParameter(param, VIDEO); EXPECT_EQ(res, VPE_ALGO_ERR_OK); + detailEnhVideo->Release(); } // set parameter to none HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_13, TestSize.Level1) { - auto detailEnh = DetailEnhancerVideo::Create(); + auto detailEnhVideo = DetailEnhancerVideo::Create(); DetailEnhancerParameters param { .uri = "", .level = DETAIL_ENH_LEVEL_NONE, }; - auto res = detailEnh->SetParameter(param, VIDEO); + auto res = detailEnhVideo->SetParameter(param, VIDEO); EXPECT_EQ(res, VPE_ALGO_ERR_OK); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_14, TestSize.Level1) { - auto detailEnh = DetailEnhancerVideo::Create(); + auto detailEnhVideo = DetailEnhancerVideo::Create(); DetailEnhancerParameters param { .uri = "", .level = DETAIL_ENH_LEVEL_HIGH, }; - auto res = detailEnh->SetParameter(param, VIDEO); - res = detailEnh->SetParameter(param, VIDEO); + auto res = detailEnhVideo->SetParameter(param, VIDEO); + res = detailEnhVideo->SetParameter(param, VIDEO); EXPECT_EQ(res, VPE_ALGO_ERR_OK); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_15, TestSize.Level1) { - auto detailEnh = DetailEnhancerVideo::Create(); + auto detailEnhVideo = DetailEnhancerVideo::Create(); std::shared_ptr cb = std::make_shared(); - auto res = detailEnh->RegisterCallback(cb); + auto res = detailEnhVideo->RegisterCallback(cb); EXPECT_EQ(res, VPE_ALGO_ERR_OK); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_16, TestSize.Level1) { - auto detailEnh = DetailEnhancerVideo::Create(); + auto detailEnhVideo = DetailEnhancerVideo::Create(); std::shared_ptr cb = std::make_shared(); - auto res = detailEnh->RegisterCallback(cb); + auto res = detailEnhVideo->RegisterCallback(cb); DetailEnhancerParameters param { .uri = "", .level = DETAIL_ENH_LEVEL_HIGH, }; - res = detailEnh->SetParameter(param, VIDEO); - auto ret = detailEnh->GetInputSurface(); - res = detailEnh->Start(); + res = detailEnhVideo->SetParameter(param, VIDEO); + auto ret = detailEnhVideo->GetInputSurface(); + res = detailEnhVideo->Start(); EXPECT_NE(res, VPE_ALGO_ERR_OK); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_17, TestSize.Level1) { - auto detailEnh = DetailEnhancerVideo::Create(); - auto res = detailEnh->Stop(); + auto detailEnhVideo = DetailEnhancerVideo::Create(); + auto res = detailEnhVideo->Stop(); EXPECT_NE(res, VPE_ALGO_ERR_OK); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_18, TestSize.Level1) { - auto detailEnh = DetailEnhancerVideo::Create(); + auto detailEnhVideo = DetailEnhancerVideo::Create(); std::shared_ptr cb = std::make_shared(); - auto res = detailEnh->RegisterCallback(cb); + auto res = detailEnhVideo->RegisterCallback(cb); DetailEnhancerParameters param { .uri = "", .level = DETAIL_ENH_LEVEL_HIGH, }; - res = detailEnh->SetParameter(param, VIDEO); - auto surface1 = detailEnh->GetInputSurface(); - res = detailEnh->SetOutputSurface(surface1); - res = detailEnh->Start(); - res = detailEnh->NotifyEos(); + res = detailEnhVideo->SetParameter(param, VIDEO); + auto surface1 = detailEnhVideo->GetInputSurface(); + res = detailEnhVideo->SetOutputSurface(surface1); + res = detailEnhVideo->Start(); + res = detailEnhVideo->NotifyEos(); EXPECT_EQ(res, VPE_ALGO_ERR_OK); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_19, TestSize.Level1) { - auto detailEnh = DetailEnhancerVideo::Create(); + auto detailEnhVideo = DetailEnhancerVideo::Create(); std::shared_ptr cb = std::make_shared(); - auto res = detailEnh->RegisterCallback(cb); + auto res = detailEnhVideo->RegisterCallback(cb); DetailEnhancerParameters param { .uri = "", .level = DETAIL_ENH_LEVEL_HIGH, }; - res = detailEnh->SetParameter(param, VIDEO); - auto surface1 = detailEnh->GetInputSurface(); - res = detailEnh->SetOutputSurface(surface1); - res = detailEnh->Start(); - res = detailEnh->ReleaseOutputBuffer(100, true); // 100 index + res = detailEnhVideo->SetParameter(param, VIDEO); + auto surface1 = detailEnhVideo->GetInputSurface(); + res = detailEnhVideo->SetOutputSurface(surface1); + res = detailEnhVideo->Start(); + res = detailEnhVideo->ReleaseOutputBuffer(100, true); // 100 index EXPECT_NE(res, VPE_ALGO_ERR_OK); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_20, TestSize.Level1) { - auto detailEnh = DetailEnhancerVideo::Create(); + auto detailEnhVideo = DetailEnhancerVideo::Create(); std::shared_ptr cb = std::make_shared(); - auto res = detailEnh->RegisterCallback(cb); + auto res = detailEnhVideo->RegisterCallback(cb); DetailEnhancerParameters param { .uri = "", .level = DETAIL_ENH_LEVEL_HIGH, }; - res = detailEnh->SetParameter(param, VIDEO); - auto surface1 = detailEnh->GetInputSurface(); - res = detailEnh->SetOutputSurface(surface1); - res = detailEnh->Start(); - res = detailEnh->ReleaseOutputBuffer(100, false); // 100 index + res = detailEnhVideo->SetParameter(param, VIDEO); + auto surface1 = detailEnhVideo->GetInputSurface(); + res = detailEnhVideo->SetOutputSurface(surface1); + res = detailEnhVideo->Start(); + res = detailEnhVideo->ReleaseOutputBuffer(100, false); // 100 index EXPECT_NE(res, VPE_ALGO_ERR_OK); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_21, TestSize.Level1) { OHNativeWindowBuffer *ohNativeWindowBuffer; - auto detailEnh = DetailEnhancerVideo::Create(); + auto detailEnhVideo = DetailEnhancerVideo::Create(); std::shared_ptr cb = std::make_shared(); - auto res = detailEnh->RegisterCallback(cb); + auto res = detailEnhVideo->RegisterCallback(cb); DetailEnhancerParameters param { .uri = "", .level = DETAIL_ENH_LEVEL_HIGH, }; - res = detailEnh->SetParameter(param, VIDEO); - auto surface = detailEnh->GetInputSurface(); + res = detailEnhVideo->SetParameter(param, VIDEO); + auto surface = detailEnhVideo->GetInputSurface(); auto detailEnh2 = DetailEnhancerVideo::Create(); auto surface2 = detailEnh2->GetInputSurface(); - res = detailEnh->SetOutputSurface(surface2); - res = detailEnh->Start(); + res = detailEnhVideo->SetOutputSurface(surface2); + res = detailEnhVideo->Start(); EXPECT_EQ(res, VPE_ALGO_ERR_OK); int fenceFd = -1; @@ -383,25 +402,26 @@ HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_21, TestSize.Level1) ret = FlushSurf(ohNativeWindowBuffer); ASSERT_EQ(ret, VPE_ALGO_ERR_OK); OH_NativeWindow_DestroyNativeWindow(nativeWindow); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_22, TestSize.Level1) { OHNativeWindowBuffer *ohNativeWindowBuffer; - auto detailEnh = DetailEnhancerVideo::Create(); + auto detailEnhVideo = DetailEnhancerVideo::Create(); std::shared_ptr cb = std::make_shared(); - auto res = detailEnh->RegisterCallback(cb); + auto res = detailEnhVideo->RegisterCallback(cb); DetailEnhancerParameters param { .uri = "", .level = DETAIL_ENH_LEVEL_HIGH, }; - res = detailEnh->SetParameter(param, VIDEO); - auto surface = detailEnh->GetInputSurface(); + res = detailEnhVideo->SetParameter(param, VIDEO); + auto surface = detailEnhVideo->GetInputSurface(); auto detailEnh2 = DetailEnhancerVideo::Create(); auto surface2 = detailEnh2->GetInputSurface(); surface2->SetRequestWidthAndHeight(10, 10); - res = detailEnh->SetOutputSurface(surface2); - res = detailEnh->Start(); + res = detailEnhVideo->SetOutputSurface(surface2); + res = detailEnhVideo->Start(); EXPECT_EQ(res, VPE_ALGO_ERR_OK); int fenceFd = -1; @@ -415,25 +435,26 @@ HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_22, TestSize.Level1) ret = FlushSurf(ohNativeWindowBuffer); ASSERT_EQ(ret, VPE_ALGO_ERR_OK); OH_NativeWindow_DestroyNativeWindow(nativeWindow); + detailEnhVideo->Release(); } HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_23, TestSize.Level1) { OHNativeWindowBuffer *ohNativeWindowBuffer; - auto detailEnh = DetailEnhancerVideo::Create(); + auto detailEnhVideo = DetailEnhancerVideo::Create(); std::shared_ptr cb = std::make_shared(); - auto res = detailEnh->RegisterCallback(cb); + auto res = detailEnhVideo->RegisterCallback(cb); DetailEnhancerParameters param { .uri = "", .level = DETAIL_ENH_LEVEL_HIGH, }; - res = detailEnh->SetParameter(param, VIDEO); - auto surface = detailEnh->GetInputSurface(); + res = detailEnhVideo->SetParameter(param, VIDEO); + auto surface = detailEnhVideo->GetInputSurface(); auto detailEnh2 = DetailEnhancerVideo::Create(); auto surface2 = detailEnh2->GetInputSurface(); surface2->SetRequestWidthAndHeight(10, 0); - res = detailEnh->SetOutputSurface(surface2); - res = detailEnh->Start(); + res = detailEnhVideo->SetOutputSurface(surface2); + res = detailEnhVideo->Start(); EXPECT_EQ(res, VPE_ALGO_ERR_OK); int fenceFd = -1; @@ -447,6 +468,7 @@ HWTEST_F(DetailEnhancerVideoUnitTest, detailenhancer_23, TestSize.Level1) ret = FlushSurf(ohNativeWindowBuffer); ASSERT_EQ(ret, VPE_ALGO_ERR_OK); OH_NativeWindow_DestroyNativeWindow(nativeWindow); + detailEnhVideo->Release(); } } // namespace VideoProcessingEngine -- Gitee