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

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

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

revision 78, Thu Mar 28 20:57:25 2002 UTC revision 1565, Sun Dec 5 13:01:27 2004 UTC
# Line 1  Line 1 
1    /*****************************************************************************
2     *
3     *  XVID MPEG-4 VIDEO CODEC
4     *  - Motion Compensation related code  -
5     *
6     *  Copyright(C) 2002 Peter Ross <pross@xvid.org>
7     *               2003 Christoph Lampert <gruel@web.de>
8     *
9     *  This program is free software ; you can redistribute it and/or modify
10     *  it under the terms of the GNU General Public License as published by
11     *  the Free Software Foundation ; either version 2 of the License, or
12     *  (at your option) any later version.
13     *
14     *  This program is distributed in the hope that it will be useful,
15     *  but WITHOUT ANY WARRANTY ; without even the implied warranty of
16     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17     *  GNU General Public License for more details.
18     *
19     *  You should have received a copy of the GNU General Public License
20     *  along with this program ; if not, write to the Free Software
21     *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22     *
23     * $Id: motion_comp.c,v 1.23 2004-12-05 13:01:27 syskin Exp $
24     *
25     ****************************************************************************/
26    
27    #include <stdio.h>
28    
29  #include "../encoder.h"  #include "../encoder.h"
30  #include "../utils/mbfunctions.h"  #include "../utils/mbfunctions.h"
31  #include "../image/interpolate8x8.h"  #include "../image/interpolate8x8.h"
32    #include "../image/qpel.h"
33  #include "../utils/timer.h"  #include "../utils/timer.h"
34    #include "motion.h"
35    
36     /*
37     * getref: calculate reference image pointer
38     * the decision to use interpolation h/v/hv or the normal image is
39     * based on dx & dy.
40     */
41    
42  #define ABS(X) (((X)>0)?(X):-(X))  static __inline const uint8_t *
43  #define SIGN(X) (((X)>0)?1:-1)  get_ref(const uint8_t * const refn,
44                    const uint8_t * const refh,
45                    const uint8_t * const refv,
46                    const uint8_t * const refhv,
47                    const uint32_t x,
48                    const uint32_t y,
49                    const uint32_t block,
50                    const int32_t dx,
51                    const int32_t dy,
52                    const int32_t stride)
53    {
54            switch (((dx & 1) << 1) + (dy & 1)) {
55            case 0:
56                    return refn + (int) (((int)x * (int)block + dx / 2) + ((int)y * (int)block + dy / 2) * (int)stride);
57            case 1:
58                    return refv + (int) (((int)x * (int)block + dx / 2) + ((int)y * (int)block + (dy - 1) / 2) * (int)stride);
59            case 2:
60                    return refh + (int) (((int)x * (int)block + (dx - 1) / 2) + ((int)y * (int)block + dy / 2) * (int)stride);
61            default:
62                    return refhv + (int) (((int)x * (int)block + (dx - 1) / 2) + ((int)y * (int)block + (dy - 1) / 2) * (int)stride);
63            }
64    }
65    
66  static __inline void compensate8x8_halfpel(  static __inline void
67                                  int16_t * const dct_codes,  compensate16x16_interpolate(int16_t * const dct_codes,
68                                  uint8_t * const cur,                                  uint8_t * const cur,
69                                  const uint8_t * const ref,                                  const uint8_t * const ref,
70                                  const uint8_t * const refh,                                  const uint8_t * const refh,
71                                  const uint8_t * const refv,                                  const uint8_t * const refv,
72                                  const uint8_t * const refhv,                                  const uint8_t * const refhv,
73                                  const uint32_t x, const uint32_t y,                                                          uint8_t * const tmp,
74                                  const int32_t dx,  const int dy,                                                          uint32_t x,
75                                  const uint32_t stride)                                                          uint32_t y,
76                                                            const int32_t dx,
77                                                            const int32_t dy,
78                                                            const int32_t stride,
79                                                            const int quarterpel,
80                                                            const int32_t rounding)
81  {  {
82          int32_t ddx,ddy;          const uint8_t * ptr;
83    
         switch ( ((dx&1)<<1) + (dy&1) )   // ((dx%2)?2:0)+((dy%2)?1:0)  
     {  
     case 0 :  
                 ddx = dx/2;  
                 ddy = dy/2;  
                 transfer_8to16sub(dct_codes, cur + y*stride + x,  
                                 ref + (y+ddy)*stride + x+ddx, stride);  
                 break;  
84    
85      case 1 :          if(quarterpel) {
86                  ddx = dx/2;                  if ((dx&3) | (dy&3)) {
87                  ddy = (dy-1)/2;                          interpolate16x16_quarterpel(tmp - y * stride - x,
88                  transfer_8to16sub(dct_codes, cur + y*stride + x,                                                                                  (uint8_t *) ref, tmp + 32,
89                                  refv + (y+ddy)*stride + x+ddx, stride);                                                                                  tmp + 64, tmp + 96, x, y, dx, dy, stride, rounding);
90                  break;                          ptr = tmp;
91                    } else ptr =  ref + ((int)y + dy/4)*(int)stride + (int)x + dx/4; /* fullpixel position */
92    
93      case 2 :          } else ptr = get_ref(ref, refh, refv, refhv, x, y, 1, dx, dy, stride);
                 ddx = (dx-1)/2;  
                 ddy = dy/2;  
                 transfer_8to16sub(dct_codes, cur + y*stride + x,  
                                 refh + (y+ddy)*stride + x+ddx, stride);  
                 break;  
94    
         default :       // case 3:  
                 ddx = (dx-1)/2;  
                 ddy = (dy-1)/2;  
95                  transfer_8to16sub(dct_codes, cur + y*stride + x,                  transfer_8to16sub(dct_codes, cur + y*stride + x,
96                                  refhv + (y+ddy)*stride + x+ddx, stride);                                                  ptr, stride);
97                  break;          transfer_8to16sub(dct_codes+64, cur + y * stride + x + 8,
98                                                    ptr + 8, stride);
99            transfer_8to16sub(dct_codes+128, cur + y * stride + x + 8*stride,
100                                                    ptr + 8*stride, stride);
101            transfer_8to16sub(dct_codes+192, cur + y * stride + x + 8*stride+8,
102                                                    ptr + 8*stride + 8, stride);
103    
104      }      }
105    
106    static __inline void
107    compensate8x8_interpolate(      int16_t * const dct_codes,
108                                                            uint8_t * const cur,
109                                                            const uint8_t * const ref,
110                                                            const uint8_t * const refh,
111                                                            const uint8_t * const refv,
112                                                            const uint8_t * const refhv,
113                                                            uint8_t * const tmp,
114                                                            uint32_t x,
115                                                            uint32_t y,
116                                                            const int32_t dx,
117                                                            const int32_t dy,
118                                                            const int32_t stride,
119                                                            const int32_t quarterpel,
120                                                            const int32_t rounding)
121    {
122            const uint8_t * ptr;
123    
124            if(quarterpel) {
125                    if ((dx&3) | (dy&3)) {
126                            interpolate8x8_quarterpel(tmp - y*stride - x,
127                                                                            (uint8_t *) ref, tmp + 32,
128                                                                            tmp + 64, tmp + 96, x, y, dx, dy, stride, rounding);
129                            ptr = tmp;
130                    } else ptr = ref + ((int)y + dy/4)*(int)stride + (int)x + dx/4; /* fullpixel position */
131            } else ptr = get_ref(ref, refh, refv, refhv, x, y, 1, dx, dy, stride);
132    
133            transfer_8to16sub(dct_codes, cur + y * stride + x, ptr, stride);
134  }  }
135    
136    
137    static void
138    CompensateChroma(       int dx, int dy,
139                                            const int i, const int j,
140                                            IMAGE * const Cur,
141                                            const IMAGE * const Ref,
142                                            uint8_t * const temp,
143                                            int16_t * const coeff,
144                                            const int32_t stride,
145                                            const int rounding)
146    { /* uv-block-based compensation */
147    
148            transfer_8to16sub(coeff, Cur->u + 8 * j * stride + 8 * i,
149                                                    interpolate8x8_switch2(temp, Ref->u, 8 * i, 8 * j,
150                                                                                                    dx, dy, stride, rounding),
151                                                    stride);
152            transfer_8to16sub(coeff + 64, Cur->v + 8 * j * stride + 8 * i,
153                                                    interpolate8x8_switch2(temp, Ref->v, 8 * i, 8 * j,
154                                                                                                    dx, dy, stride, rounding),
155                                                    stride);
156    }
157    
158  void MBMotionCompensation(  void
159          MACROBLOCK * const mb,  MBMotionCompensation(MACROBLOCK * const mb,
160          const uint32_t i,          const uint32_t i,
161          const uint32_t j,          const uint32_t j,
162          const IMAGE * const ref,          const IMAGE * const ref,
163          const IMAGE * const refh,          const IMAGE * const refh,
164          const IMAGE * const refv,          const IMAGE * const refv,
165          const IMAGE * const refhv,          const IMAGE * const refhv,
166                                            const IMAGE * const refGMC,
167          IMAGE * const cur,          IMAGE * const cur,
168          int16_t *dct_codes,          int16_t *dct_codes,
169          const uint32_t width,          const uint32_t width,
170          const uint32_t height,          const uint32_t height,
171          const uint32_t edged_width,          const uint32_t edged_width,
172          const uint32_t rounding)                                          const int32_t quarterpel,
173                                            const int32_t rounding)
174  {  {
175          static const uint32_t roundtab[16] =          int32_t dx;
176                  { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 };          int32_t dy;
177    
178            uint8_t * const tmp = refv->u;
179    
180          if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q)          if (mb->mode == MODE_NOT_CODED) {       /* quick copy for early SKIP */
181          {  /* early SKIP is only activated in P-VOPs, not in S-VOPs, so mcsel can never be 1 */
182                  int32_t dx = mb->mvs[0].x;  
183                  int32_t dy = mb->mvs[0].y;                  transfer16x16_copy(cur->y + 16 * (i + j * edged_width),
184                                                      ref->y + 16 * (i + j * edged_width),
185                                                      edged_width);
186    
187                    transfer8x8_copy(cur->u + 8 * (i + j * edged_width/2),
188                                                            ref->u + 8 * (i + j * edged_width/2),
189                                                            edged_width / 2);
190                    transfer8x8_copy(cur->v + 8 * (i + j * edged_width/2),
191                                                            ref->v + 8 * (i + j * edged_width/2),
192                                                            edged_width / 2);
193                    return;
194            }
195    
196            if ((mb->mode == MODE_NOT_CODED || mb->mode == MODE_INTER
197                                    || mb->mode == MODE_INTER_Q)) {
198    
199                  compensate8x8_halfpel(&dct_codes[0*64], cur->y, ref->y, refh->y, refv->y, refhv->y,                  if (mb->mcsel) {
                                       16*i,     16*j,     dx, dy, edged_width);  
                 compensate8x8_halfpel(&dct_codes[1*64], cur->y, ref->y, refh->y, refv->y, refhv->y,  
                                       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);            */  
   
                 /* uv-block-based compensation */  
                 interpolate8x8_switch(refv->u, ref->u, 8*i, 8*j, dx, dy, edged_width/2, rounding);  
                 transfer_8to16sub(&dct_codes[4*64],  
                                   cur->u + 8*j*edged_width/2 + 8*i,  
                                   refv->u + 8*j*edged_width/2 + 8*i, edged_width/2);  
   
                 interpolate8x8_switch(refv->v, ref->v, 8*i, 8*j, dx, dy, edged_width/2, rounding);  
                 transfer_8to16sub(&dct_codes[5*64],  
                                   cur->v + 8*j*edged_width/2 + 8*i,  
                                   refv->v + 8*j*edged_width/2 + 8*i, edged_width/2);  
200    
201                            /* call normal routine once, easier than "if (mcsel)"ing all the time */
202    
203                            transfer_8to16sub(&dct_codes[0*64], cur->y + 16*j*edged_width + 16*i,
204                                                                                            refGMC->y + 16*j*edged_width + 16*i, edged_width);
205                            transfer_8to16sub(&dct_codes[1*64], cur->y + 16*j*edged_width + 16*i+8,
206                                                                                            refGMC->y + 16*j*edged_width + 16*i+8, edged_width);
207                            transfer_8to16sub(&dct_codes[2*64], cur->y + (16*j+8)*edged_width + 16*i,
208                                                                                            refGMC->y + (16*j+8)*edged_width + 16*i, edged_width);
209                            transfer_8to16sub(&dct_codes[3*64], cur->y + (16*j+8)*edged_width + 16*i+8,
210                                                                                            refGMC->y + (16*j+8)*edged_width + 16*i+8, edged_width);
211    
212                            transfer_8to16sub(&dct_codes[4 * 64], cur->u + 8 *j*edged_width/2 + 8*i,
213                                                                    refGMC->u + 8 *j*edged_width/2 + 8*i, edged_width/2);
214    
215                            transfer_8to16sub(&dct_codes[5 * 64], cur->v + 8*j* edged_width/2 + 8*i,
216                                                                    refGMC->v + 8*j* edged_width/2 + 8*i, edged_width/2);
217    
218                            return;
219          }          }
220          else    // mode == MODE_INTER4V  
221                    /* ordinary compensation */
222    
223                    dx = (quarterpel ? mb->qmvs[0].x : mb->mvs[0].x);
224                    dy = (quarterpel ? mb->qmvs[0].y : mb->mvs[0].y);
225    
226                    compensate16x16_interpolate(&dct_codes[0 * 64], cur->y, ref->y, refh->y,
227                                                            refv->y, refhv->y, tmp, 16 * i, 16 * j, dx, dy,
228                                                            edged_width, quarterpel, rounding);
229    
230                    if (quarterpel) { dx /= 2; dy /= 2; }
231    
232                    dx = (dx >> 1) + roundtab_79[dx & 0x3];
233                    dy = (dy >> 1) + roundtab_79[dy & 0x3];
234    
235            } else {                                        /* mode == MODE_INTER4V */
236                    int k, sumx = 0, sumy = 0;
237                    const VECTOR * const mvs = (quarterpel ? mb->qmvs : mb->mvs);
238    
239                    for (k = 0; k < 4; k++) {
240                            dx = mvs[k].x;
241                            dy = mvs[k].y;
242                            sumx += quarterpel ? dx/2 : dx;
243                            sumy += quarterpel ? dy/2 : dy;
244    
245                            compensate8x8_interpolate(&dct_codes[k * 64], cur->y, ref->y, refh->y,
246                                                                            refv->y, refhv->y, tmp, 16 * i + 8*(k&1), 16 * j + 8*(k>>1), dx,
247                                                                            dy, edged_width, quarterpel, rounding);
248                    }
249                    dx = (sumx >> 3) + roundtab_76[sumx & 0xf];
250                    dy = (sumy >> 3) + roundtab_76[sumy & 0xf];
251            }
252    
253            CompensateChroma(dx, dy, i, j, cur, ref, tmp,
254                                            &dct_codes[4 * 64], edged_width / 2, rounding);
255    }
256    
257    
258    void
259    MBMotionCompensationBVOP(MBParam * pParam,
260                                                    MACROBLOCK * const mb,
261                                                    const uint32_t i,
262                                                    const uint32_t j,
263                                                    IMAGE * const cur,
264                                                    const IMAGE * const f_ref,
265                                                    const IMAGE * const f_refh,
266                                                    const IMAGE * const f_refv,
267                                                    const IMAGE * const f_refhv,
268                                                    const IMAGE * const b_ref,
269                                                    const IMAGE * const b_refh,
270                                                    const IMAGE * const b_refv,
271                                                    const IMAGE * const b_refhv,
272                                                    int16_t * dct_codes)
273          {          {
274                  int32_t sum, dx, dy;          const uint32_t edged_width = pParam->edged_width;
275            int32_t dx, dy, b_dx, b_dy, sumx, sumy, b_sumx, b_sumy;
276            int k;
277            const int quarterpel = pParam->vol_flags & XVID_VOL_QUARTERPEL;
278            const uint8_t * ptr1, * ptr2;
279            uint8_t * const tmp = f_refv->u;
280            const VECTOR * const fmvs = (quarterpel ? mb->qmvs : mb->mvs);
281            const VECTOR * const bmvs = (quarterpel ? mb->b_qmvs : mb->b_mvs);
282    
283            switch (mb->mode) {
284            case MODE_FORWARD:
285                    dx = fmvs->x; dy = fmvs->y;
286    
287                    compensate16x16_interpolate(&dct_codes[0 * 64], cur->y, f_ref->y, f_refh->y,
288                                                            f_refv->y, f_refhv->y, tmp, 16 * i, 16 * j, dx,
289                                                            dy, edged_width, quarterpel, 0);
290    
291                    if (quarterpel) { dx /= 2; dy /= 2; }
292    
293                    CompensateChroma(       (dx >> 1) + roundtab_79[dx & 0x3],
294                                                            (dy >> 1) + roundtab_79[dy & 0x3],
295                                                            i, j, cur, f_ref, tmp,
296                                                            &dct_codes[4 * 64], edged_width / 2, 0);
297    
298                    return;
299    
300            case MODE_BACKWARD:
301                    b_dx = bmvs->x; b_dy = bmvs->y;
302    
303                    compensate16x16_interpolate(&dct_codes[0 * 64], cur->y, b_ref->y, b_refh->y,
304                                                                                    b_refv->y, b_refhv->y, tmp, 16 * i, 16 * j, b_dx,
305                                                                                    b_dy, edged_width, quarterpel, 0);
306    
307                    if (quarterpel) { b_dx /= 2; b_dy /= 2; }
308    
309                    CompensateChroma(       (b_dx >> 1) + roundtab_79[b_dx & 0x3],
310                                                            (b_dy >> 1) + roundtab_79[b_dy & 0x3],
311                                                            i, j, cur, b_ref, tmp,
312                                                            &dct_codes[4 * 64], edged_width / 2, 0);
313    
314                    return;
315    
316            case MODE_INTERPOLATE:
317            case MODE_DIRECT_NO4V:
318                    dx = fmvs->x; dy = fmvs->y;
319                    b_dx = bmvs->x; b_dy = bmvs->y;
320    
321                    if (quarterpel) {
322    
323                            if ((dx&3) | (dy&3)) {
324                                    interpolate16x16_quarterpel(tmp - i * 16 - j * 16 * edged_width,
325                                            (uint8_t *) f_ref->y, tmp + 32,
326                                            tmp + 64, tmp + 96, 16*i, 16*j, dx, dy, edged_width, 0);
327                                    ptr1 = tmp;
328                            } else ptr1 = f_ref->y + (16*(int)j + dy/4)*(int)edged_width + 16*(int)i + dx/4; /* fullpixel position */
329    
330                            if ((b_dx&3) | (b_dy&3)) {
331                                    interpolate16x16_quarterpel(tmp - i * 16 - j * 16 * edged_width + 16,
332                                            (uint8_t *) b_ref->y, tmp + 32,
333                                            tmp + 64, tmp + 96, 16*i, 16*j, b_dx, b_dy, edged_width, 0);
334                                    ptr2 = tmp + 16;
335                            } else ptr2 = b_ref->y + (16*(int)j + b_dy/4)*(int)edged_width + 16*(int)i + b_dx/4; /* fullpixel position */
336    
337                            b_dx /= 2;
338                            b_dy /= 2;
339                            dx /= 2;
340                            dy /= 2;
341    
342                    } else {
343                            ptr1 = get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
344                                                            i, j, 16, dx, dy, edged_width);
345    
346                            ptr2 = get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
347                                                            i, j, 16, b_dx, b_dy, edged_width);
348                    }
349                    for (k = 0; k < 4; k++)
350                                    transfer_8to16sub2(&dct_codes[k * 64],
351                                                                            cur->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
352                                                                            ptr1 + (k&1)*8 + (k>>1)*8*edged_width,
353                                                                            ptr2 + (k&1)*8 + (k>>1)*8*edged_width, edged_width);
354    
355    
356                    dx = (dx >> 1) + roundtab_79[dx & 0x3];
357                    dy = (dy >> 1) + roundtab_79[dy & 0x3];
358    
359                    b_dx = (b_dx >> 1) + roundtab_79[b_dx & 0x3];
360                    b_dy = (b_dy >> 1) + roundtab_79[b_dy & 0x3];
361    
362                    break;
363    
364                  compensate8x8_halfpel(&dct_codes[0*64], cur->y, ref->y, refh->y, refv->y, refhv->y,          default: /* MODE_DIRECT (or MODE_DIRECT_NONE_MV in case of bframes decoding) */
365                                        16*i,     16*j,     mb->mvs[0].x, mb->mvs[0].y, edged_width);                  sumx = sumy = b_sumx = b_sumy = 0;
                 compensate8x8_halfpel(&dct_codes[1*64], cur->y, ref->y, refh->y, refv->y, refhv->y,  
                                       16*i + 8, 16*j,     mb->mvs[1].x, mb->mvs[1].y, edged_width);  
                 compensate8x8_halfpel(&dct_codes[2*64], cur->y, ref->y, refh->y, refv->y, refhv->y,  
                                       16*i,     16*j + 8, mb->mvs[2].x, mb->mvs[2].y, edged_width);  
                 compensate8x8_halfpel(&dct_codes[3*64], cur->y, ref->y, refh->y, refv->y, refhv->y,  
                                       16*i + 8, 16*j + 8, mb->mvs[3].x, mb->mvs[3].y, edged_width);  
   
                 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);  
   
                 sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y;  
                 dy = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);  
   
                 /* 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);            */  
   
                 /* uv-block-based compensation */  
                 interpolate8x8_switch(refv->u, ref->u, 8*i, 8*j, dx, dy, edged_width/2, rounding);  
                 transfer_8to16sub(&dct_codes[4*64],  
                                   cur->u + 8*j*edged_width/2 + 8*i,  
                                   refv->u + 8*j*edged_width/2 + 8*i, edged_width/2);  
   
                 interpolate8x8_switch(refv->v, ref->v, 8*i, 8*j, dx, dy, edged_width/2, rounding);  
                 transfer_8to16sub(&dct_codes[5*64],  
                                   cur->v + 8*j*edged_width/2 + 8*i,  
                                   refv->v + 8*j*edged_width/2 + 8*i, edged_width/2);  
