The branch, master has been updated
       via  04eeaeed11d721ccbcd0104c2e79e3ceb819585d (commit)
       via  f83fdad550f6dddd09c99b6e00b81c327bfb7a5e (commit)
       via  6e0034ab7e46429731fec6d2c390fa536a9157ad (commit)
      from  372dab2a4d2cbfee365b3e654681f38547916145 (commit)


- Log -----------------------------------------------------------------
commit 04eeaeed11d721ccbcd0104c2e79e3ceb819585d
Author:     Niklas Haas <[email protected]>
AuthorDate: Mon Nov 10 12:38:11 2025 +0100
Commit:     Niklas Haas <[email protected]>
CommitDate: Sat Nov 29 08:45:24 2025 +0000

    avfilter/vf_libplacebo: also rotate SAR when fitting

diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 8b5f789280..b1788565bf 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -928,10 +928,13 @@ static void update_crops(AVFilterContext *ctx, 
LibplaceboInput *in,
             /* Effective visual crop */
             double sar_in = q2d_fallback(inlink->sample_aspect_ratio, 1.0);
             double sar_out = q2d_fallback(outlink->sample_aspect_ratio, 1.0);
-            const float w_adj = sar_in / sar_out;
+
+            pl_rotation rot_total = PL_ROTATION_360 + image->rotation - 
target->rotation;
+            if (rot_total % PL_ROTATION_180 == PL_ROTATION_90)
+                sar_in = 1.0 / sar_in;
 
             pl_rect2df fixed = image->crop;
-            pl_rect2df_stretch(&fixed, w_adj, 1.0);
+            pl_rect2df_stretch(&fixed, sar_in / sar_out, 1.0);
 
             switch (s->fit_mode) {
             case FIT_FILL:
@@ -954,8 +957,7 @@ static void update_crops(AVFilterContext *ctx, 
LibplaceboInput *in,
                 pl_rect2df_aspect_fit(&target->crop, &fixed, 0.0);
             }
 
-            const pl_rotation rot_total = image->rotation - target->rotation;
-            if ((rot_total + PL_ROTATION_360) % PL_ROTATION_180 == 
PL_ROTATION_90) {
+            if (rot_total % PL_ROTATION_180 == PL_ROTATION_90) {
                 /* Libplacebo expects the input crop relative to the actual 
frame
                  * dimensions, so un-transpose them here */
                 FFSWAP(float, image->crop.x0, image->crop.y0);

commit f83fdad550f6dddd09c99b6e00b81c327bfb7a5e
Author:     Niklas Haas <[email protected]>
AuthorDate: Mon Nov 10 12:36:33 2025 +0100
Commit:     Niklas Haas <[email protected]>
CommitDate: Sat Nov 29 08:45:24 2025 +0000

    avfilter/vf_libplacebo: fix math when AVRationals are undefined

diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 5a615aceed..8b5f789280 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -861,6 +861,11 @@ static const AVFrame *ref_frame(const struct pl_frame_mix 
*mix)
     return NULL;
 }
 
+static inline double q2d_fallback(AVRational q, const double def)
+{
+    return (q.num && q.den) ? av_q2d(q) : def;
+}
+
 static void update_crops(AVFilterContext *ctx, LibplaceboInput *in,
                          struct pl_frame *target, double target_pts)
 {
@@ -882,8 +887,7 @@ static void update_crops(AVFilterContext *ctx, 
LibplaceboInput *in,
         s->var_values[VAR_IN_W]   = s->var_values[VAR_IW] = inlink->w;
         s->var_values[VAR_IN_H]   = s->var_values[VAR_IH] = inlink->h;
         s->var_values[VAR_A]      = (double) inlink->w / inlink->h;
-        s->var_values[VAR_SAR]    = inlink->sample_aspect_ratio.num ?
-            av_q2d(inlink->sample_aspect_ratio) : 1.0;
+        s->var_values[VAR_SAR]    = q2d_fallback(inlink->sample_aspect_ratio, 
1.0);
         s->var_values[VAR_IN_T]   = s->var_values[VAR_T]  = image_pts;
         s->var_values[VAR_OUT_T]  = s->var_values[VAR_OT] = target_pts;
         s->var_values[VAR_N]      = outl->frame_count_out;
@@ -920,9 +924,11 @@ static void update_crops(AVFilterContext *ctx, 
LibplaceboInput *in,
             target->crop.x1 = target->crop.x0 + s->var_values[VAR_POS_W];
             target->crop.y1 = target->crop.y0 + s->var_values[VAR_POS_H];
 
+
             /* Effective visual crop */
-            const float w_adj = av_q2d(inlink->sample_aspect_ratio) /
-                                av_q2d(outlink->sample_aspect_ratio);
+            double sar_in = q2d_fallback(inlink->sample_aspect_ratio, 1.0);
+            double sar_out = q2d_fallback(outlink->sample_aspect_ratio, 1.0);
+            const float w_adj = sar_in / sar_out;
 
             pl_rect2df fixed = image->crop;
             pl_rect2df_stretch(&fixed, w_adj, 1.0);
@@ -1278,7 +1284,7 @@ static int libplacebo_activate(AVFilterContext *ctx)
             in->qstatus = pl_queue_update(in->queue, &in->mix, pl_queue_params(
                 .pts            = TS2T(out_pts, outlink->time_base),
                 .radius         = pl_frame_mix_radius(&s->opts->params),
-                .vsync_duration = l->frame_rate.num ? 
av_q2d(av_inv_q(l->frame_rate)) : 0,
+                .vsync_duration = q2d_fallback(av_inv_q(l->frame_rate), 0.0),
             ));
 
             switch (in->qstatus) {
@@ -1461,8 +1467,7 @@ static int libplacebo_config_output(AVFilterLink *outlink)
                                  &outlink->w, &outlink->h));
 
     s->reset_sar |= s->normalize_sar || s->nb_inputs > 1;
-    double sar_in = inlink->sample_aspect_ratio.num ?
-                    av_q2d(inlink->sample_aspect_ratio) : 1.0;
+    double sar_in = q2d_fallback(inlink->sample_aspect_ratio, 1.0);
 
     int force_oar = s->force_original_aspect_ratio;
     if (!force_oar && s->fit_sense == FIT_CONSTRAINT) {
@@ -1549,8 +1554,7 @@ static int libplacebo_config_output(AVFilterLink *outlink)
     /* Static variables */
     s->var_values[VAR_OUT_W]    = s->var_values[VAR_OW] = outlink->w;
     s->var_values[VAR_OUT_H]    = s->var_values[VAR_OH] = outlink->h;
-    s->var_values[VAR_DAR]      = outlink->sample_aspect_ratio.num ?
-        av_q2d(outlink->sample_aspect_ratio) : 1.0;
+    s->var_values[VAR_DAR]      = q2d_fallback(outlink->sample_aspect_ratio, 
1.0);
     s->var_values[VAR_HSUB]     = 1 << desc->log2_chroma_w;
     s->var_values[VAR_VSUB]     = 1 << desc->log2_chroma_h;
     s->var_values[VAR_OHSUB]    = 1 << out_desc->log2_chroma_w;

commit 6e0034ab7e46429731fec6d2c390fa536a9157ad
Author:     Niklas Haas <[email protected]>
AuthorDate: Mon Nov 10 12:32:32 2025 +0100
Commit:     Niklas Haas <[email protected]>
CommitDate: Sat Nov 29 08:45:24 2025 +0000

    avfilter/vf_libplacebo: un-rotate image crop after fitting
    
    When combining rotation with a FIT_ mode other than FIT_FILL, the fitting
    logic was operating on the un-rotated rects, when it should have been
    operating on the rotated (output) rects.

diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 42501c51f2..5a615aceed 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -913,14 +913,6 @@ static void update_crops(AVFilterContext *ctx, 
LibplaceboInput *in,
         image->crop.x1 = image->crop.x0 + s->var_values[VAR_CROP_W];
         image->crop.y1 = image->crop.y0 + s->var_values[VAR_CROP_H];
 
-        const pl_rotation rot_total = image->rotation - target->rotation;
-        if ((rot_total + PL_ROTATION_360) % PL_ROTATION_180 == PL_ROTATION_90) 
{
-            /* Libplacebo expects the input crop relative to the actual frame
-             * dimensions, so un-transpose them here */
-            FFSWAP(float, image->crop.x0, image->crop.y0);
-            FFSWAP(float, image->crop.x1, image->crop.y1);
-        }
-
         if (src == ref) {
             /* Only update the target crop once, for the 'reference' frame */
             target->crop.x0 = av_expr_eval(s->pos_x_pexpr, s->var_values, 
NULL);
@@ -955,6 +947,14 @@ static void update_crops(AVFilterContext *ctx, 
LibplaceboInput *in,
             case FIT_SCALE_DOWN:
                 pl_rect2df_aspect_fit(&target->crop, &fixed, 0.0);
             }
+
+            const pl_rotation rot_total = image->rotation - target->rotation;
+            if ((rot_total + PL_ROTATION_360) % PL_ROTATION_180 == 
PL_ROTATION_90) {
+                /* Libplacebo expects the input crop relative to the actual 
frame
+                 * dimensions, so un-transpose them here */
+                FFSWAP(float, image->crop.x0, image->crop.y0);
+                FFSWAP(float, image->crop.x1, image->crop.y1);
+            }
         }
     }
 }

-----------------------------------------------------------------------

Summary of changes:
 libavfilter/vf_libplacebo.c | 42 ++++++++++++++++++++++++------------------
 1 file changed, 24 insertions(+), 18 deletions(-)


hooks/post-receive
-- 

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to