38 #define P2 p0_p[-3*stride]
39 #define P1 p0_p[-2*stride]
40 #define P0 p0_p[-1*stride]
41 #define Q0 p0_p[ 0*stride]
42 #define Q1 p0_p[ 1*stride]
43 #define Q2 p0_p[ 2*stride]
54 P0 = (
P1 + p0 +
s) >> 2;
95 P0 = (
P1 + p0 +
s) >> 2;
101 Q0 = (2*
Q1 +
s) >> 2;
199 int16_t (*
src)[8] = (int16_t(*)[8])
block;
203 for(
i = 0;
i < 8;
i++ ) {
209 const int b4 = 2 * (
a0 +
a1 +
a3) +
a1;
210 const int b5 = 2 * (
a0 -
a1 +
a2) +
a0;
211 const int b6 = 2 * (
a3 -
a2 -
a1) +
a3;
212 const int b7 = 2 * (
a0 -
a2 -
a3) -
a2;
214 const int a7 = 4 *
src[
i][2] - 10 *
src[
i][6];
215 const int a6 = 4 *
src[
i][6] + 10 *
src[
i][2];
216 const int a5 = 8 * (
src[
i][0] -
src[
i][4]) + 4;
217 const int a4 = 8 * (
src[
i][0] +
src[
i][4]) + 4;
219 const int b0 =
a4 + a6;
220 const int b1 =
a5 + a7;
221 const int b2 =
a5 - a7;
222 const int b3 =
a4 - a6;
224 src[
i][0] = (
b0 + b4) >> 3;
225 src[
i][1] = (
b1 + b5) >> 3;
226 src[
i][2] = (
b2 + b6) >> 3;
227 src[
i][3] = (
b3 + b7) >> 3;
228 src[
i][4] = (
b3 - b7) >> 3;
229 src[
i][5] = (
b2 - b6) >> 3;
230 src[
i][6] = (
b1 - b5) >> 3;
231 src[
i][7] = (
b0 - b4) >> 3;
233 for(
i = 0;
i < 8;
i++ ) {
239 const int b4 = 2 * (
a0 +
a1 +
a3) +
a1;
240 const int b5 = 2 * (
a0 -
a1 +
a2) +
a0;
241 const int b6 = 2 * (
a3 -
a2 -
a1) +
a3;
242 const int b7 = 2 * (
a0 -
a2 -
a3) -
a2;
244 const int a7 = 4 *
src[2][
i] - 10 *
src[6][
i];
245 const int a6 = 4 *
src[6][
i] + 10 *
src[2][
i];
249 const int b0 =
a4 + a6;
250 const int b1 =
a5 + a7;
251 const int b2 =
a5 - a7;
252 const int b3 =
a4 - a6;
271 #define CAVS_SUBPIX(OPNAME, OP, NAME, A, B, C, D, E, F) \
272 static void OPNAME ## cavs_filt8_h_ ## NAME(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
275 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
279 OP(dst[0], A*src[-2] + B*src[-1] + C*src[0] + D*src[1] + E*src[2] + F*src[3]);\
280 OP(dst[1], A*src[-1] + B*src[ 0] + C*src[1] + D*src[2] + E*src[3] + F*src[4]);\
281 OP(dst[2], A*src[ 0] + B*src[ 1] + C*src[2] + D*src[3] + E*src[4] + F*src[5]);\
282 OP(dst[3], A*src[ 1] + B*src[ 2] + C*src[3] + D*src[4] + E*src[5] + F*src[6]);\
283 OP(dst[4], A*src[ 2] + B*src[ 3] + C*src[4] + D*src[5] + E*src[6] + F*src[7]);\
284 OP(dst[5], A*src[ 3] + B*src[ 4] + C*src[5] + D*src[6] + E*src[7] + F*src[8]);\
285 OP(dst[6], A*src[ 4] + B*src[ 5] + C*src[6] + D*src[7] + E*src[8] + F*src[9]);\
286 OP(dst[7], A*src[ 5] + B*src[ 6] + C*src[7] + D*src[8] + E*src[9] + F*src[10]);\
292 static void OPNAME ## cavs_filt8_v_ ## NAME(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
295 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
299 const int srcB= src[-2*srcStride];\
300 const int srcA= src[-1*srcStride];\
301 const int src0= src[0 *srcStride];\
302 const int src1= src[1 *srcStride];\
303 const int src2= src[2 *srcStride];\
304 const int src3= src[3 *srcStride];\
305 const int src4= src[4 *srcStride];\
306 const int src5= src[5 *srcStride];\
307 const int src6= src[6 *srcStride];\
308 const int src7= src[7 *srcStride];\
309 const int src8= src[8 *srcStride];\
310 const int src9= src[9 *srcStride];\
311 const int src10= src[10 *srcStride];\
312 OP(dst[0*dstStride], A*srcB + B*srcA + C*src0 + D*src1 + E*src2 + F*src3);\
313 OP(dst[1*dstStride], A*srcA + B*src0 + C*src1 + D*src2 + E*src3 + F*src4);\
314 OP(dst[2*dstStride], A*src0 + B*src1 + C*src2 + D*src3 + E*src4 + F*src5);\
315 OP(dst[3*dstStride], A*src1 + B*src2 + C*src3 + D*src4 + E*src5 + F*src6);\
316 OP(dst[4*dstStride], A*src2 + B*src3 + C*src4 + D*src5 + E*src6 + F*src7);\
317 OP(dst[5*dstStride], A*src3 + B*src4 + C*src5 + D*src6 + E*src7 + F*src8);\
318 OP(dst[6*dstStride], A*src4 + B*src5 + C*src6 + D*src7 + E*src8 + F*src9);\
319 OP(dst[7*dstStride], A*src5 + B*src6 + C*src7 + D*src8 + E*src9 + F*src10);\
325 static void OPNAME ## cavs_filt16_v_ ## NAME(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
327 OPNAME ## cavs_filt8_v_ ## NAME(dst , src , dstStride, srcStride);\
328 OPNAME ## cavs_filt8_v_ ## NAME(dst+8, src+8, dstStride, srcStride);\
331 OPNAME ## cavs_filt8_v_ ## NAME(dst , src , dstStride, srcStride);\
332 OPNAME ## cavs_filt8_v_ ## NAME(dst+8, src+8, dstStride, srcStride);\
335 static void OPNAME ## cavs_filt16_h_ ## NAME(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
337 OPNAME ## cavs_filt8_h_ ## NAME(dst , src , dstStride, srcStride);\
338 OPNAME ## cavs_filt8_h_ ## NAME(dst+8, src+8, dstStride, srcStride);\
341 OPNAME ## cavs_filt8_h_ ## NAME(dst , src , dstStride, srcStride);\
342 OPNAME ## cavs_filt8_h_ ## NAME(dst+8, src+8, dstStride, srcStride);\
345 #define CAVS_SUBPIX_HV(OPNAME, OP, NAME, AH, BH, CH, DH, EH, FH, AV, BV, CV, DV, EV, FV, FULL) \
346 static void OPNAME ## cavs_filt8_hv_ ## NAME(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, ptrdiff_t dstStride, ptrdiff_t srcStride)\
348 int16_t temp[8*(8+5)];\
349 int16_t *tmp = temp;\
352 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
354 src1 -= 2*srcStride;\
355 for(i=0; i<h+5; i++)\
357 tmp[0]= AH*src1[-2] + BH*src1[-1] + CH*src1[0] + DH*src1[1] + EH*src1[2] + FH*src1[3];\
358 tmp[1]= AH*src1[-1] + BH*src1[ 0] + CH*src1[1] + DH*src1[2] + EH*src1[3] + FH*src1[4];\
359 tmp[2]= AH*src1[ 0] + BH*src1[ 1] + CH*src1[2] + DH*src1[3] + EH*src1[4] + FH*src1[5];\
360 tmp[3]= AH*src1[ 1] + BH*src1[ 2] + CH*src1[3] + DH*src1[4] + EH*src1[5] + FH*src1[6];\
361 tmp[4]= AH*src1[ 2] + BH*src1[ 3] + CH*src1[4] + DH*src1[5] + EH*src1[6] + FH*src1[7];\
362 tmp[5]= AH*src1[ 3] + BH*src1[ 4] + CH*src1[5] + DH*src1[6] + EH*src1[7] + FH*src1[8];\
363 tmp[6]= AH*src1[ 4] + BH*src1[ 5] + CH*src1[6] + DH*src1[7] + EH*src1[8] + FH*src1[9];\
364 tmp[7]= AH*src1[ 5] + BH*src1[ 6] + CH*src1[7] + DH*src1[8] + EH*src1[9] + FH*src1[10];\
372 const int tmpB= tmp[-2*8]; \
373 const int tmpA= tmp[-1*8]; \
374 const int tmp0= tmp[0 *8]; \
375 const int tmp1= tmp[1 *8]; \
376 const int tmp2= tmp[2 *8]; \
377 const int tmp3= tmp[3 *8]; \
378 const int tmp4= tmp[4 *8]; \
379 const int tmp5= tmp[5 *8]; \
380 const int tmp6= tmp[6 *8]; \
381 const int tmp7= tmp[7 *8]; \
382 const int tmp8= tmp[8 *8]; \
383 const int tmp9= tmp[9 *8]; \
384 const int tmp10=tmp[10*8]; \
385 OP(dst[0*dstStride], AV*tmpB + BV*tmpA + CV*tmp0 + DV*tmp1 + EV*tmp2 + FV*tmp3 + 64*src2[0*srcStride]); \
386 OP(dst[1*dstStride], AV*tmpA + BV*tmp0 + CV*tmp1 + DV*tmp2 + EV*tmp3 + FV*tmp4 + 64*src2[1*srcStride]); \
387 OP(dst[2*dstStride], AV*tmp0 + BV*tmp1 + CV*tmp2 + DV*tmp3 + EV*tmp4 + FV*tmp5 + 64*src2[2*srcStride]); \
388 OP(dst[3*dstStride], AV*tmp1 + BV*tmp2 + CV*tmp3 + DV*tmp4 + EV*tmp5 + FV*tmp6 + 64*src2[3*srcStride]); \
389 OP(dst[4*dstStride], AV*tmp2 + BV*tmp3 + CV*tmp4 + DV*tmp5 + EV*tmp6 + FV*tmp7 + 64*src2[4*srcStride]); \
390 OP(dst[5*dstStride], AV*tmp3 + BV*tmp4 + CV*tmp5 + DV*tmp6 + EV*tmp7 + FV*tmp8 + 64*src2[5*srcStride]); \
391 OP(dst[6*dstStride], AV*tmp4 + BV*tmp5 + CV*tmp6 + DV*tmp7 + EV*tmp8 + FV*tmp9 + 64*src2[6*srcStride]); \
392 OP(dst[7*dstStride], AV*tmp5 + BV*tmp6 + CV*tmp7 + DV*tmp8 + EV*tmp9 + FV*tmp10 + 64*src2[7*srcStride]); \
401 const int tmpB= tmp[-2*8]; \
402 const int tmpA= tmp[-1*8]; \
403 const int tmp0= tmp[0 *8]; \
404 const int tmp1= tmp[1 *8]; \
405 const int tmp2= tmp[2 *8]; \
406 const int tmp3= tmp[3 *8]; \
407 const int tmp4= tmp[4 *8]; \
408 const int tmp5= tmp[5 *8]; \
409 const int tmp6= tmp[6 *8]; \
410 const int tmp7= tmp[7 *8]; \
411 const int tmp8= tmp[8 *8]; \
412 const int tmp9= tmp[9 *8]; \
413 const int tmp10=tmp[10*8]; \
414 OP(dst[0*dstStride], AV*tmpB + BV*tmpA + CV*tmp0 + DV*tmp1 + EV*tmp2 + FV*tmp3); \
415 OP(dst[1*dstStride], AV*tmpA + BV*tmp0 + CV*tmp1 + DV*tmp2 + EV*tmp3 + FV*tmp4); \
416 OP(dst[2*dstStride], AV*tmp0 + BV*tmp1 + CV*tmp2 + DV*tmp3 + EV*tmp4 + FV*tmp5); \
417 OP(dst[3*dstStride], AV*tmp1 + BV*tmp2 + CV*tmp3 + DV*tmp4 + EV*tmp5 + FV*tmp6); \
418 OP(dst[4*dstStride], AV*tmp2 + BV*tmp3 + CV*tmp4 + DV*tmp5 + EV*tmp6 + FV*tmp7); \
419 OP(dst[5*dstStride], AV*tmp3 + BV*tmp4 + CV*tmp5 + DV*tmp6 + EV*tmp7 + FV*tmp8); \
420 OP(dst[6*dstStride], AV*tmp4 + BV*tmp5 + CV*tmp6 + DV*tmp7 + EV*tmp8 + FV*tmp9); \
421 OP(dst[7*dstStride], AV*tmp5 + BV*tmp6 + CV*tmp7 + DV*tmp8 + EV*tmp9 + FV*tmp10); \
428 static void OPNAME ## cavs_filt16_hv_ ## NAME(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, ptrdiff_t dstStride, ptrdiff_t srcStride)\
430 OPNAME ## cavs_filt8_hv_ ## NAME(dst , src1, src2 , dstStride, srcStride); \
431 OPNAME ## cavs_filt8_hv_ ## NAME(dst+8, src1+8, src2+8, dstStride, srcStride); \
432 src1 += 8*srcStride;\
433 src2 += 8*srcStride;\
435 OPNAME ## cavs_filt8_hv_ ## NAME(dst , src1, src2 , dstStride, srcStride); \
436 OPNAME ## cavs_filt8_hv_ ## NAME(dst+8, src1+8, src2+8, dstStride, srcStride); \
439 #define CAVS_MC(OPNAME, SIZE) \
440 static void OPNAME ## cavs_qpel ## SIZE ## _mc10_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
442 OPNAME ## cavs_filt ## SIZE ## _h_qpel_l(dst, src, stride, stride);\
445 static void OPNAME ## cavs_qpel ## SIZE ## _mc20_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
447 OPNAME ## cavs_filt ## SIZE ## _h_hpel(dst, src, stride, stride);\
450 static void OPNAME ## cavs_qpel ## SIZE ## _mc30_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
452 OPNAME ## cavs_filt ## SIZE ## _h_qpel_r(dst, src, stride, stride);\
455 static void OPNAME ## cavs_qpel ## SIZE ## _mc01_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
457 OPNAME ## cavs_filt ## SIZE ## _v_qpel_l(dst, src, stride, stride);\
460 static void OPNAME ## cavs_qpel ## SIZE ## _mc02_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
462 OPNAME ## cavs_filt ## SIZE ## _v_hpel(dst, src, stride, stride);\
465 static void OPNAME ## cavs_qpel ## SIZE ## _mc03_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
467 OPNAME ## cavs_filt ## SIZE ## _v_qpel_r(dst, src, stride, stride);\
470 static void OPNAME ## cavs_qpel ## SIZE ## _mc22_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
472 OPNAME ## cavs_filt ## SIZE ## _hv_jj(dst, src, NULL, stride, stride); \
475 static void OPNAME ## cavs_qpel ## SIZE ## _mc11_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
477 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src, stride, stride); \
480 static void OPNAME ## cavs_qpel ## SIZE ## _mc13_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
482 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride, stride, stride); \
485 static void OPNAME ## cavs_qpel ## SIZE ## _mc31_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
487 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+1, stride, stride); \
490 static void OPNAME ## cavs_qpel ## SIZE ## _mc33_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
492 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride+1,stride, stride); \
495 static void OPNAME ## cavs_qpel ## SIZE ## _mc21_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
497 OPNAME ## cavs_filt ## SIZE ## _hv_ff(dst, src, src+stride+1,stride, stride); \
500 static void OPNAME ## cavs_qpel ## SIZE ## _mc12_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
502 OPNAME ## cavs_filt ## SIZE ## _hv_ii(dst, src, src+stride+1,stride, stride); \
505 static void OPNAME ## cavs_qpel ## SIZE ## _mc32_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
507 OPNAME ## cavs_filt ## SIZE ## _hv_kk(dst, src, src+stride+1,stride, stride); \
510 static void OPNAME ## cavs_qpel ## SIZE ## _mc23_c(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
512 OPNAME ## cavs_filt ## SIZE ## _hv_qq(dst, src, src+stride+1,stride, stride); \
515 #define op_put1(a, b) a = cm[((b)+4)>>3]
516 #define op_put2(a, b) a = cm[((b)+64)>>7]
517 #define op_put3(a, b) a = cm[((b)+32)>>6]
518 #define op_put4(a, b) a = cm[((b)+512)>>10]
519 #define op_avg1(a, b) a = ((a)+cm[((b)+4)>>3] +1)>>1
520 #define op_avg2(a, b) a = ((a)+cm[((b)+64)>>7] +1)>>1
521 #define op_avg3(a, b) a = ((a)+cm[((b)+32)>>6] +1)>>1
522 #define op_avg4(a, b) a = ((a)+cm[((b)+512)>>10]+1)>>1
526 CAVS_SUBPIX_HV(put_,
op_put3, jj, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 0)
527 CAVS_SUBPIX_HV(put_,
op_put4, ff, 0, -1, 5, 5, -1, 0, -1, -2, 96, 42, -7, 0, 0)
528 CAVS_SUBPIX_HV(put_,
op_put4, ii, -1, -2, 96, 42, -7, 0, 0, -1, 5, 5, -1, 0, 0)
529 CAVS_SUBPIX_HV(put_,
op_put4, kk, 0, -7, 42, 96, -2, -1, 0, -1, 5, 5, -1, 0, 0)
530 CAVS_SUBPIX_HV(put_,
op_put4, qq, 0, -1, 5, 5, -1, 0, 0, -7, 42, 96, -2,-1, 0)
531 CAVS_SUBPIX_HV(put_,
op_put2, egpr, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 1)
535 CAVS_SUBPIX_HV(avg_,
op_avg3, jj, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 0)
536 CAVS_SUBPIX_HV(avg_,
op_avg4, ff, 0, -1, 5, 5, -1, 0, -1, -2, 96, 42, -7, 0, 0)
537 CAVS_SUBPIX_HV(avg_,
op_avg4, ii, -1, -2, 96, 42, -7, 0, 0, -1, 5, 5, -1, 0, 0)
538 CAVS_SUBPIX_HV(avg_,
op_avg4, kk, 0, -7, 42, 96, -2, -1, 0, -1, 5, 5, -1, 0, 0)
539 CAVS_SUBPIX_HV(avg_,
op_avg4, qq, 0, -1, 5, 5, -1, 0, 0, -7, 42, 96, -2,-1, 0)
540 CAVS_SUBPIX_HV(avg_,
op_avg2, egpr, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 1)
546 #define put_cavs_qpel8_mc00_c ff_put_pixels8x8_c
547 #define avg_cavs_qpel8_mc00_c ff_avg_pixels8x8_c
548 #define put_cavs_qpel16_mc00_c ff_put_pixels16x16_c
549 #define avg_cavs_qpel16_mc00_c ff_avg_pixels16x16_c
552 #define dspfunc(PFX, IDX, NUM) \
553 c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \
554 c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \
555 c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \
556 c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \
557 c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \
558 c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \
559 c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \
560 c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \
561 c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \
562 c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \
563 c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \
564 c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \
565 c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \
566 c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \
567 c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \
568 c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c