Fix warp modes w/ reduce stutters

This commit is contained in:
Yukino Song
2025-07-16 01:22:21 +08:00
parent 2a97b3cbff
commit fae6da3fb7
2 changed files with 7 additions and 18 deletions

View File

@@ -440,6 +440,7 @@ namespace config {
false, // headless_mode false, // headless_mode
true, // limit_framerate true, // limit_framerate
false, // double_refreshrate false, // double_refreshrate
28, // qp 28, // qp
0, // hevc_mode 0, // hevc_mode

View File

@@ -1923,10 +1923,9 @@ namespace video {
}); });
// set minimum frame time based on client-requested target framerate // set minimum frame time based on client-requested target framerate
auto minimum_frame_time = std::chrono::milliseconds(1000 / config.framerate); auto minimum_frame_time = std::chrono::nanoseconds(1000ms) * 1000 / config.encodingFramerate;
auto capture_frame_threshold = std::chrono::microseconds(1000 * 1000 / config.framerate); auto encode_frame_threshold = std::chrono::nanoseconds(1000ms) * 1000 / config.encodingFramerate;
auto encode_frame_threshold = std::chrono::microseconds(1000 * 1000 / config.encodingFramerate); auto frame_variation_threshold = encode_frame_threshold / 4;
BOOST_LOG(info) << "Capture Frame threshold: "sv << capture_frame_threshold;
BOOST_LOG(info) << "Encoding Frame threshold: "sv << encode_frame_threshold; BOOST_LOG(info) << "Encoding Frame threshold: "sv << encode_frame_threshold;
auto shutdown_event = mail->event<bool>(mail::shutdown); auto shutdown_event = mail->event<bool>(mail::shutdown);
@@ -2001,29 +2000,18 @@ namespace video {
if (auto img = images->pop(minimum_frame_time)) { if (auto img = images->pop(minimum_frame_time)) {
frame_timestamp = img->frame_timestamp; frame_timestamp = img->frame_timestamp;
// If new frame comes in way too fast, just drop // If new frame comes in way too fast, just drop
if (*frame_timestamp < (next_frame_start - capture_frame_threshold / 2)) { if (*frame_timestamp < (next_frame_start - frame_variation_threshold)) {
continue; continue;
} }
if (session->convert(*img)) { if (session->convert(*img)) {
BOOST_LOG(error) << "Could not convert image"sv; BOOST_LOG(error) << "Could not convert image"sv;
break; break;
} }
next_frame_start = *frame_timestamp + encode_frame_threshold;
} else if (!images->running()) { } else if (!images->running()) {
break; break;
} }
if (frame_timestamp) {
auto frame_diff = *frame_timestamp - next_frame_start;
next_frame_start = *frame_timestamp + encode_frame_threshold;
if (frame_diff > encode_frame_threshold / 2) {
next_frame_start = *frame_timestamp + encode_frame_threshold;
} else {
frame_timestamp = next_frame_start;
next_frame_start += encode_frame_threshold;
}
}
} }
if (encode(frame_nr++, *session, packets, channel_data, frame_timestamp)) { if (encode(frame_nr++, *session, packets, channel_data, frame_timestamp)) {