[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 702, Tue Dec 10 11:13:50 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/reduced.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(  
17                                  int16_t * const dct_codes,  static __inline void
18    compensate16x16_interpolate(int16_t * const dct_codes,
19                                  uint8_t * const cur,                                  uint8_t * const cur,
20                                  const uint8_t * const ref,                                  const uint8_t * const ref,
21                                  const uint8_t * const refh,                                  const uint8_t * const refh,
22                                  const uint8_t * const refv,                                                      uint8_t * const refv,
23                                  const uint8_t * const refhv,                                  const uint8_t * const refhv,
24                                  const uint32_t x, const uint32_t y,                                                      uint32_t x,
25                                  const int32_t dx,  const int dy,                                                      uint32_t y,
26                                  const uint32_t stride)                                                      const int32_t dx,
27                                                        const int32_t dy,
28                                                        const uint32_t stride,
29                                                        const uint32_t quarterpel,
30                                                            const int reduced_resolution,
31                                                            const uint32_t rounding)
32  {  {
         int32_t ddx,ddy;  
33    
34          switch ( ((dx&1)<<1) + (dy&1) )   // ((dx%2)?2:0)+((dy%2)?1:0)          if (reduced_resolution)
35      {      {
36      case 0 :                  const uint8_t * reference;
37                  ddx = dx/2;                  x*=2; y*=2;
                 ddy = dy/2;  
                 transfer_8to16sub(dct_codes, cur + y*stride + x,  
                                 ref + (y+ddy)*stride + x+ddx, stride);  
                 break;  
38    
39      case 1 :                  reference = get_ref(ref, refh, refv, refhv, x, y, 1, dx, dy, stride);
40                  ddx = dx/2;  
41                  ddy = (dy-1)/2;                  filter_18x18_to_8x8(dct_codes, cur+y*stride + x, stride);
42                  transfer_8to16sub(dct_codes, cur + y*stride + x,                  filter_diff_18x18_to_8x8(dct_codes, reference, stride);
43                                  refv + (y+ddy)*stride + x+ddx, stride);  
44                  break;                  filter_18x18_to_8x8(dct_codes+64, cur+y*stride + x + 16, stride);
45                    filter_diff_18x18_to_8x8(dct_codes+64, reference + 16, stride);
46    
47                    filter_18x18_to_8x8(dct_codes+128, cur+(y+16)*stride + x, stride);
48                    filter_diff_18x18_to_8x8(dct_codes+128, reference + 16*stride, stride);
49    
50                    filter_18x18_to_8x8(dct_codes+192, cur+(y+16)*stride + x + 16, stride);
51                    filter_diff_18x18_to_8x8(dct_codes+192, reference + 16*stride + 16, stride);
52    
53                    transfer32x32_copy(cur + y*stride + x, reference, stride);
54    
55            }else{
56                    if(quarterpel) {
57                            interpolate16x16_quarterpel((uint8_t *) refv, (uint8_t *) ref, (uint8_t *) refh,
58                                    (uint8_t *) refh + 64, (uint8_t *) refhv, x, y, dx, dy, stride, rounding);
59    
     case 2 :  
                 ddx = (dx-1)/2;  
                 ddy = dy/2;  
60                  transfer_8to16sub(dct_codes, cur + y*stride + x,                  transfer_8to16sub(dct_codes, cur + y*stride + x,
61                                  refh + (y+ddy)*stride + x+ddx, stride);                                                            refv + y*stride + x, stride);
62                  break;                          transfer_8to16sub(dct_codes+64, cur + y*stride + x + 8,
63                                                              refv + y*stride + x + 8, stride);
64                            transfer_8to16sub(dct_codes+128, cur + y*stride + x + 8*stride,
65                                                              refv + y*stride + x + 8*stride, stride);
66                            transfer_8to16sub(dct_codes+192, cur + y*stride + x + 8*stride + 8,
67                                                              refv + y*stride + x + 8*stride+8, stride);
68    
69                    }
70                    else
71                    {
72                            const uint8_t * reference = get_ref(ref, refh, refv, refhv, x, y, 1, dx, dy, stride);
73    
         default :       // case 3:  
                 ddx = (dx-1)/2;  
                 ddy = (dy-1)/2;  
74                  transfer_8to16sub(dct_codes, cur + y*stride + x,                  transfer_8to16sub(dct_codes, cur + y*stride + x,
75                                  refhv + (y+ddy)*stride + x+ddx, stride);                                                                    reference, stride);
76                  break;                          transfer_8to16sub(dct_codes+64, cur + y * stride + x + 8,
77                                                                      reference + 8, stride);
78                            transfer_8to16sub(dct_codes+128, cur + y * stride + x + 8*stride,
79                                                                      reference + 8*stride, stride);
80                            transfer_8to16sub(dct_codes+192, cur + y * stride + x + 8*stride+8,
81                                                                      reference + 8*stride + 8, stride);
82      }      }
83  }  }
84    }
85    
86    static __inline void
87    compensate8x8_interpolate(int16_t * const dct_codes,
88                                                      uint8_t * const cur,
89                                                      const uint8_t * const ref,
90                                                      const uint8_t * const refh,
91                                                      const uint8_t * const refv,
92                                                      const uint8_t * const refhv,
93                                                      uint32_t x,
94                                                      uint32_t y,
95                                                      const int32_t dx,
96                                                      const int32_t dy,
97                                                      const uint32_t stride,
98                                                      const uint32_t quarterpel,
99                                                      const int reduced_resolution,
100                                                      const uint32_t rounding)
101    {
102            if (reduced_resolution)
103            {
104                    const uint8_t * reference;
105                    x*=2; y*=2;
106    
107                    reference = get_ref(ref, refh, refv, refhv, x, y, 1, dx, dy, stride);
108    
109                    filter_18x18_to_8x8(dct_codes, cur+y*stride + x, stride);
110                    filter_diff_18x18_to_8x8(dct_codes, reference, stride);
111    
112  void MBMotionCompensation(                  transfer16x16_copy(cur + y*stride + x, reference, stride);
113          MACROBLOCK * const mb,  
114            } else {
115    
116                    if(quarterpel) {
117                            interpolate8x8_quarterpel((uint8_t *) refv, (uint8_t *) ref, (uint8_t *) refh,
118                                    (uint8_t *) refh + 64, (uint8_t *) refhv, x, y, dx, dy, stride, rounding);
119    
120                            transfer_8to16sub(dct_codes, cur + y*stride + x,
121                                                              refv + y*stride + x, stride);
122                    }
123                    else
124                    {
125                            const uint8_t * reference = get_ref(ref, refh, refv, refhv, x, y, 1, dx, dy, stride);
126    
127                            transfer_8to16sub(dct_codes, cur + y * stride + x,
128                                                                      reference, stride);
129                    }
130            }
131    }
132    
133    void
134    MBMotionCompensation(MACROBLOCK * const mb,
135          const uint32_t i,          const uint32_t i,
136          const uint32_t j,          const uint32_t j,
137          const IMAGE * const ref,          const IMAGE * const ref,
# Line 66  Line 143 
143          const uint32_t width,          const uint32_t width,
144          const uint32_t height,          const uint32_t height,
145          const uint32_t edged_width,          const uint32_t edged_width,
146                                             const uint32_t quarterpel,
147                                             const int reduced_resolution,
148          const uint32_t rounding)          const uint32_t rounding)
149  {  {
         static const uint32_t roundtab[16] =  
                 { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 };  
150    
151            if (mb->mode == MODE_NOT_CODED || mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) {
152    
153                    int32_t dx = (quarterpel ? mb->qmvs[0].x : mb->mvs[0].x);
154                    int32_t dy = (quarterpel ? mb->qmvs[0].y : mb->mvs[0].y);
155    
156                    if ( (mb->mode == MODE_NOT_CODED) && (dx==0) && (dy==0) ) {     /* quick copy */
157                            transfer16x16_copy(cur->y + 16 * (i + j * edged_width),
158                                                               ref->y + 16 * (i + j * edged_width),
159                                                               edged_width);
160    
161                            transfer8x8_copy(cur->u + 8 * (i + j * edged_width/2),
162                                                                    ref->u + 8 * (i + j * edged_width/2),
163                                                                    edged_width / 2);
164                            transfer8x8_copy(cur->v + 8 * (i + j * edged_width/2),
165                                                                    ref->v + 8 * (i + j * edged_width/2),
166                                                                    edged_width / 2);
167                            return;
168                    }
169            /* quick MODE_NOT_CODED for GMC with MV!=(0,0) is still needed */
170    
171          if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q)                  if (reduced_resolution)
172          {          {
173                  int32_t dx = mb->mvs[0].x;                          dx = RRV_MV_SCALEUP(dx);
174                  int32_t dy = mb->mvs[0].y;                          dy = RRV_MV_SCALEUP(dy);
175                    }
176    
177                  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,
178                                        16*i,     16*j,     dx, dy, edged_width);                                                    refv->y, refhv->y, 16 * i, 16 * j, dx, dy,
179                  compensate8x8_halfpel(&dct_codes[1*64], cur->y, ref->y, refh->y, refv->y, refhv->y,                                                    edged_width, quarterpel, reduced_resolution, 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);  
   
                 dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;  
                 dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;  
   
                 /* 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);            */  
180    
181                  /* uv-block-based compensation */                  if (quarterpel)
182                  interpolate8x8_switch(refv->u, ref->u, 8*i, 8*j, dx, dy, edged_width/2, rounding);                  {
183                            dx /= 2;
184                            dy /= 2;
185                    }
186    
187                    dx = (dx >> 1) + roundtab_79[dx & 0x3];
188                    dy = (dy >> 1) + roundtab_79[dy & 0x3];
189    
190                    /* uv-block-based compensation
191                            XXX: rrv doesnt work with 16x16 block-based intepolation.
192                            we need to use 18x18-block interpolation */
193                    if (reduced_resolution)
194                    {
195                            const stride = edged_width/2;
196                            uint8_t * current, * reference;
197    
198                            current = cur->u + 16*j*stride + 16*i;
199                            reference = refv->u + 16*j*stride + 16*i;
200                            interpolate16x16_switch(refv->u, ref->u, 16*i, 16*j, dx, dy, stride, rounding);
201                            filter_18x18_to_8x8(dct_codes + 4*64, current, stride);
202                            filter_diff_18x18_to_8x8(dct_codes + 4*64, reference, stride);
203                            transfer16x16_copy(current, reference, stride);
204    
205                            current = cur->v + 16*j*stride + 16*i;
206                            reference = refv->v + 16*j*stride + 16*i;
207                            interpolate16x16_switch(refv->v, ref->v, 16*i, 16*j, dx, dy, stride, rounding);
208                            filter_18x18_to_8x8(dct_codes + 5*64, current, stride);
209                            filter_diff_18x18_to_8x8(dct_codes + 5*64, reference, stride);
210                            transfer16x16_copy(current, reference, stride);
211                    }else{
212                  transfer_8to16sub(&dct_codes[4*64],                  transfer_8to16sub(&dct_codes[4*64],
213                                    cur->u + 8*j*edged_width/2 + 8*i,                                    cur->u + 8*j*edged_width/2 + 8*i,
214                                    refv->u + 8*j*edged_width/2 + 8*i, edged_width/2);                                                                  interpolate8x8_switch2(refv->u, ref->u, 8 * i, 8 * j,
215                                                                                                                    dx, dy, edged_width / 2, rounding),
216                                                                    edged_width / 2);
217    
                 interpolate8x8_switch(refv->v, ref->v, 8*i, 8*j, dx, dy, edged_width/2, rounding);  
218                  transfer_8to16sub(&dct_codes[5*64],                  transfer_8to16sub(&dct_codes[5*64],
219                                    cur->v + 8*j*edged_width/2 + 8*i,                                    cur->v + 8*j*edged_width/2 + 8*i,
220                                    refv->v + 8*j*edged_width/2 + 8*i, edged_width/2);                                                                  interpolate8x8_switch2(refv->u, ref->v, 8 * i, 8 * j,
221                                                                                                                    dx, dy, edged_width / 2, rounding),
222                                                                    edged_width / 2);
223                    }
224    
225            } else {                                        // mode == MODE_INTER4V
226                    int i;
227                    int32_t sum, dx, dy;
228                    VECTOR mvs[4];
229    
230                    if(quarterpel)
231                            for (i = 0; i < 4; i++) mvs[i] = mb->qmvs[i];
232                    else
233                            for (i = 0; i < 4; i++) mvs[i] = mb->mvs[i];
234    
235                    if (reduced_resolution)
236                    {
237                            for (i = 0; i < 4; i++)
238                            {
239                                    mvs[i].x = RRV_MV_SCALEUP(mvs[i].x);
240                                    mvs[i].y = RRV_MV_SCALEUP(mvs[i].y);
241                            }
242          }          }
243          else    // mode == MODE_INTER4V  
244                    compensate8x8_interpolate(&dct_codes[0 * 64], cur->y, ref->y, refh->y,
245                                                      refv->y, refhv->y, 16 * i, 16 * j, mvs[0].x,
246                                                      mvs[0].y, edged_width, quarterpel, reduced_resolution, rounding);
247                    compensate8x8_interpolate(&dct_codes[1 * 64], cur->y, ref->y, refh->y,
248                                                              refv->y, refhv->y, 16 * i + 8, 16 * j,
249                                                              mvs[1].x, mvs[1].y, edged_width, quarterpel, reduced_resolution, rounding);
250                    compensate8x8_interpolate(&dct_codes[2 * 64], cur->y, ref->y, refh->y,
251                                                              refv->y, refhv->y, 16 * i, 16 * j + 8,
252                                                              mvs[2].x, mvs[2].y, edged_width, quarterpel, reduced_resolution, rounding);
253                    compensate8x8_interpolate(&dct_codes[3 * 64], cur->y, ref->y, refh->y,
254                                                              refv->y, refhv->y, 16 * i + 8, 16 * j + 8,
255                                                              mvs[3].x, mvs[3].y, edged_width, quarterpel, reduced_resolution, rounding);
256    
257                    if(quarterpel)
258                            sum = (mvs[0].x / 2) + (mvs[1].x / 2) + (mvs[2].x / 2) + (mvs[3].x / 2);
259                    else
260                            sum = mvs[0].x + mvs[1].x + mvs[2].x + mvs[3].x;
261    
262                    dx = (sum >> 3) + roundtab_76[sum & 0xf];
263    
264                    if(quarterpel)
265                            sum = (mvs[0].y / 2) + (mvs[1].y / 2) + (mvs[2].y / 2) + (mvs[3].y / 2);
266                    else
267                            sum = mvs[0].y + mvs[1].y + mvs[2].y + mvs[3].y;
268    
269                    dy = (sum >> 3) + roundtab_76[sum & 0xf];
270    
271    
272                    /* uv-block-based compensation
273                            XXX: rrv doesnt work with 16x16 block-based intepolation.
274                            we need to use 18x18-block interpolation */
275                    if (reduced_resolution)
276          {          {
277                  int32_t sum, dx, dy;                          const stride = edged_width/2;
278                            uint8_t * current, * reference;
279    
280                  compensate8x8_halfpel(&dct_codes[0*64], cur->y, ref->y, refh->y, refv->y, refhv->y,                          current = cur->u + 16*j*stride + 16*i;
281                                        16*i,     16*j,     mb->mvs[0].x, mb->mvs[0].y, edged_width);                          reference = refv->u + 16*j*stride + 16*i;
282                  compensate8x8_halfpel(&dct_codes[1*64], cur->y, ref->y, refh->y, refv->y, refhv->y,                          interpolate16x16_switch(refv->u, ref->u, 16*i, 16*j, dx, dy, stride, rounding);
283                                        16*i + 8, 16*j,     mb->mvs[1].x, mb->mvs[1].y, edged_width);                          filter_18x18_to_8x8(dct_codes + 4*64, current, stride);
284                  compensate8x8_halfpel(&dct_codes[2*64], cur->y, ref->y, refh->y, refv->y, refhv->y,                          filter_diff_18x18_to_8x8(dct_codes + 4*64, reference, stride);
285                                        16*i,     16*j + 8, mb->mvs[2].x, mb->mvs[2].y, edged_width);                          transfer16x16_copy(current, reference, stride);
286                  compensate8x8_halfpel(&dct_codes[3*64], cur->y, ref->y, refh->y, refv->y, refhv->y,  
287                                        16*i + 8, 16*j + 8, mb->mvs[3].x, mb->mvs[3].y, edged_width);                          current = cur->v + 16*j*stride + 16*i;
288                            reference = refv->v + 16*j*stride + 16*i;
289                            interpolate16x16_switch(refv->v, ref->v, 16*i, 16*j, dx, dy, stride, rounding);
290                            filter_18x18_to_8x8(dct_codes + 5*64, current, stride);
291                            filter_diff_18x18_to_8x8(dct_codes + 5*64, reference, stride);
292                            transfer16x16_copy(current, reference, stride);
293    
294                  sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x;                  }else{
295                  dx = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);                          transfer_8to16sub(&dct_codes[4 * 64],
296                                                                    cur->u + 8 * j * edged_width / 2 + 8 * i,
297                                                                    interpolate8x8_switch2(refv->u, ref->u, 8 * i, 8 * j,
298                                                                                                                    dx, dy, edged_width / 2, rounding),
299                                                                    edged_width / 2);
300    
301                  sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y;                          transfer_8to16sub(&dct_codes[5 * 64],
302                  dy = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);                                                                  cur->v + 8 * j * edged_width / 2 + 8 * i,
303                                                                    interpolate8x8_switch2(refv->u, ref->v, 8 * i, 8 * j,
304                                                                                                                    dx, dy, edged_width / 2, rounding),
305                                                                    edged_width / 2);
306                    }
307            }
308    }
309    
310    
311    void
312    MBMotionCompensationBVOP(MBParam * pParam,
313                                                     MACROBLOCK * const mb,
314                                                     const uint32_t i,
315                                                     const uint32_t j,
316                                                     IMAGE * const cur,
317                                                     const IMAGE * const f_ref,
318                                                     const IMAGE * const f_refh,
319                                                     const IMAGE * const f_refv,
320                                                     const IMAGE * const f_refhv,
321                                                     const IMAGE * const b_ref,
322                                                     const IMAGE * const b_refh,
323                                                     const IMAGE * const b_refv,
324                                                     const IMAGE * const b_refhv,
325                                                     int16_t * dct_codes)
326    {
327            static const uint32_t roundtab[16] =
328                    { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 };
329    
330            const int32_t edged_width = pParam->edged_width;
331            int32_t dx, dy;
332            int32_t b_dx, b_dy;
333            int k,sum;
334            int x = i;
335            int y = j;
336            uint32_t quarterpel = pParam->m_quarterpel;
337    
338            switch (mb->mode) {
339            case MODE_FORWARD:
340    
341                    if (quarterpel) {
342                            dx = mb->qmvs[0].x;
343                            dy = mb->qmvs[0].y;
344                    } else {
345                            dx = mb->mvs[0].x;
346                            dy = mb->mvs[0].y;
347                    }
348    
349                    compensate16x16_interpolate(&dct_codes[0 * 64], cur->y, f_ref->y, f_refh->y,
350                                                      f_refv->y, f_refhv->y, 16 * i, 16 * j, dx,
351                                                      dy, edged_width, quarterpel, 0 /*reduced_resolution*/, 0);
352    
353                    if (quarterpel) {
354                            dx /= 2;
355                            dy /= 2;
356                    }
357    
358                    dx = (dx >> 1) + roundtab_79[dx & 0x3];
359                    dy = (dy >> 1) + roundtab_79[dy & 0x3];
360    
361                    /* uv-block-based compensation */
362                    transfer_8to16sub(&dct_codes[4 * 64],
363                                                            cur->u + 8 * j * edged_width / 2 + 8 * i,
364                                                            interpolate8x8_switch2(f_refv->u, f_ref->u, 8 * i, 8 * j,
365                                                                                                            dx, dy, edged_width / 2, 0),
366    
367                                                      edged_width / 2);
368    
369                    transfer_8to16sub(&dct_codes[5 * 64],
370                                                            cur->v + 8 * j * edged_width / 2 + 8 * i,
371                                                            interpolate8x8_switch2(f_refv->u, f_ref->v, 8 * i, 8 * j,
372                                                                                                            dx, dy, edged_width / 2, 0),
373    
374                                                      edged_width / 2);
375    
376                    break;
377    
378            case MODE_BACKWARD:
379                    if (quarterpel) {
380                            b_dx = mb->b_qmvs[0].x;
381                            b_dy = mb->b_qmvs[0].y;
382                    } else {
383                            b_dx = mb->b_mvs[0].x;
384                            b_dy = mb->b_mvs[0].y;
385                    }
386    
387                    compensate16x16_interpolate(&dct_codes[0 * 64], cur->y, b_ref->y, b_refh->y,
388                                                      b_refv->y, b_refhv->y, 16 * i, 16 * j, b_dx,
389                                                      b_dy, edged_width, quarterpel, 0 /*reduced_resolution*/, 0);
390    
391                    if (quarterpel) {
392                            b_dx /= 2;
393                            b_dy /= 2;
394                    }
395    
396                    b_dx = (b_dx >> 1) + roundtab_79[b_dx & 0x3];
397                    b_dy = (b_dy >> 1) + roundtab_79[b_dy & 0x3];
398    
                 /* 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);            */  
399    
400                  /* uv-block-based compensation */                  /* uv-block-based compensation */
                 interpolate8x8_switch(refv->u, ref->u, 8*i, 8*j, dx, dy, edged_width/2, rounding);  
401                  transfer_8to16sub(&dct_codes[4*64],                  transfer_8to16sub(&dct_codes[4*64],
402                                    cur->u + 8*j*edged_width/2 + 8*i,                                    cur->u + 8*j*edged_width/2 + 8*i,
403                                    refv->u + 8*j*edged_width/2 + 8*i, edged_width/2);                                                          interpolate8x8_switch2(f_refv->u, b_ref->u, 8 * i, 8 * j,
404                                                                                                            b_dx, b_dy, edged_width / 2, 0),
405    
406                                                            edged_width / 2);
407    
                 interpolate8x8_switch(refv->v, ref->v, 8*i, 8*j, dx, dy, edged_width/2, rounding);  
408                  transfer_8to16sub(&dct_codes[5*64],                  transfer_8to16sub(&dct_codes[5*64],
409                                    cur->v + 8*j*edged_width/2 + 8*i,                                    cur->v + 8*j*edged_width/2 + 8*i,
410                                    refv->v + 8*j*edged_width/2 + 8*i, edged_width/2);                                                          interpolate8x8_switch2(f_refv->u, b_ref->v, 8 * i, 8 * j,
411                                                                                                            b_dx, b_dy, edged_width / 2, 0),
412    
413                                                            edged_width / 2);
414    
415                    break;
416    
417            case MODE_INTERPOLATE:          /* _could_ use DIRECT, but would be overkill (no 4MV there) */
418            case MODE_DIRECT_NO4V:
419    
420                    if (quarterpel) {
421                            dx = mb->qmvs[0].x;
422                            dy = mb->qmvs[0].y;
423                            b_dx = mb->b_qmvs[0].x;
424                            b_dy = mb->b_qmvs[0].y;
425    
426                            interpolate16x16_quarterpel((uint8_t *) f_refv->y, (uint8_t *) f_ref->y, (uint8_t *) f_refh->y,
427                                    (uint8_t *) f_refh->y + 64, (uint8_t *) f_refhv->y, 16*i, 16*j, dx, dy, edged_width, 0);
428                            interpolate16x16_quarterpel((uint8_t *) b_refv->y, (uint8_t *) b_ref->y, (uint8_t *) b_refh->y,
429                                    (uint8_t *) b_refh->y + 64, (uint8_t *) b_refhv->y, 16*i, 16*j, b_dx, b_dy, edged_width, 0);
430    
431                            for (k = 0; k < 4; k++) {
432                                    transfer_8to16sub2(&dct_codes[k * 64],
433                                                                    cur->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
434                                                                    f_refv->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
435                                                                    b_refv->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
436                                                                    edged_width);
437                            }
438                            b_dx /= 2;
439                            b_dy /= 2;
440                            dx /= 2;
441                            dy /= 2;
442    
443                    } else {
444                            dx = mb->mvs[0].x;
445                            dy = mb->mvs[0].y;
446                            b_dx = mb->b_mvs[0].x;
447                            b_dy = mb->b_mvs[0].y;
448    
449                            for (k = 0; k < 4; k++) {
450                                    transfer_8to16sub2(&dct_codes[k * 64],
451                                                                    cur->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
452                                                                    get_ref(f_ref->y, f_refh->y, f_refv->y,
453                                                                                    f_refhv->y, 2*i + (k&1), 2*j + (k>>1), 8, dx, dy,
454                                                                                    edged_width),
455                                                                    get_ref(b_ref->y, b_refh->y, b_refv->y,
456                                                                                    b_refhv->y, 2*i + (k&1), 2 * j+(k>>1), 8, b_dx, b_dy,
457                                                                                    edged_width),
458                                                                    edged_width);
459                            }
460    
461                    }
462    
463    
464                    dx = (dx >> 1) + roundtab_79[dx & 0x3];
465                    dy = (dy >> 1) + roundtab_79[dy & 0x3];
466    
467                    b_dx = (b_dx >> 1) + roundtab_79[b_dx & 0x3];
468                    b_dy = (b_dy >> 1) + roundtab_79[b_dy & 0x3];
469    
470                    transfer_8to16sub2(&dct_codes[4 * 64],
471                                                            cur->u + (y * 8) * edged_width / 2 + (x * 8),
472                                                            interpolate8x8_switch2(f_refv->u, b_ref->u, 8 * i, 8 * j,
473                                                                                                            b_dx, b_dy, edged_width / 2, 0),
474                                                            interpolate8x8_switch2(f_refv->u + 8, f_ref->u, 8 * i, 8 * j,
475                                                                                                            dx, dy, edged_width / 2, 0),
476                                                            edged_width / 2);
477    
478                    transfer_8to16sub2(&dct_codes[5 * 64],
479                                                            cur->v + (y * 8) * edged_width / 2 + (x * 8),
480                                                            interpolate8x8_switch2(f_refv->u, b_ref->v, 8 * i, 8 * j,
481                                                                                                            b_dx, b_dy, edged_width / 2, 0),
482                                                            interpolate8x8_switch2(f_refv->u + 8, f_ref->v, 8 * i, 8 * j,
483                                                                                                            dx, dy, edged_width / 2, 0),
484                                                            edged_width / 2);
485    
486                    break;
487    
488            case MODE_DIRECT:
489                    if (quarterpel) {
490                            for (k=0;k<4;k++) {
491    
492                                    dx = mb->qmvs[k].x;
493                                    dy = mb->qmvs[k].y;
494                                    b_dx = mb->b_qmvs[k].x;
495                                    b_dy = mb->b_qmvs[k].y;
496    
497                                    interpolate8x8_quarterpel((uint8_t *) f_refv->y,
498                                            (uint8_t *) f_ref->y,
499                                            (uint8_t *) f_refh->y,
500                                            (uint8_t *) f_refh->y + 64,
501                                            (uint8_t *) f_refhv->y,
502                                            16*i + (k&1)*8, 16*j + (k>>1)*8, dx, dy, edged_width, 0);
503                                    interpolate8x8_quarterpel((uint8_t *) b_refv->y,
504                                            (uint8_t *) b_ref->y,
505                                            (uint8_t *) b_refh->y,
506                                            (uint8_t *) b_refh->y + 64,
507                                            (uint8_t *) b_refhv->y,
508                                            16*i + (k&1)*8, 16*j + (k>>1)*8, b_dx, b_dy, edged_width, 0);
509    
510    
511                                    transfer_8to16sub2(&dct_codes[k * 64],
512                                                                    cur->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
513                                                                    f_refv->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
514                                                                    b_refv->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
515                                                                    edged_width);
516                            }
517                            sum = mb->qmvs[0].y/2 + mb->qmvs[1].y/2 + mb->qmvs[2].y/2 + mb->qmvs[3].y/2;
518                            dy = (sum >> 3) + roundtab_76[sum & 0xf];
519                            sum = mb->qmvs[0].x/2 + mb->qmvs[1].x/2 + mb->qmvs[2].x/2 + mb->qmvs[3].x/2;
520                            dx = (sum >> 3) + roundtab_76[sum & 0xf];
521    
522                            sum = mb->b_qmvs[0].y/2 + mb->b_qmvs[1].y/2 + mb->b_qmvs[2].y/2 + mb->b_qmvs[3].y/2;
523                            b_dy = (sum >> 3) + roundtab_76[sum & 0xf];
524                            sum = mb->b_qmvs[0].x/2 + mb->b_qmvs[1].x/2 + mb->b_qmvs[2].x/2 + mb->b_qmvs[3].x/2;
525                            b_dx = (sum >> 3) + roundtab_76[sum & 0xf];
526    
527                    } else {
528                            for (k=0;k<4;k++) {
529                                    dx = mb->mvs[k].x;
530                                    dy = mb->mvs[k].y;
531    
532                                    b_dx = mb->b_mvs[k].x;
533                                    b_dy = mb->b_mvs[k].y;
534    
535                                    transfer_8to16sub2(&dct_codes[k * 64],
536                                                                    cur->y + (i*16 + (k&1)*8) + (j*16 + (k>>1)*8 ) * edged_width,
537                                                                    get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
538                                                                                    2*i + (k&1), 2*j + (k>>1), 8, dx, dy,
539                                                                                    edged_width),
540                                                                    get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
541                                                                                    2*i + (k&1), 2*j + (k>>1), 8, b_dx, b_dy,
542                                                                                    edged_width),
543                                                                    edged_width);
544                            }
545    
546                            sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x;
547                            dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
548    
549                            sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y;
550                            dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
551    
552                            sum = mb->b_mvs[0].x + mb->b_mvs[1].x + mb->b_mvs[2].x + mb->b_mvs[3].x;
553                            b_dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
554    
555                            sum = mb->b_mvs[0].y + mb->b_mvs[1].y + mb->b_mvs[2].y + mb->b_mvs[3].y;
556                            b_dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
557    
558                    }
559                    transfer_8to16sub2(&dct_codes[4 * 64],
560                                                            cur->u + (y * 8) * edged_width / 2 + (x * 8),
561                                                            interpolate8x8_switch2(f_refv->u, b_ref->u, 8 * i, 8 * j,
562                                                                                                            b_dx, b_dy, edged_width / 2, 0),
563                                                            interpolate8x8_switch2(f_refv->u + 8, f_ref->u, 8 * i, 8 * j, dx, dy,
564                                                              edged_width / 2, 0),
565                                                            edged_width / 2);
566    
567                    transfer_8to16sub2(&dct_codes[5 * 64],
568                                                            cur->v + (y * 8) * edged_width / 2 + (x * 8),
569                                                            interpolate8x8_switch2(f_refv->u, b_ref->v, 8 * i, 8 * j,
570                                                                                                            b_dx, b_dy, edged_width / 2, 0),
571                                                            interpolate8x8_switch2(f_refv->u + 8, f_ref->v, 8 * i, 8 * j,
572                                                                                                            dx, dy, edged_width / 2, 0),
573                                                            edged_width / 2);
574    
575    
576                    break;
577          }          }
578  }  }

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

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