History

Merge commit '82ee14d2cedd7867920529b408ed6c7ec2f13ff1'

* commit '82ee14d2cedd7867920529b408ed6c7ec2f13ff1': ppc: dsputil: comment formatting and wording/grammar improvements Conflicts: libavcodec/ppc/gmc_altivec.c libavcodec/ppc/idct_altivec.c

Michael Niedermayer committed 12 years ago

Commit 047cf462 parents 75cc29a 82ee14d7 files · +180 −199Browse files

Unified · Split

7 files
  1. libavcodec/ppc/dsputil_altivec.c +114 −119
  2. libavcodec/ppc/dsputil_ppc.c +29 −31
  3. libavcodec/ppc/fdct_altivec.c +3 −4
  4. libavcodec/ppc/fft_altivec.c +6 −6
  5. libavcodec/ppc/gmc_altivec.c +17 −23
  6. libavcodec/ppc/idct_altivec.c +4 −9
  7. libavcodec/ppc/int_altivec.c +7 −7
libavcodec/ppc/dsputil_altivec.c+114−119
@@ -47,27 +47,27 @@ static int sad16_x2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size · 46 unmodified lines
47 sad = (vector unsigned int)vec_splat_u32(0);47 sad = (vector unsigned int)vec_splat_u32(0);
48 for (i = 0; i < h; i++) {48 for (i = 0; i < h; i++) {
49 /* Read unaligned pixels into our vectors. The vectors are as follows:49 /* Read unaligned pixels into our vectors. The vectors are as follows:
50 pix1v: pix1[0]-pix1[15]50 * pix1v: pix1[0] - pix1[15]
51 pix2v: pix2[0]-pix2[15] pix2iv: pix2[1]-pix2[16] */51 * pix2v: pix2[0] - pix2[15] pix2iv: pix2[1] - pix2[16] */
52 pix1v = vec_ld( 0, pix1);52 pix1v = vec_ld( 0, pix1);
53 pix2l = vec_ld( 0, pix2);53 pix2l = vec_ld( 0, pix2);
54 pix2r = vec_ld(16, pix2);54 pix2r = vec_ld(16, pix2);
55 pix2v = vec_perm(pix2l, pix2r, perm1);55 pix2v = vec_perm(pix2l, pix2r, perm1);
56 pix2iv = vec_perm(pix2l, pix2r, perm2);56 pix2iv = vec_perm(pix2l, pix2r, perm2);
57 57
58 /* Calculate the average vector */58 /* Calculate the average vector. */
59 avgv = vec_avg(pix2v, pix2iv);59 avgv = vec_avg(pix2v, pix2iv);
60 60
61 /* Calculate a sum of abs differences vector */61 /* Calculate a sum of abs differences vector. */
62 t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv));62 t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv));
63 63
64 /* Add each 4 pixel group together and put 4 results into sad */64 /* Add each 4 pixel group together and put 4 results into sad. */
65 sad = vec_sum4s(t5, sad);65 sad = vec_sum4s(t5, sad);
66 66
67 pix1 += line_size;67 pix1 += line_size;
68 pix2 += line_size;68 pix2 += line_size;
69 }69 }
70 /* Sum up the four partial sums, and put the result into s */70 /* Sum up the four partial sums, and put the result into s. */
71 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);71 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
72 sumdiffs = vec_splat(sumdiffs, 3);72 sumdiffs = vec_splat(sumdiffs, 3);
73 vec_ste(sumdiffs, 0, &s);73 vec_ste(sumdiffs, 0, &s);
@@ -91,33 +91,33 @@ static int sad16_y2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size · 17 unmodified lines
91 sad = (vector unsigned int)vec_splat_u32(0);91 sad = (vector unsigned int)vec_splat_u32(0);
92 92
93 /* Due to the fact that pix3 = pix2 + line_size, the pix3 of one93 /* Due to the fact that pix3 = pix2 + line_size, the pix3 of one
94 iteration becomes pix2 in the next iteration. We can use this94 * iteration becomes pix2 in the next iteration. We can use this
95 fact to avoid a potentially expensive unaligned read, each95 * fact to avoid a potentially expensive unaligned read, each
96 time around the loop.96 * time around the loop.
97 Read unaligned pixels into our vectors. The vectors are as follows:97 * Read unaligned pixels into our vectors. The vectors are as follows:
98 pix2v: pix2[0]-pix2[15]98 * pix2v: pix2[0] - pix2[15]
99 Split the pixel vectors into shorts */99 * Split the pixel vectors into shorts. */
100 pix2l = vec_ld( 0, pix2);100 pix2l = vec_ld( 0, pix2);
101 pix2r = vec_ld(15, pix2);101 pix2r = vec_ld(15, pix2);
102 pix2v = vec_perm(pix2l, pix2r, perm);102 pix2v = vec_perm(pix2l, pix2r, perm);
103 103
104 for (i = 0; i < h; i++) {104 for (i = 0; i < h; i++) {
105 /* Read unaligned pixels into our vectors. The vectors are as follows:105 /* Read unaligned pixels into our vectors. The vectors are as follows:
106 pix1v: pix1[0]-pix1[15]106 * pix1v: pix1[0] - pix1[15]
107 pix3v: pix3[0]-pix3[15] */107 * pix3v: pix3[0] - pix3[15] */
108 pix1v = vec_ld(0, pix1);108 pix1v = vec_ld(0, pix1);
109 109
110 pix2l = vec_ld( 0, pix3);110 pix2l = vec_ld( 0, pix3);
111 pix2r = vec_ld(15, pix3);111 pix2r = vec_ld(15, pix3);
112 pix3v = vec_perm(pix2l, pix2r, perm);112 pix3v = vec_perm(pix2l, pix2r, perm);
113 113
114 /* Calculate the average vector */114 /* Calculate the average vector. */
115 avgv = vec_avg(pix2v, pix3v);115 avgv = vec_avg(pix2v, pix3v);
116 116
117 /* Calculate a sum of abs differences vector */117 /* Calculate a sum of abs differences vector. */
118 t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv));118 t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv));
119 119
120 /* Add each 4 pixel group together and put 4 results into sad */120 /* Add each 4 pixel group together and put 4 results into sad. */
121 sad = vec_sum4s(t5, sad);121 sad = vec_sum4s(t5, sad);
122 122
123 pix1 += line_size;123 pix1 += line_size;
@@ -126,7 +126,7 @@ static int sad16_y2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size · 2 unmodified lines
126 126
127 }127 }
128 128
129 /* Sum up the four partial sums, and put the result into s */129 /* Sum up the four partial sums, and put the result into s. */
130 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);130 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
131 sumdiffs = vec_splat(sumdiffs, 3);131 sumdiffs = vec_splat(sumdiffs, 3);
132 vec_ste(sumdiffs, 0, &s);132 vec_ste(sumdiffs, 0, &s);
@@ -157,12 +157,12 @@ static int sad16_xy2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_siz · 24 unmodified lines
157 s = 0;157 s = 0;
158 158
159 /* Due to the fact that pix3 = pix2 + line_size, the pix3 of one159 /* Due to the fact that pix3 = pix2 + line_size, the pix3 of one
160 iteration becomes pix2 in the next iteration. We can use this160 * iteration becomes pix2 in the next iteration. We can use this
161 fact to avoid a potentially expensive unaligned read, as well161 * fact to avoid a potentially expensive unaligned read, as well
162 as some splitting, and vector addition each time around the loop.162 * as some splitting, and vector addition each time around the loop.
163 Read unaligned pixels into our vectors. The vectors are as follows:163 * Read unaligned pixels into our vectors. The vectors are as follows:
164 pix2v: pix2[0]-pix2[15] pix2iv: pix2[1]-pix2[16]164 * pix2v: pix2[0] - pix2[15] pix2iv: pix2[1] - pix2[16]
165 Split the pixel vectors into shorts */165 * Split the pixel vectors into shorts. */
166 pix2l = vec_ld( 0, pix2);166 pix2l = vec_ld( 0, pix2);
167 pix2r = vec_ld(16, pix2);167 pix2r = vec_ld(16, pix2);
168 pix2v = vec_perm(pix2l, pix2r, perm1);168 pix2v = vec_perm(pix2l, pix2r, perm1);
@@ -177,8 +177,8 @@ static int sad16_xy2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_siz · 8 unmodified lines
177 177
178 for (i = 0; i < h; i++) {178 for (i = 0; i < h; i++) {
179 /* Read unaligned pixels into our vectors. The vectors are as follows:179 /* Read unaligned pixels into our vectors. The vectors are as follows:
180 pix1v: pix1[0]-pix1[15]180 * pix1v: pix1[0] - pix1[15]
181 pix3v: pix3[0]-pix3[15] pix3iv: pix3[1]-pix3[16] */181 * pix3v: pix3[0] - pix3[15] pix3iv: pix3[1] - pix3[16] */
182 pix1v = vec_ld(0, pix1);182 pix1v = vec_ld(0, pix1);
183 183
184 pix2l = vec_ld( 0, pix3);184 pix2l = vec_ld( 0, pix3);
@@ -187,40 +187,40 @@ static int sad16_xy2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_siz · 2 unmodified lines
187 pix3iv = vec_perm(pix2l, pix2r, perm2);187 pix3iv = vec_perm(pix2l, pix2r, perm2);
188 188
189 /* Note that AltiVec does have vec_avg, but this works on vector pairs189 /* Note that AltiVec does have vec_avg, but this works on vector pairs
190 and rounds up. We could do avg(avg(a,b),avg(c,d)), but the rounding190 * and rounds up. We could do avg(avg(a, b), avg(c, d)), but the
191 would mean that, for example, avg(3,0,0,1) = 2, when it should be 1.191 * rounding would mean that, for example, avg(3, 0, 0, 1) = 2, when
192 Instead, we have to split the pixel vectors into vectors of shorts,192 * it should be 1. Instead, we have to split the pixel vectors into
193 and do the averaging by hand. */193 * vectors of shorts and do the averaging by hand. */
194 194
195 /* Split the pixel vectors into shorts */195 /* Split the pixel vectors into shorts. */
196 pix3hv = (vector unsigned short) vec_mergeh(zero, pix3v);196 pix3hv = (vector unsigned short) vec_mergeh(zero, pix3v);
197 pix3lv = (vector unsigned short) vec_mergel(zero, pix3v);197 pix3lv = (vector unsigned short) vec_mergel(zero, pix3v);
198 pix3ihv = (vector unsigned short) vec_mergeh(zero, pix3iv);198 pix3ihv = (vector unsigned short) vec_mergeh(zero, pix3iv);
199 pix3ilv = (vector unsigned short) vec_mergel(zero, pix3iv);199 pix3ilv = (vector unsigned short) vec_mergel(zero, pix3iv);
200 200
201 /* Do the averaging on them */201 /* Do the averaging on them. */
202 t3 = vec_add(pix3hv, pix3ihv);202 t3 = vec_add(pix3hv, pix3ihv);
203 t4 = vec_add(pix3lv, pix3ilv);203 t4 = vec_add(pix3lv, pix3ilv);
204 204
205 avghv = vec_sr(vec_add(vec_add(t1, t3), two), two);205 avghv = vec_sr(vec_add(vec_add(t1, t3), two), two);
206 avglv = vec_sr(vec_add(vec_add(t2, t4), two), two);206 avglv = vec_sr(vec_add(vec_add(t2, t4), two), two);
207 207
208 /* Pack the shorts back into a result */208 /* Pack the shorts back into a result. */
209 avgv = vec_pack(avghv, avglv);209 avgv = vec_pack(avghv, avglv);
210 210
211 /* Calculate a sum of abs differences vector */211 /* Calculate a sum of abs differences vector. */
212 t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv));212 t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv));
213 213
214 /* Add each 4 pixel group together and put 4 results into sad */214 /* Add each 4 pixel group together and put 4 results into sad. */
215 sad = vec_sum4s(t5, sad);215 sad = vec_sum4s(t5, sad);
216 216
217 pix1 += line_size;217 pix1 += line_size;
218 pix3 += line_size;218 pix3 += line_size;
219 /* Transfer the calculated values for pix3 into pix2 */219 /* Transfer the calculated values for pix3 into pix2. */
220 t1 = t3;220 t1 = t3;
221 t2 = t4;221 t2 = t4;
222 }222 }
223 /* Sum up the four partial sums, and put the result into s */223 /* Sum up the four partial sums, and put the result into s. */
224 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);224 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
225 sumdiffs = vec_splat(sumdiffs, 3);225 sumdiffs = vec_splat(sumdiffs, 3);
226 vec_ste(sumdiffs, 0, &s);226 vec_ste(sumdiffs, 0, &s);
@@ -242,25 +242,25 @@ static int sad16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, i · 15 unmodified lines
242 242
243 243
244 for (i = 0; i < h; i++) {244 for (i = 0; i < h; i++) {
245 /* Read potentially unaligned pixels into t1 and t2 */245 /* Read potentially unaligned pixels into t1 and t2. */
246 vector unsigned char pix2l = vec_ld( 0, pix2);246 vector unsigned char pix2l = vec_ld( 0, pix2);
247 vector unsigned char pix2r = vec_ld(15, pix2);247 vector unsigned char pix2r = vec_ld(15, pix2);
248 t1 = vec_ld(0, pix1);248 t1 = vec_ld(0, pix1);
249 t2 = vec_perm(pix2l, pix2r, perm);249 t2 = vec_perm(pix2l, pix2r, perm);
250 250
251 /* Calculate a sum of abs differences vector */251 /* Calculate a sum of abs differences vector. */
252 t3 = vec_max(t1, t2);252 t3 = vec_max(t1, t2);
253 t4 = vec_min(t1, t2);253 t4 = vec_min(t1, t2);
254 t5 = vec_sub(t3, t4);254 t5 = vec_sub(t3, t4);
255 255
256 /* Add each 4 pixel group together and put 4 results into sad */256 /* Add each 4 pixel group together and put 4 results into sad. */
257 sad = vec_sum4s(t5, sad);257 sad = vec_sum4s(t5, sad);
258 258
259 pix1 += line_size;259 pix1 += line_size;
260 pix2 += line_size;260 pix2 += line_size;
261 }261 }
262 262
263 /* Sum up the four partial sums, and put the result into s */263 /* Sum up the four partial sums, and put the result into s. */
264 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);264 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
265 sumdiffs = vec_splat(sumdiffs, 3);265 sumdiffs = vec_splat(sumdiffs, 3);
266 vec_ste(sumdiffs, 0, &s);266 vec_ste(sumdiffs, 0, &s);
@@ -283,9 +283,9 @@ static int sad8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, in · 16 unmodified lines
283 sad = (vector unsigned int)vec_splat_u32(0);283 sad = (vector unsigned int)vec_splat_u32(0);
284 284
285 for (i = 0; i < h; i++) {285 for (i = 0; i < h; i++) {
286 /* Read potentially unaligned pixels into t1 and t2286 /* Read potentially unaligned pixels into t1 and t2.
287 Since we're reading 16 pixels, and actually only want 8,287 * Since we're reading 16 pixels, and actually only want 8,
288 mask out the last 8 pixels. The 0s don't change the sum. */288 * mask out the last 8 pixels. The 0s don't change the sum. */
289 vector unsigned char pix1l = vec_ld(0, pix1);289 vector unsigned char pix1l = vec_ld(0, pix1);
290 vector unsigned char pix1r = vec_ld(7, pix1);290 vector unsigned char pix1r = vec_ld(7, pix1);
291 vector unsigned char pix2l = vec_ld(0, pix2);291 vector unsigned char pix2l = vec_ld(0, pix2);
@@ -293,19 +293,19 @@ static int sad8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, in · 1 unmodified line
293 t1 = vec_and(vec_perm(pix1l, pix1r, perm1), permclear);293 t1 = vec_and(vec_perm(pix1l, pix1r, perm1), permclear);
294 t2 = vec_and(vec_perm(pix2l, pix2r, perm2), permclear);294 t2 = vec_and(vec_perm(pix2l, pix2r, perm2), permclear);
295 295
296 /* Calculate a sum of abs differences vector */296 /* Calculate a sum of abs differences vector. */
297 t3 = vec_max(t1, t2);297 t3 = vec_max(t1, t2);
298 t4 = vec_min(t1, t2);298 t4 = vec_min(t1, t2);
299 t5 = vec_sub(t3, t4);299 t5 = vec_sub(t3, t4);
300 300
301 /* Add each 4 pixel group together and put 4 results into sad */301 /* Add each 4 pixel group together and put 4 results into sad. */
302 sad = vec_sum4s(t5, sad);302 sad = vec_sum4s(t5, sad);
303 303
304 pix1 += line_size;304 pix1 += line_size;
305 pix2 += line_size;305 pix2 += line_size;
306 }306 }
307 307
308 /* Sum up the four partial sums, and put the result into s */308 /* Sum up the four partial sums, and put the result into s. */
309 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);309 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
310 sumdiffs = vec_splat(sumdiffs, 3);310 sumdiffs = vec_splat(sumdiffs, 3);
311 vec_ste(sumdiffs, 0, &s);311 vec_ste(sumdiffs, 0, &s);
@@ -327,17 +327,17 @@ static int pix_norm1_altivec(uint8_t *pix, int line_size) · 15 unmodified lines
327 327
328 s = 0;328 s = 0;
329 for (i = 0; i < 16; i++) {329 for (i = 0; i < 16; i++) {
330 /* Read in the potentially unaligned pixels */330 /* Read the potentially unaligned pixels. */
331 vector unsigned char pixl = vec_ld( 0, pix);331 vector unsigned char pixl = vec_ld( 0, pix);
332 vector unsigned char pixr = vec_ld(15, pix);332 vector unsigned char pixr = vec_ld(15, pix);
333 pixv = vec_perm(pixl, pixr, perm);333 pixv = vec_perm(pixl, pixr, perm);
334 334
335 /* Square the values, and add them to our sum */335 /* Square the values, and add them to our sum. */
336 sv = vec_msum(pixv, pixv, sv);336 sv = vec_msum(pixv, pixv, sv);
337 337
338 pix += line_size;338 pix += line_size;
339 }339 }
340 /* Sum up the four partial sums, and put the result into s */340 /* Sum up the four partial sums, and put the result into s. */
341 sum = vec_sums((vector signed int) sv, (vector signed int) zero);341 sum = vec_sums((vector signed int) sv, (vector signed int) zero);
342 sum = vec_splat(sum, 3);342 sum = vec_splat(sum, 3);
343 vec_ste(sum, 0, &s);343 vec_ste(sum, 0, &s);
@@ -345,11 +345,8 @@ static int pix_norm1_altivec(uint8_t *pix, int line_size) · 1 unmodified line
345 return s;345 return s;
346}346}
347 347
348/**348/* Sum of Squared Errors for an 8x8 block, AltiVec-enhanced.
349 * Sum of Squared Errors for a 8x8 block.349 * It's the sad8_altivec code above w/ squaring added. */
350 * AltiVec-enhanced.
351 * It's the sad8_altivec code above w/ squaring added.
352 */
353static int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)350static int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
354{351{
355 int i;352 int i;
@@ -365,9 +362,9 @@ static int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, in · 9 unmodified lines
365 sum = (vector unsigned int)vec_splat_u32(0);362 sum = (vector unsigned int)vec_splat_u32(0);
366 363
367 for (i = 0; i < h; i++) {364 for (i = 0; i < h; i++) {
368 /* Read potentially unaligned pixels into t1 and t2365 /* Read potentially unaligned pixels into t1 and t2.
369 Since we're reading 16 pixels, and actually only want 8,366 * Since we're reading 16 pixels, and actually only want 8,
370 mask out the last 8 pixels. The 0s don't change the sum. */367 * mask out the last 8 pixels. The 0s don't change the sum. */
371 vector unsigned char pix1l = vec_ld(0, pix1);368 vector unsigned char pix1l = vec_ld(0, pix1);
372 vector unsigned char pix1r = vec_ld(7, pix1);369 vector unsigned char pix1r = vec_ld(7, pix1);
373 vector unsigned char pix2l = vec_ld(0, pix2);370 vector unsigned char pix2l = vec_ld(0, pix2);
@@ -376,21 +373,21 @@ static int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, in · 2 unmodified lines
376 t2 = vec_and(vec_perm(pix2l, pix2r, perm2), permclear);373 t2 = vec_and(vec_perm(pix2l, pix2r, perm2), permclear);
377 374
378 /* Since we want to use unsigned chars, we can take advantage375 /* Since we want to use unsigned chars, we can take advantage
379 of the fact that abs(a-b)^2 = (a-b)^2. */376 * of the fact that abs(a - b) ^ 2 = (a - b) ^ 2. */
380 377
381 /* Calculate abs differences vector */378 /* Calculate abs differences vector. */
382 t3 = vec_max(t1, t2);379 t3 = vec_max(t1, t2);
383 t4 = vec_min(t1, t2);380 t4 = vec_min(t1, t2);
384 t5 = vec_sub(t3, t4);381 t5 = vec_sub(t3, t4);
385 382
386 /* Square the values and add them to our sum */383 /* Square the values and add them to our sum. */
387 sum = vec_msum(t5, t5, sum);384 sum = vec_msum(t5, t5, sum);
388 385
389 pix1 += line_size;386 pix1 += line_size;
390 pix2 += line_size;387 pix2 += line_size;
391 }388 }
392 389
393 /* Sum up the four partial sums, and put the result into s */390 /* Sum up the four partial sums, and put the result into s. */
394 sumsqr = vec_sums((vector signed int) sum, (vector signed int) zero);391 sumsqr = vec_sums((vector signed int) sum, (vector signed int) zero);
395 sumsqr = vec_splat(sumsqr, 3);392 sumsqr = vec_splat(sumsqr, 3);
396 vec_ste(sumsqr, 0, &s);393 vec_ste(sumsqr, 0, &s);
@@ -398,11 +395,8 @@ static int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, in · 1 unmodified line
398 return s;395 return s;
399}396}
400 397
401/**398/* Sum of Squared Errors for a 16x16 block, AltiVec-enhanced.
402 * Sum of Squared Errors for a 16x16 block.399 * It's the sad16_altivec code above w/ squaring added. */
403 * AltiVec-enhanced.
404 * It's the sad16_altivec code above w/ squaring added.
405 */
406static int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)400static int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
407{401{
408 int i;402 int i;
@@ -416,28 +410,28 @@ static int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, i · 7 unmodified lines
416 sum = (vector unsigned int)vec_splat_u32(0);410 sum = (vector unsigned int)vec_splat_u32(0);
417 411
418 for (i = 0; i < h; i++) {412 for (i = 0; i < h; i++) {
419 /* Read potentially unaligned pixels into t1 and t2 */413 /* Read potentially unaligned pixels into t1 and t2. */
420 vector unsigned char pix2l = vec_ld( 0, pix2);414 vector unsigned char pix2l = vec_ld( 0, pix2);
421 vector unsigned char pix2r = vec_ld(15, pix2);415 vector unsigned char pix2r = vec_ld(15, pix2);
422 t1 = vec_ld(0, pix1);416 t1 = vec_ld(0, pix1);
423 t2 = vec_perm(pix2l, pix2r, perm);417 t2 = vec_perm(pix2l, pix2r, perm);
424 418
425 /* Since we want to use unsigned chars, we can take advantage419 /* Since we want to use unsigned chars, we can take advantage
426 of the fact that abs(a-b)^2 = (a-b)^2. */420 * of the fact that abs(a - b) ^ 2 = (a - b) ^ 2. */
427 421
428 /* Calculate abs differences vector */422 /* Calculate abs differences vector. */
429 t3 = vec_max(t1, t2);423 t3 = vec_max(t1, t2);
430 t4 = vec_min(t1, t2);424 t4 = vec_min(t1, t2);
431 t5 = vec_sub(t3, t4);425 t5 = vec_sub(t3, t4);
432 426
433 /* Square the values and add them to our sum */427 /* Square the values and add them to our sum. */
434 sum = vec_msum(t5, t5, sum);428 sum = vec_msum(t5, t5, sum);
435 429
436 pix1 += line_size;430 pix1 += line_size;
437 pix2 += line_size;431 pix2 += line_size;
438 }432 }
439 433
440 /* Sum up the four partial sums, and put the result into s */434 /* Sum up the four partial sums, and put the result into s. */
441 sumsqr = vec_sums((vector signed int) sum, (vector signed int) zero);435 sumsqr = vec_sums((vector signed int) sum, (vector signed int) zero);
442 sumsqr = vec_splat(sumsqr, 3);436 sumsqr = vec_splat(sumsqr, 3);
443 vec_ste(sumsqr, 0, &s);437 vec_ste(sumsqr, 0, &s);
@@ -459,18 +453,18 @@ static int pix_sum_altivec(uint8_t * pix, int line_size) · 15 unmodified lines
459 sad = (vector unsigned int)vec_splat_u32(0);453 sad = (vector unsigned int)vec_splat_u32(0);
460 454
461 for (i = 0; i < 16; i++) {455 for (i = 0; i < 16; i++) {
462 /* Read the potentially unaligned 16 pixels into t1 */456 /* Read the potentially unaligned 16 pixels into t1. */
463 vector unsigned char pixl = vec_ld( 0, pix);457 vector unsigned char pixl = vec_ld( 0, pix);
464 vector unsigned char pixr = vec_ld(15, pix);458 vector unsigned char pixr = vec_ld(15, pix);
465 t1 = vec_perm(pixl, pixr, perm);459 t1 = vec_perm(pixl, pixr, perm);
466 460
467 /* Add each 4 pixel group together and put 4 results into sad */461 /* Add each 4 pixel group together and put 4 results into sad. */
468 sad = vec_sum4s(t1, sad);462 sad = vec_sum4s(t1, sad);
469 463
470 pix += line_size;464 pix += line_size;
471 }465 }
472 466
473 /* Sum up the four partial sums, and put the result into s */467 /* Sum up the four partial sums, and put the result into s. */
474 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);468 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
475 sumdiffs = vec_splat(sumdiffs, 3);469 sumdiffs = vec_splat(sumdiffs, 3);
476 vec_ste(sumdiffs, 0, &s);470 vec_ste(sumdiffs, 0, &s);
@@ -487,6 +481,9 @@ static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels, i · 10 unmodified lines
487 vector signed short shorts;481 vector signed short shorts;
488 482
489 for (i = 0; i < 8; i++) {483 for (i = 0; i < 8; i++) {
484 /* Read potentially unaligned pixels.
485 * We're reading 16 pixels, and actually only want 8,
486 * but we simply ignore the extras. */
490 // Read potentially unaligned pixels.487 // Read potentially unaligned pixels.
491 // We're reading 16 pixels, and actually only want 8,488 // We're reading 16 pixels, and actually only want 8,
492 // but we simply ignore the extras.489 // but we simply ignore the extras.
@@ -494,10 +491,10 @@ static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels, i · 1 unmodified line
494 vector unsigned char pixr = vec_ld(7, pixels);491 vector unsigned char pixr = vec_ld(7, pixels);
495 bytes = vec_perm(pixl, pixr, perm);492 bytes = vec_perm(pixl, pixr, perm);
496 493
497 // convert the bytes into shorts494 // Convert the bytes into shorts.
498 shorts = (vector signed short)vec_mergeh(zero, bytes);495 shorts = (vector signed short)vec_mergeh(zero, bytes);
499 496
500 // save the data to the block, we assume the block is 16-byte aligned497 // Save the data to the block, we assume the block is 16-byte aligned.
501 vec_st(shorts, i*16, (vector signed short*)block);498 vec_st(shorts, i*16, (vector signed short*)block);
502 499
503 pixels += line_size;500 pixels += line_size;
@@ -515,60 +512,59 @@ static void diff_pixels_altivec(int16_t *restrict block, const uint8_t *s1, · 11 unmodified lines
515 vector signed short shorts1, shorts2;512 vector signed short shorts1, shorts2;
516 513
517 for (i = 0; i < 4; i++) {514 for (i = 0; i < 4; i++) {
518 // Read potentially unaligned pixels515 /* Read potentially unaligned pixels.
519 // We're reading 16 pixels, and actually only want 8,516 * We're reading 16 pixels, and actually only want 8,
520 // but we simply ignore the extras.517 * but we simply ignore the extras. */
521 pixl = vec_ld( 0, s1);518 pixl = vec_ld( 0, s1);
522 pixr = vec_ld(15, s1);519 pixr = vec_ld(15, s1);
523 bytes = vec_perm(pixl, pixr, perm1);520 bytes = vec_perm(pixl, pixr, perm1);
524 521
525 // convert the bytes into shorts522 // Convert the bytes into shorts.
526 shorts1 = (vector signed short)vec_mergeh(zero, bytes);523 shorts1 = (vector signed short)vec_mergeh(zero, bytes);
527 524
528 // Do the same for the second block of pixels525 // Do the same for the second block of pixels.
529 pixl = vec_ld( 0, s2);526 pixl = vec_ld( 0, s2);
530 pixr = vec_ld(15, s2);527 pixr = vec_ld(15, s2);
531 bytes = vec_perm(pixl, pixr, perm2);528 bytes = vec_perm(pixl, pixr, perm2);
532 529
533 // convert the bytes into shorts530 // Convert the bytes into shorts.
534 shorts2 = (vector signed short)vec_mergeh(zero, bytes);531 shorts2 = (vector signed short)vec_mergeh(zero, bytes);
535 532
536 // Do the subtraction533 // Do the subtraction.
537 shorts1 = vec_sub(shorts1, shorts2);534 shorts1 = vec_sub(shorts1, shorts2);
538 535
539 // save the data to the block, we assume the block is 16-byte aligned536 // Save the data to the block, we assume the block is 16-byte aligned.
540 vec_st(shorts1, 0, (vector signed short*)block);537 vec_st(shorts1, 0, (vector signed short*)block);
541 538
542 s1 += stride;539 s1 += stride;
543 s2 += stride;540 s2 += stride;
544 block += 8;541 block += 8;
545 542
543 /* The code below is a copy of the code above...
544 * This is a manual unroll. */
546 545
547 // The code below is a copy of the code above... This is a manual546 /* Read potentially unaligned pixels.
548 // unroll.547 * We're reading 16 pixels, and actually only want 8,
549 548 * but we simply ignore the extras. */
550 // Read potentially unaligned pixels
551 // We're reading 16 pixels, and actually only want 8,
552 // but we simply ignore the extras.
553 pixl = vec_ld( 0, s1);549 pixl = vec_ld( 0, s1);
554 pixr = vec_ld(15, s1);550 pixr = vec_ld(15, s1);
555 bytes = vec_perm(pixl, pixr, perm1);551 bytes = vec_perm(pixl, pixr, perm1);
556 552
557 // convert the bytes into shorts553 // Convert the bytes into shorts.
558 shorts1 = (vector signed short)vec_mergeh(zero, bytes);554 shorts1 = (vector signed short)vec_mergeh(zero, bytes);
559 555
560 // Do the same for the second block of pixels556 // Do the same for the second block of pixels.
561 pixl = vec_ld( 0, s2);557 pixl = vec_ld( 0, s2);
562 pixr = vec_ld(15, s2);558 pixr = vec_ld(15, s2);
563 bytes = vec_perm(pixl, pixr, perm2);559 bytes = vec_perm(pixl, pixr, perm2);
564 560
565 // convert the bytes into shorts561 // Convert the bytes into shorts.
566 shorts2 = (vector signed short)vec_mergeh(zero, bytes);562 shorts2 = (vector signed short)vec_mergeh(zero, bytes);
567 563
568 // Do the subtraction564 // Do the subtraction.
569 shorts1 = vec_sub(shorts1, shorts2);565 shorts1 = vec_sub(shorts1, shorts2);
570 566
571 // save the data to the block, we assume the block is 16-byte aligned567 // Save the data to the block, we assume the block is 16-byte aligned.
572 vec_st(shorts1, 0, (vector signed short*)block);568 vec_st(shorts1, 0, (vector signed short*)block);
573 569
574 s1 += stride;570 s1 += stride;
@@ -595,14 +591,14 @@ static void add_bytes_altivec(uint8_t *dst, uint8_t *src, int w) { · 20 unmodified lines
595 register int i;591 register int i;
596 register vector unsigned char vdst, vsrc;592 register vector unsigned char vdst, vsrc;
597 593
598 /* dst and src are 16 bytes-aligned (guaranteed) */594 /* dst and src are 16 bytes-aligned (guaranteed). */
599 for (i = 0 ; (i + 15) < w ; i+=16) {595 for (i = 0 ; (i + 15) < w ; i+=16) {
600 vdst = vec_ld(i, (unsigned char*)dst);596 vdst = vec_ld(i, (unsigned char*)dst);
601 vsrc = vec_ld(i, (unsigned char*)src);597 vsrc = vec_ld(i, (unsigned char*)src);
602 vdst = vec_add(vsrc, vdst);598 vdst = vec_add(vsrc, vdst);
603 vec_st(vdst, i, (unsigned char*)dst);599 vec_st(vdst, i, (unsigned char*)dst);
604 }600 }
605 /* if w is not a multiple of 16 */601 /* If w is not a multiple of 16. */
606 for (; (i < w) ; i++) {602 for (; (i < w) ; i++) {
607 dst[i] = src[i];603 dst[i] = src[i];
608 }604 }
@@ -643,8 +639,8 @@ static int hadamard8_diff8x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, u · 34 unmodified lines
643 dst1 = vec_ld(stride * i, dst); \639 dst1 = vec_ld(stride * i, dst); \
644 dst2 = vec_ld((stride * i) + 15, dst); \640 dst2 = vec_ld((stride * i) + 15, dst); \
645 dstO = vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \641 dstO = vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \
646 /* promote the unsigned chars to signed shorts */ \642 /* Promote the unsigned chars to signed shorts. */ \
647 /* we're in the 8x8 function, we only care for the first 8 */ \643 /* We're in the 8x8 function, we only care for the first 8. */ \
648 srcV = (vector signed short)vec_mergeh((vector signed char)vzero, \644 srcV = (vector signed short)vec_mergeh((vector signed char)vzero, \
649 (vector signed char)srcO); \645 (vector signed char)srcO); \
650 dstV = (vector signed short)vec_mergeh((vector signed char)vzero, \646 dstV = (vector signed short)vec_mergeh((vector signed char)vzero, \
@@ -713,24 +709,23 @@ static int hadamard8_diff8x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, u · 62 unmodified lines
713}709}
714 710
715/*711/*
71616x8 works with 16 elements; it allows to avoid replicating loads, and712 * 16x8 works with 16 elements; it allows to avoid replicating loads, and
717give the compiler more rooms for scheduling. It's only used from713 * gives the compiler more room for scheduling. It's only used from
718inside hadamard8_diff16_altivec.714 * inside hadamard8_diff16_altivec.
719 715 *
720Unfortunately, it seems gcc-3.3 is a bit dumb, and the compiled code has a LOT716 * Unfortunately, it seems gcc-3.3 is a bit dumb, and the compiled code has
721of spill code, it seems gcc (unlike xlc) cannot keep everything in registers717 * a LOT of spill code, it seems gcc (unlike xlc) cannot keep everything in
722by itself. The following code include hand-made registers allocation. It's not718 * registers by itself. The following code includes hand-made register
723clean, but on a 7450 the resulting code is much faster (best case fall from719 * allocation. It's not clean, but on a 7450 the resulting code is much faster
724700+ cycles to 550).720 * (best case falls from 700+ cycles to 550).
725 721 *
726xlc doesn't add spill code, but it doesn't know how to schedule for the 7450,722 * xlc doesn't add spill code, but it doesn't know how to schedule for the
727and its code isn't much faster than gcc-3.3 on the 7450 (but uses 25% less723 * 7450, and its code isn't much faster than gcc-3.3 on the 7450 (but uses
728instructions...)724 * 25% fewer instructions...)
729 725 *
730On the 970, the hand-made RA is still a win (around 690 vs. around 780), but726 * On the 970, the hand-made RA is still a win (around 690 vs. around 780),
731xlc goes to around 660 on the regular C code...727 * but xlc goes to around 660 on the regular C code...
732*/728 */
733
734static int hadamard8_diff16x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h) {729static int hadamard8_diff16x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h) {
735 int sum;730 int sum;
736 register vector signed short731 register vector signed short
@@ -805,7 +800,7 @@ static int hadamard8_diff16x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, · 68 unmodified lines
805 dst1 = vec_ld(stride * i, dst); \800 dst1 = vec_ld(stride * i, dst); \
806 dst2 = vec_ld((stride * i) + 16, dst); \801 dst2 = vec_ld((stride * i) + 16, dst); \
807 dstO = vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \802 dstO = vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \
808 /* promote the unsigned chars to signed shorts */ \803 /* Promote the unsigned chars to signed shorts. */ \
809 srcV = (vector signed short)vec_mergeh((vector signed char)vzero, \804 srcV = (vector signed short)vec_mergeh((vector signed char)vzero, \
810 (vector signed char)srcO); \805 (vector signed char)srcO); \
811 dstV = (vector signed short)vec_mergeh((vector signed char)vzero, \806 dstV = (vector signed short)vec_mergeh((vector signed char)vzero, \
libavcodec/ppc/dsputil_ppc.c+29−31
@@ -32,24 +32,23 @@ · 31 unmodified lines
32 32
33/* ***** WARNING ***** WARNING ***** WARNING ***** */33/* ***** WARNING ***** WARNING ***** WARNING ***** */
34/*34/*
35clear_blocks_dcbz32_ppc will not work properly on PowerPC processors with a35 * clear_blocks_dcbz32_ppc will not work properly on PowerPC processors with
36cache line size not equal to 32 bytes.36 * a cache line size not equal to 32 bytes. Fortunately all processors used
37Fortunately all processor used by Apple up to at least the 7450 (aka second37 * by Apple up to at least the 7450 (AKA second generation G4) use 32-byte
38generation G4) use 32 bytes cache line.38 * cache lines. This is due to the use of the 'dcbz' instruction. It simply
39This is due to the use of the 'dcbz' instruction. It simply clear to zero a39 * clears a single cache line to zero, so you need to know the cache line
40single cache line, so you need to know the cache line size to use it !40 * size to use it! It's absurd, but it's fast...
41It's absurd, but it's fast...41 *
42 42 * update 24/06/2003: Apple released the G5 yesterday, with a PPC970.
43update 24/06/2003 : Apple released yesterday the G5, with a PPC970. cache line43 * cache line size: 128 bytes. Oups.
44size: 128 bytes. Oups.44 * The semantics of dcbz was changed, it always clears 32 bytes. So the function
45The semantic of dcbz was changed, it always clear 32 bytes. so the function45 * below will work, but will be slow. So I fixed check_dcbz_effect to use dcbzl,
46below will work, but will be slow. So I fixed check_dcbz_effect to use dcbzl,46 * which is defined to clear a cache line (as dcbz before). So we can still
47which is defined to clear a cache line (as dcbz before). So we still can47 * distinguish, and use dcbz (32 bytes) or dcbzl (one cache line) as required.
48distinguish, and use dcbz (32 bytes) or dcbzl (one cache line) as required.48 *
49 49 * see <http://developer.apple.com/technotes/tn/tn2087.html>
50see <http://developer.apple.com/technotes/tn/tn2087.html>50 * and <http://developer.apple.com/technotes/tn/tn2086.html>
51and <http://developer.apple.com/technotes/tn/tn2086.html>51 */
52*/
53static void clear_blocks_dcbz32_ppc(int16_t *blocks)52static void clear_blocks_dcbz32_ppc(int16_t *blocks)
54{53{
55 register int misal = ((unsigned long)blocks & 0x00000010);54 register int misal = ((unsigned long)blocks & 0x00000010);
@@ -73,17 +72,17 @@ static void clear_blocks_dcbz32_ppc(int16_t *blocks) · 17 unmodified lines
73 }72 }
74}73}
75 74
76/* same as above, when dcbzl clear a whole 128B cache line75/* Same as above, when dcbzl clears a whole 128 bytes cache line
77 i.e. the PPC970 aka G5 */76 * i.e. the PPC970 AKA G5. */
78#if HAVE_DCBZL77#if HAVE_DCBZL
79static void clear_blocks_dcbz128_ppc(int16_t *blocks)78static void clear_blocks_dcbz128_ppc(int16_t *blocks)
80{79{
81 register int misal = ((unsigned long)blocks & 0x0000007f);80 register int misal = ((unsigned long)blocks & 0x0000007f);
82 register int i = 0;81 register int i = 0;
83 if (misal) {82 if (misal) {
84 // we could probably also optimize this case,83 /* We could probably also optimize this case,
85 // but there's not much point as the machines84 * but there's not much point as the machines
86 // aren't available yet (2003-06-26)85 * aren't available yet (2003-06-26). */
87 memset(blocks, 0, sizeof(int16_t)*6*64);86 memset(blocks, 0, sizeof(int16_t)*6*64);
88 }87 }
89 else88 else
@@ -99,11 +98,10 @@ static void clear_blocks_dcbz128_ppc(int16_t *blocks) · 9 unmodified lines
99#endif98#endif
100 99
101#if HAVE_DCBZL100#if HAVE_DCBZL
102/* check dcbz report how many bytes are set to 0 by dcbz */101/* Check dcbz report how many bytes are set to 0 by dcbz. */
103/* update 24/06/2003 : replace dcbz by dcbzl to get102/* update 24/06/2003: Replace dcbz by dcbzl to get the intended effect
104 the intended effect (Apple "fixed" dcbz)103 * (Apple "fixed" dcbz). Unfortunately this cannot be used unless the
105 unfortunately this cannot be used unless the assembler104 * assembler knows about dcbzl ... */
106 knows about dcbzl ... */
107static long check_dcbzl_effect(void)105static long check_dcbzl_effect(void)
108{106{
109 register char *fakedata = av_malloc(1024);107 register char *fakedata = av_malloc(1024);
@@ -120,8 +118,8 @@ static long check_dcbzl_effect(void) · 10 unmodified lines
120 118
121 memset(fakedata, 0xFF, 1024);119 memset(fakedata, 0xFF, 1024);
122 120
123 /* below the constraint "b" seems to mean "Address base register"121 /* Below the constraint "b" seems to mean "address base register"
124 in gcc-3.3 / RS/6000 speaks. seems to avoid using r0, so.... */122 * in gcc-3.3 / RS/6000 speaks. Seems to avoid using r0, so.... */
125 __asm__ volatile("dcbzl %0, %1" : : "b" (fakedata_middle), "r" (zero));123 __asm__ volatile("dcbzl %0, %1" : : "b" (fakedata_middle), "r" (zero));
126 124
127 for (i = 0; i < 1024 ; i ++) {125 for (i = 0; i < 1024 ; i ++) {
@@ -145,7 +143,7 @@ av_cold void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx) · 17 unmodified lines
145 const int high_bit_depth = avctx->bits_per_raw_sample > 8;143 const int high_bit_depth = avctx->bits_per_raw_sample > 8;
146 int mm_flags = av_get_cpu_flags();144 int mm_flags = av_get_cpu_flags();
147 145
148 // Common optimizations whether AltiVec is available or not146 // common optimizations whether AltiVec is available or not
149 if (!high_bit_depth) {147 if (!high_bit_depth) {
150 switch (check_dcbzl_effect()) {148 switch (check_dcbzl_effect()) {
151 case 32:149 case 32:
libavcodec/ppc/fdct_altivec.c+3−4
@@ -259,11 +259,10 @@ void ff_fdct_altivec(int16_t *block) · 258 unmodified lines
259#undef MERGE_S16259#undef MERGE_S16
260 /* }}} */260 /* }}} */
261 261
262 /* Some of the initial calculations can be done as vector short
263 * before conversion to vector float. The following code section
264 * takes advantage of this. */
262 265
263/* Some of the initial calculations can be done as vector short before
264 * conversion to vector float. The following code section takes advantage
265 * of this.
266 */
267 /* fdct rows {{{ */266 /* fdct rows {{{ */
268 x0 = ((vector float)vec_add(vs16(b00), vs16(b70)));267 x0 = ((vector float)vec_add(vs16(b00), vs16(b70)));
269 x7 = ((vector float)vec_sub(vs16(b00), vs16(b70)));268 x7 = ((vector float)vec_sub(vs16(b00), vs16(b70)));
libavcodec/ppc/fft_altivec.c+6−6
@@ -27,12 +27,12 @@ · 26 unmodified lines
27#include "libavcodec/fft.h"27#include "libavcodec/fft.h"
28 28
29/**29/**
30 * Do a complex FFT with the parameters defined in ff_fft_init(). The30 * Do a complex FFT with the parameters defined in ff_fft_init().
31 * input data must be permuted before with s->revtab table. No31 * The input data must be permuted before with s->revtab table.
32 * 1.0/sqrt(n) normalization is done.32 * No 1.0 / sqrt(n) normalization is done.
33 * AltiVec-enabled33 * AltiVec-enabled:
34 * This code assumes that the 'z' pointer is 16 bytes-aligned34 * This code assumes that the 'z' pointer is 16 bytes-aligned.
35 * It also assumes all FFTComplex are 8 bytes-aligned pair of float35 * It also assumes all FFTComplex are 8 bytes-aligned pairs of floats.
36 */36 */
37 37
38void ff_fft_calc_altivec(FFTContext *s, FFTComplex *z);38void ff_fft_calc_altivec(FFTContext *s, FFTComplex *z);
libavcodec/ppc/gmc_altivec.c+17−23
@@ -1,6 +1,6 @@
1/*1/*
2 * GMC (Global Motion Compensation)2 * GMC (Global Motion Compensation), AltiVec-enabled
3 * AltiVec-enabled3 *
4 * Copyright (c) 2003 Romain Dolbeau <romain@dolbeau.org>4 * Copyright (c) 2003 Romain Dolbeau <romain@dolbeau.org>
5 *5 *
6 * This file is part of FFmpeg.6 * This file is part of FFmpeg.
@@ -25,10 +25,8 @@ · 18 unmodified lines
25#include "libavutil/ppc/util_altivec.h"25#include "libavutil/ppc/util_altivec.h"
26#include "dsputil_altivec.h"26#include "dsputil_altivec.h"
27 27
28/*28/* AltiVec-enhanced gmc1. ATM this code assumes stride is a multiple of 8
29 altivec-enhanced gmc1. ATM this code assume stride is a multiple of 8,29 * to preserve proper dst alignment. */
30 to preserve proper dst alignment.
31*/
32void ff_gmc1_altivec(uint8_t *dst /* align 8 */, uint8_t *src /* align1 */, int stride, int h, int x16, int y16, int rounder)30void ff_gmc1_altivec(uint8_t *dst /* align 8 */, uint8_t *src /* align1 */, int stride, int h, int x16, int y16, int rounder)
33{31{
34 const DECLARE_ALIGNED(16, unsigned short, rounder_a) = rounder;32 const DECLARE_ALIGNED(16, unsigned short, rounder_a) = rounder;
@@ -56,18 +54,16 @@ void ff_gmc1_altivec(uint8_t *dst /* align 8 */, uint8_t *src /* align1 */, int · 21 unmodified lines
56 54
57 rounderV = vec_splat((vec_u16)vec_lde(0, &rounder_a), 0);55 rounderV = vec_splat((vec_u16)vec_lde(0, &rounder_a), 0);
58 56
59 // we'll be able to pick-up our 9 char elements57 /* we'll be able to pick-up our 9 char elements at src from those
60 // at src from those 32 bytes58 * 32 bytes we load the first batch here, as inside the loop we can
61 // we load the first batch here, as inside the loop59 * reuse 'src + stride' from one iteration as the 'src' of the next. */
62 // we can re-use 'src+stride' from one iteration
63 // as the 'src' of the next.
64 src_0 = vec_ld(0, src);60 src_0 = vec_ld(0, src);
65 src_1 = vec_ld(16, src);61 src_1 = vec_ld(16, src);
66 srcvA = vec_perm(src_0, src_1, vec_lvsl(0, src));62 srcvA = vec_perm(src_0, src_1, vec_lvsl(0, src));
67 63
68 if (src_really_odd != 0x0000000F) {64 if (src_really_odd != 0x0000000F) {
69 // if (src & 0xF) == 0xF, then (src+1) is properly aligned65 /* If (src & 0xF) == 0xF, then (src + 1) is properly aligned
70 // on the second vector.66 * on the second vector. */
71 srcvB = vec_perm(src_0, src_1, vec_lvsl(1, src));67 srcvB = vec_perm(src_0, src_1, vec_lvsl(1, src));
72 } else {68 } else {
73 srcvB = src_1;69 srcvB = src_1;
@@ -81,17 +77,16 @@ void ff_gmc1_altivec(uint8_t *dst /* align 8 */, uint8_t *src /* align1 */, int · 7 unmodified lines
81 77
82 dstv = vec_ld(0, dst);78 dstv = vec_ld(0, dst);
83 79
84 // we we'll be able to pick-up our 9 char elements80 /* We'll be able to pick-up our 9 char elements at src + stride from
85 // at src + stride from those 32 bytes81 * those 32 bytes then reuse the resulting 2 vectors srvcC and srcvD
86 // then reuse the resulting 2 vectors srvcC and srcvD82 * as the next srcvA and srcvB. */
87 // as the next srcvA and srcvB
88 src_0 = vec_ld(stride + 0, src);83 src_0 = vec_ld(stride + 0, src);
89 src_1 = vec_ld(stride + 16, src);84 src_1 = vec_ld(stride + 16, src);
90 srcvC = vec_perm(src_0, src_1, vec_lvsl(stride + 0, src));85 srcvC = vec_perm(src_0, src_1, vec_lvsl(stride + 0, src));
91 86
92 if (src_really_odd != 0x0000000F) {87 if (src_really_odd != 0x0000000F) {
93 // if (src & 0xF) == 0xF, then (src+1) is properly aligned88 /* If (src & 0xF) == 0xF, then (src + 1) is properly aligned
94 // on the second vector.89 * on the second vector. */
95 srcvD = vec_perm(src_0, src_1, vec_lvsl(stride + 1, src));90 srcvD = vec_perm(src_0, src_1, vec_lvsl(stride + 1, src));
96 } else {91 } else {
97 srcvD = src_1;92 srcvD = src_1;
@@ -100,10 +95,9 @@ void ff_gmc1_altivec(uint8_t *dst /* align 8 */, uint8_t *src /* align1 */, int · 2 unmodified lines
100 srcvC = vec_mergeh(vczero, srcvC);95 srcvC = vec_mergeh(vczero, srcvC);
101 srcvD = vec_mergeh(vczero, srcvD);96 srcvD = vec_mergeh(vczero, srcvD);
102 97
103 98 /* OK, now we (finally) do the math :-)
104 // OK, now we (finally) do the math :-)99 * Those four instructions replace 32 int muls & 32 int adds.
105 // those four instructions replaces 32 int muls & 32 int adds.100 * Isn't AltiVec nice? */
106 // isn't AltiVec nice ?
107 tempA = vec_mladd((vector unsigned short)srcvA, Av, rounderV);101 tempA = vec_mladd((vector unsigned short)srcvA, Av, rounderV);
108 tempB = vec_mladd((vector unsigned short)srcvB, Bv, tempA);102 tempB = vec_mladd((vector unsigned short)srcvB, Bv, tempA);
109 tempC = vec_mladd((vector unsigned short)srcvC, Cv, tempB);103 tempC = vec_mladd((vector unsigned short)srcvC, Cv, tempB);
libavcodec/ppc/idct_altivec.c+4−9
@@ -18,24 +18,19 @@ · 17 unmodified lines
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */19 */
20 20
21/*21/* NOTE: This code is based on GPL code from the libmpeg2 project. The
22 * NOTE: This code is based on GPL code from the libmpeg2 project. The
23 * author, Michel Lespinasses, has given explicit permission to release22 * author, Michel Lespinasses, has given explicit permission to release
24 * under LGPL as part of FFmpeg.23 * under LGPL as part of FFmpeg.
25 */24 *
26
27/*
28 * FFmpeg integration by Dieter Shirley25 * FFmpeg integration by Dieter Shirley
29 *26 *
30 * This file is a direct copy of the AltiVec IDCT module from the libmpeg227 * This file is a direct copy of the AltiVec IDCT module from the libmpeg2
31 * project. I've deleted all of the libmpeg2-specific code, renamed the28 * project. I've deleted all of the libmpeg2-specific code, renamed the
32 * functions and reordered the function parameters. The only change to the29 * functions and reordered the function parameters. The only change to the
33 * IDCT function itself was to factor out the partial transposition, and to30 * IDCT function itself was to factor out the partial transposition, and to
34 * perform a full transpose at the end of the function.31 * perform a full transpose at the end of the function. */
35 */
36
37 32
38#include <stdlib.h> /* malloc(), free() */33#include <stdlib.h>
39#include <string.h>34#include <string.h>
40#include "config.h"35#include "config.h"
41#if HAVE_ALTIVEC_H36#if HAVE_ALTIVEC_H
libavcodec/ppc/int_altivec.c+7−7
@@ -19,9 +19,9 @@ · 18 unmodified lines
19 */19 */
20 20
21/**21/**
22 ** @file22 * @file
23 ** integer misc ops.23 * miscellaneous integer operations
24 **/24 */
25 25
26#include "config.h"26#include "config.h"
27#if HAVE_ALTIVEC_H27#if HAVE_ALTIVEC_H
@@ -43,8 +43,8 @@ static int ssd_int8_vs_int16_altivec(const int8_t *pix1, const int16_t *pix2, · 15 unmodified lines
43 int32_t score[4];43 int32_t score[4];
44 } u;44 } u;
45 u.vscore = vec_splat_s32(0);45 u.vscore = vec_splat_s32(0);
46//46
47//XXX lazy way, fix it later47// XXX lazy way, fix it later
48 48
49#define vec_unaligned_load(b) \49#define vec_unaligned_load(b) \
50 vec_perm(vec_ld(0,b),vec_ld(15,b),vec_lvsl(0, b));50 vec_perm(vec_ld(0,b),vec_ld(15,b),vec_lvsl(0, b));
@@ -52,12 +52,12 @@ static int ssd_int8_vs_int16_altivec(const int8_t *pix1, const int16_t *pix2, · 1 unmodified line
52 size16 = size >> 4;52 size16 = size >> 4;
53 while(size16) {53 while(size16) {
54// score += (pix1[i]-pix2[i])*(pix1[i]-pix2[i]);54// score += (pix1[i]-pix2[i])*(pix1[i]-pix2[i]);
55 //load pix1 and the first batch of pix255 // load pix1 and the first batch of pix2
56 56
57 vpix1 = vec_unaligned_load(pix1);57 vpix1 = vec_unaligned_load(pix1);
58 vpix2 = vec_unaligned_load(pix2);58 vpix2 = vec_unaligned_load(pix2);
59 pix2 += 8;59 pix2 += 8;
60 //unpack60 // unpack
61 vpix1h = vec_unpackh(vpix1);61 vpix1h = vec_unpackh(vpix1);
62 vdiff = vec_sub(vpix1h, vpix2);62 vdiff = vec_sub(vpix1h, vpix2);
63 vpix1l = vec_unpackl(vpix1);63 vpix1l = vec_unpackl(vpix1);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t