From patchwork Tue Jun 12 07:20:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruiling Song X-Patchwork-Id: 9371 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp5098205jad; Tue, 12 Jun 2018 00:21:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJMNI+ixKWgTXGiSadt2Vvnj8NJclQtBFkNfStnzrUhi6O6+Cy5t2XSLTqPrBQN2xwPHCXv X-Received: by 2002:a1c:6c0f:: with SMTP id h15-v6mr1184608wmc.30.1528788104556; Tue, 12 Jun 2018 00:21:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528788104; cv=none; d=google.com; s=arc-20160816; b=jsbMq52/cSGdLHvrvY6rrMuVKxma3d8/pcCr+7Oc/OcpRNpxivDJDGcLE5hw3TMgN4 m3Fk0AyrVYsM4xVMCdgSf9V70kHpP4s62Oz01PmOUorsATvxH/hOwPQFQQTr2KIRixrT vUvTpch33qSXahFqZMuilMC0SP7KPEvePEiY7kdHtcCyAN9Twk+/ZSLkqYqTeaAERgCX kvHbRX2XqdobmCOKG8YmDaAW3+7st9iWivy83R5Y9DvFqz0uvYgV/H2FNYgVpm6VMfuh HOiWvZZXMM2pvAAtyajIYT0s5qR1f9RARJ/msg82L2amFAvi0OjZxgsH+ZG3LlfJjARA ixFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to :arc-authentication-results; bh=8u2PUjKr1CSeX+W/q2RZF61xoa/60TTQiJUmXdU/1UY=; b=xMvSOVxvdkK843jnU7qFiQJbGaZyzpsPBUynk3i2ebcSfV7gT/AmvocPycFYbyfXtm k6N6EY1kaafbgOdS0d/QXyIw3A5ok5JltTexI9PdZrih5uq1px1f19hyGDhqHFd6vMmi o8VU00pFEPISL+y1q/72T4GL08QRgUD/uD2CQ6xZZNHCTUt+8rwLH0sk2BklSMoRNHwf o9k86xEzJbXSngbPj1VR0sbxCwNvIU1fGHUOadpJeePMd1e4nq5M5GN8XFZn60o44knf gy0aXhZ69dz2gkrkTm3E8iVXt1NNi3Odq/orNdCDluLCjP9xyvOwYdurn7XtsWHMbBUn b1ww== ARC-Authentication-Results: i=1; mx.google.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=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u6-v6si224199wru.160.2018.06.12.00.21.43; Tue, 12 Jun 2018 00:21:44 -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; 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=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0FE7168AF2E; Tue, 12 Jun 2018 10:20:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B82F268AE39 for ; Tue, 12 Jun 2018 10:20:45 +0300 (EEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jun 2018 00:21:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,213,1526367600"; d="scan'208";a="66285364" Received: from ruiling-skl2.sh.intel.com ([10.239.160.154]) by orsmga002.jf.intel.com with ESMTP; 12 Jun 2018 00:21:31 -0700 From: Ruiling Song To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Jun 2018 15:20:32 +0800 Message-Id: <1528788032-18129-1-git-send-email-ruiling.song@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH] lavfi: add helper macro for OpenCL 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: Ruiling Song MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Ruiling Song --- I am not sure whether do you think this would be useful? the main purpose is to make OpenCL error check code simpler. If we think this is good, I can go to replace current OpenCL filters to use this macro. for example: if (cle != CL_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "Failed to enqueue kernel: %d.\n", cle); err = AVERROR(EIO); goto fail; } can be replaced with: OCL_FAIL_ON_ERR(avctx, cle, AVERROR(EIO), "Failed to enqueue kernel: %d.\n", cle); Thanks! Ruiling libavfilter/opencl.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libavfilter/opencl.h b/libavfilter/opencl.h index c0a4519..c33df1c 100644 --- a/libavfilter/opencl.h +++ b/libavfilter/opencl.h @@ -97,5 +97,16 @@ int ff_opencl_filter_work_size_from_image(AVFilterContext *avctx, size_t *work_size, AVFrame *frame, int plane, int block_alignment); +/** + * A helper macro to handle OpenCL error. It will assign errcode to + * variable err, log error msg, and jump to fail label on error. + */ +#define OCL_FAIL_ON_ERR(logctx, cle, errcode, ...) do {\ + if (cle != CL_SUCCESS) {\ + av_log(logctx, AV_LOG_ERROR, __VA_ARGS__);\ + err = errcode;\ + goto fail;\ + }\ +} while(0) #endif /* AVFILTER_OPENCL_H */