diff mbox series

[FFmpeg-devel,1/2] lavfi/colorspace: add ff_matrix_mul_3x3_vec

Message ID fec89f3a61035cadf2c371e187e1f6e84ddc1dcd.1654192626.git.ffmpegagent@gmail.com
State Accepted
Commit a5b3b65dc067b900be55d7edcea3cecd65a133f0
Headers show
Series lavfi/drawutils: improve colorspace support | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

softworkz June 2, 2022, 5:57 p.m. UTC
From: rcombs <rcombs@rcombs.me>

Signed-off-by: rcombs <rcombs@rcombs.me>
---
 libavfilter/colorspace.c | 11 +++++++++++
 libavfilter/colorspace.h |  1 +
 2 files changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/libavfilter/colorspace.c b/libavfilter/colorspace.c
index 7f74fe5113..f0bd14be18 100644
--- a/libavfilter/colorspace.c
+++ b/libavfilter/colorspace.c
@@ -62,6 +62,17 @@  void ff_matrix_mul_3x3(double dst[3][3],
                         src2[m][1] * src1[1][n] +
                         src2[m][2] * src1[2][n];
 }
+
+void ff_matrix_mul_3x3_vec(double dst[3], const double vec[3], const double mat[3][3])
+{
+    int m;
+
+    for (m = 0; m < 3; m++)
+        dst[m] = vec[0] * mat[m][0] +
+                 vec[1] * mat[m][1] +
+                 vec[2] * mat[m][2];
+}
+
 /*
  * see e.g. http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
  */
diff --git a/libavfilter/colorspace.h b/libavfilter/colorspace.h
index 879518d242..4d98b1da2e 100644
--- a/libavfilter/colorspace.h
+++ b/libavfilter/colorspace.h
@@ -29,6 +29,7 @@ 
 void ff_matrix_invert_3x3(const double in[3][3], double out[3][3]);
 void ff_matrix_mul_3x3(double dst[3][3],
                const double src1[3][3], const double src2[3][3]);
+void ff_matrix_mul_3x3_vec(double dst[3], const double vec[3], const double mat[3][3]);
 void ff_fill_rgb2xyz_table(const AVPrimaryCoefficients *coeffs,
                            const AVWhitepointCoefficients *wp,
                            double rgb2xyz[3][3]);