feat: hncs (2)

This commit is contained in:
zhoubinjia committed 2026-07-24 11:51:45 +08:00
1 parent f82d87d733
commit 07b5f215aa
29 files changed
+455 -215

No files matched your search

@@ -497,9 +497,7 @@ class UserPreferencesRepository(private val context: Context) {
rawDcpId = preferences[RAW_DCP_ID_KEY],
rawDcpIdsByLens = parseNullableStringMap(preferences[RAW_DCP_IDS_BY_LENS_KEY]),
rawHncsProfileId = preferences[RAW_HNCS_PROFILE_ID_KEY],
rawHncsRenderIntent = HncsRenderIntent.fromPersistedValue(
preferences[RAW_HNCS_RENDER_INTENT_KEY]
),
rawHncsRenderIntent = HncsRenderIntent.Standard,
rawRenderingEngine = RawRenderingEngine.fromPersistedName(preferences[RAW_COLOR_ENGINE_KEY]),
rawToneMappingParameters = RawToneMappingParameters(
agxBlackRelativeExposure = preferences[RAW_AGX_BLACK_RELATIVE_EXPOSURE_KEY]
@@ -91,9 +91,7 @@ data class CameraPreset(
.copy(
rawDcpIdsByLens = normalizeRawDcpIdsByLens(rawDcpIdsByLens),
rawHncsProfileId = rawHncsProfileId?.takeIf(String::isNotBlank),
rawHncsRenderIntent = HncsRenderIntent.fromPersistedValue(
rawHncsRenderIntent
).assetValue,
rawHncsRenderIntent = HncsRenderIntent.Standard.assetValue,
rawGooglePixelToneMap = rawGooglePixelToneMap && !rawOppoMasterToneMap && !rawPhotonPgtmToneMap,
rawOppoMasterToneMap = rawOppoMasterToneMap,
rawPhotonPgtmToneMap = rawPhotonPgtmToneMap && !rawOppoMasterToneMap
@@ -125,6 +123,23 @@ data class CameraPreset(
rawDROMode = "DR100",
isBuiltIn = true
),
CameraPreset(
id = "builtin_hasselblad_natural",
name = "builtin_hasselblad_natural",
lutId = null,
colorRecipe = ColorRecipeParams.DEFAULT.copy(
masterCurvePoints = floatArrayOf(
0f, 0f,
0.2784f, 0.2392f,
0.7216f, 0.7569f,
1f, 1f
)
),
effects = EffectParams.DEFAULT,
useRaw = true,
rawRenderingEngine = RawRenderingEngine.HncsCcm.name,
isBuiltIn = true
),
CameraPreset(
id = "builtin_portrait",
name = "builtin_portrait",
@@ -65,9 +65,7 @@ internal object CameraPresetJsonCodec {
rawDcpId = obj.stringOrNull("rawDcpId"),
rawDcpIdsByLens = parseRawDcpIdsByLens(obj.get("rawDcpIdsByLens")),
rawHncsProfileId = obj.stringOrNull("rawHncsProfileId"),
rawHncsRenderIntent = HncsRenderIntent.fromPersistedValue(
obj.stringOrNull("rawHncsRenderIntent")
).assetValue,
rawHncsRenderIntent = HncsRenderIntent.Standard.assetValue,
rawRenderingEngine = parseRawRenderingEngine(
obj.stringOrNull("rawRenderingEngine") ?: obj.stringOrNull("rawColorEngine")
),
@@ -0,0 +1,118 @@
package com.hinnka.mycamera.raw
import kotlin.math.max
/**
* Phocus ColorCorrectAll camera-domain contract, adapted to PhotonCamera's
* black-subtracted and white-level-normalized RAW input.
*
* PhotonCamera expresses Phocus' active camera-gain and source-exposure terms
* in one canonical form: normalize the gains by their largest component, clamp
* in camera space, and restore the factored scale through inputEV:
*
* camera = clamp(raw * normalizedGain / hrTrunc, 0, hrMax) * inputEV
*
* With no imported Phocus image-correction state, hrTrunc/hrMax are both one.
* DNG BaselineExposure is the source exposure factor in PhotonCamera's already
* white-level-normalized domain.
*/
internal data class HncsCameraDomainContract(
val normalizedGain: FloatArray,
val inputEv: Float,
val hrTrunc: Float,
val hrMax: Float,
val cameraToWorkingMatrix: FloatArray,
) {
init {
require(normalizedGain.size == 3 && normalizedGain.all { it.isFinite() && it > 0f })
require(inputEv.isFinite() && inputEv > 0f)
require(hrTrunc.isFinite() && hrTrunc > 0f)
require(hrMax.isFinite() && hrMax > 0f)
require(cameraToWorkingMatrix.size == 9 && cameraToWorkingMatrix.all(Float::isFinite))
}
internal fun applyCameraDomain(rgb: FloatArray): FloatArray {
require(rgb.size >= 3)
return FloatArray(3) { channel ->
val gained = rgb[channel] * normalizedGain[channel] / hrTrunc
gained.coerceIn(0f, hrMax) * inputEv
}
}
}
internal object HncsCameraDomain {
const val DEFAULT_HR_TRUNC = 1f
const val DEFAULT_HR_MAX = 1f
private const val MIN_CAMERA_GAIN = 1e-3f
private const val MAX_CAMERA_GAIN = 64f
/**
* Factors the camera gains out of a composite camera-to-working matrix so
* they can be applied and clipped in camera space before that matrix.
*/
fun resolve(
compositeCameraToWorkingMatrix: FloatArray,
cameraGains: FloatArray,
baselineExposureEv: Float,
additionalExposureEv: Float = 0f,
): HncsCameraDomainContract {
require(
compositeCameraToWorkingMatrix.size == 9 &&
compositeCameraToWorkingMatrix.all(Float::isFinite)
)
val gains = sanitizeCameraGains(cameraGains)
val maximumGain = max(gains[0], max(gains[1], gains[2]))
val normalizedGain = FloatArray(3) { channel ->
gains[channel] / maximumGain
}
val cameraToWorkingMatrix = compositeCameraToWorkingMatrix.copyOf()
for (row in 0 until 3) {
for (column in 0 until 3) {
cameraToWorkingMatrix[row * 3 + column] /= gains[column]
}
}
val exposureGain = DngBaselineExposure.exactGain(
DngBaselineExposure.sanitize(baselineExposureEv) +
DngBaselineExposure.sanitize(additionalExposureEv)
)
return HncsCameraDomainContract(
normalizedGain = normalizedGain,
inputEv = exposureGain * maximumGain,
hrTrunc = DEFAULT_HR_TRUNC,
hrMax = DEFAULT_HR_MAX,
cameraToWorkingMatrix = cameraToWorkingMatrix,
)
}
/**
* Phocus GetHrEV consumes the active as-shot RGB gains. Camera2/DNG stores
* two green gains, so use their mean for the three-channel camera domain.
*/
fun fromWhiteBalanceGains(whiteBalanceGains: FloatArray): FloatArray {
fun component(index: Int, fallback: Float): Float {
val value = whiteBalanceGains.getOrElse(index) { fallback }
return value.takeIf { it.isFinite() && it > 0f } ?: fallback
}
val greenEven = component(1, 1f)
val greenOdd = component(2, greenEven)
val green = (greenEven + greenOdd) * 0.5f
return sanitizeCameraGains(
floatArrayOf(
component(0, green),
green,
component(3, green),
)
)
}
private fun sanitizeCameraGains(cameraGains: FloatArray): FloatArray {
return FloatArray(3) { channel ->
cameraGains.getOrElse(channel) { 1f }
.takeIf { it.isFinite() && it > 0f }
?.coerceIn(MIN_CAMERA_GAIN, MAX_CAMERA_GAIN)
?: 1f
}
}
}
@@ -385,9 +385,10 @@ class HncsProfileManager(private val context: Context) {
return null
}
// Phocus CXMLLut stores m* in the white-balanced camera domain and v*
// as encrypted per-channel neutral gains. PhotonCamera's demosaic output
// is deliberately un-white-balanced camera RGB, so fold diag(v*) into
// the camera matrix exactly before entering the common HNCS RGB space.
// as encrypted per-channel neutral gains. Keep the complete M*diag(v)
// transform in the render plan. HncsCameraDomain factors v back out at
// execution time so it can apply Phocus' pre-matrix headroom clamp,
// while preserving this composite matrix as the calibration invariant.
val rawCameraToXyzD50 = whiteBalancedCameraToXyzD50.copyOf()
for (row in 0 until 3) {
for (column in 0 until 3) {
@@ -1576,6 +1576,7 @@ class RawDemosaicProcessor {
} else {
null
}
val hncsRenderIntent = HncsRenderIntent.Standard
val hncsRenderPlan = when (requestedColorEngine) {
RawRenderingEngine.HncsCcm ->
HncsProfileManager(context.applicationContext).createCcmRenderPlan()
@@ -1584,7 +1585,7 @@ class RawDemosaicProcessor {
HncsProfileManager(context.applicationContext).resolveLutRenderPlan(
colorTemperature = actualMetadata.colorTemperature,
requestedProfileId = rawHncsProfileId,
renderIntent = rawHncsRenderIntent
renderIntent = hncsRenderIntent
)
else -> null
@@ -1593,7 +1594,7 @@ class RawDemosaicProcessor {
PLog.e(
TAG,
"HNCS rendering rejected: branch=$requestedColorEngine " +
"profile=$rawHncsProfileId intent=${rawHncsRenderIntent.assetValue} " +
"profile=$rawHncsProfileId intent=${hncsRenderIntent.assetValue} " +
"cct=${actualMetadata.colorTemperature}"
)
return@withContext null
@@ -1888,6 +1889,23 @@ class RawDemosaicProcessor {
dcpRenderPlan = activeDcpRenderPlan
)
}
val hncsCameraDomainGains = when {
colorEngine.usesHncsColorMap -> requireNotNull(hncsRenderPlan?.profileNeutralGains) {
"HNCS LUT branch requires its profile camera gains"
}
colorEngine.isHncs ->
HncsCameraDomain.fromWhiteBalanceGains(actualMetadata.whiteBalanceGains)
else -> null
}
val hncsCameraDomainAudit = hncsCameraDomainGains?.let { gains ->
HncsCameraDomain.resolve(
compositeCameraToWorkingMatrix = linearColorCorrectionMatrix,
cameraGains = gains,
baselineExposureEv = actualMetadata.baselineExposure,
)
}
val linearCameraWhite = resolveLinearCameraWhite(
metadata = actualMetadata,
dcpRenderPlan = activeDcpRenderPlan
@@ -1900,7 +1918,12 @@ class RawDemosaicProcessor {
"source=${hncsRenderPlan?.sourceFile} " +
"sha256=${hncsRenderPlan?.sourceSha256} profileSpace=$profileWorkingColorSpace " +
"cameraMatrix=${if (colorEngine.usesHncsColorMap) "profile-M*diag(v)-to-HNCS" else "raw-metadata"} " +
"profileNeutralGains=${hncsRenderPlan?.profileNeutralGains?.contentToString()}"
"cameraDomainGains=${hncsCameraDomainGains?.contentToString()} " +
"profileNeutralGains=${hncsRenderPlan?.profileNeutralGains?.contentToString()} " +
"normalizedCameraGain=${hncsCameraDomainAudit?.normalizedGain?.contentToString()} " +
"inputEV=${hncsCameraDomainAudit?.inputEv} " +
"hrTrunc=${hncsCameraDomainAudit?.hrTrunc} " +
"hrMax=${hncsCameraDomainAudit?.hrMax}"
)
}
logRawDcpPipeline(
@@ -2045,6 +2068,7 @@ class RawDemosaicProcessor {
useProfileExposureRamp = useProfileExposureRamp,
applyProfileDcpBaselineExposureOffset = applyDcpBaselineExposureOffset,
supportProfileOverrange = supportProfileOverrange,
hncsCameraDomainGains = hncsCameraDomainGains,
)
}
solvedExposureEv?.let { exposureEv ->
@@ -2198,8 +2222,9 @@ class RawDemosaicProcessor {
)
}
// AdobeCurve keeps BaselineExposure for the DNG SDK exposure ramp. Linear-domain
// engines apply the same EV as an exact 2^EV gain in this ProPhoto/RIMM pass.
// AdobeCurve keeps BaselineExposure for the DNG SDK exposure ramp. HNCS consumes
// it through ColorCorrectAll's camera-domain inputEV; other linear engines retain
// the exact post-matrix 2^EV gain.
checkGlError("Before LinearRcdPass")
renderLinearRcdPass(
@@ -2221,6 +2246,7 @@ class RawDemosaicProcessor {
},
clampProfileRgb = clampProfileRgb,
supportProfileOverrange = supportProfileOverrange,
hncsCameraDomainGains = hncsCameraDomainGains,
label = "LinearRcdPass"
)
@@ -4197,6 +4223,11 @@ class RawDemosaicProcessor {
uniform mat3 uColorCorrectionMatrix;
uniform vec3 uCameraWhite;
uniform float uExposureGain;
uniform int uHncsCameraDomainEnabled;
uniform vec3 uHncsCameraDomainGain;
uniform float uHncsInputEV;
uniform float uHncsHrTrunc;
uniform float uHncsHrMax;
uniform int uClampProfileRgb;
uniform int uClampProfileGainOutput;
uniform int uProfileSupportOverrange;
@@ -4277,6 +4308,12 @@ class RawDemosaicProcessor {
void main() {
vec3 rgb = texture(uDemosaickedTexture, vTexCoord).rgb;
if (uHncsCameraDomainEnabled != 0) {
rgb *= uHncsCameraDomainGain;
rgb /= uHncsHrTrunc;
rgb = clamp(rgb, vec3(0.0), vec3(uHncsHrMax));
rgb *= uHncsInputEV;
}
if (uClampProfileRgb != 0) {
rgb = min(rgb, max(uCameraWhite, vec3(0.001)));
}
@@ -10030,6 +10067,7 @@ class RawDemosaicProcessor {
profileBaselineExposureOffsetEv: Float,
clampProfileRgb: Boolean,
supportProfileOverrange: Boolean,
hncsCameraDomainGains: FloatArray? = null,
label: String
) {
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, targetFramebufferId)
@@ -10042,7 +10080,21 @@ class RawDemosaicProcessor {
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, sourceTextureId)
GLES30.glUniform1i(GLES30.glGetUniformLocation(linearRcdProgram, "uDemosaickedTexture"), 0)
val transposedCCM = transposeMatrix3x3(colorCorrectionMatrix)
val hncsCameraDomain = hncsCameraDomainGains?.let { gains ->
HncsCameraDomain.resolve(
compositeCameraToWorkingMatrix = colorCorrectionMatrix,
cameraGains = gains,
baselineExposureEv = if (applyDngBaselineExposure) {
metadata.baselineExposure
} else {
0f
},
additionalExposureEv = rawExposureCompensation,
)
}
val transposedCCM = transposeMatrix3x3(
hncsCameraDomain?.cameraToWorkingMatrix ?: colorCorrectionMatrix
)
GLES30.glUniformMatrix3fv(
GLES30.glGetUniformLocation(linearRcdProgram, "uColorCorrectionMatrix"),
1,
@@ -10061,8 +10113,12 @@ class RawDemosaicProcessor {
applyProfileGainTableMap
val exposureGain = computeLinearExposureGain(
metadata,
rawExposureCompensation,
applyDngBaselineExposure
rawExposureCompensation = if (hncsCameraDomain == null) {
rawExposureCompensation
} else {
0f
},
applyDngBaselineExposure = hncsCameraDomain == null && applyDngBaselineExposure
)
bindLinearDcpHueSatMap(
program = linearRcdProgram,
@@ -10075,6 +10131,28 @@ class RawDemosaicProcessor {
profileBaselineExposureOffsetEv
)
GLES30.glUniform1f(GLES30.glGetUniformLocation(linearRcdProgram, "uExposureGain"), exposureGain)
GLES30.glUniform1i(
GLES30.glGetUniformLocation(linearRcdProgram, "uHncsCameraDomainEnabled"),
if (hncsCameraDomain != null) 1 else 0
)
GLES30.glUniform3fv(
GLES30.glGetUniformLocation(linearRcdProgram, "uHncsCameraDomainGain"),
1,
hncsCameraDomain?.normalizedGain ?: floatArrayOf(1f, 1f, 1f),
0
)
GLES30.glUniform1f(
GLES30.glGetUniformLocation(linearRcdProgram, "uHncsInputEV"),
hncsCameraDomain?.inputEv ?: 1f
)
GLES30.glUniform1f(
GLES30.glGetUniformLocation(linearRcdProgram, "uHncsHrTrunc"),
hncsCameraDomain?.hrTrunc ?: 1f
)
GLES30.glUniform1f(
GLES30.glGetUniformLocation(linearRcdProgram, "uHncsHrMax"),
hncsCameraDomain?.hrMax ?: 1f
)
GLES30.glUniform1i(
GLES30.glGetUniformLocation(linearRcdProgram, "uClampProfileRgb"),
if (clampProfileRgb) 1 else 0
@@ -10297,7 +10375,8 @@ class RawDemosaicProcessor {
rawToneMappingParameters: RawToneMappingParameters,
useProfileExposureRamp: Boolean,
applyProfileDcpBaselineExposureOffset: Boolean,
supportProfileOverrange: Boolean
supportProfileOverrange: Boolean,
hncsCameraDomainGains: FloatArray? = null,
): Float? {
val previewSize = resolveLongEdgePreviewSize(
sourceWidth = metadata.width,
@@ -10332,6 +10411,7 @@ class RawDemosaicProcessor {
profileBaselineExposureOffsetEv = profileBaselineExposureOffsetEv,
clampProfileRgb = clampProfileRgb,
supportProfileOverrange = supportProfileOverrange,
hncsCameraDomainGains = hncsCameraDomainGains,
label = "AdobeExposurePreviewLinearPass"
)
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
@@ -10406,6 +10486,7 @@ class RawDemosaicProcessor {
profileBaselineExposureOffsetEv = profileBaselineExposureOffsetEv,
clampProfileRgb = clampProfileRgb,
supportProfileOverrange = supportProfileOverrange,
hncsCameraDomainGains = hncsCameraDomainGains,
label = "LinearExposurePreviewPass"
)
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0)
@@ -19,30 +19,6 @@ enum class RawRenderingEngine(
defaultExposureCompensationEv = 0f,
exposureCompensationDomain = RawExposureCompensationDomain.Curve
),
DarktableFilmic(
shaderId = 4,
workingColorSpace = ColorSpace.BT2020,
defaultExposureCompensationEv = RAW_RENDERING_ENGINE_DEFAULT_EXPOSURE_EV,
exposureCompensationDomain = RawExposureCompensationDomain.Linear
),
AgX(
shaderId = 1,
workingColorSpace = ColorSpace.BT2020,
defaultExposureCompensationEv = RAW_RENDERING_ENGINE_DEFAULT_EXPOSURE_EV,
exposureCompensationDomain = RawExposureCompensationDomain.Linear
),
DarktableSigmoid(
shaderId = 3,
workingColorSpace = ColorSpace.BT2020,
defaultExposureCompensationEv = RAW_RENDERING_ENGINE_DEFAULT_EXPOSURE_EV,
exposureCompensationDomain = RawExposureCompensationDomain.Linear
),
Spektrafilm(
shaderId = 2,
workingColorSpace = ColorSpace.ProPhoto,
defaultExposureCompensationEv = RAW_RENDERING_ENGINE_DEFAULT_EXPOSURE_EV,
exposureCompensationDomain = RawExposureCompensationDomain.Linear
),
HncsCcm(
shaderId = 5,
workingColorSpace = ColorSpace.HNCS,
@@ -55,6 +31,30 @@ enum class RawRenderingEngine(
defaultExposureCompensationEv = 0f,
exposureCompensationDomain = RawExposureCompensationDomain.Linear
),
AgX(
shaderId = 1,
workingColorSpace = ColorSpace.BT2020,
defaultExposureCompensationEv = RAW_RENDERING_ENGINE_DEFAULT_EXPOSURE_EV,
exposureCompensationDomain = RawExposureCompensationDomain.Linear
),
Spektrafilm(
shaderId = 2,
workingColorSpace = ColorSpace.ProPhoto,
defaultExposureCompensationEv = RAW_RENDERING_ENGINE_DEFAULT_EXPOSURE_EV,
exposureCompensationDomain = RawExposureCompensationDomain.Linear
),
DarktableSigmoid(
shaderId = 3,
workingColorSpace = ColorSpace.BT2020,
defaultExposureCompensationEv = RAW_RENDERING_ENGINE_DEFAULT_EXPOSURE_EV,
exposureCompensationDomain = RawExposureCompensationDomain.Linear
),
DarktableFilmic(
shaderId = 4,
workingColorSpace = ColorSpace.BT2020,
defaultExposureCompensationEv = RAW_RENDERING_ENGINE_DEFAULT_EXPOSURE_EV,
exposureCompensationDomain = RawExposureCompensationDomain.Linear
),
;
val isHncs: Boolean
@@ -241,7 +241,6 @@ fun CameraScreen(
val rawDcpId by viewModel.rawDcpId.collectAsState()
val rawDcpIdsByLens by viewModel.rawDcpIdsByLens.collectAsState()
val rawHncsProfileId by viewModel.rawHncsProfileId.collectAsState()
val rawHncsRenderIntent by viewModel.rawHncsRenderIntent.collectAsState()
val jpgBaselineLutId by viewModel.jpgBaselineLutId.collectAsState()
val rawBaselineLutId by viewModel.rawBaselineLutId.collectAsState()
val phantomBaselineLutId by viewModel.phantomBaselineLutId.collectAsState()
@@ -1463,7 +1462,6 @@ fun CameraScreen(
rawDcpLensOptions = rawDcpLensOptions(state.availableCameras),
availableDcps = viewModel.availableDcps,
rawHncsProfileId = rawHncsProfileId,
rawHncsRenderIntent = rawHncsRenderIntent,
availableHncsProfiles = availableHncsProfiles,
rawBaselineLutId = rawBaselineLutId,
availableLuts = viewModel.availableLutList,
@@ -1482,7 +1480,6 @@ fun CameraScreen(
onRawDcpChange = { viewModel.setRawDcpId(it) },
onRawDcpIdsByLensChange = { viewModel.setRawDcpIdsByLens(it) },
onRawHncsProfileChange = { viewModel.setRawHncsProfileId(it) },
onRawHncsRenderIntentChange = { viewModel.setRawHncsRenderIntent(it) },
onImportRawDcp = { dcpImportLauncher.launch("*/*") },
onDeleteRawDcp = { dcp ->
viewModel.deleteRawDcp(dcp.id) { success ->
@@ -32,7 +32,6 @@ import com.hinnka.mycamera.camera.MeteringMode
import com.hinnka.mycamera.lut.LutInfo
import com.hinnka.mycamera.raw.DcpInfo
import com.hinnka.mycamera.raw.HncsProfileInfo
import com.hinnka.mycamera.raw.HncsRenderIntent
import com.hinnka.mycamera.raw.RawRenderingEngine
import com.hinnka.mycamera.raw.RawToneMappingParameters
import com.hinnka.mycamera.raw.SpectralFilmSelection
@@ -87,7 +86,6 @@ fun CameraTopSheet(
rawDcpLensOptions: List<RawDcpLensOption> = emptyList(),
availableDcps: List<DcpInfo>,
rawHncsProfileId: String?,
rawHncsRenderIntent: HncsRenderIntent,
availableHncsProfiles: List<HncsProfileInfo>,
rawBaselineLutId: String?,
availableLuts: List<LutInfo>,
@@ -106,7 +104,6 @@ fun CameraTopSheet(
onRawDcpChange: (String?) -> Unit,
onRawDcpIdsByLensChange: ((Map<String, String?>) -> Unit)? = null,
onRawHncsProfileChange: (String?) -> Unit,
onRawHncsRenderIntentChange: (HncsRenderIntent) -> Unit,
onImportRawDcp: () -> Unit,
onDeleteRawDcp: (DcpInfo) -> Unit,
onRawBaselineLutChange: (String?) -> Unit,
@@ -629,6 +626,7 @@ fun CameraTopSheet(
Column(
modifier = Modifier
.fillMaxWidth()
.verticalScroll(rememberScrollState())
.navigationBarsPadding()
.padding(horizontal = 16.dp, vertical = 8.dp)
) {
@@ -668,10 +666,8 @@ fun CameraTopSheet(
onImportDcp = onImportRawDcp,
onDeleteDcp = onDeleteRawDcp,
selectedHncsProfileId = rawHncsProfileId,
selectedHncsRenderIntent = rawHncsRenderIntent,
availableHncsProfiles = availableHncsProfiles,
onSelectHncsProfile = onRawHncsProfileChange,
onSelectHncsRenderIntent = onRawHncsRenderIntentChange,
onRawExposureCompensationChange = {},
onRawAutoExposureChange = {},
onRawHighlightsAdjustmentChange = {},
@@ -109,6 +109,7 @@ fun PresetsPanel(
// 翻译内置预设名字
val displayName = when (preset.id) {
"builtin_default" -> stringResource(R.string.default_text)
"builtin_hasselblad_natural" -> stringResource(R.string.preset_builtin_hasselblad_natural)
"builtin_portrait" -> stringResource(R.string.preset_builtin_portrait)
"builtin_classic_film" -> stringResource(R.string.preset_builtin_classic_film)
"builtin_monochrome" -> stringResource(R.string.preset_builtin_monochrome)
@@ -30,7 +30,6 @@ import com.hinnka.mycamera.camera.MultiFrameConfig
import com.hinnka.mycamera.lut.LutInfo
import com.hinnka.mycamera.raw.DcpInfo
import com.hinnka.mycamera.raw.HncsProfileInfo
import com.hinnka.mycamera.raw.HncsRenderIntent
import com.hinnka.mycamera.raw.MeteringSystem
import com.hinnka.mycamera.raw.RawCfaCorrection
import com.hinnka.mycamera.raw.RawProcessingPreferences.DROMode
@@ -130,10 +129,8 @@ fun RawEditPanel(
showDngMetadataControls: Boolean = false,
contentMode: RawEditPanelContentMode = RawEditPanelContentMode.FULL,
selectedHncsProfileId: String? = null,
selectedHncsRenderIntent: HncsRenderIntent = HncsRenderIntent.Standard,
availableHncsProfiles: List<HncsProfileInfo> = emptyList(),
onSelectHncsProfile: (String?) -> Unit = {},
onSelectHncsRenderIntent: (HncsRenderIntent) -> Unit = {},
modifier: Modifier = Modifier
) {
var rawMaxOutputScaleDraft by remember {
@@ -211,38 +208,6 @@ fun RawEditPanel(
onLevelSelected = { onSelectHncsProfile(it) }
)
Spacer(modifier = Modifier.height(16.dp))
val selectedProfile = availableHncsProfiles.firstOrNull {
it.id == selectedHncsProfileId
}
val supportedIntents = selectedProfile?.intents
?: availableHncsProfiles.flatMapTo(linkedSetOf()) { it.intents }
RawChoiceSetting(
title = stringResource(R.string.settings_raw_hncs_render_intent),
description = stringResource(
R.string.settings_raw_hncs_render_intent_description
),
levels = HncsRenderIntent.entries
.filter { it in supportedIntents }
.map { intent ->
intent.assetValue to when (intent) {
HncsRenderIntent.Standard -> stringResource(
R.string.settings_raw_hncs_render_intent_standard
)
HncsRenderIntent.Reproduction -> stringResource(
R.string.settings_raw_hncs_render_intent_reproduction
)
}
},
currentLevel = selectedHncsRenderIntent.assetValue,
onLevelSelected = { persistedValue ->
onSelectHncsRenderIntent(
HncsRenderIntent.fromPersistedValue(persistedValue)
)
}
)
Spacer(modifier = Modifier.height(16.dp))
}
}
@@ -1185,7 +1185,6 @@ fun GalleryEditScreen(
}
},
selectedHncsProfileId = editRawHncsProfileId,
selectedHncsRenderIntent = editRawHncsRenderIntent,
availableHncsProfiles = availableHncsProfiles,
onSelectHncsProfile = { profileId ->
viewModel.saveRawHncsProfileSelection(
@@ -1195,14 +1194,6 @@ fun GalleryEditScreen(
requestRawPreviewRefresh()
}
},
onSelectHncsRenderIntent = { renderIntent ->
viewModel.saveRawHncsRenderIntent(
currentEditSourcePhoto,
renderIntent
) {
requestRawPreviewRefresh()
}
},
onRawExposureCompensationChange = {
viewModel.saveRawExposureCompensationValue(currentEditSourcePhoto, it)
},
@@ -34,7 +34,6 @@ import com.hinnka.mycamera.ui.components.CurveChannel
import com.hinnka.mycamera.raw.RawProfileToneMapMode
import com.hinnka.mycamera.raw.RawRenderingEngine
import com.hinnka.mycamera.raw.HncsProfileManager
import com.hinnka.mycamera.raw.HncsRenderIntent
import com.hinnka.mycamera.raw.SpectralFilmUiInfo
import com.hinnka.mycamera.ui.components.EffectsBottomSheet
import com.hinnka.mycamera.ui.components.FrameSelector
@@ -107,11 +106,6 @@ fun PresetEditorScreen(
var rawDcpId by remember { mutableStateOf(sourcePreset?.rawDcpId) }
var rawDcpIdsByLens by remember { mutableStateOf(sourcePreset?.rawDcpIdsByLens ?: emptyMap()) }
var rawHncsProfileId by remember { mutableStateOf(sourcePreset?.rawHncsProfileId) }
var rawHncsRenderIntent by remember {
mutableStateOf(
HncsRenderIntent.fromPersistedValue(sourcePreset?.rawHncsRenderIntent)
)
}
var rawRenderingEngine by remember {
mutableStateOf(RawRenderingEngine.fromPersistedName(sourcePreset?.rawRenderingEngine))
}
@@ -154,7 +148,6 @@ fun PresetEditorScreen(
rawDcpId = rawDcpId,
rawDcpIdsByLens = rawDcpIdsByLens,
rawHncsProfileId = rawHncsProfileId,
rawHncsRenderIntent = rawHncsRenderIntent.assetValue,
rawRenderingEngine = rawRenderingEngine.name,
rawGooglePixelToneMap = rawGooglePixelToneMap,
rawOppoMasterToneMap = rawOppoMasterToneMap,
@@ -522,43 +515,6 @@ fun PresetEditorScreen(
}
)
HorizontalDivider(
color = Color.White.copy(alpha = 0.05f),
modifier = Modifier.padding(vertical = 8.dp)
)
val supportedIntents = availableHncsProfiles
.firstOrNull { it.id == rawHncsProfileId }
?.intents
?: availableHncsProfiles.flatMapTo(linkedSetOf()) { it.intents }
val renderIntentNames = HncsRenderIntent.entries
.filter { it in supportedIntents }
.associateWith { intent ->
when (intent) {
HncsRenderIntent.Standard -> stringResource(
R.string.settings_raw_hncs_render_intent_standard
)
HncsRenderIntent.Reproduction -> stringResource(
R.string.settings_raw_hncs_render_intent_reproduction
)
}
}
DropdownSettingItem(
title = stringResource(R.string.settings_raw_hncs_render_intent),
description = stringResource(
R.string.settings_raw_hncs_render_intent_description
),
value = renderIntentNames[rawHncsRenderIntent].orEmpty(),
options = renderIntentNames.values.toList(),
isLoading = false,
onExpanded = {},
onOptionSelected = { selectedName ->
renderIntentNames.entries
.firstOrNull { it.value == selectedName }
?.key
?.let { rawHncsRenderIntent = it }
}
)
}
}
@@ -327,6 +327,7 @@ private fun PresetManagementItem(
private fun presetDisplayName(preset: CameraPreset): String {
return when (preset.id) {
"builtin_default" -> stringResource(R.string.default_text)
"builtin_hasselblad_natural" -> stringResource(R.string.preset_builtin_hasselblad_natural)
"builtin_portrait" -> stringResource(R.string.preset_builtin_portrait)
"builtin_classic_film" -> stringResource(R.string.preset_builtin_classic_film)
"builtin_monochrome" -> stringResource(R.string.preset_builtin_monochrome)
@@ -315,7 +315,6 @@ fun SettingsScreen(
val rawDcpId by viewModel.rawDcpId.collectAsState()
val rawDcpIdsByLens by viewModel.rawDcpIdsByLens.collectAsState()
val rawHncsProfileId by viewModel.rawHncsProfileId.collectAsState()
val rawHncsRenderIntent by viewModel.rawHncsRenderIntent.collectAsState()
val rawExposureCompensation by viewModel.rawExposureCompensation.collectAsState()
val rawAutoExposure by viewModel.rawAutoExposure.collectAsState()
val rawHighlightsAdjustment by viewModel.rawHighlightsAdjustment.collectAsState()
@@ -1748,10 +1747,8 @@ fun SettingsScreen(
rawMaxOutputScale = rawMaxOutputScale,
onRawMaxOutputScaleChange = viewModel::setRawMaxOutputScale,
selectedHncsProfileId = rawHncsProfileId,
selectedHncsRenderIntent = rawHncsRenderIntent,
availableHncsProfiles = availableHncsProfiles,
onSelectHncsProfile = viewModel::setRawHncsProfileId,
onSelectHncsRenderIntent = viewModel::setRawHncsRenderIntent,
contentMode = RawEditPanelContentMode.FULL
)
+10 -13
View File
@@ -755,20 +755,16 @@
<string name="settings_raw_color_engine_spectral_film">光譜膠片</string>
<string name="settings_raw_color_engine_spectral_film_description">模擬膠卷和相紙介質,并支援密度微調。</string>
<string name="settings_raw_color_engine_hncs">HNCS</string>
<string name="settings_raw_color_engine_hncs_description">在固定 D50 廣色域工作空間中完成 HNCS 色彩與影調渲染。</string>
<string name="settings_raw_color_engine_hncs_ccm">HNCS(CCM)</string>
<string name="settings_raw_color_engine_hncs_lut">HNCS(二維 LUT)</string>
<string name="settings_raw_hncs_color_branch">相機色彩分支</string>
<string name="settings_raw_hncs_color_branch_description">選擇 RAW 原始相機矩陣,或相機專屬 Cb/Y–Cr/Y 色度表。</string>
<string name="settings_raw_hncs_color_branch_ccm">CCM</string>
<string name="settings_raw_hncs_color_branch_lut">二維 LUT</string>
<string name="settings_raw_color_engine_hncs_description">哈蘇自然色彩解決方案:由哈蘇獨立研發的色彩管理系統</string>
<string name="settings_raw_color_engine_hncs_ccm">HNCS(原始色彩矩陣)</string>
<string name="settings_raw_color_engine_hncs_lut">HNCS(2D LUT)</string>
<string name="settings_raw_hncs_color_branch">色彩還原配置</string>
<string name="settings_raw_hncs_color_branch_description">選擇 RAW 原始色彩矩陣,或哈蘇相機專屬 Cb/Y–Cr/Y 色度表。</string>
<string name="settings_raw_hncs_color_branch_ccm">原始色彩矩陣</string>
<string name="settings_raw_hncs_color_branch_lut">2D LUT</string>
<string name="settings_raw_hncs_profile">HNCS 相機描述檔</string>
<string name="settings_raw_hncs_2d_lut">HNCS 相機二維 LUT</string>
<string name="settings_raw_hncs_profile_description">選擇與該感光元件嚴格對應的 Phocus Colormap;不會自動猜測或退回其他描述檔。</string>
<string name="settings_raw_hncs_render_intent">渲染意圖</string>
<string name="settings_raw_hncs_render_intent_description">選擇該相機描述檔中真實測量的標準或複製色度表。</string>
<string name="settings_raw_hncs_render_intent_standard">標準</string>
<string name="settings_raw_hncs_render_intent_reproduction">複製</string>
<string name="settings_raw_hncs_2d_lut">哈蘇相機專屬 2D LUT</string>
<string name="settings_raw_hncs_profile_description">非哈蘇相機使用哈蘇專屬配置會導致偏色。</string>
<string name="settings_raw_google_pixel_tone_map">Google Pixel 風格色調映射</string>
<string name="settings_raw_google_pixel_tone_map_description">使用 Google Pixel 風格的影調渲染</string>
<string name="settings_raw_oppo_master_tone_map">OPPO 大師影調</string>
@@ -1012,6 +1008,7 @@
<string name="preset_new">新建預設</string>
<string name="preset_delete_confirm">確定要刪除該預設嗎?</string>
<string name="preset_name_hint">預設名稱</string>
<string name="preset_builtin_hasselblad_natural">哈蘇自然</string>
<string name="preset_builtin_portrait">日系肖像</string>
<string name="preset_builtin_classic_film">經典膠片</string>
<string name="preset_builtin_monochrome">黑白紀實</string>
+1
View File
@@ -246,4 +246,5 @@
<string name="settings_dro_dr400">DR400</string>
<string name="settings_use_p010">P010 (10-Bit YUV)</string>
<string name="settings_use_p010_description">Aktiviert die 10-Bit YUV-Ausgabe für eine bessere Bildpräzision. Wirksam auf unterstützten Geräten, wenn RAW deaktiviert ist.</string>
<string name="settings_raw_color_engine_hncs_description">Hasselblad Natural Colour Solution: ein von Hasselblad unabhängig entwickeltes Farbmanagementsystem</string>
</resources>
+1
View File
@@ -246,4 +246,5 @@
<string name="settings_dro_dr400">DR400</string>
<string name="settings_use_p010">P010 (YUV 10 bits)</string>
<string name="settings_use_p010_description">Active la sortie YUV 10 bits pour une meilleure précision des données d\'image. Efficace sur les appareils compatibles lorsque le mode RAW est désactivé.</string>
<string name="settings_raw_color_engine_hncs_description">Hasselblad Natural Colour Solution : un système de gestion des couleurs développé indépendamment par Hasselblad</string>
</resources>
+1
View File
@@ -246,4 +246,5 @@
<string name="settings_dro_dr400">DR400</string>
<string name="settings_use_p010">P010 (10-bit YUV)</string>
<string name="settings_use_p010_description">Aktifkan output YUV 10-bit untuk presisi data gambar yang lebih baik. Efektif pada perangkat yang didukung saat RAW dinonaktifkan.</string>
<string name="settings_raw_color_engine_hncs_description">Hasselblad Natural Colour Solution: sistem manajemen warna yang dikembangkan secara independen oleh Hasselblad</string>
</resources>
+1
View File
@@ -246,4 +246,5 @@
<string name="settings_dro_dr100">DR100</string>
<string name="settings_dro_dr200">DR200</string>
<string name="settings_dro_dr400">DR400</string>
<string name="settings_raw_color_engine_hncs_description">Hasselblad Natural Colour Solution:ハッセルブラッドが独自に開発したカラーマネジメントシステム</string>
</resources>
+1
View File
@@ -247,4 +247,5 @@
<string name="settings_dro_dr100">DR100</string>
<string name="settings_dro_dr200">DR200</string>
<string name="settings_dro_dr400">DR400</string>
<string name="settings_raw_color_engine_hncs_description">Hasselblad Natural Colour Solution: 핫셀블라드가 독자적으로 개발한 컬러 매니지먼트 시스템</string>
</resources>
@@ -247,4 +247,5 @@
<string name="settings_dro_dr400">DR400</string>
<string name="settings_use_p010">P010 (YUV de 10 bits)</string>
<string name="settings_use_p010_description">Ativa a saída YUV de 10 bits para melhor precisão dos dados da imagem. Eficaz em dispositivos suportados quando o RAW está desativado.</string>
<string name="settings_raw_color_engine_hncs_description">Hasselblad Natural Colour Solution: um sistema de gerenciamento de cores desenvolvido de forma independente pela Hasselblad</string>
</resources>
+1
View File
@@ -884,4 +884,5 @@
<string name="preset_restore_defaults_confirm">การเรียกคืนค่าที่ตั้งล่วงหน้าเริ่มต้นจะล้างการแทนที่ที่กำหนดเองทั้งหมด คุณต้องการดำเนินการต่อหรือไม่?</string>
<string name="preset_custom_badge">ปรับแต่ง</string>
<string name="preset_builtin_badge">ในตัว</string>
<string name="settings_raw_color_engine_hncs_description">Hasselblad Natural Colour Solution: ระบบจัดการสีที่ Hasselblad พัฒนาขึ้นอย่างอิสระ</string>
</resources>
+10 -13
View File
@@ -755,20 +755,16 @@
<string name="settings_raw_color_engine_spectral_film">光谱胶片</string>
<string name="settings_raw_color_engine_spectral_film_description">模拟胶卷和相纸介质,并支持密度微调。</string>
<string name="settings_raw_color_engine_hncs">HNCS</string>
<string name="settings_raw_color_engine_hncs_description">在固定 D50 广色域工作空间中完成 HNCS 色彩与影调渲染。</string>
<string name="settings_raw_color_engine_hncs_ccm">HNCS(CCM)</string>
<string name="settings_raw_color_engine_hncs_lut">HNCS(二维 LUT)</string>
<string name="settings_raw_hncs_color_branch">相机色彩分支</string>
<string name="settings_raw_hncs_color_branch_description">选择 RAW 原始相机矩阵,或相机专属 Cb/Y–Cr/Y 色度表。</string>
<string name="settings_raw_hncs_color_branch_ccm">CCM</string>
<string name="settings_raw_hncs_color_branch_lut">二维 LUT</string>
<string name="settings_raw_color_engine_hncs_description">哈苏自然色彩解决方案:由哈苏独立研发的色彩管理系统</string>
<string name="settings_raw_color_engine_hncs_ccm">HNCS(原始色彩矩阵)</string>
<string name="settings_raw_color_engine_hncs_lut">HNCS(2D LUT)</string>
<string name="settings_raw_hncs_color_branch">色彩还原配置</string>
<string name="settings_raw_hncs_color_branch_description">选择 RAW 原始色彩矩阵,或哈苏相机专属 Cb/Y–Cr/Y 色度表。</string>
<string name="settings_raw_hncs_color_branch_ccm">原始色彩矩阵</string>
<string name="settings_raw_hncs_color_branch_lut">2D LUT</string>
<string name="settings_raw_hncs_profile">HNCS 相机配置</string>
<string name="settings_raw_hncs_2d_lut">HNCS 相机二维 LUT</string>
<string name="settings_raw_hncs_profile_description">选择与该传感器严格对应的 Phocus Colormap;不会自动猜测或回退到其他配置。</string>
<string name="settings_raw_hncs_render_intent">渲染意图</string>
<string name="settings_raw_hncs_render_intent_description">选择该相机配置中真实测量的标准或复制色度表。</string>
<string name="settings_raw_hncs_render_intent_standard">标准</string>
<string name="settings_raw_hncs_render_intent_reproduction">复制</string>
<string name="settings_raw_hncs_2d_lut">哈苏相机专属 2D LUT</string>
<string name="settings_raw_hncs_profile_description">非哈苏相机使用哈苏专属配置会导致偏色。</string>
<string name="settings_raw_google_pixel_tone_map">Google Pixel 风格色调映射</string>
<string name="settings_raw_google_pixel_tone_map_description">使用 Google Pixel 风格的影调渲染</string>
<string name="settings_raw_oppo_master_tone_map">OPPO 大师影调</string>
@@ -1012,6 +1008,7 @@
<string name="preset_new">新建预设</string>
<string name="preset_delete_confirm">确定要删除该预设吗?</string>
<string name="preset_name_hint">预设名称</string>
<string name="preset_builtin_hasselblad_natural">哈苏自然</string>
<string name="preset_builtin_portrait">日系肖像</string>
<string name="preset_builtin_classic_film">经典胶片</string>
<string name="preset_builtin_monochrome">黑白纪实</string>
+10 -13
View File
@@ -755,20 +755,16 @@
<string name="settings_raw_color_engine_spectral_film">光譜膠片</string>
<string name="settings_raw_color_engine_spectral_film_description">模擬膠卷和相紙介質,并支援密度微調。</string>
<string name="settings_raw_color_engine_hncs">HNCS</string>
<string name="settings_raw_color_engine_hncs_description">在固定 D50 廣色域工作空間中完成 HNCS 色彩與影調渲染。</string>
<string name="settings_raw_color_engine_hncs_ccm">HNCS(CCM)</string>
<string name="settings_raw_color_engine_hncs_lut">HNCS(二維 LUT)</string>
<string name="settings_raw_hncs_color_branch">相機色彩分支</string>
<string name="settings_raw_hncs_color_branch_description">選擇 RAW 原始相機矩陣,或相機專屬 Cb/Y–Cr/Y 色度表。</string>
<string name="settings_raw_hncs_color_branch_ccm">CCM</string>
<string name="settings_raw_hncs_color_branch_lut">二維 LUT</string>
<string name="settings_raw_color_engine_hncs_description">哈蘇自然色彩解決方案:由哈蘇獨立研發的色彩管理系統</string>
<string name="settings_raw_color_engine_hncs_ccm">HNCS(原始色彩矩陣)</string>
<string name="settings_raw_color_engine_hncs_lut">HNCS(2D LUT)</string>
<string name="settings_raw_hncs_color_branch">色彩還原配置</string>
<string name="settings_raw_hncs_color_branch_description">選擇 RAW 原始色彩矩陣,或哈蘇相機專屬 Cb/Y–Cr/Y 色度表。</string>
<string name="settings_raw_hncs_color_branch_ccm">原始色彩矩陣</string>
<string name="settings_raw_hncs_color_branch_lut">2D LUT</string>
<string name="settings_raw_hncs_profile">HNCS 相機設定檔</string>
<string name="settings_raw_hncs_2d_lut">HNCS 相機二維 LUT</string>
<string name="settings_raw_hncs_profile_description">選擇與該感光元件嚴格對應的 Phocus Colormap;不會自動猜測或退回其他設定檔。</string>
<string name="settings_raw_hncs_render_intent">渲染意圖</string>
<string name="settings_raw_hncs_render_intent_description">選擇該相機設定檔中真實測量的標準或複製色度表。</string>
<string name="settings_raw_hncs_render_intent_standard">標準</string>
<string name="settings_raw_hncs_render_intent_reproduction">複製</string>
<string name="settings_raw_hncs_2d_lut">哈蘇相機專屬 2D LUT</string>
<string name="settings_raw_hncs_profile_description">非哈蘇相機使用哈蘇專屬配置會導致偏色。</string>
<string name="settings_raw_google_pixel_tone_map">Google Pixel 風格色調映射</string>
<string name="settings_raw_google_pixel_tone_map_description">使用 Google Pixel 風格的影調渲染</string>
<string name="settings_raw_oppo_master_tone_map">OPPO 大師影調</string>
@@ -1012,6 +1008,7 @@
<string name="preset_new">新建預設</string>
<string name="preset_delete_confirm">確定要刪除該預設嗎?</string>
<string name="preset_name_hint">預設名稱</string>
<string name="preset_builtin_hasselblad_natural">哈蘇自然</string>
<string name="preset_builtin_portrait">日系肖像</string>
<string name="preset_builtin_classic_film">經典膠片</string>
<string name="preset_builtin_monochrome">黑白紀實</string>
+10 -13
View File
@@ -755,20 +755,16 @@
<string name="settings_raw_color_engine_spectral_film">光譜膠片</string>
<string name="settings_raw_color_engine_spectral_film_description">模擬膠卷和相紙介質,并支援密度微調。</string>
<string name="settings_raw_color_engine_hncs">HNCS</string>
<string name="settings_raw_color_engine_hncs_description">在固定 D50 廣色域工作空間中完成 HNCS 色彩與影調渲染。</string>
<string name="settings_raw_color_engine_hncs_ccm">HNCS(CCM)</string>
<string name="settings_raw_color_engine_hncs_lut">HNCS(二維 LUT)</string>
<string name="settings_raw_hncs_color_branch">相機色彩分支</string>
<string name="settings_raw_hncs_color_branch_description">選擇 RAW 原始相機矩陣,或相機專屬 Cb/Y–Cr/Y 色度表。</string>
<string name="settings_raw_hncs_color_branch_ccm">CCM</string>
<string name="settings_raw_hncs_color_branch_lut">二維 LUT</string>
<string name="settings_raw_color_engine_hncs_description">哈蘇自然色彩解決方案:由哈蘇獨立研發的色彩管理系統</string>
<string name="settings_raw_color_engine_hncs_ccm">HNCS(原始色彩矩陣)</string>
<string name="settings_raw_color_engine_hncs_lut">HNCS(2D LUT)</string>
<string name="settings_raw_hncs_color_branch">色彩還原配置</string>
<string name="settings_raw_hncs_color_branch_description">選擇 RAW 原始色彩矩陣,或哈蘇相機專屬 Cb/Y–Cr/Y 色度表。</string>
<string name="settings_raw_hncs_color_branch_ccm">原始色彩矩陣</string>
<string name="settings_raw_hncs_color_branch_lut">2D LUT</string>
<string name="settings_raw_hncs_profile">HNCS 相機描述檔</string>
<string name="settings_raw_hncs_2d_lut">HNCS 相機二維 LUT</string>
<string name="settings_raw_hncs_profile_description">選擇與該感光元件嚴格對應的 Phocus Colormap;不會自動猜測或退回其他描述檔。</string>
<string name="settings_raw_hncs_render_intent">算繪意圖</string>
<string name="settings_raw_hncs_render_intent_description">選擇該相機描述檔中真實測量的標準或複製色度表。</string>
<string name="settings_raw_hncs_render_intent_standard">標準</string>
<string name="settings_raw_hncs_render_intent_reproduction">複製</string>
<string name="settings_raw_hncs_2d_lut">哈蘇相機專屬 2D LUT</string>
<string name="settings_raw_hncs_profile_description">非哈蘇相機使用哈蘇專屬配置會導致偏色。</string>
<string name="settings_raw_google_pixel_tone_map">Google Pixel 風格色調映射</string>
<string name="settings_raw_google_pixel_tone_map_description">使用 Google Pixel 風格的影調渲染</string>
<string name="settings_raw_oppo_master_tone_map">OPPO 大師影調</string>
@@ -1012,6 +1008,7 @@
<string name="preset_new">新建預設</string>
<string name="preset_delete_confirm">確定要刪除該預設嗎?</string>
<string name="preset_name_hint">預設名稱</string>
<string name="preset_builtin_hasselblad_natural">哈蘇自然</string>
<string name="preset_builtin_portrait">日系肖像</string>
<string name="preset_builtin_classic_film">經典膠片</string>
<string name="preset_builtin_monochrome">黑白紀實</string>
+8 -11
View File
@@ -739,20 +739,16 @@
<string name="settings_raw_color_engine_spectral_film">Spektrafilm</string>
<string name="settings_raw_color_engine_spectral_film_description">Film stock and print medium simulation with density tuning.</string>
<string name="settings_raw_color_engine_hncs">HNCS</string>
<string name="settings_raw_color_engine_hncs_description">HNCS-style color and tone pipeline in a fixed D50 wide-gamut working space.</string>
<string name="settings_raw_color_engine_hncs_ccm">HNCS (CCM)</string>
<string name="settings_raw_color_engine_hncs_description">Hasselblad Natural Colour Solution: a colour management system independently developed by Hasselblad</string>
<string name="settings_raw_color_engine_hncs_ccm">HNCS (Original color matrix)</string>
<string name="settings_raw_color_engine_hncs_lut">HNCS (2D LUT)</string>
<string name="settings_raw_hncs_color_branch">Camera color branch</string>
<string name="settings_raw_hncs_color_branch_description">Choose the RAW camera matrix or the camera-specific Cb/Y–Cr/Y color map.</string>
<string name="settings_raw_hncs_color_branch_ccm">CCM</string>
<string name="settings_raw_hncs_color_branch">Color reproduction profile</string>
<string name="settings_raw_hncs_color_branch_description">Choose the RAW original color matrix or the Hasselblad-exclusive Cb/Y–Cr/Y color map.</string>
<string name="settings_raw_hncs_color_branch_ccm">Original color matrix</string>
<string name="settings_raw_hncs_color_branch_lut">2D LUT</string>
<string name="settings_raw_hncs_profile">HNCS camera profile</string>
<string name="settings_raw_hncs_2d_lut">HNCS camera 2D LUT</string>
<string name="settings_raw_hncs_profile_description">Select the exact Phocus Colormap profile for this sensor. No automatic or fallback profile is applied.</string>
<string name="settings_raw_hncs_render_intent">Render intent</string>
<string name="settings_raw_hncs_render_intent_description">Choose the Standard or Reproduction table measured for the selected camera profile.</string>
<string name="settings_raw_hncs_render_intent_standard">Standard</string>
<string name="settings_raw_hncs_render_intent_reproduction">Reproduction</string>
<string name="settings_raw_hncs_2d_lut">Hasselblad camera-exclusive 2D LUT</string>
<string name="settings_raw_hncs_profile_description">Using a Hasselblad-exclusive profile on a non-Hasselblad camera will cause a color cast.</string>
<string name="settings_raw_google_pixel_tone_map">Google Pixel-style tone mapping</string>
<string name="settings_raw_google_pixel_tone_map_description">Use Google Pixel-style tonal rendering.</string>
<string name="settings_raw_oppo_master_tone_map">OPPO Master tone mapping</string>
@@ -1012,6 +1008,7 @@
<string name="preset_new">New Preset</string>
<string name="preset_delete_confirm">Are you sure you want to delete this preset?</string>
<string name="preset_name_hint">Preset name</string>
<string name="preset_builtin_hasselblad_natural">Hasselblad Natural</string>
<string name="preset_builtin_portrait">Portrait Style</string>
<string name="preset_builtin_classic_film">Classic Film</string>
<string name="preset_builtin_monochrome">Monochrome</string>
@@ -0,0 +1,85 @@
package com.hinnka.mycamera.raw
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Test
class HncsCameraDomainTest {
@Test
fun factorsCameraGainsWithoutChangingUnclippedColor() {
val compositeMatrix = floatArrayOf(
2f, 3f, 5f,
7f, 11f, 13f,
17f, 19f, 23f,
)
val cameraGains = floatArrayOf(2f, 1f, 4f)
val raw = floatArrayOf(0.2f, 0.3f, 0.1f)
val contract = HncsCameraDomain.resolve(
compositeCameraToWorkingMatrix = compositeMatrix,
cameraGains = cameraGains,
baselineExposureEv = 0f,
)
val expected = multiply(compositeMatrix, raw)
val actual = multiply(contract.cameraToWorkingMatrix, contract.applyCameraDomain(raw))
assertArrayEquals(floatArrayOf(0.5f, 0.25f, 1f), contract.normalizedGain, 0f)
assertEquals(4f, contract.inputEv, 0f)
assertArrayEquals(expected, actual, 1e-5f)
}
@Test
fun clipsAfterNormalizedCameraGainAndBeforeInputEv() {
val contract = HncsCameraDomain.resolve(
compositeCameraToWorkingMatrix = identityMatrix(),
cameraGains = floatArrayOf(2f, 1f, 4f),
baselineExposureEv = 1f,
)
val camera = contract.applyCameraDomain(floatArrayOf(0.5f, 0.5f, 1.5f))
assertEquals(1f, contract.hrTrunc, 0f)
assertEquals(1f, contract.hrMax, 0f)
assertEquals(8f, contract.inputEv, 0f)
assertArrayEquals(floatArrayOf(2f, 1f, 8f), camera, 1e-5f)
}
@Test
fun baselineAndMeteringExposureAreAppliedExactlyOnceThroughInputEv() {
val contract = HncsCameraDomain.resolve(
compositeCameraToWorkingMatrix = identityMatrix(),
cameraGains = floatArrayOf(1f, 1f, 1f),
baselineExposureEv = -0.5f,
additionalExposureEv = 1.5f,
)
assertEquals(2f, contract.inputEv, 1e-6f)
assertArrayEquals(
floatArrayOf(0.4f, 0.8f, 1.2f),
contract.applyCameraDomain(floatArrayOf(0.2f, 0.4f, 0.6f)),
1e-6f,
)
}
@Test
fun convertsFourChannelAsShotGainsToPhocusRgbOrder() {
assertArrayEquals(
floatArrayOf(2f, 1.5f, 4f),
HncsCameraDomain.fromWhiteBalanceGains(floatArrayOf(2f, 1f, 2f, 4f)),
0f,
)
}
private fun identityMatrix(): FloatArray = floatArrayOf(
1f, 0f, 0f,
0f, 1f, 0f,
0f, 0f, 1f,
)
private fun multiply(matrix: FloatArray, vector: FloatArray): FloatArray =
FloatArray(3) { row ->
matrix[row * 3] * vector[0] +
matrix[row * 3 + 1] * vector[1] +
matrix[row * 3 + 2] * vector[2]
}
}
+56 -8
View File
@@ -108,7 +108,9 @@ HNCS 与 ProPhoto 数值接近,但两者是不同的处理契约,代码中
```mermaid
flowchart LR
A["线性 camera RGB + RAW white point"] --> B{"HNCS 分支"}
A["线性 camera RGB + RAW white point"] --> H0["归一化 camera gain"]
H0 --> H1["clamp(input / hrTrunc, 0, hrMax) × inputEV"]
H1 --> B{"HNCS 分支"}
B -- "CCM" --> C["当前 RAW CCM → HNCS(D50)"]
B -- "二维 LUT" --> D["profile neutral gain × 温度矩阵 → XYZ(D50)"]
D --> E["XYZ(D50) → HNCS"]
@@ -375,18 +377,64 @@ Hasselblad/LStar Gamma 分支,不能仅凭相机品牌或 UI 选项推断。
没有 LUT→CCM、HNCS→Adobe Curve、首 profile 或默认 5000 K 回退。
## 尚未伪造的运行时参数
## 相机域截断与 headroom
原始 `ColorCorrectAll` 在相机域执行:
原始 `ColorCorrectAll` shader 在输入矩阵前执行:
```text
source = clamp(input / hrTrunc, 0, hrMax) × inputEV
source = clamp(raw × normalizedCameraGain / hrTrunc, 0, hrMax) × inputEV
```
`hrTrunc/hrMax/inputEV` 来自 Phocus source description 与 image correction 状态,并非
Colormap XML 常量。PhotonCamera 已有自己的 RAW 白电平、曝光与高光重建契约,但目前没有证据
证明两套字段可以逐项等同,所以没有硬编码 Phocus headroom 数值,也没有在 HNCS 矩阵之后补一
次错误的 `[0,1]` clamp。后者已删除,以免破坏 camera→HNCS 矩阵产生的合法 overrange。
`CColorCorrectAllFilter::FilterResultGpu` 的 uniform 映射已经逐项确认:
```text
filter + 0x188 → uInputEV
filter + 0x190 → uHrTrunc
filter + 0x194 → uHrMax
```
`ColorCorrectionAllFilter::GetHrEV` 使用当前 as-shot RGB gain、source ISO/sensitivity gain 和
image-correction EV;`UpdateParameters` 再写入上述三个字段。旧版与新版
`CImageCorrection` 会把 camera gain/source exposure 分配到 gain、`inputEV` 和
`CRawColorCorrection` linearization 的不同位置,不能把某一版本的对象内存值直接套到当前
管线。没有导入 Phocus 局部曝光或镜头 EV correction 时,能够确定的默认截断因子为:
```text
hrTrunc = 1
hrMax = 1
```
PhotonCamera 把跨版本但数值等价的 gain/exposure 项规范到显式参数:
```text
normalizedCameraGain = cameraGain / max(cameraGain)
inputEV = sourceExposureGain × max(cameraGain)
```
PhotonCamera 进入该阶段前已经按 `(raw - black) / (white - black)` 完成 RAW 白电平归一化,
所以 Phocus source ISO/sensitivity normalization 在本域的等价量就是 DNG
`2^BaselineExposure`,不能再额外乘一次 ISO 或 `PostRawSensitivityBoost`。运行时使用:
```text
g = profile neutral gain // HNCS 2D LUT
g = 当前 RAW as-shot RGB gain // HNCS CCM
gNormalized = g / max(g)
inputEV = 2^BaselineExposure × max(g)
Mbase = Mcomposite × diag(1 / g)
camera = clamp(raw × gNormalized, 0, 1) × inputEV
hncs = Mbase × camera
```
未触发截断时,上式严格等于既有
`Mcomposite × raw × 2^BaselineExposure`;触发截断时则与 Phocus 一样在相机 gain 之后、
输入矩阵之前截断。`BaselineExposure` 和测光候选 EV 由 `inputEV` 消费,线性 pass 的通用
`uExposureGain` 在 HNCS 路径保持 1,因此不会重复曝光。用户编辑 EV 仍可在矩阵后、2D LUT 前
作为线性标量应用,与在输入矩阵前相乘数值等价。
这里的 `[0,1]` 只属于相机域。camera→HNCS 矩阵产生的合法负值和 overrange 不再二次 clamp,
以免破坏矩阵与后续 Cb/Y–Cr/Y 色度表的输入。
## 非 Hasselblad RAW 的相机专属 LUT