2 #define _IMAGE_INPUT_H 1
5 #include <movit/flat_input.h>
8 #include <condition_variable>
16 // An output that takes its input from a static image, loaded with ffmpeg.
17 // comes from a single 2D array with chunky pixels. The image is refreshed
18 // from disk about every second.
19 class ImageInput : public movit::FlatInput {
21 ImageInput(const std::string &filename);
23 std::string effect_type_id() const override { return "ImageInput"; }
24 void set_gl_state(GLuint glsl_program_num, const std::string& prefix, unsigned *sampler_num) override;
25 static void shutdown_updaters();
29 unsigned width, height;
30 std::unique_ptr<uint8_t[]> pixels;
31 timespec last_modified;
34 std::string filename, pathname;
35 std::shared_ptr<const Image> current_image;
37 static std::shared_ptr<const Image> load_image(const std::string &filename, const std::string &pathname);
38 static std::shared_ptr<const Image> load_image_raw(const std::string &pathname);
39 static void update_thread_func(const std::string &filename, const std::string &pathname, const timespec &first_modified);
40 static std::mutex all_images_lock;
41 static std::map<std::string, std::shared_ptr<const Image>> all_images;
42 static std::map<std::string, std::thread> update_threads;
44 static std::mutex threads_should_quit_mu;
45 static bool threads_should_quit; // Under threads_should_quit_mu.
46 static std::condition_variable threads_should_quit_modified; // Signals when threads_should_quit is set.
49 #endif // !defined(_IMAGE_INPUT_H)