X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fpbo_frame_allocator.h;h=eee25ce906d443f6656935c33e3f9cfda476af9b;hb=76a40fb903cb2d9b47473d48c5eaad97d957d6e7;hp=d7559dcfa8abfaa3c882d572780f43bc91203cca;hpb=575f6eb1b052bb1291987753b1a8cccc7f1e3ab3;p=nageru
diff --git a/nageru/pbo_frame_allocator.h b/nageru/pbo_frame_allocator.h
index d7559dc..eee25ce 100644
--- a/nageru/pbo_frame_allocator.h
+++ b/nageru/pbo_frame_allocator.h
@@ -36,6 +36,17 @@ public:
Frame create_frame(size_t width, size_t height, size_t stride) override;
void release_frame(Frame frame) override;
+ // NOTE: Does not check the buffer types; they are just assumed to be compatible.
+ void reconfigure(bmusb::PixelFormat pixel_format,
+ size_t frame_size,
+ GLuint width, GLuint height,
+ unsigned card_index,
+ MJPEGEncoder *mjpeg_encoder = nullptr,
+ size_t num_queued_frames = 16,
+ GLenum buffer = GL_PIXEL_UNPACK_BUFFER_ARB,
+ GLenum permissions = GL_MAP_WRITE_BIT,
+ GLenum map_bits = GL_MAP_FLUSH_EXPLICIT_BIT);
+
struct Userdata {
GLuint pbo;
@@ -60,6 +71,7 @@ public:
unsigned last_frame_rate_nom, last_frame_rate_den;
bool has_last_subtitle = false;
std::string last_subtitle;
+ movit::RGBTriplet white_balance{1.0f, 1.0f, 1.0f};
// These are the source of the âdata_copyâ member in Frame,
// used for MJPEG encoding. There are three possibilities:
@@ -79,10 +91,12 @@ public:
uint8_t *data_copy_malloc;
MJPEGEncoder::VAResources va_resources;
MJPEGEncoder::ReleaseVAResources va_resources_release;
+
+ int generation;
};
private:
- void init_frame(size_t frame_idx, size_t frame_size, GLuint width, GLuint height, GLenum permissions, GLenum map_bits);
+ void init_frame(size_t frame_idx, size_t frame_size, GLuint width, GLuint height, GLenum permissions, GLenum map_bits, int generation);
void destroy_frame(Frame *frame);
unsigned card_index;
@@ -92,6 +106,20 @@ private:
std::queue freelist;
GLenum buffer;
std::unique_ptr userdata;
+
+ // Used only for reconfigure(), to check whether we can do without.
+ size_t frame_size;
+ size_t num_queued_frames;
+ GLuint width, height;
+ GLenum permissions;
+ GLenum map_bits;
+ int generation = 0; // Under freelist_mutex.
+
+ struct LingeringGeneration {
+ std::unique_ptr userdata;
+ size_t num_frames_left;
+ };
+ std::map lingering_generations;
};
#endif // !defined(_PBO_FRAME_ALLOCATOR)