[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 118, Sat Apr 13 16:30:02 2002 UTC branches/dev-api-3/xvidcore/src/motion/motion_comp.c revision 449, Sun Sep 8 09:49:55 2002 UTC
# Line 1  Line 1 
1    // 01.05.2002   updated MBMotionCompensationBVOP
2  // 14.04.2002   bframe compensation  // 14.04.2002   bframe compensation
3    
4  #include "../encoder.h"  #include "../encoder.h"
# Line 9  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 28  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 75  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                  /* u,v-image-based compensation
102                     compensate8x8_halfpel(dct_codes[4], cur->u, ref->u, refh->u, refv->u, refhv->u,                  compensate8x8_halfpel(&dct_codes[4 * 64], cur->u, ref->u, refh->u,
103                     8*i, 8*j, dx, dy, edged_width/2);                                                            refv->u, refhv->u, 8 * i, 8 * j, dx, dy,
104                     compensate8x8_halfpel(dct_codes[5], cur->v, ref->v, refh->v, refv->v, refhv->v,                                                            edged_width / 2);
105                     8*i, 8*j, dx, dy, edged_width/2);            */                  compensate8x8_halfpel(&dct_codes[5 * 64], cur->v, ref->v, refh->v,
106                                                              refv->v, refhv->v, 8 * i, 8 * j, dx, dy,
107                                                              edged_width / 2);
108                    */
109    
110                  /* uv-block-based compensation */  
111                  interpolate8x8_switch(refv->u, ref->u, 8*i, 8*j, dx, dy, edged_width/2, rounding);                  /* --- u,v-block-based interpolation & compensation --- */
112    
113                    interpolate8x8_switch(refv->u, ref->u, 8 * i, 8 * j, dx, dy,
114                                                              edged_width / 2, rounding);
115                  transfer_8to16sub(&dct_codes[4*64],                  transfer_8to16sub(&dct_codes[4*64],
116                                    cur->u + 8*j*edged_width/2 + 8*i,                                    cur->u + 8*j*edged_width/2 + 8*i,
117                                    refv->u + 8*j*edged_width/2 + 8*i, edged_width/2);                                                    refv->u + 8 * j * edged_width / 2 + 8 * i,
118                                                      edged_width / 2);
119    
120                  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,
121                                                              edged_width / 2, rounding);
122                  transfer_8to16sub(&dct_codes[5*64],                  transfer_8to16sub(&dct_codes[5*64],
123                                    cur->v + 8*j*edged_width/2 + 8*i,                                    cur->v + 8*j*edged_width/2 + 8*i,
124                                    refv->v + 8*j*edged_width/2 + 8*i, edged_width/2);                                                    refv->v + 8 * j * edged_width / 2 + 8 * i,
125                                                      edged_width / 2);
126                    /* */
127    
128          }          } else                                          // mode == MODE_INTER4V
         else    // mode == MODE_INTER4V  
