From patchwork Tue Jan 4 09:08:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 33054 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp16812187iog; Tue, 4 Jan 2022 01:10:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjtQ8pMN8ANKv8B3OhhYQ4Eiopwut/fSdlpBkBjZdgr8NUrDIRhgTXgoamCId5oRlWMxWg X-Received: by 2002:a17:906:3a59:: with SMTP id a25mr38823989ejf.762.1641287421314; Tue, 04 Jan 2022 01:10:21 -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 hr40si19784128ejc.598.2022.01.04.01.10.21; Tue, 04 Jan 2022 01:10:21 -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=@nxp.com header.s=selector2 header.b=M0ffWZfG; 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=nxp.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D4D2A68B270; Tue, 4 Jan 2022 11:09:30 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2043.outbound.protection.outlook.com [40.107.21.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 50F8168B270 for ; Tue, 4 Jan 2022 11:09:28 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AsEbccddLYtOoQdzkLqskdcK+wNvWXDvT6YtP+5oYOP+cTxDPTN2i49PYMOxD5PhQDzbOC1AyfbWWd10bM25mIqQqXClpdIujc2TbfH5OPJFVwll36r8wS7SLuDhBJtUlKHPTpXwHIjsQjd7Y+x47dmZ4I4wwfm65P3nCf2ks1n1cw/ZMGnJURikd6jUdm4NMCtObRkUO5jE4w0viliLFR0IqtYrD7cRVTDJ52IdXB3a2WlwhRkjsngQzvkQ/AsYXcu2jc9P+MngQ3pHyzXE8Gv1+z03j00eJvnFez/zakqPRqxeQeeQWcCrVP3IZ57cyDT6LFW2Lkgzu31pAhX0aQ== 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=f+9O7xKonSY9OK77kWt6TXzM3MYiBm6U3tK6JBE2MYE=; b=HWAAZTvyuvznm9/RNWLo+TQMH3HKLI4AlMa9p+75IJr/Gxnx32r6Tiz9LSAetM/sBjY9072D5AHQZORO+DDPxkn1vpfRVykY7EmQmT7tQwN61PlpuKeM0oNjrs7sK8ZA5UirIo8tjJX8lR4mUWdlxKn+EPFEAJE3EDqkMDuZ9Y0gcm1B/YeFYbFmHZtkZdUvz4qIs7waKn84wCrhvY8Qk3zA/FibY1CTVBMlTNaCraj2Tzzu1ufsl5YiaXBcz1qr4Bw8r7kJxKRN/5nnSbyQJWu/M2FzviWqPsMpJhjL1eqFrzk99Fp3XER3G79ZZbFlvLvyW5Q0s0OhdKy1E8cbKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f+9O7xKonSY9OK77kWt6TXzM3MYiBm6U3tK6JBE2MYE=; b=M0ffWZfGw/Ol9EtlGo3CfLv8/7tnHrHh3r0y/gJVWy021hljvcpCnUUQ+VhzpkOOEsFFvTH4ByMbf+/MLmuZbQPk3o3AvWGQcXWqXNx85PhoatKxc84VdpOIdpXdL40FDkQPxVnh+tHFUWWnz7geGhnK96CKAIhbtEKm73+BPiQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) by AM5PR0401MB2435.eurprd04.prod.outlook.com (2603:10a6:203:36::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.14; Tue, 4 Jan 2022 09:09:14 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::b9f1:7371:3484:95b2]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::b9f1:7371:3484:95b2%4]) with mapi id 15.20.4844.016; Tue, 4 Jan 2022 09:09:14 +0000 From: Ming Qian To: ffmpeg-devel@ffmpeg.org Date: Tue, 4 Jan 2022 17:08:34 +0800 Message-Id: <20220104090836.31660-5-ming.qian@nxp.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220104090836.31660-1-ming.qian@nxp.com> References: <20220104090836.31660-1-ming.qian@nxp.com> X-ClientProxiedBy: SI2PR01CA0001.apcprd01.prod.exchangelabs.com (2603:1096:4:191::13) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fb3ae4d3-f1ef-4336-985f-08d9cf61e0e4 X-MS-TrafficTypeDiagnostic: AM5PR0401MB2435:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1186; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FeeXp9Kg/MGEe1+CBFiCZHhe49LHc0YTI7u71KSGRNJJP8Sb0/Ci7Fs5HzBQz6ToDbmbONVP5a/l3iX0AQCERehKL9McOsoAu0qGt2yBoMOB0IUoz9/C+JTYReASipjUFIT7Uq14DrHQpLvevY5NBZ7cRBbUi3gs+GkNPqLU6NwdsOYXPc/uCVru33zdChe2V2WJGFOetl7jMTFyVNAEp5UwUP/g9ulPCX1TTaEOwmH0ZnvA9dhD3P7gTZOGSjJzKG9GsxQ1gtdeD2s8bSRzn7vPfZg1NOTSc/ie63G/WApaemFBMdtVsP8HWAqeEIckut2T+iQRSPxYT9U5FKHAvsb+2TX43IfERddSvu108x5m02j7aUwFEsRuE0Alb8j0pDlBXOuCFQKItIGlLbWS/l47ik0ZgtoITKj23u9SACF3R0UDnlgbwKW0J1pJJp/Qk1VgeeqQL7c1N/pcg69aRTpjOcCDNDPCHdSR/L2MgDtB3Ck6DwS7s7MsG/v6fiVWSS2KcfONQFIAIzU3k4cPwtaf9CEG8wCi+N2Ep1m0oGawDmQvXyV6oqWQDeq/c9CiTPJ4bNrOYIkcOPgp+yCfX1UzwfX6FaXWnbs+4NYRBWbspy0TuDbj7w2tpyie9DFebyNyG3HxWFkDZI5bKKZw4lcgqHsmwdzjnGnraxb6SQNTQQxrxljGMxEYcVHkOUy6DrtXKd8IRRrfffFzy2ICZg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6341.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(26005)(36756003)(5660300002)(6506007)(83380400001)(38350700002)(38100700002)(52116002)(186003)(6916009)(316002)(66556008)(508600001)(66476007)(66946007)(86362001)(1076003)(6666004)(8936002)(8676002)(6486002)(44832011)(6512007)(2906002)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BnosUPVGJNiIkBLjB1QibqFjFwez7+PD/S9+jzmnB13mvO2nByTkmQpgcEZRAA4EgOhmsf3OnSPFvowmLlethg9rnHvqsHIEPfwLRrFAJzyyCMvRSQKbI1MtgHj2vDInbpj9i/lz8aAf42/65BCyvo7+CYSvXRVr9Jn7DoGbihTg+bF9NOGlg9QEiPddgYKZAIzjRbKk0eOAZUjmaRWAQgggZRyweyYCRLQ2eaLCiGNGGIEsvPLL+tV1albQglnXPsT6lEjt1Jm1snm84ytivOHZaYAhEtSEH0JJUJlFn41WaySXnS2FdCQ+KygChPYtMFxOKGYKsmqUAJheDqyuZMJia6rOwj6tKGlvVDPGandGxrO40GlsEdfMLVUk+xftyrcQCpxvwUzzav+XB8bN8zamdllW/ieGB3sY71OJJBVumVxGYDvVA5sk7rFst0EadBSofKJ9v5Mhr39/9R5nPXnjm+667y8v55NxRFB4k9aAcaZedz//Y553LzxGPlP46vFcevw4Gk9mTdBUpa/oSlSSA6ox35zKmmHyzSfQgYe/HiTozjs08DC50WBM0xyNN29DCKmzydzN96Fod2HVke9S7OPPQN19aDYk8TG9sVa1IlcRVssBGaERUaaZ17s6poPwbyBxBbmNNswrXpYs1BIjrZwySA10cCALSMChuHF/GBoBJLx/VsxPaBXxVl4PmMcMMoTEkQbwP36VRsEAUK57iKzMhLGMiKqe9yNa1/aYmg5SIQWVV8luqA22vztxGSnvz3wndoEU1I5R0vTvd/sdrejgoytxRku6HXhJ1nAyOdNmxx90Ms+KQbOc5v7c6jCP2J0JBtO0DNqWzPA4S05cjER0MovOsXEu5d9vnWJa2ZQYwonpxn/wcelWhCS7q0Ad6U/vPifs/UYAHQOC9yjBdYXM8HIhO/VKmUVoSDMT42qHd6hzs1lOGvH24zkWtKMdksUC+RF5QzsBQBVk1OupduAnuaSfhz6sVQ0jjBzKRjLwE3xHkfMg3JXT1YEP7Pj2helRTBzYCKbV6KahF5jpBRqZhDpKYdNg5HgqnyLvxMuO2KftC0mbp51Aclppy2CrH6JIGCXT01yvBqXwjoKThwJ/cNtcCGNVxEDvR1oILh4kkoDDS5gSUh3t1KBty2drs+sYcnrpwlLXH5dtTbiT768jkCL83SXsYYQEBaQ0F2w54wP1fl3Q3h1d542drHPyxqF5+5jJ2VIrUyxiSrGXtwKLpPtoXoNoFqs4/YX5rASGQRKYPpbI/DzUqqx7RW7hc8WgCVvq9zfiHE2zgIygIM14RFx+IEpTqpEvqYxmRAwZqvoHtuCohfDfdGklfxiJ9jUO7zvFUVl8+EVxLMMfwt6W1BehmLel3jvbv6ZE7fO63TR29fDHAH5FC+chgfyuMZt2nZEm69fdxctSeP5Set0OE5vyPfNHbzoQCcP/l46pwHe9tdA7CuCVnAe+rTkxfKu7Ix/y6QKWkQ4+x6SADAFQykgp8igbp9tCi4kcf061F+GUfum7ANSGI6D+Hx3tP120SDRnzRvuU76GDXP+z8rqIQTsBAdWSB4e/C2BEaABEdLow7LTnTLs4x0/LcRBEXX/AHPOBrrIBKLinCInX+PYWCkOV3Mmex/hxnY= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb3ae4d3-f1ef-4336-985f-08d9cf61e0e4 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jan 2022 09:09:14.3365 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 89U1nboetP/05tLqWxoiEyAmkcdpEkrtp0rpSkJAXUYOOLik/cDAYGJn+y7aR8wIuLrdwYv25IuHp3qsZbDXhQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0401MB2435 Subject: [FFmpeg-devel] [PATCH v5 5/7] avcodec/v4l2_context: resume the decoding process after source change event received. 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: tBzCwN1Mr6Hu client need to resume the decoding process after it dequeues the source change event. no matter what's the return value of v4l2_resolution_changed(). if the client doesn't resume the decoding process, the decoder may keep waiting in documentation of v4l2 stateful decoder, we can see the following description: The client must continue the sequence as described below to continue the decoding process. 1. Dequeue the source change event. Important A source change triggers an implicit decoder drain, similar to the explicit Drain sequence. The decoder is stopped after it completes. The decoding process must be resumed with either a pair of calls to VIDIOC_STREAMOFF() and VIDIOC_STREAMON() on the CAPTURE queue, or a call to VIDIOC_DECODER_CMD() with the V4L2_DEC_CMD_START command. 2. Continue with the Capture Setup sequence. Signed-off-by: Ming Qian --- libavcodec/v4l2_context.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c index 0a0f5b226960..b7b584dfbef6 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -180,7 +180,7 @@ static int v4l2_handle_event(V4L2Context *ctx) V4L2m2mContext *s = ctx_to_m2mctx(ctx); struct v4l2_format cap_fmt = s->capture.format; struct v4l2_event evt = { 0 }; - int reinit, ret; + int ret; ret = ioctl(s->fd, VIDIOC_DQEVENT, &evt); if (ret < 0) { @@ -202,8 +202,7 @@ static int v4l2_handle_event(V4L2Context *ctx) return 0; } - reinit = v4l2_resolution_changed(&s->capture, &cap_fmt); - if (reinit) { + if (v4l2_resolution_changed(&s->capture, &cap_fmt)) { s->capture.height = v4l2_get_height(&cap_fmt); s->capture.width = v4l2_get_width(&cap_fmt); s->capture.sample_aspect_ratio = v4l2_get_sar(&s->capture); @@ -212,28 +211,20 @@ static int v4l2_handle_event(V4L2Context *ctx) return 0; } - if (reinit) - s->reinit = 1; + s->reinit = 1; - if (reinit) { - if (s->avctx) - ret = ff_set_dimensions(s->avctx, s->capture.width, s->capture.height); - if (ret < 0) - av_log(logger(ctx), AV_LOG_WARNING, "update avcodec height and width\n"); + if (s->avctx) + ret = ff_set_dimensions(s->avctx, s->capture.width, s->capture.height); + if (ret < 0) + av_log(logger(ctx), AV_LOG_WARNING, "update avcodec height and width\n"); - ret = ff_v4l2_m2m_codec_reinit(s); - if (ret) { - av_log(logger(ctx), AV_LOG_ERROR, "v4l2_m2m_codec_reinit\n"); - return AVERROR(EINVAL); - } - goto reinit_run; + ret = ff_v4l2_m2m_codec_reinit(s); + if (ret) { + av_log(logger(ctx), AV_LOG_ERROR, "v4l2_m2m_codec_reinit\n"); + return AVERROR(EINVAL); } - /* dummy event received */ - return 0; - /* reinit executed */ -reinit_run: return 1; }