[svn] / branches / dev-api-4 / xvidcore / src / motion / motion_comp.c Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/src/motion/motion_comp.c

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

revision 152, Wed May 1 13:00:02 2002 UTC revision 341, Thu Jul 25 00:43:19 2002 UTC
# Line 10  Line 10 
10  #define ABS(X) (((X)>0)?(X):-(X))  #define ABS(X) (((X)>0)?(X):-(X))
11  #define SIGN(X) (((X)>0)?1:-1)  #define SIGN(X) (((X)>0)?1:-1)
12    
13  static __inline void compensate8x8_halfpel(  static __inline void
14                                  int16_t * const dct_codes,  compensate8x8_halfpel(int16_t * const dct_codes,
15                                  uint8_t * const cur,                                  uint8_t * const cur,
16                                  const uint8_t * const ref,                                  const uint8_t * const ref,
17                                  const uint8_t * const refh,                                  const uint8_t * const refh,
18                                  const uint8_t * const refv,                                  const uint8_t * const refv,
19                                  const uint8_t * const refhv,                                  const uint8_t * const refhv,
20                                  const uint32_t x, const uint32_t y,                                            const uint32_t x,
21                                  const int32_t dx,  const int dy,                                            const uint32_t y,
22                                              const int32_t dx,
23                                              const int dy,
24                                  const uint32_t stride)                                  const uint32_t stride)
25  {  {
26          int32_t ddx,ddy;          int32_t ddx,ddy;
# Line 29  Line 31 
31                  ddx = dx/2;                  ddx = dx/2;
32                  ddy = dy/2;                  ddy = dy/2;
33                  transfer_8to16sub(dct_codes, cur + y*stride + x,                  transfer_8to16sub(dct_codes, cur + y*stride + x,
34                                  ref + (y+ddy)*stride + x+ddx, stride);                                                    ref + (int) ((y + ddy) * stride + x + ddx), stride);
35                  break;                  break;
36    
37      case 1 :      case 1 :
38                  ddx = dx/2;                  ddx = dx/2;
39                  ddy = (dy-1)/2;                  ddy = (dy-1)/2;
40                  transfer_8to16sub(dct_codes, cur + y*stride + x,                  transfer_8to16sub(dct_codes, cur + y*stride + x,
41                                  refv + (y+ddy)*stride + x+ddx, stride);                                                    refv + (int) ((y + ddy) * stride + x + ddx), stride);
42                  break;                  break;
43    
44      case 2 :      case 2 :
45                  ddx = (dx-1)/2;                  ddx = (dx-1)/2;
46                  ddy = dy/2;                  ddy = dy/2;
47                  transfer_8to16sub(dct_codes, cur + y*stride + x,                  transfer_8to16sub(dct_codes, cur + y*stride + x,
48                                  refh + (y+ddy)*stride + x+ddx, stride);                                                    refh + (int) ((y + ddy) * stride + x + ddx), stride);
49                  break;                  break;
50    
51          default :       // case 3:          default :       // case 3:
52                  ddx = (dx-1)/2;                  ddx = (dx-1)/2;
53                  ddy = (dy-1)/2;                  ddy = (dy-1)/2;
54                  transfer_8to16sub(dct_codes, cur + y*stride + x,                  transfer_8to16sub(dct_codes, cur + y*stride + x,
55                                  refhv + (y+ddy)*stride + x+ddx, stride);                                                    refhv + (int) ((y + ddy) * stride + x + ddx), stride);
56                  break;                  break;
57      }      }
58  }  }
59    
60    
61    
62  void MBMotionCompensation(  void
63          MACROBLOCK * const mb,  MBMotionCompensation(MACROBLOCK * const mb,
64          const uint32_t i,          const uint32_t i,
65          const uint32_t j,          const uint32_t j,
66          const IMAGE * const ref,          const IMAGE * const ref,
# Line 76  Line 78 
78                  { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 };                  { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 };
79    
80    
81          if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q)          if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) {
         {  
82                  int32_t dx = mb->mvs[0].x;                  int32_t dx = mb->mvs[0].x;
83                  int32_t dy = mb->mvs[0].y;                  int32_t dy = mb->mvs[0].y;
84    
85                  compensate8x8_halfpel(&dct_codes[0*64], cur->y, ref->y, refh->y, refv->y, refhv->y,                  compensate8x8_halfpel(&dct_codes[0 * 64], cur->y, ref->y, refh->y,
86                                        16*i,     16*j,     dx, dy, edged_width);                                                            refv->y, refhv->y, 16 * i, 16 * j, dx, dy,
87                  compensate8x8_halfpel(&dct_codes[1*64], cur->y, ref->y, refh->y, refv->y, refhv->y,                                                            edged_width);
88                                        16*i + 8, 16*j,     dx, dy, edged_width);                  compensate8x8_halfpel(&dct_codes[1 * 64], cur->y, ref->y, refh->y,
89                  compensate8x8_halfpel(&dct_codes[2*64], cur->y, ref->y, refh->y, refv->y, refhv->y,                                                            refv->y, refhv->y, 16 * i + 8, 16 * j, dx, dy,
90                                        16*i,     16*j + 8, dx, dy, edged_width);                                                            edged_width);
91                  compensate8x8_halfpel(&dct_codes[3*64], cur->y, ref->y, refh->y, refv->y, refhv->y,                  compensate8x8_halfpel(&dct_codes[2 * 64], cur->y, ref->y, refh->y,
92                                        16*i + 8, 16*j + 8, dx, dy, edged_width);                                                            refv->y, refhv->y, 16 * i, 16 * j + 8, dx, dy,
93                                                              edged_width);
94                    compensate8x8_halfpel(&dct_codes[3 * 64], cur->y, ref->y, refh->y,
95                                                              refv->y, refhv->y, 16 * i + 8, 16 * j + 8, dx,
96                                                              dy, edged_width);
97    
98                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;
99                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;
100    
101                  /* uv-image-based compensation */                  /* uv-image-based compensation */
102  #ifdef BFRAMES  #ifdef BFRAMES
103                     compensate8x8_halfpel(&dct_codes[4*64], cur->u, ref->u, refh->u, refv->u, refhv->u,                  compensate8x8_halfpel(&dct_codes[4 * 64], cur->u, ref->u, refh->u,
104                     8*i, 8*j, dx, dy, edged_width/2);                                                            refv->u, refhv->u, 8 * i, 8 * j, dx, dy,
105                     compensate8x8_halfpel(&dct_codes[5*64], cur->v, ref->v, refh->v, refv->v, refhv->v,                                                            edged_width / 2);
106                     8*i, 8*j, dx, dy, edged_width/2);                  compensate8x8_halfpel(&dct_codes[5 * 64], cur->v, ref->v, refh->v,
107                                                              refv->v, refhv->v, 8 * i, 8 * j, dx, dy,
108                                                              edged_width / 2);
109  #else  #else
110                  /* uv-block-based compensation */                  /* uv-block-based compensation */
111                  interpolate8x8_switch(refv->u, ref->u, 8*i, 8*j, dx, dy, edged_width/2, rounding);                  interpolate8x8_switch(refv->u, ref->u, 8 * i, 8 * j, dx, dy,
112                                                              edged_width / 2, rounding);
113                  transfer_8to16sub(&dct_codes[4*64],                  transfer_8to16sub(&dct_codes[4*64],
114                                    cur->u + 8*j*edged_width/2 + 8*i,                                    cur->u + 8*j*edged_width/2 + 8*i,
115                                    refv->u + 8*j*edged_width/2 + 8*i, edged_width/2);                                                    refv->u + 8 * j * edged_width / 2 + 8 * i,
116                                                      edged_width / 2);
117    
118                  interpolate8x8_switch(refv->v, ref->v, 8*i, 8*j, dx, dy, edged_width/2, rounding);                  interpolate8x8_switch(refv->v, ref->v, 8 * i, 8 * j, dx, dy,
119                                                              edged_width / 2, rounding);
120                  transfer_8to16sub(&dct_codes[5*64],                  transfer_8to16sub(&dct_codes[5*64],
121                                    cur->v + 8*j*edged_width/2 + 8*i,                                    cur->v + 8*j*edged_width/2 + 8*i,
122                                    refv->v + 8*j*edged_width/2 + 8*i, edged_width/2);                                                    refv->v + 8 * j * edged_width / 2 + 8 * i,
123                                                      edged_width / 2);
124  #endif  #endif
125          }          } else                                          // mode == MODE_INTER4V
         else    // mode == MODE_INTER4V  