129          {          {
130                  int32_t sum, dx, dy;                  int32_t sum, dx, dy;
131    
132                  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,
133                                        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,
134                  compensate8x8_halfpel(&dct_codes[1*64], cur->y, ref->y, refh->y, refv->y, refhv->y,                                                            mb->mvs[0].y, edged_width);
135                                        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,
136                  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,
137                                        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);
138                  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,
139                                        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,
140                                                              mb->mvs[2].x, mb->mvs[2].y, edged_width);
141                    compensate8x8_halfpel(&dct_codes[3 * 64], cur->y, ref->y, refh->y,
142                                                              refv->y, refhv->y, 16 * i + 8, 16 * j + 8,
143                                                              mb->mvs[3].x, mb->mvs[3].y, edged_width);
144    
145                  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;
146                  dx = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);                  dx = (sum ? SIGN(sum) *
147                              (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);
148    
149                  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;
150                  dy = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);                  dy = (sum ? SIGN(sum) *
151                              (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);
152    
153                  /* uv-image-based compensation                  /* --- uv-image-based compensation -- -
154                     compensate8x8_halfpel(dct_codes[4], cur->u, ref->u, refh->u, refv->u, refhv->u,                  compensate8x8_halfpel(&dct_codes[4 * 64], cur->u, ref->u, refh->u,
155                     8*i, 8*j, dx, dy, edged_width/2);                                                            refv->u, refhv->u, 8 * i, 8 * j, dx, dy,
156                     compensate8x8_halfpel(dct_codes[5], cur->v, ref->v, refh->v, refv->v, refhv->v,                                                            edged_width / 2);
157                     8*i, 8*j, dx, dy, edged_width/2);            */                  compensate8x8_halfpel(&dct_codes[5 * 64], cur->v, ref->v, refh->v,
158                                                              refv->v, refhv->v, 8 * i, 8 * j, dx, dy,
159                                                              edged_width / 2);
160                    */
161    
162                    /* --- uv-block-based compensation ---
163                    WARNING: these ditry the refv->u and refv->v images   */
164    
165                  /* uv-block-based compensation */                  interpolate8x8_switch(refv->u, ref->u, 8 * i, 8 * j, dx, dy,
166                  interpolate8x8_switch(refv->u, ref->u, 8*i, 8*j, dx, dy, edged_width/2, rounding);                                                            edged_width / 2, rounding);
167                  transfer_8to16sub(&dct_codes[4*64],                  transfer_8to16sub(&dct_codes[4*64],
168                                    cur->u + 8*j*edged_width/2 + 8*i,                                    cur->u + 8*j*edged_width/2 + 8*i,
169                                    refv->u + 8*j*edged_width/2 + 8*i, edged_width/2);                                                    refv->u + 8 * j * edged_width / 2 + 8 * i,
170                                                      edged_width / 2);
171    
172                  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,
173                                                              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, edged_width/2);                                                    refv->v + 8 * j * edged_width / 2 + 8 * i,
177                                                      edged_width / 2);
178                    /* */
179          }          }
180  }  }
181    
182    
183    void
184  void MBMotionCompensationBVOP(  MBMotionCompensationBVOP(MBParam * pParam,
                         MBParam * pParam,  
185                          MACROBLOCK * const mb,                          MACROBLOCK * const mb,
186                      const uint32_t i,                      const uint32_t i,
187                          const uint32_t j,                          const uint32_t j,
# Line 165  Line 194 
194                          const IMAGE * const b_refh,                          const IMAGE * const b_refh,
195                      const IMAGE * const b_refv,                      const IMAGE * const b_refv,
196                          const IMAGE * const b_refhv,                          const IMAGE * const b_refhv,
197                      int16_t dct_codes[][64])                                                   int16_t * dct_codes)
198  {  {
199          static const uint32_t roundtab[16] =          static const uint32_t roundtab[16] =
200                  { 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 };
# Line 173  Line 202 
202          const int32_t edged_width = pParam->edged_width;          const int32_t edged_width = pParam->edged_width;
203          int32_t dx, dy;          int32_t dx, dy;
204          int32_t b_dx, b_dy;          int32_t b_dx, b_dy;
205            int k,sum;
206          int x = i;          int x = i;
207          int y = j;          int y = j;
208    
209    
210            switch (mb->mode) {
         switch(mb->mode)  
         {  
211          case MODE_FORWARD :          case MODE_FORWARD :
212                  dx = mb->mvs[0].x;                  dx = mb->mvs[0].x;
213                  dy = mb->mvs[0].y;                  dy = mb->mvs[0].y;
214    
215                  transfer_8to16sub_c(                  transfer_8to16sub_c(&dct_codes[0 * 64],
                         dct_codes[0],  
216                          cur->y + (j*16)*edged_width + (i*16),                          cur->y + (j*16)*edged_width + (i*16),
217                          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,
218                                                          i*16, j*16, 1, dx, dy, edged_width),                                                          i*16, j*16, 1, dx, dy, edged_width),
219                          edged_width);                          edged_width);
220    
221                  transfer_8to16sub(                  transfer_8to16sub(&dct_codes[1 * 64],
                         dct_codes[1],  
222                          cur->y + (j*16)*edged_width + (i*16+8),                          cur->y + (j*16)*edged_width + (i*16+8),
223                          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,
224                                                          i*16+8, j*16, 1, dx, dy, edged_width),                                                          i*16+8, j*16, 1, dx, dy, edged_width),
225                          edged_width);                          edged_width);
226    
227                  transfer_8to16sub_c(                  transfer_8to16sub_c(&dct_codes[2 * 64],
                         dct_codes[2],  
228                          cur->y + (j*16+8)*edged_width + (i*16),                          cur->y + (j*16+8)*edged_width + (i*16),
229                          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,
230                                                          i*16, j*16+8, 1, dx, dy, edged_width),                                                                          i * 16, j * 16 + 8, 1, dx, dy,
231                          edged_width);                                                                          edged_width), edged_width);
232    
233                  transfer_8to16sub(                  transfer_8to16sub(&dct_codes[3 * 64],
                         dct_codes[3],  
234                          cur->y + (j*16+8)*edged_width + (i*16+8),                          cur->y + (j*16+8)*edged_width + (i*16+8),
235                          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,
236                                                          i*16+8, j*16+8, 1, dx, dy, edged_width),                                                                    i * 16 + 8, j * 16 + 8, 1, dx, dy,
237                          edged_width);                                                                    edged_width), edged_width);
238    
239    
240                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;
241                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;
242    
243                  /* uv-image-based compensation */                  /* --- uv-image-based compensation ---
244                  compensate8x8_halfpel(dct_codes[4], 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,
245                                                                  8*i, 8*j, dx, dy, edged_width/2);                                                            f_refv->u, f_refhv->u, 8 * i, 8 * j, dx, dy,
246                  compensate8x8_halfpel(dct_codes[5], cur->v, f_ref->v, f_refh->v, f_refv->v, f_refhv->v,                                                            edged_width / 2);
247                                                                  8*i, 8*j, dx, dy, edged_width/2);                  compensate8x8_halfpel(&dct_codes[5 * 64], cur->v, f_ref->v, f_refh->v,
248                                                              f_refv->v, f_refhv->v, 8 * i, 8 * j, dx, dy,
249                                                              edged_width / 2);
250                    */
251    
252                    /* --- u,v-block-based interpolation & compensation --- */
253                    interpolate8x8_switch(f_refv->u, f_ref->u, 8 * i, 8 * j, dx, dy,
254                                                              edged_width / 2, 0);
255                    transfer_8to16sub(&dct_codes[4 * 64],
256                                                      cur->u + 8 * j * edged_width / 2 + 8 * i,
257                                                      f_refv->u + 8 * j * edged_width / 2 + 8 * i,
258                                                      edged_width / 2);
259    
260                    interpolate8x8_switch(f_refv->v, f_ref->v, 8 * i, 8 * j, dx, dy,
261                                                              edged_width / 2, 0);
262                    transfer_8to16sub(&dct_codes[5 * 64],
263                                                      cur->v + 8 * j * edged_width / 2 + 8 * i,
264                                                      f_refv->v + 8 * j * edged_width / 2 + 8 * i,
265                                                      edged_width / 2);
266                    /* */
267    
268                  break;                  break;
269    
# Line 228  Line 271 
271                  b_dx = mb->b_mvs[0].x;                  b_dx = mb->b_mvs[0].x;
272                  b_dy = mb->b_mvs[0].y;                  b_dy = mb->b_mvs[0].y;
273    
274                  transfer_8to16sub_c(                  transfer_8to16sub_c(&dct_codes[0 * 64],
                         dct_codes[0],  
275                          cur->y + (j*16)*edged_width + (i*16),                          cur->y + (j*16)*edged_width + (i*16),
276                          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,
277                                                          i*16, j*16, 1, b_dx, b_dy, edged_width),                                                                          i * 16, j * 16, 1, b_dx, b_dy,
278                          edged_width);                                                                          edged_width), edged_width);
279    
280                  transfer_8to16sub(                  transfer_8to16sub(&dct_codes[1 * 64],
                         dct_codes[1],  
281                          cur->y + (j*16)*edged_width + (i*16+8),                          cur->y + (j*16)*edged_width + (i*16+8),
282                          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,
283                                                          i*16+8, j*16, 1, b_dx, b_dy, edged_width),                                                                    i * 16 + 8, j * 16, 1, b_dx, b_dy,
284                          edged_width);                                                                    edged_width), edged_width);
285    
286                  transfer_8to16sub_c(                  transfer_8to16sub_c(&dct_codes[2 * 64],
                         dct_codes[2],  
287                          cur->y + (j*16+8)*edged_width + (i*16),                          cur->y + (j*16+8)*edged_width + (i*16),
288                          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,
289                                                          i*16, j*16+8, 1, b_dx, b_dy, edged_width),                                                                          i * 16, j * 16 + 8, 1, b_dx, b_dy,
290                          edged_width);                                                                          edged_width), edged_width);
291    
292                  transfer_8to16sub(                  transfer_8to16sub(&dct_codes[3 * 64],
                         dct_codes[3],  
293                          cur->y + (j*16+8)*edged_width + (i*16+8),                          cur->y + (j*16+8)*edged_width + (i*16+8),
294                          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,
295                                                          i*16+8, j*16+8, 1, b_dx, b_dy, edged_width),                                                                    i * 16 + 8, j * 16 + 8, 1, b_dx, b_dy,
296                          edged_width);                                                                    edged_width), edged_width);
297    
298                  b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;                  b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;
299                  b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;                  b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;
300    
301                  /* uv-image-based compensation */                  /* --- uv-image-based compensation ---
302                  compensate8x8_halfpel(dct_codes[4], cur->u,                  compensate8x8_halfpel(&dct_codes[4 * 64], cur->u, b_ref->u, b_refh->u,
303                                          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,
304                                          8*i, 8*j, b_dx, b_dy, edged_width/2);                                                            edged_width / 2);
305                  compensate8x8_halfpel(dct_codes[5], cur->v,                  compensate8x8_halfpel(&dct_codes[5 * 64], cur->v, b_ref->v, b_refh->v,
306                                          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,
307                                          8*i, 8*j, b_dx, b_dy, edged_width/2);                                                            edged_width / 2);
308                    */
309    
310                    /* --- u,v-block-based interpolation & compensation --- */
311                    interpolate8x8_switch(b_refv->u, b_ref->u, 8 * i, 8 * j, b_dx, b_dy,
312                                                              edged_width / 2, 0);
313                    transfer_8to16sub(&dct_codes[4 * 64],
314                                                      cur->u + 8 * j * edged_width / 2 + 8 * i,
315                                                      b_refv->u + 8 * j * edged_width / 2 + 8 * i,
316                                                      edged_width / 2);
317    
318                    interpolate8x8_switch(b_refv->v, b_ref->v, 8 * i, 8 * j, b_dx, b_dy,
319                                                              edged_width / 2, 0);
320                    transfer_8to16sub(&dct_codes[5 * 64],
321                                                      cur->v + 8 * j * edged_width / 2 + 8 * i,
322                                                      b_refv->v + 8 * j * edged_width / 2 + 8 * i,
323                                                      edged_width / 2);
324                    /* */
325    
326                  break;                  break;
327    
328    
329          case MODE_INTERPOLATE :          case MODE_INTERPOLATE:          /* _could_ use DIRECT, but would be overkill (no 4MV there) */
330    
331                  dx = mb->mvs[0].x;                  dx = mb->mvs[0].x;
332                  dy = mb->mvs[0].y;                  dy = mb->mvs[0].y;
333    
334                  b_dx = mb->b_mvs[0].x;                  b_dx = mb->b_mvs[0].x;
335                  b_dy = mb->b_mvs[0].y;                  b_dy = mb->b_mvs[0].y;
336    
337                  transfer_8to16sub2_c(                  for (k=0;k<4;k++)
338                                  dct_codes[0],                  {
339                                  cur->y + (i*16) + (j*16)*edged_width,                          transfer_8to16sub2_c(&dct_codes[k * 64],
340                                  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,
341                                                          16*i, 16*j, 1, dx, dy, edged_width),                                                           get_ref(f_ref->y, f_refh->y, f_refv->y,
342                                  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,
343                                                          16*i, 16*j, 1, b_dx, b_dy, edged_width),                                                                           edged_width),
344                                                             get_ref(b_ref->y, b_refh->y, b_refv->y,
345                                                                             b_refhv->y, 2*i + (k&1), 2 * j+(k>>1), 8, b_dx, b_dy,
346                                                                             edged_width),
347                                  edged_width);                                  edged_width);
348                    }
349    
350                  transfer_8to16sub2_c(                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;
351                                  dct_codes[1],                  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);  
352    
353                  transfer_8to16sub2_c(                  b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;
354                                  dct_codes[2],                  b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;
355                                  cur->y + (i*16) + (j*16+8)*edged_width,  
356                                  get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,                  /* --- uv-image-based compensation ---
357                                                          16*i, 16*j+8, 1, dx, dy, edged_width),  
358                                  get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,                  transfer_8to16sub2_c(&dct_codes[4 * 64],
359                                                          16*i, 16*j+8, 1, b_dx, b_dy, edged_width),                                                           cur->u + (y * 8) * edged_width / 2 + (x * 8),
360                                  edged_width);                                                           get_ref(f_ref->u, f_refh->u, f_refv->u,
361                                                                             f_refhv->u, i, j, 8, dx, dy,
362                                                                             edged_width / 2),
363                                                             get_ref(b_ref->u, b_refh->u, b_refv->u,
364                                                                             b_refhv->u, i, j, 8, b_dx, b_dy,
365                                                                             edged_width / 2),
366                                                             edged_width / 2);
367    
368                    transfer_8to16sub2_c(&dct_codes[5 * 64],
369                                                             cur->v + (y * 8) * edged_width / 2 + (x * 8),
370                                                             get_ref(f_ref->v, f_refh->v, f_refv->v,
371                                                                             f_refhv->v, 8 * i, 8 * j, 1, dx, dy,
372                                                                             edged_width / 2),
373                                                             get_ref(b_ref->v, b_refh->v, b_refv->v,
374                                                                             b_refhv->v, 8 * i, 8 * j, 1, b_dx, b_dy,
375                                                                             edged_width / 2),
376                                                             edged_width / 2);
377                     */
378    
379                    /* --- u,v-block-based interpolation & compensation ---  */
380                    interpolate8x8_switch(f_refv->u, f_ref->u, 8 * i, 8 * j,   dx,   dy, edged_width / 2, 0);
381                    interpolate8x8_switch(b_refv->u, b_ref->u, 8 * i, 8 * j, b_dx, b_dy, edged_width / 2, 0);
382                    transfer_8to16sub2_c(&dct_codes[4 * 64],
383                                                               cur->u + 8 * y * edged_width / 2 + 8 * x,
384                                                            f_refv->u + 8 * j * edged_width / 2 + 8 * i,
385                                                            b_refv->u + 8 * j * edged_width / 2 + 8 * i,
386                                                            edged_width / 2);
387    
388                    interpolate8x8_switch(f_refv->v, f_ref->v, 8 * i, 8 * j,   dx,   dy, edged_width / 2, 0);
389                    interpolate8x8_switch(b_refv->v, b_ref->v, 8 * i, 8 * j, b_dx, b_dy, edged_width / 2, 0);
390                    transfer_8to16sub2_c(&dct_codes[5 * 64],
391                                                               cur->v + 8 * y * edged_width / 2 + 8 * x,
392                                                            f_refv->v + 8 * j * edged_width / 2 + 8 * i,
393                                                            b_refv->v + 8 * j * edged_width / 2 + 8 * i,
394                                                            edged_width / 2);
395                     /* */
396                    break;
397    
398                  transfer_8to16sub2_c(          case MODE_DIRECT:
399                                  dct_codes[3],  
400                                  cur->y + (i*16+8) + (j*16+8)*edged_width,                  for (k=0;k<4;k++)
401                    {
402                            dx = mb->mvs[k].x;
403                            dy = mb->mvs[k].y;
404    
405                            b_dx = mb->b_mvs[k].x;
406                            b_dy = mb->b_mvs[k].y;
407    
408    //              fprintf(stderr,"Direct Vector %d -- %d:%d    %d:%d\n",k,dx,dy,b_dx,b_dy);
409    
410                            transfer_8to16sub2_c(&dct_codes[k * 64],
411                                                             cur->y + (i*16 + (k&1)*8) + (j*16 + (k>>1)*8 ) * edged_width,
412                                  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,
413                                                          16*i + 8, 16*j + 8, 1, dx, dy, edged_width),                                                                           2*i + (k&1), 2*j + (k>>1), 8, dx, dy,
414                                                                             edged_width),
415                                  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,
416                                                          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,
417                                                                             edged_width),
418                                  edged_width);                                  edged_width);
419                    }
420    
421                    sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x;
422                    dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
423    
424                  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;
425                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;                  dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
426    
                 b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;  
                 b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;  
