Loading media/libmediaplayerservice/StagefrightRecorder.cpp +8 −16 Original line number Diff line number Diff line Loading @@ -709,26 +709,18 @@ status_t StagefrightRecorder::setParamCaptureFpsEnable(int32_t captureFpsEnable) status_t StagefrightRecorder::setParamCaptureFps(double fps) { ALOGV("setParamCaptureFps: %.2f", fps); constexpr int64_t k1E12 = 1000000000000ll; int64_t fpsx1e12 = k1E12 * fps; if (fpsx1e12 == 0) { ALOGE("FPS is zero or too small"); return BAD_VALUE; } // This does not overflow since 10^6 * 10^12 < 2^63 int64_t timeUs = 1000000ll * k1E12 / fpsx1e12; // Not allowing time more than a day and a millisecond for error margin. // Note: 1e12 / 86400 = 11574074.(074) and 1e18 / 11574074 = 86400000553; // therefore 1 ms of margin should be sufficient. if (timeUs <= 0 || timeUs > 86400001000ll) { ALOGE("Time between frame capture (%lld) is out of range [0, 1 Day]", (long long)timeUs); // FPS value is from Java layer where double follows IEEE-754, which is not // necessarily true for double here. constexpr double kIeee754Epsilon = 2.220446049250313e-16; constexpr double kEpsilon = std::max(std::numeric_limits<double>::epsilon(), kIeee754Epsilon); // Not allowing fps less than 1 frame / day minus epsilon. if (fps < 1.0 / 86400 - kEpsilon) { ALOGE("fps (%lf) is out of range (>= 1 frame / day)", fps); return BAD_VALUE; } mCaptureFps = fps; mTimeBetweenCaptureUs = timeUs; mTimeBetweenCaptureUs = std::llround(1e6 / fps); return OK; } Loading Loading
media/libmediaplayerservice/StagefrightRecorder.cpp +8 −16 Original line number Diff line number Diff line Loading @@ -709,26 +709,18 @@ status_t StagefrightRecorder::setParamCaptureFpsEnable(int32_t captureFpsEnable) status_t StagefrightRecorder::setParamCaptureFps(double fps) { ALOGV("setParamCaptureFps: %.2f", fps); constexpr int64_t k1E12 = 1000000000000ll; int64_t fpsx1e12 = k1E12 * fps; if (fpsx1e12 == 0) { ALOGE("FPS is zero or too small"); return BAD_VALUE; } // This does not overflow since 10^6 * 10^12 < 2^63 int64_t timeUs = 1000000ll * k1E12 / fpsx1e12; // Not allowing time more than a day and a millisecond for error margin. // Note: 1e12 / 86400 = 11574074.(074) and 1e18 / 11574074 = 86400000553; // therefore 1 ms of margin should be sufficient. if (timeUs <= 0 || timeUs > 86400001000ll) { ALOGE("Time between frame capture (%lld) is out of range [0, 1 Day]", (long long)timeUs); // FPS value is from Java layer where double follows IEEE-754, which is not // necessarily true for double here. constexpr double kIeee754Epsilon = 2.220446049250313e-16; constexpr double kEpsilon = std::max(std::numeric_limits<double>::epsilon(), kIeee754Epsilon); // Not allowing fps less than 1 frame / day minus epsilon. if (fps < 1.0 / 86400 - kEpsilon) { ALOGE("fps (%lf) is out of range (>= 1 frame / day)", fps); return BAD_VALUE; } mCaptureFps = fps; mTimeBetweenCaptureUs = timeUs; mTimeBetweenCaptureUs = std::llround(1e6 / fps); return OK; } Loading