[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 152, Wed May 1 13:00:02 2002 UTC branches/dev-api-3/xvidcore/src/motion/motion_comp.c revision 658, Tue Nov 19 13:04:35 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  // 01.05.2002   updated MBMotionCompensationBVOP
4  // 14.04.2002   bframe compensation  // 14.04.2002   bframe compensation
5    
# Line 10  Line 12 
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          int32_t ddx,ddy;          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                    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 70  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                                                                    ref->y + 16 * (i + j * edged_width),
130                                                                    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                    compensate16x16_interpolate(&dct_codes[0 * 64], cur->y, ref->y, refh->y,
152                                                      refv->y, refhv->y, 16 * i, 16 * j, dx,
153                                                      dy, edged_width, quarterpel, rounding);
154    
155                    if (quarterpel)
156          {          {
157                  int32_t dx = mb->mvs[0].x;                          dx /= 2;
158                  int32_t dy = mb->mvs[0].y;                          dy /= 2;
159                    }
160    
161                    dx = (dx >> 1) + roundtab_79[dx & 0x3];
162                    dy = (dy >> 1) + roundtab_79[dy & 0x3];
163    
                 compensate8x8_halfpel(&dct_codes[0*64], cur->y, ref->y, refh->y, refv->y, refhv->y,  
                                       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 */  
 #ifdef BFRAMES  
                    compensate8x8_halfpel(&dct_codes[4*64], cur->u, ref->u, refh->u, refv->u, refhv->u,  
                    8*i, 8*j, dx, dy, edged_width/2);  
                    compensate8x8_halfpel(&dct_codes[5*64], cur->v, ref->v, refh->v, refv->v, refhv->v,  
                    8*i, 8*j, dx, dy, edged_width/2);  
 #else  
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  #endif                                                                                                          dx, dy, edged_width / 2, rounding),
175          }                                                          edged_width / 2);
         else    // mode == MODE_INTER4V  
         {  
                 int32_t sum, dx, dy;  
176    
177                  compensate8x8_halfpel(&dct_codes[0*64], cur->y, ref->y, refh->y, refv->y, refhv->y,          } else {                                        // mode == MODE_INTER4V
178                                        16*i,     16*j,     mb->mvs[0].x, mb->mvs[0].y, edged_width);                  int32_t sum, dx, dy;
179                  compensate8x8_halfpel(&dct_codes[1*64], cur->y, ref->y, refh->y, refv->y, refhv->y,                  VECTOR *mvs;
                                       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);  
180    
181                  sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x;                  if(quarterpel)
182                  dx = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);                          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                  sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y;                  dy = (sum >> 3) + roundtab_76[sum & 0xf];
                 dy = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);  
212    
                 /* uv-image-based compensation */  
 #ifdef BFRAMES  
                    compensate8x8_halfpel(&dct_codes[4*64], cur->u, ref->u, refh->u, refv->u, refhv->u,  
                    8*i, 8*j, dx, dy, edged_width/2);  
                    compensate8x8_halfpel(&dct_codes[5*64], cur->v, ref->v, refh->v, refv->v, refhv->v,  
                    8*i, 8*j, dx, dy, edged_width/2);  
 #else  
213                  /* uv-block-based compensation */                  /* uv-block-based compensation */
                 interpolate8x8_switch(refv->u, ref->u, 8*i, 8*j, dx, dy, edged_width/2, rounding);  
214                  transfer_8to16sub(&dct_codes[4*64],                  transfer_8to16sub(&dct_codes[4*64],
215                                    cur->u + 8*j*edged_width/2 + 8*i,                                    cur->u + 8*j*edged_width/2 + 8*i,
216                                    refv->u + 8*j*edged_width/2 + 8*i, edged_width/2);                                                          interpolate8x8_switch2(refv->u, ref->u, 8 * i, 8 * j,
217                                                                                                            dx, dy, edged_width / 2, rounding),
218                                                            edged_width / 2);
219    
                 interpolate8x8_switch(refv->v, ref->v, 8*i, 8*j, dx, dy, edged_width/2, rounding);  
