[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 78, Thu Mar 28 20:57:25 2002 UTC revision 152, Wed May 1 13:00:02 2002 UTC
# Line 1  Line 1 
1    // 01.05.2002   updated MBMotionCompensationBVOP
2    // 14.04.2002   bframe compensation
3    
4  #include "../encoder.h"  #include "../encoder.h"
5  #include "../utils/mbfunctions.h"  #include "../utils/mbfunctions.h"
6  #include "../image/interpolate8x8.h"  #include "../image/interpolate8x8.h"
7  #include "../utils/timer.h"  #include "../utils/timer.h"
8    #include "motion.h"
9    
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)
# Line 89  Line 93 
93                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;
94                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;
95    
96                  /* uv-image-based compensation                  /* uv-image-based compensation */
97                     compensate8x8_halfpel(dct_codes[4], cur->u, ref->u, refh->u, refv->u, refhv->u,  #ifdef BFRAMES
98                       compensate8x8_halfpel(&dct_codes[4*64], cur->u, ref->u, refh->u, refv->u, refhv->u,
99                     8*i, 8*j, dx, dy, edged_width/2);                     8*i, 8*j, dx, dy, edged_width/2);
100                     compensate8x8_halfpel(dct_codes[5], cur->v, ref->v, refh->v, refv->v, refhv->v,                     compensate8x8_halfpel(&dct_codes[5*64], cur->v, ref->v, refh->v, refv->v, refhv->v,
101                     8*i, 8*j, dx, dy, edged_width/2);            */                     8*i, 8*j, dx, dy, edged_width/2);
102    #else
103                  /* uv-block-based compensation */                  /* uv-block-based compensation */
104                  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, edged_width/2, rounding);
105                  transfer_8to16sub(&dct_codes[4*64],                  transfer_8to16sub(&dct_codes[4*64],
# Line 105  Line 110 
110                  transfer_8to16sub(&dct_codes[5*64],                  transfer_8to16sub(&dct_codes[5*64],
111                                    cur->v + 8*j*edged_width/2 + 8*i,                                    cur->v + 8*j*edged_width/2 + 8*i,
112                                    refv->v + 8*j*edged_width/2 + 8*i, edged_width/2);                                    refv->v + 8*j*edged_width/2 + 8*i, edged_width/2);
113    #endif
114          }          }
115          else    // mode == MODE_INTER4V          else    // mode == MODE_INTER4V
116          {          {
# Line 126  Line 131 
131                  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;
132                  dy = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);                  dy = (sum ? SIGN(sum) * (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);
133    
134                  /* uv-image-based compensation                  /* uv-image-based compensation */
135                     compensate8x8_halfpel(dct_codes[4], cur->u, ref->u, refh->u, refv->u, refhv->u,  #ifdef BFRAMES
136                       compensate8x8_halfpel(&dct_codes[4*64], cur->u, ref->u, refh->u, refv->u, refhv->u,
137                     8*i, 8*j, dx, dy, edged_width/2);                     8*i, 8*j, dx, dy, edged_width/2);
138                     compensate8x8_halfpel(dct_codes[5], cur->v, ref->v, refh->v, refv->v, refhv->v,                     compensate8x8_halfpel(&dct_codes[5*64], cur->v, ref->v, refh->v, refv->v, refhv->v,
139                     8*i, 8*j, dx, dy, edged_width/2);            */                     8*i, 8*j, dx, dy, edged_width/2);
140    #else
141                  /* uv-block-based compensation */                  /* uv-block-based compensation */
142                  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, edged_width/2, rounding);
143                  transfer_8to16sub(&dct_codes[4*64],                  transfer_8to16sub(&dct_codes[4*64],
# Line 142  Line 148 
148                  transfer_8to16sub(&dct_codes[5*64],                  transfer_8to16sub(&dct_codes[5*64],
149                                    cur->v + 8*j*edged_width/2 + 8*i,                                    cur->v + 8*j*edged_width/2 + 8*i,
150                                    refv->v + 8*j*edged_width/2 + 8*i, edged_width/2);                                    refv->v + 8*j*edged_width/2 + 8*i, edged_width/2);
151    #endif
152            }
153    }
154    
155    
156    void MBMotionCompensationBVOP(
157                            MBParam * pParam,
158                            MACROBLOCK * const mb,
159                        const uint32_t i,
160                            const uint32_t j,
161                            IMAGE * const cur,
162                        const IMAGE * const f_ref,
163                            const IMAGE * const f_refh,
164                        const IMAGE * const f_refv,
165                            const IMAGE * const f_refhv,
166                        const IMAGE * const b_ref,
167                            const IMAGE * const b_refh,
168                        const IMAGE * const b_refv,
169                            const IMAGE * const b_refhv,
170                        int16_t * dct_codes)
171    {
172            static const uint32_t roundtab[16] =
173                    { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 };
174    
175            const int32_t edged_width = pParam->edged_width;
176            int32_t dx, dy;
177            int32_t b_dx, b_dy;
178            int x = i;
179            int y = j;
180    
181    
182    
183            switch(mb->mode)
184            {
185            case MODE_FORWARD :
186                    dx = mb->mvs[0].x;
187                    dy = mb->mvs[0].y;
188    
189                    transfer_8to16sub_c(
190                            &dct_codes[0*64],
191                            cur->y + (j*16)*edged_width + (i*16),
192                            get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
193                                                            i*16, j*16, 1, dx, dy, edged_width),
194                            edged_width);
195    
196                    transfer_8to16sub(
197                            &dct_codes[1*64],
198                            cur->y + (j*16)*edged_width + (i*16+8),
199                            get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
200                                                            i*16+8, j*16, 1, dx, dy, edged_width),
201                            edged_width);
202    
203                    transfer_8to16sub_c(
204                            &dct_codes[2*64],
205                            cur->y + (j*16+8)*edged_width + (i*16),
206                            get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
207                                                            i*16, j*16+8, 1, dx, dy, edged_width),
208                            edged_width);
209    
210                    transfer_8to16sub(
211                            &dct_codes[3*64],
212                            cur->y + (j*16+8)*edged_width + (i*16+8),
213                            get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
214                                                            i*16+8, j*16+8, 1, dx, dy, edged_width),
215                            edged_width);
216    
217    
218                    dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;
219                    dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;
220    
221                    /* uv-image-based compensation */
222                    compensate8x8_halfpel(&dct_codes[4*64], cur->u, f_ref->u, f_refh->u, f_refv->u, f_refhv->u,
223                                                                    8*i, 8*j, dx, dy, edged_width/2);
224                    compensate8x8_halfpel(&dct_codes[5*64], cur->v, f_ref->v, f_refh->v, f_refv->v, f_refhv->v,
225                                                                    8*i, 8*j, dx, dy, edged_width/2);
226    
227                    break;
228    
229            case MODE_BACKWARD :
230                    b_dx = mb->b_mvs[0].x;
231                    b_dy = mb->b_mvs[0].y;
232    
233                    transfer_8to16sub_c(
234                            &dct_codes[0*64],
235                            cur->y + (j*16)*edged_width + (i*16),
236                            get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
237                                                            i*16, j*16, 1, b_dx, b_dy, edged_width),
238                            edged_width);
239    
240                    transfer_8to16sub(
241                            &dct_codes[1*64],
242                            cur->y + (j*16)*edged_width + (i*16+8),
243                            get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
244                                                            i*16+8, j*16, 1, b_dx, b_dy, edged_width),
245                            edged_width);
246    
247                    transfer_8to16sub_c(
248                            &dct_codes[2*64],
249                            cur->y + (j*16+8)*edged_width + (i*16),
250                            get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
251                                                            i*16, j*16+8, 1, b_dx, b_dy, edged_width),
252                            edged_width);
253    
254                    transfer_8to16sub(
255                            &dct_codes[3*64],
256                            cur->y + (j*16+8)*edged_width + (i*16+8),
257                            get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
258                                                            i*16+8, j*16+8, 1, b_dx, b_dy, edged_width),
259                            edged_width);
260    
261                    b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;
262                    b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;
263    
264                    /* uv-image-based compensation */
265                    compensate8x8_halfpel(&dct_codes[4*64], cur->u,
266                                            b_ref->u, b_refh->u, b_refv->u, b_refhv->u,
267                                            8*i, 8*j, b_dx, b_dy, edged_width/2);
268                    compensate8x8_halfpel(&dct_codes[5*64], cur->v,
269                                            b_ref->v, b_refh->v, b_refv->v, b_refhv->v,
270                                            8*i, 8*j, b_dx, b_dy, edged_width/2);
271    
272                    break;
273    
274    
275            case MODE_INTERPOLATE :
276                    dx = mb->mvs[0].x;
277                    dy = mb->mvs[0].y;
278                    b_dx = mb->b_mvs[0].x;
279                    b_dy = mb->b_mvs[0].y;
280    
281                    transfer_8to16sub2_c(
282                                    &dct_codes[0*64],
283                                    cur->y + (i*16) + (j*16)*edged_width,
284                                    get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
285                                                            16*i, 16*j, 1, dx, dy, edged_width),
286                                    get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
287                                                            16*i, 16*j, 1, b_dx, b_dy, edged_width),
288                                    edged_width);
289    
290                    transfer_8to16sub2_c(
291                                    &dct_codes[1*64],
292                                    cur->y + (i*16+8) + (j*16)*edged_width,
293                                    get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
294                                                            16*i+8, 16*j, 1, dx, dy, edged_width),
295                                    get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
296                                                            16*i+8, 16*j, 1, b_dx, b_dy, edged_width),
297                                    edged_width);
298    
299                    transfer_8to16sub2_c(
300                                    &dct_codes[2*64],
301                                    cur->y + (i*16) + (j*16+8)*edged_width,
302                                    get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
303                                                            16*i, 16*j+8, 1, dx, dy, edged_width),
304                                    get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
305                                                            16*i, 16*j+8, 1, b_dx, b_dy, edged_width),
306                                    edged_width);
307    
308                    transfer_8to16sub2_c(
309                                    &dct_codes[3*64],
310                                    cur->y + (i*16+8) + (j*16+8)*edged_width,
311                                    get_ref(f_ref->y, f_refh->y, f_refv->y, f_refhv->y,
312                                                            16*i + 8, 16*j + 8, 1, dx, dy, edged_width),
313                                    get_ref(b_ref->y, b_refh->y, b_refv->y, b_refhv->y,
314                                                            16*i + 8, 16*j + 8, 1, b_dx, b_dy, edged_width),
315                                    edged_width);
316    
317    
318                    dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;
319                    dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;
320    
321                    b_dx = (b_dx & 3) ? (b_dx >> 1) | 1 : b_dx / 2;
322                    b_dy = (b_dy & 3) ? (b_dy >> 1) | 1 : b_dy / 2;
323    
324                    transfer_8to16sub2_c(
325                                    &dct_codes[4*64],
326                                    cur->u + (y*8)*edged_width/2 + (x*8),
327                                    get_ref(f_ref->u, f_refh->u, f_refv->u, f_refhv->u,
328                                                            8*i, 8*j, 1, dx, dy, edged_width/2),
329                                    get_ref(b_ref->u, b_refh->u, b_refv->u, b_refhv->u,
330                                                            8*i, 8*j, 1, b_dx, b_dy, edged_width/2),
331                                    edged_width/2);
332    
333                    transfer_8to16sub2_c(
334                                    &dct_codes[5*64],
335                                    cur->v + (y*8)*edged_width/2 + (x*8),
336                                    get_ref(f_ref->v, f_refh->v, f_refv->v, f_refhv->v,
337                                                            8*i, 8*j, 1, dx, dy, edged_width/2),
338                                    get_ref(b_ref->v, b_refh->v, b_refv->v, b_refhv->v,
339                                                            8*i, 8*j, 1, b_dx, b_dy, edged_width/2),
340                                    edged_width/2);
341    
342                    break;
343    
344            case MODE_DIRECT :
345                    // todo
346                    break;
347          }          }
348    
349  }  }

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

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