comparison vc1.c @ 3404:0f56ae23d338 libavcodec

Optimizations suggested by Michael Niedermayer
author kostya
date Tue, 04 Jul 2006 15:33:28 +0000
parents e88c3bc82b15
children 58c4fd135462
comparison
equal deleted inserted replaced
3403:fc0eb7836ccb 3404:0f56ae23d338
1017 1017
1018 dsp->put_no_rnd_qpel_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize); 1018 dsp->put_no_rnd_qpel_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize);
1019 } 1019 }
1020 } 1020 }
1021 1021
1022 #define SETMAXMIN(var) \
1023 if(var > ma) ma = var; \
1024 if(var < mi) mi = var;
1025
1026 static inline int median4(int a, int b, int c, int d) 1022 static inline int median4(int a, int b, int c, int d)
1027 { 1023 {
1028 int ma, mi; 1024 if(a < b) {
1029 1025 if(c < d) return (FFMIN(b, d) + FFMAX(a, c)) >> 1;
1030 ma = mi = a; 1026 else return (FFMIN(b, c) + FFMAX(a, d)) >> 1;
1031 SETMAXMIN(b); 1027 } else {
1032 SETMAXMIN(c); 1028 if(c < d) return (FFMIN(a, d) + FFMAX(b, c)) >> 1;
1033 SETMAXMIN(d); 1029 else return (FFMIN(a, c) + FFMAX(b, d)) >> 1;
1034 1030 }
1035 return (a + b + c + d - ma - mi) >> 1;
1036 } 1031 }
1037 1032
1038 1033
1039 /** Do motion compensation for 4-MV macroblock - both chroma blocks 1034 /** Do motion compensation for 4-MV macroblock - both chroma blocks
1040 */ 1035 */
1406 * @fixme XXX: Don't know how to initialize mquant otherwise in last case 1401 * @fixme XXX: Don't know how to initialize mquant otherwise in last case
1407 */ 1402 */
1408 #define GET_MQUANT() \ 1403 #define GET_MQUANT() \
1409 if (v->dquantfrm) \ 1404 if (v->dquantfrm) \
1410 { \ 1405 { \
1406 int edges = 0; \
1411 if (v->dqprofile == DQPROFILE_ALL_MBS) \ 1407 if (v->dqprofile == DQPROFILE_ALL_MBS) \
1412 { \ 1408 { \
1413 if (v->dqbilevel) \ 1409 if (v->dqbilevel) \
1414 { \ 1410 { \
1415 mquant = (get_bits(gb, 1)) ? v->pq : v->altpq; \ 1411 mquant = (get_bits(gb, 1)) ? v->pq : v->altpq; \
1419 mqdiff = get_bits(gb, 3); \ 1415 mqdiff = get_bits(gb, 3); \
1420 if (mqdiff != 7) mquant = v->pq + mqdiff; \ 1416 if (mqdiff != 7) mquant = v->pq + mqdiff; \
1421 else mquant = get_bits(gb, 5); \ 1417 else mquant = get_bits(gb, 5); \
1422 } \ 1418 } \
1423 } \ 1419 } \
1424 else if(v->dqprofile == DQPROFILE_SINGLE_EDGE) \ 1420 if(v->dqprofile == DQPROFILE_SINGLE_EDGE) \
1425 { \ 1421 edges = 1 << v->dqsbedge; \
1426 switch(v->dqsbedge){ \
1427 case 0: /* left */ \
1428 mquant = (s->mb_x) ? v->pq : v->altpq; \
1429 break; \
1430 case 1: /* top */ \
1431 mquant = (s->mb_y) ? v->pq : v->altpq; \
1432 break; \
1433 case 2: /* right */ \
1434 mquant = (s->mb_x != (s->mb_width - 1)) ? v->pq : v->altpq; \
1435 break; \
1436 case 3: /* bottom */ \
1437 mquant = (s->mb_y != (s->mb_height-1)) ? v->pq : v->altpq; \
1438 break; \
1439 default: \
1440 mquant = v->pq; \
1441 } \
1442 } \
1443 else if(v->dqprofile == DQPROFILE_DOUBLE_EDGES) \ 1422 else if(v->dqprofile == DQPROFILE_DOUBLE_EDGES) \
1444 { \ 1423 edges = (3 << v->dqsbedge) % 15; \
1445 switch(v->dqsbedge){ \
1446 case 0: /* left and top */ \
1447 mquant = (s->mb_x && s->mb_y) ? v->pq : v->altpq; \
1448 break; \
1449 case 1: /* top and right */ \
1450 mquant = (s->mb_y && s->mb_x != (s->mb_width - 1)) ? v->pq : v->altpq; \
1451 break; \
1452 case 2: /* right and bottom */ \
1453 mquant = (s->mb_x != (s->mb_width - 1) && s->mb_y != (s->mb_height-1)) ? v->pq : v->altpq; \
1454 break; \
1455 case 3: /* bottom and left */ \
1456 mquant = (s->mb_x && s->mb_y != (s->mb_height-1)) ? v->pq : v->altpq; \
1457 break; \
1458 default: \
1459 mquant = v->pq; \
1460 } \
1461 } \
1462 else if(v->dqprofile == DQPROFILE_FOUR_EDGES) \ 1424 else if(v->dqprofile == DQPROFILE_FOUR_EDGES) \
1463 { \ 1425 edges = 15; \
1464 mquant = (s->mb_x && s->mb_y && s->mb_x != (s->mb_width - 1) && s->mb_y != (s->mb_height-1)) ? v->pq : v->altpq; \ 1426 mquant = v->pq; \
1465 } \ 1427 if((edges&1) && !s->mb_x) \
1466 else mquant = v->pq; \ 1428 mquant = v->altpq; \
1429 if((edges&2) && !s->mb_y) \
1430 mquant = v->altpq; \
1431 if((edges&4) && s->mb_x == (s->mb_width - 1)) \
1432 mquant = v->altpq; \
1433 if((edges&8) && s->mb_y == (s->mb_height - 1)) \
1434 mquant = v->altpq; \
1467 } 1435 }
1468 1436
1469 /** 1437 /**
1470 * @def GET_MVDATA(_dmv_x, _dmv_y) 1438 * @def GET_MVDATA(_dmv_x, _dmv_y)
1471 * @brief Get MV differentials 1439 * @brief Get MV differentials