]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/blobdiff - libavcodec/lcldec.c
Fix segault
[frescor/ffmpeg.git] / libavcodec / lcldec.c
index 61806612db3361741644523ed5db8d86c485009e..e4114f88ca451e43a71bde9650eac305e706ab17 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 /**
- * @file lcl.c
+ * @file libavcodec/lcldec.c
  * LCL (LossLess Codec Library) Video Codec
  * Decoder for MSZH and ZLIB codecs
  * Experimental encoder for ZLIB RGB24
 #include <stdlib.h>
 
 #include "avcodec.h"
-#include "bitstream.h"
+#include "get_bits.h"
 #include "lcl.h"
 
-#ifdef CONFIG_ZLIB
+#if CONFIG_ZLIB
 #include <zlib.h>
 #endif
 
@@ -65,7 +65,7 @@ typedef struct LclDecContext {
     unsigned int decomp_size;
     // Decompression buffer
     unsigned char* decomp_buf;
-#ifdef CONFIG_ZLIB
+#if CONFIG_ZLIB
     z_stream zstream;
 #endif
 } LclDecContext;
@@ -161,8 +161,10 @@ static unsigned int mszh_decomp(unsigned char * srcptr, int srclen, unsigned cha
  * Decode a frame
  *
  */
-static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size)
+static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
 {
+    const uint8_t *buf = avpkt->data;
+    int buf_size = avpkt->size;
     LclDecContext * const c = avctx->priv_data;
     unsigned char *encoded = (unsigned char *)buf;
     unsigned int pixel_ptr;
@@ -174,7 +176,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const
     unsigned char yq, y1q, uq, vq;
     int uqvq;
     unsigned int mthread_inlen, mthread_outlen;
-#ifdef CONFIG_ZLIB
+#if CONFIG_ZLIB
     int zret; // Zlib return code
 #endif
     unsigned int len = buf_size;
@@ -235,7 +237,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const
         }
         break;
     case CODEC_ID_ZLIB:
-#ifdef CONFIG_ZLIB
+#if CONFIG_ZLIB
         /* Using the original dll with normal compression (-1) and RGB format
          * gives a file with ZLIB fourcc, but frame is really uncompressed.
          * To be sure that's true check also frame size */
@@ -524,7 +526,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
     c->pic.data[0] = NULL;
 
-#ifdef CONFIG_ZLIB
+#if CONFIG_ZLIB
     // Needed if zlib unused or init aborted before inflateInit
     memset(&(c->zstream), 0, sizeof(z_stream));
 #endif
@@ -599,7 +601,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
         }
         break;
     case CODEC_ID_ZLIB:
-#ifdef CONFIG_ZLIB
+#if CONFIG_ZLIB
         switch (c->compression) {
         case COMP_ZLIB_HISPEED:
             av_log(avctx, AV_LOG_INFO, "High speed compression.\n");
@@ -648,7 +650,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
     /* If needed init zlib */
     if (avctx->codec_id == CODEC_ID_ZLIB) {
-#ifdef CONFIG_ZLIB
+#if CONFIG_ZLIB
         c->zstream.zalloc = Z_NULL;
         c->zstream.zfree = Z_NULL;
         c->zstream.opaque = Z_NULL;
@@ -679,14 +681,14 @@ static av_cold int decode_end(AVCodecContext *avctx)
 
     if (c->pic.data[0])
         avctx->release_buffer(avctx, &c->pic);
-#ifdef CONFIG_ZLIB
+#if CONFIG_ZLIB
     inflateEnd(&(c->zstream));
 #endif
 
     return 0;
 }
 
-#ifdef CONFIG_MSZH_DECODER
+#if CONFIG_MSZH_DECODER
 AVCodec mszh_decoder = {
     "mszh",
     CODEC_TYPE_VIDEO,
@@ -697,10 +699,11 @@ AVCodec mszh_decoder = {
     decode_end,
     decode_frame,
     CODEC_CAP_DR1,
+    .long_name = NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) MSZH"),
 };
 #endif
 
-#ifdef CONFIG_ZLIB_DECODER
+#if CONFIG_ZLIB_DECODER
 AVCodec zlib_decoder = {
     "zlib",
     CODEC_TYPE_VIDEO,
@@ -711,5 +714,6 @@ AVCodec zlib_decoder = {
     decode_end,
     decode_frame,
     CODEC_CAP_DR1,
+    .long_name = NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) ZLIB"),
 };
 #endif