feat: remove tonemap/hlg10

This commit is contained in:
zhoubinjia committed 2026-09-02 17:47:22 +08:00
1 parent 383b760913
commit 946a282c7d
28 files changed
+80 -865

No files matched your search

@@ -10,10 +10,8 @@ import android.hardware.camera2.*
import android.hardware.camera2.params.ColorSpaceTransform
import android.hardware.camera2.params.MeteringRectangle
import android.hardware.camera2.params.OutputConfiguration
import android.hardware.camera2.params.DynamicRangeProfiles
import android.hardware.camera2.params.RggbChannelVector
import android.hardware.camera2.params.SessionConfiguration
import android.hardware.camera2.params.TonemapCurve
import android.media.Image
import android.media.ImageReader
import android.os.Build
@@ -222,13 +220,6 @@ class Camera2Controller(private val context: Context) {
UNAVAILABLE
}
private enum class CameraOutputType {
PREVIEW,
STILL_CAPTURE,
RAW_CAPTURE,
VIDEO_RECORD
}
private val cameraManager: CameraManager by lazy {
context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
}
@@ -284,8 +275,8 @@ class Camera2Controller(private val context: Context) {
private var imageReader: ImageReader? = null
private var stabilizationImageReader: ImageReader? = null
// 降噪等级 (0=Off, 1=Fast, 2=High Quality, 3=ZSL, 4=Minimal, 5=Auto)
private var nrLevel = 5
// 降噪等级 (0=Off, 1=Fast, 2=High Quality, 3=ZSL, 4=Minimal)
private var nrLevel = NoiseReductionLevel.DEFAULT
// 锐化等级 (0=Off, 1=Fast, 2=High Quality, 3=Zero Shutter Lag/Real-time)
private var edgeLevel = 1
@@ -312,7 +303,6 @@ class Camera2Controller(private val context: Context) {
private var availableEdgeModes: IntArray = intArrayOf()
private var availableNoiseReductionModes: IntArray = intArrayOf()
private var availableTonemapModes: IntArray = intArrayOf()
private var tonemapMaxCurvePoints: Int = 0
private var availableColorCorrectionAberrationModes: IntArray = intArrayOf()
private var availableHotPixelModes: IntArray = intArrayOf()
private var availableShadingModes: IntArray = intArrayOf()
@@ -332,7 +322,6 @@ class Camera2Controller(private val context: Context) {
private var requestedRawCaptureEnabled = false
private var isRawSupported = false
private var isP010Supported = false
private var isHlg10Supported = false
private var isStreamUseCaseSupported = false
private var availableStreamUseCases: LongArray = longArrayOf()
private var isZslControlSupported: Boolean? = null
@@ -1679,7 +1668,6 @@ class Camera2Controller(private val context: Context) {
availableEdgeModes = intArrayOf()
availableNoiseReductionModes = intArrayOf()
availableTonemapModes = intArrayOf()
tonemapMaxCurvePoints = 0
availableColorCorrectionAberrationModes = intArrayOf()
availableHotPixelModes = intArrayOf()
availableShadingModes = intArrayOf()
@@ -1697,7 +1685,6 @@ class Camera2Controller(private val context: Context) {
malformedColorCorrectionGainsReported = false
isRawSupported = false
isP010Supported = false
isHlg10Supported = false
isStreamUseCaseSupported = false
availableStreamUseCases = longArrayOf()
lastAfState = null
@@ -2191,8 +2178,6 @@ class Camera2Controller(private val context: Context) {
?: intArrayOf()
availableTonemapModes =
openCharacteristics.get(CameraCharacteristics.TONEMAP_AVAILABLE_TONE_MAP_MODES) ?: intArrayOf()
tonemapMaxCurvePoints =
openCharacteristics.get(CameraCharacteristics.TONEMAP_MAX_CURVE_POINTS) ?: 0
availableColorCorrectionAberrationModes =
openCharacteristics.get(CameraCharacteristics.COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES)
?: intArrayOf()
@@ -2251,14 +2236,6 @@ class Camera2Controller(private val context: Context) {
(outputPhysicalCameraId?.let {
!isPhysicalOutputProfileFailed(it, ImageFormat.YCBCR_P010)
} ?: true)
isHlg10Supported = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && isP010Supported) {
val dynamicRangeProfiles =
openCharacteristics.get(CameraCharacteristics.REQUEST_AVAILABLE_DYNAMIC_RANGE_PROFILES)
dynamicRangeProfiles?.supportedProfiles?.contains(DynamicRangeProfiles.HLG10) == true
} else {
false
}
val resolvedVideoPreviewSize = refreshVideoCapabilities(openCharacteristics)
previewSize = when (captureMode) {
CaptureMode.VIDEO -> resolvedVideoPreviewSize
@@ -2305,7 +2282,6 @@ class Camera2Controller(private val context: Context) {
useRaw = requestedRawCaptureEnabled,
isRawSupported = isRawSupported,
isP010Supported = isP010Supported,
isHlg10Supported = isHlg10Supported,
availableNrModes = selectableNrModes,
supportsCctWhiteBalance = supportsCctWhiteBalance(),
canAdjustWhiteBalance = false,
@@ -2675,7 +2651,6 @@ class Camera2Controller(private val context: Context) {
}
private fun createPreviewSession(
forceStandardSession: Boolean = false,
forceWithoutVendorSessionParameters: Boolean = false,
openGeneration: Long = cameraOpenGeneration
) {
@@ -2722,7 +2697,7 @@ class Camera2Controller(private val context: Context) {
stabilizationReader?.surface?.let(::addTarget)
videoSurface?.let(::addTarget)
// 应用所有相机参数(曝光、白平衡、闪光灯、变焦、色调映射)
// 应用所有相机参数(曝光、白平衡、闪光灯、变焦)
applyBaseCameraSettings(this, isCapture = false)
}
@@ -2735,37 +2710,15 @@ class Camera2Controller(private val context: Context) {
}
if (captureMode == CaptureMode.VIDEO) {
val useHlgCapture = _state.value.useHlg10 &&
stabilizationReader == null &&
activeOutputPhysicalCameraId == null &&
!forceStandardSession
val sessionConfig = SessionConfiguration(
SessionConfiguration.SESSION_REGULAR,
buildList {
add(
createOutputConfiguration(
surface = surface,
useHlgCapture = useHlgCapture,
outputType = CameraOutputType.PREVIEW
)
)
add(createOutputConfiguration(surface))
stabilizationReader?.surface?.let { eisSurface ->
add(
createOutputConfiguration(
surface = eisSurface,
useHlgCapture = false,
outputType = CameraOutputType.PREVIEW,
)
)
add(createOutputConfiguration(eisSurface))
}
videoSurface?.let { encoderSurface ->
add(
createOutputConfiguration(
surface = encoderSurface,
useHlgCapture = useHlgCapture,
outputType = CameraOutputType.VIDEO_RECORD
)
)
add(createOutputConfiguration(encoderSurface))
}
},
Executors.newSingleThreadExecutor(),
@@ -2776,11 +2729,6 @@ class Camera2Controller(private val context: Context) {
safeCloseCaptureSession(session, "stale video preview session")
return
}
if (useHlgCapture) {
_state.value = _state.value.copy(currentDynamicRangeProfile = "HLG10")
} else if (_state.value.currentDynamicRangeProfile != "STANDARD") {
_state.value = _state.value.copy(currentDynamicRangeProfile = "STANDARD")
}
closeUnusedStabilizationImageReader(stabilizationReader)
onSessionConfigured(session, openGeneration, sessionGeneration)
}
@@ -2790,12 +2738,11 @@ class Camera2Controller(private val context: Context) {
safeCloseCaptureSession(session, "stale video configure failure")
return
}
PLog.e(TAG, "Video session configuration failed: useHlgCapture=$useHlgCapture")
PLog.e(TAG, "Video session configuration failed")
safeCloseCaptureSession(session, "video configure failure")
if (vendorSessionParametersApplied &&
retryPreviewSessionWithoutVendorSessionParameters(
reason = "video configure failed",
forceStandardSession = forceStandardSession,
openGeneration = openGeneration
)
) {
@@ -2804,12 +2751,6 @@ class Camera2Controller(private val context: Context) {
if (retryPreviewSessionWithoutPhysicalOutput("video configure failed", openGeneration)) {
return
}
if (useHlgCapture) {
PLog.w(TAG, "Retrying video preview session with STANDARD dynamic range fallback")
_state.value = _state.value.copy(currentDynamicRangeProfile = "STANDARD")
createPreviewSession(forceStandardSession = true, openGeneration = openGeneration)
return
}
handlePreviewSessionFailure("video configure failed", openGeneration)
}
}
@@ -2824,49 +2765,20 @@ class Camera2Controller(private val context: Context) {
return
}
// Android 9+ 使用 SessionConfiguration
val useHlgCapture = _state.value.useHlg10 &&
stabilizationReader == null &&
activeOutputPhysicalCameraId == null &&
!isRawCaptureReader(reader) &&
!forceStandardSession
val readerFormat = reader?.imageFormat ?: ImageFormat.YUV_420_888
PLog.i(
TAG,
"Creating preview session: forceStandard=$forceStandardSession, " +
"useHlgCapture=$useHlgCapture, readerFormat=${imageFormatToString(readerFormat)}, " +
"isP010Supported=$isP010Supported, isHlg10Supported=$isHlg10Supported"
"Creating preview session: readerFormat=${imageFormatToString(readerFormat)}, " +
"isP010Supported=$isP010Supported"
)
val outputConfigs = buildList {
add(
createOutputConfiguration(
surface = surface,
useHlgCapture = useHlgCapture,
outputType = CameraOutputType.PREVIEW
)
)
add(createOutputConfiguration(surface))
stabilizationReader?.surface?.let { eisSurface ->
add(
createOutputConfiguration(
surface = eisSurface,
useHlgCapture = false,
outputType = CameraOutputType.PREVIEW,
)
)
add(createOutputConfiguration(eisSurface))
}
reader?.surface?.let { captureSurface ->
add(
createOutputConfiguration(
surface = captureSurface,
useHlgCapture = useHlgCapture,
outputType = if (readerFormat == ImageFormat.RAW_SENSOR) {
CameraOutputType.RAW_CAPTURE
} else {
CameraOutputType.STILL_CAPTURE
}
)
)
add(createOutputConfiguration(captureSurface))
}
}
val sessionConfig = SessionConfiguration(
@@ -2880,11 +2792,6 @@ class Camera2Controller(private val context: Context) {
safeCloseCaptureSession(session, "stale preview session")
return
}
if (useHlgCapture) {
_state.value = _state.value.copy(currentDynamicRangeProfile = "HLG10")
} else if (_state.value.currentDynamicRangeProfile != "STANDARD") {
_state.value = _state.value.copy(currentDynamicRangeProfile = "STANDARD")
}
closeUnusedStabilizationImageReader(stabilizationReader)
onSessionConfigured(session, openGeneration, sessionGeneration)
}
@@ -2896,15 +2803,13 @@ class Camera2Controller(private val context: Context) {
}
PLog.e(
TAG,
"Session configuration failed: useHlgCapture=$useHlgCapture, " +
"readerFormat=${imageFormatToString(readerFormat)}, " +
"Session configuration failed: readerFormat=${imageFormatToString(readerFormat)}, " +
"sessionColorSpace=${if (shouldUseP3ColorSpace()) "DISPLAY_P3" else "DEFAULT"}"
)
safeCloseCaptureSession(session, "photo configure failure")
if (vendorSessionParametersApplied &&
retryPreviewSessionWithoutVendorSessionParameters(
reason = "photo configure failed",
forceStandardSession = forceStandardSession,
openGeneration = openGeneration
)
) {
@@ -2913,18 +2818,12 @@ class Camera2Controller(private val context: Context) {
if (retryPreviewSessionWithoutPhysicalOutput("photo configure failed", openGeneration)) {
return
}
if (useHlgCapture) {
PLog.w(TAG, "Retrying preview session with STANDARD dynamic range fallback")
_state.value = _state.value.copy(currentDynamicRangeProfile = "STANDARD")
createPreviewSession(forceStandardSession = true, openGeneration = openGeneration)
return
}
handlePreviewSessionFailure("photo configure failed", openGeneration)
}
}
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
if (shouldUseP3ColorSpace() && !useHlgCapture) {
if (shouldUseP3ColorSpace()) {
sessionConfig.setColorSpace(ColorSpace.Named.DISPLAY_P3)
}
}
@@ -2940,7 +2839,6 @@ class Camera2Controller(private val context: Context) {
if (vendorSessionParametersApplied &&
retryPreviewSessionWithoutVendorSessionParameters(
reason = "create session illegal state: ${e.message}",
forceStandardSession = forceStandardSession,
openGeneration = openGeneration
)
) {
@@ -2959,7 +2857,6 @@ class Camera2Controller(private val context: Context) {
if (vendorSessionParametersApplied &&
retryPreviewSessionWithoutVendorSessionParameters(
reason = "create session exception: ${e.message}",
forceStandardSession = forceStandardSession,
openGeneration = openGeneration
)
) {
@@ -3158,13 +3055,11 @@ class Camera2Controller(private val context: Context) {
private fun retryPreviewSessionWithoutVendorSessionParameters(
reason: String,
forceStandardSession: Boolean,
openGeneration: Long
): Boolean {
if (openGeneration != cameraOpenGeneration) return false
PLog.w(TAG, "Retrying preview session without vendor session parameters: $reason")
createPreviewSession(
forceStandardSession = forceStandardSession,
forceWithoutVendorSessionParameters = true,
openGeneration = openGeneration
)
@@ -3189,11 +3084,7 @@ class Camera2Controller(private val context: Context) {
return true
}
private fun createOutputConfiguration(
surface: Surface,
useHlgCapture: Boolean,
outputType: CameraOutputType
): OutputConfiguration {
private fun createOutputConfiguration(surface: Surface): OutputConfiguration {
return OutputConfiguration(surface).apply {
activeOutputPhysicalCameraId?.let { physicalCameraId ->
setPhysicalCameraId(physicalCameraId)
@@ -3203,40 +3094,6 @@ class Camera2Controller(private val context: Context) {
"(openCameraId=$activeOpenCameraId)"
)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE && !DeviceUtil.isHarmonyOS) {
dynamicRangeProfile = if (useHlgCapture) {
DynamicRangeProfiles.HLG10
} else {
DynamicRangeProfiles.STANDARD
}
}
/*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
val streamUseCase = when (outputType) {
CameraOutputType.PREVIEW ->
CameraMetadata.SCALER_AVAILABLE_STREAM_USE_CASES_PREVIEW.toLong()
CameraOutputType.STILL_CAPTURE ->
CameraMetadata.SCALER_AVAILABLE_STREAM_USE_CASES_STILL_CAPTURE.toLong()
CameraOutputType.RAW_CAPTURE -> null
CameraOutputType.VIDEO_RECORD ->
CameraMetadata.SCALER_AVAILABLE_STREAM_USE_CASES_VIDEO_RECORD.toLong()
}
if (streamUseCase == null) {
PLog.i(TAG, "OutputConfiguration streamUseCase=DEFAULT for ${outputType.name}")
} else if (
isStreamUseCaseSupported && availableStreamUseCases.contains(streamUseCase)
) {
setStreamUseCase(streamUseCase)
PLog.i(TAG, "OutputConfiguration streamUseCase=${outputType.name}")
} else {
PLog.d(
TAG,
"OutputConfiguration streamUseCase=${outputType.name} unsupported; using DEFAULT"
)
}
}*/
}
}
@@ -3583,10 +3440,8 @@ class Camera2Controller(private val context: Context) {
if (!isRawCapture) {
// 6. 图像质量设置(锐化、降噪)
applyImageQualitySettings(builder, isCapture)
applyImageQualitySettings(builder)
// 7. 视频 Log / 色调映射设置
applyToneMapSettings(builder, currentState, isCapture)
}
// 8. 防抖设置
@@ -4239,88 +4094,6 @@ class Camera2Controller(private val context: Context) {
builder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, resolvedRange)
}
private fun generateSrgbCurve(linearizeInput: Boolean = false): FloatArray {
val points = 64
val curve = FloatArray(points * 2)
for (i in 0 until points) {
val x = i.toFloat() / (points - 1)
val y = if (linearizeInput) {
x
} else {
linearToSrgb(x)
}
curve[i * 2] = x
curve[i * 2 + 1] = y.coerceIn(0f, 1f)
}
return curve
}
private fun inverseSrgb(x: Float): Float {
return if (x <= 0.04045f) {
x / 12.92f
} else {
Math.pow(((x + 0.055) / 1.055), 2.4).toFloat()
}
}
private fun linearToSrgb(x: Float): Float {
return if (x <= 0.0031308f) {
12.92f * x
} else {
1.055f * Math.pow(x.toDouble(), 1.0 / 2.4).toFloat() - 0.055f
}
}
private fun generateLinearToneCurve(): FloatArray {
return floatArrayOf(0f, 0f, 1f, 1f)
}
private fun applyToneMapSettings(builder: CaptureRequest.Builder, state: CameraState, isCapture: Boolean) {
val linearizeInput = if (isCapture) state.fixTonemapCapture else state.fixTonemapPreview
val tonemapMode = sanitizeTonemapMode(state.tonemapMode)
when (tonemapMode) {
"SYSTEM_DEFAULT" -> applyDefaultToneMapSettings(builder, state, isCapture)
"SRGB" -> {
if (availableTonemapModes.contains(CaptureRequest.TONEMAP_MODE_CONTRAST_CURVE)) {
builder.set(CaptureRequest.TONEMAP_MODE, CaptureRequest.TONEMAP_MODE_CONTRAST_CURVE)
val srgbCurve = generateSrgbCurve(linearizeInput)
val curve = TonemapCurve(srgbCurve, srgbCurve, srgbCurve)
builder.set(CaptureRequest.TONEMAP_CURVE, curve)
}
}
else -> {
applyDefaultToneMapSettings(builder, state, isCapture)
}
}
}
private fun applyDefaultToneMapSettings(
builder: CaptureRequest.Builder,
state: CameraState,
isCapture: Boolean
) {
val preferredTonemapMode = when {
isCapture && state.captureMode == CaptureMode.PHOTO &&
availableTonemapModes.contains(CaptureRequest.TONEMAP_MODE_HIGH_QUALITY) -> {
CaptureRequest.TONEMAP_MODE_HIGH_QUALITY
}
availableTonemapModes.contains(CaptureRequest.TONEMAP_MODE_FAST) -> {
CaptureRequest.TONEMAP_MODE_FAST
}
else -> null
}
preferredTonemapMode?.let { builder.set(CaptureRequest.TONEMAP_MODE, it) }
}
private fun sanitizeTonemapMode(mode: String): String {
return when (mode) {
"FAST", "HIGH_QUALITY" -> "SYSTEM_DEFAULT"
"REC709" -> "SRGB"
"SYSTEM_DEFAULT", "SRGB" -> mode
else -> "SYSTEM_DEFAULT"
}
}
/**
* 应用白平衡设置
*/
@@ -4812,7 +4585,7 @@ class Camera2Controller(private val context: Context) {
* @param builder 需要配置的 Builder
* @param isCapture 是否为拍摄请求(拍摄时使用高质量模式)
*/
private fun applyImageQualitySettings(builder: CaptureRequest.Builder, isCapture: Boolean) {
private fun applyImageQualitySettings(builder: CaptureRequest.Builder) {
try {
val currentState = _state.value
val isBurst = currentState.isMultiFrameEnabled
@@ -4834,19 +4607,24 @@ class Camera2Controller(private val context: Context) {
} else if (availableEdgeModes.contains(CaptureRequest.EDGE_MODE_FAST)) {
builder.set(CaptureRequest.EDGE_MODE, CaptureRequest.EDGE_MODE_FAST)
}
val resolvedNrLevel = resolveAutoNoiseReductionLevel(currentState, isCapture)
val effectiveNrLevel = if (isBurst && resolvedNrLevel == 2) 1 else resolvedNrLevel
val effectiveNrLevel = if (
isBurst && nrLevel == NoiseReductionLevel.HIGH_QUALITY
) {
NoiseReductionLevel.FAST
} else {
nrLevel
}
val noiseReductionMode = when (effectiveNrLevel) {
0 -> CaptureRequest.NOISE_REDUCTION_MODE_OFF
4 -> if (availableNoiseReductionModes.contains(CaptureRequest.NOISE_REDUCTION_MODE_MINIMAL)) {
NoiseReductionLevel.OFF -> CaptureRequest.NOISE_REDUCTION_MODE_OFF
NoiseReductionLevel.MINIMAL -> if (availableNoiseReductionModes.contains(CaptureRequest.NOISE_REDUCTION_MODE_MINIMAL)) {
CaptureRequest.NOISE_REDUCTION_MODE_MINIMAL
} else {
CaptureRequest.NOISE_REDUCTION_MODE_FAST
}
1 -> CaptureRequest.NOISE_REDUCTION_MODE_FAST
2 -> CaptureRequest.NOISE_REDUCTION_MODE_HIGH_QUALITY
3 -> if (availableNoiseReductionModes.contains(CaptureRequest.NOISE_REDUCTION_MODE_ZERO_SHUTTER_LAG)) {
NoiseReductionLevel.FAST -> CaptureRequest.NOISE_REDUCTION_MODE_FAST
NoiseReductionLevel.HIGH_QUALITY -> CaptureRequest.NOISE_REDUCTION_MODE_HIGH_QUALITY
NoiseReductionLevel.ZERO_SHUTTER_LAG -> if (availableNoiseReductionModes.contains(CaptureRequest.NOISE_REDUCTION_MODE_ZERO_SHUTTER_LAG)) {
CaptureRequest.NOISE_REDUCTION_MODE_ZERO_SHUTTER_LAG
} else {
CaptureRequest.NOISE_REDUCTION_MODE_FAST
@@ -4939,7 +4717,7 @@ class Camera2Controller(private val context: Context) {
}
private fun buildSelectableNoiseReductionModes(hardwareModes: IntArray): IntArray {
val orderedModes = mutableListOf(5)
val orderedModes = mutableListOf<Int>()
val preferredOrder = listOf(
CaptureRequest.NOISE_REDUCTION_MODE_OFF,
CaptureRequest.NOISE_REDUCTION_MODE_FAST,
@@ -4955,34 +4733,6 @@ class Camera2Controller(private val context: Context) {
return orderedModes.toIntArray()
}
private fun resolveAutoNoiseReductionLevel(state: CameraState, isCapture: Boolean): Int {
if (nrLevel != 5) {
return nrLevel
}
val lightValue = calculateCaptureLightValue(state, isCapture)
val resolvedLevel = when {
lightValue >= 9.0 -> 0
lightValue >= 6.0 -> 4
lightValue >= 4.0 -> 1
else -> 2
}
PLog.d(TAG, "Auto NR resolved by LV=$lightValue to level=$resolvedLevel")
return resolvedLevel
}
private fun calculateCaptureLightValue(state: CameraState, isCapture: Boolean): Double {
val aperture = state.physicalAperture.takeIf { it > 0f }?.toDouble() ?: 2.0
val exposureTimeNs = if (isCapture) {
state.shutterSpeed
} else {
coercePreviewExposureTime(state)
}
val exposureTimeSeconds = exposureTimeNs / 1_000_000_000.0
val iso = state.iso.coerceAtLeast(1).toDouble()
val ev100 = ln((aperture * aperture / exposureTimeSeconds) * (100.0 / iso)) / ln(2.0)
return (ev100 * 10.0).roundToInt() / 10.0
}
/**
* 设置锐化等级
*/
@@ -4994,8 +4744,9 @@ class Camera2Controller(private val context: Context) {
* 设置降噪等级
*/
fun setNRLevel(level: Int) {
nrLevel = level
_state.value = _state.value.copy(nrLevel = level)
val normalizedLevel = NoiseReductionLevel.normalize(level)
nrLevel = normalizedLevel
_state.value = _state.value.copy(nrLevel = normalizedLevel)
}
fun setVendorCaptureSettingsByLens(settingsByLens: VendorCaptureSettingsByLens) {
@@ -5123,39 +4874,6 @@ class Camera2Controller(private val context: Context) {
PLog.d(TAG, "RAW 最低快门速度: $resolvedValue ns")
}
/**
* 设置色调映射模式
*/
fun setTonemapMode(mode: String) {
val resolvedMode = sanitizeTonemapMode(mode)
_state.value = _state.value.copy(tonemapMode = resolvedMode)
PLog.d(TAG, "色调映射模式: $resolvedMode")
previewRequestBuilder?.apply {
applyToneMapSettings(this, _state.value, false)
updatePreview()
}
}
/**
* 设置是否修复自定义色调映射预览异常
*/
fun setFixTonemapPreview(enabled: Boolean) {
_state.value = _state.value.copy(fixTonemapPreview = enabled)
PLog.d(TAG, "修复色调映射预览异常: $enabled")
previewRequestBuilder?.apply {
applyToneMapSettings(this, _state.value, false)
updatePreview()
}
}
/**
* 设置是否修复自定义色调映射拍摄异常
*/
fun setFixTonemapCapture(enabled: Boolean) {
_state.value = _state.value.copy(fixTonemapCapture = enabled)
PLog.d(TAG, "修复色调映射拍摄异常: $enabled")
}
/**
* 设置虚化模拟光圈大小
*/
@@ -6778,7 +6496,6 @@ class Camera2Controller(private val context: Context) {
hasActiveLut = _state.value.lutEnabled && _state.value.currentLutName != null
),
colorLayers = colorLayers,
hlgInput = _state.value.useHlg10 && !useEnhancedStabilization,
cameraTimestampSource = getActiveOpenCameraCharacteristics()
?.get(CameraCharacteristics.SENSOR_INFO_TIMESTAMP_SOURCE)
?: CameraCharacteristics.SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN,
@@ -8040,7 +7757,7 @@ class Camera2Controller(private val context: Context) {
// previewSurface?.let { addTarget(it) }
// }
// 应用所有相机参数(曝光、白平衡、闪光灯、变焦、色调映射)
// 应用所有相机参数(曝光、白平衡、闪光灯、变焦)
// isCapture = true 确保使用完整的曝光时间(不限制长曝光)
applyBaseCameraSettings(this, isCapture = true, isRawCapture = isRawCapture)
@@ -8877,12 +8594,6 @@ class Camera2Controller(private val context: Context) {
_state.value = _state.value.copy(useP010 = enabled)
}
fun setUseHlg10(enabled: Boolean) {
_state.value = _state.value.copy(
useHlg10 = enabled,
)
}
fun setUseP3ColorSpace(enabled: Boolean) {
_state.value = _state.value.copy(useP3ColorSpace = enabled)
}
@@ -9,6 +9,20 @@ import com.hinnka.mycamera.video.VideoConfig
import com.hinnka.mycamera.video.VideoRecordingState
import kotlin.math.abs
object NoiseReductionLevel {
const val OFF = 0
const val FAST = 1
const val HIGH_QUALITY = 2
const val ZERO_SHUTTER_LAG = 3
const val MINIMAL = 4
const val DEFAULT = HIGH_QUALITY
fun normalize(level: Int): Int = when (level) {
OFF, FAST, HIGH_QUALITY, ZERO_SHUTTER_LAG, MINIMAL -> level
else -> DEFAULT
}
}
/**
* 画面比例。内置比例使用稳定名称持久化,自定义比例使用 CUSTOM_宽_高。
*/
@@ -341,8 +355,8 @@ data class CameraState(
// 网格线
val showGrid: Boolean = false, // 是否显示网格线
// 降噪等级 (0=Off, 1=Fast, 2=High Quality, 3=ZSL, 4=Minimal, 5=Auto)
val nrLevel: Int = 5,
// 降噪等级 (0=Off, 1=Fast, 2=High Quality, 3=ZSL, 4=Minimal)
val nrLevel: Int = NoiseReductionLevel.DEFAULT,
val availableNrModes: IntArray = intArrayOf(),
val vendorCaptureSettingsByLens: VendorCaptureSettingsByLens = VendorCaptureSettingsByLens.Empty,
val customVendorKeySettings: CustomVendorKeySettings = CustomVendorKeySettings.Empty,
@@ -358,24 +372,18 @@ data class CameraState(
val rawMinShutterSpeedNs: Long = 0L,
val useLivePhoto: Boolean = false,
val droMode: String = "OFF",
val tonemapMode: String = "SYSTEM_DEFAULT",
val fixTonemapPreview: Boolean = false,
val fixTonemapCapture: Boolean = false,
// 是否正在拍摄 Live Photo (用于 UI 动画)
val isCapturingLivePhoto: Boolean = false,
val applyUltraHDR: Boolean = true,
val useP010: Boolean = false,
val useHlg10: Boolean = false,
val useP3ColorSpace: Boolean = false,
val isP010Supported: Boolean = false,
val isHlg10Supported: Boolean = false,
val burstCapturing: Boolean = false,
val hdrBracketCapturing: Boolean = false,
val hdrBracketFrameCount: Int = 0,
val latitude: Double? = null,
val longitude: Double? = null,
val isP3Supported: Boolean = false,
val currentDynamicRangeProfile: String = "STANDARD",
val captureMode: CaptureMode = CaptureMode.PHOTO,
val photoPreviewStabilizationEnabled: Boolean = false,
val videoConfig: VideoConfig = VideoConfig(),
@@ -393,9 +401,6 @@ data class CameraState(
val isAutoExposure: Boolean
get() = isIsoAuto && isShutterSpeedAuto
val isHLG: Boolean
get() = currentDynamicRangeProfile == "HLG10"
val isMultiFrameEnabled: Boolean
get() = multiFrameOutputScale != null && (!useRaw || isRawSupported)
@@ -61,9 +61,6 @@ internal object BackupPreferenceSanitizer {
"logical_camera_binding_whitelist",
"hidden_focal_lengths",
"video_audio_input_id",
"fix_tonemap_preview",
"fix_tonemap_capture",
"hlg_hardware_compatibility_enabled",
"camera_startup_defaults_restored_v1",
)
@@ -18,6 +18,7 @@ import com.hinnka.mycamera.camera.IszLensConfig
import com.hinnka.mycamera.camera.IszRawDngMetadataCorrections
import com.hinnka.mycamera.camera.MultiFrameConfig
import com.hinnka.mycamera.camera.MeteringMode
import com.hinnka.mycamera.camera.NoiseReductionLevel
import com.hinnka.mycamera.camera.VendorCaptureSettings
import com.hinnka.mycamera.camera.VendorCaptureSettingsByLens
import com.hinnka.mycamera.gallery.PhotoSavePath
@@ -70,15 +71,6 @@ private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(
},
)
private fun sanitizeTonemapMode(mode: String): String {
return when (mode) {
"FAST", "HIGH_QUALITY" -> "SYSTEM_DEFAULT"
"REC709" -> "SRGB"
"SYSTEM_DEFAULT", "SRGB" -> mode
else -> "SYSTEM_DEFAULT"
}
}
private fun resolveStoredRawAutoExposure(mode: String?, legacyValue: Boolean?): Boolean {
return when {
mode.equals("OFF", ignoreCase = true) -> false
@@ -182,7 +174,7 @@ data class UserPreferences(
val autoSaveAfterCapture: Boolean = true, // 自动保存
val photoSavePath: PhotoSavePath = PhotoSavePath.DCIM_PHOTON,
val photoSaveTreeUri: String? = null,
val nrLevel: Int = 5, // 降噪等级:0=Off, 1=Fast, 2=High Quality, 3=ZSL, 4=Minimal, 5=Auto
val nrLevel: Int = NoiseReductionLevel.DEFAULT, // 降噪等级:0=Off, 1=Fast, 2=High Quality, 3=ZSL, 4=Minimal
val edgeLevel: Int = 1, // 锐化等级:0=Off, 1=Fast, 2=High Quality, 3=Real-time
val vendorCaptureSettingsByLens: VendorCaptureSettingsByLens = VendorCaptureSettingsByLens.Empty,
val customVendorKeySettings: CustomVendorKeySettings = CustomVendorKeySettings.Empty,
@@ -219,16 +211,11 @@ data class UserPreferences(
val captureButtonColor: Int = 0xFFFFFFFF.toInt(),
val captureButtonImagePath: String? = null,
val droMode: String = "OFF", // DRO 模式
val tonemapMode: String = "SYSTEM_DEFAULT", // 色调映射模式
val fixTonemapPreview: Boolean = false, // 修复部分设备自定义色调映射预览异常
val fixTonemapCapture: Boolean = false, // 修复部分设备自定义色调映射拍摄异常
val applyUltraHDR: Boolean = false, // 是否应用 Ultra HDR 策略
val colorSpace: ColorSpace = ColorSpace.SRGB,
val logCurve: TransferCurve = TransferCurve.SRGB,
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 = false,
val useP3ColorSpace: Boolean = false,
val videoResolution: VideoResolutionPreset = VideoResolutionPreset.FHD_1080P,
val videoFps: VideoFpsPreset = VideoFpsPreset.FPS_30,
@@ -481,15 +468,10 @@ class UserPreferencesRepository(private val context: Context) {
private val CAPTURE_BUTTON_COLOR = intPreferencesKey("capture_button_color")
private val CAPTURE_BUTTON_IMAGE_PATH = stringPreferencesKey("capture_button_image_path")
private val DRO_MODE = stringPreferencesKey("dro_mode")
private val TONEMAP_MODE = stringPreferencesKey("tonemap_mode")
private val FIX_TONEMAP_PREVIEW = booleanPreferencesKey("fix_tonemap_preview")
private val FIX_TONEMAP_CAPTURE = booleanPreferencesKey("fix_tonemap_capture")
private val APPLY_ULTRA_HDR = booleanPreferencesKey("apply_ultra_hdr")
private val COLOR_SPACE = stringPreferencesKey("color_space")
private val LOG_CURVE = stringPreferencesKey("log_curve")
private val USE_P010 = booleanPreferencesKey("use_p010")
private val USE_HLG10 = booleanPreferencesKey("use_hlg10")
private val HLG_HARDWARE_COMPATIBILITY_ENABLED = booleanPreferencesKey("hlg_hardware_compatibility_enabled")
private val USE_P3_COLOR_SPACE = booleanPreferencesKey("use_p3_color_space")
private val VIDEO_RESOLUTION = stringPreferencesKey("video_resolution")
private val VIDEO_FPS = stringPreferencesKey("video_fps")
@@ -719,7 +701,9 @@ class UserPreferencesRepository(private val context: Context) {
autoSaveAfterCapture = preferences[AUTO_SAVE_AFTER_CAPTURE] ?: true,
photoSavePath = PhotoSavePath.fromPersistedName(preferences[PHOTO_SAVE_PATH]),
photoSaveTreeUri = preferences[PHOTO_SAVE_TREE_URI]?.takeIf { it.isNotBlank() },
nrLevel = preferences[NR_LEVEL] ?: 5,
nrLevel = NoiseReductionLevel.normalize(
preferences[NR_LEVEL] ?: NoiseReductionLevel.DEFAULT
),
edgeLevel = preferences[EDGE_LEVEL] ?: 1,
vendorCaptureSettingsByLens = VendorCaptureSettingsByLens.deserialize(
preferences[VENDOR_CAPTURE_SETTINGS]
@@ -785,16 +769,11 @@ class UserPreferencesRepository(private val context: Context) {
captureButtonImagePath = preferences[CAPTURE_BUTTON_IMAGE_PATH]
?.takeIf { it.isNotBlank() },
droMode = preferences[DRO_MODE] ?: if (preferences[RAW_DRO_ENABLED_KEY] == true) "DR100" else "OFF",
tonemapMode = sanitizeTonemapMode(preferences[TONEMAP_MODE] ?: "SYSTEM_DEFAULT"),
fixTonemapPreview = preferences[FIX_TONEMAP_PREVIEW] ?: false,
fixTonemapCapture = preferences[FIX_TONEMAP_CAPTURE] ?: false,
applyUltraHDR = preferences[APPLY_ULTRA_HDR] ?: false,
colorSpace = ColorSpace.valueOf(preferences[COLOR_SPACE] ?: ColorSpace.SRGB.name),
logCurve = TransferCurve.fromPersistedName(preferences[LOG_CURVE] ?: TransferCurve.SRGB.name),
rawLuts = parseRawLuts(preferences),
useP010 = preferences[USE_P010] ?: false,
useHlg10 = preferences[USE_HLG10] ?: false,
hlgHardwareCompatibilityEnabled = preferences[HLG_HARDWARE_COMPATIBILITY_ENABLED] ?: false,
useP3ColorSpace = preferences[USE_P3_COLOR_SPACE] ?: false,
videoResolution = storedVideoResolution,
videoFps = storedVideoFps,
@@ -1326,7 +1305,6 @@ class UserPreferencesRepository(private val context: Context) {
if (preferences[CAMERA_STARTUP_DEFAULTS_RESTORED_V1] == true) {
return@edit
}
preferences[TONEMAP_MODE] = "SYSTEM_DEFAULT"
val exposureMode = RawAdaptiveExposureMode.fromPersistedValue(
value = preferences[RAW_AUTO_EXPOSURE_MODE_KEY],
usePhotonHdr =
@@ -1684,7 +1662,7 @@ class UserPreferencesRepository(private val context: Context) {
*/
suspend fun saveNRLevel(level: Int) {
context.dataStore.edit { preferences ->
preferences[NR_LEVEL] = level
preferences[NR_LEVEL] = NoiseReductionLevel.normalize(level)
}
}
@@ -2111,33 +2089,6 @@ class UserPreferencesRepository(private val context: Context) {
}
}
/**
* 保存色调映射模式
*/
suspend fun saveTonemapMode(mode: String) {
context.dataStore.edit { preferences ->
preferences[TONEMAP_MODE] = sanitizeTonemapMode(mode)
}
}
/**
* 保存是否修复自定义色调映射预览异常
*/
suspend fun saveFixTonemapPreview(enabled: Boolean) {
context.dataStore.edit { preferences ->
preferences[FIX_TONEMAP_PREVIEW] = enabled
}
}
/**
* 保存是否修复自定义色调映射拍摄异常
*/
suspend fun saveFixTonemapCapture(enabled: Boolean) {
context.dataStore.edit { preferences ->
preferences[FIX_TONEMAP_CAPTURE] = enabled
}
}
/**
* 保存是否应用 Ultra HDR 策略
*/
@@ -2191,18 +2142,6 @@ class UserPreferencesRepository(private val context: Context) {
}
}
suspend fun saveUseHlg10(enabled: Boolean) {
context.dataStore.edit { preferences ->
preferences[USE_HLG10] = enabled
}
}
suspend fun saveHlgHardwareCompatibilityEnabled(enabled: Boolean) {
context.dataStore.edit { preferences ->
preferences[HLG_HARDWARE_COMPATIBILITY_ENABLED] = enabled
}
}
/**
* 保存是否启用 P3 色域
*/
@@ -293,7 +293,6 @@ object GalleryManager {
}
val metadata = baseMetadata.copy(
lutId = lutId,
tonemapMode = mgcTonemapMode(preferences?.tonemapMode),
colorRecipeParams = lutId?.let { repository.lutManager.loadColorRecipeParams(it) },
baselineTarget = baselineLutId?.let { BaselineColorCorrectionTarget.RAW },
baselineLutId = baselineLutId,
@@ -370,15 +369,6 @@ object GalleryManager {
}
}
private fun mgcTonemapMode(tonemapMode: String?): String {
return when (tonemapMode) {
"FAST", "HIGH_QUALITY", null -> "SYSTEM_DEFAULT"
"REC709" -> "SRGB"
"SYSTEM_DEFAULT", "SRGB" -> tonemapMode
else -> "SYSTEM_DEFAULT"
}
}
data class PhotoMetadataUpdate(
val photoId: String,
val metadata: MediaMetadata
@@ -67,12 +67,6 @@ class PhotoProcessor(
val metadata: MediaMetadata,
)
private suspend fun shouldDecodeHlgInput(metadata: MediaMetadata): Boolean {
val isHlg = metadata.dynamicRangeProfile == "HLG10"
if (!isHlg) return false
return userPreferencesRepository.userPreferences.firstOrNull()?.hlgHardwareCompatibilityEnabled ?: false
}
private suspend fun resolveRawAutoWhiteBalanceEstimate(metadata: MediaMetadata): Boolean {
return metadata.rawAutoWhiteBalanceEstimate
?: (userPreferencesRepository.userPreferences.firstOrNull()?.rawAutoWhiteBalanceEstimate ?: false)
@@ -323,7 +317,6 @@ class PhotoProcessor(
val lutStackResult = lutImageProcessor.applyLutStackWithLuminanceGain(
sdrBitmap,
isHlgInput = false,
colorCorrection.baselineLayer,
colorCorrection.creativeLayer,
0f,
@@ -725,7 +718,6 @@ class PhotoProcessor(
lutImageProcessor.applyLutStack(
b,
isHlgInput = false,
colorCorrection.baselineLayer,
colorCorrection.creativeLayer,
0f,
@@ -789,7 +781,6 @@ class PhotoProcessor(
if (onLutLuminanceGainMap != null) {
val lutStackResult = lutImageProcessor.applyLutStackWithLuminanceGain(
result,
isHlgInput = shouldDecodeHlgInput(metadata),
colorCorrection.baselineLayer,
colorCorrection.creativeLayer,
finalSharpening,
@@ -802,7 +793,6 @@ class PhotoProcessor(
} else {
result = lutImageProcessor.applyLutStack(
result,
isHlgInput = shouldDecodeHlgInput(metadata),
colorCorrection.baselineLayer,
colorCorrection.creativeLayer,
finalSharpening,
@@ -18,7 +18,6 @@ internal data class ColorPassLocations(
val uVideoLogEnabledLocation: Int,
val uVideoLogCurveLocation: Int,
val uVideoColorSpaceLocation: Int,
val uIsHlgInputLocation: Int,
val uColorRecipeEnabledLocation: Int,
val uExposureLocation: Int,
val uContrastLocation: Int,
@@ -119,7 +118,6 @@ internal class PreviewColorProgramCache {
uVideoLogEnabledLocation = GLES30.glGetUniformLocation(program, "uVideoLogEnabled"),
uVideoLogCurveLocation = GLES30.glGetUniformLocation(program, "uVideoLogCurve"),
uVideoColorSpaceLocation = GLES30.glGetUniformLocation(program, "uVideoColorSpace"),
uIsHlgInputLocation = GLES30.glGetUniformLocation(program, "uIsHlgInput"),
uColorRecipeEnabledLocation = GLES30.glGetUniformLocation(program, "uColorRecipeEnabled"),
uExposureLocation = GLES30.glGetUniformLocation(program, "uExposure"),
uContrastLocation = GLES30.glGetUniformLocation(program, "uContrast"),
@@ -168,7 +168,6 @@ class LutImageProcessor(context: Context? = null) {
private var uLutCurveLoc = 0
private var uLutColorSpaceLoc = 0
private var uInputColorSpaceLoc = 0
private var uIsHlgInputLoc = 0
private var uMVPMatrixLoc = 0
// 色彩配方 Uniform 位置
@@ -346,7 +345,6 @@ class LutImageProcessor(context: Context? = null) {
width: Int,
height: Int,
colorSpace: ColorSpace,
isHlgInput: Boolean = false,
lutConfig: LutConfig?,
colorRecipeParams: ColorRecipeParams?,
sharpeningValue: Float = 0f,
@@ -426,7 +424,6 @@ class LutImageProcessor(context: Context? = null) {
width, height,
inputTexId,
colorSpace,
isHlgInput,
lutConfig,
effectiveRecipeParams,
sharpening,
@@ -441,7 +438,6 @@ class LutImageProcessor(context: Context? = null) {
width: Int,
height: Int,
colorSpace: ColorSpace,
isHlgInput: Boolean = false,
baselineLayer: LutRenderLayer?,
creativeLayer: LutRenderLayer?,
sharpeningValue: Float = 0f,
@@ -457,7 +453,6 @@ class LutImageProcessor(context: Context? = null) {
width = width,
height = height,
colorSpace = colorSpace,
isHlgInput = isHlgInput,
lutConfig = baselineLayer.lutConfig,
colorRecipeParams = baselineLayer.colorRecipeParams,
noiseReductionValue = 0f,
@@ -477,7 +472,6 @@ class LutImageProcessor(context: Context? = null) {
width = width,
height = height,
colorSpace = colorSpace,
isHlgInput = isHlgInput,
lutConfig = baselineLayer.lutConfig,
colorRecipeParams = baselineLayer.colorRecipeParams,
sharpeningValue = sharpeningValue,
@@ -489,7 +483,6 @@ class LutImageProcessor(context: Context? = null) {
width = width,
height = height,
colorSpace = colorSpace,
isHlgInput = isHlgInput,
lutConfig = creativeLayer?.lutConfig,
colorRecipeParams = creativeLayer?.colorRecipeParams,
sharpeningValue = sharpeningValue,
@@ -511,7 +504,6 @@ class LutImageProcessor(context: Context? = null) {
*/
suspend fun applyLut(
bitmap: Bitmap,
isHlgInput: Boolean = false,
lutConfig: LutConfig?,
colorRecipeParams: ColorRecipeParams?,
sharpeningValue: Float = 0f,
@@ -594,7 +586,6 @@ class LutImageProcessor(context: Context? = null) {
width, height,
inputTexId,
renderColorSpace,
isHlgInput,
lutConfig,
effectiveRecipeParams,
sharpening,
@@ -606,7 +597,6 @@ class LutImageProcessor(context: Context? = null) {
suspend fun applyLutStack(
bitmap: Bitmap,
isHlgInput: Boolean = false,
baselineLayer: LutRenderLayer?,
creativeLayer: LutRenderLayer?,
sharpeningValue: Float = 0f,
@@ -619,7 +609,6 @@ class LutImageProcessor(context: Context? = null) {
hasBaseline && hasCreative -> {
val baseBitmap = applyLut(
bitmap = bitmap,
isHlgInput = isHlgInput,
lutConfig = baselineLayer.lutConfig,
colorRecipeParams = baselineLayer.colorRecipeParams,
noiseReductionValue = 0f,
@@ -636,7 +625,6 @@ class LutImageProcessor(context: Context? = null) {
}
hasBaseline -> applyLut(
bitmap = bitmap,
isHlgInput = isHlgInput,
lutConfig = baselineLayer.lutConfig,
colorRecipeParams = baselineLayer.colorRecipeParams,
sharpeningValue = sharpeningValue,
@@ -645,7 +633,6 @@ class LutImageProcessor(context: Context? = null) {
)
else -> applyLut(
bitmap = bitmap,
isHlgInput = isHlgInput,
lutConfig = creativeLayer?.lutConfig,
colorRecipeParams = creativeLayer?.colorRecipeParams,
sharpeningValue = sharpeningValue,
@@ -662,7 +649,6 @@ class LutImageProcessor(context: Context? = null) {
*/
suspend fun applyLutStackWithLuminanceGain(
bitmap: Bitmap,
isHlgInput: Boolean = false,
baselineLayer: LutRenderLayer?,
creativeLayer: LutRenderLayer?,
sharpeningValue: Float = 0f,
@@ -672,20 +658,19 @@ class LutImageProcessor(context: Context? = null) {
): LutStackRenderResult {
val rendered = applyLutStack(
bitmap = bitmap,
isHlgInput = isHlgInput,
baselineLayer = baselineLayer,
creativeLayer = creativeLayer,
sharpeningValue = sharpeningValue,
noiseReductionValue = noiseReductionValue,
chromaNoiseReductionValue = chromaNoiseReductionValue,
)
val luminanceGainMap = if (isHlgInput || !bitmap.colorSpace.isEncodedSrgbFamily() ||
val luminanceGainMap = if (!bitmap.colorSpace.isEncodedSrgbFamily() ||
!rendered.colorSpace.isEncodedSrgbFamily()
) {
PLog.e(
TAG,
"LUT luminance sidecar requires encoded sRGB input/output: " +
"isHlg=$isHlgInput, before=${bitmap.colorSpace}, after=${rendered.colorSpace}"
"before=${bitmap.colorSpace}, after=${rendered.colorSpace}"
)
null
} else withContext(glDispatcher) {
@@ -852,7 +837,6 @@ class LutImageProcessor(context: Context? = null) {
height = height,
inputTextureId = bitmapDenoiseTexId[0],
inputColorSpace = bitmap.colorSpace ?: ColorSpace.get(ColorSpace.Named.SRGB),
isHlgInput = false,
lutConfig = null,
effectiveRecipeParams = null,
sharpening = 0f,
@@ -868,7 +852,6 @@ class LutImageProcessor(context: Context? = null) {
height: Int,
inputTextureId: Int,
inputColorSpace: ColorSpace,
isHlgInput: Boolean,
lutConfig: LutConfig?,
effectiveRecipeParams: ColorRecipeParams?,
sharpening: Float,
@@ -935,7 +918,6 @@ class LutImageProcessor(context: Context? = null) {
val inputColorSpaceId = if (inputColorSpace == ColorSpace.get(ColorSpace.Named.DISPLAY_P3)) 1 else 0
GLES30.glUniform1i(GLES30.glGetUniformLocation(program, "uInputColorSpace"), inputColorSpaceId)
GLES30.glUniform1i(uIsHlgInputLoc, if (isHlgInput) 1 else 0)
// 设置色彩配方参数
GLES30.glUniform1i(
@@ -1355,7 +1337,6 @@ class LutImageProcessor(context: Context? = null) {
uLutCurveLoc = GLES30.glGetUniformLocation(shaderProgram, "uLutCurve")
uLutColorSpaceLoc = GLES30.glGetUniformLocation(shaderProgram, "uLutColorSpace")
uInputColorSpaceLoc = GLES30.glGetUniformLocation(shaderProgram, "uInputColorSpace")
uIsHlgInputLoc = GLES30.glGetUniformLocation(shaderProgram, "uIsHlgInput")
uMVPMatrixLoc = GLES30.glGetUniformLocation(shaderProgram, "uMVPMatrix")
// 获取色彩配方 uniform 位置
@@ -3239,7 +3220,6 @@ class LutImageProcessor(context: Context? = null) {
uniform int uLutCurve;
uniform int uLutColorSpace;
uniform int uInputColorSpace;
uniform bool uIsHlgInput;
// 色彩配方控制
uniform bool uColorRecipeEnabled;
@@ -3297,7 +3277,6 @@ class LutImageProcessor(context: Context? = null) {
}
${PreviewColorShaderModules.COLOR_TRANSFER_CORE}
${PreviewColorShaderModules.HLG_TO_LINEAR}
${PreviewColorShaderModules.EXPOSURE}
${DirectFlashShader.GLSL}
${ThreeWayColorGradingShader.GLSL}
@@ -3306,10 +3285,6 @@ class LutImageProcessor(context: Context? = null) {
vec3 prepareToneSample(vec3 sampleColor) {
vec3 prepared = sampleColor;
if (uIsHlgInput) {
prepared = hlgToLinear(prepared);
prepared = linearToSrgb(prepared);
}
if (abs(uExposure) > 0.001) {
prepared = applyExposureInLinearSpace(prepared, uExposure);
}
@@ -3446,11 +3421,6 @@ class LutImageProcessor(context: Context? = null) {
color = sampleImage(uvCoord);
}
if (uIsHlgInput) {
color.rgb = hlgToLinear(color.rgb);
color.rgb = linearToSrgb(color.rgb);
}
// === 色彩配方处理(按专业后期流程顺序) ===
if (uColorRecipeEnabled) {
// 1. 曝光调整(在线性空间执行 EV 增益,再回到显示空间)
@@ -129,9 +129,6 @@ class LutRenderer(context: Context) : GLSurfaceView.Renderer {
private var aCopyPositionLoc: Int = 0
private var aCopyTexCoordLoc: Int = 0
// 是否以 HLG10 动态范围采集(Log LUT 兼容性方案)
var isHlgInput: Boolean = false
// 曲线纹理
private var curveTextureId: Int = 0
private var baselineCurveTextureId: Int = 0
@@ -819,7 +816,6 @@ class LutRenderer(context: Context) : GLSurfaceView.Renderer {
lutEnabled: Boolean,
params: com.hinnka.mycamera.model.ColorRecipeParams,
enableVideoLog: Boolean,
treatSourceAsHlgInput: Boolean,
): ColorPassLocations? {
val variant = PreviewColorShaderVariant.forPass(
textureSource = textureSource,
@@ -827,7 +823,6 @@ class LutRenderer(context: Context) : GLSurfaceView.Renderer {
lutConfig = lutConfig,
lutEnabled = lutEnabled && lutConfig != null,
videoLogEnabled = enableVideoLog && videoLogProfile.isEnabled,
hlgInput = treatSourceAsHlgInput,
)
return colorProgramCache.get(variant)
}
@@ -850,7 +845,6 @@ class LutRenderer(context: Context) : GLSurfaceView.Renderer {
curveTextureId: Int,
curveEnabled: Boolean,
enableVideoLog: Boolean,
treatSourceAsHlgInput: Boolean,
) {
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, targetFboId)
GLES30.glViewport(0, 0, width, height)
@@ -889,9 +883,6 @@ class LutRenderer(context: Context) : GLSurfaceView.Renderer {
GLES30.glUniform1i(locations.uVideoLogEnabledLocation, if (enableVideoLog && videoLogProfile.isEnabled) 1 else 0)
GLES30.glUniform1i(locations.uVideoLogCurveLocation, LutShaderMappings.transferCurveId(videoLogProfile.logCurve))
GLES30.glUniform1i(locations.uVideoColorSpaceLocation, LutShaderMappings.colorSpaceId(videoLogProfile.colorSpace))
GLES30.glUniform1i(locations.uIsHlgInputLocation, if (treatSourceAsHlgInput) 1 else 0)
// PLog.d(TAG, "uIsHlgInputLocation=$treatSourceAsHlgInput")
val recipeEnabled = !params.isDefault()
GLES30.glUniform1i(locations.uColorRecipeEnabledLocation, if (recipeEnabled) 1 else 0)
@@ -1142,7 +1133,6 @@ class LutRenderer(context: Context) : GLSurfaceView.Renderer {
lutEnabled = lutEnabled && currentLutConfig != null,
params = creativeParams,
enableVideoLog = false,
treatSourceAsHlgInput = false,
) ?: run {
return
}
@@ -1164,7 +1154,6 @@ class LutRenderer(context: Context) : GLSurfaceView.Renderer {
curveTextureId = curveTextureId,
curveEnabled = curveEnabled && curveTextureId != 0,
enableVideoLog = false,
treatSourceAsHlgInput = false
)
currentTexId = stackTextureId
}
@@ -1442,14 +1431,12 @@ class LutRenderer(context: Context) : GLSurfaceView.Renderer {
false
}
val enableVideoLog = true
val currentSourceIsHlg = isHlgInput && previewStabilizationUseCase == null
val locations = getColorPassLocations(
textureSource = currentCameraTextureSource,
lutConfig = layerLutConfig,
lutEnabled = layerLutEnabled,
params = layerParams,
enableVideoLog = enableVideoLog,
treatSourceAsHlgInput = currentSourceIsHlg,
) ?: return
drawColorPass(
locations = locations,
@@ -1469,7 +1456,6 @@ class LutRenderer(context: Context) : GLSurfaceView.Renderer {
curveTextureId = layerCurveTextureId,
curveEnabled = layerCurveEnabled,
enableVideoLog = enableVideoLog,
treatSourceAsHlgInput = currentSourceIsHlg,
)
// 测光和直方图(按需)
@@ -36,7 +36,6 @@ internal object PreviewColorShader {
uniform bool uVideoLogEnabled;
uniform int uVideoLogCurve;
uniform int uVideoColorSpace;
uniform bool uIsHlgInput;
uniform bool uColorRecipeEnabled;
uniform mat4 uSTMatrix;
@@ -89,7 +88,6 @@ internal object PreviewColorShader {
const float PI = 3.14159265359;
${PreviewColorShaderModules.COLOR_TRANSFER_CORE}
${if (variant.includeHlgInput) PreviewColorShaderModules.HLG_TO_LINEAR else PreviewColorShaderModules.HLG_TO_LINEAR_STUB}
${PreviewColorShaderModules.EXPOSURE}
${DirectFlashShader.GLSL}
${ThreeWayColorGradingShader.GLSL}
@@ -207,11 +205,6 @@ internal object PreviewColorShader {
color = texture(uCameraTexture, uvCoord);
}
if (uIsHlgInput) {
color.rgb = hlgToLinear(color.rgb);
color.rgb = linearToSrgb(color.rgb);
}
${if (variant.includeJpegInputToneCurve) """
color.rgb = applyJpegInputToneCurve(color.rgb);
color.rgb = sanitizeColor(color.rgb);
@@ -18,23 +18,6 @@ internal object PreviewColorShaderModules {
}
""".trimIndent()
val HLG_TO_LINEAR = """
vec3 hlgToLinear(vec3 e) {
float ha = 0.17883277;
float hb = 1.0 - 4.0 * ha;
float hc = 0.5 - ha * log(4.0 * ha);
vec3 low = e * e / 3.0;
vec3 high = (exp((e - hc) / ha) + hb) / 12.0;
return mix(low, high, step(vec3(0.5), e));
}
""".trimIndent()
val HLG_TO_LINEAR_STUB = """
vec3 hlgToLinear(vec3 e) {
return e;
}
""".trimIndent()
val EXPOSURE = """
vec3 applyExposureInLinearSpace(vec3 srgbColor, float exposureEv) {
vec3 linearColor = srgbToLinear(max(srgbColor, vec3(0.0)));
@@ -11,7 +11,6 @@ internal enum class PreviewColorTextureSource {
internal data class PreviewColorShaderVariant(
val textureSource: PreviewColorTextureSource,
val includeHlgInput: Boolean,
val includeExtendedLutCurves: Boolean,
val includeOklchDensity: Boolean,
val includeLchMixer: Boolean,
@@ -27,12 +26,10 @@ internal data class PreviewColorShaderVariant(
lutConfig: LutConfig?,
lutEnabled: Boolean,
videoLogEnabled: Boolean,
hlgInput: Boolean,
): PreviewColorShaderVariant {
val lutCurve = lutConfig?.curve ?: TransferCurve.SRGB
return PreviewColorShaderVariant(
textureSource = textureSource,
includeHlgInput = hlgInput,
includeExtendedLutCurves = videoLogEnabled ||
(lutEnabled && lutCurve.shaderId !in SIMPLE_LUT_CURVES),
includeOklchDensity = abs(params.color) > EPSILON,
@@ -43,7 +43,6 @@ class RealtimeVideoRenderer(
private val encoderOutputSize: Size,
colorLayers: List<VideoColorEffectLayer>,
private val videoLogProfile: VideoLogProfile,
private val hlgInput: Boolean,
private val mirrorHorizontally: Boolean,
private val mirrorVertically: Boolean,
private val encoderColorConfig: VideoEncoderColorConfig,
@@ -185,7 +184,7 @@ class RealtimeVideoRenderer(
TAG,
"Initialized: camera=${cameraInputSize.width}x${cameraInputSize.height}, " +
"encoder=${encoderOutputSize.width}x${encoderOutputSize.height}, " +
"layers=${layers.size}, log=${videoLogProfile.name}, hlgInput=$hlgInput, " +
"layers=${layers.size}, log=${videoLogProfile.name}, " +
"enhancedStabilization=$enhancedStabilizationEnabled, " +
"stabilizationStrength=$enhancedStabilizationStrength, " +
"mirrorH=$mirrorHorizontally, mirrorV=$mirrorVertically, " +
@@ -253,7 +252,6 @@ class RealtimeVideoRenderer(
cropRect = sourceCropRect,
mvpMatrix = firstPassMvpMatrix,
enableVideoLog = videoLogProfile.isEnabled,
treatSourceAsHlgInput = hlgInput,
presentationTimeNs = timestampNs,
)
@@ -274,7 +272,6 @@ class RealtimeVideoRenderer(
cropRect = fullCropRect,
mvpMatrix = identityMatrix,
enableVideoLog = false,
treatSourceAsHlgInput = false,
presentationTimeNs = timestampNs,
)
}
@@ -366,7 +363,6 @@ class RealtimeVideoRenderer(
cropRect: FloatArray,
mvpMatrix: FloatArray,
enableVideoLog: Boolean,
treatSourceAsHlgInput: Boolean,
presentationTimeNs: Long,
) {
val lutEnabled = layer.lutConfig != null && layer.lutTextureId != 0
@@ -376,7 +372,6 @@ class RealtimeVideoRenderer(
lutConfig = layer.lutConfig,
lutEnabled = lutEnabled,
videoLogEnabled = enableVideoLog,
hlgInput = treatSourceAsHlgInput,
)
val locations = colorProgramCache.get(variant)
?: throw IllegalStateException("Cannot create realtime video color shader: $variant")
@@ -436,11 +431,6 @@ class RealtimeVideoRenderer(
locations.uVideoColorSpaceLocation,
LutShaderMappings.colorSpaceId(videoLogProfile.colorSpace),
)
GLES30.glUniform1i(
locations.uIsHlgInputLocation,
if (treatSourceAsHlgInput) 1 else 0,
)
bindRecipeUniforms(
locations = locations,
params = layer.params,
@@ -88,7 +88,6 @@ private class VideoLutShaderProgram(
uniform int uLutCurve;
uniform int uLutColorSpace;
uniform int uInputColorSpace;
uniform int uIsHlgInput;
// 色彩配方控制
uniform int uColorRecipeEnabled;
@@ -160,23 +159,6 @@ private class VideoLutShaderProgram(
return sign(c) * result;
}
vec3 hlgToLinear(vec3 e) {
float ha = 0.17883277;
float hb = 1.0 - 4.0 * ha;
float hc = 0.5 - ha * log(4.0 * ha);
vec3 low = e * e / 3.0;
vec3 high = (exp((e - hc) / ha) + hb) / 12.0;
return mix(low, high, step(vec3(0.5), e));
}
vec3 bt2020ToLinearSrgb(vec3 rgb) {
return mat3(
1.660491, -0.124550, -0.018151,
-0.587641, 1.132900, -0.100579,
-0.072850, -0.008350, 1.118730
) * rgb;
}
vec3 applyExposureInLinearSpace(vec3 srgbColor, float exposureEv) {
vec3 linearColor = srgbToLinear(max(srgbColor, vec3(0.0)));
linearColor *= exp2(exposureEv);
@@ -541,12 +523,6 @@ private class VideoLutShaderProgram(
color = texture(uImageTexture, uvCoord);
}
if (uIsHlgInput != 0) {
color.rgb = hlgToLinear(color.rgb);
color.rgb = bt2020ToLinearSrgb(color.rgb);
color.rgb = linearToSrgb(color.rgb);
}
if (uColorRecipeEnabled != 0) {
if (abs(uExposure) > 0.001) {
color.rgb = applyExposureInLinearSpace(color.rgb, uExposure);
@@ -987,7 +963,6 @@ private class VideoLutShaderProgram(
}
GLES30.glUniform1i(GLES30.glGetUniformLocation(programId, "uInputColorSpace"), 0) // 默认 sRGB
GLES30.glUniform1i(GLES30.glGetUniformLocation(programId, "uIsHlgInput"), 0)
GLES30.glUniform1f(GLES30.glGetUniformLocation(programId, "uChromaticAberration"), 0f)
GLES30.glUniform1f(GLES30.glGetUniformLocation(programId, "uSharpening"), 0f)
@@ -245,11 +245,6 @@ class CameraGLSurfaceView @JvmOverloads constructor(
requestRender()
}
fun setIsHlgInput(isHlg: Boolean) {
renderer.isHlgInput = isHlg
requestRender()
}
fun setAutoFocus(auto: Boolean) {
renderer.isAutoFocus = auto
requestRender()
@@ -67,7 +67,6 @@ fun CameraPreviewGL(
onFirstPreviewFrame: (() -> Unit)? = null,
livePhotoRecorder: LivePhotoRecorder? = null,
videoLogProfile: VideoLogProfile = VideoLogProfile.OFF,
isHlgInput: Boolean = false,
isEyeFocusBusy: Boolean = false,
onGLSurfaceViewReady: ((CameraGLSurfaceView) -> Unit)? = null,
isAutoFocus: Boolean = true,
@@ -314,7 +313,6 @@ fun CameraPreviewGL(
glSurfaceView.setMeteringMode(meteringMode)
glSurfaceView.setLivePhotoRecorder(livePhotoRecorder)
glSurfaceView.setVideoLogProfile(videoLogProfile)
glSurfaceView.setIsHlgInput(isHlgInput)
glSurfaceView.setAutoFocus(isAutoFocus)
glSurfaceView.setFocusPeakingEnabled(focusPeakingEnabled)
glSurfaceView.setEyeFocusBusy(isEyeFocusBusy)
@@ -243,7 +243,6 @@ fun CameraScreen(
val ultraHdrEnabled by viewModel.ultraHdrGainMapEnabled.collectAsState()
val useLivePhoto by viewModel.useLivePhoto.collectAsState()
val enableDevelopAnimation by viewModel.enableDevelopAnimation.collectAsState()
val hlgHardwareCompatibilityEnabled by viewModel.hlgHardwareCompatibilityEnabled.collectAsState()
val phantomMode by viewModel.phantomMode.collectAsState()
val topSheetAspectRatios by viewModel.topSheetAspectRatios.collectAsState()
val videoCodec by viewModel.videoCodec.collectAsState()
@@ -1209,7 +1208,6 @@ fun CameraScreen(
},
livePhotoRecorder = viewModel.livePhotoRecorder,
videoLogProfile = state.videoConfig.logProfile,
isHlgInput = if (hlgHardwareCompatibilityEnabled) state.isHLG else false,
isEyeFocusBusy = viewModel.isEyeFocusBusy,
isAutoFocus = state.isAutoFocus,
focusPeakingEnabled = focusPeakingEnabled && !state.isHyperfocalFocusEnabled,
@@ -116,6 +116,7 @@ import com.hinnka.mycamera.camera.IszLensConfig
import com.hinnka.mycamera.camera.IszRawDngMetadataCorrections
import com.hinnka.mycamera.camera.LensType
import com.hinnka.mycamera.camera.MultiFrameConfig
import com.hinnka.mycamera.camera.NoiseReductionLevel
import com.hinnka.mycamera.camera.RawBlackBorderCrop
import com.hinnka.mycamera.camera.VendorCaptureKey
import com.hinnka.mycamera.camera.VendorCaptureSettings
@@ -232,15 +233,6 @@ private val RAW_MIN_SHUTTER_SPEED_OPTIONS = listOf(
1_000_000_000L / 2000,
)
private fun sanitizeSettingsTonemapMode(mode: String): String {
return when (mode) {
"FAST", "HIGH_QUALITY" -> "SYSTEM_DEFAULT"
"REC709" -> "SRGB"
"SYSTEM_DEFAULT", "SRGB" -> mode
else -> "SYSTEM_DEFAULT"
}
}
private fun openExternalUrl(context: Context, url: String) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
@@ -333,7 +325,7 @@ fun SettingsScreen(
val customAspectRatios by viewModel.customAspectRatios.collectAsState()
val availablePhotoAspectRatios by viewModel.availablePhotoAspectRatios.collectAsState()
val autoSaveAfterCapture by viewModel.autoSaveAfterCapture.collectAsState(initial = true)
val nrLevel by viewModel.nrLevel.collectAsState(initial = 5)
val nrLevel by viewModel.nrLevel.collectAsState(initial = NoiseReductionLevel.DEFAULT)
val edgeLevel by viewModel.edgeLevel.collectAsState(initial = 1)
val vendorCaptureSettingsByLens by viewModel.vendorCaptureSettingsByLens.collectAsState()
val customVendorKeySettings by viewModel.customVendorKeySettings.collectAsState()
@@ -356,13 +348,7 @@ fun SettingsScreen(
val photoQuality by viewModel.photoQuality.collectAsState(initial = 95)
val useHeicExport by viewModel.useHeicExport.collectAsState(initial = false)
val useJpeg444Export by viewModel.useJpeg444Export.collectAsState(initial = false)
val tonemapMode by viewModel.tonemapMode.collectAsState()
val settingsTonemapMode = remember(tonemapMode) { sanitizeSettingsTonemapMode(tonemapMode) }
val fixTonemapPreview by viewModel.fixTonemapPreview.collectAsState()
val fixTonemapCapture by viewModel.fixTonemapCapture.collectAsState()
val useP010 by viewModel.useP010.collectAsState()
val useHlg10 by viewModel.useHlg10.collectAsState()
val hlgHardwareCompatibilityEnabled by viewModel.hlgHardwareCompatibilityEnabled.collectAsState()
val useP3ColorSpace by viewModel.useP3ColorSpace.collectAsState()
val ultraHdrGainMapEnabled by viewModel.ultraHdrGainMapEnabled.collectAsState()
val useHdrScreenMode by viewModel.useHdrScreenMode.collectAsState()
@@ -531,16 +517,6 @@ fun SettingsScreen(
}
}
fun applyTonemapMode(mode: String) {
viewModel.setTonemapMode(mode)
}
LaunchedEffect(tonemapMode, settingsTonemapMode) {
if (settingsTonemapMode != tonemapMode) {
applyTonemapMode(settingsTonemapMode)
}
}
LaunchedEffect(windowScreenBrightness) {
windowScreenBrightnessEnabled = windowScreenBrightness != null
windowScreenBrightness?.let {
@@ -1824,12 +1800,11 @@ fun SettingsScreen(
title = stringResource(R.string.settings_nr_level),
description = stringResource(R.string.settings_nr_level_description),
levels = listOf(
5 to stringResource(R.string.settings_nr_level_auto),
0 to stringResource(R.string.settings_nr_level_off),
1 to stringResource(R.string.settings_nr_level_fast),
2 to stringResource(R.string.settings_nr_level_high_quality),
3 to stringResource(R.string.settings_nr_level_zsl),
4 to stringResource(R.string.settings_nr_level_minimal)
NoiseReductionLevel.OFF to stringResource(R.string.settings_nr_level_off),
NoiseReductionLevel.FAST to stringResource(R.string.settings_nr_level_fast),
NoiseReductionLevel.HIGH_QUALITY to stringResource(R.string.settings_nr_level_high_quality),
NoiseReductionLevel.ZERO_SHUTTER_LAG to stringResource(R.string.settings_nr_level_zsl),
NoiseReductionLevel.MINIMAL to stringResource(R.string.settings_nr_level_minimal)
),
currentLevel = nrLevel,
onLevelSelected = { viewModel.setNRLevel(it) }
@@ -1865,46 +1840,6 @@ fun SettingsScreen(
onClick = { baselinePickerTarget = BaselineColorCorrectionTarget.JPG }
)
HorizontalDivider(
color = Color.White.copy(alpha = 0.1f),
modifier = Modifier.padding(vertical = 12.dp)
)
QualityLevelSetting(
title = stringResource(R.string.settings_tonemap_mode),
description = stringResource(R.string.settings_tonemap_mode_description),
levels = listOf(
"SYSTEM_DEFAULT" to stringResource(R.string.settings_tonemap_mode_system_default),
"SRGB" to stringResource(R.string.settings_tonemap_mode_srgb),
),
currentLevel = settingsTonemapMode,
onLevelSelected = ::applyTonemapMode
)
HorizontalDivider(
color = Color.White.copy(alpha = 0.1f),
modifier = Modifier.padding(vertical = 12.dp)
)
SwitchSettingItem(
title = stringResource(R.string.settings_fix_tonemap_preview),
description = stringResource(R.string.settings_fix_tonemap_preview_description),
checked = fixTonemapPreview,
onCheckedChange = { viewModel.setFixTonemapPreview(it) }
)
HorizontalDivider(
color = Color.White.copy(alpha = 0.1f),
modifier = Modifier.padding(vertical = 12.dp)
)
SwitchSettingItem(
title = stringResource(R.string.settings_fix_tonemap_capture),
description = stringResource(R.string.settings_fix_tonemap_capture_description),
checked = fixTonemapCapture,
onCheckedChange = { viewModel.setFixTonemapCapture(it) }
)
if (state.isP010Supported) {
HorizontalDivider(
color = Color.White.copy(alpha = 0.1f),
@@ -1933,36 +1868,6 @@ fun SettingsScreen(
)
}
if (isHdrSettingsSupported && 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) }
)
}
}
}
@@ -3140,8 +3045,7 @@ private fun SettingsCategoryOverview(
stringResource(R.string.settings_multi_frame_denoise_frame_count),
stringResource(R.string.settings_nr_level),
stringResource(R.string.settings_edge_level),
stringResource(R.string.settings_baseline_jpg_title),
stringResource(R.string.settings_tonemap_mode)
stringResource(R.string.settings_baseline_jpg_title)
).joinToString(" · "),
onClick = { onPageSelected(SettingsPage.PHOTO_MODE) }
)
@@ -129,7 +129,6 @@ class VideoRecorder(
private var requestedEnhancedStabilizationStrength = DEFAULT_VIDEO_STABILIZATION_STRENGTH
private var requestedEnhancedStabilizationLookahead = DEFAULT_VIDEO_STABILIZATION_LOOKAHEAD
private var cameraInputStarted = false
private var hlgCameraInput = false
private var requestedCameraTimestampSource = CameraCharacteristics.SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN
private var cameraTimestampToBoottimeOffsetNs = UNSET_TIMESTAMP
private var timelineOriginUs = UNSET_TIMESTAMP
@@ -189,7 +188,6 @@ class VideoRecorder(
codecMime: String,
colorConfig: VideoEncoderColorRequest = VideoEncoderColorRequest(),
colorLayers: List<VideoColorEffectLayer> = emptyList(),
hlgInput: Boolean = false,
cameraTimestampSource: Int = CameraCharacteristics.SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN,
orientationHintDegrees: Int = 0,
flipEncodedFrame: Boolean = false,
@@ -214,7 +212,6 @@ class VideoRecorder(
requestedCodecMime = codecMime
requestedColorConfig = colorConfig
requestedColorLayers = colorLayers.toList()
hlgCameraInput = hlgInput
requestedCameraTimestampSource = cameraTimestampSource
requestedFlipEncodedFrame = flipEncodedFrame
requestedEnhancedStabilization = enhancedStabilization
@@ -359,7 +356,6 @@ class VideoRecorder(
encoderOutputSize = requestedSize,
colorLayers = requestedColorLayers,
videoLogProfile = requestedColorConfig.logProfile,
hlgInput = hlgCameraInput,
mirrorHorizontally =
requestedFlipEncodedFrame && requestedOrientationHintDegrees % 180 == 0,
mirrorVertically =
@@ -134,18 +134,6 @@ data class MultipleExposureSessionState(
get() = capturedCount >= 2 && !isProcessing
}
private const val TONEMAP_MODE_SYSTEM_DEFAULT = "SYSTEM_DEFAULT"
private const val TONEMAP_MODE_SRGB = "SRGB"
private fun sanitizeViewModelTonemapMode(mode: String): String {
return when (mode) {
"FAST", "HIGH_QUALITY" -> TONEMAP_MODE_SYSTEM_DEFAULT
"REC709" -> TONEMAP_MODE_SRGB
TONEMAP_MODE_SYSTEM_DEFAULT, TONEMAP_MODE_SRGB -> mode
else -> TONEMAP_MODE_SYSTEM_DEFAULT
}
}
private fun resolvePreviewBaselineTarget(prefs: UserPreferences): BaselineColorCorrectionTarget? {
return if (prefs.useRaw) null else BaselineColorCorrectionTarget.JPG
}
@@ -1055,14 +1043,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
return base.normalized()
}
private fun effectiveCameraTonemapMode(prefs: UserPreferences): String {
return sanitizeViewModelTonemapMode(prefs.tonemapMode)
}
private fun metadataTonemapMode(prefs: UserPreferences?): String {
return sanitizeViewModelTonemapMode(prefs?.tonemapMode ?: TONEMAP_MODE_SYSTEM_DEFAULT)
}
fun savePreset(preset: com.hinnka.mycamera.model.CameraPreset) {
viewModelScope.launch {
val resolvedPreset = presetMutationMutex.withLock {
@@ -1361,7 +1341,7 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
.stateIn(viewModelScope, SharingStarted.Eagerly, AspectRatio.entries)
val nrLevel: StateFlow<Int> = userPreferencesRepository.userPreferences
.map { it.nrLevel }
.stateIn(viewModelScope, SharingStarted.Eagerly, 5)
.stateIn(viewModelScope, SharingStarted.Eagerly, NoiseReductionLevel.DEFAULT)
val useRaw: StateFlow<Boolean> = userPreferencesRepository.userPreferences
.map { it.useRaw }
.stateIn(viewModelScope, SharingStarted.Eagerly, false)
@@ -1675,15 +1655,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
val droMode: StateFlow<String> = userPreferencesRepository.userPreferences
.map { it.droMode }
.stateIn(viewModelScope, SharingStarted.Eagerly, "OFF")
val tonemapMode: StateFlow<String> = userPreferencesRepository.userPreferences
.map { it.tonemapMode }
.stateIn(viewModelScope, SharingStarted.Eagerly, "SYSTEM_DEFAULT")
val fixTonemapPreview: StateFlow<Boolean> = userPreferencesRepository.userPreferences
.map { it.fixTonemapPreview }
.stateIn(viewModelScope, SharingStarted.Eagerly, false)
val fixTonemapCapture: StateFlow<Boolean> = userPreferencesRepository.userPreferences
.map { it.fixTonemapCapture }
.stateIn(viewModelScope, SharingStarted.Eagerly, false)
val applyUltraHDR: StateFlow<Boolean> = userPreferencesRepository.userPreferences
.map { it.applyUltraHDR }
.stateIn(viewModelScope, SharingStarted.Eagerly, false)
@@ -1712,12 +1683,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
val useP010: StateFlow<Boolean> = userPreferencesRepository.userPreferences
.map { it.useP010 }
.stateIn(viewModelScope, SharingStarted.Eagerly, false)
val useHlg10: StateFlow<Boolean> = userPreferencesRepository.userPreferences
.map { it.useHlg10 }
.stateIn(viewModelScope, SharingStarted.Eagerly, false)
val hlgHardwareCompatibilityEnabled: StateFlow<Boolean> = userPreferencesRepository.userPreferences
.map { it.hlgHardwareCompatibilityEnabled }
.stateIn(viewModelScope, SharingStarted.Eagerly, false)
val useP3ColorSpace: StateFlow<Boolean> = userPreferencesRepository.userPreferences
.map { it.useP3ColorSpace }
.stateIn(viewModelScope, SharingStarted.Eagerly, false)
@@ -2185,12 +2150,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
if (currentCameraState.rawMinShutterSpeedNs != it.rawMinShutterSpeedNs) {
cameraController.setRawMinShutterSpeedNs(it.rawMinShutterSpeedNs)
}
val effectiveTonemapMode = effectiveCameraTonemapMode(it)
if (currentCameraState.tonemapMode != effectiveTonemapMode) {
cameraController.setTonemapMode(effectiveTonemapMode)
}
cameraController.setFixTonemapPreview(it.fixTonemapPreview)
cameraController.setFixTonemapCapture(it.fixTonemapCapture)
if (cameraController.state.value.meteringMode != it.meteringMode) {
cameraController.setMeteringMode(it.meteringMode)
}
@@ -2229,8 +2188,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
cameraController.setApplyUltraHDR(it.applyUltraHDR)
// 同步 P010 设置到相机控制器
cameraController.setUseP010(it.useP010)
// 同步 HLG10 设置到相机控制器
cameraController.setUseHlg10(it.useHlg10)
// 同步 P3 色域设置到相机控制器
cameraController.setUseP3ColorSpace(it.useP3ColorSpace)
}
@@ -2399,10 +2356,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
cameraController.setUseLivePhoto(
prefs.useLivePhoto && !prefs.useJpgMax && prefs.captureMode == CaptureMode.PHOTO
)
cameraController.setTonemapMode(effectiveCameraTonemapMode(prefs))
cameraController.setFixTonemapPreview(prefs.fixTonemapPreview)
cameraController.setFixTonemapCapture(prefs.fixTonemapCapture)
// 应用保存的虚拟光圈
applyDefaultVirtualAperture(prefs.defaultVirtualAperture)
} else {
@@ -2420,7 +2373,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
state.collect { currentState ->
glSurfaceView?.let { view ->
view.setVideoLogProfile(currentState.videoConfig.logProfile)
view.setIsHlgInput(shouldTreatPreviewAsHlgInput(currentState))
currentState.focusPoint?.let { fp ->
view.setFocusPoint(android.graphics.PointF(fp.first, fp.second))
}
@@ -2970,7 +2922,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
view.setParams(currentRecipeParams.value)
view.setColorRecipeEnabled(!currentRecipeParams.value.isDefault())
view.setVideoLogProfile(currentState.videoConfig.logProfile)
view.setIsHlgInput(shouldTreatPreviewAsHlgInput(currentState))
view.restoreRenderStateAfterResume()
}
}
@@ -3026,7 +2977,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
return MediaMetadata(
lutId = lutIdToSave,
tonemapMode = metadataTonemapMode(userPrefs),
frameId = frameIdToSave,
colorRecipeParams = getMergedRecipeParams(),
baselineTarget = baselineMetadata?.first,
@@ -3297,8 +3247,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
captureInfo = captureInfo,
captureMode = "multiple_exposure",
multipleExposureFrameCount = multipleExposureState.targetCount
).copy(
tonemapMode = "SYSTEM_DEFAULT"
).also { multipleExposureMetadata = it }
val frameFile = GalleryManager.saveMultipleExposureFrame(
@@ -4148,26 +4096,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
}
}
private fun shouldUseHlgCapture(): Boolean {
val state = state.value
val baseCondition = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU &&
state.isP010Supported &&
state.isHlg10Supported &&
!state.useRaw
if (!baseCondition) return false
// 用户主动开启 HLG10 录制
val userHlg = state.useP010 && state.useHlg10
// Log LUT 需要 HLG 采集获取线性信号(替代 tonemap gamma,提升兼容性)
val logLutHlg = state.lutEnabled && state.isLogLutActive
// Video Log 同样需要 HLG 采集获取线性信号
val videoLogHlg = state.captureMode == CaptureMode.VIDEO && state.videoConfig.logProfile.isEnabled
return userHlg || logLutHlg || videoLogHlg
}
private fun shouldTreatPreviewAsHlgInput(currentState: CameraState): Boolean {
return hlgHardwareCompatibilityEnabled.value && currentState.isHLG
}
/**
* 切换到下一个滤镜
*/
@@ -4293,21 +4221,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
}
}
fun setUseHlg10(enabled: Boolean) {
cameraController.setUseHlg10(enabled)
viewModelScope.launch {
userPreferencesRepository.saveUseHlg10(enabled)
}
reopenCamera()
}
fun setHlgHardwareCompatibilityEnabled(enabled: Boolean) {
viewModelScope.launch {
userPreferencesRepository.saveHlgHardwareCompatibilityEnabled(enabled)
}
glSurfaceView?.setIsHlgInput(shouldTreatPreviewAsHlgInput(state.value))
}
fun setUseP3ColorSpace(enabled: Boolean) {
cameraController.setUseP3ColorSpace(enabled)
viewModelScope.launch {
@@ -4388,7 +4301,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
val params = getMergedRecipeParams(contentRepository.lutManager.loadColorRecipeParams(currentLutId.value))
contentRepository.imageProcessor.applyLut(
bitmap = bitmap,
isHlgInput = shouldTreatPreviewAsHlgInput(state.value),
lutConfig = lut,
colorRecipeParams = params
)
@@ -5549,7 +5461,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
// 创建统一的 PhotoMetadata,包含编辑配置和拍摄信息
val metadata = MediaMetadata(
lutId = lutIdToSave,
tonemapMode = metadataTonemapMode(userPrefs),
frameId = frameIdToSave,
colorRecipeParams = getMergedRecipeParams(),
baselineTarget = baselineMetadata?.first,
@@ -5616,7 +5527,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
droMode = droModeString,
isMirrored = shouldMirror,
colorSpace = captureInfo.colorSpace,
dynamicRangeProfile = state.value.currentDynamicRangeProfile,
computationalAperture = aperture,
focusPointX = state.value.focusPoint?.first,
focusPointY = state.value.focusPoint?.second,
@@ -5791,7 +5701,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
droMode = droMode.value,
isMirrored = shouldMirror,
colorSpace = captureInfo.colorSpace,
dynamicRangeProfile = currentState.currentDynamicRangeProfile,
computationalAperture = computationalAperture,
focusPointX = currentState.focusPoint?.first,
focusPointY = currentState.focusPoint?.second,
@@ -6003,7 +5912,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
// 创建统一的 PhotoMetadata,包含编辑配置和拍摄信息
val metadata = MediaMetadata(
lutId = lutIdToSave,
tonemapMode = metadataTonemapMode(userPrefs),
frameId = frameIdToSave,
colorRecipeParams = getMergedRecipeParams(),
baselineTarget = baselineMetadata?.first,
@@ -6070,7 +5978,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
droMode = droModeString,
isMirrored = shouldMirror,
colorSpace = captureInfo.colorSpace,
dynamicRangeProfile = state.value.currentDynamicRangeProfile,
computationalAperture = aperture,
focusPointX = state.value.focusPoint?.first,
focusPointY = state.value.focusPoint?.second,
@@ -6438,7 +6345,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
// 创建统一的 PhotoMetadata,包含编辑配置和拍摄信息
val metadata = MediaMetadata(
lutId = lutIdToSave,
tonemapMode = metadataTonemapMode(userPrefs),
frameId = frameIdToSave,
colorRecipeParams = getMergedRecipeParams(),
baselineTarget = baselineMetadata?.first,
@@ -6500,7 +6406,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
aperture = captureInfo.formatAperture(),
isMirrored = shouldMirror,
colorSpace = captureInfo.colorSpace,
dynamicRangeProfile = state.value.currentDynamicRangeProfile,
computationalAperture = aperture,
focusPointX = state.value.focusPoint?.first,
focusPointY = state.value.focusPoint?.second,
@@ -6719,27 +6624,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
}
}
/**
* 设置色调映射模式
*/
fun setTonemapMode(mode: String) {
viewModelScope.launch {
userPreferencesRepository.saveTonemapMode(sanitizeViewModelTonemapMode(mode))
}
}
fun setFixTonemapPreview(enabled: Boolean) {
viewModelScope.launch {
userPreferencesRepository.saveFixTonemapPreview(enabled)
}
}
fun setFixTonemapCapture(enabled: Boolean) {
viewModelScope.launch {
userPreferencesRepository.saveFixTonemapCapture(enabled)
}
}
fun togglePhantomMode() {
val newMode = !phantomMode.value
viewModelScope.launch {
@@ -4416,7 +4416,6 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
if (photo.isVideo) return false
val metadata = photo.metadata ?: photo.relatedPhoto?.metadata ?: return false
return metadata.hasEmbeddedGainmap ||
metadata.dynamicRangeProfile == "HLG10" ||
GalleryManager.getDngFile(getApplication(), photo.id).exists() ||
GalleryManager.getHighQualityPhotoFile(getApplication(), photo.id).exists() ||
GalleryManager.getPhotoFile(getApplication(), photo.id).exists()
+2 -15
View File
@@ -258,8 +258,8 @@
<string name="settings_frame_style">邊框樣式</string>
<string name="settings_frame_description">為拍攝的相片添加裝飾性邊框和水印</string>
<string name="settings_section_software_processing">細節微調</string>
<string name="settings_baseline_jpg_title">JPG 基準色彩校正</string>
<string name="settings_baseline_jpg_description">選擇普通 JPG 創意 LUT 之前先應用的基準 LUT 與基準配方。</string>
<string name="settings_baseline_jpg_title">基準色彩校正</string>
<string name="settings_baseline_jpg_description">選擇創意 LUT 之前先應用的基準 LUT 與基準配方。</string>
<string name="settings_baseline_raw_title">基準色彩校正</string>
<string name="raw_dcp_title">DCP</string>
<string name="raw_dcp_import">匯入 DCP</string>
@@ -324,7 +324,6 @@
<string name="settings_nr_level_fast">快速</string>
<string name="settings_nr_level_high_quality">高品質</string>
<string name="settings_nr_level_zsl">零延遲</string>
<string name="settings_nr_level_auto">自動</string>
<string name="settings_edge_level">銳化等級</string>
<string name="settings_edge_level_description">調整系統硬體邊緣增強(銳化)模式。</string>
<string name="settings_add_isz_lens">新增 ISZ/DCG 鏡頭</string>
@@ -405,14 +404,6 @@
<string name="settings_use_heic_export_description">在支援的設備上優先使用原生 HEIC 匯出。</string>
<string name="settings_use_jpeg_444_export">JPEG 4:4:4 匯出</string>
<string name="settings_use_jpeg_444_export_description">使用 4:4:4 色度取樣匯出 JPEG,保留最完整的色彩細節。檔案較大,且會關閉 HEIC 匯出;有增益圖時會保留 Ultra HDR。</string>
<string name="settings_tonemap_mode">色調映射</string>
<string name="settings_tonemap_mode_description">調整硬體色調映射(對比度/伽馬)模式</string>
<string name="settings_tonemap_mode_system_default">系統預設</string>
<string name="settings_tonemap_mode_srgb">sRGB</string>
<string name="settings_fix_tonemap_preview">修復色調映射預覽異常</string>
<string name="settings_fix_tonemap_preview_description">部分設備預覽已自帶 sRGB Gamma。開啟后僅在預覽中先轉為線性再應用自訂色調曲線,拍攝輸出不變。</string>
<string name="settings_fix_tonemap_capture">修復色調映射拍攝異常</string>
<string name="settings_fix_tonemap_capture_description">部分設備拍攝輸出已自帶 sRGB Gamma。開啟后會在拍攝請求中先轉為線性再應用自訂色調曲線。</string>
<!-- LUT -->
<string name="filter_intensity">濾鏡強度</string>
@@ -815,10 +806,6 @@
<string name="settings_dro_dr400">DR400</string>
<string name="settings_use_p010">P010 (10位 YUV)</string>
<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">部分設備開啟 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_ultra_hdr_gain_map">Ultra HDR</string>
+2 -15
View File
@@ -198,8 +198,8 @@
<string name="settings_frame_style">สไตล์กรอบ</string>
<string name="settings_frame_description">เพิ่มกรอบตกแต่งและลายน้ำให้กับรูปภาพ</string>
<string name="settings_section_software_processing">การปรับจูน</string>
<string name="settings_baseline_jpg_title">การแก้ไขสีพื้นฐาน JPG</string>
<string name="settings_baseline_jpg_description">ใช้ LUT พื้นฐานและสูตรพื้นฐานก่อนเลือก LUT ครีเอทีฟโฆษณา JPG ปกติ</string>
<string name="settings_baseline_jpg_title">การแก้ไขสีพื้นฐาน</string>
<string name="settings_baseline_jpg_description">ใช้ LUT พื้นฐานและสูตรพื้นฐานก่อนเลือก LUT ครีเอทีฟ</string>
<string name="settings_baseline_raw_title">การแก้ไขสีพื้นฐาน</string>
<string name="raw_dcp_title">DCP</string>
<string name="raw_dcp_import">นำเข้า DCP</string>
@@ -243,7 +243,6 @@
<string name="settings_nr_level_fast">เร็ว</string>
<string name="settings_nr_level_high_quality">HQ</string>
<string name="settings_nr_level_zsl">ZSL</string>
<string name="settings_nr_level_auto">อัตโนมัติ</string>
<string name="settings_edge_level">ระดับความคมชัด</string>
<string name="settings_edge_level_description">ปรับโหมดการเร่งความคมชัดที่ขอบด้วยฮาร์ดแวร์</string>
<string name="settings_sharpening">เพิ่มความคมชัด</string>
@@ -255,14 +254,6 @@
<string name="settings_detail_enhancement_description">ปรับแต่งพารามิเตอร์ของความคมชัดและการลดสัญญาณรบกวนอย่างละเอียด</string>
<string name="settings_photo_quality">คุณภาพรูปภาพ</string>
<string name="settings_photo_quality_description">เลือกคุณภาพการบีบอัด JPEG สำหรับรูปภาพ (คุณภาพสูง = ภาพชัดขึ้น แต่ไฟล์มีขนาดใหญ่ขึ้น)</string>
<string name="settings_tonemap_mode">การทำแผนที่โทน</string>
<string name="settings_tonemap_mode_description">ปรับโหมดการจับคู่โทนสีฮาร์ดแวร์ (คอนทราสต์/แกมมา)</string>
<string name="settings_tonemap_mode_system_default">ค่าเริ่มต้นของระบบ</string>
<string name="settings_tonemap_mode_srgb">sRGB</string>
<string name="settings_fix_tonemap_preview">แก้ไขข้อยกเว้นการแสดงตัวอย่างการแมปโทน</string>
<string name="settings_fix_tonemap_preview_description">ตัวอย่างอุปกรณ์บางรุ่นมาพร้อมกับ sRGB Gamma อยู่แล้ว หลังจากเปิดใช้งาน กล้องจะแปลงเป็นเส้นตรงในหน้าตัวอย่างเท่านั้น จากนั้นจึงใช้ Tone Curve แบบกำหนดเอง และเอาต์พุตการถ่ายภาพยังคงไม่เปลี่ยนแปลง</string>
<string name="settings_fix_tonemap_capture">แก้ไขข้อยกเว้นการถ่ายภาพการแมปโทน</string>
<string name="settings_fix_tonemap_capture_description">ภาพถ่ายจากอุปกรณ์บางรุ่นมี sRGB Gamma อยู่แล้ว หลังจากเปิดใช้งาน กล้องจะแปลงอินพุตการถ่ายภาพเป็นเส้นตรงก่อนใช้ Tone Curve แบบกำหนดเอง</string>
<!-- LUT -->
<string name="filter_intensity">ความเข้ม LUT</string>
@@ -633,10 +624,6 @@
<string name="settings_dro_dr400">DR400</string>
<string name="settings_use_p010">P010 (YUV 10 บิต)</string>
<string name="settings_use_p010_description">เปิดใช้งานเอาต์พุต YUV 10 บิตเพื่อความแม่นยำของข้อมูลภาพที่ดีขึ้น มีผลกับอุปกรณ์ที่รองรับเมื่อปิดใช้งาน 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">ภาพอาจมืดหรือผิดปกติหลังจากเปิด 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_ultra_hdr_gain_map">Ultra HDR</string>
+2 -15
View File
@@ -258,8 +258,8 @@
<string name="settings_frame_style">边框样式</string>
<string name="settings_frame_description">为拍摄的照片添加装饰性边框和水印</string>
<string name="settings_section_software_processing">细节微调</string>
<string name="settings_baseline_jpg_title">JPG 基准色彩校正</string>
<string name="settings_baseline_jpg_description">选择普通 JPG 创意 LUT 之前先应用的基准 LUT 与基准配方。</string>
<string name="settings_baseline_jpg_title">基准色彩校正</string>
<string name="settings_baseline_jpg_description">选择创意 LUT 之前先应用的基准 LUT 与基准配方。</string>
<string name="settings_baseline_raw_title">基准色彩校正</string>
<string name="raw_dcp_title">DCP</string>
<string name="raw_dcp_import">导入 DCP</string>
@@ -342,7 +342,6 @@
<string name="settings_nr_level_fast">快速</string>
<string name="settings_nr_level_high_quality">高质量</string>
<string name="settings_nr_level_zsl">零延迟</string>
<string name="settings_nr_level_auto">自动</string>
<string name="settings_edge_level">锐化等级</string>
<string name="settings_edge_level_description">调整系统硬件边缘增强(锐化)模式。</string>
<string name="settings_add_isz_lens">新增 ISZ/DCG 镜头</string>
@@ -423,14 +422,6 @@
<string name="settings_use_heic_export_description">在支持的设备上优先使用原生 HEIC 导出。</string>
<string name="settings_use_jpeg_444_export">JPEG 4:4:4 导出</string>
<string name="settings_use_jpeg_444_export_description">使用 4:4:4 色度采样导出 JPEG,保留最完整的色彩细节。文件体积更大,且会关闭 HEIC 导出;有增益图时会保留 Ultra HDR。</string>
<string name="settings_tonemap_mode">色调映射</string>
<string name="settings_tonemap_mode_description">调整硬件色调映射(对比度/伽马)模式</string>
<string name="settings_tonemap_mode_system_default">系统默认</string>
<string name="settings_tonemap_mode_srgb">sRGB</string>
<string name="settings_fix_tonemap_preview">修复色调映射预览异常</string>
<string name="settings_fix_tonemap_preview_description">部分设备预览已自带 sRGB Gamma。开启后仅在预览中先转为线性再应用自定义色调曲线,拍摄输出不变。</string>
<string name="settings_fix_tonemap_capture">修复色调映射拍摄异常</string>
<string name="settings_fix_tonemap_capture_description">部分设备拍摄输出已自带 sRGB Gamma。开启后会在拍摄请求中先转为线性再应用自定义色调曲线。</string>
<!-- LUT -->
<string name="filter_intensity">滤镜强度</string>
@@ -833,10 +824,6 @@
<string name="settings_dro_dr400">DR400</string>
<string name="settings_use_p010">P010 (10位 YUV)</string>
<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">部分设备开启 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_ultra_hdr_gain_map">Ultra HDR</string>
+2 -15
View File
@@ -258,8 +258,8 @@
<string name="settings_frame_style">邊框樣式</string>
<string name="settings_frame_description">為拍攝的相片添加裝飾性邊框和水印</string>
<string name="settings_section_software_processing">細節微調</string>
<string name="settings_baseline_jpg_title">JPG 基準色彩校正</string>
<string name="settings_baseline_jpg_description">選擇普通 JPG 創意 LUT 之前先應用的基準 LUT 與基準配方。</string>
<string name="settings_baseline_jpg_title">基準色彩校正</string>
<string name="settings_baseline_jpg_description">選擇創意 LUT 之前先應用的基準 LUT 與基準配方。</string>
<string name="settings_baseline_raw_title">基準色彩校正</string>
<string name="raw_dcp_title">DCP</string>
<string name="raw_dcp_import">匯入 DCP</string>
@@ -324,7 +324,6 @@
<string name="settings_nr_level_fast">快速</string>
<string name="settings_nr_level_high_quality">高品質</string>
<string name="settings_nr_level_zsl">零延遲</string>
<string name="settings_nr_level_auto">自動</string>
<string name="settings_edge_level">銳化等級</string>
<string name="settings_edge_level_description">調整系統硬體邊緣增強(銳化)模式。</string>
<string name="settings_add_isz_lens">新增 ISZ/DCG 鏡頭</string>
@@ -405,14 +404,6 @@
<string name="settings_use_heic_export_description">在支援的設備上優先使用原生 HEIC 匯出。</string>
<string name="settings_use_jpeg_444_export">JPEG 4:4:4 匯出</string>
<string name="settings_use_jpeg_444_export_description">使用 4:4:4 色度取樣匯出 JPEG,保留最完整的色彩細節。檔案較大,且會關閉 HEIC 匯出;有增益圖時會保留 Ultra HDR。</string>
<string name="settings_tonemap_mode">色調映射</string>
<string name="settings_tonemap_mode_description">調整硬體色調映射(對比度/伽馬)模式</string>
<string name="settings_tonemap_mode_system_default">系統預設</string>
<string name="settings_tonemap_mode_srgb">sRGB</string>
<string name="settings_fix_tonemap_preview">修復色調映射預覽異常</string>
<string name="settings_fix_tonemap_preview_description">部分設備預覽已自帶 sRGB Gamma。開啟后僅在預覽中先轉為線性再應用自訂色調曲線,拍攝輸出不變。</string>
<string name="settings_fix_tonemap_capture">修復色調映射拍攝異常</string>
<string name="settings_fix_tonemap_capture_description">部分設備拍攝輸出已自帶 sRGB Gamma。開啟后會在拍攝請求中先轉為線性再應用自訂色調曲線。</string>
<!-- LUT -->
<string name="filter_intensity">濾鏡強度</string>
@@ -815,10 +806,6 @@
<string name="settings_dro_dr400">DR400</string>
<string name="settings_use_p010">P010 (10位 YUV)</string>
<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">部分設備開啟 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_ultra_hdr_gain_map">Ultra HDR</string>
+2 -15
View File
@@ -258,8 +258,8 @@
<string name="settings_frame_style">邊框樣式</string>
<string name="settings_frame_description">為拍攝的相片添加裝飾性邊框和水印</string>
<string name="settings_section_software_processing">細節微調</string>
<string name="settings_baseline_jpg_title">JPG 基準色彩校正</string>
<string name="settings_baseline_jpg_description">選擇普通 JPG 創意 LUT 之前先應用的基準 LUT 與基準配方。</string>
<string name="settings_baseline_jpg_title">基準色彩校正</string>
<string name="settings_baseline_jpg_description">選擇創意 LUT 之前先應用的基準 LUT 與基準配方。</string>
<string name="settings_baseline_raw_title">基準色彩校正</string>
<string name="raw_dcp_title">DCP</string>
<string name="raw_dcp_import">匯入 DCP</string>
@@ -324,7 +324,6 @@
<string name="settings_nr_level_fast">快速</string>
<string name="settings_nr_level_high_quality">高品質</string>
<string name="settings_nr_level_zsl">零延遲</string>
<string name="settings_nr_level_auto">自動</string>
<string name="settings_edge_level">銳化等級</string>
<string name="settings_edge_level_description">調整系統硬體邊緣增強(銳化)模式。</string>
<string name="settings_add_isz_lens">新增 ISZ/DCG 鏡頭</string>
@@ -405,14 +404,6 @@
<string name="settings_use_heic_export_description">在支援的設備上優先使用原生 HEIC 匯出。</string>
<string name="settings_use_jpeg_444_export">JPEG 4:4:4 匯出</string>
<string name="settings_use_jpeg_444_export_description">使用 4:4:4 色度取樣匯出 JPEG,保留最完整的色彩細節。檔案較大,且會關閉 HEIC 匯出;有增益圖時會保留 Ultra HDR。</string>
<string name="settings_tonemap_mode">色調映射</string>
<string name="settings_tonemap_mode_description">調整硬體色調映射(對比度/伽馬)模式</string>
<string name="settings_tonemap_mode_system_default">系統預設</string>
<string name="settings_tonemap_mode_srgb">sRGB</string>
<string name="settings_fix_tonemap_preview">修復色調映射預覽異常</string>
<string name="settings_fix_tonemap_preview_description">部分設備預覽已自帶 sRGB Gamma。開啟后僅在預覽中先轉為線性再應用自訂色調曲線,拍攝輸出不變。</string>
<string name="settings_fix_tonemap_capture">修復色調映射拍攝異常</string>
<string name="settings_fix_tonemap_capture_description">部分設備拍攝輸出已自帶 sRGB Gamma。開啟后會在拍攝請求中先轉為線性再應用自訂色調曲線。</string>
<!-- LUT -->
<string name="filter_intensity">濾鏡強度</string>
@@ -815,10 +806,6 @@
<string name="settings_dro_dr400">DR400</string>
<string name="settings_use_p010">P010 (10位 YUV)</string>
<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">部分設備開啟 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_ultra_hdr_gain_map">Ultra HDR</string>
+2 -15
View File
@@ -262,8 +262,8 @@
<string name="settings_frame_style">Frame Style</string>
<string name="settings_frame_description">Add decorative frame and watermark to photos</string>
<string name="settings_section_software_processing">Fine Tuning</string>
<string name="settings_baseline_jpg_title">JPG Baseline Color Correction</string>
<string name="settings_baseline_jpg_description">Choose the baseline LUT and recipe applied before the regular JPG creative LUT.</string>
<string name="settings_baseline_jpg_title">Baseline Color Correction</string>
<string name="settings_baseline_jpg_description">Choose the baseline LUT and recipe applied before the creative LUT.</string>
<string name="settings_baseline_raw_title">Baseline Color Correction</string>
<string name="raw_dcp_title">DCP</string>
<string name="raw_dcp_import">Import DCP</string>
@@ -346,7 +346,6 @@
<string name="settings_nr_level_fast">Fast</string>
<string name="settings_nr_level_high_quality">HQ</string>
<string name="settings_nr_level_zsl">ZSL</string>
<string name="settings_nr_level_auto">Auto</string>
<string name="settings_edge_level">Sharpening Level</string>
<string name="settings_edge_level_description">Adjust the hardware edge enhancement (sharpening) mode.</string>
<string name="settings_add_isz_lens">Add ISZ/DCG Lens</string>
@@ -427,14 +426,6 @@
<string name="settings_use_heic_export_description">Prefer native HEIC export on supported devices.</string>
<string name="settings_use_jpeg_444_export">JPEG 4:4:4 Export</string>
<string name="settings_use_jpeg_444_export_description">Export JPEGs with 4:4:4 chroma sampling for maximum color detail. Files are larger, HEIC export is disabled, and Ultra HDR gain maps are preserved when available.</string>
<string name="settings_tonemap_mode">Tone Mapping</string>
<string name="settings_tonemap_mode_description">Adjust the hardware tone mapping (contrast/gamma) mode</string>
<string name="settings_tonemap_mode_system_default">System Default</string>
<string name="settings_tonemap_mode_srgb">sRGB</string>
<string name="settings_fix_tonemap_preview">Fix tone mapping preview</string>
<string name="settings_fix_tonemap_preview_description">Linearize preview input before applying custom tone curves on devices whose preview already includes sRGB gamma. Capture output is unchanged.</string>
<string name="settings_fix_tonemap_capture">Fix tone mapping capture</string>
<string name="settings_fix_tonemap_capture_description">Linearize capture input before applying custom tone curves on devices whose captured images already include sRGB gamma.</string>
<string name="settings_background">Background</string>
<string name="settings_background_description">Change the app background image</string>
<string name="settings_custom_background">Custom...</string>
@@ -948,10 +939,6 @@
<string name="settings_cfa_correction_8x8_bggr">8x8 BGGR</string>
<string name="settings_use_p010">P010 (10-bit YUV)</string>
<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 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_ultra_hdr_gain_map">Ultra HDR</string>
@@ -9,7 +9,6 @@ class PreviewColorShaderTest {
fun jpegInputToneCurveRunsBeforeRecipeAndPhotonLut() {
val variant = PreviewColorShaderVariant(
textureSource = PreviewColorTextureSource.TEXTURE_2D,
includeHlgInput = false,
includeExtendedLutCurves = true,
includeOklchDensity = true,
includeLchMixer = true,
@@ -30,7 +29,6 @@ class PreviewColorShaderTest {
fun normalPreviewDoesNotContainJpegInputToneCurve() {
val variant = PreviewColorShaderVariant(
textureSource = PreviewColorTextureSource.EXTERNAL_OES,
includeHlgInput = false,
includeExtendedLutCurves = true,
includeOklchDensity = true,
includeLchMixer = true,
@@ -46,7 +44,6 @@ class PreviewColorShaderTest {
fun capturedSpatialEffectsMatchStaticImageOrder() {
val variant = PreviewColorShaderVariant(
textureSource = PreviewColorTextureSource.TEXTURE_2D,
includeHlgInput = false,
includeExtendedLutCurves = true,
includeOklchDensity = true,
includeLchMixer = true,
@@ -70,7 +67,6 @@ class PreviewColorShaderTest {
fun customLogFilmGrainRunsBeforeLogEncoding() {
val variant = PreviewColorShaderVariant(
textureSource = PreviewColorTextureSource.TEXTURE_2D,
includeHlgInput = false,
includeExtendedLutCurves = true,
includeOklchDensity = false,
includeLchMixer = false,
@@ -90,7 +86,6 @@ class PreviewColorShaderTest {
fun displayPipelineDoesNotInlineFilmGrain() {
val variant = PreviewColorShaderVariant(
textureSource = PreviewColorTextureSource.TEXTURE_2D,
includeHlgInput = false,
includeExtendedLutCurves = false,
includeOklchDensity = false,
includeLchMixer = false,