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