aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2023-12-03 18:41:31 +0100
committerPaul B Mahol <onemda@gmail.com>2023-12-03 18:43:26 +0100
commite3e3531d1ed85e6c0a123491c247d4de2e171a9e (patch)
tree617714e92cc37db8ab39ebef4b3a5821fbe55180 /libavfilter
parent8888574d10766b7d5ced5ab076496b3664a023a4 (diff)
downloadffmpeg-e3e3531d1ed85e6c0a123491c247d4de2e171a9e.tar.gz
avfilter/vsrc_gradients: make rotation always continuous if speed changes
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vsrc_gradients.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavfilter/vsrc_gradients.c b/libavfilter/vsrc_gradients.c
index d3264b96c8..2d7c0fa681 100644
--- a/libavfilter/vsrc_gradients.c
+++ b/libavfilter/vsrc_gradients.c
@@ -37,6 +37,7 @@ typedef struct GradientsContext {
int64_t pts;
int64_t duration; ///< duration expressed in microseconds
float speed;
+ float angle;
uint8_t color_rgba[8][4];
float color_rgbaf[8][4];
@@ -392,10 +393,12 @@ static int activate(AVFilterContext *ctx)
if (ff_outlink_frame_wanted(outlink)) {
AVFrame *frame = ff_get_video_buffer(outlink, s->w, s->h);
- float angle = (s->speed > 0.f) ? fmodf(s->pts * s->speed, 2.f * M_PI) : 1.f;
+ float angle = fmodf(s->angle, 2.f * M_PI);
const float w2 = s->w / 2.f;
const float h2 = s->h / 2.f;
+ s->angle = angle + s->speed;
+
s->fx0 = (s->x0 - w2) * cosf(angle) - (s->y0 - h2) * sinf(angle) + w2;
s->fy0 = (s->x0 - w2) * sinf(angle) + (s->y0 - h2) * cosf(angle) + h2;