1 #ifndef _PBO_FRAME_ALLOCATOR
2 #define _PBO_FRAME_ALLOCATOR 1
11 #include "bmusb/bmusb.h"
13 // An allocator that allocates straight into OpenGL pinned memory.
14 // Meant for video frames only. We use a queue rather than a stack,
15 // since we want to maximize pipelineability.
16 class PBOFrameAllocator : public bmusb::FrameAllocator {
18 // Note: You need to have an OpenGL context when calling
20 PBOFrameAllocator(size_t frame_size,
21 GLuint width, GLuint height,
22 size_t num_queued_frames = 16, // FIXME: should be 6
23 GLenum buffer = GL_PIXEL_UNPACK_BUFFER_ARB,
24 GLenum permissions = GL_MAP_WRITE_BIT,
25 GLenum map_bits = GL_MAP_FLUSH_EXPLICIT_BIT);
26 ~PBOFrameAllocator() override;
27 Frame alloc_frame() override;
28 void release_frame(Frame frame) override;
33 // The second set is only used for the second field of interlaced inputs.
34 GLuint tex_y[2], tex_cbcr[2];
35 GLuint last_width[2], last_height[2];
36 bool last_interlaced, last_has_signal, last_is_connected;
37 unsigned last_frame_rate_nom, last_frame_rate_den;
41 std::mutex freelist_mutex;
42 std::queue<Frame> freelist;
44 std::unique_ptr<Userdata[]> userdata;
47 #endif // !defined(_PBO_FRAME_ALLOCATOR)