From 879a6d2a84bd728847c13ab9d07d4c1f32b472d7 Mon Sep 17 00:00:00 2001 From: Weijie Wang Date: Tue, 29 Aug 2017 19:51:59 +0800 Subject: SnapdragonCamera: Support HFR 60 and 90 fps Support HFR 60 and 90 fps Change-Id: Ib615196e691782ee6d595d5216f2966cee284a9c --- src/com/android/camera/CaptureModule.java | 6 ++-- src/com/android/camera/SettingsManager.java | 56 ++++++++++------------------- 2 files changed, 23 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index 105e2381a..7d70a569a 100755 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -191,7 +191,7 @@ public class CaptureModule implements CameraModule, PhotoController, // we can change it based on memory status or other requirements. private static final int LONGSHOT_CANCEL_THRESHOLD = 40 * 1024 * 1024; - private static final int NORMAL_SESSION_MAX_FPS = 60; + private static final int NORMAL_SESSION_MAX_FPS = 30; private static final int SCREEN_DELAY = 2 * 60 * 1000; @@ -254,9 +254,11 @@ public class CaptureModule implements CameraModule, PhotoController, public static CaptureResult.Key gazeDegree = new CaptureResult.Key<>("org.codeaurora.qcamera3.stats.gaze_degree", byte[].class); + public static final CameraCharacteristics.Key hfrFpsTable = + new CameraCharacteristics.Key<>("org.quic.camera2.customhfrfps.info.CustomHFRFpsTable", int[].class); + public static final CaptureRequest.Key sharpness_control = new CaptureRequest.Key<>( "org.codeaurora.qcamera3.sharpness.strength", Integer.class); - public static final CaptureRequest.Key exposure_metering = new CaptureRequest.Key<>( "org.codeaurora.qcamera3.exposure_metering.exposure_metering_mode", Integer.class); diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java index 675970b3d..826662ee6 100755 --- a/src/com/android/camera/SettingsManager.java +++ b/src/com/android/camera/SettingsManager.java @@ -175,6 +175,8 @@ public class SettingsManager implements ListMenu.SettingsListener { private JSONObject mDependency; private int mCameraId; private Set mFilteredKeys; + private int[] mExtendedHFRSize;//An array of pairs (fps, maxW, maxH) + private static Map> VIDEO_ENCODER_PROFILE_TABLE = new HashMap<>(); public Map getValuesMap() { @@ -303,6 +305,12 @@ public class SettingsManager implements ListMenu.SettingsListener { mValuesMap = new HashMap<>(); mDependendsOnMap = new HashMap<>(); mFilteredKeys = new HashSet<>(); + try { + mExtendedHFRSize = mCharacteristics.get(cameraId).get(CaptureModule.hfrFpsTable); + }catch(IllegalArgumentException exception) { + exception.printStackTrace(); + } + filterPreferences(cameraId); initDependencyTable(); initializeValueMap(); @@ -1012,7 +1020,6 @@ public class SettingsManager implements ListMenu.SettingsListener { private List getSupportedHighFrameRate() { ArrayList supported = new ArrayList(); supported.add("off"); - ListPreference videoQuality = mPreferenceGroup.findPreference(KEY_VIDEO_QUALITY); if (videoQuality == null) return supported; String videoSizeStr = videoQuality.getValue(); @@ -1031,11 +1038,17 @@ public class SettingsManager implements ListMenu.SettingsListener { } catch (IllegalArgumentException ex) { Log.w(TAG, "HFR is not supported for this resolution " + ex); } - - // 60 fps goes through normal sesssion if it is supported by device - int maxFpsForNormalSession = getSupportedMaximumVideoFPSForNormalSession(mCameraId, videoSize); - supported.add("hfr" + maxFpsForNormalSession); - supported.add("hsr" + maxFpsForNormalSession); + 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]); + } + } + } } return supported; @@ -1188,37 +1201,6 @@ public class SettingsManager implements ListMenu.SettingsListener { return res; } - private boolean checkAeAvailableTargetFpsRanges(int cameraId, int fps) { - boolean supported = false; - Range[] aeFpsRanges = mCharacteristics.get(cameraId).get(CameraCharacteristics - .CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES); - - for (Range r : aeFpsRanges) { - Log.d(TAG, "["+r.getLower()+", "+r.getUpper()+"]"); - if ((fps <= (int)r.getUpper()) && - (fps >= (int)r.getLower())) { - supported = true; - break; - } - } - return supported; - } - - private int getSupportedMaximumVideoFPSForNormalSession(int cameraId, Size videoSize) { - StreamConfigurationMap map = mCharacteristics.get(cameraId).get( - CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); - long duration = map.getOutputMinFrameDuration(MediaRecorder.class, videoSize); - int fps = (int)(1000000000.0/duration); - if (!checkAeAvailableTargetFpsRanges(cameraId, fps)) { - Log.d(TAG, "FPS="+fps+" is not in available target FPS range"); - fps = 0; - } - Log.d(TAG, "Size="+videoSize.getWidth()+"x"+videoSize.getHeight()+ - ", Min Duration ="+duration+", Max fps=" + fps); - return fps; - } - - public Size[] getSupportedThumbnailSizes(int cameraId) { return mCharacteristics.get(cameraId).get( CameraCharacteristics.JPEG_AVAILABLE_THUMBNAIL_SIZES); -- cgit v1.2.3