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

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

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