[svn] / branches / dev-api-3 / xvidcore / src / motion / motion_comp.c Repository:
ViewVC logotype

Diff of /branches/dev-api-3/xvidcore/src/motion/motion_comp.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/xvidcore/src/motion/motion_comp.c revision 3, Fri Mar 8 02:46:11 2002 UTC branches/dev-api-3/xvidcore/src/motion/motion_comp.c revision 581, Sat Oct 5 21:42:04 2002 UTC
# Line 1  Line 1 
1    // 04.10.2002   added qpel support to MBMotionCompensation
2    // 01.05.2002   updated MBMotionCompensationBVOP
3    // 14.04.2002   bframe compensation
4    
5  #include "../encoder.h"  #include "../encoder.h"
6  #include "../utils/mbfunctions.h"  #include "../utils/mbfunctions.h"
7  #include "../image/interpolate8x8.h"  #include "../image/interpolate8x8.h"
8  #include "../utils/timer.h"  #include "../utils/timer.h"
9    #include "motion.h"
10    
11  #define ABS(X) (((X)>0)?(X):-(X))  #define ABS(X) (((X)>0)?(X):-(X))
12  #define SIGN(X) (((X)>0)?1:-1)  #define SIGN(X) (((X)>0)?1:-1)
13    
14  static __inline void compensate8x8_halfpel(  
15                                  int16_t * const dct_codes,  static __inline void
16    compensate8x8_interpolate(int16_t * const dct_codes,
17                                  uint8_t * const cur,                                  uint8_t * const cur,
18                                  const uint8_t * const ref,                                  const uint8_t * const ref,
19                                  const uint8_t * const refh,                                  const uint8_t * const refh,
20                                  const uint8_t * const refv,                                  const uint8_t * const refv,
21                                  const uint8_t * const refhv,                                  const uint8_t * const refhv,
22                                  const uint32_t x, const uint32_t y,                                                    const uint32_t x,
23                                  const int32_t dx,  const int dy,                                                    const uint32_t y,
24                                  const uint32_t stride)                                                    const int32_t dx,
25                                                      const int32_t dy,
26                                                      const uint32_t stride,
27                                                      const uint32_t quarterpel,
28                                                      const uint32_t rounding)
29  {  {
30          int32_t ddx,ddy;          if(quarterpel) {
31                    interpolate8x8_quarterpel((uint8_t *) refv, (uint8_t *) ref, (uint8_t *) refh,
32                            (uint8_t *) refh + 64, (uint8_t *) refhv, x, y, dx, dy, stride, rounding);
33    
         switch ( ((dx&1)<<1) + (dy&1) )   // ((dx%2)?2:0)+((dy%2)?1:0)  
     {  
     case 0 :  
                 ddx = dx/2;  
                 ddy = dy/2;  
34                  transfer_8to16sub(dct_codes, cur + y*stride + x,                  transfer_8to16sub(dct_codes, cur + y*stride + x,
35                                  ref + (y+ddy)*stride + x+ddx, stride);                                                    refv + y*stride + x, stride);
36                  break;          }
37            else
38      case 1 :          {
39                  ddx = dx/2;                  const uint8_t * reference;
                 ddy = (dy-1)/2;  
                 transfer_8to16sub(dct_codes, cur + y*stride + x,  
                                 refv + (y+ddy)*stride + x+ddx, stride);  
                 break;  
   
     case 2 :  
                 ddx = (dx-1)/2;  
                 ddy = dy/2;  
                 transfer_8to16sub(dct_codes, cur + y*stride + x,  
                                 refh + (y+ddy)*stride + x+ddx, stride);  
                 break;  
40    
41                    switch (((dx & 1) << 1) + (dy & 1))     // ((dx%2)?2:0)+((dy%2)?1:0)
42                    {
43                    case 0: reference = ref + ((y + dy / 2) * stride + x + dx / 2); break;
44                    case 1: reference = refv + ((y + (dy-1) / 2) * stride + x + dx / 2); break;
45                    case 2: reference = refh + ((y + dy / 2) * stride + x + (dx-1) / 2); break;
46          default :       // case 3:          default :       // case 3:
47                  ddx = (dx-1)/2;                          reference = refhv + ((y + (dy-1) / 2) * stride + x + (dx-1) / 2); break;
48                  ddy = (dy-1)/2;                  }
49                  transfer_8to16sub(dct_codes, cur + y*stride + x,                  transfer_8to16sub(dct_codes, cur + y*stride + x,
50                                  refhv + (y+ddy)*stride + x+ddx, stride);                                                            reference, stride);
                 break;  
51      }      }
52  }  }
53    
54    void
55    MBMotionCompensation(MACROBLOCK * const mb,
 void MBMotionCompensation(  
                         MACROBLOCK * const mb,  
56                      const uint32_t i,                      const uint32_t i,
57                          const uint32_t j,                          const uint32_t j,
58                      const IMAGE * const ref,                      const IMAGE * const ref,
# Line 62  Line 60 
60                      const IMAGE * const refv,                      const IMAGE * const refv,
61                          const IMAGE * const refhv,                          const IMAGE * const refhv,
62                      IMAGE * const cur,                      IMAGE * const cur,
63                      int16_t dct_codes[][64],                                           int16_t * dct_codes,
64                          const uint32_t width,                          const uint32_t width,
65                          const uint32_t height,                          const uint32_t height,
66                          const uint32_t edged_width,                          const uint32_t edged_width,
67                                             const uint32_t quarterpel,
68                          const uint32_t rounding)                          const uint32_t rounding)
69  {  {
70          static const uint32_t roundtab[16] =          if (mb->mode == MODE_NOT_CODED) {
71                  { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 };                  transfer8x8_copy(cur->y + 16 * (i + j * edged_width),
72                                                            ref->y + 16 * (i + j * edged_width),
73                                                            edged_width);
74                    transfer8x8_copy(cur->y + 16 * (i + j * edged_width) + 8,
75                                                            ref->y + 16 * (i + j * edged_width) + 8,
76                                                            edged_width);
77                    transfer8x8_copy(cur->y + 16 * (i + j * edged_width) + 8 * edged_width,
78                                                            ref->y + 16 * (i + j * edged_width) + 8 * edged_width,
79                                                            edged_width);
80                    transfer8x8_copy(cur->y + 16 * (i + j * edged_width) + 8 * (edged_width+1),
81                                                            ref->y + 16 * (i + j * edged_width) + 8 * (edged_width+1),
82                                                            edged_width);
83    
84                    transfer8x8_copy(cur->u + 8 * (i + j * edged_width/2),
85                                                            ref->u + 8 * (i + j * edged_width/2),
86                                                            edged_width / 2);
87                    transfer8x8_copy(cur->v + 8 * (i + j * edged_width/2),
88                                                            ref->v + 8 * (i + j * edged_width/2),
89                                                            edged_width / 2);
90                    return;
91            }
92    
93          if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q)          if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) {
         {  
94                  int32_t dx = mb->mvs[0].x;                  int32_t dx = mb->mvs[0].x;
95                  int32_t dy = mb->mvs[0].y;                  int32_t dy = mb->mvs[0].y;
96    
97                  compensate8x8_halfpel(dct_codes[0], cur->y, ref->y, refh->y, refv->y, refhv->y,                  if(quarterpel) {
98                                                                  16*i,     16*j,     dx, dy, edged_width);                          dx = mb->qmvs[0].x;
99                  compensate8x8_halfpel(dct_codes[1], cur->y, ref->y, refh->y, refv->y, refhv->y,                          dy = mb->qmvs[0].y;
100                                                                  16*i + 8, 16*j,     dx, dy, edged_width);                  }
101                  compensate8x8_halfpel(dct_codes[2], cur->y, ref->y, refh->y, refv->y, refhv->y,  
102                                                                  16*i,     16*j + 8, dx, dy, edged_width);                  compensate8x8_interpolate(&dct_codes[0 * 64], cur->y, ref->y, refh->y,
103                  compensate8x8_halfpel(dct_codes[3], cur->y, ref->y, refh->y, refv->y, refhv->y,                                                            refv->y, refhv->y, 16 * i, 16 * j, dx, dy,
104                                                                  16*i + 8, 16*j + 8, dx, dy, edged_width);                                                            edged_width, quarterpel, rounding);
105                    compensate8x8_interpolate(&dct_codes[1 * 64], cur->y, ref->y, refh->y,
106                                                              refv->y, refhv->y, 16 * i + 8, 16 * j, dx, dy,
107                                                              edged_width, quarterpel, rounding);
108                    compensate8x8_interpolate(&dct_codes[2 * 64], cur->y, ref->y, refh->y,
109                                                              refv->y, refhv->y, 16 * i, 16 * j + 8, dx, dy,
110                                                              edged_width, quarterpel, rounding);
111                    compensate8x8_interpolate(&dct_codes[3 * 64], cur->y, ref->y, refh->y,
112                                                              refv->y, refhv->y, 16 * i + 8, 16 * j + 8, dx,
113                                                              dy, edged_width, quarterpel, rounding);
114    
115                    if (quarterpel)
116                    {
117                            dx = (dx >> 1) | (dx & 1);
118                            dy = (dy >> 1) | (dy & 1);
119                    }
120    
121                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;
122                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;
123    
124                  /* uv-image-based compensation                  /* uv-block-based compensation */
125                  compensate8x8_halfpel(dct_codes[4], cur->u, ref->u, refh->u, refv->u, refhv->u,                  transfer_8to16sub(&dct_codes[4 * 64],
126                                                                  8*i, 8*j, dx, dy, edged_width/2);                                                          cur->u + 8 * j * edged_width / 2 + 8 * i,
127                  compensate8x8_halfpel(dct_codes[5], cur->v, ref->v, refh->v, refv->v, refhv->v,                                                          interpolate8x8_switch2(refv->u, ref->u, 8 * i, 8 * j,
128                                                                  8*i, 8*j, dx, dy, edged_width/2);               */                                                                                                          dx, dy, edged_width / 2, rounding),
129                                                            edged_width / 2);
130    
131                    transfer_8to16sub(&dct_codes[5 * 64],
132                                                            cur->v + 8 * j * edged_width / 2 + 8 * i,
133                                                            interpolate8x8_switch2(refv->u, ref->v, 8 * i, 8 * j,
134                                                                                                            dx, dy, edged_width / 2, rounding),
135                                                            edged_width / 2);
136    
137            } else {                                        // mode == MODE_INTER4V
138                    int32_t sum, dx, dy;
139                    VECTOR *mvs;
140    
141                    if(quarterpel)
142                            mvs = mb->qmvs;
143                    else
144                            mvs = mb->mvs;
145    
146                    compensate8x8_interpolate(&dct_codes[0 * 64], cur->y, ref->y, refh->y,
147                                                              refv->y, refhv->y, 16 * i, 16 * j, mvs[0].x,
148                                                              mvs[0].y, edged_width, quarterpel, rounding);
149                    compensate8x8_interpolate(&dct_codes[1 * 64], cur->y, ref->y, refh->y,
150                                                              refv->y, refhv->y, 16 * i + 8, 16 * j,
151                                                              mvs[1].x, mvs[1].y, edged_width, quarterpel, rounding);
152                    compensate8x8_interpolate(&dct_codes[2 * 64], cur->y, ref->y, refh->y,
153                                                              refv->y, refhv->y, 16 * i, 16 * j + 8,
154                                                              mvs[2].x, mvs[2].y, edged_width, quarterpel, rounding);
155                    compensate8x8_interpolate(&dct_codes[3 * 64], cur->y, ref->y, refh->y,
156                                                              refv->y, refhv->y, 16 * i + 8, 16 * j + 8,
157                                                              mvs[3].x, mvs[3].y, edged_width, quarterpel, rounding);
158    
159                    sum = mvs[0].x + mvs[1].x + mvs[2].x + mvs[3].x;
160    
161                    if(quarterpel)
162                            sum /= 2;
163    
164                    dx = (sum ? SIGN(sum) *
165                              (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);
166    
167                    sum = mvs[0].y + mvs[1].y + mvs[2].y + mvs[3].y;
168    
169                    if(quarterpel)
170                            sum /= 2;
171    
172                    dy = (sum ? SIGN(sum) *
173                              (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);
174    
175                  /* uv-block-based compensation */                  /* uv-block-based compensation */
176                  interpolate8x8_switch(refv->u, ref->u, 8*i, 8*j, dx, dy, edged_width/2, rounding);                  transfer_8to16sub(&dct_codes[4 * 64],
                 transfer_8to16sub(dct_codes[4],  
177                                  cur->u + 8*j*edged_width/2 + 8*i,                                  cur->u + 8*j*edged_width/2 + 8*i,
178                                  refv->u + 8*j*edged_width/2 + 8*i, edged_width/2);                                                          interpolate8x8_switch2(refv->u, ref->u, 8 * i, 8 * j,
179                                                                                                            dx, dy, edged_width / 2, rounding),
180                                                            edged_width / 2);
181    
182                  interpolate8x8_switch(refv->v, ref->v, 8*i, 8*j, dx, dy, edged_width/2, rounding);                  transfer_8to16sub(&dct_codes[5 * 64],
                 transfer_8to16sub(dct_codes[5],  
183                                  cur->v + 8*j*edged_width/2 + 8*i,                                  cur->v + 8*j*edged_width/2 + 8*i,
184                                  refv->v + 8*j*edged_width/2 + 8*i, edged_width/2);                                                          interpolate8x8_switch2(refv->u, ref->v, 8 * i, 8 * j,
185                                                                                                            dx, dy, edged_width / 2, rounding),
186    
187                                                            edged_width / 2);
188          }          }
189          else    // mode == MODE_INTER4V  }
190    
191    
192    void
193    MBMotionCompensationBVOP(MBParam * pParam,
194                                                     MACROBLOCK * const mb,
195                                                     const uint32_t i,
196                                                     const uint32_t j,
197                                                     IMAGE * const cur,
198                                                     const IMAGE * const f_ref,
199                                                     const IMAGE * const f_refh,
200                                                     const IMAGE * const f_refv,
201                                                     const IMAGE * const f_refhv,
202                                                     const IMAGE * const b_ref,
203                                                     const IMAGE * const b_refh,
204                                                     const IMAGE * const b_refv,
205                                                     const IMAGE * const b_refhv,
206                                                     int16_t * dct_codes)
207          {          {
208                  int32_t sum, dx, dy;          static const uint32_t roundtab[16] =
209                    { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 };
210    
211                  compensate8x8_halfpel(dct_codes[0], cur->y, ref->y, refh->y, refv->y, refhv->y,          const int32_t edged_width = pParam->edged_width;
212                                                                  16*i,     16*j,     mb->mvs[0].x, mb->mvs[0].y, edged_width);          int32_t dx, dy;
213                  compensate8x8_halfpel(dct_codes[1], cur->y, ref->y, refh->y, refv->y, refhv->y,          int32_t b_dx, b_dy;
214                                                                  16*i + 8, 16*j,     mb->mvs[1].x, mb->mvs[1].y, edged_width);          int k,sum;
215                  compensate8x8_halfpel(dct_codes[2], cur->y, ref->y, refh->y, refv->y, refhv->y,          int x = i;
216                                                                  16*i,     16*j + 8, mb->mvs[2].x, mb->mvs[2].y, edged_width);          int y = j;
217                  compensate8x8_halfpel(dct_codes[3], cur->y, ref->y, refh->y, refv->y, refhv->y,  
218                                                                  16*i + 8, 16*j + 8, mb->mvs[3].x, mb->mvs[3].y, edged_width);  
219            switch (mb->mode) {
220            case MODE_FORWARD:
221                    dx = mb->mvs[0].x;
222                    dy = mb->mvs[0].y;
223    
224                    transfer_8to16sub(&dct_codes[0 * 64],
225                                                            cur->y + (j * 16) * edged_width + (i * 16),
226                                                            get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
227                                                                            i * 16, j * 16, 1, dx, dy, edged_width),
228                                                            edged_width);
229    
230                    transfer_8to16sub(&dct_codes[1 * 64],
231                                                            cur->y + (j * 16) * edged_width + (i * 16 + 8),
232                                                            get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
233                                                                      i * 16 + 8, j * 16, 1, dx, dy, edged_width),
234                                                            edged_width);
235    
236                    transfer_8to16sub(&dct_codes[2 * 64],
237                                                            cur->y + (j * 16 + 8) * edged_width + (i * 16),
238                                                            get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
239                                                                            i * 16, j * 16 + 8, 1, dx, dy, edged_width),
240                                                            edged_width);
241    
242                    transfer_8to16sub(&dct_codes[3 * 64],
243                                                            cur->y + (j * 16 + 8) * edged_width + (i * 16 + 8),
244                                                            get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
245                                                                      i * 16 + 8, j * 16 + 8, 1, dx, dy, edged_width),
246                                                            edged_width);
247    
                 sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x;  
                 dx = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);  
