[FFmpeg-devel] [PATCHv2 1/5] lavu/float_dsp: add double-precision scalar product

Rémi Denis-Courmont remi at remlab.net
Thu May 30 22:31:49 EEST 2024


Le torstaina 30. toukokuuta 2024, 22.06.55 EEST Rémi Denis-Courmont a écrit :
> The function pointer is appended to the structure for backward binary
> compatibility. Fortunately, this is allocated by libavutil, not by the
> user, so increasing the structure size is safe.
> ---
>  libavutil/float_dsp.c | 12 ++++++++++++
>  libavutil/float_dsp.h | 31 ++++++++++++++++++++++++++++++-
>  2 files changed, 42 insertions(+), 1 deletion(-)
> 
> diff --git a/libavutil/float_dsp.c b/libavutil/float_dsp.c
> index e9fb023466..08bbc85e3e 100644
> --- a/libavutil/float_dsp.c
> +++ b/libavutil/float_dsp.c
> @@ -132,6 +132,17 @@ float avpriv_scalarproduct_float_c(const float *v1,
> const float *v2, int len) return p;
>  }
> 
> +double ff_scalarproduct_double_c(const double *v1, const double *v2,
> +                                 size_t len)
> +{
> +    double p = 0.0;
> +
> +    for (size_t i = 0; i < len; i++)
> +        p += v1[i] * v2[i];
> +
> +    return p;
> +}
> +

If somebody wants to write x86 assembly, they can probably borrow most of the 
code for evaluate_lls. It is a double precision scalar product with a little 
bit of extra fluff in the prologue.

-- 
レミ・デニ-クールモン
http://www.remlab.net/





More information about the ffmpeg-devel mailing list