From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id C12E4444D0 for ; Mon, 12 Dec 2022 20:08:30 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C2FB368BD9A; Mon, 12 Dec 2022 22:08:26 +0200 (EET) Received: from mail-vk1-f182.google.com (mail-vk1-f182.google.com [209.85.221.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A1A7068BA1C for ; Mon, 12 Dec 2022 22:08:20 +0200 (EET) Received: by mail-vk1-f182.google.com with SMTP id v81so505808vkv.5 for ; Mon, 12 Dec 2022 12:08:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:references:in-reply-to:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=hVzHcc/0cZeIF0eb23/TPI+OItje87dWT5w2Qi6xM5g=; b=OEiqcf8+KsbQB3HFmJxmKpsX57dDBuGPeMY2NDXiRMxDjPe6JhRJNxgz+yh+D1TEV5 1Wd2vZP0idWI/fWDvNO1ytwhhwOLRxl0IdbdozI9vUQ4SR1p4pmGlC5n3uXVuNnHnFqn rO3qibmxsDefpCLRJ/9I9rcelHkCSySSSWk2zBR7mUv9SF8si4DqO8O6mWIW+6D2cxIU 6DCxnJFXndGxmwfHZTe+03/QZ96Kz4EMh7DrxcDW+jGUortR939upIt7vDDXu86lx5ni ZNwPTF93y31rMU8dABp2Kf8y+1X8XWTVD7f+4iwfq71nWR54Hx+zgA4aOHSJ5DetSoiH vhWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:references:in-reply-to:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hVzHcc/0cZeIF0eb23/TPI+OItje87dWT5w2Qi6xM5g=; b=a2NYzKvRGE9ARxbLZPpMpW7iOIa0TLP0yEDvdx0uIio0CQsQygU3KTgSHUvUBkuo+f UCRbVfDCm7frs2sauDkD6mBXib4KFNHqdE5DNhc9SOpTcpw8+508mEd4NzOCoyIGFkVu jUJDr1hPSgUEFj9Kva4OQa6T2lFu4TqtrnsIAoiwrF0KNRYb7mhXVxcpx30LcPT5i6rD gw0GR0pquIw4GI8q7cuwsyofI30EIU9woy7ax2+Cflp69CtmhCxbOEOnCqofagV3T990 t5jYjcK0uM3geUqFwisj8MYpwC+haPfpkZQV06YD5Khnac2rWWHKF2CQQO0fWXj6vdwo YTeg== X-Gm-Message-State: ANoB5pli+rJFUQkITX3DOoMfqFT2woFgyHGqyMWHlWeMW4i3deyO5U3c 5O8UgLFVnThpVLdRfbOHUP0Q6SHi6JBbiLh+SI9yyazJ X-Google-Smtp-Source: AA0mqf6gY6EdFtosLPAKkVsXMNNsAwq1PY2lBKUAPvmId8yf37jvxwE+rMWLkEY03u4eHjoYakfCAQ7QjXfijuc9ul0= X-Received: by 2002:a1f:adce:0:b0:3bc:9f94:d7f1 with SMTP id w197-20020a1fadce000000b003bc9f94d7f1mr40256139vke.21.1670875698624; Mon, 12 Dec 2022 12:08:18 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a05:612c:2428:b0:32a:5eaa:92e4 with HTTP; Mon, 12 Dec 2022 12:08:17 -0800 (PST) In-Reply-To: <20220402120623.142534-1-onemda@gmail.com> References: <20220402120623.142534-1-onemda@gmail.com> From: Paul B Mahol Date: Mon, 12 Dec 2022 21:08:17 +0100 Message-ID: To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH 1/2] avfilter/src_movie: switch to activate() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Can I ask some knowledgeable people to comment why this patch have issues? On 4/2/22, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol > --- > libavfilter/src_movie.c | 90 +++++++++++++++++++++++++---------------- > 1 file changed, 56 insertions(+), 34 deletions(-) > > diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c > index 711854c23c..bc7b0d37af 100644 > --- a/libavfilter/src_movie.c > +++ b/libavfilter/src_movie.c > @@ -46,6 +46,7 @@ > > #include "audio.h" > #include "avfilter.h" > +#include "filters.h" > #include "formats.h" > #include "internal.h" > #include "video.h" > @@ -55,6 +56,7 @@ typedef struct MovieStream { > AVCodecContext *codec_ctx; > int64_t discontinuity_threshold; > int64_t last_pts; > + int got_eof; > } MovieStream; > > typedef struct MovieContext { > @@ -70,6 +72,8 @@ typedef struct MovieContext { > int64_t discontinuity_threshold; > int64_t ts_offset; > int dec_threads; > + int got_eagain; > + int got_wanted; > > AVFormatContext *format_ctx; > > @@ -100,7 +104,6 @@ static const AVOption movie_options[]= { > }; > > static int movie_config_output_props(AVFilterLink *outlink); > -static int movie_request_frame(AVFilterLink *outlink); > > static AVStream *find_stream(void *log, AVFormatContext *avf, const char > *spec) > { > @@ -314,7 +317,6 @@ static av_cold int movie_common_init(AVFilterContext > *ctx) > if (!pad.name) > return AVERROR(ENOMEM); > pad.config_props = movie_config_output_props; > - pad.request_frame = movie_request_frame; > if ((ret = ff_append_outpad_free_name(ctx, &pad)) < 0) > return ret; > if ( movie->st[i].st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO > && > @@ -554,47 +556,67 @@ static int movie_push_frame(AVFilterContext *ctx, > unsigned out_id) > return 0; > } > > -static int movie_request_frame(AVFilterLink *outlink) > +static int activate(AVFilterContext *ctx) > { > - AVFilterContext *ctx = outlink->src; > MovieContext *movie = ctx->priv; > - unsigned out_id = FF_OUTLINK_IDX(outlink); > + int ret = 0; > + > + /* check all decoders for available output */ > + for (int i = 0; i < ctx->nb_outputs; i++) { > + if (movie->st[i].got_eof) > + continue; > + > + if (ff_outlink_frame_wanted(ctx->outputs[i])) > + movie->got_wanted++; > > - while (1) { > - int got_eagain = 0, got_eof = 0; > - int ret = 0; > + ret = movie_push_frame(ctx, i); > + if (ret == AVERROR(EAGAIN)) > + movie->got_eagain++; > + else if (ret == AVERROR_EOF) > + movie->st[i].got_eof = 1; > + else if (ret < 0) > + return ret; > + } > + > + if (movie->got_eagain || movie->got_wanted) { > + /* all decoders require more input -> read a new packet */ > + movie->got_eagain = 0; > + movie->got_wanted = 0; > + ret = movie_decode_packet(ctx); > + if (ret < 0 && ret != AVERROR(EAGAIN)) > + return ret; > + ff_filter_set_ready(ctx, 100); > + return 0; > + } else { > + int nb_eofs = 0; > > - /* check all decoders for available output */ > for (int i = 0; i < ctx->nb_outputs; i++) { > - ret = movie_push_frame(ctx, i); > - if (ret == AVERROR(EAGAIN)) > - got_eagain++; > - else if (ret == AVERROR_EOF) > - got_eof++; > - else if (ret < 0) > - return ret; > - else if (i == out_id) > - return 0; > + if (movie->st[i].got_eof) { > + if (movie->loop_count == 1) > + ff_outlink_set_status(ctx->outputs[i], AVERROR_EOF, > movie->st[i].last_pts); > + nb_eofs++; > + } > + } > + > + if (nb_eofs != ctx->nb_outputs) { > + ff_filter_set_ready(ctx, 100); > + return 0; > } > > - if (got_eagain) { > - /* all decoders require more input -> read a new packet */ > - ret = movie_decode_packet(ctx); > + if (movie->loop_count != 1) { > + ret = rewind_file(ctx); > if (ret < 0) > return ret; > - } else if (got_eof) { > - /* all decoders flushed */ > - if (movie->loop_count != 1) { > - ret = rewind_file(ctx); > - if (ret < 0) > - return ret; > - movie->loop_count -= movie->loop_count > 1; > - av_log(ctx, AV_LOG_VERBOSE, "Stream finished, > looping.\n"); > - continue; > - } > - return AVERROR_EOF; > + movie->loop_count -= movie->loop_count > 1; > + av_log(ctx, AV_LOG_VERBOSE, "Stream finished, looping.\n"); > + for (int i = 0; i < ctx->nb_outputs; i++) > + movie->st[i].got_eof = 0; > + ff_filter_set_ready(ctx, 100); > } > + return 0; > } > + > + return FFERROR_NOT_READY; > } > > static int process_command(AVFilterContext *ctx, const char *cmd, const > char *args, > @@ -651,7 +673,7 @@ const AVFilter ff_avsrc_movie = { > .init = movie_common_init, > .uninit = movie_uninit, > FILTER_QUERY_FUNC(movie_query_formats), > - > + .activate = activate, > .inputs = NULL, > .outputs = NULL, > .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS, > @@ -670,7 +692,7 @@ const AVFilter ff_avsrc_amovie = { > .init = movie_common_init, > .uninit = movie_uninit, > FILTER_QUERY_FUNC(movie_query_formats), > - > + .activate = activate, > .inputs = NULL, > .outputs = NULL, > .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS, > -- > 2.35.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".