From fb964ae47e1f2e32c0caa5bdb0aed3a1659e27ff Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Tue, 3 Mar 2026 09:01:43 +0100 Subject: [PATCH] vcomp/jpegxs: fix exitting when no frame sent eg. `uv -c jpegxs` (only) broken since 942a76725 (2026-02-24) The `stop` var was actually needed this so revert this occurence but improve to push to the encoder just if configured. --- src/video_compress/jpegxs.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/video_compress/jpegxs.cpp b/src/video_compress/jpegxs.cpp index 8a317168f..0ca59f3bd 100644 --- a/src/video_compress/jpegxs.cpp +++ b/src/video_compress/jpegxs.cpp @@ -100,6 +100,7 @@ struct state_video_compress_jpegxs { bool configured = 0; bool reconfiguring = 0; + bool stop = false; video_desc saved_desc; @@ -160,15 +161,18 @@ while (true) { auto frame = s->in_queue.pop(); if (!frame) { - { unique_lock lock(s->mtx); - svt_jpeg_xs_frame_t enc_input; - svt_jpeg_xs_frame_pool_get(s->frame_pool, &enc_input, /*blocking*/ 1); - enc_input.user_prv_ctx_ptr = JXS_POISON_PILL; - svt_jpeg_xs_encoder_send_picture(&s->encoder, &enc_input, /*blocking*/ 1); - s->frames_sent++; - } - s->cv_configured.notify_one(); + if (s->configured) { + svt_jpeg_xs_frame_t enc_input; + svt_jpeg_xs_frame_pool_get(s->frame_pool, &enc_input, /*blocking*/ 1); + enc_input.user_prv_ctx_ptr = JXS_POISON_PILL; + svt_jpeg_xs_encoder_send_picture(&s->encoder, &enc_input, /*blocking*/ 1); + s->frames_sent++; + } else { + s->stop = true; + lock.unlock(); + s->cv_configured.notify_one(); + } break; } @@ -227,10 +231,11 @@ static void jpegxs_worker_get(state_video_compress_jpegxs *s) { { unique_lock lock(s->mtx); s->cv_configured.wait(lock, [&]{ - return s->configured; + return s->configured || s->stop; }); - if (!s->configured) { + if (s->stop) { + s->out_queue.push({}); return; } }