[FFmpeg-cvslog] avfilter/vsrc_gradients: make rotation always continuous if speed changes
Paul B Mahol
git at videolan.org
Sun Dec 3 19:35:57 EET 2023
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Dec 3 18:41:31 2023 +0100| [e3e3531d1ed85e6c0a123491c247d4de2e171a9e] | committer: Paul B Mahol
avfilter/vsrc_gradients: make rotation always continuous if speed changes
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e3e3531d1ed85e6c0a123491c247d4de2e171a9e
---
libavfilter/vsrc_gradients.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
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;
More information about the ffmpeg-cvslog
mailing list