70 return ((src_sz >> 1) * 3 + (src_sz & 1));
101 for (i = 1; i < src_sz; i++) {
102 if (prev_b != src[i] || cnt == 255) {
105 if (nbytes >= dst_sz)
107 dst[nbytes++] = prev_b;
111 if (nbytes >= dst_sz - 2)
113 dst[nbytes++] = prev_b;
114 dst[nbytes++] = prev_b;
115 dst[nbytes++] = (
unsigned char)cnt;
124 if (nbytes >= dst_sz)
126 dst[nbytes++] = prev_b;
129 if (nbytes >= dst_sz - 2)
131 dst[nbytes++] = prev_b;
132 dst[nbytes++] = prev_b;
133 dst[nbytes++] = (
unsigned char)cnt;
139 int G_rle_expand(
unsigned char *src,
int src_sz,
unsigned char *dst,
int dst_sz)
141 int i, j, nbytes, cnt;
142 unsigned char prev_b;
164 if (nbytes + cnt > dst_sz)
166 for (j = 0; j < cnt; j++) {
167 dst[nbytes++] = prev_b;
175 if (prev_b != src[i]) {
176 if (nbytes + cnt > dst_sz)
178 dst[nbytes++] = prev_b;
186 if (nbytes >= dst_sz)
189 dst[nbytes++] = prev_b;
int G_rle_compress_bound(int src_sz)
int G_rle_compress(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
int G_rle_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)