diff options
author | Niklas Haas <git@haasn.dev> | 2025-06-16 20:01:48 +0200 |
---|---|---|
committer | Niklas Haas <git@haasn.dev> | 2025-06-20 15:13:25 +0200 |
commit | 7039a37e358ec93bd589f2ac25f3aad13c5cce7e (patch) | |
tree | 7e7e812e85693b7e33d0c0819da0d253c4947af0 | |
parent | c0698840c41ced3f2fd0ff4070fd4294e6164dd6 (diff) | |
download | ffmpeg-7039a37e358ec93bd589f2ac25f3aad13c5cce7e.tar.gz |
avfilter/vf_libplacebo: add `reset_sar` option
This was requested by users of `vf_libplacebo`, to mirror the existing
option on the other `vf_scale_*` family of filters. While we have
`vf_normalize`, it was not as useful in the event that the content
stretching was actually desired.
Bridges an important usability gap between `vf_scale` and `vf_libplacebo`
that made mixing and matching the filters needlessly difficult.
-rw-r--r-- | doc/filters.texi | 12 | ||||
-rw-r--r-- | libavfilter/vf_libplacebo.c | 5 |
2 files changed, 11 insertions, 6 deletions
diff --git a/doc/filters.texi b/doc/filters.texi index f32fc23c70..21dab1045a 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16291,11 +16291,15 @@ will be performed. @item force_divisible_by Work the same as the identical @ref{scale} filter options. +@item reset_sar +If enabled, output frames will always have a pixel aspect ratio of 1:1. If +disabled (the default), any aspect ratio mismatches, including those from +e.g. anamorphic video sources, are forwarded to the output pixel aspect ratio. + @item normalize_sar -If enabled, output frames will always have a pixel aspect ratio of 1:1. This -will introduce additional padding/cropping as necessary. If disabled (the -default), any aspect ratio mismatches, including those from e.g. anamorphic -video sources, are forwarded to the output pixel aspect ratio. +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. @item pad_crop_ratio Specifies a ratio (between @code{0.0} and @code{1.0}) between padding and diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 52731caa6c..475030c80d 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -1298,7 +1298,7 @@ static int libplacebo_config_output(AVFilterLink *outlink) RET(ff_scale_eval_dimensions(s, s->w_expr, s->h_expr, inlink, outlink, &outlink->w, &outlink->h)); - s->reset_sar = s->normalize_sar || s->nb_inputs > 1; + 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; @@ -1401,7 +1401,8 @@ static const AVOption libplacebo_options[] = { { "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_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 }, - { "normalize_sar", "force SAR normalization to 1:1 by adjusting pos_x/y/w/h", OFFSET(normalize_sar), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, 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 }, { "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 }, { "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 }, |