From: Niklas Haas <ffmpeg@haasn.xyz> To: ffmpeg-devel@ffmpeg.org Cc: Niklas Haas <git@haasn.dev> Subject: [FFmpeg-devel] [PATCH 5/5] avfilter/libplacebo: add option for outputting separate fields Date: Sun, 16 Feb 2025 16:58:55 +0100 Message-ID: <20250216155855.450044-5-ffmpeg@haasn.xyz> (raw) In-Reply-To: <20250216155855.450044-1-ffmpeg@haasn.xyz> From: Niklas Haas <git@haasn.dev> cf. the other deinterlacing-aware filters. --- doc/filters.texi | 5 +++++ libavfilter/vf_libplacebo.c | 23 ++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index c7c8a5668e..6f0c89489e 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16632,6 +16632,11 @@ Yet another deinterlacing filter. See the @ref{yadif} filter for more details. @item skip_spatial_check Skip the spatial deinterlacing check when using @code{yadif} deinterlacing. + +@item send_fields +Output a frame for each field, rather than for each frame. Note that this will +always double the tagged output frame rate, even if the input does not contain +any interlaced frames. Disabled by default. @end table @subsubsection Debanding diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 7dc275f565..528eabd6d0 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -215,6 +215,7 @@ typedef struct LibplaceboContext { /* pl_deinterlace_params */ int deinterlace; int skip_spatial_check; + int send_fields; /* pl_deband_params */ int deband; @@ -970,8 +971,7 @@ static int handle_input(AVFilterContext *ctx, LibplaceboInput *input) int64_t pts; while ((ret = ff_inlink_consume_frame(inlink, &in)) > 0) { - in->opaque = s; - pl_queue_push(input->queue, &(struct pl_source_frame) { + struct pl_source_frame src = { .pts = in->pts * av_q2d(inlink->time_base), .duration = in->duration * av_q2d(inlink->time_base), .first_field = s->deinterlace ? pl_field_from_avframe(in) : PL_FIELD_NONE, @@ -979,12 +979,21 @@ static int handle_input(AVFilterContext *ctx, LibplaceboInput *input) .map = map_frame, .unmap = unmap_frame, .discard = discard_frame, - }); + }; + + in->opaque = s; + pl_queue_push(input->queue, &src); if (!s->fps.num) { /* Internally queue an output frame for the same PTS */ pts = av_rescale_q(in->pts, inlink->time_base, outlink->time_base); av_fifo_write(input->out_pts, &pts, 1); + + if (s->send_fields && src.first_field != PL_FIELD_NONE) { + /* Queue the second field for interlaced content */ + pts += av_rescale_q(in->duration, inlink->time_base, outlink->time_base) / 2; + av_fifo_write(input->out_pts, &pts, 1); + } } } @@ -1242,6 +1251,13 @@ static int libplacebo_config_output(AVFilterLink *outlink) avctx->inputs[i]->time_base, AV_TIME_BASE / 2, AV_TIME_BASE_Q); } + + if (s->deinterlace && s->send_fields) { + const AVRational q2 = { 2, 1 }; + ol->frame_rate = av_mul_q(ol->frame_rate, q2); + /* Ensure output frame timestamps are divisible by two */ + outlink->time_base = av_div_q(outlink->time_base, q2); + } } /* Static variables */ @@ -1376,6 +1392,7 @@ static const AVOption libplacebo_options[] = { { "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 }, + { "send_fields", "Output a frame for each field", OFFSET(send_fields), 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 }, -- 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".
prev parent reply other threads:[~2025-02-16 16:02 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 ` [FFmpeg-devel] [PATCH 2/5] avfilter/libplacebo: add deinterlacing options Niklas Haas 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 ` Niklas Haas [this message]
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-5-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