220                  transfer_8to16sub(&dct_codes[5*64],                  transfer_8to16sub(&dct_codes[5*64],
221                                    cur->v + 8*j*edged_width/2 + 8*i,                                    cur->v + 8*j*edged_width/2 + 8*i,
222                                    refv->v + 8*j*edged_width/2 + 8*i, edged_width/2);                                                          interpolate8x8_switch2(refv->u, ref->v, 8 * i, 8 * j,
223  #endif                                                                                                          dx, dy, edged_width / 2, rounding),
224                                                            edged_width / 2);
225          }          }
226  }  }
227    
228    
229  void MBMotionCompensationBVOP(  void
230                          MBParam * pParam,  MBMotionCompensationBVOP(MBParam * pParam,
231                          MACROBLOCK * const mb,                          MACROBLOCK * const mb,
232                      const uint32_t i,                      const uint32_t i,
233                          const uint32_t j,                          const uint32_t j,
# Line 175  Line 248 
248          const int32_t edged_width = pParam->edged_width;          const int32_t edged_width = pParam->edged_width;
249          int32_t dx, dy;          int32_t dx, dy;
250          int32_t b_dx, b_dy;          int32_t b_dx, b_dy;
251            int k,sum;
252          int x = i;          int x = i;
253          int y = j;          int y = j;
254            uint32_t quarterpel = pParam->m_quarterpel;
255    
256            switch (mb->mode) {
   
         switch(mb->mode)  
         {  
257          case MODE_FORWARD :          case MODE_FORWARD :
258    
259                    if (quarterpel) {
260                            dx = mb->qmvs[0].x;
261                            dy = mb->qmvs[0].y;
262                    } else {
263                  dx = mb->mvs[0].x;                  dx = mb->mvs[0].x;
264                  dy = mb->mvs[0].y;                  dy = mb->mvs[0].y;
265                    }
266    
267                  transfer_8to16sub_c(                  compensate16x16_interpolate(&dct_codes[0 * 64], cur->y, f_ref->y, f_refh->y,
268                          &dct_codes[0*64],                                                    f_refv->y, f_refhv->y, 16 * i, 16 * j, dx,
269                          cur->y + (j*16)*edged_width + (i*16),                                                    dy, edged_width, quarterpel, 0);
270                          get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,  
271                                                          i*16, j*16, 1, dx, dy, edged_width),                  if (quarterpel) {
272                          edged_width);                          dx /= 2;
273                            dy /= 2;
274                    }
275    
276                  transfer_8to16sub(                  dx = (dx >> 1) + roundtab_79[dx & 0x3];
277                          &dct_codes[1*64],                  dy = (dy >> 1) + roundtab_79[dy & 0x3];
                         cur->y + (j*16)*edged_width + (i*16+8),  
                         get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,  
                                                         i*16+8, j*16, 1, dx, dy, edged_width),  
                         edged_width);  
278    
279                  transfer_8to16sub_c(                  /* uv-block-based compensation */
280                          &dct_codes[2*64],                  transfer_8to16sub(&dct_codes[4 * 64],
281                          cur->y + (j*16+8)*edged_width + (i*16),                                                          cur->u + 8 * j * edged_width / 2 + 8 * i,
282                          get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,                                                          interpolate8x8_switch2(f_refv->u, f_ref->u, 8 * i, 8 * j,
283                                                          i*16, j*16+8, 1, dx, dy, edged_width),                                                                                                          dx, dy, edged_width / 2, 0),
                         edged_width);  
   
                 transfer_8to16sub(  
                         &dct_codes[3*64],  
                         cur->y + (j*16+8)*edged_width + (i*16+8),  
                         get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,  
                                                         i*16+8, j*16+8, 1, dx, dy, edged_width),  
                         edged_width);  
284    
285                                                      edged_width / 2);
286    
287                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;                  transfer_8to16sub(&dct_codes[5 * 64],
288                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;                                                          cur->v + 8 * j * edged_width / 2 + 8 * i,
289                                                            interpolate8x8_switch2(f_refv->u, f_ref->v, 8 * i, 8 * j,
290                                                                                                            dx, dy, edged_width / 2, 0),
291    
292                  /* uv-image-based compensation */                                                    edged_width / 2);
                 compensate8x8_halfpel(&dct_codes[4*64], cur->u, f_ref->u, f_refh->u, f_refv->u, f_refhv->u,  
                                                                 8*i, 8*j, dx, dy, edged_width/2);  
                 compensate8x8_halfpel(&dct_codes[5*64], cur->v, f_ref->v, f_refh->v, f_refv->v, f_refhv->v,  
                                                                 8*i, 8*j, dx, dy, edged_width/2);  
