Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Unified Diff: webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java

Issue 2013413002: Android: Change camera fps range selection (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove overspecified test Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« webrtc/api/api_tests.gyp ('K') | « webrtc/api/api_tests.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java
diff --git a/webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java b/webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java
index 2fa685d1fbceda2fbb9f7ceac4d2e2bb5bfdb251..96ce973a6f0371fc06f84d490ece73567716a2cd 100644
--- a/webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java
+++ b/webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java
@@ -181,15 +181,36 @@ public class CameraEnumerationAndroid {
}
}
+ // Prefer a fps range with an upper bound close to |framerate|. Also prefer a fps range with a low
+ // lower bound, to allow the framerate to fluctuate based on lightning conditions.
public static CaptureFormat.FramerateRange getClosestSupportedFramerateRange(
List<CaptureFormat.FramerateRange> supportedFramerates, final int requestedFps) {
return Collections.min(supportedFramerates,
new ClosestComparator<CaptureFormat.FramerateRange>() {
- private static final int MAX_FPS_WEIGHT = 10;
+ // Progressive penalty if the upper bound is further away than |MAX_FPS_DIFF_THRESHOLD|
+ // from requested.
+ private static final int MAX_FPS_DIFF_THRESHOLD = 5000;
+ private static final int MAX_FPS_LOW_DIFF_WEIGHT = 1;
+ private static final int MAX_FPS_HIGH_DIFF_WEIGHT = 3;
+
+ // Progressive penalty if the lower bound is bigger than |MIN_FPS_THRESHOLD|.
+ private static final int MIN_FPS_THRESHOLD = 8000;
+ private static final int MIN_FPS_LOW_VALUE_WEIGHT = 1;
+ private static final int MIN_FPS_HIGH_VALUE_WEIGHT = 4;
+
+ // Use one weight for small |value| less than |threshold|, and another weight above.
+ private int progressivePenalty(int value, int threshold, int lowWeight, int highWeight) {
+ return (value < threshold)
+ ? value * lowWeight
+ : threshold * lowWeight + (value - threshold) * highWeight;
+ }
@Override
int diff(CaptureFormat.FramerateRange range) {
- return range.min + MAX_FPS_WEIGHT * abs(requestedFps * 1000 - range.max);
+ return progressivePenalty(range.min,
+ MIN_FPS_THRESHOLD, MIN_FPS_LOW_VALUE_WEIGHT, MIN_FPS_HIGH_VALUE_WEIGHT)
sakal 2016/05/27 13:10:47 nit: 11 space indentation?
+ + progressivePenalty(Math.abs(requestedFps * 1000 - range.max),
+ MAX_FPS_DIFF_THRESHOLD, MAX_FPS_LOW_DIFF_WEIGHT, MAX_FPS_HIGH_DIFF_WEIGHT);
}
});
}
« webrtc/api/api_tests.gyp ('K') | « webrtc/api/api_tests.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698