126          {          {
127                  int32_t sum, dx, dy;                  int32_t sum, dx, dy;
128    
129                  compensate8x8_halfpel(&dct_codes[0*64], cur->y, ref->y, refh->y, refv->y, refhv->y,                  compensate8x8_halfpel(&dct_codes[0 * 64], cur->y, ref->y, refh->y,
130                                        16*i,     16*j,     mb->mvs[0].x, mb->mvs[0].y, edged_width);                                                            refv->y, refhv->y, 16 * i, 16 * j, mb->mvs[0].x,
131                  compensate8x8_halfpel(&dct_codes[1*64], cur->y, ref->y, refh->y, refv->y, refhv->y,                                                            mb->mvs[0].y, edged_width);
132                                        16*i + 8, 16*j,     mb->mvs[1].x, mb->mvs[1].y, edged_width);                  compensate8x8_halfpel(&dct_codes[1 * 64], cur->y, ref->y, refh->y,
133                  compensate8x8_halfpel(&dct_codes[2*64], cur->y, ref->y, refh->y, refv->y, refhv->y,                                                            refv->y, refhv->y, 16 * i + 8, 16 * j,
134                                        16*i,     16*j + 8, mb->mvs[2].x, mb->mvs[2].y, edged_width);                                                            mb->mvs[1].x, mb->mvs[1].y, edged_width);
135                  compensate8x8_halfpel(&dct_codes[3*64], cur->y, ref->y, refh->y, refv->y, refhv->y,                  compensate8x8_halfpel(&dct_codes[2 * 64], cur->y, ref->y, refh->y,
136                                        16*i + 8, 16*j + 8, mb->mvs[3].x, mb->mvs[3].y, edged_width);                                                            refv->y, refhv->y, 16 * i, 16 * j + 8,
137                                                              mb->mvs[2].x, mb->mvs[2].y, edged_width);
138                    compensate8x8_halfpel(&dct_codes[3 * 64], cur->y, ref->y, refh->y,
139                                                              refv->y, refhv->y, 16 * i + 8, 16 * j + 8,
140                                                              mb->mvs[3].x, mb->mvs[3].y, edged_width);
141    
142                  sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x;                  sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x;
143                  dx = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);                  dx = (sum ? SIGN(sum) *
144                              (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);
145    
146                  sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y;                  sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y;
147                  dy = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);                  dy = (sum ? SIGN(sum) *
148                              (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);
149    
150                  /* uv-image-based compensation */                  /* uv-image-based compensation */
151  #ifdef BFRAMES  #ifdef BFRAMES
152                     compensate8x8_halfpel(&dct_codes[4*64], cur->u, ref->u, refh->u, refv->u, refhv->u,                  compensate8x8_halfpel(&dct_codes[4 * 64], cur->u, ref->u, refh->u,
153                     8*i, 8*j, dx, dy, edged_width/2);                                                            refv->u, refhv->u, 8 * i, 8 * j, dx, dy,
154                     compensate8x8_halfpel(&dct_codes[5*64], cur->v, ref->v, refh->v, refv->v, refhv->v,                                                            edged_width / 2);
155                     8*i, 8*j, dx, dy, edged_width/2);                  compensate8x8_halfpel(&dct_codes[5 * 64], cur->v, ref->v, refh->v,
156                                                              refv->v, refhv->v, 8 * i, 8 * j, dx, dy,
157                                                              edged_width / 2);
158  #else  #else
159                  /* uv-block-based compensation */                  /* uv-block-based compensation */
160                  interpolate8x8_switch(refv->u, ref->u, 8*i, 8*j, dx, dy, edged_width/2, rounding);                  interpolate8x8_switch(refv->u, ref->u, 8 * i, 8 * j, dx, dy,
161                                                              edged_width / 2, rounding);
162                  transfer_8to16sub(&dct_codes[4*64],                  transfer_8to16sub(&dct_codes[4*64],
163                                    cur->u + 8*j*edged_width/2 + 8*i,                                    cur->u + 8*j*edged_width/2 + 8*i,
164                                    refv->u + 8*j*edged_width/2 + 8*i, edged_width/2);                                                    refv->u + 8 * j * edged_width / 2 + 8 * i,
165                                                      edged_width / 2);
166    
167                  interpolate8x8_switch(refv->v, ref->v, 8*i, 8*j, dx, dy, edged_width/2, rounding);                  interpolate8x8_switch(refv->v, ref->v, 8 * i, 8 * j, dx, dy,
168                                                              edged_width / 2, rounding);
169                  transfer_8to16sub(&dct_codes[5*64],                  transfer_8to16sub(&dct_codes[5*64],
170                                    cur->v + 8*j*edged_width/2 + 8*i,                                    cur->v + 8*j*edged_width/2 + 8*i,
171                                    refv->v + 8*j*edged_width/2 + 8*i, edged_width/2);                                                    refv->v + 8 * j * edged_width / 2 + 8 * i,
172                                                      edged_width / 2);
173  #endif  #endif
174          }          }
175  }  }
176    
177    
178  void MBMotionCompensationBVOP(  void
179                          MBParam * pParam,  MBMotionCompensationBVOP(MBParam * pParam,
180                          MACROBLOCK * const mb,                          MACROBLOCK * const mb,
181                      const uint32_t i,                      const uint32_t i,
182                          const uint32_t j,                          const uint32_t j,
# Line 175  Line 197 
197          const int32_t edged_width = pParam->edged_width;          const int32_t edged_width = pParam->edged_width;
198          int32_t dx, dy;          int32_t dx, dy;
199          int32_t b_dx, b_dy;          int32_t b_dx, b_dy;
200            int k,sum;
201          int x = i;          int x = i;
202          int y = j;          int y = j;
203    
204    
205            switch (mb->mode) {
         switch(mb->mode)  
         {  
206          case MODE_FORWARD :          case MODE_FORWARD :
207                  dx = mb->mvs[0].x;                  dx = mb->mvs[0].x;
208                  dy = mb->mvs[0].y;                  dy = mb->mvs[0].y;
209    
210                  transfer_8to16sub_c(                  transfer_8to16sub_c(&dct_codes[0 * 64],
                         &dct_codes[0*64],  
211                          cur->y + (j*16)*edged_width + (i*16),                          cur->y + (j*16)*edged_width + (i*16),
212                          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,
213                                                          i*16, j*16, 1, dx, dy, edged_width),                                                          i*16, j*16, 1, dx, dy, edged_width),
214                          edged_width);                          edged_width);
215    
216                  transfer_8to16sub(                  transfer_8to16sub(&dct_codes[1 * 64],
                         &dct_codes[1*64],  
217                          cur->y + (j*16)*edged_width + (i*16+8),                          cur->y + (j*16)*edged_width + (i*16+8),
218                          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,
219                                                          i*16+8, j*16, 1, dx, dy, edged_width),                                                          i*16+8, j*16, 1, dx, dy, edged_width),
220                          edged_width);                          edged_width);
221    
222                  transfer_8to16sub_c(                  transfer_8to16sub_c(&dct_codes[2 * 64],
                         &dct_codes[2*64],  
223                          cur->y + (j*16+8)*edged_width + (i*16),                          cur->y + (j*16+8)*edged_width + (i*16),
224                          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,
225                                                          i*16, j*16+8, 1, dx, dy, edged_width),                                                                          i * 16, j * 16 + 8, 1, dx, dy,
226                          edged_width);                                                                          edged_width), edged_width);
227    
228                  transfer_8to16sub(                  transfer_8to16sub(&dct_codes[3 * 64],
                         &dct_codes[3*64],  
229                          cur->y + (j*16+8)*edged_width + (i*16+8),                          cur->y + (j*16+8)*edged_width + (i*16+8),
230                          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,
231                                                          i*16+8, j*16+8, 1, dx, dy, edged_width),                                                                    i * 16 + 8, j * 16 + 8, 1, dx, dy,
232                          edged_width);                                                                    edged_width), edged_width);
233    
234    
235                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;
236                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;
237    
238                  /* uv-image-based compensation */                  /* uv-image-based compensation */
239                  compensate8x8_halfpel(&dct_codes[4*64], cur->u, f_ref->u, f_refh->u, f_refv->u, f_refhv->u,                  compensate8x8_halfpel(&dct_codes[4 * 64], cur->u, f_ref->u, f_refh->u,
240                                                                  8*i, 8*j, dx, dy, edged_width/2);                                                            f_refv->u, f_refhv->u, 8 * i, 8 * j, dx, dy,
241                  compensate8x8_halfpel(&dct_codes[5*64], cur->v, f_ref->v, f_refh->v, f_refv->v, f_refhv->v,                                                            edged_width / 2);
242                                                                  8*i, 8*j, dx, dy, edged_width/2);                  compensate8x8_halfpel(&dct_codes[5 * 64], cur->v, f_ref->v, f_refh->v,
243                                                              f_refv->v, f_refhv->v, 8 * i, 8 * j, dx, dy,
244                                                              edged_width / 2);
245    
246                  break;                  break;
247    
# Line 230  Line 249 
249                  b_dx = mb->b_mvs[0].x;                  b_dx = mb->b_mvs[0].x;
250                  b_dy = mb->b_mvs[0].y;                  b_dy = mb->b_mvs[0].y;
251    
252                  transfer_8to16sub_c(                  transfer_8to16sub_c(&dct_codes[0 * 64],
                         &dct_codes[0*64],  
253                          cur->y + (j*16)*edged_width + (i*16),                          cur->y + (j*16)*edged_width + (i*16),
254                          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,
255                                                          i*16, j*16, 1, b_dx, b_dy, edged_width),                                                                          i * 16, j * 16, 1, b_dx, b_dy,
256                          edged_width);                                                                          edged_width), edged_width);
257    
258                  transfer_8to16sub(                  transfer_8to16sub(&dct_codes[1 * 64],
                         &dct_codes[1*64],  
259                          cur->y + (j*16)*edged_width + (i*16+8),                          cur->y + (j*16)*edged_width + (i*16+8),
260                          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,
261                                                          i*16+8, j*16, 1, b_dx, b_dy, edged_width),                                                                    i * 16 + 8, j * 16, 1, b_dx, b_dy,
262                          edged_width);                                                                    edged_width), edged_width);
263    
264                  transfer_8to16sub_c(                  transfer_8to16sub_c(&dct_codes[2 * 64],
                         &dct_codes[2*64],  
265                          cur->y + (j*16+8)*edged_width + (i*16),                          cur->y + (j*16+8)*edged_width + (i*16),
266                          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,
267                                                          i*16, j*16+8, 1, b_dx, b_dy, edged_width),                                                                          i * 16, j * 16 + 8, 1, b_dx, b_dy,
268                          edged_width);                                                                          edged_width), edged_width);
269    
270                  transfer_8to16sub(                  transfer_8to16sub(&dct_codes[3 * 64],
                         &dct_codes[3*64],  
271                          cur->y + (j*16+8)*edged_width + (i*16+8),                          cur->y + (j*16+8)*edged_width + (i*16+8),
272                          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,
273                                                          i*16+8, j*16+8, 1, b_dx, b_dy, edged_width),                                                                    i * 16 + 8, j * 16 + 8, 1, b_dx, b_dy,
274                          edged_width);                                                                    edged_width), edged_width);
275    
276                  b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;                  b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;
277                  b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;                  b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;
278    
279                  /* uv-image-based compensation */                  /* uv-image-based compensation */
280                  compensate8x8_halfpel(&dct_codes[4*64], cur->u,                  compensate8x8_halfpel(&dct_codes[4 * 64], cur->u, b_ref->u, b_refh->u,
281                                          b_ref->u, b_refh->u, b_refv->u, b_refhv->u,                                                            b_refv->u, b_refhv->u, 8 * i, 8 * j, b_dx, b_dy,
282                                          8*i, 8*j, b_dx, b_dy, edged_width/2);                                                            edged_width / 2);
283                  compensate8x8_halfpel(&dct_codes[5*64], cur->v,                  compensate8x8_halfpel(&dct_codes[5 * 64], cur->v, b_ref->v, b_refh->v,
284                                          b_ref->v, b_refh->v, b_refv->v, b_refhv->v,                                                            b_refv->v, b_refhv->v, 8 * i, 8 * j, b_dx, b_dy,
285                                          8*i, 8*j, b_dx, b_dy, edged_width/2);                                                            edged_width / 2);
286    
287                  break;                  break;
288    
289    
290          case MODE_INTERPOLATE :          case MODE_INTERPOLATE:          /* _could_ use DIRECT, but would be overkill (no 4MV there) */
291    
292                  dx = mb->mvs[0].x;                  dx = mb->mvs[0].x;
293                  dy = mb->mvs[0].y;                  dy = mb->mvs[0].y;
294    
295                  b_dx = mb->b_mvs[0].x;                  b_dx = mb->b_mvs[0].x;
296                  b_dy = mb->b_mvs[0].y;                  b_dy = mb->b_mvs[0].y;
297    
298                  transfer_8to16sub2_c(                  for (k=0;k<4;k++)
299                                  &dct_codes[0*64],                  {
300                                  cur->y + (i*16) + (j*16)*edged_width,                          transfer_8to16sub2_c(&dct_codes[k * 64],
301                                  get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,                                                           cur->y + (i * 16+(k&1)*8) + (j * 16+((k>>1)*8)) * edged_width,
302                                                          16*i, 16*j, 1, dx, dy, edged_width),                                                           get_ref(f_ref->y, f_refh->y, f_refv->y,
303                                  get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,                                                                           f_refhv->y, 2*i + (k&1), 2*j + (k>>1), 8, dx, dy,
304                                                          16*i, 16*j, 1, b_dx, b_dy, edged_width),                                                                           edged_width),
305                                                             get_ref(b_ref->y, b_refh->y, b_refv->y,
306                                                                             b_refhv->y, 2*i + (k&1), 2 * j+(k>>1), 8, b_dx, b_dy,
307                                                                             edged_width),
308                                  edged_width);                                  edged_width);
309                    }
310    
311                  transfer_8to16sub2_c(                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;
312                                  &dct_codes[1*64],                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;
                                 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);  
