518{
520 if (!vc) {
522 "VideoFileReader: decode thread — container expired");
524 return;
525 }
526
527 const uint64_t total = vc->get_total_source_frames();
528 const uint32_t ring_cap = vc->get_ring_capacity();
531 : ring_cap / 4;
532
535 const uint64_t read_pos = vc->get_read_position()[0];
536
537 if (head >= total)
538 break;
539
540 const uint64_t buffered = (head > read_pos) ? (head - read_pos) : 0;
541
542 if (buffered >= static_cast<uint64_t>(ring_cap)) {
544 m_decode_cv.wait_for(lock, std::chrono::milliseconds(50), [&] {
546 return true;
548 const uint64_t rp = vc->get_read_position()[0];
549 const uint64_t ahead = (
h > rp) ? (
h - rp) : 0;
550 return ahead <= static_cast<uint64_t>(ring_cap -
threshold);
551 });
552 continue;
553 }
554
555 const uint64_t want = static_cast<uint64_t>(ring_cap) - buffered;
556 const uint64_t capped = std::min(want, total - head);
557 const uint64_t batch = std::min(capped,
559
561
562 if (decoded == 0)
563 break;
564 }
565
567}
#define MF_WARN(comp, ctx,...)
std::condition_variable m_decode_cv
uint64_t decode_batch(Kakshya::VideoFileContainer &vc, uint64_t batch_size)
Decode up to batch_size frames starting at m_decode_head.
uint32_t m_decode_batch_size
std::atomic< bool > m_decode_stop
std::weak_ptr< Kakshya::VideoFileContainer > m_container_ref
std::atomic< bool > m_decode_active
uint32_t m_refill_threshold
std::atomic< uint64_t > m_decode_head
std::mutex m_decode_mutex
@ FileIO
Filesystem I/O operations.
@ IO
Networking, file handling, streaming.