mirror of
https://github.com/cottongin/cardputerzero-camera.git
synced 2026-11-20 22:34:49 -06:00
fix: enable Z loupe/zoom across modes, 1-30 timelapse FPS, and CM0-safe MP4 compile
This commit is contained in:
@@ -825,8 +825,7 @@ struct AppView::Impl {
|
||||
if (show_live_frame) {
|
||||
scaled_vf.resize(static_cast<size_t>(feed_w) * static_cast<size_t>(feed_h) *
|
||||
3u);
|
||||
const float loupe =
|
||||
(state.mode == AppMode::Photo && state.loupe_enabled) ? 2.0f : 1.0f;
|
||||
const float loupe = state.loupe_enabled ? 2.0f : 1.0f;
|
||||
scale_crop_rgb24(live_frame->rgb24.data(), live_frame->width,
|
||||
live_frame->height, scaled_vf.data(), feed_w, feed_h,
|
||||
loupe);
|
||||
@@ -875,7 +874,7 @@ struct AppView::Impl {
|
||||
|
||||
// Top-right Zoom / Loupe badge
|
||||
int right_edge = vf_x + kVfW - 5;
|
||||
if (state.mode == AppMode::Photo && state.loupe_enabled) {
|
||||
if (state.loupe_enabled) {
|
||||
const std::string ltext = "LOUPE 2x";
|
||||
const int lw = measure_pill_badge_w(canvas, ltext, false);
|
||||
draw_pill_badge(canvas, right_edge - lw, badge_y, 16, ltext,
|
||||
@@ -1009,7 +1008,9 @@ struct AppView::Impl {
|
||||
false};
|
||||
cards[1] = {
|
||||
"OUT",
|
||||
state.config.timelapse_output_mode == "photos" ? "JPG" : "MP4",
|
||||
state.config.timelapse_output_mode == "photos"
|
||||
? "JPG"
|
||||
: ("MP4 " + std::to_string(state.config.timelapse_fps)),
|
||||
0,
|
||||
false};
|
||||
cards[2] = {"RES",
|
||||
@@ -1059,24 +1060,27 @@ struct AppView::Impl {
|
||||
draw_kbd_hint(canvas, pal, hx2, 156, "S", "Set", 8, 2);
|
||||
} else if (state.mode == AppMode::Video) {
|
||||
if (state.video_recording) {
|
||||
draw_kbd_hint(canvas, pal, hx1, 143, "Esc", "Stop Rec", 8, 2);
|
||||
draw_kbd_hint(canvas, pal, hx2, 156, "5/7", "Zoom", 8, 2);
|
||||
} else {
|
||||
draw_kbd_hint(canvas, pal, hx1, 143, "Ent", "Rec", 8, 4);
|
||||
draw_kbd_hint(canvas, pal, hx1, 143, "M", "Mic", 8, 2);
|
||||
draw_kbd_hint(canvas, pal, hx1, 143, "Esc", "Stop", 8, 2);
|
||||
draw_kbd_hint(canvas, pal, hx1, 143, "Z", "Lpe", 8, 2);
|
||||
draw_kbd_hint(canvas, pal, hx2, 156, "5/7", "Zm", 8, 3);
|
||||
draw_kbd_hint(canvas, pal, hx2, 156, "S", "Set", 8, 2);
|
||||
draw_kbd_hint(canvas, pal, hx2, 156, "G", "Grd", 8, 2);
|
||||
} else {
|
||||
draw_kbd_hint(canvas, pal, hx1, 143, "Ent", "Rec", 8, 3);
|
||||
draw_kbd_hint(canvas, pal, hx1, 143, "M", "Mic", 8, 2);
|
||||
draw_kbd_hint(canvas, pal, hx2, 156, "5/7", "Zm", 8, 2);
|
||||
draw_kbd_hint(canvas, pal, hx2, 156, "Z", "Lpe", 8, 2);
|
||||
}
|
||||
} else {
|
||||
if (state.timelapse.running) {
|
||||
draw_kbd_hint(canvas, pal, hx1, 143, "Esc", "Stop", 8, 2);
|
||||
canvas.draw_text(FontRole::Sans, 8, inner_x, 157, "Capturing...",
|
||||
pal.status_online);
|
||||
draw_kbd_hint(canvas, pal, hx1, 143, "Z", "Lpe", 8, 2);
|
||||
draw_kbd_hint(canvas, pal, hx2, 156, "5/7", "Zm", 8, 3);
|
||||
draw_kbd_hint(canvas, pal, hx2, 156, "G", "Grd", 8, 2);
|
||||
} else {
|
||||
draw_kbd_hint(canvas, pal, hx1, 143, "Ent", "Go", 8, 4);
|
||||
draw_kbd_hint(canvas, pal, hx1, 143, "C", "Cust", 8, 2);
|
||||
draw_kbd_hint(canvas, pal, hx2, 156, "8", "Gal", 8, 4);
|
||||
draw_kbd_hint(canvas, pal, hx2, 156, "S", "Set", 8, 2);
|
||||
draw_kbd_hint(canvas, pal, hx2, 156, "5/7", "Zm", 8, 2);
|
||||
draw_kbd_hint(canvas, pal, hx2, 156, "Z", "Lpe", 8, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1408,7 +1412,8 @@ struct AppView::Impl {
|
||||
const std::array<std::pair<std::string, std::string>, 4> rows = {{
|
||||
{"Interval (s)",
|
||||
std::to_string(state.tl_custom_interval_sec) + "s"},
|
||||
{"Video FPS", std::to_string(state.tl_custom_fps) + " fps"},
|
||||
{"Video FPS (1-30)",
|
||||
std::to_string(state.tl_custom_fps) + " fps"},
|
||||
{"Stop Mode", state.tl_custom_stop_mode},
|
||||
{"Stop Value", stop_val_str},
|
||||
}};
|
||||
|
||||
@@ -56,10 +56,7 @@ AppConfig sanitize_config(AppConfig cfg) {
|
||||
if (!is_one_of(cfg.timelapse_output_mode, {"video", "photos"})) {
|
||||
cfg.timelapse_output_mode = "video";
|
||||
}
|
||||
if (cfg.timelapse_fps != 15 && cfg.timelapse_fps != 24 &&
|
||||
cfg.timelapse_fps != 30) {
|
||||
cfg.timelapse_fps = 24;
|
||||
}
|
||||
cfg.timelapse_fps = std::clamp(cfg.timelapse_fps, 1, 30);
|
||||
if (!is_one_of(cfg.timelapse_stop_mode, {"manual", "shots", "duration"})) {
|
||||
cfg.timelapse_stop_mode = "manual";
|
||||
}
|
||||
|
||||
@@ -160,6 +160,10 @@ std::vector<std::string> TimelapseEngine::build_compile_command(
|
||||
"ffmpeg",
|
||||
"-nostdin",
|
||||
"-y",
|
||||
"-threads",
|
||||
"1",
|
||||
"-filter_threads",
|
||||
"1",
|
||||
"-framerate",
|
||||
std::to_string(safe_fps),
|
||||
"-start_number",
|
||||
@@ -168,25 +172,35 @@ std::vector<std::string> TimelapseEngine::build_compile_command(
|
||||
input_pattern,
|
||||
};
|
||||
|
||||
if (to_lower_ascii(resolution) == "8mp") {
|
||||
// Scale to CM0/VideoCore IV memory-safe dimensions while preserving aspect ratio.
|
||||
if (to_lower_ascii(resolution) == "1080p") {
|
||||
args.push_back("-vf");
|
||||
args.push_back("scale=1440:1080:flags=lanczos");
|
||||
args.push_back("scale=1280:720:flags=bilinear,setsar=1");
|
||||
} else {
|
||||
args.push_back("-vf");
|
||||
args.push_back("scale=1024:768:flags=bilinear,setsar=1");
|
||||
}
|
||||
|
||||
if (use_hw_encoder) {
|
||||
args.push_back("-c:v");
|
||||
args.push_back("h264_v4l2m2m");
|
||||
args.push_back("-num_output_buffers");
|
||||
args.push_back("4");
|
||||
args.push_back("-b:v");
|
||||
args.push_back("6M");
|
||||
args.push_back("5M");
|
||||
args.push_back("-pix_fmt");
|
||||
args.push_back("yuv420p");
|
||||
} else {
|
||||
args.push_back("-c:v");
|
||||
args.push_back("libx264");
|
||||
args.push_back("-threads");
|
||||
args.push_back("2");
|
||||
args.push_back("-preset");
|
||||
args.push_back("veryfast");
|
||||
args.push_back("ultrafast");
|
||||
args.push_back("-crf");
|
||||
args.push_back("22");
|
||||
args.push_back("23");
|
||||
args.push_back("-x264-params");
|
||||
args.push_back("rc-lookahead=0:ref=1:bframes=0:threads=2:lookahead-threads=1:sync-lookahead=0");
|
||||
args.push_back("-pix_fmt");
|
||||
args.push_back("yuv420p");
|
||||
}
|
||||
@@ -246,7 +260,8 @@ bool TimelapseEngine::start(const AppConfig& cfg, uint64_t now_ms) {
|
||||
const std::string res =
|
||||
cfg.timelapse_resolution.empty() ? "2mp" : to_lower_ascii(cfg.timelapse_resolution);
|
||||
const int interval_sec = std::clamp(cfg.timelapse_interval_sec, 1, 3600);
|
||||
const int fps = (cfg.timelapse_fps > 0) ? cfg.timelapse_fps : 24;
|
||||
const int fps =
|
||||
(cfg.timelapse_fps > 0) ? std::clamp(cfg.timelapse_fps, 1, 30) : 24;
|
||||
|
||||
TimelapseManifest m;
|
||||
m.session_id = paths.session_id;
|
||||
@@ -576,18 +591,7 @@ bool TimelapseEngine::run_compile_attempt(
|
||||
on_progress(cur, total_frames);
|
||||
}
|
||||
}
|
||||
} else if (line == "progress=end" && total_frames > 0 &&
|
||||
last_reported < total_frames) {
|
||||
last_reported = total_frames;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
state_.compile_current = total_frames;
|
||||
state_.compile_total = total_frames;
|
||||
state_.compile_progress = 1.0f;
|
||||
}
|
||||
if (on_progress) {
|
||||
on_progress(total_frames, total_frames);
|
||||
}
|
||||
// progress=end is emitted even on failed encoder init; leave 100% completion to compile_session() on exit 0.
|
||||
}
|
||||
};
|
||||
|
||||
@@ -776,6 +780,11 @@ bool TimelapseEngine::compile_session(
|
||||
|
||||
if (!ok && !cancelled) {
|
||||
remove_silent(paths.mp4_tmp_path);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
state_.compile_current = 0;
|
||||
state_.compile_progress = 0.0f;
|
||||
}
|
||||
ok = run_compile_attempt(ffmpeg, paths, fps, resolution, false,
|
||||
total_frames, on_progress, err);
|
||||
std::lock_guard<std::mutex> plock(compile_proc_mutex_);
|
||||
|
||||
@@ -22,7 +22,6 @@ constexpr uint64_t kCaptureFlashMs = 150ULL;
|
||||
constexpr uint64_t kToastDurationMs = 3000ULL;
|
||||
constexpr std::array<float, 5> kZoomSteps = {1.0f, 1.5f, 2.0f, 3.0f, 4.0f};
|
||||
constexpr std::array<int, 6> kIntervalPresets = {2, 5, 10, 30, 60, 300};
|
||||
constexpr std::array<int, 3> kFpsPresets = {15, 24, 30};
|
||||
constexpr std::array<int, 4> kDimPresets = {15, 30, 60, 0};
|
||||
constexpr std::array<const char*, 5> kOrientPresets = {"auto", "0", "180",
|
||||
"hflip", "vflip"};
|
||||
@@ -1123,7 +1122,7 @@ void UiController::open_timelapse_custom_input() {
|
||||
state_.modal = OverlayModal::TimelapseCustomInput;
|
||||
state_.tl_custom_cursor = 0;
|
||||
state_.tl_custom_interval_sec = state_.config.timelapse_interval_sec;
|
||||
state_.tl_custom_fps = state_.config.timelapse_fps;
|
||||
state_.tl_custom_fps = std::clamp(state_.config.timelapse_fps, 1, 30);
|
||||
state_.tl_custom_stop_mode = state_.config.timelapse_stop_mode;
|
||||
state_.tl_custom_stop_value = state_.config.timelapse_stop_value;
|
||||
state_.tl_custom_text.clear();
|
||||
@@ -1185,13 +1184,25 @@ bool UiController::handle_none_modal_key(char ch,
|
||||
? static_cast<char>(std::tolower(static_cast<unsigned char>(ch)))
|
||||
: 0;
|
||||
|
||||
// Active Timelapse running locks all mode/settings switches
|
||||
// Active Timelapse running locks all mode/settings switches while keeping zoom/loupe/grid active
|
||||
if (tl_running) {
|
||||
if (code == KeyCode::Enter || code == KeyCode::Esc || lower == '6' ||
|
||||
lower == 'q') {
|
||||
state_.modal = OverlayModal::TimelapseStopConfirm;
|
||||
return true;
|
||||
}
|
||||
if (lower == '5') {
|
||||
adjust_zoom(-1);
|
||||
return true;
|
||||
}
|
||||
if (lower == '7') {
|
||||
adjust_zoom(+1);
|
||||
return true;
|
||||
}
|
||||
if (lower == 'z') {
|
||||
state_.loupe_enabled = !state_.loupe_enabled;
|
||||
return true;
|
||||
}
|
||||
if (lower == 'g') {
|
||||
state_.config.grid_enabled = !state_.config.grid_enabled;
|
||||
persist_config();
|
||||
@@ -1200,7 +1211,7 @@ bool UiController::handle_none_modal_key(char ch,
|
||||
return false;
|
||||
}
|
||||
|
||||
// Active Video recording locks transitions while keeping zoom and stop active
|
||||
// Active Video recording locks transitions while keeping zoom/loupe/grid/stop active
|
||||
if (vid_recording) {
|
||||
if (code == KeyCode::Enter || code == KeyCode::Space ||
|
||||
code == KeyCode::Esc || lower == '6') {
|
||||
@@ -1215,6 +1226,10 @@ bool UiController::handle_none_modal_key(char ch,
|
||||
adjust_zoom(+1);
|
||||
return true;
|
||||
}
|
||||
if (lower == 'z') {
|
||||
state_.loupe_enabled = !state_.loupe_enabled;
|
||||
return true;
|
||||
}
|
||||
if (lower == 'g') {
|
||||
state_.config.grid_enabled = !state_.config.grid_enabled;
|
||||
persist_config();
|
||||
@@ -1268,11 +1283,6 @@ bool UiController::handle_none_modal_key(char ch,
|
||||
return true;
|
||||
}
|
||||
if (code == KeyCode::Right || lower == 'l') {
|
||||
// Note: lowercase 'l' toggles Loupe in Photo mode per spec §5.4/§5.8!
|
||||
if (lower == 'l' && state_.mode == AppMode::Photo) {
|
||||
state_.loupe_enabled = !state_.loupe_enabled;
|
||||
return true;
|
||||
}
|
||||
adjust_rail_setting(+1);
|
||||
return true;
|
||||
}
|
||||
@@ -1297,12 +1307,9 @@ bool UiController::handle_none_modal_key(char ch,
|
||||
case '7':
|
||||
adjust_zoom(+1);
|
||||
return true;
|
||||
case 'l':
|
||||
if (state_.mode == AppMode::Photo) {
|
||||
state_.loupe_enabled = !state_.loupe_enabled;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case 'z':
|
||||
state_.loupe_enabled = !state_.loupe_enabled;
|
||||
return true;
|
||||
case 'f':
|
||||
if (state_.mode == AppMode::Photo) {
|
||||
state_.filter = next_filter(state_.filter, +1);
|
||||
@@ -1765,7 +1772,7 @@ bool UiController::handle_tl_custom_key(char ch,
|
||||
(code == KeyCode::Char && (ch == '\n' || ch == '\r'))) {
|
||||
state_.config.timelapse_interval_sec =
|
||||
std::clamp(state_.tl_custom_interval_sec, 1, 3600);
|
||||
state_.config.timelapse_fps = state_.tl_custom_fps;
|
||||
state_.config.timelapse_fps = std::clamp(state_.tl_custom_fps, 1, 30);
|
||||
state_.config.timelapse_stop_mode = state_.tl_custom_stop_mode;
|
||||
state_.config.timelapse_stop_value =
|
||||
(state_.tl_custom_stop_mode == "manual")
|
||||
@@ -1797,16 +1804,19 @@ bool UiController::handle_tl_custom_key(char ch,
|
||||
return true;
|
||||
}
|
||||
|
||||
// Numeric entry for Interval (row 0) or Stop Value (row 3)
|
||||
// Numeric entry for Interval (row 0), Video FPS (row 1), or Stop Value (row 3)
|
||||
if (code == KeyCode::Char && std::isdigit(static_cast<unsigned char>(ch))) {
|
||||
if (state_.tl_custom_cursor == 0 ||
|
||||
if (state_.tl_custom_cursor == 0 || state_.tl_custom_cursor == 1 ||
|
||||
(state_.tl_custom_cursor == 3 &&
|
||||
state_.tl_custom_stop_mode != "manual")) {
|
||||
if (state_.tl_custom_text.size() < 4) {
|
||||
const size_t max_len = (state_.tl_custom_cursor == 1) ? 2 : 4;
|
||||
if (state_.tl_custom_text.size() < max_len) {
|
||||
state_.tl_custom_text.push_back(ch);
|
||||
const int val = std::atoi(state_.tl_custom_text.c_str());
|
||||
if (state_.tl_custom_cursor == 0) {
|
||||
state_.tl_custom_interval_sec = std::clamp(val, 1, 3600);
|
||||
} else if (state_.tl_custom_cursor == 1) {
|
||||
state_.tl_custom_fps = std::clamp(val, 1, 30);
|
||||
} else if (state_.tl_custom_stop_mode == "shots") {
|
||||
state_.tl_custom_stop_value = std::clamp(val, 1, 9999);
|
||||
} else {
|
||||
@@ -1820,6 +1830,9 @@ bool UiController::handle_tl_custom_key(char ch,
|
||||
if (code == KeyCode::Backspace ||
|
||||
(code == KeyCode::Char &&
|
||||
(ch == '\b' || static_cast<unsigned char>(ch) == 0x7f))) {
|
||||
if (state_.tl_custom_cursor == 1 && state_.tl_custom_text.empty()) {
|
||||
state_.tl_custom_text = std::to_string(std::clamp(state_.tl_custom_fps, 1, 30));
|
||||
}
|
||||
if (!state_.tl_custom_text.empty()) {
|
||||
state_.tl_custom_text.pop_back();
|
||||
const int val =
|
||||
@@ -1827,6 +1840,8 @@ bool UiController::handle_tl_custom_key(char ch,
|
||||
: std::atoi(state_.tl_custom_text.c_str());
|
||||
if (state_.tl_custom_cursor == 0) {
|
||||
state_.tl_custom_interval_sec = std::clamp(val, 1, 3600);
|
||||
} else if (state_.tl_custom_cursor == 1) {
|
||||
state_.tl_custom_fps = std::clamp(val, 1, 30);
|
||||
} else if (state_.tl_custom_stop_mode == "shots") {
|
||||
state_.tl_custom_stop_value = std::clamp(val, 1, 9999);
|
||||
} else if (state_.tl_custom_stop_mode == "duration") {
|
||||
@@ -1845,9 +1860,8 @@ bool UiController::handle_tl_custom_key(char ch,
|
||||
state_.tl_custom_interval_sec =
|
||||
std::clamp(state_.tl_custom_interval_sec + delta * step, 1, 3600);
|
||||
} else if (state_.tl_custom_cursor == 1) {
|
||||
const int idx = find_index_int(kFpsPresets, state_.tl_custom_fps);
|
||||
state_.tl_custom_fps =
|
||||
kFpsPresets[static_cast<size_t>((idx + delta + 3) % 3)];
|
||||
std::clamp(state_.tl_custom_fps + delta, 1, 30);
|
||||
} else if (state_.tl_custom_cursor == 2) {
|
||||
static constexpr std::array<const char*, 3> kStopModes = {
|
||||
"manual", "shots", "duration"};
|
||||
|
||||
@@ -307,6 +307,15 @@ void test_config_defaults_roundtrip_and_corrupt_fallback() {
|
||||
assert(loaded.ev == custom.ev);
|
||||
assert(loaded.camera_transform == custom.camera_transform);
|
||||
|
||||
// Custom timelapse FPS (1..30) round-trips and out-of-range values clamp to [1, 30]
|
||||
custom.timelapse_fps = 12;
|
||||
assert(cz::save_config(custom));
|
||||
assert(cz::load_config().timelapse_fps == 12);
|
||||
write_bytes(env_cfg, "{ \"timelapse_fps\": 0 }");
|
||||
assert(cz::load_config().timelapse_fps == 1);
|
||||
write_bytes(env_cfg, "{ \"timelapse_fps\": 99 }");
|
||||
assert(cz::load_config().timelapse_fps == 30);
|
||||
|
||||
// Corrupt JSON falls back gracefully to defaults without throwing
|
||||
write_bytes(env_cfg, "{ \"theme\": \"light\", broken_json ");
|
||||
const cz::AppConfig recovered = cz::load_config();
|
||||
|
||||
@@ -310,23 +310,31 @@ void test_timelapse_compile_8mp_scaling_and_h264_fallback() {
|
||||
|
||||
const auto cmd_8mp_hw =
|
||||
cz::TimelapseEngine::build_compile_command(paths, 24, "8mp", true);
|
||||
assert(has_arg_pair(cmd_8mp_hw, "-vf", "scale=1440:1080:flags=lanczos"));
|
||||
assert(has_arg_pair(cmd_8mp_hw, "-threads", "1"));
|
||||
assert(has_arg_pair(cmd_8mp_hw, "-filter_threads", "1"));
|
||||
assert(has_arg_pair(cmd_8mp_hw, "-vf", "scale=1024:768:flags=bilinear,setsar=1"));
|
||||
assert(has_arg_pair(cmd_8mp_hw, "-c:v", "h264_v4l2m2m"));
|
||||
assert(has_arg_pair(cmd_8mp_hw, "-num_output_buffers", "4"));
|
||||
assert(has_arg_pair(cmd_8mp_hw, "-b:v", "5M"));
|
||||
assert(has_arg_pair(cmd_8mp_hw, "-f", "mp4"));
|
||||
assert(has_arg_pair(cmd_8mp_hw, "-movflags", "+faststart"));
|
||||
assert(has_arg(cmd_8mp_hw, paths.mp4_tmp_path));
|
||||
|
||||
const auto cmd_2mp_sw =
|
||||
cz::TimelapseEngine::build_compile_command(paths, 24, "2mp", false);
|
||||
assert(!has_arg(cmd_2mp_sw, "-vf"));
|
||||
cz::TimelapseEngine::build_compile_command(paths, 12, "2mp", false);
|
||||
assert(has_arg_pair(cmd_2mp_sw, "-framerate", "12"));
|
||||
assert(has_arg_pair(cmd_2mp_sw, "-vf", "scale=1024:768:flags=bilinear,setsar=1"));
|
||||
assert(has_arg_pair(cmd_2mp_sw, "-c:v", "libx264"));
|
||||
assert(has_arg_pair(cmd_2mp_sw, "-preset", "veryfast"));
|
||||
assert(has_arg_pair(cmd_2mp_sw, "-crf", "22"));
|
||||
assert(has_arg_pair(cmd_2mp_sw, "-threads", "2"));
|
||||
assert(has_arg_pair(cmd_2mp_sw, "-preset", "ultrafast"));
|
||||
assert(has_arg_pair(cmd_2mp_sw, "-crf", "23"));
|
||||
assert(has_arg_pair(cmd_2mp_sw, "-x264-params",
|
||||
"rc-lookahead=0:ref=1:bframes=0:threads=2:lookahead-threads=1:sync-lookahead=0"));
|
||||
assert(has_arg_pair(cmd_2mp_sw, "-f", "mp4"));
|
||||
|
||||
const auto cmd_1080_hw =
|
||||
cz::TimelapseEngine::build_compile_command(paths, 30, "1080p", true);
|
||||
assert(!has_arg(cmd_1080_hw, "-vf"));
|
||||
assert(has_arg_pair(cmd_1080_hw, "-vf", "scale=1280:720:flags=bilinear,setsar=1"));
|
||||
assert(has_arg_pair(cmd_1080_hw, "-framerate", "30"));
|
||||
|
||||
// Generate 3 real JPEGs and compile with 8mp scaling (triggers h264_v4l2m2m -> libx264 fallback on macOS)
|
||||
@@ -366,15 +374,15 @@ void test_timelapse_compile_8mp_scaling_and_h264_fallback() {
|
||||
assert(!engine.state().compiling);
|
||||
assert(engine.state().last_error.empty());
|
||||
|
||||
// Probe compiled MP4 via GalleryStore to verify 1440x1080 scaled output
|
||||
// Probe compiled MP4 via GalleryStore to verify CM0-safe 1024x768 scaled output
|
||||
cz::GalleryStore gallery;
|
||||
assert(gallery.refresh(out_dir));
|
||||
assert(gallery.items().size() == 1);
|
||||
cz::GalleryItem item = gallery.items()[0];
|
||||
assert(item.type == cz::GalleryItemType::Video);
|
||||
assert(gallery.probe_video_meta(item));
|
||||
assert(item.width == 1440);
|
||||
assert(item.height == 1080);
|
||||
assert(item.width == 1024);
|
||||
assert(item.height == 768);
|
||||
|
||||
// Also test video-mode live capture + request_stop() + cancel_compile() preserving staging files
|
||||
cz::SimCameraBackend sim;
|
||||
|
||||
@@ -269,18 +269,27 @@ void test_photo_controls_zoom_loupe_filters_and_timer() {
|
||||
ctrl.handle_key('5', cz::KeyCode::Char, now);
|
||||
assert(ctrl.state().zoom == 1.0f);
|
||||
|
||||
// Loupe L toggles 2x viewfinder magnification without changing sensor zoom
|
||||
// Loupe Z toggles 2x viewfinder magnification without changing sensor zoom;
|
||||
// lowercase 'l' acts as Right (adjust_rail_setting(+1)) for hjkl navigation.
|
||||
ctrl.handle_key('7', cz::KeyCode::Char, now);
|
||||
assert(ctrl.state().zoom == 1.5f);
|
||||
const int calls_before_loupe = spy->set_controls_calls;
|
||||
ctrl.handle_key('l', cz::KeyCode::Char, now);
|
||||
ctrl.handle_key('z', cz::KeyCode::Char, now);
|
||||
assert(ctrl.state().loupe_enabled);
|
||||
assert(ctrl.state().zoom == 1.5f);
|
||||
assert(spy->last_zoom == 1.5f);
|
||||
assert(spy->set_controls_calls == calls_before_loupe);
|
||||
ctrl.handle_key('L', cz::KeyCode::Char, now);
|
||||
ctrl.handle_key('Z', cz::KeyCode::Char, now);
|
||||
assert(!ctrl.state().loupe_enabled);
|
||||
|
||||
assert(ctrl.state().rail_cursor == 1);
|
||||
assert(ctrl.state().config.ev == 0.0);
|
||||
ctrl.handle_key('l', cz::KeyCode::Char, now);
|
||||
assert(!ctrl.state().loupe_enabled);
|
||||
assert(ctrl.state().config.ev == 0.5);
|
||||
ctrl.handle_key('h', cz::KeyCode::Char, now);
|
||||
assert(ctrl.state().config.ev == 0.0);
|
||||
|
||||
// F cycles through all 9 filters and wraps back to None
|
||||
const cz::FilterId expected_filters[9] = {
|
||||
cz::FilterId::BW, cz::FilterId::HiCon, cz::FilterId::Sepia,
|
||||
@@ -461,6 +470,25 @@ void test_video_mode_locks_transitions_while_recording() {
|
||||
assert(ctrl.state().config.ev == ev_before);
|
||||
assert(cz::load_config(cfg_path).ev == ev_before);
|
||||
|
||||
// Idle Z toggles Loupe in Video mode too and renders distinctly
|
||||
assert(!ctrl.state().loupe_enabled);
|
||||
cz::PreviewFrame vid_live;
|
||||
assert(ctrl.backend()->copy_latest_preview(0, vid_live));
|
||||
cz::AppView vid_view;
|
||||
vid_view.render(ctrl.state(), &vid_live, nullptr);
|
||||
std::vector<uint32_t> vid_no_loupe(
|
||||
vid_view.pixels(),
|
||||
vid_view.pixels() + cz::AppView::kWidth * cz::AppView::kHeight);
|
||||
ctrl.handle_key('z', cz::KeyCode::Char, now);
|
||||
assert(ctrl.state().loupe_enabled);
|
||||
vid_view.render(ctrl.state(), &vid_live, nullptr);
|
||||
std::vector<uint32_t> vid_with_loupe(
|
||||
vid_view.pixels(),
|
||||
vid_view.pixels() + cz::AppView::kWidth * cz::AppView::kHeight);
|
||||
assert(vid_no_loupe != vid_with_loupe);
|
||||
ctrl.handle_key('Z', cz::KeyCode::Char, now);
|
||||
assert(!ctrl.state().loupe_enabled);
|
||||
|
||||
// Start recording with Enter
|
||||
ctrl.handle_key(0, cz::KeyCode::Enter, now);
|
||||
assert(ctrl.state().video_recording);
|
||||
@@ -479,9 +507,13 @@ void test_video_mode_locks_transitions_while_recording() {
|
||||
assert(!ctrl.should_quit());
|
||||
}
|
||||
|
||||
// Zoom 5/7 still works live during recording
|
||||
// Zoom 5/7 and Loupe Z still work live during recording
|
||||
ctrl.handle_key('7', cz::KeyCode::Char, now);
|
||||
assert(ctrl.state().zoom == 1.5f);
|
||||
ctrl.handle_key('z', cz::KeyCode::Char, now);
|
||||
assert(ctrl.state().loupe_enabled);
|
||||
ctrl.handle_key('z', cz::KeyCode::Char, now);
|
||||
assert(!ctrl.state().loupe_enabled);
|
||||
|
||||
now += 1500;
|
||||
ctrl.tick(now);
|
||||
@@ -818,19 +850,80 @@ void test_text_input_timelapse_custom_recovery_and_modal_renders() {
|
||||
assert(ctrl.state().modal == cz::OverlayModal::TimelapseCustomInput);
|
||||
ctrl.handle_key('1', cz::KeyCode::Char, now);
|
||||
ctrl.handle_key('2', cz::KeyCode::Char, now);
|
||||
assert(ctrl.state().tl_custom_interval_sec == 12);
|
||||
ctrl.handle_key(0, cz::KeyCode::Down, now);
|
||||
ctrl.handle_key(0, cz::KeyCode::Right, now); // 24 -> 30 fps
|
||||
assert(ctrl.state().tl_custom_fps == 30);
|
||||
ctrl.handle_key(0, cz::KeyCode::Down, now);
|
||||
ctrl.handle_key(0, cz::KeyCode::Right, now); // manual -> shots
|
||||
assert(ctrl.state().tl_custom_stop_mode == "shots");
|
||||
view.render(ctrl.state(), &live, nullptr);
|
||||
ctrl.handle_key(0, cz::KeyCode::Enter, now);
|
||||
assert(ctrl.state().modal == cz::OverlayModal::None);
|
||||
assert(ctrl.state().config.timelapse_interval_sec == 12);
|
||||
assert(ctrl.state().config.timelapse_fps == 30);
|
||||
assert(ctrl.state().config.timelapse_stop_mode == "shots");
|
||||
assert(ctrl.state().tl_custom_interval_sec == 12);
|
||||
ctrl.handle_key(0, cz::KeyCode::Down, now);
|
||||
// Custom FPS supports +/-1 stepping AND direct 1..30 numeric typing
|
||||
assert(ctrl.state().tl_custom_fps == 24);
|
||||
ctrl.handle_key(0, cz::KeyCode::Right, now);
|
||||
assert(ctrl.state().tl_custom_fps == 25);
|
||||
ctrl.handle_key('h', cz::KeyCode::Char, now);
|
||||
assert(ctrl.state().tl_custom_fps == 24);
|
||||
ctrl.handle_key('1', cz::KeyCode::Char, now);
|
||||
ctrl.handle_key('2', cz::KeyCode::Char, now);
|
||||
assert(ctrl.state().tl_custom_fps == 12);
|
||||
ctrl.handle_key(0, cz::KeyCode::Backspace, now);
|
||||
assert(ctrl.state().tl_custom_fps == 1);
|
||||
ctrl.handle_key(0, cz::KeyCode::Backspace, now);
|
||||
ctrl.handle_key('3', cz::KeyCode::Char, now);
|
||||
ctrl.handle_key('5', cz::KeyCode::Char, now);
|
||||
assert(ctrl.state().tl_custom_fps == 30);
|
||||
ctrl.handle_key(0, cz::KeyCode::Backspace, now);
|
||||
ctrl.handle_key(0, cz::KeyCode::Backspace, now);
|
||||
ctrl.handle_key('7', cz::KeyCode::Char, now);
|
||||
assert(ctrl.state().tl_custom_fps == 7);
|
||||
ctrl.handle_key(0, cz::KeyCode::Down, now);
|
||||
ctrl.handle_key(0, cz::KeyCode::Right, now); // manual -> shots
|
||||
assert(ctrl.state().tl_custom_stop_mode == "shots");
|
||||
view.render(ctrl.state(), &live, nullptr);
|
||||
ctrl.handle_key(0, cz::KeyCode::Enter, now);
|
||||
assert(ctrl.state().modal == cz::OverlayModal::None);
|
||||
assert(ctrl.state().config.timelapse_interval_sec == 12);
|
||||
assert(ctrl.state().config.timelapse_fps == 7);
|
||||
assert(cz::load_config(cfg_path).timelapse_fps == 7);
|
||||
assert(ctrl.state().config.timelapse_stop_mode == "shots");
|
||||
|
||||
// Timelapse idle & active zoom (5/7) and Loupe (Z) work cleanly
|
||||
assert(ctrl.state().zoom == 1.0f);
|
||||
assert(!ctrl.state().loupe_enabled);
|
||||
ctrl.handle_key('7', cz::KeyCode::Char, now);
|
||||
assert(ctrl.state().zoom == 1.5f);
|
||||
ctrl.handle_key('z', cz::KeyCode::Char, now);
|
||||
assert(ctrl.state().loupe_enabled);
|
||||
view.render(ctrl.state(), &live, nullptr);
|
||||
std::vector<uint32_t> tl_with_loupe(
|
||||
view.pixels(), view.pixels() + cz::AppView::kWidth * cz::AppView::kHeight);
|
||||
ctrl.handle_key('z', cz::KeyCode::Char, now);
|
||||
assert(!ctrl.state().loupe_enabled);
|
||||
view.render(ctrl.state(), &live, nullptr);
|
||||
std::vector<uint32_t> tl_no_loupe(
|
||||
view.pixels(), view.pixels() + cz::AppView::kWidth * cz::AppView::kHeight);
|
||||
assert(tl_with_loupe != tl_no_loupe);
|
||||
|
||||
// Also verify zoom & Loupe stay responsive while Timelapse is actively running
|
||||
ctrl.handle_key(0, cz::KeyCode::Enter, now);
|
||||
ctrl.tick(now);
|
||||
assert(ctrl.state().timelapse.running);
|
||||
ctrl.handle_key('7', cz::KeyCode::Char, now);
|
||||
assert(ctrl.state().zoom == 2.0f);
|
||||
ctrl.handle_key('5', cz::KeyCode::Char, now);
|
||||
assert(ctrl.state().zoom == 1.5f);
|
||||
ctrl.handle_key('z', cz::KeyCode::Char, now);
|
||||
assert(ctrl.state().loupe_enabled);
|
||||
ctrl.handle_key('z', cz::KeyCode::Char, now);
|
||||
assert(!ctrl.state().loupe_enabled);
|
||||
ctrl.handle_key(0, cz::KeyCode::Esc, now);
|
||||
assert(ctrl.state().modal == cz::OverlayModal::TimelapseStopConfirm);
|
||||
ctrl.handle_key('y', cz::KeyCode::Char, now);
|
||||
{
|
||||
const auto dl =
|
||||
std::chrono::steady_clock::now() + std::chrono::seconds(8);
|
||||
while (ctrl.state().modal == cz::OverlayModal::TimelapseCompiling &&
|
||||
std::chrono::steady_clock::now() < dl) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
now += 20;
|
||||
ctrl.tick(now);
|
||||
}
|
||||
}
|
||||
|
||||
// Settings -> DirPicker -> [T] TextInput manual directory entry
|
||||
ctrl.handle_key('s', cz::KeyCode::Char, now);
|
||||
|
||||
Reference in New Issue
Block a user