summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Desaulniers <ndesaulniers@google.com>2019-11-13 15:12:21 -0800
committerNick Desaulniers <ndesaulniers@google.com>2019-11-13 15:12:21 -0800
commit25128ad4ae1c8a05c1cb2787e9b4fb19a9cc741f (patch)
tree41b656ecaf370b1395fd069613b3c0a94103f8f9
parent209322146e1c2350181913e19f975edfecb040dd (diff)
downloadcuttlefish_common-25128ad4ae1c8a05c1cb2787e9b4fb19a9cc741f.tar.gz
cuttlefish: EmulatedFakeCamera2: fix -Wimplicit-int-float-conversion
IEEE754 single precision cannot precisely represent RAND_MAX. error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-int-float-conversion] For purposes of generating random uniforms, this does not matter. Add explicit casts of RAND_MAX to float to fix. Bug: 139945549 Test: lunch aosp_cf_x86_phone-userdebug && mm Change-Id: I72fe9a4f0fa76a0df1552fffb16a793205272d78 Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
-rw-r--r--guest/hals/camera/EmulatedFakeCamera2.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/guest/hals/camera/EmulatedFakeCamera2.cpp b/guest/hals/camera/EmulatedFakeCamera2.cpp
index 63a5c1a9..e2923619 100644
--- a/guest/hals/camera/EmulatedFakeCamera2.cpp
+++ b/guest/hals/camera/EmulatedFakeCamera2.cpp
@@ -1441,12 +1441,12 @@ status_t EmulatedFakeCamera2::ReadoutThread::collectStatisticsMetadata(
// To simulate some kind of real detection going on, we jitter the rectangles
// on each frame by a few pixels in each dimension.
for (size_t i = 0; i < numFaces * 4; i++) {
- rects[i] += (int32_t)(((float)rand() / RAND_MAX) * 6 - 3);
+ rects[i] += (int32_t)(((float)rand() / (float)RAND_MAX) * 6 - 3);
}
// The confidence scores (0-100) are similarly jittered.
uint8_t scores[numFaces] = {85, 95};
for (size_t i = 0; i < numFaces; i++) {
- scores[i] += (int32_t)(((float)rand() / RAND_MAX) * 10 - 5);
+ scores[i] += (int32_t)(((float)rand() / (float)RAND_MAX) * 10 - 5);
}
res = add_camera_metadata_entry(frame, ANDROID_STATISTICS_FACE_RECTANGLES,
@@ -1485,7 +1485,7 @@ status_t EmulatedFakeCamera2::ReadoutThread::collectStatisticsMetadata(
};
// Jitter these a bit less than the rects
for (size_t i = 0; i < numFaces * 6; i++) {
- features[i] += (int32_t)(((float)rand() / RAND_MAX) * 4 - 2);
+ features[i] += (int32_t)(((float)rand() / (float)RAND_MAX) * 4 - 2);
}
// These are unique IDs that are used to identify each face while it's
// visible to the detector (if a face went away and came back, it'd get a