From: Niklas Haas <ffmpeg@haasn.xyz>
To: ffmpeg-devel@ffmpeg.org
Cc: Niklas Haas <git@haasn.dev>
Subject: [FFmpeg-devel] [PATCH 6/6] lavfi/vf_libplacebo: add frame_mixer option
Date: Wed, 10 May 2023 15:55:09 +0200
Message-ID: <20230510135509.4074-6-ffmpeg@haasn.xyz> (raw)
In-Reply-To: <20230510135509.4074-1-ffmpeg@haasn.xyz>
From: Niklas Haas <git@haasn.dev>
Fairly straightforward. We just need to modify the scaler handling code
slightly to support looking at a different list of filter presets.
---
doc/filters.texi | 31 +++++++++++++++++++++++++++++++
libavfilter/vf_libplacebo.c | 17 +++++++++++------
2 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index 3e17ba1654..42ce313743 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16167,6 +16167,31 @@ Cubic BC spline with parameters recommended by Mitchell and Netravali. Very
little ringing.
@end table
+@item frame_mixer
+Controls the kernel used for mixing frames temporally. The default value is
+@code{none}, which disables frame mixing. For a full list of possible values,
+pass @code{help} to this option. The most important values are:
+@table @samp
+@item none
+Disables frame mixing, giving a result equivalent to "nearest neighbour"
+semantics.
+
+@item oversample
+Oversamples the input video to create a "Smooth Motion"-type effect: if an
+output frame would exactly fall on the transition between two video frames, it
+is blended according to the relative overlap. This is the recommended option
+whenever preserving the original subjective appearance is desired.
+
+@item mitchell_clamp
+Larger filter kernel that smoothly interpolates multiple frames in a manner
+designed to eliminate ringing and other artefacts as much as possible. This is
+the recommended option wherever maximum visual smoothness is desired.
+
+@item linear
+Linear blend/fade between frames. Especially useful for constructing e.g.
+slideshows.
+@end table
+
@item lut_entries
Configures the size of scaler LUTs, ranging from @code{1} to @code{256}. The
default of @code{0} will pick libplacebo's internal default, typically
@@ -16524,6 +16549,12 @@ Rescale input to fit into standard 1080p, with high quality scaling:
libplacebo=w=1920:h=1080:force_original_aspect_ratio=decrease:normalize_sar=true:upscaler=ewa_lanczos:downscaler=ewa_lanczos
@end example
+@item
+Interpolate low FPS / VFR input to smoothed constant 60 fps output:
+@example
+libplacebo=fps=60:frame_mixer=mitchell_clamp
+@end example
+
@item
Convert input to standard sRGB JPEG:
@example
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 2bec942358..9cbc1bac94 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -164,6 +164,7 @@ typedef struct LibplaceboContext {
struct pl_render_params params;
char *upscaler;
char *downscaler;
+ char *frame_mixer;
int lut_entries;
float antiringing;
int sigmoid;
@@ -285,17 +286,19 @@ static int parse_shader(AVFilterContext *avctx, const void *shader, size_t len)
static int find_scaler(AVFilterContext *avctx,
const struct pl_filter_config **opt,
- const char *name)
+ const char *name, int frame_mixing)
{
- const struct pl_filter_preset *preset;
+ const struct pl_filter_preset *preset, *presets_avail;
+ presets_avail = frame_mixing ? pl_frame_mixers : pl_scale_filters;
+
if (!strcmp(name, "help")) {
av_log(avctx, AV_LOG_INFO, "Available scaler presets:\n");
- for (preset = pl_scale_filters; preset->name; preset++)
+ for (preset = presets_avail; preset->name; preset++)
av_log(avctx, AV_LOG_INFO, " %s\n", preset->name);
return AVERROR_EXIT;
}
- for (preset = pl_scale_filters; preset->name; preset++) {
+ for (preset = presets_avail; preset->name; preset++) {
if (!strcmp(name, preset->name)) {
*opt = preset->filter;
return 0;
@@ -411,8 +414,9 @@ static int update_settings(AVFilterContext *ctx)
.disable_fbos = s->disable_fbos,
);
- RET(find_scaler(ctx, &s->params.upscaler, s->upscaler));
- RET(find_scaler(ctx, &s->params.downscaler, s->downscaler));
+ RET(find_scaler(ctx, &s->params.upscaler, s->upscaler, 0));
+ RET(find_scaler(ctx, &s->params.downscaler, s->downscaler, 0));
+ RET(find_scaler(ctx, &s->params.frame_mixer, s->frame_mixer, 1));
return 0;
fail:
@@ -1107,6 +1111,7 @@ static const AVOption libplacebo_options[] = {
{ "upscaler", "Upscaler function", OFFSET(upscaler), AV_OPT_TYPE_STRING, {.str = "spline36"}, .flags = DYNAMIC },
{ "downscaler", "Downscaler function", OFFSET(downscaler), AV_OPT_TYPE_STRING, {.str = "mitchell"}, .flags = DYNAMIC },
+ { "frame_mixer", "Frame mixing function", OFFSET(frame_mixer), AV_OPT_TYPE_STRING, {.str = "none"}, .flags = DYNAMIC },
{ "lut_entries", "Number of scaler LUT entries", OFFSET(lut_entries), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 256, DYNAMIC },
{ "antiringing", "Antiringing strength (for non-EWA filters)", OFFSET(antiringing), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, 0.0, 1.0, DYNAMIC },
{ "sigmoid", "Enable sigmoid upscaling", OFFSET(sigmoid), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
--
2.40.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2023-05-10 13:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-10 13:55 [FFmpeg-devel] [PATCH 1/6] lavfi/vf_libplacebo: update render params on demand Niklas Haas
2023-05-10 13:55 ` [FFmpeg-devel] [PATCH 2/6] lavfi/vf_libplacebo: split and refactor logic Niklas Haas
2023-05-10 13:55 ` [FFmpeg-devel] [PATCH 3/6] lavfi/vf_libplacebo: switch to pl_queue-based design Niklas Haas
2023-05-10 13:55 ` [FFmpeg-devel] [PATCH 4/6] lavfi/vf_libplacebo: switch to activate() Niklas Haas
2023-05-10 13:55 ` [FFmpeg-devel] [PATCH 5/6] lavfi/vf_libplacebo: allow fps conversion Niklas Haas
2023-05-10 13:55 ` Niklas Haas [this message]
2023-05-14 9:22 ` [FFmpeg-devel] [PATCH 1/6] lavfi/vf_libplacebo: update render params on demand Niklas Haas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230510135509.4074-6-ffmpeg@haasn.xyz \
--to=ffmpeg@haasn.xyz \
--cc=ffmpeg-devel@ffmpeg.org \
--cc=git@haasn.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git