From patchwork Sun Sep 5 04:28:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 30001 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp2661117iov; Sat, 4 Sep 2021 21:28:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx17/ta8K+R6wm/6Ya2fm9mRPH9H1yUsqCMANppORJjm363bWh1oEBP+QzSx3akh9J3RxhJ X-Received: by 2002:a05:6402:4396:: with SMTP id o22mr7085166edc.232.1630816121611; Sat, 04 Sep 2021 21:28:41 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gb1si4764613ejc.89.2021.09.04.21.28.40; Sat, 04 Sep 2021 21:28:41 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@hotmail.com header.s=selector1 header.b=iWfNErVh; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hotmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CC11F68038B; Sun, 5 Sep 2021 07:28:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11olkn2095.outbound.protection.outlook.com [40.92.19.95]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ABDC968038B for ; Sun, 5 Sep 2021 07:28:29 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GjEL1ovkm3hVVdHcMHo/f2QglunDrpfcjgpvkDzMQW0piYhGFT56dFdI27BQ4wqmBuG1gUoDD9Sl9Azhjv0a+yE+qV4No+Rqfy7YKEmRFZmZq1pCvQSQRQzm1+swkCQ5eW5SDQPrudDlp2Xq0BkgH6HRPhhqIIUTP6HpRb6wFupLxQl8Y5LaTjd/NYuq6sMLbZUVoHgmrXpN75ImVplAmA4P/M9nTJFsVoja1rx2MLzFZguBeEQvY71ZqqjpTcoqlKj9Y2VT6LpF2VV21nTG88h7mKKL9XguFVlSwXH8OO61Y1TG2WmBjve+3khY01XZ2Qzt3U87x1tAj7zAx8/t8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=uvt4TyCSV8oBhdxYC+hx6FFETA2DeUJAS4O46z8mbRk=; b=jtRFveSKq/sFYLv/u7XnnDW1HDJ0KS3EdFMry3ZtKPIP+UH+OBxEh2E1cjMU1xwdT/OTTlpPmVe5OdDpy8PYp0LGOn0EyqMseDnWNSFKu5ZcqRsE6l7vBM4bwlBNi67Pt4GgP9dPCgw5PmUIosNI/mq3rSGVHUgQhgpNdTPYi80KXABv015aa+4lu8D4UHsOOR7Ln8OwIQCUk8hFsrrAznTgFEL6rGRURMFTJI9P2j2rNaERmfgipw0zmMBjy5LPE703ROBTyDRbGZmyGDuEOOHEWgdzTO9t68ucClffQnJUXfsDCoq8pGCDqGY/KimrnKLYHZzyfFXc7/t2R2lotQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uvt4TyCSV8oBhdxYC+hx6FFETA2DeUJAS4O46z8mbRk=; b=iWfNErVhc0C18gLQEugiojzxYOzpEmqgohK0XD33Ji//tKTwHdBFq6yOTJfmjMxi3vZVWOcoubV4IEiNhqvmA/ZV0SJlqgtoiAZZpru6FiTfE2TAhSVHfvMMkmlyjVAPUTN2uIAv+rsGaznoF8iCeBosIjBfXHHOln1DdQ7dR5uFCbgNvsYEP0YBFpGGfUMtz8oj14iJ7QaNJ8m81ERgQOAqYrORZPQumNg7zve5NaH8nvCrVS5QzTv5WhmmrRmxwF+Rpych9iE+aEM3PKaOGnK2HEDT760wLCQofNgy/trCy2Wq2gxpapuI4haC8onrqtkjwo2QbkrVvVNrWVWyPg== Received: from MN2PR04MB5981.namprd04.prod.outlook.com (2603:10b6:208:da::10) by MN2PR04MB5597.namprd04.prod.outlook.com (2603:10b6:208:a0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17; Sun, 5 Sep 2021 04:28:26 +0000 Received: from MN2PR04MB5981.namprd04.prod.outlook.com ([fe80::ecfe:2528:2012:22cb]) by MN2PR04MB5981.namprd04.prod.outlook.com ([fe80::ecfe:2528:2012:22cb%5]) with mapi id 15.20.4478.025; Sun, 5 Sep 2021 04:28:26 +0000 From: Soft Works To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH] avfilter/avfilter: Fix hardcoded input index Thread-Index: Adeh93YIZUeJtbmURcC8FdMWbCE+xw== Date: Sun, 5 Sep 2021 04:28:26 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [WYNeKo1IdyOlroYpYyleeF+jxLg2vc+I] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e815f69d-d791-4992-f0ea-08d970259b04 x-ms-traffictypediagnostic: MN2PR04MB5597: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 6ZwYdBUqaoXA/bp9fzHEcQFLFD+KaHwo6ziaoaa8oh2Y/yxQFhCTd/Vqah7xasggceOW6CEYu6pbH2O72xHQrjIsDAXDIHzr6kbwYCbc045rReRiga1DlFEAcd4UFDzBIfs0fRKBJKST5zvqsF7iTYdrAynjjuw0VpxVUWydinYlow+kI3wKRkvGTT6qXSU8zIj5lC8p3sQGbLlEMffsw5qTGNWlomXbdTsmS2ZLG3cHAklAGSD2xNCWEqTD75ZddKZQht34z2w4b4Lgx+zD7yZDl70QlzFOJoZkhvnRxWxLwbp3hRHvB47oBSC9M+sEaqKxJQAx2tJRG0H6WRZcvv0t0C8wNdHfvsDw4kQQSkjPwKKlW7dlGw3hUK/NtXTwcE+zjlpG8H/SnlDWP7uOUhpqmN8fAAhp1gOuIvg3d7wpW4cpdR1EfxZR0hnrkhkN x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: cwNfA2WR8c65N2XQ84J4DuVTxWyxkDgDn1fpfMFyAOBLVnyEvyJu6ra5OOFDuUDgg+4H+/EVZVy8X7DDiZm5jldRUCndE4f91eVItRoo1DVAhV00FLN10jjDzokvA55EfPaVjl0VLwOJwW+5CYOkag== x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-3174-20-msonline-outlook-529c7.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR04MB5981.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: e815f69d-d791-4992-f0ea-08d970259b04 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Sep 2021 04:28:26.5139 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB5597 Subject: [FFmpeg-devel] [PATCH] avfilter/avfilter: Fix hardcoded input index 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: EmvaVF3o4LcR This fix targets cases where multiple input pads have a .filter_frame function. ff_request_frame_to_filter needs to call ff_request_frame with the correct input pad instead of the hardcoded first one. Signed-off-by: softworkz --- libavfilter/avfilter.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index a04f8ed62f..78377ac7f9 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -461,7 +461,7 @@ static int64_t guess_status_pts(AVFilterContext *ctx, int status, AVRational lin return AV_NOPTS_VALUE; } -static int ff_request_frame_to_filter(AVFilterLink *link) +static int ff_request_frame_to_filter(AVFilterLink *link, int input_index) { int ret = -1; @@ -470,8 +470,8 @@ static int ff_request_frame_to_filter(AVFilterLink *link) link->frame_blocked_in = 1; if (link->srcpad->request_frame) ret = link->srcpad->request_frame(link); - else if (link->src->inputs[0]) - ret = ff_request_frame(link->src->inputs[0]); + else if (link->src->inputs[input_index]) + ret = ff_request_frame(link->src->inputs[input_index]); if (ret < 0) { if (ret != AVERROR(EAGAIN) && ret != link->status_in) ff_avfilter_link_set_in_status(link, ret, guess_status_pts(link->src, ret, link->time_base)); @@ -1169,6 +1169,14 @@ static int forward_status_change(AVFilterContext *filter, AVFilterLink *in) { unsigned out = 0, progress = 0; int ret; + int input_index = 0; + + for (int i = 0; i < in->dst->nb_inputs; i++) { + if (&in->dst->input_pads[i] == in->dstpad) { + input_index = i; + break; + } + } av_assert0(!in->status_out); if (!filter->nb_outputs) { @@ -1178,7 +1186,7 @@ static int forward_status_change(AVFilterContext *filter, AVFilterLink *in) while (!in->status_out) { if (!filter->outputs[out]->status_in) { progress++; - ret = ff_request_frame_to_filter(filter->outputs[out]); + ret = ff_request_frame_to_filter(filter->outputs[out], input_index); if (ret < 0) return ret; } @@ -1215,7 +1223,7 @@ static int ff_filter_activate_default(AVFilterContext *filter) for (i = 0; i < filter->nb_outputs; i++) { if (filter->outputs[i]->frame_wanted_out && !filter->outputs[i]->frame_blocked_in) { - return ff_request_frame_to_filter(filter->outputs[i]); + return ff_request_frame_to_filter(filter->outputs[i], 0); } } return FFERROR_NOT_READY;