static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,

                            AVPacket *avpkt)

{

    PCXContext * const s = avctx->priv_data;

    AVFrame *picture = data;

    AVFrame * const p = &s->picture;

    GetByteContext gb;

    int compressed, xmin, ymin, xmax, ymax, ret;

    unsigned int w, h, bits_per_pixel, bytes_per_line, nplanes, stride, y, x,

                 bytes_per_scanline;

    uint8_t *ptr, *scanline;



    if (avpkt->size < 128)

        return AVERROR_INVALIDDATA;



    bytestream2_init(&gb, avpkt->data, avpkt->size);



    if (bytestream2_get_byteu(&gb) != 0x0a || bytestream2_get_byteu(&gb) > 5) {

        av_log(avctx, AV_LOG_ERROR, "this is not PCX encoded data\n");

        return AVERROR_INVALIDDATA;

    }



    compressed = bytestream2_get_byteu(&gb);

    bits_per_pixel = bytestream2_get_byteu(&gb);

    xmin = bytestream2_get_le16u(&gb);

    ymin = bytestream2_get_le16u(&gb);

    xmax = bytestream2_get_le16u(&gb);

    ymax = bytestream2_get_le16u(&gb);

    avctx->sample_aspect_ratio.num = bytestream2_get_le16u(&gb);

    avctx->sample_aspect_ratio.den = bytestream2_get_le16u(&gb);



    if (xmax < xmin || ymax < ymin) {

        av_log(avctx, AV_LOG_ERROR, "invalid image dimensions\n");

        return AVERROR_INVALIDDATA;

    }



    w = xmax - xmin + 1;

    h = ymax - ymin + 1;



    bytestream2_skipu(&gb, 49);

    nplanes            = bytestream2_get_byteu(&gb);

    bytes_per_line     = bytestream2_get_le16u(&gb);

    bytes_per_scanline = nplanes * bytes_per_line;



    if (bytes_per_scanline < (w * bits_per_pixel * nplanes + 7) / 8) {

        av_log(avctx, AV_LOG_ERROR, "PCX data is corrupted\n");

        return AVERROR_INVALIDDATA;

    }



    switch ((nplanes<<8) + bits_per_pixel) {

        case 0x0308:

            avctx->pix_fmt = AV_PIX_FMT_RGB24;

            break;

        case 0x0108:

        case 0x0104:

        case 0x0102:

        case 0x0101:

        case 0x0401:

        case 0x0301:

        case 0x0201:

            avctx->pix_fmt = AV_PIX_FMT_PAL8;

            break;

        default:

            av_log(avctx, AV_LOG_ERROR, "invalid PCX file\n");

            return AVERROR_INVALIDDATA;

    }



    bytestream2_skipu(&gb, 60);



    if (p->data[0])

        avctx->release_buffer(avctx, p);



    if ((ret = av_image_check_size(w, h, 0, avctx)) < 0)

        return ret;

    if (w != avctx->width || h != avctx->height)

        avcodec_set_dimensions(avctx, w, h);

    if ((ret = ff_get_buffer(avctx, p)) < 0) {

        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");

        return ret;

    }



    p->pict_type = AV_PICTURE_TYPE_I;



    ptr    = p->data[0];

    stride = p->linesize[0];



    scanline = av_malloc(bytes_per_scanline);

    if (!scanline)

        return AVERROR(ENOMEM);



    if (nplanes == 3 && bits_per_pixel == 8) {

        for (y=0; y<h; y++) {

            pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);



            for (x=0; x<w; x++) {

                ptr[3*x  ] = scanline[x                    ];

                ptr[3*x+1] = scanline[x+ bytes_per_line    ];

                ptr[3*x+2] = scanline[x+(bytes_per_line<<1)];

            }



            ptr += stride;

        }



    } else if (nplanes == 1 && bits_per_pixel == 8) {

        int palstart = avpkt->size - 769;



        for (y=0; y<h; y++, ptr+=stride) {

            pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);

            memcpy(ptr, scanline, w);

        }



        if (bytestream2_tell(&gb) != palstart) {

            av_log(avctx, AV_LOG_WARNING, "image data possibly corrupted\n");

            bytestream2_seek(&gb, palstart, SEEK_SET);

        }

        if (bytestream2_get_byte(&gb) != 12) {

            av_log(avctx, AV_LOG_ERROR, "expected palette after image data\n");

            ret = AVERROR_INVALIDDATA;

            goto end;

        }



    } else if (nplanes == 1) {   /* all packed formats, max. 16 colors */

        GetBitContext s;



        for (y=0; y<h; y++) {

            init_get_bits8(&s, scanline, bytes_per_scanline);



            pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);



            for (x=0; x<w; x++)

                ptr[x] = get_bits(&s, bits_per_pixel);

            ptr += stride;

        }



    } else {    /* planar, 4, 8 or 16 colors */

        int i;



        for (y=0; y<h; y++) {

            pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);



            for (x=0; x<w; x++) {

                int m = 0x80 >> (x&7), v = 0;

                for (i=nplanes - 1; i>=0; i--) {

                    v <<= 1;

                    v  += !!(scanline[i*bytes_per_line + (x>>3)] & m);

                }

                ptr[x] = v;

            }

            ptr += stride;

        }

    }



    ret = bytestream2_tell(&gb);

    if (nplanes == 1 && bits_per_pixel == 8) {

        pcx_palette(&gb, (uint32_t *) p->data[1], 256);

        ret += 256 * 3;

    } else if (bits_per_pixel * nplanes == 1) {

        AV_WN32A(p->data[1]  , 0xFF000000);

        AV_WN32A(p->data[1]+4, 0xFFFFFFFF);

    } else if (bits_per_pixel < 8) {

        bytestream2_seek(&gb, 16, SEEK_SET);

        pcx_palette(&gb, (uint32_t *) p->data[1], 16);

    }



    *picture = s->picture;

    *got_frame = 1;



