diff options
author | Timmy Li <timmyli@google.com> | 2023-08-30 23:15:09 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2023-08-30 23:15:09 +0000 |
commit | 659d5f5af5afb9914f43085a438c10378490ad01 (patch) | |
tree | e4ed06782e914ec3531874341716763ac2ebfea1 | |
parent | 5c1f98720c00ff1b593538cfb56114da13cc07e6 (diff) | |
parent | 4337e908c95aab939cd479736544aa7410483135 (diff) | |
download | camera-659d5f5af5afb9914f43085a438c10378490ad01.tar.gz |
Merge "Add new vendor tag for [24,24] and [24,30] transition." into udc-qpr-dev
-rw-r--r-- | common/hal/common/vendor_tag_defs.h | 12 | ||||
-rw-r--r-- | common/hal/google_camera_hal/vendor_tags.cc | 3 | ||||
-rw-r--r-- | common/hal/utils/utils.cc | 48 |
3 files changed, 56 insertions, 7 deletions
diff --git a/common/hal/common/vendor_tag_defs.h b/common/hal/common/vendor_tag_defs.h index bce1b13..e9b8cd0 100644 --- a/common/hal/common/vendor_tag_defs.h +++ b/common/hal/common/vendor_tag_defs.h @@ -49,6 +49,7 @@ enum VendorTagIds : uint32_t { kSwDenoiseEnabled, kVideoSwDenoiseEnabled, kVideo60to30FPSThermalThrottle, + kVideoFpsThrottle, // This should not be used as a vendor tag ID on its own, but as a placeholder // to indicate the end of currently defined vendor tag IDs kEndMarker @@ -242,6 +243,17 @@ static const std::vector<VendorTag> kInternalVendorTags = { {.tag_id = VendorTagIds::kVideo60to30FPSThermalThrottle, .tag_name = "Video60to30FPSThermalThrottle", .tag_type = CameraMetadataType::kByte}, + // Video Fps Throttle Enabled + // + // Indicates whether hal should accept changes in + // fps range without reconfiguring graph. This allows for + // smooth transitions. + // + // Present in: request and session keys + // Payload: VideoFpsThrottle + {.tag_id = VendorTagIds::kVideoFpsThrottle, + .tag_name = "VideoFpsThrottle", + .tag_type = CameraMetadataType::kByte}, }; // Google Camera HAL vendor tag sections diff --git a/common/hal/google_camera_hal/vendor_tags.cc b/common/hal/google_camera_hal/vendor_tags.cc index f1f0641..7d84c28 100644 --- a/common/hal/google_camera_hal/vendor_tags.cc +++ b/common/hal/google_camera_hal/vendor_tags.cc @@ -108,6 +108,9 @@ status_t ModifyCharacteristicsKeys(HalCameraMetadata* metadata) { // VendorTagIds::kVideo60to30FPSThermalThrottle session_keys.push_back(VendorTagIds::kVideo60to30FPSThermalThrottle); request_keys.push_back(VendorTagIds::kVideo60to30FPSThermalThrottle); + // VendorTagIds::kVideoFpsThrottle + session_keys.push_back(VendorTagIds::kVideoFpsThrottle); + request_keys.push_back(VendorTagIds::kVideoFpsThrottle); // Update the static metadata with the new set of keys if (metadata->Set(ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS, request_keys.data(), diff --git a/common/hal/utils/utils.cc b/common/hal/utils/utils.cc index f8023a3..897e2c8 100644 --- a/common/hal/utils/utils.cc +++ b/common/hal/utils/utils.cc @@ -24,6 +24,8 @@ #include <hardware/gralloc.h> #include <sys/stat.h> +#include <array> + #include "utils.h" #include "vendor_tag_defs.h" @@ -31,6 +33,31 @@ namespace android { namespace google_camera_hal { namespace utils { +namespace { + +using FpsRange = std::pair<int32_t, int32_t>; + +bool IsAcceptableThrottledFpsChange(const FpsRange& old_fps, + const FpsRange& new_fps) { + // We allow smooth transitions between [30,30] to [60,60] and [24,24] and [24,30]. + constexpr std::array<std::pair<FpsRange, FpsRange>, 3> kAcceptableTransitions = { + std::make_pair<FpsRange, FpsRange>({30, 30}, {60, 60}), + std::make_pair<FpsRange, FpsRange>({24, 24}, {24, 30}), + std::make_pair<FpsRange, FpsRange>({24, 24}, {30, 30}), + }; + + for (const std::pair<FpsRange, FpsRange>& range : kAcceptableTransitions) { + // We don't care about the direction of the transition. + if ((old_fps == range.first && new_fps == range.second) || + (new_fps == range.first && old_fps == range.second)) { + return true; + } + } + + return false; +} +} // namespace + constexpr char kRealtimeThreadSetProp[] = "persist.vendor.camera.realtimethread"; @@ -374,6 +401,10 @@ bool IsSessionParameterCompatible(const HalCameraMetadata* old_session, // the special case that AE FPS is throttling [60, 60] to [30, 30] or // restored from [30, 30] to [60, 60] from GCA side when session parameter // kVideo60to30FPSThermalThrottle is enabled. + // Added kVideoFpsThrottle more generic transitions such + // as between [24,24] and [24,30]. kVideoFpsThrottle should be used + // over kVideo60to30FPSThermalThrottle going forth. They are functionally + // the same, but kVideoFpsThrottle is more generically named. uint8_t video_60_to_30fps_thermal_throttle = 0; camera_metadata_ro_entry_t video_60_to_30fps_throttle_entry; if (new_session->Get(kVideo60to30FPSThermalThrottle, @@ -382,14 +413,17 @@ bool IsSessionParameterCompatible(const HalCameraMetadata* old_session, video_60_to_30fps_throttle_entry.data.u8[0]; } + uint8_t video_fps_throttle = 0; + camera_metadata_ro_entry_t video_fps_throttle_entry; + if (new_session->Get(kVideoFpsThrottle, &video_fps_throttle_entry) == OK) { + video_fps_throttle = video_fps_throttle_entry.data.u8[0]; + } + bool ignore_fps_range_diff = false; - if (video_60_to_30fps_thermal_throttle) { - if (((old_min_fps == 60) && (old_max_fps == 60) && - (new_min_fps == 30) && (new_max_fps == 30)) || - ((old_min_fps == 30) && (old_max_fps == 30) && - (new_min_fps == 60) && (new_max_fps == 60))) { - ignore_fps_range_diff = true; - } + if (video_60_to_30fps_thermal_throttle || video_fps_throttle) { + ignore_fps_range_diff = IsAcceptableThrottledFpsChange( + /*old_fps=*/{old_min_fps, old_max_fps}, + /*new_fps=*/{new_min_fps, new_max_fps}); } if (old_max_fps == new_max_fps || ignore_fps_range_diff) { |