MayaFlux 0.4.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 572 of file VideoFileReader.cpp.

573{
574 if (position.empty())
575 return false;
576
577 const uint64_t target_frame = position[0];
578
580
581 std::shared_ptr<VideoStreamContext> video;
582 std::shared_ptr<FFmpegDemuxContext> demux;
583 {
584 std::shared_lock lock(m_context_mutex);
585 if (!m_demux || !m_video || !m_video->is_valid()) {
586 set_error("Cannot seek: reader not open");
587 return false;
588 }
589 video = m_video;
590 demux = m_demux;
591 }
592
593 if (!seek_internal(demux, video, target_frame))
594 return false;
595
596 m_decode_head.store(target_frame);
597
598 auto vc = m_container_ref.lock();
599 if (!vc)
600 return true;
601
602 vc->invalidate_ring();
603 vc->set_read_position({ target_frame });
604
605 const uint64_t total = vc->get_total_source_frames();
606 const uint64_t batch = std::min(
607 static_cast<uint64_t>(m_decode_batch_size),
608 total > target_frame ? total - target_frame : 0UL);
609
610 decode_batch(*vc, batch);
611
612 if (m_decode_head.load() < total)
614
615 return true;
616}
glm::vec3 position
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, position, seek_internal(), set_error(), start_decode_thread(), and stop_decode_thread().

+ Here is the call graph for this function: