From patchwork Thu Mar 2 09:45:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wm4 X-Patchwork-Id: 2732 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.31.14 with SMTP id f14csp170046vsf; Thu, 2 Mar 2017 01:45:37 -0800 (PST) X-Received: by 10.223.144.65 with SMTP id h59mr12929320wrh.30.1488447937776; Thu, 02 Mar 2017 01:45:37 -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 e17si1515981wre.324.2017.03.02.01.45.37; Thu, 02 Mar 2017 01:45:37 -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=@googlemail.com; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 21C97688340; Thu, 2 Mar 2017 11:45:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f179.google.com (mail-wr0-f179.google.com [209.85.128.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 069BE6800B7 for ; Thu, 2 Mar 2017 11:45:16 +0200 (EET) Received: by mail-wr0-f179.google.com with SMTP id u108so47899047wrb.3 for ; Thu, 02 Mar 2017 01:45:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=kmPMrowFdviqP2AJr81iUEod7E53Ki7F3QlGgAa4y0Y=; b=lNQttx1Gy2uSpw5hGi0wBOpw4U3fCFSkWg+hfXWBBCl6UUS8ZlE24yxu9WKr5cbv3m F9e0z00XrciWigB2dnx0GjHgyomNcjsnj/+UGSCYvPnw443Ryx6FbTe1xySMmtEOjAap 2bDPQLMguCv0K4lFUahJMZLN6pMnD6dUv5jXETfES4ANkYyFwD9IlTUgmnnU9krogECV Hz2OEchwATnwIBpWRtOXhNf/2/kUbrMgpsKHXaqbeCmpSfdIh4Qad6KArfCQcbN+acIJ 0jJwT8M1K5w1tmo5jGdA5TA0FuNG1gGVfHP9MqZvoLYNsKqOUvd2gKMiFS5rQOoanAMO dIVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=kmPMrowFdviqP2AJr81iUEod7E53Ki7F3QlGgAa4y0Y=; b=cq4TzHNoW/DLoIsQGBbwGQw189/+SxkzYRRNC3y2LKHm+xka0WHJ+LWV/dtWEFVJWK NTuCt/ZpwTf88wVXe3DbkOjO3LaHMuVZWtDAPpIdWYmVUm/tzb/pAim35UdxjoQutfQV 3jQxPIG4WzTXBY28YoY1jSPY7ipGAZO5DwBwP5muIGdmAW8Rhl0xKV7hUl8p8ZES8UsH gL/rpK5sfBWrrZbLF12Wa42SAj5qInKb5rhGKPw4cDvIZYrlGaWjE74EboFQF3CJMDOa ONz8AXApRXkEY1ZeLMlFFAreaiZSP1nhEJ8nX+XvVbI1LxlHbyd/lwUYEj79KGj1WkWb pAxA== X-Gm-Message-State: AMke39l4fFT495PfF+R07aZ3HabGEJDc5e0B8faK+RV9wJ8x//OqJXkciC9nyAUvCPyFNA== X-Received: by 10.223.148.230 with SMTP id 93mr11201071wrr.13.1488447927335; Thu, 02 Mar 2017 01:45:27 -0800 (PST) Received: from localhost.localdomain (p4FF003DA.dip0.t-ipconnect.de. [79.240.3.218]) by smtp.googlemail.com with ESMTPSA id 128sm8877647wmp.11.2017.03.02.01.45.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 01:45:26 -0800 (PST) From: wm4 To: ffmpeg-devel@ffmpeg.org Date: Thu, 2 Mar 2017 10:45:23 +0100 Message-Id: <20170302094524.10628-1-nfxjfg@googlemail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170215223132.GZ5776@nb4> References: <20170215223132.GZ5776@nb4> Subject: [FFmpeg-devel] [PATCH v2 1/2] lavc: consider an error during decoder draining as EOF X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" There is no reason that draining couldn't return an error or two. But some decoders don't handle this very well, and might always return an error. This can lead to API users getting into an infinite loop and burning CPU, because no progress is made and EOF is never returned. In fact, ffmpeg.c contains a hack against such a case. It is removed with this patch. This particular error case seems to have been fixed since the hack was added, though. This might lose frames if decoding returns errors during draining. --- Minor lavc bump missing. --- libavcodec/utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 1156e43079..db3adb18d4 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -2807,12 +2807,12 @@ static int do_decode(AVCodecContext *avctx, AVPacket *pkt) if (ret == AVERROR(EAGAIN)) ret = pkt->size; - if (ret < 0) - return ret; - if (avctx->internal->draining && !got_frame) avctx->internal->draining_done = 1; + if (ret < 0) + return ret; + if (ret >= pkt->size) { av_packet_unref(avctx->internal->buffer_pkt); } else {