[Spice-commits] 3 commits - server/jpeg-encoder.c server/jpeg-encoder.h server/memslot.c server/memslot.h server/red-parse-qxl.c
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jun 26 17:07:56 UTC 2018
server/jpeg-encoder.c | 30 +++++++++---------------------
server/jpeg-encoder.h | 3 +--
server/memslot.c | 14 +++++++-------
server/memslot.h | 2 +-
server/red-parse-qxl.c | 4 ++--
5 files changed, 20 insertions(+), 33 deletions(-)
New commits:
commit 4ce6439596fa7ba12ce98852cc4566b17c725cff
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sat Jun 2 21:39:15 2018 +0100
memslot: Return void* from memslot_get_virt
The result of this function is always cast to a pointer, there
is no reason to return an integer.
This API looks copied from a kernel environment where virtual
addresses can have different sizes compare to pointers.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/server/memslot.c b/server/memslot.c
index 7074b432..a87a717b 100644
--- a/server/memslot.c
+++ b/server/memslot.c
@@ -89,8 +89,8 @@ unsigned long memslot_max_size_virt(RedMemSlotInfo *info,
* return virtual address if successful, which may be 0.
* returns 0 and sets error to 1 if an error condition occurs.
*/
-unsigned long memslot_get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size,
- int group_id, int *error)
+void* memslot_get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size,
+ int group_id, int *error)
{
int slot_id;
int generation;
@@ -102,7 +102,7 @@ unsigned long memslot_get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t
if (group_id > info->num_memslots_groups) {
spice_critical("group_id too big");
*error = 1;
- return 0;
+ return NULL;
}
slot_id = memslot_get_id(info, addr);
@@ -110,7 +110,7 @@ unsigned long memslot_get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t
print_memslots(info);
spice_critical("slot_id %d too big, addr=%" PRIx64, slot_id, addr);
*error = 1;
- return 0;
+ return NULL;
}
slot = &info->mem_slots[group_id][slot_id];
@@ -121,7 +121,7 @@ unsigned long memslot_get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t
spice_critical("address generation is not valid, group_id %d, slot_id %d, gen %d, slot_gen %d\n",
group_id, slot_id, generation, slot->generation);
*error = 1;
- return 0;
+ return NULL;
}
h_virt = __get_clean_virt(info, addr);
@@ -129,10 +129,10 @@ unsigned long memslot_get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t
if (!memslot_validate_virt(info, h_virt, slot_id, add_size, group_id)) {
*error = 1;
- return 0;
+ return NULL;
}
- return h_virt;
+ return (void*)(uintptr_t)h_virt;
}
void memslot_info_init(RedMemSlotInfo *info,
diff --git a/server/memslot.h b/server/memslot.h
index 71f1210d..d8d67d55 100644
--- a/server/memslot.h
+++ b/server/memslot.h
@@ -58,7 +58,7 @@ int memslot_validate_virt(RedMemSlotInfo *info, unsigned long virt, int slot_id,
unsigned long memslot_max_size_virt(RedMemSlotInfo *info,
unsigned long virt, int slot_id,
uint32_t group_id);
-unsigned long memslot_get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size,
+void *memslot_get_virt(RedMemSlotInfo *info, QXLPHYSICAL addr, uint32_t add_size,
int group_id, int *error);
void memslot_info_init(RedMemSlotInfo *info,
diff --git a/server/red-parse-qxl.c b/server/red-parse-qxl.c
index 4a45c0f7..d28c935f 100644
--- a/server/red-parse-qxl.c
+++ b/server/red-parse-qxl.c
@@ -371,7 +371,7 @@ static SpiceChunks *red_get_image_data_flat(RedMemSlotInfo *slots, int group_id,
{
SpiceChunks *data;
int error;
- unsigned long bitmap_virt;
+ void *bitmap_virt;
bitmap_virt = memslot_get_virt(slots, addr, size, group_id, &error);
if (error) {
@@ -380,7 +380,7 @@ static SpiceChunks *red_get_image_data_flat(RedMemSlotInfo *slots, int group_id,
data = spice_chunks_new(1);
data->data_size = size;
- data->chunk[0].data = (void*)bitmap_virt;
+ data->chunk[0].data = bitmap_virt;
data->chunk[0].len = size;
return data;
}
commit 355c51084969a3b84e26431bc13dc6415e155673
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Jun 5 00:25:47 2018 +0100
jpeg-encoder: Remove JPEG_IMAGE_TYPE_RGB24
Never used.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/server/jpeg-encoder.c b/server/jpeg-encoder.c
index e6591876..a31d63d7 100644
--- a/server/jpeg-encoder.c
+++ b/server/jpeg-encoder.c
@@ -161,11 +161,6 @@ static void convert_BGRX32_to_RGB24(void *line, int width, uint8_t **out_line)
}
}
-static void convert_RGB24_to_RGB24(void *line, int width, uint8_t **out_line)
-{
- *out_line = line;
-}
-
#define FILL_LINES() { \
if (lines == lines_end) { \
@@ -186,9 +181,7 @@ static void do_jpeg_encode(JpegEncoder *jpeg, uint8_t *lines, unsigned int num_l
width = jpeg->cur_image.width;
stride = jpeg->cur_image.stride;
- if (jpeg->cur_image.type != JPEG_IMAGE_TYPE_RGB24) {
- RGB24_line = g_new(uint8_t, width*3);
- }
+ RGB24_line = g_new(uint8_t, width*3);
lines_end = lines + (stride * num_lines);
@@ -199,9 +192,7 @@ static void do_jpeg_encode(JpegEncoder *jpeg, uint8_t *lines, unsigned int num_l
jpeg_write_scanlines(&jpeg->cinfo, row_pointer, 1);
}
- if (jpeg->cur_image.type != JPEG_IMAGE_TYPE_RGB24) {
- g_free(RGB24_line);
- }
+ g_free(RGB24_line);
}
int jpeg_encode(JpegEncoderContext *enc, int quality, JpegEncoderImageType type,
@@ -218,9 +209,6 @@ int jpeg_encode(JpegEncoderContext *enc, int quality, JpegEncoderImageType type,
case JPEG_IMAGE_TYPE_RGB16:
enc->cur_image.convert_line_to_RGB24 = convert_RGB16_to_RGB24;
break;
- case JPEG_IMAGE_TYPE_RGB24:
- enc->cur_image.convert_line_to_RGB24 = convert_RGB24_to_RGB24;
- break;
case JPEG_IMAGE_TYPE_BGR24:
enc->cur_image.convert_line_to_RGB24 = convert_BGR24_to_RGB24;
break;
diff --git a/server/jpeg-encoder.h b/server/jpeg-encoder.h
index 0a1c2e78..4037a988 100644
--- a/server/jpeg-encoder.h
+++ b/server/jpeg-encoder.h
@@ -38,7 +38,6 @@ typedef enum {
JPEG_IMAGE_TYPE_RGB16,
/* in byte per color types, the notation is according to the order of the
colors in the memory */
- JPEG_IMAGE_TYPE_RGB24,
JPEG_IMAGE_TYPE_BGR24,
JPEG_IMAGE_TYPE_BGRX32,
} JpegEncoderImageType;
commit a8e88a991e208164c255a306f5b83932105c9fbf
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sat Jun 2 21:37:58 2018 +0100
jpeg-encoder: Avoid useless conversions
Define JpegEncoderContext as an abstract structure.
This allows to reduce casts.
Also remove some alignment warnings on some architecture like mips.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/server/jpeg-encoder.c b/server/jpeg-encoder.c
index a6eaf86f..e6591876 100644
--- a/server/jpeg-encoder.c
+++ b/server/jpeg-encoder.c
@@ -24,7 +24,7 @@
#include "red-common.h"
#include "jpeg-encoder.h"
-typedef struct JpegEncoder {
+struct JpegEncoderContext {
JpegEncoderUsrContext *usr;
struct jpeg_destination_mgr dest_mgr;
@@ -39,7 +39,9 @@ typedef struct JpegEncoder {
unsigned int out_size;
void (*convert_line_to_RGB24) (void *line, int width, uint8_t **out_line);
} cur_image;
-} JpegEncoder;
+};
+
+typedef struct JpegEncoderContext JpegEncoder;
/* jpeg destination manager callbacks */
@@ -97,12 +99,12 @@ JpegEncoderContext* jpeg_encoder_create(JpegEncoderUsrContext *usr)
jpeg_create_compress(&enc->cinfo);
enc->cinfo.client_data = enc;
enc->cinfo.dest = &enc->dest_mgr;
- return (JpegEncoderContext*)enc;
+ return enc;
}
void jpeg_encoder_destroy(JpegEncoderContext* encoder)
{
- jpeg_destroy_compress(&((JpegEncoder*)encoder)->cinfo);
+ jpeg_destroy_compress(&encoder->cinfo);
g_free(encoder);
}
@@ -202,12 +204,10 @@ static void do_jpeg_encode(JpegEncoder *jpeg, uint8_t *lines, unsigned int num_l
}
}
-int jpeg_encode(JpegEncoderContext *jpeg, int quality, JpegEncoderImageType type,
+int jpeg_encode(JpegEncoderContext *enc, int quality, JpegEncoderImageType type,
int width, int height, uint8_t *lines, unsigned int num_lines, int stride,
uint8_t *io_ptr, unsigned int num_io_bytes)
{
- JpegEncoder *enc = (JpegEncoder *)jpeg;
-
enc->cur_image.type = type;
enc->cur_image.width = width;
enc->cur_image.height = height;
diff --git a/server/jpeg-encoder.h b/server/jpeg-encoder.h
index 665cf9f7..0a1c2e78 100644
--- a/server/jpeg-encoder.h
+++ b/server/jpeg-encoder.h
@@ -43,7 +43,7 @@ typedef enum {
JPEG_IMAGE_TYPE_BGRX32,
} JpegEncoderImageType;
-typedef void* JpegEncoderContext;
+typedef struct JpegEncoderContext JpegEncoderContext;
typedef struct JpegEncoderUsrContext JpegEncoderUsrContext;
struct JpegEncoderUsrContext {
More information about the Spice-commits
mailing list