[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.2.1, Sat May 3 23:26:35 2003 UTC revision 1.6, Wed Jan 5 23:02:15 2005 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  #ifdef ARCH_IS_PPC
82  extern XVID_QP_FUNCS *xvid_QP_Add_Funcs;  // <- main pointer for enc/dec structure  extern XVID_QP_FUNCS xvid_QP_Funcs_Altivec_C;
83    extern XVID_QP_FUNCS xvid_QP_Add_Funcs_Altivec_C;
84    #endif
85    
86    #ifdef ARCH_IS_X86_64
87    extern XVID_QP_FUNCS xvid_QP_Funcs_x86_64;
88    extern XVID_QP_FUNCS xvid_QP_Add_Funcs_x86_64;
89    #endif
90    
91    extern XVID_QP_FUNCS *xvid_QP_Funcs;      /* <- main pointer for enc/dec structure */
92    extern XVID_QP_FUNCS *xvid_QP_Add_Funcs;  /* <- main pointer for enc/dec structure */
93    
94  /*****************************************************************************  /*****************************************************************************
95   * macros   * macros
# Line 100  Line 111 
111    
112   ****************************************************************************/   ****************************************************************************/
113    
114  static __inline void new_interpolate16x16_quarterpel(  static void __inline
115      uint8_t * const cur,  interpolate16x16_quarterpel(uint8_t * const cur,
116      uint8_t * const refn,      uint8_t * const refn,
117                  uint8_t * const refh,                  uint8_t * const refh,
118                  uint8_t * const refv,                  uint8_t * const refv,
# Line 119  Line 130 
130    
131          int32_t x_int, y_int;          int32_t x_int, y_int;
132    
133    const int32_t xRef = x*4 + dx;          const int32_t xRef = (int)x*4 + dx;
134    const int32_t yRef = y*4 + dy;          const int32_t yRef = (int)y*4 + dy;
135    
136       Ops = xvid_QP_Funcs; // TODO: pass as argument          Ops = xvid_QP_Funcs;
137       quads = (dx&3) | ((dy&3)<<2);       quads = (dx&3) | ((dy&3)<<2);
138    
139    x_int = xRef/4;    x_int = xRef/4;
# Line 134  Line 145 
145     y_int--;     y_int--;
146    
147      dst = cur + y * stride + x;      dst = cur + y * stride + x;
148          src = refn + y_int * stride + x_int;          src = refn + y_int * (int)stride + x_int;
149    
150    tmp = refh; // we need at least a 16 x stride scratch block          tmp = refh; /* we need at least a 16 x stride scratch block */
151    
152    switch(quads) {    switch(quads) {
153      case 0:      case 0:
# Line 202  Line 213 
213    }    }
214  }  }
215    
216  static __inline void new_interpolate16x8_quarterpel(  static void __inline
217      uint8_t * const cur,  interpolate16x16_add_quarterpel(uint8_t * const cur,
218      uint8_t * const refn,      uint8_t * const refn,
219                  uint8_t * const refh,                  uint8_t * const refh,
220                  uint8_t * const refv,                  uint8_t * const refv,
# Line 218  Line 229 
229          uint8_t *tmp;          uint8_t *tmp;
230          int32_t quads;          int32_t quads;
231          const XVID_QP_FUNCS *Ops;          const XVID_QP_FUNCS *Ops;
232            const XVID_QP_FUNCS *Ops_Copy;
233    
234          int32_t x_int, y_int;          int32_t x_int, y_int;
235    
236    const int32_t xRef = x*4 + dx;          const int32_t xRef = (int)x*4 + dx;
237    const int32_t yRef = y*4 + dy;          const int32_t yRef = (int)y*4 + dy;
238    
239       Ops = xvid_QP_Funcs; // TODO: pass as argument          Ops = xvid_QP_Add_Funcs;
240            Ops_Copy = xvid_QP_Funcs;
241       quads = (dx&3) | ((dy&3)<<2);       quads = (dx&3) | ((dy&3)<<2);
242    
243    x_int = xRef/4;    x_int = xRef/4;
# Line 236  Line 249 
249     y_int--;     y_int--;
250    
251      dst = cur + y * stride + x;      dst = cur + y * stride + x;
252          src = refn + y_int * stride + x_int;          src = refn + y_int * (int)stride + x_int;
253    
254    tmp = refh; // we need at least a 16 x stride scratch block          tmp = refh; /* we need at least a 16 x stride scratch block */
255    
256            switch(quads) {
257            case 0:
258                    /* NB: there is no halfpel involved ! the name's function can be
259                     *     misleading */
260                    interpolate8x8_halfpel_add(dst, src, stride, rounding);
261                    interpolate8x8_halfpel_add(dst+8, src+8, stride, rounding);
262                    interpolate8x8_halfpel_add(dst+8*stride, src+8*stride, stride, rounding);
263                    interpolate8x8_halfpel_add(dst+8*stride+8, src+8*stride+8, stride, rounding);
264                    break;
265            case 1:
266                    Ops->H_Pass_Avrg(dst, src, 16, stride, rounding);
267                    break;
268            case 2:
269                    Ops->H_Pass(dst, src, 16, stride, rounding);
270                    break;
271            case 3:
272                    Ops->H_Pass_Avrg_Up(dst, src, 16, stride, rounding);
273                    break;
274            case 4:
275                    Ops->V_Pass_Avrg(dst, src, 16, stride, rounding);
276                    break;
277            case 5:
278                    Ops_Copy->H_Pass_Avrg(tmp, src, 17, stride, rounding);
279                    Ops->V_Pass_Avrg(dst, tmp, 16, stride, rounding);
280                    break;
281            case 6:
282                    Ops_Copy->H_Pass(tmp, src,        17, stride, rounding);
283                    Ops->V_Pass_Avrg(dst, tmp, 16, stride, rounding);
284                    break;
285            case 7:
286                    Ops_Copy->H_Pass_Avrg_Up(tmp, src, 17, stride, rounding);
287                    Ops->V_Pass_Avrg(dst, tmp, 16, stride, rounding);
288                    break;
289            case 8:
290                    Ops->V_Pass(dst, src, 16, stride, rounding);
291                    break;
292            case 9:
293                    Ops_Copy->H_Pass_Avrg(tmp, src, 17, stride, rounding);
294                    Ops->V_Pass(dst, tmp, 16, stride, rounding);
295                    break;
296            case 10:
297                    Ops_Copy->H_Pass(tmp, src, 17, stride, rounding);
298                    Ops->V_Pass(dst, tmp, 16, stride, rounding);
299                    break;
300            case 11:
301                    Ops_Copy->H_Pass_Avrg_Up(tmp, src, 17, stride, rounding);
302                    Ops->V_Pass(dst, tmp, 16, stride, rounding);
303                    break;
304            case 12:
305                    Ops->V_Pass_Avrg_Up(dst, src, 16, stride, rounding);
306                    break;
307            case 13:
308                    Ops_Copy->H_Pass_Avrg(tmp, src, 17, stride, rounding);
309                    Ops->V_Pass_Avrg_Up(dst, tmp, 16, stride, rounding);
310                    break;
311            case 14:
312                    Ops_Copy->H_Pass(tmp, src, 17, stride, rounding);
313                    Ops->V_Pass_Avrg_Up( dst, tmp, 16, stride, rounding);
314                    break;
315            case 15:
316                    Ops_Copy->H_Pass_Avrg_Up(tmp, src, 17, stride, rounding);
317                    Ops->V_Pass_Avrg_Up(dst, tmp, 16, stride, rounding);
318                    break;
319            }
320    }
321    
322    static void __inline
323    interpolate16x8_quarterpel(uint8_t * const cur,
324                                                               uint8_t * const refn,
325                                                               uint8_t * const refh,
326                                                               uint8_t * const refv,
327                                                               uint8_t * const refhv,
328                                                               const uint32_t x, const uint32_t y,
329                                                               const int32_t dx,  const int dy,
330                                                               const uint32_t stride,
331                                                               const uint32_t rounding)
332    {
333            const uint8_t *src;
334            uint8_t *dst;
335            uint8_t *tmp;
336            int32_t quads;
337            const XVID_QP_FUNCS *Ops;
338    
339            int32_t x_int, y_int;
340    
341            const int32_t xRef = (int)x*4 + dx;
342            const int32_t yRef = (int)y*4 + dy;
343    
344            Ops = xvid_QP_Funcs;
345            quads = (dx&3) | ((dy&3)<<2);
346    
347            x_int = xRef/4;
348            if (xRef < 0 && xRef % 4)
349                    x_int--;
350    
351            y_int    = yRef/4;
352            if (yRef < 0 && yRef % 4)
353                    y_int--;
354    
355            dst = cur + y * stride + x;
356            src = refn + y_int * (int)stride + x_int;
357    
358            tmp = refh; /* we need at least a 16 x stride scratch block */
359    
360    switch(quads) {    switch(quads) {
361      case 0:      case 0:
# Line 302  Line 419 
419    }    }
420  }  }
421    
422  static __inline void new_interpolate8x8_quarterpel(  static void __inline
423      uint8_t * const cur,  interpolate8x8_quarterpel(uint8_t * const cur,
424      uint8_t * const refn,      uint8_t * const refn,
425                  uint8_t * const refh,                  uint8_t * const refh,
426                  uint8_t * const refv,                  uint8_t * const refv,
# Line 321  Line 438 
438    
439          int32_t x_int, y_int;          int32_t x_int, y_int;
440    
441    const int32_t xRef = x*4 + dx;          const int32_t xRef = (int)x*4 + dx;
442    const int32_t yRef = y*4 + dy;          const int32_t yRef = (int)y*4 + dy;
443    
444       Ops = xvid_QP_Funcs; // TODO: pass as argument          Ops = xvid_QP_Funcs;
445       quads = (dx&3) | ((dy&3)<<2);       quads = (dx&3) | ((dy&3)<<2);
446    
447    x_int = xRef/4;    x_int = xRef/4;
# Line 336  Line 453 
453     y_int--;     y_int--;
454    
455      dst = cur + y * stride + x;      dst = cur + y * stride + x;
456          src = refn + y_int * stride + x_int;          src = refn + y_int * (int)stride + x_int;
457    
458    tmp = refh; // we need at least a 16 x stride scratch block          tmp = refh; /* we need at least a 16 x stride scratch block */
459    
460    switch(quads) {    switch(quads) {
461      case 0:      case 0:
# Line 400  Line 517 
517      break;      break;
518    }    }
519  }  }
520  /*****************************************************************************/  
521    static void __inline
522    interpolate8x8_add_quarterpel(uint8_t * const cur,
523                                                              uint8_t * const refn,
524                                                              uint8_t * const refh,
525                                                              uint8_t * const refv,
526                                                              uint8_t * const refhv,
527                                                              const uint32_t x, const uint32_t y,
528                                                              const int32_t dx,  const int dy,
529                                                              const uint32_t stride,
530                                                              const uint32_t rounding)
531    {
532            const uint8_t *src;
533            uint8_t *dst;
534            uint8_t *tmp;
535            int32_t quads;
536            const XVID_QP_FUNCS *Ops;
537            const XVID_QP_FUNCS *Ops_Copy;
538    
539            int32_t x_int, y_int;
540    
541            const int32_t xRef = (int)x*4 + dx;
542            const int32_t yRef = (int)y*4 + dy;
543    
544            Ops = xvid_QP_Add_Funcs;
545            Ops_Copy = xvid_QP_Funcs;
546            quads = (dx&3) | ((dy&3)<<2);
547    
548            x_int = xRef/4;
549            if (xRef < 0 && xRef % 4)
550                    x_int--;
551    
552            y_int    = yRef/4;
553            if (yRef < 0 && yRef % 4)
554                    y_int--;
555    
556            dst = cur + y * stride + x;
557            src = refn + y_int * (int)stride + x_int;
558    
559            tmp = refh; /* we need at least a 16 x stride scratch block */
560    
561            switch(quads) {
562            case 0:
563                    /* Misleading function name, there is no halfpel involved
564                     * just dst and src averaging with rounding=0 */
565                    interpolate8x8_halfpel_add(dst, src, stride, rounding);
566                    break;
567            case 1:
568                    Ops->H_Pass_Avrg_8(dst, src, 8, stride, rounding);
569                    break;
570            case 2:
571                    Ops->H_Pass_8(dst, src, 8, stride, rounding);
572                    break;
573            case 3:
574                    Ops->H_Pass_Avrg_Up_8(dst, src, 8, stride, rounding);
575                    break;
576            case 4:
577                    Ops->V_Pass_Avrg_8(dst, src, 8, stride, rounding);
578                    break;
579            case 5:
580                    Ops_Copy->H_Pass_Avrg_8(tmp, src, 9, stride, rounding);
581                    Ops->V_Pass_Avrg_8(dst, tmp, 8, stride, rounding);
582                    break;
583            case 6:
584                    Ops_Copy->H_Pass_8(tmp, src, 9, stride, rounding);
585                    Ops->V_Pass_Avrg_8(dst, tmp, 8, stride, rounding);
586                    break;
587            case 7:
588                    Ops_Copy->H_Pass_Avrg_Up_8(tmp, src, 9, stride, rounding);
589                    Ops->V_Pass_Avrg_8(dst, tmp, 8, stride, rounding);
590                    break;
591            case 8:
592                    Ops->V_Pass_8(dst, src, 8, stride, rounding);
593                    break;
594            case 9:
595                    Ops_Copy->H_Pass_Avrg_8(tmp, src, 9, stride, rounding);
596                    Ops->V_Pass_8(dst, tmp, 8, stride, rounding);
597                    break;
598            case 10:
599                    Ops_Copy->H_Pass_8(tmp, src, 9, stride, rounding);
600                    Ops->V_Pass_8(dst, tmp, 8, stride, rounding);
601                    break;
602            case 11:
603                    Ops_Copy->H_Pass_Avrg_Up_8(tmp, src, 9, stride, rounding);
604                    Ops->V_Pass_8(dst, tmp, 8, stride, rounding);
605                    break;
606            case 12:
607                    Ops->V_Pass_Avrg_Up_8(dst, src, 8, stride, rounding);
608                    break;
609            case 13:
610                    Ops_Copy->H_Pass_Avrg_8(tmp, src, 9, stride, rounding);
611                    Ops->V_Pass_Avrg_Up_8(dst, tmp, 8, stride, rounding);
612                    break;
613            case 14:
614                    Ops_Copy->H_Pass_8(tmp, src, 9, stride, rounding);
615                    Ops->V_Pass_Avrg_Up_8( dst, tmp, 8, stride, rounding);
616                    break;
617            case 15:
618                    Ops_Copy->H_Pass_Avrg_Up_8(tmp, src, 9, stride, rounding);
619                    Ops->V_Pass_Avrg_Up_8(dst, tmp, 8, stride, rounding);
620                    break;
621            }
622    }
623    
624  #endif  /* _XVID_QPEL_H_ */  #endif  /* _XVID_QPEL_H_ */

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.6

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