@ -27,6 +27,7 @@
# include "avcodec.h"
# include "bytestream.h"
# include "internal.h"
# include "zlib_wrapper.h"
# include <zlib.h>
@ -36,7 +37,7 @@ typedef struct MSCCContext {
uint8_t * decomp_buf ;
unsigned int uncomp_size ;
uint8_t * uncomp_buf ;
z_stream zstream ;
FFZStream zstream ;
uint32_t pal [ 256 ] ;
} MSCCContext ;
@ -132,6 +133,7 @@ static int decode_frame(AVCodecContext *avctx,
AVPacket * avpkt )
{
MSCCContext * s = avctx - > priv_data ;
z_stream * const zstream = & s - > zstream . zstream ;
AVFrame * frame = data ;
uint8_t * buf = avpkt - > data ;
int buf_size = avpkt - > size ;
@ -166,22 +168,22 @@ static int decode_frame(AVCodecContext *avctx,
memcpy ( frame - > data [ 1 ] , s - > pal , AVPALETTE_SIZE ) ;
}
ret = inflateReset ( & s - > zstream ) ;
ret = inflateReset ( zstream ) ;
if ( ret ! = Z_OK ) {
av_log ( avctx , AV_LOG_ERROR , " Inflate reset error: %d \n " , ret ) ;
return AVERROR_UNKNOWN ;
}
s - > zstream . next_in = buf ;
s - > zstream . avail_in = buf_size ;
s - > zstream . next_out = s - > decomp_buf ;
s - > zstream . avail_out = s - > decomp_size ;
ret = inflate ( & s - > zstream , Z_FINISH ) ;
z stream - > next_in = buf ;
z stream - > avail_in = buf_size ;
z stream - > next_out = s - > decomp_buf ;
z stream - > avail_out = s - > decomp_size ;
ret = inflate ( zstream , Z_FINISH ) ;
if ( ret ! = Z_STREAM_END ) {
av_log ( avctx , AV_LOG_ERROR , " Inflate error: %d \n " , ret ) ;
return AVERROR_UNKNOWN ;
}
bytestream2_init ( & gb , s - > decomp_buf , s - > zstream . total_out ) ;
bytestream2_init ( & gb , s - > decomp_buf , z stream - > total_out ) ;
bytestream2_init_writer ( & pb , s - > uncomp_buf , s - > uncomp_size ) ;
ret = rle_uncompress ( avctx , & gb , & pb ) ;
@ -204,7 +206,7 @@ static int decode_frame(AVCodecContext *avctx,
static av_cold int decode_init ( AVCodecContext * avctx )
{
MSCCContext * s = avctx - > priv_data ;
int stride , zret ;
int stride ;
switch ( avctx - > bits_per_coded_sample ) {
case 8 : avctx - > pix_fmt = AV_PIX_FMT_PAL8 ; break ;
@ -227,16 +229,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
if ( ! ( s - > uncomp_buf = av_malloc ( s - > uncomp_size ) ) )
return AVERROR ( ENOMEM ) ;
s - > zstream . zalloc = Z_NULL ;
s - > zstream . zfree = Z_NULL ;
s - > zstream . opaque = Z_NULL ;
zret = inflateInit ( & s - > zstream ) ;
if ( zret ! = Z_OK ) {
av_log ( avctx , AV_LOG_ERROR , " Inflate init error: %d \n " , zret ) ;
return AVERROR_UNKNOWN ;
}
return 0 ;
return ff_inflate_init ( & s - > zstream , avctx ) ;
}
static av_cold int decode_close ( AVCodecContext * avctx )
@ -247,7 +240,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
s - > decomp_size = 0 ;
av_freep ( & s - > uncomp_buf ) ;
s - > uncomp_size = 0 ;
inflateE nd( & s - > zstream ) ;
ff_inflate_e nd( & s - > zstream ) ;
return 0 ;
}