Mercurial > libavcodec.hg
comparison motion_est.c @ 612:c0005de2be59 libavcodec
new ratecontrol code
author | michaelni |
---|---|
date | Sun, 25 Aug 2002 21:19:50 +0000 |
parents | 98e39397636b |
children | a5aa53b6e648 |
comparison
equal
deleted
inserted
replaced
611:3214d3f4519e | 612:c0005de2be59 |
---|---|
39 #define P_LAST_TOP P[7] | 39 #define P_LAST_TOP P[7] |
40 #define P_LAST_BOTTOM P[8] | 40 #define P_LAST_BOTTOM P[8] |
41 #define P_MV1 P[9] | 41 #define P_MV1 P[9] |
42 | 42 |
43 | 43 |
44 static int pix_sum(UINT8 * pix, int line_size) | |
45 { | |
46 int s, i, j; | |
47 | |
48 s = 0; | |
49 for (i = 0; i < 16; i++) { | |
50 for (j = 0; j < 16; j += 8) { | |
51 s += pix[0]; | |
52 s += pix[1]; | |
53 s += pix[2]; | |
54 s += pix[3]; | |
55 s += pix[4]; | |
56 s += pix[5]; | |
57 s += pix[6]; | |
58 s += pix[7]; | |
59 pix += 8; | |
60 } | |
61 pix += line_size - 16; | |
62 } | |
63 return s; | |
64 } | |
65 | |
66 static int pix_dev(UINT8 * pix, int line_size, int mean) | 44 static int pix_dev(UINT8 * pix, int line_size, int mean) |
67 { | 45 { |
68 int s, i, j; | 46 int s, i, j; |
69 | 47 |
70 s = 0; | 48 s = 0; |
76 s += ABS(pix[3]-mean); | 54 s += ABS(pix[3]-mean); |
77 s += ABS(pix[4]-mean); | 55 s += ABS(pix[4]-mean); |
78 s += ABS(pix[5]-mean); | 56 s += ABS(pix[5]-mean); |
79 s += ABS(pix[6]-mean); | 57 s += ABS(pix[6]-mean); |
80 s += ABS(pix[7]-mean); | 58 s += ABS(pix[7]-mean); |
81 pix += 8; | |
82 } | |
83 pix += line_size - 16; | |
84 } | |
85 return s; | |
86 } | |
87 | |
88 static int pix_norm1(UINT8 * pix, int line_size) | |
89 { | |
90 int s, i, j; | |
91 UINT32 *sq = squareTbl + 256; | |
92 | |
93 s = 0; | |
94 for (i = 0; i < 16; i++) { | |
95 for (j = 0; j < 16; j += 8) { | |
96 s += sq[pix[0]]; | |
97 s += sq[pix[1]]; | |
98 s += sq[pix[2]]; | |
99 s += sq[pix[3]]; | |
100 s += sq[pix[4]]; | |
101 s += sq[pix[5]]; | |
102 s += sq[pix[6]]; | |
103 s += sq[pix[7]]; | |
104 pix += 8; | 59 pix += 8; |
105 } | 60 } |
106 pix += line_size - 16; | 61 pix += line_size - 16; |
107 } | 62 } |
108 return s; | 63 return s; |
1576 bmin= ff_estimate_motion_b(s, mb_x, mb_y, s->b_back_mv_table, s->next_picture[0], s->b_code) - quant; | 1531 bmin= ff_estimate_motion_b(s, mb_x, mb_y, s->b_back_mv_table, s->next_picture[0], s->b_code) - quant; |
1577 //printf(" %d %d ", s->b_forw_mv_table[xy][0], s->b_forw_mv_table[xy][1]); | 1532 //printf(" %d %d ", s->b_forw_mv_table[xy][0], s->b_forw_mv_table[xy][1]); |
1578 | 1533 |
1579 fbmin= bidir_refine(s, mb_x, mb_y); | 1534 fbmin= bidir_refine(s, mb_x, mb_y); |
1580 | 1535 |
1581 if(s->flags&CODEC_FLAG_HQ){ | 1536 { |
1582 type= MB_TYPE_FORWARD | MB_TYPE_BACKWARD | MB_TYPE_BIDIR | MB_TYPE_DIRECT; | |
1583 }else{ | |
1584 int score= dmin; | 1537 int score= dmin; |
1585 type=MB_TYPE_DIRECT; | 1538 type=MB_TYPE_DIRECT; |
1586 | 1539 |
1587 if(fmin<score){ | 1540 if(fmin<score){ |
1588 score=fmin; | 1541 score=fmin; |
1594 } | 1547 } |
1595 if(fbmin<score){ | 1548 if(fbmin<score){ |
1596 score=fbmin; | 1549 score=fbmin; |
1597 type= MB_TYPE_BIDIR; | 1550 type= MB_TYPE_BIDIR; |
1598 } | 1551 } |
1552 score= (score*score)>>8; | |
1599 s->mc_mb_var_sum += score; | 1553 s->mc_mb_var_sum += score; |
1600 s->mc_mb_var[mb_y*s->mb_width + mb_x] = score; | 1554 s->mc_mb_var[mb_y*s->mb_width + mb_x] = score; //FIXME use SSD |
1601 } | 1555 } |
1556 | |
1557 if(s->flags&CODEC_FLAG_HQ){ | |
1558 type= MB_TYPE_FORWARD | MB_TYPE_BACKWARD | MB_TYPE_BIDIR | MB_TYPE_DIRECT; //FIXME something smarter | |
1559 } | |
1560 | |
1602 /* | 1561 /* |
1603 { | 1562 { |
1604 static int count=0; | 1563 static int count=0; |
1605 static int sum=0; | 1564 static int sum=0; |
1606 if(type==MB_TYPE_DIRECT){ | 1565 if(type==MB_TYPE_DIRECT){ |