30 #define LP(p) *(uint32_t*)(p)
31 #define LPC(p) *(const uint32_t*)(p)
34 #define UNPACK(ph,pl,tt0,tt1) do { \
35 uint32_t t0,t1; t0=tt0;t1=tt1; \
36 ph = ( (t0 & ~BYTE_VEC32(0x03))>>2) + ( (t1 & ~BYTE_VEC32(0x03))>>2); \
37 pl = (t0 & BYTE_VEC32(0x03)) + (t1 & BYTE_VEC32(0x03)); } while(0)
39 #define rnd_PACK(ph,pl,nph,npl) ph + nph + (((pl + npl + BYTE_VEC32(0x02))>>2) & BYTE_VEC32(0x03))
40 #define no_rnd_PACK(ph,pl,nph,npl) ph + nph + (((pl + npl + BYTE_VEC32(0x01))>>2) & BYTE_VEC32(0x03))
43 #define MERGE1(a,b,ofs) (ofs==0)?a:( ((a)>>(8*ofs))|((b)<<(32-8*ofs)) )
44 #define MERGE2(a,b,ofs) (ofs==3)?b:( ((a)>>(8*(ofs+1)))|((b)<<(32-8*(ofs+1))) )
51 #define put(d,s) d = s
52 #define avg(d,s) d = rnd_avg32(s,d)
57 OP(LP(dest),MERGE1(LPC(ref),LPC(ref+4),ofs)); \
64 OP(LP(dest),LPC(ref)); \
69 #define OP_C(ofs,sz,avg2) \
76 OP(LP(dest+0), MERGE1(t0,t1,ofs)); \
78 OP(LP(dest+4), MERGE1(t1,t0,ofs)); \
81 OP(LP(dest+8), MERGE1(t0,t1,ofs)); \
83 OP(LP(dest+12), MERGE1(t1,t0,ofs)); \
91 #define OP_C0(sz,avg2) \
94 OP(LP(dest+0), LPC(ref+0)); \
95 OP(LP(dest+4), LPC(ref+4)); \
97 OP(LP(dest+8), LPC(ref+8)); \
98 OP(LP(dest+12), LPC(ref+12)); \
105 #define OP_X(ofs,sz,avg2) \
112 OP(LP(dest+0), avg2(MERGE1(t0,t1,ofs),MERGE2(t0,t1,ofs))); \
114 OP(LP(dest+4), avg2(MERGE1(t1,t0,ofs),MERGE2(t1,t0,ofs))); \
117 OP(LP(dest+8), avg2(MERGE1(t0,t1,ofs),MERGE2(t0,t1,ofs))); \
119 OP(LP(dest+12), avg2(MERGE1(t1,t0,ofs),MERGE2(t1,t0,ofs))); \
127 #define OP_Y0(sz,avg2) \
129 uint32_t t0,t1,t2,t3,t; \
141 OP(LP(dest+0), avg2(t0,t)); t0 = t; \
143 OP(LP(dest+4), avg2(t1,t)); t1 = t; \
146 OP(LP(dest+8), avg2(t2,t)); t2 = t; \
148 OP(LP(dest+12), avg2(t3,t)); t3 = t; \
154 #define OP_Y(ofs,sz,avg2) \
156 uint32_t t0,t1,t2,t3,t,w0,w1; \
161 t0 = MERGE1(w0,w1,ofs); \
163 t1 = MERGE1(w1,w0,ofs); \
166 t2 = MERGE1(w0,w1,ofs); \
168 t3 = MERGE1(w1,w0,ofs); \
175 t = MERGE1(w0,w1,ofs); \
176 OP(LP(dest+0), avg2(t0,t)); t0 = t; \
178 t = MERGE1(w1,w0,ofs); \
179 OP(LP(dest+4), avg2(t1,t)); t1 = t; \
182 t = MERGE1(w0,w1,ofs); \
183 OP(LP(dest+8), avg2(t2,t)); t2 = t; \
185 t = MERGE1(w1,w0,ofs); \
186 OP(LP(dest+12), avg2(t3,t)); t3 = t; \
192 #define OP_X0(sz,avg2) OP_X(0,sz,avg2)
193 #define OP_XY0(sz,PACK) OP_XY(0,sz,PACK)
194 #define OP_XY(ofs,sz,PACK) \
196 uint32_t t2,t3,w0,w1; \
197 uint32_t a0,a1,a2,a3,a4,a5,a6,a7; \
202 UNPACK(a0,a1,MERGE1(w0,w1,ofs),MERGE2(w0,w1,ofs)); \
204 UNPACK(a2,a3,MERGE1(w1,w0,ofs),MERGE2(w1,w0,ofs)); \
207 UNPACK(a4,a5,MERGE1(w0,w1,ofs),MERGE2(w0,w1,ofs)); \
209 UNPACK(a6,a7,MERGE1(w1,w0,ofs),MERGE2(w1,w0,ofs)); \
215 UNPACK(t2,t3,MERGE1(w0,w1,ofs),MERGE2(w0,w1,ofs)); \
216 OP(LP(dest+0),PACK(a0,a1,t2,t3)); \
219 UNPACK(t2,t3,MERGE1(w1,w0,ofs),MERGE2(w1,w0,ofs)); \
220 OP(LP(dest+4),PACK(a2,a3,t2,t3)); \
224 UNPACK(t2,t3,MERGE1(w0,w1,ofs),MERGE2(w0,w1,ofs)); \
225 OP(LP(dest+8),PACK(a4,a5,t2,t3)); \
228 UNPACK(t2,t3,MERGE1(w1,w0,ofs),MERGE2(w1,w0,ofs)); \
229 OP(LP(dest+12),PACK(a6,a7,t2,t3)); \
236 #define DEFFUNC(op,rnd,xy,sz,OP_N,avgfunc) \
237 static void op##_##rnd##_pixels##sz##_##xy (uint8_t * dest, const uint8_t * ref, \
238 const ptrdiff_t stride, int height) \
240 switch((int)ref&3) { \
241 case 0:OP_N##0(sz,rnd##_##avgfunc); return; \
242 case 1:OP_N(1,sz,rnd##_##avgfunc); return; \
243 case 2:OP_N(2,sz,rnd##_##avgfunc); return; \
244 case 3:OP_N(3,sz,rnd##_##avgfunc); return; \
252 DEFFUNC(put,no_rnd,x,8,OP_X,avg32)
254 DEFFUNC(put,no_rnd,y,8,OP_Y,avg32)
256 DEFFUNC(put,no_rnd,xy,8,OP_XY,PACK)
258 DEFFUNC(put, rnd,x,16,OP_X,avg32)
259 DEFFUNC(put,no_rnd,x,16,OP_X,avg32)
260 DEFFUNC(put, rnd,y,16,OP_Y,avg32)
261 DEFFUNC(put,no_rnd,y,16,OP_Y,avg32)
262 DEFFUNC(put, rnd,xy,16,OP_XY,PACK)
263 DEFFUNC(put,no_rnd,xy,16,OP_XY,PACK)
270 DEFFUNC(avg, rnd,y,8,OP_Y,avg32)
271 DEFFUNC(avg, rnd,xy,8,OP_XY,PACK)
272 DEFFUNC(avg, rnd,o,16,OP_C,avg32)
273 DEFFUNC(avg, rnd,x,16,OP_X,avg32)
274 DEFFUNC(avg,no_rnd,x,16,OP_X,avg32)
275 DEFFUNC(avg, rnd,y,16,OP_Y,avg32)
276 DEFFUNC(avg,no_rnd,y,16,OP_Y,avg32)
277 DEFFUNC(avg, rnd,xy,16,OP_XY,PACK)
278 DEFFUNC(avg,no_rnd,xy,16,OP_XY,PACK)
282 #define put_no_rnd_pixels8_o put_rnd_pixels8_o
283 #define put_no_rnd_pixels16_o put_rnd_pixels16_o
284 #define avg_no_rnd_pixels16_o avg_rnd_pixels16_o
286 #define put_pixels8_c put_rnd_pixels8_o
287 #define put_pixels16_c put_rnd_pixels16_o
288 #define avg_pixels8_c avg_rnd_pixels8_o
289 #define avg_pixels16_c avg_rnd_pixels16_o
290 #define put_no_rnd_pixels8_c put_rnd_pixels8_o
291 #define put_no_rnd_pixels16_c put_rnd_pixels16_o
292 #define avg_no_rnd_pixels16_c avg_rnd_pixels16_o
306 if (!high_bit_depth) {
342 #define dspfunc(PFX, IDX, NUM) \
343 c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_sh4; \
344 c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_sh4; \
345 c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_sh4; \
346 c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_sh4; \
347 c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_sh4; \
348 c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_sh4; \
349 c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_sh4; \
350 c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_sh4; \
351 c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_sh4; \
352 c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_sh4; \
353 c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_sh4; \
354 c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_sh4; \
355 c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_sh4; \
356 c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_sh4; \
357 c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_sh4; \
358 c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_sh4
361 dspfunc(put_no_rnd_qpel, 0, 16);
367 dspfunc(put_no_rnd_qpel, 1, 8);