重构UCD模块
This commit is contained in:
@@ -157,9 +157,118 @@ def _ensure_checkerboard_image(width, height, grid_size, center_white):
|
||||
_IMAGE_CACHE[key] = path
|
||||
return path
|
||||
|
||||
|
||||
def _ld_ucd_params_signature(self: "PQAutomationApp") -> tuple:
|
||||
"""Local Dimming 发图前 UCD 参数签名,用于跳过未变化的重复配置。"""
|
||||
test_type = getattr(self.config, "current_test_type", "screen_module")
|
||||
cfg = self.config.current_test_types.get(test_type, {})
|
||||
timing = cfg.get("timing", "")
|
||||
|
||||
if test_type == "screen_module":
|
||||
color_space = (
|
||||
self.screen_module_color_space_var.get()
|
||||
if hasattr(self, "screen_module_color_space_var")
|
||||
else cfg.get("colorimetry", "sRGB")
|
||||
)
|
||||
data_range = (
|
||||
self.screen_module_data_range_var.get()
|
||||
if hasattr(self, "screen_module_data_range_var")
|
||||
else cfg.get("data_range", "Full")
|
||||
)
|
||||
bit_depth = (
|
||||
self.screen_module_bit_depth_var.get()
|
||||
if hasattr(self, "screen_module_bit_depth_var")
|
||||
else f"{int(cfg.get('bpc', 8))}bit"
|
||||
)
|
||||
output_format = (
|
||||
self.screen_module_output_format_var.get()
|
||||
if hasattr(self, "screen_module_output_format_var")
|
||||
else cfg.get("color_format", "RGB")
|
||||
)
|
||||
elif test_type == "sdr_movie":
|
||||
color_space = (
|
||||
self.sdr_color_space_var.get()
|
||||
if hasattr(self, "sdr_color_space_var")
|
||||
else cfg.get("colorimetry", "sRGB")
|
||||
)
|
||||
data_range = (
|
||||
self.sdr_data_range_var.get()
|
||||
if hasattr(self, "sdr_data_range_var")
|
||||
else cfg.get("data_range", "Full")
|
||||
)
|
||||
bit_depth = (
|
||||
self.sdr_bit_depth_var.get()
|
||||
if hasattr(self, "sdr_bit_depth_var")
|
||||
else f"{int(cfg.get('bpc', 8))}bit"
|
||||
)
|
||||
output_format = (
|
||||
self.sdr_output_format_var.get()
|
||||
if hasattr(self, "sdr_output_format_var")
|
||||
else cfg.get("color_format", "RGB")
|
||||
)
|
||||
elif test_type == "hdr_movie":
|
||||
color_space = (
|
||||
self.hdr_color_space_var.get()
|
||||
if hasattr(self, "hdr_color_space_var")
|
||||
else cfg.get("colorimetry", "sRGB")
|
||||
)
|
||||
data_range = (
|
||||
self.hdr_data_range_var.get()
|
||||
if hasattr(self, "hdr_data_range_var")
|
||||
else cfg.get("data_range", "Full")
|
||||
)
|
||||
bit_depth = (
|
||||
self.hdr_bit_depth_var.get()
|
||||
if hasattr(self, "hdr_bit_depth_var")
|
||||
else f"{int(cfg.get('bpc', 8))}bit"
|
||||
)
|
||||
output_format = (
|
||||
self.hdr_output_format_var.get()
|
||||
if hasattr(self, "hdr_output_format_var")
|
||||
else cfg.get("color_format", "RGB")
|
||||
)
|
||||
max_cll = self.hdr_maxcll_var.get() if hasattr(self, "hdr_maxcll_var") else None
|
||||
max_fall = self.hdr_maxfall_var.get() if hasattr(self, "hdr_maxfall_var") else None
|
||||
return (test_type, timing, color_space, data_range, bit_depth, output_format, max_cll, max_fall)
|
||||
elif test_type == "local_dimming":
|
||||
color_space = (
|
||||
self.local_dimming_color_space_var.get()
|
||||
if hasattr(self, "local_dimming_color_space_var")
|
||||
else cfg.get("colorimetry", "sRGB")
|
||||
)
|
||||
data_range = (
|
||||
self.local_dimming_data_range_var.get()
|
||||
if hasattr(self, "local_dimming_data_range_var")
|
||||
else cfg.get("data_range", "Full")
|
||||
)
|
||||
bit_depth = (
|
||||
self.local_dimming_bit_depth_var.get()
|
||||
if hasattr(self, "local_dimming_bit_depth_var")
|
||||
else f"{int(cfg.get('bpc', 8))}bit"
|
||||
)
|
||||
output_format = (
|
||||
self.local_dimming_output_format_var.get()
|
||||
if hasattr(self, "local_dimming_output_format_var")
|
||||
else cfg.get("color_format", "RGB")
|
||||
)
|
||||
else:
|
||||
return (test_type,)
|
||||
|
||||
return (test_type, timing, color_space, data_range, bit_depth, output_format)
|
||||
|
||||
|
||||
def invalidate_ld_ucd_params_cache(self: "PQAutomationApp") -> None:
|
||||
"""信号格式或分辨率变更后,强制下次发图重新写入 UCD 参数。"""
|
||||
self._last_ld_ucd_signature = None
|
||||
|
||||
|
||||
def _apply_ld_ucd_params(self: "PQAutomationApp") -> bool:
|
||||
"""发送 Local Dimming 图案前,按当前测试类型写入 UCD 参数。"""
|
||||
test_type = getattr(self.config, "current_test_type", "screen_module")
|
||||
signature = _ld_ucd_params_signature(self)
|
||||
if getattr(self, "_last_ld_ucd_signature", None) == signature:
|
||||
return True
|
||||
|
||||
test_type = signature[0]
|
||||
cfg = self.config.current_test_types.get(test_type, {})
|
||||
|
||||
try:
|
||||
@@ -279,6 +388,7 @@ def _apply_ld_ucd_params(self: "PQAutomationApp") -> bool:
|
||||
self._dispatch_ui(self.log_gui.log, "Local Dimming UCD 参数设置失败", "error")
|
||||
return False
|
||||
|
||||
self._last_ld_ucd_signature = signature
|
||||
return True
|
||||
except Exception as e:
|
||||
self._dispatch_ui(self.log_gui.log, f"Local Dimming UCD 参数设置异常: {e}", "error")
|
||||
@@ -914,5 +1024,6 @@ class LocalDimmingMixin:
|
||||
clear_ld_records = clear_ld_records
|
||||
save_local_dimming_results = save_local_dimming_results
|
||||
plot_ld_instant_peak_curve = plot_ld_instant_peak_curve
|
||||
invalidate_ld_ucd_params_cache = invalidate_ld_ucd_params_cache
|
||||
|
||||
_insert_ld_tree_item = _insert_ld_tree_item
|
||||
|
||||
Reference in New Issue
Block a user