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