some minor touchup

This commit is contained in:
David Bears 2026-01-16 11:10:18 -05:00
parent 921f8eb690
commit 7542ee4f8c
No known key found for this signature in database
GPG Key ID: FB975E12C69F7177
2 changed files with 16 additions and 14 deletions

View File

@ -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";
}

View File

@ -33,19 +33,19 @@ class QVideoOutputDevice ;
template<typename T, int N>
class NetQueue {
std::array<T, N> arr;
std::atomic<int> head = 0;
std::atomic<int> tail = 0;
std::atomic<int> mhead = 0;
std::atomic<int> 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