293    
294                  break;                  break;
295    
296          case MODE_BACKWARD :          case MODE_BACKWARD :
297                    if (quarterpel) {
298                            b_dx = mb->b_qmvs[0].x;
299                            b_dy = mb->b_qmvs[0].y;
300                    } else {
301                  b_dx = mb->b_mvs[0].x;                  b_dx = mb->b_mvs[0].x;
302                  b_dy = mb->b_mvs[0].y;                  b_dy = mb->b_mvs[0].y;
303                    }
304    
305                  transfer_8to16sub_c(                  compensate16x16_interpolate(&dct_codes[0 * 64], cur->y, b_ref->y, b_refh->y,
306                          &dct_codes[0*64],                                                    b_refv->y, b_refhv->y, 16 * i, 16 * j, b_dx,
307                          cur->y + (j*16)*edged_width + (i*16),                                                    b_dy, edged_width, quarterpel, 0);
308                          get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,  
309                                                          i*16, j*16, 1, b_dx, b_dy, edged_width),                  if (quarterpel) {
310                          edged_width);                          b_dx /= 2;
311                            b_dy /= 2;
312                    }
313    
314                  transfer_8to16sub(                  b_dx = (b_dx >> 1) + roundtab_79[b_dx & 0x3];
315                          &dct_codes[1*64],                  b_dy = (b_dy >> 1) + roundtab_79[b_dy & 0x3];
                         cur->y + (j*16)*edged_width + (i*16+8),  
                         get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,  
                                                         i*16+8, j*16, 1, b_dx, b_dy, edged_width),  
                         edged_width);  
316    
                 transfer_8to16sub_c(  
                         &dct_codes[2*64],  
                         cur->y + (j*16+8)*edged_width + (i*16),  
                         get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,  
                                                         i*16, j*16+8, 1, b_dx, b_dy, edged_width),  
                         edged_width);  
317    
318                  transfer_8to16sub(                  /* uv-block-based compensation */
319                          &dct_codes[3*64],                  transfer_8to16sub(&dct_codes[4 * 64],
320                          cur->y + (j*16+8)*edged_width + (i*16+8),                                                          cur->u + 8 * j * edged_width / 2 + 8 * i,
321                          get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,                                                          interpolate8x8_switch2(f_refv->u, b_ref->u, 8 * i, 8 * j,
322                                                          i*16+8, j*16+8, 1, b_dx, b_dy, edged_width),                                                                                                          b_dx, b_dy, edged_width / 2, 0),
                         edged_width);  
