[cvs] / xvidcore / src / image / qpel.h Repository:
ViewVC logotype

Diff of /xvidcore/src/image/qpel.h

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

revision 1.1.4.1, Fri Aug 22 15:52:35 2003 UTC revision 1.4, Tue Oct 12 21:08:41 2004 UTC
# Line 3  Line 3 
3  *  XVID MPEG-4 VIDEO CODEC  *  XVID MPEG-4 VIDEO CODEC
4  *  - QPel interpolation -  *  - QPel interpolation -
5  *  *
6     *  Copyright(C) 2003 Pascal Massimino <skal@planet-d.net>
7     *
8  *  This program is free software ; you can redistribute it and/or modify  *  This program is free software ; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation ; either version 2 of the License, or  *  the Free Software Foundation ; either version 2 of the License, or
# Line 17  Line 19 
19  *  along with this program ; if not, write to the Free Software  *  along with this program ; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21  *  *
22  *****************************************************************************/   * $Id$
   
 /**************************************************************************  
  *  
  *      History:  
23   *   *
24   *  22.10.2002  initial coding  - Skal -   ****************************************************************************/
  *  
  *************************************************************************/  
25    
26  #ifndef _XVID_QPEL_H_  #ifndef _XVID_QPEL_H_
27  #define _XVID_QPEL_H_  #define _XVID_QPEL_H_
28    
29    #include "interpolate8x8.h"
30  #include "../utils/mem_transfer.h"  #include "../utils/mem_transfer.h"
31    
32  /*****************************************************************************  /*****************************************************************************
# Line 41  Line 38 
38    
39  typedef  XVID_QP_PASS_SIGNATURE(XVID_QP_PASS);  typedef  XVID_QP_PASS_SIGNATURE(XVID_QP_PASS);
40    
41      // We put everything in a single struct so it can easily be passed  /* We put everything in a single struct so it can easily be passed
42      // to prediction functions as a whole...   * to prediction functions as a whole... */
43    
44  struct XVID_QP_FUNCS {  typedef struct _XVID_QP_FUNCS {
45    
46      // filter for QPel 16x? prediction          /* filter for QPel 16x? prediction */
47    
48    XVID_QP_PASS *H_Pass;    XVID_QP_PASS *H_Pass;
49    XVID_QP_PASS *H_Pass_Avrg;    XVID_QP_PASS *H_Pass_Avrg;
# Line 55  Line 52 
52    XVID_QP_PASS *V_Pass_Avrg;    XVID_QP_PASS *V_Pass_Avrg;
53    XVID_QP_PASS *V_Pass_Avrg_Up;    XVID_QP_PASS *V_Pass_Avrg_Up;
54    
55      // filter for QPel 8x? prediction      /* filter for QPel 8x? prediction */
56    
57    XVID_QP_PASS *H_Pass_8;    XVID_QP_PASS *H_Pass_8;
58    XVID_QP_PASS *H_Pass_Avrg_8;    XVID_QP_PASS *H_Pass_Avrg_8;
# Line 63  Line 60 
60    XVID_QP_PASS *V_Pass_8;    XVID_QP_PASS *V_Pass_8;
61    XVID_QP_PASS *V_Pass_Avrg_8;    XVID_QP_PASS *V_Pass_Avrg_8;
62    XVID_QP_PASS *V_Pass_Avrg_Up_8;    XVID_QP_PASS *V_Pass_Avrg_Up_8;
63  };  } XVID_QP_FUNCS;
 typedef struct XVID_QP_FUNCS  XVID_QP_FUNCS;  
