[FFmpeg-cvslog] lavfi/opencl: add ff_opencl_print_const_matrix_3x3()
Ruiling Song
git at videolan.org
Fri Mar 22 03:40:31 EET 2019
ffmpeg | branch: master | Ruiling Song <ruiling.song at intel.com> | Tue Jan 22 14:47:54 2019 +0800| [2593122a167de3294abd5b9cf04df5b8072ee3ed] | committer: Ruiling Song
lavfi/opencl: add ff_opencl_print_const_matrix_3x3()
This is used to print a 3x3 matrix into a part of OpenCL
source code.
Signed-off-by: Ruiling Song <ruiling.song at intel.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2593122a167de3294abd5b9cf04df5b8072ee3ed
---
libavfilter/opencl.c | 13 +++++++++++++
libavfilter/opencl.h | 8 ++++++++
2 files changed, 21 insertions(+)
diff --git a/libavfilter/opencl.c b/libavfilter/opencl.c
index ac5eec68c6..95f0bfc604 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 1b7f117865..0b06232ade 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 */
More information about the ffmpeg-cvslog
mailing list