323    
324                  b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;                                                          edged_width / 2);
325                  b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;  
326                    transfer_8to16sub(&dct_codes[5 * 64],
327                                                            cur->v + 8 * j * edged_width / 2 + 8 * i,
328                                                            interpolate8x8_switch2(f_refv->u, b_ref->v, 8 * i, 8 * j,
329                                                                                                            b_dx, b_dy, edged_width / 2, 0),
330    
331                  /* uv-image-based compensation */                                                          edged_width / 2);
                 compensate8x8_halfpel(&dct_codes[4*64], cur->u,  
                                         b_ref->u, b_refh->u, b_refv->u, b_refhv->u,  
                                         8*i, 8*j, b_dx, b_dy, edged_width/2);  
                 compensate8x8_halfpel(&dct_codes[5*64], cur->v,  
                                         b_ref->v, b_refh->v, b_refv->v, b_refhv->v,  
                                         8*i, 8*j, b_dx, b_dy, edged_width/2);  
332    
333                  break;                  break;
334    
335            case MODE_INTERPOLATE:          /* _could_ use DIRECT, but would be overkill (no 4MV there) */
336            case MODE_DIRECT_NO4V:
337    
338                    if (quarterpel) {
339                            dx = mb->qmvs[0].x;
340                            dy = mb->qmvs[0].y;
341                            b_dx = mb->b_qmvs[0].x;
342                            b_dy = mb->b_qmvs[0].y;
343    
344                            interpolate16x16_quarterpel((uint8_t *) f_refv->y, (uint8_t *) f_ref->y, (uint8_t *) f_refh->y,
345                                    (uint8_t *) f_refh->y + 64, (uint8_t *) f_refhv->y, 16*i, 16*j, dx, dy, edged_width, 0);
346                            interpolate16x16_quarterpel((uint8_t *) b_refv->y, (uint8_t *) b_ref->y, (uint8_t *) b_refh->y,
347                                    (uint8_t *) b_refh->y + 64, (uint8_t *) b_refhv->y, 16*i, 16*j, b_dx, b_dy, edged_width, 0);
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                                                                    f_refv->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
353                                                                    b_refv->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
354                                                                    edged_width);
355                            }
356                            b_dx /= 2;
357                            b_dy /= 2;
358                            dx /= 2;
359                            dy /= 2;
360    
361          case MODE_INTERPOLATE :                  } else {
362                  dx = mb->mvs[0].x;                  dx = mb->mvs[0].x;
363                  dy = mb->mvs[0].y;                  dy = mb->mvs[0].y;
364                  b_dx = mb->b_mvs[0].x;                  b_dx = mb->b_mvs[0].x;
365                  b_dy = mb->b_mvs[0].y;                  b_dy = mb->b_mvs[0].y;
366    
367                  transfer_8to16sub2_c(                          for (k = 0; k < 4; k++) {
368                                  &dct_codes[0*64],                                  transfer_8to16sub2(&dct_codes[k * 64],
369                                  cur->y + (i*16) + (j*16)*edged_width,                                                                  cur->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
370                                  get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,                                                                  get_ref(f_ref->y, f_refh->y, f_refv->y,
371                                                          16*i, 16*j, 1, dx, dy, edged_width),                                                                                  f_refhv->y, 2*i + (k&1), 2*j + (k>>1), 8, dx, dy,
372                                  get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,                                                                                  edged_width),
373                                                          16*i, 16*j, 1, b_dx, b_dy, edged_width),                                                                  get_ref(b_ref->y, b_refh->y, b_refv->y,
374                                                                                    b_refhv->y, 2*i + (k&1), 2 * j+(k>>1), 8, b_dx, b_dy,
375                                                                                    edged_width),
376                                  edged_width);                                  edged_width);
377                            }
378    
379                  transfer_8to16sub2_c(                  }
                                 &dct_codes[1*64],  
                                 cur->y + (i*16+8) + (j*16)*edged_width,  
                                 get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,  
                                                         16*i+8, 16*j, 1, dx, dy, edged_width),  
                                 get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,  
                                                         16*i+8, 16*j, 1, b_dx, b_dy, edged_width),  
                                 edged_width);  
