[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 118, Sat Apr 13 16:30:02 2002 UTC revision 374, Thu Aug 15 19:52:16 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                  /* uv-image-based compensation */
102                     compensate8x8_halfpel(dct_codes[4], cur->u, ref->u, refh->u, refv->u, refhv->u,  /* Always do block-based compensation, until check for HALFPEL is possible
103                     8*i, 8*j, dx, dy, edged_width/2);  #ifdef BFRAMES
104                     compensate8x8_halfpel(dct_codes[5], cur->v, ref->v, refh->v, refv->v, refhv->v,                  compensate8x8_halfpel(&dct_codes[4 * 64], cur->u, ref->u, refh->u,
105                     8*i, 8*j, dx, dy, edged_width/2);            */                                                            refv->u, refhv->u, 8 * i, 8 * j, dx, dy,
106                                                              edged_width / 2);
107                    compensate8x8_halfpel(&dct_codes[5 * 64], cur->v, ref->v, refh->v,
108                                                              refv->v, refhv->v, 8 * i, 8 * j, dx, dy,
109                                                              edged_width / 2);
110    #else
111    */
112                  /* uv-block-based compensation */                  /* uv-block-based compensation */
113                  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,
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          else    // mode == MODE_INTER4V  #endif
128    */
129            } else                                          // mode == MODE_INTER4V
130          {          {
131                  int32_t sum, dx, dy;                  int32_t sum, dx, dy;
132    
133                  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,
134                                        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,
135                  compensate8x8_halfpel(&dct_codes[1*64], cur->y, ref->y, refh->y, refv->y, refhv->y,                                                            mb->mvs[0].y, edged_width);
136                                        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,
137                  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,
138                                        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);
139                  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,
140                                        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,
141                                                              mb->mvs[2].x, mb->mvs[2].y, edged_width);
142                    compensate8x8_halfpel(&dct_codes[3 * 64], cur->y, ref->y, refh->y,
143                                                              refv->y, refhv->y, 16 * i + 8, 16 * j + 8,
144                                                              mb->mvs[3].x, mb->mvs[3].y, edged_width);
145    
146                  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;
147                  dx = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);                  dx = (sum ? SIGN(sum) *
148                              (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);
149    
150                  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;
151                  dy = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);                  dy = (sum ? SIGN(sum) *
152                              (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);
                 /* uv-image-based compensation  
                    compensate8x8_halfpel(dct_codes[4], cur->u, ref->u, refh->u, refv->u, refhv->u,  
                    8*i, 8*j, dx, dy, edged_width/2);  
                    compensate8x8_halfpel(dct_codes[5], cur->v, ref->v, refh->v, refv->v, refhv->v,  
                    8*i, 8*j, dx, dy, edged_width/2);            */  
153    
154                    /* uv-image-based compensation */
155    #ifdef BFRAMES
156                    compensate8x8_halfpel(&dct_codes[4 * 64], cur->u, ref->u, refh->u,
157                                                              refv->u, refhv->u, 8 * i, 8 * j, dx, dy,
158                                                              edged_width / 2);
159                    compensate8x8_halfpel(&dct_codes[5 * 64], cur->v, ref->v, refh->v,
160                                                              refv->v, refhv->v, 8 * i, 8 * j, dx, dy,
161                                                              edged_width / 2);
162    #else
163                  /* uv-block-based compensation */                  /* uv-block-based compensation */
164                  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,
165                                                              edged_width / 2, rounding);
166                  transfer_8to16sub(&dct_codes[4*64],                  transfer_8to16sub(&dct_codes[4*64],
167                                    cur->u + 8*j*edged_width/2 + 8*i,                                    cur->u + 8*j*edged_width/2 + 8*i,
168                                    refv->u + 8*j*edged_width/2 + 8*i, edged_width/2);                                                    refv->u + 8 * j * edged_width / 2 + 8 * i,
169                                                      edged_width / 2);
170    
171                  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,
172                                                              edged_width / 2, rounding);
173                  transfer_8to16sub(&dct_codes[5*64],                  transfer_8to16sub(&dct_codes[5*64],
174                                    cur->v + 8*j*edged_width/2 + 8*i,                                    cur->v + 8*j*edged_width/2 + 8*i,
175                                    refv->v + 8*j*edged_width/2 + 8*i, edged_width/2);                                                    refv->v + 8 * j * edged_width / 2 + 8 * i,
176                                                      edged_width / 2);
177    #endif
178          }          }
179  }  }
180    
181    
182    void
183  void MBMotionCompensationBVOP(  MBMotionCompensationBVOP(MBParam * pParam,
                         MBParam * pParam,  
184                          MACROBLOCK * const mb,                          MACROBLOCK * const mb,
185                      const uint32_t i,                      const uint32_t i,
186                          const uint32_t j,                          const uint32_t j,
# Line 165  Line 193 
193                          const IMAGE * const b_refh,                          const IMAGE * const b_refh,
194                      const IMAGE * const b_refv,                      const IMAGE * const b_refv,
195                          const IMAGE * const b_refhv,                          const IMAGE * const b_refhv,
196                      int16_t dct_codes[][64])                                                   int16_t * dct_codes)
197  {  {
198          static const uint32_t roundtab[16] =          static const uint32_t roundtab[16] =
199                  { 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 201 
201          const int32_t edged_width = pParam->edged_width;          const int32_t edged_width = pParam->edged_width;
202          int32_t dx, dy;          int32_t dx, dy;
203          int32_t b_dx, b_dy;          int32_t b_dx, b_dy;
204            int k,sum;
205          int x = i;          int x = i;
206          int y = j;          int y = j;
207    
208    
209            switch (mb->mode) {
         switch(mb->mode)  
         {  
210          case MODE_FORWARD :          case MODE_FORWARD :
211                  dx = mb->mvs[0].x;                  dx = mb->mvs[0].x;
212                  dy = mb->mvs[0].y;                  dy = mb->mvs[0].y;
213    
214                  transfer_8to16sub_c(                  transfer_8to16sub_c(&dct_codes[0 * 64],
                         dct_codes[0],  
215                          cur->y + (j*16)*edged_width + (i*16),                          cur->y + (j*16)*edged_width + (i*16),
216                          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,
217                                                          i*16, j*16, 1, dx, dy, edged_width),                                                          i*16, j*16, 1, dx, dy, edged_width),
218                          edged_width);                          edged_width);
219    
220                  transfer_8to16sub(                  transfer_8to16sub(&dct_codes[1 * 64],
                         dct_codes[1],  
221                          cur->y + (j*16)*edged_width + (i*16+8),                          cur->y + (j*16)*edged_width + (i*16+8),
222                          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,
223                                                          i*16+8, j*16, 1, dx, dy, edged_width),                                                          i*16+8, j*16, 1, dx, dy, edged_width),
224                          edged_width);                          edged_width);
225    
226                  transfer_8to16sub_c(                  transfer_8to16sub_c(&dct_codes[2 * 64],
                         dct_codes[2],  
227                          cur->y + (j*16+8)*edged_width + (i*16),                          cur->y + (j*16+8)*edged_width + (i*16),
228                          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,
229                                                          i*16, j*16+8, 1, dx, dy, edged_width),                                                                          i * 16, j * 16 + 8, 1, dx, dy,
230                          edged_width);                                                                          edged_width), edged_width);
231    
232                  transfer_8to16sub(                  transfer_8to16sub(&dct_codes[3 * 64],
                         dct_codes[3],  
233                          cur->y + (j*16+8)*edged_width + (i*16+8),                          cur->y + (j*16+8)*edged_width + (i*16+8),
234                          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,
235                                                          i*16+8, j*16+8, 1, dx, dy, edged_width),                                                                    i * 16 + 8, j * 16 + 8, 1, dx, dy,
236                          edged_width);                                                                    edged_width), edged_width);
237    
238    
239                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;
240                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;
241    
242                  /* uv-image-based compensation */                  /* uv-image-based compensation */
243                  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,
244                                                                  8*i, 8*j, dx, dy, edged_width/2);                                                            f_refv->u, f_refhv->u, 8 * i, 8 * j, dx, dy,
245                  compensate8x8_halfpel(dct_codes[5], cur->v, f_ref->v, f_refh->v, f_refv->v, f_refhv->v,                                                            edged_width / 2);
246                                                                  8*i, 8*j, dx, dy, edged_width/2);                  compensate8x8_halfpel(&dct_codes[5 * 64], cur->v, f_ref->v, f_refh->v,
247                                                              f_refv->v, f_refhv->v, 8 * i, 8 * j, dx, dy,
248                                                              edged_width / 2);
249    
250                  break;                  break;
251    
# Line 228  Line 253 
253                  b_dx = mb->b_mvs[0].x;                  b_dx = mb->b_mvs[0].x;
254                  b_dy = mb->b_mvs[0].y;                  b_dy = mb->b_mvs[0].y;
255    
256                  transfer_8to16sub_c(                  transfer_8to16sub_c(&dct_codes[0 * 64],
                         dct_codes[0],  
257                          cur->y + (j*16)*edged_width + (i*16),                          cur->y + (j*16)*edged_width + (i*16),
258                          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,
259                                                          i*16, j*16, 1, b_dx, b_dy, edged_width),                                                                          i * 16, j * 16, 1, b_dx, b_dy,
260                          edged_width);                                                                          edged_width), edged_width);
261    
262                  transfer_8to16sub(                  transfer_8to16sub(&dct_codes[1 * 64],
                         dct_codes[1],  
263                          cur->y + (j*16)*edged_width + (i*16+8),                          cur->y + (j*16)*edged_width + (i*16+8),
264                          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,
265                                                          i*16+8, j*16, 1, b_dx, b_dy, edged_width),                                                                    i * 16 + 8, j * 16, 1, b_dx, b_dy,
266                          edged_width);                                                                    edged_width), edged_width);
267    
268                  transfer_8to16sub_c(                  transfer_8to16sub_c(&dct_codes[2 * 64],
                         dct_codes[2],  
269                          cur->y + (j*16+8)*edged_width + (i*16),                          cur->y + (j*16+8)*edged_width + (i*16),
270                          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,
271                                                          i*16, j*16+8, 1, b_dx, b_dy, edged_width),                                                                          i * 16, j * 16 + 8, 1, b_dx, b_dy,
272                          edged_width);                                                                          edged_width), edged_width);
273    
274                  transfer_8to16sub(                  transfer_8to16sub(&dct_codes[3 * 64],
                         dct_codes[3],  
275                          cur->y + (j*16+8)*edged_width + (i*16+8),                          cur->y + (j*16+8)*edged_width + (i*16+8),
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+8, j*16+8, 1, b_dx, b_dy, edged_width),                                                                    i * 16 + 8, j * 16 + 8, 1, b_dx, b_dy,
278                          edged_width);                                                                    edged_width), edged_width);
279    
280                  b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;                  b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;
281                  b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;                  b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;
282    
283                  /* uv-image-based compensation */                  /* uv-image-based compensation */
284                  compensate8x8_halfpel(dct_codes[4], cur->u,                  compensate8x8_halfpel(&dct_codes[4 * 64], cur->u, b_ref->u, b_refh->u,
285                                          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,
286                                          8*i, 8*j, b_dx, b_dy, edged_width/2);                                                            edged_width / 2);
287                  compensate8x8_halfpel(dct_codes[5], cur->v,                  compensate8x8_halfpel(&dct_codes[5 * 64], cur->v, b_ref->v, b_refh->v,
288                                          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,
289                                          8*i, 8*j, b_dx, b_dy, edged_width/2);                                                            edged_width / 2);
290    
291                  break;                  break;
292    
293    
294          case MODE_INTERPOLATE :          case MODE_INTERPOLATE:          /* _could_ use DIRECT, but would be overkill (no 4MV there) */
295    
296                  dx = mb->mvs[0].x;                  dx = mb->mvs[0].x;
297                  dy = mb->mvs[0].y;                  dy = mb->mvs[0].y;
298    
299                  b_dx = mb->b_mvs[0].x;                  b_dx = mb->b_mvs[0].x;
300                  b_dy = mb->b_mvs[0].y;                  b_dy = mb->b_mvs[0].y;
301    
302                  transfer_8to16sub2_c(                  for (k=0;k<4;k++)
303                                  dct_codes[0],                  {
304                                  cur->y + (i*16) + (j*16)*edged_width,                          transfer_8to16sub2_c(&dct_codes[k * 64],
305                                  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,
306                                                          16*i, 16*j, 1, dx, dy, edged_width),                                                           get_ref(f_ref->y, f_refh->y, f_refv->y,
307                                  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,
308                                                          16*i, 16*j, 1, b_dx, b_dy, edged_width),                                                                           edged_width),
309                                                             get_ref(b_ref->y, b_refh->y, b_refv->y,
310                                                                             b_refhv->y, 2*i + (k&1), 2 * j+(k>>1), 8, b_dx, b_dy,
311                                                                             edged_width),
312                                  edged_width);                                  edged_width);
313                    }
314    
315                  transfer_8to16sub2_c(                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;
316                                  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);  
317    
318                  transfer_8to16sub2_c(                  b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;
319                                  dct_codes[2],                  b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;
320                                  cur->y + (i*16) + (j*16+8)*edged_width,  
321                                  get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,                  transfer_8to16sub2_c(&dct_codes[4 * 64],
322                                                          16*i, 16*j+8, 1, dx, dy, edged_width),                                                           cur->u + (y * 8) * edged_width / 2 + (x * 8),
323                                  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,
324                                                          16*i, 16*j+8, 1, b_dx, b_dy, edged_width),                                                                           f_refhv->u, i, j, 8, dx, dy,
325                                  edged_width);                                                                           edged_width / 2),
326                                                             get_ref(b_ref->u, b_refh->u, b_refv->u,
327                                                                             b_refhv->u, i, j, 8, b_dx, b_dy,
328                                                                             edged_width / 2),
329                                                             edged_width / 2);
330    
331                    transfer_8to16sub2_c(&dct_codes[5 * 64],
332                                                             cur->v + (y * 8) * edged_width / 2 + (x * 8),
333                                                             get_ref(f_ref->v, f_refh->v, f_refv->v,
334                                                                             f_refhv->v, 8 * i, 8 * j, 1, dx, dy,
335                                                                             edged_width / 2),
336                                                             get_ref(b_ref->v, b_refh->v, b_refv->v,
337                                                                             b_refhv->v, 8 * i, 8 * j, 1, b_dx, b_dy,
338                                                                             edged_width / 2),
339                                                             edged_width / 2);
340    
341                    break;
342    
343            case MODE_DIRECT:
344    
345                  transfer_8to16sub2_c(                  for (k=0;k<4;k++)
346                                  dct_codes[3],                  {
347                                  cur->y + (i*16+8) + (j*16+8)*edged_width,                          dx = mb->mvs[k].x;
348                            dy = mb->mvs[k].y;
349    
350                            b_dx = mb->b_mvs[k].x;
351                            b_dy = mb->b_mvs[k].y;
352    
353    //              fprintf(stderr,"Direct Vector %d -- %d:%d    %d:%d\n",k,dx,dy,b_dx,b_dy);
354    
355                            transfer_8to16sub2_c(&dct_codes[k * 64],
356                                                             cur->y + (i*16 + (k&1)*8) + (j*16 + (k>>1)*8 ) * edged_width,
357                                  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,
358                                                          16*i + 8, 16*j + 8, 1, dx, dy, edged_width),                                                                           2*i + (k&1), 2*j + (k>>1), 8, dx, dy,
359                                                                             edged_width),
360                                  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,
361                                                          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,
362                                                                             edged_width),
363                                  edged_width);                                  edged_width);
364                    }
365    
366                    sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x;
367                    dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
368    
369                  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;
370                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;                  dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
371    
                 b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;  
                 b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;  
