Merge lp:~serge-hallyn/ubuntu/raring/spice/spice-compiler-warnings into lp:ubuntu/raring/spice
- Raring (13.04)
- spice-compiler-warnings
- Merge into raring
Proposed by
Serge Hallyn
Status: | Merged |
---|---|
Merged at revision: | 11 |
Proposed branch: | lp:~serge-hallyn/ubuntu/raring/spice/spice-compiler-warnings |
Merge into: | lp:ubuntu/raring/spice |
Diff against target: |
657 lines (+575/-31) (has conflicts) 7 files modified
.pc/applied-patches.OTHER (+3/-0) .pc/fix-missing-PIXEL-pointer-cast/spice-common/common/lz_compress_tmpl.c (+547/-0) debian/changelog (+3/-3) debian/patches/fix-compiler-warnings.patch (+0/-27) debian/patches/fix-missing-PIXEL-pointer-cast (+17/-0) debian/patches/series (+1/-1) spice-common/common/lz_compress_tmpl.c (+4/-0) Contents conflict in .pc/applied-patches Text conflict in spice-common/common/lz_compress_tmpl.c |
To merge this branch: | bzr merge lp:~serge-hallyn/ubuntu/raring/spice/spice-compiler-warnings |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Dustin Kirkland | Pending | ||
Review via email: mp+146239@code.launchpad.net |
Commit message
Description of the change
Update to remove the handling of seteuid(0) failure.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file '.pc/applied-patches.OTHER' | |||
2 | --- .pc/applied-patches.OTHER 1970-01-01 00:00:00 +0000 | |||
3 | +++ .pc/applied-patches.OTHER 2013-02-01 22:40:24 +0000 | |||
4 | @@ -0,0 +1,3 @@ | |||
5 | 1 | link-libspice-server-with-libm-libpthread.patch | ||
6 | 2 | make-celt-to-be-optional.patch | ||
7 | 3 | fix-missing-PIXEL-pointer-cast | ||
8 | 0 | 4 | ||
9 | === added directory '.pc/fix-missing-PIXEL-pointer-cast' | |||
10 | === added file '.pc/fix-missing-PIXEL-pointer-cast/.timestamp' | |||
11 | === added directory '.pc/fix-missing-PIXEL-pointer-cast/spice-common' | |||
12 | === added directory '.pc/fix-missing-PIXEL-pointer-cast/spice-common/common' | |||
13 | === added file '.pc/fix-missing-PIXEL-pointer-cast/spice-common/common/lz_compress_tmpl.c' | |||
14 | --- .pc/fix-missing-PIXEL-pointer-cast/spice-common/common/lz_compress_tmpl.c 1970-01-01 00:00:00 +0000 | |||
15 | +++ .pc/fix-missing-PIXEL-pointer-cast/spice-common/common/lz_compress_tmpl.c 2013-02-01 22:40:24 +0000 | |||
16 | @@ -0,0 +1,547 @@ | |||
17 | 1 | /* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */ | ||
18 | 2 | /* | ||
19 | 3 | |||
20 | 4 | Copyright (C) 2009 Red Hat, Inc. and/or its affiliates. | ||
21 | 5 | |||
22 | 6 | This library is free software; you can redistribute it and/or | ||
23 | 7 | modify it under the terms of the GNU Lesser General Public | ||
24 | 8 | License as published by the Free Software Foundation; either | ||
25 | 9 | version 2.1 of the License, or (at your option) any later version. | ||
26 | 10 | |||
27 | 11 | This library is distributed in the hope that it will be useful, | ||
28 | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
29 | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
30 | 14 | Lesser General Public License for more details. | ||
31 | 15 | |||
32 | 16 | This file incorporates work covered by the following copyright and | ||
33 | 17 | permission notice: | ||
34 | 18 | Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) | ||
35 | 19 | Copyright (C) 2006 Ariya Hidayat (ariya@kde.org) | ||
36 | 20 | Copyright (C) 2005 Ariya Hidayat (ariya@kde.org) | ||
37 | 21 | |||
38 | 22 | Permission is hereby granted, free of charge, to any person | ||
39 | 23 | obtaining a copy of this software and associated documentation | ||
40 | 24 | files (the "Software"), to deal in the Software without | ||
41 | 25 | restriction, including without limitation the rights to use, copy, | ||
42 | 26 | modify, merge, publish, distribute, sublicense, and/or sell copies | ||
43 | 27 | of the Software, and to permit persons to whom the Software is | ||
44 | 28 | furnished to do so, subject to the following conditions: | ||
45 | 29 | |||
46 | 30 | The above copyright notice and this permission notice shall be | ||
47 | 31 | included in all copies or substantial portions of the Software. | ||
48 | 32 | |||
49 | 33 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
50 | 34 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
51 | 35 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
52 | 36 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
53 | 37 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
54 | 38 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
55 | 39 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
56 | 40 | SOFTWARE. | ||
57 | 41 | |||
58 | 42 | */ | ||
59 | 43 | #ifdef HAVE_CONFIG_H | ||
60 | 44 | #include <config.h> | ||
61 | 45 | #endif | ||
62 | 46 | |||
63 | 47 | #define DJB2_START 5381; | ||
64 | 48 | #define DJB2_HASH(hash, c) (hash = ((hash << 5) + hash) ^ (c)) //|{hash = ((hash << 5) + hash) + c;} | ||
65 | 49 | |||
66 | 50 | /* | ||
67 | 51 | For each pixel type the following macros are defined: | ||
68 | 52 | PIXEL : input type | ||
69 | 53 | FNAME(name) | ||
70 | 54 | ENCODE_PIXEL(encoder, pixel) : writing a pixel to the compressed buffer (byte by byte) | ||
71 | 55 | SAME_PIXEL(pix1, pix2) : comparing two pixels | ||
72 | 56 | HASH_FUNC(value, pix_ptr) : hash func of 3 consecutive pixels | ||
73 | 57 | */ | ||
74 | 58 | |||
75 | 59 | #ifdef LZ_PLT | ||
76 | 60 | #define PIXEL one_byte_pixel_t | ||
77 | 61 | #define FNAME(name) lz_plt_##name | ||
78 | 62 | #define ENCODE_PIXEL(e, pix) encode(e, (pix).a) // gets the pixel and write only the needed bytes | ||
79 | 63 | // from the pixel | ||
80 | 64 | #define SAME_PIXEL(pix1, pix2) ((pix1).a == (pix2).a) | ||
81 | 65 | #define HASH_FUNC(v, p) { \ | ||
82 | 66 | v = DJB2_START; \ | ||
83 | 67 | DJB2_HASH(v, p[0].a); \ | ||
84 | 68 | DJB2_HASH(v, p[1].a); \ | ||
85 | 69 | DJB2_HASH(v, p[2].a); \ | ||
86 | 70 | v &= HASH_MASK; \ | ||
87 | 71 | } | ||
88 | 72 | #endif | ||
89 | 73 | |||
90 | 74 | #ifdef LZ_A8 | ||
91 | 75 | #define PIXEL one_byte_pixel_t | ||
92 | 76 | #define FNAME(name) lz_a8_##name | ||
93 | 77 | #define ENCODE_PIXEL(e, pix) encode(e, (pix).a) // gets the pixel and write only the needed bytes | ||
94 | 78 | // from the pixel | ||
95 | 79 | #define SAME_PIXEL(pix1, pix2) ((pix1).a == (pix2).a) | ||
96 | 80 | #define HASH_FUNC(v, p) { \ | ||
97 | 81 | v = DJB2_START; \ | ||
98 | 82 | DJB2_HASH(v, p[0].a); \ | ||
99 | 83 | DJB2_HASH(v, p[1].a); \ | ||
100 | 84 | DJB2_HASH(v, p[2].a); \ | ||
101 | 85 | v &= HASH_MASK; \ | ||
102 | 86 | } | ||
103 | 87 | #endif | ||
104 | 88 | |||
105 | 89 | #ifdef LZ_RGB_ALPHA | ||
106 | 90 | //#undef LZ_RGB_ALPHA | ||
107 | 91 | #define PIXEL rgb32_pixel_t | ||
108 | 92 | #define FNAME(name) lz_rgb_alpha_##name | ||
109 | 93 | #define ENCODE_PIXEL(e, pix) {encode(e, (pix).pad);} | ||
110 | 94 | #define SAME_PIXEL(pix1, pix2) ((pix1).pad == (pix2).pad) | ||
111 | 95 | #define HASH_FUNC(v, p) { \ | ||
112 | 96 | v = DJB2_START; \ | ||
113 | 97 | DJB2_HASH(v, p[0].pad); \ | ||
114 | 98 | DJB2_HASH(v, p[1].pad); \ | ||
115 | 99 | DJB2_HASH(v, p[2].pad); \ | ||
116 | 100 | v &= HASH_MASK; \ | ||
117 | 101 | } | ||
118 | 102 | #endif | ||
119 | 103 | |||
120 | 104 | |||
121 | 105 | #ifdef LZ_RGB16 | ||
122 | 106 | #define PIXEL rgb16_pixel_t | ||
123 | 107 | #define FNAME(name) lz_rgb16_##name | ||
124 | 108 | #define GET_r(pix) (((pix) >> 10) & 0x1f) | ||
125 | 109 | #define GET_g(pix) (((pix) >> 5) & 0x1f) | ||
126 | 110 | #define GET_b(pix) ((pix) & 0x1f) | ||
127 | 111 | #define ENCODE_PIXEL(e, pix) {encode(e, (pix) >> 8); encode(e, (pix) & 0xff);} | ||
128 | 112 | |||
129 | 113 | #define HASH_FUNC(v, p) { \ | ||
130 | 114 | v = DJB2_START; \ | ||
131 | 115 | DJB2_HASH(v, p[0] & (0x00ff)); \ | ||
132 | 116 | DJB2_HASH(v, (p[0] >> 8) & (0x007f)); \ | ||
133 | 117 | DJB2_HASH(v, p[1]&(0x00ff)); \ | ||
134 | 118 | DJB2_HASH(v, (p[1] >> 8) & (0x007f)); \ | ||
135 | 119 | DJB2_HASH(v, p[2] & (0x00ff)); \ | ||
136 | 120 | DJB2_HASH(v, (p[2] >> 8) & (0x007f)); \ | ||
137 | 121 | v &= HASH_MASK; \ | ||
138 | 122 | } | ||
139 | 123 | #endif | ||
140 | 124 | |||
141 | 125 | #ifdef LZ_RGB24 | ||
142 | 126 | #define PIXEL rgb24_pixel_t | ||
143 | 127 | #define FNAME(name) lz_rgb24_##name | ||
144 | 128 | #define ENCODE_PIXEL(e, pix) {encode(e, (pix).b); encode(e, (pix).g); encode(e, (pix).r);} | ||
145 | 129 | #endif | ||
146 | 130 | |||
147 | 131 | #ifdef LZ_RGB32 | ||
148 | 132 | #define PIXEL rgb32_pixel_t | ||
149 | 133 | #define FNAME(name) lz_rgb32_##name | ||
150 | 134 | #define ENCODE_PIXEL(e, pix) {encode(e, (pix).b); encode(e, (pix).g); encode(e, (pix).r);} | ||
151 | 135 | #endif | ||
152 | 136 | |||
153 | 137 | |||
154 | 138 | #if defined(LZ_RGB24) || defined(LZ_RGB32) | ||
155 | 139 | #define GET_r(pix) ((pix).r) | ||
156 | 140 | #define GET_g(pix) ((pix).g) | ||
157 | 141 | #define GET_b(pix) ((pix).b) | ||
158 | 142 | #define HASH_FUNC(v, p) { \ | ||
159 | 143 | v = DJB2_START; \ | ||
160 | 144 | DJB2_HASH(v, p[0].r); \ | ||
161 | 145 | DJB2_HASH(v, p[0].g); \ | ||
162 | 146 | DJB2_HASH(v, p[0].b); \ | ||
163 | 147 | DJB2_HASH(v, p[1].r); \ | ||
164 | 148 | DJB2_HASH(v, p[1].g); \ | ||
165 | 149 | DJB2_HASH(v, p[1].b); \ | ||
166 | 150 | DJB2_HASH(v, p[2].r); \ | ||
167 | 151 | DJB2_HASH(v, p[2].g); \ | ||
168 | 152 | DJB2_HASH(v, p[2].b); \ | ||
169 | 153 | v &= HASH_MASK; \ | ||
170 | 154 | } | ||
171 | 155 | #endif | ||
172 | 156 | |||
173 | 157 | #if defined(LZ_RGB16) || defined(LZ_RGB24) || defined(LZ_RGB32) | ||
174 | 158 | #define SAME_PIXEL(p1, p2) (GET_r(p1) == GET_r(p2) && GET_g(p1) == GET_g(p2) && \ | ||
175 | 159 | GET_b(p1) == GET_b(p2)) | ||
176 | 160 | |||
177 | 161 | #endif | ||
178 | 162 | |||
179 | 163 | #define PIXEL_ID(pix_ptr, seg_ptr) (pix_ptr - ((PIXEL *)seg_ptr->lines) + seg_ptr->size_delta) | ||
180 | 164 | |||
181 | 165 | // when encoding, the ref can be in previous segment, and we should check that it doesn't | ||
182 | 166 | // exceeds its bounds. | ||
183 | 167 | // TODO: optimization: when only one chunk exists or when the reference is in the same segment, | ||
184 | 168 | // don't make checks if we reach end of segments | ||
185 | 169 | // TODO: optimize to continue match between segments? | ||
186 | 170 | // TODO: check hash function | ||
187 | 171 | // TODO: check times | ||
188 | 172 | |||
189 | 173 | /* compresses one segment starting from 'from'.*/ | ||
190 | 174 | static void FNAME(compress_seg)(Encoder *encoder, LzImageSegment *seg, PIXEL *from, int copied) | ||
191 | 175 | { | ||
192 | 176 | const PIXEL *ip = from; | ||
193 | 177 | const PIXEL *ip_bound = (PIXEL *)(seg->lines_end) - BOUND_OFFSET; | ||
194 | 178 | const PIXEL *ip_limit = (PIXEL *)(seg->lines_end) - LIMIT_OFFSET; | ||
195 | 179 | HashEntry *hslot; | ||
196 | 180 | int hval; | ||
197 | 181 | int copy = copied; | ||
198 | 182 | |||
199 | 183 | if (copy == 0) { | ||
200 | 184 | encode_copy_count(encoder, MAX_COPY - 1); | ||
201 | 185 | } | ||
202 | 186 | |||
203 | 187 | |||
204 | 188 | while (LZ_EXPECT_CONDITIONAL(ip < ip_limit)) { // TODO: maybe change ip_limit and enabling | ||
205 | 189 | // moving to the next seg | ||
206 | 190 | const PIXEL *ref; | ||
207 | 191 | const PIXEL *ref_limit; | ||
208 | 192 | size_t distance; | ||
209 | 193 | |||
210 | 194 | /* minimum match length */ | ||
211 | 195 | #if defined(LZ_PLT) || defined(LZ_RGB_ALPHA) || defined(LZ_A8) | ||
212 | 196 | size_t len = 3; | ||
213 | 197 | #elif defined(LZ_RGB16) | ||
214 | 198 | size_t len = 2; | ||
215 | 199 | #else | ||
216 | 200 | size_t len = 1; | ||
217 | 201 | #endif | ||
218 | 202 | /* comparison starting-point */ | ||
219 | 203 | const PIXEL *anchor = ip; | ||
220 | 204 | |||
221 | 205 | |||
222 | 206 | |||
223 | 207 | // TODO: RLE without checking if not first byte. | ||
224 | 208 | // TODO: optimize comparisons | ||
225 | 209 | |||
226 | 210 | /* check for a run */ // TODO for RGB we can use less pixels | ||
227 | 211 | if (LZ_EXPECT_CONDITIONAL(ip > (PIXEL *)(seg->lines))) { | ||
228 | 212 | if (SAME_PIXEL(ip[-1], ip[0]) && SAME_PIXEL(ip[0], ip[1]) && SAME_PIXEL(ip[1], ip[2])) { | ||
229 | 213 | distance = 1; | ||
230 | 214 | ip += 3; | ||
231 | 215 | ref = anchor + 2; | ||
232 | 216 | ref_limit = (PIXEL *)(seg->lines_end); | ||
233 | 217 | #if defined(LZ_RGB16) || defined(LZ_RGB24) || defined(LZ_RGB32) | ||
234 | 218 | len = 3; | ||
235 | 219 | #endif | ||
236 | 220 | goto match; | ||
237 | 221 | } | ||
238 | 222 | } | ||
239 | 223 | |||
240 | 224 | /* find potential match */ | ||
241 | 225 | HASH_FUNC(hval, ip); | ||
242 | 226 | hslot = encoder->htab + hval; | ||
243 | 227 | ref = (PIXEL *)(hslot->ref); | ||
244 | 228 | ref_limit = (PIXEL *)(hslot->image_seg->lines_end); | ||
245 | 229 | |||
246 | 230 | /* calculate distance to the match */ | ||
247 | 231 | distance = PIXEL_ID(anchor, seg) - PIXEL_ID(ref, hslot->image_seg); | ||
248 | 232 | |||
249 | 233 | /* update hash table */ | ||
250 | 234 | hslot->image_seg = seg; | ||
251 | 235 | hslot->ref = (uint8_t *)anchor; | ||
252 | 236 | |||
253 | 237 | /* is this a match? check the first 3 pixels */ | ||
254 | 238 | if (distance == 0 || (distance >= MAX_FARDISTANCE)) { | ||
255 | 239 | goto literal; | ||
256 | 240 | } | ||
257 | 241 | /* check if the hval key identical*/ | ||
258 | 242 | // no need to check ref limit here because the word size in the htab is 3 pixels | ||
259 | 243 | if (!SAME_PIXEL(*ref, *ip)) { | ||
260 | 244 | ref++; | ||
261 | 245 | ip++; | ||
262 | 246 | goto literal; | ||
263 | 247 | } | ||
264 | 248 | ref++; | ||
265 | 249 | ip++; | ||
266 | 250 | |||
267 | 251 | /* minimum match length for rgb16 is 2 and for plt and alpha is 3 */ | ||
268 | 252 | #if defined(LZ_PLT) || defined(LZ_RGB_ALPHA) || defined(LZ_RGB16) || defined(LZ_A8) | ||
269 | 253 | if (!SAME_PIXEL(*ref, *ip)) { | ||
270 | 254 | ref++; | ||
271 | 255 | ip++; | ||
272 | 256 | goto literal; | ||
273 | 257 | } | ||
274 | 258 | ref++; | ||
275 | 259 | ip++; | ||
276 | 260 | #endif | ||
277 | 261 | |||
278 | 262 | #if defined(LZ_PLT) || defined(LZ_RGB_ALPHA) || defined(LZ_A8) | ||
279 | 263 | if (!SAME_PIXEL(*ref, *ip)) { | ||
280 | 264 | ref++; | ||
281 | 265 | ip++; | ||
282 | 266 | goto literal; | ||
283 | 267 | } | ||
284 | 268 | ref++; | ||
285 | 269 | ip++; | ||
286 | 270 | #endif | ||
287 | 271 | /* far, needs at least 5-byte match */ | ||
288 | 272 | if (distance >= MAX_DISTANCE) { | ||
289 | 273 | #if defined(LZ_PLT) || defined(LZ_RGB_ALPHA) || defined(LZ_A8) | ||
290 | 274 | if (ref >= (ref_limit - 1)) { | ||
291 | 275 | goto literal; | ||
292 | 276 | } | ||
293 | 277 | #else | ||
294 | 278 | if (ref > (ref_limit - 1)) { | ||
295 | 279 | goto literal; | ||
296 | 280 | } | ||
297 | 281 | #endif | ||
298 | 282 | if (!SAME_PIXEL(*ref, *ip)) { | ||
299 | 283 | ref++; | ||
300 | 284 | ip++; | ||
301 | 285 | goto literal; | ||
302 | 286 | } | ||
303 | 287 | ref++; | ||
304 | 288 | ip++; | ||
305 | 289 | len++; | ||
306 | 290 | #if defined(LZ_PLT) || defined(LZ_RGB_ALPHA) || defined(LZ_A8) | ||
307 | 291 | if (!SAME_PIXEL(*ref, *ip)) { | ||
308 | 292 | ref++; | ||
309 | 293 | ip++; | ||
310 | 294 | goto literal; | ||
311 | 295 | } | ||
312 | 296 | ref++; | ||
313 | 297 | ip++; | ||
314 | 298 | len++; | ||
315 | 299 | #endif | ||
316 | 300 | } | ||
317 | 301 | match: // RLE or dictionary (both are encoded by distance from ref (-1) and length) | ||
318 | 302 | |||
319 | 303 | /* distance is biased */ | ||
320 | 304 | distance--; | ||
321 | 305 | |||
322 | 306 | // ip is located now at the position of the second mismatch. | ||
323 | 307 | // later it will be subtracted by 3 | ||
324 | 308 | |||
325 | 309 | if (!distance) { | ||
326 | 310 | /* zero distance means a run */ | ||
327 | 311 | PIXEL x = *ref; | ||
328 | 312 | while ((ip < ip_bound) && (ref < ref_limit)) { // TODO: maybe separate a run from | ||
329 | 313 | // the same seg or from different | ||
330 | 314 | // ones in order to spare | ||
331 | 315 | // ref < ref_limit | ||
332 | 316 | if (!SAME_PIXEL(*ref, x)) { | ||
333 | 317 | ref++; | ||
334 | 318 | break; | ||
335 | 319 | } else { | ||
336 | 320 | ref++; | ||
337 | 321 | ip++; | ||
338 | 322 | } | ||
339 | 323 | } | ||
340 | 324 | } else { | ||
341 | 325 | // TODO: maybe separate a run from the same seg or from different ones in order | ||
342 | 326 | // to spare ref < ref_limit and that way we can also perform 8 calls of | ||
343 | 327 | // (ref++ != ip++) outside a loop | ||
344 | 328 | for (;;) { | ||
345 | 329 | while ((ip < ip_bound) && (ref < ref_limit)) { | ||
346 | 330 | if (!SAME_PIXEL(*ref, *ip)) { | ||
347 | 331 | ref++; | ||
348 | 332 | ip++; | ||
349 | 333 | break; | ||
350 | 334 | } else { | ||
351 | 335 | ref++; | ||
352 | 336 | ip++; | ||
353 | 337 | } | ||
354 | 338 | } | ||
355 | 339 | break; | ||
356 | 340 | } | ||
357 | 341 | } | ||
358 | 342 | |||
359 | 343 | /* if we have copied something, adjust the copy count */ | ||
360 | 344 | if (copy) { | ||
361 | 345 | /* copy is biased, '0' means 1 byte copy */ | ||
362 | 346 | update_copy_count(encoder, copy - 1); | ||
363 | 347 | } else { | ||
364 | 348 | /* back, to overwrite the copy count */ | ||
365 | 349 | compress_output_prev(encoder); | ||
366 | 350 | } | ||
367 | 351 | |||
368 | 352 | /* reset literal counter */ | ||
369 | 353 | copy = 0; | ||
370 | 354 | |||
371 | 355 | /* length is biased, '1' means a match of 3 pixels for PLT and alpha*/ | ||
372 | 356 | /* for RGB 16 1 means 2 */ | ||
373 | 357 | /* for RGB24/32 1 means 1...*/ | ||
374 | 358 | ip -= 3; | ||
375 | 359 | len = ip - anchor; | ||
376 | 360 | #if defined(LZ_RGB16) | ||
377 | 361 | len++; | ||
378 | 362 | #elif defined(LZ_RGB24) || defined(LZ_RGB32) | ||
379 | 363 | len += 2; | ||
380 | 364 | #endif | ||
381 | 365 | /* encode the match (like fastlz level 2)*/ | ||
382 | 366 | if (distance < MAX_DISTANCE) { // MAX_DISTANCE is 2^13 - 1 | ||
383 | 367 | // when copy is performed, the byte that holds the copy count is smaller than 32. | ||
384 | 368 | // When there is a reference, the first byte is always larger then 32 | ||
385 | 369 | |||
386 | 370 | // 3 bits = length, 5 bits = 5 MSB of distance, 8 bits = 8 LSB of distance | ||
387 | 371 | if (len < 7) { | ||
388 | 372 | encode(encoder, (uint8_t)((len << 5) + (distance >> 8))); | ||
389 | 373 | encode(encoder, (uint8_t)(distance & 255)); | ||
390 | 374 | } else { // more than 3 bits are needed for length | ||
391 | 375 | // 3 bits 7, 5 bits = 5 MSB of distance, next bytes are 255 till we | ||
392 | 376 | // receive a smaller number, last byte = 8 LSB of distance | ||
393 | 377 | encode(encoder, (uint8_t)((7 << 5) + (distance >> 8))); | ||
394 | 378 | for (len -= 7; len >= 255; len -= 255) { | ||
395 | 379 | encode(encoder, 255); | ||
396 | 380 | } | ||
397 | 381 | encode(encoder, (uint8_t)len); | ||
398 | 382 | encode(encoder, (uint8_t)(distance & 255)); | ||
399 | 383 | } | ||
400 | 384 | } else { | ||
401 | 385 | /* far away */ | ||
402 | 386 | if (len < 7) { // the max_far_distance is ~2^16+2^13 so two more bytes are needed | ||
403 | 387 | // 3 bits = length, 5 bits = 5 MSB of MAX_DISTANCE, 8 bits = 8 LSB of MAX_DISTANCE, | ||
404 | 388 | // 8 bits = 8 MSB distance-MAX_distance (smaller than 2^16),8 bits=8 LSB of | ||
405 | 389 | // distance-MAX_distance | ||
406 | 390 | distance -= MAX_DISTANCE; | ||
407 | 391 | encode(encoder, (uint8_t)((len << 5) + 31)); | ||
408 | 392 | encode(encoder, (uint8_t)255); | ||
409 | 393 | encode(encoder, (uint8_t)(distance >> 8)); | ||
410 | 394 | encode(encoder, (uint8_t)(distance & 255)); | ||
411 | 395 | } else { | ||
412 | 396 | // same as before, but the first byte is followed by the left overs of len | ||
413 | 397 | distance -= MAX_DISTANCE; | ||
414 | 398 | encode(encoder, (uint8_t)((7 << 5) + 31)); | ||
415 | 399 | for (len -= 7; len >= 255; len -= 255) { | ||
416 | 400 | encode(encoder, 255); | ||
417 | 401 | } | ||
418 | 402 | encode(encoder, (uint8_t)len); | ||
419 | 403 | encode(encoder, 255); | ||
420 | 404 | encode(encoder, (uint8_t)(distance >> 8)); | ||
421 | 405 | encode(encoder, (uint8_t)(distance & 255)); | ||
422 | 406 | } | ||
423 | 407 | } | ||
424 | 408 | |||
425 | 409 | /* update the hash at match boundary */ | ||
426 | 410 | #if defined(LZ_RGB16) || defined(LZ_RGB24) || defined(LZ_RGB32) | ||
427 | 411 | if (ip > anchor) { | ||
428 | 412 | #endif | ||
429 | 413 | HASH_FUNC(hval, ip); | ||
430 | 414 | encoder->htab[hval].ref = (uint8_t *)ip; | ||
431 | 415 | ip++; | ||
432 | 416 | encoder->htab[hval].image_seg = seg; | ||
433 | 417 | #if defined(LZ_RGB16) || defined(LZ_RGB24) || defined(LZ_RGB32) | ||
434 | 418 | } else {ip++; | ||
435 | 419 | } | ||
436 | 420 | #endif | ||
437 | 421 | #if defined(LZ_RGB24) || defined(LZ_RGB32) | ||
438 | 422 | if (ip > anchor) { | ||
439 | 423 | #endif | ||
440 | 424 | HASH_FUNC(hval, ip); | ||
441 | 425 | encoder->htab[hval].ref = (uint8_t *)ip; | ||
442 | 426 | ip++; | ||
443 | 427 | encoder->htab[hval].image_seg = seg; | ||
444 | 428 | #if defined(LZ_RGB24) || defined(LZ_RGB32) | ||
445 | 429 | } else {ip++; | ||
446 | 430 | } | ||
447 | 431 | #endif | ||
448 | 432 | /* assuming literal copy */ | ||
449 | 433 | encode_copy_count(encoder, MAX_COPY - 1); | ||
450 | 434 | continue; | ||
451 | 435 | |||
452 | 436 | literal: | ||
453 | 437 | ENCODE_PIXEL(encoder, *anchor); | ||
454 | 438 | anchor++; | ||
455 | 439 | ip = anchor; | ||
456 | 440 | copy++; | ||
457 | 441 | |||
458 | 442 | if (LZ_UNEXPECT_CONDITIONAL(copy == MAX_COPY)) { | ||
459 | 443 | copy = 0; | ||
460 | 444 | encode_copy_count(encoder, MAX_COPY - 1); | ||
461 | 445 | } | ||
462 | 446 | } // END LOOP (ip < ip_limit) | ||
463 | 447 | |||
464 | 448 | |||
465 | 449 | /* left-over as literal copy */ | ||
466 | 450 | ip_bound++; | ||
467 | 451 | while (ip <= ip_bound) { | ||
468 | 452 | ENCODE_PIXEL(encoder, *ip); | ||
469 | 453 | ip++; | ||
470 | 454 | copy++; | ||
471 | 455 | if (copy == MAX_COPY) { | ||
472 | 456 | copy = 0; | ||
473 | 457 | encode_copy_count(encoder, MAX_COPY - 1); | ||
474 | 458 | } | ||
475 | 459 | } | ||
476 | 460 | |||
477 | 461 | /* if we have copied something, adjust the copy length */ | ||
478 | 462 | if (copy) { | ||
479 | 463 | update_copy_count(encoder, copy - 1); | ||
480 | 464 | } else { | ||
481 | 465 | compress_output_prev(encoder); // in case we created a new buffer for copy, check that | ||
482 | 466 | // red_worker could handle size that do not contain the | ||
483 | 467 | // ne buffer | ||
484 | 468 | } | ||
485 | 469 | } | ||
486 | 470 | |||
487 | 471 | |||
488 | 472 | /* initializes the hash table. if the file is very small, copies it. | ||
489 | 473 | copies the first two pixels of the first segment, and sends the segments | ||
490 | 474 | one by one to compress_seg. | ||
491 | 475 | the number of bytes compressed are stored inside encoder. | ||
492 | 476 | */ | ||
493 | 477 | static void FNAME(compress)(Encoder *encoder) | ||
494 | 478 | { | ||
495 | 479 | LzImageSegment *cur_seg = encoder->head_image_segs; | ||
496 | 480 | HashEntry *hslot; | ||
497 | 481 | PIXEL *ip; | ||
498 | 482 | PIXEL *ip_start; | ||
499 | 483 | |||
500 | 484 | // fetch the first image segment that is not too small | ||
501 | 485 | while (cur_seg && ((((PIXEL *)cur_seg->lines_end) - ((PIXEL *)cur_seg->lines)) < 4)) { | ||
502 | 486 | ip_start = cur_seg->lines; | ||
503 | 487 | // coping the segment | ||
504 | 488 | if (cur_seg->lines != cur_seg->lines_end) { | ||
505 | 489 | ip = (PIXEL *)cur_seg->lines; | ||
506 | 490 | // Note: we assume MAX_COPY > 3 | ||
507 | 491 | encode_copy_count(encoder, (uint8_t)( | ||
508 | 492 | (((PIXEL *)cur_seg->lines_end) - ((PIXEL *)cur_seg->lines)) - 1)); | ||
509 | 493 | while (ip < (PIXEL *)cur_seg->lines_end) { | ||
510 | 494 | ENCODE_PIXEL(encoder, *ip); | ||
511 | 495 | ip++; | ||
512 | 496 | } | ||
513 | 497 | } | ||
514 | 498 | cur_seg = cur_seg->next; | ||
515 | 499 | } | ||
516 | 500 | |||
517 | 501 | if (!cur_seg) { | ||
518 | 502 | return; | ||
519 | 503 | } | ||
520 | 504 | |||
521 | 505 | ip = (PIXEL *)cur_seg->lines; | ||
522 | 506 | |||
523 | 507 | /* initialize hash table */ | ||
524 | 508 | for (hslot = encoder->htab; hslot < encoder->htab + HASH_SIZE; hslot++) { | ||
525 | 509 | hslot->ref = (uint8_t*)ip; | ||
526 | 510 | hslot->image_seg = cur_seg; | ||
527 | 511 | } | ||
528 | 512 | |||
529 | 513 | encode_copy_count(encoder, MAX_COPY - 1); | ||
530 | 514 | ENCODE_PIXEL(encoder, *ip); | ||
531 | 515 | ip++; | ||
532 | 516 | ENCODE_PIXEL(encoder, *ip); | ||
533 | 517 | ip++; | ||
534 | 518 | |||
535 | 519 | // compressing the first segment | ||
536 | 520 | FNAME(compress_seg)(encoder, cur_seg, ip, 2); | ||
537 | 521 | |||
538 | 522 | // compressing the next segments | ||
539 | 523 | for (cur_seg = cur_seg->next; cur_seg; cur_seg = cur_seg->next) { | ||
540 | 524 | FNAME(compress_seg)(encoder, cur_seg, (PIXEL *)cur_seg->lines, 0); | ||
541 | 525 | } | ||
542 | 526 | } | ||
543 | 527 | |||
544 | 528 | #undef FNAME | ||
545 | 529 | #undef PIXEL_ID | ||
546 | 530 | #undef PIXEL | ||
547 | 531 | #undef ENCODE_PIXEL | ||
548 | 532 | #undef SAME_PIXEL | ||
549 | 533 | #undef LZ_READU16 | ||
550 | 534 | #undef HASH_FUNC | ||
551 | 535 | #undef BYTES_TO_16 | ||
552 | 536 | #undef HASH_FUNC_16 | ||
553 | 537 | #undef GET_r | ||
554 | 538 | #undef GET_g | ||
555 | 539 | #undef GET_b | ||
556 | 540 | #undef GET_CODE | ||
557 | 541 | #undef LZ_PLT | ||
558 | 542 | #undef LZ_RGB_ALPHA | ||
559 | 543 | #undef LZ_RGB16 | ||
560 | 544 | #undef LZ_RGB24 | ||
561 | 545 | #undef LZ_RGB32 | ||
562 | 546 | #undef LZ_A8 | ||
563 | 547 | #undef HASH_FUNC2 | ||
564 | 0 | 548 | ||
565 | === modified file 'debian/changelog' | |||
566 | --- debian/changelog 2013-02-01 20:25:36 +0000 | |||
567 | +++ debian/changelog 2013-02-01 22:40:24 +0000 | |||
568 | @@ -1,7 +1,7 @@ | |||
570 | 1 | spice (0.12.0-0ubuntu2) UNRELEASED; urgency=low | 1 | spice (0.12.0-0ubuntu2) raring; urgency=low |
571 | 2 | 2 | ||
574 | 3 | * debian/patches/fix-compiler-warnings.patch: fix compiler warnings in | 3 | * debian/patches/fix-missing-PIXEL-pointer-cast: address compiler warning in |
575 | 4 | the common and server code. | 4 | the spice-common code. |
576 | 5 | 5 | ||
577 | 6 | -- Serge Hallyn <serge.hallyn@ubuntu.com> Fri, 01 Feb 2013 14:24:43 -0600 | 6 | -- Serge Hallyn <serge.hallyn@ubuntu.com> Fri, 01 Feb 2013 14:24:43 -0600 |
578 | 7 | 7 | ||
579 | 8 | 8 | ||
580 | === removed file 'debian/patches/fix-compiler-warnings.patch' | |||
581 | --- debian/patches/fix-compiler-warnings.patch 2013-02-01 20:25:36 +0000 | |||
582 | +++ debian/patches/fix-compiler-warnings.patch 1970-01-01 00:00:00 +0000 | |||
583 | @@ -1,27 +0,0 @@ | |||
584 | 1 | Index: spice-0.12.0/spice-common/common/backtrace.c | ||
585 | 2 | =================================================================== | ||
586 | 3 | --- spice-0.12.0.orig/spice-common/common/backtrace.c 2012-08-22 16:33:04.000000000 +0000 | ||
587 | 4 | +++ spice-0.12.0/spice-common/common/backtrace.c 2013-02-01 19:28:10.127899552 +0000 | ||
588 | 5 | @@ -78,7 +78,8 @@ | ||
589 | 6 | /* CHILD */ | ||
590 | 7 | char parent[16]; | ||
591 | 8 | |||
592 | 9 | - seteuid(0); | ||
593 | 10 | + if (seteuid(0)) /* ERROR */ | ||
594 | 11 | + return -1; | ||
595 | 12 | close(STDIN_FILENO); | ||
596 | 13 | close(STDOUT_FILENO); | ||
597 | 14 | dup2(pipefd[1],STDOUT_FILENO); | ||
598 | 15 | Index: spice-0.12.0/spice-common/common/lz_compress_tmpl.c | ||
599 | 16 | =================================================================== | ||
600 | 17 | --- spice-0.12.0.orig/spice-common/common/lz_compress_tmpl.c 2012-09-02 17:52:16.000000000 +0000 | ||
601 | 18 | +++ spice-0.12.0/spice-common/common/lz_compress_tmpl.c 2013-02-01 19:57:28.051899552 +0000 | ||
602 | 19 | @@ -483,7 +483,7 @@ | ||
603 | 20 | |||
604 | 21 | // fetch the first image segment that is not too small | ||
605 | 22 | while (cur_seg && ((((PIXEL *)cur_seg->lines_end) - ((PIXEL *)cur_seg->lines)) < 4)) { | ||
606 | 23 | - ip_start = cur_seg->lines; | ||
607 | 24 | + ip_start = (PIXEL *) cur_seg->lines; | ||
608 | 25 | // coping the segment | ||
609 | 26 | if (cur_seg->lines != cur_seg->lines_end) { | ||
610 | 27 | ip = (PIXEL *)cur_seg->lines; | ||
611 | 28 | 0 | ||
612 | === added file 'debian/patches/fix-missing-PIXEL-pointer-cast' | |||
613 | --- debian/patches/fix-missing-PIXEL-pointer-cast 1970-01-01 00:00:00 +0000 | |||
614 | +++ debian/patches/fix-missing-PIXEL-pointer-cast 2013-02-01 22:40:24 +0000 | |||
615 | @@ -0,0 +1,17 @@ | |||
616 | 1 | Description: Address a compilation warning due to missing typecast | ||
617 | 2 | Author: Serge Hallyn <serge.hallyn@ubuntu.com> | ||
618 | 3 | Forwarded: yes | ||
619 | 4 | |||
620 | 5 | Index: spice/spice-common/common/lz_compress_tmpl.c | ||
621 | 6 | =================================================================== | ||
622 | 7 | --- spice.orig/spice-common/common/lz_compress_tmpl.c 2013-02-01 16:27:43.000000000 -0600 | ||
623 | 8 | +++ spice/spice-common/common/lz_compress_tmpl.c 2013-02-01 16:34:55.205042276 -0600 | ||
624 | 9 | @@ -483,7 +483,7 @@ | ||
625 | 10 | |||
626 | 11 | // fetch the first image segment that is not too small | ||
627 | 12 | while (cur_seg && ((((PIXEL *)cur_seg->lines_end) - ((PIXEL *)cur_seg->lines)) < 4)) { | ||
628 | 13 | - ip_start = cur_seg->lines; | ||
629 | 14 | + ip_start = (PIXEL *)cur_seg->lines; | ||
630 | 15 | // coping the segment | ||
631 | 16 | if (cur_seg->lines != cur_seg->lines_end) { | ||
632 | 17 | ip = (PIXEL *)cur_seg->lines; | ||
633 | 0 | 18 | ||
634 | === modified file 'debian/patches/series' | |||
635 | --- debian/patches/series 2013-02-01 20:25:36 +0000 | |||
636 | +++ debian/patches/series 2013-02-01 22:40:24 +0000 | |||
637 | @@ -1,3 +1,3 @@ | |||
638 | 1 | link-libspice-server-with-libm-libpthread.patch | 1 | link-libspice-server-with-libm-libpthread.patch |
639 | 2 | make-celt-to-be-optional.patch | 2 | make-celt-to-be-optional.patch |
641 | 3 | fix-compiler-warnings.patch | 3 | fix-missing-PIXEL-pointer-cast |
642 | 4 | 4 | ||
643 | === modified file 'spice-common/common/lz_compress_tmpl.c' | |||
644 | --- spice-common/common/lz_compress_tmpl.c 2013-02-01 20:42:32 +0000 | |||
645 | +++ spice-common/common/lz_compress_tmpl.c 2013-02-01 22:40:24 +0000 | |||
646 | @@ -483,7 +483,11 @@ | |||
647 | 483 | 483 | ||
648 | 484 | // fetch the first image segment that is not too small | 484 | // fetch the first image segment that is not too small |
649 | 485 | while (cur_seg && ((((PIXEL *)cur_seg->lines_end) - ((PIXEL *)cur_seg->lines)) < 4)) { | 485 | while (cur_seg && ((((PIXEL *)cur_seg->lines_end) - ((PIXEL *)cur_seg->lines)) < 4)) { |
650 | 486 | <<<<<<< TREE | ||
651 | 486 | ip_start = cur_seg->lines; | 487 | ip_start = cur_seg->lines; |
652 | 488 | ======= | ||
653 | 489 | ip_start = (PIXEL *)cur_seg->lines; | ||
654 | 490 | >>>>>>> MERGE-SOURCE | ||
655 | 487 | // coping the segment | 491 | // coping the segment |
656 | 488 | if (cur_seg->lines != cur_seg->lines_end) { | 492 | if (cur_seg->lines != cur_seg->lines_end) { |
657 | 489 | ip = (PIXEL *)cur_seg->lines; | 493 | ip = (PIXEL *)cur_seg->lines; |