Skip to content
Snippets Groups Projects
Commit 45d7895a authored by Shao-Chuan Lee's avatar Shao-Chuan Lee Committed by Automerger Merge Worker
Browse files

V4L2EncodeComponent: clamp framerate to at least 1 on dynamic framerate change am: 39f241ae

parents 40521db6 39f241ae
No related branches found
No related tags found
No related merge requests found
...@@ -756,8 +756,8 @@ bool V4L2EncodeComponent::encode(C2ConstGraphicBlock block, uint64_t index, int6 ...@@ -756,8 +756,8 @@ bool V4L2EncodeComponent::encode(C2ConstGraphicBlock block, uint64_t index, int6
// Dynamically adjust framerate based on the frame's timestamp if required. // Dynamically adjust framerate based on the frame's timestamp if required.
constexpr int64_t kMaxFramerateDiff = 5; constexpr int64_t kMaxFramerateDiff = 5;
if (mLastFrameTime && (timestamp > *mLastFrameTime)) { if (mLastFrameTime && (timestamp > *mLastFrameTime)) {
int64_t newFramerate = int64_t newFramerate = std::max(
static_cast<int64_t>(std::round(1000000.0 / (timestamp - *mLastFrameTime))); static_cast<int64_t>(std::round(1000000.0 / (timestamp - *mLastFrameTime))), 1LL);
if (abs(mFramerate - newFramerate) > kMaxFramerateDiff) { if (abs(mFramerate - newFramerate) > kMaxFramerateDiff) {
ALOGV("Adjusting framerate to %" PRId64 " based on frame timestamps", newFramerate); ALOGV("Adjusting framerate to %" PRId64 " based on frame timestamps", newFramerate);
mInterface->setFramerate(static_cast<uint32_t>(newFramerate)); mInterface->setFramerate(static_cast<uint32_t>(newFramerate));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment