[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 652, Sun Nov 17 00:35:33 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 file is part of XviD, a free MPEG-4 video encoder/decoder
9     *
10      This program is distributed in the hope that it will be useful,   *  XviD is free software; you can redistribute it and/or modify it
11      but WITHOUT ANY WARRANTY; without even the implied warranty of   *  under the terms of the GNU General Public License as published by
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   *  the Free Software Foundation; either version 2 of the License, or
13      GNU General Public License for more details.   *  (at your option) any later version.
14     *
15      You should have received a copy of the GNU General Public License   *  This program is distributed in the hope that it will be useful,
16      along with this program; if not, write to the Free Software   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18     *  GNU General Public License for more details.
19     *
20      $Id: sad_altivec.c,v 1.2 2002-04-11 10:18:40 canard Exp $   *  You should have received a copy of the GNU General Public License
21      $Source: /home/xvid/cvs_copy/cvs-server-root/xvid/xvidcore/src/motion/ppc_asm/sad_altivec.c,v $   *  along with this program; if not, write to the Free Software
22      $Date: 2002-04-11 10:18:40 $   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
23      $Author: canard $   *
24     *  Under section 8 of the GNU General Public License, the copyright
25  */   *  holders of XVID explicitly forbid distribution in the following
26     *  countries:
27     *
28     *    - Japan
29     *    - United States of America
30     *
31     *  Linking XviD statically or dynamically with other modules is making a
32     *  combined work based on XviD.  Thus, the terms and conditions of the
33     *  GNU General Public License cover the whole combination.
34     *
35     *  As a special exception, the copyright holders of XviD give you
36     *  permission to link XviD with independent modules that communicate with
37     *  XviD solely through the VFW1.1 and DShow interfaces, regardless of the
38     *  license terms of these independent modules, and to copy and distribute
39     *  the resulting combined work under terms of your choice, provided that
40     *  every copy of the combined work is accompanied by a complete copy of
41     *  the source code of XviD (the version of XviD used to produce the
42     *  combined work), being distributed under the terms of the GNU General
43     *  Public License plus this exception.  An independent module is a module
44     *  which is not derived from or based on XviD.
45     *
46     *  Note that people who make modified versions of XviD are not obligated
47     *  to grant this special exception for their modified versions; it is
48     *  their choice whether to do so.  The GNU General Public License gives
49     *  permission to release a modified version without this exception; this
50     *  exception also makes it possible to release a modified version which
51     *  carries forward this exception.
52     *
53     * $Id: sad_altivec.c,v 1.5 2002-11-17 00:32:06 edgomez Exp $
54     *
55     ****************************************************************************/
56    
57  #define G_REG  #define G_REG
58    
# Line 39  Line 69 
69  static const vector unsigned char perms[2] = {  static const vector unsigned char perms[2] = {
70          (vector unsigned char)( /* Used when cur is aligned */          (vector unsigned char)( /* Used when cur is aligned */
71                  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,                  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
72                  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17                                                             0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17),
         ),  
73          (vector unsigned char)( /* Used when cur is unaligned */          (vector unsigned char)( /* Used when cur is unaligned */
74                  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,                  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
75                  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f                                                             0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f),
         ),  
76  };  };
77    
78  #ifdef G_REG  #ifdef G_REG
79  void sadInit_altivec(void)  void
80    sadInit_altivec(void)
81  {  {
82          perm0 = perms[0];          perm0 = perms[0];
83          perm1 = perms[1];          perm1 = perms[1];
84          zerovec = (vector unsigned int)(0);          zerovec = (vector unsigned int)(0);
85  }  }
86  static inline const vector unsigned char get_perm(unsigned long i)  static inline const vector unsigned char
87    get_perm(unsigned long i)
88  {  {
89          return i ? perm1 : perm0;          return i ? perm1 : perm0;
90  }  }
91    
92  #define ZERODEF  #define ZERODEF
93  #define ZEROVEC zerovec  #define ZEROVEC zerovec
94  #else  #else
95  void sadInit_altivec(void) { }  void
96  static inline const vector unsigned char get_perm(unsigned long i)  sadInit_altivec(void)
97    {
98    }
99    static inline const vector unsigned char
100    get_perm(unsigned long i)
101  {  {
102          return perms[i];          return perms[i];
103  }  }
104    
105  #define ZERODEF vector unsigned int zerovec = (vector unsigned int)(0)  #define ZERODEF vector unsigned int zerovec = (vector unsigned int)(0)
106  #define ZEROVEC zerovec  #define ZEROVEC zerovec
107  #endif  #endif
# Line 93  Line 129 
129    vector unsigned int sad;    vector unsigned int sad;
130    vector signed int sumdiffs, best_vec;    vector signed int sumdiffs, best_vec;
131    unsigned long result;    unsigned long result;
132    
133    ZERODEF;    ZERODEF;
134    
135  #ifdef DEBUG  #ifdef DEBUG
# Line 170  Line 207 
207    vector unsigned char perm_cur;    vector unsigned char perm_cur;
208    vector unsigned char perm_ref1, perm_ref2;    vector unsigned char perm_ref1, perm_ref2;
209    unsigned long result;    unsigned long result;
210    
211    ZERODEF;    ZERODEF;
212    
213  #ifdef DEBUG  #ifdef DEBUG
# Line 222  Line 260 
260    vector unsigned char t2,t3,t4, mn;    vector unsigned char t2,t3,t4, mn;
261    vector unsigned int mean, dev;    vector unsigned int mean, dev;
262    vector signed int sumdiffs;    vector signed int sumdiffs;
263    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,
264                    c13, c14, c15;
265    unsigned long result;    unsigned long result;
266    
267    ZERODEF;    ZERODEF;
268    
269    mean = (vector unsigned int)(ZEROVEC);    mean = (vector unsigned int)(ZEROVEC);
# Line 248  Line 288 
288    MEAN16(15);    MEAN16(15);
289    
290    sumdiffs = vec_sums((vector signed int) mean, (vector signed int) ZEROVEC);    sumdiffs = vec_sums((vector signed int) mean, (vector signed int) ZEROVEC);
291    mn = vec_perm((vector unsigned char)sumdiffs, (vector unsigned char)sumdiffs,          mn = vec_perm((vector unsigned char) sumdiffs,
292          (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,
293                                                                                                                                                       14,
294                                                                                                                                                       14,
295                                                                                                                                                       14,
296                                                                                                                                                       14,
297                                                                                                                                                       14,
298                                                                                                                                                       14,
299                                                                                                                                                       14,
300                                                                                                                                                       14,
301                                                                                                                                                       14,
302                                                                                                                                                       14,
303                                                                                                                                                       14,
304                                                                                                                                                       14,
305                                                                                                                                                       14,
306                                                                                                                                                       14,
307                                                                                                                                                       14));
308    DEV16(0);    DEV16(0);
309    DEV16(1);    DEV16(1);
310    DEV16(2);    DEV16(2);

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

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