The branch, master has been updated
       via  b80f28fcbcedbf48b760921e85c5f2ae4f2f802a (commit)
       via  12d696cff4eeaccb8610c02056fd5f7342d51ac3 (commit)
       via  6ad839ff2e1ac36b6ab9ad6f687208a57731df7e (commit)
      from  74115b017c3038b717162bb56346afb4ad937be3 (commit)


- Log -----------------------------------------------------------------
commit b80f28fcbcedbf48b760921e85c5f2ae4f2f802a
Author:     Niklas Haas <[email protected]>
AuthorDate: Tue Sep 23 20:49:07 2025 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Tue Sep 30 15:39:39 2025 +0000

    avfilter/vf_libplacebo: introduce `fit_sense` option
    
    This allows choosing whether the `fit_mode` merely controls the placement
    of the image within the output resolution, or whether the output resolution
    is also adjusted according to the given `fit_mode`.

diff --git a/doc/filters.texi b/doc/filters.texi
index bb96e75d2a..262e7ad009 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16449,7 +16449,8 @@ will be performed.
 
 @item force_original_aspect_ratio
 @item force_divisible_by
-Work the same as the identical @ref{scale} filter options.
+Work the same as the identical @ref{scale} filter options. Note that
+@option{force_divisible_by} also works with @code{fit_sense=constraint}.
 
 @item reset_sar
 If enabled, output frames will always have a pixel aspect ratio of 1:1.  If
@@ -16503,6 +16504,22 @@ to either @code{contain} or @code{none}, depending on 
whether the input is
 larger than the output or not.
 @end table
 
+@item fit_sense
+When @option{fit_mode} is in use, this option controls how the fit strategy
+is applied against the specified output resolution. Mutually exclusive with
+@option{force_original_aspect_ratio}. Valid values are:
+
+@table @samp
+@item target
+The computed output resolution is taken as the exact size of the output frame.
+This is the default behavior.
+
+@item constraint
+The computed output resolution is a size reference against which the fit mode
+is applied, enlarging or decreasing the true frame size as needed to fit the
+content.
+@end table
+
 @item fillcolor
 Set the color used to fill the output area not covered by the output image, for
 example as a result of @option{normalize_sar}. For the general syntax of this
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 2cf58b1f8d..2b3738c8e0 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -161,6 +161,12 @@ enum fit_mode {
     FIT_MODE_NB,
 };
 
