[svn] / trunk / xvidcore / src / motion / motion_comp.c Repository:
ViewVC logotype

Diff of /trunk/xvidcore/src/motion/motion_comp.c

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

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

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

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