2 * LCL (LossLess Codec Library) Codec
3 * Copyright (c) 2002-2004 Roberto Togni
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
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.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * @file libavcodec/lcldec.c
24 * LCL (LossLess Codec Library) Video Codec
25 * Decoder for MSZH and ZLIB codecs
26 * Experimental encoder for ZLIB RGB24
31 * Ver2.23 By Kenji Oshima 2000.09.20
32 * avimszh.dll, avizlib.dll
34 * A description of the decoding algorithm can be found here:
35 * http://www.pcisys.net/~melanson/codecs
37 * Supports: BGR24 (RGB 24bpp)
55 typedef struct LclDecContext
{
64 // Decompressed data size
65 unsigned int decomp_size
;
66 // Decompression buffer
67 unsigned char* decomp_buf
;
79 static inline unsigned char fix (int pix14
)
83 tmp
= (pix14
+ 0x80000) >> 20;
93 static inline unsigned char get_b (unsigned char yq
, signed char bq
)
95 return fix((yq
<< 20) + bq
* 1858076);
100 static inline unsigned char get_g (unsigned char yq
, signed char bq
, signed char rq
)
102 return fix((yq
<< 20) - bq
* 360857 - rq
* 748830);
107 static inline unsigned char get_r (unsigned char yq
, signed char rq
)
109 return fix((yq
<< 20) + rq
* 1470103);
114 static unsigned int mszh_decomp(unsigned char * srcptr
, int srclen
, unsigned char * destptr
, unsigned int destsize
)
116 unsigned char *destptr_bak
= destptr
;
117 unsigned char *destptr_end
= destptr
+ destsize
;
118 unsigned char mask
= 0;
119 unsigned char maskbit
= 0;
120 unsigned int ofs
, cnt
;
122 while ((srclen
> 0) && (destptr
< destptr_end
)) {
129 if ((mask
& (1 << (--maskbit
))) == 0) {
130 if (destptr
+ 4 > destptr_end
)
132 *(int*)destptr
= *(int*)srcptr
;
140 cnt
= ((cnt
>> 3) & 0x1f) + 1;
144 if (destptr
+ cnt
> destptr_end
) {
145 cnt
= destptr_end
- destptr
;
147 for (; cnt
> 0; cnt
--) {
148 *(destptr
) = *(destptr
- ofs
);
154 return (destptr
- destptr_bak
);
164 static int decode_frame(AVCodecContext
*avctx
, void *data
, int *data_size
, AVPacket
*avpkt
)
166 const uint8_t *buf
= avpkt
->data
;
167 int buf_size
= avpkt
->size
;
168 LclDecContext
* const c
= avctx
->priv_data
;
169 unsigned char *encoded
= (unsigned char *)buf
;
170 unsigned int pixel_ptr
;
172 unsigned char *outptr
;
173 unsigned int width
= avctx
->width
; // Real image width
174 unsigned int height
= avctx
->height
; // Real image height
175 unsigned int mszh_dlen
;
176 unsigned char yq
, y1q
, uq
, vq
;
178 unsigned int mthread_inlen
, mthread_outlen
;
180 int zret
; // Zlib return code
182 unsigned int len
= buf_size
;
185 avctx
->release_buffer(avctx
, &c
->pic
);
187 c
->pic
.reference
= 0;
188 c
->pic
.buffer_hints
= FF_BUFFER_HINTS_VALID
;
189 if(avctx
->get_buffer(avctx
, &c
->pic
) < 0){
190 av_log(avctx
, AV_LOG_ERROR
, "get_buffer() failed\n");
194 outptr
= c
->pic
.data
[0]; // Output image pointer
196 /* Decompress frame */
197 switch (avctx
->codec_id
) {
199 switch (c
->compression
) {
201 if (c
->flags
& FLAG_MULTITHREAD
) {
202 mthread_inlen
= *((unsigned int*)encoded
);
203 mthread_outlen
= *((unsigned int*)(encoded
+4));
204 if (mthread_outlen
> c
->decomp_size
) // this should not happen
205 mthread_outlen
= c
->decomp_size
;
206 mszh_dlen
= mszh_decomp(encoded
+ 8, mthread_inlen
, c
->decomp_buf
, c
->decomp_size
);
207 if (mthread_outlen
!= mszh_dlen
) {
208 av_log(avctx
, AV_LOG_ERROR
, "Mthread1 decoded size differs (%d != %d)\n",
209 mthread_outlen
, mszh_dlen
);
212 mszh_dlen
= mszh_decomp(encoded
+ 8 + mthread_inlen
, len
- mthread_inlen
,
213 c
->decomp_buf
+ mthread_outlen
, c
->decomp_size
- mthread_outlen
);
214 if (mthread_outlen
!= mszh_dlen
) {
215 av_log(avctx
, AV_LOG_ERROR
, "Mthread2 decoded size differs (%d != %d)\n",
216 mthread_outlen
, mszh_dlen
);
219 encoded
= c
->decomp_buf
;
220 len
= c
->decomp_size
;
222 mszh_dlen
= mszh_decomp(encoded
, len
, c
->decomp_buf
, c
->decomp_size
);
223 if (c
->decomp_size
!= mszh_dlen
) {
224 av_log(avctx
, AV_LOG_ERROR
, "Decoded size differs (%d != %d)\n",
225 c
->decomp_size
, mszh_dlen
);
228 encoded
= c
->decomp_buf
;
232 case COMP_MSZH_NOCOMP
:
235 av_log(avctx
, AV_LOG_ERROR
, "BUG! Unknown MSZH compression in frame decoder.\n");
241 /* Using the original dll with normal compression (-1) and RGB format
242 * gives a file with ZLIB fourcc, but frame is really uncompressed.
243 * To be sure that's true check also frame size */
244 if ((c
->compression
== COMP_ZLIB_NORMAL
) && (c
->imgtype
== IMGTYPE_RGB24
) &&
245 (len
== width
* height
* 3))
247 zret
= inflateReset(&(c
->zstream
));
249 av_log(avctx
, AV_LOG_ERROR
, "Inflate reset error: %d\n", zret
);
252 if (c
->flags
& FLAG_MULTITHREAD
) {
253 mthread_inlen
= *((unsigned int*)encoded
);
254 mthread_outlen
= *((unsigned int*)(encoded
+4));
255 if (mthread_outlen
> c
->decomp_size
)
256 mthread_outlen
= c
->decomp_size
;
257 c
->zstream
.next_in
= encoded
+ 8;
258 c
->zstream
.avail_in
= mthread_inlen
;
259 c
->zstream
.next_out
= c
->decomp_buf
;
260 c
->zstream
.avail_out
= c
->decomp_size
;
261 zret
= inflate(&(c
->zstream
), Z_FINISH
);
262 if ((zret
!= Z_OK
) && (zret
!= Z_STREAM_END
)) {
263 av_log(avctx
, AV_LOG_ERROR
, "Mthread1 inflate error: %d\n", zret
);
266 if (mthread_outlen
!= (unsigned int)(c
->zstream
.total_out
)) {
267 av_log(avctx
, AV_LOG_ERROR
, "Mthread1 decoded size differs (%u != %lu)\n",
268 mthread_outlen
, c
->zstream
.total_out
);
271 zret
= inflateReset(&(c
->zstream
));
273 av_log(avctx
, AV_LOG_ERROR
, "Mthread2 inflate reset error: %d\n", zret
);
276 c
->zstream
.next_in
= encoded
+ 8 + mthread_inlen
;
277 c
->zstream
.avail_in
= len
- mthread_inlen
;
278 c
->zstream
.next_out
= c
->decomp_buf
+ mthread_outlen
;
279 c
->zstream
.avail_out
= c
->decomp_size
- mthread_outlen
;
280 zret
= inflate(&(c
->zstream
), Z_FINISH
);
281 if ((zret
!= Z_OK
) && (zret
!= Z_STREAM_END
)) {
282 av_log(avctx
, AV_LOG_ERROR
, "Mthread2 inflate error: %d\n", zret
);
285 if (mthread_outlen
!= (unsigned int)(c
->zstream
.total_out
)) {
286 av_log(avctx
, AV_LOG_ERROR
, "Mthread2 decoded size differs (%d != %lu)\n",
287 mthread_outlen
, c
->zstream
.total_out
);
291 c
->zstream
.next_in
= encoded
;
292 c
->zstream
.avail_in
= len
;
293 c
->zstream
.next_out
= c
->decomp_buf
;
294 c
->zstream
.avail_out
= c
->decomp_size
;
295 zret
= inflate(&(c
->zstream
), Z_FINISH
);
296 if ((zret
!= Z_OK
) && (zret
!= Z_STREAM_END
)) {
297 av_log(avctx
, AV_LOG_ERROR
, "Inflate error: %d\n", zret
);
300 if (c
->decomp_size
!= (unsigned int)(c
->zstream
.total_out
)) {
301 av_log(avctx
, AV_LOG_ERROR
, "Decoded size differs (%d != %lu)\n",
302 c
->decomp_size
, c
->zstream
.total_out
);
306 encoded
= c
->decomp_buf
;
307 len
= c
->decomp_size
;
309 av_log(avctx
, AV_LOG_ERROR
, "BUG! Zlib support not compiled in frame decoder.\n");
314 av_log(avctx
, AV_LOG_ERROR
, "BUG! Unknown codec in frame decoder compression switch.\n");
319 /* Apply PNG filter */
320 if ((avctx
->codec_id
== CODEC_ID_ZLIB
) && (c
->flags
& FLAG_PNGFILTER
)) {
321 switch (c
->imgtype
) {
324 for (row
= 0; row
< height
; row
++) {
325 pixel_ptr
= row
* width
* 3;
326 yq
= encoded
[pixel_ptr
++];
327 uqvq
= AV_RL16(encoded
+pixel_ptr
);
329 for (col
= 1; col
< width
; col
++) {
330 encoded
[pixel_ptr
] = yq
-= encoded
[pixel_ptr
];
331 uqvq
-= AV_RL16(encoded
+pixel_ptr
+1);
332 AV_WL16(encoded
+pixel_ptr
+1, uqvq
);
338 for (row
= 0; row
< height
; row
++) {
339 pixel_ptr
= row
* width
* 2;
341 for (col
= 0; col
< width
/4; col
++) {
342 encoded
[pixel_ptr
] = yq
-= encoded
[pixel_ptr
];
343 encoded
[pixel_ptr
+1] = yq
-= encoded
[pixel_ptr
+1];
344 encoded
[pixel_ptr
+2] = yq
-= encoded
[pixel_ptr
+2];
345 encoded
[pixel_ptr
+3] = yq
-= encoded
[pixel_ptr
+3];
346 encoded
[pixel_ptr
+4] = uq
-= encoded
[pixel_ptr
+4];
347 encoded
[pixel_ptr
+5] = uq
-= encoded
[pixel_ptr
+5];
348 encoded
[pixel_ptr
+6] = vq
-= encoded
[pixel_ptr
+6];
349 encoded
[pixel_ptr
+7] = vq
-= encoded
[pixel_ptr
+7];
355 for (row
= 0; row
< height
; row
++) {
356 pixel_ptr
= row
* width
/ 2 * 3;
358 for (col
= 0; col
< width
/4; col
++) {
359 encoded
[pixel_ptr
] = yq
-= encoded
[pixel_ptr
];
360 encoded
[pixel_ptr
+1] = yq
-= encoded
[pixel_ptr
+1];
361 encoded
[pixel_ptr
+2] = yq
-= encoded
[pixel_ptr
+2];
362 encoded
[pixel_ptr
+3] = yq
-= encoded
[pixel_ptr
+3];
363 encoded
[pixel_ptr
+4] = uq
-= encoded
[pixel_ptr
+4];
364 encoded
[pixel_ptr
+5] = vq
-= encoded
[pixel_ptr
+5];
370 for (row
= 0; row
< height
; row
++) {
371 pixel_ptr
= row
* width
* 2;
373 for (col
= 0; col
< width
/2; col
++) {
374 encoded
[pixel_ptr
] = yq
-= encoded
[pixel_ptr
];
375 encoded
[pixel_ptr
+1] = yq
-= encoded
[pixel_ptr
+1];
376 encoded
[pixel_ptr
+2] = uq
-= encoded
[pixel_ptr
+2];
377 encoded
[pixel_ptr
+3] = vq
-= encoded
[pixel_ptr
+3];
383 for (row
= 0; row
< height
/2; row
++) {
384 pixel_ptr
= row
* width
* 3;
385 yq
= y1q
= uq
= vq
=0;
386 for (col
= 0; col
< width
/2; col
++) {
387 encoded
[pixel_ptr
] = yq
-= encoded
[pixel_ptr
];
388 encoded
[pixel_ptr
+1] = yq
-= encoded
[pixel_ptr
+1];
389 encoded
[pixel_ptr
+2] = y1q
-= encoded
[pixel_ptr
+2];
390 encoded
[pixel_ptr
+3] = y1q
-= encoded
[pixel_ptr
+3];
391 encoded
[pixel_ptr
+4] = uq
-= encoded
[pixel_ptr
+4];
392 encoded
[pixel_ptr
+5] = vq
-= encoded
[pixel_ptr
+5];
398 av_log(avctx
, AV_LOG_ERROR
, "BUG! Unknown imagetype in pngfilter switch.\n");
403 /* Convert colorspace */
404 switch (c
->imgtype
) {
406 for (row
= height
- 1; row
>= 0; row
--) {
407 pixel_ptr
= row
* c
->pic
.linesize
[0];
408 for (col
= 0; col
< width
; col
++) {
409 outptr
[pixel_ptr
++] = get_b(encoded
[0], encoded
[1]);
410 outptr
[pixel_ptr
++] = get_g(encoded
[0], encoded
[1], encoded
[2]);
411 outptr
[pixel_ptr
++] = get_r(encoded
[0], encoded
[2]);
417 for (row
= height
- 1; row
>= 0; row
--) {
418 pixel_ptr
= row
* c
->pic
.linesize
[0];
419 for (col
= 0; col
< width
/4; col
++) {
420 outptr
[pixel_ptr
++] = get_b(encoded
[0], encoded
[4]);
421 outptr
[pixel_ptr
++] = get_g(encoded
[0], encoded
[4], encoded
[6]);
422 outptr
[pixel_ptr
++] = get_r(encoded
[0], encoded
[6]);
423 outptr
[pixel_ptr
++] = get_b(encoded
[1], encoded
[4]);
424 outptr
[pixel_ptr
++] = get_g(encoded
[1], encoded
[4], encoded
[6]);
425 outptr
[pixel_ptr
++] = get_r(encoded
[1], encoded
[6]);
426 outptr
[pixel_ptr
++] = get_b(encoded
[2], encoded
[5]);
427 outptr
[pixel_ptr
++] = get_g(encoded
[2], encoded
[5], encoded
[7]);
428 outptr
[pixel_ptr
++] = get_r(encoded
[2], encoded
[7]);
429 outptr
[pixel_ptr
++] = get_b(encoded
[3], encoded
[5]);
430 outptr
[pixel_ptr
++] = get_g(encoded
[3], encoded
[5], encoded
[7]);
431 outptr
[pixel_ptr
++] = get_r(encoded
[3], encoded
[7]);
437 for (row
= height
- 1; row
>= 0; row
--) {
438 pixel_ptr
= row
* c
->pic
.linesize
[0];
439 for (col
= 0; col
< width
; col
++) {
440 outptr
[pixel_ptr
++] = encoded
[0];
441 outptr
[pixel_ptr
++] = encoded
[1];
442 outptr
[pixel_ptr
++] = encoded
[2];
448 for (row
= height
- 1; row
>= 0; row
--) {
449 pixel_ptr
= row
* c
->pic
.linesize
[0];
450 for (col
= 0; col
< width
/4; col
++) {
451 outptr
[pixel_ptr
++] = get_b(encoded
[0], encoded
[4]);
452 outptr
[pixel_ptr
++] = get_g(encoded
[0], encoded
[4], encoded
[5]);
453 outptr
[pixel_ptr
++] = get_r(encoded
[0], encoded
[5]);
454 outptr
[pixel_ptr
++] = get_b(encoded
[1], encoded
[4]);
455 outptr
[pixel_ptr
++] = get_g(encoded
[1], encoded
[4], encoded
[5]);
456 outptr
[pixel_ptr
++] = get_r(encoded
[1], encoded
[5]);
457 outptr
[pixel_ptr
++] = get_b(encoded
[2], encoded
[4]);
458 outptr
[pixel_ptr
++] = get_g(encoded
[2], encoded
[4], encoded
[5]);
459 outptr
[pixel_ptr
++] = get_r(encoded
[2], encoded
[5]);
460 outptr
[pixel_ptr
++] = get_b(encoded
[3], encoded
[4]);
461 outptr
[pixel_ptr
++] = get_g(encoded
[3], encoded
[4], encoded
[5]);
462 outptr
[pixel_ptr
++] = get_r(encoded
[3], encoded
[5]);
468 for (row
= height
- 1; row
>= 0; row
--) {
469 pixel_ptr
= row
* c
->pic
.linesize
[0];
470 for (col
= 0; col
< width
/2; col
++) {
471 outptr
[pixel_ptr
++] = get_b(encoded
[0], encoded
[2]);
472 outptr
[pixel_ptr
++] = get_g(encoded
[0], encoded
[2], encoded
[3]);
473 outptr
[pixel_ptr
++] = get_r(encoded
[0], encoded
[3]);
474 outptr
[pixel_ptr
++] = get_b(encoded
[1], encoded
[2]);
475 outptr
[pixel_ptr
++] = get_g(encoded
[1], encoded
[2], encoded
[3]);
476 outptr
[pixel_ptr
++] = get_r(encoded
[1], encoded
[3]);
482 for (row
= height
/ 2 - 1; row
>= 0; row
--) {
483 pixel_ptr
= 2 * row
* c
->pic
.linesize
[0];
484 for (col
= 0; col
< width
/2; col
++) {
485 outptr
[pixel_ptr
] = get_b(encoded
[0], encoded
[4]);
486 outptr
[pixel_ptr
+1] = get_g(encoded
[0], encoded
[4], encoded
[5]);
487 outptr
[pixel_ptr
+2] = get_r(encoded
[0], encoded
[5]);
488 outptr
[pixel_ptr
+3] = get_b(encoded
[1], encoded
[4]);
489 outptr
[pixel_ptr
+4] = get_g(encoded
[1], encoded
[4], encoded
[5]);
490 outptr
[pixel_ptr
+5] = get_r(encoded
[1], encoded
[5]);
491 outptr
[pixel_ptr
-c
->pic
.linesize
[0]] = get_b(encoded
[2], encoded
[4]);
492 outptr
[pixel_ptr
-c
->pic
.linesize
[0]+1] = get_g(encoded
[2], encoded
[4], encoded
[5]);
493 outptr
[pixel_ptr
-c
->pic
.linesize
[0]+2] = get_r(encoded
[2], encoded
[5]);
494 outptr
[pixel_ptr
-c
->pic
.linesize
[0]+3] = get_b(encoded
[3], encoded
[4]);
495 outptr
[pixel_ptr
-c
->pic
.linesize
[0]+4] = get_g(encoded
[3], encoded
[4], encoded
[5]);
496 outptr
[pixel_ptr
-c
->pic
.linesize
[0]+5] = get_r(encoded
[3], encoded
[5]);
503 av_log(avctx
, AV_LOG_ERROR
, "BUG! Unknown imagetype in image decoder.\n");
507 *data_size
= sizeof(AVFrame
);
508 *(AVFrame
*)data
= c
->pic
;
510 /* always report that the buffer was completely consumed */
519 static av_cold
int decode_init(AVCodecContext
*avctx
)
521 LclDecContext
* const c
= avctx
->priv_data
;
522 unsigned int basesize
= avctx
->width
* avctx
->height
;
523 unsigned int max_basesize
= ((avctx
->width
+ 3) & ~3) * ((avctx
->height
+ 3) & ~3);
524 unsigned int max_decomp_size
;
525 int zret
; // Zlib return code
527 c
->pic
.data
[0] = NULL
;
530 // Needed if zlib unused or init aborted before inflateInit
531 memset(&(c
->zstream
), 0, sizeof(z_stream
));
534 if (avctx
->extradata_size
< 8) {
535 av_log(avctx
, AV_LOG_ERROR
, "Extradata size too small.\n");
539 if (avcodec_check_dimensions(avctx
, avctx
->width
, avctx
->height
) < 0) {
543 /* Check codec type */
544 if (((avctx
->codec_id
== CODEC_ID_MSZH
) && (*((char *)avctx
->extradata
+ 7) != CODEC_MSZH
)) ||
545 ((avctx
->codec_id
== CODEC_ID_ZLIB
) && (*((char *)avctx
->extradata
+ 7) != CODEC_ZLIB
))) {
546 av_log(avctx
, AV_LOG_ERROR
, "Codec id and codec type mismatch. This should not happen.\n");
549 /* Detect image type */
550 switch (c
->imgtype
= *((char *)avctx
->extradata
+ 4)) {
552 c
->decomp_size
= basesize
* 3;
553 max_decomp_size
= max_basesize
* 3;
554 av_log(avctx
, AV_LOG_INFO
, "Image type is YUV 1:1:1.\n");
557 c
->decomp_size
= basesize
* 2;
558 max_decomp_size
= max_basesize
* 2;
559 av_log(avctx
, AV_LOG_INFO
, "Image type is YUV 4:2:2.\n");
562 c
->decomp_size
= basesize
* 3;
563 max_decomp_size
= max_basesize
* 3;
564 av_log(avctx
, AV_LOG_INFO
, "Image type is RGB 24.\n");
567 c
->decomp_size
= basesize
/ 2 * 3;
568 max_decomp_size
= max_basesize
/ 2 * 3;
569 av_log(avctx
, AV_LOG_INFO
, "Image type is YUV 4:1:1.\n");
572 c
->decomp_size
= basesize
* 2;
573 max_decomp_size
= max_basesize
* 2;
574 av_log(avctx
, AV_LOG_INFO
, "Image type is YUV 2:1:1.\n");
577 c
->decomp_size
= basesize
/ 2 * 3;
578 max_decomp_size
= max_basesize
/ 2 * 3;
579 av_log(avctx
, AV_LOG_INFO
, "Image type is YUV 4:2:0.\n");
582 av_log(avctx
, AV_LOG_ERROR
, "Unsupported image format %d.\n", c
->imgtype
);
586 /* Detect compression method */
587 c
->compression
= *((char *)avctx
->extradata
+ 5);
588 switch (avctx
->codec_id
) {
590 switch (c
->compression
) {
592 av_log(avctx
, AV_LOG_INFO
, "Compression enabled.\n");
594 case COMP_MSZH_NOCOMP
:
596 av_log(avctx
, AV_LOG_INFO
, "No compression.\n");
599 av_log(avctx
, AV_LOG_ERROR
, "Unsupported compression format for MSZH (%d).\n", c
->compression
);
605 switch (c
->compression
) {
606 case COMP_ZLIB_HISPEED
:
607 av_log(avctx
, AV_LOG_INFO
, "High speed compression.\n");
609 case COMP_ZLIB_HICOMP
:
610 av_log(avctx
, AV_LOG_INFO
, "High compression.\n");
612 case COMP_ZLIB_NORMAL
:
613 av_log(avctx
, AV_LOG_INFO
, "Normal compression.\n");
616 if ((c
->compression
< Z_NO_COMPRESSION
) || (c
->compression
> Z_BEST_COMPRESSION
)) {
617 av_log(avctx
, AV_LOG_ERROR
, "Unsupported compression level for ZLIB: (%d).\n", c
->compression
);
620 av_log(avctx
, AV_LOG_INFO
, "Compression level for ZLIB: (%d).\n", c
->compression
);
623 av_log(avctx
, AV_LOG_ERROR
, "Zlib support not compiled.\n");
628 av_log(avctx
, AV_LOG_ERROR
, "BUG! Unknown codec in compression switch.\n");
632 /* Allocate decompression buffer */
633 if (c
->decomp_size
) {
634 if ((c
->decomp_buf
= av_malloc(max_decomp_size
)) == NULL
) {
635 av_log(avctx
, AV_LOG_ERROR
, "Can't allocate decompression buffer.\n");
641 c
->flags
= *((char *)avctx
->extradata
+ 6);
642 if (c
->flags
& FLAG_MULTITHREAD
)
643 av_log(avctx
, AV_LOG_INFO
, "Multithread encoder flag set.\n");
644 if (c
->flags
& FLAG_NULLFRAME
)
645 av_log(avctx
, AV_LOG_INFO
, "Nullframe insertion flag set.\n");
646 if ((avctx
->codec_id
== CODEC_ID_ZLIB
) && (c
->flags
& FLAG_PNGFILTER
))
647 av_log(avctx
, AV_LOG_INFO
, "PNG filter flag set.\n");
648 if (c
->flags
& FLAGMASK_UNUSED
)
649 av_log(avctx
, AV_LOG_ERROR
, "Unknown flag set (%d).\n", c
->flags
);
651 /* If needed init zlib */
652 if (avctx
->codec_id
== CODEC_ID_ZLIB
) {
654 c
->zstream
.zalloc
= Z_NULL
;
655 c
->zstream
.zfree
= Z_NULL
;
656 c
->zstream
.opaque
= Z_NULL
;
657 zret
= inflateInit(&(c
->zstream
));
659 av_log(avctx
, AV_LOG_ERROR
, "Inflate init error: %d\n", zret
);
663 av_log(avctx
, AV_LOG_ERROR
, "Zlib support not compiled.\n");
668 avctx
->pix_fmt
= PIX_FMT_BGR24
;
678 static av_cold
int decode_end(AVCodecContext
*avctx
)
680 LclDecContext
* const c
= avctx
->priv_data
;
683 avctx
->release_buffer(avctx
, &c
->pic
);
685 inflateEnd(&(c
->zstream
));
691 #if CONFIG_MSZH_DECODER
692 AVCodec mszh_decoder
= {
696 sizeof(LclDecContext
),
702 .long_name
= NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) MSZH"),
706 #if CONFIG_ZLIB_DECODER
707 AVCodec zlib_decoder
= {
711 sizeof(LclDecContext
),
717 .long_name
= NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) ZLIB"),