366    
367                    for (k = 0; k < 4; k++) {
368    
369                            dx = fmvs[k].x; dy = fmvs[k].y;
370                            b_dx = bmvs[k].x; b_dy = bmvs[k].y;
371    
372                            if (quarterpel) {
373                                    sumx += dx/2; sumy += dy/2;
374                                    b_sumx += b_dx/2; b_sumy += b_dy/2;
375    
376                                    if ((dx&3) | (dy&3)) {
377                                            interpolate8x8_quarterpel(tmp - (i * 16+(k&1)*8) - (j * 16+((k>>1)*8)) * edged_width,
378                                                    (uint8_t *) f_ref->y,
379                                                    tmp + 32, tmp + 64, tmp + 96,
380                                                    16*i + (k&1)*8, 16*j + (k>>1)*8, dx, dy, edged_width, 0);
381                                            ptr1 = tmp;
382                                    } else ptr1 = f_ref->y + (16*(int)j + (k>>1)*8 + dy/4)*(int)edged_width + 16*(int)i + (k&1)*8 + dx/4;
383    
384                                    if ((b_dx&3) | (b_dy&3)) {
385                                            interpolate8x8_quarterpel(tmp - (i * 16+(k&1)*8) - (j * 16+((k>>1)*8)) * edged_width + 16,
386                                                    (uint8_t *) b_ref->y,
387                                                    tmp + 16, tmp + 32, tmp + 48,
388                                                    16*i + (k&1)*8, 16*j + (k>>1)*8, b_dx, b_dy, edged_width, 0);
389                                            ptr2 = tmp + 16;
390                                    } else ptr2 = b_ref->y + (16*(int)j + (k>>1)*8 + b_dy/4)*(int)edged_width + 16*(int)i + (k&1)*8 + b_dx/4;
391                            } else {
392                                    sumx += dx; sumy += dy;
393                                    b_sumx += b_dx; b_sumy += b_dy;
394    
395                                    ptr1 = get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
396                                                                    2*i + (k&1), 2*j + (k>>1), 8, dx, dy, edged_width);
397                                    ptr2 = get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
398                                                                    2*i + (k&1), 2*j + (k>>1), 8, b_dx, b_dy,  edged_width);
399          }          }
400                            transfer_8to16sub2(&dct_codes[k * 64],
401                                                                    cur->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
402                                                                    ptr1, ptr2,     edged_width);
403    
404                    }
405    
406                    dx = (sumx >> 3) + roundtab_76[sumx & 0xf];
407                    dy = (sumy >> 3) + roundtab_76[sumy & 0xf];
408                    b_dx = (b_sumx >> 3) + roundtab_76[b_sumx & 0xf];
409                    b_dy = (b_sumy >> 3) + roundtab_76[b_sumy & 0xf];
410    
411                    break;
412            }
413    
414            /* block-based chroma interpolation for direct and interpolate modes */
415            transfer_8to16sub2(&dct_codes[4 * 64],
416                                                    cur->u + (j * 8) * edged_width / 2 + (i * 8),
417                                                    interpolate8x8_switch2(tmp, b_ref->u, 8 * i, 8 * j,
418                                                                                                    b_dx, b_dy, edged_width / 2, 0),
419                                                    interpolate8x8_switch2(tmp + 8, f_ref->u, 8 * i, 8 * j,
420                                                                                                    dx, dy, edged_width / 2, 0),
421                                                    edged_width / 2);
422    
423            transfer_8to16sub2(&dct_codes[5 * 64],
424                                                    cur->v + (j * 8) * edged_width / 2 + (i * 8),
425                                                    interpolate8x8_switch2(tmp, b_ref->v, 8 * i, 8 * j,
426                                                                                                    b_dx, b_dy, edged_width / 2, 0),
427                                                    interpolate8x8_switch2(tmp + 8, f_ref->v, 8 * i, 8 * j,
428                                                                                                    dx, dy, edged_width / 2, 0),
429                                                    edged_width / 2);
430  }  }

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

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