From 7542ee4f8cfef13b1df8ecdd5faac4085cc6c584 Mon Sep 17 00:00:00 2001 From: David Bears Date: Fri, 16 Jan 2026 11:10:18 -0500 Subject: [PATCH] some minor touchup --- plugins/VOIP/gui/VideoProcessor.cpp | 10 ++++++---- plugins/VOIP/gui/VideoProcessor.h | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/plugins/VOIP/gui/VideoProcessor.cpp b/plugins/VOIP/gui/VideoProcessor.cpp index 1d62a5dd4..cc7b72291 100644 --- a/plugins/VOIP/gui/VideoProcessor.cpp +++ b/plugins/VOIP/gui/VideoProcessor.cpp @@ -156,7 +156,7 @@ VideoProcessor::~VideoProcessor() while(!_encoded_out_queue.empty()) { - _encoded_out_queue.getTail().clear(); + _encoded_out_queue.tail().clear(); _encoded_out_queue.pop() ; } } @@ -355,7 +355,7 @@ bool JPEGVideo::encodeData(const QImage& image,uint32_t /* size_hint */, NetQueu // check if we make a diff image, or if we use the full frame. if(dst.full()) return false; - RsVOIPDataChunk& voip_chunk = dst.getHead(); + RsVOIPDataChunk& voip_chunk = dst.head(); QImage encoded_frame ; bool differential_frame ; @@ -741,7 +741,7 @@ bool FFmpegVideo::encodeData(const QImage& image, uint32_t target_encoding_bitra else #endif { - RsVOIPDataChunk& voip_chunk = dst.getHead(); + RsVOIPDataChunk& voip_chunk = dst.head(); voip_chunk.data = rs_malloc(pkt.size + HEADER_SIZE) ; if(!voip_chunk.data) { @@ -843,9 +843,11 @@ bool FFmpegVideo::decodeData(const RsVOIPDataChunk& chunk, QImage& image) << image.width() << "x" << image.height() << std::endl; #endif - // clear out the internal buffer and drop the frames to avoid latency + // Clear out the internal buffer and drop the frames to avoid latency. // Video decoders typically only create one frame per packet, so this // shouldn't happen under normal circumstances. + // Ideally, we would render the most recent frame and discard earlier ones, + // but that would require copying of frames that is not worth it. while(!avcodec_receive_frame(decoding_context, decoding_frame_buffer)) { std::cerr << "warning: dropping decoded frame"; } diff --git a/plugins/VOIP/gui/VideoProcessor.h b/plugins/VOIP/gui/VideoProcessor.h index 3ad3d72b1..a747ec344 100644 --- a/plugins/VOIP/gui/VideoProcessor.h +++ b/plugins/VOIP/gui/VideoProcessor.h @@ -33,19 +33,19 @@ class QVideoOutputDevice ; template class NetQueue { std::array arr; - std::atomic head = 0; - std::atomic tail = 0; + std::atomic mhead = 0; + std::atomic mtail = 0; public: - bool full() const { return head - tail == N; } - T& getHead() { return arr[head % N]; } - void push() { head++; } - bool push(const T& e) { return !full() && ((arr[head++ % N] = e), true); } + bool full() const { return mhead - mtail == N; } + T& head() { return arr[mhead % N]; } + void push() { mhead++; } + bool push(const T& e) { return !full() && ((arr[mhead++ % N] = e), true); } - bool empty() const { return head == tail; } - T& getTail() { return arr[tail % N]; } - void pop() { tail++; } - bool pop(T& e) { return !empty() && ((e = arr[tail++ % N]), true); } + bool empty() const { return mhead == mtail; } + T& tail() { return arr[mtail % N]; } + void pop() { mtail++; } + bool pop(T& e) { return !empty() && ((e = arr[mtail++ % N]), true); } }; class VideoCodec