427    
428                  transfer_8to16sub2_c(                  sum = mb->b_mvs[0].x + mb->b_mvs[1].x + mb->b_mvs[2].x + mb->b_mvs[3].x;
429                                  dct_codes[4],                  b_dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
430    
431                    sum = mb->b_mvs[0].y + mb->b_mvs[1].y + mb->b_mvs[2].y + mb->b_mvs[3].y;
432                    b_dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
433    
434    /*              // for QPel don't forget to always do
435    
436                    if (quarterpel)
437                            sum /= 2;
438    */
439    
440                    /* --- uv-image-based compensation ---
441                    transfer_8to16sub2_c(&dct_codes[4 * 64],
442                                  cur->u + (y*8)*edged_width/2 + (x*8),                                  cur->u + (y*8)*edged_width/2 + (x*8),
443                                  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,
444                                                          8*i, 8*j, 1, dx, dy, edged_width/2),                                                                           f_refhv->u, i, j, 8, dx, dy,
445                                  get_ref(b_ref->u, b_refh->u, b_refv->u, b_refhv->u,                                                                           edged_width / 2),
446                                                          8*i, 8*j, 1, b_dx, b_dy, edged_width/2),                                                           get_ref(b_ref->u, b_refh->u, b_refv->u,
447                                                                             b_refhv->u, i, j, 8, b_dx, b_dy,
448                                                                             edged_width / 2),
449                                  edged_width/2);                                  edged_width/2);
450    
451                  transfer_8to16sub2_c(                  transfer_8to16sub2_c(&dct_codes[5 * 64],
                                 dct_codes[5],  
452                                  cur->v + (y*8)*edged_width/2 + (x*8),                                  cur->v + (y*8)*edged_width/2 + (x*8),
453                                  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,
454                                                          8*i, 8*j, 1, dx, dy, edged_width/2),                                                                           f_refhv->v, i, j, 8, dx, dy,
455                                  get_ref(b_ref->v, b_refh->v, b_refv->v, b_refhv->v,                                                                           edged_width / 2),
456                                                          8*i, 8*j, 1, b_dx, b_dy, edged_width/2),                                                           get_ref(b_ref->v, b_refh->v, b_refv->v,
457                                                                             b_refhv->v, i, j, 8, b_dx, b_dy,
458                                                                             edged_width / 2),
459                                  edged_width/2);                                  edged_width/2);
460                    */
461    
                 break;  
462    
463          case MODE_DIRECT :                  /* --- uv-block-based compensation */
464                  // todo                  interpolate8x8_switch(f_refv->u, f_ref->u, 8 * i, 8 * j,   dx,   dy, edged_width / 2, 0);
465                    interpolate8x8_switch(b_refv->u, b_ref->u, 8 * i, 8 * j, b_dx, b_dy, edged_width / 2, 0);
466                    transfer_8to16sub2_c(&dct_codes[4 * 64],
467                                                               cur->u + 8 * y * edged_width / 2 + 8 * x,
468                                                            f_refv->u + 8 * j * edged_width / 2 + 8 * i,
469                                                            b_refv->u + 8 * j * edged_width / 2 + 8 * i,
470                                                            edged_width / 2);
471    
472                    interpolate8x8_switch(f_refv->v, f_ref->v, 8 * i, 8 * j,   dx,   dy, edged_width / 2, 0);
473                    interpolate8x8_switch(b_refv->v, b_ref->v, 8 * i, 8 * j, b_dx, b_dy, edged_width / 2, 0);
474                    transfer_8to16sub2_c(&dct_codes[5 * 64],
475                                                               cur->v + 8 * y * edged_width / 2 + 8 * x,
476                                                            f_refv->v + 8 * j * edged_width / 2 + 8 * i,
477                                                            b_refv->v + 8 * j * edged_width / 2 + 8 * i,
478                                                            edged_width / 2);
479                    /* */
480                  break;                  break;
481          }          }
   
482  }  }
   

Legend:
Removed from v.118  
changed lines
  Added in v.449

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