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

Legend:
Removed from v.78  
changed lines
  Added in v.619

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