From patchwork Tue Jan 22 07:15:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruiling Song X-Patchwork-Id: 11821 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id A419B44CDA1 for ; Tue, 22 Jan 2019 09:18:39 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C7E8568A99E; Tue, 22 Jan 2019 09:18:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7F7B268A99E for ; Tue, 22 Jan 2019 09:18:20 +0200 (EET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jan 2019 23:18:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,505,1539673200"; d="scan'208";a="293351652" Received: from ruiling-skl2.sh.intel.com ([10.239.158.154]) by orsmga005.jf.intel.com with ESMTP; 21 Jan 2019 23:18:32 -0800 From: Ruiling Song To: ffmpeg-devel@ffmpeg.org Date: Tue, 22 Jan 2019 15:15:37 +0800 Message-Id: <1548141337-32109-5-git-send-email-ruiling.song@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1548141337-32109-1-git-send-email-ruiling.song@intel.com> References: <1548141337-32109-1-git-send-email-ruiling.song@intel.com> Subject: [FFmpeg-devel] [PATCH 5/5] lavfi/colorspace_common: add ifdef check to be more compatible. 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" Some filters may not need to do linearize/delinearize, thus will even not define them. Add ifdef check, so they could easily re-use the .cl file. Signed-off-by: Ruiling Song --- libavfilter/opencl/colorspace_common.cl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavfilter/opencl/colorspace_common.cl b/libavfilter/opencl/colorspace_common.cl index 1d68a54..ac911f0 100644 --- a/libavfilter/opencl/colorspace_common.cl +++ b/libavfilter/opencl/colorspace_common.cl @@ -124,10 +124,14 @@ float3 yuv2rgb(float y, float u, float v) { float3 yuv2lrgb(float3 yuv) { float3 rgb = yuv2rgb(yuv.x, yuv.y, yuv.z); +#ifdef linearize float r = linearize(rgb.x); float g = linearize(rgb.y); float b = linearize(rgb.z); return (float3)(r, g, b); +#else + return rgb; +#endif } float3 rgb2yuv(float r, float g, float b) { @@ -151,19 +155,25 @@ float rgb2y(float r, float g, float b) { } float3 lrgb2yuv(float3 c) { +#ifdef delinearize float r = delinearize(c.x); float g = delinearize(c.y); float b = delinearize(c.z); - return rgb2yuv(r, g, b); +#else + return rgb2yuv(c.x, c.y, c.z); +#endif } float lrgb2y(float3 c) { +#ifdef delinearize float r = delinearize(c.x); float g = delinearize(c.y); float b = delinearize(c.z); - return rgb2y(r, g, b); +#else + return rgb2y(c.x, c.y, c.z); +#endif } float3 lrgb2lrgb(float3 c) {