end:

    av_free(scanline);

    return ret;

}

static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,

                            AVPacket *avpkt)

{

    PCXContext * const s = avctx->priv_data;

    AVFrame *picture = data;

    AVFrame * const p = &s->picture;

    GetByteContext gb;

    int compressed, xmin, ymin, xmax, ymax, ret;

    unsigned int w, h, bits_per_pixel, bytes_per_line, nplanes, stride, y, x,

                 bytes_per_scanline;

    uint8_t *ptr, *scanline;



    if (avpkt->size < 128)

        return AVERROR_INVALIDDATA;



    bytestream2_init(&gb, avpkt->data, avpkt->size);



    if (bytestream2_get_byteu(&gb) != 0x0a || bytestream2_get_byteu(&gb) > 5) {

        av_log(avctx, AV_LOG_ERROR, "this is not PCX encoded data\n");

        return AVERROR_INVALIDDATA;

    }



    compressed = bytestream2_get_byteu(&gb);

    bits_per_pixel = bytestream2_get_byteu(&gb);

    xmin = bytestream2_get_le16u(&gb);

    ymin = bytestream2_get_le16u(&gb);

    xmax = bytestream2_get_le16u(&gb);

    ymax = bytestream2_get_le16u(&gb);

    avctx->sample_aspect_ratio.num = bytestream2_get_le16u(&gb);

    avctx->sample_aspect_ratio.den = bytestream2_get_le16u(&gb);



    if (xmax < xmin || ymax < ymin) {

        av_log(avctx, AV_LOG_ERROR, "invalid image dimensions\n");

        return AVERROR_INVALIDDATA;

    }



    w = xmax - xmin + 1;

    h = ymax - ymin + 1;



    bytestream2_skipu(&gb, 49);

    nplanes            = bytestream2_get_byteu(&gb);

    bytes_per_line     = bytestream2_get_le16u(&gb);

    bytes_per_scanline = nplanes * bytes_per_line;



    if (bytes_per_scanline < (w * bits_per_pixel * nplanes + 7) / 8) {

        av_log(avctx, AV_LOG_ERROR, "PCX data is corrupted\n");

        return AVERROR_INVALIDDATA;

    }



    switch ((nplanes<<8) + bits_per_pixel) {

        case 0x0308:

            avctx->pix_fmt = AV_PIX_FMT_RGB24;

            break;

        case 0x0108:

        case 0x0104:

        case 0x0102:

        case 0x0101:

        case 0x0401:

        case 0x0301:

        case 0x0201:

            avctx->pix_fmt = AV_PIX_FMT_PAL8;

            break;

        default:

            av_log(avctx, AV_LOG_ERROR, "invalid PCX file\n");

            return AVERROR_INVALIDDATA;

    }



    bytestream2_skipu(&gb, 60);



    if (p->data[0])

        avctx->release_buffer(avctx, p);



    if ((ret = av_image_check_size(w, h, 0, avctx)) < 0)

        return ret;

    if (w != avctx->width || h != avctx->height)

        avcodec_set_dimensions(avctx, w, h);

    if ((ret = ff_get_buffer(avctx, p)) < 0) {

        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");

        return ret;

    }



    p->pict_type = AV_PICTURE_TYPE_I;



    ptr    = p->data[0];

    stride = p->linesize[0];



    scanline = av_malloc(bytes_per_scanline);

    if (!scanline)

        return AVERROR(ENOMEM);



    if (nplanes == 3 && bits_per_pixel == 8) {

        for (y=0; y<h; y++) {

            pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);



            for (x=0; x<w; x++) {

                ptr[3*x  ] = scanline[x                    ];

                ptr[3*x+1] = scanline[x+ bytes_per_line    ];

                ptr[3*x+2] = scanline[x+(bytes_per_line<<1)];

            }



            ptr += stride;

        }



    } else if (nplanes == 1 && bits_per_pixel == 8) {

        int palstart = avpkt->size - 769;



        for (y=0; y<h; y++, ptr+=stride) {

            pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);

            memcpy(ptr, scanline, w);

        }



        if (bytestream2_tell(&gb) != palstart) {

            av_log(avctx, AV_LOG_WARNING, "image data possibly corrupted\n");

            bytestream2_seek(&gb, palstart, SEEK_SET);

        }

        if (bytestream2_get_byte(&gb) != 12) {

            av_log(avctx, AV_LOG_ERROR, "expected palette after image data\n");

            ret = AVERROR_INVALIDDATA;

            goto end;

        }



    } else if (nplanes == 1) {   

        GetBitContext s;



        for (y=0; y<h; y++) {

            init_get_bits8(&s, scanline, bytes_per_scanline);



            pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);



            for (x=0; x<w; x++)

                ptr[x] = get_bits(&s, bits_per_pixel);

            ptr += stride;

        }



    } else {    

        int i;



        for (y=0; y<h; y++) {

            pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);



            for (x=0; x<w; x++) {

                int m = 0x80 >> (x&7), v = 0;

                for (i=nplanes - 1; i>=0; i--) {

                    v <<= 1;

                    v  += !!(scanline[i*bytes_per_line + (x>>3)] & m);

                }

                ptr[x] = v;

            }

            ptr += stride;

        }

    }



    ret = bytestream2_tell(&gb);

    if (nplanes == 1 && bits_per_pixel == 8) {

        pcx_palette(&gb, (uint32_t *) p->data[1], 256);

        ret += 256 * 3;

    } else if (bits_per_pixel * nplanes == 1) {

        AV_WN32A(p->data[1]  , 0xFF000000);

        AV_WN32A(p->data[1]+4, 0xFFFFFFFF);

    } else if (bits_per_pixel < 8) {

        bytestream2_seek(&gb, 16, SEEK_SET);

        pcx_palette(&gb, (uint32_t *) p->data[1], 16);

    }



    *picture = s->picture;

    *got_frame = 1;



