mirror of
https://github.com/librempeg/librempeg
synced 2024-11-22 00:51:37 +00:00
lavu/float_dsp: add double-precision scalar product
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. Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
parent
e5ae4e49b4
commit
a8304ef327
@ -139,6 +139,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;
|
||||
}
|
||||
|
||||
av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact)
|
||||
{
|
||||
AVFloatDSPContext *fdsp = av_mallocz(sizeof(AVFloatDSPContext));
|
||||
@ -157,6 +168,7 @@ av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact)
|
||||
fdsp->vector_fmul_reverse = vector_fmul_reverse_c;
|
||||
fdsp->butterflies_float = butterflies_float_c;
|
||||
fdsp->scalarproduct_float = avpriv_scalarproduct_float_c;
|
||||
fdsp->scalarproduct_double = ff_scalarproduct_double_c;
|
||||
|
||||
#if ARCH_AARCH64
|
||||
ff_float_dsp_init_aarch64(fdsp);
|
||||
|
@ -19,6 +19,8 @@
|
||||
#ifndef AVUTIL_FLOAT_DSP_H
|
||||
#define AVUTIL_FLOAT_DSP_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct AVFloatDSPContext {
|
||||
/**
|
||||
* Calculate the entry wise product of two vectors of floats and store the result in
|
||||
@ -177,11 +179,8 @@ typedef struct AVFloatDSPContext {
|
||||
* a vector of doubles.
|
||||
*
|
||||
* @param dst output vector
|
||||
* constraints: 32-byte aligned
|
||||
* @param src0 first input vector
|
||||
* constraints: 32-byte aligned
|
||||
* @param src1 second input vector
|
||||
* constraints: 32-byte aligned
|
||||
* @param len number of elements in the input
|
||||
* constraints: multiple of 16
|
||||
*/
|
||||
@ -203,12 +202,28 @@ typedef struct AVFloatDSPContext {
|
||||
* @param len number of elements in the input
|
||||
* constraints: multiple of 16
|
||||
*/
|
||||
|
||||
void (*vector_dmul_add)(double *dst, const double *src0, const double *src1,
|
||||
const double *src2, int len);
|
||||
|
||||
/**
|
||||
* Calculate the scalar product of two vectors of doubles.
|
||||
*
|
||||
* @param v1 first vector
|
||||
* constraints: 32-byte aligned
|
||||
* @param v2 second vector
|
||||
* constraints: 32-byte aligned
|
||||
* @param len length of vectors
|
||||
* constraints: 32-byte aligned
|
||||
*
|
||||
* @return inner product of the vectors
|
||||
*/
|
||||
double (*scalarproduct_double)(const double *v1, const double *v2,
|
||||
size_t len);
|
||||
} AVFloatDSPContext;
|
||||
|
||||
/**
|
||||
* Return the scalar product of two vectors.
|
||||
* Return the scalar product of two vectors of floats.
|
||||
*
|
||||
* @param v1 first input vector
|
||||
* @param v2 first input vector
|
||||
@ -218,6 +233,18 @@ typedef struct AVFloatDSPContext {
|
||||
*/
|
||||
float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len);
|
||||
|
||||
/**
|
||||
* Return the scalar product of two vectors of doubles.
|
||||
*
|
||||
* @param v1 first input vector
|
||||
* @param v2 first input vector
|
||||
* @param len number of elements
|
||||
*
|
||||
* @return inner product of the vectors
|
||||
*/
|
||||
double ff_scalarproduct_double_c(const double *v1, const double *v2,
|
||||
size_t len);
|
||||
|
||||
void ff_float_dsp_init_aarch64(AVFloatDSPContext *fdsp);
|
||||
void ff_float_dsp_init_arm(AVFloatDSPContext *fdsp);
|
||||
void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int strict);
|
||||
|
Loading…
Reference in New Issue
Block a user