Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Niklas Haas <ffmpeg@haasn.xyz>
To: ffmpeg-devel@ffmpeg.org
Cc: Niklas Haas <git@haasn.dev>
Subject: [FFmpeg-devel] [PATCH 2/5] avfilter/libplacebo: add deinterlacing options
Date: Sun, 16 Feb 2025 16:58:52 +0100
Message-ID: <20250216155855.450044-2-ffmpeg@haasn.xyz> (raw)
In-Reply-To: <20250216155855.450044-1-ffmpeg@haasn.xyz>

From: Niklas Haas <git@haasn.dev>

These were introduced in libplacebo API version 220. We actually already
map the field by default, but deinterlacing was never enabled unless the user
explicitly forced it using extra_ops.
---
 doc/filters.texi            | 19 +++++++++++++++++++
 libavfilter/vf_libplacebo.c | 17 +++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 4cefef6cbc..c7c8a5668e 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16615,6 +16615,25 @@ Enable sigmoidal compression during upscaling. Reduces ringing slightly.
 Enabled by default.
 @end table
 
+@subsubsection Deinterlacing
+Deinterlacing is automatically supported when frames are tagged as interlaced,
+however frames are not deinterlaced unless a deinterlacing algorithm is chosen.
+@table @option
+@item deinterlace
+The the deinterlacing algorithm to use.
+@table @samp
+@item weave
+No deinterlacing, weave fields together into a single frame. This is the default.
+@item bob
+Naive bob deinterlacing, simply repeat each field line twice.
+@item yadif
+Yet another deinterlacing filter. See the @ref{yadif} filter for more details.
+@end table
+
+@item skip_spatial_check
+Skip the spatial deinterlacing check when using @code{yadif} deinterlacing.
+@end table
+
 @subsubsection Debanding
 Libplacebo comes with a built-in debanding filter that is good at counteracting
 many common sources of banding and blocking. Turning this on is highly
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index e1c6629f6d..fbbc9d5cb7 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -49,6 +49,7 @@ static inline AVFrame *pl_get_mapped_avframe(const struct pl_frame *frame)
 typedef struct pl_options_t {
     // Backwards compatibility shim of this struct
     struct pl_render_params params;
+    struct pl_deinterlace_params deinterlace_params;
     struct pl_deband_params deband_params;
     struct pl_sigmoid_params sigmoid_params;
     struct pl_color_adjustment color_adjustment;
@@ -211,6 +212,10 @@ typedef struct LibplaceboContext {
     int force_dither;
     int disable_fbos;
 
+    /* pl_deinterlace_params */
+    int deinterlace;
+    int skip_spatial_check;
+
     /* pl_deband_params */
     int deband;
     int deband_iterations;
@@ -372,6 +377,11 @@ static int update_settings(AVFilterContext *ctx)
 
     RET(av_parse_color(color_rgba, s->fillcolor, -1, s));
 
+    opts->deinterlace_params = *pl_deinterlace_params(
+        .algo = s->deinterlace,
+        .skip_spatial_check = s->skip_spatial_check,
+    );
+
     opts->deband_params = *pl_deband_params(
         .iterations = s->deband_iterations,
         .threshold = s->deband_threshold,
@@ -436,6 +446,7 @@ static int update_settings(AVFilterContext *ctx)
         .corner_rounding = s->corner_rounding,
 #endif
 
+        .deinterlace_params = &opts->deinterlace_params,
         .deband_params = s->deband ? &opts->deband_params : NULL,
         .sigmoid_params = s->sigmoid ? &opts->sigmoid_params : NULL,
         .color_adjustment = &opts->color_adjustment,
@@ -1358,6 +1369,12 @@ static const AVOption libplacebo_options[] = {
     { "apply_filmgrain", "Apply film grain metadata", OFFSET(apply_filmgrain), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
     { "apply_dolbyvision", "Apply Dolby Vision metadata", OFFSET(apply_dovi), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
 
+    { "deinterlace", "Deinterlacing mode", OFFSET(deinterlace), AV_OPT_TYPE_INT, {.i64 = PL_DEINTERLACE_WEAVE}, 0, PL_DEINTERLACE_ALGORITHM_COUNT - 1, DYNAMIC, .unit = "deinterlace" },
+        { "weave", "Weave fields together (no-op)",    0, AV_OPT_TYPE_CONST, {.i64 = PL_DEINTERLACE_WEAVE}, 0, 0, STATIC, .unit = "deinterlace" },
+        { "bob",   "Naive bob deinterlacing",          0, AV_OPT_TYPE_CONST, {.i64 = PL_DEINTERLACE_BOB},   0, 0, STATIC, .unit = "deinterlace" },
+        { "yadif", "Yet another deinterlacing filter", 0, AV_OPT_TYPE_CONST, {.i64 = PL_DEINTERLACE_YADIF}, 0, 0, STATIC, .unit = "deinterlace" },
+    { "skip_spatial_check", "Skip yadif spatial check", OFFSET(skip_spatial_check), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
+
     { "deband", "Enable debanding", OFFSET(deband), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
     { "deband_iterations", "Deband iterations", OFFSET(deband_iterations), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 16, DYNAMIC },
     { "deband_threshold", "Deband threshold", OFFSET(deband_threshold), AV_OPT_TYPE_FLOAT, {.dbl = 4.0}, 0.0, 1024.0, DYNAMIC },
-- 
2.47.0

_______________________________________________
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".

  reply	other threads:[~2025-02-16 16:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-16 15:58 [FFmpeg-devel] [PATCH 1/5] configure: align libplacebo version check with reality Niklas Haas
2025-02-16 15:58 ` Niklas Haas [this message]
2025-02-16 15:58 ` [FFmpeg-devel] [PATCH 3/5] avfilter/libplacebo: only mark frame fields when deinterlacing Niklas Haas
2025-02-16 15:58 ` [FFmpeg-devel] [PATCH 4/5] avfilter/libplacebo: strip interlaced flag " Niklas Haas
2025-02-16 15:58 ` [FFmpeg-devel] [PATCH 5/5] avfilter/libplacebo: add option for outputting separate fields 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=20250216155855.450044-2-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