[cvs] / xvidcore / src / utils / mem_transfer.c Repository:
ViewVC logotype

Diff of /xvidcore/src/utils/mem_transfer.c

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

revision 1.3, Wed Jun 12 20:38:41 2002 UTC revision 1.11, Wed Jul 14 23:26:06 2004 UTC
# Line 1  Line 1 
1  /**************************************************************************  /*****************************************************************************
2   *   *
3   *      XVID MPEG-4 VIDEO CODEC   *      XVID MPEG-4 VIDEO CODEC
4   *      8bit<->16bit transfer   *  - 8bit<->16bit transfer  -
5   *   *
6   *      This program is an implementation of a part of one or more MPEG-4   *  Copyright(C) 2001-2003 Peter Ross <pross@xvid.org>
  *      Video tools as specified in ISO/IEC 14496-2 standard.  Those intending  
  *      to use this software module in hardware or software products are  
  *      advised that its use may infringe existing patents or copyrights, and  
  *      any such use would be at such party's own risk.  The original  
  *      developer of this software module and his/her company, and subsequent  
  *      editors and their companies, will have no liability for use of this  
  *      software or modifications or derivatives thereof.  
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
# Line 24  Line 17 
17   *   *
18   *      You should have received a copy of the GNU General Public License   *      You should have received a copy of the GNU General Public License
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., 675 Mass Ave, Cambridge, MA 02139, USA.   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  *  
  *************************************************************************/  
   
 /**************************************************************************  
21   *   *
22   *      History:   * $Id$
23   *   *
24   *      14.04.2002      added transfer_8to16sub2   ****************************************************************************/
  *      07.01.2002      merge functions from compensate; rename functions  
  *      22.12.2001      transfer_8to8add16 limit fix  
  *      07.11.2001      initial version; (c)2001 peter ross <pross@cs.rmit.edu.au>  
