libcvd
skipbuffer.h
1 #ifndef CVD_INCLUDE_SKIPBUFFER_H
2 #define CVD_INCLUDE_SKIPBUFFER_H
3 
4 #include <cvd/videobuffer.h>
5 
6 namespace CVD
7 {
8 
12 
13 template <typename T>
14 class SkipBuffer : public VideoBuffer<T>
15 {
16  public:
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 
33  {
34  return m_vidbuf.size();
35  }
36 
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 
50  {
51  return &m_vidbuf;
52  }
53 
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
virtual bool frame_pending()
Is there a frame waiting in the buffer? This function does not block.
Definition: skipbuffer.h:59
void put_frame(CVD::VideoFrame< T > *f)
Tell the buffer that you are finished with this frame.
Definition: skipbuffer.h:54
Base class which provides untyped access to video grabber objects.
Definition: videobuffer.h:39
All classes and functions are within the CVD namespace.
Definition: argb.h:6
A decorator class which wraps a VideoBuffer to return fields instead of the original frames (see also...
Definition: deinterlacebuffer.h:64
A decorator class which wraps a VideoBuffer to skip frames.
Definition: skipbuffer.h:14
Base class for objects which provide a typed video stream.
Definition: videobuffer.h:88
VideoBufferType::Type type()
Returns the type of the video stream.
Definition: videobuffer.h:136
virtual void seek_to(double)
Go to a particular point in the video buffer (only implemented in buffers of recorded video) ...
Definition: videobuffer.h:72
virtual void seek_to(double t)
Go to a particular point in the video buffer (only implemented in buffers of recorded video) ...
Definition: skipbuffer.h:64
SkipBuffer(CVD::VideoBuffer< T > &buf, bool do_seek, double seek, int drop_)
Construct a DeinterlaceBuffer by wrapping it around another VideoBuffer.
Definition: skipbuffer.h:21
virtual double frame_rate()
What is the (expected) frame rate of this video buffer, in frames per second?
Definition: skipbuffer.h:69
CVD::VideoFrame< T > * get_frame()
Returns the next frame from the buffer. This function blocks until a frame is ready.
Definition: skipbuffer.h:37
ImageRef size()
The size of the VideoFrames returns by this buffer.
Definition: skipbuffer.h:32
Definition: image_ref.h:29
A frame from a VideoBuffer.
Definition: videoframe.h:35
virtual RawVideoBuffer * source_buffer()
Which video grabber provides the source images for this video grabber.
Definition: skipbuffer.h:49
The buffer is flushable: it is live and VideoBuffer::frame_pending() returns an accurate result...
Definition: videobuffer.h:26