From patchwork Thu Jul 29 06:00:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 29111 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5d:965a:0:0:0:0:0 with SMTP id d26csp5517447ios; Wed, 28 Jul 2021 23:01:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSb6+oEV9SevEDg+qaLV4DbUwSS+Z9vXwMUPcVlo908Qq501pdZUD7Ay5bH4hP0GD9K8GR X-Received: by 2002:a17:906:2c45:: with SMTP id f5mr2988170ejh.464.1627538468391; Wed, 28 Jul 2021 23:01:08 -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 ku15si1881729ejc.731.2021.07.28.23.01.08; Wed, 28 Jul 2021 23:01:08 -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=@nxp.com header.s=selector2 header.b="m37re/19"; 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 6608768A28C; Thu, 29 Jul 2021 09:00:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2050.outbound.protection.outlook.com [40.107.21.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D1D4768A107 for ; Thu, 29 Jul 2021 09:00:49 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DZZg/I3cAlKAgjiNP/5UZNQTbFOu8XfMUxrla8gifRTseGhiSPu7KHIUK2GyUy0L9sg/a1BiDU52bQZPjD85nYr0aQtnT26ZKmkuXDo8I/u/Lo1rbAiAcG+97Bnv7EjZ+NB/ywexkoE+yGvTbtagpqnadN/4HhWu7uBD+YpfTL2/ZC/sRg24UYOw4SUD2xSWfx3WNN5cS0tWWPC61f7RrJxOWplMVaEGDn51+9w5yPccpYkhjXdfa9j8wIy2wpgPVa811uhj1DN1w7MjlwqX5uSHTRFsy+leIOQvRWEuE1txfexsxwqSgoh5OGOm20hxw0rGxqSfdWpl9IUOYRD2Qw== 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-SenderADCheck; bh=nB1dbceK0gwm9f+9sIqxPNzLCFkR+7NQ3cNoIfiX+js=; b=NikfBZJHmwe9iLx8L21AvyDDGRti2iCg8K7rbYHLw6l49ChRr2ooLYEt6t+TbN5WfSITl0WU8kYqQjLm/6++1QuOApeHIHGR9zkhhClfmDBmLl8EMTbe/QVqYJQNjQA7aLNKgn9ou9Oqk8TMZ9uTw0CRMJm6qwQ8UeGFOWGQwZSbGhByVDZ1oLLm6AUSaaCpqmG9PO7MNBSNZ8EHPchTHt2g7BHkBDtvIapbXiu1h2Xx2ODhsOU+oM1NkiHgmjxRfMSJiriyv8EHBdzO1FZgcq1YiYKb1Tt2nJawYBVo2XyJmUcF7NqPQuR6RqHsvho6N9guR2RKMaKFvuYp3mkpUw== 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=nB1dbceK0gwm9f+9sIqxPNzLCFkR+7NQ3cNoIfiX+js=; b=m37re/19lLeNiGqi180Dn3bXWlkSh7xRiqS+U01WU/CLZh8gDxw1H02t0YOXYqpQAkdAVj7ujrDF6IbzrUg13bq6T9Pdrw0voAVq/Rl4Mp5Uaam4V+RFFki5vVW+wt1CpPru15t1pp9WGipsB6Npb/NuiNoQ4HnFackpz8ym8r8= Authentication-Results: ffmpeg.org; dkim=none (message not signed) header.d=none;ffmpeg.org; dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) by AM7PR04MB7127.eurprd04.prod.outlook.com (2603:10a6:20b:113::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Thu, 29 Jul 2021 06:00:43 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::81e3:1e06:83ee:5db8]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::81e3:1e06:83ee:5db8%3]) with mapi id 15.20.4352.031; Thu, 29 Jul 2021 06:00:43 +0000 From: Ming Qian To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Jul 2021 14:00:26 +0800 Message-Id: <20210729060027.9513-2-ming.qian@nxp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210729060027.9513-1-ming.qian@nxp.com> References: <20210729060027.9513-1-ming.qian@nxp.com> X-ClientProxiedBy: SG2PR02CA0113.apcprd02.prod.outlook.com (2603:1096:4:92::29) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv11149.swis.cn-sha01.nxp.com (119.31.174.70) by SG2PR02CA0113.apcprd02.prod.outlook.com (2603:1096:4:92::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Thu, 29 Jul 2021 06:00:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 124c199a-7a38-4bb3-778b-08d9525633a6 X-MS-TrafficTypeDiagnostic: AM7PR04MB7127: 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: XeceTmcj+8jp3bQoB6FjXsj+2Shi0NU9PKcgBudahYYhrOcikTSAUaFPruKBcJV99IraMYr5stkHM6TV6CG27vjRZ3HAC7hiWBvXgpvZ23hEXRVVRfX5/1roTKnliUUXklbsItVB/4HXdlxi7FTiYzCgIP9MfWp28DCvC2hL4yQk1rQ0wDFFgDv2279Bf4ei0HZZls5njWEoIiYJASyCxABJev2idHmoFiI97kisJ1p0MCT8RrxA4Z5x6TwUPjwP8hsRv4VRz2//CL55Wdvglq0nCqlMUaQb/SSDQuLOIbe9hJkbSHXNSESqoWc66mEIKKfUi5hmHJSMhaaXD1uyvWkYQLZvK76Xk8ukfBWMErpT4sZI0pEeZb/Td46JQ01Fjczwa5aTy7RTBaKd8sN3Pd6tRihKAKhJ8BfYmdzvoocsJ29rAOZHXDD5FBmJHrDY1hcNqRDe7/R9d+SZwH6+sDIJ0gntZhcySYyzWbTBR0ftYHej4865I3vbRNj2pS13/2DgUWOGBa4YxuQ4Ztbz0RRQ2Csfr9y31OFV5Cs9LV5/diq72Cs8Fp8KqZbgPDYlssZg5i0SPeJxo3O+hjnGpmwlxYzh+2NUFS7qwXte3f5d1eZt3UKvv4DewcyPZYqgSl8L8Yaj9i6KqYTTEQ3mOecSVnRVIv/r1OiDhH9/T9txYQCfORi7FhU/VMZN6Fsm+ybDU3VM1K66Y6NANoo0Dg== 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)(376002)(366004)(39860400002)(396003)(136003)(346002)(66476007)(44832011)(66946007)(66556008)(6916009)(316002)(478600001)(86362001)(186003)(2906002)(8936002)(5660300002)(6666004)(6486002)(1076003)(52116002)(7696005)(8676002)(36756003)(2616005)(38100700002)(956004)(38350700002)(26005)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 28Jkbz5anUw70Ro183CAWI05ANLj3T38EDY1UAiCTsxcioI5g8xgU7vaTmKBJXm1yTInoNRL3YSO4IqOFvB4Rq0e6dv5ak0Qr9zfy5KuCCoWqSo5Lbb2Kb/VvsN+oc/03/TnHbjTJkM6KxYcr3wm49/RM8cPnWdS/IvyjsGC0TvKI3/12KpsdXbNBvSj1Tqo8q0wKCGPfRoQ89UfdJfvYSxovPraDLTth3lNcND8aSbXRbr4r7xI/0Ch5h5LPHoAtFvpYXbh+Z40sTUahhX4Yim/7Oml8qL8DXFk4Yc9xZfHx7T8f3ie+b5zwiiob1xUP1+FDr9sNamxBPjJVLG1xcfzcdSzXOG7lDXed4CxfYIGomyu7ZsGG3O5Ks2KDDhf/rjPJgAtplJv6/sYQL7sC/1LSImzt0+z/eoTqJgUHDWxEJ+VLXgqmQ40xq7hXS7ZJmF+6ywh3AyaW+6CGaODrLgUeW/5hDYibvvd/lLqsfFJ2iSlLZEEIkIQQV4EGJQ+Idu7Lva85R3v6uKC0LbebhBBJPiElPxakCXT4qhAHfZ8RtMhEitvg+Hhx8qllMWszCfXoBBY9QQKli8KP04ZPafGHpxI4/V+tRR5oDpWElxsr8V4kesTcbd2eVqeVaDZwOg+PDy8bLuh8Rs+4rD56nN1rjxh0Rpv/72Kq8FwPjlZFHjmOpCkMO/GHccEEF/QQIazh6qxmg1t03xj+znBG3J/KvAetn7vkU2HphwLccwOKC1T8Im+SjFpVvDx9WdoZbr37vW3jQhG1hJQztI68HXqLKmEpfQCJYoexIN2PEnX3etUgavnuPKtSlRECosljTTsR474jaPGkIDVNP+hmYqez6MwFSTpq8vGbrRMVXo/ktK/9NsrB8NCx0XJ58QVwO9neBw7jb+foiJSYCv1mnaFIUKUNYAB6I8Q6Eda3tWS3Vj/sdEiAlytPAV65dHKQQWBfy9cQJHvs/99ABLnQdQTMMziUBw3kxLw+GzL66xn0Ac1CboUCj+hcae0wQhT40+O96ALEISnYW+GW1S20X9deC1t6A/89ySaqp+UzNhomTcACzQBMFSJqHijRcg1YYNdShKO/bcEsQMq5cnolMl2Zq22bSw338SMcP2qu6lVCmI0bY6B11uxCBTp3wA/ATbrEGLBAkYRUJgmE12bNh+0cQ2Q/s8XmXu2aVAs1kVY7glBMB+nGODXCz9+kw4WTFR0HP/TO/qVdnFw0M8KBJDQ5t5yfYLRHocuEJ9HPi84cEzJ+2ZTs09MF+EfvJgGcHuA/OghGBDPZ97GVQ+pPsrnooXFwJIiBmBRaS6merlpEwbi7yxM7uxBafWklsZX X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 124c199a-7a38-4bb3-778b-08d9525633a6 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jul 2021 06:00:43.8467 (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: QDLrPG0P/nSkYe4W5cuUE7ZlIGL0TSGku24P3+sIOs8evIn3jmfJJLgM/OumpT1+0PRoJK+IJlgwH3R8A9ye6A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB7127 Subject: [FFmpeg-devel] [PATCH v3 2/3] 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: qr4pwTF8CGrJ 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 dda5157698c3..df41e982fc56 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -163,7 +163,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) { @@ -185,35 +185,26 @@ 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); } - 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; }