25    
26   *************************************************************************/  #include "../global.h"
27    #include "mem_transfer.h"
28    
29    /* Function pointers - Initialized in the xvid.c module */
30    
31    TRANSFER_8TO16COPY_PTR transfer_8to16copy;
32    TRANSFER_16TO8COPY_PTR transfer_16to8copy;
33    
34  TRANSFER_8TO16SUB_PTR  transfer_8to16sub;  TRANSFER_8TO16SUB_PTR  transfer_8to16sub;
35    TRANSFER_8TO16SUBRO_PTR  transfer_8to16subro;
36  TRANSFER_8TO16SUB2_PTR transfer_8to16sub2;  TRANSFER_8TO16SUB2_PTR transfer_8to16sub2;
37  TRANSFER_16TO8ADD_PTR  transfer_16to8add;  TRANSFER_16TO8ADD_PTR  transfer_16to8add;
38    
39  // function pointers  TRANSFER8X8_COPY_PTR transfer8x8_copy;
40    
41    
42  /*****************************************************************************  /*****************************************************************************
43   *   *
44  TRANSFER_8TO16SUB_PTR transfer_8to16sub;   * All these functions are used to transfer data from a 8 bit data array
45   * to a 16 bit data array.   * to a 16 bit data array.
46  TRANSFER_16TO8ADD_PTR transfer_16to8add;   *
47   * This is typically used during motion compensation, that's why some   * This is typically used during motion compensation, that's why some
48   * functions also do the addition/substraction of another buffer during the   * functions also do the addition/substraction of another buffer during the
49   * so called  transfer.   * so called  transfer.
50   *   *
51     ****************************************************************************/
52    
53    /*
54     * SRC - the source buffer
55     * DST - the destination buffer
56     *
57     * Then the function does the 8->16 bit transfer and this serie of operations :
58     *
59     *    SRC (8bit)  = SRC
60     *    DST (16bit) = SRC
61   */   */
62    void
63    transfer_8to16copy_c(int16_t * const dst,
64                                             const uint8_t * const src,
65                                             uint32_t stride)
66    {
67            uint32_t i, j;
68    
69            for (j = 0; j < 8; j++) {
70                    for (i = 0; i < 8; i++) {
71                          dst[j * 8 + i] = (int16_t) src[j * stride + i];                          dst[j * 8 + i] = (int16_t) src[j * stride + i];
72                  }                  }
73          }          }
# Line 69  Line 82 
82   *    SRC (16bit) = SRC   *    SRC (16bit) = SRC
83   *    DST (8bit)  = max(min(SRC, 255), 0)   *    DST (8bit)  = max(min(SRC, 255), 0)
84   */   */
85    void
86    transfer_16to8copy_c(uint8_t * const dst,
87                                             const int16_t * const src,
88                                             uint32_t stride)
89    {
90            uint32_t i, j;
91    
92            for (j = 0; j < 8; j++) {
93                    for (i = 0; i < 8; i++) {
94                          int16_t pixel = src[j * 8 + i];                          int16_t pixel = src[j * 8 + i];
95    
96                          if (pixel < 0) {                          if (pixel < 0) {
# Line 95  Line 116 
116   *    R   (8bit)  = R   *    R   (8bit)  = R
117   *    C   (8bit)  = R   *    C   (8bit)  = R
118   *    DCT (16bit) = C - R   *    DCT (16bit) = C - R
   perform motion compensation (and 8bit->16bit dct transfer)  
   ... with write back  
119  */  */
120    void
121    transfer_8to16sub_c(int16_t * const dct,
122                                            uint8_t * const cur,
123                                            const uint8_t * ref,
124                                            const uint32_t stride)
125    {
126            uint32_t i, j;
127    
128            for (j = 0; j < 8; j++) {
129                  for (i = 0; i < 8; i++) {                  for (i = 0; i < 8; i++) {
130                          uint8_t c = cur[j * stride + i];                          uint8_t c = cur[j * stride + i];
131                          uint8_t r = ref[j * stride + i];                          uint8_t r = ref[j * stride + i];
# Line 109  Line 137 
137  }  }
138    
139    
140    void
141    transfer_8to16subro_c(int16_t * const dct,
142                                            const uint8_t * const cur,
143                                            const uint8_t * ref,
144                                            const uint32_t stride)
145    {
146            uint32_t i, j;
147    
148            for (j = 0; j < 8; j++) {
149                    for (i = 0; i < 8; i++) {
150                            uint8_t c = cur[j * stride + i];
151                            uint8_t r = ref[j * stride + i];
152                            dct[j * 8 + i] = (int16_t) c - (int16_t) r;
153                    }
154            }
155    }
156    
157    
158    
159  /*  /*
160   * C   - the current buffer   * C   - the current buffer
161   * R1  - the 1st reference buffer   * R1  - the 1st reference buffer
# Line 119  Line 166 
166   *   *
167   *    R1  (8bit) = R1   *    R1  (8bit) = R1
168   *    R2  (8bit) = R2   *    R2  (8bit) = R2
169    performs bi motion compensation (and 8bit->16bit dct transfer)   *    R   (temp) = min((R1 + R2)/2, 255)
170    .. but does not write back   *    DCT (16bit)= C - R
171     *    C   (8bit) = R
172  */  */
173    void
174    transfer_8to16sub2_c(int16_t * const dct,
175                                             uint8_t * const cur,
176                                             const uint8_t * ref1,
177                                             const uint8_t * ref2,
178                                             const uint32_t stride)
179    {
180            uint32_t i, j;
181    
182          for (j = 0; j < 8; j++) {          for (j = 0; j < 8; j++) {
183                  for (i = 0; i < 8; i++) {                  for (i = 0; i < 8; i++) {
184                          uint8_t c = cur[j * stride + i];                          uint8_t c = cur[j * stride + i];
# Line 130  Line 187 
187                          if (r > 255) {                          if (r > 255) {
188                                  r = 255;                                  r = 255;
189                          }                          }
190                          //cur[j * stride + i] = r;                          cur[j * stride + i] = r;
191                          dct[j * 8 + i] = (int16_t) c - (int16_t) r;                          dct[j * 8 + i] = (int16_t) c - (int16_t) r;
192                  }                  }
193          }          }
# Line 146  Line 203 
203   *    SRC (16bit) = SRC   *    SRC (16bit) = SRC
204   *    DST (8bit)  = max(min(DST+SRC, 255), 0)   *    DST (8bit)  = max(min(DST+SRC, 255), 0)
205   */   */
206    void
207    transfer_16to8add_c(uint8_t * const dst,
208                                            const int16_t * const src,
209                                            uint32_t stride)
210    {
211            uint32_t i, j;
212    
213            for (j = 0; j < 8; j++) {
214                    for (i = 0; i < 8; i++) {
215                          int16_t pixel = (int16_t) dst[j * stride + i] + src[j * 8 + i];                          int16_t pixel = (int16_t) dst[j * stride + i] + src[j * 8 + i];
216    
217                          if (pixel < 0) {                          if (pixel < 0) {
# Line 167  Line 233 
233   *    SRC (8bit) = SRC   *    SRC (8bit) = SRC
234   *    DST (8bit) = SRC   *    DST (8bit) = SRC
235   */   */
236    void
237    transfer8x8_copy_c(uint8_t * const dst,
238                                       const uint8_t * const src,
239                                       const uint32_t stride)
240    {
241            uint32_t j;
242    
243            for (j = 0; j < 8; j++) {
244                    uint32_t *d= (uint32_t*)(dst + j*stride);
245                          dst[j * stride + i] = src[j * stride + i];                  const uint32_t *s = (const uint32_t*)(src + j*stride);
246                  }                  *(d+0) = *(s+0);
247                    *(d+1) = *(s+1);
248          }          }
249  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.11

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