313    
314                  transfer_8to16sub2_c(                  b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;
315                                  &dct_codes[2*64],                  b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;
316                                  cur->y + (i*16) + (j*16+8)*edged_width,  
317                                  get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,                  transfer_8to16sub2_c(&dct_codes[4 * 64],
318                                                          16*i, 16*j+8, 1, dx, dy, edged_width),                                                           cur->u + (y * 8) * edged_width / 2 + (x * 8),
319                                  get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,                                                           get_ref(f_ref->u, f_refh->u, f_refv->u,
320                                                          16*i, 16*j+8, 1, b_dx, b_dy, edged_width),                                                                           f_refhv->u, i, j, 8, dx, dy,
321                                  edged_width);                                                                           edged_width / 2),
322                                                             get_ref(b_ref->u, b_refh->u, b_refv->u,
323                                                                             b_refhv->u, i, j, 8, b_dx, b_dy,
324                                                                             edged_width / 2),
325                                                             edged_width / 2);
326    
327                  transfer_8to16sub2_c(                  transfer_8to16sub2_c(&dct_codes[5 * 64],
328                                  &dct_codes[3*64],                                                           cur->v + (y * 8) * edged_width / 2 + (x * 8),
329                                  cur->y + (i*16+8) + (j*16+8)*edged_width,                                                           get_ref(f_ref->v, f_refh->v, f_refv->v,
330                                                                             f_refhv->v, 8 * i, 8 * j, 1, dx, dy,
331                                                                             edged_width / 2),
332                                                             get_ref(b_ref->v, b_refh->v, b_refv->v,
333                                                                             b_refhv->v, 8 * i, 8 * j, 1, b_dx, b_dy,
334                                                                             edged_width / 2),
335                                                             edged_width / 2);
336    
337                    break;
338    
339            case MODE_DIRECT:
340    
341                    for (k=0;k<4;k++)
342                    {
343                            dx = mb->mvs[k].x;
344                            dy = mb->mvs[k].y;
345    
346                            b_dx = mb->b_mvs[k].x;
347                            b_dy = mb->b_mvs[k].y;
348    
349    //              fprintf(stderr,"Direct Vector %d -- %d:%d    %d:%d\n",k,dx,dy,b_dx,b_dy);
350    
351                            transfer_8to16sub2_c(&dct_codes[k * 64],
352                                                             cur->y + (i*16 + (k&1)*8) + (j*16 + (k>>1)*8 ) * edged_width,
353                                  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,
354                                                          16*i + 8, 16*j + 8, 1, dx, dy, edged_width),                                                                           2*i + (k&1), 2*j + (k>>1), 8, dx, dy,
355                                                                             edged_width),
356                                  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,
357                                                          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,
358                                                                             edged_width),
359                                  edged_width);                                  edged_width);
360                    }
361    
362                    sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x;
363                    dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
364    
365                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;                  sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y;
366                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;                  dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
367    
                 b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;  
                 b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;  
