MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
FrameSeekProcessor.hpp
Go to the documentation of this file.
1#pragma once
2
4
6
7namespace MayaFlux::Kakshya {
8
9/**
10 * @class FrameSeekProcessor
11 * @brief FrameAccessProcessor whose read position follows a function of time.
12 *
13 * The video counterpart of the time-mapped read in CursorAccessProcessor. With a
14 * time map set, each process() call advances a clock by 1 / global fps seconds and
15 * reads the frame the map points at, so scrub, freeze, reverse, a tap trailing a
16 * live DynamicVideoStream (TimeMaps::lagged with the stream's frame rate) and
17 * stutter all work on video. Without a map it behaves exactly like
18 * FrameAccessProcessor.
19 *
20 * The map takes seconds since the last reset() and returns a position in frames.
21 * Positions wrap inside the loop region when the container loops, and are held at
22 * the first or last frame otherwise.
23 */
24class MAYAFLUX_API FrameSeekProcessor : public FrameAccessProcessor {
25public:
26 void on_attach(const std::shared_ptr<SignalSourceContainer>& container) override;
27
28 void process(const std::shared_ptr<SignalSourceContainer>& container) override;
29
30 /**
31 * @brief Drive the read position from a function of time.
32 *
33 * Passing a different map restarts the clock at zero. Passing the map already
34 * set is a no-op.
35 *
36 * @param map Time map, or null to go back to FrameAccessProcessor behaviour.
37 */
38 void set_time_map(const std::shared_ptr<const Kinesis::TimeMap>& map);
39
40 /**
41 * @brief Restart the time map over and over, with a length that can change.
42 *
43 * Needs a time map. The length map takes seconds since the last reset() and
44 * returns how long, in seconds, the repeat that starts then should last. Each
45 * repeat restarts the time map from zero.
46 *
47 * @param length Repeat length in seconds, or null for no repeating.
48 */
49 void set_repeat(const std::shared_ptr<const Kinesis::TimeMap>& length);
50
51 /**
52 * @brief Mix the two frames either side of a fractional position.
53 *
54 * Gives smooth slow motion at the cost of ghosting. Applies to 8-bit and
55 * 32-bit float formats; other formats read the nearer frame. Off by default.
56 */
57 void set_blend(bool enable) { m_blend = enable; }
58
59 /**
60 * @brief Trail a stream that is being written, by a lag that can change.
61 *
62 * Sets a time map that follows @p write_head at this processor's frame rate
63 * minus the lag, so the rate is the one frames are appended at. The clock
64 * restarts at zero, so pass the write head as it is now.
65 *
66 * @param write_head Index of the next frame to be written.
67 * @param lag Distance behind the head in frames, per second since the restart.
68 */
69 void trail(double write_head, Kinesis::TimeMap lag);
70
71 /**
72 * @brief Trail a stream that is being written by a fixed number of frames.
73 * @param write_head Index of the next frame to be written.
74 * @param lag_frames Distance behind the head in frames.
75 */
76 void trail(double write_head, double lag_frames);
77
78 /**
79 * @brief Restart the clock and the repeat.
80 */
81 void reset();
82
83private:
84 std::shared_ptr<const Kinesis::TimeMap> m_time_map;
85 std::shared_ptr<const Kinesis::TimeMap> m_repeat;
86 uint64_t m_ticks {};
87 uint64_t m_repeat_start {};
88 uint64_t m_repeat_length {};
89 bool m_blend {};
90
91 double position_at(uint64_t tick);
92};
93
94} // namespace MayaFlux::Kakshya
uint64_t length
Definition Composite.cpp:11
std::shared_ptr< const Kinesis::TimeMap > m_time_map
void set_blend(bool enable)
Mix the two frames either side of a fractional position.
std::shared_ptr< const Kinesis::TimeMap > m_repeat
FrameAccessProcessor whose read position follows a function of time.
Typed, composable, stateless callable from domain D to range R.
Definition Tendency.hpp:22