diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2018-11-13 14:50:50 -0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2018-11-13 14:50:50 -0800 |
commit | 58805e8405e134106ac22cc24535e749ef416e26 (patch) | |
tree | 4f51b63cbf356ced8f115e3f5a1e9c1d6d603355 /src | |
parent | 319aaa494e0a98e88311783d0f46bee2f85d52cf (diff) | |
parent | af387227df44a268d7b5d0f990014c4160544fd5 (diff) | |
download | android_packages_apps_Snap-58805e8405e134106ac22cc24535e749ef416e26.tar.gz android_packages_apps_Snap-58805e8405e134106ac22cc24535e749ef416e26.tar.bz2 android_packages_apps_Snap-58805e8405e134106ac22cc24535e749ef416e26.zip |
Merge "Update FPS for HFR" into camera-SnapdragonCamera.lnx.2.0
Diffstat (limited to 'src')
-rwxr-xr-x | src/com/android/camera/SettingsManager.java | 59 |
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; } |