[Spice-devel] [PATCH v5 3/9] Better encapsulation for image_encoders_compress_glz call
Pavel Grunt
pgrunt at redhat.com
Wed Jun 15 20:40:26 UTC 2016
On Wed, 2016-06-15 at 16:23 +0200, Pavel Grunt wrote:
> Hi,
>
> On Wed, 2016-06-15 at 10:37 +0100, Frediano Ziglio wrote:
> > Do not access too much encoders data.
> > Slightly different as now if glz is frozen lz compression is used.
>
> What about documenting the compression rules as a comment for
> 'dcc_compress_image()' ?
>
it is not related to the patch itself
> >
> > Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Pavel Grunt <pgrunt at redhat.com>
> > ---
> > server/dcc-encoders.c | 15 +++++++++++++++
> > server/dcc.c | 17 ++++-------------
> > 2 files changed, 19 insertions(+), 13 deletions(-)
> >
> > diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
> > index 098a397..9916d41 100644
> > --- a/server/dcc-encoders.c
> > +++ b/server/dcc-encoders.c
> > @@ -1191,6 +1191,17 @@ int image_encoders_compress_glz(ImageEncoders *enc,
> > spice_info("LZ global compress fmt=%d", src->format);
> > #endif
> >
> > + if ((src->x * src->y) >= glz_enc_dictionary_get_size(enc->glz_dict-
> > > dict)) {
> > + return FALSE;
> > + }
> > +
> > + pthread_rwlock_rdlock(&enc->glz_dict->encode_lock);
> > + /* using the global dictionary only if it is not frozen */
> > + if (enc->glz_dict->migrate_freeze) {
> > + pthread_rwlock_unlock(&enc->glz_dict->encode_lock);
> > + return FALSE;
> > + }
> > +
> > encoder_data_init(&glz_data->data);
> >
> > glz_drawable = get_glz_drawable(enc, drawable);
> > @@ -1241,8 +1252,12 @@ int image_encoders_compress_glz(ImageEncoders *enc,
> > o_comp_data->comp_buf_size = zlib_size;
> >
> > stat_compress_add(&enc->shared_data->zlib_glz_stat, start_time,
> > glz_size,
> > zlib_size);
> > + pthread_rwlock_unlock(&enc->glz_dict->encode_lock);
> > return TRUE;
> > +
> > glz:
> > + pthread_rwlock_unlock(&enc->glz_dict->encode_lock);
> > +
> > dest->descriptor.type = SPICE_IMAGE_TYPE_GLZ_RGB;
> > dest->u.lz_rgb.data_size = glz_size;
> >
> > diff --git a/server/dcc.c b/server/dcc.c
> > index 48c009d..fc601e9 100644
> > --- a/server/dcc.c
> > +++ b/server/dcc.c
> > @@ -735,19 +735,10 @@ int dcc_compress_image(DisplayChannelClient *dcc,
> > success = image_encoders_compress_quic(&dcc->encoders, dest, src,
> > o_comp_data);
> > break;
> > case SPICE_IMAGE_COMPRESSION_GLZ:
> > - if ((src->x * src->y) < glz_enc_dictionary_get_size(dcc-
> > > encoders.glz_dict->dict)) {
> > - int frozen;
> > - /* using the global dictionary only if it is not frozen */
> > - pthread_rwlock_rdlock(&dcc->encoders.glz_dict->encode_lock);
> > - frozen = dcc->encoders.glz_dict->migrate_freeze;
> > - if (!frozen) {
> > - success = image_encoders_compress_glz(&dcc->encoders, dest,
> > src, drawable, o_comp_data,
> > - display_channel-
> > > enable_zlib_glz_wrap);
> > - }
> > - pthread_rwlock_unlock(&dcc->encoders.glz_dict->encode_lock);
> > - if (!frozen) {
> > - break;
> > - }
> > + success = image_encoders_compress_glz(&dcc->encoders, dest, src,
> > drawable, o_comp_data,
> > + display_channel-
> > > enable_zlib_glz_wrap);
> > + if (success) {
> > + break;
> > }
> > goto lz_compress;
> > #ifdef USE_LZ4
More information about the Spice-devel
mailing list