51 #if CONFIG_ZLIB_DECODER 
   69 #if CONFIG_ZLIB_DECODER 
   79 static unsigned int mszh_decomp(
const unsigned char * srcptr, 
int srclen, 
unsigned char * destptr, 
unsigned int destsize)
 
   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;
 
   87     while (srcptr < srcptr_end && destptr < destptr_end) {
 
   88         if (!(mask & maskbit)) {
 
   89             memcpy(destptr, srcptr, 4);
 
   93             unsigned ofs = bytestream_get_le16(&srcptr);
 
   94             unsigned cnt = (ofs >> 11) + 1;
 
   96             ofs = 
FFMIN(ofs, destptr - destptr_bak);
 
   98             cnt = 
FFMIN(cnt, destptr_end - destptr);
 
  104                 memset(destptr, 0, cnt);
 
  112                 if (destptr_end - destptr < 32 || srcptr_end - srcptr < 32) 
break;
 
  113                 memcpy(destptr, srcptr, 32);
 
  122     return destptr - destptr_bak;
 
  126 #if CONFIG_ZLIB_DECODER 
  137     int zret = inflateReset(&c->zstream);
 
  142     c->zstream.next_in = (
uint8_t *)src;
 
  143     c->zstream.avail_in = src_len;
 
  146     zret = 
inflate(&c->zstream, Z_FINISH);
 
  147     if (zret != Z_OK && zret != Z_STREAM_END) {
 
  151     if (expected != (
unsigned int)c->zstream.total_out) {
 
  153                expected, c->zstream.total_out);
 
  156     return c->zstream.total_out;
 
  170     int buf_size = avpkt->
size;
 
  172     unsigned int pixel_ptr;
 
  174     unsigned char *encoded = avpkt->
data, *outptr;
 
  175     uint8_t *y_out, *u_out, *v_out;
 
  178     unsigned int mszh_dlen;
 
  179     unsigned char yq, y1q, uq, vq;
 
  181     unsigned int mthread_inlen, mthread_outlen;
 
  182     unsigned int len = buf_size;
 
  188     outptr = frame->
data[0]; 
 
  204                 mthread_inlen = 
FFMIN(mthread_inlen, len - 8);
 
  205                 mthread_outlen = 
AV_RL32(buf + 4);
 
  208                 if (mthread_outlen != mszh_dlen) {
 
  210                            mthread_outlen, mszh_dlen);
 
  213                 mszh_dlen = 
mszh_decomp(buf + 8 + mthread_inlen, len - 8 - mthread_inlen,
 
  215                 if (mthread_outlen != mszh_dlen) {
 
  217                            mthread_outlen, mszh_dlen);
 
  252             if (len < ((width * height * bppx2) >> 1))
 
  261 #if CONFIG_ZLIB_DECODER 
  267             len == width * height * 3) {
 
  276             mthread_inlen = 
FFMIN(mthread_inlen, len - 8);
 
  277             mthread_outlen = 
AV_RL32(buf + 4);
 
  279             ret = zlib_decomp(avctx, buf + 8, mthread_inlen, 0, mthread_outlen);
 
  280             if (ret < 0) 
return ret;
 
  281             ret = zlib_decomp(avctx, buf + 8 + mthread_inlen, len - 8 - mthread_inlen,
 
  282                               mthread_outlen, mthread_outlen);
 
  283             if (ret < 0) 
return ret;
 
  285             int ret = zlib_decomp(avctx, buf, len, 0, c->
decomp_size);
 
  286             if (ret < 0) 
return ret;
 
  293         av_log(avctx, 
AV_LOG_ERROR, 
"BUG! Unknown codec in frame decoder compression switch.\n");
 
  303             for (row = 0; row < 
height; row++) {
 
  304                 pixel_ptr = row * width * 3;
 
  305                 yq = encoded[pixel_ptr++];
 
  306                 uqvq = 
AV_RL16(encoded+pixel_ptr);
 
  308                 for (col = 1; col < 
width; col++) {
 
  309                     encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
 
  310                     uqvq -= 
AV_RL16(encoded+pixel_ptr+1);
 
  311                     AV_WL16(encoded+pixel_ptr+1, uqvq);
 
  317             for (row = 0; row < 
height; row++) {
 
  318                 pixel_ptr = row * width * 2;
 
  320                 for (col = 0; col < width/4; col++) {
 
  321                     encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
 
  322                     encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
 
  323                     encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2];
 
  324                     encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3];
 
  325                     encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
 
  326                     encoded[pixel_ptr+5] = uq -= encoded[pixel_ptr+5];
 
  327                     encoded[pixel_ptr+6] = vq -= encoded[pixel_ptr+6];
 
  328                     encoded[pixel_ptr+7] = vq -= encoded[pixel_ptr+7];
 
  334             for (row = 0; row < 
height; row++) {
 
  335                 pixel_ptr = row * width / 2 * 3;
 
  337                 for (col = 0; col < width/4; col++) {
 
  338                     encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
 
  339                     encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
 
  340                     encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2];
 
  341                     encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3];
 
  342                     encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
 
  343                     encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5];
 
  349             for (row = 0; row < 
height; row++) {
 
  350                 pixel_ptr = row * width * 2;
 
  352                 for (col = 0; col < width/2; col++) {
 
  353                     encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
 
  354                     encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
 
  355                     encoded[pixel_ptr+2] = uq -= encoded[pixel_ptr+2];
 
  356                     encoded[pixel_ptr+3] = vq -= encoded[pixel_ptr+3];
 
  362             for (row = 0; row < height/2; row++) {
 
  363                 pixel_ptr = row * width * 3;
 
  364                 yq = y1q = uq = vq =0;
 
  365                 for (col = 0; col < width/2; col++) {
 
  366                     encoded[pixel_ptr] = yq -= encoded[pixel_ptr];
 
  367                     encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];
 
  368                     encoded[pixel_ptr+2] = y1q -= encoded[pixel_ptr+2];
 
  369                     encoded[pixel_ptr+3] = y1q -= encoded[pixel_ptr+3];
 
  370                     encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];
 
  371                     encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5];
 
  383     y_out = frame->
data[0] + (height - 1) * frame->
linesize[0];
 
  384     u_out = frame->
data[1] + (height - 1) * frame->
linesize[1];
 
  385     v_out = frame->
data[2] + (height - 1) * frame->
linesize[2];
 
  388         for (row = 0; row < 
height; row++) {
 
  389             for (col = 0; col < 
width; col++) {
 
  390                 y_out[col] = *encoded++;
 
  391                 u_out[col] = *encoded++ + 128;
 
  392                 v_out[col] = *encoded++ + 128;
 
  400         for (row = 0; row < 
height; row++) {
 
  401             for (col = 0; col < width - 3; col += 4) {
 
  402                 memcpy(y_out + col, encoded, 4);
 
  404                 u_out[ col >> 1     ] = *encoded++ + 128;
 
  405                 u_out[(col >> 1) + 1] = *encoded++ + 128;
 
  406                 v_out[ col >> 1     ] = *encoded++ + 128;
 
  407                 v_out[(col >> 1) + 1] = *encoded++ + 128;
 
  415         linesize = len < 
FFALIGN(3 * width, 4) * height ? 3 * width : 
FFALIGN(3 * width, 4);
 
  416         for (row = height - 1; row >= 0; row--) {
 
  417             pixel_ptr = row * frame->
linesize[0];
 
  418             memcpy(outptr + pixel_ptr, encoded, 3 * width);
 
  423         for (row = 0; row < 
height; row++) {
 
  424             for (col = 0; col < width - 3; col += 4) {
 
  425                 memcpy(y_out + col, encoded, 4);
 
  427                 u_out[col >> 2] = *encoded++ + 128;
 
  428                 v_out[col >> 2] = *encoded++ + 128;
 
  436         for (row = 0; row < 
height; row++) {
 
  437             for (col = 0; col < width - 1; col += 2) {
 
  438                 memcpy(y_out + col, encoded, 2);
 
  440                 u_out[col >> 1] = *encoded++ + 128;
 
  441                 v_out[col >> 1] = *encoded++ + 128;
 
  449         u_out = frame->
data[1] + ((height >> 1) - 1) * frame->
linesize[1];
 
  450         v_out = frame->
data[2] + ((height >> 1) - 1) * frame->
linesize[2];
 
  451         for (row = 0; row < height - 1; row += 2) {
 
  452             for (col = 0; col < width - 1; col += 2) {
 
  453                 memcpy(y_out + col, encoded, 2);
 
  455                 memcpy(y_out + col - frame->
linesize[0], encoded, 2);
 
  457                 u_out[col >> 1] = *encoded++ + 128;
 
  458                 v_out[col >> 1] = *encoded++ + 128;
 
  484     unsigned int basesize = avctx->
width * avctx->
height;
 
  487     unsigned int max_decomp_size;
 
  488     int subsample_h, subsample_v;
 
  498         av_log(avctx, 
AV_LOG_ERROR, 
"Codec id and codec type mismatch. This should not happen.\n");
 
  505         max_decomp_size = max_basesize * 3;
 
  511         max_decomp_size = max_basesize * 2;
 
  514         if (avctx->
width % 4) {
 
  521         max_decomp_size = max_basesize * 3;
 
  527         max_decomp_size = max_basesize / 2 * 3;
 
  533         max_decomp_size = max_basesize * 2;
 
  539         max_decomp_size = max_basesize / 2 * 3;
 
  549     if (avctx->
width % (1<<subsample_h) || avctx->
height % (1<<subsample_v)) {
 
  571 #if CONFIG_ZLIB_DECODER 
  617 #if CONFIG_ZLIB_DECODER 
  620         c->zstream.zalloc = Z_NULL;
 
  621         c->zstream.zfree = Z_NULL;
 
  622         c->zstream.opaque = Z_NULL;
 
  623         zret = inflateInit(&c->zstream);
 
  645 #if CONFIG_ZLIB_DECODER 
  647         inflateEnd(&c->zstream);
 
  653 #if CONFIG_MSZH_DECODER 
  667 #if CONFIG_ZLIB_DECODER 
#define AVERROR_INVALIDDATA
Invalid data found when processing input. 
This structure describes decoded (raw) audio or video data. 
ptrdiff_t const GLvoid * data
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples) 
memory handling functions 
static av_cold int init(AVCodecContext *avctx)
#define COMP_ZLIB_HISPEED
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx. 
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature. 
uint8_t * extradata
some codecs need / can use extradata like Huffman tables. 
static void inflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered. 
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static const uint16_t mask[17]
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor. 
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers. 
const char * name
Name of the codec implementation. 
static const uint8_t offset[127][2]
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) 
int width
picture width / height. 
packed RGB 8:8:8, 24bpp, BGRBGR... 
unsigned char * decomp_buf
Libavcodec external API header. 
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line. 
main external API structure. 
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame. 
BYTE int const BYTE int int int height
static av_cold int decode_end(AVCodecContext *avctx)
static unsigned int mszh_decomp(const unsigned char *srcptr, int srclen, unsigned char *destptr, unsigned int destsize)
static av_cold int decode_init(AVCodecContext *avctx)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes. 
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) 
common internal api header. 
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) 
#define AVERROR_UNKNOWN
Unknown error, typically from an external library. 
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
deliberately overlapping memcpy implementation 
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data. 
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.