feat: refine HLG10 HDR support and add compatibility decoding setting

This commit is contained in:
Hinnka committed 2026-05-31 10:21:38 +08:00
1 parent d9475929ec
commit 5bbd9ee5a8
9 files changed
+42 -14

No files matched your search

@@ -128,7 +128,7 @@ data class UserPreferences(
val rawLuts: Map<String, String> = mapOf(TransferCurve.SRGB.name to RawProfile.STANDARD_SRGB.rawLut),
val useP010: Boolean = false,
val useHlg10: Boolean = false,
val hlgHardwareCompatibilityEnabled: Boolean = true,
val hlgHardwareCompatibilityEnabled: Boolean = false,
val useP3ColorSpace: Boolean = false,
val videoResolution: VideoResolutionPreset = VideoResolutionPreset.FHD_1080P,
val videoFps: VideoFpsPreset = VideoFpsPreset.FPS_30,
@@ -371,7 +371,7 @@ class UserPreferencesRepository(private val context: Context) {
rawLuts = parseRawLuts(preferences),
useP010 = preferences[USE_P010] ?: false,
useHlg10 = preferences[USE_HLG10] ?: false,
hlgHardwareCompatibilityEnabled = preferences[HLG_HARDWARE_COMPATIBILITY_ENABLED] ?: true,
hlgHardwareCompatibilityEnabled = preferences[HLG_HARDWARE_COMPATIBILITY_ENABLED] ?: false,
useP3ColorSpace = preferences[USE_P3_COLOR_SPACE] ?: false,
videoResolution = VideoResolutionPreset.valueOf(
preferences[VIDEO_RESOLUTION] ?: VideoResolutionPreset.FHD_1080P.name
@@ -51,7 +51,7 @@ class PhotoProcessor(
private suspend fun shouldDecodeHlgInput(metadata: MediaMetadata): Boolean {
val isHlg = metadata.dynamicRangeProfile == "HLG10"
if (!isHlg) return false
return userPreferencesRepository.userPreferences.firstOrNull()?.hlgHardwareCompatibilityEnabled ?: true
return userPreferencesRepository.userPreferences.firstOrNull()?.hlgHardwareCompatibilityEnabled ?: false
}
private suspend fun resolveRawAutoWhiteBalanceEstimate(metadata: MediaMetadata): Boolean {
@@ -2441,7 +2441,6 @@ class LutImageProcessor {
if (uIsHlgInput) {
color.rgb = hlgToLinear(color.rgb);
color.rgb = bt2020ToLinearSrgb(color.rgb);
color.rgb = linearToSrgb(color.rgb);
}
@@ -760,7 +760,6 @@ object Shaders {
if (uIsHlgInput) {
color.rgb = hlgToLinear(color.rgb);
color.rgb = bt2020ToLinearSrgb(color.rgb);
color.rgb = linearToSrgb(color.rgb);
}
@@ -1005,6 +1005,37 @@ fun SettingsScreen(
}
if (isHdrSettingsSupported) {
if (state.isHlg10Supported) {
HorizontalDivider(
color = Color.White.copy(alpha = 0.1f),
modifier = Modifier.padding(vertical = 12.dp)
)
SwitchSettingItem(
title = stringResource(R.string.settings_use_hlg10),
description = stringResource(R.string.settings_use_hlg10_description),
checked = useHlg10,
onCheckedChange = {
viewModel.setUseHlg10(it)
if (it) {
viewModel.setUseP010(true)
}
}
)
HorizontalDivider(
color = Color.White.copy(alpha = 0.1f),
modifier = Modifier.padding(vertical = 12.dp)
)
SwitchSettingItem(
title = stringResource(R.string.settings_hlg_hardware_compatibility),
description = stringResource(R.string.settings_hlg_hardware_compatibility_description),
checked = hlgHardwareCompatibilityEnabled,
onCheckedChange = { viewModel.setHlgHardwareCompatibilityEnabled(it) }
)
}
HorizontalDivider(
color = Color.White.copy(alpha = 0.1f),
modifier = Modifier.padding(vertical = 12.dp)
@@ -366,7 +366,7 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
.stateIn(viewModelScope, SharingStarted.Eagerly, false)
val hlgHardwareCompatibilityEnabled: StateFlow<Boolean> = userPreferencesRepository.userPreferences
.map { it.hlgHardwareCompatibilityEnabled }
.stateIn(viewModelScope, SharingStarted.Eagerly, true)
.stateIn(viewModelScope, SharingStarted.Eagerly, false)
val useP3ColorSpace: StateFlow<Boolean> = userPreferencesRepository.userPreferences
.map { it.useP3ColorSpace }
.stateIn(viewModelScope, SharingStarted.Eagerly, false)
@@ -571,8 +571,7 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
// 同步 P010 设置到相机控制器
cameraController.setUseP010(it.useP010)
// 同步 HLG10 设置到相机控制器
// cameraController.setUseHlg10(it.useHlg10)
cameraController.setUseHlg10(false)
cameraController.setUseHlg10(it.useHlg10)
// 同步 P3 色域设置到相机控制器
cameraController.setUseP3ColorSpace(it.useP3ColorSpace)
}
+2 -2
View File
@@ -723,8 +723,8 @@
<string name="settings_use_p010_description">启用 10位 YUV 输出以获得更好的图像数据精度。仅在支持的设备上且 RAW 关闭时生效。</string>
<string name="settings_use_hlg10">HLG10 HDR</string>
<string name="settings_use_hlg10_description">在支持的设备上启用 HLG10 动态范围拍摄。需同时开启 P010 且关闭 RAW。</string>
<string name="settings_hlg_hardware_compatibility">HLG 输入解码</string>
<string name="settings_hlg_hardware_compatibility_description">在 Log 视频和 Log LUT 处理中手动解码输入的 HLG 数据;关闭后,则认为系统已自动完成 HLG 解码,不再额外干预。</string>
<string name="settings_hlg_hardware_compatibility">HLG 兼容性解码</string>
<string name="settings_hlg_hardware_compatibility_description">部分设备开启 HLG 拍摄后画面可能偏暗或异常。若遇到画面异常,请开启此选项进行手动解码;画面正常请保持关闭。</string>
<string name="settings_use_p3_color_space">P3 色域</string>
<string name="settings_use_p3_color_space_description">在支持的设备上启用 Display P3 输出。默认关闭。</string>
<string name="settings_auto_enable_hdr_for_hdr_capture">默认开启 HDR</string>
+2 -2
View File
@@ -482,8 +482,8 @@
<string name="settings_use_p010_description">啟用 10 位 YUV 輸出以獲得更好的影像資料精度。僅在支援的裝置上且 RAW 關閉時生效。</string>
<string name="settings_use_hlg10">HLG10 HDR</string>
<string name="settings_use_hlg10_description">在支援的裝置上啟用 HLG10 動態範圍拍攝。需同時開啟 P010 且關閉 RAW。</string>
<string name="settings_hlg_hardware_compatibility">HLG 輸入解碼</string>
<string name="settings_hlg_hardware_compatibility_description">在 Log 影片和 Log LUT 處理中手動解碼輸入的 HLG 資料;關閉時,則視為系統已自動完成 HLG 解碼,不再額外干預。</string>
<string name="settings_hlg_hardware_compatibility">HLG 兼容性解碼</string>
<string name="settings_hlg_hardware_compatibility_description">部分裝置開啟 HLG 拍攝後畫面可能偏暗或異常。若遇到畫面異常,請開啟此選項進行手動解碼;畫面正常請關閉。</string>
<string name="refresh">重新整理</string>
<string name="refresh_success">預覽已重新整理</string>
<string name="settings_background">背景設定</string>
+2 -2
View File
@@ -763,8 +763,8 @@
<string name="settings_use_p010_description">Enable 10-bit YUV output for better image data precision. Effective on supported devices when RAW is disabled.</string>
<string name="settings_use_hlg10">HLG10 HDR</string>
<string name="settings_use_hlg10_description">Enable HLG10 dynamic range capture on supported devices. Requires P010 and RAW to be off.</string>
<string name="settings_hlg_hardware_compatibility">HLG input decode</string>
<string name="settings_hlg_hardware_compatibility_description">HLG input is decoded manually during Log video and Log LUT processing. When off, the app assumes the system has already decoded HLG and applies no extra handling.</string>
<string name="settings_hlg_hardware_compatibility">HLG Compatibility Decoding</string>
<string name="settings_hlg_hardware_compatibility_description">Some devices render dark or washed-out images under HLG. Enable this to manually decode HLG in shader if preview is abnormal.</string>
<string name="settings_use_p3_color_space">P3 Color Space</string>
<string name="settings_use_p3_color_space_description">Enable Display P3 output on supported devices. Default is off.</string>
<string name="settings_auto_enable_hdr_for_hdr_capture">Enable HDR by default</string>