[FFmpeg-cvslog] lavfi/vf_libplacebo: fix crop expr PTS calculation

Niklas Haas git at videolan.org
Wed May 24 15:40:52 EEST 2023


ffmpeg | branch: master | Niklas Haas <git at haasn.dev> | Wed May 24 14:35:49 2023 +0200| [0bce5590c3956184365d5600425e9c1dddb513ec] | committer: Niklas Haas

lavfi/vf_libplacebo: fix crop expr PTS calculation

mix->timestamps is expressed relative to the source timebase, which is
possibly a different timescale from `base_pts`. We can't mix-and-match
here. The only reason this worked in my previous testing was because I
was testing on a source file which had an exactly matching timebase.

Fix it by always using the exact PTS as tagged on the AVFrame.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0bce5590c3956184365d5600425e9c1dddb513ec
---

 libavfilter/vf_libplacebo.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index d4b2f21328..adebcc4541 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -651,7 +651,7 @@ fail:
 
 static void update_crops(AVFilterContext *ctx,
                          struct pl_frame_mix *mix, struct pl_frame *target,
-                         uint64_t ref_sig, double base_pts)
+                         uint64_t ref_sig, double target_pts)
 {
     LibplaceboContext *s = ctx->priv;
 
@@ -659,11 +659,12 @@ static void update_crops(AVFilterContext *ctx,
         // Mutate the `pl_frame.crop` fields in-place. This is fine because we
         // own the entire pl_queue, and hence, the pointed-at frames.
         struct pl_frame *image = (struct pl_frame *) mix->frames[i];
-        double image_pts = base_pts + mix->timestamps[i];
+        const AVFrame *src = pl_get_mapped_avframe(image);
+        double image_pts = src->pts * av_q2d(ctx->inputs[0]->time_base);
 
         /* Update dynamic variables */
         s->var_values[VAR_IN_T]   = s->var_values[VAR_T]  = image_pts;
-        s->var_values[VAR_OUT_T]  = s->var_values[VAR_OT] = base_pts;
+        s->var_values[VAR_OUT_T]  = s->var_values[VAR_OT] = target_pts;
         s->var_values[VAR_N]      = ctx->outputs[0]->frame_count_out;
 
         /* Clear these explicitly to avoid leaking previous frames' state */



More information about the ffmpeg-cvslog mailing list