Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
timings.cpp
Go to the documentation of this file.
1/*
2 Timings - timing specifications for a frame quantised data stream
3
4 Copyright (C)
5 2012, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12* *****************************************************************/
13
14
25#include "lib/time/formats.hpp"
27#include "lib/rational.hpp"
28
29
30namespace steam {
31namespace play {
32
34 using lib::time::Time;
37 using lib::time::FSecs;
38
39 namespace { // Hard wired placeholder settings...
40
43
44 }//(End)hard wired settings
45
46
47 namespace { // hidden local details of the service implementation....
48
49 inline PQuant
51 {
52 return PQuant (new lib::time::FixedFrameQuantiser (fps));
53 }
54
55 } // (End) hidden service impl details
56
57
58
70 : grid_{buildStandardGridForFramerate(fps)}
71 , playbackUrgency {ASAP}
72 , playbackSpeed {1}
73 , scheduledDelivery{Time::NEVER}
74 , outputLatency{Duration::NIL}
75 , engineLatency{DEFAULT_ENGINE_LATENCY}
76 {
77 ENSURE (grid_);
78 }
79
80 Timings::Timings (FrameRate fps, Time realTimeAnchor)
81 : grid_{buildStandardGridForFramerate(fps)}
82 , playbackUrgency {TIMEBOUND}
83 , playbackSpeed {1}
84 , scheduledDelivery{realTimeAnchor}
85 , outputLatency {Duration::NIL}
86 , engineLatency{DEFAULT_ENGINE_LATENCY}
87 {
88 ENSURE (grid_);
89 }
90
92
93
97
98
99
101 bool
103 {
104 return bool(grid_)
105 and (( (ASAP == playbackUrgency or NICE == playbackUrgency)
107 or
110 );
111 }
112
113 Time
115 {
116 return Time(grid_->timeOf(0));
117 }
118
119
120 Time
121 Timings::getFrameStartAt (FrameCnt frameNr) const
122 {
123 return Time(grid_->timeOf(frameNr));
124 }
125
126
129 {
130 FrameCnt frameNr = grid_->gridPoint (refPoint);
131 return getFrameDurationAt(frameNr);
132 }
133
134
136 Timings::getFrameDurationAt (FrameCnt refFrameNr) const
137 {
138 return Offset (grid_->timeOf(refFrameNr), grid_->timeOf(refFrameNr + 1));
139 }
140
141
142 FrameCnt
144 {
145 FrameCnt frameNr = grid_->gridPoint (refPoint);
146 return grid_->timeOf(frameNr) == refPoint? frameNr
147 : frameNr+1;
148 }
149
150
151
163
164
165 Time
166 Timings::getTimeDue(FrameCnt frameOffset) const
167 {
169 {
170 REQUIRE (scheduledDelivery != Time::NEVER);
171 return scheduledDelivery
172 + getRealOffset (frameOffset);
173 }
174 else
175 return Time::NEVER;
176 }
177
178
179 Offset
180 Timings::getRealOffset (FrameCnt frameOffset) const
181 {
182 Offset nominalOffset (grid_->timeOf(0), grid_->timeOf(frameOffset));
183 return isOriginalSpeed()? nominalOffset
184 : nominalOffset * playbackSpeed;
186 }
187
188
191 {
192 UNIMPLEMENTED ("controlling the job planning rhythm");
193 }
194
195
196 FrameCnt
198 {
199 TimeVar breakingPoint = grid_->timeOf(anchorFrame);
200 breakingPoint += getPlanningChunkDuration();
201 FrameCnt nextFrame = grid_->gridPoint (breakingPoint);
202
203 ASSERT (breakingPoint <= grid_->timeOf(nextFrame));
204 ASSERT (breakingPoint > grid_->timeOf(nextFrame-1));
205
206 if (grid_->timeOf(nextFrame) == breakingPoint)
207 return nextFrame;
208 else
209 return nextFrame+1;
210 }
211
212
213
214 Timings
215 Timings::constrainedBy (Timings additionalConditions)
216 {
217 UNIMPLEMENTED ("how to combine timing constraints");
218 }
219
220
221
222}} // namespace steam::play
Duration is the internal Lumiera time metric.
Simple stand-alone Quantiser implementation based on a constant sized gird.
Framerate specified as frames per second.
static const FrameRate HALTED
Offset measures a distance in time.
basic constant internal time value.
a mutable time value, behaving like a plain number, allowing copy and re-accessing
Lumiera's internal time value datatype.
static const Time NEVER
border condition marker value. NEVER >= any time value
static const Time MIN
static const Time MAX
Generic frame timing specification.
Definition timings.hpp:87
FrameCnt getBreakPointAfter(TimeValue refPoint) const
the next grid point at or after the given reference time
Definition timings.cpp:143
bool isOriginalSpeed() const
Definition timings.hpp:187
Duration getPlanningChunkDuration() const
the minimum time span to be covered by frame calculation jobs planned in one sway.
Definition timings.cpp:190
lib::time::PQuant grid_
Definition timings.hpp:88
Time getOrigin() const
Definition timings.cpp:114
Duration getFrameDurationAt(TimeValue refPoint) const
Definition timings.cpp:128
FrameCnt establishNextPlanningChunkStart(FrameCnt anchorFrame) const
establish the time point to anchor the next planning chunk, in accordance with getPlanningChunkDurati...
Definition timings.cpp:197
Timings(FrameRate fps)
Create a default initialised Timing constraint record.
Definition timings.cpp:69
Time scheduledDelivery
a wall clock time corresponding to the Grid's origin. Can be Time::Never (=not time bound)
Definition timings.hpp:93
Time getFrameStartAt(FrameCnt frameNr) const
Definition timings.cpp:121
bool isValid() const
Consistency self-check.
Definition timings.cpp:102
static Timings DISABLED
marker for halted output
Definition timings.hpp:106
Timings constrainedBy(Timings additionalConditions)
Definition timings.cpp:215
Time getTimeDue(FrameCnt frameOffset) const
real time deadline for the given frame, without any latency.
Definition timings.cpp:166
Duration constantFrameTimingsInterval(TimeValue startPoint) const
the frame spacing and duration remains constant for some time...
Definition timings.cpp:159
Offset getRealOffset(FrameCnt frameOffset) const
calculate the given frame's distance from origin, but do so using the real time scale,...
Definition timings.cpp:180
boost::rational< FrameCnt > playbackSpeed
Definition timings.hpp:92
PlaybackUrgency playbackUrgency
Definition timings.hpp:91
Definition of time code formats This header is part of the Lumiera time and timecode handling library...
int64_t FrameCnt
relative framecount or frame number.
Definition digxel.hpp:310
std::shared_ptr< const Quantiser > PQuant
Definition formats.hpp:58
boost::rational< int64_t > FSecs
rational representation of fractional seconds
const Duration DEFAULT_JOB_PLANNING_TURNOVER(FSecs(3, 2))
PQuant buildStandardGridForFramerate(FrameRate fps)
Definition timings.cpp:50
Steam-Layer implementation namespace root.
Rational number support, based on boost::rational.
Support library to represent grid-aligned time specifications This is part of Lumiera's time and time...
How to define a timing specification or constraint.