00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "libavcodec/dsputil.h"
00024 #include "dsputil_ppc.h"
00025 #include "util_altivec.h"
00026 #include "types_altivec.h"
00027 #include "dsputil_altivec.h"
00028
00029
00030
00031
00032
00033 #define GMC1_PERF_COND (h==8)
00034 void gmc1_altivec(uint8_t *dst , uint8_t *src , int stride, int h, int x16, int y16, int rounder)
00035 {
00036 POWERPC_PERF_DECLARE(altivec_gmc1_num, GMC1_PERF_COND);
00037 const DECLARE_ALIGNED(16, unsigned short, rounder_a) = rounder;
00038 const DECLARE_ALIGNED(16, unsigned short, ABCD)[8] =
00039 {
00040 (16-x16)*(16-y16),
00041 ( x16)*(16-y16),
00042 (16-x16)*( y16),
00043 ( x16)*( y16),
00044 0, 0, 0, 0
00045 };
00046 register const vector unsigned char vczero = (const vector unsigned char)vec_splat_u8(0);
00047 register const vector unsigned short vcsr8 = (const vector unsigned short)vec_splat_u16(8);
00048 register vector unsigned char dstv, dstv2, src_0, src_1, srcvA, srcvB, srcvC, srcvD;
00049 register vector unsigned short Av, Bv, Cv, Dv, rounderV, tempA, tempB, tempC, tempD;
00050 int i;
00051 unsigned long dst_odd = (unsigned long)dst & 0x0000000F;
00052 unsigned long src_really_odd = (unsigned long)src & 0x0000000F;
00053
00054
00055 POWERPC_PERF_START_COUNT(altivec_gmc1_num, GMC1_PERF_COND);
00056
00057 tempA = vec_ld(0, (unsigned short*)ABCD);
00058 Av = vec_splat(tempA, 0);
00059 Bv = vec_splat(tempA, 1);
00060 Cv = vec_splat(tempA, 2);
00061 Dv = vec_splat(tempA, 3);
00062
00063 rounderV = vec_splat((vec_u16)vec_lde(0, &rounder_a), 0);
00064
00065
00066
00067
00068
00069
00070 src_0 = vec_ld(0, src);
00071 src_1 = vec_ld(16, src);
00072 srcvA = vec_perm(src_0, src_1, vec_lvsl(0, src));
00073
00074 if (src_really_odd != 0x0000000F) {
00075
00076
00077 srcvB = vec_perm(src_0, src_1, vec_lvsl(1, src));
00078 } else {
00079 srcvB = src_1;
00080 }
00081 srcvA = vec_mergeh(vczero, srcvA);
00082 srcvB = vec_mergeh(vczero, srcvB);
00083
00084 for(i=0; i<h; i++) {
00085 dst_odd = (unsigned long)dst & 0x0000000F;
00086 src_really_odd = (((unsigned long)src) + stride) & 0x0000000F;
00087
00088 dstv = vec_ld(0, dst);
00089
00090
00091
00092
00093
00094 src_0 = vec_ld(stride + 0, src);
00095 src_1 = vec_ld(stride + 16, src);
00096 srcvC = vec_perm(src_0, src_1, vec_lvsl(stride + 0, src));
00097
00098 if (src_really_odd != 0x0000000F) {
00099
00100
00101 srcvD = vec_perm(src_0, src_1, vec_lvsl(stride + 1, src));
00102 } else {
00103 srcvD = src_1;
00104 }
00105
00106 srcvC = vec_mergeh(vczero, srcvC);
00107 srcvD = vec_mergeh(vczero, srcvD);
00108
00109
00110
00111
00112
00113 tempA = vec_mladd((vector unsigned short)srcvA, Av, rounderV);
00114 tempB = vec_mladd((vector unsigned short)srcvB, Bv, tempA);
00115 tempC = vec_mladd((vector unsigned short)srcvC, Cv, tempB);
00116 tempD = vec_mladd((vector unsigned short)srcvD, Dv, tempC);
00117
00118 srcvA = srcvC;
00119 srcvB = srcvD;
00120
00121 tempD = vec_sr(tempD, vcsr8);
00122
00123 dstv2 = vec_pack(tempD, (vector unsigned short)vczero);
00124
00125 if (dst_odd) {
00126 dstv2 = vec_perm(dstv, dstv2, vcprm(0,1,s0,s1));
00127 } else {
00128 dstv2 = vec_perm(dstv, dstv2, vcprm(s0,s1,2,3));
00129 }
00130
00131 vec_st(dstv2, 0, dst);
00132
00133 dst += stride;
00134 src += stride;
00135 }
00136
00137 POWERPC_PERF_STOP_COUNT(altivec_gmc1_num, GMC1_PERF_COND);
00138 }