From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 27621411E7 for ; Tue, 4 Jan 2022 09:09:57 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9752368B27D; Tue, 4 Jan 2022 11:09:28 +0200 (EET) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130082.outbound.protection.outlook.com [40.107.13.82]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8919768B11F for ; Tue, 4 Jan 2022 11:09:22 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TuoIg04vI/6+6Y+NYfB/5iMTUOMudp7xgciAa8IpOfRgZrsWNrPqv1ki+SNNAS9p14UayAQPgWItlxl5kx3YBc6wxJC4V02UfUYc95TIBQlZNf33e87VeRi3R6Sa1X36P7Eq13bzIC6d5boMwbTfptEhXtSJk+6DJ/6umMhm69Xiw4dtLhJXiN5Wc4YamLLUM7b2NQdzd6UCLcQvu7CxuT4a7LdoU5i8KyzB1gRVAeOY87NNrqm3eZLh4hTYVbRaj68/mQUso45uROf86oMFRuSQH/yggOr/PPtIHuYjl7DLZZl43hsfwbBAnoXM2VdwQMfclhFh5FyMC7IwA4Xaeg== 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=p+9tSbaHYi7e8yCcNkjj4LKeCORANjgo5zRFTu4LSAQ=; b=X+tnf5GLvFwXAPP7F1ckckQxmDTuzfdzSB2n7zg0U1HrZmZqFeqf+7Wc6DHunsNXVhfd3ERvTLQlX8nb56EmVbLYUaaI3lYE9/Xh+C3l5jx46NlMb3MZMvV6MEMfdhHkqBYEYEv4rCNpagTSdkDwuJhS3v2fhdTv1HQ6hZLCQGPDR8LS0jSuM7DVMDolGJsPbgmem40EDRHEUhC60/ZVNwfeBCh9u66NmvVmowkn1MFfLuvW2JS6L2j5UOrHUVPBl1peb3WcfktVDwNvN4m1T/2yNr77bxKfBsSOzq/VpnPNsazGrXKBVPhjFTbpBCOw2Zc5kdz92v93vvpKeHrN+A== 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=p+9tSbaHYi7e8yCcNkjj4LKeCORANjgo5zRFTu4LSAQ=; b=sDgZgChmUF8otsxlpPQ75w+3TuiyJ57o6emrzYUx6G2XgxOv7/P8axtsyVOrmjmIdKhl7vwhPq2gI26rZIhNbaf7RB4my7tcZYvpaOt9WD4mYcJM+As87MBhglaos1Q/vqwy2TyeQCMfswOnRWdTUUgqZYUWYBGiRlxsE/GTgoA= 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 AM6PR04MB5928.eurprd04.prod.outlook.com (2603:10a6:20b:a3::20) 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:17 +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:17 +0000 From: Ming Qian To: ffmpeg-devel@ffmpeg.org Date: Tue, 4 Jan 2022 17:08:36 +0800 Message-Id: <20220104090836.31660-7-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: 0075dccf-3d2e-4494-1dbe-08d9cf61e275 X-MS-TrafficTypeDiagnostic: AM6PR04MB5928:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Zb2I5HyOQepPk0WONnEWOKQLwwqeGItXIy5pjUHQzEHONhVyk2BWOXsNcW4fCMtXMbAoMaAnYKmtBKvkaFwJY5TuilIwcPQPyCeQxAqpFdxHcwLNxRDzQgockJzV3iwze7B8Z+uLuUqGbrDAABFKnS3gKRY7JPtnV1hHiiTVFhtd7VnxihIcA0cWioR3PCsVvIIz2/vEmA0grq5m0rI7OimP/ILo/N1kOxRX9j9b+GEgtAX+b09BGj/lvc8d5jmToD1wEYzGDpz0vF1nZdtW6VQHsmQUO5mL4Bnj2H1jILlqqssKCS2cQyw5vyntSezQaGnbx3yu52wTiczwZdVrQ+5zC2DEiZJR03dw8at9zN2mItBCYE1TRa0r/XG/gqcxq0inG4yP6G+yI9eDVHT5p45bwIhs+upj3TUJcXtPL83pbsldxW9B/qbd1fkPUzu399AROZwiP+O7VJ32wzmAxonJ/z8H5jTRZYPsz4Xmxyu1xFXunDR7Gn+ObsAWMXG96aOt920YGdUSbsVzRcPwWQAv0wNfb9o+8eVI0fUOcgKE5eqRqrnHaQ06/mxrdeY5Ps1B+5WV+PKnpIS9eNFACrO+a83vaCw79JqZjXa8Ke36y0mUnre/JB5JawlouzyQb9NfM8n6DcTiGT+zOGDCeZslHCaLaAANrY2ekL9wCWAEZbtOF8DOvLduRjjyzVby/4W8jB5bHWLTEAdO6djcjcCelBSlfRGi60ObK/9ZUXw= 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)(6506007)(36756003)(6916009)(6512007)(2906002)(38100700002)(6666004)(2616005)(6486002)(8936002)(316002)(66476007)(26005)(5660300002)(1076003)(66556008)(66946007)(83380400001)(508600001)(44832011)(8676002)(52116002)(186003)(86362001)(70780200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Xp5uHHFMzEkQTdWijCY/rW2Ou2NjrI/f4LvOw1TZUUzzHqoWefCrC5O7O1je?= =?us-ascii?Q?H5Cgcx7A/2rDsL72FZFbTbCMNGMZZBOpHuSzT8+heotk8i/+znFxY2MQbwso?= =?us-ascii?Q?1KD3HD+36zvqmkyGBTAB7JXlrWzgMXh10/tr0iFNz4ECiF34y0yNTs8ShhtZ?= =?us-ascii?Q?2RBuCQvz3s4gymHfmq07EGH/zHR9xRtydhzcby0dLgmcNNGUYEeXZy0rHv3c?= =?us-ascii?Q?zw+D/I5UdnbuYiCSucluNXoYUpVAea2HqRJB7NUuQs05R5jHuAsZNRJBGOth?= =?us-ascii?Q?khtAWZCdHtD5yEZFyn33ipcPqCTjLb/Z8HdVxjnTWOq0JLwZEGmua9NoouQg?= =?us-ascii?Q?iqHLGeMLDB4lDh7zO8FO91Jl8r27s9jz06kRppSQJmA5fprsR7njWzvhbCH1?= =?us-ascii?Q?sQkxUJIgVaTOX9lFYwp5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?= =?us-ascii?Q?rJfHYeZ2Ge7Snwbj1gizVlmzmy5h1oHDFQ6D66nMCR9RS5yAaWCMEvGiHVx6?= =?us-ascii?Q?7JZsSabNCl5I2xPmtVQIrA/2V3q1X1SwnhYOAXR4ebyVPw5yUX+k360RBSxq?= =?us-ascii?Q?hTlf6Cn15zz+3iX7lwkXYME5hGwhS81Od1O0Z4i128+3KDMRIinuo6lKgav9?= =?us-ascii?Q?qkWOw+VcOgOwWrWl8jqQCeDOng+a+Pf0AkXlkozzOYPYW6ywIYVR9a3v1Cmn?= =?us-ascii?Q?1aa6lOfmVkJigEDocHNwaeIaatcXaa1FmahitfUXs20hdEfvfEUGyX+ZCoRr?= =?us-ascii?Q?6bs3Xdz/a7a2yanDFHuEuxs=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0075dccf-3d2e-4494-1dbe-08d9cf61e275 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:16.9926 (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: mYl9KvWN6wMaMpcsrjnDLicRM5H0Xsy/VVbOpoj0tyfZ6QQJpD1yKXmYURVnXZNAxeV0EuUsBGC7YhvrtMvwFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB5928 Subject: [FFmpeg-devel] [PATCH v5 7/7] avcodec/v4l2_m2m_dec: setup capture queue before enqueue the first frame 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: there are two proper ways to setup capture queue. 1. client wait the source change event, then setup the capture queue and streamon 2. client setup the capture queue in advance, but to avoid time issues, client should start the capture queue before it enqueue the sequence header to decoder driver through output queue. and the sequence header is always in the first frame, so client should start capture before enqueue the first frame. ffmpeg use the method 2 to setup capture queue, but currently ffmpeg enqueue the first frame before starting the capture queue. so in driver side, there are time issues. when driver has parsed the resolution from sequence header, but the client may not finished setup the capture. so driver can't decide whether to notify a source change event to client. and the following flow may be chaotic. And it's OK that client setup capture queue first, then enqueue the first frame. Signed-off-by: Ming Qian --- libavcodec/v4l2_m2m_dec.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c index b0c3d30ac8ae..e67758531ace 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c @@ -153,6 +153,14 @@ static int v4l2_receive_frame(AVCodecContext *avctx, AVFrame *frame) if (s->draining) goto dequeue; + ret = v4l2_try_start(avctx); + if (ret) { + /* can't recover */ + if (ret != AVERROR(ENOMEM)) + ret = 0; + goto fail; + } + ret = ff_v4l2_context_enqueue_packet(output, &s->buf_pkt); if (ret < 0 && ret != AVERROR(EAGAIN)) goto fail; @@ -161,16 +169,6 @@ static int v4l2_receive_frame(AVCodecContext *avctx, AVFrame *frame) if (ret != AVERROR(EAGAIN)) av_packet_unref(&s->buf_pkt); - if (!s->draining) { - ret = v4l2_try_start(avctx); - if (ret) { - /* cant recover */ - if (ret != AVERROR(ENOMEM)) - ret = 0; - goto fail; - } - } - dequeue: return ff_v4l2_context_dequeue_frame(capture, frame, -1); fail: -- 2.33.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".