64    
65  /*****************************************************************************  /*****************************************************************************
66   * fwd dcl   * fwd dcl
67   ****************************************************************************/   ****************************************************************************/
68    extern void xvid_Init_QP();
69    
70    extern XVID_QP_FUNCS xvid_QP_Funcs_C_ref;       /* for P-frames */
71    extern XVID_QP_FUNCS xvid_QP_Add_Funcs_C_ref;   /* for B-frames */
72    
73  extern XVID_QP_FUNCS xvid_QP_Funcs_C;       // for P-frames  extern XVID_QP_FUNCS xvid_QP_Funcs_C;       /* for P-frames */
74  extern XVID_QP_FUNCS xvid_QP_Add_Funcs_C;   // for B-frames  extern XVID_QP_FUNCS xvid_QP_Add_Funcs_C;   /* for B-frames */
75    
76    #ifdef ARCH_IS_IA32
77  extern XVID_QP_FUNCS xvid_QP_Funcs_mmx;  extern XVID_QP_FUNCS xvid_QP_Funcs_mmx;
78  extern XVID_QP_FUNCS xvid_QP_Add_Funcs_mmx;  extern XVID_QP_FUNCS xvid_QP_Add_Funcs_mmx;
79  extern void xvid_Init_QP_mmx(); // should be called at mmx initialization  #endif
80    
81  extern XVID_QP_FUNCS *xvid_QP_Funcs;      // <- main pointer for enc/dec structure  extern XVID_QP_FUNCS *xvid_QP_Funcs;      /* <- main pointer for enc/dec structure */
82  extern XVID_QP_FUNCS *xvid_QP_Add_Funcs;  // <- main pointer for enc/dec structure  extern XVID_QP_FUNCS *xvid_QP_Add_Funcs;  /* <- main pointer for enc/dec structure */
83    
84  /*****************************************************************************  /*****************************************************************************
85   * macros   * macros
# Line 100  Line 101 
101    
102   ****************************************************************************/   ****************************************************************************/
103    
104  static __inline void new_interpolate16x16_quarterpel(  static void __inline
105      uint8_t * const cur,  interpolate16x16_quarterpel(uint8_t * const cur,
106      uint8_t * const refn,      uint8_t * const refn,
107                  uint8_t * const refh,                  uint8_t * const refh,
108                  uint8_t * const refv,                  uint8_t * const refv,
# Line 119  Line 120 
120    
121          int32_t x_int, y_int;          int32_t x_int, y_int;
122    
123    const int32_t xRef = x*4 + dx;          const int32_t xRef = (int)x*4 + dx;
124    const int32_t yRef = y*4 + dy;          const int32_t yRef = (int)y*4 + dy;
125    
126       Ops = xvid_QP_Funcs; // TODO: pass as argument          Ops = xvid_QP_Funcs;
127       quads = (dx&3) | ((dy&3)<<2);       quads = (dx&3) | ((dy&3)<<2);
128    
129    x_int = xRef/4;    x_int = xRef/4;
# Line 134  Line 135 
135     y_int--;     y_int--;
136    
137      dst = cur + y * stride + x;      dst = cur + y * stride + x;
138          src = refn + y_int * stride + x_int;          src = refn + y_int * (int)stride + x_int;
139    
140    tmp = refh; // we need at least a 16 x stride scratch block          tmp = refh; /* we need at least a 16 x stride scratch block */
141    
142    switch(quads) {    switch(quads) {
143      case 0:      case 0:
# Line 202  Line 203 
203    }    }
204  }  }
205    
206  static __inline void new_interpolate16x8_quarterpel(  static void __inline
207      uint8_t * const cur,  interpolate16x16_add_quarterpel(uint8_t * const cur,
208                                                                    uint8_t * const refn,
209                                                                    uint8_t * const refh,
210                                                                    uint8_t * const refv,
211                                                                    uint8_t * const refhv,
212                                                                    const uint32_t x, const uint32_t y,
213                                                                    const int32_t dx,  const int dy,
214                                                                    const uint32_t stride,
215                                                                    const uint32_t rounding)
216    {
217            const uint8_t *src;
218            uint8_t *dst;
219            uint8_t *tmp;
220            int32_t quads;
221            const XVID_QP_FUNCS *Ops;
222            const XVID_QP_FUNCS *Ops_Copy;
223    
224            int32_t x_int, y_int;
225    
226            const int32_t xRef = (int)x*4 + dx;
227            const int32_t yRef = (int)y*4 + dy;
228    
229            Ops = xvid_QP_Add_Funcs;
230            Ops_Copy = xvid_QP_Funcs;
231            quads = (dx&3) | ((dy&3)<<2);
232    
233            x_int = xRef/4;
234            if (xRef < 0 && xRef % 4)
235                    x_int--;
236    
237            y_int    = yRef/4;
238            if (yRef < 0 && yRef % 4)
239                    y_int--;
240    
241            dst = cur + y * stride + x;
242            src = refn + y_int * (int)stride + x_int;
243    
244            tmp = refh; /* we need at least a 16 x stride scratch block */
245    
246            switch(quads) {
247            case 0:
248                    /* NB: there is no halfpel involved ! the name's function can be
249                     *     misleading */
250                    interpolate8x8_halfpel_add(dst, src, stride, rounding);
251                    interpolate8x8_halfpel_add(dst+8, src+8, stride, rounding);
252                    interpolate8x8_halfpel_add(dst+8*stride, src+8*stride, stride, rounding);
253                    interpolate8x8_halfpel_add(dst+8*stride+8, src+8*stride+8, stride, rounding);
254                    break;
255            case 1:
256                    Ops->H_Pass_Avrg(dst, src, 16, stride, rounding);
257                    break;
258            case 2:
259                    Ops->H_Pass(dst, src, 16, stride, rounding);
260                    break;
261            case 3:
262                    Ops->H_Pass_Avrg_Up(dst, src, 16, stride, rounding);
263                    break;
264            case 4:
265                    Ops->V_Pass_Avrg(dst, src, 16, stride, rounding);
266                    break;
267            case 5:
268                    Ops_Copy->H_Pass_Avrg(tmp, src, 17, stride, rounding);
269                    Ops->V_Pass_Avrg(dst, tmp, 16, stride, rounding);
270                    break;
271            case 6:
272                    Ops_Copy->H_Pass(tmp, src,        17, stride, rounding);
273                    Ops->V_Pass_Avrg(dst, tmp, 16, stride, rounding);
274                    break;
275            case 7:
276                    Ops_Copy->H_Pass_Avrg_Up(tmp, src, 17, stride, rounding);
277                    Ops->V_Pass_Avrg(dst, tmp, 16, stride, rounding);
278                    break;
279            case 8:
280                    Ops->V_Pass(dst, src, 16, stride, rounding);
281                    break;
282            case 9:
283                    Ops_Copy->H_Pass_Avrg(tmp, src, 17, stride, rounding);
284                    Ops->V_Pass(dst, tmp, 16, stride, rounding);
285                    break;
286            case 10:
287                    Ops_Copy->H_Pass(tmp, src, 17, stride, rounding);
288                    Ops->V_Pass(dst, tmp, 16, stride, rounding);
289                    break;
290            case 11:
291                    Ops_Copy->H_Pass_Avrg_Up(tmp, src, 17, stride, rounding);
292                    Ops->V_Pass(dst, tmp, 16, stride, rounding);
293                    break;
294            case 12:
295                    Ops->V_Pass_Avrg_Up(dst, src, 16, stride, rounding);
296                    break;
297            case 13:
298                    Ops_Copy->H_Pass_Avrg(tmp, src, 17, stride, rounding);
299                    Ops->V_Pass_Avrg_Up(dst, tmp, 16, stride, rounding);
300                    break;
301            case 14:
302                    Ops_Copy->H_Pass(tmp, src, 17, stride, rounding);
303                    Ops->V_Pass_Avrg_Up( dst, tmp, 16, stride, rounding);
304                    break;
305            case 15:
306                    Ops_Copy->H_Pass_Avrg_Up(tmp, src, 17, stride, rounding);
307                    Ops->V_Pass_Avrg_Up(dst, tmp, 16, stride, rounding);
308                    break;
309            }
310    }
311    
312    static void __inline
313    interpolate16x8_quarterpel(uint8_t * const cur,
314      uint8_t * const refn,      uint8_t * const refn,
315                  uint8_t * const refh,                  uint8_t * const refh,
316                  uint8_t * const refv,                  uint8_t * const refv,
# Line 221  Line 328 
328    
329          int32_t x_int, y_int;          int32_t x_int, y_int;
330    
331    const int32_t xRef = x*4 + dx;          const int32_t xRef = (int)x*4 + dx;
332    const int32_t yRef = y*4 + dy;          const int32_t yRef = (int)y*4 + dy;
333    
334       Ops = xvid_QP_Funcs; // TODO: pass as argument          Ops = xvid_QP_Funcs;
335       quads = (dx&3) | ((dy&3)<<2);       quads = (dx&3) | ((dy&3)<<2);
336    
337    x_int = xRef/4;    x_int = xRef/4;
# Line 236  Line 343 
343     y_int--;     y_int--;
344    
345      dst = cur + y * stride + x;      dst = cur + y * stride + x;
346          src = refn + y_int * stride + x_int;          src = refn + y_int * (int)stride + x_int;
347    
348    tmp = refh; // we need at least a 16 x stride scratch block          tmp = refh; /* we need at least a 16 x stride scratch block */
349    
350    switch(quads) {    switch(quads) {
351      case 0:      case 0:
# Line 302  Line 409 
409    }    }
410  }  }
411    
412  static __inline void new_interpolate8x8_quarterpel(  static void __inline
413      uint8_t * const cur,  interpolate8x8_quarterpel(uint8_t * const cur,
414      uint8_t * const refn,      uint8_t * const refn,
415                  uint8_t * const refh,                  uint8_t * const refh,
416                  uint8_t * const refv,                  uint8_t * const refv,
# Line 321  Line 428 
428    
429          int32_t x_int, y_int;          int32_t x_int, y_int;
430    
431    const int32_t xRef = x*4 + dx;          const int32_t xRef = (int)x*4 + dx;
432    const int32_t yRef = y*4 + dy;          const int32_t yRef = (int)y*4 + dy;
433    
434       Ops = xvid_QP_Funcs; // TODO: pass as argument          Ops = xvid_QP_Funcs;
435       quads = (dx&3) | ((dy&3)<<2);       quads = (dx&3) | ((dy&3)<<2);
436    
437    x_int = xRef/4;    x_int = xRef/4;
# Line 336  Line 443 
443     y_int--;     y_int--;
444    
445      dst = cur + y * stride + x;      dst = cur + y * stride + x;
446          src = refn + y_int * stride + x_int;          src = refn + y_int * (int)stride + x_int;
447    
448    tmp = refh; // we need at least a 16 x stride scratch block          tmp = refh; /* we need at least a 16 x stride scratch block */
449    
450    switch(quads) {    switch(quads) {
451      case 0:      case 0:
# Line 400  Line 507 
507      break;      break;
508    }    }
509  }  }
510  /*****************************************************************************/  
511    static void __inline
512    interpolate8x8_add_quarterpel(uint8_t * const cur,
513                                                              uint8_t * const refn,
514                                                              uint8_t * const refh,
515                                                              uint8_t * const refv,
516                                                              uint8_t * const refhv,
517                                                              const uint32_t x, const uint32_t y,
518                                                              const int32_t dx,  const int dy,
519                                                              const uint32_t stride,
520                                                              const uint32_t rounding)
521    {
522            const uint8_t *src;
523            uint8_t *dst;
524            uint8_t *tmp;
525            int32_t quads;
526            const XVID_QP_FUNCS *Ops;
527            const XVID_QP_FUNCS *Ops_Copy;
528    
529            int32_t x_int, y_int;
530    
531            const int32_t xRef = (int)x*4 + dx;
532            const int32_t yRef = (int)y*4 + dy;
533    
534            Ops = xvid_QP_Add_Funcs;
535            Ops_Copy = xvid_QP_Funcs;
536            quads = (dx&3) | ((dy&3)<<2);
537    
538            x_int = xRef/4;
539            if (xRef < 0 && xRef % 4)
540                    x_int--;
541    
542            y_int    = yRef/4;
543            if (yRef < 0 && yRef % 4)
544                    y_int--;
545    
546            dst = cur + y * stride + x;
547            src = refn + y_int * (int)stride + x_int;
548    
549            tmp = refh; /* we need at least a 16 x stride scratch block */
550    
551            switch(quads) {
552            case 0:
553                    /* Misleading function name, there is no halfpel involved
554                     * just dst and src averaging with rounding=0 */
555                    interpolate8x8_halfpel_add(dst, src, stride, rounding);
556                    break;
557            case 1:
558                    Ops->H_Pass_Avrg_8(dst, src, 8, stride, rounding);
559                    break;
560            case 2:
561                    Ops->H_Pass_8(dst, src, 8, stride, rounding);
562                    break;
563            case 3:
564                    Ops->H_Pass_Avrg_Up_8(dst, src, 8, stride, rounding);
565                    break;
566            case 4:
567                    Ops->V_Pass_Avrg_8(dst, src, 8, stride, rounding);
568                    break;
569            case 5:
570                    Ops_Copy->H_Pass_Avrg_8(tmp, src, 9, stride, rounding);
571                    Ops->V_Pass_Avrg_8(dst, tmp, 8, stride, rounding);
572                    break;
573            case 6:
574                    Ops_Copy->H_Pass_8(tmp, src, 9, stride, rounding);
575                    Ops->V_Pass_Avrg_8(dst, tmp, 8, stride, rounding);
576                    break;
577            case 7:
578                    Ops_Copy->H_Pass_Avrg_Up_8(tmp, src, 9, stride, rounding);
579                    Ops->V_Pass_Avrg_8(dst, tmp, 8, stride, rounding);
580                    break;
581            case 8:
582                    Ops->V_Pass_8(dst, src, 8, stride, rounding);
583                    break;
584            case 9:
585                    Ops_Copy->H_Pass_Avrg_8(tmp, src, 9, stride, rounding);
586                    Ops->V_Pass_8(dst, tmp, 8, stride, rounding);
587                    break;
588            case 10:
589                    Ops_Copy->H_Pass_8(tmp, src, 9, stride, rounding);
590                    Ops->V_Pass_8(dst, tmp, 8, stride, rounding);
591                    break;
592            case 11:
593                    Ops_Copy->H_Pass_Avrg_Up_8(tmp, src, 9, stride, rounding);
594                    Ops->V_Pass_8(dst, tmp, 8, stride, rounding);
595                    break;
596            case 12:
597                    Ops->V_Pass_Avrg_Up_8(dst, src, 8, stride, rounding);
598                    break;
599            case 13:
600                    Ops_Copy->H_Pass_Avrg_8(tmp, src, 9, stride, rounding);
601                    Ops->V_Pass_Avrg_Up_8(dst, tmp, 8, stride, rounding);
602                    break;
603            case 14:
604                    Ops_Copy->H_Pass_8(tmp, src, 9, stride, rounding);
605                    Ops->V_Pass_Avrg_Up_8( dst, tmp, 8, stride, rounding);
606                    break;
607            case 15:
608                    Ops_Copy->H_Pass_Avrg_Up_8(tmp, src, 9, stride, rounding);
609                    Ops->V_Pass_Avrg_Up_8(dst, tmp, 8, stride, rounding);
610                    break;
611            }
612    }
613    
614  #endif  /* _XVID_QPEL_H_ */  #endif  /* _XVID_QPEL_H_ */

Legend:
Removed from v.1.1.4.1  
changed lines
  Added in v.1.4

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