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 39D67409FF for ; Sat, 25 Dec 2021 07:28:43 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8E44B68B0DC; Sat, 25 Dec 2021 09:28:41 +0200 (EET) Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9155468B0BE for ; Sat, 25 Dec 2021 09:28:35 +0200 (EET) Received: by mail-qk1-f172.google.com with SMTP id l11so9925435qke.11 for ; Fri, 24 Dec 2021 23:28:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=6JnamAFKl6pGkaobGcFayhPMV2dvW1YzGJLn6UmCE4g=; b=YlLLqolmgpVqn36klFVefSHTaFS3Jhqf+syJD1qb8OYukF8V/XiKsQH5C/SdvKman4 WDqrm0IhxWhmNaBROfqGQ8uxoUew28b2L2XlCWfkCfTnnAdxCHn+W0qigunazxorGxko odDYbjEI5eMuLyAvl8fiyTtu0CUXiWwWV4OymVFKVwuudPJXWe6VN8Ehr69ZGDIZ4Oau ERi2z12mj6YaM8VyYnTfvJ2qKwpp9iPMV8EX1rViYMZmP3eUk/jYJIPWMJFSzgd0tshp yCtxzLBjV/ZVbXeLy/tQRLGo/krqgGq5raCs9Bv7tSadnaY0LUb0kSl7RWH+a36bYffT D4gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=6JnamAFKl6pGkaobGcFayhPMV2dvW1YzGJLn6UmCE4g=; b=27uMZF9DDRGnhcLV2+6n8e63B2s3aE3t1S9Z6g36Unvn7Psm/F2de6n9NLCMWs0jf2 mJvVjSKB0byeotmdlpyjv/UZgydqwg7oaQWvYMoD46w9eav5VbTuHBMdupJmS5BWMWoi JVqjIZ8S4GGq7oQHS/s+ug76x61BjyT12gM6zLY4mrJfDOyCj0pNq5Dp/VtysORcQ6uz BThFRNBIAzeW/OiJpJnct7/287weEcqpBlOmhxA4bgYJumOFOC8OSFIDzXjreW3FK0Wc 1LjVMswdMmS23CKSzuO9LgxW9U1jkhg2kmzc0wL9W6KVeY1P7XfC4W+e7nXH7iNuQfSR nrEg== X-Gm-Message-State: AOAM533IKkl8kzDRZZ0J8FXGpp9+burtu1G2K8CLblNN7QB1GBDKqqO0 Eq3EGjTvQ+7UqKcdkyVBMgLfe8sxKuc= X-Google-Smtp-Source: ABdhPJxw8tcpI0/PejzF8Qz25UMNH+SYm0aGqRgyAmzrIRA4AaD4mRfZPdaH3oxgPs++MWZq8ZNsBA== X-Received: by 2002:ae9:f801:: with SMTP id x1mr5989152qkh.183.1640417313249; Fri, 24 Dec 2021 23:28:33 -0800 (PST) Received: from jackie (pool-173-48-211-61.bstnma.fios.verizon.net. [173.48.211.61]) by smtp.gmail.com with ESMTPSA id 8sm8643693qtz.28.2021.12.24.23.28.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Dec 2021 23:28:32 -0800 (PST) Date: Sat, 25 Dec 2021 02:28:31 -0500 From: Andriy Gelman To: FFmpeg development discussions and patches Message-ID: <20211225072831.ox5rzxrzck6s6hp4@jackie> References: <20211214021215.456493-1-aicommander@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211214021215.456493-1-aicommander@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/v4l2_m2m_dec: dequeue frame if input isn't ready 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: On Tue, 14. Dec 02:12, Cameron Gutman wrote: > The V4L2M2M API operates asynchronously, so multiple packets can > be enqueued before getting a batch of frames back. Since it was > only possible to receive a frame by submitting another packet, > there wasn't a way to drain those excess output frames from when > avcodec_receive_frame() returned AVERROR(EAGAIN). > > In my testing, this change reduced decode latency of a real-time > 60 FPS H.264 stream by approximately 10x (200ms -> 20ms) on a > Raspberry Pi 4. > > Signed-off-by: Cameron Gutman > --- > libavcodec/v4l2_m2m_dec.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c > index 224eb3d5e7..b0c3d30ac8 100644 > --- a/libavcodec/v4l2_m2m_dec.c > +++ b/libavcodec/v4l2_m2m_dec.c > @@ -142,8 +142,12 @@ static int v4l2_receive_frame(AVCodecContext *avctx, AVFrame *frame) > > if (!s->buf_pkt.size) { > ret = ff_decode_get_packet(avctx, &s->buf_pkt); > - if (ret < 0 && ret != AVERROR_EOF) > - return ret; > + if (ret < 0) { > + if (ret == AVERROR(EAGAIN)) > + return ff_v4l2_context_dequeue_frame(capture, frame, 0); > + else if (ret != AVERROR_EOF) > + return ret; > + } > } The change lgtm. I tested on Rpi4 and odroid xu4. Will apply this on Sunday if no one else comments. Thanks, -- Andriy _______________________________________________ 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".