[Spice-devel] [PATCH 06/30] Move dcc_compress_image_quic to dcc-encoders.c
Frediano Ziglio
fziglio at redhat.com
Thu Jun 9 09:48:33 UTC 2016
>
> On Tue, 2016-06-07 at 11:17 +0100, Frediano Ziglio wrote:
> > Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> > ---
> > server/dcc-encoders.c | 76
> > +++++++++++++++++++++++++++++++++++++++++++++++++++
> > server/dcc-encoders.h | 10 +++++++
> > server/dcc.c | 73
> > -------------------------------------------------
> > server/dcc.h | 7 -----
> > 4 files changed, 86 insertions(+), 80 deletions(-)
> >
> > diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
> > index 7d317d5..99e5507 100644
> > --- a/server/dcc-encoders.c
> > +++ b/server/dcc-encoders.c
> > @@ -704,3 +704,79 @@ void dcc_release_glz(DisplayChannelClient *dcc)
> > glz_enc_dictionary_destroy(shared_dict->dict, &dcc->glz_data.usr);
> > free(shared_dict);
> > }
> > +
> > +int dcc_compress_image_quic(EncodersData *enc, SpiceImage *dest,
> > + SpiceBitmap *src, compress_send_data_t*
> > o_comp_data,
> > + stat_info_t *stats)
> > +{
> > + QuicData *quic_data = &enc->quic_data;
> > + QuicContext *quic = enc->quic;
> > + volatile QuicImageType type;
> > + int size, stride;
> > + stat_start_time_t start_time;
> > + stat_start_time_init(&start_time, stats);
> > +
> > +#ifdef COMPRESS_DEBUG
> > + spice_info("QUIC compress");
> > +#endif
> > +
> > + switch (src->format) {
> > + case SPICE_BITMAP_FMT_32BIT:
> > + type = QUIC_IMAGE_TYPE_RGB32;
> > + break;
> > + case SPICE_BITMAP_FMT_RGBA:
> > + type = QUIC_IMAGE_TYPE_RGBA;
> > + break;
> > + case SPICE_BITMAP_FMT_16BIT:
> > + type = QUIC_IMAGE_TYPE_RGB16;
> > + break;
> > + case SPICE_BITMAP_FMT_24BIT:
> > + type = QUIC_IMAGE_TYPE_RGB24;
> > + break;
> > + default:
> > + return FALSE;
> > + }
> > +
> > + encoder_data_init(&quic_data->data);
> > +
> > + if (setjmp(quic_data->data.jmp_env)) {
> > + encoder_data_reset(&quic_data->data);
> > + return FALSE;
> > + }
> > +
> > + if (src->data->flags & SPICE_CHUNKS_FLAGS_UNSTABLE) {
> > + spice_chunks_linearize(src->data);
> > + }
> > +
> > + quic_data->data.u.lines_data.chunks = src->data;
> > + quic_data->data.u.lines_data.stride = src->stride;
> > + if ((src->flags & SPICE_BITMAP_FLAGS_TOP_DOWN)) {
> > + quic_data->data.u.lines_data.next = 0;
> > + quic_data->data.u.lines_data.reverse = 0;
> > + stride = src->stride;
> > + } else {
> > + quic_data->data.u.lines_data.next = src->data->num_chunks - 1;
> > + quic_data->data.u.lines_data.reverse = 1;
> > + stride = -src->stride;
> > + }
> > + size = quic_encode(quic, type, src->x, src->y, NULL, 0, stride,
> > + quic_data->data.bufs_head->buf.words,
> > +
> > G_N_ELEMENTS(quic_data->data.bufs_head->buf.words));
> > +
> > + // the compressed buffer is bigger than the original data
> > + if ((size << 2) > (src->y * src->stride)) {
> > + longjmp(quic_data->data.jmp_env, 1);
> > + }
> > +
> > + dest->descriptor.type = SPICE_IMAGE_TYPE_QUIC;
> > + dest->u.quic.data_size = size << 2;
> > +
> > + o_comp_data->comp_buf = quic_data->data.bufs_head;
> > + o_comp_data->comp_buf_size = size << 2;
> > +
> > + stat_compress_add(stats, start_time, src->stride * src->y,
> > + o_comp_data->comp_buf_size);
> > + return TRUE;
> > +}
> > +
> > +
> > diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h
> > index 6bed548..a75678e 100644
> > --- a/server/dcc-encoders.h
> > +++ b/server/dcc-encoders.h
> > @@ -167,6 +167,16 @@ struct EncodersData {
> > QuicContext *quic;
> > };
> >
> > +typedef struct compress_send_data_t {
> > + void* comp_buf;
>
> As long as we're moving this type, can we take the opportunity fix this
> alignment issue?
>
Not aware of this issue...
> > + uint32_t comp_buf_size;
> > + SpicePalette *lzplt_palette;
> > + int is_lossy;
> > +} compress_send_data_t;
> > +
> > +int dcc_compress_image_quic(EncodersData *enc, SpiceImage *dest,
> > + SpiceBitmap *src, compress_send_data_t*
> > o_comp_data,
> > + stat_info_t *stats);
> > #define RED_RELEASE_BUNCH_SIZE 64
> >
> > #endif /* DCC_ENCODERS_H_ */
> > diff --git a/server/dcc.c b/server/dcc.c
> > index 27e668c..0bc806a 100644
> > --- a/server/dcc.c
> > +++ b/server/dcc.c
> > @@ -1026,79 +1026,6 @@ static int
> > dcc_compress_image_lz4(DisplayChannelClient
> > *dcc, SpiceImage *dest,
> > }
> > #endif
> >
> > -static int dcc_compress_image_quic(EncodersData *enc, SpiceImage *dest,
> > - SpiceBitmap *src, compress_send_data_t*
> > o_comp_data, stat_info_t *stats)
> > -{
> > - QuicData *quic_data = &enc->quic_data;
> > - QuicContext *quic = enc->quic;
> > - volatile QuicImageType type;
> > - int size, stride;
> > - stat_start_time_t start_time;
> > - stat_start_time_init(&start_time, stats);
> > -
> > -#ifdef COMPRESS_DEBUG
> > - spice_info("QUIC compress");
> > -#endif
> > -
> > - switch (src->format) {
> > - case SPICE_BITMAP_FMT_32BIT:
> > - type = QUIC_IMAGE_TYPE_RGB32;
> > - break;
> > - case SPICE_BITMAP_FMT_RGBA:
> > - type = QUIC_IMAGE_TYPE_RGBA;
> > - break;
> > - case SPICE_BITMAP_FMT_16BIT:
> > - type = QUIC_IMAGE_TYPE_RGB16;
> > - break;
> > - case SPICE_BITMAP_FMT_24BIT:
> > - type = QUIC_IMAGE_TYPE_RGB24;
> > - break;
> > - default:
> > - return FALSE;
> > - }
> > -
> > - encoder_data_init(&quic_data->data);
> > -
> > - if (setjmp(quic_data->data.jmp_env)) {
> > - encoder_data_reset(&quic_data->data);
> > - return FALSE;
> > - }
> > -
> > - if (src->data->flags & SPICE_CHUNKS_FLAGS_UNSTABLE) {
> > - spice_chunks_linearize(src->data);
> > - }
> > -
> > - quic_data->data.u.lines_data.chunks = src->data;
> > - quic_data->data.u.lines_data.stride = src->stride;
> > - if ((src->flags & SPICE_BITMAP_FLAGS_TOP_DOWN)) {
> > - quic_data->data.u.lines_data.next = 0;
> > - quic_data->data.u.lines_data.reverse = 0;
> > - stride = src->stride;
> > - } else {
> > - quic_data->data.u.lines_data.next = src->data->num_chunks - 1;
> > - quic_data->data.u.lines_data.reverse = 1;
> > - stride = -src->stride;
> > - }
> > - size = quic_encode(quic, type, src->x, src->y, NULL, 0, stride,
> > - quic_data->data.bufs_head->buf.words,
> > -
> > G_N_ELEMENTS(quic_data->data.bufs_head->buf.words));
> > -
> > - // the compressed buffer is bigger than the original data
> > - if ((size << 2) > (src->y * src->stride)) {
> > - longjmp(quic_data->data.jmp_env, 1);
> > - }
> > -
> > - dest->descriptor.type = SPICE_IMAGE_TYPE_QUIC;
> > - dest->u.quic.data_size = size << 2;
> > -
> > - o_comp_data->comp_buf = quic_data->data.bufs_head;
> > - o_comp_data->comp_buf_size = size << 2;
> > -
> > - stat_compress_add(stats, start_time, src->stride * src->y,
> > - o_comp_data->comp_buf_size);
> > - return TRUE;
> > -}
> > -
> > #define MIN_DIMENSION_TO_QUIC 3
> > /**
> > * quic doesn't handle:
> > diff --git a/server/dcc.h b/server/dcc.h
> > index 0ac5f5a..4b93c73 100644
> > --- a/server/dcc.h
> > +++ b/server/dcc.h
> > @@ -216,13 +216,6 @@ RedPipeItem
> > * dcc_gl_scanout_item_new (RedChannel
> > RedPipeItem
> > * dcc_gl_draw_item_new (RedChannelClient
> > *rcc,
> > void
> > *data, int num);
> >
> > -typedef struct compress_send_data_t {
> > - void* comp_buf;
> > - uint32_t comp_buf_size;
> > - SpicePalette *lzplt_palette;
> > - int is_lossy;
> > -} compress_send_data_t;
> > -
> > int dcc_compress_image
> > (Display
> > ChannelClient *dcc,
> > SpiceIm
> > age *dest, SpiceBitmap *src, Drawable *drawable,
> > int
> > can_lossy,
>
>
> minor comment above
>
> Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
>
Frediano
More information about the Spice-devel
mailing list