From patchwork Fri Jul 16 09:47:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 28934 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5d:965a:0:0:0:0:0 with SMTP id d26csp1601962ios; Fri, 16 Jul 2021 02:47:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmahcsiPjPrXoIKZCJGxUoqRPv3Z0fFUftF4c9wcjzbvLb4kcsahb1ZZ2gxzFQm2JgRHdj X-Received: by 2002:a05:6402:190c:: with SMTP id e12mr13239402edz.176.1626428865852; Fri, 16 Jul 2021 02:47:45 -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 n2si9918724eju.548.2021.07.16.02.47.44; Fri, 16 Jul 2021 02:47:45 -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=rdiPEPAe; 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 3EC1768A1E4; Fri, 16 Jul 2021 12:47:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2086.outbound.protection.outlook.com [40.107.20.86]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7F2F768A62B for ; Fri, 16 Jul 2021 12:47:34 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l//ZzkOKGW++uyDRyq6NMhO4rJw7soFq62jc3kVLWPZrUbc1TS8gix2K5VLtH+m4a/vVubJ1NldQxAkm+xiU7hfFWuuMMQ5Mn8M9YiMVJxgB0Dg873dPaytsRJdEal/5oF7LRDDJ0uweWLJGQ+GRPGYamif+iAm6EZzk0om55lp8lO8g3FApEH+WmzaLQi74rkGy+Lc9lGMTVZvPVohKT99aB/gR8i1WtXwhN0eGYIh4l09W4Uthk/Ann9nRnC1fiOBjrJAxSirFCysD8cug/y9hmZsXbRfyEeWDStkcOMbcowYUIBEzgLSnynzE/o4NxlMbAumS21Zt/yMc+ufd/g== 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=+uFDMLMQA3ZNF4SbU2xK+FMj1DOBDd6Jg58Room9W8s=; b=lmZMApVKnmIC9QL93MtV068hyWHkBjCqzLdY1tZSWGfkpC+a9dBIhJ2pAl5WdvnYrtz76J/XJ/W9rEiHmTZhZXtCE84yIBnr8CsrEFOl3fT61Beklq83MzOLgfaHJBDEw5hMXHETM/9SGOBn2Mi+fJOmHr+l1D2MjnVnPjjHBu9Or9cIhQLHYGAOsG0yjDwYRLJajuPOJFWkuOp5nQDNdaaV3s0Sl5/p1HEMC7FBy8rQKhFHQgBkaON+auGZApLffeZtMpqCEI7cCmxBBt30A1K/ytSg/lyBpYQ+SKtawj8dPi/SKQKanlHvh2HY/vbsaRgtqVZXjlsmoo+833A1Aw== 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=+uFDMLMQA3ZNF4SbU2xK+FMj1DOBDd6Jg58Room9W8s=; b=rdiPEPAe/42upNAEMoULi8jR6SIIOwxu399ycncEmy+uu4p7WPDnT5jhFmFQeXBL69xJhflC+nKOLGvWIYriUiqbPSa4VA04QZul+1My0/5/MGnUFW++9daeKYyApZatFa/hbi5jn4e6qUivugosOTGa2YBFLs4P+aWwPLCsb2c= 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 AM6PR04MB6581.eurprd04.prod.outlook.com (2603:10a6:20b:fc::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.23; Fri, 16 Jul 2021 09:47:30 +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.4308.027; Fri, 16 Jul 2021 09:47:30 +0000 From: Ming Qian To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jul 2021 17:47:14 +0800 Message-Id: <20210716094714.28755-1-ming.qian@nxp.com> X-Mailer: git-send-email 2.32.0 X-ClientProxiedBy: SG2PR01CA0133.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::13) 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 SG2PR01CA0133.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Fri, 16 Jul 2021 09:47:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ac80c4dc-967a-442b-c0a4-08d9483eba64 X-MS-TrafficTypeDiagnostic: AM6PR04MB6581: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1850; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q9pGPDA7t9s0i1d3P0h2wrajr81Yfzt3QvgYstv5qQsw7hCn/zebP2rLwIOmjl3wCC/r0Rc2nYdq9OJQAnbsi8Nr4XAOKm2OUrMb2+boi7yQh+6VeVCBSQn7BgrfILZS4vpoXQFybku7d/EEqcOueSBUoxBKr6TWPOmnpJURE+YwcEjmAr9DDBSrEYxMo68wyYg0FG3hAOyQhOBcKGVVV+2orTLyEjAqrv+iirw9yIjV+hFoscYxFtOzfH1gtKxpEr0tNWzvrSkvvMlJp35UYuy7ElFP9UhWUjqWmSoirUxATHw2jxVzXTWK8GF9x0SqZWuvQZKNJzBGRtU8i2HPYsrdWaHTFhxAGYLpy1OguG6Ck3ekjiSW4Qv9bKhWQ8wom6g3Y7yQ4tXVNdicwG5xT5xyF4L5Vovy9ynPpnAZjCvxGAVyhtTSuToRJMXJbMQ5qp6ZY7jiWSkxpvLNtzrIqwzavypaTDl+DERZ9CHWcPJKHzGYrE1Xh4KzcN3HALJoGmCMgp9hBgNGWRhp+3migH3DI+LOmBNMtmRpncB/mjOYlEOm6Gyh5IfRlXWWRGqi3fmxespglmXCUUE/z4qTtn5x2f8Zkg5cxmqWvupVqhhRco9ti5biUe7jdZcMLwWQuw6IS6dYagwUoBxgdMd7npvN3prXSXCXHRv2IO4WB9VEY8ZfjXFhvS+d+0zi0CTIL+jqgZl0pVJwT0XiE2pgeQ== 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)(38350700002)(316002)(1076003)(44832011)(7696005)(8936002)(52116002)(8676002)(5660300002)(83380400001)(36756003)(66946007)(2906002)(4326008)(2616005)(26005)(6916009)(38100700002)(186003)(66556008)(66476007)(6486002)(956004)(86362001)(478600001)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 17FxrGCGn0zlEv9KnDTkY7aiWW2PZLdl0o0+6FAEzfBNxLVt0I5QpGPx4GGQGS7mOsSI1vR3mchOoz7LsKHkUtp18PtSY1M+bgy+bmHs39UTnaqn3HofCdyKR5NdCaedcexifwZPDZtLNEewjwWlAmktLt9UTgpsIYPq1Knz5obDLCxikv2+b/sCd48CjQ/I7izvRYdfL630fz6UG2JnCr1UnKrucpCKbX0u7nj01NRYUAVV6eFoHxYrq9W+8jT4Py5OvOlWrr4IbeiCiyU9S8HrVK/YLCN+R1BBLg+YRED9Vj5YUeR9yoF9Wn0S0MIuAXGvPG3/9oIODTplO+W4li+6yzWpnK92N7rt3b5WANevoVgZvz0+GV5WCun3bqZUxtnschILWl+iQg6gaZI1vXrz6y/J1IpZ0Q4W4R1BFZEjpdF1evgEJgasmb7Qk4hBKkWvbDqqM33W9nWX1W1lT3HrmDlJU+RQqWcac2JlxBZ00NoamftIhZ83LW9ieqY9qnb8xg/S+YKuv1oTZsq8F8qwIy0zPTdq+ZD4ZzIuaQfkbwt0/Bpy+XMx/yzyKkPKQVhZghlLj6hLswLJ72kuRoskwZF7kl/DFodp0TmDrFCSFu/gTFyj8R7Sd8qHXBCYSZxz91iGDoyxhqoSrR6D1KfVQR957JgBWWTnEoIR269SepnJQ3zYY3G0EdLYuF/dP5m74u2SGZ10SkPqx017Rh3sBrdNrgBPtJUxUX7cQQB/8rmI49yO0yTHNHcJ9uPFym/caXKIvBd8O3xbY6NIA2RDLZOBWrT1LmTCGjlKDgnF+c9X3SVlWGh1RD2mBsy3+/PqHIilNjZHJ9ED4yV/0MFqaP5bojd9tGbITnp2JvsR/bO8qKeQjLa5B9foGiPAAc68078/r0N9P/m/0BYM+7MB7CbENiLUecq+Kzozjv+NG6xR5+J1kihgGpc1je3ojYpA8VXJBARKU+vizlwVu5oQo7z30odNyR4qV8T8/phwx7gqHpzuGhMZyV/2x5zNQZWY9Zw2+1E7N9z9XfYLcbl2P+hOxKGX/xwkTG4tc6G5ENOaBKYff9FShm8LBzJW/KmKNy+ibhqznIx9/MrrODQPhnQWxoN+dZ3Y+bPB4d4hFinX5tjBltlPoleVglAg7ijXHGqGFtp+wZnLzd1/gdgSKmd1yjeUK9yKHEsWlC9qMhwf0RKdTD8wfW5sSve8UpSENL4n8XRwoBmwpK48L+5Pwwi6/POZpWGVzw/AuyD8obPUzDSfWdgGkFqpeJpLUI2hFWH0FuLM7zAK15VPewUmxzVl63YgBAosQsYv0NSIxzqBEiEu7PmHh9A38CZB X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac80c4dc-967a-442b-c0a4-08d9483eba64 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 09:47:30.4391 (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: 0e3qQ2sX41IHJilSyXTPR85KvqKx1trTrf8OeJC2wYmN0eUf61jQye6hGazbBA2vg6Wg1idl0OJHkOYGnWR7MA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB6581 Subject: [FFmpeg-devel] [PATCH v1] avcodec/v4l2_context: don't reinit output queue when dynamic resolution change 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 Cc: ming.qian@nxp.com Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: usVYeltkMuQ0 in the v4l2 stateful video document, we can see the following description: During the resolution change sequence, the OUTPUT queue must remain streaming. Calling VIDIOC_STREAMOFF() on the OUTPUT queue would abort the sequence and initiate a seek. In principle, the OUTPUT queue operates separately from the CAPTURE queue and this remains true for the duration of the entire resolution change sequence as well. so don't reinit the output queue when handling the resolution change event Signed-off-by: Ming Qian --- libavcodec/v4l2_context.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c index ff1ea8e57b08..dda5157698c3 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -162,9 +162,8 @@ static int v4l2_handle_event(V4L2Context *ctx) { V4L2m2mContext *s = ctx_to_m2mctx(ctx); struct v4l2_format cap_fmt = s->capture.format; - struct v4l2_format out_fmt = s->output.format; struct v4l2_event evt = { 0 }; - int full_reinit, reinit, ret; + int reinit, ret; ret = ioctl(s->fd, VIDIOC_DQEVENT, &evt); if (ret < 0) { @@ -180,25 +179,12 @@ static int v4l2_handle_event(V4L2Context *ctx) if (evt.type != V4L2_EVENT_SOURCE_CHANGE) return 0; - ret = ioctl(s->fd, VIDIOC_G_FMT, &out_fmt); - if (ret) { - av_log(logger(ctx), AV_LOG_ERROR, "%s VIDIOC_G_FMT\n", s->output.name); - return 0; - } - ret = ioctl(s->fd, VIDIOC_G_FMT, &cap_fmt); if (ret) { av_log(logger(ctx), AV_LOG_ERROR, "%s VIDIOC_G_FMT\n", s->capture.name); return 0; } - full_reinit = v4l2_resolution_changed(&s->output, &out_fmt); - if (full_reinit) { - s->output.height = v4l2_get_height(&out_fmt); - s->output.width = v4l2_get_width(&out_fmt); - s->output.sample_aspect_ratio = v4l2_get_sar(&s->output); - } - reinit = v4l2_resolution_changed(&s->capture, &cap_fmt); if (reinit) { s->capture.height = v4l2_get_height(&cap_fmt); @@ -206,18 +192,9 @@ static int v4l2_handle_event(V4L2Context *ctx) s->capture.sample_aspect_ratio = v4l2_get_sar(&s->capture); } - if (full_reinit || reinit) + if (reinit) s->reinit = 1; - if (full_reinit) { - ret = ff_v4l2_m2m_codec_full_reinit(s); - if (ret) { - av_log(logger(ctx), AV_LOG_ERROR, "v4l2_m2m_codec_full_reinit\n"); - return AVERROR(EINVAL); - } - goto reinit_run; - } - if (reinit) { if (s->avctx) ret = ff_set_dimensions(s->avctx, s->capture.width, s->capture.height);