380    
381                  transfer_8to16sub2_c(  
382                                  &dct_codes[2*64],                  dx = (dx >> 1) + roundtab_79[dx & 0x3];
383                                  cur->y + (i*16) + (j*16+8)*edged_width,                  dy = (dy >> 1) + roundtab_79[dy & 0x3];
384                                  get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,  
385                                                          16*i, 16*j+8, 1, dx, dy, edged_width),                  b_dx = (b_dx >> 1) + roundtab_79[b_dx & 0x3];
386                                  get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,                  b_dy = (b_dy >> 1) + roundtab_79[b_dy & 0x3];
387                                                          16*i, 16*j+8, 1, b_dx, b_dy, edged_width),  
388                    transfer_8to16sub2(&dct_codes[4 * 64],
389                                                            cur->u + (y * 8) * edged_width / 2 + (x * 8),
390                                                            interpolate8x8_switch2(f_refv->u, b_ref->u, 8 * i, 8 * j,
391                                                                                                            b_dx, b_dy, edged_width / 2, 0),
392                                                            interpolate8x8_switch2(f_refv->u + 8, f_ref->u, 8 * i, 8 * j,
393                                                                                                            dx, dy, edged_width / 2, 0),
394                                                            edged_width / 2);
395    
396                    transfer_8to16sub2(&dct_codes[5 * 64],
397                                                            cur->v + (y * 8) * edged_width / 2 + (x * 8),
398                                                            interpolate8x8_switch2(f_refv->u, b_ref->v, 8 * i, 8 * j,
399                                                                                                            b_dx, b_dy, edged_width / 2, 0),
400                                                            interpolate8x8_switch2(f_refv->u + 8, f_ref->v, 8 * i, 8 * j,
401                                                                                                            dx, dy, edged_width / 2, 0),
402                                                            edged_width / 2);
403    
404                    break;
405    
406            case MODE_DIRECT:
407                    if (quarterpel) {
408                            for (k=0;k<4;k++) {
409    
410                                    dx = mb->qmvs[k].x;
411                                    dy = mb->qmvs[k].y;
412                                    b_dx = mb->b_qmvs[k].x;
413                                    b_dy = mb->b_qmvs[k].y;
414    
415                                    interpolate8x8_quarterpel((uint8_t *) f_refv->y,
416                                            (uint8_t *) f_ref->y,
417                                            (uint8_t *) f_refh->y,
418                                            (uint8_t *) f_refh->y + 64,
419                                            (uint8_t *) f_refhv->y,
420                                            16*i + (k&1)*8, 16*j + (k>>1)*8, dx, dy, edged_width, 0);
421                                    interpolate8x8_quarterpel((uint8_t *) b_refv->y,
422                                            (uint8_t *) b_ref->y,
423                                            (uint8_t *) b_refh->y,
424                                            (uint8_t *) b_refh->y + 64,
425                                            (uint8_t *) b_refhv->y,
426                                            16*i + (k&1)*8, 16*j + (k>>1)*8, b_dx, b_dy, edged_width, 0);
427    
428    
429                                    transfer_8to16sub2(&dct_codes[k * 64],
430                                                                    cur->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
431                                                                    f_refv->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
432                                                                    b_refv->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
433                                  edged_width);                                  edged_width);
434                            }
435                            sum = mb->qmvs[0].y/2 + mb->qmvs[1].y/2 + mb->qmvs[2].y/2 + mb->qmvs[3].y/2;
436                            dy = (sum >> 3) + roundtab_76[sum & 0xf];
437                            sum = mb->qmvs[0].x/2 + mb->qmvs[1].x/2 + mb->qmvs[2].x/2 + mb->qmvs[3].x/2;
438                            dx = (sum >> 3) + roundtab_76[sum & 0xf];
439    
440                            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;
441                            b_dy = (sum >> 3) + roundtab_76[sum & 0xf];
442                            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;
443                            b_dx = (sum >> 3) + roundtab_76[sum & 0xf];
444    
445                    } else {
446                            for (k=0;k<4;k++) {
447                                    dx = mb->mvs[k].x;
448                                    dy = mb->mvs[k].y;
449    
450                                    b_dx = mb->b_mvs[k].x;
451                                    b_dy = mb->b_mvs[k].y;
452    
453                  transfer_8to16sub2_c(                                  transfer_8to16sub2(&dct_codes[k * 64],
454                                  &dct_codes[3*64],                                                                  cur->y + (i*16 + (k&1)*8) + (j*16 + (k>>1)*8 ) * edged_width,
                                 cur->y + (i*16+8) + (j*16+8)*edged_width,  
455                                  get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,                                  get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
456                                                          16*i + 8, 16*j + 8, 1, dx, dy, edged_width),                                                                                  2*i + (k&1), 2*j + (k>>1), 8, dx, dy,
457                                                                                    edged_width),
458                                  get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,                                  get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
459                                                          16*i + 8, 16*j + 8, 1, b_dx, b_dy, edged_width),                                                                                  2*i + (k&1), 2*j + (k>>1), 8, b_dx, b_dy,
460                                                                                    edged_width),
461                                  edged_width);                                  edged_width);
462                            }
463    
464                            sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x;
465                            dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
466    
467                            sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y;
468                            dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
469    
470                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;                          sum = mb->b_mvs[0].x + mb->b_mvs[1].x + mb->b_mvs[2].x + mb->b_mvs[3].x;
471                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;                          b_dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
472    
473                  b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;                          sum = mb->b_mvs[0].y + mb->b_mvs[1].y + mb->b_mvs[2].y + mb->b_mvs[3].y;
474                  b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;                          b_dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
475    
476                  transfer_8to16sub2_c(                  }
477                                  &dct_codes[4*64],                  transfer_8to16sub2(&dct_codes[4 * 64],
478                                  cur->u + (y*8)*edged_width/2 + (x*8),                                  cur->u + (y*8)*edged_width/2 + (x*8),
479                                  get_ref(f_ref->u, f_refh->u, f_refv->u, f_refhv->u,                                                          interpolate8x8_switch2(f_refv->u, b_ref->u, 8 * i, 8 * j,
480                                                          8*i, 8*j, 1, dx, dy, edged_width/2),                                                                                                          b_dx, b_dy, edged_width / 2, 0),
481                                  get_ref(b_ref->u, b_refh->u, b_refv->u, b_refhv->u,                                                          interpolate8x8_switch2(f_refv->u + 8, f_ref->u, 8 * i, 8 * j, dx, dy,
482                                                          8*i, 8*j, 1, b_dx, b_dy, edged_width/2),                                                            edged_width / 2, 0),
483                                  edged_width/2);                                  edged_width/2);
484    
485                  transfer_8to16sub2_c(                  transfer_8to16sub2(&dct_codes[5 * 64],
                                 &dct_codes[5*64],  
486                                  cur->v + (y*8)*edged_width/2 + (x*8),                                  cur->v + (y*8)*edged_width/2 + (x*8),
487                                  get_ref(f_ref->v, f_refh->v, f_refv->v, f_refhv->v,                                                          interpolate8x8_switch2(f_refv->u, b_ref->v, 8 * i, 8 * j,
488                                                          8*i, 8*j, 1, dx, dy, edged_width/2),                                                                                                          b_dx, b_dy, edged_width / 2, 0),
489                                  get_ref(b_ref->v, b_refh->v, b_refv->v, b_refhv->v,                                                          interpolate8x8_switch2(f_refv->u + 8, f_ref->v, 8 * i, 8 * j,
490                                                          8*i, 8*j, 1, b_dx, b_dy, edged_width/2),                                                                                                          dx, dy, edged_width / 2, 0),
491                                  edged_width/2);                                  edged_width/2);
492    
                 break;  
493    
         case MODE_DIRECT :  
                 // todo  
494                  break;                  break;
495          }          }
   
496  }  }

Legend:
Removed from v.152  
changed lines
  Added in v.658

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