[FFmpeg-devel] [PATCH] lavfi/colorspace: Add namespace prefix to global functions
Song, Ruiling
ruiling.song at intel.com
Tue Jun 26 03:50:12 EEST 2018
> -----Original Message-----
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces at ffmpeg.org] On Behalf Of
> Mark Thompson
> Sent: Tuesday, June 26, 2018 5:02 AM
> To: ffmpeg-devel at ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH] lavfi/colorspace: Add namespace prefix to
> global functions
>
> ---
> On 25/06/18 02:34, Song, Ruiling wrote:
> >> -----Original Message-----
> >> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces at ffmpeg.org] On Behalf
> Of
> >> Mark Thompson
> >> Sent: Monday, June 25, 2018 2:26 AM
> >> To: ffmpeg-devel at ffmpeg.org
> >> Subject: [FFmpeg-devel] [PATCH 1/5] lavfi/colorspace: Add namespace prefix
> to
> >> global functions
> >>
> >> ---
> >> libavfilter/colorspace.c | 13 +++++++------
> >> libavfilter/colorspace.h | 10 ++++++----
> >> libavfilter/vf_colorspace.c | 22 +++++++++++-----------
> >> libavfilter/vf_tonemap_opencl.c | 8 ++++----
> >> 4 files changed, 28 insertions(+), 25 deletions(-)
> >>
> >> ...
> >> --- a/libavfilter/colorspace.h
> >> +++ b/libavfilter/colorspace.h
> >> @@ -34,8 +34,10 @@ struct WhitepointCoefficients {
> >> double xw, yw;
> >> };
> >>
> >> -void invert_matrix3x3(const double in[3][3], double out[3][3]);
> >> -void mul3x3(double dst[3][3], const double src1[3][3], const double
> src2[3][3]);
> >> -void fill_rgb2xyz_table(const struct PrimaryCoefficients *coeffs,
> >> - const struct WhitepointCoefficients *wp, double rgb2xyz[3][3]);
> >> +void ff_invert_matrix3x3(const double in[3][3], double out[3][3]);
> >> +void ff_mul3x3(double dst[3][3],
> >> + const double src1[3][3], const double src2[3][3]);
> >> +void ff_fill_rgb2xyz_table(const struct PrimaryCoefficients *coeffs,
> >> + const struct WhitepointCoefficients *wp,
> >> + double rgb2xyz[3][3]);
> > I am basically ok with the patch. But I am not sure whether below function
> names would be more applicable as now they are under 'ff_' prefix.
> > ff_matrix_inverse_3x3()
> > ff_matrix_mul_3x3()
>
> Yeah, those names would probably be better.
>
> How about this?
This version LGTM!
Ruiling
>
> - Mark
>
>
> libavfilter/colorspace.c | 13 +++++++------
> libavfilter/colorspace.h | 10 ++++++----
> libavfilter/vf_colorspace.c | 22 +++++++++++-----------
> libavfilter/vf_tonemap_opencl.c | 8 ++++----
> 4 files changed, 28 insertions(+), 25 deletions(-)
>
> diff --git a/libavfilter/colorspace.c b/libavfilter/colorspace.c
> index 7fd7bdf0d9..45da1dd124 100644
> --- a/libavfilter/colorspace.c
> +++ b/libavfilter/colorspace.c
> @@ -20,7 +20,7 @@
> #include "colorspace.h"
>
>
> -void invert_matrix3x3(const double in[3][3], double out[3][3])
> +void ff_matrix_invert_3x3(const double in[3][3], double out[3][3])
> {
> double m00 = in[0][0], m01 = in[0][1], m02 = in[0][2],
> m10 = in[1][0], m11 = in[1][1], m12 = in[1][2],
> @@ -47,7 +47,8 @@ void invert_matrix3x3(const double in[3][3], double
> out[3][3])
> }
> }
>
> -void mul3x3(double dst[3][3], const double src1[3][3], const double src2[3][3])
> +void ff_matrix_mul_3x3(double dst[3][3],
> + const double src1[3][3], const double src2[3][3])
> {
> int m, n;
>
> @@ -60,9 +61,9 @@ void mul3x3(double dst[3][3], const double src1[3][3],
> const double src2[3][3])
> /*
> * see e.g.
> http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
> */
> -void fill_rgb2xyz_table(const struct PrimaryCoefficients *coeffs,
> - const struct WhitepointCoefficients *wp,
> - double rgb2xyz[3][3])
> +void ff_fill_rgb2xyz_table(const struct PrimaryCoefficients *coeffs,
> + const struct WhitepointCoefficients *wp,
> + double rgb2xyz[3][3])
> {
> double i[3][3], sr, sg, sb, zw;
>
> @@ -73,7 +74,7 @@ void fill_rgb2xyz_table(const struct PrimaryCoefficients
> *coeffs,
> rgb2xyz[2][0] = (1.0 - coeffs->xr - coeffs->yr) / coeffs->yr;
> rgb2xyz[2][1] = (1.0 - coeffs->xg - coeffs->yg) / coeffs->yg;
> rgb2xyz[2][2] = (1.0 - coeffs->xb - coeffs->yb) / coeffs->yb;
> - invert_matrix3x3(rgb2xyz, i);
> + ff_matrix_invert_3x3(rgb2xyz, i);
> zw = 1.0 - wp->xw - wp->yw;
> sr = i[0][0] * wp->xw + i[0][1] * wp->yw + i[0][2] * zw;
> sg = i[1][0] * wp->xw + i[1][1] * wp->yw + i[1][2] * zw;
> diff --git a/libavfilter/colorspace.h b/libavfilter/colorspace.h
> index d330917bd3..9d45ee2366 100644
> --- a/libavfilter/colorspace.h
> +++ b/libavfilter/colorspace.h
> @@ -34,8 +34,10 @@ struct WhitepointCoefficients {
> double xw, yw;
> };
>
> -void invert_matrix3x3(const double in[3][3], double out[3][3]);
> -void mul3x3(double dst[3][3], const double src1[3][3], const double src2[3][3]);
> -void fill_rgb2xyz_table(const struct PrimaryCoefficients *coeffs,
> - const struct WhitepointCoefficients *wp, double rgb2xyz[3][3]);
> +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_fill_rgb2xyz_table(const struct PrimaryCoefficients *coeffs,
> + const struct WhitepointCoefficients *wp,
> + double rgb2xyz[3][3]);
> #endif
> diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
> index b593215daa..56621d15e2 100644
> --- a/libavfilter/vf_colorspace.c
> +++ b/libavfilter/vf_colorspace.c
> @@ -371,7 +371,7 @@ static void fill_whitepoint_conv_table(double out[3][3],
> enum WhitepointAdaptati
> double mai[3][3], fac[3][3], tmp[3][3];
> double rs, gs, bs, rd, gd, bd;
>
> - invert_matrix3x3(ma, mai);
> + ff_matrix_invert_3x3(ma, mai);
> rs = ma[0][0] * wp_src->xw + ma[0][1] * wp_src->yw + ma[0][2] * zw_src;
> gs = ma[1][0] * wp_src->xw + ma[1][1] * wp_src->yw + ma[1][2] * zw_src;
> bs = ma[2][0] * wp_src->xw + ma[2][1] * wp_src->yw + ma[2][2] * zw_src;
> @@ -382,8 +382,8 @@ static void fill_whitepoint_conv_table(double out[3][3],
> enum WhitepointAdaptati
> fac[1][1] = gd / gs;
> fac[2][2] = bd / bs;
> fac[0][1] = fac[0][2] = fac[1][0] = fac[1][2] = fac[2][0] = fac[2][1] = 0.0;
> - mul3x3(tmp, ma, fac);
> - mul3x3(out, tmp, mai);
> + ff_matrix_mul_3x3(tmp, ma, fac);
> + ff_matrix_mul_3x3(out, tmp, mai);
> }
>
> static void apply_lut(int16_t *buf[3], ptrdiff_t stride,
> @@ -588,19 +588,19 @@ static int create_filtergraph(AVFilterContext *ctx,
>
> wp_out = &whitepoint_coefficients[s->out_primaries->wp];
> wp_in = &whitepoint_coefficients[s->in_primaries->wp];
> - fill_rgb2xyz_table(&s->out_primaries->coeff, wp_out, rgb2xyz);
> - invert_matrix3x3(rgb2xyz, xyz2rgb);
> - fill_rgb2xyz_table(&s->in_primaries->coeff, wp_in, rgb2xyz);
> + ff_fill_rgb2xyz_table(&s->out_primaries->coeff, wp_out, rgb2xyz);
> + ff_matrix_invert_3x3(rgb2xyz, xyz2rgb);
> + ff_fill_rgb2xyz_table(&s->in_primaries->coeff, wp_in, rgb2xyz);
> if (s->out_primaries->wp != s->in_primaries->wp &&
> s->wp_adapt != WP_ADAPT_IDENTITY) {
> double wpconv[3][3], tmp[3][3];
>
> fill_whitepoint_conv_table(wpconv, s->wp_adapt, s->in_primaries->wp,
> s->out_primaries->wp);
> - mul3x3(tmp, rgb2xyz, wpconv);
> - mul3x3(rgb2rgb, tmp, xyz2rgb);
> + ff_matrix_mul_3x3(tmp, rgb2xyz, wpconv);
> + ff_matrix_mul_3x3(rgb2rgb, tmp, xyz2rgb);
> } else {
> - mul3x3(rgb2rgb, rgb2xyz, xyz2rgb);
> + ff_matrix_mul_3x3(rgb2rgb, rgb2xyz, xyz2rgb);
> }
> for (m = 0; m < 3; m++)
> for (n = 0; n < 3; n++) {
> @@ -725,7 +725,7 @@ static int create_filtergraph(AVFilterContext *ctx,
> for (n = 0; n < 8; n++)
> s->yuv_offset[0][n] = off;
> fill_rgb2yuv_table(s->in_lumacoef, rgb2yuv);
> - invert_matrix3x3(rgb2yuv, yuv2rgb);
> + ff_matrix_invert_3x3(rgb2yuv, yuv2rgb);
> bits = 1 << (in_desc->comp[0].depth - 1);
> for (n = 0; n < 3; n++) {
> for (in_rng = s->in_y_rng, m = 0; m < 3; m++, in_rng = s->in_uv_rng) {
> @@ -781,7 +781,7 @@ static int create_filtergraph(AVFilterContext *ctx,
> double yuv2yuv[3][3];
> int in_rng, out_rng;
>
> - mul3x3(yuv2yuv, yuv2rgb, rgb2yuv);
> + ff_matrix_mul_3x3(yuv2yuv, yuv2rgb, rgb2yuv);
> for (out_rng = s->out_y_rng, m = 0; m < 3; m++, out_rng = s->out_uv_rng)
> {
> for (in_rng = s->in_y_rng, n = 0; n < 3; n++, in_rng = s->in_uv_rng) {
> s->yuv2yuv_coeffs[m][n][0] =
> diff --git a/libavfilter/vf_tonemap_opencl.c b/libavfilter/vf_tonemap_opencl.c
> index 6063456d28..36c7fbe774 100644
> --- a/libavfilter/vf_tonemap_opencl.c
> +++ b/libavfilter/vf_tonemap_opencl.c
> @@ -124,10 +124,10 @@ static void get_rgb2rgb_matrix(enum
> AVColorPrimaries in, enum AVColorPrimaries o
> double rgb2rgb[3][3]) {
> double rgb2xyz[3][3], xyz2rgb[3][3];
>
> - fill_rgb2xyz_table(&primaries_table[out], &whitepoint_table[out], rgb2xyz);
> - invert_matrix3x3(rgb2xyz, xyz2rgb);
> - fill_rgb2xyz_table(&primaries_table[in], &whitepoint_table[in], rgb2xyz);
> - mul3x3(rgb2rgb, rgb2xyz, xyz2rgb);
> + ff_fill_rgb2xyz_table(&primaries_table[out], &whitepoint_table[out],
> rgb2xyz);
> + ff_matrix_invert_3x3(rgb2xyz, xyz2rgb);
> + ff_fill_rgb2xyz_table(&primaries_table[in], &whitepoint_table[in], rgb2xyz);
> + ff_matrix_mul_3x3(rgb2rgb, rgb2xyz, xyz2rgb);
> }
>
> #define OPENCL_SOURCE_NB 3
> --
> 2.18.0
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
More information about the ffmpeg-devel
mailing list