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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download)

1 : Isibaar 1.1 /**************************************************************************
2 :     *
3 :     * XVID MPEG-4 VIDEO CODEC
4 :     * 8bit<->16bit transfer
5 :     *
6 :     * This program is an implementation of a part of one or more MPEG-4
7 :     * Video tools as specified in ISO/IEC 14496-2 standard. Those intending
8 :     * to use this software module in hardware or software products are
9 :     * advised that its use may infringe existing patents or copyrights, and
10 :     * any such use would be at such party's own risk. The original
11 :     * developer of this software module and his/her company, and subsequent
12 :     * editors and their companies, will have no liability for use of this
13 :     * software or modifications or derivatives thereof.
14 :     *
15 :     * This program is free software; you can redistribute it and/or modify
16 :     * it under the terms of the GNU General Public License as published by
17 :     * the Free Software Foundation; either version 2 of the License, or
18 :     * (at your option) any later version.
19 :     *
20 :     * This program is distributed in the hope that it will be useful,
21 :     * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 :     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 :     * GNU General Public License for more details.
24 :     *
25 :     * You should have received a copy of the GNU General Public License
26 :     * along with this program; if not, write to the Free Software
27 :     * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 :     *
29 :     *************************************************************************/
30 :    
31 :     /**************************************************************************
32 :     *
33 :     * History:
34 :     *
35 : suxen_drol 1.2 * 14.04.2002 added transfer_8to16sub2
36 : Isibaar 1.1 * 07.01.2002 merge functions from compensate; rename functions
37 :     * 22.12.2001 transfer_8to8add16 limit fix
38 :     * 07.11.2001 initial version; (c)2001 peter ross <pross@cs.rmit.edu.au>
39 :    
40 :     *************************************************************************/
41 :    
42 :     TRANSFER_8TO16SUB_PTR transfer_8to16sub;
43 :     TRANSFER_8TO16SUB2_PTR transfer_8to16sub2;
44 :     TRANSFER_16TO8ADD_PTR transfer_16to8add;
45 :    
46 :     // function pointers
47 :     TRANSFER_8TO16COPY_PTR transfer_8to16copy;
48 :     TRANSFER_16TO8COPY_PTR transfer_16to8copy;
49 :     *
50 :     TRANSFER_8TO16SUB_PTR transfer_8to16sub;
51 : suxen_drol 1.2 TRANSFER_8TO16SUB2_PTR transfer_8to16sub2;
52 : Isibaar 1.1 TRANSFER_16TO8ADD_PTR transfer_16to8add;
53 :     * This is typically used during motion compensation, that's why some
54 :     TRANSFER8X8_COPY_PTR transfer8x8_copy;
55 :     * so called transfer.
56 :     *
57 :     */
58 :     void transfer_8to16copy_c(int16_t * const dst,
59 :     const uint8_t * const src,
60 :     uint32_t stride)
61 :    
62 :     /*
63 :     * SRC - the source buffer
64 :     * DST - the destination buffer
65 :     *
66 :     dst[j * 8 + i] = (int16_t)src[j * stride + i];
67 :     *
68 :     * SRC (16bit) = SRC
69 :     * DST (8bit) = max(min(SRC, 255), 0)
70 :     */
71 :    
72 :     void transfer_16to8copy_c(uint8_t * const dst,
73 :     const int16_t * const src,
74 :     uint32_t stride)
75 :     } else if (pixel > 255) {
76 :     pixel = 255;
77 :     }
78 :     dst[j * stride + i] = (uint8_t) pixel;
79 :     }
80 :     }
81 :    
82 :    
83 :    
84 :    
85 :     }
86 :     dst[j * stride + i] = (uint8_t)pixel;
87 :     * R - the reference buffer
88 :     * DCT - the dct coefficient buffer
89 :     *
90 :     * Then the function does the 8->16 bit transfer and this serie of operations :
91 :     *
92 :     * R (8bit) = R
93 :     * C (8bit) = R
94 :     * DCT (16bit) = C - R
95 :     perform motion compensation (and 8bit->16bit dct transfer)
96 : suxen_drol 1.2 ... with write back
97 : Isibaar 1.1 */
98 :     void transfer_8to16sub_c(int16_t * const dct,
99 :     uint8_t * const cur,
100 :     const uint8_t * ref,
101 :     const uint32_t stride)
102 :     dct[j * 8 + i] = (int16_t) c - (int16_t) r;
103 :     }
104 :     }
105 :     for (j = 0; j < 8; j++)
106 :     {
107 :     for (i = 0; i < 8; i++)
108 :     {
109 :    
110 :     /*
111 :     * R1 - the 1st reference buffer
112 : suxen_drol 1.2 dct[j * 8 + i] = (int16_t)c - (int16_t)r;
113 :     * DCT - the dct coefficient buffer
114 :     *
115 :     * Then the function does the 8->16 bit transfer and this serie of operations :
116 :     *
117 :     * R1 (8bit) = R1
118 :     * R2 (8bit) = R2
119 :     performs bi motion compensation (and 8bit->16bit dct transfer)
120 :     .. but does not write back
121 :     */
122 :     void transfer_8to16sub2_c(int16_t * const dct,
123 :     uint8_t * const cur,
124 :     const uint8_t * ref1,
125 :     const uint8_t * ref2,
126 :     const uint32_t stride)
127 :     r = 255;
128 :     }
129 :     //cur[j * stride + i] = r;
130 :     for (j = 0; j < 8; j++)
131 :     {
132 :     for (i = 0; i < 8; i++)
133 :     {
134 :     }
135 :     int r = (ref1[j * stride + i] + ref2[j * stride + i] + 1) / 2;
136 :     if (r > 255)
137 :     {
138 :     /*
139 :     * SRC - the source buffer
140 :     * DST - the destination buffer
141 : Isibaar 1.1 dct[j * 8 + i] = (int16_t)c - (int16_t)r;
142 :     * Then the function does the 16->8 bit transfer and this serie of operations :
143 :     *
144 :     * SRC (16bit) = SRC
145 :     * DST (8bit) = max(min(DST+SRC, 255), 0)
146 :     */
147 :     void transfer_16to8add_c(uint8_t * const dst,
148 :     if (pixel < 0) {
149 :     pixel = 0;
150 :     } else if (pixel > 255) {
151 :     pixel = 255;
152 :     }
153 :     dst[j * stride + i] = (uint8_t) pixel;
154 :     }
155 :     int16_t pixel = (int16_t)dst[j * stride + i] + src[j * 8 + i];
156 :    
157 :     /*
158 :     * SRC - the source buffer
159 :     * DST - the destination buffer
160 :     }
161 :     dst[j * stride + i] = (uint8_t)pixel;
162 :     *
163 :     * SRC (8bit) = SRC
164 :     * DST (8bit) = SRC
165 :     */
166 :    
167 :    
168 :    
169 :     void transfer8x8_copy_c(uint8_t * const dst,
170 :     const uint8_t * const src,
171 :     const uint32_t stride)
172 :    

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