summaryrefslogtreecommitdiff
path: root/libavcodec/ppc
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2013-12-23 19:48:43 +0100
committerDiego Biurrun <diego@biurrun.de>2014-05-29 06:41:15 -0700
commit65d5d5865845f057cc6530a8d0f34db952d9009c (patch)
tree87f2ff44f58d550ae4076e741a4c6b3564d98bc0 /libavcodec/ppc
parent2ea2612df508abdd1f97c6a6ef56275a52c5c41e (diff)
dsputil: Move SVQ1 encoding specific bits into svq1enc
Diffstat (limited to 'libavcodec/ppc')
-rw-r--r--libavcodec/ppc/Makefile1
-rw-r--r--libavcodec/ppc/int_altivec.c44
-rw-r--r--libavcodec/ppc/svq1enc_altivec.c80
3 files changed, 81 insertions, 44 deletions
diff --git a/libavcodec/ppc/Makefile b/libavcodec/ppc/Makefile
index 07806661f4..ec0674c817 100644
--- a/libavcodec/ppc/Makefile
+++ b/libavcodec/ppc/Makefile
@@ -12,6 +12,7 @@ OBJS-$(CONFIG_MPEGVIDEO) += ppc/mpegvideo_altivec.o
OBJS-$(CONFIG_VIDEODSP) += ppc/videodsp_ppc.o
OBJS-$(CONFIG_VP3DSP) += ppc/vp3dsp_altivec.o
+OBJS-$(CONFIG_SVQ1_ENCODER) += ppc/svq1enc_altivec.o
OBJS-$(CONFIG_VC1_DECODER) += ppc/vc1dsp_altivec.o
OBJS-$(CONFIG_VORBIS_DECODER) += ppc/vorbisdsp_altivec.o
OBJS-$(CONFIG_VP7_DECODER) += ppc/vp8dsp_altivec.o
diff --git a/libavcodec/ppc/int_altivec.c b/libavcodec/ppc/int_altivec.c
index cd1984a54c..fa3cb66095 100644
--- a/libavcodec/ppc/int_altivec.c
+++ b/libavcodec/ppc/int_altivec.c
@@ -34,48 +34,6 @@
#include "libavcodec/dsputil.h"
#include "dsputil_altivec.h"
-static int ssd_int8_vs_int16_altivec(const int8_t *pix1, const int16_t *pix2,
- int size)
-{
- int i, size16 = size >> 4;
- vector signed char vpix1;
- vector signed short vpix2, vdiff, vpix1l, vpix1h;
- union {
- vector signed int vscore;
- int32_t score[4];
- } u = { .vscore = vec_splat_s32(0) };
-
-// XXX lazy way, fix it later
-
- while (size16) {
- // score += (pix1[i] - pix2[i]) * (pix1[i] - pix2[i]);
- // load pix1 and the first batch of pix2
-
- vpix1 = vec_unaligned_load(pix1);
- vpix2 = vec_unaligned_load(pix2);
- pix2 += 8;
- // unpack
- vpix1h = vec_unpackh(vpix1);
- vdiff = vec_sub(vpix1h, vpix2);
- vpix1l = vec_unpackl(vpix1);
- // load another batch from pix2
- vpix2 = vec_unaligned_load(pix2);
- u.vscore = vec_msum(vdiff, vdiff, u.vscore);
- vdiff = vec_sub(vpix1l, vpix2);
- u.vscore = vec_msum(vdiff, vdiff, u.vscore);
- pix1 += 16;
- pix2 += 8;
- size16--;
- }
- u.vscore = vec_sums(u.vscore, vec_splat_s32(0));
-
- size %= 16;
- for (i = 0; i < size; i++)
- u.score[3] += (pix1[i] - pix2[i]) * (pix1[i] - pix2[i]);
-
- return u.score[3];
-}
-
static int32_t scalarproduct_int16_altivec(const int16_t *v1, const int16_t *v2,
int order)
{
@@ -140,8 +98,6 @@ static int32_t scalarproduct_and_madd_int16_altivec(int16_t *v1,
av_cold void ff_int_init_altivec(DSPContext *c, AVCodecContext *avctx)
{
- c->ssd_int8_vs_int16 = ssd_int8_vs_int16_altivec;
-
c->scalarproduct_int16 = scalarproduct_int16_altivec;
c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_altivec;
diff --git a/libavcodec/ppc/svq1enc_altivec.c b/libavcodec/ppc/svq1enc_altivec.c
new file mode 100644
index 0000000000..005239f430
--- /dev/null
+++ b/libavcodec/ppc/svq1enc_altivec.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2007 Luca Barbato <lu_zero@gentoo.org>
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * 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.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * 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
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "config.h"
+#if HAVE_ALTIVEC_H
+#include <altivec.h>
+#endif
+
+#include "libavutil/attributes.h"
+#include "libavutil/ppc/types_altivec.h"
+#include "libavutil/ppc/util_altivec.h"
+#include "libavcodec/svq1enc.h"
+
+#if HAVE_ALTIVEC
+static int ssd_int8_vs_int16_altivec(const int8_t *pix1, const int16_t *pix2,
+ int size)
+{
+ int i, size16 = size >> 4;
+ vector signed char vpix1;
+ vector signed short vpix2, vdiff, vpix1l, vpix1h;
+ union {
+ vector signed int vscore;
+ int32_t score[4];
+ } u = { .vscore = vec_splat_s32(0) };
+
+ while (size16) {
+ // score += (pix1[i] - pix2[i]) * (pix1[i] - pix2[i]);
+ // load pix1 and the first batch of pix2
+
+ vpix1 = vec_unaligned_load(pix1);
+ vpix2 = vec_unaligned_load(pix2);
+ pix2 += 8;
+ // unpack
+ vpix1h = vec_unpackh(vpix1);
+ vdiff = vec_sub(vpix1h, vpix2);
+ vpix1l = vec_unpackl(vpix1);
+ // load another batch from pix2
+ vpix2 = vec_unaligned_load(pix2);
+ u.vscore = vec_msum(vdiff, vdiff, u.vscore);
+ vdiff = vec_sub(vpix1l, vpix2);
+ u.vscore = vec_msum(vdiff, vdiff, u.vscore);
+ pix1 += 16;
+ pix2 += 8;
+ size16--;
+ }
+ u.vscore = vec_sums(u.vscore, vec_splat_s32(0));
+
+ size %= 16;
+ for (i = 0; i < size; i++)
+ u.score[3] += (pix1[i] - pix2[i]) * (pix1[i] - pix2[i]);
+
+ return u.score[3];
+}
+#endif /* HAVE_ALTIVEC */
+
+av_cold void ff_svq1enc_init_ppc(SVQ1EncContext *c)
+{
+#if HAVE_ALTIVEC
+ c->ssd_int8_vs_int16 = ssd_int8_vs_int16_altivec;
+#endif /* HAVE_ALTIVEC */
+}