368    
369                  transfer_8to16sub2_c(                  sum = mb->b_mvs[0].x + mb->b_mvs[1].x + mb->b_mvs[2].x + mb->b_mvs[3].x;
370                                  &dct_codes[4*64],                  b_dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
371    
372                    sum = mb->b_mvs[0].y + mb->b_mvs[1].y + mb->b_mvs[2].y + mb->b_mvs[3].y;
373                    b_dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
374    
375    /*              // for QPel don't forget to always do
376    
377                    if (quarterpel)
378                            sum /= 2;
379    */
380    
381                    transfer_8to16sub2_c(&dct_codes[4 * 64],
382                                  cur->u + (y*8)*edged_width/2 + (x*8),                                  cur->u + (y*8)*edged_width/2 + (x*8),
383                                  get_ref(f_ref->u, f_refh->u, f_refv->u, f_refhv->u,                                                           get_ref(f_ref->u, f_refh->u, f_refv->u,
384                                                          8*i, 8*j, 1, dx, dy, edged_width/2),                                                                           f_refhv->u, i, j, 8, dx, dy,
385                                  get_ref(b_ref->u, b_refh->u, b_refv->u, b_refhv->u,                                                                           edged_width / 2),
386                                                          8*i, 8*j, 1, b_dx, b_dy, edged_width/2),                                                           get_ref(b_ref->u, b_refh->u, b_refv->u,
387                                                                             b_refhv->u, i, j, 8, b_dx, b_dy,
388                                                                             edged_width / 2),
389                                  edged_width/2);                                  edged_width/2);
390    
391                  transfer_8to16sub2_c(                  transfer_8to16sub2_c(&dct_codes[5 * 64],
                                 &dct_codes[5*64],  
392                                  cur->v + (y*8)*edged_width/2 + (x*8),                                  cur->v + (y*8)*edged_width/2 + (x*8),
393                                  get_ref(f_ref->v, f_refh->v, f_refv->v, f_refhv->v,                                                           get_ref(f_ref->v, f_refh->v, f_refv->v,
394                                                          8*i, 8*j, 1, dx, dy, edged_width/2),                                                                           f_refhv->v, i, j, 8, dx, dy,
395                                  get_ref(b_ref->v, b_refh->v, b_refv->v, b_refhv->v,                                                                           edged_width / 2),
396                                                          8*i, 8*j, 1, b_dx, b_dy, edged_width/2),                                                           get_ref(b_ref->v, b_refh->v, b_refv->v,
397                                                                             b_refhv->v, i, j, 8, b_dx, b_dy,
398                                                                             edged_width / 2),
399                                  edged_width/2);                                  edged_width/2);
400    
                 break;  
401    
         case MODE_DIRECT :  
                 // todo  
402                  break;                  break;
403          }          }
   
404  }  }

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

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