#include <stdlib.h>
#include "avcodec.h"
-#include "put_bits.h"
#include "lcl.h"
#include <zlib.h>
AVCodecContext *avctx;
AVFrame pic;
- PutBitContext pb;
// Image type
int imgtype;
int compression;
// Flags
int flags;
- // Decompressed data size
- unsigned int decomp_size;
- // Maximum compressed data size
- unsigned int max_comp_size;
- // Compression buffer
- unsigned char* comp_buf;
z_stream zstream;
} LclEncContext;
switch(avctx->pix_fmt){
case PIX_FMT_BGR24:
c->imgtype = IMGTYPE_RGB24;
- c->decomp_size = avctx->width * avctx->height * 3;
avctx->bits_per_coded_sample= 24;
break;
default:
return -1;
}
- ((uint8_t*)avctx->extradata)[0]= 4;
- ((uint8_t*)avctx->extradata)[1]= 0;
- ((uint8_t*)avctx->extradata)[2]= 0;
- ((uint8_t*)avctx->extradata)[3]= 0;
- ((uint8_t*)avctx->extradata)[4]= c->imgtype;
- ((uint8_t*)avctx->extradata)[5]= c->compression;
- ((uint8_t*)avctx->extradata)[6]= c->flags;
- ((uint8_t*)avctx->extradata)[7]= CODEC_ZLIB;
+ avctx->extradata[0]= 4;
+ avctx->extradata[1]= 0;
+ avctx->extradata[2]= 0;
+ avctx->extradata[3]= 0;
+ avctx->extradata[4]= c->imgtype;
+ avctx->extradata[5]= c->compression;
+ avctx->extradata[6]= c->flags;
+ avctx->extradata[7]= CODEC_ZLIB;
c->avctx->extradata_size= 8;
c->zstream.zalloc = Z_NULL;
LclEncContext *c = avctx->priv_data;
av_freep(&avctx->extradata);
- av_freep(&c->comp_buf);
deflateEnd(&c->zstream);
return 0;