FFmpeg
Loading...
Searching...
No Matches
mpegvideoencdsp_altivec.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "config.h"
20
21#include <stdint.h>
22
25
27
29
30#if HAVE_VSX
31static int pix_norm1_altivec(const uint8_t *pix, ptrdiff_t line_size)
32{
33 int i, s = 0;
34 const vector unsigned int zero =
35 (const vector unsigned int) vec_splat_u32(0);
36 vector unsigned int sv = (vector unsigned int) vec_splat_u32(0);
37 vector signed int sum;
38
39 for (i = 0; i < 16; i++) {
40 /* Read the potentially unaligned pixels. */
41 //vector unsigned char pixl = vec_ld(0, pix);
42 //vector unsigned char pixr = vec_ld(15, pix);
43 //vector unsigned char pixv = vec_perm(pixl, pixr, perm);
44 vector unsigned char pixv = vec_vsx_ld(0, pix);
45
46 /* Square the values, and add them to our sum. */
47 sv = vec_msum(pixv, pixv, sv);
48
49 pix += line_size;
50 }
51 /* Sum up the four partial sums, and put the result into s. */
52 sum = vec_sums((vector signed int) sv, (vector signed int) zero);
53 sum = vec_splat(sum, 3);
54 vec_ste(sum, 0, &s);
55 return s;
56}
57#else
58static int pix_norm1_altivec(const uint8_t *pix, ptrdiff_t line_size)
59{
60 int i, s = 0;
61 const vector unsigned int zero =
62 (const vector unsigned int) vec_splat_u32(0);
63 vector unsigned char perm = vec_lvsl(0, pix);
64 vector unsigned int sv = (vector unsigned int) vec_splat_u32(0);
65 vector signed int sum;
66
67 for (i = 0; i < 16; i++) {
68 /* Read the potentially unaligned pixels. */
69 vector unsigned char pixl = vec_ld(0, pix);
70 vector unsigned char pixr = vec_ld(15, pix);
71 vector unsigned char pixv = vec_perm(pixl, pixr, perm);
72
73 /* Square the values, and add them to our sum. */
74 sv = vec_msum(pixv, pixv, sv);
75
76 pix += line_size;
77 }
78 /* Sum up the four partial sums, and put the result into s. */
79 sum = vec_sums((vector signed int) sv, (vector signed int) zero);
80 sum = vec_splat(sum, 3);
81 vec_ste(sum, 0, &s);
82
83 return s;
84}
85#endif /* HAVE_VSX */
86
87#if HAVE_VSX
88static int pix_sum_altivec(const uint8_t *pix, ptrdiff_t line_size)
89{
90 int i, s;
91 const vector unsigned int zero =
92 (const vector unsigned int) vec_splat_u32(0);
93 vector unsigned int sad = (vector unsigned int) vec_splat_u32(0);
94 vector signed int sumdiffs;
95
96 for (i = 0; i < 16; i++) {
97 /* Read the potentially unaligned 16 pixels into t1. */
98 //vector unsigned char pixl = vec_ld(0, pix);
99 //vector unsigned char pixr = vec_ld(15, pix);
100 //vector unsigned char t1 = vec_perm(pixl, pixr, perm);
101 vector unsigned char t1 = vec_vsx_ld(0, pix);
102
103 /* Add each 4 pixel group together and put 4 results into sad. */
104 sad = vec_sum4s(t1, sad);
105
106 pix += line_size;
107 }
108
109 /* Sum up the four partial sums, and put the result into s. */
110 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
111 sumdiffs = vec_splat(sumdiffs, 3);
112 vec_ste(sumdiffs, 0, &s);
113 return s;
114}
115#else
116static int pix_sum_altivec(const uint8_t *pix, ptrdiff_t line_size)
117{
118 int i, s;
119 const vector unsigned int zero =
120 (const vector unsigned int) vec_splat_u32(0);
121 vector unsigned char perm = vec_lvsl(0, pix);
122 vector unsigned int sad = (vector unsigned int) vec_splat_u32(0);
123 vector signed int sumdiffs;
124
125 for (i = 0; i < 16; i++) {
126 /* Read the potentially unaligned 16 pixels into t1. */
127 vector unsigned char pixl = vec_ld(0, pix);
128 vector unsigned char pixr = vec_ld(15, pix);
129 vector unsigned char t1 = vec_perm(pixl, pixr, perm);
130
131 /* Add each 4 pixel group together and put 4 results into sad. */
132 sad = vec_sum4s(t1, sad);
133
134 pix += line_size;
135 }
136
137 /* Sum up the four partial sums, and put the result into s. */
138 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
139 sumdiffs = vec_splat(sumdiffs, 3);
140 vec_ste(sumdiffs, 0, &s);
141
142 return s;
143}
144
145#endif /* HAVE_VSX */
146
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
perm
Definition f_perms.c:75
static int zero(InterplayACMContext *s, unsigned ind, unsigned col)
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
static int pix_sum_altivec(const uint8_t *pix, ptrdiff_t line_size)
av_cold void ff_mpegvideoencdsp_init_altivec(MpegvideoEncDSPContext *c, AVCodecContext *avctx)
static int pix_norm1_altivec(const uint8_t *pix, ptrdiff_t line_size)
enum AVPixelFormat pix
Definition ohcodec.c:55
main external API structure.
Definition avcodec.h:443
Contains misc utility macros and inline functions.
static double c[64]