Bound desktop decoder work and drain Android codec with monotonic EOS timestamps

This commit is contained in:
evgeny committed 2026-10-14 00:04:08 +02:00
1 parent 9c01535c78
commit be7c3c5811
2 files changed
+18 -5

No files matched your search

+10
View File
@@ -309,6 +309,11 @@ void StreamPlayerWindow::decode() {
int received;
while ((received = avcodec_receive_frame(decoder, frame)) == 0) {
decoded++;
if (frame->width <= 0 || frame->width > 4096 || frame->height <= 0 || frame->height > 4096) {
DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "desktop H264 dimensions invalid id=%llu size=%dx%d",
(unsigned long long)p.id, frame->width, frame->height);
fail(text("Invalid stream video dimensions")); p.running = false; break;
}
int64_t pts = frame->best_effort_timestamp == AV_NOPTS_VALUE ? (int64_t)record.pts : frame->best_effort_timestamp;
{ std::lock_guard<std::mutex> guard(p.lock); if (pts < p.clock(nowUs()) - 100000) { discarded++; continue; } }
converter = sws_getCachedContext(converter, frame->width, frame->height, (AVPixelFormat)frame->format,
@@ -322,6 +327,11 @@ void StreamPlayerWindow::decode() {
}
if (record.format.rotation) image = image.transformed(QTransform().rotate(record.format.rotation));
std::lock_guard<std::mutex> guard(p.lock);
if (p.videos.size() >= 4) {
DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "desktop video preparation exceeded id=%llu frames=%zu",
(unsigned long long)p.id, p.videos.size());
fail(text("Stream video decoder failed")); p.running = false; break;
}
p.videoBytes += (size_t)image.sizeInBytes(); p.videos.push_back({std::move(image), pts});
}
if (received != AVERROR(EAGAIN) && received != AVERROR_EOF && p.running) {