Skip to content

Commit ff7b84b

Browse files
authored
Improve backwards scanning to skip no more than one checkpoint (#18328)
1 parent 7b2912b commit ff7b84b

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

input/bsv/bsvmovie.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,12 +1677,15 @@ bool bsv_movie_peek_frame_info(bsv_movie_t *movie, uint8_t *token, uint64_t *len
16771677
bool movie_find_checkpoint_before(bsv_movie_t *movie, int64_t frame, bool consider_paused,
16781678
int64_t *cp_pos_out, int64_t *cp_frame_out)
16791679
{
1680-
/* skip to prev needs to go back at least 60 frames if rewinding when not paused */
16811680
runloop_state_t *runloop_st = runloop_state_get_ptr();
16821681
bool paused = !!(runloop_st->flags & RUNLOOP_FLAG_PAUSED) || consider_paused;
1683-
const int64_t prev_skip_min_distance = 60;
1682+
/* skip to prev would prefer to go back at least 30 frames if
1683+
rewinding when not paused, but won't skip over more than one
1684+
checkpoint while going backwards. */
1685+
const int64_t prev_skip_min_distance = 30;
16841686
int64_t target_frame = frame, cur_frame = 0;
16851687
int64_t initial_pos, cp_pos=-1, cp_frame=-1;
1688+
int64_t maybe_last_frame = -1, maybe_last_pos = -1;
16861689
uint64_t frame_len;
16871690
uint8_t tok;
16881691
if (!movie || movie->version == 0)
@@ -1702,6 +1705,16 @@ bool movie_find_checkpoint_before(bsv_movie_t *movie, int64_t frame, bool consid
17021705
cp_pos = intfstream_tell(movie->file);
17031706
cp_frame = cur_frame;
17041707
}
1708+
else
1709+
{
1710+
if (maybe_last_pos > 0)
1711+
{
1712+
cp_pos = maybe_last_pos;
1713+
cp_frame = maybe_last_frame;
1714+
}
1715+
maybe_last_pos = intfstream_tell(movie->file);
1716+
maybe_last_frame = cur_frame;
1717+
}
17051718
}
17061719
cur_frame += 1;
17071720
intfstream_seek(movie->file, frame_len, SEEK_CUR);

menu/menu_setting.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11597,10 +11597,12 @@ static bool setting_append_list(
1159711597
parent_group,
1159811598
general_write_handler,
1159911599
general_read_handler);
11600-
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint_special;
11600+
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
1160111601
(*list)[list_info->index - 1].get_string_representation =
1160211602
&setting_get_string_representation_uint_replay_checkpoint_interval;
11603-
menu_settings_list_current_add_range(list, list_info, 0, 3600, 60, true, true);
11603+
menu_settings_list_current_add_range(list, list_info, 0, 0, 1, true, false);
11604+
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_CMD_APPLY_AUTO);
11605+
1160411606

1160511607
CONFIG_BOOL(
1160611608
list, list_info,

0 commit comments

Comments
 (0)