16 #ifndef OPENSHOT_ANALOGTAPE_EFFECT_H
17 #define OPENSHOT_ANALOGTAPE_EFFECT_H
19 #include "../EffectBase.h"
22 #include "../KeyFrame.h"
32 #if defined(__GNUC__) || defined(__clang__)
33 #define OS_RESTRICT __restrict__
43 void init_effect_details();
44 static inline uint32_t fnv1a_32(
const std::string &s) {
45 uint32_t h = 2166136261u;
46 for (
unsigned char c : s) {
52 static inline uint32_t fnv1a_32(uint32_t h, uint32_t d) {
53 unsigned char bytes[4];
55 bytes[1] = (d >> 8) & 0xFF;
56 bytes[2] = (d >> 16) & 0xFF;
57 bytes[3] = (d >> 24) & 0xFF;
58 for (
int i = 0; i < 4; ++i) {
64 static inline float hash01(uint32_t seed, uint32_t a, uint32_t b, uint32_t c) {
65 uint32_t h = fnv1a_32(seed, a);
68 return h / 4294967295.0f;
70 static inline float row_density(uint32_t seed,
int frame,
int y) {
71 int tc = (frame >> 3);
73 float a = (y & 7) / 8.0f;
74 float h0 = hash01(seed, tc, y0, 31);
75 float h1 = hash01(seed, tc, y0 + 1, 31);
76 float m = (1 - a) * h0 + a * h1;
79 static inline void box_blur_row(
const float *
OS_RESTRICT src,
82 std::memcpy(dst, src, w *
sizeof(
float));
85 const int win = 2 * r + 1;
87 for (
int k = -r; k <= r; ++k)
88 sum += src[std::clamp(k, 0, w - 1)];
90 for (
int x = 1; x < w; ++x) {
91 int add = std::min(w - 1, x + r);
92 int sub = std::max(0, x - r - 1);
93 sum += src[add] - src[sub];
98 int last_w = 0, last_h = 0;
99 std::vector<float> Y, U, V, tmpY, tmpU, tmpV, dx;
115 std::shared_ptr<openshot::Frame>
116 GetFrame(std::shared_ptr<openshot::Frame> frame,
117 int64_t frame_number)
override;
119 std::shared_ptr<openshot::Frame>
GetFrame(int64_t frame_number)
override {
120 return GetFrame(std::make_shared<openshot::Frame>(), frame_number);
124 std::string
Json()
const override;
125 void SetJson(
const std::string value)
override;
129 std::string
PropertiesJSON(int64_t requested_frame)
const override;