tools/cl2c: change to tools/source2c and allow non-OpenCL source files

pull/389/head
Lynne 2 years ago
parent 7cfd7e4af4
commit 88e2cca3db
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464
  1. 11
      libavfilter/Makefile
  2. 28
      libavfilter/opencl_source.h
  3. 2
      libavfilter/vf_avgblur_opencl.c
  4. 2
      libavfilter/vf_colorkey_opencl.c
  5. 2
      libavfilter/vf_convolution_opencl.c
  6. 2
      libavfilter/vf_deshake_opencl.c
  7. 2
      libavfilter/vf_neighbor_opencl.c
  8. 2
      libavfilter/vf_nlmeans_opencl.c
  9. 2
      libavfilter/vf_overlay_opencl.c
  10. 2
      libavfilter/vf_pad_opencl.c
  11. 2
      libavfilter/vf_remap_opencl.c
  12. 4
      libavfilter/vf_tonemap_opencl.c
  13. 2
      libavfilter/vf_transpose_opencl.c
  14. 2
      libavfilter/vf_unsharp_opencl.c
  15. 2
      libavfilter/vf_xfade_opencl.c
  16. 1
      libavfilter/vulkan/.gitignore
  17. 10
      tools/source2c

@ -651,10 +651,17 @@ TESTPROGS = drawutils filtfmts formats integral
TOOLS-$(CONFIG_LIBZMQ) += zmqsend
clean::
$(RM) $(CLEANSUFFIXES:%=libavfilter/dnn/%) $(CLEANSUFFIXES:%=libavfilter/opencl/%)
$(RM) $(CLEANSUFFIXES:%=libavfilter/dnn/%) $(CLEANSUFFIXES:%=libavfilter/opencl/%) \
$(CLEANSUFFIXES:%=libavfilter/vulkan/%)
OPENCL = $(subst $(SRC_PATH)/,,$(wildcard $(SRC_PATH)/libavfilter/opencl/*.cl))
.SECONDARY: $(OPENCL:.cl=.c)
libavfilter/opencl/%.c: TAG = OPENCL
libavfilter/opencl/%.c: $(SRC_PATH)/libavfilter/opencl/%.cl
$(M)$(SRC_PATH)/tools/cl2c $< $@
$(M)$(SRC_PATH)/tools/source2c $< $@
VULKAN = $(subst $(SRC_PATH)/,,$(wildcard $(SRC_PATH)/libavfilter/vulkan/*.comp))
.SECONDARY: $(VULKAN:.comp=.c)
libavfilter/vulkan/%.c: TAG = OPENCL
libavfilter/vulkan/%.c: $(SRC_PATH)/libavfilter/vulkan/%.comp
$(M)$(SRC_PATH)/tools/source2c $< $@

@ -19,19 +19,19 @@
#ifndef AVFILTER_OPENCL_SOURCE_H
#define AVFILTER_OPENCL_SOURCE_H
extern const char *ff_opencl_source_avgblur;
extern const char *ff_opencl_source_colorkey;
extern const char *ff_opencl_source_colorspace_common;
extern const char *ff_opencl_source_convolution;
extern const char *ff_opencl_source_deshake;
extern const char *ff_opencl_source_neighbor;
extern const char *ff_opencl_source_nlmeans;
extern const char *ff_opencl_source_overlay;
extern const char *ff_opencl_source_pad;
extern const char *ff_opencl_source_remap;
extern const char *ff_opencl_source_tonemap;
extern const char *ff_opencl_source_transpose;
extern const char *ff_opencl_source_unsharp;
extern const char *ff_opencl_source_xfade;
extern const char *ff_source_avgblur_cl;
extern const char *ff_source_colorkey_cl;
extern const char *ff_source_colorspace_common_cl;
extern const char *ff_source_convolution_cl;
extern const char *ff_source_deshake_cl;
extern const char *ff_source_neighbor_cl;
extern const char *ff_source_nlmeans_cl;
extern const char *ff_source_overlay_cl;
extern const char *ff_source_pad_cl;
extern const char *ff_source_remap_cl;
extern const char *ff_source_tonemap_cl;
extern const char *ff_source_transpose_cl;
extern const char *ff_source_unsharp_cl;
extern const char *ff_source_xfade_cl;
#endif /* AVFILTER_OPENCL_SOURCE_H */

@ -59,7 +59,7 @@ static int avgblur_opencl_init(AVFilterContext *avctx)
cl_int cle;
int err;
err = ff_opencl_filter_load_program(avctx, &ff_opencl_source_avgblur, 1);
err = ff_opencl_filter_load_program(avctx, &ff_source_avgblur_cl, 1);
if (err < 0)
goto fail;

@ -52,7 +52,7 @@ static int colorkey_opencl_init(AVFilterContext *avctx)
cl_int cle;
int err;
err = ff_opencl_filter_load_program(avctx, &ff_opencl_source_colorkey, 1);
err = ff_opencl_filter_load_program(avctx, &ff_source_colorkey_cl, 1);
if (err < 0)
goto fail;

@ -62,7 +62,7 @@ static int convolution_opencl_init(AVFilterContext *avctx)
cl_int cle;
int err;
err = ff_opencl_filter_load_program(avctx, &ff_opencl_source_convolution, 1);
err = ff_opencl_filter_load_program(avctx, &ff_source_convolution_cl, 1);
if (err < 0)
goto fail;

@ -1251,7 +1251,7 @@ static int deshake_opencl_init(AVFilterContext *avctx)
}
ctx->sw_format = hw_frames_ctx->sw_format;
err = ff_opencl_filter_load_program(avctx, &ff_opencl_source_deshake, 1);
err = ff_opencl_filter_load_program(avctx, &ff_source_deshake_cl, 1);
if (err < 0)
goto fail;

@ -55,7 +55,7 @@ static int neighbor_opencl_init(AVFilterContext *avctx)
cl_int cle;
int err;
err = ff_opencl_filter_load_program(avctx, &ff_opencl_source_neighbor, 1);
err = ff_opencl_filter_load_program(avctx, &ff_source_neighbor_cl, 1);
if (err < 0)
goto fail;

@ -98,7 +98,7 @@ static int nlmeans_opencl_init(AVFilterContext *avctx, int width, int height)
if (!ctx->patch_size_uv)
ctx->patch_size_uv = ctx->patch_size;
err = ff_opencl_filter_load_program(avctx, &ff_opencl_source_nlmeans, 1);
err = ff_opencl_filter_load_program(avctx, &ff_source_nlmeans_cl, 1);
if (err < 0)
goto fail;

@ -51,7 +51,7 @@ static int overlay_opencl_load(AVFilterContext *avctx,
{
OverlayOpenCLContext *ctx = avctx->priv;
cl_int cle;
const char *source = ff_opencl_source_overlay;
const char *source = ff_source_overlay_cl;
const char *kernel;
const AVPixFmtDescriptor *main_desc, *overlay_desc;
int err, i, main_planes, overlay_planes;

@ -93,7 +93,7 @@ static int pad_opencl_init(AVFilterContext *avctx, AVFrame *input_frame)
ctx->hsub = desc->log2_chroma_w;
ctx->vsub = desc->log2_chroma_h;
err = ff_opencl_filter_load_program(avctx, &ff_opencl_source_pad, 1);
err = ff_opencl_filter_load_program(avctx, &ff_source_pad_cl, 1);
if (err < 0)
goto fail;

@ -73,7 +73,7 @@ static int remap_opencl_load(AVFilterContext *avctx,
{
RemapOpenCLContext *ctx = avctx->priv;
cl_int cle;
const char *source = ff_opencl_source_remap;
const char *source = ff_source_remap_cl;
const char *kernel = kernels[ctx->interp];
const AVPixFmtDescriptor *main_desc;
int err, main_planes;

@ -240,8 +240,8 @@ static int tonemap_opencl_init(AVFilterContext *avctx)
av_log(avctx, AV_LOG_DEBUG, "Generated OpenCL header:\n%s\n", header.str);
opencl_sources[0] = header.str;
opencl_sources[1] = ff_opencl_source_tonemap;
opencl_sources[2] = ff_opencl_source_colorspace_common;
opencl_sources[1] = ff_source_tonemap_cl;
opencl_sources[2] = ff_source_colorspace_common_cl;
err = ff_opencl_filter_load_program(avctx, opencl_sources, OPENCL_SOURCE_NB);
av_bprint_finalize(&header, NULL);

@ -44,7 +44,7 @@ static int transpose_opencl_init(AVFilterContext *avctx)
cl_int cle;
int err;
err = ff_opencl_filter_load_program(avctx, &ff_opencl_source_transpose, 1);
err = ff_opencl_filter_load_program(avctx, &ff_source_transpose_cl, 1);
if (err < 0)
goto fail;

@ -69,7 +69,7 @@ static int unsharp_opencl_init(AVFilterContext *avctx)
cl_int cle;
int err;
err = ff_opencl_filter_load_program(avctx, &ff_opencl_source_unsharp, 1);
err = ff_opencl_filter_load_program(avctx, &ff_source_unsharp_cl, 1);
if (err < 0)
goto fail;

@ -93,7 +93,7 @@ static int xfade_opencl_load(AVFilterContext *avctx,
if (ctx->transition == CUSTOM) {
err = ff_opencl_filter_load_program_from_file(avctx, ctx->source_file);
} else {
err = ff_opencl_filter_load_program(avctx, &ff_opencl_source_xfade, 1);
err = ff_opencl_filter_load_program(avctx, &ff_source_xfade_cl, 1);
}
if (err < 0)
return err;

@ -1,7 +1,6 @@
#!/bin/sh
# Convert an OpenCL source file into a C source file containing the
# OpenCL source as a C string. Also adds a #line directive so that
# compiler messages are useful.
# Convert a source file into a C source file containing the
# source code as a C string.
# This file is part of FFmpeg.
#
@ -22,12 +21,11 @@
input="$1"
output="$2"
name=$(basename "$input" | sed 's/.cl$//')
name=$(basename "$input" | sed 's/\./_/')
cat >$output <<EOF
// Generated from $input
const char *ff_opencl_source_$name =
"#line 1 \"$input\"\n"
const char *ff_source_$name =
EOF
# Convert \ to \\ and " to \", then add " to the start and end of the line.
Loading…
Cancel
Save