From patchwork Thu Apr 6 15:36:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wm4 X-Patchwork-Id: 3320 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.44.195 with SMTP id s186csp710304vss; Thu, 6 Apr 2017 08:36:55 -0700 (PDT) X-Received: by 10.28.181.78 with SMTP id e75mr18522647wmf.105.1491493014903; Thu, 06 Apr 2017 08:36:54 -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 d3si3494465wmf.12.2017.04.06.08.36.54; Thu, 06 Apr 2017 08:36:54 -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=@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 DAA87688281; Thu, 6 Apr 2017 18:36:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 23CA9680A04 for ; Thu, 6 Apr 2017 18:36:42 +0300 (EEST) Received: by mail-wr0-f193.google.com with SMTP id g19so12494938wrb.0 for ; Thu, 06 Apr 2017 08:36:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=JDD+4Q3ZvfLCaJVOYEcU4SN39Tel1wqVUnWYJP/F+AM=; b=ocSux+fo5TvXqd4yN0rInpFp0qZmc7LsiAkJ4Rf4Ls2VRbuOKg2R1k6kExgEznhoXJ 5L7H9Lo+qbrQBar08M86D3stfYA+Njr7ON+9c2yD4X0QnAUV5NHJ37jeA42EIhtW3eXP C6y2hH+EnT8RMIwhkl07zfhd8eCDiRdSRanFiPZCWpZX5inqFMZX4bPdoMfr4quTxwWc R1f2H0AQDUYIoqFVqW04f2CfQDdjxm7DpESep46MfkmmeJxZLTcYnOIP3u30yOLhA+kU 2ErWQXwCDsKliJgXGjgM+22nSJYWGafj+jglkpXbdLlFU9ypEdJZzuICMIIVZaikePYA d2+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JDD+4Q3ZvfLCaJVOYEcU4SN39Tel1wqVUnWYJP/F+AM=; b=XRcWEPwnqNthcdY3bKZhlfuPgxCrbF+9ullTjwvGNRRLIXgEFBU4K029Nxhq4/eCHD 1xA6ZwdaXCsjaiJPh4rwZtfez+ykc9IhH0KPrxA+kjV9p/mzQZWKMZiQ0BnUdiAv0N2N vfiex5A8aQROrMZfmZ7sIvxWEyll95eJp+wfE5c3dRmEL9ICj0IIv6swnreL0j509NmG gFOAG4+Z79/YEsX4a0iBFHD+SlN60N9/uJi99NRtOXxunVKpGvrHpjVFu6paY0684rFv bAb8r4QQB469KWh8tzo9xFCnCp6VqS+x0oiluLGRrzzWrAiB2vundK9SIenD+gEO7fzT JNrw== X-Gm-Message-State: AFeK/H1oC94egGLm7qk9k/5znAC45o/nNlh1isqTJ8UT2O6TyIbR9aIa 9X8Rb1i4v+jP0FMw X-Received: by 10.28.136.81 with SMTP id k78mr24537663wmd.36.1491493004897; Thu, 06 Apr 2017 08:36:44 -0700 (PDT) Received: from localhost.localdomain (p4FF02741.dip0.t-ipconnect.de. [79.240.39.65]) by smtp.googlemail.com with ESMTPSA id g63sm26923304wme.11.2017.04.06.08.36.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Apr 2017 08:36:44 -0700 (PDT) From: wm4 To: ffmpeg-devel@ffmpeg.org Date: Thu, 6 Apr 2017 17:36:43 +0200 Message-Id: <20170406153643.647-1-nfxjfg@googlemail.com> X-Mailer: git-send-email 2.11.0 Subject: [FFmpeg-devel] [PATCH] pthread_frame: don't return stale error codes after flush 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 Cc: wm4 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Consider the following sequence of events: - open a codec without AV_CODEC_CAP_DELAY - decode call fails with an error - ff_thread_flush() is called - drain packet is sent Then the last step would make ff_thread_decode_frame() return an error, because p->result can still be set to an error value. This is because submit_packet returns immediately if AV_CODEC_CAP_DELAY is not set, and no worker thread gets the chance to reset p->result, yet its value is trusted by ff_thread_decode_frame(). Fix this by clearing the error fields on flush. --- libavcodec/pthread_frame.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 9a6b83ac45..7586f00bec 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -859,6 +859,7 @@ void ff_thread_flush(AVCodecContext *avctx) // Make sure decode flush calls with size=0 won't return old frames p->got_frame = 0; av_frame_unref(p->frame); + p->result = 0; release_delayed_buffers(p);