[Spice-devel] [PATCH spice-server 2/2] Use only one algorithm for choosing image compression
Pavel Grunt
pgrunt at redhat.com
Fri Jun 26 08:18:19 PDT 2015
It is possible to use red_compress_image() instead of having similar
checks for image compression in red_marshall_image().
---
server/red_worker.c | 56 ++++-------------------------------------------------
1 file changed, 4 insertions(+), 52 deletions(-)
diff --git a/server/red_worker.c b/server/red_worker.c
index 3a305d8..9e16f73 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -8815,9 +8815,6 @@ static void red_marshall_image(RedChannelClient *rcc, SpiceMarshaller *m, ImageI
SpiceChunks *chunks;
QRegion *surface_lossy_region;
int comp_succeeded;
- int lossy_comp = FALSE;
- int lz_comp = FALSE;
- spice_image_compression_t comp_mode;
SpiceMsgDisplayDrawCopy copy;
SpiceMarshaller *src_bitmap_out, *mask_bitmap_out;
SpiceMarshaller *bitmap_palette_out, *lzplt_palette_out;
@@ -8870,54 +8867,8 @@ static void red_marshall_image(RedChannelClient *rcc, SpiceMarshaller *m, ImageI
&src_bitmap_out, &mask_bitmap_out);
compress_send_data_t comp_send_data = {0};
-
- comp_mode = display_channel->common.worker->image_compression;
-
- if (((comp_mode == SPICE_IMAGE_COMPRESS_AUTO_LZ) ||
- (comp_mode == SPICE_IMAGE_COMPRESS_AUTO_GLZ)) && !_stride_is_extra(&bitmap)) {
-
- if (BITMAP_FMT_HAS_GRADUALITY(item->image_format)) {
- BitmapGradualType grad_level;
-
- grad_level = _get_bitmap_graduality_level(display_channel->common.worker,
- &bitmap,
- worker->mem_slots.internal_groupslot_id);
- if (grad_level == BITMAP_GRADUAL_HIGH) {
- // if we use lz for alpha, the stride can't be extra
- lossy_comp = display_channel->enable_jpeg && item->can_lossy;
- } else {
- lz_comp = TRUE;
- }
- } else {
- lz_comp = TRUE;
- }
- }
-
- if (lossy_comp) {
- comp_succeeded = red_jpeg_compress_image(dcc, &red_image,
- &bitmap, &comp_send_data,
- worker->mem_slots.internal_groupslot_id);
- } else {
- if (!lz_comp) {
- comp_succeeded = red_quic_compress_image(dcc, &red_image, &bitmap,
- &comp_send_data,
- worker->mem_slots.internal_groupslot_id);
- } else {
-#ifdef USE_LZ4
- if (comp_mode == SPICE_IMAGE_COMPRESS_LZ4 &&
- bitmap_fmt_is_rgb(bitmap.format) &&
- red_channel_client_test_remote_cap(&dcc->common.base,
- SPICE_DISPLAY_CAP_LZ4_COMPRESSION)) {
- comp_succeeded = red_lz4_compress_image(dcc, &red_image, &bitmap,
- &comp_send_data,
- worker->mem_slots.internal_groupslot_id);
- } else
-#endif
- comp_succeeded = red_lz_compress_image(dcc, &red_image, &bitmap,
- &comp_send_data,
- worker->mem_slots.internal_groupslot_id);
- }
- }
+ comp_succeeded = red_compress_image(dcc, &red_image, &bitmap, NULL, item->can_lossy,
+ &comp_send_data);
surface_lossy_region = &dcc->surface_client_lossy_region[item->surface_id];
if (comp_succeeded) {
@@ -8931,7 +8882,8 @@ static void red_marshall_image(RedChannelClient *rcc, SpiceMarshaller *m, ImageI
spice_marshall_Palette(lzplt_palette_out, comp_send_data.lzplt_palette);
}
- if (lossy_comp) {
+ if (red_image.descriptor.type == SPICE_IMAGE_TYPE_JPEG ||
+ red_image.descriptor.type == SPICE_IMAGE_TYPE_JPEG_ALPHA) {
region_add(surface_lossy_region, ©.base.box);
} else {
region_remove(surface_lossy_region, ©.base.box);
--
2.4.4
More information about the Spice-devel
mailing list