From 02a6c79978efeccac5458c88a5947b1c64148369 Mon Sep 17 00:00:00 2001 From: Tome Date: Tue, 8 Jul 2025 17:07:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E6=95=B0=E6=BA=A2=E5=87=BA=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tome --- .../feedingsmoother/base/time_statistician.cpp | 10 +++++++++- .../fpscontroller/fps_controller_process.cpp | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/base/time_statistician.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/base/time_statistician.cpp index 31c8c440..6d13dc88 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/base/time_statistician.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/base/time_statistician.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -35,6 +35,10 @@ void TimeStatistician::CalAverFeedInterval(const int64_t feedTime) return; } feedIndex_++; + if (feedIntervalSum_ > INT64_MAX - feedInterval_) { + DHLOGE("feedIntervalSum_ overflow"); + return; + } feedIntervalSum_ += feedInterval_; averFeedInterval_ = feedIntervalSum_ / static_cast(feedIndex_); lastFeedTime_ = feedTime_; @@ -49,6 +53,10 @@ void TimeStatistician::CalAverTimeStampInterval(const int64_t timeStamp) return; } timeStampIndex_++; + if (timeStampIntervalSum_ > INT64_MAX - timeStampInterval_) { + DHLOGE("timeStampIntervalSum_ overflow"); + return; + } timeStampIntervalSum_ += timeStampInterval_; averTimeStampInterval_ = timeStampIntervalSum_ / static_cast(timeStampIndex_); lastTimeStamp_ = timeStamp_; diff --git a/services/data_process/src/pipeline_node/fpscontroller/fps_controller_process.cpp b/services/data_process/src/pipeline_node/fpscontroller/fps_controller_process.cpp index 98d6b0a5..d2c7c0d3 100644 --- a/services/data_process/src/pipeline_node/fpscontroller/fps_controller_process.cpp +++ b/services/data_process/src/pipeline_node/fpscontroller/fps_controller_process.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 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 @@ -143,6 +143,10 @@ void FpsControllerProcess::UpdateFrameRateCorrectionFactor(int64_t nowMs) const float msPerSecond = 1000; const float maxInstantaneousFrameRateCoefficient = 1.1; float maxInstantaneousFrameRateThreshold = targetFrameRate_ * maxInstantaneousFrameRateCoefficient; + if (recentFrameTimeSpanMs_ == 0) { + DHLOGE("Frame control, recentFrameTimeSpanMs_ is 0, cannot calculate frame rate."); + return; + } float instantaneousFrameRate = msPerSecond / recentFrameTimeSpanMs_; if (instantaneousFrameRate < 0) { instantaneousFrameRate = -instantaneousFrameRate; @@ -275,6 +279,10 @@ bool FpsControllerProcess::ReduceFrameRateByUniformStrategy(int32_t incomingFrmR * rate, the incoming frames are reduced uniformly. */ bool isDrop = false; + if (frameRateOvershootMdf_ > INT32_MAX - (incomingFrmRate - targetFrameRate_)) { + DHLOGE("Overshoot value is too large, reset to 0."); + return false; + } int32_t overshoot = frameRateOvershootMdf_ + (incomingFrmRate - targetFrameRate_); if (overshoot < 0) { overshoot = 0; -- Gitee