aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShao-Chuan Lee <shaochuan@google.com>2022-06-02 08:32:15 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-06-02 08:32:15 +0000
commit7846d9d43c9e4a1aa2309742687f4a52aeef122c (patch)
treeea8b101fa7800092fc1595b4b051bedb29e21427
parent6fee68bc74cbd97d281252a9e8c2bfd1ebe669fd (diff)
parent45d7895a8debf6abc537d923a0efd6e1f59ccb69 (diff)
downloadv4l2_codec2-7846d9d43c9e4a1aa2309742687f4a52aeef122c.tar.gz
V4L2EncodeComponent: clamp framerate to at least 1 on dynamic framerate change am: 39f241ae60 am: 45d7895a8d
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/v4l2_codec2/+/18707983 Change-Id: I14849e87ec645214b34435ede93920bf67303d4d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--components/V4L2EncodeComponent.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/components/V4L2EncodeComponent.cpp b/components/V4L2EncodeComponent.cpp
index a1b46ab..4ce4404 100644
--- a/components/V4L2EncodeComponent.cpp
+++ b/components/V4L2EncodeComponent.cpp
@@ -756,8 +756,8 @@ bool V4L2EncodeComponent::encode(C2ConstGraphicBlock block, uint64_t index, int6
// Dynamically adjust framerate based on the frame's timestamp if required.
constexpr int64_t kMaxFramerateDiff = 5;
if (mLastFrameTime && (timestamp > *mLastFrameTime)) {
- int64_t newFramerate =
- static_cast<int64_t>(std::round(1000000.0 / (timestamp - *mLastFrameTime)));
+ int64_t newFramerate = std::max(
+ static_cast<int64_t>(std::round(1000000.0 / (timestamp - *mLastFrameTime))), 1LL);
if (abs(mFramerate - newFramerate) > kMaxFramerateDiff) {
ALOGV("Adjusting framerate to %" PRId64 " based on frame timestamps", newFramerate);
mInterface->setFramerate(static_cast<uint32_t>(newFramerate));