History

Merge commit '30f3f959879eee7890973e8cc9ce076450ced111'

* commit '30f3f959879eee7890973e8cc9ce076450ced111': ppc: dsputil: K&R formatting cosmetics

Michael Niedermayer committed 12 years ago

Commit 13405ec2 parents 047cf46 30f3f953 files · +429 −391Browse files

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

Unified · Split

3 files
  1. libavcodec/ppc/dsputil_altivec.c +394 −355
  2. libavcodec/ppc/dsputil_altivec.h +7 −5
  3. libavcodec/ppc/dsputil_ppc.c +28 −31
libavcodec/ppc/dsputil_altivec.c+394−355
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 #if HAVE_ALTIVEC_H
2525 #include <altivec.h>
2626 #endif
27+
2728 #include "libavutil/attributes.h"
2829 #include "libavutil/ppc/types_altivec.h"
2930 #include "libavutil/ppc/util_altivec.h"
@@ -31,11 +32,13 @@ · 1 unmodified line
3132 #include "libavcodec/dsputil.h"
3233 #include "dsputil_altivec.h"
3334
34−static int sad16_x2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
35+static int sad16_x2_altivec(void *v, uint8_t *pix1, uint8_t *pix2,
36+ int line_size, int h)
3537 {
3638 int i;
3739 int s;
38− const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0);
40+ const vector unsigned char zero =
41+ (const vector unsigned char) vec_splat_u8(0);
3942 vector unsigned char perm1 = vec_lvsl(0, pix2);
4043 vector unsigned char perm2 = vec_add(perm1, vec_splat_u8(1));
4144 vector unsigned char pix2l, pix2r;
@@ -44,13 +47,13 @@ static int sad16_x2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size · 2 unmodified lines
4447 vector signed int sumdiffs;
4548
4649 s = 0;
47− sad = (vector unsigned int)vec_splat_u32(0);
50+ sad = (vector unsigned int) vec_splat_u32(0);
4851 for (i = 0; i < h; i++) {
4952 /* Read unaligned pixels into our vectors. The vectors are as follows:
5053 * pix1v: pix1[0] - pix1[15]
5154 * pix2v: pix2[0] - pix2[15] pix2iv: pix2[1] - pix2[16] */
52− pix1v = vec_ld( 0, pix1);
53− pix2l = vec_ld( 0, pix2);
55+ pix1v = vec_ld(0, pix1);
56+ pix2l = vec_ld(0, pix2);
5457 pix2r = vec_ld(16, pix2);
5558 pix2v = vec_perm(pix2l, pix2r, perm1);
5659 pix2iv = vec_perm(pix2l, pix2r, perm2);
@@ -75,11 +78,13 @@ static int sad16_x2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size · 18 unmodified lines
7578 return s;
7679 }
7780
78−static int sad16_y2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
81+static int sad16_y2_altivec(void *v, uint8_t *pix1, uint8_t *pix2,
82+ int line_size, int h)
7983 {
8084 int i;
8185 int s;
82− const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0);
86+ const vector unsigned char zero =
87+ (const vector unsigned char) vec_splat_u8(0);
8388 vector unsigned char perm = vec_lvsl(0, pix2);
8489 vector unsigned char pix2l, pix2r;
8590 vector unsigned char pix1v, pix2v, pix3v, avgv, t5;
@@ -88,7 +93,7 @@ static int sad16_y2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size · 2 unmodified lines
8893 uint8_t *pix3 = pix2 + line_size;
8994
9095 s = 0;
91− sad = (vector unsigned int)vec_splat_u32(0);
96+ sad = (vector unsigned int) vec_splat_u32(0);
9297
9398 /* Due to the fact that pix3 = pix2 + line_size, the pix3 of one
9499 * iteration becomes pix2 in the next iteration. We can use this
@@ -97,7 +102,7 @@ static int sad16_y2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size · 2 unmodified lines
97102 * Read unaligned pixels into our vectors. The vectors are as follows:
98103 * pix2v: pix2[0] - pix2[15]
99104 * Split the pixel vectors into shorts. */
100− pix2l = vec_ld( 0, pix2);
105+ pix2l = vec_ld(0, pix2);
101106 pix2r = vec_ld(15, pix2);
102107 pix2v = vec_perm(pix2l, pix2r, perm);
103108
@@ -105,9 +110,9 @@ static int sad16_y2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size · 1 unmodified line
105110 /* Read unaligned pixels into our vectors. The vectors are as follows:
106111 * pix1v: pix1[0] - pix1[15]
107112 * pix3v: pix3[0] - pix3[15] */
108− pix1v = vec_ld(0, pix1);
113+ pix1v = vec_ld(0, pix1);
109114
110− pix2l = vec_ld( 0, pix3);
115+ pix2l = vec_ld(0, pix3);
111116 pix2r = vec_ld(15, pix3);
112117 pix3v = vec_perm(pix2l, pix2r, perm);
113118
@@ -123,7 +128,6 @@ static int sad16_y2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size · 9 unmodified lines
123128 pix1 += line_size;
124129 pix2v = pix3v;
125130 pix3 += line_size;
126−
127131 }
128132
129133 /* Sum up the four partial sums, and put the result into s. */
@@ -133,13 +137,16 @@ static int sad16_y2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size · 3 unmodified lines
133137 return s;
134138 }
135139
136−static int sad16_xy2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
140+static int sad16_xy2_altivec(void *v, uint8_t *pix1, uint8_t *pix2,
141+ int line_size, int h)
137142 {
138143 int i;
139144 int s;
140145 uint8_t *pix3 = pix2 + line_size;
141− const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0);
142− const vector unsigned short two = (const vector unsigned short)vec_splat_u16(2);
146+ const vector unsigned char zero =
147+ (const vector unsigned char) vec_splat_u8(0);
148+ const vector unsigned short two =
149+ (const vector unsigned short) vec_splat_u16(2);
143150 vector unsigned char avgv, t5;
144151 vector unsigned char perm1 = vec_lvsl(0, pix2);
145152 vector unsigned char perm2 = vec_add(perm1, vec_splat_u8(1));
@@ -152,7 +159,7 @@ static int sad16_xy2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_siz · 6 unmodified lines
152159 vector unsigned int sad;
153160 vector signed int sumdiffs;
154161
155− sad = (vector unsigned int)vec_splat_u32(0);
162+ sad = (vector unsigned int) vec_splat_u32(0);
156163
157164 s = 0;
158165
@@ -163,7 +170,7 @@ static int sad16_xy2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_siz · 4 unmodified lines
163170 * Read unaligned pixels into our vectors. The vectors are as follows:
164171 * pix2v: pix2[0] - pix2[15] pix2iv: pix2[1] - pix2[16]
165172 * Split the pixel vectors into shorts. */
166− pix2l = vec_ld( 0, pix2);
173+ pix2l = vec_ld(0, pix2);
167174 pix2r = vec_ld(16, pix2);
168175 pix2v = vec_perm(pix2l, pix2r, perm1);
169176 pix2iv = vec_perm(pix2l, pix2r, perm2);
@@ -172,16 +179,16 @@ static int sad16_xy2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_siz · 2 unmodified lines
172179 pix2lv = (vector unsigned short) vec_mergel(zero, pix2v);
173180 pix2ihv = (vector unsigned short) vec_mergeh(zero, pix2iv);
174181 pix2ilv = (vector unsigned short) vec_mergel(zero, pix2iv);
175− t1 = vec_add(pix2hv, pix2ihv);
176− t2 = vec_add(pix2lv, pix2ilv);
182+ t1 = vec_add(pix2hv, pix2ihv);
183+ t2 = vec_add(pix2lv, pix2ilv);
177184
178185 for (i = 0; i < h; i++) {
179186 /* Read unaligned pixels into our vectors. The vectors are as follows:
180187 * pix1v: pix1[0] - pix1[15]
181188 * pix3v: pix3[0] - pix3[15] pix3iv: pix3[1] - pix3[16] */
182− pix1v = vec_ld(0, pix1);
189+ pix1v = vec_ld(0, pix1);
183190
184− pix2l = vec_ld( 0, pix3);
191+ pix2l = vec_ld(0, pix3);
185192 pix2r = vec_ld(16, pix3);
186193 pix3v = vec_perm(pix2l, pix2r, perm1);
187194 pix3iv = vec_perm(pix2l, pix2r, perm2);
@@ -228,22 +235,23 @@ static int sad16_xy2_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_siz · 40 unmodified lines
228235 return s;
229236 }
230237
231−static int sad16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
238+static int sad16_altivec(void *v, uint8_t *pix1, uint8_t *pix2,
239+ int line_size, int h)
232240 {
233241 int i;
234242 int s;
235− const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
243+ const vector unsigned int zero =
244+ (const vector unsigned int) vec_splat_u32(0);
236245 vector unsigned char perm = vec_lvsl(0, pix2);
237− vector unsigned char t1, t2, t3,t4, t5;
246+ vector unsigned char t1, t2, t3, t4, t5;
238247 vector unsigned int sad;
239248 vector signed int sumdiffs;
240249
241− sad = (vector unsigned int)vec_splat_u32(0);
242−
250+ sad = (vector unsigned int) vec_splat_u32(0);
243251
244252 for (i = 0; i < h; i++) {
245253 /* Read potentially unaligned pixels into t1 and t2. */
246− vector unsigned char pix2l = vec_ld( 0, pix2);
254+ vector unsigned char pix2l = vec_ld(0, pix2);
247255 vector unsigned char pix2r = vec_ld(15, pix2);
248256 t1 = vec_ld(0, pix1);
249257 t2 = vec_perm(pix2l, pix2r, perm);
@@ -268,19 +276,23 @@ static int sad16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, i · 18 unmodified lines
268276 return s;
269277 }
270278
271−static int sad8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
279+static int sad8_altivec(void *v, uint8_t *pix1, uint8_t *pix2,
280+ int line_size, int h)
272281 {
273282 int i;
274283 int s;
275− const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
276− const vector unsigned char permclear = (vector unsigned char){255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0};
284+ const vector unsigned int zero =
285+ (const vector unsigned int) vec_splat_u32(0);
286+ const vector unsigned char permclear =
287+ (vector unsigned char)
288+ { 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0 };
277289 vector unsigned char perm1 = vec_lvsl(0, pix1);
278290 vector unsigned char perm2 = vec_lvsl(0, pix2);
279− vector unsigned char t1, t2, t3,t4, t5;
291+ vector unsigned char t1, t2, t3, t4, t5;
280292 vector unsigned int sad;
281293 vector signed int sumdiffs;
282294
283− sad = (vector unsigned int)vec_splat_u32(0);
295+ sad = (vector unsigned int) vec_splat_u32(0);
284296
285297 for (i = 0; i < h; i++) {
286298 /* Read potentially unaligned pixels into t1 and t2.
@@ -317,18 +329,19 @@ static int pix_norm1_altivec(uint8_t *pix, int line_size) · 30 unmodified lines
317329 {
318330 int i;
319331 int s;
320− const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
332+ const vector unsigned int zero =
333+ (const vector unsigned int) vec_splat_u32(0);
321334 vector unsigned char perm = vec_lvsl(0, pix);
322335 vector unsigned char pixv;
323336 vector unsigned int sv;
324337 vector signed int sum;
325338
326− sv = (vector unsigned int)vec_splat_u32(0);
339+ sv = (vector unsigned int) vec_splat_u32(0);
327340
328341 s = 0;
329342 for (i = 0; i < 16; i++) {
330343 /* Read the potentially unaligned pixels. */
331− vector unsigned char pixl = vec_ld( 0, pix);
344+ vector unsigned char pixl = vec_ld(0, pix);
332345 vector unsigned char pixr = vec_ld(15, pix);
333346 pixv = vec_perm(pixl, pixr, perm);
334347
@@ -347,19 +360,23 @@ static int pix_norm1_altivec(uint8_t *pix, int line_size) · 12 unmodified lines
347360
348361 /* Sum of Squared Errors for an 8x8 block, AltiVec-enhanced.
349362 * It's the sad8_altivec code above w/ squaring added. */
350−static int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
363+static int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2,
364+ int line_size, int h)
351365 {
352366 int i;
353367 int s;
354− const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
355− const vector unsigned char permclear = (vector unsigned char){255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0};
368+ const vector unsigned int zero =
369+ (const vector unsigned int) vec_splat_u32(0);
370+ const vector unsigned char permclear =
371+ (vector unsigned char)
372+ { 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0 };
356373 vector unsigned char perm1 = vec_lvsl(0, pix1);
357374 vector unsigned char perm2 = vec_lvsl(0, pix2);
358− vector unsigned char t1, t2, t3,t4, t5;
375+ vector unsigned char t1, t2, t3, t4, t5;
359376 vector unsigned int sum;
360377 vector signed int sumsqr;
361378
362− sum = (vector unsigned int)vec_splat_u32(0);
379+ sum = (vector unsigned int) vec_splat_u32(0);
363380
364381 for (i = 0; i < h; i++) {
365382 /* Read potentially unaligned pixels into t1 and t2.
@@ -397,21 +414,23 @@ static int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, in · 31 unmodified lines
397414
398415 /* Sum of Squared Errors for a 16x16 block, AltiVec-enhanced.
399416 * It's the sad16_altivec code above w/ squaring added. */
400−static int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
417+static int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2,
418+ int line_size, int h)
401419 {
402420 int i;
403421 int s;
404− const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
422+ const vector unsigned int zero =
423+ (const vector unsigned int) vec_splat_u32(0);
405424 vector unsigned char perm = vec_lvsl(0, pix2);
406− vector unsigned char t1, t2, t3,t4, t5;
425+ vector unsigned char t1, t2, t3, t4, t5;
407426 vector unsigned int sum;
408427 vector signed int sumsqr;
409428
410− sum = (vector unsigned int)vec_splat_u32(0);
429+ sum = (vector unsigned int) vec_splat_u32(0);
411430
412431 for (i = 0; i < h; i++) {
413432 /* Read potentially unaligned pixels into t1 and t2. */
414− vector unsigned char pix2l = vec_ld( 0, pix2);
433+ vector unsigned char pix2l = vec_ld(0, pix2);
415434 vector unsigned char pix2r = vec_ld(15, pix2);
416435 t1 = vec_ld(0, pix1);
417436 t2 = vec_perm(pix2l, pix2r, perm);
@@ -439,9 +458,10 @@ static int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, i · 21 unmodified lines
439458 return s;
440459 }
441460
442−static int pix_sum_altivec(uint8_t * pix, int line_size)
461+static int pix_sum_altivec(uint8_t *pix, int line_size)
443462 {
444− const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
463+ const vector unsigned int zero =
464+ (const vector unsigned int) vec_splat_u32(0);
445465 vector unsigned char perm = vec_lvsl(0, pix);
446466 vector unsigned char t1;
447467 vector unsigned int sad;
@@ -450,11 +470,11 @@ static int pix_sum_altivec(uint8_t * pix, int line_size) · 2 unmodified lines
450470 int i;
451471 int s;
452472
453− sad = (vector unsigned int)vec_splat_u32(0);
473+ sad = (vector unsigned int) vec_splat_u32(0);
454474
455475 for (i = 0; i < 16; i++) {
456476 /* Read the potentially unaligned 16 pixels into t1. */
457− vector unsigned char pixl = vec_ld( 0, pix);
477+ vector unsigned char pixl = vec_ld(0, pix);
458478 vector unsigned char pixr = vec_ld(15, pix);
459479 t1 = vec_perm(pixl, pixr, perm);
460480
@@ -472,72 +492,72 @@ static int pix_sum_altivec(uint8_t * pix, int line_size) · 11 unmodified lines
472492 return s;
473493 }
474494
475−static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels, int line_size)
495+static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels,
496+ int line_size)
476497 {
477498 int i;
478499 vector unsigned char perm = vec_lvsl(0, pixels);
479500 vector unsigned char bytes;
480− const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0);
501+ const vector unsigned char zero =
502+ (const vector unsigned char) vec_splat_u8(0);
481503 vector signed short shorts;
482504
483505 for (i = 0; i < 8; i++) {
484506 /* Read potentially unaligned pixels.
485507 * We're reading 16 pixels, and actually only want 8,
486508 * but we simply ignore the extras. */
487− // Read potentially unaligned pixels.
488− // We're reading 16 pixels, and actually only want 8,
489− // but we simply ignore the extras.
490509 vector unsigned char pixl = vec_ld(0, pixels);
491510 vector unsigned char pixr = vec_ld(7, pixels);
492511 bytes = vec_perm(pixl, pixr, perm);
493512
494513 // Convert the bytes into shorts.
495− shorts = (vector signed short)vec_mergeh(zero, bytes);
514+ shorts = (vector signed short) vec_mergeh(zero, bytes);
496515
497516 // Save the data to the block, we assume the block is 16-byte aligned.
498− vec_st(shorts, i*16, (vector signed short*)block);
517+ vec_st(shorts, i * 16, (vector signed short *) block);
499518
500519 pixels += line_size;
501520 }
502521 }
503522
504523 static void diff_pixels_altivec(int16_t *restrict block, const uint8_t *s1,
505− const uint8_t *s2, int stride)
524+ const uint8_t *s2, int stride)
506525 {
507526 int i;
508527 vector unsigned char perm1 = vec_lvsl(0, s1);
509528 vector unsigned char perm2 = vec_lvsl(0, s2);
510529 vector unsigned char bytes, pixl, pixr;
511− const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0);
530+ const vector unsigned char zero =
531+ (const vector unsigned char) vec_splat_u8(0);
512532 vector signed short shorts1, shorts2;
513533
514534 for (i = 0; i < 4; i++) {
515535 /* Read potentially unaligned pixels.
516536 * We're reading 16 pixels, and actually only want 8,
517537 * but we simply ignore the extras. */
518− pixl = vec_ld( 0, s1);
519− pixr = vec_ld(15, s1);
538+ pixl = vec_ld(0, s1);
539+ pixr = vec_ld(15, s1);
520540 bytes = vec_perm(pixl, pixr, perm1);
521541
522542 // Convert the bytes into shorts.
523− shorts1 = (vector signed short)vec_mergeh(zero, bytes);
543+ shorts1 = (vector signed short) vec_mergeh(zero, bytes);
524544
525545 // Do the same for the second block of pixels.
526− pixl = vec_ld( 0, s2);
527− pixr = vec_ld(15, s2);
546+ pixl = vec_ld(0, s2);
547+ pixr = vec_ld(15, s2);
528548 bytes = vec_perm(pixl, pixr, perm2);
529549
530550 // Convert the bytes into shorts.
531− shorts2 = (vector signed short)vec_mergeh(zero, bytes);
551+ shorts2 = (vector signed short) vec_mergeh(zero, bytes);
532552
533553 // Do the subtraction.
534554 shorts1 = vec_sub(shorts1, shorts2);
535555
536556 // Save the data to the block, we assume the block is 16-byte aligned.
537− vec_st(shorts1, 0, (vector signed short*)block);
557+ vec_st(shorts1, 0, (vector signed short *) block);
538558
539− s1 += stride;
540− s2 += stride;
559+ s1 += stride;
560+ s2 += stride;
541561 block += 8;
542562
543563 /* The code below is a copy of the code above...
@@ -546,35 +566,35 @@ static void diff_pixels_altivec(int16_t *restrict block, const uint8_t *s1, · 2 unmodified lines
546566 /* Read potentially unaligned pixels.
547567 * We're reading 16 pixels, and actually only want 8,
548568 * but we simply ignore the extras. */
549− pixl = vec_ld( 0, s1);
550− pixr = vec_ld(15, s1);
569+ pixl = vec_ld(0, s1);
570+ pixr = vec_ld(15, s1);
551571 bytes = vec_perm(pixl, pixr, perm1);
552572
553573 // Convert the bytes into shorts.
554− shorts1 = (vector signed short)vec_mergeh(zero, bytes);
574+ shorts1 = (vector signed short) vec_mergeh(zero, bytes);
555575
556576 // Do the same for the second block of pixels.
557− pixl = vec_ld( 0, s2);
558− pixr = vec_ld(15, s2);
577+ pixl = vec_ld(0, s2);
578+ pixr = vec_ld(15, s2);
559579 bytes = vec_perm(pixl, pixr, perm2);
560580
561581 // Convert the bytes into shorts.
562− shorts2 = (vector signed short)vec_mergeh(zero, bytes);
582+ shorts2 = (vector signed short) vec_mergeh(zero, bytes);
563583
564584 // Do the subtraction.
565585 shorts1 = vec_sub(shorts1, shorts2);
566586
567587 // Save the data to the block, we assume the block is 16-byte aligned.
568− vec_st(shorts1, 0, (vector signed short*)block);
588+ vec_st(shorts1, 0, (vector signed short *) block);
569589
570− s1 += stride;
571− s2 += stride;
590+ s1 += stride;
591+ s2 += stride;
572592 block += 8;
573593 }
574594 }
575595
576−
577−static void clear_block_altivec(int16_t *block) {
596+static void clear_block_altivec(int16_t *block)
597+{
578598 LOAD_ZERO;
579599 vec_st(zero_s16v, 0, block);
580600 vec_st(zero_s16v, 16, block);
@@ -586,124 +606,128 @@ static void clear_block_altivec(int16_t *block) { · 5 unmodified lines
586606 vec_st(zero_s16v, 112, block);
587607 }
588608
589−
590−static void add_bytes_altivec(uint8_t *dst, uint8_t *src, int w) {
609+static void add_bytes_altivec(uint8_t *dst, uint8_t *src, int w)
610+{
591611 register int i;
592612 register vector unsigned char vdst, vsrc;
593613
594614 /* dst and src are 16 bytes-aligned (guaranteed). */
595− for (i = 0 ; (i + 15) < w ; i+=16) {
596− vdst = vec_ld(i, (unsigned char*)dst);
597− vsrc = vec_ld(i, (unsigned char*)src);
615+ for (i = 0; (i + 15) < w; i += 16) {
616+ vdst = vec_ld(i, (unsigned char *) dst);
617+ vsrc = vec_ld(i, (unsigned char *) src);
598618 vdst = vec_add(vsrc, vdst);
599− vec_st(vdst, i, (unsigned char*)dst);
619+ vec_st(vdst, i, (unsigned char *) dst);
600620 }
601621 /* If w is not a multiple of 16. */
602− for (; (i < w) ; i++) {
622+ for (; (i < w); i++)
603623 dst[i] = src[i];
604− }
605624 }
606625
607−static int hadamard8_diff8x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){
626+static int hadamard8_diff8x8_altivec(/* MpegEncContext */ void *s, uint8_t *dst,
627+ uint8_t *src, int stride, int h)
628+{
608629 int sum;
609630 register const vector unsigned char vzero =
610− (const vector unsigned char)vec_splat_u8(0);
631+ (const vector unsigned char) vec_splat_u8(0);
611632 register vector signed short temp0, temp1, temp2, temp3, temp4,
612633 temp5, temp6, temp7;
613634 {
614− register const vector signed short vprod1 =(const vector signed short)
615− { 1,-1, 1,-1, 1,-1, 1,-1 };
616− register const vector signed short vprod2 =(const vector signed short)
617− { 1, 1,-1,-1, 1, 1,-1,-1 };
618− register const vector signed short vprod3 =(const vector signed short)
619− { 1, 1, 1, 1,-1,-1,-1,-1 };
620− register const vector unsigned char perm1 = (const vector unsigned char)
621− {0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
622− 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D};
623− register const vector unsigned char perm2 = (const vector unsigned char)
624− {0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03,
625− 0x0C, 0x0D, 0x0E, 0x0F, 0x08, 0x09, 0x0A, 0x0B};
626− register const vector unsigned char perm3 = (const vector unsigned char)
627− {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
628− 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
629−
630−#define ONEITERBUTTERFLY(i, res) \
631− { \
632− register vector unsigned char src1, src2, srcO; \
633− register vector unsigned char dst1, dst2, dstO; \
634− register vector signed short srcV, dstV; \
635− register vector signed short but0, but1, but2, op1, op2, op3; \
636− src1 = vec_ld(stride * i, src); \
637− src2 = vec_ld((stride * i) + 15, src); \
638− srcO = vec_perm(src1, src2, vec_lvsl(stride * i, src)); \
639− dst1 = vec_ld(stride * i, dst); \
640− dst2 = vec_ld((stride * i) + 15, dst); \
641− dstO = vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \
642− /* Promote the unsigned chars to signed shorts. */ \
643− /* We're in the 8x8 function, we only care for the first 8. */ \
644− srcV = (vector signed short)vec_mergeh((vector signed char)vzero, \
645− (vector signed char)srcO); \
646− dstV = (vector signed short)vec_mergeh((vector signed char)vzero, \
647− (vector signed char)dstO); \
648− /* subtractions inside the first butterfly */ \
649− but0 = vec_sub(srcV, dstV); \
650− op1 = vec_perm(but0, but0, perm1); \
651− but1 = vec_mladd(but0, vprod1, op1); \
652− op2 = vec_perm(but1, but1, perm2); \
653− but2 = vec_mladd(but1, vprod2, op2); \
654− op3 = vec_perm(but2, but2, perm3); \
655− res = vec_mladd(but2, vprod3, op3); \
635+ register const vector signed short vprod1 =
636+ (const vector signed short) { 1, -1, 1, -1, 1, -1, 1, -1 };
637+ register const vector signed short vprod2 =
638+ (const vector signed short) { 1, 1, -1, -1, 1, 1, -1, -1 };
639+ register const vector signed short vprod3 =
640+ (const vector signed short) { 1, 1, 1, 1, -1, -1, -1, -1 };
641+ register const vector unsigned char perm1 =
642+ (const vector unsigned char)
643+ { 0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
644+ 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D };
645+ register const vector unsigned char perm2 =
646+ (const vector unsigned char)
647+ { 0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03,
648+ 0x0C, 0x0D, 0x0E, 0x0F, 0x08, 0x09, 0x0A, 0x0B };
649+ register const vector unsigned char perm3 =
650+ (const vector unsigned char)
651+ { 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
652+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
653+
654+#define ONEITERBUTTERFLY(i, res) \
655+ { \
656+ register vector unsigned char src1, src2, srcO; \
657+ register vector unsigned char dst1, dst2, dstO; \
658+ register vector signed short srcV, dstV; \
659+ register vector signed short but0, but1, but2, op1, op2, op3; \
660+ src1 = vec_ld(stride * i, src); \
661+ src2 = vec_ld((stride * i) + 15, src); \
662+ srcO = vec_perm(src1, src2, vec_lvsl(stride * i, src)); \
663+ dst1 = vec_ld(stride * i, dst); \
664+ dst2 = vec_ld((stride * i) + 15, dst); \
665+ dstO = vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \
666+ /* Promote the unsigned chars to signed shorts. */ \
667+ /* We're in the 8x8 function, we only care for the first 8. */ \
668+ srcV = (vector signed short) vec_mergeh((vector signed char) vzero, \
669+ (vector signed char) srcO); \
670+ dstV = (vector signed short) vec_mergeh((vector signed char) vzero, \
671+ (vector signed char) dstO); \
672+ /* subtractions inside the first butterfly */ \
673+ but0 = vec_sub(srcV, dstV); \
674+ op1 = vec_perm(but0, but0, perm1); \
675+ but1 = vec_mladd(but0, vprod1, op1); \
676+ op2 = vec_perm(but1, but1, perm2); \
677+ but2 = vec_mladd(but1, vprod2, op2); \
678+ op3 = vec_perm(but2, but2, perm3); \
679+ res = vec_mladd(but2, vprod3, op3); \
656680 }
657− ONEITERBUTTERFLY(0, temp0);
658− ONEITERBUTTERFLY(1, temp1);
659− ONEITERBUTTERFLY(2, temp2);
660− ONEITERBUTTERFLY(3, temp3);
661− ONEITERBUTTERFLY(4, temp4);
662− ONEITERBUTTERFLY(5, temp5);
663− ONEITERBUTTERFLY(6, temp6);
664− ONEITERBUTTERFLY(7, temp7);
681+ ONEITERBUTTERFLY(0, temp0);
682+ ONEITERBUTTERFLY(1, temp1);
683+ ONEITERBUTTERFLY(2, temp2);
684+ ONEITERBUTTERFLY(3, temp3);
685+ ONEITERBUTTERFLY(4, temp4);
686+ ONEITERBUTTERFLY(5, temp5);
687+ ONEITERBUTTERFLY(6, temp6);
688+ ONEITERBUTTERFLY(7, temp7);
665689 }
666690 #undef ONEITERBUTTERFLY
667691 {
668− register vector signed int vsum;
669− register vector signed short line0 = vec_add(temp0, temp1);
670− register vector signed short line1 = vec_sub(temp0, temp1);
671− register vector signed short line2 = vec_add(temp2, temp3);
672− register vector signed short line3 = vec_sub(temp2, temp3);
673− register vector signed short line4 = vec_add(temp4, temp5);
674− register vector signed short line5 = vec_sub(temp4, temp5);
675− register vector signed short line6 = vec_add(temp6, temp7);
676− register vector signed short line7 = vec_sub(temp6, temp7);
677−
678− register vector signed short line0B = vec_add(line0, line2);
679− register vector signed short line2B = vec_sub(line0, line2);
680− register vector signed short line1B = vec_add(line1, line3);
681− register vector signed short line3B = vec_sub(line1, line3);
682− register vector signed short line4B = vec_add(line4, line6);
683− register vector signed short line6B = vec_sub(line4, line6);
684− register vector signed short line5B = vec_add(line5, line7);
685− register vector signed short line7B = vec_sub(line5, line7);
686−
687− register vector signed short line0C = vec_add(line0B, line4B);
688− register vector signed short line4C = vec_sub(line0B, line4B);
689− register vector signed short line1C = vec_add(line1B, line5B);
690− register vector signed short line5C = vec_sub(line1B, line5B);
691− register vector signed short line2C = vec_add(line2B, line6B);
692− register vector signed short line6C = vec_sub(line2B, line6B);
693− register vector signed short line3C = vec_add(line3B, line7B);
694− register vector signed short line7C = vec_sub(line3B, line7B);
695−
696− vsum = vec_sum4s(vec_abs(line0C), vec_splat_s32(0));
697− vsum = vec_sum4s(vec_abs(line1C), vsum);
698− vsum = vec_sum4s(vec_abs(line2C), vsum);
699− vsum = vec_sum4s(vec_abs(line3C), vsum);
700− vsum = vec_sum4s(vec_abs(line4C), vsum);
701− vsum = vec_sum4s(vec_abs(line5C), vsum);
702− vsum = vec_sum4s(vec_abs(line6C), vsum);
703− vsum = vec_sum4s(vec_abs(line7C), vsum);
704− vsum = vec_sums(vsum, (vector signed int)vzero);
705− vsum = vec_splat(vsum, 3);
706− vec_ste(vsum, 0, &sum);
692+ register vector signed int vsum;
693+ register vector signed short line0 = vec_add(temp0, temp1);
694+ register vector signed short line1 = vec_sub(temp0, temp1);
695+ register vector signed short line2 = vec_add(temp2, temp3);
696+ register vector signed short line3 = vec_sub(temp2, temp3);
697+ register vector signed short line4 = vec_add(temp4, temp5);
698+ register vector signed short line5 = vec_sub(temp4, temp5);
699+ register vector signed short line6 = vec_add(temp6, temp7);
700+ register vector signed short line7 = vec_sub(temp6, temp7);
701+
702+ register vector signed short line0B = vec_add(line0, line2);
703+ register vector signed short line2B = vec_sub(line0, line2);
704+ register vector signed short line1B = vec_add(line1, line3);
705+ register vector signed short line3B = vec_sub(line1, line3);
706+ register vector signed short line4B = vec_add(line4, line6);
707+ register vector signed short line6B = vec_sub(line4, line6);
708+ register vector signed short line5B = vec_add(line5, line7);
709+ register vector signed short line7B = vec_sub(line5, line7);
710+
711+ register vector signed short line0C = vec_add(line0B, line4B);
712+ register vector signed short line4C = vec_sub(line0B, line4B);
713+ register vector signed short line1C = vec_add(line1B, line5B);
714+ register vector signed short line5C = vec_sub(line1B, line5B);
715+ register vector signed short line2C = vec_add(line2B, line6B);
716+ register vector signed short line6C = vec_sub(line2B, line6B);
717+ register vector signed short line3C = vec_add(line3B, line7B);
718+ register vector signed short line7C = vec_sub(line3B, line7B);
719+
720+ vsum = vec_sum4s(vec_abs(line0C), vec_splat_s32(0));
721+ vsum = vec_sum4s(vec_abs(line1C), vsum);
722+ vsum = vec_sum4s(vec_abs(line2C), vsum);
723+ vsum = vec_sum4s(vec_abs(line3C), vsum);
724+ vsum = vec_sum4s(vec_abs(line4C), vsum);
725+ vsum = vec_sum4s(vec_abs(line5C), vsum);
726+ vsum = vec_sum4s(vec_abs(line6C), vsum);
727+ vsum = vec_sum4s(vec_abs(line7C), vsum);
728+ vsum = vec_sums(vsum, (vector signed int) vzero);
729+ vsum = vec_splat(vsum, 3);
730+ vec_ste(vsum, 0, &sum);
707731 }
708732 return sum;
709733 }
@@ -726,7 +750,9 @@ static int hadamard8_diff8x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, u · 16 unmodified lines
726750 * On the 970, the hand-made RA is still a win (around 690 vs. around 780),
727751 * but xlc goes to around 660 on the regular C code...
728752 */
729−static int hadamard8_diff16x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h) {
753+static int hadamard8_diff16x8_altivec(/* MpegEncContext */ void *s, uint8_t *dst,
754+ uint8_t *src, int stride, int h)
755+{
730756 int sum;
731757 register vector signed short
732758 temp0 __asm__ ("v0"),
@@ -747,186 +773,195 @@ static int hadamard8_diff16x8_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, · 14 unmodified lines
747773 temp6S __asm__ ("v14"),
748774 temp7S __asm__ ("v15");
749775 register const vector unsigned char vzero __asm__ ("v31") =
750− (const vector unsigned char)vec_splat_u8(0);
776+ (const vector unsigned char) vec_splat_u8(0);
751777 {
752− register const vector signed short vprod1 __asm__ ("v16") =
753− (const vector signed short){ 1,-1, 1,-1, 1,-1, 1,-1 };
754− register const vector signed short vprod2 __asm__ ("v17") =
755− (const vector signed short){ 1, 1,-1,-1, 1, 1,-1,-1 };
756− register const vector signed short vprod3 __asm__ ("v18") =
757− (const vector signed short){ 1, 1, 1, 1,-1,-1,-1,-1 };
758− register const vector unsigned char perm1 __asm__ ("v19") =
759− (const vector unsigned char)
760− {0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
761− 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D};
762− register const vector unsigned char perm2 __asm__ ("v20") =
763− (const vector unsigned char)
764− {0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03,
765− 0x0C, 0x0D, 0x0E, 0x0F, 0x08, 0x09, 0x0A, 0x0B};
766− register const vector unsigned char perm3 __asm__ ("v21") =
767− (const vector unsigned char)
768− {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
769− 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
770−
771−#define ONEITERBUTTERFLY(i, res1, res2) \
772− { \
773− register vector unsigned char src1 __asm__ ("v22"), \
774− src2 __asm__ ("v23"), \
775− dst1 __asm__ ("v24"), \
776− dst2 __asm__ ("v25"), \
777− srcO __asm__ ("v22"), \
778− dstO __asm__ ("v23"); \
779− \
780− register vector signed short srcV __asm__ ("v24"), \
781− dstV __asm__ ("v25"), \
782− srcW __asm__ ("v26"), \
783− dstW __asm__ ("v27"), \
784− but0 __asm__ ("v28"), \
785− but0S __asm__ ("v29"), \
786− op1 __asm__ ("v30"), \
787− but1 __asm__ ("v22"), \
788− op1S __asm__ ("v23"), \
789− but1S __asm__ ("v24"), \
790− op2 __asm__ ("v25"), \
791− but2 __asm__ ("v26"), \
792− op2S __asm__ ("v27"), \
793− but2S __asm__ ("v28"), \
794− op3 __asm__ ("v29"), \
795− op3S __asm__ ("v30"); \
796− \
797− src1 = vec_ld(stride * i, src); \
798− src2 = vec_ld((stride * i) + 16, src); \
799− srcO = vec_perm(src1, src2, vec_lvsl(stride * i, src)); \
800− dst1 = vec_ld(stride * i, dst); \
801− dst2 = vec_ld((stride * i) + 16, dst); \
802− dstO = vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \
803− /* Promote the unsigned chars to signed shorts. */ \
804− srcV = (vector signed short)vec_mergeh((vector signed char)vzero, \
805− (vector signed char)srcO); \
806− dstV = (vector signed short)vec_mergeh((vector signed char)vzero, \
807− (vector signed char)dstO); \
808− srcW = (vector signed short)vec_mergel((vector signed char)vzero, \
809− (vector signed char)srcO); \
810− dstW = (vector signed short)vec_mergel((vector signed char)vzero, \
811− (vector signed char)dstO); \
812− /* subtractions inside the first butterfly */ \
813− but0 = vec_sub(srcV, dstV); \
814− but0S = vec_sub(srcW, dstW); \
815− op1 = vec_perm(but0, but0, perm1); \
816− but1 = vec_mladd(but0, vprod1, op1); \
817− op1S = vec_perm(but0S, but0S, perm1); \
818− but1S = vec_mladd(but0S, vprod1, op1S); \
819− op2 = vec_perm(but1, but1, perm2); \
820− but2 = vec_mladd(but1, vprod2, op2); \
821− op2S = vec_perm(but1S, but1S, perm2); \
822− but2S = vec_mladd(but1S, vprod2, op2S); \
823− op3 = vec_perm(but2, but2, perm3); \
824− res1 = vec_mladd(but2, vprod3, op3); \
825− op3S = vec_perm(but2S, but2S, perm3); \
826− res2 = vec_mladd(but2S, vprod3, op3S); \
778+ register const vector signed short vprod1 __asm__ ("v16") =
779+ (const vector signed short) { 1, -1, 1, -1, 1, -1, 1, -1 };
780+
781+ register const vector signed short vprod2 __asm__ ("v17") =
782+ (const vector signed short) { 1, 1, -1, -1, 1, 1, -1, -1 };
783+
784+ register const vector signed short vprod3 __asm__ ("v18") =
785+ (const vector signed short) { 1, 1, 1, 1, -1, -1, -1, -1 };
786+
787+ register const vector unsigned char perm1 __asm__ ("v19") =
788+ (const vector unsigned char)
789+ { 0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
790+ 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D };
791+
792+ register const vector unsigned char perm2 __asm__ ("v20") =
793+ (const vector unsigned char)
794+ { 0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03,
795+ 0x0C, 0x0D, 0x0E, 0x0F, 0x08, 0x09, 0x0A, 0x0B };
796+
797+ register const vector unsigned char perm3 __asm__ ("v21") =
798+ (const vector unsigned char)
799+ { 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
800+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
801+
802+#define ONEITERBUTTERFLY(i, res1, res2) \
803+ { \
804+ register vector unsigned char \
805+ src1 __asm__ ("v22"), \
806+ src2 __asm__ ("v23"), \
807+ dst1 __asm__ ("v24"), \
808+ dst2 __asm__ ("v25"), \
809+ srcO __asm__ ("v22"), \
810+ dstO __asm__ ("v23"); \
811+ \
812+ register vector signed short \
813+ srcV __asm__ ("v24"), \
814+ dstV __asm__ ("v25"), \
815+ srcW __asm__ ("v26"), \
816+ dstW __asm__ ("v27"), \
817+ but0 __asm__ ("v28"), \
818+ but0S __asm__ ("v29"), \
819+ op1 __asm__ ("v30"), \
820+ but1 __asm__ ("v22"), \
821+ op1S __asm__ ("v23"), \
822+ but1S __asm__ ("v24"), \
823+ op2 __asm__ ("v25"), \
824+ but2 __asm__ ("v26"), \
825+ op2S __asm__ ("v27"), \
826+ but2S __asm__ ("v28"), \
827+ op3 __asm__ ("v29"), \
828+ op3S __asm__ ("v30"); \
829+ \
830+ src1 = vec_ld(stride * i, src); \
831+ src2 = vec_ld((stride * i) + 16, src); \
832+ srcO = vec_perm(src1, src2, vec_lvsl(stride * i, src)); \
833+ dst1 = vec_ld(stride * i, dst); \
834+ dst2 = vec_ld((stride * i) + 16, dst); \
835+ dstO = vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \
836+ /* Promote the unsigned chars to signed shorts. */ \
837+ srcV = (vector signed short) vec_mergeh((vector signed char) vzero, \
838+ (vector signed char) srcO); \
839+ dstV = (vector signed short) vec_mergeh((vector signed char) vzero, \
840+ (vector signed char) dstO); \
841+ srcW = (vector signed short) vec_mergel((vector signed char) vzero, \
842+ (vector signed char) srcO); \
843+ dstW = (vector signed short) vec_mergel((vector signed char) vzero, \
844+ (vector signed char) dstO); \
845+ /* subtractions inside the first butterfly */ \
846+ but0 = vec_sub(srcV, dstV); \
847+ but0S = vec_sub(srcW, dstW); \
848+ op1 = vec_perm(but0, but0, perm1); \
849+ but1 = vec_mladd(but0, vprod1, op1); \
850+ op1S = vec_perm(but0S, but0S, perm1); \
851+ but1S = vec_mladd(but0S, vprod1, op1S); \
852+ op2 = vec_perm(but1, but1, perm2); \
853+ but2 = vec_mladd(but1, vprod2, op2); \
854+ op2S = vec_perm(but1S, but1S, perm2); \
855+ but2S = vec_mladd(but1S, vprod2, op2S); \
856+ op3 = vec_perm(but2, but2, perm3); \
857+ res1 = vec_mladd(but2, vprod3, op3); \
858+ op3S = vec_perm(but2S, but2S, perm3); \
859+ res2 = vec_mladd(but2S, vprod3, op3S); \
827860 }
828− ONEITERBUTTERFLY(0, temp0, temp0S);
829− ONEITERBUTTERFLY(1, temp1, temp1S);
830− ONEITERBUTTERFLY(2, temp2, temp2S);
831− ONEITERBUTTERFLY(3, temp3, temp3S);
832− ONEITERBUTTERFLY(4, temp4, temp4S);
833− ONEITERBUTTERFLY(5, temp5, temp5S);
834− ONEITERBUTTERFLY(6, temp6, temp6S);
835− ONEITERBUTTERFLY(7, temp7, temp7S);
861+ ONEITERBUTTERFLY(0, temp0, temp0S);
862+ ONEITERBUTTERFLY(1, temp1, temp1S);
863+ ONEITERBUTTERFLY(2, temp2, temp2S);
864+ ONEITERBUTTERFLY(3, temp3, temp3S);
865+ ONEITERBUTTERFLY(4, temp4, temp4S);
866+ ONEITERBUTTERFLY(5, temp5, temp5S);
867+ ONEITERBUTTERFLY(6, temp6, temp6S);
868+ ONEITERBUTTERFLY(7, temp7, temp7S);
836869 }
837870 #undef ONEITERBUTTERFLY
838871 {
839− register vector signed int vsum;
840− register vector signed short line0S, line1S, line2S, line3S, line4S,
841− line5S, line6S, line7S, line0BS,line2BS,
842− line1BS,line3BS,line4BS,line6BS,line5BS,
843− line7BS,line0CS,line4CS,line1CS,line5CS,
844− line2CS,line6CS,line3CS,line7CS;
845−
846− register vector signed short line0 = vec_add(temp0, temp1);
847− register vector signed short line1 = vec_sub(temp0, temp1);
848− register vector signed short line2 = vec_add(temp2, temp3);
849− register vector signed short line3 = vec_sub(temp2, temp3);
850− register vector signed short line4 = vec_add(temp4, temp5);
851− register vector signed short line5 = vec_sub(temp4, temp5);
852− register vector signed short line6 = vec_add(temp6, temp7);
853− register vector signed short line7 = vec_sub(temp6, temp7);
854−
855− register vector signed short line0B = vec_add(line0, line2);
856− register vector signed short line2B = vec_sub(line0, line2);
857− register vector signed short line1B = vec_add(line1, line3);
858− register vector signed short line3B = vec_sub(line1, line3);
859− register vector signed short line4B = vec_add(line4, line6);
860− register vector signed short line6B = vec_sub(line4, line6);
861− register vector signed short line5B = vec_add(line5, line7);
862− register vector signed short line7B = vec_sub(line5, line7);
863−
864− register vector signed short line0C = vec_add(line0B, line4B);
865− register vector signed short line4C = vec_sub(line0B, line4B);
866− register vector signed short line1C = vec_add(line1B, line5B);
867− register vector signed short line5C = vec_sub(line1B, line5B);
868− register vector signed short line2C = vec_add(line2B, line6B);
869− register vector signed short line6C = vec_sub(line2B, line6B);
870− register vector signed short line3C = vec_add(line3B, line7B);
871− register vector signed short line7C = vec_sub(line3B, line7B);
872−
873− vsum = vec_sum4s(vec_abs(line0C), vec_splat_s32(0));
874− vsum = vec_sum4s(vec_abs(line1C), vsum);
875− vsum = vec_sum4s(vec_abs(line2C), vsum);
876− vsum = vec_sum4s(vec_abs(line3C), vsum);
877− vsum = vec_sum4s(vec_abs(line4C), vsum);
878− vsum = vec_sum4s(vec_abs(line5C), vsum);
879− vsum = vec_sum4s(vec_abs(line6C), vsum);
880− vsum = vec_sum4s(vec_abs(line7C), vsum);
881−
882− line0S = vec_add(temp0S, temp1S);
883− line1S = vec_sub(temp0S, temp1S);
884− line2S = vec_add(temp2S, temp3S);
885− line3S = vec_sub(temp2S, temp3S);
886− line4S = vec_add(temp4S, temp5S);
887− line5S = vec_sub(temp4S, temp5S);
888− line6S = vec_add(temp6S, temp7S);
889− line7S = vec_sub(temp6S, temp7S);
890−
891− line0BS = vec_add(line0S, line2S);
892− line2BS = vec_sub(line0S, line2S);
893− line1BS = vec_add(line1S, line3S);
894− line3BS = vec_sub(line1S, line3S);
895− line4BS = vec_add(line4S, line6S);
896− line6BS = vec_sub(line4S, line6S);
897− line5BS = vec_add(line5S, line7S);
898− line7BS = vec_sub(line5S, line7S);
899−
900− line0CS = vec_add(line0BS, line4BS);
901− line4CS = vec_sub(line0BS, line4BS);
902− line1CS = vec_add(line1BS, line5BS);
903− line5CS = vec_sub(line1BS, line5BS);
904− line2CS = vec_add(line2BS, line6BS);
905− line6CS = vec_sub(line2BS, line6BS);
906− line3CS = vec_add(line3BS, line7BS);
907− line7CS = vec_sub(line3BS, line7BS);
908−
909− vsum = vec_sum4s(vec_abs(line0CS), vsum);
910− vsum = vec_sum4s(vec_abs(line1CS), vsum);
911− vsum = vec_sum4s(vec_abs(line2CS), vsum);
912− vsum = vec_sum4s(vec_abs(line3CS), vsum);
913− vsum = vec_sum4s(vec_abs(line4CS), vsum);
914− vsum = vec_sum4s(vec_abs(line5CS), vsum);
915− vsum = vec_sum4s(vec_abs(line6CS), vsum);
916− vsum = vec_sum4s(vec_abs(line7CS), vsum);
917− vsum = vec_sums(vsum, (vector signed int)vzero);
918− vsum = vec_splat(vsum, 3);
919− vec_ste(vsum, 0, &sum);
872+ register vector signed int vsum;
873+ register vector signed short line0S, line1S, line2S, line3S, line4S,
874+ line5S, line6S, line7S, line0BS, line2BS,
875+ line1BS, line3BS, line4BS, line6BS, line5BS,
876+ line7BS, line0CS, line4CS, line1CS, line5CS,
877+ line2CS, line6CS, line3CS, line7CS;
878+
879+ register vector signed short line0 = vec_add(temp0, temp1);
880+ register vector signed short line1 = vec_sub(temp0, temp1);
881+ register vector signed short line2 = vec_add(temp2, temp3);
882+ register vector signed short line3 = vec_sub(temp2, temp3);
883+ register vector signed short line4 = vec_add(temp4, temp5);
884+ register vector signed short line5 = vec_sub(temp4, temp5);
885+ register vector signed short line6 = vec_add(temp6, temp7);
886+ register vector signed short line7 = vec_sub(temp6, temp7);
887+
888+ register vector signed short line0B = vec_add(line0, line2);
889+ register vector signed short line2B = vec_sub(line0, line2);
890+ register vector signed short line1B = vec_add(line1, line3);
891+ register vector signed short line3B = vec_sub(line1, line3);
892+ register vector signed short line4B = vec_add(line4, line6);
893+ register vector signed short line6B = vec_sub(line4, line6);
894+ register vector signed short line5B = vec_add(line5, line7);
895+ register vector signed short line7B = vec_sub(line5, line7);
896+
897+ register vector signed short line0C = vec_add(line0B, line4B);
898+ register vector signed short line4C = vec_sub(line0B, line4B);
899+ register vector signed short line1C = vec_add(line1B, line5B);
900+ register vector signed short line5C = vec_sub(line1B, line5B);
901+ register vector signed short line2C = vec_add(line2B, line6B);
902+ register vector signed short line6C = vec_sub(line2B, line6B);
903+ register vector signed short line3C = vec_add(line3B, line7B);
904+ register vector signed short line7C = vec_sub(line3B, line7B);
905+
906+ vsum = vec_sum4s(vec_abs(line0C), vec_splat_s32(0));
907+ vsum = vec_sum4s(vec_abs(line1C), vsum);
908+ vsum = vec_sum4s(vec_abs(line2C), vsum);
909+ vsum = vec_sum4s(vec_abs(line3C), vsum);
910+ vsum = vec_sum4s(vec_abs(line4C), vsum);
911+ vsum = vec_sum4s(vec_abs(line5C), vsum);
912+ vsum = vec_sum4s(vec_abs(line6C), vsum);
913+ vsum = vec_sum4s(vec_abs(line7C), vsum);
914+
915+ line0S = vec_add(temp0S, temp1S);
916+ line1S = vec_sub(temp0S, temp1S);
917+ line2S = vec_add(temp2S, temp3S);
918+ line3S = vec_sub(temp2S, temp3S);
919+ line4S = vec_add(temp4S, temp5S);
920+ line5S = vec_sub(temp4S, temp5S);
921+ line6S = vec_add(temp6S, temp7S);
922+ line7S = vec_sub(temp6S, temp7S);
923+
924+ line0BS = vec_add(line0S, line2S);
925+ line2BS = vec_sub(line0S, line2S);
926+ line1BS = vec_add(line1S, line3S);
927+ line3BS = vec_sub(line1S, line3S);
928+ line4BS = vec_add(line4S, line6S);
929+ line6BS = vec_sub(line4S, line6S);
930+ line5BS = vec_add(line5S, line7S);
931+ line7BS = vec_sub(line5S, line7S);
932+
933+ line0CS = vec_add(line0BS, line4BS);
934+ line4CS = vec_sub(line0BS, line4BS);
935+ line1CS = vec_add(line1BS, line5BS);
936+ line5CS = vec_sub(line1BS, line5BS);
937+ line2CS = vec_add(line2BS, line6BS);
938+ line6CS = vec_sub(line2BS, line6BS);
939+ line3CS = vec_add(line3BS, line7BS);
940+ line7CS = vec_sub(line3BS, line7BS);
941+
942+ vsum = vec_sum4s(vec_abs(line0CS), vsum);
943+ vsum = vec_sum4s(vec_abs(line1CS), vsum);
944+ vsum = vec_sum4s(vec_abs(line2CS), vsum);
945+ vsum = vec_sum4s(vec_abs(line3CS), vsum);
946+ vsum = vec_sum4s(vec_abs(line4CS), vsum);
947+ vsum = vec_sum4s(vec_abs(line5CS), vsum);
948+ vsum = vec_sum4s(vec_abs(line6CS), vsum);
949+ vsum = vec_sum4s(vec_abs(line7CS), vsum);
950+ vsum = vec_sums(vsum, (vector signed int) vzero);
951+ vsum = vec_splat(vsum, 3);
952+ vec_ste(vsum, 0, &sum);
920953 }
921954 return sum;
922955 }
923956
924−static int hadamard8_diff16_altivec(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){
957+static int hadamard8_diff16_altivec(/* MpegEncContext */ void *s, uint8_t *dst,
958+ uint8_t *src, int stride, int h)
959+{
925960 int score;
926961 score = hadamard8_diff16x8_altivec(s, dst, src, stride, 8);
927− if (h==16) {
928− dst += 8*stride;
929− src += 8*stride;
962+ if (h == 16) {
963+ dst += 8 * stride;
964+ src += 8 * stride;
930965 score += hadamard8_diff16x8_altivec(s, dst, src, stride, 8);
931966 }
932967 return score;
@@ -941,17 +976,21 @@ av_cold void ff_dsputil_init_altivec(DSPContext *c, AVCodecContext *avctx) · 8 unmodified lines
941976 c->pix_abs[0][3] = sad16_xy2_altivec;
942977 c->pix_abs[0][0] = sad16_altivec;
943978 c->pix_abs[1][0] = sad8_altivec;
944− c->sad[0]= sad16_altivec;
945− c->sad[1]= sad8_altivec;
979+
980+ c->sad[0] = sad16_altivec;
981+ c->sad[1] = sad8_altivec;
982+ c->sse[0] = sse16_altivec;
983+ c->sse[1] = sse8_altivec;
984+
946985 c->pix_norm1 = pix_norm1_altivec;
947− c->sse[1]= sse8_altivec;
948− c->sse[0]= sse16_altivec;
949− c->pix_sum = pix_sum_altivec;
986+ c->pix_sum = pix_sum_altivec;
987+
950988 c->diff_pixels = diff_pixels_altivec;
951− c->add_bytes= add_bytes_altivec;
989+ c->add_bytes = add_bytes_altivec;
990+
952991 if (!high_bit_depth) {
953− c->get_pixels = get_pixels_altivec;
954− c->clear_block = clear_block_altivec;
992+ c->get_pixels = get_pixels_altivec;
993+ c->clear_block = clear_block_altivec;
955994 }
956995
957996 c->hadamard8_diff[0] = hadamard8_diff16_altivec;
libavcodec/ppc/dsputil_altivec.h+7−5
@@ -24,11 +24,13 @@ · 23 unmodified lines
2424 #define AVCODEC_PPC_DSPUTIL_ALTIVEC_H
2525
2626 #include <stdint.h>
27−#include "libavcodec/dsputil.h"
2827
29−void ff_put_pixels16_altivec(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h);
28+#include "libavcodec/dsputil.h"
3029
31−void ff_avg_pixels16_altivec(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h);
30+void ff_avg_pixels16_altivec(uint8_t *block, const uint8_t *pixels,
31+ ptrdiff_t line_size, int h);
32+void ff_put_pixels16_altivec(uint8_t *block, const uint8_t *pixels,
33+ ptrdiff_t line_size, int h);
3234
3335 void ff_fdct_altivec(int16_t *block);
3436 void ff_gmc1_altivec(uint8_t *dst, uint8_t *src, int stride, int h,
@@ -36,7 +38,7 @@ void ff_gmc1_altivec(uint8_t *dst, uint8_t *src, int stride, int h, · 1 unmodified line
3638 void ff_idct_put_altivec(uint8_t *dest, int line_size, int16_t *block);
3739 void ff_idct_add_altivec(uint8_t *dest, int line_size, int16_t *block);
3840
39−void ff_dsputil_init_altivec(DSPContext* c, AVCodecContext *avctx);
40−void ff_int_init_altivec(DSPContext* c, AVCodecContext *avctx);
41+void ff_dsputil_init_altivec(DSPContext *c, AVCodecContext *avctx);
42+void ff_int_init_altivec(DSPContext *c, AVCodecContext *avctx);
4143
4244 #endif /* AVCODEC_PPC_DSPUTIL_ALTIVEC_H */
libavcodec/ppc/dsputil_ppc.c+28−31
@@ -51,23 +51,23 @@ · 50 unmodified lines
5151 */
5252 static void clear_blocks_dcbz32_ppc(int16_t *blocks)
5353 {
54− register int misal = ((unsigned long)blocks & 0x00000010);
54+ register int misal = ((unsigned long) blocks & 0x00000010);
5555 register int i = 0;
56+
5657 if (misal) {
57− ((unsigned long*)blocks)[0] = 0L;
58− ((unsigned long*)blocks)[1] = 0L;
59− ((unsigned long*)blocks)[2] = 0L;
60− ((unsigned long*)blocks)[3] = 0L;
58+ ((unsigned long *) blocks)[0] = 0L;
59+ ((unsigned long *) blocks)[1] = 0L;
60+ ((unsigned long *) blocks)[2] = 0L;
61+ ((unsigned long *) blocks)[3] = 0L;
6162 i += 16;
6263 }
63− for ( ; i < sizeof(int16_t)*6*64-31 ; i += 32) {
64− __asm__ volatile("dcbz %0,%1" : : "b" (blocks), "r" (i) : "memory");
65− }
64+ for (; i < sizeof(int16_t) * 6 * 64 - 31; i += 32)
65+ __asm__ volatile ("dcbz %0,%1" :: "b" (blocks), "r" (i) : "memory");
6666 if (misal) {
67− ((unsigned long*)blocks)[188] = 0L;
68− ((unsigned long*)blocks)[189] = 0L;
69− ((unsigned long*)blocks)[190] = 0L;
70− ((unsigned long*)blocks)[191] = 0L;
67+ ((unsigned long *) blocks)[188] = 0L;
68+ ((unsigned long *) blocks)[189] = 0L;
69+ ((unsigned long *) blocks)[190] = 0L;
70+ ((unsigned long *) blocks)[191] = 0L;
7171 i += 16;
7272 }
7373 }
@@ -77,23 +77,23 @@ static void clear_blocks_dcbz32_ppc(int16_t *blocks) · 3 unmodified lines
7777 #if HAVE_DCBZL
7878 static void clear_blocks_dcbz128_ppc(int16_t *blocks)
7979 {
80− register int misal = ((unsigned long)blocks & 0x0000007f);
80+ register int misal = ((unsigned long) blocks & 0x0000007f);
8181 register int i = 0;
82+
8283 if (misal) {
8384 /* We could probably also optimize this case,
8485 * but there's not much point as the machines
8586 * aren't available yet (2003-06-26). */
86− memset(blocks, 0, sizeof(int16_t)*6*64);
87+ memset(blocks, 0, sizeof(int16_t) * 6 * 64);
88+ } else {
89+ for (; i < sizeof(int16_t) * 6 * 64; i += 128)
90+ __asm__ volatile ("dcbzl %0,%1" :: "b" (blocks), "r" (i) : "memory");
8791 }
88− else
89− for ( ; i < sizeof(int16_t)*6*64 ; i += 128) {
90− __asm__ volatile("dcbzl %0,%1" : : "b" (blocks), "r" (i) : "memory");
91− }
9292 }
9393 #else
9494 static void clear_blocks_dcbz128_ppc(int16_t *blocks)
9595 {
96− memset(blocks, 0, sizeof(int16_t)*6*64);
96+ memset(blocks, 0, sizeof(int16_t) * 6 * 64);
9797 }
9898 #endif
9999
@@ -110,9 +110,8 @@ static long check_dcbzl_effect(void) · 10 unmodified lines
110110 register long i = 0;
111111 long count = 0;
112112
113− if (!fakedata) {
113+ if (!fakedata)
114114 return 0L;
115− }
116115
117116 fakedata_middle = (fakedata + 512);
118117
@@ -120,12 +119,11 @@ static long check_dcbzl_effect(void) · 1 unmodified line
120119
121120 /* Below the constraint "b" seems to mean "address base register"
122121 * in gcc-3.3 / RS/6000 speaks. Seems to avoid using r0, so.... */
123− __asm__ volatile("dcbzl %0, %1" : : "b" (fakedata_middle), "r" (zero));
122+ __asm__ volatile ("dcbzl %0, %1" :: "b" (fakedata_middle), "r" (zero));
124123
125− for (i = 0; i < 1024 ; i ++) {
126− if (fakedata[i] == (char)0)
124+ for (i = 0; i < 1024; i++)
125+ if (fakedata[i] == (char) 0)
127126 count++;
128− }
129127
130128 av_free(fakedata);
131129
@@ -134,7 +132,7 @@ static long check_dcbzl_effect(void) · 2 unmodified lines
134132 #else
135133 static long check_dcbzl_effect(void)
136134 {
137− return 0;
135+ return 0;
138136 }
139137 #endif
140138
@@ -145,7 +143,7 @@ av_cold void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx) · 4 unmodified lines
145143
146144 // common optimizations whether AltiVec is available or not
147145 if (!high_bit_depth) {
148− switch (check_dcbzl_effect()) {
146+ switch (check_dcbzl_effect()) {
149147 case 32:
150148 c->clear_blocks = clear_blocks_dcbz32_ppc;
151149 break;
@@ -154,7 +152,7 @@ av_cold void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx) · 2 unmodified lines
154152 break;
155153 default:
156154 break;
157− }
155+ }
158156 }
159157
160158 if (PPC_ALTIVEC(mm_flags)) {
@@ -173,11 +171,10 @@ av_cold void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx) · 12 unmodified lines
173171 if (avctx->lowres == 0 && avctx->bits_per_raw_sample <= 8) {
174172 if ((avctx->idct_algo == FF_IDCT_AUTO) ||
175173 (avctx->idct_algo == FF_IDCT_ALTIVEC)) {
176− c->idct_put = ff_idct_put_altivec;
177− c->idct_add = ff_idct_add_altivec;
174+ c->idct_put = ff_idct_put_altivec;
175+ c->idct_add = ff_idct_add_altivec;
178176 c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
179177 }
180178 }
181−
182179 }
183180 }

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