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
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)
45 #include "bitstream.h"
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
, const uint8_t *buf
, int buf_size
)
166 LclDecContext
* const c
= avctx
->priv_data
;
167 unsigned char *encoded
= (unsigned char *)buf
;
168 unsigned int pixel_ptr
;
170 unsigned char *outptr
;
171 unsigned int width
= avctx
->width
; // Real image width
172 unsigned int height
= avctx
->height
; // Real image height
173 unsigned int mszh_dlen
;
174 unsigned char yq
, y1q
, uq
, vq
;
176 unsigned int mthread_inlen
, mthread_outlen
;
178 int zret
; // Zlib return code
180 unsigned int len
= buf_size
;
183 avctx
->release_buffer(avctx
, &c
->pic
);
185 c
->pic
.reference
= 0;
186 c
->pic
.buffer_hints
= FF_BUFFER_HINTS_VALID
;
187 if(avctx
->get_buffer(avctx
, &c
->pic
) < 0){
188 av_log(avctx
, AV_LOG_ERROR
, "get_buffer() failed\n");
192 outptr
= c
->pic
.data
[0]; // Output image pointer
194 /* Decompress frame */
195 switch (avctx
->codec_id
) {
197 switch (c
->compression
) {
199 if (c
->flags
& FLAG_MULTITHREAD
) {
200 mthread_inlen
= *((unsigned int*)encoded
);
201 mthread_outlen
= *((unsigned int*)(encoded
+4));
202 if (mthread_outlen
> c
->decomp_size
) // this should not happen
203 mthread_outlen
= c
->decomp_size
;
204 mszh_dlen
= mszh_decomp(encoded
+ 8, mthread_inlen
, c
->decomp_buf
, c
->decomp_size
);
205 if (mthread_outlen
!= mszh_dlen
) {
206 av_log(avctx
, AV_LOG_ERROR
, "Mthread1 decoded size differs (%d != %d)\n",
207 mthread_outlen
, mszh_dlen
);
210 mszh_dlen
= mszh_decomp(encoded
+ 8 + mthread_inlen
, len
- mthread_inlen
,
211 c
->decomp_buf
+ mthread_outlen
, c
->decomp_size
- mthread_outlen
);
212 if (mthread_outlen
!= mszh_dlen
) {
213 av_log(avctx
, AV_LOG_ERROR
, "Mthread2 decoded size differs (%d != %d)\n",
214 mthread_outlen
, mszh_dlen
);
217 encoded
= c
->decomp_buf
;
218 len
= c
->decomp_size
;
220 mszh_dlen
= mszh_decomp(encoded
, len
, c
->decomp_buf
, c
->decomp_size
);
221 if (c
->decomp_size
!= mszh_dlen
) {
222 av_log(avctx
, AV_LOG_ERROR
, "Decoded size differs (%d != %d)\n",
223 c
->decomp_size
, mszh_dlen
);
226 encoded
= c
->decomp_buf
;
230 case COMP_MSZH_NOCOMP
:
233 av_log(avctx
, AV_LOG_ERROR
, "BUG! Unknown MSZH compression in frame decoder.\n");
239 /* Using the original dll with normal compression (-1) and RGB format
240 * gives a file with ZLIB fourcc, but frame is really uncompressed.
241 * To be sure that's true check also frame size */
242 if ((c
->compression
== COMP_ZLIB_NORMAL
) && (c
->imgtype
== IMGTYPE_RGB24
) &&
243 (len
== width
* height
* 3))
245 zret
= inflateReset(&(c
->zstream
));
247 av_log(avctx
, AV_LOG_ERROR
, "Inflate reset error: %d\n", zret
);
250 if (c
->flags
& FLAG_MULTITHREAD
) {
251 mthread_inlen
= *((unsigned int*)encoded
);
252 mthread_outlen
= *((unsigned int*)(encoded
+4));
253 if (mthread_outlen
> c
->decomp_size
)
254 mthread_outlen
= c
->decomp_size
;
255 c
->zstream
.next_in
= encoded
+ 8;
256 c
->zstream
.avail_in
= mthread_inlen
;
257 c
->zstream
.next_out
= c
->decomp_buf
;
258 c
->zstream
.avail_out
= c
->decomp_size
;
259 zret
= inflate(&(c
->zstream
), Z_FINISH
);
260 if ((zret
!= Z_OK
) && (zret
!= Z_STREAM_END
)) {
261 av_log(avctx
, AV_LOG_ERROR
, "Mthread1 inflate error: %d\n", zret
);
264 if (mthread_outlen
!= (unsigned int)(c
->zstream
.total_out
)) {
265 av_log(avctx
, AV_LOG_ERROR
, "Mthread1 decoded size differs (%u != %lu)\n",
266 mthread_outlen
, c
->zstream
.total_out
);
269 zret
= inflateReset(&(c
->zstream
));
271 av_log(avctx
, AV_LOG_ERROR
, "Mthread2 inflate reset error: %d\n", zret
);
274 c
->zstream
.next_in
= encoded
+ 8 + mthread_inlen
;
275 c
->zstream
.avail_in
= len
- mthread_inlen
;
276 c
->zstream
.next_out
= c
->decomp_buf
+ mthread_outlen
;
277 c
->zstream
.avail_out
= c
->decomp_size
- mthread_outlen
;
278 zret
= inflate(&(c
->zstream
), Z_FINISH
);
279 if ((zret
!= Z_OK
) && (zret
!= Z_STREAM_END
)) {
280 av_log(avctx
, AV_LOG_ERROR
, "Mthread2 inflate error: %d\n", zret
);
283 if (mthread_outlen
!= (unsigned int)(c
->zstream
.total_out
)) {
284 av_log(avctx
, AV_LOG_ERROR
, "Mthread2 decoded size differs (%d != %lu)\n",
285 mthread_outlen
, c
->zstream
.total_out
);
289 c
->zstream
.next_in
= encoded
;
290 c
->zstream
.avail_in
= len
;
291 c
->zstream
.next_out
= c
->decomp_buf
;
292 c
->zstream
.avail_out
= c
->decomp_size
;
293 zret
= inflate(&(c
->zstream
), Z_FINISH
);
294 if ((zret
!= Z_OK
) && (zret
!= Z_STREAM_END
)) {
295 av_log(avctx
, AV_LOG_ERROR
, "Inflate error: %d\n", zret
);
298 if (c
->decomp_size
!= (unsigned int)(c
->zstream
.total_out
)) {
299 av_log(avctx
, AV_LOG_ERROR
, "Decoded size differs (%d != %lu)\n",
300 c
->decomp_size
, c
->zstream
.total_out
);
304 encoded
= c
->decomp_buf
;
305 len
= c
->decomp_size
;
307 av_log(avctx
, AV_LOG_ERROR
, "BUG! Zlib support not compiled in frame decoder.\n");
312 av_log(avctx
, AV_LOG_ERROR
, "BUG! Unknown codec in frame decoder compression switch.\n");
317 /* Apply PNG filter */
318 if ((avctx
->codec_id
== CODEC_ID_ZLIB
) && (c
->flags
& FLAG_PNGFILTER
)) {
319 switch (c
->imgtype
) {
322 for (row
= 0; row
< height
; row
++) {
323 pixel_ptr
= row
* width
* 3;
324 yq
= encoded
[pixel_ptr
++];
325 uqvq
= AV_RL16(encoded
+pixel_ptr
);
327 for (col
= 1; col
< width
; col
++) {
328 encoded
[pixel_ptr
] = yq
-= encoded
[pixel_ptr
];
329 uqvq
-= AV_RL16(encoded
+pixel_ptr
+1);
330 AV_WL16(encoded
+pixel_ptr
+1, uqvq
);
336 for (row
= 0; row
< height
; row
++) {
337 pixel_ptr
= row
* width
* 2;
339 for (col
= 0; col
< width
/4; col
++) {
340 encoded
[pixel_ptr
] = yq
-= encoded
[pixel_ptr
];
341 encoded
[pixel_ptr
+1] = yq
-= encoded
[pixel_ptr
+1];
342 encoded
[pixel_ptr
+2] = yq
-= encoded
[pixel_ptr
+2];
343 encoded
[pixel_ptr
+3] = yq
-= encoded
[pixel_ptr
+3];
344 encoded
[pixel_ptr
+4] = uq
-= encoded
[pixel_ptr
+4];
345 encoded
[pixel_ptr
+5] = uq
-= encoded
[pixel_ptr
+5];
346 encoded
[pixel_ptr
+6] = vq
-= encoded
[pixel_ptr
+6];
347 encoded
[pixel_ptr
+7] = vq
-= encoded
[pixel_ptr
+7];
353 for (row
= 0; row
< height
; row
++) {
354 pixel_ptr
= row
* width
/ 2 * 3;
356 for (col
= 0; col
< width
/4; col
++) {
357 encoded
[pixel_ptr
] = yq
-= encoded
[pixel_ptr
];
358 encoded
[pixel_ptr
+1] = yq
-= encoded
[pixel_ptr
+1];
359 encoded
[pixel_ptr
+2] = yq
-= encoded
[pixel_ptr
+2];
360 encoded
[pixel_ptr
+3] = yq
-= encoded
[pixel_ptr
+3];
361 encoded
[pixel_ptr
+4] = uq
-= encoded
[pixel_ptr
+4];
362 encoded
[pixel_ptr
+5] = vq
-= encoded
[pixel_ptr
+5];
368 for (row
= 0; row
< height
; row
++) {
369 pixel_ptr
= row
* width
* 2;
371 for (col
= 0; col
< width
/2; col
++) {
372 encoded
[pixel_ptr
] = yq
-= encoded
[pixel_ptr
];
373 encoded
[pixel_ptr
+1] = yq
-= encoded
[pixel_ptr
+1];
374 encoded
[pixel_ptr
+2] = uq
-= encoded
[pixel_ptr
+2];
375 encoded
[pixel_ptr
+3] = vq
-= encoded
[pixel_ptr
+3];
381 for (row
= 0; row
< height
/2; row
++) {
382 pixel_ptr
= row
* width
* 3;
383 yq
= y1q
= uq
= vq
=0;
384 for (col
= 0; col
< width
/2; col
++) {
385 encoded
[pixel_ptr
] = yq
-= encoded
[pixel_ptr
];
386 encoded
[pixel_ptr
+1] = yq
-= encoded
[pixel_ptr
+1];
387 encoded
[pixel_ptr
+2] = y1q
-= encoded
[pixel_ptr
+2];
388 encoded
[pixel_ptr
+3] = y1q
-= encoded
[pixel_ptr
+3];
389 encoded
[pixel_ptr
+4] = uq
-= encoded
[pixel_ptr
+4];
390 encoded
[pixel_ptr
+5] = vq
-= encoded
[pixel_ptr
+5];
396 av_log(avctx
, AV_LOG_ERROR
, "BUG! Unknown imagetype in pngfilter switch.\n");
401 /* Convert colorspace */
402 switch (c
->imgtype
) {
404 for (row
= height
- 1; row
>= 0; row
--) {
405 pixel_ptr
= row
* c
->pic
.linesize
[0];
406 for (col
= 0; col
< width
; col
++) {
407 outptr
[pixel_ptr
++] = get_b(encoded
[0], encoded
[1]);
408 outptr
[pixel_ptr
++] = get_g(encoded
[0], encoded
[1], encoded
[2]);
409 outptr
[pixel_ptr
++] = get_r(encoded
[0], encoded
[2]);
415 for (row
= height
- 1; row
>= 0; row
--) {
416 pixel_ptr
= row
* c
->pic
.linesize
[0];
417 for (col
= 0; col
< width
/4; col
++) {
418 outptr
[pixel_ptr
++] = get_b(encoded
[0], encoded
[4]);
419 outptr
[pixel_ptr
++] = get_g(encoded
[0], encoded
[4], encoded
[6]);
420 outptr
[pixel_ptr
++] = get_r(encoded
[0], encoded
[6]);
421 outptr
[pixel_ptr
++] = get_b(encoded
[1], encoded
[4]);
422 outptr
[pixel_ptr
++] = get_g(encoded
[1], encoded
[4], encoded
[6]);
423 outptr
[pixel_ptr
++] = get_r(encoded
[1], encoded
[6]);
424 outptr
[pixel_ptr
++] = get_b(encoded
[2], encoded
[5]);
425 outptr
[pixel_ptr
++] = get_g(encoded
[2], encoded
[5], encoded
[7]);
426 outptr
[pixel_ptr
++] = get_r(encoded
[2], encoded
[7]);
427 outptr
[pixel_ptr
++] = get_b(encoded
[3], encoded
[5]);
428 outptr
[pixel_ptr
++] = get_g(encoded
[3], encoded
[5], encoded
[7]);
429 outptr
[pixel_ptr
++] = get_r(encoded
[3], encoded
[7]);
435 for (row
= height
- 1; row
>= 0; row
--) {
436 pixel_ptr
= row
* c
->pic
.linesize
[0];
437 for (col
= 0; col
< width
; col
++) {
438 outptr
[pixel_ptr
++] = encoded
[0];
439 outptr
[pixel_ptr
++] = encoded
[1];
440 outptr
[pixel_ptr
++] = encoded
[2];
446 for (row
= height
- 1; row
>= 0; row
--) {
447 pixel_ptr
= row
* c
->pic
.linesize
[0];
448 for (col
= 0; col
< width
/4; col
++) {
449 outptr
[pixel_ptr
++] = get_b(encoded
[0], encoded
[4]);
450 outptr
[pixel_ptr
++] = get_g(encoded
[0], encoded
[4], encoded
[5]);
451 outptr
[pixel_ptr
++] = get_r(encoded
[0], encoded
[5]);
452 outptr
[pixel_ptr
++] = get_b(encoded
[1], encoded
[4]);
453 outptr
[pixel_ptr
++] = get_g(encoded
[1], encoded
[4], encoded
[5]);
454 outptr
[pixel_ptr
++] = get_r(encoded
[1], encoded
[5]);
455 outptr
[pixel_ptr
++] = get_b(encoded
[2], encoded
[4]);
456 outptr
[pixel_ptr
++] = get_g(encoded
[2], encoded
[4], encoded
[5]);
457 outptr
[pixel_ptr
++] = get_r(encoded
[2], encoded
[5]);
458 outptr
[pixel_ptr
++] = get_b(encoded
[3], encoded
[4]);
459 outptr
[pixel_ptr
++] = get_g(encoded
[3], encoded
[4], encoded
[5]);
460 outptr
[pixel_ptr
++] = get_r(encoded
[3], encoded
[5]);
466 for (row
= height
- 1; row
>= 0; row
--) {
467 pixel_ptr
= row
* c
->pic
.linesize
[0];
468 for (col
= 0; col
< width
/2; col
++) {
469 outptr
[pixel_ptr
++] = get_b(encoded
[0], encoded
[2]);
470 outptr
[pixel_ptr
++] = get_g(encoded
[0], encoded
[2], encoded
[3]);
471 outptr
[pixel_ptr
++] = get_r(encoded
[0], encoded
[3]);
472 outptr
[pixel_ptr
++] = get_b(encoded
[1], encoded
[2]);
473 outptr
[pixel_ptr
++] = get_g(encoded
[1], encoded
[2], encoded
[3]);
474 outptr
[pixel_ptr
++] = get_r(encoded
[1], encoded
[3]);
480 for (row
= height
/ 2 - 1; row
>= 0; row
--) {
481 pixel_ptr
= 2 * row
* c
->pic
.linesize
[0];
482 for (col
= 0; col
< width
/2; col
++) {
483 outptr
[pixel_ptr
] = get_b(encoded
[0], encoded
[4]);
484 outptr
[pixel_ptr
+1] = get_g(encoded
[0], encoded
[4], encoded
[5]);
485 outptr
[pixel_ptr
+2] = get_r(encoded
[0], encoded
[5]);
486 outptr
[pixel_ptr
+3] = get_b(encoded
[1], encoded
[4]);
487 outptr
[pixel_ptr
+4] = get_g(encoded
[1], encoded
[4], encoded
[5]);
488 outptr
[pixel_ptr
+5] = get_r(encoded
[1], encoded
[5]);
489 outptr
[pixel_ptr
-c
->pic
.linesize
[0]] = get_b(encoded
[2], encoded
[4]);
490 outptr
[pixel_ptr
-c
->pic
.linesize
[0]+1] = get_g(encoded
[2], encoded
[4], encoded
[5]);
491 outptr
[pixel_ptr
-c
->pic
.linesize
[0]+2] = get_r(encoded
[2], encoded
[5]);
492 outptr
[pixel_ptr
-c
->pic
.linesize
[0]+3] = get_b(encoded
[3], encoded
[4]);
493 outptr
[pixel_ptr
-c
->pic
.linesize
[0]+4] = get_g(encoded
[3], encoded
[4], encoded
[5]);
494 outptr
[pixel_ptr
-c
->pic
.linesize
[0]+5] = get_r(encoded
[3], encoded
[5]);
501 av_log(avctx
, AV_LOG_ERROR
, "BUG! Unknown imagetype in image decoder.\n");
505 *data_size
= sizeof(AVFrame
);
506 *(AVFrame
*)data
= c
->pic
;
508 /* always report that the buffer was completely consumed */
517 static av_cold
int decode_init(AVCodecContext
*avctx
)
519 LclDecContext
* const c
= avctx
->priv_data
;
520 unsigned int basesize
= avctx
->width
* avctx
->height
;
521 unsigned int max_basesize
= ((avctx
->width
+ 3) & ~3) * ((avctx
->height
+ 3) & ~3);
522 unsigned int max_decomp_size
;
523 int zret
; // Zlib return code
525 c
->pic
.data
[0] = NULL
;
528 // Needed if zlib unused or init aborted before inflateInit
529 memset(&(c
->zstream
), 0, sizeof(z_stream
));
532 if (avctx
->extradata_size
< 8) {
533 av_log(avctx
, AV_LOG_ERROR
, "Extradata size too small.\n");
537 if (avcodec_check_dimensions(avctx
, avctx
->width
, avctx
->height
) < 0) {
541 /* Check codec type */
542 if (((avctx
->codec_id
== CODEC_ID_MSZH
) && (*((char *)avctx
->extradata
+ 7) != CODEC_MSZH
)) ||
543 ((avctx
->codec_id
== CODEC_ID_ZLIB
) && (*((char *)avctx
->extradata
+ 7) != CODEC_ZLIB
))) {
544 av_log(avctx
, AV_LOG_ERROR
, "Codec id and codec type mismatch. This should not happen.\n");
547 /* Detect image type */
548 switch (c
->imgtype
= *((char *)avctx
->extradata
+ 4)) {
550 c
->decomp_size
= basesize
* 3;
551 max_decomp_size
= max_basesize
* 3;
552 av_log(avctx
, AV_LOG_INFO
, "Image type is YUV 1:1:1.\n");
555 c
->decomp_size
= basesize
* 2;
556 max_decomp_size
= max_basesize
* 2;
557 av_log(avctx
, AV_LOG_INFO
, "Image type is YUV 4:2:2.\n");
560 c
->decomp_size
= basesize
* 3;
561 max_decomp_size
= max_basesize
* 3;
562 av_log(avctx
, AV_LOG_INFO
, "Image type is RGB 24.\n");
565 c
->decomp_size
= basesize
/ 2 * 3;
566 max_decomp_size
= max_basesize
/ 2 * 3;
567 av_log(avctx
, AV_LOG_INFO
, "Image type is YUV 4:1:1.\n");
570 c
->decomp_size
= basesize
* 2;
571 max_decomp_size
= max_basesize
* 2;
572 av_log(avctx
, AV_LOG_INFO
, "Image type is YUV 2:1:1.\n");
575 c
->decomp_size
= basesize
/ 2 * 3;
576 max_decomp_size
= max_basesize
/ 2 * 3;
577 av_log(avctx
, AV_LOG_INFO
, "Image type is YUV 4:2:0.\n");
580 av_log(avctx
, AV_LOG_ERROR
, "Unsupported image format %d.\n", c
->imgtype
);
584 /* Detect compression method */
585 c
->compression
= *((char *)avctx
->extradata
+ 5);
586 switch (avctx
->codec_id
) {
588 switch (c
->compression
) {
590 av_log(avctx
, AV_LOG_INFO
, "Compression enabled.\n");
592 case COMP_MSZH_NOCOMP
:
594 av_log(avctx
, AV_LOG_INFO
, "No compression.\n");
597 av_log(avctx
, AV_LOG_ERROR
, "Unsupported compression format for MSZH (%d).\n", c
->compression
);
603 switch (c
->compression
) {
604 case COMP_ZLIB_HISPEED
:
605 av_log(avctx
, AV_LOG_INFO
, "High speed compression.\n");
607 case COMP_ZLIB_HICOMP
:
608 av_log(avctx
, AV_LOG_INFO
, "High compression.\n");
610 case COMP_ZLIB_NORMAL
:
611 av_log(avctx
, AV_LOG_INFO
, "Normal compression.\n");
614 if ((c
->compression
< Z_NO_COMPRESSION
) || (c
->compression
> Z_BEST_COMPRESSION
)) {
615 av_log(avctx
, AV_LOG_ERROR
, "Unsupported compression level for ZLIB: (%d).\n", c
->compression
);
618 av_log(avctx
, AV_LOG_INFO
, "Compression level for ZLIB: (%d).\n", c
->compression
);
621 av_log(avctx
, AV_LOG_ERROR
, "Zlib support not compiled.\n");
626 av_log(avctx
, AV_LOG_ERROR
, "BUG! Unknown codec in compression switch.\n");
630 /* Allocate decompression buffer */
631 if (c
->decomp_size
) {
632 if ((c
->decomp_buf
= av_malloc(max_decomp_size
)) == NULL
) {
633 av_log(avctx
, AV_LOG_ERROR
, "Can't allocate decompression buffer.\n");
639 c
->flags
= *((char *)avctx
->extradata
+ 6);
640 if (c
->flags
& FLAG_MULTITHREAD
)
641 av_log(avctx
, AV_LOG_INFO
, "Multithread encoder flag set.\n");
642 if (c
->flags
& FLAG_NULLFRAME
)
643 av_log(avctx
, AV_LOG_INFO
, "Nullframe insertion flag set.\n");
644 if ((avctx
->codec_id
== CODEC_ID_ZLIB
) && (c
->flags
& FLAG_PNGFILTER
))
645 av_log(avctx
, AV_LOG_INFO
, "PNG filter flag set.\n");
646 if (c
->flags
& FLAGMASK_UNUSED
)
647 av_log(avctx
, AV_LOG_ERROR
, "Unknown flag set (%d).\n", c
->flags
);
649 /* If needed init zlib */
650 if (avctx
->codec_id
== CODEC_ID_ZLIB
) {
652 c
->zstream
.zalloc
= Z_NULL
;
653 c
->zstream
.zfree
= Z_NULL
;
654 c
->zstream
.opaque
= Z_NULL
;
655 zret
= inflateInit(&(c
->zstream
));
657 av_log(avctx
, AV_LOG_ERROR
, "Inflate init error: %d\n", zret
);
661 av_log(avctx
, AV_LOG_ERROR
, "Zlib support not compiled.\n");
666 avctx
->pix_fmt
= PIX_FMT_BGR24
;
676 static av_cold
int decode_end(AVCodecContext
*avctx
)
678 LclDecContext
* const c
= avctx
->priv_data
;
681 avctx
->release_buffer(avctx
, &c
->pic
);
683 inflateEnd(&(c
->zstream
));
689 #ifdef CONFIG_MSZH_DECODER
690 AVCodec mszh_decoder
= {
694 sizeof(LclDecContext
),
700 .long_name
="LCL (LossLess Codec Library) MSZH",
704 #ifdef CONFIG_ZLIB_DECODER
705 AVCodec zlib_decoder
= {
709 sizeof(LclDecContext
),
715 .long_name
="LCL (LossLess Codec Library) ZLIB",