372    
373                  transfer_8to16sub2_c(                  sum = mb->b_mvs[0].x + mb->b_mvs[1].x + mb->b_mvs[2].x + mb->b_mvs[3].x;
374                                  dct_codes[4],                  b_dx = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
375    
376                    sum = mb->b_mvs[0].y + mb->b_mvs[1].y + mb->b_mvs[2].y + mb->b_mvs[3].y;
377                    b_dy = (sum == 0 ? 0 : SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2));
378    
379    /*              // for QPel don't forget to always do
380    
381                    if (quarterpel)
382                            sum /= 2;
383    */
384    
385                    transfer_8to16sub2_c(&dct_codes[4 * 64],
386                                  cur->u + (y*8)*edged_width/2 + (x*8),                                  cur->u + (y*8)*edged_width/2 + (x*8),
387                                  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,
388                                                          8*i, 8*j, 1, dx, dy, edged_width/2),                                                                           f_refhv->u, i, j, 8, dx, dy,
389                                  get_ref(b_ref->u, b_refh->u, b_refv->u, b_refhv->u,                                                                           edged_width / 2),
390                                                          8*i, 8*j, 1, b_dx, b_dy, edged_width/2),                                                           get_ref(b_ref->u, b_refh->u, b_refv->u,
391                                                                             b_refhv->u, i, j, 8, b_dx, b_dy,
392                                                                             edged_width / 2),
393                                  edged_width/2);                                  edged_width/2);
394    
395                  transfer_8to16sub2_c(                  transfer_8to16sub2_c(&dct_codes[5 * 64],
                                 dct_codes[5],  
396                                  cur->v + (y*8)*edged_width/2 + (x*8),                                  cur->v + (y*8)*edged_width/2 + (x*8),
397                                  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,
398                                                          8*i, 8*j, 1, dx, dy, edged_width/2),                                                                           f_refhv->v, i, j, 8, dx, dy,
399                                  get_ref(b_ref->v, b_refh->v, b_refv->v, b_refhv->v,                                                                           edged_width / 2),
400                                                          8*i, 8*j, 1, b_dx, b_dy, edged_width/2),                                                           get_ref(b_ref->v, b_refh->v, b_refv->v,
401                                                                             b_refhv->v, i, j, 8, b_dx, b_dy,
402                                                                             edged_width / 2),
403                                  edged_width/2);                                  edged_width/2);
404    
                 break;  
405    
         case MODE_DIRECT :  
                 // todo  
406                  break;                  break;
407          }          }
   
408  }  }
   

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

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