[cvs] / xvidcore / src / motion / sad.c Repository:
ViewVC logotype

Diff of /xvidcore/src/motion/sad.c

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

revision 1.5, Wed Jun 12 20:38:40 2002 UTC revision 1.8, Fri Sep 6 16:59:47 2002 UTC
# Line 1  Line 1 
1  /**************************************************************************  /*****************************************************************************
2   *   *
3   *      XVID MPEG-4 VIDEO CODEC   *      XVID MPEG-4 VIDEO CODEC
4   *      sum of absolute difference   *  - SAD calculation module (C part) -
5     *
6     *  Copyright(C) 2002 Michael Militzer
7     *  Copyright(C) 2002 Pete Ross
8     *
9     *  This program is an implementation of a part of one or more MPEG-4
10     *  Video tools as specified in ISO/IEC 14496-2 standard.  Those intending
11     *  to use this software module in hardware or software products are
12     *  advised that its use may infringe existing patents or copyrights, and
13     *  any such use would be at such party's own risk.  The original
14     *  developer of this software module and his/her company, and subsequent
15     *  editors and their companies, will have no liability for use of this
16     *  software or modifications or derivatives thereof.
17   *   *
18   *      This program is free software; you can redistribute it and/or modify   *      This program is free software; you can redistribute it and/or modify
19   *      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
# Line 15  Line 27 
27   *   *
28   *      You should have received a copy of the GNU General Public License   *      You should have received a copy of the GNU General Public License
29   *      along with this program; if not, write to the Free Software   *      along with this program; if not, write to the Free Software
30   *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  *  
  *************************************************************************/  
   
 /**************************************************************************  
  *  
  *      History:  
  *  
  *      14.02.2002      added sad16bi_c()  
  *      10.11.2001      initial version; (c)2001 peter ross <pross@cs.rmit.edu.au>  
31   *   *
32   *************************************************************************/   ****************************************************************************/
   
33    
34  #include "../portab.h"  #include "../portab.h"
35  #include "sad.h"  #include "sad.h"
# Line 42  Line 44 
44    
45  #define ABS(X) (((X)>0)?(X):-(X))  #define ABS(X) (((X)>0)?(X):-(X))
46    
47    #define MRSAD16_CORRFACTOR 8
48  uint32_t  uint32_t
49  sad8FuncPtr sad8;  mrsad16_c(const uint8_t * const cur,
50                    const uint8_t * const ref,                    const uint8_t * const ref,
51                      const uint32_t stride,
52                    const uint32_t best_sad)                    const uint32_t best_sad)
53  {  {
54    
# Line 165  Line 168 
168  {  {
169    
170          uint32_t sad = 0;          uint32_t sad = 0;
171            uint32_t i, j;
172            uint8_t const *ptr_cur = cur;
173            uint8_t const *ptr_ref1 = ref1;
174            uint8_t const *ptr_ref2 = ref2;
175    
176            for (j = 0; j < 8; j++) {
177    
178                    for (i = 0; i < 8; i++) {
179                            int pixel = (ptr_ref1[i] + ptr_ref2[i] + 1) / 2;
180    
181                            if (pixel < 0) {
182                                    pixel = 0;
183                            } else if (pixel > 255) {
184                                    pixel = 255;
185                            }
186    
187                            sad += ABS(ptr_cur[i] - pixel);
188                    }
189    
190                    ptr_cur += stride;
191                    ptr_ref1 += stride;
192                    ptr_ref2 += stride;
193    
194            }
195    
196            return sad;
197    
198    }
199    
200    
201    
202    uint32_t
203    sad8_c(const uint8_t * const cur,
204               const uint8_t * const ref,
205               const uint32_t stride)
206    {
207            uint32_t sad = 0;
208            uint32_t i, j;
209          uint8_t const *ptr_cur = cur;          uint8_t const *ptr_cur = cur;
210          uint8_t const *ptr_ref = ref;          uint8_t const *ptr_ref = ref;
211    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.8

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