summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjinwu <jinwu@codeaurora.org>2018-10-15 17:19:11 +0800
committerGerrit - the friendly Code Review server <code-review@localhost>2018-11-07 18:23:54 -0800
commitaf387227df44a268d7b5d0f990014c4160544fd5 (patch)
treea502dcbc003fc69c05bdb1f8fa87558cdf7700bb /src
parent644a5781c1c3af5824875f45b9a6f23bc3ca775c (diff)
downloadandroid_packages_apps_Snap-af387227df44a268d7b5d0f990014c4160544fd5.tar.gz
android_packages_apps_Snap-af387227df44a268d7b5d0f990014c4160544fd5.tar.bz2
android_packages_apps_Snap-af387227df44a268d7b5d0f990014c4160544fd5.zip
Update FPS for HFR
Calculate maxFPS from media_codecs.xml and compare with supported FPS get from characteristics or hfrFpsTable to filter FPS. Change-Id: Idfeaacd22927105139c333b6257d307e420dde26
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/android/camera/SettingsManager.java59
1 files changed, 47 insertions, 12 deletions
diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java
index 27c0de6ec..bb6ea90c9 100755
--- a/src/com/android/camera/SettingsManager.java
+++ b/src/com/android/camera/SettingsManager.java
@@ -38,6 +38,11 @@ import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CameraMetadata;
import android.hardware.camera2.params.StreamConfigurationMap;
+import android.media.MediaCodecInfo;
+import android.media.MediaCodecInfo.CodecCapabilities;
+import android.media.MediaCodecInfo.VideoCapabilities;
+import android.media.MediaCodecList;
+import android.media.MediaFormat;
import android.media.MediaRecorder;
import android.media.CamcorderProfile;
import android.preference.PreferenceManager;
@@ -1152,36 +1157,66 @@ public class SettingsManager implements ListMenu.SettingsListener {
ArrayList<String> supported = new ArrayList<String>();
supported.add("off");
ListPreference videoQuality = mPreferenceGroup.findPreference(KEY_VIDEO_QUALITY);
- if (videoQuality == null) return supported;
+ ListPreference videoEncoder = mPreferenceGroup.findPreference(KEY_VIDEO_ENCODER);
+ if (videoQuality == null || videoEncoder == null) return supported;
String videoSizeStr = videoQuality.getValue();
+ int videoEncoderNum = SettingTranslation.getVideoEncoder(videoEncoder.getValue());
+ VideoCapabilities videoCapabilities = null;
+ boolean findVideoEncoder = false;
if (videoSizeStr != null) {
Size videoSize = parseSize(videoSizeStr);
+ MediaCodecList allCodecs = new MediaCodecList(MediaCodecList.ALL_CODECS);
+ for (MediaCodecInfo info : allCodecs.getCodecInfos()) {
+ if (!info.isEncoder() || info.getName().contains("google")) continue;
+ for (String type : info.getSupportedTypes()) {
+ if ((videoEncoderNum == MediaRecorder.VideoEncoder.MPEG_4_SP && type.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_MPEG4))
+ || (videoEncoderNum == MediaRecorder.VideoEncoder.H263 && type.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_H263))
+ || (videoEncoderNum == MediaRecorder.VideoEncoder.H264 && type.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_AVC))
+ || (videoEncoderNum == MediaRecorder.VideoEncoder.HEVC && type.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_HEVC))) {
+ CodecCapabilities codecCapabilities = info.getCapabilitiesForType(type);
+ videoCapabilities = codecCapabilities.getVideoCapabilities();
+ findVideoEncoder = true;
+ break;
+ }
+ }
+ if (findVideoEncoder) break;
+ }
+
try {
Range[] range = getSupportedHighSpeedVideoFPSRange(mCameraId, videoSize);
for (Range r : range) {
// To support HFR for both preview and recording,
// minmal FPS needs to be equal to maximum FPS
- if ((int) r.getUpper() == (int)r.getLower()) {
- supported.add("hfr" + String.valueOf(r.getUpper()));
- supported.add("hsr" + String.valueOf(r.getUpper()));
+ if ((int) r.getUpper() == (int) r.getLower()) {
+ if (videoCapabilities != null) {
+ if (videoCapabilities.areSizeAndRateSupported(
+ videoSize.getWidth(), videoSize.getHeight(), (int) r.getUpper())) {
+ supported.add("hfr" + String.valueOf(r.getUpper()));
+ supported.add("hsr" + String.valueOf(r.getUpper()));
+ }
+ }
}
}
} catch (IllegalArgumentException ex) {
Log.w(TAG, "HFR is not supported for this resolution " + ex);
}
- if ( mExtendedHFRSize != null && mExtendedHFRSize.length >= 3 ) {
- for( int i=0; i < mExtendedHFRSize.length; i+=3 ) {
- String item = "hfr" + mExtendedHFRSize[i+2];
- if ( !supported.contains(item)
+ if (mExtendedHFRSize != null && mExtendedHFRSize.length >= 3) {
+ for (int i = 0; i < mExtendedHFRSize.length; i += 3) {
+ String item = "hfr" + mExtendedHFRSize[i + 2];
+ if (!supported.contains(item)
&& videoSize.getWidth() <= mExtendedHFRSize[i]
- && videoSize.getHeight() <= mExtendedHFRSize[i+1] ) {
- supported.add(item);
- supported.add("hsr"+mExtendedHFRSize[i+2]);
+ && videoSize.getHeight() <= mExtendedHFRSize[i + 1]) {
+ if (videoCapabilities != null) {
+ if (videoCapabilities.areSizeAndRateSupported(
+ videoSize.getWidth(), videoSize.getHeight(), mExtendedHFRSize[i + 2])) {
+ supported.add(item);
+ supported.add("hsr" + mExtendedHFRSize[i + 2]);
+ }
+ }
}
}
}
}
-
return supported;
}