[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 209, Fri Jun 14 13:29:07 2002 UTC branches/dev-api-3/xvidcore/src/motion/motion_comp.c revision 618, Thu Oct 31 06:52:26 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 11  Line 13 
13  #define SIGN(X) (((X)>0)?1:-1)  #define SIGN(X) (((X)>0)?1:-1)
14    
15  static __inline void  static __inline void
16  compensate8x8_halfpel(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,
# Line 20  Line 22 
22                                            const uint32_t x,                                            const uint32_t x,
23                                            const uint32_t y,                                            const uint32_t y,
24                                            const int32_t dx,                                            const int32_t dx,
25                                            const int dy,                                                      const int32_t dy,
26                                            const uint32_t stride)                                                      const uint32_t stride,
27                                                        const uint32_t quarterpel,
28                                                        const uint32_t rounding)
29    {
30            if(quarterpel) {
31                    interpolate16x16_quarterpel((uint8_t *) refv, (uint8_t *) ref, (uint8_t *) refh,
32                            (uint8_t *) refh + 64, (uint8_t *) refhv, x, y, dx, dy, stride, rounding);
33    
34                    transfer_8to16sub(dct_codes, cur + y*stride + x,
35                                                      refv + y*stride + x, stride);
36                    transfer_8to16sub(dct_codes+64, cur + y*stride + x + 8,
37                                                      refv + y*stride + x + 8, stride);
38                    transfer_8to16sub(dct_codes+128, cur + y*stride + x + 8*stride,
39                                                      refv + y*stride + x + 8*stride, stride);
40                    transfer_8to16sub(dct_codes+192, cur + y*stride + x + 8*stride + 8,
41                                                      refv + y*stride + x + 8*stride+8, stride);
42    
43            }
44            else
45  {  {
46          int32_t ddx, ddy;                  const uint8_t * reference;
47    
48          switch (((dx & 1) << 1) + (dy & 1))     // ((dx%2)?2:0)+((dy%2)?1:0)          switch (((dx & 1) << 1) + (dy & 1))     // ((dx%2)?2:0)+((dy%2)?1:0)
49          {          {
50          case 0:                  case 0: reference = ref + ((y + dy / 2) * stride + x + dx / 2); break;
51                  ddx = dx / 2;                  case 1: reference = refv + ((y + (dy-1) / 2) * stride + x + dx / 2); break;
52                  ddy = dy / 2;                  case 2: reference = refh + ((y + dy / 2) * stride + x + (dx-1) / 2); break;
53                    default:                                        // case 3:
54                            reference = refhv + ((y + (dy-1) / 2) * stride + x + (dx-1) / 2); break;
55                    }
56                  transfer_8to16sub(dct_codes, cur + y * stride + x,                  transfer_8to16sub(dct_codes, cur + y * stride + x,
57                                                    ref + (int) ((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 + (int) ((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 + (int) ((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 + (int) ((y + ddy) * stride + x + ddx), stride);                                                            reference, stride);
                 break;  
103          }          }
104  }  }
105    
   
   
106  void  void
107  MBMotionCompensation(MACROBLOCK * const mb,  MBMotionCompensation(MACROBLOCK * const mb,
108                                           const uint32_t i,                                           const uint32_t i,
# Line 72  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) {
123                  { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 };                  transfer8x8_copy(cur->y + 16 * (i + j * edged_width),
124                                                            ref->y + 16 * (i + j * edged_width),
125                                                            edged_width);
126                    transfer8x8_copy(cur->y + 16 * (i + j * edged_width) + 8,
127                                                            ref->y + 16 * (i + j * edged_width) + 8,
128                                                            edged_width);
129                    transfer8x8_copy(cur->y + 16 * (i + j * edged_width) + 8 * edged_width,
130                                                            ref->y + 16 * (i + j * edged_width) + 8 * edged_width,
131                                                            edged_width);
132                    transfer8x8_copy(cur->y + 16 * (i + j * edged_width) + 8 * (edged_width+1),
133                                                            ref->y + 16 * (i + j * edged_width) + 8 * (edged_width+1),
134                                                            edged_width);
135    
136                    transfer8x8_copy(cur->u + 8 * (i + j * edged_width/2),
137                                                            ref->u + 8 * (i + j * edged_width/2),
138                                                            edged_width / 2);
139                    transfer8x8_copy(cur->v + 8 * (i + j * edged_width/2),
140                                                            ref->v + 8 * (i + j * edged_width/2),
141                                                            edged_width / 2);
142                    return;
143            }
144    
145          if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) {          if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) {
146                  int32_t dx = mb->mvs[0].x;                  int32_t dx = mb->mvs[0].x;
147                  int32_t dy = mb->mvs[0].y;                  int32_t dy = mb->mvs[0].y;
148    
149                  compensate8x8_halfpel(&dct_codes[0 * 64], cur->y, ref->y, refh->y,                  if(quarterpel) {
150                                                            refv->y, refhv->y, 16 * i, 16 * j, dx, dy,                          dx = mb->qmvs[0].x;
151                                                            edged_width);                          dy = mb->qmvs[0].y;
152                  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);  
153    
154                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;                  compensate16x16_interpolate(&dct_codes[0 * 64], cur->y, ref->y, refh->y,
155                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;                                                            refv->y, refhv->y, 16 * i, 16 * j, dx,
156                                                              dy, edged_width, quarterpel, rounding);
157    
158                    if (quarterpel)
159                    {
160                            dx /= 2;
161                            dy /= 2;
162                    }
163    
164                    dx = (dx >> 1) + roundtab_79[dx & 0x3];
165                    dy = (dy >> 1) + roundtab_79[dy & 0x3];
166    
                 /* 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  
167                  /* uv-block-based compensation */                  /* uv-block-based compensation */
                 interpolate8x8_switch(refv->u, ref->u, 8 * i, 8 * j, dx, dy,  
                                                           edged_width / 2, rounding);  
168                  transfer_8to16sub(&dct_codes[4 * 64],                  transfer_8to16sub(&dct_codes[4 * 64],
169                                                    cur->u + 8 * j * edged_width / 2 + 8 * i,                                                    cur->u + 8 * j * edged_width / 2 + 8 * i,
170                                                    refv->u + 8 * j * edged_width / 2 + 8 * i,                                                          interpolate8x8_switch2(refv->u, ref->u, 8 * i, 8 * j,
171                                                                                                            dx, dy, edged_width / 2, rounding),
172                                                    edged_width / 2);                                                    edged_width / 2);
173    
                 interpolate8x8_switch(refv->v, ref->v, 8 * i, 8 * j, dx, dy,  
                                                           edged_width / 2, rounding);  
174                  transfer_8to16sub(&dct_codes[5 * 64],                  transfer_8to16sub(&dct_codes[5 * 64],
175                                                    cur->v + 8 * j * edged_width / 2 + 8 * i,                                                    cur->v + 8 * j * edged_width / 2 + 8 * i,
176                                                    refv->v + 8 * j * edged_width / 2 + 8 * i,                                                          interpolate8x8_switch2(refv->u, ref->v, 8 * i, 8 * j,
177                                                                                                            dx, dy, edged_width / 2, rounding),
178                                                    edged_width / 2);                                                    edged_width / 2);
179  #endif  
180          } else                                          // mode == MODE_INTER4V          } else {                                        // mode == MODE_INTER4V
         {  
181                  int32_t sum, dx, dy;                  int32_t sum, dx, dy;
182                    VECTOR *mvs;
183    
184                  compensate8x8_halfpel(&dct_codes[0 * 64], cur->y, ref->y, refh->y,                  if(quarterpel)
185                                                            refv->y, refhv->y, 16 * i, 16 * j, mb->mvs[0].x,                          mvs = mb->qmvs;
186                                                            mb->mvs[0].y, edged_width);                  else
187                  compensate8x8_halfpel(&dct_codes[1 * 64], cur->y, ref->y, refh->y,                          mvs = mb->mvs;
188    
189                    compensate8x8_interpolate(&dct_codes[0 * 64], cur->y, ref->y, refh->y,
190                                                              refv->y, refhv->y, 16 * i, 16 * j, mvs[0].x,
191                                                              mvs[0].y, edged_width, quarterpel, rounding);
192                    compensate8x8_interpolate(&dct_codes[1 * 64], cur->y, ref->y, refh->y,
193                                                            refv->y, refhv->y, 16 * i + 8, 16 * j,                                                            refv->y, refhv->y, 16 * i + 8, 16 * j,
194                                                            mb->mvs[1].x, mb->mvs[1].y, edged_width);                                                            mvs[1].x, mvs[1].y, edged_width, quarterpel, rounding);
195                  compensate8x8_halfpel(&dct_codes[2 * 64], cur->y, ref->y, refh->y,                  compensate8x8_interpolate(&dct_codes[2 * 64], cur->y, ref->y, refh->y,
196                                                            refv->y, refhv->y, 16 * i, 16 * j + 8,                                                            refv->y, refhv->y, 16 * i, 16 * j + 8,
197                                                            mb->mvs[2].x, mb->mvs[2].y, edged_width);                                                            mvs[2].x, mvs[2].y, edged_width, quarterpel, rounding);
198                  compensate8x8_halfpel(&dct_codes[3 * 64], cur->y, ref->y, refh->y,                  compensate8x8_interpolate(&dct_codes[3 * 64], cur->y, ref->y, refh->y,
199                                                            refv->y, refhv->y, 16 * i + 8, 16 * j + 8,                                                            refv->y, refhv->y, 16 * i + 8, 16 * j + 8,
200                                                            mb->mvs[3].x, mb->mvs[3].y, edged_width);                                                            mvs[3].x, mvs[3].y, edged_width, quarterpel, rounding);
201    
202                  sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x;                  if(quarterpel)
203                  dx = (sum ? SIGN(sum) *                          sum = (mvs[0].x / 2) + (mvs[1].x / 2) + (mvs[2].x / 2) + (mvs[3].x / 2);
204                            (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);                  else
205                            sum = mvs[0].x + mvs[1].x + mvs[2].x + mvs[3].x;
206    
207                  sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y;                  dx = (sum >> 3) + roundtab_76[sum & 0xf];
208                  dy = (sum ? SIGN(sum) *  
209                            (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);                  if(quarterpel)
210                            sum = (mvs[0].y / 2) + (mvs[1].y / 2) + (mvs[2].y / 2) + (mvs[3].y / 2);
211                    else
212                            sum = mvs[0].y + mvs[1].y + mvs[2].y + mvs[3].y;
213    
214                    dy = (sum >> 3) + roundtab_76[sum & 0xf];
215    
                 /* 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  
216                  /* uv-block-based compensation */                  /* uv-block-based compensation */
                 interpolate8x8_switch(refv->u, ref->u, 8 * i, 8 * j, dx, dy,  
                                                           edged_width / 2, rounding);  
217                  transfer_8to16sub(&dct_codes[4 * 64],                  transfer_8to16sub(&dct_codes[4 * 64],
218                                                    cur->u + 8 * j * edged_width / 2 + 8 * i,                                                    cur->u + 8 * j * edged_width / 2 + 8 * i,
219                                                    refv->u + 8 * j * edged_width / 2 + 8 * i,                                                          interpolate8x8_switch2(refv->u, ref->u, 8 * i, 8 * j,
220                                                                                                            dx, dy, edged_width / 2, rounding),
221                                                    edged_width / 2);                                                    edged_width / 2);
222    
                 interpolate8x8_switch(refv->v, ref->v, 8 * i, 8 * j, dx, dy,  
                                                           edged_width / 2, rounding);  
223                  transfer_8to16sub(&dct_codes[5 * 64],                  transfer_8to16sub(&dct_codes[5 * 64],
224                                                    cur->v + 8 * j * edged_width / 2 + 8 * i,                                                    cur->v + 8 * j * edged_width / 2 + 8 * i,
225                                                    refv->v + 8 * j * edged_width / 2 + 8 * i,                                                          interpolate8x8_switch2(refv->u, ref->v, 8 * i, 8 * j,
226                                                                                                            dx, dy, edged_width / 2, rounding),
227    
228                                                    edged_width / 2);                                                    edged_width / 2);
 #endif  
229          }          }
230  }  }
231    
# Line 197  Line 252 
252          const int32_t edged_width = pParam->edged_width;          const int32_t edged_width = pParam->edged_width;
253          int32_t dx, dy;          int32_t dx, dy;
254          int32_t b_dx, b_dy;          int32_t b_dx, b_dy;
255            int k,sum;
256          int x = i;          int x = i;
257          int y = j;          int y = j;
258    
259    
   
260          switch (mb->mode) {          switch (mb->mode) {
261          case MODE_FORWARD:          case MODE_FORWARD:
262                  dx = mb->mvs[0].x;                  dx = mb->mvs[0].x;
263                  dy = mb->mvs[0].y;                  dy = mb->mvs[0].y;
264    
265                  transfer_8to16sub_c(&dct_codes[0 * 64],                  transfer_8to16sub(&dct_codes[0 * 64],
266                                                          cur->y + (j * 16) * edged_width + (i * 16),                                                          cur->y + (j * 16) * edged_width + (i * 16),
267                                                          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,
268                                                                          i * 16, j * 16, 1, dx, dy, edged_width),                                                                          i * 16, j * 16, 1, dx, dy, edged_width),
# Line 219  Line 274 
274                                                                    i * 16 + 8, j * 16, 1, dx, dy, edged_width),                                                                    i * 16 + 8, j * 16, 1, dx, dy, edged_width),
275                                                    edged_width);                                                    edged_width);
276    
277                  transfer_8to16sub_c(&dct_codes[2 * 64],                  transfer_8to16sub(&dct_codes[2 * 64],
278                                                          cur->y + (j * 16 + 8) * edged_width + (i * 16),                                                          cur->y + (j * 16 + 8) * edged_width + (i * 16),
279                                                          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,
280                                                                          i * 16, j * 16 + 8, 1, dx, dy,                                                                          i * 16, j * 16 + 8, 1, dx, dy, edged_width),
281                                                                          edged_width), edged_width);                                                          edged_width);
282    
283                  transfer_8to16sub(&dct_codes[3 * 64],                  transfer_8to16sub(&dct_codes[3 * 64],
284                                                    cur->y + (j * 16 + 8) * edged_width + (i * 16 + 8),                                                    cur->y + (j * 16 + 8) * edged_width + (i * 16 + 8),
285                                                    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,
286                                                                    i * 16 + 8, j * 16 + 8, 1, dx, dy,                                                                    i * 16 + 8, j * 16 + 8, 1, dx, dy, edged_width),
287                                                                    edged_width), edged_width);                                                          edged_width);
288    
289    
290                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;
291                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;
292    
293                  /* uv-image-based compensation */                  /* uv-block-based compensation */
294                  compensate8x8_halfpel(&dct_codes[4 * 64], cur->u, f_ref->u, f_refh->u,                  transfer_8to16sub(&dct_codes[4 * 64],
295                                                            f_refv->u, f_refhv->u, 8 * i, 8 * j, dx, dy,                                                          cur->u + 8 * j * edged_width / 2 + 8 * i,
296                                                            interpolate8x8_switch2(f_refv->u, f_ref->u, 8 * i, 8 * j,
297                                                                                                            dx, dy, edged_width / 2, 0),
298    
299                                                            edged_width / 2);                                                            edged_width / 2);
300                  compensate8x8_halfpel(&dct_codes[5 * 64], cur->v, f_ref->v, f_refh->v,  
301                                                            f_refv->v, f_refhv->v, 8 * i, 8 * j, dx, dy,                  transfer_8to16sub(&dct_codes[5 * 64],
302                                                            cur->v + 8 * j * edged_width / 2 + 8 * i,
303                                                            interpolate8x8_switch2(f_refv->u, f_ref->v, 8 * i, 8 * j,
304                                                                                                            dx, dy, edged_width / 2, 0),
305    
306                                                            edged_width / 2);                                                            edged_width / 2);
307    
308                  break;                  break;
# Line 249  Line 311 
311                  b_dx = mb->b_mvs[0].x;                  b_dx = mb->b_mvs[0].x;
312                  b_dy = mb->b_mvs[0].y;                  b_dy = mb->b_mvs[0].y;
313    
314                  transfer_8to16sub_c(&dct_codes[0 * 64],                  transfer_8to16sub(&dct_codes[0 * 64],
315                                                          cur->y + (j * 16) * edged_width + (i * 16),                                                          cur->y + (j * 16) * edged_width + (i * 16),
316                                                          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,
317                                                                          i * 16, j * 16, 1, b_dx, b_dy,                                                                          i * 16, j * 16, 1, b_dx, b_dy,
# Line 261  Line 323 
323                                                                    i * 16 + 8, j * 16, 1, b_dx, b_dy,                                                                    i * 16 + 8, j * 16, 1, b_dx, b_dy,
324                                                                    edged_width), edged_width);                                                                    edged_width), edged_width);
325    
326                  transfer_8to16sub_c(&dct_codes[2 * 64],                  transfer_8to16sub(&dct_codes[2 * 64],
327                                                          cur->y + (j * 16 + 8) * edged_width + (i * 16),                                                          cur->y + (j * 16 + 8) * edged_width + (i * 16),
328                                                          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,
329                                                                          i * 16, j * 16 + 8, 1, b_dx, b_dy,                                                                          i * 16, j * 16 + 8, 1, b_dx, b_dy,
# Line 276  Line 338 
338                  b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;                  b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;
339                  b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;                  b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;
340    
341                  /* uv-image-based compensation */                  /* uv-block-based compensation */
342                  compensate8x8_halfpel(&dct_codes[4 * 64], cur->u, b_ref->u, b_refh->u,                  transfer_8to16sub(&dct_codes[4 * 64],
343                                                            b_refv->u, b_refhv->u, 8 * i, 8 * j, b_dx, b_dy,                                                          cur->u + 8 * j * edged_width / 2 + 8 * i,
344                                                            interpolate8x8_switch2(f_refv->u, b_ref->u, 8 * i, 8 * j,
345                                                                                                            b_dx, b_dy, edged_width / 2, 0),
346    
347                                                            edged_width / 2);                                                            edged_width / 2);
348                  compensate8x8_halfpel(&dct_codes[5 * 64], cur->v, b_ref->v, b_refh->v,  
349                                                            b_refv->v, b_refhv->v, 8 * i, 8 * j, b_dx, b_dy,                  transfer_8to16sub(&dct_codes[5 * 64],
350                                                            cur->v + 8 * j * edged_width / 2 + 8 * i,
351                                                            interpolate8x8_switch2(f_refv->u, b_ref->v, 8 * i, 8 * j,
352                                                                                                            b_dx, b_dy, edged_width / 2, 0),
353    
354                                                            edged_width / 2);                                                            edged_width / 2);
355    
356                  break;                  break;
357    
358    
359          case MODE_INTERPOLATE:          case MODE_INTERPOLATE:          /* _could_ use DIRECT, but would be overkill (no 4MV there) */
360            case MODE_DIRECT_NO4V:
361    
362                  dx = mb->mvs[0].x;                  dx = mb->mvs[0].x;
363                  dy = mb->mvs[0].y;                  dy = mb->mvs[0].y;
364    
365                  b_dx = mb->b_mvs[0].x;                  b_dx = mb->b_mvs[0].x;
366                  b_dy = mb->b_mvs[0].y;                  b_dy = mb->b_mvs[0].y;
367    
368                  transfer_8to16sub2_c(&dct_codes[0 * 64],                  for (k = 0; k < 4; k++) {
369                                                           cur->y + (i * 16) + (j * 16) * edged_width,                          transfer_8to16sub2(&dct_codes[k * 64],
370                                                            cur->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
371                                                           get_ref(f_ref->y, f_refh->y, f_refv->y,                                                           get_ref(f_ref->y, f_refh->y, f_refv->y,
372                                                                           f_refhv->y, 16 * i, 16 * j, 1, dx, dy,                                                                          f_refhv->y, 2*i + (k&1), 2*j + (k>>1), 8, dx, dy,
                                                                          edged_width), get_ref(b_ref->y, b_refh->y,  
                                                                                                                    b_refv->y,  
                                                                                                                    b_refhv->y, 16 * i,  
                                                                                                                    16 * j, 1, b_dx,  
                                                                                                                    b_dy, edged_width),  
                                                          edged_width);  
   
                 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,  
373                                                                                                                     edged_width),                                                                                                                     edged_width),
374                                                           edged_width);                                                          get_ref(b_ref->y, b_refh->y, b_refv->y,
375                                                                            b_refhv->y, 2*i + (k&1), 2 * j+(k>>1), 8, b_dx, b_dy,
                 transfer_8to16sub2_c(&dct_codes[2 * 64],  
                                                          cur->y + (i * 16) + (j * 16 + 8) * edged_width,  
                                                          get_ref(f_ref->y, f_refh->y, f_refv->y,  
                                                                          f_refhv->y, 16 * i, 16 * j + 8, 1, dx, dy,  
                                                                          edged_width), get_ref(b_ref->y, b_refh->y,  
                                                                                                                    b_refv->y,  
                                                                                                                    b_refhv->y, 16 * i,  
                                                                                                                    16 * j + 8, 1, b_dx,  
                                                                                                                    b_dy, edged_width),  
                                                          edged_width);  
   
                 transfer_8to16sub2_c(&dct_codes[3 * 64],  
                                                          cur->y + (i * 16 + 8) + (j * 16 +  
                                                                                                           8) * edged_width,  
                                                          get_ref(f_ref->y, f_refh->y, f_refv->y,  
                                                                          f_refhv->y, 16 * i + 8, 16 * j + 8, 1, dx,  
                                                                          dy, edged_width), get_ref(b_ref->y,  
                                                                                                                            b_refh->y,  
                                                                                                                            b_refv->y,  
                                                                                                                            b_refhv->y,  
                                                                                                                            16 * i + 8,  
                                                                                                                            16 * j + 8, 1,  
                                                                                                                            b_dx, b_dy,  
376                                                                                                                             edged_width),                                                                                                                             edged_width),
377                                                           edged_width);                                                           edged_width);
378                    }
379    
380                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;
381                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;
# Line 349  Line 383 
383                  b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;                  b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;
384                  b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;                  b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;
385    
386                  transfer_8to16sub2_c(&dct_codes[4 * 64],                  transfer_8to16sub2(&dct_codes[4 * 64],
387                                                           cur->u + (y * 8) * edged_width / 2 + (x * 8),                                                           cur->u + (y * 8) * edged_width / 2 + (x * 8),
388                                                           get_ref(f_ref->u, f_refh->u, f_refv->u,                                                          interpolate8x8_switch2(f_refv->u, b_ref->u, 8 * i, 8 * j,
389                                                                           f_refhv->u, 8 * i, 8 * j, 1, dx, dy,                                                                                                          b_dx, b_dy, edged_width / 2, 0),
390                                                                           edged_width / 2), get_ref(b_ref->u,                                                          interpolate8x8_switch2(f_refv->u + 8, f_ref->u, 8 * i, 8 * j,
391                                                                                                                             b_refh->u,                                                                                                          dx, dy, edged_width / 2, 0),
                                                                                                                            b_refv->u,  
                                                                                                                            b_refhv->u,  
                                                                                                                            8 * i, 8 * j, 1,  
                                                                                                                            b_dx, b_dy,  
                                                                                                                            edged_width /  
                                                                                                                            2),  
392                                                           edged_width / 2);                                                           edged_width / 2);
393    
394                  transfer_8to16sub2_c(&dct_codes[5 * 64],                  transfer_8to16sub2(&dct_codes[5 * 64],
395                                                           cur->v + (y * 8) * edged_width / 2 + (x * 8),                                                           cur->v + (y * 8) * edged_width / 2 + (x * 8),
396                                                           get_ref(f_ref->v, f_refh->v, f_refv->v,                                                          interpolate8x8_switch2(f_refv->u, b_ref->v, 8 * i, 8 * j,
397                                                                           f_refhv->v, 8 * i, 8 * j, 1, dx, dy,                                                                                                          b_dx, b_dy, edged_width / 2, 0),
398                                                                           edged_width / 2), get_ref(b_ref->v,                                                          interpolate8x8_switch2(f_refv->u + 8, f_ref->v, 8 * i, 8 * j,
399                                                                                                                             b_refh->v,                                                                                                          dx, dy, edged_width / 2, 0),
                                                                                                                            b_refv->v,  
                                                                                                                            b_refhv->v,  
                                                                                                                            8 * i, 8 * j, 1,  
                                                                                                                            b_dx, b_dy,  
                                                                                                                            edged_width /  
                                                                                                                            2),  
400                                                           edged_width / 2);                                                           edged_width / 2);
401    
402                  break;                  break;
403    
404          case MODE_DIRECT:          case MODE_DIRECT:
405                  // todo  
406                  break;                  for (k=0;k<4;k++)
407                    {
408                            dx = mb->mvs[k].x;
409                            dy = mb->mvs[k].y;
410    
411                            b_dx = mb->b_mvs[k].x;
412                            b_dy = mb->b_mvs[k].y;
413    
414    //              fprintf(stderr,"Direct Vector %d -- %d:%d    %d:%d\n",k,dx,dy,b_dx,b_dy);
415    
416                            transfer_8to16sub2(&dct_codes[k * 64],
417                                                            cur->y + (i*16 + (k&1)*8) + (j*16 + (k>>1)*8 ) * edged_width,
418                                                            get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
419                                                                            2*i + (k&1), 2*j + (k>>1), 8, dx, dy,
420                                                                            edged_width),
421                                                            get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
422                                                                            2*i + (k&1), 2*j + (k>>1), 8, b_dx, b_dy,
423                                                                            edged_width),
424                                                            edged_width);
425          }          }
426    
427                    sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x;
428                    dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
429    
430                    sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y;
431                    dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
432    
433    
434                    sum = mb->b_mvs[0].x + mb->b_mvs[1].x + mb->b_mvs[2].x + mb->b_mvs[3].x;
435                    b_dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
436    
437                    sum = mb->b_mvs[0].y + mb->b_mvs[1].y + mb->b_mvs[2].y + mb->b_mvs[3].y;
438                    b_dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
439    
440    /*              // for QPel don't forget to always do
441    
442                    if (quarterpel)
443                            sum /= 2;
444    */
445                    transfer_8to16sub2(&dct_codes[4 * 64],
446                                                            cur->u + (y * 8) * edged_width / 2 + (x * 8),
447                                                            interpolate8x8_switch2(f_refv->u, b_ref->u, 8 * i, 8 * j,
448                                                                                                            b_dx, b_dy, edged_width / 2, 0),
449                                                            interpolate8x8_switch2(f_refv->u + 8, f_ref->u, 8 * i, 8 * j, dx, dy,
450                                                              edged_width / 2, 0),
451                                                            edged_width / 2);
452    
453                    transfer_8to16sub2(&dct_codes[5 * 64],
454                                                            cur->v + (y * 8) * edged_width / 2 + (x * 8),
455                                                            interpolate8x8_switch2(f_refv->u, b_ref->v, 8 * i, 8 * j,
456                                                                                                            b_dx, b_dy, edged_width / 2, 0),
457                                                            interpolate8x8_switch2(f_refv->u + 8, f_ref->v, 8 * i, 8 * j,
458                                                                                                            dx, dy, edged_width / 2, 0),
459                                                            edged_width / 2);
460    
461    
462                    break;
463            }
464  }  }

Legend:
Removed from v.209  
changed lines
  Added in v.618

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