248    
249                  sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y;                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;
250                  dy = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;
251    
252                  /* uv-image-based compensation                  /* uv-block-based compensation */
253                  compensate8x8_halfpel(dct_codes[4], cur->u, ref->u, refh->u, refv->u, refhv->u,                  transfer_8to16sub(&dct_codes[4 * 64],
254                                                                  8*i, 8*j, dx, dy, edged_width/2);                                                          cur->u + 8 * j * edged_width / 2 + 8 * i,
255                  compensate8x8_halfpel(dct_codes[5], cur->v, ref->v, refh->v, refv->v, refhv->v,                                                          interpolate8x8_switch2(f_refv->u, f_ref->u, 8 * i, 8 * j,
256                                                                  8*i, 8*j, dx, dy, edged_width/2);               */                                                                                                          dx, dy, edged_width / 2, 0),
257    
258                                                      edged_width / 2);
259    
260                    transfer_8to16sub(&dct_codes[5 * 64],
261                                                            cur->v + 8 * j * edged_width / 2 + 8 * i,
262                                                            interpolate8x8_switch2(f_refv->u, f_ref->v, 8 * i, 8 * j,
263                                                                                                            dx, dy, edged_width / 2, 0),
264    
265                                                      edged_width / 2);
266    
267                    break;
268    
269            case MODE_BACKWARD:
270                    b_dx = mb->b_mvs[0].x;
271                    b_dy = mb->b_mvs[0].y;
272    
273                    transfer_8to16sub(&dct_codes[0 * 64],
274                                                            cur->y + (j * 16) * edged_width + (i * 16),
275                                                            get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
276                                                                            i * 16, j * 16, 1, b_dx, b_dy,
277                                                                            edged_width), edged_width);
278    
279                    transfer_8to16sub(&dct_codes[1 * 64],
280                                                      cur->y + (j * 16) * edged_width + (i * 16 + 8),
281                                                      get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
282                                                                      i * 16 + 8, j * 16, 1, b_dx, b_dy,
283                                                                      edged_width), edged_width);
284    
285                    transfer_8to16sub(&dct_codes[2 * 64],
286                                                            cur->y + (j * 16 + 8) * edged_width + (i * 16),
287                                                            get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
288                                                                            i * 16, j * 16 + 8, 1, b_dx, b_dy,
289                                                                            edged_width), edged_width);
290    
291                    transfer_8to16sub(&dct_codes[3 * 64],
292                                                      cur->y + (j * 16 + 8) * edged_width + (i * 16 + 8),
293                                                      get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
294                                                                      i * 16 + 8, j * 16 + 8, 1, b_dx, b_dy,
295                                                                      edged_width), edged_width);
296    
297                    b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;
298                    b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;
299    
300                  /* uv-block-based compensation */                  /* uv-block-based compensation */
301                  interpolate8x8_switch(refv->u, ref->u, 8*i, 8*j, dx, dy, edged_width/2, rounding);                  transfer_8to16sub(&dct_codes[4 * 64],
                 transfer_8to16sub(dct_codes[4],  
302                                  cur->u + 8*j*edged_width/2 + 8*i,                                  cur->u + 8*j*edged_width/2 + 8*i,
303                                  refv->u + 8*j*edged_width/2 + 8*i, edged_width/2);                                                          interpolate8x8_switch2(f_refv->u, b_ref->u, 8 * i, 8 * j,
304                                                                                                            b_dx, b_dy, edged_width / 2, 0),
305    
306                                                            edged_width / 2);
307    
308                  interpolate8x8_switch(refv->v, ref->v, 8*i, 8*j, dx, dy, edged_width/2, rounding);                  transfer_8to16sub(&dct_codes[5 * 64],
                 transfer_8to16sub(dct_codes[5],  
309                                  cur->v + 8*j*edged_width/2 + 8*i,                                  cur->v + 8*j*edged_width/2 + 8*i,
310                                  refv->v + 8*j*edged_width/2 + 8*i, edged_width/2);                                                          interpolate8x8_switch2(f_refv->u, b_ref->v, 8 * i, 8 * j,
311                                                                                                            b_dx, b_dy, edged_width / 2, 0),
312    
313                                                            edged_width / 2);
314    
315                    break;
316    
317    
318            case MODE_INTERPOLATE:          /* _could_ use DIRECT, but would be overkill (no 4MV there) */
319            case MODE_DIRECT_NO4V:
320    
321                    dx = mb->mvs[0].x;
322                    dy = mb->mvs[0].y;
323    
324                    b_dx = mb->b_mvs[0].x;
325                    b_dy = mb->b_mvs[0].y;
326    
327                    for (k = 0; k < 4; k++) {
328                            transfer_8to16sub2(&dct_codes[k * 64],
329                                                            cur->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
330                                                            get_ref(f_ref->y, f_refh->y, f_refv->y,
331                                                                            f_refhv->y, 2*i + (k&1), 2*j + (k>>1), 8, dx, dy,
332                                                                            edged_width),
333                                                            get_ref(b_ref->y, b_refh->y, b_refv->y,
334                                                                            b_refhv->y, 2*i + (k&1), 2 * j+(k>>1), 8, b_dx, b_dy,
335                                                                            edged_width),
336                                                            edged_width);
337                    }
338    
339                    dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;
340                    dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;
341    
342                    b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;
343                    b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;
344    
345                    transfer_8to16sub2(&dct_codes[4 * 64],
346                                                            cur->u + (y * 8) * edged_width / 2 + (x * 8),
347                                                            interpolate8x8_switch2(f_refv->u, b_ref->u, 8 * i, 8 * j,
348                                                                                                            b_dx, b_dy, edged_width / 2, 0),
349                                                            interpolate8x8_switch2(f_refv->u + 8, f_ref->u, 8 * i, 8 * j,
350                                                                                                            dx, dy, edged_width / 2, 0),
351                                                            edged_width / 2);
352    
353                    transfer_8to16sub2(&dct_codes[5 * 64],
354                                                            cur->v + (y * 8) * edged_width / 2 + (x * 8),
355                                                            interpolate8x8_switch2(f_refv->u, b_ref->v, 8 * i, 8 * j,
356                                                                                                            b_dx, b_dy, edged_width / 2, 0),
357                                                            interpolate8x8_switch2(f_refv->u + 8, f_ref->v, 8 * i, 8 * j,
358                                                                                                            dx, dy, edged_width / 2, 0),
359                                                            edged_width / 2);
360    
361                    break;
362    
363            case MODE_DIRECT:
364    
365                    for (k=0;k<4;k++)
366                    {
367                            dx = mb->mvs[k].x;
368                            dy = mb->mvs[k].y;
369    
370                            b_dx = mb->b_mvs[k].x;
371                            b_dy = mb->b_mvs[k].y;
372    
373    //              fprintf(stderr,"Direct Vector %d -- %d:%d    %d:%d\n",k,dx,dy,b_dx,b_dy);
374    
375                            transfer_8to16sub2(&dct_codes[k * 64],
376                                                            cur->y + (i*16 + (k&1)*8) + (j*16 + (k>>1)*8 ) * edged_width,
377                                                            get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
378                                                                            2*i + (k&1), 2*j + (k>>1), 8, dx, dy,
379                                                                            edged_width),
380                                                            get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
381                                                                            2*i + (k&1), 2*j + (k>>1), 8, b_dx, b_dy,
382                                                                            edged_width),
383                                                            edged_width);
384                    }
385    
386                    sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x;
387                    dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
388    
389                    sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y;
390                    dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
391    
392    
393                    sum = mb->b_mvs[0].x + mb->b_mvs[1].x + mb->b_mvs[2].x + mb->b_mvs[3].x;
394                    b_dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
395    
396                    sum = mb->b_mvs[0].y + mb->b_mvs[1].y + mb->b_mvs[2].y + mb->b_mvs[3].y;
397                    b_dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
398    
399    /*              // for QPel don't forget to always do
400    
401                    if (quarterpel)
402                            sum /= 2;
403    */
404                    transfer_8to16sub2(&dct_codes[4 * 64],
405                                                            cur->u + (y * 8) * edged_width / 2 + (x * 8),
406                                                            interpolate8x8_switch2(f_refv->u, b_ref->u, 8 * i, 8 * j,
407                                                                                                            b_dx, b_dy, edged_width / 2, 0),
408                                                            interpolate8x8_switch2(f_refv->u + 8, f_ref->u, 8 * i, 8 * j, dx, dy,
409                                                              edged_width / 2, 0),
410                                                            edged_width / 2);
411    
412                    transfer_8to16sub2(&dct_codes[5 * 64],
413                                                            cur->v + (y * 8) * edged_width / 2 + (x * 8),
414                                                            interpolate8x8_switch2(f_refv->u, b_ref->v, 8 * i, 8 * j,
415                                                                                                            b_dx, b_dy, edged_width / 2, 0),
416                                                            interpolate8x8_switch2(f_refv->u + 8, f_ref->v, 8 * i, 8 * j,
417                                                                                                            dx, dy, edged_width / 2, 0),
418                                                            edged_width / 2);
419    
420    
421                    break;
422          }          }
423  }  }

Legend:
Removed from v.3  
changed lines
  Added in v.581

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