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