diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2019-05-05 12:34:01 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2019-05-06 03:42:13 +0200 |
commit | 6eda8a85b84c4e661a8763429ae1978f8da7f9dd (patch) | |
tree | 5169e1bf6779f7442235f36a206a91e224cda05d /video-ps3eye/PS3EYEDriver/frame-queue.hpp | |
parent | 12dfd6dcf60d9fefef7f8723fb9bc5a21fdb5b61 (diff) |
video/ps3eye: WIP
Diffstat (limited to 'video-ps3eye/PS3EYEDriver/frame-queue.hpp')
-rw-r--r-- | video-ps3eye/PS3EYEDriver/frame-queue.hpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/video-ps3eye/PS3EYEDriver/frame-queue.hpp b/video-ps3eye/PS3EYEDriver/frame-queue.hpp new file mode 100644 index 00000000..8cee2223 --- /dev/null +++ b/video-ps3eye/PS3EYEDriver/frame-queue.hpp @@ -0,0 +1,33 @@ +#pragma once +#include "ps3eye.hpp" + +#include <mutex> +#include <condition_variable> + +struct FrameQueue final +{ + FrameQueue(uint32_t frame_size); + + inline uint8_t* ptr() { return frame_buffer.get(); } + uint8_t* Enqueue(); + + bool Dequeue(uint8_t* dest, int width, int height, ps3eye_camera::format fmt, bool flip_v); + static void DebayerGray(int frame_width, int frame_height, const uint8_t* inBayer, uint8_t* outBuffer); + + template<int nchannels> + static void set_alpha(uint8_t* destGreen); + + template<int nchannels> + void debayer_RGB(int frame_width, int frame_height, const uint8_t* inBayer, uint8_t* outBuffer, bool inBGR, bool flip_v); + +private: + std::unique_ptr<uint8_t[]> frame_buffer; + std::mutex mutex; + std::condition_variable queue_cvar; + uint32_t frame_size = 0; + uint32_t head = 0; + uint32_t tail = 0; + uint32_t available = 0; + + static constexpr unsigned num_frames = 4; +}; |