20 #include <freerdp/config.h>
22 #include <freerdp/codec/bitmap.h>
23 #include <freerdp/codec/planar.h>
25 static INLINE UINT16 GETPIXEL16(
const void* WINPR_RESTRICT d, UINT32 x, UINT32 y, UINT32 w)
27 const BYTE* WINPR_RESTRICT src = (
const BYTE*)d + ((y * w + x) *
sizeof(UINT16));
28 return (UINT16)(((UINT16)src[1] << 8) | (UINT16)src[0]);
31 static INLINE UINT32 GETPIXEL32(
const void* WINPR_RESTRICT d, UINT32 x, UINT32 y, UINT32 w)
33 const BYTE* WINPR_RESTRICT src = (
const BYTE*)d + ((y * w + x) *
sizeof(UINT32));
34 return (((UINT32)src[3]) << 24) | (((UINT32)src[2]) << 16) | (((UINT32)src[1]) << 8) |
39 static INLINE UINT16 IN_PIXEL16(
const void* WINPR_RESTRICT in_ptr, UINT32 in_x, UINT32 in_y,
40 UINT32 in_w, UINT16 in_last_pixel)
45 return GETPIXEL16(in_ptr, in_x, in_y, in_w);
51 static INLINE UINT32 IN_PIXEL32(
const void* WINPR_RESTRICT in_ptr, UINT32 in_x, UINT32 in_y,
52 UINT32 in_w, UINT32 in_last_pixel)
57 return GETPIXEL32(in_ptr, in_x, in_y, in_w);
64 static INLINE UINT16 out_color_count_2(UINT16 in_count,
wStream* WINPR_RESTRICT in_s,
71 const BYTE temp = ((0x3 << 5) | in_count) & 0xFF;
72 Stream_Write_UINT8(in_s, temp);
74 else if (in_count < 256 + 32)
76 const BYTE temp = (in_count - 32) & 0xFF;
77 Stream_Write_UINT8(in_s, 0x60);
78 Stream_Write_UINT8(in_s, temp);
82 Stream_Write_UINT8(in_s, 0xf3);
83 Stream_Write_UINT16(in_s, in_count);
86 Stream_Write_UINT16(in_s, in_data);
91 #define OUT_COLOR_COUNT2(in_count, in_s, in_data) \
92 in_count = out_color_count_2(in_count, in_s, in_data)
96 static INLINE UINT16 out_color_count_3(UINT16 in_count,
wStream* WINPR_RESTRICT in_s,
103 const BYTE temp = ((0x3 << 5) | in_count) & 0xFF;
104 Stream_Write_UINT8(in_s, temp);
106 else if (in_count < 256 + 32)
108 const BYTE temp = (in_count - 32) & 0xFF;
109 Stream_Write_UINT8(in_s, 0x60);
110 Stream_Write_UINT8(in_s, temp);
114 Stream_Write_UINT8(in_s, 0xf3);
115 Stream_Write_UINT16(in_s, in_count);
118 Stream_Write_UINT8(in_s, in_data & 0xFF);
120 Stream_Write_UINT8(in_s, (in_data >> 8) & 0xFF);
121 Stream_Write_UINT8(in_s, (in_data >> 16) & 0xFF);
127 #define OUT_COLOR_COUNT3(in_count, in_s, in_data) \
128 in_count = out_color_count_3(in_count, in_s, in_data)
132 static INLINE UINT16 out_copy_count_2(UINT16 in_count,
wStream* WINPR_RESTRICT in_s,
133 wStream* WINPR_RESTRICT in_data)
140 const BYTE temp = ((0x4 << 5) | in_count) & 0xFF;
141 Stream_Write_UINT8(in_s, temp);
143 else if (in_count < 256 + 32)
145 const BYTE temp = (in_count - 32) & 0xFF;
146 Stream_Write_UINT8(in_s, 0x80);
147 Stream_Write_UINT8(in_s, temp);
151 Stream_Write_UINT8(in_s, 0xf4);
152 Stream_Write_UINT16(in_s, in_count);
155 Stream_Write(in_s, Stream_Buffer(in_data), 2ULL * in_count);
158 Stream_SetPosition(in_data, 0);
161 #define OUT_COPY_COUNT2(in_count, in_s, in_data) \
162 in_count = out_copy_count_2(in_count, in_s, in_data)
165 static INLINE UINT16 out_copy_count_3(UINT16 in_count,
wStream* WINPR_RESTRICT in_s,
166 wStream* WINPR_RESTRICT in_data)
172 const BYTE temp = ((0x4 << 5) | in_count) & 0xFF;
173 Stream_Write_UINT8(in_s, temp);
175 else if (in_count < 256 + 32)
177 const BYTE temp = (in_count - 32) & 0xFF;
178 Stream_Write_UINT8(in_s, 0x80);
179 Stream_Write_UINT8(in_s, temp);
183 Stream_Write_UINT8(in_s, 0xf4);
184 Stream_Write_UINT16(in_s, in_count);
187 Stream_Write(in_s, Stream_Pointer(in_data), 3ULL * in_count);
190 Stream_SetPosition(in_data, 0);
193 #define OUT_COPY_COUNT3(in_count, in_s, in_data) \
194 in_count = out_copy_count_3(in_count, in_s, in_data)
198 static INLINE UINT16 out_bicolor_count_2(UINT16 in_count,
wStream* WINPR_RESTRICT in_s,
199 UINT16 in_color1, UINT16 in_color2)
203 if (in_count / 2 < 16)
205 const BYTE temp = ((0xe << 4) | (in_count / 2)) & 0xFF;
206 Stream_Write_UINT8(in_s, temp);
208 else if (in_count / 2 < 256 + 16)
210 const BYTE temp = (in_count / 2 - 16) & 0xFF;
211 Stream_Write_UINT8(in_s, 0xe0);
212 Stream_Write_UINT8(in_s, temp);
216 Stream_Write_UINT8(in_s, 0xf8);
217 Stream_Write_UINT16(in_s, in_count / 2);
220 Stream_Write_UINT16(in_s, in_color1);
221 Stream_Write_UINT16(in_s, in_color2);
227 #define OUT_BICOLOR_COUNT2(in_count, in_s, in_color1, in_color2) \
228 in_count = out_bicolor_count_2(in_count, in_s, in_color1, in_color2)
232 static INLINE UINT16 out_bicolor_count_3(UINT16 in_count,
wStream* WINPR_RESTRICT in_s,
233 UINT32 in_color1, UINT32 in_color2)
237 if (in_count / 2 < 16)
239 const BYTE temp = ((0xe << 4) | (in_count / 2)) & 0xFF;
240 Stream_Write_UINT8(in_s, temp);
242 else if (in_count / 2 < 256 + 16)
244 const BYTE temp = (in_count / 2 - 16) & 0xFF;
245 Stream_Write_UINT8(in_s, 0xe0);
246 Stream_Write_UINT8(in_s, temp);
250 Stream_Write_UINT8(in_s, 0xf8);
251 Stream_Write_UINT16(in_s, in_count / 2);
254 Stream_Write_UINT8(in_s, in_color1 & 0xFF);
255 Stream_Write_UINT8(in_s, (in_color1 >> 8) & 0xFF);
256 Stream_Write_UINT8(in_s, (in_color1 >> 16) & 0xFF);
257 Stream_Write_UINT8(in_s, in_color2 & 0xFF);
258 Stream_Write_UINT8(in_s, (in_color2 >> 8) & 0xFF);
259 Stream_Write_UINT8(in_s, (in_color2 >> 16) & 0xFF);
265 #define OUT_BICOLOR_COUNT3(in_count, in_s, in_color1, in_color2) \
266 in_count = out_bicolor_count_3(in_count, in_s, in_color1, in_color2)
270 static INLINE UINT16 out_fill_count_2(UINT16 in_count,
wStream* WINPR_RESTRICT in_s)
276 Stream_Write_UINT8(in_s, in_count & 0xFF);
278 else if (in_count < 256 + 32)
280 const BYTE temp = (in_count - 32) & 0xFF;
281 Stream_Write_UINT8(in_s, 0x0);
282 Stream_Write_UINT8(in_s, temp);
286 Stream_Write_UINT8(in_s, 0xf0);
287 Stream_Write_UINT16(in_s, in_count);
294 #define OUT_FILL_COUNT2(in_count, in_s) in_count = out_fill_count_2(in_count, in_s)
298 static INLINE UINT16 out_fill_count_3(UINT16 in_count,
wStream* WINPR_RESTRICT in_s)
304 Stream_Write_UINT8(in_s, in_count & 0xFF);
306 else if (in_count < 256 + 32)
308 const BYTE temp = (in_count - 32) & 0xFF;
309 Stream_Write_UINT8(in_s, 0x0);
310 Stream_Write_UINT8(in_s, temp);
314 Stream_Write_UINT8(in_s, 0xf0);
315 Stream_Write_UINT16(in_s, in_count);
321 #define OUT_FILL_COUNT3(in_count, in_s) in_count = out_fill_count_3(in_count, in_s)
325 static INLINE UINT16 out_mix_count_2(UINT16 in_count,
wStream* WINPR_RESTRICT in_s)
331 const BYTE temp = ((0x1 << 5) | in_count) & 0xFF;
332 Stream_Write_UINT8(in_s, temp);
334 else if (in_count < 256 + 32)
336 const BYTE temp = (in_count - 32) & 0xFF;
337 Stream_Write_UINT8(in_s, 0x20);
338 Stream_Write_UINT8(in_s, temp);
342 Stream_Write_UINT8(in_s, 0xf1);
343 Stream_Write_UINT16(in_s, in_count);
349 #define OUT_MIX_COUNT2(in_count, in_s) in_count = out_mix_count_2(in_count, in_s)
353 static INLINE UINT16 out_mix_count_3(UINT16 in_count,
wStream* WINPR_RESTRICT in_s)
359 const BYTE temp = ((0x1 << 5) | in_count) & 0xFF;
360 Stream_Write_UINT8(in_s, temp);
362 else if (in_count < 256 + 32)
364 const BYTE temp = (in_count - 32) & 0xFF;
365 Stream_Write_UINT8(in_s, 0x20);
366 Stream_Write_UINT8(in_s, temp);
370 Stream_Write_UINT8(in_s, 0xf1);
371 Stream_Write_UINT16(in_s, in_count);
378 #define OUT_MIX_COUNT3(in_count, in_s) in_count = out_mix_count_3(in_count, in_s)
382 static INLINE UINT16 out_from_count_2(UINT16 in_count,
wStream* WINPR_RESTRICT in_s,
383 const char* WINPR_RESTRICT in_mask,
size_t in_mask_len)
387 if ((in_count % 8) == 0 && in_count < 249)
389 const BYTE temp = ((0x2 << 5) | (in_count / 8)) & 0xFF;
390 Stream_Write_UINT8(in_s, temp);
392 else if (in_count < 256)
394 const BYTE temp = (in_count - 1) & 0xFF;
395 Stream_Write_UINT8(in_s, 0x40);
396 Stream_Write_UINT8(in_s, temp);
400 Stream_Write_UINT8(in_s, 0xf2);
401 Stream_Write_UINT16(in_s, in_count);
404 Stream_Write(in_s, in_mask, in_mask_len);
409 #define OUT_FOM_COUNT2(in_count, in_s, in_mask, in_mask_len) \
410 in_count = out_from_count_2(in_count, in_s, in_mask, in_mask_len)
414 static INLINE UINT16 out_from_count_3(UINT16 in_count,
wStream* WINPR_RESTRICT in_s,
415 const char* WINPR_RESTRICT in_mask,
size_t in_mask_len)
419 if ((in_count % 8) == 0 && in_count < 249)
421 const BYTE temp = ((0x2 << 5) | (in_count / 8)) & 0xFF;
422 Stream_Write_UINT8(in_s, temp);
424 else if (in_count < 256)
426 const BYTE temp = (in_count - 1) & 0xFF;
427 Stream_Write_UINT8(in_s, 0x40);
428 Stream_Write_UINT8(in_s, temp);
432 Stream_Write_UINT8(in_s, 0xf2);
433 Stream_Write_UINT16(in_s, in_count);
436 Stream_Write(in_s, in_mask, in_mask_len);
441 #define OUT_FOM_COUNT3(in_count, in_s, in_mask, in_mask_len) \
442 in_count = out_from_count_3(in_count, in_s, in_mask, in_mask_len)
444 #define TEST_FILL ((last_line == 0 && pixel == 0) || (last_line != 0 && pixel == ypixel))
445 #define TEST_MIX ((last_line == 0 && pixel == mix) || (last_line != 0 && pixel == (ypixel ^ mix)))
446 #define TEST_FOM TEST_FILL || TEST_MIX
447 #define TEST_COLOR pixel == last_pixel
448 #define TEST_BICOLOR \
449 ((pixel != last_pixel) && \
450 ((!bicolor_spin && (pixel == bicolor1) && (last_pixel == bicolor2)) || \
451 (bicolor_spin && (pixel == bicolor2) && (last_pixel == bicolor1))))
452 #define RESET_COUNTS \
461 bicolor_spin = FALSE; \
464 static INLINE SSIZE_T freerdp_bitmap_compress_24(
const void* WINPR_RESTRICT srcData, UINT32 width,
465 UINT32 height,
wStream* WINPR_RESTRICT s,
466 UINT32 byte_limit, UINT32 start_line,
467 wStream* WINPR_RESTRICT temp_s, UINT32 e)
469 char fom_mask[8192] = { 0 };
470 SSIZE_T lines_sent = 0;
472 UINT16 color_count = 0;
473 UINT32 last_pixel = 0;
474 UINT32 last_ypixel = 0;
475 UINT16 bicolor_count = 0;
478 BOOL bicolor_spin = FALSE;
479 UINT32 end = width + e;
480 UINT32 out_count = end * 3;
481 UINT16 fill_count = 0;
482 UINT16 mix_count = 0;
483 const UINT32 mix = 0xFFFFFF;
484 UINT16 fom_count = 0;
485 size_t fom_mask_len = 0;
486 const char* start = (
const char*)srcData;
487 const char* line = start + 4ULL * width * start_line;
488 const char* last_line = NULL;
490 while ((line >= start) && (out_count < 32768))
492 size_t i = Stream_GetPosition(s) + 3ULL * count;
494 if ((i - (3ULL * color_count) >= byte_limit) &&
495 (i - (3ULL * bicolor_count) >= byte_limit) && (i - (3ULL * fill_count) >= byte_limit) &&
496 (i - (3ULL * mix_count) >= byte_limit) && (i - (3ULL * fom_count) >= byte_limit))
501 out_count += end * 3;
503 for (UINT32 j = 0; j < end; j++)
506 const UINT32 pixel = IN_PIXEL32(line, j, 0, width, last_pixel);
507 const UINT32 ypixel = IN_PIXEL32(last_line, j, 0, width, last_ypixel);
511 if (fill_count > 3 && fill_count >= color_count && fill_count >= bicolor_count &&
512 fill_count >= mix_count && fill_count >= fom_count)
514 if (fill_count > count)
518 OUT_COPY_COUNT3(count, s, temp_s);
519 OUT_FILL_COUNT3(fill_count, s);
528 if (mix_count > 3 && mix_count >= fill_count && mix_count >= bicolor_count &&
529 mix_count >= color_count && mix_count >= fom_count)
531 if (mix_count > count)
535 OUT_COPY_COUNT3(count, s, temp_s);
536 OUT_MIX_COUNT3(mix_count, s);
545 if (color_count > 3 && color_count >= fill_count && color_count >= bicolor_count &&
546 color_count >= mix_count && color_count >= fom_count)
548 if (color_count > count)
551 count -= color_count;
552 OUT_COPY_COUNT3(count, s, temp_s);
553 OUT_COLOR_COUNT3(color_count, s, last_pixel);
562 if (bicolor_count > 3 && bicolor_count >= fill_count &&
563 bicolor_count >= color_count && bicolor_count >= mix_count &&
564 bicolor_count >= fom_count)
566 if ((bicolor_count % 2) != 0)
569 if (bicolor_count > count)
572 count -= bicolor_count;
573 OUT_COPY_COUNT3(count, s, temp_s);
574 OUT_BICOLOR_COUNT3(bicolor_count, s, bicolor2, bicolor1);
579 bicolor1 = last_pixel;
581 bicolor_spin = FALSE;
586 if (fom_count > 3 && fom_count >= fill_count && fom_count >= color_count &&
587 fom_count >= mix_count && fom_count >= bicolor_count)
589 if (fom_count > count)
593 OUT_COPY_COUNT3(count, s, temp_s);
594 OUT_FOM_COUNT3(fom_count, s, fom_mask, fom_mask_len);
619 bicolor_spin = !bicolor_spin;
625 if ((fom_count % 8) == 0)
627 fom_mask[fom_mask_len] = 0;
631 if (pixel == (ypixel ^ mix))
633 fom_mask[fom_mask_len - 1] |= (1 << (fom_count % 8));
639 Stream_Write_UINT8(temp_s, pixel & 0xff);
640 Stream_Write_UINT8(temp_s, (pixel >> 8) & 0xff);
641 Stream_Write_UINT8(temp_s, (pixel >> 16) & 0xff);
644 last_ypixel = ypixel;
650 if (fill_count > 3 && fill_count >= color_count && fill_count >= bicolor_count &&
651 fill_count >= mix_count && fill_count >= fom_count)
653 if (fill_count > count)
657 OUT_COPY_COUNT3(count, s, temp_s);
658 OUT_FILL_COUNT3(fill_count, s);
664 if (mix_count > 3 && mix_count >= fill_count && mix_count >= bicolor_count &&
665 mix_count >= color_count && mix_count >= fom_count)
667 if (mix_count > count)
671 OUT_COPY_COUNT3(count, s, temp_s);
672 OUT_MIX_COUNT3(mix_count, s);
678 if (fom_count > 3 && fom_count >= fill_count && fom_count >= color_count &&
679 fom_count >= mix_count && fom_count >= bicolor_count)
681 if (fom_count > count)
685 OUT_COPY_COUNT3(count, s, temp_s);
686 OUT_FOM_COUNT3(fom_count, s, fom_mask, fom_mask_len);
695 line = line - 4ULL * width;
700 Stream_SetPosition(temp_s, 0);
702 if (fill_count > 3 && fill_count >= color_count && fill_count >= bicolor_count &&
703 fill_count >= mix_count && fill_count >= fom_count)
705 if (fill_count > count)
709 OUT_COPY_COUNT3(count, s, temp_s);
710 OUT_FILL_COUNT3(fill_count, s);
712 else if (mix_count > 3 && mix_count >= color_count && mix_count >= bicolor_count &&
713 mix_count >= fill_count && mix_count >= fom_count)
715 if (mix_count > count)
719 OUT_COPY_COUNT3(count, s, temp_s);
720 OUT_MIX_COUNT3(mix_count, s);
722 else if (color_count > 3 && color_count >= mix_count && color_count >= bicolor_count &&
723 color_count >= fill_count && color_count >= fom_count)
725 if (color_count > count)
728 count -= color_count;
729 OUT_COPY_COUNT3(count, s, temp_s);
730 OUT_COLOR_COUNT3(color_count, s, last_pixel);
732 else if (bicolor_count > 3 && bicolor_count >= mix_count && bicolor_count >= color_count &&
733 bicolor_count >= fill_count && bicolor_count >= fom_count)
735 if ((bicolor_count % 2) != 0)
738 if (bicolor_count > count)
741 count -= bicolor_count;
742 OUT_COPY_COUNT3(count, s, temp_s);
743 OUT_BICOLOR_COUNT3(bicolor_count, s, bicolor2, bicolor1);
745 if (bicolor_count > count)
748 count -= bicolor_count;
749 OUT_COPY_COUNT3(count, s, temp_s);
750 OUT_BICOLOR_COUNT3(bicolor_count, s, bicolor1, bicolor2);
752 else if (fom_count > 3 && fom_count >= mix_count && fom_count >= color_count &&
753 fom_count >= fill_count && fom_count >= bicolor_count)
755 if (fom_count > count)
759 OUT_COPY_COUNT3(count, s, temp_s);
760 OUT_FOM_COUNT3(fom_count, s, fom_mask, fom_mask_len);
764 OUT_COPY_COUNT3(count, s, temp_s);
770 static INLINE SSIZE_T freerdp_bitmap_compress_16(
const void* WINPR_RESTRICT srcData, UINT32 width,
771 UINT32 height,
wStream* WINPR_RESTRICT s,
772 UINT32 bpp, UINT32 byte_limit, UINT32 start_line,
773 wStream* WINPR_RESTRICT temp_s, UINT32 e)
775 char fom_mask[8192] = { 0 };
776 SSIZE_T lines_sent = 0;
778 UINT16 color_count = 0;
779 UINT16 last_pixel = 0;
780 UINT16 last_ypixel = 0;
781 UINT16 bicolor_count = 0;
784 BOOL bicolor_spin = FALSE;
785 UINT32 end = width + e;
786 UINT32 out_count = end * 2;
787 UINT16 fill_count = 0;
788 UINT16 mix_count = 0;
789 const UINT32 mix = (bpp == 15) ? 0xBA1F : 0xFFFF;
790 UINT16 fom_count = 0;
791 size_t fom_mask_len = 0;
792 const char* start = (
const char*)srcData;
793 const char* line = start + 2ULL * width * start_line;
794 const char* last_line = NULL;
796 while ((line >= start) && (out_count < 32768))
798 size_t i = Stream_GetPosition(s) + 2ULL * count;
800 if ((i - (2ULL * color_count) >= byte_limit) &&
801 (i - (2ULL * bicolor_count) >= byte_limit) && (i - (2ULL * fill_count) >= byte_limit) &&
802 (i - (2ULL * mix_count) >= byte_limit) && (i - (2ULL * fom_count) >= byte_limit))
807 out_count += end * 2;
809 for (UINT32 j = 0; j < end; j++)
812 const UINT16 pixel = IN_PIXEL16(line, j, 0, width, last_pixel);
813 const UINT16 ypixel = IN_PIXEL16(last_line, j, 0, width, last_ypixel);
817 if (fill_count > 3 && fill_count >= color_count && fill_count >= bicolor_count &&
818 fill_count >= mix_count && fill_count >= fom_count)
820 if (fill_count > count)
824 OUT_COPY_COUNT2(count, s, temp_s);
825 OUT_FILL_COUNT2(fill_count, s);
834 if (mix_count > 3 && mix_count >= fill_count && mix_count >= bicolor_count &&
835 mix_count >= color_count && mix_count >= fom_count)
837 if (mix_count > count)
841 OUT_COPY_COUNT2(count, s, temp_s);
842 OUT_MIX_COUNT2(mix_count, s);
851 if (color_count > 3 && color_count >= fill_count && color_count >= bicolor_count &&
852 color_count >= mix_count && color_count >= fom_count)
854 if (color_count > count)
857 count -= color_count;
858 OUT_COPY_COUNT2(count, s, temp_s);
859 OUT_COLOR_COUNT2(color_count, s, last_pixel);
868 if ((bicolor_count > 3) && (bicolor_count >= fill_count) &&
869 (bicolor_count >= color_count) && (bicolor_count >= mix_count) &&
870 (bicolor_count >= fom_count))
872 if ((bicolor_count % 2) != 0)
875 if (bicolor_count > count)
878 count -= bicolor_count;
879 OUT_COPY_COUNT2(count, s, temp_s);
880 OUT_BICOLOR_COUNT2(bicolor_count, s, bicolor2, bicolor1);
885 bicolor1 = last_pixel;
887 bicolor_spin = FALSE;
892 if (fom_count > 3 && fom_count >= fill_count && fom_count >= color_count &&
893 fom_count >= mix_count && fom_count >= bicolor_count)
895 if (fom_count > count)
899 OUT_COPY_COUNT2(count, s, temp_s);
900 OUT_FOM_COUNT2(fom_count, s, fom_mask, fom_mask_len);
925 bicolor_spin = !bicolor_spin;
931 if ((fom_count % 8) == 0)
933 fom_mask[fom_mask_len] = 0;
937 if (pixel == (ypixel ^ mix))
939 fom_mask[fom_mask_len - 1] |= (1 << (fom_count % 8));
945 Stream_Write_UINT16(temp_s, pixel);
948 last_ypixel = ypixel;
954 if (fill_count > 3 && fill_count >= color_count && fill_count >= bicolor_count &&
955 fill_count >= mix_count && fill_count >= fom_count)
957 if (fill_count > count)
961 OUT_COPY_COUNT2(count, s, temp_s);
962 OUT_FILL_COUNT2(fill_count, s);
968 if (mix_count > 3 && mix_count >= fill_count && mix_count >= bicolor_count &&
969 mix_count >= color_count && mix_count >= fom_count)
971 if (mix_count > count)
975 OUT_COPY_COUNT2(count, s, temp_s);
976 OUT_MIX_COUNT2(mix_count, s);
982 if (fom_count > 3 && fom_count >= fill_count && fom_count >= color_count &&
983 fom_count >= mix_count && fom_count >= bicolor_count)
985 if (fom_count > count)
989 OUT_COPY_COUNT2(count, s, temp_s);
990 OUT_FOM_COUNT2(fom_count, s, fom_mask, fom_mask_len);
999 line = line - 2ULL * width;
1004 Stream_SetPosition(temp_s, 0);
1006 if (fill_count > 3 && fill_count >= color_count && fill_count >= bicolor_count &&
1007 fill_count >= mix_count && fill_count >= fom_count)
1009 if (fill_count > count)
1012 count -= fill_count;
1013 OUT_COPY_COUNT2(count, s, temp_s);
1014 OUT_FILL_COUNT2(fill_count, s);
1016 else if (mix_count > 3 && mix_count >= color_count && mix_count >= bicolor_count &&
1017 mix_count >= fill_count && mix_count >= fom_count)
1019 if (mix_count > count)
1023 OUT_COPY_COUNT2(count, s, temp_s);
1024 OUT_MIX_COUNT2(mix_count, s);
1026 else if (color_count > 3 && color_count >= mix_count && color_count >= bicolor_count &&
1027 color_count >= fill_count && color_count >= fom_count)
1029 if (color_count > count)
1032 count -= color_count;
1033 OUT_COPY_COUNT2(count, s, temp_s);
1034 OUT_COLOR_COUNT2(color_count, s, last_pixel);
1036 else if (bicolor_count > 3 && bicolor_count >= mix_count && bicolor_count >= color_count &&
1037 bicolor_count >= fill_count && bicolor_count >= fom_count)
1039 if ((bicolor_count % 2) != 0)
1042 if (bicolor_count > count)
1045 count -= bicolor_count;
1046 OUT_COPY_COUNT2(count, s, temp_s);
1047 OUT_BICOLOR_COUNT2(bicolor_count, s, bicolor2, bicolor1);
1049 if (bicolor_count > count)
1052 count -= bicolor_count;
1053 OUT_COPY_COUNT2(count, s, temp_s);
1054 OUT_BICOLOR_COUNT2(bicolor_count, s, bicolor1, bicolor2);
1056 else if (fom_count > 3 && fom_count >= mix_count && fom_count >= color_count &&
1057 fom_count >= fill_count && fom_count >= bicolor_count)
1059 if (fom_count > count)
1063 OUT_COPY_COUNT2(count, s, temp_s);
1064 OUT_FOM_COUNT2(fom_count, s, fom_mask, fom_mask_len);
1068 OUT_COPY_COUNT2(count, s, temp_s);
1074 SSIZE_T freerdp_bitmap_compress(
const void* WINPR_RESTRICT srcData, UINT32 width, UINT32 height,
1075 wStream* WINPR_RESTRICT s, UINT32 bpp, UINT32 byte_limit,
1076 UINT32 start_line,
wStream* WINPR_RESTRICT temp_s, UINT32 e)
1078 Stream_SetPosition(temp_s, 0);
1084 return freerdp_bitmap_compress_16(srcData, width, height, s, bpp, byte_limit,
1085 start_line, temp_s, e);
1088 return freerdp_bitmap_compress_24(srcData, width, height, s, byte_limit, start_line,