end:

    av_free(scanline);

    return ret;

}

static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,

                            AVPacket *VAR_3)

{

    PCXContext * const s = VAR_0->priv_data;

    AVFrame *picture = VAR_1;

    AVFrame * const p = &s->picture;

    GetByteContext gb;

    int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;

    unsigned int VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16, VAR_17,

                 VAR_18;

    uint8_t *ptr, *scanline;



    if (VAR_3->size < 128)

        return AVERROR_INVALIDDATA;



    bytestream2_init(&gb, VAR_3->VAR_1, VAR_3->size);



    if (bytestream2_get_byteu(&gb) != 0x0a || bytestream2_get_byteu(&gb) > 5) {

        av_log(VAR_0, AV_LOG_ERROR, "this is not PCX encoded VAR_1\n");

        return AVERROR_INVALIDDATA;

    }



    VAR_4 = bytestream2_get_byteu(&gb);

    VAR_12 = bytestream2_get_byteu(&gb);

    VAR_5 = bytestream2_get_le16u(&gb);

    VAR_6 = bytestream2_get_le16u(&gb);

    VAR_7 = bytestream2_get_le16u(&gb);

    VAR_8 = bytestream2_get_le16u(&gb);

    VAR_0->sample_aspect_ratio.num = bytestream2_get_le16u(&gb);

    VAR_0->sample_aspect_ratio.den = bytestream2_get_le16u(&gb);



    if (VAR_7 < VAR_5 || VAR_8 < VAR_6) {

        av_log(VAR_0, AV_LOG_ERROR, "invalid image dimensions\n");

        return AVERROR_INVALIDDATA;

    }



    VAR_10 = VAR_7 - VAR_5 + 1;

    VAR_11 = VAR_8 - VAR_6 + 1;



    bytestream2_skipu(&gb, 49);

    VAR_14            = bytestream2_get_byteu(&gb);

    VAR_13     = bytestream2_get_le16u(&gb);

    VAR_18 = VAR_14 * VAR_13;



    if (VAR_18 < (VAR_10 * VAR_12 * VAR_14 + 7) / 8) {

        av_log(VAR_0, AV_LOG_ERROR, "PCX VAR_1 is corrupted\n");

        return AVERROR_INVALIDDATA;

    }



    switch ((VAR_14<<8) + VAR_12) {

        case 0x0308:

            VAR_0->pix_fmt = AV_PIX_FMT_RGB24;

            break;

        case 0x0108:

        case 0x0104:

        case 0x0102:

        case 0x0101:

        case 0x0401:

        case 0x0301:

        case 0x0201:

            VAR_0->pix_fmt = AV_PIX_FMT_PAL8;

            break;

        default:

            av_log(VAR_0, AV_LOG_ERROR, "invalid PCX file\n");

            return AVERROR_INVALIDDATA;

    }



    bytestream2_skipu(&gb, 60);



    if (p->VAR_1[0])

        VAR_0->release_buffer(VAR_0, p);



    if ((VAR_9 = av_image_check_size(VAR_10, VAR_11, 0, VAR_0)) < 0)

        return VAR_9;

    if (VAR_10 != VAR_0->width || VAR_11 != VAR_0->height)

        avcodec_set_dimensions(VAR_0, VAR_10, VAR_11);

    if ((VAR_9 = ff_get_buffer(VAR_0, p)) < 0) {

        av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");

        return VAR_9;

    }



    p->pict_type = AV_PICTURE_TYPE_I;



    ptr    = p->VAR_1[0];

    VAR_15 = p->linesize[0];



    scanline = av_malloc(VAR_18);

    if (!scanline)

        return AVERROR(ENOMEM);



    if (VAR_14 == 3 && VAR_12 == 8) {

        for (VAR_16=0; VAR_16<VAR_11; VAR_16++) {

            pcx_rle_decode(&gb, scanline, VAR_18, VAR_4);



            for (VAR_17=0; VAR_17<VAR_10; VAR_17++) {

                ptr[3*VAR_17  ] = scanline[VAR_17                    ];

                ptr[3*VAR_17+1] = scanline[VAR_17+ VAR_13    ];

                ptr[3*VAR_17+2] = scanline[VAR_17+(VAR_13<<1)];

            }



            ptr += VAR_15;

        }



    } else if (VAR_14 == 1 && VAR_12 == 8) {

        int VAR_19 = VAR_3->size - 769;



        for (VAR_16=0; VAR_16<VAR_11; VAR_16++, ptr+=VAR_15) {

            pcx_rle_decode(&gb, scanline, VAR_18, VAR_4);

            memcpy(ptr, scanline, VAR_10);

        }



        if (bytestream2_tell(&gb) != VAR_19) {

            av_log(VAR_0, AV_LOG_WARNING, "image VAR_1 possibly corrupted\n");

            bytestream2_seek(&gb, VAR_19, SEEK_SET);

        }

        if (bytestream2_get_byte(&gb) != 12) {

            av_log(VAR_0, AV_LOG_ERROR, "expected palette after image VAR_1\n");

            VAR_9 = AVERROR_INVALIDDATA;

            goto end;

        }



    } else if (VAR_14 == 1) {   

        GetBitContext s;



        for (VAR_16=0; VAR_16<VAR_11; VAR_16++) {

            init_get_bits8(&s, scanline, VAR_18);



            pcx_rle_decode(&gb, scanline, VAR_18, VAR_4);



            for (VAR_17=0; VAR_17<VAR_10; VAR_17++)

                ptr[VAR_17] = get_bits(&s, VAR_12);

            ptr += VAR_15;

        }



    } else {    

        int VAR_20;



        for (VAR_16=0; VAR_16<VAR_11; VAR_16++) {

            pcx_rle_decode(&gb, scanline, VAR_18, VAR_4);



            for (VAR_17=0; VAR_17<VAR_10; VAR_17++) {

                int VAR_21 = 0x80 >> (VAR_17&7), VAR_22 = 0;

                for (VAR_20=VAR_14 - 1; VAR_20>=0; VAR_20--) {

                    VAR_22 <<= 1;

                    VAR_22  += !!(scanline[VAR_20*VAR_13 + (VAR_17>>3)] & VAR_21);

                }

                ptr[VAR_17] = VAR_22;

            }

            ptr += VAR_15;

        }

    }



    VAR_9 = bytestream2_tell(&gb);

    if (VAR_14 == 1 && VAR_12 == 8) {

        pcx_palette(&gb, (uint32_t *) p->VAR_1[1], 256);

        VAR_9 += 256 * 3;

    } else if (VAR_12 * VAR_14 == 1) {

        AV_WN32A(p->VAR_1[1]  , 0xFF000000);

        AV_WN32A(p->VAR_1[1]+4, 0xFFFFFFFF);

    } else if (VAR_12 < 8) {

        bytestream2_seek(&gb, 16, SEEK_SET);

        pcx_palette(&gb, (uint32_t *) p->VAR_1[1], 16);

    }



    *picture = s->picture;

    *VAR_2 = 1;



end:

    av_free(scanline);

    return VAR_9;

}

