1 /* 2 Copyright (C) 2009 Red Hat, Inc. 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with this library; if not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef GLZ_ENCODER_DICT_H_ 19 #define GLZ_ENCODER_DICT_H_ 20 21 #include <stdint.h> 22 23 /* 24 Interface for maintaining lz dictionary that is shared among several encoders. 25 The interface for accessing the dictionary for encoding purposes is located in 26 glz-encoder-priv.h 27 */ 28 29 SPICE_BEGIN_DECLS 30 31 typedef void GlzEncDictContext; 32 typedef void GlzEncDictImageContext; 33 34 typedef void GlzUsrImageContext; 35 typedef struct GlzEncoderUsrContext GlzEncoderUsrContext; 36 37 /* NOTE: DISPLAY_MIGRATE_DATA_VERSION should change in case GlzEncDictRestoreData changes*/ 38 typedef struct GlzEncDictRestoreData { 39 uint32_t size; 40 uint32_t max_encoders; 41 uint64_t last_image_id; 42 } GlzEncDictRestoreData; 43 44 /* size : maximal number of pixels occupying the window 45 max_encoders: maximal number of encoders that use the dictionary 46 usr : callbacks */ 47 GlzEncDictContext *glz_enc_dictionary_create(uint32_t size, uint32_t max_encoders, 48 GlzEncoderUsrContext *usr); 49 50 void glz_enc_dictionary_destroy(GlzEncDictContext *opaque_dict, GlzEncoderUsrContext *usr); 51 52 /* returns the window capacity in pixels */ 53 uint32_t glz_enc_dictionary_get_size(GlzEncDictContext *); 54 55 /* returns the current state of the dictionary. 56 NOTE - you should use it only when no encoder uses the dictionary. */ 57 void glz_enc_dictionary_get_restore_data(GlzEncDictContext *opaque_dict, 58 GlzEncDictRestoreData *out_data, 59 GlzEncoderUsrContext *usr); 60 61 /* creates a dictionary and initialized it by use the given info */ 62 GlzEncDictContext *glz_enc_dictionary_restore(GlzEncDictRestoreData *restore_data, 63 GlzEncoderUsrContext *usr); 64 65 /* image: the context returned by the encoder when the image was encoded. 66 NOTE - you should use this routine only when no encoder uses the dictionary.*/ 67 void glz_enc_dictionary_remove_image(GlzEncDictContext *opaque_dict, 68 GlzEncDictImageContext *image, GlzEncoderUsrContext *usr); 69 70 SPICE_END_DECLS 71 72 #endif /* GLZ_ENCODER_DICT_H_ */ 73