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

Diff of /trunk/xvidcore/src/motion/ppc_asm/sad_altivec.c

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

revision 115, Thu Apr 11 10:18:40 2002 UTC revision 430, Fri Sep 6 16:59:47 2002 UTC
# Line 1  Line 1 
1  /*  /*****************************************************************************
2     *
3      Copyright (C) 2002 Benjamin Herrenschmidt <benh@kernel.crashing.org>   *  XVID MPEG-4 VIDEO CODEC
4     *  - altivec sum of absolute difference (C version)
5      This program is free software; you can redistribute it and/or modify   *
6      it under the terms of the GNU General Public License as published by   *  Copyright (C) 2002 Benjamin Herrenschmidt <benh@kernel.crashing.org>
7      the Free Software Foundation; either version 2 of the License, or   *
8      (at your option) any later version.   *  This program is an implementation of a part of one or more MPEG-4
9     *  Video tools as specified in ISO/IEC 14496-2 standard.  Those intending
10      This program is distributed in the hope that it will be useful,   *  to use this software module in hardware or software products are
11      but WITHOUT ANY WARRANTY; without even the implied warranty of   *  advised that its use may infringe existing patents or copyrights, and
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   *  any such use would be at such party's own risk.  The original
13      GNU General Public License for more details.   *  developer of this software module and his/her company, and subsequent
14     *  editors and their companies, will have no liability for use of this
15      You should have received a copy of the GNU General Public License   *  software or modifications or derivatives thereof.
16      along with this program; if not, write to the Free Software   *
17      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   *  This program is free software; you can redistribute it and/or modify
18     *  it under the terms of the GNU General Public License as published by
19     *  the Free Software Foundation; either version 2 of the License, or
20      $Id: sad_altivec.c,v 1.2 2002-04-11 10:18:40 canard Exp $   *  (at your option) any later version.
21      $Source: /home/xvid/cvs_copy/cvs-server-root/xvid/xvidcore/src/motion/ppc_asm/sad_altivec.c,v $   *
22      $Date: 2002-04-11 10:18:40 $   *  This program is distributed in the hope that it will be useful,
23      $Author: canard $   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
24     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  */   *  GNU General Public License for more details.
26     *
27     *  You should have received a copy of the GNU General Public License
28     *  along with this program; if not, write to the Free Software
29     *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
30     *
31     *  $Id: sad_altivec.c,v 1.4 2002-09-06 16:59:47 chl Exp $
32     *
33     ****************************************************************************/
34    
35  #define G_REG  #define G_REG
36    
# Line 39  Line 47 
47  static const vector unsigned char perms[2] = {  static const vector unsigned char perms[2] = {
48          (vector unsigned char)( /* Used when cur is aligned */          (vector unsigned char)( /* Used when cur is aligned */
49                  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,                  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
50                  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17                                                             0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17),
         ),  
51          (vector unsigned char)( /* Used when cur is unaligned */          (vector unsigned char)( /* Used when cur is unaligned */
52                  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,                  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
53                  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f                                                             0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f),
         ),  
54  };  };
55    
56  #ifdef G_REG  #ifdef G_REG
57  void sadInit_altivec(void)  void
58    sadInit_altivec(void)
59  {  {
60          perm0 = perms[0];          perm0 = perms[0];
61          perm1 = perms[1];          perm1 = perms[1];
62          zerovec = (vector unsigned int)(0);          zerovec = (vector unsigned int)(0);
63  }  }
64  static inline const vector unsigned char get_perm(unsigned long i)  static inline const vector unsigned char
65    get_perm(unsigned long i)
66  {  {
67          return i ? perm1 : perm0;          return i ? perm1 : perm0;
68  }  }
69    
70  #define ZERODEF  #define ZERODEF
71  #define ZEROVEC zerovec  #define ZEROVEC zerovec
72  #else  #else
73  void sadInit_altivec(void) { }  void
74  static inline const vector unsigned char get_perm(unsigned long i)  sadInit_altivec(void)
75    {
76    }
77    static inline const vector unsigned char
78    get_perm(unsigned long i)
79  {  {
80          return perms[i];          return perms[i];
81  }  }
82    
83  #define ZERODEF vector unsigned int zerovec = (vector unsigned int)(0)  #define ZERODEF vector unsigned int zerovec = (vector unsigned int)(0)
84  #define ZEROVEC zerovec  #define ZEROVEC zerovec
85  #endif  #endif
# Line 93  Line 107 
107    vector unsigned int sad;    vector unsigned int sad;
108    vector signed int sumdiffs, best_vec;    vector signed int sumdiffs, best_vec;
109    unsigned long result;    unsigned long result;
110    
111    ZERODEF;    ZERODEF;
112    
113  #ifdef DEBUG  #ifdef DEBUG
# Line 170  Line 185 
185    vector unsigned char perm_cur;    vector unsigned char perm_cur;
186    vector unsigned char perm_ref1, perm_ref2;    vector unsigned char perm_ref1, perm_ref2;
187    unsigned long result;    unsigned long result;
188    
189    ZERODEF;    ZERODEF;
190    
191  #ifdef DEBUG  #ifdef DEBUG
# Line 222  Line 238 
238    vector unsigned char t2,t3,t4, mn;    vector unsigned char t2,t3,t4, mn;
239    vector unsigned int mean, dev;    vector unsigned int mean, dev;
240    vector signed int sumdiffs;    vector signed int sumdiffs;
241    vector unsigned char c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15;          vector unsigned char c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
242                    c13, c14, c15;
243    unsigned long result;    unsigned long result;
244    
245    ZERODEF;    ZERODEF;
246    
247    mean = (vector unsigned int)(ZEROVEC);    mean = (vector unsigned int)(ZEROVEC);
# Line 248  Line 266 
266    MEAN16(15);    MEAN16(15);
267    
268    sumdiffs = vec_sums((vector signed int) mean, (vector signed int) ZEROVEC);    sumdiffs = vec_sums((vector signed int) mean, (vector signed int) ZEROVEC);
269    mn = vec_perm((vector unsigned char)sumdiffs, (vector unsigned char)sumdiffs,          mn = vec_perm((vector unsigned char) sumdiffs,
270          (vector unsigned char)(14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14));                                    (vector unsigned char) sumdiffs, (vector unsigned char) (14,
271                                                                                                                                                       14,
272                                                                                                                                                       14,
273                                                                                                                                                       14,
274                                                                                                                                                       14,
275                                                                                                                                                       14,
276                                                                                                                                                       14,
277                                                                                                                                                       14,
278                                                                                                                                                       14,
279                                                                                                                                                       14,
280                                                                                                                                                       14,
281                                                                                                                                                       14,
282                                                                                                                                                       14,
283                                                                                                                                                       14,
284                                                                                                                                                       14,
285                                                                                                                                                       14));
286    DEV16(0);    DEV16(0);
287    DEV16(1);    DEV16(1);
288    DEV16(2);    DEV16(2);

Legend:
Removed from v.115  
changed lines
  Added in v.430

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