From patchwork Tue Jan 22 07:15:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruiling Song X-Patchwork-Id: 11819 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 19D9B44CDA1 for ; Tue, 22 Jan 2019 09:18:35 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3B29668AA14; Tue, 22 Jan 2019 09:18:23 +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 2580D68A7C5 for ; Tue, 22 Jan 2019 09:18:15 +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:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,505,1539673200"; d="scan'208";a="293351642" Received: from ruiling-skl2.sh.intel.com ([10.239.158.154]) by orsmga005.jf.intel.com with ESMTP; 21 Jan 2019 23:18:29 -0800 From: Ruiling Song To: ffmpeg-devel@ffmpeg.org Date: Tue, 22 Jan 2019 15:15:35 +0800 Message-Id: <1548141337-32109-3-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 3/5] lavfi/opencl: add ff_opencl_print_const_matrix_3x3() 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" This is used to print a 3x3 matrix into a part of OpenCL source code. Signed-off-by: Ruiling Song --- libavfilter/opencl.c | 13 +++++++++++++ libavfilter/opencl.h | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/libavfilter/opencl.c b/libavfilter/opencl.c index ac5eec6..95f0bfc 100644 --- a/libavfilter/opencl.c +++ b/libavfilter/opencl.c @@ -337,3 +337,16 @@ int ff_opencl_filter_work_size_from_image(AVFilterContext *avctx, return 0; } + +void ff_opencl_print_const_matrix_3x3(AVBPrint *buf, const char *name_str, + double mat[3][3]) +{ + int i, j; + av_bprintf(buf, "__constant float %s[9] = {\n", name_str); + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) + av_bprintf(buf, " %.5ff,", mat[i][j]); + av_bprintf(buf, "\n"); + } + av_bprintf(buf, "};\n"); +} diff --git a/libavfilter/opencl.h b/libavfilter/opencl.h index 1b7f117..0b06232 100644 --- a/libavfilter/opencl.h +++ b/libavfilter/opencl.h @@ -25,6 +25,7 @@ // it was introduced in OpenCL 2.0. #define CL_USE_DEPRECATED_OPENCL_1_2_APIS +#include "libavutil/bprint.h" #include "libavutil/buffer.h" #include "libavutil/hwcontext.h" #include "libavutil/hwcontext_opencl.h" @@ -124,5 +125,12 @@ int ff_opencl_filter_work_size_from_image(AVFilterContext *avctx, size_t *work_size, AVFrame *frame, int plane, int block_alignment); +/** + * Print a 3x3 matrix into a buffer as __constant array, which could + * be included in an OpenCL program. +*/ + +void ff_opencl_print_const_matrix_3x3(AVBPrint *buf, const char *name_str, + double mat[3][3]); #endif /* AVFILTER_OPENCL_H */