[svn] / trunk / xvidcore / src / motion / motion_comp.c Repository:
ViewVC logotype

Annotation of /trunk/xvidcore/src/motion/motion_comp.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 78 - (view) (download)

1 : Isibaar 3 #include "../encoder.h"
2 :     #include "../utils/mbfunctions.h"
3 :     #include "../image/interpolate8x8.h"
4 :     #include "../utils/timer.h"
5 :    
6 :     #define ABS(X) (((X)>0)?(X):-(X))
7 :     #define SIGN(X) (((X)>0)?1:-1)
8 :    
9 :     static __inline void compensate8x8_halfpel(
10 :     int16_t * const dct_codes,
11 :     uint8_t * const cur,
12 :     const uint8_t * const ref,
13 :     const uint8_t * const refh,
14 :     const uint8_t * const refv,
15 :     const uint8_t * const refhv,
16 :     const uint32_t x, const uint32_t y,
17 :     const int32_t dx, const int dy,
18 :     const uint32_t stride)
19 :     {
20 :     int32_t ddx,ddy;
21 :    
22 :     switch ( ((dx&1)<<1) + (dy&1) ) // ((dx%2)?2:0)+((dy%2)?1:0)
23 :     {
24 :     case 0 :
25 :     ddx = dx/2;
26 :     ddy = dy/2;
27 :     transfer_8to16sub(dct_codes, cur + y*stride + x,
28 :     ref + (y+ddy)*stride + x+ddx, stride);
29 :     break;
30 :    
31 :     case 1 :
32 :     ddx = dx/2;
33 :     ddy = (dy-1)/2;
34 :     transfer_8to16sub(dct_codes, cur + y*stride + x,
35 :     refv + (y+ddy)*stride + x+ddx, stride);
36 :     break;
37 :    
38 :     case 2 :
39 :     ddx = (dx-1)/2;
40 :     ddy = dy/2;
41 :     transfer_8to16sub(dct_codes, cur + y*stride + x,
42 :     refh + (y+ddy)*stride + x+ddx, stride);
43 :     break;
44 :    
45 :     default : // case 3:
46 :     ddx = (dx-1)/2;
47 :     ddy = (dy-1)/2;
48 :     transfer_8to16sub(dct_codes, cur + y*stride + x,
49 :     refhv + (y+ddy)*stride + x+ddx, stride);
50 :     break;
51 :     }
52 :     }
53 :    
54 :    
55 :    
56 :     void MBMotionCompensation(
57 : edgomez 78 MACROBLOCK * const mb,
58 :     const uint32_t i,
59 :     const uint32_t j,
60 :     const IMAGE * const ref,
61 :     const IMAGE * const refh,
62 :     const IMAGE * const refv,
63 :     const IMAGE * const refhv,
64 :     IMAGE * const cur,
65 :     int16_t *dct_codes,
66 :     const uint32_t width,
67 :     const uint32_t height,
68 :     const uint32_t edged_width,
69 :     const uint32_t rounding)
70 : Isibaar 3 {
71 :     static const uint32_t roundtab[16] =
72 :     { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 };
73 :    
74 :    
75 :     if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q)
76 :     {
77 :     int32_t dx = mb->mvs[0].x;
78 :     int32_t dy = mb->mvs[0].y;
79 :    
80 : edgomez 78 compensate8x8_halfpel(&dct_codes[0*64], cur->y, ref->y, refh->y, refv->y, refhv->y,
81 :     16*i, 16*j, dx, dy, edged_width);
82 :     compensate8x8_halfpel(&dct_codes[1*64], cur->y, ref->y, refh->y, refv->y, refhv->y,
83 :     16*i + 8, 16*j, dx, dy, edged_width);
84 :     compensate8x8_halfpel(&dct_codes[2*64], cur->y, ref->y, refh->y, refv->y, refhv->y,
85 :     16*i, 16*j + 8, dx, dy, edged_width);
86 :     compensate8x8_halfpel(&dct_codes[3*64], cur->y, ref->y, refh->y, refv->y, refhv->y,
87 :     16*i + 8, 16*j + 8, dx, dy, edged_width);
88 : Isibaar 3
89 :     dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;
90 :     dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;
91 :    
92 :     /* uv-image-based compensation
93 : edgomez 78 compensate8x8_halfpel(dct_codes[4], cur->u, ref->u, refh->u, refv->u, refhv->u,
94 :     8*i, 8*j, dx, dy, edged_width/2);
95 :     compensate8x8_halfpel(dct_codes[5], cur->v, ref->v, refh->v, refv->v, refhv->v,
96 :     8*i, 8*j, dx, dy, edged_width/2); */
97 : Isibaar 3
98 :     /* uv-block-based compensation */
99 :     interpolate8x8_switch(refv->u, ref->u, 8*i, 8*j, dx, dy, edged_width/2, rounding);
100 : edgomez 78 transfer_8to16sub(&dct_codes[4*64],
101 :     cur->u + 8*j*edged_width/2 + 8*i,
102 :     refv->u + 8*j*edged_width/2 + 8*i, edged_width/2);
103 : Isibaar 3
104 :     interpolate8x8_switch(refv->v, ref->v, 8*i, 8*j, dx, dy, edged_width/2, rounding);
105 : edgomez 78 transfer_8to16sub(&dct_codes[5*64],
106 :     cur->v + 8*j*edged_width/2 + 8*i,
107 :     refv->v + 8*j*edged_width/2 + 8*i, edged_width/2);
108 : Isibaar 3
109 :     }
110 :     else // mode == MODE_INTER4V
111 :     {
112 :     int32_t sum, dx, dy;
113 :    
114 : edgomez 78 compensate8x8_halfpel(&dct_codes[0*64], cur->y, ref->y, refh->y, refv->y, refhv->y,
115 :     16*i, 16*j, mb->mvs[0].x, mb->mvs[0].y, edged_width);
116 :     compensate8x8_halfpel(&dct_codes[1*64], cur->y, ref->y, refh->y, refv->y, refhv->y,
117 :     16*i + 8, 16*j, mb->mvs[1].x, mb->mvs[1].y, edged_width);
118 :     compensate8x8_halfpel(&dct_codes[2*64], cur->y, ref->y, refh->y, refv->y, refhv->y,
119 :     16*i, 16*j + 8, mb->mvs[2].x, mb->mvs[2].y, edged_width);
120 :     compensate8x8_halfpel(&dct_codes[3*64], cur->y, ref->y, refh->y, refv->y, refhv->y,
121 :     16*i + 8, 16*j + 8, mb->mvs[3].x, mb->mvs[3].y, edged_width);
122 : Isibaar 3
123 :     sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x;
124 :     dx = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);
125 :    
126 :     sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y;
127 :     dy = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);
128 :    
129 :     /* uv-image-based compensation
130 : edgomez 78 compensate8x8_halfpel(dct_codes[4], cur->u, ref->u, refh->u, refv->u, refhv->u,
131 :     8*i, 8*j, dx, dy, edged_width/2);
132 :     compensate8x8_halfpel(dct_codes[5], cur->v, ref->v, refh->v, refv->v, refhv->v,
133 :     8*i, 8*j, dx, dy, edged_width/2); */
134 : Isibaar 3
135 :     /* uv-block-based compensation */
136 :     interpolate8x8_switch(refv->u, ref->u, 8*i, 8*j, dx, dy, edged_width/2, rounding);
137 : edgomez 78 transfer_8to16sub(&dct_codes[4*64],
138 :     cur->u + 8*j*edged_width/2 + 8*i,
139 :     refv->u + 8*j*edged_width/2 + 8*i, edged_width/2);
140 : Isibaar 3
141 :     interpolate8x8_switch(refv->v, ref->v, 8*i, 8*j, dx, dy, edged_width/2, rounding);
142 : edgomez 78 transfer_8to16sub(&dct_codes[5*64],
143 :     cur->v + 8*j*edged_width/2 + 8*i,
144 :     refv->v + 8*j*edged_width/2 + 8*i, edged_width/2);
145 : Isibaar 3
146 :     }
147 :     }

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4