comparison flashsv.c @ 4367:b885917fbfef libavcodec

Get rid of #ifdef CONFIG_ZLIB in the code. Code cleanup.
author banan
date Sun, 21 Jan 2007 12:26:23 +0000
parents c8c591fe26f8
children e6eb67453d94
comparison
equal deleted inserted replaced
4366:f8753597422c 4367:b885917fbfef
47 * block sizes should give a better result then to just use a fixed size. 47 * block sizes should give a better result then to just use a fixed size.
48 */ 48 */
49 49
50 #include <stdio.h> 50 #include <stdio.h>
51 #include <stdlib.h> 51 #include <stdlib.h>
52 #include <zlib.h>
52 53
53 #include "common.h" 54 #include "common.h"
54 #include "avcodec.h" 55 #include "avcodec.h"
55 #include "bitstream.h" 56 #include "bitstream.h"
56
57 #ifdef CONFIG_ZLIB
58 #include <zlib.h>
59 #endif
60 57
61 typedef struct FlashSVContext { 58 typedef struct FlashSVContext {
62 AVCodecContext *avctx; 59 AVCodecContext *avctx;
63 AVFrame frame; 60 AVFrame frame;
64 int image_width, image_height; 61 int image_width, image_height;
65 int block_width, block_height; 62 int block_width, block_height;
66 uint8_t* tmpblock; 63 uint8_t* tmpblock;
67 int block_size; 64 int block_size;
68 #ifdef CONFIG_ZLIB
69 z_stream zstream; 65 z_stream zstream;
70 #endif
71 } FlashSVContext; 66 } FlashSVContext;
72 67
73 68
74 static void copy_region(uint8_t *sptr, uint8_t *dptr, 69 static void copy_region(uint8_t *sptr, uint8_t *dptr,
75 int dx, int dy, int h, int w, int stride) 70 int dx, int dy, int h, int w, int stride)
88 { 83 {
89 FlashSVContext *s = (FlashSVContext *)avctx->priv_data; 84 FlashSVContext *s = (FlashSVContext *)avctx->priv_data;
90 int zret; // Zlib return code 85 int zret; // Zlib return code
91 86
92 s->avctx = avctx; 87 s->avctx = avctx;
93 #ifdef CONFIG_ZLIB
94 s->zstream.zalloc = Z_NULL; 88 s->zstream.zalloc = Z_NULL;
95 s->zstream.zfree = Z_NULL; 89 s->zstream.zfree = Z_NULL;
96 s->zstream.opaque = Z_NULL; 90 s->zstream.opaque = Z_NULL;
97 zret = inflateInit(&(s->zstream)); 91 zret = inflateInit(&(s->zstream));
98 if (zret != Z_OK) { 92 if (zret != Z_OK) {
99 av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret); 93 av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
100 return 1; 94 return 1;
101 } 95 }
102 #else
103 av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled. Needed for the decoder.\n");
104 return 1;
105 #endif
106 avctx->pix_fmt = PIX_FMT_BGR24; 96 avctx->pix_fmt = PIX_FMT_BGR24;
107 avctx->has_b_frames = 0; 97 avctx->has_b_frames = 0;
108 s->frame.data[0] = NULL; 98 s->frame.data[0] = NULL;
109 99
110 return 0; 100 return 0;
196 186
197 if (size == 0) { 187 if (size == 0) {
198 /* no change, don't do anything */ 188 /* no change, don't do anything */
199 } else { 189 } else {
200 /* decompress block */ 190 /* decompress block */
201 #ifdef CONFIG_ZLIB
202 int ret = inflateReset(&(s->zstream)); 191 int ret = inflateReset(&(s->zstream));
203 if (ret != Z_OK) 192 if (ret != Z_OK)
204 { 193 {
205 av_log(avctx, AV_LOG_ERROR, "error in decompression (reset) of block %dx%d\n", i, j); 194 av_log(avctx, AV_LOG_ERROR, "error in decompression (reset) of block %dx%d\n", i, j);
206 /* return -1; */ 195 /* return -1; */
220 if ((ret != Z_OK) && (ret != Z_STREAM_END)) 209 if ((ret != Z_OK) && (ret != Z_STREAM_END))
221 { 210 {
222 av_log(avctx, AV_LOG_ERROR, "error in decompression of block %dx%d: %d\n", i, j, ret); 211 av_log(avctx, AV_LOG_ERROR, "error in decompression of block %dx%d: %d\n", i, j, ret);
223 /* return -1; */ 212 /* return -1; */
224 } 213 }
225 #else
226 av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled in.\n");
227 return -1;
228 #endif
229 copy_region(s->tmpblock, s->frame.data[0], s->image_height-(hp+hs+1), wp, hs, ws, s->frame.linesize[0]); 214 copy_region(s->tmpblock, s->frame.data[0], s->image_height-(hp+hs+1), wp, hs, ws, s->frame.linesize[0]);
230 skip_bits(&gb, 8*size); /* skip the consumed bits */ 215 skip_bits(&gb, 8*size); /* skip the consumed bits */
231 } 216 }
232 } 217 }
233 } 218 }
245 230
246 231
247 static int flashsv_decode_end(AVCodecContext *avctx) 232 static int flashsv_decode_end(AVCodecContext *avctx)
248 { 233 {
249 FlashSVContext *s = (FlashSVContext *)avctx->priv_data; 234 FlashSVContext *s = (FlashSVContext *)avctx->priv_data;
250 #ifdef CONFIG_ZLIB
251 inflateEnd(&(s->zstream)); 235 inflateEnd(&(s->zstream));
252 #endif
253 /* release the frame if needed */ 236 /* release the frame if needed */
254 if (s->frame.data[0]) 237 if (s->frame.data[0])
255 avctx->release_buffer(avctx, &s->frame); 238 avctx->release_buffer(avctx, &s->frame);
256 239
257 /* free the tmpblock */ 240 /* free the tmpblock */