Skip to content

Commit 07ca8bc

Browse files
committed
Add linear interpolation support and tests
Read and honor IMIV_IMGUI_TEST_ENGINE_LINEAR_INTERPOLATION in the UI (imiv_frame.cpp), and parse/emit a linear_interpolation attribute in the test engine (imiv_test_engine.cpp) so test scenarios can control sampling mode via env. Update sampling and OCIO regression tools: sampling scenario steps now set linear_interpolation explicitly instead of using the preferences step (imiv_sampling_regression.py), and the OCIO live-update tool picks a preferred target view (avoiding raw/video when possible) and clarifies failure messages to include the switch mode (imiv_ocio_live_update_regression.py). These changes allow deterministic regression runs that toggle linear/nearest sampling and improve target-view selection for live OCIO tests.
1 parent 16c7eff commit 07ca8bc

4 files changed

Lines changed: 58 additions & 15 deletions

File tree

src/imiv/imiv_frame.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,20 @@ namespace {
130130
ui_state.ocio_image_color_space = std::string(
131131
Strutil::strip(value));
132132
}
133+
134+
if (read_env_value("IMIV_IMGUI_TEST_ENGINE_LINEAR_INTERPOLATION",
135+
value)) {
136+
const string_view trimmed = Strutil::strip(value);
137+
if (trimmed == "1" || Strutil::iequals(trimmed, "true")
138+
|| Strutil::iequals(trimmed, "yes")
139+
|| Strutil::iequals(trimmed, "on")) {
140+
ui_state.linear_interpolation = true;
141+
} else if (trimmed == "0" || Strutil::iequals(trimmed, "false")
142+
|| Strutil::iequals(trimmed, "no")
143+
|| Strutil::iequals(trimmed, "off")) {
144+
ui_state.linear_interpolation = false;
145+
}
146+
}
133147
}
134148

135149
void begin_developer_screenshot_request(DeveloperUiState& developer_ui,

src/imiv/imiv_test_engine.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ namespace {
159159
bool has_display = false;
160160
bool has_view = false;
161161
bool has_image_color_space = false;
162+
bool has_linear_interpolation = false;
163+
bool linear_interpolation = false;
162164
std::string display;
163165
std::string view;
164166
std::string image_color_space;
@@ -376,6 +378,10 @@ namespace {
376378
step.ocio.has_image_color_space = true;
377379
step.ocio.image_color_space = ocio_cs_attr.as_string();
378380
}
381+
if (parse_bool_attr(step_node.attribute("linear_interpolation"),
382+
step.ocio.linear_interpolation)) {
383+
step.ocio.has_linear_interpolation = true;
384+
}
379385

380386
parse_bool_attr(step_node.attribute("screenshot"),
381387
step.capture.screenshot);
@@ -909,6 +915,11 @@ namespace {
909915
"IMIV_IMGUI_TEST_ENGINE_OCIO_IMAGE_COLOR_SPACE",
910916
&ocio.image_color_space);
911917
}
918+
if (ocio.has_linear_interpolation) {
919+
const std::string value = ocio.linear_interpolation ? "1" : "0";
920+
set_process_env_value(
921+
"IMIV_IMGUI_TEST_ENGINE_LINEAR_INTERPOLATION", &value);
922+
}
912923
}
913924

914925
bool write_test_engine_scenario_step_outputs(

src/imiv/tools/imiv_ocio_live_update_regression.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,24 @@ def _pick_first_other(values: list[str], current: str) -> str:
177177
return ""
178178

179179

180+
def _pick_preferred_target_view(values: list[str], current: str) -> str:
181+
ranked: list[str] = []
182+
for value in values:
183+
if value == current:
184+
continue
185+
lowered = value.lower()
186+
penalty = 0
187+
if "raw" in lowered:
188+
penalty += 100
189+
if "video" in lowered:
190+
penalty += 40
191+
ranked.append((penalty, value))
192+
if not ranked:
193+
return ""
194+
ranked.sort(key=lambda item: (item[0], item[1]))
195+
return ranked[0][1]
196+
197+
180198
def _display_priority(display_name: str, current_display: str) -> tuple[int, str]:
181199
name = display_name.lower()
182200
score = 100
@@ -285,7 +303,13 @@ def _resolve_live_targets(
285303
target_views = display_views.get(target_display, [])
286304
target_view = args.target_view.strip()
287305
if not target_view:
288-
target_view = initial_view if initial_view in target_views else "default"
306+
target_view = _pick_preferred_target_view(target_views, initial_view)
307+
if not target_view:
308+
target_view = (
309+
target_views[0]
310+
if target_views
311+
else ("default" if initial_view != "default" else initial_view)
312+
)
289313
else:
290314
raise RuntimeError(f"unsupported switch mode: {switch_mode}")
291315

@@ -881,7 +905,7 @@ def main() -> int:
881905
)
882906
if static_switch_diff <= 4.0:
883907
return _fail(
884-
"live OCIO view switch did not update the image region "
908+
f"live OCIO {switch_mode} switch did not update the image region "
885909
f"(mean abs RGB diff={static_switch_diff:.4f})"
886910
)
887911

@@ -890,7 +914,7 @@ def main() -> int:
890914
)
891915
if target_switch_diff > 2.0:
892916
return _fail(
893-
"live OCIO view switch does not match the settled target view "
917+
f"live OCIO {switch_mode} switch does not match the settled target state "
894918
f"(mean abs RGB diff={target_switch_diff:.4f})"
895919
)
896920

src/imiv/tools/imiv_sampling_regression.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,24 +129,18 @@ def _write_scenario(path: Path, runtime_dir_rel: str) -> None:
129129
root.set("out_dir", runtime_dir_rel)
130130
root.set("layout_items", "true")
131131

132-
_scenario_step(root, "nearest", delay_frames=3, screenshot=True, layout=True)
133132
_scenario_step(
134133
root,
135-
"open_preferences",
136-
key_chord="ctrl+comma",
137-
post_action_delay_frames=2,
138-
)
139-
_scenario_step(
140-
root,
141-
"enable_linear",
142-
set_ref="iv Preferences",
143-
item_click="Linear interpolation",
144-
post_action_delay_frames=2,
134+
"nearest",
135+
delay_frames=3,
136+
linear_interpolation=False,
137+
screenshot=True,
138+
layout=True,
145139
)
146140
_scenario_step(
147141
root,
148142
"linear",
149-
key_chord="ctrl+comma",
143+
linear_interpolation=True,
150144
post_action_delay_frames=2,
151145
screenshot=True,
152146
layout=True,

0 commit comments

Comments
 (0)