From: Thilo Borgmann via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Thilo Borgmann <thilo.borgmann@mail.de>
Subject: Re: [FFmpeg-devel] [PATCH v3 1/2] avfilter: Add fsync filter
Date: Sun, 7 Jan 2024 14:02:44 +0100
Message-ID: <5acb01a9-0363-422d-a7bf-0b888354e68c@mail.de> (raw)
In-Reply-To: <82761741-27f5-49dd-8bf9-0127f4688993@gmail.com>
Am 06.01.24 um 18:39 schrieb James Almer:
> On 12/16/2023 5:13 AM, Thilo Borgmann via ffmpeg-devel wrote:
>> ---
>> Changelog | 1 +
>> MAINTAINERS | 1 +
>> configure | 2 +
>> doc/filters.texi | 33 +++++
>> libavfilter/Makefile | 1 +
>> libavfilter/allfilters.c | 1 +
>> libavfilter/version.h | 2 +-
>> libavfilter/vf_fsync.c | 286 +++++++++++++++++++++++++++++++++++++++
>> 8 files changed, 326 insertions(+), 1 deletion(-)
>> create mode 100644 libavfilter/vf_fsync.c
>
> [...]
>
>> +static int activate(AVFilterContext *ctx)
>> +{
>> + FsyncContext *s = ctx->priv;
>> + AVFilterLink *inlink = ctx->inputs[0];
>> + AVFilterLink *outlink = ctx->outputs[0];
>> +
>> + int ret, line_count;
>> + AVFrame *frame;
>> +
>> + FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
>> +
>> + buf_skip_eol(s);
>> + line_count = buf_get_line_count(s);
>> + if (line_count < 0) {
>> + line_count = buf_reload(s);
>> + if (line_count < 0)
>> + return line_count;
>> + line_count = buf_get_line_count(s);
>> + if (line_count < 0)
>> + return line_count;
>> + }
>> +
>> + if (avio_feof(s->avio_ctx) && buf_get_zero(s) < 3) {
>> + av_log(ctx, AV_LOG_DEBUG, "End of file. To zero = %i\n", buf_get_zero(s));
>> + goto end;
>> + }
>> +
>> + if (s->last_frame) {
>> + ret = av_sscanf(s->cur, "%"PRId64" %"PRId64" %d/%d", &s->ptsi, &s->pts, &s->tb_num, &s->tb_den);
>> + if (ret != 4) {
>> + av_log(ctx, AV_LOG_ERROR, "Unexpected format found (%i / 4).\n", ret);
>> + ff_outlink_set_status(outlink, AVERROR_INVALIDDATA, AV_NOPTS_VALUE);
>> + return AVERROR_INVALIDDATA;
>> + }
>> +
>> + av_log(ctx, AV_LOG_DEBUG, "frame %lli ", s->last_frame->pts);
>> +
>> + if (s->last_frame->pts >= s->ptsi) {
>> + av_log(ctx, AV_LOG_DEBUG, ">= %lli: DUP LAST with pts = %lli\n", s->ptsi, s->pts);
>> +
>> + // clone frame
>> + frame = av_frame_clone(s->last_frame);
>> + if (!frame) {
>> + ff_outlink_set_status(outlink, AVERROR(ENOMEM), AV_NOPTS_VALUE);
>> + return AVERROR(ENOMEM);
>> + }
>> +
>> + // set output pts and timebase
>> + frame->pts = s->pts;
>> + frame->time_base = av_make_q((int)s->tb_num, (int)s->tb_den);
>> +
>> + // advance cur to eol, skip over eol in the next call
>> + s->cur += line_count;
>> +
>> + // call again
>> + if (ff_inoutlink_check_flow(inlink, outlink))
>> + ff_filter_set_ready(ctx, 100);
>> +
>> + // filter frame
>> + return ff_filter_frame(outlink, frame);
>> + } else if (s->last_frame->pts < s->ptsi) {
>> + av_log(ctx, AV_LOG_DEBUG, "< %lli: DROP\n", s->ptsi);
>> + av_frame_free(&s->last_frame);
>> +
>> + // call again
>> + if (ff_inoutlink_check_flow(inlink, outlink))
>> + ff_filter_set_ready(ctx, 100);
>> +
>> + return 0;
>> + }
>> + }
>> +
>> +end:
>> + ret = ff_inlink_consume_frame(inlink, &s->last_frame);
>
> There's a leak in this filter, and i suspect it's here. If s->last_frame is not NULL, the pointer will be rewritten and the frame will leak.
>
> http://fate.ffmpeg.org/history.cgi?slot=x86_64-archlinux-gcc-valgrind-no-undef
Indeed - fixed & pushed.
Thanks,
Thilo
_______________________________________________
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:[~2024-01-07 13:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-16 8:13 [FFmpeg-devel] [PATCH v3 0/2] " Thilo Borgmann via ffmpeg-devel
2023-12-16 8:13 ` [FFmpeg-devel] [PATCH v3 1/2] " Thilo Borgmann via ffmpeg-devel
2023-12-17 22:51 ` Michael Niedermayer
2023-12-18 11:02 ` Thilo Borgmann via ffmpeg-devel
2023-12-31 12:31 ` Thilo Borgmann via ffmpeg-devel
2024-01-05 8:32 ` Thilo Borgmann via ffmpeg-devel
2023-12-18 1:04 ` Stefano Sabatini
2023-12-18 11:03 ` Thilo Borgmann via ffmpeg-devel
2024-01-06 17:39 ` James Almer
2024-01-07 13:02 ` Thilo Borgmann via ffmpeg-devel [this message]
2023-12-16 8:13 ` [FFmpeg-devel] [PATCH v3 2/2] fate: Add fsync filter tests Thilo Borgmann via ffmpeg-devel
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=5acb01a9-0363-422d-a7bf-0b888354e68c@mail.de \
--to=ffmpeg-devel@ffmpeg.org \
--cc=thilo.borgmann@mail.de \
/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