libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
motionband.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_PROAV
13#include <promeki/namespace.h>
14#include <promeki/array.h>
15#include <promeki/list.h>
16#include <promeki/error.h>
17#include <promeki/color.h>
18#include <promeki/imagedesc.h>
21
22PROMEKI_NAMESPACE_BEGIN
23
118class MotionBand {
119 public:
121 enum Position {
122 Bottom = 0,
123 Top = 1
124 };
125
127 static constexpr int DefaultHeight = 16;
128
130 MotionBand();
131
133 ~MotionBand();
134
135 MotionBand(const MotionBand &) = delete;
136 MotionBand &operator=(const MotionBand &) = delete;
137
139 bool enabled() const { return _enabled; }
140
149 void setEnabled(bool val);
150
152 int height() const { return _height; }
153
163 void setHeight(int lines);
164
166 int sequenceLength() const { return _sequenceLength; }
167
176 void setSequenceLength(int frames);
177
179 int offset() const { return _offset; }
180
189 void setOffset(int frames);
190
192 Position position() const { return _position; }
193
197 void setPosition(Position p);
198
200 int borderWidth() const { return _borderWidth; }
201
203 void setBorderWidth(int pixels);
204
206 const Color &backgroundColor() const { return _backgroundColor; }
207
209 void setBackgroundColor(const Color &c);
210
212 const Color &markerColor() const { return _markerColor; }
213
215 void setMarkerColor(const Color &c);
216
218 const Color &borderColor() const { return _borderColor; }
219
221 void setBorderColor(const Color &c);
222
234 int reservedLines() const { return _enabled ? _height : 0; }
235
253 Error apply(UncompressedVideoPayload &inout, uint64_t frameCount) const;
254
265 void setAllocator(MediaIOAllocator::Ptr allocator);
266
268 MediaIOAllocator::Ptr allocator() const { return _allocator; }
269
277 void invalidateCache() const;
278
279 private:
280 bool _enabled = false;
281 int _height = DefaultHeight;
282 int _sequenceLength = 0;
283 int _offset = 0;
284 Position _position = Position::Bottom;
285 int _borderWidth = 4;
286 Color _backgroundColor;
287 Color _markerColor;
288 Color _borderColor;
289
290 MediaIOAllocator::Ptr _allocator;
291
292 // Cache: one slot per cycle frame, lazily filled on
293 // first request. All slots are sized to the same
294 // (imageWidth x effectiveHeight) and rendered in the
295 // descriptor's pixel format so apply() is just a
296 // plane-by-plane memcpy.
297 mutable List<UncompressedVideoPayload::Ptr> _cache;
298 mutable size_t _cacheImgWidth = 0;
299 mutable size_t _cacheImgHeight = 0;
300 mutable int _cachePixelFormatId = 0;
301 mutable int _cacheEffectiveHeight = 0;
302
308 int effectiveBandHeight(const ImageDesc &target) const;
309
314 UncompressedVideoPayload::Ptr cachedFrame(int frameInCycle, const ImageDesc &target) const;
315
320 void renderFrame(UncompressedVideoPayload &out, int frameInCycle) const;
321
328 ImageDesc rgbScratchDesc(const ImageDesc &target, int bandHeight) const;
329
335 ImageDesc bandDesc(const ImageDesc &target, int bandHeight) const;
336
341 int bandTopY(const ImageDesc &target, int bandHeight) const;
342};
343
344PROMEKI_NAMESPACE_END
345
346#endif // PROMEKI_ENABLE_PROAV