[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.7, Sun Nov 17 00:51:11 2002 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     *  Copyright(C) 2001-2002 Peter Ross <pross@xvid.org>
7   *   *
8   *      This program is an implementation of a part of one or more MPEG-4   *  This file is part of XviD, a free MPEG-4 video encoder/decoder
  *      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.  
9   *   *
10   *      This program is free software; you can redistribute it and/or modify   *  XviD is free software; you can redistribute it and/or modify it
11   *      it under the terms of the GNU General Public License as published by   *  under the terms of the GNU General Public License as published by
12   *      the Free Software Foundation; either version 2 of the License, or   *      the Free Software Foundation; either version 2 of the License, or
13   *      (at your option) any later version.   *      (at your option) any later version.
14   *   *
# Line 24  Line 19 
19   *   *
20   *      You should have received a copy of the GNU General Public License   *      You should have received a copy of the GNU General Public License
21   *      along with this program; if not, write to the Free Software   *      along with this program; if not, write to the Free Software
22   *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
23   *   *
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$
54     *
55     ****************************************************************************/
56    
57  /**************************************************************************  #include "../global.h"
58   *  #include "mem_transfer.h"
  *      History:  
  *  
  *      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>  
59    
60   *************************************************************************/  /* Function pointers - Initialized in the xvid.c module */
61    
62    TRANSFER_8TO16COPY_PTR transfer_8to16copy;
63    TRANSFER_16TO8COPY_PTR transfer_16to8copy;
64    
65  TRANSFER_8TO16SUB_PTR  transfer_8to16sub;  TRANSFER_8TO16SUB_PTR  transfer_8to16sub;
66  TRANSFER_8TO16SUB2_PTR transfer_8to16sub2;  TRANSFER_8TO16SUB2_PTR transfer_8to16sub2;
67  TRANSFER_16TO8ADD_PTR  transfer_16to8add;  TRANSFER_16TO8ADD_PTR  transfer_16to8add;
68    
69  // function pointers  TRANSFER8X8_COPY_PTR transfer8x8_copy;
70    
71    
72  /*****************************************************************************  /*****************************************************************************
73   *   *
74  TRANSFER_8TO16SUB_PTR transfer_8to16sub;   * All these functions are used to transfer data from a 8 bit data array
75   * to a 16 bit data array.   * to a 16 bit data array.
76  TRANSFER_16TO8ADD_PTR transfer_16to8add;   *
77   * This is typically used during motion compensation, that's why some   * This is typically used during motion compensation, that's why some
78   * functions also do the addition/substraction of another buffer during the   * functions also do the addition/substraction of another buffer during the
79   * so called  transfer.   * so called  transfer.
80   *   *
81     ****************************************************************************/
82    
83    /*
84     * SRC - the source buffer
85     * DST - the destination buffer
86     *
87     * Then the function does the 8->16 bit transfer and this serie of operations :
88     *
89     *    SRC (8bit)  = SRC
90     *    DST (16bit) = SRC
91   */   */
92    void
93    transfer_8to16copy_c(int16_t * const dst,
94                                             const uint8_t * const src,
95                                             uint32_t stride)
96    {
97            uint32_t i, j;
98    
99            for (j = 0; j < 8; j++) {
100                    for (i = 0; i < 8; i++) {
101                          dst[j * 8 + i] = (int16_t) src[j * stride + i];                          dst[j * 8 + i] = (int16_t) src[j * stride + i];
102                  }                  }
103          }          }
# Line 69  Line 112 
112   *    SRC (16bit) = SRC   *    SRC (16bit) = SRC
113   *    DST (8bit)  = max(min(SRC, 255), 0)   *    DST (8bit)  = max(min(SRC, 255), 0)
114   */   */
115    void
116    transfer_16to8copy_c(uint8_t * const dst,
117                                             const int16_t * const src,
118                                             uint32_t stride)
119    {
120            uint32_t i, j;
121    
122            for (j = 0; j < 8; j++) {
123                    for (i = 0; i < 8; i++) {
124                          int16_t pixel = src[j * 8 + i];                          int16_t pixel = src[j * 8 + i];
125    
126                          if (pixel < 0) {                          if (pixel < 0) {
# Line 95  Line 146 
146   *    R   (8bit)  = R   *    R   (8bit)  = R
147   *    C   (8bit)  = R   *    C   (8bit)  = R
148   *    DCT (16bit) = C - R   *    DCT (16bit) = C - R
   perform motion compensation (and 8bit->16bit dct transfer)  
   ... with write back  
149  */  */
150    void
151    transfer_8to16sub_c(int16_t * const dct,
152                                            uint8_t * const cur,
153                                            const uint8_t * ref,
154                                            const uint32_t stride)
155    {
156            uint32_t i, j;
157    
158            for (j = 0; j < 8; j++) {
159                  for (i = 0; i < 8; i++) {                  for (i = 0; i < 8; i++) {
160                          uint8_t c = cur[j * stride + i];                          uint8_t c = cur[j * stride + i];
161                          uint8_t r = ref[j * stride + i];                          uint8_t r = ref[j * stride + i];
# Line 119  Line 177 
177   *   *
178   *    R1  (8bit) = R1   *    R1  (8bit) = R1
179   *    R2  (8bit) = R2   *    R2  (8bit) = R2
180    performs bi motion compensation (and 8bit->16bit dct transfer)   *    C   (8bit) = C
181    .. but does not write back   *    DCT (16bit)= C - min((R1 + R2)/2, 255)
182  */  */
183    void
184    transfer_8to16sub2_c(int16_t * const dct,
185                                             uint8_t * const cur,
186                                             const uint8_t * ref1,
187                                             const uint8_t * ref2,
188                                             const uint32_t stride)
189    {
190            uint32_t i, j;
191    
192          for (j = 0; j < 8; j++) {          for (j = 0; j < 8; j++) {
193                  for (i = 0; i < 8; i++) {                  for (i = 0; i < 8; i++) {
194                          uint8_t c = cur[j * stride + i];                          uint8_t c = cur[j * stride + i];
# Line 146  Line 213 
213   *    SRC (16bit) = SRC   *    SRC (16bit) = SRC
214   *    DST (8bit)  = max(min(DST+SRC, 255), 0)   *    DST (8bit)  = max(min(DST+SRC, 255), 0)
215   */   */
216    void
217    transfer_16to8add_c(uint8_t * const dst,
218                                            const int16_t * const src,
219                                            uint32_t stride)
220    {
221            uint32_t i, j;
222    
223            for (j = 0; j < 8; j++) {
224                    for (i = 0; i < 8; i++) {
225                          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];
226    
227                          if (pixel < 0) {                          if (pixel < 0) {
# Line 167  Line 243 
243   *    SRC (8bit) = SRC   *    SRC (8bit) = SRC
244   *    DST (8bit) = SRC   *    DST (8bit) = SRC
245   */   */
246    void
247    transfer8x8_copy_c(uint8_t * const dst,
248                                       const uint8_t * const src,
249                                       const uint32_t stride)
250    {
251            uint32_t i, j;
252    
253            for (j = 0; j < 8; j++) {
254                    for (i = 0; i < 8; i++) {
255                          dst[j * stride + i] = src[j * stride + i];                          dst[j * stride + i] = src[j * stride + i];
256                  }                  }
257          }          }

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

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