vnc-enc-zlib.c (e16f4c8770b73f530dad842a31298963b6c7e41d) vnc-enc-zlib.c (6bf21f3d83e95bcc4ba35a7a07cc6655e8b010b0)
1/*
2 * QEMU VNC display driver: zlib encoding
3 *
4 * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>
5 * Copyright (C) 2006 Fabrice Bellard
6 * Copyright (C) 2009 Red Hat, Inc
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy

--- 62 unchanged lines hidden (view full) ---

71 if (zstream->opaque != vs) {
72 int err;
73
74 VNC_DEBUG("VNC: initializing zlib stream\n");
75 VNC_DEBUG("VNC: opaque = %p | vs = %p\n", zstream->opaque, vs);
76 zstream->zalloc = vnc_zlib_zalloc;
77 zstream->zfree = vnc_zlib_zfree;
78
1/*
2 * QEMU VNC display driver: zlib encoding
3 *
4 * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>
5 * Copyright (C) 2006 Fabrice Bellard
6 * Copyright (C) 2009 Red Hat, Inc
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy

--- 62 unchanged lines hidden (view full) ---

71 if (zstream->opaque != vs) {
72 int err;
73
74 VNC_DEBUG("VNC: initializing zlib stream\n");
75 VNC_DEBUG("VNC: opaque = %p | vs = %p\n", zstream->opaque, vs);
76 zstream->zalloc = vnc_zlib_zalloc;
77 zstream->zfree = vnc_zlib_zfree;
78
79 err = deflateInit2(zstream, vs->tight.compression, Z_DEFLATED, MAX_WBITS,
79 err = deflateInit2(zstream, vs->tight->compression, Z_DEFLATED,
80 MAX_WBITS,
80 MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);
81
82 if (err != Z_OK) {
83 fprintf(stderr, "VNC: error initializing zlib\n");
84 return -1;
85 }
86
81 MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);
82
83 if (err != Z_OK) {
84 fprintf(stderr, "VNC: error initializing zlib\n");
85 return -1;
86 }
87
87 vs->zlib.level = vs->tight.compression;
88 vs->zlib.level = vs->tight->compression;
88 zstream->opaque = vs;
89 }
90
89 zstream->opaque = vs;
90 }
91
91 if (vs->tight.compression != vs->zlib.level) {
92 if (deflateParams(zstream, vs->tight.compression,
92 if (vs->tight->compression != vs->zlib.level) {
93 if (deflateParams(zstream, vs->tight->compression,
93 Z_DEFAULT_STRATEGY) != Z_OK) {
94 return -1;
95 }
94 Z_DEFAULT_STRATEGY) != Z_OK) {
95 return -1;
96 }
96 vs->zlib.level = vs->tight.compression;
97 vs->zlib.level = vs->tight->compression;
97 }
98
99 // reserve memory in output buffer
100 buffer_reserve(&vs->output, vs->zlib.zlib.offset + 64);
101
102 // set pointers
103 zstream->next_in = vs->zlib.zlib.buffer;
104 zstream->avail_in = vs->zlib.zlib.offset;

--- 49 unchanged lines hidden ---
98 }
99
100 // reserve memory in output buffer
101 buffer_reserve(&vs->output, vs->zlib.zlib.offset + 64);
102
103 // set pointers
104 zstream->next_in = vs->zlib.zlib.buffer;
105 zstream->avail_in = vs->zlib.zlib.offset;

--- 49 unchanged lines hidden ---