00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00028 #include "vc1dsp.h"
00029
00030
00033 static void vc1_v_overlap_c(uint8_t* src, int stride)
00034 {
00035 int i;
00036 int a, b, c, d;
00037 int d1, d2;
00038 int rnd = 1;
00039 for(i = 0; i < 8; i++) {
00040 a = src[-2*stride];
00041 b = src[-stride];
00042 c = src[0];
00043 d = src[stride];
00044 d1 = (a - d + 3 + rnd) >> 3;
00045 d2 = (a - d + b - c + 4 - rnd) >> 3;
00046
00047 src[-2*stride] = a - d1;
00048 src[-stride] = av_clip_uint8(b - d2);
00049 src[0] = av_clip_uint8(c + d2);
00050 src[stride] = d + d1;
00051 src++;
00052 rnd = !rnd;
00053 }
00054 }
00055
00058 static void vc1_h_overlap_c(uint8_t* src, int stride)
00059 {
00060 int i;
00061 int a, b, c, d;
00062 int d1, d2;
00063 int rnd = 1;
00064 for(i = 0; i < 8; i++) {
00065 a = src[-2];
00066 b = src[-1];
00067 c = src[0];
00068 d = src[1];
00069 d1 = (a - d + 3 + rnd) >> 3;
00070 d2 = (a - d + b - c + 4 - rnd) >> 3;
00071
00072 src[-2] = a - d1;
00073 src[-1] = av_clip_uint8(b - d2);
00074 src[0] = av_clip_uint8(c + d2);
00075 src[1] = d + d1;
00076 src += stride;
00077 rnd = !rnd;
00078 }
00079 }
00080
00081 static void vc1_v_s_overlap_c(DCTELEM *top, DCTELEM *bottom)
00082 {
00083 int i;
00084 int a, b, c, d;
00085 int d1, d2;
00086 int rnd1 = 4, rnd2 = 3;
00087 for(i = 0; i < 8; i++) {
00088 a = top[48];
00089 b = top[56];
00090 c = bottom[0];
00091 d = bottom[8];
00092 d1 = a - d;
00093 d2 = a - d + b - c;
00094
00095 top[48] = ((a << 3) - d1 + rnd1) >> 3;
00096 top[56] = ((b << 3) - d2 + rnd2) >> 3;
00097 bottom[0] = ((c << 3) + d2 + rnd1) >> 3;
00098 bottom[8] = ((d << 3) + d1 + rnd2) >> 3;
00099
00100 bottom++;
00101 top++;
00102 rnd2 = 7 - rnd2;
00103 rnd1 = 7 - rnd1;
00104 }
00105 }
00106
00107 static void vc1_h_s_overlap_c(DCTELEM *left, DCTELEM *right)
00108 {
00109 int i;
00110 int a, b, c, d;
00111 int d1, d2;
00112 int rnd1 = 4, rnd2 = 3;
00113 for(i = 0; i < 8; i++) {
00114 a = left[6];
00115 b = left[7];
00116 c = right[0];
00117 d = right[1];
00118 d1 = a - d;
00119 d2 = a - d + b - c;
00120
00121 left[6] = ((a << 3) - d1 + rnd1) >> 3;
00122 left[7] = ((b << 3) - d2 + rnd2) >> 3;
00123 right[0] = ((c << 3) + d2 + rnd1) >> 3;
00124 right[1] = ((d << 3) + d1 + rnd2) >> 3;
00125
00126 right += 8;
00127 left += 8;
00128 rnd2 = 7 - rnd2;
00129 rnd1 = 7 - rnd1;
00130 }
00131 }
00132
00141 static av_always_inline int vc1_filter_line(uint8_t* src, int stride, int pq){
00142 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
00143
00144 int a0 = (2*(src[-2*stride] - src[ 1*stride]) - 5*(src[-1*stride] - src[ 0*stride]) + 4) >> 3;
00145 int a0_sign = a0 >> 31;
00146 a0 = (a0 ^ a0_sign) - a0_sign;
00147 if(a0 < pq){
00148 int a1 = FFABS((2*(src[-4*stride] - src[-1*stride]) - 5*(src[-3*stride] - src[-2*stride]) + 4) >> 3);
00149 int a2 = FFABS((2*(src[ 0*stride] - src[ 3*stride]) - 5*(src[ 1*stride] - src[ 2*stride]) + 4) >> 3);
00150 if(a1 < a0 || a2 < a0){
00151 int clip = src[-1*stride] - src[ 0*stride];
00152 int clip_sign = clip >> 31;
00153 clip = ((clip ^ clip_sign) - clip_sign)>>1;
00154 if(clip){
00155 int a3 = FFMIN(a1, a2);
00156 int d = 5 * (a3 - a0);
00157 int d_sign = (d >> 31);
00158 d = ((d ^ d_sign) - d_sign) >> 3;
00159 d_sign ^= a0_sign;
00160
00161 if( d_sign ^ clip_sign )
00162 d = 0;
00163 else{
00164 d = FFMIN(d, clip);
00165 d = (d ^ d_sign) - d_sign;
00166 src[-1*stride] = cm[src[-1*stride] - d];
00167 src[ 0*stride] = cm[src[ 0*stride] + d];
00168 }
00169 return 1;
00170 }
00171 }
00172 }
00173 return 0;
00174 }
00175
00185 static inline void vc1_loop_filter(uint8_t* src, int step, int stride, int len, int pq)
00186 {
00187 int i;
00188 int filt3;
00189
00190 for(i = 0; i < len; i += 4){
00191 filt3 = vc1_filter_line(src + 2*step, stride, pq);
00192 if(filt3){
00193 vc1_filter_line(src + 0*step, stride, pq);
00194 vc1_filter_line(src + 1*step, stride, pq);
00195 vc1_filter_line(src + 3*step, stride, pq);
00196 }
00197 src += step * 4;
00198 }
00199 }
00200
00201 static void vc1_v_loop_filter4_c(uint8_t *src, int stride, int pq)
00202 {
00203 vc1_loop_filter(src, 1, stride, 4, pq);
00204 }
00205
00206 static void vc1_h_loop_filter4_c(uint8_t *src, int stride, int pq)
00207 {
00208 vc1_loop_filter(src, stride, 1, 4, pq);
00209 }
00210
00211 static void vc1_v_loop_filter8_c(uint8_t *src, int stride, int pq)
00212 {
00213 vc1_loop_filter(src, 1, stride, 8, pq);
00214 }
00215
00216 static void vc1_h_loop_filter8_c(uint8_t *src, int stride, int pq)
00217 {
00218 vc1_loop_filter(src, stride, 1, 8, pq);
00219 }
00220
00221 static void vc1_v_loop_filter16_c(uint8_t *src, int stride, int pq)
00222 {
00223 vc1_loop_filter(src, 1, stride, 16, pq);
00224 }
00225
00226 static void vc1_h_loop_filter16_c(uint8_t *src, int stride, int pq)
00227 {
00228 vc1_loop_filter(src, stride, 1, 16, pq);
00229 }
00230
00233 static void vc1_inv_trans_8x8_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
00234 {
00235 int i;
00236 int dc = block[0];
00237 const uint8_t *cm;
00238 dc = (3 * dc + 1) >> 1;
00239 dc = (3 * dc + 16) >> 5;
00240 cm = ff_cropTbl + MAX_NEG_CROP + dc;
00241 for(i = 0; i < 8; i++){
00242 dest[0] = cm[dest[0]];
00243 dest[1] = cm[dest[1]];
00244 dest[2] = cm[dest[2]];
00245 dest[3] = cm[dest[3]];
00246 dest[4] = cm[dest[4]];
00247 dest[5] = cm[dest[5]];
00248 dest[6] = cm[dest[6]];
00249 dest[7] = cm[dest[7]];
00250 dest += linesize;
00251 }
00252 }
00253
00254 static void vc1_inv_trans_8x8_c(DCTELEM block[64])
00255 {
00256 int i;
00257 register int t1,t2,t3,t4,t5,t6,t7,t8;
00258 DCTELEM *src, *dst, temp[64];
00259
00260 src = block;
00261 dst = temp;
00262 for(i = 0; i < 8; i++){
00263 t1 = 12 * (src[ 0] + src[32]) + 4;
00264 t2 = 12 * (src[ 0] - src[32]) + 4;
00265 t3 = 16 * src[16] + 6 * src[48];
00266 t4 = 6 * src[16] - 16 * src[48];
00267
00268 t5 = t1 + t3;
00269 t6 = t2 + t4;
00270 t7 = t2 - t4;
00271 t8 = t1 - t3;
00272
00273 t1 = 16 * src[ 8] + 15 * src[24] + 9 * src[40] + 4 * src[56];
00274 t2 = 15 * src[ 8] - 4 * src[24] - 16 * src[40] - 9 * src[56];
00275 t3 = 9 * src[ 8] - 16 * src[24] + 4 * src[40] + 15 * src[56];
00276 t4 = 4 * src[ 8] - 9 * src[24] + 15 * src[40] - 16 * src[56];
00277
00278 dst[0] = (t5 + t1) >> 3;
00279 dst[1] = (t6 + t2) >> 3;
00280 dst[2] = (t7 + t3) >> 3;
00281 dst[3] = (t8 + t4) >> 3;
00282 dst[4] = (t8 - t4) >> 3;
00283 dst[5] = (t7 - t3) >> 3;
00284 dst[6] = (t6 - t2) >> 3;
00285 dst[7] = (t5 - t1) >> 3;
00286
00287 src += 1;
00288 dst += 8;
00289 }
00290
00291 src = temp;
00292 dst = block;
00293 for(i = 0; i < 8; i++){
00294 t1 = 12 * (src[ 0] + src[32]) + 64;
00295 t2 = 12 * (src[ 0] - src[32]) + 64;
00296 t3 = 16 * src[16] + 6 * src[48];
00297 t4 = 6 * src[16] - 16 * src[48];
00298
00299 t5 = t1 + t3;
00300 t6 = t2 + t4;
00301 t7 = t2 - t4;
00302 t8 = t1 - t3;
00303
00304 t1 = 16 * src[ 8] + 15 * src[24] + 9 * src[40] + 4 * src[56];
00305 t2 = 15 * src[ 8] - 4 * src[24] - 16 * src[40] - 9 * src[56];
00306 t3 = 9 * src[ 8] - 16 * src[24] + 4 * src[40] + 15 * src[56];
00307 t4 = 4 * src[ 8] - 9 * src[24] + 15 * src[40] - 16 * src[56];
00308
00309 dst[ 0] = (t5 + t1) >> 7;
00310 dst[ 8] = (t6 + t2) >> 7;
00311 dst[16] = (t7 + t3) >> 7;
00312 dst[24] = (t8 + t4) >> 7;
00313 dst[32] = (t8 - t4 + 1) >> 7;
00314 dst[40] = (t7 - t3 + 1) >> 7;
00315 dst[48] = (t6 - t2 + 1) >> 7;
00316 dst[56] = (t5 - t1 + 1) >> 7;
00317
00318 src++;
00319 dst++;
00320 }
00321 }
00322
00325 static void vc1_inv_trans_8x4_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
00326 {
00327 int i;
00328 int dc = block[0];
00329 const uint8_t *cm;
00330 dc = ( 3 * dc + 1) >> 1;
00331 dc = (17 * dc + 64) >> 7;
00332 cm = ff_cropTbl + MAX_NEG_CROP + dc;
00333 for(i = 0; i < 4; i++){
00334 dest[0] = cm[dest[0]];
00335 dest[1] = cm[dest[1]];
00336 dest[2] = cm[dest[2]];
00337 dest[3] = cm[dest[3]];
00338 dest[4] = cm[dest[4]];
00339 dest[5] = cm[dest[5]];
00340 dest[6] = cm[dest[6]];
00341 dest[7] = cm[dest[7]];
00342 dest += linesize;
00343 }
00344 }
00345
00346 static void vc1_inv_trans_8x4_c(uint8_t *dest, int linesize, DCTELEM *block)
00347 {
00348 int i;
00349 register int t1,t2,t3,t4,t5,t6,t7,t8;
00350 DCTELEM *src, *dst;
00351 const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
00352
00353 src = block;
00354 dst = block;
00355 for(i = 0; i < 4; i++){
00356 t1 = 12 * (src[0] + src[4]) + 4;
00357 t2 = 12 * (src[0] - src[4]) + 4;
00358 t3 = 16 * src[2] + 6 * src[6];
00359 t4 = 6 * src[2] - 16 * src[6];
00360
00361 t5 = t1 + t3;
00362 t6 = t2 + t4;
00363 t7 = t2 - t4;
00364 t8 = t1 - t3;
00365
00366 t1 = 16 * src[1] + 15 * src[3] + 9 * src[5] + 4 * src[7];
00367 t2 = 15 * src[1] - 4 * src[3] - 16 * src[5] - 9 * src[7];
00368 t3 = 9 * src[1] - 16 * src[3] + 4 * src[5] + 15 * src[7];
00369 t4 = 4 * src[1] - 9 * src[3] + 15 * src[5] - 16 * src[7];
00370
00371 dst[0] = (t5 + t1) >> 3;
00372 dst[1] = (t6 + t2) >> 3;
00373 dst[2] = (t7 + t3) >> 3;
00374 dst[3] = (t8 + t4) >> 3;
00375 dst[4] = (t8 - t4) >> 3;
00376 dst[5] = (t7 - t3) >> 3;
00377 dst[6] = (t6 - t2) >> 3;
00378 dst[7] = (t5 - t1) >> 3;
00379
00380 src += 8;
00381 dst += 8;
00382 }
00383
00384 src = block;
00385 for(i = 0; i < 8; i++){
00386 t1 = 17 * (src[ 0] + src[16]) + 64;
00387 t2 = 17 * (src[ 0] - src[16]) + 64;
00388 t3 = 22 * src[ 8] + 10 * src[24];
00389 t4 = 22 * src[24] - 10 * src[ 8];
00390
00391 dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)];
00392 dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)];
00393 dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)];
00394 dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)];
00395
00396 src ++;
00397 dest++;
00398 }
00399 }
00400
00403 static void vc1_inv_trans_4x8_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
00404 {
00405 int i;
00406 int dc = block[0];
00407 const uint8_t *cm;
00408 dc = (17 * dc + 4) >> 3;
00409 dc = (12 * dc + 64) >> 7;
00410 cm = ff_cropTbl + MAX_NEG_CROP + dc;
00411 for(i = 0; i < 8; i++){
00412 dest[0] = cm[dest[0]];
00413 dest[1] = cm[dest[1]];
00414 dest[2] = cm[dest[2]];
00415 dest[3] = cm[dest[3]];
00416 dest += linesize;
00417 }
00418 }
00419
00420 static void vc1_inv_trans_4x8_c(uint8_t *dest, int linesize, DCTELEM *block)
00421 {
00422 int i;
00423 register int t1,t2,t3,t4,t5,t6,t7,t8;
00424 DCTELEM *src, *dst;
00425 const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
00426
00427 src = block;
00428 dst = block;
00429 for(i = 0; i < 8; i++){
00430 t1 = 17 * (src[0] + src[2]) + 4;
00431 t2 = 17 * (src[0] - src[2]) + 4;
00432 t3 = 22 * src[1] + 10 * src[3];
00433 t4 = 22 * src[3] - 10 * src[1];
00434
00435 dst[0] = (t1 + t3) >> 3;
00436 dst[1] = (t2 - t4) >> 3;
00437 dst[2] = (t2 + t4) >> 3;
00438 dst[3] = (t1 - t3) >> 3;
00439
00440 src += 8;
00441 dst += 8;
00442 }
00443
00444 src = block;
00445 for(i = 0; i < 4; i++){
00446 t1 = 12 * (src[ 0] + src[32]) + 64;
00447 t2 = 12 * (src[ 0] - src[32]) + 64;
00448 t3 = 16 * src[16] + 6 * src[48];
00449 t4 = 6 * src[16] - 16 * src[48];
00450
00451 t5 = t1 + t3;
00452 t6 = t2 + t4;
00453 t7 = t2 - t4;
00454 t8 = t1 - t3;
00455
00456 t1 = 16 * src[ 8] + 15 * src[24] + 9 * src[40] + 4 * src[56];
00457 t2 = 15 * src[ 8] - 4 * src[24] - 16 * src[40] - 9 * src[56];
00458 t3 = 9 * src[ 8] - 16 * src[24] + 4 * src[40] + 15 * src[56];
00459 t4 = 4 * src[ 8] - 9 * src[24] + 15 * src[40] - 16 * src[56];
00460
00461 dest[0*linesize] = cm[dest[0*linesize] + ((t5 + t1) >> 7)];
00462 dest[1*linesize] = cm[dest[1*linesize] + ((t6 + t2) >> 7)];
00463 dest[2*linesize] = cm[dest[2*linesize] + ((t7 + t3) >> 7)];
00464 dest[3*linesize] = cm[dest[3*linesize] + ((t8 + t4) >> 7)];
00465 dest[4*linesize] = cm[dest[4*linesize] + ((t8 - t4 + 1) >> 7)];
00466 dest[5*linesize] = cm[dest[5*linesize] + ((t7 - t3 + 1) >> 7)];
00467 dest[6*linesize] = cm[dest[6*linesize] + ((t6 - t2 + 1) >> 7)];
00468 dest[7*linesize] = cm[dest[7*linesize] + ((t5 - t1 + 1) >> 7)];
00469
00470 src ++;
00471 dest++;
00472 }
00473 }
00474
00477 static void vc1_inv_trans_4x4_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
00478 {
00479 int i;
00480 int dc = block[0];
00481 const uint8_t *cm;
00482 dc = (17 * dc + 4) >> 3;
00483 dc = (17 * dc + 64) >> 7;
00484 cm = ff_cropTbl + MAX_NEG_CROP + dc;
00485 for(i = 0; i < 4; i++){
00486 dest[0] = cm[dest[0]];
00487 dest[1] = cm[dest[1]];
00488 dest[2] = cm[dest[2]];
00489 dest[3] = cm[dest[3]];
00490 dest += linesize;
00491 }
00492 }
00493
00494 static void vc1_inv_trans_4x4_c(uint8_t *dest, int linesize, DCTELEM *block)
00495 {
00496 int i;
00497 register int t1,t2,t3,t4;
00498 DCTELEM *src, *dst;
00499 const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
00500
00501 src = block;
00502 dst = block;
00503 for(i = 0; i < 4; i++){
00504 t1 = 17 * (src[0] + src[2]) + 4;
00505 t2 = 17 * (src[0] - src[2]) + 4;
00506 t3 = 22 * src[1] + 10 * src[3];
00507 t4 = 22 * src[3] - 10 * src[1];
00508
00509 dst[0] = (t1 + t3) >> 3;
00510 dst[1] = (t2 - t4) >> 3;
00511 dst[2] = (t2 + t4) >> 3;
00512 dst[3] = (t1 - t3) >> 3;
00513
00514 src += 8;
00515 dst += 8;
00516 }
00517
00518 src = block;
00519 for(i = 0; i < 4; i++){
00520 t1 = 17 * (src[ 0] + src[16]) + 64;
00521 t2 = 17 * (src[ 0] - src[16]) + 64;
00522 t3 = 22 * src[ 8] + 10 * src[24];
00523 t4 = 22 * src[24] - 10 * src[ 8];
00524
00525 dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)];
00526 dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)];
00527 dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)];
00528 dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)];
00529
00530 src ++;
00531 dest++;
00532 }
00533 }
00534
00535
00537 #define VC1_MSPEL_FILTER_16B(DIR, TYPE) \
00538 static av_always_inline int vc1_mspel_ ## DIR ## _filter_16bits(const TYPE *src, int stride, int mode) \
00539 { \
00540 switch(mode){ \
00541 case 0: \
00542 return 0; \
00543 case 1: \
00544 return -4*src[-stride] + 53*src[0] + 18*src[stride] - 3*src[stride*2]; \
00545 case 2: \
00546 return -src[-stride] + 9*src[0] + 9*src[stride] - src[stride*2]; \
00547 case 3: \
00548 return -3*src[-stride] + 18*src[0] + 53*src[stride] - 4*src[stride*2]; \
00549 } \
00550 return 0; \
00551 }
00552
00553 VC1_MSPEL_FILTER_16B(ver, uint8_t);
00554 VC1_MSPEL_FILTER_16B(hor, int16_t);
00555
00556
00559 static av_always_inline int vc1_mspel_filter(const uint8_t *src, int stride, int mode, int r)
00560 {
00561 switch(mode){
00562 case 0:
00563 return src[0];
00564 case 1:
00565 return (-4*src[-stride] + 53*src[0] + 18*src[stride] - 3*src[stride*2] + 32 - r) >> 6;
00566 case 2:
00567 return (-src[-stride] + 9*src[0] + 9*src[stride] - src[stride*2] + 8 - r) >> 4;
00568 case 3:
00569 return (-3*src[-stride] + 18*src[0] + 53*src[stride] - 4*src[stride*2] + 32 - r) >> 6;
00570 }
00571 return 0;
00572 }
00573
00576 #define VC1_MSPEL_MC(OP, OPNAME)\
00577 static void OPNAME ## vc1_mspel_mc(uint8_t *dst, const uint8_t *src, int stride, int hmode, int vmode, int rnd)\
00578 {\
00579 int i, j;\
00580 \
00581 if (vmode) { \
00582 int r;\
00583 \
00584 if (hmode) { \
00585 static const int shift_value[] = { 0, 5, 1, 5 };\
00586 int shift = (shift_value[hmode]+shift_value[vmode])>>1;\
00587 int16_t tmp[11*8], *tptr = tmp;\
00588 \
00589 r = (1<<(shift-1)) + rnd-1;\
00590 \
00591 src -= 1;\
00592 for(j = 0; j < 8; j++) {\
00593 for(i = 0; i < 11; i++)\
00594 tptr[i] = (vc1_mspel_ver_filter_16bits(src + i, stride, vmode)+r)>>shift;\
00595 src += stride;\
00596 tptr += 11;\
00597 }\
00598 \
00599 r = 64-rnd;\
00600 tptr = tmp+1;\
00601 for(j = 0; j < 8; j++) {\
00602 for(i = 0; i < 8; i++)\
00603 OP(dst[i], (vc1_mspel_hor_filter_16bits(tptr + i, 1, hmode)+r)>>7);\
00604 dst += stride;\
00605 tptr += 11;\
00606 }\
00607 \
00608 return;\
00609 }\
00610 else { \
00611 r = 1-rnd;\
00612 \
00613 for(j = 0; j < 8; j++) {\
00614 for(i = 0; i < 8; i++)\
00615 OP(dst[i], vc1_mspel_filter(src + i, stride, vmode, r));\
00616 src += stride;\
00617 dst += stride;\
00618 }\
00619 return;\
00620 }\
00621 }\
00622 \
00623 \
00624 for(j = 0; j < 8; j++) {\
00625 for(i = 0; i < 8; i++)\
00626 OP(dst[i], vc1_mspel_filter(src + i, 1, hmode, rnd));\
00627 dst += stride;\
00628 src += stride;\
00629 }\
00630 }
00631
00632 #define op_put(a, b) a = av_clip_uint8(b)
00633 #define op_avg(a, b) a = (a + av_clip_uint8(b) + 1) >> 1
00634
00635 VC1_MSPEL_MC(op_put, put_)
00636 VC1_MSPEL_MC(op_avg, avg_)
00637
00638
00639
00640 #define PUT_VC1_MSPEL(a, b)\
00641 static void put_vc1_mspel_mc ## a ## b ##_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) { \
00642 put_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
00643 }\
00644 static void avg_vc1_mspel_mc ## a ## b ##_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) { \
00645 avg_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
00646 }
00647
00648 PUT_VC1_MSPEL(1, 0)
00649 PUT_VC1_MSPEL(2, 0)
00650 PUT_VC1_MSPEL(3, 0)
00651
00652 PUT_VC1_MSPEL(0, 1)
00653 PUT_VC1_MSPEL(1, 1)
00654 PUT_VC1_MSPEL(2, 1)
00655 PUT_VC1_MSPEL(3, 1)
00656
00657 PUT_VC1_MSPEL(0, 2)
00658 PUT_VC1_MSPEL(1, 2)
00659 PUT_VC1_MSPEL(2, 2)
00660 PUT_VC1_MSPEL(3, 2)
00661
00662 PUT_VC1_MSPEL(0, 3)
00663 PUT_VC1_MSPEL(1, 3)
00664 PUT_VC1_MSPEL(2, 3)
00665 PUT_VC1_MSPEL(3, 3)
00666
00667 static void put_no_rnd_vc1_chroma_mc8_c(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y){
00668 const int A=(8-x)*(8-y);
00669 const int B=( x)*(8-y);
00670 const int C=(8-x)*( y);
00671 const int D=( x)*( y);
00672 int i;
00673
00674 assert(x<8 && y<8 && x>=0 && y>=0);
00675
00676 for(i=0; i<h; i++)
00677 {
00678 dst[0] = (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + 32 - 4) >> 6;
00679 dst[1] = (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6;
00680 dst[2] = (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6;
00681 dst[3] = (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6;
00682 dst[4] = (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + 32 - 4) >> 6;
00683 dst[5] = (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + 32 - 4) >> 6;
00684 dst[6] = (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + 32 - 4) >> 6;
00685 dst[7] = (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + 32 - 4) >> 6;
00686 dst+= stride;
00687 src+= stride;
00688 }
00689 }
00690
00691 static void put_no_rnd_vc1_chroma_mc4_c(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y){
00692 const int A=(8-x)*(8-y);
00693 const int B=( x)*(8-y);
00694 const int C=(8-x)*( y);
00695 const int D=( x)*( y);
00696 int i;
00697
00698 assert(x<8 && y<8 && x>=0 && y>=0);
00699
00700 for(i=0; i<h; i++)
00701 {
00702 dst[0] = (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + 32 - 4) >> 6;
00703 dst[1] = (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6;
00704 dst[2] = (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6;
00705 dst[3] = (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6;
00706 dst+= stride;
00707 src+= stride;
00708 }
00709 }
00710
00711 #define avg2(a,b) ((a+b+1)>>1)
00712 static void avg_no_rnd_vc1_chroma_mc8_c(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y){
00713 const int A=(8-x)*(8-y);
00714 const int B=( x)*(8-y);
00715 const int C=(8-x)*( y);
00716 const int D=( x)*( y);
00717 int i;
00718
00719 assert(x<8 && y<8 && x>=0 && y>=0);
00720
00721 for(i=0; i<h; i++)
00722 {
00723 dst[0] = avg2(dst[0], ((A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + 32 - 4) >> 6));
00724 dst[1] = avg2(dst[1], ((A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6));
00725 dst[2] = avg2(dst[2], ((A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6));
00726 dst[3] = avg2(dst[3], ((A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6));
00727 dst[4] = avg2(dst[4], ((A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + 32 - 4) >> 6));
00728 dst[5] = avg2(dst[5], ((A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + 32 - 4) >> 6));
00729 dst[6] = avg2(dst[6], ((A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + 32 - 4) >> 6));
00730 dst[7] = avg2(dst[7], ((A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + 32 - 4) >> 6));
00731 dst+= stride;
00732 src+= stride;
00733 }
00734 }
00735
00736 #if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
00737
00738 static void sprite_h_c(uint8_t *dst, const uint8_t *src, int offset, int advance, int count)
00739 {
00740 while (count--) {
00741 int a = src[(offset >> 16) ];
00742 int b = src[(offset >> 16) + 1];
00743 *dst++ = a + ((b - a) * (offset&0xFFFF) >> 16);
00744 offset += advance;
00745 }
00746 }
00747
00748 static av_always_inline void sprite_v_template(uint8_t *dst, const uint8_t *src1a, const uint8_t *src1b, int offset1,
00749 int two_sprites, const uint8_t *src2a, const uint8_t *src2b, int offset2,
00750 int alpha, int scaled, int width)
00751 {
00752 int a1, b1, a2, b2;
00753 while (width--) {
00754 a1 = *src1a++;
00755 if (scaled) {
00756 b1 = *src1b++;
00757 a1 = a1 + ((b1 - a1) * offset1 >> 16);
00758 }
00759 if (two_sprites) {
00760 a2 = *src2a++;
00761 if (scaled > 1) {
00762 b2 = *src2b++;
00763 a2 = a2 + ((b2 - a2) * offset2 >> 16);
00764 }
00765 a1 = a1 + ((a2 - a1) * alpha >> 16);
00766 }
00767 *dst++ = a1;
00768 }
00769 }
00770
00771 static void sprite_v_single_c(uint8_t *dst, const uint8_t *src1a, const uint8_t *src1b, int offset, int width)
00772 {
00773 sprite_v_template(dst, src1a, src1b, offset, 0, NULL, NULL, 0, 0, 1, width);
00774 }
00775
00776 static void sprite_v_double_noscale_c(uint8_t *dst, const uint8_t *src1a, const uint8_t *src2a, int alpha, int width)
00777 {
00778 sprite_v_template(dst, src1a, NULL, 0, 1, src2a, NULL, 0, alpha, 0, width);
00779 }
00780
00781 static void sprite_v_double_onescale_c(uint8_t *dst, const uint8_t *src1a, const uint8_t *src1b, int offset1,
00782 const uint8_t *src2a, int alpha, int width)
00783 {
00784 sprite_v_template(dst, src1a, src1b, offset1, 1, src2a, NULL, 0, alpha, 1, width);
00785 }
00786
00787 static void sprite_v_double_twoscale_c(uint8_t *dst, const uint8_t *src1a, const uint8_t *src1b, int offset1,
00788 const uint8_t *src2a, const uint8_t *src2b, int offset2,
00789 int alpha, int width)
00790 {
00791 sprite_v_template(dst, src1a, src1b, offset1, 1, src2a, src2b, offset2, alpha, 2, width);
00792 }
00793
00794 #endif
00795
00796 av_cold void ff_vc1dsp_init(VC1DSPContext* dsp) {
00797 dsp->vc1_inv_trans_8x8 = vc1_inv_trans_8x8_c;
00798 dsp->vc1_inv_trans_4x8 = vc1_inv_trans_4x8_c;
00799 dsp->vc1_inv_trans_8x4 = vc1_inv_trans_8x4_c;
00800 dsp->vc1_inv_trans_4x4 = vc1_inv_trans_4x4_c;
00801 dsp->vc1_inv_trans_8x8_dc = vc1_inv_trans_8x8_dc_c;
00802 dsp->vc1_inv_trans_4x8_dc = vc1_inv_trans_4x8_dc_c;
00803 dsp->vc1_inv_trans_8x4_dc = vc1_inv_trans_8x4_dc_c;
00804 dsp->vc1_inv_trans_4x4_dc = vc1_inv_trans_4x4_dc_c;
00805 dsp->vc1_h_overlap = vc1_h_overlap_c;
00806 dsp->vc1_v_overlap = vc1_v_overlap_c;
00807 dsp->vc1_h_s_overlap = vc1_h_s_overlap_c;
00808 dsp->vc1_v_s_overlap = vc1_v_s_overlap_c;
00809 dsp->vc1_v_loop_filter4 = vc1_v_loop_filter4_c;
00810 dsp->vc1_h_loop_filter4 = vc1_h_loop_filter4_c;
00811 dsp->vc1_v_loop_filter8 = vc1_v_loop_filter8_c;
00812 dsp->vc1_h_loop_filter8 = vc1_h_loop_filter8_c;
00813 dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_c;
00814 dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_c;
00815
00816 dsp->put_vc1_mspel_pixels_tab[ 0] = ff_put_pixels8x8_c;
00817 dsp->put_vc1_mspel_pixels_tab[ 1] = put_vc1_mspel_mc10_c;
00818 dsp->put_vc1_mspel_pixels_tab[ 2] = put_vc1_mspel_mc20_c;
00819 dsp->put_vc1_mspel_pixels_tab[ 3] = put_vc1_mspel_mc30_c;
00820 dsp->put_vc1_mspel_pixels_tab[ 4] = put_vc1_mspel_mc01_c;
00821 dsp->put_vc1_mspel_pixels_tab[ 5] = put_vc1_mspel_mc11_c;
00822 dsp->put_vc1_mspel_pixels_tab[ 6] = put_vc1_mspel_mc21_c;
00823 dsp->put_vc1_mspel_pixels_tab[ 7] = put_vc1_mspel_mc31_c;
00824 dsp->put_vc1_mspel_pixels_tab[ 8] = put_vc1_mspel_mc02_c;
00825 dsp->put_vc1_mspel_pixels_tab[ 9] = put_vc1_mspel_mc12_c;
00826 dsp->put_vc1_mspel_pixels_tab[10] = put_vc1_mspel_mc22_c;
00827 dsp->put_vc1_mspel_pixels_tab[11] = put_vc1_mspel_mc32_c;
00828 dsp->put_vc1_mspel_pixels_tab[12] = put_vc1_mspel_mc03_c;
00829 dsp->put_vc1_mspel_pixels_tab[13] = put_vc1_mspel_mc13_c;
00830 dsp->put_vc1_mspel_pixels_tab[14] = put_vc1_mspel_mc23_c;
00831 dsp->put_vc1_mspel_pixels_tab[15] = put_vc1_mspel_mc33_c;
00832
00833 dsp->avg_vc1_mspel_pixels_tab[ 0] = ff_avg_pixels8x8_c;
00834 dsp->avg_vc1_mspel_pixels_tab[ 1] = avg_vc1_mspel_mc10_c;
00835 dsp->avg_vc1_mspel_pixels_tab[ 2] = avg_vc1_mspel_mc20_c;
00836 dsp->avg_vc1_mspel_pixels_tab[ 3] = avg_vc1_mspel_mc30_c;
00837 dsp->avg_vc1_mspel_pixels_tab[ 4] = avg_vc1_mspel_mc01_c;
00838 dsp->avg_vc1_mspel_pixels_tab[ 5] = avg_vc1_mspel_mc11_c;
00839 dsp->avg_vc1_mspel_pixels_tab[ 6] = avg_vc1_mspel_mc21_c;
00840 dsp->avg_vc1_mspel_pixels_tab[ 7] = avg_vc1_mspel_mc31_c;
00841 dsp->avg_vc1_mspel_pixels_tab[ 8] = avg_vc1_mspel_mc02_c;
00842 dsp->avg_vc1_mspel_pixels_tab[ 9] = avg_vc1_mspel_mc12_c;
00843 dsp->avg_vc1_mspel_pixels_tab[10] = avg_vc1_mspel_mc22_c;
00844 dsp->avg_vc1_mspel_pixels_tab[11] = avg_vc1_mspel_mc32_c;
00845 dsp->avg_vc1_mspel_pixels_tab[12] = avg_vc1_mspel_mc03_c;
00846 dsp->avg_vc1_mspel_pixels_tab[13] = avg_vc1_mspel_mc13_c;
00847 dsp->avg_vc1_mspel_pixels_tab[14] = avg_vc1_mspel_mc23_c;
00848 dsp->avg_vc1_mspel_pixels_tab[15] = avg_vc1_mspel_mc33_c;
00849
00850 dsp->put_no_rnd_vc1_chroma_pixels_tab[0]= put_no_rnd_vc1_chroma_mc8_c;
00851 dsp->avg_no_rnd_vc1_chroma_pixels_tab[0]= avg_no_rnd_vc1_chroma_mc8_c;
00852 dsp->put_no_rnd_vc1_chroma_pixels_tab[1] = put_no_rnd_vc1_chroma_mc4_c;
00853
00854 #if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
00855 dsp->sprite_h = sprite_h_c;
00856 dsp->sprite_v_single = sprite_v_single_c;
00857 dsp->sprite_v_double_noscale = sprite_v_double_noscale_c;
00858 dsp->sprite_v_double_onescale = sprite_v_double_onescale_c;
00859 dsp->sprite_v_double_twoscale = sprite_v_double_twoscale_c;
00860 #endif
00861
00862 if (HAVE_ALTIVEC)
00863 ff_vc1dsp_init_altivec(dsp);
00864 if (HAVE_MMX)
00865 ff_vc1dsp_init_mmx(dsp);
00866 }