1 #ifndef _PBO_FRAME_ALLOCATOR
2 #define _PBO_FRAME_ALLOCATOR 1
10 #include "bmusb/bmusb.h"
12 // An allocator that allocates straight into OpenGL pinned memory.
13 // Meant for video frames only. We use a queue rather than a stack,
14 // since we want to maximize pipelineability.
15 class PBOFrameAllocator : public FrameAllocator {
17 // Note: You need to have an OpenGL context when calling
19 PBOFrameAllocator(size_t frame_size,
20 GLuint width, GLuint height,
21 size_t num_queued_frames = 16, // FIXME: should be 6
22 GLenum buffer = GL_PIXEL_UNPACK_BUFFER_ARB,
23 GLenum permissions = GL_MAP_WRITE_BIT,
24 GLenum map_bits = GL_MAP_FLUSH_EXPLICIT_BIT);
25 ~PBOFrameAllocator() override;
26 Frame alloc_frame() override;
27 void release_frame(Frame frame) override;
31 GLuint tex_y, tex_cbcr;
37 std::mutex freelist_mutex;
38 std::queue<Frame> freelist;
40 std::unique_ptr<Userdata[]> userdata;
43 #endif // !defined(_PBO_FRAME_ALLOCATOR)