MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ seek()

bool MayaFlux::IO::VideoFileReader::seek ( const std::vector< uint64_t > &  position)
overridevirtual

Seek to a specific position in the file.

Parameters
positionTarget position in N-dimensional space.
Returns
true if seek was successful.

Implements MayaFlux::IO::FileReader.

Definition at line 567 of file VideoFileReader.cpp.

568{
569 if (position.empty())
570 return false;
571
572 const uint64_t target_frame = position[0];
573
575
576 std::shared_ptr<VideoStreamContext> video;
577 std::shared_ptr<FFmpegDemuxContext> demux;
578 {
579 std::shared_lock lock(m_context_mutex);
580 if (!m_demux || !m_video || !m_video->is_valid()) {
581 set_error("Cannot seek: reader not open");
582 return false;
583 }
584 video = m_video;
585 demux = m_demux;
586 }
587
588 if (!seek_internal(demux, video, target_frame))
589 return false;
590
591 m_decode_head.store(target_frame);
592
593 auto vc = m_container_ref.lock();
594 if (!vc)
595 return true;
596
597 vc->invalidate_ring();
598 vc->set_read_position({ target_frame });
599
600 const uint64_t total = vc->get_total_source_frames();
601 const uint64_t batch = std::min(
602 static_cast<uint64_t>(m_decode_batch_size),
603 total > target_frame ? total - target_frame : 0UL);
604
605 decode_batch(*vc, batch);
606
607 if (m_decode_head.load() < total)
609
610 return true;
611}
uint64_t decode_batch(Kakshya::VideoFileContainer &vc, uint64_t batch_size)
Decode up to batch_size frames starting at m_decode_head.
void set_error(const std::string &msg) const
std::weak_ptr< Kakshya::VideoFileContainer > m_container_ref
std::shared_ptr< FFmpegDemuxContext > m_demux
bool seek_internal(const std::shared_ptr< FFmpegDemuxContext > &demux, const std::shared_ptr< VideoStreamContext > &video, uint64_t frame_position)
std::shared_ptr< VideoStreamContext > m_video
std::atomic< uint64_t > m_decode_head

References decode_batch(), m_container_ref, m_context_mutex, m_decode_batch_size, m_decode_head, m_demux, m_video, seek_internal(), set_error(), start_decode_thread(), and stop_decode_thread().

+ Here is the call graph for this function: