From patchwork Mon Mar 27 12:28:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wm4 X-Patchwork-Id: 3124 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.44.195 with SMTP id s186csp140855vss; Mon, 27 Mar 2017 05:28:36 -0700 (PDT) X-Received: by 10.28.71.87 with SMTP id u84mr9504936wma.101.1490617716612; Mon, 27 Mar 2017 05:28:36 -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 e143si596536wmf.158.2017.03.27.05.28.34; Mon, 27 Mar 2017 05:28:36 -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 801CE68834A; Mon, 27 Mar 2017 15:28:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f172.google.com (mail-wr0-f172.google.com [209.85.128.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 022E268830A for ; Mon, 27 Mar 2017 15:28:03 +0300 (EEST) Received: by mail-wr0-f172.google.com with SMTP id u1so54554254wra.2 for ; Mon, 27 Mar 2017 05:28:24 -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=CFi84NX1I+19+F65WCCW+zDDj92jebIV2iWg5SFdUb0=; b=orBuUrJCDr3Jfre10IiJ4p+k5HWrsiLsf5sVDiEDguhdCWrmzzmPvwGSJdb4k4Olfa gsxHkgA3DjtxtJMKSr7od7Cd5uwlCbbDN/io72M85Jx11DHCoRJJOwTdMjW9lYBn0w3k n3+gxBTu/+Xz4RH8W6lM4kl615kt7hataTMbO/hgEAgv2SXi4h9Q4vznq12m3pyKwejS aORPlkT880x7+vjfUfBfEjmLkEe5V+tWK2GYW9CFDrxISc4IGWllh7jXEYJjAh5QPSl1 UbyVcCdLyrApEVOT5o/KguNvc8PkJxD0gTQbMKi8cKysnuMH2BH8xgaPXQH7uRAXxLzw vnbg== 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=CFi84NX1I+19+F65WCCW+zDDj92jebIV2iWg5SFdUb0=; b=G/bsJpMjrlDldAEoliJ7BwuBmipGYvCQ//AGDLXS4/NF8AmJo2qSrUENBB/bVeY2Lf OfmuptANePmi/hzvlVvi0qyg/9di3fQEa8i1oljm/VH3DBai2vDkgCoCuYpRb3KTZ7vn c94cNrKGHh7kJjz72MxTnMUUvb+7TgwxV6d7VcwDq9ZZj0VFCqYw75cir9oXiE32Jmlb Us3Vj9K/BfDZo2kbvuu0Jv7DKxc/PfowfXtY2ipv8pqiVawuMHyTORU8nrEuDsdotxyR kflTj7UVQtf34uyO2rscQpBj2kzooYmOauwcX+px19DRan9FiOTHy1cmxlThEJsAZJXK oQrg== X-Gm-Message-State: AFeK/H3LH/wZ6uLXalhfHIRORLKK7qRlDper+X5H2hI1MOuRDsLDQTnCox8uNhwRQrZuzA== X-Received: by 10.28.208.72 with SMTP id h69mr9593516wmg.100.1490617704480; Mon, 27 Mar 2017 05:28:24 -0700 (PDT) Received: from localhost.localdomain (p4FF0281A.dip0.t-ipconnect.de. [79.240.40.26]) by smtp.googlemail.com with ESMTPSA id 127sm651445wmu.27.2017.03.27.05.28.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Mar 2017 05:28:23 -0700 (PDT) From: wm4 To: ffmpeg-devel@ffmpeg.org Date: Mon, 27 Mar 2017 14:28:17 +0200 Message-Id: <20170327122817.10940-1-nfxjfg@googlemail.com> X-Mailer: git-send-email 2.11.0 Subject: [FFmpeg-devel] [PATCH] pthread_frame: minor simplification to error handling 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" Get rid of the "ret" variable, and always use err. Report the packet as consumed if err is unset. This should be equivalent to the old code, which obviously required err=0 for p->result>=0 (and otherwise, p->result must have had the value err was last set to). The code block added by commit 32a5b631267 is also not needed anymore, because the new code strictly returns err if it's >=0. --- Not totally sure about this, but it seems to work out? I probably missed something obvious. --- libavcodec/pthread_frame.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index b618be0bf5..36e4a8affa 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -468,7 +468,7 @@ int ff_thread_decode_frame(AVCodecContext *avctx, FrameThreadContext *fctx = avctx->internal->thread_ctx; int finished = fctx->next_finished; PerThreadContext *p; - int err, ret = 0; + int err; /* release the async lock, permitting blocked hwaccel threads to * go forward while we are in this function */ @@ -496,7 +496,7 @@ int ff_thread_decode_frame(AVCodecContext *avctx, if (fctx->delaying) { *got_picture_ptr=0; if (avpkt->size) { - ret = avpkt->size; + err = avpkt->size; goto finish; } } @@ -542,21 +542,12 @@ int ff_thread_decode_frame(AVCodecContext *avctx, fctx->next_finished = finished; - /* - * When no frame was found while flushing, but an error occurred in - * any thread, return it instead of 0. - * Otherwise the error can get lost. - */ - if (!avpkt->size && !*got_picture_ptr) - goto finish; - /* return the size of the consumed packet if no error occurred */ - ret = (p->result >= 0) ? avpkt->size : p->result; + if (err >= 0) + err = avpkt->size; finish: async_lock(fctx); - if (err < 0) - return err; - return ret; + return err; } void ff_thread_report_progress(ThreadFrame *f, int n, int field)