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

Showing the changes to libavcodec/ppc (7 of 7 files). Show all

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
4747 sad = (vector unsigned int)vec_splat_u32(0);
4848 for (i = 0; i < h; i++) {
4949 /* Read unaligned pixels into our vectors. The vectors are as follows:
50− pix1v: pix1[0]-pix1[15]
51− pix2v: pix2[0]-pix2[15] pix2iv: pix2[1]-pix2[16] */
50+ * pix1v: pix1[0] - pix1[15]
51+ * pix2v: pix2[0] - pix2[15] pix2iv: pix2[1] - pix2[16] */
5252 pix1v = vec_ld( 0, pix1);
5353 pix2l = vec_ld( 0, pix2);
5454 pix2r = vec_ld(16, pix2);
5555 pix2v = vec_perm(pix2l, pix2r, perm1);
5656 pix2iv = vec_perm(pix2l, pix2r, perm2);
5757
58− /* Calculate the average vector */
58+ /* Calculate the average vector. */
5959 avgv = vec_avg(pix2v, pix2iv);
6060
61− /* Calculate a sum of abs differences vector */
61+ /* Calculate a sum of abs differences vector. */
6262 t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv));
6363
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. */
6565 sad = vec_sum4s(t5, sad);
6666
6767 pix1 += line_size;
6868 pix2 += line_size;
6969 }
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. */
7171 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
7272 sumdiffs = vec_splat(sumdiffs, 3);
7373 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
9191 sad = (vector unsigned int)vec_splat_u32(0);
9292
9393 /* Due to the fact that pix3 = pix2 + line_size, the pix3 of one
94− iteration becomes pix2 in the next iteration. We can use this
95− fact to avoid a potentially expensive unaligned read, each
96− time around the loop.
97− Read unaligned pixels into our vectors. The vectors are as follows:
98− pix2v: pix2[0]-pix2[15]
99− Split the pixel vectors into shorts */
94+ * iteration becomes pix2 in the next iteration. We can use this
95+ * fact to avoid a potentially expensive unaligned read, each
96+ * time around the loop.
97+ * Read unaligned pixels into our vectors. The vectors are as follows:
98+ * pix2v: pix2[0] - pix2[15]
99+ * Split the pixel vectors into shorts. */
100100 pix2l = vec_ld( 0, pix2);
101101 pix2r = vec_ld(15, pix2);
102102 pix2v = vec_perm(pix2l, pix2r, perm);
103103
104104 for (i = 0; i < h; i++) {
105105 /* Read unaligned pixels into our vectors. The vectors are as follows:
106− pix1v: pix1[0]-pix1[15]
107− pix3v: pix3[0]-pix3[15] */
106+ * pix1v: pix1[0] - pix1[15]
107+ * pix3v: pix3[0] - pix3[15] */
108108 pix1v = vec_ld(0, pix1);
109109
110110 pix2l = vec_ld( 0, pix3);
111111 pix2r = vec_ld(15, pix3);
112112 pix3v = vec_perm(pix2l, pix2r, perm);
113113
114− /* Calculate the average vector */
114+ /* Calculate the average vector. */
115115 avgv = vec_avg(pix2v, pix3v);
116116
117− /* Calculate a sum of abs differences vector */
117+ /* Calculate a sum of abs differences vector. */
118118 t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv));
119119
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. */
121121 sad = vec_sum4s(t5, sad);
122122
123123 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
126126
127127 }
128128
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. */
130130 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
131131 sumdiffs = vec_splat(sumdiffs, 3);
132132 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
157157 s = 0;
158158
159159 /* Due to the fact that pix3 = pix2 + line_size, the pix3 of one
160− iteration becomes pix2 in the next iteration. We can use this
161− fact to avoid a potentially expensive unaligned read, as well
162− as some splitting, and vector addition each time around the loop.
163− Read unaligned pixels into our vectors. The vectors are as follows:
164− pix2v: pix2[0]-pix2[15] pix2iv: pix2[1]-pix2[16]
165− Split the pixel vectors into shorts */
160+ * iteration becomes pix2 in the next iteration. We can use this
161+ * fact to avoid a potentially expensive unaligned read, as well
162+ * as some splitting, and vector addition each time around the loop.
163+ * Read unaligned pixels into our vectors. The vectors are as follows:
164+ * pix2v: pix2[0] - pix2[15] pix2iv: pix2[1] - pix2[16]
165+ * Split the pixel vectors into shorts. */
166166 pix2l = vec_ld( 0, pix2);
167167 pix2r = vec_ld(16, pix2);
168168 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
177177
178178 for (i = 0; i < h; i++) {
179179 /* Read unaligned pixels into our vectors. The vectors are as follows:
180− pix1v: pix1[0]-pix1[15]
181− pix3v: pix3[0]-pix3[15] pix3iv: pix3[1]-pix3[16] */
180+ * pix1v: pix1[0] - pix1[15]
181+ * pix3v: pix3[0] - pix3[15] pix3iv: pix3[1] - pix3[16] */
182182 pix1v = vec_ld(0, pix1);
183183
184184 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
187187 pix3iv = vec_perm(pix2l, pix2r, perm2);
188188
189189 /* 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 rounding
191− would mean that, for example, avg(3,0,0,1) = 2, when it should be 1.
192− Instead, we have to split the pixel vectors into vectors of shorts,
193− and do the averaging by hand. */
190+ * and rounds up. We could do avg(avg(a, b), avg(c, d)), but the
191+ * rounding would mean that, for example, avg(3, 0, 0, 1) = 2, when
192+ * it should be 1. Instead, we have to split the pixel vectors into
193+ * vectors of shorts and do the averaging by hand. */
194194
195− /* Split the pixel vectors into shorts */
195+ /* Split the pixel vectors into shorts. */
196196 pix3hv = (vector unsigned short) vec_mergeh(zero, pix3v);
197197 pix3lv = (vector unsigned short) vec_mergel(zero, pix3v);
198198 pix3ihv = (vector unsigned short) vec_mergeh(zero, pix3iv);
199199 pix3ilv = (vector unsigned short) vec_mergel(zero, pix3iv);
200200
201− /* Do the averaging on them */
201+ /* Do the averaging on them. */
202202 t3 = vec_add(pix3hv, pix3ihv);
203203 t4 = vec_add(pix3lv, pix3ilv);
204204
205205 avghv = vec_sr(vec_add(vec_add(t1, t3), two), two);
206206 avglv = vec_sr(vec_add(vec_add(t2, t4), two), two);
207207
208− /* Pack the shorts back into a result */
208+ /* Pack the shorts back into a result. */
209209 avgv = vec_pack(avghv, avglv);
210210
211− /* Calculate a sum of abs differences vector */
211+ /* Calculate a sum of abs differences vector. */
212212 t5 = vec_sub(vec_max(pix1v, avgv), vec_min(pix1v, avgv));
213213
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. */
215215 sad = vec_sum4s(t5, sad);
216216
217217 pix1 += line_size;
218218 pix3 += line_size;
219− /* Transfer the calculated values for pix3 into pix2 */
219+ /* Transfer the calculated values for pix3 into pix2. */
220220 t1 = t3;
221221 t2 = t4;
222222 }
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. */
224224 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
225225 sumdiffs = vec_splat(sumdiffs, 3);
226226 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
242242
243243
244244 for (i = 0; i < h; i++) {
245− /* Read potentially unaligned pixels into t1 and t2 */
245+ /* Read potentially unaligned pixels into t1 and t2. */
246246 vector unsigned char pix2l = vec_ld( 0, pix2);
247247 vector unsigned char pix2r = vec_ld(15, pix2);
248248 t1 = vec_ld(0, pix1);
249249 t2 = vec_perm(pix2l, pix2r, perm);
250250
251− /* Calculate a sum of abs differences vector */
251+ /* Calculate a sum of abs differences vector. */
252252 t3 = vec_max(t1, t2);
253253 t4 = vec_min(t1, t2);
254254 t5 = vec_sub(t3, t4);
255255
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. */
257257 sad = vec_sum4s(t5, sad);
258258
259259 pix1 += line_size;
260260 pix2 += line_size;
261261 }
262262
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. */
264264 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
265265 sumdiffs = vec_splat(sumdiffs, 3);
266266 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
283283 sad = (vector unsigned int)vec_splat_u32(0);
284284
285285 for (i = 0; i < h; i++) {
286− /* Read potentially unaligned pixels into t1 and t2
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. */
286+ /* Read potentially unaligned pixels into t1 and t2.
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. */
289289 vector unsigned char pix1l = vec_ld(0, pix1);
290290 vector unsigned char pix1r = vec_ld(7, pix1);
291291 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
293293 t1 = vec_and(vec_perm(pix1l, pix1r, perm1), permclear);
294294 t2 = vec_and(vec_perm(pix2l, pix2r, perm2), permclear);
295295
296− /* Calculate a sum of abs differences vector */
296+ /* Calculate a sum of abs differences vector. */
297297 t3 = vec_max(t1, t2);
298298 t4 = vec_min(t1, t2);
299299 t5 = vec_sub(t3, t4);
300300
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. */
302302 sad = vec_sum4s(t5, sad);
303303
304304 pix1 += line_size;
305305 pix2 += line_size;
306306 }
307307
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. */
309309 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
310310 sumdiffs = vec_splat(sumdiffs, 3);
311311 vec_ste(sumdiffs, 0, &s);
@@ -327,17 +327,17 @@ static int pix_norm1_altivec(uint8_t *pix, int line_size) · 15 unmodified lines
327327
328328 s = 0;
329329 for (i = 0; i < 16; i++) {
330− /* Read in the potentially unaligned pixels */
330+ /* Read the potentially unaligned pixels. */
331331 vector unsigned char pixl = vec_ld( 0, pix);
332332 vector unsigned char pixr = vec_ld(15, pix);
333333 pixv = vec_perm(pixl, pixr, perm);
334334
335− /* Square the values, and add them to our sum */
335+ /* Square the values, and add them to our sum. */
336336 sv = vec_msum(pixv, pixv, sv);
337337
338338 pix += line_size;
339339 }
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. */
341341 sum = vec_sums((vector signed int) sv, (vector signed int) zero);
342342 sum = vec_splat(sum, 3);
343343 vec_ste(sum, 0, &s);
@@ -345,11 +345,8 @@ static int pix_norm1_altivec(uint8_t *pix, int line_size) · 1 unmodified line
345345 return s;
346346 }
347347
348−/**
349− * Sum of Squared Errors for a 8x8 block.
350− * AltiVec-enhanced.
351− * It's the sad8_altivec code above w/ squaring added.
352− */
348+/* Sum of Squared Errors for an 8x8 block, AltiVec-enhanced.
349+ * It's the sad8_altivec code above w/ squaring added. */
353350 static int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
354351 {
355352 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
365362 sum = (vector unsigned int)vec_splat_u32(0);
366363
367364 for (i = 0; i < h; i++) {
368− /* Read potentially unaligned pixels into t1 and t2
369− 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. */
365+ /* Read potentially unaligned pixels into t1 and t2.
366+ * Since we're reading 16 pixels, and actually only want 8,
367+ * mask out the last 8 pixels. The 0s don't change the sum. */
371368 vector unsigned char pix1l = vec_ld(0, pix1);
372369 vector unsigned char pix1r = vec_ld(7, pix1);
373370 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
376373 t2 = vec_and(vec_perm(pix2l, pix2r, perm2), permclear);
377374
378375 /* 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. */
380377
381− /* Calculate abs differences vector */
378+ /* Calculate abs differences vector. */
382379 t3 = vec_max(t1, t2);
383380 t4 = vec_min(t1, t2);
384381 t5 = vec_sub(t3, t4);
385382
386− /* Square the values and add them to our sum */
383+ /* Square the values and add them to our sum. */
387384 sum = vec_msum(t5, t5, sum);
388385
389386 pix1 += line_size;
390387 pix2 += line_size;
391388 }
392389
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. */
394391 sumsqr = vec_sums((vector signed int) sum, (vector signed int) zero);
395392 sumsqr = vec_splat(sumsqr, 3);
396393 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
398395 return s;
399396 }
400397
401−/**
402− * Sum of Squared Errors for a 16x16 block.
403− * AltiVec-enhanced.
404− * It's the sad16_altivec code above w/ squaring added.
405− */
398+/* Sum of Squared Errors for a 16x16 block, AltiVec-enhanced.
399+ * It's the sad16_altivec code above w/ squaring added. */
406400 static int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
407401 {
408402 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
416410 sum = (vector unsigned int)vec_splat_u32(0);
417411
418412 for (i = 0; i < h; i++) {
419− /* Read potentially unaligned pixels into t1 and t2 */
413+ /* Read potentially unaligned pixels into t1 and t2. */
420414 vector unsigned char pix2l = vec_ld( 0, pix2);
421415 vector unsigned char pix2r = vec_ld(15, pix2);
422416 t1 = vec_ld(0, pix1);
423417 t2 = vec_perm(pix2l, pix2r, perm);
424418
425419 /* 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. */
427421
428− /* Calculate abs differences vector */
422+ /* Calculate abs differences vector. */
429423 t3 = vec_max(t1, t2);
430424 t4 = vec_min(t1, t2);
431425 t5 = vec_sub(t3, t4);
432426
433− /* Square the values and add them to our sum */
427+ /* Square the values and add them to our sum. */
434428 sum = vec_msum(t5, t5, sum);
435429
436430 pix1 += line_size;
437431 pix2 += line_size;
438432 }
439433
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. */
441435 sumsqr = vec_sums((vector signed int) sum, (vector signed int) zero);
442436 sumsqr = vec_splat(sumsqr, 3);
443437 vec_ste(sumsqr, 0, &s);
@@ -459,18 +453,18 @@ static int pix_sum_altivec(uint8_t * pix, int line_size) · 15 unmodified lines
459453 sad = (vector unsigned int)vec_splat_u32(0);
460454
461455 for (i = 0; i < 16; i++) {
462− /* Read the potentially unaligned 16 pixels into t1 */
456+ /* Read the potentially unaligned 16 pixels into t1. */
463457 vector unsigned char pixl = vec_ld( 0, pix);
464458 vector unsigned char pixr = vec_ld(15, pix);
465459 t1 = vec_perm(pixl, pixr, perm);
466460
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. */
468462 sad = vec_sum4s(t1, sad);
469463
470464 pix += line_size;
471465 }
472466
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. */
474468 sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero);
475469 sumdiffs = vec_splat(sumdiffs, 3);
476470 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
487481 vector signed short shorts;
488482
489483 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. */
490487 // Read potentially unaligned pixels.
491488 // We're reading 16 pixels, and actually only want 8,
492489 // 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
494491 vector unsigned char pixr = vec_ld(7, pixels);
495492 bytes = vec_perm(pixl, pixr, perm);
496493
497− // convert the bytes into shorts
494+ // Convert the bytes into shorts.
498495 shorts = (vector signed short)vec_mergeh(zero, bytes);
499496
500− // save the data to the block, we assume the block is 16-byte aligned
497+ // Save the data to the block, we assume the block is 16-byte aligned.
501498 vec_st(shorts, i*16, (vector signed short*)block);
502499
503500 pixels += line_size;
@@ -515,60 +512,59 @@ static void diff_pixels_altivec(int16_t *restrict block, const uint8_t *s1, · 11 unmodified lines
515512 vector signed short shorts1, shorts2;
516513
517514 for (i = 0; i < 4; i++) {
518− // Read potentially unaligned pixels
519− // We're reading 16 pixels, and actually only want 8,
520− // but we simply ignore the extras.
515+ /* Read potentially unaligned pixels.
516+ * We're reading 16 pixels, and actually only want 8,
517+ * but we simply ignore the extras. */
521518 pixl = vec_ld( 0, s1);
522519 pixr = vec_ld(15, s1);
523520 bytes = vec_perm(pixl, pixr, perm1);
524521
525− // convert the bytes into shorts
522+ // Convert the bytes into shorts.
526523 shorts1 = (vector signed short)vec_mergeh(zero, bytes);
527524
528− // Do the same for the second block of pixels
525+ // Do the same for the second block of pixels.
529526 pixl = vec_ld( 0, s2);
530527 pixr = vec_ld(15, s2);
531528 bytes = vec_perm(pixl, pixr, perm2);
532529
533− // convert the bytes into shorts
530+ // Convert the bytes into shorts.
534531 shorts2 = (vector signed short)vec_mergeh(zero, bytes);
535532
536− // Do the subtraction
533+ // Do the subtraction.
537534 shorts1 = vec_sub(shorts1, shorts2);
538535
539− // save the data to the block, we assume the block is 16-byte aligned
536+ // Save the data to the block, we assume the block is 16-byte aligned.
540537 vec_st(shorts1, 0, (vector signed short*)block);
541538
542539 s1 += stride;
543540 s2 += stride;
544541 block += 8;
545542
543+ /* The code below is a copy of the code above...
544+ * This is a manual unroll. */
546545
547− // The code below is a copy of the code above... This is a manual
548− // unroll.
549−
550− // Read potentially unaligned pixels
551− // We're reading 16 pixels, and actually only want 8,
552− // but we simply ignore the extras.
546+ /* Read potentially unaligned pixels.
547+ * We're reading 16 pixels, and actually only want 8,
548+ * but we simply ignore the extras. */
553549 pixl = vec_ld( 0, s1);
554550 pixr = vec_ld(15, s1);
555551 bytes = vec_perm(pixl, pixr, perm1);
556552
557− // convert the bytes into shorts
553+ // Convert the bytes into shorts.
558554 shorts1 = (vector signed short)vec_mergeh(zero, bytes);
559555
560− // Do the same for the second block of pixels
556+ // Do the same for the second block of pixels.
561557 pixl = vec_ld( 0, s2);
562558 pixr = vec_ld(15, s2);
563559 bytes = vec_perm(pixl, pixr, perm2);
564560
565− // convert the bytes into shorts
561+ // Convert the bytes into shorts.
566562 shorts2 = (vector signed short)vec_mergeh(zero, bytes);
567563
568− // Do the subtraction
564+ // Do the subtraction.
569565 shorts1 = vec_sub(shorts1, shorts2);
570566
571− // save the data to the block, we assume the block is 16-byte aligned
567+ // Save the data to the block, we assume the block is 16-byte aligned.
572568 vec_st(shorts1, 0, (vector signed short*)block);
573569
574570 s1 += stride;
@@ -595,14 +591,14 @@ static void add_bytes_altivec(uint8_t *dst, uint8_t *src, int w) { · 20 unmodified lines
595591 register int i;
596592 register vector unsigned char vdst, vsrc;
597593
598− /* dst and src are 16 bytes-aligned (guaranteed) */
594+ /* dst and src are 16 bytes-aligned (guaranteed). */
599595 for (i = 0 ; (i + 15) < w ; i+=16) {
600596 vdst = vec_ld(i, (unsigned char*)dst);
601597 vsrc = vec_ld(i, (unsigned char*)src);
602598 vdst = vec_add(vsrc, vdst);
603599 vec_st(vdst, i, (unsigned char*)dst);
604600 }
605− /* if w is not a multiple of 16 */
601+ /* If w is not a multiple of 16. */
606602 for (; (i < w) ; i++) {
607603 dst[i] = src[i];
608604 }
@@ -643,8 +639,8 @@ static int hadamard8_diff8x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, u · 34 unmodified lines
643639 dst1 = vec_ld(stride * i, dst); \
644640 dst2 = vec_ld((stride * i) + 15, dst); \
645641 dstO = vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \
646− /* promote the unsigned chars to signed shorts */ \
647− /* we're in the 8x8 function, we only care for the first 8 */ \
642+ /* Promote the unsigned chars to signed shorts. */ \
643+ /* We're in the 8x8 function, we only care for the first 8. */ \
648644 srcV = (vector signed short)vec_mergeh((vector signed char)vzero, \
649645 (vector signed char)srcO); \
650646 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
713709 }
714710
715711 /*
716−16x8 works with 16 elements; it allows to avoid replicating loads, and
717−give the compiler more rooms for scheduling. It's only used from
718−inside hadamard8_diff16_altivec.
719−
720−Unfortunately, it seems gcc-3.3 is a bit dumb, and the compiled code has a LOT
721−of spill code, it seems gcc (unlike xlc) cannot keep everything in registers
722−by itself. The following code include hand-made registers allocation. It's not
723−clean, but on a 7450 the resulting code is much faster (best case fall from
724−700+ cycles to 550).
725−
726−xlc doesn't add spill code, but it doesn't know how to schedule for the 7450,
727−and its code isn't much faster than gcc-3.3 on the 7450 (but uses 25% less
728−instructions...)
729−
730−On the 970, the hand-made RA is still a win (around 690 vs. around 780), but
731−xlc goes to around 660 on the regular C code...
732−*/
733−
712+ * 16x8 works with 16 elements; it allows to avoid replicating loads, and
713+ * gives the compiler more room for scheduling. It's only used from
714+ * inside hadamard8_diff16_altivec.
715+ *
716+ * Unfortunately, it seems gcc-3.3 is a bit dumb, and the compiled code has
717+ * a LOT of spill code, it seems gcc (unlike xlc) cannot keep everything in
718+ * registers by itself. The following code includes hand-made register
719+ * allocation. It's not clean, but on a 7450 the resulting code is much faster
720+ * (best case falls from 700+ cycles to 550).
721+ *
722+ * xlc doesn't add spill code, but it doesn't know how to schedule for the
723+ * 7450, and its code isn't much faster than gcc-3.3 on the 7450 (but uses
724+ * 25% fewer instructions...)
725+ *
726+ * On the 970, the hand-made RA is still a win (around 690 vs. around 780),
727+ * but xlc goes to around 660 on the regular C code...
728+ */
734729 static int hadamard8_diff16x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h) {
735730 int sum;
736731 register vector signed short
@@ -805,7 +800,7 @@ static int hadamard8_diff16x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, · 68 unmodified lines
805800 dst1 = vec_ld(stride * i, dst); \
806801 dst2 = vec_ld((stride * i) + 16, dst); \
807802 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. */ \
809804 srcV = (vector signed short)vec_mergeh((vector signed char)vzero, \
810805 (vector signed char)srcO); \
811806 dstV = (vector signed short)vec_mergeh((vector signed char)vzero, \
libavcodec/ppc/dsputil_ppc.c+29−31
@@ -32,24 +32,23 @@ · 31 unmodified lines
3232
3333 /* ***** WARNING ***** WARNING ***** WARNING ***** */
3434 /*
35−clear_blocks_dcbz32_ppc will not work properly on PowerPC processors with a
36−cache line size not equal to 32 bytes.
37−Fortunately all processor used by Apple up to at least the 7450 (aka second
38−generation G4) use 32 bytes cache line.
39−This is due to the use of the 'dcbz' instruction. It simply clear to zero a
40−single cache line, so you need to know the cache line size to use it !
41−It's absurd, but it's fast...
42−
43−update 24/06/2003 : Apple released yesterday the G5, with a PPC970. cache line
44−size: 128 bytes. Oups.
45−The semantic of dcbz was changed, it always clear 32 bytes. so the function
46−below will work, but will be slow. So I fixed check_dcbz_effect to use dcbzl,
47−which is defined to clear a cache line (as dcbz before). So we still can
48−distinguish, and use dcbz (32 bytes) or dcbzl (one cache line) as required.
49−
50−see <http://developer.apple.com/technotes/tn/tn2087.html>
51−and <http://developer.apple.com/technotes/tn/tn2086.html>
52−*/
35+ * clear_blocks_dcbz32_ppc will not work properly on PowerPC processors with
36+ * a cache line size not equal to 32 bytes. Fortunately all processors used
37+ * by Apple up to at least the 7450 (AKA second generation G4) use 32-byte
38+ * cache lines. This is due to the use of the 'dcbz' instruction. It simply
39+ * clears a single cache line to zero, so you need to know the cache line
40+ * size to use it! It's absurd, but it's fast...
41+ *
42+ * update 24/06/2003: Apple released the G5 yesterday, with a PPC970.
43+ * cache line size: 128 bytes. Oups.
44+ * The semantics of dcbz was changed, it always clears 32 bytes. So the function
45+ * below 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
47+ * distinguish, and use dcbz (32 bytes) or dcbzl (one cache line) as required.
48+ *
49+ * see <http://developer.apple.com/technotes/tn/tn2087.html>
50+ * and <http://developer.apple.com/technotes/tn/tn2086.html>
51+ */
5352 static void clear_blocks_dcbz32_ppc(int16_t *blocks)
5453 {
5554 register int misal = ((unsigned long)blocks & 0x00000010);
@@ -73,17 +72,17 @@ static void clear_blocks_dcbz32_ppc(int16_t *blocks) · 17 unmodified lines
7372 }
7473 }
7574
76−/* same as above, when dcbzl clear a whole 128B cache line
77− i.e. the PPC970 aka G5 */
75+/* Same as above, when dcbzl clears a whole 128 bytes cache line
76+ * i.e. the PPC970 AKA G5. */
7877 #if HAVE_DCBZL
7978 static void clear_blocks_dcbz128_ppc(int16_t *blocks)
8079 {
8180 register int misal = ((unsigned long)blocks & 0x0000007f);
8281 register int i = 0;
8382 if (misal) {
84− // we could probably also optimize this case,
85− // but there's not much point as the machines
86− // aren't available yet (2003-06-26)
83+ /* We could probably also optimize this case,
84+ * but there's not much point as the machines
85+ * aren't available yet (2003-06-26). */
8786 memset(blocks, 0, sizeof(int16_t)*6*64);
8887 }
8988 else
@@ -99,11 +98,10 @@ static void clear_blocks_dcbz128_ppc(int16_t *blocks) · 9 unmodified lines
9998 #endif
10099
101100 #if HAVE_DCBZL
102−/* check dcbz report how many bytes are set to 0 by dcbz */
103−/* update 24/06/2003 : replace dcbz by dcbzl to get
104− the intended effect (Apple "fixed" dcbz)
105− unfortunately this cannot be used unless the assembler
106− knows about dcbzl ... */
101+/* Check dcbz report how many bytes are set to 0 by dcbz. */
102+/* update 24/06/2003: Replace dcbz by dcbzl to get the intended effect
103+ * (Apple "fixed" dcbz). Unfortunately this cannot be used unless the
104+ * assembler knows about dcbzl ... */
107105 static long check_dcbzl_effect(void)
108106 {
109107 register char *fakedata = av_malloc(1024);
@@ -120,8 +118,8 @@ static long check_dcbzl_effect(void) · 10 unmodified lines
120118
121119 memset(fakedata, 0xFF, 1024);
122120
123− /* below the constraint "b" seems to mean "Address base register"
124− in gcc-3.3 / RS/6000 speaks. seems to avoid using r0, so.... */
121+ /* Below the constraint "b" seems to mean "address base register"
122+ * in gcc-3.3 / RS/6000 speaks. Seems to avoid using r0, so.... */
125123 __asm__ volatile("dcbzl %0, %1" : : "b" (fakedata_middle), "r" (zero));
126124
127125 for (i = 0; i < 1024 ; i ++) {
@@ -145,7 +143,7 @@ av_cold void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx) · 17 unmodified lines
145143 const int high_bit_depth = avctx->bits_per_raw_sample > 8;
146144 int mm_flags = av_get_cpu_flags();
147145
148− // Common optimizations whether AltiVec is available or not
146+ // common optimizations whether AltiVec is available or not
149147 if (!high_bit_depth) {
150148 switch (check_dcbzl_effect()) {
151149 case 32:
libavcodec/ppc/fdct_altivec.c+3−4
@@ -259,11 +259,10 @@ void ff_fdct_altivec(int16_t *block) · 258 unmodified lines
259259 #undef MERGE_S16
260260 /* }}} */
261261
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. */
262265
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− */
267266 /* fdct rows {{{ */
268267 x0 = ((vector float)vec_add(vs16(b00), vs16(b70)));
269268 x7 = ((vector float)vec_sub(vs16(b00), vs16(b70)));
libavcodec/ppc/fft_altivec.c+6−6
@@ -27,12 +27,12 @@ · 26 unmodified lines
2727 #include "libavcodec/fft.h"
2828
2929 /**
30− * Do a complex FFT with the parameters defined in ff_fft_init(). The
31− * input data must be permuted before with s->revtab table. No
32− * 1.0/sqrt(n) normalization is done.
33− * AltiVec-enabled
34− * This code assumes that the 'z' pointer is 16 bytes-aligned
35− * It also assumes all FFTComplex are 8 bytes-aligned pair of float
30+ * Do a complex FFT with the parameters defined in ff_fft_init().
31+ * The input data must be permuted before with s->revtab table.
32+ * No 1.0 / sqrt(n) normalization is done.
33+ * AltiVec-enabled:
34+ * This code assumes that the 'z' pointer is 16 bytes-aligned.
35+ * It also assumes all FFTComplex are 8 bytes-aligned pairs of floats.
3636 */
3737
3838 void ff_fft_calc_altivec(FFTContext *s, FFTComplex *z);
libavcodec/ppc/gmc_altivec.c+17−23
@@ -1,6 +1,6 @@
11 /*
2− * GMC (Global Motion Compensation)
3− * AltiVec-enabled
2+ * GMC (Global Motion Compensation), AltiVec-enabled
3+ *
44 * Copyright (c) 2003 Romain Dolbeau <romain@dolbeau.org>
55 *
66 * This file is part of FFmpeg.
@@ -25,10 +25,8 @@ · 18 unmodified lines
2525 #include "libavutil/ppc/util_altivec.h"
2626 #include "dsputil_altivec.h"
2727
28−/*
29− altivec-enhanced gmc1. ATM this code assume stride is a multiple of 8,
30− to preserve proper dst alignment.
31−*/
28+/* AltiVec-enhanced gmc1. ATM this code assumes stride is a multiple of 8
29+ * to preserve proper dst alignment. */
3230 void ff_gmc1_altivec(uint8_t *dst /* align 8 */, uint8_t *src /* align1 */, int stride, int h, int x16, int y16, int rounder)
3331 {
3432 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
5654
5755 rounderV = vec_splat((vec_u16)vec_lde(0, &rounder_a), 0);
5856
59− // we'll be able to pick-up our 9 char elements
60− // at src from those 32 bytes
61− // we load the first batch here, as inside the loop
62− // we can re-use 'src+stride' from one iteration
63− // as the 'src' of the next.
57+ /* we'll be able to pick-up our 9 char elements at src from those
58+ * 32 bytes we load the first batch here, as inside the loop we can
59+ * reuse 'src + stride' from one iteration as the 'src' of the next. */
6460 src_0 = vec_ld(0, src);
6561 src_1 = vec_ld(16, src);
6662 srcvA = vec_perm(src_0, src_1, vec_lvsl(0, src));
6763
6864 if (src_really_odd != 0x0000000F) {
69− // if (src & 0xF) == 0xF, then (src+1) is properly aligned
70− // on the second vector.
65+ /* If (src & 0xF) == 0xF, then (src + 1) is properly aligned
66+ * on the second vector. */
7167 srcvB = vec_perm(src_0, src_1, vec_lvsl(1, src));
7268 } else {
7369 srcvB = src_1;
@@ -81,17 +77,16 @@ void ff_gmc1_altivec(uint8_t *dst /* align 8 */, uint8_t *src /* align1 */, int · 7 unmodified lines
8177
8278 dstv = vec_ld(0, dst);
8379
84− // we we'll be able to pick-up our 9 char elements
85− // at src + stride from those 32 bytes
86− // then reuse the resulting 2 vectors srvcC and srcvD
87− // as the next srcvA and srcvB
80+ /* We'll be able to pick-up our 9 char elements at src + stride from
81+ * those 32 bytes then reuse the resulting 2 vectors srvcC and srcvD
82+ * as the next srcvA and srcvB. */
8883 src_0 = vec_ld(stride + 0, src);
8984 src_1 = vec_ld(stride + 16, src);
9085 srcvC = vec_perm(src_0, src_1, vec_lvsl(stride + 0, src));
9186
9287 if (src_really_odd != 0x0000000F) {
93− // if (src & 0xF) == 0xF, then (src+1) is properly aligned
94− // on the second vector.
88+ /* If (src & 0xF) == 0xF, then (src + 1) is properly aligned
89+ * on the second vector. */
9590 srcvD = vec_perm(src_0, src_1, vec_lvsl(stride + 1, src));
9691 } else {
9792 srcvD = src_1;
@@ -100,10 +95,9 @@ void ff_gmc1_altivec(uint8_t *dst /* align 8 */, uint8_t *src /* align1 */, int · 2 unmodified lines
10095 srcvC = vec_mergeh(vczero, srcvC);
10196 srcvD = vec_mergeh(vczero, srcvD);
10297
103−
104− // OK, now we (finally) do the math :-)
105− // those four instructions replaces 32 int muls & 32 int adds.
106− // isn't AltiVec nice ?
98+ /* OK, now we (finally) do the math :-)
99+ * Those four instructions replace 32 int muls & 32 int adds.
100+ * Isn't AltiVec nice? */
107101 tempA = vec_mladd((vector unsigned short)srcvA, Av, rounderV);
108102 tempB = vec_mladd((vector unsigned short)srcvB, Bv, tempA);
109103 tempC = vec_mladd((vector unsigned short)srcvC, Cv, tempB);
libavcodec/ppc/idct_altivec.c+4−9
@@ -18,24 +18,19 @@ · 17 unmodified lines
1818 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1919 */
2020
21−/*
22− * NOTE: This code is based on GPL code from the libmpeg2 project. The
21+/* NOTE: This code is based on GPL code from the libmpeg2 project. The
2322 * author, Michel Lespinasses, has given explicit permission to release
2423 * under LGPL as part of FFmpeg.
25− */
26−
27−/*
24+ *
2825 * FFmpeg integration by Dieter Shirley
2926 *
3027 * This file is a direct copy of the AltiVec IDCT module from the libmpeg2
3128 * project. I've deleted all of the libmpeg2-specific code, renamed the
3229 * functions and reordered the function parameters. The only change to the
3330 * IDCT function itself was to factor out the partial transposition, and to
34− * perform a full transpose at the end of the function.
35− */
36−
31+ * perform a full transpose at the end of the function. */
3732
38−#include <stdlib.h> /* malloc(), free() */
33+#include <stdlib.h>
3934 #include <string.h>
4035 #include "config.h"
4136 #if HAVE_ALTIVEC_H
libavcodec/ppc/int_altivec.c+7−7
@@ -19,9 +19,9 @@ · 18 unmodified lines
1919 */
2020
2121 /**
22− ** @file
23− ** integer misc ops.
24− **/
22+ * @file
23+ * miscellaneous integer operations
24+ */
2525
2626 #include "config.h"
2727 #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
4343 int32_t score[4];
4444 } u;
4545 u.vscore = vec_splat_s32(0);
46−//
47−//XXX lazy way, fix it later
46+
47+// XXX lazy way, fix it later
4848
4949 #define vec_unaligned_load(b) \
5050 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
5252 size16 = size >> 4;
5353 while(size16) {
5454 // score += (pix1[i]-pix2[i])*(pix1[i]-pix2[i]);
55− //load pix1 and the first batch of pix2
55+ // load pix1 and the first batch of pix2
5656
5757 vpix1 = vec_unaligned_load(pix1);
5858 vpix2 = vec_unaligned_load(pix2);
5959 pix2 += 8;
60− //unpack
60+ // unpack
6161 vpix1h = vec_unpackh(vpix1);
6262 vdiff = vec_sub(vpix1h, vpix2);
6363 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