From patchwork Sat Nov 27 19:38:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 31771 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp4020028iob; Sat, 27 Nov 2021 11:40:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4IDVGegzx/Je84Gb4Sy8Z86j0uK3b4dDeJQMuK3EHVssaAUUL+wEYju32D4ZzR9SvIIjD X-Received: by 2002:a05:6402:4301:: with SMTP id m1mr58410939edc.54.1638042015481; Sat, 27 Nov 2021 11:40:15 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id kx3si16416538ejc.504.2021.11.27.11.40.15; Sat, 27 Nov 2021 11:40:15 -0800 (PST) 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=BUCCf8ys; 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 B0A0A68A927; Sat, 27 Nov 2021 21:38:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07olkn2024.outbound.protection.outlook.com [40.92.43.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8944168AB2E for ; Sat, 27 Nov 2021 21:38:07 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XzI4R+JsrmnMtmAciMu4iUOkrog8pHX8NxnFmALczuPq5mUDLCycVx51d38Cfs7nGYBIZ351nT08J2gfai2eUhMX81l8LykM8AgwRm9M1uEUyofn7F3CyFbkAg3rdbAT7ZMyow59AvYp6QehY6DU9BEkvI2narJbhaCC+wiFdnPRGXGgU/wiKNfuqLhGbq9VeetKAKc8R9r+k3vjaJ7bSOcch1KzLEgt8DYTvEVWd1uOXDotVsmeGu/QD0QTLXBgJqUNAJLlhhGyWCW7YA9Qesd2YBBcCbN7wy64D6l5LHyy71zqPzYLLLNx7EpY0MHVZw+QM8/GTTlTNHggPLeLBA== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PEr5v4/HVAs6sNUIpVFS6ON8WAePVTYCgWJ0N59LIZQ=; b=N8Zla7qjVs8vS2g0MXL3krhyK8JQHPSCYXB5NRNUU9h027T/qGhIX6OxSN35jiwM5J5bu8mJDK08Qpr/5iAwsHobeOmuYaptQI9izsNwbbUQ5jwbYLsWD850N8sWWgNtJmnYfS2MBNxwfx/BSc5a1ZdOufy4Em77FNmtk2q1qlEhmlPfxkovRTWkpOWfYCPUST0IzIPfEW83ATK32THG/t0YsgaKtPjewFxwHsuAwksc9Nh0jVR1bP98jnREK8FrtYPNkYJKix+BbUJAutn2QIRwrl6g45OmxIYLulgvrEpcmdRgP5UvPNW6kn44Ord7VQD8i/KX9xsOBJFxvq+NBg== 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=PEr5v4/HVAs6sNUIpVFS6ON8WAePVTYCgWJ0N59LIZQ=; b=BUCCf8ysWgchC5FMV24GVOxKSDyAvWiYYZX/3UgSPU3gIWgQ318QLYeNblTT7EXlmDu85qfgSMGqnwzPrRZxDYSF2Rg0l7ShHy7D0u00h9Z1M60AETZoMdIr1NX8wvZ6R7qxXxPH0MDXt1khg4ylsB2SNHkVtrLbTjjYSM9GHePyzB4zzCTDb2KHNKDZRc7hVo9tBb2z6xK7qvSpQ1e27sZYTx4UY42lkxY3kI1KSWJ2MCysxa8tRPofZn6/xZdEs5/8FuuTfx03yCGKJIKdEIN0xHkME75cm/ghovqntNsWPwIdjMcYgrv9yRJc30XTnW+HeGY7bQ9AbIwUaLzszg== Received: from DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM (2603:10b6:8:b::20) by DM8P223MB0031.NAMP223.PROD.OUTLOOK.COM (2603:10b6:8:b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23; Sat, 27 Nov 2021 19:38:04 +0000 Received: from DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM ([fe80::9c8d:fc63:9488:9775]) by DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM ([fe80::9c8d:fc63:9488:9775%5]) with mapi id 15.20.4734.022; Sat, 27 Nov 2021 19:38:04 +0000 From: Soft Works To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v17 13/19] avfilter/avfilter: Fix hardcoded input index Thread-Index: AQHX48ZLnv9rD/8ouEipnR4lCL1GRg== Date: Sat, 27 Nov 2021 19:38:04 +0000 Message-ID: References: <7463f4e16ad074b56143d86846344e23a3594ef3.1638041335.git.softworkz@hotmail.com> <2931036119e295dd393764444287c4dd80d423f8.1638041335.git.softworkz@hotmail.com> <8aacfe4a7c5e4726ed39d46acaaef90bf5814218.1638041335.git.softworkz@hotmail.com> <8d80df6d4b54df71b170bbe8c354affd37137f8a.1638041335.git.softworkz@hotmail.com> <5e1287cba1f2ec854a8f50e46e4a8f59946d5371.1638041335.git.softworkz@hotmail.com> <25112ef4909e299f58d3156730eaf72a161c4326.1638041335.git.softworkz@hotmail.com> <3ae909310bf54f300042ca0472bca0029203be00.1638041335.git.softworkz@hotmail.com> In-Reply-To: <3ae909310bf54f300042ca0472bca0029203be00.1638041335.git.softworkz@hotmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [YwrPYLN0QWJ3jYq0Y9q9/w4AlmQwZG/x] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: dc917609-262d-4b87-5f26-08d9b1dd6e67 x-ms-traffictypediagnostic: DM8P223MB0031: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: nw0O91XQ0xPZiAgRRiBMPgb458CwPmdKJ1IPyQPNCfvP507Ea0ASvcepgw65b+Okj+INPXql5/AXeGmfyvpBCP98Ol16/T2Oe0YWWZpOlUJFKyTZvzw/UFLd6aW0U+RuZ1Osg4BL1SfKy59uM6f7FTkHWPcdqYdBbDYs3tkuN57Bzhg/KdapXmkxV+lS4mcKmIoiTWdXjcro+bzVBBLAK/gTi/uFw2OJy8Dj74G3nrUzBYq/4QIGhzv9EOWdQxfLMc2noIfx4ysM0wGhZ2AHUiFJi3V6bG8uuQ2pmrXO1/7jo8aL2NchQmlRPV/M1G/kbkS+G9H5oIlaMOCS7FTdxCNMQogyrS9nj4m2B0Wr5EqK5cni4nCLqxk2vTCdmf63kyVcPVlVmyElKuFiWler6PRdzrLUR5jsMMqjMy4C7yh2tozWxgTxUFzKIt9pm6A3wxwo7/bCUsfGqkJgmwFRT64FJvaB8XhjBBHevY9BTjfYoX3ie39ksuiJPU6uNjRNpDRwTu0cKBtYPBaIlrH87Z4zvaBvfSCdhqb4+S3MWdXXQDIQZ8CJqNgPn41d/l1JvkXERa7+Ma+K0dqAbmrh8A== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: lW2pUolFPBrvZu1nBhCIx2Bk6V/zx9UwTJcL4VRnej8AbiU8njeZqeRxtuJme58FxWVUcqoLyRjkzRzWGcWoMxIrSMbFKpbjjw+oYV2k4gcIQABBACJBtdwnLNRytxZ2lW7SEziYAq9pu6BYh5Pyt8dYmp16nHxCdJ1qpA6hTCVjDRwspIJ/TC84Zk2w0bUtUteDZ35XwCApzELRXOv7v+MhQTIhmi/U9qtWs1Fc8udt32/W5NGWLJxTuFADL98oxndrN/F0vza8sYR6YNzXLvzlmOxcYLkBtoxp52LO4Z0zlzwptLJnJenWybttd8Wo9hmGy/jzit5DDhh697F1Ruf88sZsPy55DaO4lcAFkbs5a5FjDR5ptzYR/5QaJBqissRyZf6csEsaSPQ4ILcSGT+13p1g3icUt/mE3Mtj2FeSqiXLCPTC1xBuof4wum10uCZYpCO63L724IprWUmQf+lA7XOdVs8HLJRJmnaC2BUr0/0QwAXTsoj4+hlVN2UVwpwD34JTqsTu1WAT7K4Cfe5gI1qG0IwQY3seZGLC0JfzLe3BbdLWzt7n1jhGDNyYF6Tnq3HpeFJHKOmDY0DcqJx0pVAXvFzkxHSPicS3BoItolkVW6p8rl45gOWOiEsR4kRMrsgOVY7Ph+9HjlaE8xOTEuqew5dZERqD0UxJ9q2RRczbIbGDp5IypbzyWuWnxnZiapzODZWJlv+M6WlzKg== MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-3912-16-msonline-outlook-1fc6d.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: dc917609-262d-4b87-5f26-08d9b1dd6e67 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2021 19:38:04.7374 (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: DM8P223MB0031 Subject: [FFmpeg-devel] [PATCH v17 13/19] 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: /grtpEYL0cxG This fix targets (rare) 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 75d5e86539..aa9aa71f53 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -463,7 +463,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; @@ -472,8 +472,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)); @@ -1172,6 +1172,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) { @@ -1181,7 +1189,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; } @@ -1218,7 +1226,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;