[Spice-devel] [PATCH spice 09/11] server/mjpeg_encoder: allow varying jpeg quality
Yonit Halperin
yhalperi at redhat.com
Sun Apr 8 08:43:18 PDT 2012
Signed-off-by: Yonit Halperin <yhalperi at redhat.com>
---
server/mjpeg_encoder.c | 5 ++---
server/mjpeg_encoder.h | 1 +
server/red_worker.c | 1 +
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/server/mjpeg_encoder.c b/server/mjpeg_encoder.c
index b3685f8..72d9040 100644
--- a/server/mjpeg_encoder.c
+++ b/server/mjpeg_encoder.c
@@ -27,7 +27,6 @@
struct MJpegEncoder {
uint8_t *row;
int first_frame;
- int quality;
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
@@ -43,7 +42,6 @@ MJpegEncoder *mjpeg_encoder_new()
enc = spice_new0(MJpegEncoder, 1);
enc->first_frame = TRUE;
- enc->quality = 70;
enc->cinfo.err = jpeg_std_error(&enc->jerr);
jpeg_create_compress(&enc->cinfo);
@@ -196,6 +194,7 @@ spice_jpeg_mem_dest(j_compress_ptr cinfo,
/* end of code from libjpeg */
int mjpeg_encoder_start_frame(MJpegEncoder *encoder, SpiceBitmapFmt format,
+ int quality,
int width, int height,
uint8_t **dest, size_t *dest_len)
{
@@ -244,7 +243,7 @@ int mjpeg_encoder_start_frame(MJpegEncoder *encoder, SpiceBitmapFmt format,
encoder->cinfo.image_height = height;
jpeg_set_defaults(&encoder->cinfo);
encoder->cinfo.dct_method = JDCT_IFAST;
- jpeg_set_quality(&encoder->cinfo, encoder->quality, TRUE);
+ jpeg_set_quality(&encoder->cinfo, quality, TRUE);
jpeg_start_compress(&encoder->cinfo, encoder->first_frame);
return TRUE;
diff --git a/server/mjpeg_encoder.h b/server/mjpeg_encoder.h
index 3a005b7..08077e8 100644
--- a/server/mjpeg_encoder.h
+++ b/server/mjpeg_encoder.h
@@ -28,6 +28,7 @@ void mjpeg_encoder_destroy(MJpegEncoder *encoder);
uint8_t mjpeg_encoder_get_bytes_per_pixel(MJpegEncoder *encoder);
int mjpeg_encoder_start_frame(MJpegEncoder *encoder, SpiceBitmapFmt format,
+ int quality,
int width, int height,
uint8_t **dest, size_t *dest_len);
int mjpeg_encoder_encode_scanline(MJpegEncoder *encoder, uint8_t *src_pixels,
diff --git a/server/red_worker.c b/server/red_worker.c
index f876c15..a9942cf 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -8126,6 +8126,7 @@ static inline int red_marshall_stream_data(RedChannelClient *rcc,
outbuf_size = dcc->send_data.stream_outbuf_size;
if (!mjpeg_encoder_start_frame(stream->mjpeg_encoder, image->u.bitmap.format,
+ 70,
width, height,
&dcc->send_data.stream_outbuf,
&outbuf_size)) {
--
1.7.7.6
More information about the Spice-devel
mailing list