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 0C7B940855 for ; Sat, 2 Apr 2022 12:04:21 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5F3CF68B11B; Sat, 2 Apr 2022 15:04:19 +0300 (EEST) Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DA384680422 for ; Sat, 2 Apr 2022 15:04:13 +0300 (EEST) Received: by mail-ed1-f43.google.com with SMTP id b24so5787773edu.10 for ; Sat, 02 Apr 2022 05:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=Bus35fwkKlgpB6pCkPUbHAxa1Rnk61qKEq+p/plMMnQ=; b=Y/fhylz022jkZ8gVE6rB6seWgdgW7PMubQ7YDRO94s/0DaXOhQ9+N9gPoBsL+zxLjs 2oopVwBgD1FU81FSp4R8bIcPQdctL3MPO/jQPRdWEKQQb11xtqLrIWa5acm/ZFKfOIFx pRWDK9SPOWN2iT9i9keMvuI3HrrkeIu2NnkrrqiWos47Dg0IEYmKdsPgR3alGwfnS3/8 QcceRMJd8YbAY6FxJr3wm93Zr2zO+gmZGiU0ePzuKdVAVfbrKn2VXNtft0ilTRyV/DQj G/34jap+Qz55Y/b2i/sSHJrufZeDIK1TQvxAYzE6RZeJL9rDFd+v3nyQ/Cg9RCxw6ZnF fcGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=Bus35fwkKlgpB6pCkPUbHAxa1Rnk61qKEq+p/plMMnQ=; b=e/jmlh2YNG9hsfka+XjVVZdoZQcjVc/b8HAgyAvDHtSKmqnqkj6fBmobpWigToNpDr UVXOF0E70oFNoY5JZCE0r5khs4U87GqKaYZKYfyZRUnXS6d1yaGNGSeIedXi4Ln/sWq8 lfIxMFix84bztwv0zWCMeTfpYIYry2jRCCCbaqNuTY8MZwVL5yoYB+Kc6T5SZdEo/kW8 NwLH2suDpUvKUVczaOsfnmTSHTF/5+IWc/hCKhl0aHMcyt0XWeNcT03xOZkEaZ0/DGuE u3TQX+3SXFwP/hDQBKUWF661ttF2JekiWJ1d3X/Gb6OamZL670SO7jrWSIRppo0Yhxd2 gv0g== X-Gm-Message-State: AOAM532cv0OuclGVOaGmDk9mfMvSkUygzD5zn4uQyN6/nU3FvODyMZ6o HR5yYKfATvFmU/VwIDG+txr91YQCANc= X-Google-Smtp-Source: ABdhPJyr8Ug0XT6IuYyzhOUZemh7kIIL8EL1E3txRu+DRwL9DFeoNtQuySdXVVGePRFUqEjlhax/hg== X-Received: by 2002:aa7:d74d:0:b0:419:1d7:adcc with SMTP id a13-20020aa7d74d000000b0041901d7adccmr25050326eds.407.1648901053313; Sat, 02 Apr 2022 05:04:13 -0700 (PDT) Received: from localhost.localdomain ([95.168.120.6]) by smtp.gmail.com with ESMTPSA id dd6-20020a1709069b8600b006df08710d00sm2075752ejc.85.2022.04.02.05.04.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Apr 2022 05:04:12 -0700 (PDT) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Sat, 2 Apr 2022 14:06:22 +0200 Message-Id: <20220402120623.142534-1-onemda@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [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: 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".