2 #define _IMAGE_INPUT_H 1
12 #include <movit/flat_input.h>
14 // An output that takes its input from a static image, loaded with ffmpeg.
15 // comes from a single 2D array with chunky pixels. The image is refreshed
16 // from disk about every second.
17 class ImageInput : public movit::FlatInput {
19 ImageInput(const std::string &pathname);
21 std::string effect_type_id() const override { return "ImageInput"; }
22 void set_gl_state(GLuint glsl_program_num, const std::string& prefix, unsigned *sampler_num) override;
23 static void shutdown_updaters();
27 std::unique_ptr<uint8_t[]> pixels;
28 timespec last_modified;
32 std::shared_ptr<const Image> current_image;
34 static std::shared_ptr<const Image> load_image(const std::string &pathname);
35 static std::shared_ptr<const Image> load_image_raw(const std::string &pathname);
36 static void update_thread_func(const std::string &pathname, const timespec &first_modified);
37 static std::mutex all_images_lock;
38 static std::map<std::string, std::shared_ptr<const Image>> all_images;
39 static std::map<std::string, std::thread> update_threads;
40 static volatile bool threads_should_quit;
43 #endif // !defined(_IMAGE_INPUT_H)