lcldec.c
Go to the documentation of this file.
1 /*
2  * LCL (LossLess Codec Library) Codec
3  * Copyright (c) 2002-2004 Roberto Togni
4  *
5  * This file is part of Libav.
6  *
7  * Libav 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.
11  *
12  * Libav 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.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
41 #include <stdio.h>
42 #include <stdlib.h>
43 
44 #include "avcodec.h"
45 #include "bytestream.h"
46 #include "lcl.h"
47 #include "libavutil/lzo.h"
48 
49 #if CONFIG_ZLIB_DECODER
50 #include <zlib.h>
51 #endif
52 
53 /*
54  * Decoder context
55  */
56 typedef struct LclDecContext {
58 
59  // Image type
60  int imgtype;
61  // Compression type
63  // Flags
64  int flags;
65  // Decompressed data size
66  unsigned int decomp_size;
67  // Decompression buffer
68  unsigned char* decomp_buf;
69 #if CONFIG_ZLIB_DECODER
70  z_stream zstream;
71 #endif
73 
74 
79 static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsigned char * destptr, unsigned int destsize)
80 {
81  unsigned char *destptr_bak = destptr;
82  unsigned char *destptr_end = destptr + destsize;
83  const unsigned char *srcptr_end = srcptr + srclen;
84  unsigned mask = *srcptr++;
85  unsigned maskbit = 0x80;
86 
87  while (srcptr < srcptr_end && destptr < destptr_end) {
88  if (!(mask & maskbit)) {
89  memcpy(destptr, srcptr, 4);
90  destptr += 4;
91  srcptr += 4;
92  } else {
93  unsigned ofs = bytestream_get_le16(&srcptr);
94  unsigned cnt = (ofs >> 11) + 1;
95  ofs &= 0x7ff;
96  ofs = FFMIN(ofs, destptr - destptr_bak);
97  cnt *= 4;
98  cnt = FFMIN(cnt, destptr_end - destptr);
99  av_memcpy_backptr(destptr, ofs, cnt);
100  destptr += cnt;
101  }
102  maskbit >>= 1;
103  if (!maskbit) {
104  mask = *srcptr++;
105  while (!mask) {
106  if (destptr_end - destptr < 32 || srcptr_end - srcptr < 32) break;
107  memcpy(destptr, srcptr, 32);
108  destptr += 32;
109  srcptr += 32;
110  mask = *srcptr++;
111  }
112  maskbit = 0x80;
113  }
114  }
115 
116  return destptr - destptr_bak;
117 }
118 
119 
120 #if CONFIG_ZLIB_DECODER
121 
128 static int zlib_decomp(AVCodecContext *avctx, const uint8_t *src, int src_len, int offset, int expected)
129 {
130  LclDecContext *c = avctx->priv_data;
131  int zret = inflateReset(&c->zstream);
132  if (zret != Z_OK) {
133  av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
134  return -1;
135  }
136  c->zstream.next_in = src;
137  c->zstream.avail_in = src_len;
138  c->zstream.next_out = c->decomp_buf + offset;
139  c->zstream.avail_out = c->decomp_size - offset;
140  zret = inflate(&c->zstream, Z_FINISH);
141  if (zret != Z_OK && zret != Z_STREAM_END) {
142  av_log(avctx, AV_LOG_ERROR, "Inflate error: %d\n", zret);
143  return -1;
144  }
145  if (expected != (unsigned int)c->zstream.total_out) {
146  av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %lu)\n",
147  expected, c->zstream.total_out);
148  return -1;
149  }
150  return c->zstream.total_out;
151 }
152 #endif
153 
154 
155 /*
156  *
157  * Decode a frame
158  *
159  */
160 static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
161 {
162  const uint8_t *buf = avpkt->data;
163  int buf_size = avpkt->size;
164  LclDecContext * const c = avctx->priv_data;
165  unsigned char *encoded = (unsigned char *)buf;
166  unsigned int pixel_ptr;
167  int row, col;
168  unsigned char *outptr;
169  uint8_t *y_out, *u_out, *v_out;
170  unsigned int width = avctx->width; // Real image width
171  unsigned int height = avctx->height; // Real image height
172  unsigned int mszh_dlen;
173  unsigned char yq, y1q, uq, vq;
174  int uqvq;
175  unsigned int mthread_inlen, mthread_outlen;
176  unsigned int len = buf_size;
177 
178  if(c->pic.data[0])
179  avctx->release_buffer(avctx, &c->pic);
180 
181  c->pic.reference = 0;
183  if(avctx->get_buffer(avctx, &c->pic) < 0){
184  av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
185  return -1;
186  }
187 
188  outptr = c->pic.data[0]; // Output image pointer
189 
190  /* Decompress frame */
191  switch (avctx->codec_id) {
192  case CODEC_ID_MSZH:
193  switch (c->compression) {
194  case COMP_MSZH:
195  if (c->flags & FLAG_MULTITHREAD) {
196  mthread_inlen = AV_RL32(encoded);
197  mthread_inlen = FFMIN(mthread_inlen, len - 8);
198  mthread_outlen = AV_RL32(encoded+4);
199  mthread_outlen = FFMIN(mthread_outlen, c->decomp_size);
200  mszh_dlen = mszh_decomp(encoded + 8, mthread_inlen, c->decomp_buf, c->decomp_size);
201  if (mthread_outlen != mszh_dlen) {
202  av_log(avctx, AV_LOG_ERROR, "Mthread1 decoded size differs (%d != %d)\n",
203  mthread_outlen, mszh_dlen);
204  return -1;
205  }
206  mszh_dlen = mszh_decomp(encoded + 8 + mthread_inlen, len - 8 - mthread_inlen,
207  c->decomp_buf + mthread_outlen, c->decomp_size - mthread_outlen);
208  if (mthread_outlen != mszh_dlen) {
209  av_log(avctx, AV_LOG_ERROR, "Mthread2 decoded size differs (%d != %d)\n",
210  mthread_outlen, mszh_dlen);
211  return -1;
212  }
213  encoded = c->decomp_buf;
214  len = c->decomp_size;
215  } else {
216  mszh_dlen = mszh_decomp(encoded, len, c->decomp_buf, c->decomp_size);
217  if (c->decomp_size != mszh_dlen) {
218  av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %d)\n",
219  c->decomp_size, mszh_dlen);
220  return -1;
221  }
222  encoded = c->decomp_buf;
223  len = mszh_dlen;
224  }
225  break;
226  case COMP_MSZH_NOCOMP: {
227  int bppx2;
228  switch (c->imgtype) {
229  case IMGTYPE_YUV111:
230  case IMGTYPE_RGB24:
231  bppx2 = 6;
232  break;
233  case IMGTYPE_YUV422:
234  case IMGTYPE_YUV211:
235  bppx2 = 4;
236  break;
237  case IMGTYPE_YUV411:
238  case IMGTYPE_YUV420:
239  bppx2 = 3;
240  break;
241  default:
242  bppx2 = 0; // will error out below
243  break;
244  }
245  if (len < ((width * height * bppx2) >> 1))
246  return AVERROR_INVALIDDATA;
247  break;
248  }
249  default:
250  av_log(avctx, AV_LOG_ERROR, "BUG! Unknown MSZH compression in frame decoder.\n");
251  return -1;
252  }
253  break;
254 #if CONFIG_ZLIB_DECODER
255  case CODEC_ID_ZLIB:
256  /* Using the original dll with normal compression (-1) and RGB format
257  * gives a file with ZLIB fourcc, but frame is really uncompressed.
258  * To be sure that's true check also frame size */
259  if (c->compression == COMP_ZLIB_NORMAL && c->imgtype == IMGTYPE_RGB24 &&
260  len == width * height * 3)
261  break;
262  if (c->flags & FLAG_MULTITHREAD) {
263  int ret;
264  mthread_inlen = AV_RL32(encoded);
265  mthread_inlen = FFMIN(mthread_inlen, len - 8);
266  mthread_outlen = AV_RL32(encoded+4);
267  mthread_outlen = FFMIN(mthread_outlen, c->decomp_size);
268  ret = zlib_decomp(avctx, encoded + 8, mthread_inlen, 0, mthread_outlen);
269  if (ret < 0) return ret;
270  ret = zlib_decomp(avctx, encoded + 8 + mthread_inlen, len - 8 - mthread_inlen,
271  mthread_outlen, mthread_outlen);
272  if (ret < 0) return ret;
273  } else {
274  int ret = zlib_decomp(avctx, encoded, len, 0, c->decomp_size);
275  if (ret < 0) return ret;
276  }
277  encoded = c->decomp_buf;
278  len = c->decomp_size;
279  break;
280 #endif
281  default:
282  av_log(avctx, AV_LOG_ERROR, "BUG! Unknown codec in frame decoder compression switch.\n");
283  return -1;
284  }
285 
286 
287  /* Apply PNG filter */
288  if (avctx->codec_id == CODEC_ID_ZLIB && (c->flags & FLAG_PNGFILTER)) {
289  switch (c->imgtype) {
290  case IMGTYPE_YUV111:
291  case IMGTYPE_RGB24:
292  for (row = 0; row < height; row++) {
293  pixel_ptr = row * width * 3;
294  yq = encoded[pixel_ptr++];
295  uqvq = AV_RL16(encoded+pixel_ptr);
296  pixel_ptr += 2;
297  for (col = 1; col < width; col++) {
298  encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
299  uqvq -= AV_RL16(encoded+pixel_ptr+1);
300  AV_WL16(encoded+pixel_ptr+1, uqvq);
301  pixel_ptr += 3;
302  }
303  }
304  break;
305  case IMGTYPE_YUV422:
306  for (row = 0; row < height; row++) {
307  pixel_ptr = row * width * 2;
308  yq = uq = vq =0;
309  for (col = 0; col < width/4; col++) {
310  encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
311  encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
312  encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2];
313  encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3];
314  encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
315  encoded[pixel_ptr+5] = uq -= encoded[pixel_ptr+5];
316  encoded[pixel_ptr+6] = vq -= encoded[pixel_ptr+6];
317  encoded[pixel_ptr+7] = vq -= encoded[pixel_ptr+7];
318  pixel_ptr += 8;
319  }
320  }
321  break;
322  case IMGTYPE_YUV411:
323  for (row = 0; row < height; row++) {
324  pixel_ptr = row * width / 2 * 3;
325  yq = uq = vq =0;
326  for (col = 0; col < width/4; col++) {
327  encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
328  encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
329  encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2];
330  encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3];
331  encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
332  encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5];
333  pixel_ptr += 6;
334  }
335  }
336  break;
337  case IMGTYPE_YUV211:
338  for (row = 0; row < height; row++) {
339  pixel_ptr = row * width * 2;
340  yq = uq = vq =0;
341  for (col = 0; col < width/2; col++) {
342  encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
343  encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
344  encoded[pixel_ptr+2] = uq -= encoded[pixel_ptr+2];
345  encoded[pixel_ptr+3] = vq -= encoded[pixel_ptr+3];
346  pixel_ptr += 4;
347  }
348  }
349  break;
350  case IMGTYPE_YUV420:
351  for (row = 0; row < height/2; row++) {
352  pixel_ptr = row * width * 3;
353  yq = y1q = uq = vq =0;
354  for (col = 0; col < width/2; col++) {
355  encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
356  encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
357  encoded[pixel_ptr+2] = y1q -= encoded[pixel_ptr+2];
358  encoded[pixel_ptr+3] = y1q -= encoded[pixel_ptr+3];
359  encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
360  encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5];
361  pixel_ptr += 6;
362  }
363  }
364  break;
365  default:
366  av_log(avctx, AV_LOG_ERROR, "BUG! Unknown imagetype in pngfilter switch.\n");
367  return -1;
368  }
369  }
370 
371  /* Convert colorspace */
372  y_out = c->pic.data[0] + (height - 1) * c->pic.linesize[0];
373  u_out = c->pic.data[1] + (height - 1) * c->pic.linesize[1];
374  v_out = c->pic.data[2] + (height - 1) * c->pic.linesize[2];
375  switch (c->imgtype) {
376  case IMGTYPE_YUV111:
377  for (row = 0; row < height; row++) {
378  for (col = 0; col < width; col++) {
379  y_out[col] = *encoded++;
380  u_out[col] = *encoded++ + 128;
381  v_out[col] = *encoded++ + 128;
382  }
383  y_out -= c->pic.linesize[0];
384  u_out -= c->pic.linesize[1];
385  v_out -= c->pic.linesize[2];
386  }
387  break;
388  case IMGTYPE_YUV422:
389  for (row = 0; row < height; row++) {
390  for (col = 0; col < width - 3; col += 4) {
391  memcpy(y_out + col, encoded, 4);
392  encoded += 4;
393  u_out[ col >> 1 ] = *encoded++ + 128;
394  u_out[(col >> 1) + 1] = *encoded++ + 128;
395  v_out[ col >> 1 ] = *encoded++ + 128;
396  v_out[(col >> 1) + 1] = *encoded++ + 128;
397  }
398  y_out -= c->pic.linesize[0];
399  u_out -= c->pic.linesize[1];
400  v_out -= c->pic.linesize[2];
401  }
402  break;
403  case IMGTYPE_RGB24:
404  for (row = height - 1; row >= 0; row--) {
405  pixel_ptr = row * c->pic.linesize[0];
406  memcpy(outptr + pixel_ptr, encoded, 3 * width);
407  encoded += 3 * width;
408  }
409  break;
410  case IMGTYPE_YUV411:
411  for (row = 0; row < height; row++) {
412  for (col = 0; col < width - 3; col += 4) {
413  memcpy(y_out + col, encoded, 4);
414  encoded += 4;
415  u_out[col >> 2] = *encoded++ + 128;
416  v_out[col >> 2] = *encoded++ + 128;
417  }
418  y_out -= c->pic.linesize[0];
419  u_out -= c->pic.linesize[1];
420  v_out -= c->pic.linesize[2];
421  }
422  break;
423  case IMGTYPE_YUV211:
424  for (row = 0; row < height; row++) {
425  for (col = 0; col < width - 1; col += 2) {
426  memcpy(y_out + col, encoded, 2);
427  encoded += 2;
428  u_out[col >> 1] = *encoded++ + 128;
429  v_out[col >> 1] = *encoded++ + 128;
430  }
431  y_out -= c->pic.linesize[0];
432  u_out -= c->pic.linesize[1];
433  v_out -= c->pic.linesize[2];
434  }
435  break;
436  case IMGTYPE_YUV420:
437  u_out = c->pic.data[1] + ((height >> 1) - 1) * c->pic.linesize[1];
438  v_out = c->pic.data[2] + ((height >> 1) - 1) * c->pic.linesize[2];
439  for (row = 0; row < height - 1; row += 2) {
440  for (col = 0; col < width - 1; col += 2) {
441  memcpy(y_out + col, encoded, 2);
442  encoded += 2;
443  memcpy(y_out + col - c->pic.linesize[0], encoded, 2);
444  encoded += 2;
445  u_out[col >> 1] = *encoded++ + 128;
446  v_out[col >> 1] = *encoded++ + 128;
447  }
448  y_out -= c->pic.linesize[0] << 1;
449  u_out -= c->pic.linesize[1];
450  v_out -= c->pic.linesize[2];
451  }
452  break;
453  default:
454  av_log(avctx, AV_LOG_ERROR, "BUG! Unknown imagetype in image decoder.\n");
455  return -1;
456  }
457 
458  *data_size = sizeof(AVFrame);
459  *(AVFrame*)data = c->pic;
460 
461  /* always report that the buffer was completely consumed */
462  return buf_size;
463 }
464 
465 /*
466  *
467  * Init lcl decoder
468  *
469  */
471 {
472  LclDecContext * const c = avctx->priv_data;
473  unsigned int basesize = avctx->width * avctx->height;
474  unsigned int max_basesize = FFALIGN(avctx->width, 4) * FFALIGN(avctx->height, 4) + AV_LZO_OUTPUT_PADDING;
475  unsigned int max_decomp_size;
476 
477  if (avctx->extradata_size < 8) {
478  av_log(avctx, AV_LOG_ERROR, "Extradata size too small.\n");
479  return AVERROR_INVALIDDATA;
480  }
481 
482  /* Check codec type */
483  if ((avctx->codec_id == CODEC_ID_MSZH && avctx->extradata[7] != CODEC_MSZH) ||
484  (avctx->codec_id == CODEC_ID_ZLIB && avctx->extradata[7] != CODEC_ZLIB)) {
485  av_log(avctx, AV_LOG_ERROR, "Codec id and codec type mismatch. This should not happen.\n");
486  }
487 
488  /* Detect image type */
489  switch (c->imgtype = avctx->extradata[4]) {
490  case IMGTYPE_YUV111:
491  c->decomp_size = basesize * 3;
492  max_decomp_size = max_basesize * 3;
493  avctx->pix_fmt = PIX_FMT_YUV444P;
494  av_log(avctx, AV_LOG_DEBUG, "Image type is YUV 1:1:1.\n");
495  break;
496  case IMGTYPE_YUV422:
497  c->decomp_size = basesize * 2;
498  max_decomp_size = max_basesize * 2;
499  avctx->pix_fmt = PIX_FMT_YUV422P;
500  av_log(avctx, AV_LOG_DEBUG, "Image type is YUV 4:2:2.\n");
501  break;
502  case IMGTYPE_RGB24:
503  c->decomp_size = basesize * 3;
504  max_decomp_size = max_basesize * 3;
505  avctx->pix_fmt = PIX_FMT_BGR24;
506  av_log(avctx, AV_LOG_DEBUG, "Image type is RGB 24.\n");
507  break;
508  case IMGTYPE_YUV411:
509  c->decomp_size = basesize / 2 * 3;
510  max_decomp_size = max_basesize / 2 * 3;
511  avctx->pix_fmt = PIX_FMT_YUV411P;
512  av_log(avctx, AV_LOG_DEBUG, "Image type is YUV 4:1:1.\n");
513  break;
514  case IMGTYPE_YUV211:
515  c->decomp_size = basesize * 2;
516  max_decomp_size = max_basesize * 2;
517  avctx->pix_fmt = PIX_FMT_YUV422P;
518  av_log(avctx, AV_LOG_DEBUG, "Image type is YUV 2:1:1.\n");
519  break;
520  case IMGTYPE_YUV420:
521  c->decomp_size = basesize / 2 * 3;
522  max_decomp_size = max_basesize / 2 * 3;
523  avctx->pix_fmt = PIX_FMT_YUV420P;
524  av_log(avctx, AV_LOG_DEBUG, "Image type is YUV 4:2:0.\n");
525  break;
526  default:
527  av_log(avctx, AV_LOG_ERROR, "Unsupported image format %d.\n", c->imgtype);
528  return AVERROR_INVALIDDATA;
529  }
530 
531  /* Detect compression method */
532  c->compression = (int8_t)avctx->extradata[5];
533  switch (avctx->codec_id) {
534  case CODEC_ID_MSZH:
535  switch (c->compression) {
536  case COMP_MSZH:
537  av_log(avctx, AV_LOG_DEBUG, "Compression enabled.\n");
538  break;
539  case COMP_MSZH_NOCOMP:
540  c->decomp_size = 0;
541  av_log(avctx, AV_LOG_DEBUG, "No compression.\n");
542  break;
543  default:
544  av_log(avctx, AV_LOG_ERROR, "Unsupported compression format for MSZH (%d).\n", c->compression);
545  return AVERROR_INVALIDDATA;
546  }
547  break;
548 #if CONFIG_ZLIB_DECODER
549  case CODEC_ID_ZLIB:
550  switch (c->compression) {
551  case COMP_ZLIB_HISPEED:
552  av_log(avctx, AV_LOG_DEBUG, "High speed compression.\n");
553  break;
554  case COMP_ZLIB_HICOMP:
555  av_log(avctx, AV_LOG_DEBUG, "High compression.\n");
556  break;
557  case COMP_ZLIB_NORMAL:
558  av_log(avctx, AV_LOG_DEBUG, "Normal compression.\n");
559  break;
560  default:
561  if (c->compression < Z_NO_COMPRESSION || c->compression > Z_BEST_COMPRESSION) {
562  av_log(avctx, AV_LOG_ERROR, "Unsupported compression level for ZLIB: (%d).\n", c->compression);
563  return AVERROR_INVALIDDATA;
564  }
565  av_log(avctx, AV_LOG_DEBUG, "Compression level for ZLIB: (%d).\n", c->compression);
566  }
567  break;
568 #endif
569  default:
570  av_log(avctx, AV_LOG_ERROR, "BUG! Unknown codec in compression switch.\n");
571  return AVERROR_INVALIDDATA;
572  }
573 
574  /* Allocate decompression buffer */
575  if (c->decomp_size) {
576  if ((c->decomp_buf = av_malloc(max_decomp_size)) == NULL) {
577  av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
578  return AVERROR(ENOMEM);
579  }
580  }
581 
582  /* Detect flags */
583  c->flags = avctx->extradata[6];
584  if (c->flags & FLAG_MULTITHREAD)
585  av_log(avctx, AV_LOG_DEBUG, "Multithread encoder flag set.\n");
586  if (c->flags & FLAG_NULLFRAME)
587  av_log(avctx, AV_LOG_DEBUG, "Nullframe insertion flag set.\n");
588  if (avctx->codec_id == CODEC_ID_ZLIB && (c->flags & FLAG_PNGFILTER))
589  av_log(avctx, AV_LOG_DEBUG, "PNG filter flag set.\n");
590  if (c->flags & FLAGMASK_UNUSED)
591  av_log(avctx, AV_LOG_ERROR, "Unknown flag set (%d).\n", c->flags);
592 
593  /* If needed init zlib */
594 #if CONFIG_ZLIB_DECODER
595  if (avctx->codec_id == CODEC_ID_ZLIB) {
596  int zret;
597  c->zstream.zalloc = Z_NULL;
598  c->zstream.zfree = Z_NULL;
599  c->zstream.opaque = Z_NULL;
600  zret = inflateInit(&c->zstream);
601  if (zret != Z_OK) {
602  av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
603  av_freep(&c->decomp_buf);
604  return AVERROR_UNKNOWN;
605  }
606  }
607 #endif
608 
609  return 0;
610 }
611 
612 /*
613  *
614  * Uninit lcl decoder
615  *
616  */
618 {
619  LclDecContext * const c = avctx->priv_data;
620 
621  av_freep(&c->decomp_buf);
622  if (c->pic.data[0])
623  avctx->release_buffer(avctx, &c->pic);
624 #if CONFIG_ZLIB_DECODER
625  if (avctx->codec_id == CODEC_ID_ZLIB)
626  inflateEnd(&c->zstream);
627 #endif
628 
629  return 0;
630 }
631 
632 #if CONFIG_MSZH_DECODER
633 AVCodec ff_mszh_decoder = {
634  .name = "mszh",
635  .type = AVMEDIA_TYPE_VIDEO,
636  .id = CODEC_ID_MSZH,
637  .priv_data_size = sizeof(LclDecContext),
638  .init = decode_init,
639  .close = decode_end,
640  .decode = decode_frame,
641  .capabilities = CODEC_CAP_DR1,
642  .long_name = NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) MSZH"),
643 };
644 #endif
645 
646 #if CONFIG_ZLIB_DECODER
647 AVCodec ff_zlib_decoder = {
648  .name = "zlib",
649  .type = AVMEDIA_TYPE_VIDEO,
650  .id = CODEC_ID_ZLIB,
651  .priv_data_size = sizeof(LclDecContext),
652  .init = decode_init,
653  .close = decode_end,
654  .decode = decode_frame,
655  .capabilities = CODEC_CAP_DR1,
656  .long_name = NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) ZLIB"),
657 };
658 #endif