2012-05-21 16:58:41 +00:00
|
|
|
/*
|
2012-06-08 21:48:35 +00:00
|
|
|
* Copyright 2005 Balatoni Denes
|
|
|
|
* Copyright 2006 Loren Merritt
|
2012-05-21 16:58:41 +00:00
|
|
|
*
|
2012-06-08 21:48:35 +00:00
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2012-05-21 16:58:41 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
2012-06-08 21:48:35 +00:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2012-05-21 16:58:41 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-06-08 21:48:35 +00:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2012-05-21 16:58:41 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2013-09-10 06:30:54 +00:00
|
|
|
#include "attributes.h"
|
2012-05-21 16:58:41 +00:00
|
|
|
#include "float_dsp.h"
|
2014-11-14 13:39:45 +00:00
|
|
|
#include "mem.h"
|
2012-05-21 16:58:41 +00:00
|
|
|
|
|
|
|
static void vector_fmul_c(float *dst, const float *src0, const float *src1,
|
|
|
|
int len)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
dst[i] = src0[i] * src1[i];
|
|
|
|
}
|
|
|
|
|
2012-06-08 17:49:56 +00:00
|
|
|
static void vector_fmac_scalar_c(float *dst, const float *src, float mul,
|
|
|
|
int len)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
dst[i] += src[i] * mul;
|
|
|
|
}
|
|
|
|
|
2012-09-22 22:13:57 +00:00
|
|
|
static void vector_fmul_scalar_c(float *dst, const float *src, float mul,
|
|
|
|
int len)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
dst[i] = src[i] * mul;
|
|
|
|
}
|
|
|
|
|
2012-09-24 19:00:53 +00:00
|
|
|
static void vector_dmul_scalar_c(double *dst, const double *src, double mul,
|
|
|
|
int len)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
dst[i] = src[i] * mul;
|
|
|
|
}
|
|
|
|
|
2013-01-07 04:47:30 +00:00
|
|
|
static void vector_fmul_window_c(float *dst, const float *src0,
|
|
|
|
const float *src1, const float *win, int len)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
dst += len;
|
|
|
|
win += len;
|
|
|
|
src0 += len;
|
|
|
|
|
|
|
|
for (i = -len, j = len - 1; i < 0; i++, j--) {
|
|
|
|
float s0 = src0[i];
|
|
|
|
float s1 = src1[j];
|
|
|
|
float wi = win[i];
|
|
|
|
float wj = win[j];
|
|
|
|
dst[i] = s0 * wj - s1 * wi;
|
|
|
|
dst[j] = s0 * wi + s1 * wj;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-20 06:26:58 +00:00
|
|
|
static void vector_fmul_add_c(float *dst, const float *src0, const float *src1,
|
|
|
|
const float *src2, int len){
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
dst[i] = src0[i] * src1[i] + src2[i];
|
|
|
|
}
|
|
|
|
|
2013-01-20 21:20:30 +00:00
|
|
|
static void vector_fmul_reverse_c(float *dst, const float *src0,
|
|
|
|
const float *src1, int len)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
src1 += len-1;
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
dst[i] = src0[i] * src1[-i];
|
|
|
|
}
|
|
|
|
|
2013-01-23 23:49:47 +00:00
|
|
|
static void butterflies_float_c(float *av_restrict v1, float *av_restrict v2,
|
2013-01-20 23:41:14 +00:00
|
|
|
int len)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
float t = v1[i] - v2[i];
|
|
|
|
v1[i] += v2[i];
|
|
|
|
v2[i] = t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-20 23:41:52 +00:00
|
|
|
float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len)
|
|
|
|
{
|
|
|
|
float p = 0.0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
p += v1[i] * v2[i];
|
|
|
|
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2013-04-30 16:31:25 +00:00
|
|
|
av_cold void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
|
2012-05-21 16:58:41 +00:00
|
|
|
{
|
|
|
|
fdsp->vector_fmul = vector_fmul_c;
|
2012-06-08 17:49:56 +00:00
|
|
|
fdsp->vector_fmac_scalar = vector_fmac_scalar_c;
|
2012-09-22 22:13:57 +00:00
|
|
|
fdsp->vector_fmul_scalar = vector_fmul_scalar_c;
|
2012-09-24 19:00:53 +00:00
|
|
|
fdsp->vector_dmul_scalar = vector_dmul_scalar_c;
|
2013-01-07 04:47:30 +00:00
|
|
|
fdsp->vector_fmul_window = vector_fmul_window_c;
|
2013-01-20 06:26:58 +00:00
|
|
|
fdsp->vector_fmul_add = vector_fmul_add_c;
|
2013-01-20 21:20:30 +00:00
|
|
|
fdsp->vector_fmul_reverse = vector_fmul_reverse_c;
|
2013-01-20 23:41:14 +00:00
|
|
|
fdsp->butterflies_float = butterflies_float_c;
|
2013-01-20 23:41:52 +00:00
|
|
|
fdsp->scalarproduct_float = avpriv_scalarproduct_float_c;
|
2012-05-21 16:58:41 +00:00
|
|
|
|
2014-03-20 13:16:25 +00:00
|
|
|
if (ARCH_AARCH64)
|
|
|
|
ff_float_dsp_init_aarch64(fdsp);
|
|
|
|
if (ARCH_ARM)
|
|
|
|
ff_float_dsp_init_arm(fdsp);
|
|
|
|
if (ARCH_PPC)
|
|
|
|
ff_float_dsp_init_ppc(fdsp, bit_exact);
|
|
|
|
if (ARCH_X86)
|
|
|
|
ff_float_dsp_init_x86(fdsp);
|
2014-03-22 17:52:21 +00:00
|
|
|
if (ARCH_MIPS)
|
|
|
|
ff_float_dsp_init_mips(fdsp);
|
2012-05-21 16:58:41 +00:00
|
|
|
}
|
2014-03-03 18:15:35 +00:00
|
|
|
|
2014-11-14 13:39:45 +00:00
|
|
|
av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact)
|
|
|
|
{
|
|
|
|
AVFloatDSPContext *ret = av_mallocz(sizeof(AVFloatDSPContext));
|
|
|
|
if (ret)
|
|
|
|
avpriv_float_dsp_init(ret, bit_exact);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-03 18:15:35 +00:00
|
|
|
#ifdef TEST
|
|
|
|
|
|
|
|
#include <float.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2014-10-10 05:18:14 +00:00
|
|
|
#if HAVE_UNISTD_H
|
|
|
|
#include <unistd.h> /* for getopt */
|
|
|
|
#endif
|
|
|
|
#if !HAVE_GETOPT
|
|
|
|
#include "compat/getopt.c"
|
|
|
|
#endif
|
2014-03-03 18:15:35 +00:00
|
|
|
|
2014-03-19 12:50:38 +00:00
|
|
|
#include "common.h"
|
2014-03-03 18:15:35 +00:00
|
|
|
#include "cpu.h"
|
2014-03-19 12:50:38 +00:00
|
|
|
#include "internal.h"
|
2014-03-03 18:15:35 +00:00
|
|
|
#include "lfg.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "random_seed.h"
|
|
|
|
|
|
|
|
#define LEN 240
|
|
|
|
|
|
|
|
static void fill_float_array(AVLFG *lfg, float *a, int len)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
double bmg[2], stddev = 10.0, mean = 0.0;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i += 2) {
|
|
|
|
av_bmg_get(lfg, bmg);
|
|
|
|
a[i] = bmg[0] * stddev + mean;
|
|
|
|
a[i + 1] = bmg[1] * stddev + mean;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static int compare_floats(const float *a, const float *b, int len,
|
|
|
|
float max_diff)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
if (fabsf(a[i] - b[i]) > max_diff) {
|
|
|
|
av_log(NULL, AV_LOG_ERROR, "%d: %- .12f - %- .12f = % .12g\n",
|
|
|
|
i, a[i], b[i], a[i] - b[i]);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void fill_double_array(AVLFG *lfg, double *a, int len)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
double bmg[2], stddev = 10.0, mean = 0.0;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i += 2) {
|
|
|
|
av_bmg_get(lfg, bmg);
|
|
|
|
a[i] = bmg[0] * stddev + mean;
|
|
|
|
a[i + 1] = bmg[1] * stddev + mean;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int compare_doubles(const double *a, const double *b, int len,
|
|
|
|
double max_diff)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
if (fabs(a[i] - b[i]) > max_diff) {
|
|
|
|
av_log(NULL, AV_LOG_ERROR, "%d: %- .12f - %- .12f = % .12g\n",
|
|
|
|
i, a[i], b[i], a[i] - b[i]);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test_vector_fmul(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
|
|
|
const float *v1, const float *v2)
|
|
|
|
{
|
2014-03-19 12:50:38 +00:00
|
|
|
LOCAL_ALIGNED(32, float, cdst, [LEN]);
|
|
|
|
LOCAL_ALIGNED(32, float, odst, [LEN]);
|
2014-03-03 18:15:35 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
cdsp->vector_fmul(cdst, v1, v2, LEN);
|
|
|
|
fdsp->vector_fmul(odst, v1, v2, LEN);
|
|
|
|
|
|
|
|
if (ret = compare_floats(cdst, odst, LEN, FLT_EPSILON))
|
2014-03-18 23:09:22 +00:00
|
|
|
av_log(NULL, AV_LOG_ERROR, "vector_fmul failed\n");
|
2014-03-03 18:15:35 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ARBITRARY_FMAC_SCALAR_CONST 0.005
|
|
|
|
static int test_vector_fmac_scalar(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
|
|
|
const float *v1, const float *src0, float scale)
|
|
|
|
{
|
2014-03-19 12:50:38 +00:00
|
|
|
LOCAL_ALIGNED(32, float, cdst, [LEN]);
|
|
|
|
LOCAL_ALIGNED(32, float, odst, [LEN]);
|
2014-03-03 18:15:35 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
memcpy(cdst, v1, LEN * sizeof(*v1));
|
|
|
|
memcpy(odst, v1, LEN * sizeof(*v1));
|
|
|
|
|
|
|
|
cdsp->vector_fmac_scalar(cdst, src0, scale, LEN);
|
|
|
|
fdsp->vector_fmac_scalar(odst, src0, scale, LEN);
|
|
|
|
|
|
|
|
if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMAC_SCALAR_CONST))
|
2014-03-18 23:09:22 +00:00
|
|
|
av_log(NULL, AV_LOG_ERROR, "vector_fmac_scalar failed\n");
|
2014-03-03 18:15:35 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test_vector_fmul_scalar(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
|
|
|
const float *v1, float scale)
|
|
|
|
{
|
2014-03-19 12:50:38 +00:00
|
|
|
LOCAL_ALIGNED(32, float, cdst, [LEN]);
|
|
|
|
LOCAL_ALIGNED(32, float, odst, [LEN]);
|
2014-03-03 18:15:35 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
cdsp->vector_fmul_scalar(cdst, v1, scale, LEN);
|
|
|
|
fdsp->vector_fmul_scalar(odst, v1, scale, LEN);
|
|
|
|
|
|
|
|
if (ret = compare_floats(cdst, odst, LEN, FLT_EPSILON))
|
2014-03-18 23:09:22 +00:00
|
|
|
av_log(NULL, AV_LOG_ERROR, "vector_fmul_scalar failed\n");
|
2014-03-03 18:15:35 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test_vector_dmul_scalar(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
|
|
|
const double *v1, double scale)
|
|
|
|
{
|
2014-03-19 12:50:38 +00:00
|
|
|
LOCAL_ALIGNED(32, double, cdst, [LEN]);
|
|
|
|
LOCAL_ALIGNED(32, double, odst, [LEN]);
|
2014-03-03 18:15:35 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
cdsp->vector_dmul_scalar(cdst, v1, scale, LEN);
|
|
|
|
fdsp->vector_dmul_scalar(odst, v1, scale, LEN);
|
|
|
|
|
|
|
|
if (ret = compare_doubles(cdst, odst, LEN, DBL_EPSILON))
|
2014-03-18 23:09:22 +00:00
|
|
|
av_log(NULL, AV_LOG_ERROR, "vector_dmul_scalar failed\n");
|
2014-03-03 18:15:35 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ARBITRARY_FMUL_WINDOW_CONST 0.008
|
|
|
|
static int test_vector_fmul_window(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
|
|
|
const float *v1, const float *v2, const float *v3)
|
|
|
|
{
|
2014-03-19 12:50:38 +00:00
|
|
|
LOCAL_ALIGNED(32, float, cdst, [LEN]);
|
|
|
|
LOCAL_ALIGNED(32, float, odst, [LEN]);
|
2014-03-03 18:15:35 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
cdsp->vector_fmul_window(cdst, v1, v2, v3, LEN / 2);
|
|
|
|
fdsp->vector_fmul_window(odst, v1, v2, v3, LEN / 2);
|
|
|
|
|
|
|
|
if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMUL_WINDOW_CONST))
|
2014-03-18 23:09:22 +00:00
|
|
|
av_log(NULL, AV_LOG_ERROR, "vector_fmul_window failed\n");
|
2014-03-03 18:15:35 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ARBITRARY_FMUL_ADD_CONST 0.005
|
|
|
|
static int test_vector_fmul_add(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
|
|
|
const float *v1, const float *v2, const float *v3)
|
|
|
|
{
|
2014-03-19 12:50:38 +00:00
|
|
|
LOCAL_ALIGNED(32, float, cdst, [LEN]);
|
|
|
|
LOCAL_ALIGNED(32, float, odst, [LEN]);
|
2014-03-03 18:15:35 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
cdsp->vector_fmul_add(cdst, v1, v2, v3, LEN);
|
|
|
|
fdsp->vector_fmul_add(odst, v1, v2, v3, LEN);
|
|
|
|
|
|
|
|
if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMUL_ADD_CONST))
|
2014-03-18 23:09:22 +00:00
|
|
|
av_log(NULL, AV_LOG_ERROR, "vector_fmul_add failed\n");
|
2014-03-03 18:15:35 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test_vector_fmul_reverse(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
|
|
|
const float *v1, const float *v2)
|
|
|
|
{
|
2014-03-19 12:50:38 +00:00
|
|
|
LOCAL_ALIGNED(32, float, cdst, [LEN]);
|
|
|
|
LOCAL_ALIGNED(32, float, odst, [LEN]);
|
2014-03-03 18:15:35 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
cdsp->vector_fmul_reverse(cdst, v1, v2, LEN);
|
|
|
|
fdsp->vector_fmul_reverse(odst, v1, v2, LEN);
|
|
|
|
|
|
|
|
if (ret = compare_floats(cdst, odst, LEN, FLT_EPSILON))
|
2014-03-18 23:09:22 +00:00
|
|
|
av_log(NULL, AV_LOG_ERROR, "vector_fmul_reverse failed\n");
|
2014-03-03 18:15:35 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test_butterflies_float(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
|
|
|
const float *v1, const float *v2)
|
|
|
|
{
|
2014-03-19 12:50:38 +00:00
|
|
|
LOCAL_ALIGNED(32, float, cv1, [LEN]);
|
|
|
|
LOCAL_ALIGNED(32, float, cv2, [LEN]);
|
|
|
|
LOCAL_ALIGNED(32, float, ov1, [LEN]);
|
|
|
|
LOCAL_ALIGNED(32, float, ov2, [LEN]);
|
2014-03-03 18:15:35 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
memcpy(cv1, v1, LEN * sizeof(*v1));
|
|
|
|
memcpy(cv2, v2, LEN * sizeof(*v2));
|
|
|
|
memcpy(ov1, v1, LEN * sizeof(*v1));
|
|
|
|
memcpy(ov2, v2, LEN * sizeof(*v2));
|
|
|
|
|
|
|
|
cdsp->butterflies_float(cv1, cv2, LEN);
|
|
|
|
fdsp->butterflies_float(ov1, ov2, LEN);
|
|
|
|
|
|
|
|
if ((ret = compare_floats(cv1, ov1, LEN, FLT_EPSILON)) ||
|
|
|
|
(ret = compare_floats(cv2, ov2, LEN, FLT_EPSILON)))
|
2014-03-18 23:09:22 +00:00
|
|
|
av_log(NULL, AV_LOG_ERROR, "butterflies_float failed\n");
|
2014-03-03 18:15:35 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ARBITRARY_SCALARPRODUCT_CONST 0.2
|
|
|
|
static int test_scalarproduct_float(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
|
|
|
const float *v1, const float *v2)
|
|
|
|
{
|
|
|
|
float cprod, oprod;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
cprod = cdsp->scalarproduct_float(v1, v2, LEN);
|
|
|
|
oprod = fdsp->scalarproduct_float(v1, v2, LEN);
|
|
|
|
|
|
|
|
if (ret = compare_floats(&cprod, &oprod, 1, ARBITRARY_SCALARPRODUCT_CONST))
|
2014-03-18 23:09:22 +00:00
|
|
|
av_log(NULL, AV_LOG_ERROR, "scalarproduct_float failed\n");
|
2014-03-03 18:15:35 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2014-10-10 05:18:14 +00:00
|
|
|
int ret = 0, seeded = 0;
|
2014-03-03 18:15:35 +00:00
|
|
|
uint32_t seed;
|
|
|
|
AVFloatDSPContext fdsp, cdsp;
|
|
|
|
AVLFG lfg;
|
|
|
|
|
2014-03-19 12:50:38 +00:00
|
|
|
LOCAL_ALIGNED(32, float, src0, [LEN]);
|
|
|
|
LOCAL_ALIGNED(32, float, src1, [LEN]);
|
|
|
|
LOCAL_ALIGNED(32, float, src2, [LEN]);
|
|
|
|
LOCAL_ALIGNED(32, double, dbl_src0, [LEN]);
|
|
|
|
LOCAL_ALIGNED(32, double, dbl_src1, [LEN]);
|
2014-03-03 18:15:35 +00:00
|
|
|
|
2014-10-10 05:18:14 +00:00
|
|
|
for (;;) {
|
|
|
|
int arg = getopt(argc, argv, "s:c:");
|
|
|
|
if (arg == -1)
|
|
|
|
break;
|
|
|
|
switch (arg) {
|
|
|
|
case 's':
|
|
|
|
seed = strtoul(optarg, NULL, 10);
|
|
|
|
seeded = 1;
|
|
|
|
break;
|
|
|
|
case 'c':
|
|
|
|
{
|
|
|
|
int cpuflags = av_get_cpu_flags();
|
|
|
|
|
|
|
|
if (av_parse_cpu_caps(&cpuflags, optarg) < 0)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
av_force_cpu_flags(cpuflags);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!seeded)
|
2014-03-03 18:15:35 +00:00
|
|
|
seed = av_get_random_seed();
|
|
|
|
|
2014-10-10 05:18:14 +00:00
|
|
|
av_log(NULL, AV_LOG_INFO, "float_dsp-test: %s %u\n", seeded ? "seed" : "random seed", seed);
|
2014-03-03 18:15:35 +00:00
|
|
|
|
|
|
|
av_lfg_init(&lfg, seed);
|
|
|
|
|
|
|
|
fill_float_array(&lfg, src0, LEN);
|
|
|
|
fill_float_array(&lfg, src1, LEN);
|
|
|
|
fill_float_array(&lfg, src2, LEN);
|
|
|
|
|
|
|
|
fill_double_array(&lfg, dbl_src0, LEN);
|
|
|
|
fill_double_array(&lfg, dbl_src1, LEN);
|
|
|
|
|
|
|
|
avpriv_float_dsp_init(&fdsp, 1);
|
2015-08-07 12:35:32 +00:00
|
|
|
av_force_cpu_flags(0);
|
2014-03-03 18:15:35 +00:00
|
|
|
avpriv_float_dsp_init(&cdsp, 1);
|
|
|
|
|
|
|
|
if (test_vector_fmul(&fdsp, &cdsp, src0, src1))
|
|
|
|
ret -= 1 << 0;
|
|
|
|
if (test_vector_fmac_scalar(&fdsp, &cdsp, src2, src0, src1[0]))
|
|
|
|
ret -= 1 << 1;
|
|
|
|
if (test_vector_fmul_scalar(&fdsp, &cdsp, src0, src1[0]))
|
|
|
|
ret -= 1 << 2;
|
|
|
|
if (test_vector_fmul_window(&fdsp, &cdsp, src0, src1, src2))
|
|
|
|
ret -= 1 << 3;
|
|
|
|
if (test_vector_fmul_add(&fdsp, &cdsp, src0, src1, src2))
|
|
|
|
ret -= 1 << 4;
|
|
|
|
if (test_vector_fmul_reverse(&fdsp, &cdsp, src0, src1))
|
|
|
|
ret -= 1 << 5;
|
|
|
|
if (test_butterflies_float(&fdsp, &cdsp, src0, src1))
|
|
|
|
ret -= 1 << 6;
|
|
|
|
if (test_scalarproduct_float(&fdsp, &cdsp, src0, src1))
|
|
|
|
ret -= 1 << 7;
|
|
|
|
if (test_vector_dmul_scalar(&fdsp, &cdsp, dbl_src0, dbl_src1[0]))
|
|
|
|
ret -= 1 << 8;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* TEST */
|