Debian Codegraph @

cvd/video/skipbuffer.h

raw symbols SCIP
1 #ifndef CVD_INCLUDE_SKIPBUFFER_H
2 #define CVD_INCLUDE_SKIPBUFFER_H
3
4 #include <cvd/videobuffer.h>
5
6 namespace CVD
7 {
8
9 /// A decorator class which wraps a VideoBuffer to skip frames
10 /// @param T The pixel type of the original VideoBuffer
11 /// @ingroup gVideoBuffer
12
13 template <typename T>
14 class SkipBuffer : public VideoBuffer<T>
15 {
16 public:
17 typedef DeinterlaceBufferFields Fields;
18 /// Construct a DeinterlaceBuffer by wrapping it around another VideoBuffer
19 /// @param buf The buffer that will provide the raw frames
20 /// @param fields The fields to
21 SkipBuffer(CVD::VideoBuffer<T>& buf, bool do_seek, double seek, int drop_)
22 : VideoBuffer<T>(buf.type())
23 , m_vidbuf(buf)
24 , drop(drop_)
25 {
26 if(do_seek)
27 buf.seek_to(seek);
28 }
29
30 /// The size of the VideoFrames returns by this buffer. This will be half the
31 /// height of the original frames.
32 ImageRef size()
33 {
34 return m_vidbuf.size();
35 }
36
37 CVD::VideoFrame<T>* get_frame()
38 {
39 CVD::VideoFrame<T>* f = m_vidbuf.get_frame();
40
41 for(int i = 0; i < drop && (m_vidbuf.type() == VideoBufferType::Flushable || m_vidbuf.frame_pending()); i++)
42 {
43 m_vidbuf.put_frame(m_vidbuf.get_frame());
44 }
45
46 return f;
47 }
48
49 virtual RawVideoBuffer* source_buffer()
50 {
51 return &m_vidbuf;
52 }
53
54 void put_frame(CVD::VideoFrame<T>* f)
55 {
56 return m_vidbuf.put_frame(f);
57 }
58
59 virtual bool frame_pending()
60 {
61 return m_vidbuf.frame_pending();
62 }
63
64 virtual void seek_to(double t)
65 {
66 return m_vidbuf.seek_to(t);
67 }
68
69 virtual double frame_rate()
70 {
71 return m_vidbuf.frame_rate();
72 }
73
74 private:
75 CVD::VideoBuffer<T>& m_vidbuf;
76 int drop;
77 };
78 }
79
80 #endif