Mercurial > libavcodec.hg
annotate lcl.c @ 4191:c9867abab7e6 libavcodec
Update error message
author | kostya |
---|---|
date | Mon, 13 Nov 2006 11:36:22 +0000 |
parents | c8c591fe26f8 |
children | 66ef3690d108 |
rev | line source |
---|---|
1743 | 1 /* |
2 * LCL (LossLess Codec Library) Codec | |
3 * Copyright (c) 2002-2004 Roberto Togni | |
4 * | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3777
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3777
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3777
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
1743 | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3777
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
1743 | 11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3777
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
1743 | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3777
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2979
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
1743 | 20 * |
21 */ | |
22 | |
23 /** | |
24 * @file lcl.c | |
25 * LCL (LossLess Codec Library) Video Codec | |
26 * Decoder for MSZH and ZLIB codecs | |
27 * Experimental encoder for ZLIB RGB24 | |
28 * | |
29 * Fourcc: MSZH, ZLIB | |
30 * | |
31 * Original Win32 dll: | |
32 * Ver2.23 By Kenji Oshima 2000.09.20 | |
33 * avimszh.dll, avizlib.dll | |
34 * | |
35 * A description of the decoding algorithm can be found here: | |
36 * http://www.pcisys.net/~melanson/codecs | |
37 * | |
38 * Supports: BGR24 (RGB 24bpp) | |
39 * | |
40 */ | |
41 | |
42 #include <stdio.h> | |
43 #include <stdlib.h> | |
44 | |
45 #include "common.h" | |
2398
582e635cfa08
common.c -> bitstream.c (and the single non bitstream func -> utils.c)
michael
parents:
2250
diff
changeset
|
46 #include "bitstream.h" |
1743 | 47 #include "avcodec.h" |
48 | |
49 #ifdef CONFIG_ZLIB | |
50 #include <zlib.h> | |
51 #endif | |
52 | |
53 | |
54 #define BMPTYPE_YUV 1 | |
55 #define BMPTYPE_RGB 2 | |
56 | |
57 #define IMGTYPE_YUV111 0 | |
58 #define IMGTYPE_YUV422 1 | |
59 #define IMGTYPE_RGB24 2 | |
60 #define IMGTYPE_YUV411 3 | |
61 #define IMGTYPE_YUV211 4 | |
62 #define IMGTYPE_YUV420 5 | |
63 | |
64 #define COMP_MSZH 0 | |
65 #define COMP_MSZH_NOCOMP 1 | |
66 #define COMP_ZLIB_HISPEED 1 | |
67 #define COMP_ZLIB_HICOMP 9 | |
68 #define COMP_ZLIB_NORMAL -1 | |
69 | |
70 #define FLAG_MULTITHREAD 1 | |
71 #define FLAG_NULLFRAME 2 | |
72 #define FLAG_PNGFILTER 4 | |
73 #define FLAGMASK_UNUSED 0xf8 | |
74 | |
75 #define CODEC_MSZH 1 | |
76 #define CODEC_ZLIB 3 | |
77 | |
78 #define FOURCC_MSZH mmioFOURCC('M','S','Z','H') | |
79 #define FOURCC_ZLIB mmioFOURCC('Z','L','I','B') | |
80 | |
81 /* | |
82 * Decoder context | |
83 */ | |
84 typedef struct LclContext { | |
85 | |
2979 | 86 AVCodecContext *avctx; |
87 AVFrame pic; | |
1743 | 88 PutBitContext pb; |
89 | |
90 // Image type | |
91 int imgtype; | |
92 // Compression type | |
93 int compression; | |
94 // Flags | |
95 int flags; | |
96 // Decompressed data size | |
97 unsigned int decomp_size; | |
98 // Decompression buffer | |
99 unsigned char* decomp_buf; | |
100 // Maximum compressed data size | |
101 unsigned int max_comp_size; | |
102 // Compression buffer | |
103 unsigned char* comp_buf; | |
104 #ifdef CONFIG_ZLIB | |
105 z_stream zstream; | |
106 #endif | |
107 } LclContext; | |
108 | |
109 | |
110 /* | |
111 * | |
112 * Helper functions | |
113 * | |
114 */ | |
115 static inline unsigned char fix (int pix14) | |
116 { | |
117 int tmp; | |
118 | |
119 tmp = (pix14 + 0x80000) >> 20; | |
120 if (tmp < 0) | |
121 return 0; | |
122 if (tmp > 255) | |
123 return 255; | |
124 return tmp; | |
125 } | |
126 | |
127 | |
128 | |
129 static inline unsigned char get_b (unsigned char yq, signed char bq) | |
130 { | |
131 return fix((yq << 20) + bq * 1858076); | |
132 } | |
133 | |
134 | |
135 | |
136 static inline unsigned char get_g (unsigned char yq, signed char bq, signed char rq) | |
137 { | |
138 return fix((yq << 20) - bq * 360857 - rq * 748830); | |
139 } | |
140 | |
141 | |
142 | |
143 static inline unsigned char get_r (unsigned char yq, signed char rq) | |
144 { | |
145 return fix((yq << 20) + rq * 1470103); | |
146 } | |
147 | |
148 | |
149 | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
150 static unsigned int mszh_decomp(unsigned char * srcptr, int srclen, unsigned char * destptr, unsigned int destsize) |
1743 | 151 { |
152 unsigned char *destptr_bak = destptr; | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
153 unsigned char *destptr_end = destptr + destsize; |
1743 | 154 unsigned char mask = 0; |
155 unsigned char maskbit = 0; | |
156 unsigned int ofs, cnt; | |
2967 | 157 |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
158 while ((srclen > 0) && (destptr < destptr_end)) { |
1743 | 159 if (maskbit == 0) { |
160 mask = *(srcptr++); | |
161 maskbit = 8; | |
162 srclen--; | |
163 continue; | |
164 } | |
165 if ((mask & (1 << (--maskbit))) == 0) { | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
166 if (destptr + 4 > destptr_end) |
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
167 break; |
1743 | 168 *(int*)destptr = *(int*)srcptr; |
169 srclen -= 4; | |
170 destptr += 4; | |
171 srcptr += 4; | |
172 } else { | |
173 ofs = *(srcptr++); | |
174 cnt = *(srcptr++); | |
175 ofs += cnt * 256;; | |
176 cnt = ((cnt >> 3) & 0x1f) + 1; | |
177 ofs &= 0x7ff; | |
178 srclen -= 2; | |
179 cnt *= 4; | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
180 if (destptr + cnt > destptr_end) { |
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
181 cnt = destptr_end - destptr; |
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
182 } |
1743 | 183 for (; cnt > 0; cnt--) { |
184 *(destptr) = *(destptr - ofs); | |
185 destptr++; | |
186 } | |
187 } | |
188 } | |
189 | |
190 return (destptr - destptr_bak); | |
191 } | |
192 | |
193 | |
194 | |
3777 | 195 #ifdef CONFIG_DECODERS |
1743 | 196 /* |
197 * | |
198 * Decode a frame | |
199 * | |
200 */ | |
201 static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) | |
202 { | |
2979 | 203 LclContext * const c = (LclContext *)avctx->priv_data; |
204 unsigned char *encoded = (unsigned char *)buf; | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
205 unsigned int pixel_ptr; |
1743 | 206 int row, col; |
207 unsigned char *outptr; | |
208 unsigned int width = avctx->width; // Real image width | |
209 unsigned int height = avctx->height; // Real image height | |
210 unsigned int mszh_dlen; | |
211 unsigned char yq, y1q, uq, vq; | |
212 int uqvq; | |
213 unsigned int mthread_inlen, mthread_outlen; | |
214 #ifdef CONFIG_ZLIB | |
215 int zret; // Zlib return code | |
216 #endif | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
217 unsigned int len = buf_size; |
1743 | 218 |
2979 | 219 if(c->pic.data[0]) |
220 avctx->release_buffer(avctx, &c->pic); | |
1743 | 221 |
2979 | 222 c->pic.reference = 0; |
223 c->pic.buffer_hints = FF_BUFFER_HINTS_VALID; | |
224 if(avctx->get_buffer(avctx, &c->pic) < 0){ | |
225 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | |
226 return -1; | |
227 } | |
1743 | 228 |
229 outptr = c->pic.data[0]; // Output image pointer | |
230 | |
231 /* Decompress frame */ | |
232 switch (avctx->codec_id) { | |
233 case CODEC_ID_MSZH: | |
234 switch (c->compression) { | |
235 case COMP_MSZH: | |
236 if (c->flags & FLAG_MULTITHREAD) { | |
237 mthread_inlen = *((unsigned int*)encoded); | |
238 mthread_outlen = *((unsigned int*)(encoded+4)); | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
239 if (mthread_outlen > c->decomp_size) // this should not happen |
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
240 mthread_outlen = c->decomp_size; |
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
241 mszh_dlen = mszh_decomp(encoded + 8, mthread_inlen, c->decomp_buf, c->decomp_size); |
1743 | 242 if (mthread_outlen != mszh_dlen) { |
243 av_log(avctx, AV_LOG_ERROR, "Mthread1 decoded size differs (%d != %d)\n", | |
244 mthread_outlen, mszh_dlen); | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
245 return -1; |
1743 | 246 } |
247 mszh_dlen = mszh_decomp(encoded + 8 + mthread_inlen, len - mthread_inlen, | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
248 c->decomp_buf + mthread_outlen, c->decomp_size - mthread_outlen); |
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
249 if (mthread_outlen != mszh_dlen) { |
1743 | 250 av_log(avctx, AV_LOG_ERROR, "Mthread2 decoded size differs (%d != %d)\n", |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
251 mthread_outlen, mszh_dlen); |
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
252 return -1; |
1743 | 253 } |
254 encoded = c->decomp_buf; | |
255 len = c->decomp_size; | |
256 } else { | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
257 mszh_dlen = mszh_decomp(encoded, len, c->decomp_buf, c->decomp_size); |
1743 | 258 if (c->decomp_size != mszh_dlen) { |
259 av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %d)\n", | |
260 c->decomp_size, mszh_dlen); | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
261 return -1; |
1743 | 262 } |
263 encoded = c->decomp_buf; | |
264 len = mszh_dlen; | |
265 } | |
266 break; | |
267 case COMP_MSZH_NOCOMP: | |
268 break; | |
269 default: | |
270 av_log(avctx, AV_LOG_ERROR, "BUG! Unknown MSZH compression in frame decoder.\n"); | |
271 return -1; | |
272 } | |
273 break; | |
274 case CODEC_ID_ZLIB: | |
275 #ifdef CONFIG_ZLIB | |
276 /* Using the original dll with normal compression (-1) and RGB format | |
277 * gives a file with ZLIB fourcc, but frame is really uncompressed. | |
278 * To be sure that's true check also frame size */ | |
279 if ((c->compression == COMP_ZLIB_NORMAL) && (c->imgtype == IMGTYPE_RGB24) && | |
280 (len == width * height * 3)) | |
281 break; | |
282 zret = inflateReset(&(c->zstream)); | |
283 if (zret != Z_OK) { | |
284 av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret); | |
285 return -1; | |
286 } | |
287 if (c->flags & FLAG_MULTITHREAD) { | |
288 mthread_inlen = *((unsigned int*)encoded); | |
289 mthread_outlen = *((unsigned int*)(encoded+4)); | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
290 if (mthread_outlen > c->decomp_size) |
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
291 mthread_outlen = c->decomp_size; |
1743 | 292 c->zstream.next_in = encoded + 8; |
293 c->zstream.avail_in = mthread_inlen; | |
294 c->zstream.next_out = c->decomp_buf; | |
2967 | 295 c->zstream.avail_out = c->decomp_size; |
1743 | 296 zret = inflate(&(c->zstream), Z_FINISH); |
297 if ((zret != Z_OK) && (zret != Z_STREAM_END)) { | |
298 av_log(avctx, AV_LOG_ERROR, "Mthread1 inflate error: %d\n", zret); | |
299 return -1; | |
300 } | |
301 if (mthread_outlen != (unsigned int)(c->zstream.total_out)) { | |
302 av_log(avctx, AV_LOG_ERROR, "Mthread1 decoded size differs (%u != %lu)\n", | |
303 mthread_outlen, c->zstream.total_out); | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
304 return -1; |
1743 | 305 } |
306 zret = inflateReset(&(c->zstream)); | |
307 if (zret != Z_OK) { | |
308 av_log(avctx, AV_LOG_ERROR, "Mthread2 inflate reset error: %d\n", zret); | |
309 return -1; | |
310 } | |
311 c->zstream.next_in = encoded + 8 + mthread_inlen; | |
312 c->zstream.avail_in = len - mthread_inlen; | |
313 c->zstream.next_out = c->decomp_buf + mthread_outlen; | |
2967 | 314 c->zstream.avail_out = c->decomp_size - mthread_outlen; |
1743 | 315 zret = inflate(&(c->zstream), Z_FINISH); |
316 if ((zret != Z_OK) && (zret != Z_STREAM_END)) { | |
317 av_log(avctx, AV_LOG_ERROR, "Mthread2 inflate error: %d\n", zret); | |
318 return -1; | |
319 } | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
320 if (mthread_outlen != (unsigned int)(c->zstream.total_out)) { |
1743 | 321 av_log(avctx, AV_LOG_ERROR, "Mthread2 decoded size differs (%d != %lu)\n", |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
322 mthread_outlen, c->zstream.total_out); |
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
323 return -1; |
1743 | 324 } |
325 } else { | |
326 c->zstream.next_in = encoded; | |
327 c->zstream.avail_in = len; | |
328 c->zstream.next_out = c->decomp_buf; | |
329 c->zstream.avail_out = c->decomp_size; | |
330 zret = inflate(&(c->zstream), Z_FINISH); | |
331 if ((zret != Z_OK) && (zret != Z_STREAM_END)) { | |
332 av_log(avctx, AV_LOG_ERROR, "Inflate error: %d\n", zret); | |
333 return -1; | |
334 } | |
335 if (c->decomp_size != (unsigned int)(c->zstream.total_out)) { | |
336 av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %lu)\n", | |
337 c->decomp_size, c->zstream.total_out); | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
338 return -1; |
1743 | 339 } |
340 } | |
341 encoded = c->decomp_buf; | |
342 len = c->decomp_size;; | |
343 #else | |
344 av_log(avctx, AV_LOG_ERROR, "BUG! Zlib support not compiled in frame decoder.\n"); | |
345 return -1; | |
346 #endif | |
347 break; | |
348 default: | |
349 av_log(avctx, AV_LOG_ERROR, "BUG! Unknown codec in frame decoder compression switch.\n"); | |
350 return -1; | |
351 } | |
352 | |
353 | |
354 /* Apply PNG filter */ | |
355 if ((avctx->codec_id == CODEC_ID_ZLIB) && (c->flags & FLAG_PNGFILTER)) { | |
356 switch (c->imgtype) { | |
357 case IMGTYPE_YUV111: | |
358 case IMGTYPE_RGB24: | |
359 for (row = 0; row < height; row++) { | |
360 pixel_ptr = row * width * 3; | |
361 yq = encoded[pixel_ptr++]; | |
362 uqvq = encoded[pixel_ptr++]; | |
2979 | 363 uqvq+=(encoded[pixel_ptr++] << 8); |
1743 | 364 for (col = 1; col < width; col++) { |
365 encoded[pixel_ptr] = yq -= encoded[pixel_ptr]; | |
366 uqvq -= (encoded[pixel_ptr+1] | (encoded[pixel_ptr+2]<<8)); | |
367 encoded[pixel_ptr+1] = (uqvq) & 0xff; | |
368 encoded[pixel_ptr+2] = ((uqvq)>>8) & 0xff; | |
369 pixel_ptr += 3; | |
370 } | |
371 } | |
372 break; | |
373 case IMGTYPE_YUV422: | |
374 for (row = 0; row < height; row++) { | |
375 pixel_ptr = row * width * 2; | |
376 yq = uq = vq =0; | |
377 for (col = 0; col < width/4; col++) { | |
378 encoded[pixel_ptr] = yq -= encoded[pixel_ptr]; | |
379 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1]; | |
380 encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2]; | |
381 encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3]; | |
382 encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4]; | |
383 encoded[pixel_ptr+5] = uq -= encoded[pixel_ptr+5]; | |
384 encoded[pixel_ptr+6] = vq -= encoded[pixel_ptr+6]; | |
385 encoded[pixel_ptr+7] = vq -= encoded[pixel_ptr+7]; | |
386 pixel_ptr += 8; | |
387 } | |
388 } | |
389 break; | |
390 case IMGTYPE_YUV411: | |
391 for (row = 0; row < height; row++) { | |
392 pixel_ptr = row * width / 2 * 3; | |
393 yq = uq = vq =0; | |
394 for (col = 0; col < width/4; col++) { | |
395 encoded[pixel_ptr] = yq -= encoded[pixel_ptr]; | |
396 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1]; | |
397 encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2]; | |
398 encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3]; | |
399 encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4]; | |
400 encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5]; | |
401 pixel_ptr += 6; | |
402 } | |
403 } | |
404 break; | |
405 case IMGTYPE_YUV211: | |
406 for (row = 0; row < height; row++) { | |
407 pixel_ptr = row * width * 2; | |
408 yq = uq = vq =0; | |
409 for (col = 0; col < width/2; col++) { | |
410 encoded[pixel_ptr] = yq -= encoded[pixel_ptr]; | |
411 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1]; | |
412 encoded[pixel_ptr+2] = uq -= encoded[pixel_ptr+2]; | |
413 encoded[pixel_ptr+3] = vq -= encoded[pixel_ptr+3]; | |
414 pixel_ptr += 4; | |
415 } | |
416 } | |
417 break; | |
418 case IMGTYPE_YUV420: | |
419 for (row = 0; row < height/2; row++) { | |
420 pixel_ptr = row * width * 3; | |
421 yq = y1q = uq = vq =0; | |
422 for (col = 0; col < width/2; col++) { | |
423 encoded[pixel_ptr] = yq -= encoded[pixel_ptr]; | |
424 encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1]; | |
425 encoded[pixel_ptr+2] = y1q -= encoded[pixel_ptr+2]; | |
426 encoded[pixel_ptr+3] = y1q -= encoded[pixel_ptr+3]; | |
427 encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4]; | |
428 encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5]; | |
429 pixel_ptr += 6; | |
430 } | |
431 } | |
432 break; | |
433 default: | |
434 av_log(avctx, AV_LOG_ERROR, "BUG! Unknown imagetype in pngfilter switch.\n"); | |
435 return -1; | |
436 } | |
437 } | |
438 | |
439 /* Convert colorspace */ | |
440 switch (c->imgtype) { | |
441 case IMGTYPE_YUV111: | |
442 for (row = height - 1; row >= 0; row--) { | |
443 pixel_ptr = row * c->pic.linesize[0]; | |
444 for (col = 0; col < width; col++) { | |
445 outptr[pixel_ptr++] = get_b(encoded[0], encoded[1]); | |
446 outptr[pixel_ptr++] = get_g(encoded[0], encoded[1], encoded[2]); | |
447 outptr[pixel_ptr++] = get_r(encoded[0], encoded[2]); | |
448 encoded += 3; | |
449 } | |
450 } | |
451 break; | |
452 case IMGTYPE_YUV422: | |
453 for (row = height - 1; row >= 0; row--) { | |
454 pixel_ptr = row * c->pic.linesize[0]; | |
455 for (col = 0; col < width/4; col++) { | |
456 outptr[pixel_ptr++] = get_b(encoded[0], encoded[4]); | |
457 outptr[pixel_ptr++] = get_g(encoded[0], encoded[4], encoded[6]); | |
458 outptr[pixel_ptr++] = get_r(encoded[0], encoded[6]); | |
459 outptr[pixel_ptr++] = get_b(encoded[1], encoded[4]); | |
460 outptr[pixel_ptr++] = get_g(encoded[1], encoded[4], encoded[6]); | |
461 outptr[pixel_ptr++] = get_r(encoded[1], encoded[6]); | |
462 outptr[pixel_ptr++] = get_b(encoded[2], encoded[5]); | |
463 outptr[pixel_ptr++] = get_g(encoded[2], encoded[5], encoded[7]); | |
464 outptr[pixel_ptr++] = get_r(encoded[2], encoded[7]); | |
465 outptr[pixel_ptr++] = get_b(encoded[3], encoded[5]); | |
466 outptr[pixel_ptr++] = get_g(encoded[3], encoded[5], encoded[7]); | |
467 outptr[pixel_ptr++] = get_r(encoded[3], encoded[7]); | |
468 encoded += 8; | |
469 } | |
470 } | |
471 break; | |
472 case IMGTYPE_RGB24: | |
473 for (row = height - 1; row >= 0; row--) { | |
474 pixel_ptr = row * c->pic.linesize[0]; | |
475 for (col = 0; col < width; col++) { | |
476 outptr[pixel_ptr++] = encoded[0]; | |
477 outptr[pixel_ptr++] = encoded[1]; | |
478 outptr[pixel_ptr++] = encoded[2]; | |
479 encoded += 3; | |
480 } | |
481 } | |
482 break; | |
483 case IMGTYPE_YUV411: | |
484 for (row = height - 1; row >= 0; row--) { | |
485 pixel_ptr = row * c->pic.linesize[0]; | |
486 for (col = 0; col < width/4; col++) { | |
487 outptr[pixel_ptr++] = get_b(encoded[0], encoded[4]); | |
488 outptr[pixel_ptr++] = get_g(encoded[0], encoded[4], encoded[5]); | |
489 outptr[pixel_ptr++] = get_r(encoded[0], encoded[5]); | |
490 outptr[pixel_ptr++] = get_b(encoded[1], encoded[4]); | |
491 outptr[pixel_ptr++] = get_g(encoded[1], encoded[4], encoded[5]); | |
492 outptr[pixel_ptr++] = get_r(encoded[1], encoded[5]); | |
493 outptr[pixel_ptr++] = get_b(encoded[2], encoded[4]); | |
494 outptr[pixel_ptr++] = get_g(encoded[2], encoded[4], encoded[5]); | |
495 outptr[pixel_ptr++] = get_r(encoded[2], encoded[5]); | |
496 outptr[pixel_ptr++] = get_b(encoded[3], encoded[4]); | |
497 outptr[pixel_ptr++] = get_g(encoded[3], encoded[4], encoded[5]); | |
498 outptr[pixel_ptr++] = get_r(encoded[3], encoded[5]); | |
499 encoded += 6; | |
500 } | |
501 } | |
502 break; | |
503 case IMGTYPE_YUV211: | |
504 for (row = height - 1; row >= 0; row--) { | |
505 pixel_ptr = row * c->pic.linesize[0]; | |
506 for (col = 0; col < width/2; col++) { | |
507 outptr[pixel_ptr++] = get_b(encoded[0], encoded[2]); | |
508 outptr[pixel_ptr++] = get_g(encoded[0], encoded[2], encoded[3]); | |
509 outptr[pixel_ptr++] = get_r(encoded[0], encoded[3]); | |
510 outptr[pixel_ptr++] = get_b(encoded[1], encoded[2]); | |
511 outptr[pixel_ptr++] = get_g(encoded[1], encoded[2], encoded[3]); | |
512 outptr[pixel_ptr++] = get_r(encoded[1], encoded[3]); | |
513 encoded += 4; | |
514 } | |
515 } | |
516 break; | |
517 case IMGTYPE_YUV420: | |
518 for (row = height / 2 - 1; row >= 0; row--) { | |
519 pixel_ptr = 2 * row * c->pic.linesize[0]; | |
520 for (col = 0; col < width/2; col++) { | |
521 outptr[pixel_ptr] = get_b(encoded[0], encoded[4]); | |
522 outptr[pixel_ptr+1] = get_g(encoded[0], encoded[4], encoded[5]); | |
523 outptr[pixel_ptr+2] = get_r(encoded[0], encoded[5]); | |
524 outptr[pixel_ptr+3] = get_b(encoded[1], encoded[4]); | |
525 outptr[pixel_ptr+4] = get_g(encoded[1], encoded[4], encoded[5]); | |
526 outptr[pixel_ptr+5] = get_r(encoded[1], encoded[5]); | |
527 outptr[pixel_ptr-c->pic.linesize[0]] = get_b(encoded[2], encoded[4]); | |
528 outptr[pixel_ptr-c->pic.linesize[0]+1] = get_g(encoded[2], encoded[4], encoded[5]); | |
529 outptr[pixel_ptr-c->pic.linesize[0]+2] = get_r(encoded[2], encoded[5]); | |
530 outptr[pixel_ptr-c->pic.linesize[0]+3] = get_b(encoded[3], encoded[4]); | |
531 outptr[pixel_ptr-c->pic.linesize[0]+4] = get_g(encoded[3], encoded[4], encoded[5]); | |
532 outptr[pixel_ptr-c->pic.linesize[0]+5] = get_r(encoded[3], encoded[5]); | |
533 pixel_ptr += 6; | |
534 encoded += 6; | |
535 } | |
536 } | |
537 break; | |
538 default: | |
539 av_log(avctx, AV_LOG_ERROR, "BUG! Unknown imagetype in image decoder.\n"); | |
540 return -1; | |
541 } | |
542 | |
543 *data_size = sizeof(AVFrame); | |
544 *(AVFrame*)data = c->pic; | |
545 | |
546 /* always report that the buffer was completely consumed */ | |
547 return buf_size; | |
548 } | |
3777 | 549 #endif |
1743 | 550 |
3777 | 551 #ifdef CONFIG_ENCODERS |
1743 | 552 /* |
553 * | |
554 * Encode a frame | |
555 * | |
556 */ | |
557 static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ | |
558 LclContext *c = avctx->priv_data; | |
559 AVFrame *pict = data; | |
560 AVFrame * const p = &c->pic; | |
561 int i; | |
562 int zret; // Zlib return code | |
563 | |
564 #ifndef CONFIG_ZLIB | |
565 av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled in.\n"); | |
566 return -1; | |
567 #else | |
568 | |
569 init_put_bits(&c->pb, buf, buf_size); | |
2967 | 570 |
1743 | 571 *p = *pict; |
572 p->pict_type= FF_I_TYPE; | |
573 p->key_frame= 1; | |
2967 | 574 |
1743 | 575 if(avctx->pix_fmt != PIX_FMT_BGR24){ |
576 av_log(avctx, AV_LOG_ERROR, "Format not supported!\n"); | |
577 return -1; | |
578 } | |
579 | |
580 zret = deflateReset(&(c->zstream)); | |
581 if (zret != Z_OK) { | |
582 av_log(avctx, AV_LOG_ERROR, "Deflate reset error: %d\n", zret); | |
583 return -1; | |
584 } | |
585 c->zstream.next_out = c->comp_buf; | |
586 c->zstream.avail_out = c->max_comp_size; | |
587 | |
2250
902caf560c43
Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents:
2248
diff
changeset
|
588 for(i = avctx->height - 1; i >= 0; i--) { |
902caf560c43
Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents:
2248
diff
changeset
|
589 c->zstream.next_in = p->data[0]+p->linesize[0]*i; |
902caf560c43
Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents:
2248
diff
changeset
|
590 c->zstream.avail_in = avctx->width*3; |
902caf560c43
Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents:
2248
diff
changeset
|
591 zret = deflate(&(c->zstream), Z_NO_FLUSH); |
902caf560c43
Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents:
2248
diff
changeset
|
592 if (zret != Z_OK) { |
2979 | 593 av_log(avctx, AV_LOG_ERROR, "Deflate error: %d\n", zret); |
594 return -1; | |
2250
902caf560c43
Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents:
2248
diff
changeset
|
595 } |
902caf560c43
Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents:
2248
diff
changeset
|
596 } |
1743 | 597 zret = deflate(&(c->zstream), Z_FINISH); |
2250
902caf560c43
Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents:
2248
diff
changeset
|
598 if (zret != Z_STREAM_END) { |
1743 | 599 av_log(avctx, AV_LOG_ERROR, "Deflate error: %d\n", zret); |
600 return -1; | |
601 } | |
602 | |
603 for (i = 0; i < c->zstream.total_out; i++) | |
604 put_bits(&c->pb, 8, c->comp_buf[i]); | |
605 flush_put_bits(&c->pb); | |
606 | |
607 return c->zstream.total_out; | |
608 #endif | |
609 } | |
3777 | 610 #endif /* CONFIG_ENCODERS */ |
1743 | 611 |
3777 | 612 #ifdef CONFIG_DECODERS |
1743 | 613 /* |
614 * | |
615 * Init lcl decoder | |
616 * | |
617 */ | |
618 static int decode_init(AVCodecContext *avctx) | |
619 { | |
620 LclContext * const c = (LclContext *)avctx->priv_data; | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
621 unsigned int basesize = avctx->width * avctx->height; |
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
622 unsigned int max_basesize = ((avctx->width + 3) & ~3) * ((avctx->height + 3) & ~3); |
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
623 unsigned int max_decomp_size; |
1743 | 624 int zret; // Zlib return code |
625 | |
626 c->avctx = avctx; | |
627 avctx->has_b_frames = 0; | |
628 | |
629 c->pic.data[0] = NULL; | |
630 | |
631 #ifdef CONFIG_ZLIB | |
632 // Needed if zlib unused or init aborted before inflateInit | |
2967 | 633 memset(&(c->zstream), 0, sizeof(z_stream)); |
1743 | 634 #endif |
635 | |
636 if (avctx->extradata_size < 8) { | |
637 av_log(avctx, AV_LOG_ERROR, "Extradata size too small.\n"); | |
638 return 1; | |
639 } | |
640 | |
2429
4b350cc506a7
Use avcodec_check_dimensions instead of custom hack
rtognimp
parents:
2418
diff
changeset
|
641 if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) { |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
642 return 1; |
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
643 } |
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
644 |
2967 | 645 /* Check codec type */ |
1743 | 646 if (((avctx->codec_id == CODEC_ID_MSZH) && (*((char *)avctx->extradata + 7) != CODEC_MSZH)) || |
647 ((avctx->codec_id == CODEC_ID_ZLIB) && (*((char *)avctx->extradata + 7) != CODEC_ZLIB))) { | |
648 av_log(avctx, AV_LOG_ERROR, "Codec id and codec type mismatch. This should not happen.\n"); | |
649 } | |
650 | |
651 /* Detect image type */ | |
652 switch (c->imgtype = *((char *)avctx->extradata + 4)) { | |
653 case IMGTYPE_YUV111: | |
654 c->decomp_size = basesize * 3; | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
655 max_decomp_size = max_basesize * 3; |
1743 | 656 av_log(avctx, AV_LOG_INFO, "Image type is YUV 1:1:1.\n"); |
657 break; | |
658 case IMGTYPE_YUV422: | |
659 c->decomp_size = basesize * 2; | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
660 max_decomp_size = max_basesize * 2; |
1743 | 661 av_log(avctx, AV_LOG_INFO, "Image type is YUV 4:2:2.\n"); |
662 break; | |
663 case IMGTYPE_RGB24: | |
664 c->decomp_size = basesize * 3; | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
665 max_decomp_size = max_basesize * 3; |
1743 | 666 av_log(avctx, AV_LOG_INFO, "Image type is RGB 24.\n"); |
667 break; | |
668 case IMGTYPE_YUV411: | |
669 c->decomp_size = basesize / 2 * 3; | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
670 max_decomp_size = max_basesize / 2 * 3; |
1743 | 671 av_log(avctx, AV_LOG_INFO, "Image type is YUV 4:1:1.\n"); |
672 break; | |
673 case IMGTYPE_YUV211: | |
674 c->decomp_size = basesize * 2; | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
675 max_decomp_size = max_basesize * 2; |
1743 | 676 av_log(avctx, AV_LOG_INFO, "Image type is YUV 2:1:1.\n"); |
677 break; | |
678 case IMGTYPE_YUV420: | |
679 c->decomp_size = basesize / 2 * 3; | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
680 max_decomp_size = max_basesize / 2 * 3; |
1743 | 681 av_log(avctx, AV_LOG_INFO, "Image type is YUV 4:2:0.\n"); |
682 break; | |
683 default: | |
684 av_log(avctx, AV_LOG_ERROR, "Unsupported image format %d.\n", c->imgtype); | |
685 return 1; | |
686 } | |
687 | |
688 /* Detect compression method */ | |
689 c->compression = *((char *)avctx->extradata + 5); | |
690 switch (avctx->codec_id) { | |
691 case CODEC_ID_MSZH: | |
692 switch (c->compression) { | |
693 case COMP_MSZH: | |
694 av_log(avctx, AV_LOG_INFO, "Compression enabled.\n"); | |
695 break; | |
696 case COMP_MSZH_NOCOMP: | |
697 c->decomp_size = 0; | |
698 av_log(avctx, AV_LOG_INFO, "No compression.\n"); | |
699 break; | |
700 default: | |
701 av_log(avctx, AV_LOG_ERROR, "Unsupported compression format for MSZH (%d).\n", c->compression); | |
702 return 1; | |
703 } | |
704 break; | |
705 case CODEC_ID_ZLIB: | |
706 #ifdef CONFIG_ZLIB | |
707 switch (c->compression) { | |
708 case COMP_ZLIB_HISPEED: | |
709 av_log(avctx, AV_LOG_INFO, "High speed compression.\n"); | |
710 break; | |
711 case COMP_ZLIB_HICOMP: | |
712 av_log(avctx, AV_LOG_INFO, "High compression.\n"); | |
713 break; | |
714 case COMP_ZLIB_NORMAL: | |
715 av_log(avctx, AV_LOG_INFO, "Normal compression.\n"); | |
716 break; | |
717 default: | |
718 if ((c->compression < Z_NO_COMPRESSION) || (c->compression > Z_BEST_COMPRESSION)) { | |
2979 | 719 av_log(avctx, AV_LOG_ERROR, "Unsupported compression level for ZLIB: (%d).\n", c->compression); |
1743 | 720 return 1; |
721 } | |
722 av_log(avctx, AV_LOG_INFO, "Compression level for ZLIB: (%d).\n", c->compression); | |
723 } | |
724 #else | |
725 av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled.\n"); | |
726 return 1; | |
727 #endif | |
728 break; | |
729 default: | |
730 av_log(avctx, AV_LOG_ERROR, "BUG! Unknown codec in compression switch.\n"); | |
731 return 1; | |
732 } | |
733 | |
734 /* Allocate decompression buffer */ | |
735 if (c->decomp_size) { | |
2418
82af834636c2
Check pointers before writing to memory, fix possible integer overflows
rtognimp
parents:
2398
diff
changeset
|
736 if ((c->decomp_buf = av_malloc(max_decomp_size)) == NULL) { |
1743 | 737 av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); |
738 return 1; | |
739 } | |
740 } | |
2967 | 741 |
742 /* Detect flags */ | |
1743 | 743 c->flags = *((char *)avctx->extradata + 6); |
744 if (c->flags & FLAG_MULTITHREAD) | |
745 av_log(avctx, AV_LOG_INFO, "Multithread encoder flag set.\n"); | |
746 if (c->flags & FLAG_NULLFRAME) | |
747 av_log(avctx, AV_LOG_INFO, "Nullframe insertion flag set.\n"); | |
748 if ((avctx->codec_id == CODEC_ID_ZLIB) && (c->flags & FLAG_PNGFILTER)) | |
749 av_log(avctx, AV_LOG_INFO, "PNG filter flag set.\n"); | |
750 if (c->flags & FLAGMASK_UNUSED) | |
751 av_log(avctx, AV_LOG_ERROR, "Unknown flag set (%d).\n", c->flags); | |
752 | |
753 /* If needed init zlib */ | |
754 if (avctx->codec_id == CODEC_ID_ZLIB) { | |
755 #ifdef CONFIG_ZLIB | |
756 c->zstream.zalloc = Z_NULL; | |
757 c->zstream.zfree = Z_NULL; | |
758 c->zstream.opaque = Z_NULL; | |
759 zret = inflateInit(&(c->zstream)); | |
760 if (zret != Z_OK) { | |
761 av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret); | |
762 return 1; | |
763 } | |
764 #else | |
765 av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled.\n"); | |
766 return 1; | |
767 #endif | |
768 } | |
769 | |
770 avctx->pix_fmt = PIX_FMT_BGR24; | |
771 | |
772 return 0; | |
773 } | |
3777 | 774 #endif /* CONFIG_DECODERS */ |
1743 | 775 |
3777 | 776 #ifdef CONFIG_ENCODERS |
1743 | 777 /* |
778 * | |
779 * Init lcl encoder | |
780 * | |
781 */ | |
782 static int encode_init(AVCodecContext *avctx) | |
783 { | |
784 LclContext *c = avctx->priv_data; | |
785 int zret; // Zlib return code | |
786 | |
787 #ifndef CONFIG_ZLIB | |
788 av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled.\n"); | |
789 return 1; | |
790 #else | |
791 | |
792 c->avctx= avctx; | |
2967 | 793 |
1743 | 794 assert(avctx->width && avctx->height); |
2967 | 795 |
1743 | 796 avctx->extradata= av_mallocz(8); |
797 avctx->coded_frame= &c->pic; | |
798 | |
799 // Will be user settable someday | |
800 c->compression = 6; | |
801 c->flags = 0; | |
802 | |
803 switch(avctx->pix_fmt){ | |
804 case PIX_FMT_BGR24: | |
805 c->imgtype = IMGTYPE_RGB24; | |
806 c->decomp_size = avctx->width * avctx->height * 3; | |
807 avctx->bits_per_sample= 24; | |
808 break; | |
809 default: | |
810 av_log(avctx, AV_LOG_ERROR, "Format %d not supported\n", avctx->pix_fmt); | |
811 return -1; | |
812 } | |
813 | |
814 ((uint8_t*)avctx->extradata)[0]= 4; | |
815 ((uint8_t*)avctx->extradata)[1]= 0; | |
816 ((uint8_t*)avctx->extradata)[2]= 0; | |
817 ((uint8_t*)avctx->extradata)[3]= 0; | |
818 ((uint8_t*)avctx->extradata)[4]= c->imgtype; | |
819 ((uint8_t*)avctx->extradata)[5]= c->compression; | |
820 ((uint8_t*)avctx->extradata)[6]= c->flags; | |
2250
902caf560c43
Zlib encoder: fix image orientation (was flipped), 100l in deflate error
rtognimp
parents:
2248
diff
changeset
|
821 ((uint8_t*)avctx->extradata)[7]= CODEC_ZLIB; |
1743 | 822 c->avctx->extradata_size= 8; |
2967 | 823 |
1743 | 824 c->zstream.zalloc = Z_NULL; |
825 c->zstream.zfree = Z_NULL; | |
826 c->zstream.opaque = Z_NULL; | |
827 zret = deflateInit(&(c->zstream), c->compression); | |
828 if (zret != Z_OK) { | |
829 av_log(avctx, AV_LOG_ERROR, "Deflate init error: %d\n", zret); | |
830 return 1; | |
831 } | |
832 | |
833 /* Conservative upper bound taken from zlib v1.2.1 source */ | |
834 c->max_comp_size = c->decomp_size + ((c->decomp_size + 7) >> 3) + | |
835 ((c->decomp_size + 63) >> 6) + 11; | |
836 if ((c->comp_buf = av_malloc(c->max_comp_size)) == NULL) { | |
837 av_log(avctx, AV_LOG_ERROR, "Can't allocate compression buffer.\n"); | |
838 return 1; | |
839 } | |
840 | |
841 return 0; | |
842 #endif | |
843 } | |
3777 | 844 #endif /* CONFIG_ENCODERS */ |
1743 | 845 |
846 | |
847 | |
3777 | 848 #ifdef CONFIG_DECODERS |
1743 | 849 /* |
850 * | |
851 * Uninit lcl decoder | |
852 * | |
853 */ | |
854 static int decode_end(AVCodecContext *avctx) | |
855 { | |
2979 | 856 LclContext * const c = (LclContext *)avctx->priv_data; |
1743 | 857 |
2979 | 858 if (c->pic.data[0]) |
859 avctx->release_buffer(avctx, &c->pic); | |
1743 | 860 #ifdef CONFIG_ZLIB |
861 inflateEnd(&(c->zstream)); | |
862 #endif | |
863 | |
2979 | 864 return 0; |
1743 | 865 } |
3777 | 866 #endif |
1743 | 867 |
3777 | 868 #ifdef CONFIG_ENCODERS |
1743 | 869 /* |
870 * | |
871 * Uninit lcl encoder | |
872 * | |
873 */ | |
874 static int encode_end(AVCodecContext *avctx) | |
875 { | |
876 LclContext *c = avctx->priv_data; | |
877 | |
878 av_freep(&avctx->extradata); | |
2248
e4e1b4f31db6
segfault fix by (Kostya <cannonball at bw-team dot com>)
michael
parents:
1744
diff
changeset
|
879 av_freep(&c->comp_buf); |
1743 | 880 #ifdef CONFIG_ZLIB |
881 deflateEnd(&(c->zstream)); | |
882 #endif | |
2967 | 883 |
1743 | 884 return 0; |
885 } | |
3777 | 886 #endif |
1743 | 887 |
3777 | 888 #ifdef CONFIG_MSZH_DECODER |
1743 | 889 AVCodec mszh_decoder = { |
2979 | 890 "mszh", |
891 CODEC_TYPE_VIDEO, | |
892 CODEC_ID_MSZH, | |
893 sizeof(LclContext), | |
894 decode_init, | |
895 NULL, | |
896 decode_end, | |
897 decode_frame, | |
898 CODEC_CAP_DR1, | |
1743 | 899 }; |
3777 | 900 #endif |
1743 | 901 |
3777 | 902 #ifdef CONFIG_ZLIB_DECODER |
1743 | 903 AVCodec zlib_decoder = { |
2979 | 904 "zlib", |
905 CODEC_TYPE_VIDEO, | |
906 CODEC_ID_ZLIB, | |
907 sizeof(LclContext), | |
908 decode_init, | |
909 NULL, | |
910 decode_end, | |
911 decode_frame, | |
912 CODEC_CAP_DR1, | |
1743 | 913 }; |
3777 | 914 #endif |
1743 | 915 |
916 #ifdef CONFIG_ENCODERS | |
917 | |
918 AVCodec zlib_encoder = { | |
919 "zlib", | |
920 CODEC_TYPE_VIDEO, | |
921 CODEC_ID_ZLIB, | |
922 sizeof(LclContext), | |
923 encode_init, | |
924 encode_frame, | |
925 encode_end, | |
926 }; | |
927 | |
928 #endif //CONFIG_ENCODERS |