From 3db9508be424d144d8cd718d1398718eb6e4ad7e Mon Sep 17 00:00:00 2001
From: Alexandre Courbot <acourbot@google.com>
Date: Thu, 23 Jun 2022 17:00:41 +0900
Subject: [PATCH] V4L2EncodeComponent: fix build error

Patch 0fa30254bd7e introduced a type mismatch when building for 32-bit architecture. This error is visible when running "mmm external/v4l2_codec2":

    external/v4l2_codec2/components/V4L2EncodeComponent.cpp:782:32: error: no matching function for call to 'max'
            int64_t newFramerate = std::max(
                                   ^~~~~~~~
    external/libcxx/include/algorithm:2529:1: note: candidate template ignored: deduced conflicting types for parameter '_Tp' ('long' vs. 'long long')
    max(const _Tp& __a, const _Tp& __b)
    ^
    external/libcxx/include/algorithm:2539:1: note: candidate template ignored: could not match 'initializer_list<type-parameter-0-0>' against 'long'
    max(initializer_list<_Tp> __t, _Compare __comp)
    ^
    external/libcxx/include/algorithm:2547:1: note: candidate function template not viable: requires single argument '__t', but 2 arguments were provided
    max(initializer_list<_Tp> __t)
    ^
    external/libcxx/include/algorithm:2521:1: note: candidate function template not viable: requires 3 arguments, but 2 were provided
    max(const _Tp& __a, const _Tp& __b, _Compare __comp)
    ^

Fix this by casting the right member of the cmp operation to int64_t.

Test: mmm external/v4l2_codec2

Change-Id: Id2cc220b9122eec412823f577f07ecd82bad60fc
(cherry picked from commit a0377993b84da09547aad11f2f27560e0bf4dcd5)
---
 components/V4L2EncodeComponent.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/components/V4L2EncodeComponent.cpp b/components/V4L2EncodeComponent.cpp
index 4ce4404..c2a2679 100644
--- a/components/V4L2EncodeComponent.cpp
+++ b/components/V4L2EncodeComponent.cpp
@@ -757,7 +757,8 @@ bool V4L2EncodeComponent::encode(C2ConstGraphicBlock block, uint64_t index, int6
     constexpr int64_t kMaxFramerateDiff = 5;
     if (mLastFrameTime && (timestamp > *mLastFrameTime)) {
         int64_t newFramerate = std::max(
-                static_cast<int64_t>(std::round(1000000.0 / (timestamp - *mLastFrameTime))), 1LL);
+                static_cast<int64_t>(std::round(1000000.0 / (timestamp - *mLastFrameTime))),
+                static_cast<int64_t>(1LL));
         if (abs(mFramerate - newFramerate) > kMaxFramerateDiff) {
             ALOGV("Adjusting framerate to %" PRId64 " based on frame timestamps", newFramerate);
             mInterface->setFramerate(static_cast<uint32_t>(newFramerate));
-- 
GitLab