[FFmpeg-cvslog] lavfi/vf_tonemap_opencl: fix build

rcombs git at videolan.org
Thu Jun 2 04:14:58 EEST 2022


ffmpeg | branch: master | rcombs <rcombs at rcombs.me> | Wed Jun  1 20:09:17 2022 -0500| [c6364b711bad1fe2fbd90e5b2798f87080ddf5ea] | committer: rcombs

lavfi/vf_tonemap_opencl: fix build

This was broken in d42b410e05ad1c4d6e74aa981b4a4423103291fb.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c6364b711bad1fe2fbd90e5b2798f87080ddf5ea
---

 libavfilter/vf_tonemap_opencl.c | 39 +++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/libavfilter/vf_tonemap_opencl.c b/libavfilter/vf_tonemap_opencl.c
index 121ef7d6f4..f6ebb694a8 100644
--- a/libavfilter/vf_tonemap_opencl.c
+++ b/libavfilter/vf_tonemap_opencl.c
@@ -80,16 +80,6 @@ static const char *const delinearize_funcs[AVCOL_TRC_NB] = {
     [AVCOL_TRC_BT2020_10] = "inverse_eotf_bt1886",
 };
 
-static const struct PrimaryCoefficients primaries_table[AVCOL_PRI_NB] = {
-    [AVCOL_PRI_BT709]  = { 0.640, 0.330, 0.300, 0.600, 0.150, 0.060 },
-    [AVCOL_PRI_BT2020] = { 0.708, 0.292, 0.170, 0.797, 0.131, 0.046 },
-};
-
-static const struct WhitepointCoefficients whitepoint_table[AVCOL_PRI_NB] = {
-    [AVCOL_PRI_BT709]  = { 0.3127, 0.3290 },
-    [AVCOL_PRI_BT2020] = { 0.3127, 0.3290 },
-};
-
 static const char *const tonemap_func[TONEMAP_MAX] = {
     [TONEMAP_NONE]     = "direct",
     [TONEMAP_LINEAR]   = "linear",
@@ -100,14 +90,22 @@ static const char *const tonemap_func[TONEMAP_MAX] = {
     [TONEMAP_MOBIUS]   = "mobius",
 };
 
-static void get_rgb2rgb_matrix(enum AVColorPrimaries in, enum AVColorPrimaries out,
-                               double rgb2rgb[3][3]) {
+static int get_rgb2rgb_matrix(enum AVColorPrimaries in, enum AVColorPrimaries out,
+                              double rgb2rgb[3][3]) {
     double rgb2xyz[3][3], xyz2rgb[3][3];
 
-    ff_fill_rgb2xyz_table(&primaries_table[out], &whitepoint_table[out], rgb2xyz);
+    const AVColorPrimariesDesc *in_primaries = av_csp_primaries_desc_from_id(in);
+    const AVColorPrimariesDesc *out_primaries = av_csp_primaries_desc_from_id(out);
+
+    if (!in_primaries || !out_primaries)
+        return AVERROR(EINVAL);
+
+    ff_fill_rgb2xyz_table(&out_primaries->prim, &out_primaries->wp, rgb2xyz);
     ff_matrix_invert_3x3(rgb2xyz, xyz2rgb);
-    ff_fill_rgb2xyz_table(&primaries_table[in], &whitepoint_table[in], rgb2xyz);
+    ff_fill_rgb2xyz_table(&in_primaries->prim, &in_primaries->wp, rgb2xyz);
     ff_matrix_mul_3x3(rgb2rgb, rgb2xyz, xyz2rgb);
+
+    return 0;
 }
 
 #define OPENCL_SOURCE_NB 3
@@ -120,7 +118,7 @@ static int tonemap_opencl_init(AVFilterContext *avctx)
     TonemapOpenCLContext *ctx = avctx->priv;
     int rgb2rgb_passthrough = 1;
     double rgb2rgb[3][3], rgb2yuv[3][3], yuv2rgb[3][3];
-    const struct LumaCoefficients *luma_src, *luma_dst;
+    const AVLumaCoefficients *luma_src, *luma_dst;
     cl_int cle;
     int err;
     AVBPrint header;
@@ -184,7 +182,8 @@ static int tonemap_opencl_init(AVFilterContext *avctx)
     av_bprintf(&header, "#define DETECTION_FRAMES %d\n", DETECTION_FRAMES);
 
     if (ctx->primaries_out != ctx->primaries_in) {
-        get_rgb2rgb_matrix(ctx->primaries_in, ctx->primaries_out, rgb2rgb);
+        if ((err = get_rgb2rgb_matrix(ctx->primaries_in, ctx->primaries_out, rgb2rgb)) < 0)
+            goto fail;
         rgb2rgb_passthrough = 0;
     }
     if (ctx->range_in == AVCOL_RANGE_JPEG)
@@ -201,7 +200,7 @@ static int tonemap_opencl_init(AVFilterContext *avctx)
         ff_opencl_print_const_matrix_3x3(&header, "rgb2rgb", rgb2rgb);
 
 
-    luma_src = ff_get_luma_coefficients(ctx->colorspace_in);
+    luma_src = av_csp_luma_coeffs_from_avcsp(ctx->colorspace_in);
     if (!luma_src) {
         err = AVERROR(EINVAL);
         av_log(avctx, AV_LOG_ERROR, "unsupported input colorspace %d (%s)\n",
@@ -209,7 +208,7 @@ static int tonemap_opencl_init(AVFilterContext *avctx)
         goto fail;
     }
 
-    luma_dst = ff_get_luma_coefficients(ctx->colorspace_out);
+    luma_dst = av_csp_luma_coeffs_from_avcsp(ctx->colorspace_out);
     if (!luma_dst) {
         err = AVERROR(EINVAL);
         av_log(avctx, AV_LOG_ERROR, "unsupported output colorspace %d (%s)\n",
@@ -225,9 +224,9 @@ static int tonemap_opencl_init(AVFilterContext *avctx)
     ff_opencl_print_const_matrix_3x3(&header, "rgb_matrix", yuv2rgb);
 
     av_bprintf(&header, "constant float3 luma_src = {%.4ff, %.4ff, %.4ff};\n",
-               luma_src->cr, luma_src->cg, luma_src->cb);
+               av_q2d(luma_src->cr), av_q2d(luma_src->cg), av_q2d(luma_src->cb));
     av_bprintf(&header, "constant float3 luma_dst = {%.4ff, %.4ff, %.4ff};\n",
-               luma_dst->cr, luma_dst->cg, luma_dst->cb);
+               av_q2d(luma_dst->cr), av_q2d(luma_dst->cg), av_q2d(luma_dst->cb));
 
     av_bprintf(&header, "#define linearize %s\n", linearize_funcs[ctx->trc_in]);
     av_bprintf(&header, "#define delinearize %s\n",



More information about the ffmpeg-cvslog mailing list