From 2a8cef2947b2d8e436dbec331ac6454d6c9df105 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Mon, 13 Apr 2026 18:14:28 -0400 Subject: Single frame -> Static Signed-off-by: Andrew Opalach --- src/buffer/video.c | 22 +++++++++++----------- src/buffer/video.h | 2 +- src/buffer/video_null.h | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/buffer') diff --git a/src/buffer/video.c b/src/buffer/video.c index 5a469a4..fac08b9 100644 --- a/src/buffer/video.c +++ b/src/buffer/video.c @@ -33,7 +33,7 @@ bool camu_video_buffer_init(struct camu_video_buffer *buf, struct camu_clock *cl buf->latency = 0.0; atomic_store(f64)(&buf->pts, -1.0, AL_ATOMIC_RELAXED); buf->seek_pts = -1.0; - buf->single_frame = true; + buf->is_static = true; buf->queue = NULL; buf->buffered = false; buf->weighted_first_read = false; @@ -55,7 +55,7 @@ bool camu_video_buffer_configure(struct camu_video_buffer *buf, struct camu_code const char *format_name = camu_pixel_format_name(fmt->format); switch (stream->mode) { case CAMU_NORMAL: { - buf->single_frame = true; + buf->is_static = true; buf->avg_frame_duration = 0.0; log_info("Stream: %s (%ux%u) IMAGE.", format_name, fmt->width, fmt->height); break; @@ -63,8 +63,8 @@ bool camu_video_buffer_configure(struct camu_video_buffer *buf, struct camu_code #ifdef CAMU_HAVE_FFMPEG case CAMU_FFMPEG_COMPAT: { AVRational frame_rate = stream->av.stream->avg_frame_rate; - buf->single_frame = stream->duration == 0 || frame_rate.den == 0; - if (buf->single_frame) { + buf->is_static = stream->duration == 0 || frame_rate.den == 0; + if (buf->is_static) { buf->avg_frame_duration = 0.0; log_info("Stream: %s (%ux%u) IMAGE.", format_name, fmt->width, fmt->height); } else { @@ -131,7 +131,7 @@ static bool push_av_frame_internal(struct camu_video_buffer *buf, AVFrame *frame f64 pts = frame->best_effort_timestamp * av_q2d(stream->time_base); f64 base_pts = atomic_load(f64)(&buf->pts, AL_ATOMIC_ACQUIRE); f64 duration = camu_ff_frame_duration(frame) * av_q2d(stream->time_base); - if (!buf->single_frame && frame_is_late(buf->clock, base_pts, pts, duration)) { + if (!buf->is_static && frame_is_late(buf->clock, base_pts, pts, duration)) { log_trace("Discarding late frame with PTS %f.", pts); return false; } @@ -152,8 +152,8 @@ void camu_video_buffer_push(struct camu_video_buffer *buf, struct camu_codec_fra { u8 flow = atomic_load(u32)(&buf->flow, AL_ATOMIC_ACQUIRE); if (flow != FLOWING) { - // A single frame will be FLUSHED after any push(). - if (buf->single_frame) { + // A static buffer will be FLUSHED after any push(). + if (buf->is_static) { log_warn("Unexpected duplicate frame received."); } camu_codec_frame_discard(frame); @@ -182,9 +182,9 @@ void camu_video_buffer_push(struct camu_video_buffer *buf, struct camu_codec_fra } s32 count = buf->queue->count(buf->queue); - if (!buf->buffered && (buf->single_frame || count >= BUFFER_MARK_BUFFERED)) { - // Preserve order of: set flow -> flush -> callback, for single frames. - if (buf->single_frame) { + if (!buf->buffered && (buf->is_static || count >= BUFFER_MARK_BUFFERED)) { + // Preserve order of: set flow -> flush -> callback, for static buffers. + if (buf->is_static) { atomic_store(u32)(&buf->flow, FLUSHED, AL_ATOMIC_RELEASE); buf->queue->flush(buf->queue); } @@ -240,7 +240,7 @@ bool camu_video_buffer_read(struct camu_video_buffer *buf, void *out, bool *weig al_assert(buf->buffered); f64 base_pts = atomic_load(f64)(&buf->pts, AL_ATOMIC_ACQUIRE); - if (!buf->single_frame) { + if (!buf->is_static) { bool allow_set = !buf->weighted_first_read; bool armed_for_pause = false; f64 pts = camu_clock_get_pts(buf->clock, buf->latency, allow_set, &armed_for_pause); diff --git a/src/buffer/video.h b/src/buffer/video.h index 112688a..19dfd6e 100644 --- a/src/buffer/video.h +++ b/src/buffer/video.h @@ -19,7 +19,7 @@ struct camu_video_buffer { atomic(f64) pts; f64 seek_pts; - bool single_frame; + bool is_static; f64 avg_frame_duration; struct camu_scaler_format fmt; diff --git a/src/buffer/video_null.h b/src/buffer/video_null.h index da9d969..90eb2c2 100644 --- a/src/buffer/video_null.h +++ b/src/buffer/video_null.h @@ -9,7 +9,7 @@ struct camu_video_buffer { struct camu_codec_stream *stream; f64 seek_pts; - bool single_frame; + bool is_static; f64 avg_frame_duration; #ifdef CAMU_SCREEN_THREADED atomic(bool) ref; @@ -28,7 +28,7 @@ AL_IGNORE_WARNING("-Wunused-function") static bool camu_video_buffer_init(struct camu_video_buffer *buf, struct camu_clock *clock) { (void)clock; - buf->single_frame = true; + buf->is_static = true; buf->avg_frame_duration = 0.0; #ifdef CAMU_SCREEN_THREADED al_atomic_store(bool)(&buf->ref, false, AL_ATOMIC_RELAXED); -- cgit v1.2.3-101-g0448