static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{ PCXContext * const s = VAR_0->priv_data; AVFrame *picture = VAR_1; AVFrame * const p = &s->picture; GetByteContext gb; int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9; unsigned int VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16, VAR_17,
VAR_18; uint8_t *ptr, *scanline; if (VAR_3->size < 128)
return AVERROR_INVALIDDATA; bytestream2_init(&gb, VAR_3->VAR_1, VAR_3->size); if (bytestream2_get_byteu(&gb) != 0x0a || bytestream2_get_byteu(&gb) > 5) { av_log(VAR_0, AV_LOG_ERROR, "this is not PCX encoded VAR_1\n"); return AVERROR_INVALIDDATA; } VAR_4 = bytestream2_get_byteu(&gb); VAR_12 = bytestream2_get_byteu(&gb); VAR_5 = bytestream2_get_le16u(&gb); VAR_6 = bytestream2_get_le16u(&gb); VAR_7 = bytestream2_get_le16u(&gb); VAR_8 = bytestream2_get_le16u(&gb); VAR_0->sample_aspect_ratio.num = bytestream2_get_le16u(&gb); VAR_0->sample_aspect_ratio.den = bytestream2_get_le16u(&gb); if (VAR_7 < VAR_5 || VAR_8 < VAR_6) { av_log(VAR_0, AV_LOG_ERROR, "invalid image dimensions\n"); return AVERROR_INVALIDDATA; } VAR_10 = VAR_7 - VAR_5 + 1; VAR_11 = VAR_8 - VAR_6 + 1; bytestream2_skipu(&gb, 49); VAR_14            = bytestream2_get_byteu(&gb); VAR_13     = bytestream2_get_le16u(&gb); VAR_18 = VAR_14 * VAR_13; if (VAR_18 < (VAR_10 * VAR_12 * VAR_14 + 7) / 8) { av_log(VAR_0, AV_LOG_ERROR, "PCX VAR_1 is corrupted\n"); return AVERROR_INVALIDDATA; } switch ((VAR_14<<8) + VAR_12) { case 0x0308:
VAR_0->pix_fmt = AV_PIX_FMT_RGB24; break; case 0x0108:
case 0x0104:
case 0x0102:
case 0x0101:
case 0x0401:
case 0x0301:
case 0x0201:
VAR_0->pix_fmt = AV_PIX_FMT_PAL8; break; default:
av_log(VAR_0, AV_LOG_ERROR, "invalid PCX file\n"); return AVERROR_INVALIDDATA; } bytestream2_skipu(&gb, 60); if (p->VAR_1[0])
VAR_0->release_buffer(VAR_0, p); if ((VAR_9 = av_image_check_size(VAR_10, VAR_11, 0, VAR_0)) < 0)
return VAR_9; if (VAR_10 != VAR_0->width || VAR_11 != VAR_0->height)
avcodec_set_dimensions(VAR_0, VAR_10, VAR_11); if ((VAR_9 = ff_get_buffer(VAR_0, p)) < 0) { av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n"); return VAR_9; } p->pict_type = AV_PICTURE_TYPE_I; ptr    = p->VAR_1[0]; VAR_15 = p->linesize[0]; scanline = av_malloc(VAR_18); if (!scanline)
return AVERROR(ENOMEM); if (VAR_14 == 3 && VAR_12 == 8) { for (VAR_16=0; VAR_16<VAR_11; VAR_16++) { pcx_rle_decode(&gb, scanline, VAR_18, VAR_4); for (VAR_17=0; VAR_17<VAR_10; VAR_17++) { ptr[3*VAR_17  ] = scanline[VAR_17                    ]; ptr[3*VAR_17+1] = scanline[VAR_17+ VAR_13    ]; ptr[3*VAR_17+2] = scanline[VAR_17+(VAR_13<<1)]; } ptr += VAR_15; } } else if (VAR_14 == 1 && VAR_12 == 8) { int VAR_19 = VAR_3->size - 769; for (VAR_16=0; VAR_16<VAR_11; VAR_16++, ptr+=VAR_15) { pcx_rle_decode(&gb, scanline, VAR_18, VAR_4); memcpy(ptr, scanline, VAR_10); } if (bytestream2_tell(&gb) != VAR_19) { av_log(VAR_0, AV_LOG_WARNING, "image VAR_1 possibly corrupted\n"); bytestream2_seek(&gb, VAR_19, SEEK_SET); } if (bytestream2_get_byte(&gb) != 12) { av_log(VAR_0, AV_LOG_ERROR, "expected palette after image VAR_1\n"); VAR_9 = AVERROR_INVALIDDATA; goto end; } } else if (VAR_14 == 1) { GetBitContext s; for (VAR_16=0; VAR_16<VAR_11; VAR_16++) { init_get_bits8(&s, scanline, VAR_18); pcx_rle_decode(&gb, scanline, VAR_18, VAR_4); for (VAR_17=0; VAR_17<VAR_10; VAR_17++) ptr[VAR_17] = get_bits(&s, VAR_12); ptr += VAR_15; } } else { int VAR_20; for (VAR_16=0; VAR_16<VAR_11; VAR_16++) { pcx_rle_decode(&gb, scanline, VAR_18, VAR_4); for (VAR_17=0; VAR_17<VAR_10; VAR_17++) { int VAR_21 = 0x80 >> (VAR_17&7), VAR_22 = 0; for (VAR_20=VAR_14 - 1; VAR_20>=0; VAR_20--) { VAR_22 <<= 1; VAR_22  += !!(scanline[VAR_20*VAR_13 + (VAR_17>>3)] & VAR_21); } ptr[VAR_17] = VAR_22; } ptr += VAR_15; } } VAR_9 = bytestream2_tell(&gb); if (VAR_14 == 1 && VAR_12 == 8) { pcx_palette(&gb, (uint32_t *) p->VAR_1[1], 256); VAR_9 += 256 * 3; } else if (VAR_12 * VAR_14 == 1) { AV_WN32A(p->VAR_1[1]  , 0xFF000000); AV_WN32A(p->VAR_1[1]+4, 0xFFFFFFFF); } else if (VAR_12 < 8) { bytestream2_seek(&gb, 16, SEEK_SET); pcx_palette(&gb, (uint32_t *) p->VAR_1[1], 16); } *picture = s->picture; *VAR_2 = 1; end:
av_free(scanline); return VAR_9; }