00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <stdio.h>
00026 #include "dsputil.h"
00027 #include "cavsdsp.h"
00028 #include "libavutil/common.h"
00029
00030
00031
00032
00033
00034
00035
00036 #define P2 p0_p[-3*stride]
00037 #define P1 p0_p[-2*stride]
00038 #define P0 p0_p[-1*stride]
00039 #define Q0 p0_p[ 0*stride]
00040 #define Q1 p0_p[ 1*stride]
00041 #define Q2 p0_p[ 2*stride]
00042
00043 static inline void loop_filter_l2(uint8_t *p0_p,int stride,int alpha, int beta) {
00044 int p0 = P0;
00045 int q0 = Q0;
00046
00047 if(abs(p0-q0)<alpha && abs(P1-p0)<beta && abs(Q1-q0)<beta) {
00048 int s = p0 + q0 + 2;
00049 alpha = (alpha>>2) + 2;
00050 if(abs(P2-p0) < beta && abs(p0-q0) < alpha) {
00051 P0 = (P1 + p0 + s) >> 2;
00052 P1 = (2*P1 + s) >> 2;
00053 } else
00054 P0 = (2*P1 + s) >> 2;
00055 if(abs(Q2-q0) < beta && abs(q0-p0) < alpha) {
00056 Q0 = (Q1 + q0 + s) >> 2;
00057 Q1 = (2*Q1 + s) >> 2;
00058 } else
00059 Q0 = (2*Q1 + s) >> 2;
00060 }
00061 }
00062
00063 static inline void loop_filter_l1(uint8_t *p0_p, int stride, int alpha, int beta, int tc) {
00064 int p0 = P0;
00065 int q0 = Q0;
00066
00067 if(abs(p0-q0)<alpha && abs(P1-p0)<beta && abs(Q1-q0)<beta) {
00068 int delta = av_clip(((q0-p0)*3+P1-Q1+4)>>3,-tc, tc);
00069 P0 = av_clip_uint8(p0+delta);
00070 Q0 = av_clip_uint8(q0-delta);
00071 if(abs(P2-p0)<beta) {
00072 delta = av_clip(((P0-P1)*3+P2-Q0+4)>>3, -tc, tc);
00073 P1 = av_clip_uint8(P1+delta);
00074 }
00075 if(abs(Q2-q0)<beta) {
00076 delta = av_clip(((Q1-Q0)*3+P0-Q2+4)>>3, -tc, tc);
00077 Q1 = av_clip_uint8(Q1-delta);
00078 }
00079 }
00080 }
00081
00082 static inline void loop_filter_c2(uint8_t *p0_p,int stride,int alpha, int beta) {
00083 int p0 = P0;
00084 int q0 = Q0;
00085
00086 if(abs(p0-q0)<alpha && abs(P1-p0)<beta && abs(Q1-q0)<beta) {
00087 int s = p0 + q0 + 2;
00088 alpha = (alpha>>2) + 2;
00089 if(abs(P2-p0) < beta && abs(p0-q0) < alpha) {
00090 P0 = (P1 + p0 + s) >> 2;
00091 } else
00092 P0 = (2*P1 + s) >> 2;
00093 if(abs(Q2-q0) < beta && abs(q0-p0) < alpha) {
00094 Q0 = (Q1 + q0 + s) >> 2;
00095 } else
00096 Q0 = (2*Q1 + s) >> 2;
00097 }
00098 }
00099
00100 static inline void loop_filter_c1(uint8_t *p0_p,int stride,int alpha, int beta,
00101 int tc) {
00102 if(abs(P0-Q0)<alpha && abs(P1-P0)<beta && abs(Q1-Q0)<beta) {
00103 int delta = av_clip(((Q0-P0)*3+P1-Q1+4)>>3, -tc, tc);
00104 P0 = av_clip_uint8(P0+delta);
00105 Q0 = av_clip_uint8(Q0-delta);
00106 }
00107 }
00108
00109 #undef P0
00110 #undef P1
00111 #undef P2
00112 #undef Q0
00113 #undef Q1
00114 #undef Q2
00115
00116 static void cavs_filter_lv_c(uint8_t *d, int stride, int alpha, int beta, int tc,
00117 int bs1, int bs2) {
00118 int i;
00119 if(bs1==2)
00120 for(i=0;i<16;i++)
00121 loop_filter_l2(d + i*stride,1,alpha,beta);
00122 else {
00123 if(bs1)
00124 for(i=0;i<8;i++)
00125 loop_filter_l1(d + i*stride,1,alpha,beta,tc);
00126 if (bs2)
00127 for(i=8;i<16;i++)
00128 loop_filter_l1(d + i*stride,1,alpha,beta,tc);
00129 }
00130 }
00131
00132 static void cavs_filter_lh_c(uint8_t *d, int stride, int alpha, int beta, int tc,
00133 int bs1, int bs2) {
00134 int i;
00135 if(bs1==2)
00136 for(i=0;i<16;i++)
00137 loop_filter_l2(d + i,stride,alpha,beta);
00138 else {
00139 if(bs1)
00140 for(i=0;i<8;i++)
00141 loop_filter_l1(d + i,stride,alpha,beta,tc);
00142 if (bs2)
00143 for(i=8;i<16;i++)
00144 loop_filter_l1(d + i,stride,alpha,beta,tc);
00145 }
00146 }
00147
00148 static void cavs_filter_cv_c(uint8_t *d, int stride, int alpha, int beta, int tc,
00149 int bs1, int bs2) {
00150 int i;
00151 if(bs1==2)
00152 for(i=0;i<8;i++)
00153 loop_filter_c2(d + i*stride,1,alpha,beta);
00154 else {
00155 if(bs1)
00156 for(i=0;i<4;i++)
00157 loop_filter_c1(d + i*stride,1,alpha,beta,tc);
00158 if (bs2)
00159 for(i=4;i<8;i++)
00160 loop_filter_c1(d + i*stride,1,alpha,beta,tc);
00161 }
00162 }
00163
00164 static void cavs_filter_ch_c(uint8_t *d, int stride, int alpha, int beta, int tc,
00165 int bs1, int bs2) {
00166 int i;
00167 if(bs1==2)
00168 for(i=0;i<8;i++)
00169 loop_filter_c2(d + i,stride,alpha,beta);
00170 else {
00171 if(bs1)
00172 for(i=0;i<4;i++)
00173 loop_filter_c1(d + i,stride,alpha,beta,tc);
00174 if (bs2)
00175 for(i=4;i<8;i++)
00176 loop_filter_c1(d + i,stride,alpha,beta,tc);
00177 }
00178 }
00179
00180
00181
00182
00183
00184
00185
00186 static void cavs_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride) {
00187 int i;
00188 DCTELEM (*src)[8] = (DCTELEM(*)[8])block;
00189 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
00190
00191 src[0][0] += 8;
00192
00193 for( i = 0; i < 8; i++ ) {
00194 const int a0 = 3*src[i][1] - (src[i][7]<<1);
00195 const int a1 = 3*src[i][3] + (src[i][5]<<1);
00196 const int a2 = (src[i][3]<<1) - 3*src[i][5];
00197 const int a3 = (src[i][1]<<1) + 3*src[i][7];
00198
00199 const int b4 = ((a0 + a1 + a3)<<1) + a1;
00200 const int b5 = ((a0 - a1 + a2)<<1) + a0;
00201 const int b6 = ((a3 - a2 - a1)<<1) + a3;
00202 const int b7 = ((a0 - a2 - a3)<<1) - a2;
00203
00204 const int a7 = (src[i][2]<<2) - 10*src[i][6];
00205 const int a6 = (src[i][6]<<2) + 10*src[i][2];
00206 const int a5 = ((src[i][0] - src[i][4]) << 3) + 4;
00207 const int a4 = ((src[i][0] + src[i][4]) << 3) + 4;
00208
00209 const int b0 = a4 + a6;
00210 const int b1 = a5 + a7;
00211 const int b2 = a5 - a7;
00212 const int b3 = a4 - a6;
00213
00214 src[i][0] = (b0 + b4) >> 3;
00215 src[i][1] = (b1 + b5) >> 3;
00216 src[i][2] = (b2 + b6) >> 3;
00217 src[i][3] = (b3 + b7) >> 3;
00218 src[i][4] = (b3 - b7) >> 3;
00219 src[i][5] = (b2 - b6) >> 3;
00220 src[i][6] = (b1 - b5) >> 3;
00221 src[i][7] = (b0 - b4) >> 3;
00222 }
00223 for( i = 0; i < 8; i++ ) {
00224 const int a0 = 3*src[1][i] - (src[7][i]<<1);
00225 const int a1 = 3*src[3][i] + (src[5][i]<<1);
00226 const int a2 = (src[3][i]<<1) - 3*src[5][i];
00227 const int a3 = (src[1][i]<<1) + 3*src[7][i];
00228
00229 const int b4 = ((a0 + a1 + a3)<<1) + a1;
00230 const int b5 = ((a0 - a1 + a2)<<1) + a0;
00231 const int b6 = ((a3 - a2 - a1)<<1) + a3;
00232 const int b7 = ((a0 - a2 - a3)<<1) - a2;
00233
00234 const int a7 = (src[2][i]<<2) - 10*src[6][i];
00235 const int a6 = (src[6][i]<<2) + 10*src[2][i];
00236 const int a5 = (src[0][i] - src[4][i]) << 3;
00237 const int a4 = (src[0][i] + src[4][i]) << 3;
00238
00239 const int b0 = a4 + a6;
00240 const int b1 = a5 + a7;
00241 const int b2 = a5 - a7;
00242 const int b3 = a4 - a6;
00243
00244 dst[i + 0*stride] = cm[ dst[i + 0*stride] + ((b0 + b4) >> 7)];
00245 dst[i + 1*stride] = cm[ dst[i + 1*stride] + ((b1 + b5) >> 7)];
00246 dst[i + 2*stride] = cm[ dst[i + 2*stride] + ((b2 + b6) >> 7)];
00247 dst[i + 3*stride] = cm[ dst[i + 3*stride] + ((b3 + b7) >> 7)];
00248 dst[i + 4*stride] = cm[ dst[i + 4*stride] + ((b3 - b7) >> 7)];
00249 dst[i + 5*stride] = cm[ dst[i + 5*stride] + ((b2 - b6) >> 7)];
00250 dst[i + 6*stride] = cm[ dst[i + 6*stride] + ((b1 - b5) >> 7)];
00251 dst[i + 7*stride] = cm[ dst[i + 7*stride] + ((b0 - b4) >> 7)];
00252 }
00253 }
00254
00255
00256
00257
00258
00259
00260
00261 #define CAVS_SUBPIX(OPNAME, OP, NAME, A, B, C, D, E, F) \
00262 static void OPNAME ## cavs_filt8_h_ ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
00263 const int h=8;\
00264 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
00265 int i;\
00266 for(i=0; i<h; i++)\
00267 {\
00268 OP(dst[0], A*src[-2] + B*src[-1] + C*src[0] + D*src[1] + E*src[2] + F*src[3]);\
00269 OP(dst[1], A*src[-1] + B*src[ 0] + C*src[1] + D*src[2] + E*src[3] + F*src[4]);\
00270 OP(dst[2], A*src[ 0] + B*src[ 1] + C*src[2] + D*src[3] + E*src[4] + F*src[5]);\
00271 OP(dst[3], A*src[ 1] + B*src[ 2] + C*src[3] + D*src[4] + E*src[5] + F*src[6]);\
00272 OP(dst[4], A*src[ 2] + B*src[ 3] + C*src[4] + D*src[5] + E*src[6] + F*src[7]);\
00273 OP(dst[5], A*src[ 3] + B*src[ 4] + C*src[5] + D*src[6] + E*src[7] + F*src[8]);\
00274 OP(dst[6], A*src[ 4] + B*src[ 5] + C*src[6] + D*src[7] + E*src[8] + F*src[9]);\
00275 OP(dst[7], A*src[ 5] + B*src[ 6] + C*src[7] + D*src[8] + E*src[9] + F*src[10]);\
00276 dst+=dstStride;\
00277 src+=srcStride;\
00278 }\
00279 }\
00280 \
00281 static void OPNAME ## cavs_filt8_v_ ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
00282 const int w=8;\
00283 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
00284 int i;\
00285 for(i=0; i<w; i++)\
00286 {\
00287 const int srcB= src[-2*srcStride];\
00288 const int srcA= src[-1*srcStride];\
00289 const int src0= src[0 *srcStride];\
00290 const int src1= src[1 *srcStride];\
00291 const int src2= src[2 *srcStride];\
00292 const int src3= src[3 *srcStride];\
00293 const int src4= src[4 *srcStride];\
00294 const int src5= src[5 *srcStride];\
00295 const int src6= src[6 *srcStride];\
00296 const int src7= src[7 *srcStride];\
00297 const int src8= src[8 *srcStride];\
00298 const int src9= src[9 *srcStride];\
00299 const int src10= src[10 *srcStride];\
00300 OP(dst[0*dstStride], A*srcB + B*srcA + C*src0 + D*src1 + E*src2 + F*src3);\
00301 OP(dst[1*dstStride], A*srcA + B*src0 + C*src1 + D*src2 + E*src3 + F*src4);\
00302 OP(dst[2*dstStride], A*src0 + B*src1 + C*src2 + D*src3 + E*src4 + F*src5);\
00303 OP(dst[3*dstStride], A*src1 + B*src2 + C*src3 + D*src4 + E*src5 + F*src6);\
00304 OP(dst[4*dstStride], A*src2 + B*src3 + C*src4 + D*src5 + E*src6 + F*src7);\
00305 OP(dst[5*dstStride], A*src3 + B*src4 + C*src5 + D*src6 + E*src7 + F*src8);\
00306 OP(dst[6*dstStride], A*src4 + B*src5 + C*src6 + D*src7 + E*src8 + F*src9);\
00307 OP(dst[7*dstStride], A*src5 + B*src6 + C*src7 + D*src8 + E*src9 + F*src10);\
00308 dst++;\
00309 src++;\
00310 }\
00311 }\
00312 \
00313 static void OPNAME ## cavs_filt16_v_ ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
00314 OPNAME ## cavs_filt8_v_ ## NAME(dst , src , dstStride, srcStride);\
00315 OPNAME ## cavs_filt8_v_ ## NAME(dst+8, src+8, dstStride, srcStride);\
00316 src += 8*srcStride;\
00317 dst += 8*dstStride;\
00318 OPNAME ## cavs_filt8_v_ ## NAME(dst , src , dstStride, srcStride);\
00319 OPNAME ## cavs_filt8_v_ ## NAME(dst+8, src+8, dstStride, srcStride);\
00320 }\
00321 \
00322 static void OPNAME ## cavs_filt16_h_ ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
00323 OPNAME ## cavs_filt8_h_ ## NAME(dst , src , dstStride, srcStride);\
00324 OPNAME ## cavs_filt8_h_ ## NAME(dst+8, src+8, dstStride, srcStride);\
00325 src += 8*srcStride;\
00326 dst += 8*dstStride;\
00327 OPNAME ## cavs_filt8_h_ ## NAME(dst , src , dstStride, srcStride);\
00328 OPNAME ## cavs_filt8_h_ ## NAME(dst+8, src+8, dstStride, srcStride);\
00329 }\
00330
00331 #define CAVS_SUBPIX_HV(OPNAME, OP, NAME, AH, BH, CH, DH, EH, FH, AV, BV, CV, DV, EV, FV, FULL) \
00332 static void OPNAME ## cavs_filt8_hv_ ## NAME(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int srcStride){\
00333 int16_t temp[8*(8+5)];\
00334 int16_t *tmp = temp;\
00335 const int h=8;\
00336 const int w=8;\
00337 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
00338 int i;\
00339 src1 -= 2*srcStride;\
00340 for(i=0; i<h+5; i++)\
00341 {\
00342 tmp[0]= AH*src1[-2] + BH*src1[-1] + CH*src1[0] + DH*src1[1] + EH*src1[2] + FH*src1[3];\
00343 tmp[1]= AH*src1[-1] + BH*src1[ 0] + CH*src1[1] + DH*src1[2] + EH*src1[3] + FH*src1[4];\
00344 tmp[2]= AH*src1[ 0] + BH*src1[ 1] + CH*src1[2] + DH*src1[3] + EH*src1[4] + FH*src1[5];\
00345 tmp[3]= AH*src1[ 1] + BH*src1[ 2] + CH*src1[3] + DH*src1[4] + EH*src1[5] + FH*src1[6];\
00346 tmp[4]= AH*src1[ 2] + BH*src1[ 3] + CH*src1[4] + DH*src1[5] + EH*src1[6] + FH*src1[7];\
00347 tmp[5]= AH*src1[ 3] + BH*src1[ 4] + CH*src1[5] + DH*src1[6] + EH*src1[7] + FH*src1[8];\
00348 tmp[6]= AH*src1[ 4] + BH*src1[ 5] + CH*src1[6] + DH*src1[7] + EH*src1[8] + FH*src1[9];\
00349 tmp[7]= AH*src1[ 5] + BH*src1[ 6] + CH*src1[7] + DH*src1[8] + EH*src1[9] + FH*src1[10];\
00350 tmp+=8;\
00351 src1+=srcStride;\
00352 }\
00353 if(FULL) {\
00354 tmp = temp+8*2; \
00355 for(i=0; i<w; i++) \
00356 { \
00357 const int tmpB= tmp[-2*8]; \
00358 const int tmpA= tmp[-1*8]; \
00359 const int tmp0= tmp[0 *8]; \
00360 const int tmp1= tmp[1 *8]; \
00361 const int tmp2= tmp[2 *8]; \
00362 const int tmp3= tmp[3 *8]; \
00363 const int tmp4= tmp[4 *8]; \
00364 const int tmp5= tmp[5 *8]; \
00365 const int tmp6= tmp[6 *8]; \
00366 const int tmp7= tmp[7 *8]; \
00367 const int tmp8= tmp[8 *8]; \
00368 const int tmp9= tmp[9 *8]; \
00369 const int tmp10=tmp[10*8]; \
00370 OP(dst[0*dstStride], AV*tmpB + BV*tmpA + CV*tmp0 + DV*tmp1 + EV*tmp2 + FV*tmp3 + 64*src2[0*srcStride]); \
00371 OP(dst[1*dstStride], AV*tmpA + BV*tmp0 + CV*tmp1 + DV*tmp2 + EV*tmp3 + FV*tmp4 + 64*src2[1*srcStride]); \
00372 OP(dst[2*dstStride], AV*tmp0 + BV*tmp1 + CV*tmp2 + DV*tmp3 + EV*tmp4 + FV*tmp5 + 64*src2[2*srcStride]); \
00373 OP(dst[3*dstStride], AV*tmp1 + BV*tmp2 + CV*tmp3 + DV*tmp4 + EV*tmp5 + FV*tmp6 + 64*src2[3*srcStride]); \
00374 OP(dst[4*dstStride], AV*tmp2 + BV*tmp3 + CV*tmp4 + DV*tmp5 + EV*tmp6 + FV*tmp7 + 64*src2[4*srcStride]); \
00375 OP(dst[5*dstStride], AV*tmp3 + BV*tmp4 + CV*tmp5 + DV*tmp6 + EV*tmp7 + FV*tmp8 + 64*src2[5*srcStride]); \
00376 OP(dst[6*dstStride], AV*tmp4 + BV*tmp5 + CV*tmp6 + DV*tmp7 + EV*tmp8 + FV*tmp9 + 64*src2[6*srcStride]); \
00377 OP(dst[7*dstStride], AV*tmp5 + BV*tmp6 + CV*tmp7 + DV*tmp8 + EV*tmp9 + FV*tmp10 + 64*src2[7*srcStride]); \
00378 dst++; \
00379 tmp++; \
00380 src2++; \
00381 } \
00382 } else {\
00383 tmp = temp+8*2; \
00384 for(i=0; i<w; i++) \
00385 { \
00386 const int tmpB= tmp[-2*8]; \
00387 const int tmpA= tmp[-1*8]; \
00388 const int tmp0= tmp[0 *8]; \
00389 const int tmp1= tmp[1 *8]; \
00390 const int tmp2= tmp[2 *8]; \
00391 const int tmp3= tmp[3 *8]; \
00392 const int tmp4= tmp[4 *8]; \
00393 const int tmp5= tmp[5 *8]; \
00394 const int tmp6= tmp[6 *8]; \
00395 const int tmp7= tmp[7 *8]; \
00396 const int tmp8= tmp[8 *8]; \
00397 const int tmp9= tmp[9 *8]; \
00398 const int tmp10=tmp[10*8]; \
00399 OP(dst[0*dstStride], AV*tmpB + BV*tmpA + CV*tmp0 + DV*tmp1 + EV*tmp2 + FV*tmp3); \
00400 OP(dst[1*dstStride], AV*tmpA + BV*tmp0 + CV*tmp1 + DV*tmp2 + EV*tmp3 + FV*tmp4); \
00401 OP(dst[2*dstStride], AV*tmp0 + BV*tmp1 + CV*tmp2 + DV*tmp3 + EV*tmp4 + FV*tmp5); \
00402 OP(dst[3*dstStride], AV*tmp1 + BV*tmp2 + CV*tmp3 + DV*tmp4 + EV*tmp5 + FV*tmp6); \
00403 OP(dst[4*dstStride], AV*tmp2 + BV*tmp3 + CV*tmp4 + DV*tmp5 + EV*tmp6 + FV*tmp7); \
00404 OP(dst[5*dstStride], AV*tmp3 + BV*tmp4 + CV*tmp5 + DV*tmp6 + EV*tmp7 + FV*tmp8); \
00405 OP(dst[6*dstStride], AV*tmp4 + BV*tmp5 + CV*tmp6 + DV*tmp7 + EV*tmp8 + FV*tmp9); \
00406 OP(dst[7*dstStride], AV*tmp5 + BV*tmp6 + CV*tmp7 + DV*tmp8 + EV*tmp9 + FV*tmp10); \
00407 dst++; \
00408 tmp++; \
00409 } \
00410 }\
00411 }\
00412 \
00413 static void OPNAME ## cavs_filt16_hv_ ## NAME(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int srcStride){ \
00414 OPNAME ## cavs_filt8_hv_ ## NAME(dst , src1, src2 , dstStride, srcStride); \
00415 OPNAME ## cavs_filt8_hv_ ## NAME(dst+8, src1+8, src2+8, dstStride, srcStride); \
00416 src1 += 8*srcStride;\
00417 src2 += 8*srcStride;\
00418 dst += 8*dstStride;\
00419 OPNAME ## cavs_filt8_hv_ ## NAME(dst , src1, src2 , dstStride, srcStride); \
00420 OPNAME ## cavs_filt8_hv_ ## NAME(dst+8, src1+8, src2+8, dstStride, srcStride); \
00421 }\
00422
00423 #define CAVS_MC(OPNAME, SIZE) \
00424 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc10_c(uint8_t *dst, uint8_t *src, int stride){\
00425 OPNAME ## cavs_filt ## SIZE ## _h_qpel_l(dst, src, stride, stride);\
00426 }\
00427 \
00428 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc20_c(uint8_t *dst, uint8_t *src, int stride){\
00429 OPNAME ## cavs_filt ## SIZE ## _h_hpel(dst, src, stride, stride);\
00430 }\
00431 \
00432 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc30_c(uint8_t *dst, uint8_t *src, int stride){\
00433 OPNAME ## cavs_filt ## SIZE ## _h_qpel_r(dst, src, stride, stride);\
00434 }\
00435 \
00436 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc01_c(uint8_t *dst, uint8_t *src, int stride){\
00437 OPNAME ## cavs_filt ## SIZE ## _v_qpel_l(dst, src, stride, stride);\
00438 }\
00439 \
00440 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc02_c(uint8_t *dst, uint8_t *src, int stride){\
00441 OPNAME ## cavs_filt ## SIZE ## _v_hpel(dst, src, stride, stride);\
00442 }\
00443 \
00444 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc03_c(uint8_t *dst, uint8_t *src, int stride){\
00445 OPNAME ## cavs_filt ## SIZE ## _v_qpel_r(dst, src, stride, stride);\
00446 }\
00447 \
00448 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc22_c(uint8_t *dst, uint8_t *src, int stride){\
00449 OPNAME ## cavs_filt ## SIZE ## _hv_jj(dst, src, NULL, stride, stride); \
00450 }\
00451 \
00452 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc11_c(uint8_t *dst, uint8_t *src, int stride){\
00453 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src, stride, stride); \
00454 }\
00455 \
00456 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc13_c(uint8_t *dst, uint8_t *src, int stride){\
00457 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride, stride, stride); \
00458 }\
00459 \
00460 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc31_c(uint8_t *dst, uint8_t *src, int stride){\
00461 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+1, stride, stride); \
00462 }\
00463 \
00464 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc33_c(uint8_t *dst, uint8_t *src, int stride){\
00465 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride+1,stride, stride); \
00466 }\
00467 \
00468 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc21_c(uint8_t *dst, uint8_t *src, int stride){\
00469 OPNAME ## cavs_filt ## SIZE ## _hv_ff(dst, src, src+stride+1,stride, stride); \
00470 }\
00471 \
00472 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc12_c(uint8_t *dst, uint8_t *src, int stride){\
00473 OPNAME ## cavs_filt ## SIZE ## _hv_ii(dst, src, src+stride+1,stride, stride); \
00474 }\
00475 \
00476 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc32_c(uint8_t *dst, uint8_t *src, int stride){\
00477 OPNAME ## cavs_filt ## SIZE ## _hv_kk(dst, src, src+stride+1,stride, stride); \
00478 }\
00479 \
00480 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc23_c(uint8_t *dst, uint8_t *src, int stride){\
00481 OPNAME ## cavs_filt ## SIZE ## _hv_qq(dst, src, src+stride+1,stride, stride); \
00482 }\
00483
00484 #define op_put1(a, b) a = cm[((b)+4)>>3]
00485 #define op_put2(a, b) a = cm[((b)+64)>>7]
00486 #define op_put3(a, b) a = cm[((b)+32)>>6]
00487 #define op_put4(a, b) a = cm[((b)+512)>>10]
00488 #define op_avg1(a, b) a = ((a)+cm[((b)+4)>>3] +1)>>1
00489 #define op_avg2(a, b) a = ((a)+cm[((b)+64)>>7] +1)>>1
00490 #define op_avg3(a, b) a = ((a)+cm[((b)+32)>>6] +1)>>1
00491 #define op_avg4(a, b) a = ((a)+cm[((b)+512)>>10]+1)>>1
00492 CAVS_SUBPIX(put_ , op_put1, hpel, 0, -1, 5, 5, -1, 0)
00493 CAVS_SUBPIX(put_ , op_put2, qpel_l, -1, -2, 96, 42, -7, 0)
00494 CAVS_SUBPIX(put_ , op_put2, qpel_r, 0, -7, 42, 96, -2, -1)
00495 CAVS_SUBPIX_HV(put_, op_put3, jj, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 0)
00496 CAVS_SUBPIX_HV(put_, op_put4, ff, 0, -1, 5, 5, -1, 0, -1, -2, 96, 42, -7, 0, 0)
00497 CAVS_SUBPIX_HV(put_, op_put4, ii, -1, -2, 96, 42, -7, 0, 0, -1, 5, 5, -1, 0, 0)
00498 CAVS_SUBPIX_HV(put_, op_put4, kk, 0, -7, 42, 96, -2, -1, 0, -1, 5, 5, -1, 0, 0)
00499 CAVS_SUBPIX_HV(put_, op_put4, qq, 0, -1, 5, 5, -1, 0, 0, -7, 42, 96, -2,-1, 0)
00500 CAVS_SUBPIX_HV(put_, op_put2, egpr, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 1)
00501 CAVS_SUBPIX(avg_ , op_avg1, hpel, 0, -1, 5, 5, -1, 0)
00502 CAVS_SUBPIX(avg_ , op_avg2, qpel_l, -1, -2, 96, 42, -7, 0)
00503 CAVS_SUBPIX(avg_ , op_avg2, qpel_r, 0, -7, 42, 96, -2, -1)
00504 CAVS_SUBPIX_HV(avg_, op_avg3, jj, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 0)
00505 CAVS_SUBPIX_HV(avg_, op_avg4, ff, 0, -1, 5, 5, -1, 0, -1, -2, 96, 42, -7, 0, 0)
00506 CAVS_SUBPIX_HV(avg_, op_avg4, ii, -1, -2, 96, 42, -7, 0, 0, -1, 5, 5, -1, 0, 0)
00507 CAVS_SUBPIX_HV(avg_, op_avg4, kk, 0, -7, 42, 96, -2, -1, 0, -1, 5, 5, -1, 0, 0)
00508 CAVS_SUBPIX_HV(avg_, op_avg4, qq, 0, -1, 5, 5, -1, 0, 0, -7, 42, 96, -2,-1, 0)
00509 CAVS_SUBPIX_HV(avg_, op_avg2, egpr, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 1)
00510 CAVS_MC(put_, 8)
00511 CAVS_MC(put_, 16)
00512 CAVS_MC(avg_, 8)
00513 CAVS_MC(avg_, 16)
00514
00515 #define ff_put_cavs_qpel8_mc00_c ff_put_pixels8x8_c
00516 #define ff_avg_cavs_qpel8_mc00_c ff_avg_pixels8x8_c
00517 #define ff_put_cavs_qpel16_mc00_c ff_put_pixels16x16_c
00518 #define ff_avg_cavs_qpel16_mc00_c ff_avg_pixels16x16_c
00519
00520 av_cold void ff_cavsdsp_init(CAVSDSPContext* c, AVCodecContext *avctx) {
00521 #define dspfunc(PFX, IDX, NUM) \
00522 c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_c; \
00523 c->PFX ## _pixels_tab[IDX][ 1] = ff_ ## PFX ## NUM ## _mc10_c; \
00524 c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_c; \
00525 c->PFX ## _pixels_tab[IDX][ 3] = ff_ ## PFX ## NUM ## _mc30_c; \
00526 c->PFX ## _pixels_tab[IDX][ 4] = ff_ ## PFX ## NUM ## _mc01_c; \
00527 c->PFX ## _pixels_tab[IDX][ 5] = ff_ ## PFX ## NUM ## _mc11_c; \
00528 c->PFX ## _pixels_tab[IDX][ 6] = ff_ ## PFX ## NUM ## _mc21_c; \
00529 c->PFX ## _pixels_tab[IDX][ 7] = ff_ ## PFX ## NUM ## _mc31_c; \
00530 c->PFX ## _pixels_tab[IDX][ 8] = ff_ ## PFX ## NUM ## _mc02_c; \
00531 c->PFX ## _pixels_tab[IDX][ 9] = ff_ ## PFX ## NUM ## _mc12_c; \
00532 c->PFX ## _pixels_tab[IDX][10] = ff_ ## PFX ## NUM ## _mc22_c; \
00533 c->PFX ## _pixels_tab[IDX][11] = ff_ ## PFX ## NUM ## _mc32_c; \
00534 c->PFX ## _pixels_tab[IDX][12] = ff_ ## PFX ## NUM ## _mc03_c; \
00535 c->PFX ## _pixels_tab[IDX][13] = ff_ ## PFX ## NUM ## _mc13_c; \
00536 c->PFX ## _pixels_tab[IDX][14] = ff_ ## PFX ## NUM ## _mc23_c; \
00537 c->PFX ## _pixels_tab[IDX][15] = ff_ ## PFX ## NUM ## _mc33_c
00538 dspfunc(put_cavs_qpel, 0, 16);
00539 dspfunc(put_cavs_qpel, 1, 8);
00540 dspfunc(avg_cavs_qpel, 0, 16);
00541 dspfunc(avg_cavs_qpel, 1, 8);
00542 c->cavs_filter_lv = cavs_filter_lv_c;
00543 c->cavs_filter_lh = cavs_filter_lh_c;
00544 c->cavs_filter_cv = cavs_filter_cv_c;
00545 c->cavs_filter_ch = cavs_filter_ch_c;
00546 c->cavs_idct8_add = cavs_idct8_add_c;
00547 c->idct_perm = FF_NO_IDCT_PERM;
00548
00549 if (HAVE_MMX) ff_cavsdsp_init_mmx(c, avctx);
00550 }