From patchwork Thu Apr 27 18:32:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Faiz X-Patchwork-Id: 3504 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp976410vsd; Thu, 27 Apr 2017 11:38:09 -0700 (PDT) X-Received: by 10.28.7.137 with SMTP id 131mr2951760wmh.49.1493318289735; Thu, 27 Apr 2017 11:38:09 -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 30si3186511wrg.187.2017.04.27.11.38.09; Thu, 27 Apr 2017 11:38:09 -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=@gmail.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=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C646E689213; Thu, 27 Apr 2017 21:38:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ACF29680674 for ; Thu, 27 Apr 2017 21:37:58 +0300 (EEST) Received: by mail-pf0-f196.google.com with SMTP id c198so12837627pfc.0 for ; Thu, 27 Apr 2017 11:38:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ZH7mktN/QNvqEs6uxXLOab3X0nRKGFfStmjdEq3iOHY=; b=cMeyd8dAf1kbAqrjVKfjtWA6oTaqHOP82O8n+rB8T79HcGg427WVaYf/tAFMBJYNYM NTglleXHdvqLch0vREf9/AydjwCGcOnIdHwStvhOEsqAB2R6vJVeI2fvmHlioOjmnziB soONWF7/7cjUcoPP7JFDP926td1ZtQxjzC+OoB1qeVtriMOs4m9Nob1lAH7SFbSFsOgF Z9utrwGKfTnHq+wNoV7SAVO6rxxRQCMBBa48BXhqfDK1aVBrQNS7pMdCLWmmTZTGQRN2 6445bXM7zWG4TrrFYCedd1GTutkX+YBQiHpEwRD/NXheiyyzh24U+WXf5g+t/Cy91HUH 5YsA== 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=ZH7mktN/QNvqEs6uxXLOab3X0nRKGFfStmjdEq3iOHY=; b=qHZBILoZUqn0rkraX+d95X2sIZAjT2J1PKzf5zgqiJWVxPLXerbbM2vOMv11IZdFsR OMwEle731/9+WPbKopF6X2jsznTyvW2O6CuDeG3DKQqjnBdz4Ja4+PJpst5h9+QCq95O QspfZ3lWoSRnWMkyPL/nP0mo5i8sHfs1kGoOWeg+dJJs6V6+oJQH04Ph4wWQ2Dx7bvOv IEfZ8oUcdNDrLu01sN8JqpYRTaML3iUVqQ0uh8RCG6XZ0d+sp80zyRDLcipOG49AeALv Q6V98bAryCh7CKUOe8AaeVBL7bwOrwz87yCsc6WGhV73eNGyJO5KPddv0lMNraWVB/0M W4IA== X-Gm-Message-State: AN3rC/54j3q+2wN88hRDp78qT7BE1TfWjK69KVvLfqBNSLgzEoQrqkqs 454QgBCLQeQUIw== X-Received: by 10.98.152.78 with SMTP id q75mr7452764pfd.256.1493317950250; Thu, 27 Apr 2017 11:32:30 -0700 (PDT) Received: from localhost.localdomain ([114.120.238.90]) by smtp.gmail.com with ESMTPSA id h85sm5529317pfd.114.2017.04.27.11.32.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Apr 2017 11:32:29 -0700 (PDT) From: Muhammad Faiz To: ffmpeg-devel@ffmpeg.org Date: Fri, 28 Apr 2017 01:32:04 +0700 Message-Id: <20170427183204.20445-1-mfcc64@gmail.com> X-Mailer: git-send-email 2.9.3 Subject: [FFmpeg-devel] [PATCH] avcodec/pthread_frame, decode: allow errors to happen on draining 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: Muhammad Faiz MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" So, all frames and errors are correctly reported in order. Fix fate failure with THREADS>=4: make fate-h264-attachment-631 THREADS=4 Suggested-by: wm4, Ronald S. Bultje, Marton Balint Signed-off-by: Muhammad Faiz --- libavcodec/decode.c | 3 ++- libavcodec/pthread_frame.c | 15 +++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 6ff3c40..f4d32e3 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -568,7 +568,8 @@ FF_ENABLE_DEPRECATION_WARNINGS avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1})); #endif - if (avctx->internal->draining && !got_frame) + /* do not stop draining when got_frame != 0 or ret < 0 */ + if (avctx->internal->draining && !got_frame && ret >= 0) avci->draining_done = 1; avci->compat_decode_consumed += ret; diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 13d6828..363b139 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -509,8 +509,8 @@ int ff_thread_decode_frame(AVCodecContext *avctx, /* * Return the next available frame from the oldest thread. * If we're at the end of the stream, then we have to skip threads that - * didn't output a frame, because we don't want to accidentally signal - * EOF (avpkt->size == 0 && *got_picture_ptr == 0). + * didn't output a frame/error, because we don't want to accidentally signal + * EOF (avpkt->size == 0 && *got_picture_ptr == 0 && err >= 0). */ do { @@ -526,20 +526,19 @@ int ff_thread_decode_frame(AVCodecContext *avctx, av_frame_move_ref(picture, p->frame); *got_picture_ptr = p->got_frame; picture->pkt_dts = p->avpkt.dts; - - if (p->result < 0) - err = p->result; + err = p->result; /* * A later call with avkpt->size == 0 may loop over all threads, - * including this one, searching for a frame to return before being + * including this one, searching for a frame/error to return before being * stopped by the "finished != fctx->next_finished" condition. - * Make sure we don't mistakenly return the same frame again. + * Make sure we don't mistakenly return the same frame/error again. */ p->got_frame = 0; + p->result = 0; if (finished >= avctx->thread_count) finished = 0; - } while (!avpkt->size && !*got_picture_ptr && finished != fctx->next_finished); + } while (!avpkt->size && !*got_picture_ptr && err >= 0 && finished != fctx->next_finished); update_context_from_thread(avctx, p->avctx, 1);