comparison cscd.c @ 3034:d37065d8aeff libavcodec

Our own LZO (1X) implementation, under LGPL and optimized for readability. Tested on CamStudio sample files.
author reimar
date Thu, 12 Jan 2006 17:52:41 +0000
parents 6bc2dc147ac5
children 0b546eab515d
comparison
equal deleted inserted replaced
3033:e8599ab02b38 3034:d37065d8aeff
23 #include "avcodec.h" 23 #include "avcodec.h"
24 24
25 #ifdef CONFIG_ZLIB 25 #ifdef CONFIG_ZLIB
26 #include <zlib.h> 26 #include <zlib.h>
27 #endif 27 #endif
28 #ifdef CONFIG_LZO 28 #include "lzo.h"
29 #include <lzo1x.h>
30 #endif
31 29
32 typedef struct { 30 typedef struct {
33 AVFrame pic; 31 AVFrame pic;
34 int linelen, height, bpp; 32 int linelen, height, bpp;
35 unsigned int decomp_size; 33 unsigned int decomp_size;
156 } 154 }
157 155
158 // decompress data 156 // decompress data
159 switch ((buf[0] >> 1) & 7) { 157 switch ((buf[0] >> 1) & 7) {
160 case 0: { // lzo compression 158 case 0: { // lzo compression
161 #ifdef CONFIG_LZO 159 int outlen = c->decomp_size, inlen = buf_size - 2;
162 unsigned int dlen = c->decomp_size; 160 if (lzo1x_decode(c->decomp_buf, &outlen, &buf[2], &inlen))
163 if (lzo1x_decompress_safe(&buf[2], buf_size - 2,
164 c->decomp_buf, &dlen, NULL) != LZO_E_OK)
165 av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n"); 161 av_log(avctx, AV_LOG_ERROR, "error during lzo decompression\n");
166 break; 162 break;
167 #else
168 av_log(avctx, AV_LOG_ERROR, "compiled without lzo (GPL) support\n");
169 return -1;
170 #endif
171 } 163 }
172 case 1: { // zlib compression 164 case 1: { // zlib compression
173 #ifdef CONFIG_ZLIB 165 #ifdef CONFIG_ZLIB
174 unsigned long dlen = c->decomp_size; 166 unsigned long dlen = c->decomp_size;
175 if (uncompress(c->decomp_buf, &dlen, &buf[2], buf_size - 2) != Z_OK) 167 if (uncompress(c->decomp_buf, &dlen, &buf[2], buf_size - 2) != Z_OK)