+enum fit_sense {
+    FIT_TARGET,
+    FIT_CONSTRAINT,
+    FIT_SENSE_NB,
+};
+
 typedef struct LibplaceboContext {
     /* lavfi vulkan*/
     FFVulkanContext vkctx;
@@ -206,6 +212,7 @@ typedef struct LibplaceboContext {
     int reset_sar;
     int normalize_sar;
     int fit_mode;
+    int fit_sense;
     int apply_filmgrain;
     int apply_dovi;
     int colorspace;
@@ -1452,11 +1459,24 @@ static int libplacebo_config_output(AVFilterLink 
*outlink)
     double sar_in = inlink->sample_aspect_ratio.num ?
                     av_q2d(inlink->sample_aspect_ratio) : 1.0;
 
+    int force_oar = s->force_original_aspect_ratio;
+    if (!force_oar && s->fit_sense == FIT_CONSTRAINT) {
+        if (s->fit_mode == FIT_CONTAIN || s->fit_mode == FIT_SCALE_DOWN) {
+            force_oar = SCALE_FORCE_OAR_DECREASE;
+        } else if (s->fit_mode == FIT_COVER) {
+            force_oar = SCALE_FORCE_OAR_INCREASE;
+        }
+    }
+
     ff_scale_adjust_dimensions(inlink, &outlink->w, &outlink->h,
-                               s->force_original_aspect_ratio,
-                               s->force_divisible_by,
+                               force_oar, s->force_divisible_by,
                                s->reset_sar ? sar_in : 1.0);
 
+    if (s->fit_mode == FIT_SCALE_DOWN && s->fit_sense == FIT_CONSTRAINT) {
+        int w_adj = s->reset_sar ? sar_in * inlink->w : inlink->w;
+        outlink->w = FFMIN(outlink->w, w_adj);
+        outlink->h = FFMIN(outlink->h, inlink->h);
+    }
 
     if (s->nb_inputs > 1 && !s->disable_fbos) {
         /* Create a separate renderer and composition texture */
@@ -1586,6 +1606,9 @@ static const AVOption libplacebo_options[] = {
         { "none",       "Keep input unscaled, padding and cropping as needed", 
 0, AV_OPT_TYPE_CONST, {.i64 = FIT_NONE },       0, 0, STATIC, .unit = 
"fit_mode" },
         { "place",      "Keep input unscaled, padding and cropping as needed", 
 0, AV_OPT_TYPE_CONST, {.i64 = FIT_NONE },       0, 0, STATIC, .unit = 
"fit_mode" },
         { "scale_down", "Downscale only if larger, padding to preserve 
aspect", 0, AV_OPT_TYPE_CONST, {.i64 = FIT_SCALE_DOWN }, 0, 0, STATIC, .unit = 
"fit_mode" },
+    { "fit_sense", "Output size strategy (for the base layer only)", 
OFFSET(fit_sense), AV_OPT_TYPE_INT, {.i64 = FIT_TARGET }, 0, FIT_SENSE_NB - 1, 
STATIC, .unit = "fit_sense" },
+        { "target",     "Computed resolution is the exact output size",        
 0, AV_OPT_TYPE_CONST, {.i64 = FIT_TARGET     }, 0, 0, STATIC, .unit = 
"fit_sense" },
+        { "constraint", "Computed resolution constrains the output size",      
 0, AV_OPT_TYPE_CONST, {.i64 = FIT_CONSTRAINT }, 0, 0, STATIC, .unit = 
"fit_sense" },
     { "fillcolor", "Background fill color", OFFSET(fillcolor), 
AV_OPT_TYPE_COLOR, {.str = "black@0"}, .flags = DYNAMIC },
     { "corner_rounding", "Corner rounding radius", OFFSET(corner_rounding), 
AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 1.0, .flags = DYNAMIC },
     { "lut", "Path to custom LUT file to apply", OFFSET(lut_filename), 
AV_OPT_TYPE_STRING, { .str = NULL }, .flags = STATIC },

commit 12d696cff4eeaccb8610c02056fd5f7342d51ac3
Author:     Niklas Haas <[email protected]>
AuthorDate: Mon Sep 8 18:28:19 2025 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Tue Sep 30 15:39:39 2025 +0000

    avfilter/vf_libplacebo: introduce `fit_mode` option
    
    The semantics of these keywords are well-defined by the CSS 'object-fit'
    property. This is arguably more user-friendly and less obtuse than the
    existing `normalize_sar` and `pad_crop_ratio` options. Additionally, this
    comes with two new (useful) behaviors, `none` and `scale_down`, neither of
    which map elegantly to the existing options.
    
    One additional benefit of this option is that, unlike `normalize_sar`, it
    does *not* also imply `reset_sar`; meaning that users can now choose to
    have an anamorphic base layer and still have the overlay images scaled to 
fit
    on top of it according to the chosen strategy.
    
    See-Also: https://drafts.csswg.org/css-images/#the-object-fit

diff --git a/doc/filters.texi b/doc/filters.texi
index 8224574220..bb96e75d2a 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16459,7 +16459,7 @@ e.g. anamorphic video sources, are forwarded to the 
output pixel aspect ratio.
 @item normalize_sar
 Like @option{reset_sar}, but instead of stretching the video content to fill
 the new output aspect ratio, the content is instead padded or cropped as
-necessary.
+necessary. Mutually exclusive with @option{fit_mode}. Disabled by default.
 
 @item pad_crop_ratio
 Specifies a ratio (between @code{0.0} and @code{1.0}) between padding and
@@ -16469,6 +16469,40 @@ content with black borders, while a value of 
@code{1.0} always crops off parts
 of the content. Intermediate values are possible, leading to a mix of the two
 approaches.
 
+@item fit_mode
+Specify the content fit strategy according to a list of predefined modes.
+Determines how the input image is to be placed inside the destination crop
+rectangle (as defined by @code{pos_x/y} and @code{pos_w/h}). The names and
+their implementations are taken from the CSS 'object-fit' property. Note that
+this option is mutually exclusive with @option{normalize_sar}. Defaults to
+@code{fill}. Valid values are:
+
+@table @samp
+@item fill
+Stretch the input to the output rectangle, ignoring aspect ratio mismatches.
+Note that unless @option{reset_sar} is also enabled, the output will still
+have the correct pixel aspect ratio tagged.
+
+@item contain
+Scale the input to fit inside the output, preserving aspect ratio by padding.
+Equivalent to @option{normalize_sar} with @option{pad_crop_ratio} set to
+@code{0.0}.
+
+@item cover
+Scale the input to fill the output, preserving aspect ratio by cropping.
+Equivalent to @option{normalize_sar} with @option{pad_crop_ratio} set to
+@code{1.0}.
+
+@item none, place
+Don't scale the input. The input will be placed inside the output rectangle at
+its natural size; which may result in additional padding or cropping.
+
+@item scale_down
+Scale the input down as much as needed to fit inside the output. Equivalent
+to either @code{contain} or @code{none}, depending on whether the input is
+larger than the output or not.
+@end table
+
 @item fillcolor
 Set the color used to fill the output area not covered by the output image, for
 example as a result of @option{normalize_sar}. For the general syntax of this
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 1454f364e4..2cf58b1f8d 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -152,6 +152,15 @@ typedef struct LibplaceboInput {
     int status;
 } LibplaceboInput;
 
+enum fit_mode {
+    FIT_FILL,
+    FIT_CONTAIN,
+    FIT_COVER,
+    FIT_NONE,
+    FIT_SCALE_DOWN,
+    FIT_MODE_NB,
+};
+
 typedef struct LibplaceboContext {
     /* lavfi vulkan*/
     FFVulkanContext vkctx;
@@ -196,6 +205,7 @@ typedef struct LibplaceboContext {
     int force_divisible_by;
     int reset_sar;
     int normalize_sar;
+    int fit_mode;
     int apply_filmgrain;
     int apply_dovi;
     int colorspace;
@@ -543,6 +553,11 @@ static int libplacebo_init(AVFilterContext *avctx)
     LibplaceboContext *s = avctx->priv;
     const AVVulkanDeviceContext *vkhwctx = NULL;
 
+    if (s->normalize_sar && s->fit_mode != FIT_FILL) {
+        av_log(avctx, AV_LOG_WARNING, "normalize_sar has no effect when using "
+               "a fit mode other than 'fill'\n");
+    }
+
     /* Create libplacebo log context */
     s->log = pl_log_create(PL_API_VER, pl_log_params(
         .log_level = get_log_level(),
@@ -841,6 +856,7 @@ static void update_crops(AVFilterContext *ctx, 
LibplaceboInput *in,
 {
     FilterLink     *outl = ff_filter_link(ctx->outputs[0]);
     LibplaceboContext *s = ctx->priv;
+    const AVFilterLink *outlink = ctx->outputs[0];
     const AVFilterLink *inlink = ctx->inputs[in->idx];
     const AVFrame *ref = ref_frame(&in->mix);
 
@@ -900,10 +916,33 @@ static void update_crops(AVFilterContext *ctx, 
LibplaceboInput *in,
             target->crop.y0 = av_expr_eval(s->pos_y_pexpr, s->var_values, 
NULL);
             target->crop.x1 = target->crop.x0 + s->var_values[VAR_POS_W];
             target->crop.y1 = target->crop.y0 + s->var_values[VAR_POS_H];
-            if (s->normalize_sar) {
-                float aspect = pl_rect2df_aspect(&image->crop);
-                aspect *= av_q2d(inlink->sample_aspect_ratio);
-                pl_rect2df_aspect_set(&target->crop, aspect, 
s->pad_crop_ratio);
+
+            /* Effective visual crop */
+            const float w_adj = av_q2d(inlink->sample_aspect_ratio) /
+                                av_q2d(outlink->sample_aspect_ratio);
+
+            pl_rect2df fixed = image->crop;
+            pl_rect2df_stretch(&fixed, w_adj, 1.0);
+
+            switch (s->fit_mode) {
+            case FIT_FILL:
+                if (s->normalize_sar)
+                    pl_rect2df_aspect_copy(&target->crop, &fixed, 
s->pad_crop_ratio);
+                break;
+            case FIT_CONTAIN:
+                pl_rect2df_aspect_copy(&target->crop, &fixed, 0.0);
+                break;
+            case FIT_COVER:
+                pl_rect2df_aspect_copy(&target->crop, &fixed, 1.0);
+                break;
+            case FIT_NONE: {
+                const float sx = fabsf(pl_rect_w(fixed)) / 
pl_rect_w(target->crop);
+                const float sy = fabsf(pl_rect_h(fixed)) / 
pl_rect_h(target->crop);
+                pl_rect2df_stretch(&target->crop, sx, sy);
+                break;
+            }
+            case FIT_SCALE_DOWN:
+                pl_rect2df_aspect_fit(&target->crop, &fixed, 0.0);
             }
         }
     }
@@ -1446,7 +1485,7 @@ static int libplacebo_config_output(AVFilterLink *outlink)
     if (s->reset_sar) {
         /* SAR is normalized, or we have multiple inputs, set out to 1:1 */
         outlink->sample_aspect_ratio = (AVRational){ 1, 1 };
-    } else if (inlink->sample_aspect_ratio.num) {
+    } else if (inlink->sample_aspect_ratio.num && s->fit_mode == FIT_FILL) {
         /* This is consistent with other scale_* filters, which only
          * set the outlink SAR to be equal to the scale SAR iff the input SAR
          * was set to something nonzero */
@@ -1540,6 +1579,13 @@ static const AVOption libplacebo_options[] = {
     { "reset_sar", "force SAR normalization to 1:1 by adjusting pos_x/y/w/h", 
OFFSET(reset_sar), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, STATIC },
     { "normalize_sar", "like reset_sar, but pad/crop instead of stretching the 
video", OFFSET(normalize_sar), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, STATIC },
     { "pad_crop_ratio", "ratio between padding and cropping when normalizing 
SAR (0=pad, 1=crop)", OFFSET(pad_crop_ratio), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 
0.0, 1.0, DYNAMIC },
+    { "fit_mode", "Content fit strategy for placing input layers in the 
output", OFFSET(fit_mode), AV_OPT_TYPE_INT, {.i64 = FIT_FILL }, 0, FIT_MODE_NB 
- 1, STATIC, .unit = "fit_mode" },
+        { "fill",       "Stretch content, ignoring aspect ratio",              
 0, AV_OPT_TYPE_CONST, {.i64 = FIT_FILL },       0, 0, STATIC, .unit = 
"fit_mode" },
+        { "contain",    "Stretch content, padding to preserve aspect",         
 0, AV_OPT_TYPE_CONST, {.i64 = FIT_CONTAIN },    0, 0, STATIC, .unit = 
"fit_mode" },
+        { "cover",      "Stretch content, cropping to preserve aspect",        
 0, AV_OPT_TYPE_CONST, {.i64 = FIT_COVER },      0, 0, STATIC, .unit = 
"fit_mode" },
+        { "none",       "Keep input unscaled, padding and cropping as needed", 
 0, AV_OPT_TYPE_CONST, {.i64 = FIT_NONE },       0, 0, STATIC, .unit = 
"fit_mode" },
+        { "place",      "Keep input unscaled, padding and cropping as needed", 
 0, AV_OPT_TYPE_CONST, {.i64 = FIT_NONE },       0, 0, STATIC, .unit = 
"fit_mode" },
+        { "scale_down", "Downscale only if larger, padding to preserve 
aspect", 0, AV_OPT_TYPE_CONST, {.i64 = FIT_SCALE_DOWN }, 0, 0, STATIC, .unit = 
"fit_mode" },
     { "fillcolor", "Background fill color", OFFSET(fillcolor), 
AV_OPT_TYPE_COLOR, {.str = "black@0"}, .flags = DYNAMIC },
     { "corner_rounding", "Corner rounding radius", OFFSET(corner_rounding), 
AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 1.0, .flags = DYNAMIC },
     { "lut", "Path to custom LUT file to apply", OFFSET(lut_filename), 
AV_OPT_TYPE_STRING, { .str = NULL }, .flags = STATIC },

commit 6ad839ff2e1ac36b6ab9ad6f687208a57731df7e
Author:     Niklas Haas <[email protected]>
AuthorDate: Tue Sep 23 16:17:12 2025 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Tue Sep 30 15:39:39 2025 +0000

    avfilter/vf_scale_*: add enum names for force_oar magic values

diff --git a/libavfilter/scale_eval.c b/libavfilter/scale_eval.c
index 53f5e22b0e..ad65610992 100644
--- a/libavfilter/scale_eval.c
+++ b/libavfilter/scale_eval.c
@@ -148,14 +148,14 @@ int ff_scale_adjust_dimensions(AVFilterLink *inlink,
     /* Note that force_original_aspect_ratio may overwrite the previous set
      * dimensions so that it is not divisible by the set factors anymore
      * unless force_divisible_by is defined as well */
-    if (force_original_aspect_ratio) {
+    if (force_original_aspect_ratio != SCALE_FORCE_OAR_DISABLE) {
         // Including force_divisible_by here rounds to the nearest multiple of 
it.
         int64_t tmp_w = av_rescale(h, inlink->w * w_adj, inlink->h * 
(int64_t)force_divisible_by)
                     * force_divisible_by;
         int64_t tmp_h = av_rescale(w, inlink->h, inlink->w * w_adj * 
(int64_t)force_divisible_by)
                     * force_divisible_by;
 
-        if (force_original_aspect_ratio == 1) {
+        if (force_original_aspect_ratio == SCALE_FORCE_OAR_DECREASE) {
              w = FFMIN(tmp_w, w);
              h = FFMIN(tmp_h, h);
              if (force_divisible_by > 1) {
@@ -163,7 +163,7 @@ int ff_scale_adjust_dimensions(AVFilterLink *inlink,
                  w = w / force_divisible_by * force_divisible_by;
                  h = h / force_divisible_by * force_divisible_by;
              }
-        } else {
+        } else { // SCALE_FORCE_OAR_INCREASE
              w = FFMAX(tmp_w, w);
              h = FFMAX(tmp_h, h);
              if (force_divisible_by > 1) {
diff --git a/libavfilter/scale_eval.h b/libavfilter/scale_eval.h
index 6cab623e1c..067703df21 100644
--- a/libavfilter/scale_eval.h
+++ b/libavfilter/scale_eval.h
@@ -21,6 +21,13 @@
 
 #include "avfilter.h"
 
+enum {
+    SCALE_FORCE_OAR_DISABLE,
+    SCALE_FORCE_OAR_DECREASE,
+    SCALE_FORCE_OAR_INCREASE,
+    SCALE_FORCE_OAR_NB,
+};
+
 /**
  * Parse and evaluate string expressions for width and height. Upon success,
  * ff_scale_adjust_dimensions must be called with evaluated width and height
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 80d3b273bb..1454f364e4 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -1532,10 +1532,10 @@ static const AVOption libplacebo_options[] = {
     { "pos_w", "Output video placement w", OFFSET(pos_w_expr), 
AV_OPT_TYPE_STRING, {.str = "ow"}, .flags = DYNAMIC },
     { "pos_h", "Output video placement h", OFFSET(pos_h_expr), 
AV_OPT_TYPE_STRING, {.str = "oh"}, .flags = DYNAMIC },
     { "format", "Output video format", OFFSET(out_format_string), 
AV_OPT_TYPE_STRING, .flags = STATIC },
-    { "force_original_aspect_ratio", "decrease or increase w/h if necessary to 
keep the original AR", OFFSET(force_original_aspect_ratio), AV_OPT_TYPE_INT, { 
.i64 = 0 }, 0, 2, STATIC, .unit = "force_oar" },
-        { "disable",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, STATIC, 
.unit = "force_oar" },
-        { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, STATIC, 
.unit = "force_oar" },
-        { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 0, STATIC, 
.unit = "force_oar" },
+    { "force_original_aspect_ratio", "decrease or increase w/h if necessary to 
keep the original AR", OFFSET(force_original_aspect_ratio), AV_OPT_TYPE_INT, { 
.i64 = 0 }, 0, SCALE_FORCE_OAR_NB-1, STATIC, .unit = "force_oar" },
+        { "disable",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
SCALE_FORCE_OAR_DISABLE  }, 0, 0, STATIC, .unit = "force_oar" },
+        { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
SCALE_FORCE_OAR_DECREASE }, 0, 0, STATIC, .unit = "force_oar" },
+        { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
SCALE_FORCE_OAR_INCREASE }, 0, 0, STATIC, .unit = "force_oar" },
     { "force_divisible_by", "enforce that the output resolution is divisible 
by a defined integer when force_original_aspect_ratio is used", 
OFFSET(force_divisible_by), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 256, STATIC },
     { "reset_sar", "force SAR normalization to 1:1 by adjusting pos_x/y/w/h", 
OFFSET(reset_sar), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, STATIC },
     { "normalize_sar", "like reset_sar, but pad/crop instead of stretching the 
video", OFFSET(normalize_sar), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, STATIC },
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 1ef1de8419..61d3ee0a0f 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -1148,10 +1148,10 @@ static const AVOption scale_options[] = {
     { "in_h_chr_pos",   "input horizontal chroma position in luma grid/256",   
OFFSET(in_h_chr_pos),  AV_OPT_TYPE_INT, { .i64 = -513}, -513, 512, FLAGS },
     { "out_v_chr_pos",   "output vertical chroma position in luma grid/256"  , 
OFFSET(out_v_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513}, -513, 512, FLAGS },
     { "out_h_chr_pos",   "output horizontal chroma position in luma grid/256", 
OFFSET(out_h_chr_pos), AV_OPT_TYPE_INT, { .i64 = -513}, -513, 512, FLAGS },
-    { "force_original_aspect_ratio", "decrease or increase w/h if necessary to 
keep the original AR", OFFSET(force_original_aspect_ratio), AV_OPT_TYPE_INT, { 
.i64 = 0}, 0, 2, FLAGS, .unit = "force_oar" },
-    { "disable",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, FLAGS, .unit 
= "force_oar" },
-    { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, FLAGS, .unit 
= "force_oar" },
-    { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 0, FLAGS, .unit 
= "force_oar" },
+    { "force_original_aspect_ratio", "decrease or increase w/h if necessary to 
keep the original AR", OFFSET(force_original_aspect_ratio), AV_OPT_TYPE_INT, { 
.i64 = 0}, 0, SCALE_FORCE_OAR_NB-1, FLAGS, .unit = "force_oar" },
+    { "disable",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_DISABLE  
}, 0, 0, FLAGS, .unit = "force_oar" },
+    { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_DECREASE 
}, 0, 0, FLAGS, .unit = "force_oar" },
+    { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_INCREASE 
}, 0, 0, FLAGS, .unit = "force_oar" },
     { "force_divisible_by", "enforce that the output resolution is divisible 
by a defined integer when force_original_aspect_ratio is used", 
OFFSET(force_divisible_by), AV_OPT_TYPE_INT, { .i64 = 1}, 1, 256, FLAGS },
     { "reset_sar", "reset SAR to 1 and scale to square pixels if scaling 
proportionally", OFFSET(reset_sar), AV_OPT_TYPE_BOOL, { .i64 = 0}, 0, 1, FLAGS 
},
     { "param0", "Scaler param 0",             OFFSET(param[0]),  
AV_OPT_TYPE_DOUBLE, { .dbl = DBL_MAX  }, -DBL_MAX, DBL_MAX, FLAGS },
diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c
index 44eef207ca..88a6e20610 100644
--- a/libavfilter/vf_scale_cuda.c
+++ b/libavfilter/vf_scale_cuda.c
@@ -621,10 +621,10 @@ static const AVOption options[] = {
     { "format", "Output video pixel format", OFFSET(format), 
AV_OPT_TYPE_PIXEL_FMT, { .i64 = AV_PIX_FMT_NONE }, INT_MIN, INT_MAX, 
.flags=FLAGS },
     { "passthrough", "Do not process frames at all if parameters match", 
OFFSET(passthrough), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
     { "param", "Algorithm-Specific parameter", OFFSET(param), 
AV_OPT_TYPE_FLOAT, { .dbl = SCALE_CUDA_PARAM_DEFAULT }, -FLT_MAX, FLT_MAX, 
FLAGS },
-    { "force_original_aspect_ratio", "decrease or increase w/h if necessary to 
keep the original AR", OFFSET(force_original_aspect_ratio), AV_OPT_TYPE_INT, { 
.i64 = 0 }, 0, 2, FLAGS, .unit = "force_oar" },
-        { "disable",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, FLAGS, 
.unit = "force_oar" },
-        { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, FLAGS, 
.unit = "force_oar" },
-        { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 0, FLAGS, 
.unit = "force_oar" },
+    { "force_original_aspect_ratio", "decrease or increase w/h if necessary to 
keep the original AR", OFFSET(force_original_aspect_ratio), AV_OPT_TYPE_INT, { 
.i64 = 0 }, 0, SCALE_FORCE_OAR_NB-1, FLAGS, .unit = "force_oar" },
+        { "disable",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
SCALE_FORCE_OAR_DISABLE  }, 0, 0, FLAGS, .unit = "force_oar" },
+        { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
SCALE_FORCE_OAR_DECREASE }, 0, 0, FLAGS, .unit = "force_oar" },
+        { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
SCALE_FORCE_OAR_INCREASE }, 0, 0, FLAGS, .unit = "force_oar" },
     { "force_divisible_by", "enforce that the output resolution is divisible 
by a defined integer when force_original_aspect_ratio is used", 
OFFSET(force_divisible_by), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 256, FLAGS },
     { "reset_sar", "reset SAR to 1 and scale to square pixels if scaling 
proportionally", OFFSET(reset_sar), AV_OPT_TYPE_BOOL, { .i64 = 0}, 0, 1, FLAGS 
},
     { NULL },
diff --git a/libavfilter/vf_scale_npp.c b/libavfilter/vf_scale_npp.c
index 0529db3a29..8e9113521c 100644
--- a/libavfilter/vf_scale_npp.c
+++ b/libavfilter/vf_scale_npp.c
@@ -978,10 +978,10 @@ static const AVOption options[] = {
         { "cubic2p_b05c03",     "2-parameter cubic (B=1/2, C=3/10)", 0, 
AV_OPT_TYPE_CONST, { .i64 = NPPI_INTER_CUBIC2P_B05C03     }, 0, 0, FLAGS, .unit 
= "interp_algo" },
         { "super",              "supersampling",                     0, 
AV_OPT_TYPE_CONST, { .i64 = NPPI_INTER_SUPER              }, 0, 0, FLAGS, .unit 
= "interp_algo" },
         { "lanczos",            "Lanczos",                           0, 
AV_OPT_TYPE_CONST, { .i64 = NPPI_INTER_LANCZOS            }, 0, 0, FLAGS, .unit 
= "interp_algo" },
-    { "force_original_aspect_ratio", "decrease or increase w/h if necessary to 
keep the original AR", OFFSET(force_original_aspect_ratio), AV_OPT_TYPE_INT, { 
.i64 = 0 }, 0, 2, FLAGS, .unit = "force_oar" },
-    { "disable",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, FLAGS, .unit 
= "force_oar" },
-    { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, FLAGS, .unit 
= "force_oar" },
-    { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 0, FLAGS, .unit 
= "force_oar" },
+    { "force_original_aspect_ratio", "decrease or increase w/h if necessary to 
keep the original AR", OFFSET(force_original_aspect_ratio), AV_OPT_TYPE_INT, { 
.i64 = 0 }, 0, SCALE_FORCE_OAR_NB-1, FLAGS, .unit = "force_oar" },
+    { "disable",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_DISABLE  
}, 0, 0, FLAGS, .unit = "force_oar" },
+    { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_DECREASE 
}, 0, 0, FLAGS, .unit = "force_oar" },
+    { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_INCREASE 
}, 0, 0, FLAGS, .unit = "force_oar" },
     { "force_divisible_by", "enforce that the output resolution is divisible 
by a defined integer when force_original_aspect_ratio is used", 
OFFSET(force_divisible_by), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 256, FLAGS },
     { "reset_sar", "reset SAR to 1 and scale to square pixels if scaling 
proportionally", OFFSET(reset_sar), AV_OPT_TYPE_BOOL, { .i64 = 0}, 0, 1, FLAGS 
},
     { "eval", "specify when to evaluate expressions", OFFSET(eval_mode), 
AV_OPT_TYPE_INT, { .i64 = EVAL_MODE_INIT }, 0, EVAL_MODE_NB-1, FLAGS, .unit = 
"eval" },
diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
index 547142d425..1ba925afa5 100644
--- a/libavfilter/vf_scale_vaapi.c
+++ b/libavfilter/vf_scale_vaapi.c
@@ -277,10 +277,10 @@ static const AVOption scale_vaapi_options[] = {
     { "out_chroma_location", "Output chroma sample location",
       OFFSET(chroma_location_string),  AV_OPT_TYPE_STRING,
       { .str = NULL }, .flags = FLAGS },
-    { "force_original_aspect_ratio", "decrease or increase w/h if necessary to 
keep the original AR", OFFSET(force_original_aspect_ratio), AV_OPT_TYPE_INT, { 
.i64 = 0}, 0, 2, FLAGS, .unit = "force_oar" },
-    { "disable",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, FLAGS, .unit 
= "force_oar" },
-    { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, FLAGS, .unit 
= "force_oar" },
-    { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 0, FLAGS, .unit 
= "force_oar" },
+    { "force_original_aspect_ratio", "decrease or increase w/h if necessary to 
keep the original AR", OFFSET(force_original_aspect_ratio), AV_OPT_TYPE_INT, { 
.i64 = 0}, 0, SCALE_FORCE_OAR_NB-1, FLAGS, .unit = "force_oar" },
+    { "disable",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_DISABLE  
}, 0, 0, FLAGS, .unit = "force_oar" },
+    { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_DECREASE 
}, 0, 0, FLAGS, .unit = "force_oar" },
+    { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_INCREASE 
}, 0, 0, FLAGS, .unit = "force_oar" },
     { "force_divisible_by", "enforce that the output resolution is divisible 
by a defined integer when force_original_aspect_ratio is used", 
OFFSET(force_divisible_by), AV_OPT_TYPE_INT, { .i64 = 1}, 1, 256, FLAGS },
     { "reset_sar", "reset SAR to 1 and scale to square pixels if scaling 
proportionally", OFFSET(reset_sar), AV_OPT_TYPE_BOOL, { .i64 = 0}, 0, 1, FLAGS 
},
 
diff --git a/libavfilter/vf_scale_vt.c b/libavfilter/vf_scale_vt.c
index c024717bc2..3d4ba44dc6 100644
--- a/libavfilter/vf_scale_vt.c
+++ b/libavfilter/vf_scale_vt.c
@@ -248,7 +248,8 @@ static int scale_vt_config_output(AVFilterLink *outlink)
     if (err < 0)
         return err;
 
-    ff_scale_adjust_dimensions(inlink, &s->output_width, &s->output_height, 0, 
1, 1.f);
+    ff_scale_adjust_dimensions(inlink, &s->output_width, &s->output_height,
+                               SCALE_FORCE_OAR_DISABLE, 1, 1.f);
 
     outlink->w = s->output_width;
     outlink->h = s->output_height;
diff --git a/libavfilter/vf_scale_vulkan.c b/libavfilter/vf_scale_vulkan.c
index c23cfe262f..f8e069f4a4 100644
--- a/libavfilter/vf_scale_vulkan.c
+++ b/libavfilter/vf_scale_vulkan.c
@@ -389,7 +389,8 @@ static int scale_vulkan_config_output(AVFilterLink *outlink)
     if (err < 0)
         return err;
 
-    ff_scale_adjust_dimensions(inlink, &vkctx->output_width, 
&vkctx->output_height, 0, 1, 1.f);
+    ff_scale_adjust_dimensions(inlink, &vkctx->output_width, 
&vkctx->output_height,
+                               SCALE_FORCE_OAR_DISABLE, 1, 1.f);
 
     outlink->w = vkctx->output_width;
     outlink->h = vkctx->output_height;
diff --git a/libavfilter/vf_vpp_amf.c b/libavfilter/vf_vpp_amf.c
index 92923a4757..78815551be 100644
--- a/libavfilter/vf_vpp_amf.c
+++ b/libavfilter/vf_vpp_amf.c
@@ -216,10 +216,10 @@ static const AVOption vpp_amf_options[] = {
     { "smpte428",       "SMPTE428",                 0,  AV_OPT_TYPE_CONST, { 
.i64 = AMF_COLOR_TRANSFER_CHARACTERISTIC_SMPTE428 }, 0, 0, FLAGS, "trc" },
     { "arib-std-b67",   "ARIB_STD_B67",             0,  AV_OPT_TYPE_CONST, { 
.i64 = AMF_COLOR_TRANSFER_CHARACTERISTIC_ARIB_STD_B67 }, 0, 0, FLAGS, "trc" },
 
-    { "force_original_aspect_ratio", "decrease or increase w/h if necessary to 
keep the original AR", OFFSET(force_original_aspect_ratio), AV_OPT_TYPE_INT, { 
.i64 = 0}, 0, 2, FLAGS, "force_oar" },
-    { "disable",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, FLAGS, 
"force_oar" },
-    { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, FLAGS, 
"force_oar" },
-    { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 0, FLAGS, 
"force_oar" },
+    { "force_original_aspect_ratio", "decrease or increase w/h if necessary to 
keep the original AR", OFFSET(force_original_aspect_ratio), AV_OPT_TYPE_INT, { 
.i64 = 0}, 0, SCALE_FORCE_OAR_NB-1, FLAGS, "force_oar" },
+    { "disable",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_DISABLE  
}, 0, 0, FLAGS, "force_oar" },
+    { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_DECREASE 
}, 0, 0, FLAGS, "force_oar" },
+    { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_INCREASE 
}, 0, 0, FLAGS, "force_oar" },
     { "force_divisible_by", "enforce that the output resolution is divisible 
by a defined integer when force_original_aspect_ratio is used", 
OFFSET(force_divisible_by), AV_OPT_TYPE_INT, { .i64 = 1}, 1, 256, FLAGS },
     { "reset_sar", "reset SAR to 1 and scale to square pixels if scaling 
proportionally", OFFSET(reset_sar), AV_OPT_TYPE_BOOL, { .i64 = 0}, 0, 1, FLAGS 
},
 

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

Summary of changes:
 doc/filters.texi              | 55 +++++++++++++++++++++++++-
 libavfilter/scale_eval.c      |  6 +--
 libavfilter/scale_eval.h      |  7 ++++
 libavfilter/vf_libplacebo.c   | 91 +++++++++++++++++++++++++++++++++++++------
 libavfilter/vf_scale.c        |  8 ++--
 libavfilter/vf_scale_cuda.c   |  8 ++--
 libavfilter/vf_scale_npp.c    |  8 ++--
 libavfilter/vf_scale_vaapi.c  |  8 ++--
 libavfilter/vf_scale_vt.c     |  3 +-
 libavfilter/vf_scale_vulkan.c |  3 +-
 libavfilter/vf_vpp_amf.c      |  8 ++--
 11 files changed, 167 insertions(+), 38 deletions(-)


hooks/post-receive
-- 

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

Reply via email to