Parent Directory | Revision Log
Revision 195 - (view) (download)
1 : | edgomez | 195 | /************************************************************************** |
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 : | * 14.04.2002 added transfer_8to16sub2 | ||
36 : | * 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 : | |||
48 : | /***************************************************************************** | ||
49 : | * | ||
50 : | TRANSFER_8TO16SUB_PTR transfer_8to16sub; | ||
51 : | * to a 16 bit data array. | ||
52 : | TRANSFER_16TO8ADD_PTR transfer_16to8add; | ||
53 : | * This is typically used during motion compensation, that's why some | ||
54 : | * functions also do the addition/substraction of another buffer during the | ||
55 : | * so called transfer. | ||
56 : | * | ||
57 : | */ | ||
58 : | dst[j * 8 + i] = (int16_t) src[j * stride + i]; | ||
59 : | } | ||
60 : | } | ||
61 : | } | ||
62 : | |||
63 : | /* | ||
64 : | * SRC - the source buffer | ||
65 : | * DST - the destination buffer | ||
66 : | * | ||
67 : | * Then the function does the 8->16 bit transfer and this serie of operations : | ||
68 : | * | ||
69 : | * SRC (16bit) = SRC | ||
70 : | * DST (8bit) = max(min(SRC, 255), 0) | ||
71 : | */ | ||
72 : | |||
73 : | int16_t pixel = src[j * 8 + i]; | ||
74 : | |||
75 : | if (pixel < 0) { | ||
76 : | pixel = 0; | ||
77 : | } else if (pixel > 255) { | ||
78 : | pixel = 255; | ||
79 : | } | ||
80 : | dst[j * stride + i] = (uint8_t) pixel; | ||
81 : | } | ||
82 : | } | ||
83 : | } | ||
84 : | |||
85 : | |||
86 : | |||
87 : | |||
88 : | /* | ||
89 : | * C - the current buffer | ||
90 : | * R - the reference buffer | ||
91 : | * DCT - the dct coefficient buffer | ||
92 : | * | ||
93 : | * Then the function does the 8->16 bit transfer and this serie of operations : | ||
94 : | * | ||
95 : | * R (8bit) = R | ||
96 : | * C (8bit) = R | ||
97 : | * DCT (16bit) = C - R | ||
98 : | perform motion compensation (and 8bit->16bit dct transfer) | ||
99 : | ... with write back | ||
100 : | */ | ||
101 : | for (i = 0; i < 8; i++) { | ||
102 : | uint8_t c = cur[j * stride + i]; | ||
103 : | uint8_t r = ref[j * stride + i]; | ||
104 : | |||
105 : | cur[j * stride + i] = r; | ||
106 : | dct[j * 8 + i] = (int16_t) c - (int16_t) r; | ||
107 : | } | ||
108 : | } | ||
109 : | } | ||
110 : | |||
111 : | |||
112 : | /* | ||
113 : | * C - the current buffer | ||
114 : | * R1 - the 1st reference buffer | ||
115 : | * R2 - the 2nd reference buffer | ||
116 : | * DCT - the dct coefficient buffer | ||
117 : | * | ||
118 : | * Then the function does the 8->16 bit transfer and this serie of operations : | ||
119 : | * | ||
120 : | * R1 (8bit) = R1 | ||
121 : | * R2 (8bit) = R2 | ||
122 : | performs bi motion compensation (and 8bit->16bit dct transfer) | ||
123 : | .. but does not write back | ||
124 : | */ | ||
125 : | for (j = 0; j < 8; j++) { | ||
126 : | for (i = 0; i < 8; i++) { | ||
127 : | uint8_t c = cur[j * stride + i]; | ||
128 : | int r = (ref1[j * stride + i] + ref2[j * stride + i] + 1) / 2; | ||
129 : | |||
130 : | if (r > 255) { | ||
131 : | r = 255; | ||
132 : | } | ||
133 : | //cur[j * stride + i] = r; | ||
134 : | dct[j * 8 + i] = (int16_t) c - (int16_t) r; | ||
135 : | } | ||
136 : | } | ||
137 : | } | ||
138 : | |||
139 : | |||
140 : | /* | ||
141 : | * SRC - the source buffer | ||
142 : | * DST - the destination buffer | ||
143 : | * | ||
144 : | * Then the function does the 16->8 bit transfer and this serie of operations : | ||
145 : | * | ||
146 : | * SRC (16bit) = SRC | ||
147 : | * DST (8bit) = max(min(DST+SRC, 255), 0) | ||
148 : | */ | ||
149 : | int16_t pixel = (int16_t) dst[j * stride + i] + src[j * 8 + i]; | ||
150 : | |||
151 : | if (pixel < 0) { | ||
152 : | pixel = 0; | ||
153 : | } else if (pixel > 255) { | ||
154 : | pixel = 255; | ||
155 : | } | ||
156 : | dst[j * stride + i] = (uint8_t) pixel; | ||
157 : | } | ||
158 : | } | ||
159 : | } | ||
160 : | |||
161 : | /* | ||
162 : | * SRC - the source buffer | ||
163 : | * DST - the destination buffer | ||
164 : | * | ||
165 : | * Then the function does the 8->8 bit transfer and this serie of operations : | ||
166 : | * | ||
167 : | * SRC (8bit) = SRC | ||
168 : | * DST (8bit) = SRC | ||
169 : | */ | ||
170 : | |||
171 : | |||
172 : | |||
173 : | dst[j * stride + i] = src[j * stride + i]; | ||
174 : | } | ||
175 : | } | ||
176 : | } |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |