[PATCH spice-server 1/2] jpeg-encoder: Avoid useless conversions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 server/jpeg-encoder.c | 14 +++++++-------
 server/jpeg-encoder.h |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

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 {
-- 
2.17.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]