2011-01-30 17:06:46 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2006 Luca Barbato <lu_zero@gentoo.org>
|
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* This file is part of Libav.
|
2011-01-30 17:06:46 +02:00
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* Libav is free software; you can redistribute it and/or
|
2011-01-30 17:06:46 +02: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.
|
|
|
|
*
|
2011-03-18 19:35:10 +02:00
|
|
|
* Libav is distributed in the hope that it will be useful,
|
2011-01-30 17:06:46 +02: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
|
2011-03-18 19:35:10 +02:00
|
|
|
* License along with Libav; if not, write to the Free Software
|
2011-01-30 17:06:46 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2013-04-14 15:47:30 +03:00
|
|
|
#include "config.h"
|
2013-02-01 12:31:59 +03:00
|
|
|
#include "libavutil/attributes.h"
|
2013-08-23 19:48:17 +03:00
|
|
|
#include "libavutil/cpu.h"
|
2012-08-06 16:49:32 +03:00
|
|
|
#include "libavutil/mem.h"
|
2014-06-05 18:46:47 +03:00
|
|
|
#include "libavutil/ppc/cpu.h"
|
2013-04-14 15:47:30 +03:00
|
|
|
#include "libavutil/ppc/util_altivec.h"
|
|
|
|
#include "libavcodec/fmtconvert.h"
|
2011-01-30 17:06:46 +02:00
|
|
|
|
2013-04-14 15:47:30 +03:00
|
|
|
#if HAVE_ALTIVEC
|
|
|
|
|
2012-12-28 00:33:51 +03:00
|
|
|
static void int32_to_float_fmul_scalar_altivec(float *dst, const int32_t *src,
|
2012-07-22 21:37:24 +03:00
|
|
|
float mul, int len)
|
2011-01-30 17:06:46 +02:00
|
|
|
{
|
|
|
|
union {
|
|
|
|
vector float v;
|
|
|
|
float s[4];
|
|
|
|
} mul_u;
|
|
|
|
int i;
|
|
|
|
vector float src1, src2, dst1, dst2, mul_v, zero;
|
|
|
|
|
|
|
|
zero = (vector float)vec_splat_u32(0);
|
|
|
|
mul_u.s[0] = mul;
|
|
|
|
mul_v = vec_splat(mul_u.v, 0);
|
|
|
|
|
2012-07-22 21:37:24 +03:00
|
|
|
for (i = 0; i < len; i += 8) {
|
2011-01-30 17:06:46 +02:00
|
|
|
src1 = vec_ctf(vec_ld(0, src+i), 0);
|
|
|
|
src2 = vec_ctf(vec_ld(16, src+i), 0);
|
|
|
|
dst1 = vec_madd(src1, mul_v, zero);
|
|
|
|
dst2 = vec_madd(src2, mul_v, zero);
|
|
|
|
vec_st(dst1, 0, dst+i);
|
|
|
|
vec_st(dst2, 16, dst+i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-14 15:47:30 +03:00
|
|
|
#endif /* HAVE_ALTIVEC */
|
|
|
|
|
|
|
|
av_cold void ff_fmt_convert_init_ppc(FmtConvertContext *c,
|
|
|
|
AVCodecContext *avctx)
|
2011-01-30 17:06:46 +02:00
|
|
|
{
|
2013-04-14 15:47:30 +03:00
|
|
|
#if HAVE_ALTIVEC
|
2014-06-05 18:46:47 +03:00
|
|
|
if (!PPC_ALTIVEC(av_get_cpu_flags()))
|
2013-08-23 19:48:17 +03:00
|
|
|
return;
|
|
|
|
|
2011-01-30 17:06:46 +02:00
|
|
|
c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_altivec;
|
2013-04-14 15:47:30 +03:00
|
|
|
#endif /* HAVE_ALTIVEC */
|
2011-01-30 17:06:46 +02:00
|
|
|
}
|