MandelVideoGenerator.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef MANDELVIDEOGENERATOR_H
  2. #define MANDELVIDEOGENERATOR_H
  3. #include "Mandel.h"
  4. #include "VideoStream.h"
  5. #include "Gradient.h"
  6. #include "Bitmap.h"
  7. #include "VideoRecipe.h"
  8. #include <functional>
  9. struct ExportVideoInfo
  10. {
  11. /// the viewport at the start of the video
  12. mnd::MandelViewport start;
  13. /// the viewport at the end of the video
  14. mnd::MandelViewport end;
  15. /// Info struct to hold further data about the generation
  16. /// of mandelbrot images. The Viewport specified in this
  17. /// struct is ignored.
  18. mnd::MandelInfo mi;
  19. /// the gradient to use
  20. alm::Gradient gradient;
  21. int fps;
  22. double zoomSpeed;
  23. std::string path;
  24. /// bitrate in kbps
  25. int bitrate;
  26. std::string preset;
  27. };
  28. struct MandelVideoProgressInfo
  29. {
  30. int64_t framesExported;
  31. float progress;
  32. };
  33. class MandelVideoGenerator
  34. {
  35. public:
  36. using ProgressCallback = std::function<void(const MandelVideoProgressInfo&)>;
  37. private:
  38. const ExportVideoInfo evi;
  39. std::vector<ProgressCallback> progressCallbacks;
  40. public:
  41. MandelVideoGenerator(const ExportVideoInfo& evi);
  42. void generate(mnd::MandelGenerator& gen);
  43. void addProgressCallback(ProgressCallback pc);
  44. private:
  45. void callCallbacks(const MandelVideoProgressInfo& evi);
  46. Bitmap<RGBColor> overlay(const Bitmap<RGBColor>& outer,
  47. const Bitmap<RGBColor>& inner,
  48. long bw, long bh,
  49. double scale, double oversizeFactor);
  50. };
  51. namespace alm
  52. {
  53. void exportVideo(const VideoRecipe& vr, const std::string& path);
  54. }
  55. #endif // MANDELVIDEOGENERATOR_H