static int xan_decode_frame_type0(AVCodecContext *avctx, AVPacket *avpkt)

{

    const uint8_t *buf = avpkt->data;

    XanContext *s = avctx->priv_data;

    uint8_t *ybuf, *prev_buf, *src = s->scratch_buffer;

    unsigned  chroma_off, corr_off;

    int cur, last, size;

    int i, j;

    int ret;



    corr_off   = AV_RL32(buf + 8);

    chroma_off = AV_RL32(buf + 4);



    if ((ret = xan_decode_chroma(avctx, avpkt)) != 0)

        return ret;



    size = avpkt->size - 4;

    if (corr_off >= avpkt->size) {

        av_log(avctx, AV_LOG_WARNING, "Ignoring invalid correction block position\n");

        corr_off = 0;

    }

    if (corr_off)

        size = corr_off;

    if (chroma_off)

        size = FFMIN(size, chroma_off);

    ret = xan_unpack_luma(buf + 12, size, src, s->buffer_size >> 1);

    if (ret) {

        av_log(avctx, AV_LOG_ERROR, "Luma decoding failed\n");

        return ret;

    }



    ybuf = s->y_buffer;

    last = *src++;

    ybuf[0] = last << 1;

    for (j = 1; j < avctx->width - 1; j += 2) {

        cur = (last + *src++) & 0x1F;

        ybuf[j]   = last + cur;

        ybuf[j+1] = cur << 1;

        last = cur;

    }

    ybuf[j]  = last << 1;

    prev_buf = ybuf;

    ybuf += avctx->width;



    for (i = 1; i < avctx->height; i++) {

        last = ((prev_buf[0] >> 1) + *src++) & 0x1F;

        ybuf[0] = last << 1;

        for (j = 1; j < avctx->width - 1; j += 2) {

            cur = ((prev_buf[j + 1] >> 1) + *src++) & 0x1F;

            ybuf[j]   = last + cur;

            ybuf[j+1] = cur << 1;

            last = cur;

        }

        ybuf[j] = last << 1;

        prev_buf = ybuf;

        ybuf += avctx->width;

    }



    if (corr_off) {

        int corr_end, dec_size;



        corr_end = avpkt->size;

        if (chroma_off > corr_off)

            corr_end = chroma_off;

        dec_size = xan_unpack(s->scratch_buffer, s->buffer_size,

                              avpkt->data + 8 + corr_off,

                              corr_end - corr_off);

        if (dec_size < 0)

            dec_size = 0;

        for (i = 0; i < dec_size; i++)

            s->y_buffer[i*2+1] = (s->y_buffer[i*2+1] + (s->scratch_buffer[i] << 1)) & 0x3F;

    }



    src  = s->y_buffer;

    ybuf = s->pic.data[0];

    for (j = 0; j < avctx->height; j++) {

        for (i = 0; i < avctx->width; i++)

            ybuf[i] = (src[i] << 2) | (src[i] >> 3);

        src  += avctx->width;

        ybuf += s->pic.linesize[0];

    }



    return 0;

}

static int xan_decode_frame_type0(AVCodecContext *avctx, AVPacket *avpkt)

{

    const uint8_t *buf = avpkt->data;

    XanContext *s = avctx->priv_data;

    uint8_t *ybuf, *prev_buf, *src = s->scratch_buffer;

    unsigned  chroma_off, corr_off;

    int cur, last, size;

    int i, j;

    int ret;



    corr_off   = AV_RL32(buf + 8);

    chroma_off = AV_RL32(buf + 4);



    if ((ret = xan_decode_chroma(avctx, avpkt)) != 0)

        return ret;



    size = avpkt->size - 4;

    if (corr_off >= avpkt->size) {

        av_log(avctx, AV_LOG_WARNING, "Ignoring invalid correction block position\n");

        corr_off = 0;

    }

    if (corr_off)

        size = corr_off;

    if (chroma_off)

        size = FFMIN(size, chroma_off);

    ret = xan_unpack_luma(buf + 12, size, src, s->buffer_size >> 1);

    if (ret) {

        av_log(avctx, AV_LOG_ERROR, "Luma decoding failed\n");

        return ret;

    }



    ybuf = s->y_buffer;

    last = *src++;

    ybuf[0] = last << 1;

    for (j = 1; j < avctx->width - 1; j += 2) {

        cur = (last + *src++) & 0x1F;

        ybuf[j]   = last + cur;

        ybuf[j+1] = cur << 1;

        last = cur;

    }

    ybuf[j]  = last << 1;

    prev_buf = ybuf;

    ybuf += avctx->width;



    for (i = 1; i < avctx->height; i++) {

        last = ((prev_buf[0] >> 1) + *src++) & 0x1F;

        ybuf[0] = last << 1;

        for (j = 1; j < avctx->width - 1; j += 2) {

            cur = ((prev_buf[j + 1] >> 1) + *src++) & 0x1F;

            ybuf[j]   = last + cur;

            ybuf[j+1] = cur << 1;

            last = cur;

        }

        ybuf[j] = last << 1;

        prev_buf = ybuf;

        ybuf += avctx->width;

    }



    if (corr_off) {

        int corr_end, dec_size;



        corr_end = avpkt->size;

        if (chroma_off > corr_off)

            corr_end = chroma_off;

        dec_size = xan_unpack(s->scratch_buffer, s->buffer_size,

                              avpkt->data + 8 + corr_off,

                              corr_end - corr_off);

        if (dec_size < 0)

            dec_size = 0;

        for (i = 0; i < dec_size; i++)

            s->y_buffer[i*2+1] = (s->y_buffer[i*2+1] + (s->scratch_buffer[i] << 1)) & 0x3F;

    }



    src  = s->y_buffer;

    ybuf = s->pic.data[0];

    for (j = 0; j < avctx->height; j++) {

        for (i = 0; i < avctx->width; i++)

            ybuf[i] = (src[i] << 2) | (src[i] >> 3);

        src  += avctx->width;

        ybuf += s->pic.linesize[0];

    }



    return 0;

}

    const uint8_t *buf = avpkt->data;     chroma_off = AV_RL32(buf + 4); static int xan_decode_frame_type0(AVCodecContext *avctx, AVPacket *avpkt)     const uint8_t *buf = avpkt->data;     int cur, last, size;     corr_off   = AV_RL32(buf + 8);     chroma_off = AV_RL32(buf + 4);     if ((ret = xan_decode_chroma(avctx, avpkt)) != 0)     size = avpkt->size - 4;     if (corr_off >= avpkt->size) {     if (corr_off)         size = corr_off;     if (chroma_off)         size = FFMIN(size, chroma_off);     ret = xan_unpack_luma(buf + 12, size, src, s->buffer_size >> 1);         corr_end = avpkt->size;         dec_size = xan_unpack(s->scratch_buffer, s->buffer_size,                               avpkt->data + 8 + corr_off,                               corr_end - corr_off);     const uint8_t *buf = avpkt->data;     if ((ret = xan_decode_chroma(avctx, avpkt)) != 0)
static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1)

{

    const uint8_t *VAR_2 = VAR_1->data;

    XanContext *s = VAR_0->priv_data;

    uint8_t *ybuf, *prev_buf, *src = s->scratch_buffer;

    unsigned  VAR_3, VAR_4;

    int VAR_5, VAR_6, VAR_7;

    int VAR_8, VAR_9;

    int VAR_10;



    VAR_4   = AV_RL32(VAR_2 + 8);

    VAR_3 = AV_RL32(VAR_2 + 4);



    if ((VAR_10 = xan_decode_chroma(VAR_0, VAR_1)) != 0)

        return VAR_10;



    VAR_7 = VAR_1->VAR_7 - 4;

    if (VAR_4 >= VAR_1->VAR_7) {

        av_log(VAR_0, AV_LOG_WARNING, "Ignoring invalid correction block position\n");

        VAR_4 = 0;

    }

    if (VAR_4)

        VAR_7 = VAR_4;

    if (VAR_3)

        VAR_7 = FFMIN(VAR_7, VAR_3);

    VAR_10 = xan_unpack_luma(VAR_2 + 12, VAR_7, src, s->buffer_size >> 1);

    if (VAR_10) {

        av_log(VAR_0, AV_LOG_ERROR, "Luma decoding failed\n");

        return VAR_10;

    }



    ybuf = s->y_buffer;

    VAR_6 = *src++;

    ybuf[0] = VAR_6 << 1;

    for (VAR_9 = 1; VAR_9 < VAR_0->width - 1; VAR_9 += 2) {

        VAR_5 = (VAR_6 + *src++) & 0x1F;

        ybuf[VAR_9]   = VAR_6 + VAR_5;

        ybuf[VAR_9+1] = VAR_5 << 1;

        VAR_6 = VAR_5;

    }

    ybuf[VAR_9]  = VAR_6 << 1;

    prev_buf = ybuf;

    ybuf += VAR_0->width;



    for (VAR_8 = 1; VAR_8 < VAR_0->height; VAR_8++) {

        VAR_6 = ((prev_buf[0] >> 1) + *src++) & 0x1F;

        ybuf[0] = VAR_6 << 1;

        for (VAR_9 = 1; VAR_9 < VAR_0->width - 1; VAR_9 += 2) {

            VAR_5 = ((prev_buf[VAR_9 + 1] >> 1) + *src++) & 0x1F;

            ybuf[VAR_9]   = VAR_6 + VAR_5;

            ybuf[VAR_9+1] = VAR_5 << 1;

            VAR_6 = VAR_5;

        }

        ybuf[VAR_9] = VAR_6 << 1;

        prev_buf = ybuf;

        ybuf += VAR_0->width;

    }



    if (VAR_4) {

        int VAR_11, VAR_12;



        VAR_11 = VAR_1->VAR_7;

        if (VAR_3 > VAR_4)

            VAR_11 = VAR_3;

        VAR_12 = xan_unpack(s->scratch_buffer, s->buffer_size,

                              VAR_1->data + 8 + VAR_4,

                              VAR_11 - VAR_4);

        if (VAR_12 < 0)

            VAR_12 = 0;

        for (VAR_8 = 0; VAR_8 < VAR_12; VAR_8++)

            s->y_buffer[VAR_8*2+1] = (s->y_buffer[VAR_8*2+1] + (s->scratch_buffer[VAR_8] << 1)) & 0x3F;

    }



    src  = s->y_buffer;

    ybuf = s->pic.data[0];

    for (VAR_9 = 0; VAR_9 < VAR_0->height; VAR_9++) {

        for (VAR_8 = 0; VAR_8 < VAR_0->width; VAR_8++)

            ybuf[VAR_8] = (src[VAR_8] << 2) | (src[VAR_8] >> 3);

        src  += VAR_0->width;

        ybuf += s->pic.linesize[0];

    }



    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1)
{ const uint8_t *VAR_2 = VAR_1->data; XanContext *s = VAR_0->priv_data; uint8_t *ybuf, *prev_buf, *src = s->scratch_buffer; unsigned  VAR_3, VAR_4; int VAR_5, VAR_6, VAR_7; int VAR_8, VAR_9; int VAR_10; VAR_4   = AV_RL32(VAR_2 + 8); VAR_3 = AV_RL32(VAR_2 + 4); if ((VAR_10 = xan_decode_chroma(VAR_0, VAR_1)) != 0)
return VAR_10; VAR_7 = VAR_1->VAR_7 - 4; if (VAR_4 >= VAR_1->VAR_7) { av_log(VAR_0, AV_LOG_WARNING, "Ignoring invalid correction block position\n"); VAR_4 = 0; } if (VAR_4)
VAR_7 = VAR_4; if (VAR_3)
VAR_7 = FFMIN(VAR_7, VAR_3); VAR_10 = xan_unpack_luma(VAR_2 + 12, VAR_7, src, s->buffer_size >> 1); if (VAR_10) { av_log(VAR_0, AV_LOG_ERROR, "Luma decoding failed\n"); return VAR_10; } ybuf = s->y_buffer; VAR_6 = *src++; ybuf[0] = VAR_6 << 1; for (VAR_9 = 1; VAR_9 < VAR_0->width - 1; VAR_9 += 2) { VAR_5 = (VAR_6 + *src++) & 0x1F; ybuf[VAR_9]   = VAR_6 + VAR_5; ybuf[VAR_9+1] = VAR_5 << 1; VAR_6 = VAR_5; } ybuf[VAR_9]  = VAR_6 << 1; prev_buf = ybuf; ybuf += VAR_0->width; for (VAR_8 = 1; VAR_8 < VAR_0->height; VAR_8++) { VAR_6 = ((prev_buf[0] >> 1) + *src++) & 0x1F; ybuf[0] = VAR_6 << 1; for (VAR_9 = 1; VAR_9 < VAR_0->width - 1; VAR_9 += 2) { VAR_5 = ((prev_buf[VAR_9 + 1] >> 1) + *src++) & 0x1F; ybuf[VAR_9]   = VAR_6 + VAR_5; ybuf[VAR_9+1] = VAR_5 << 1; VAR_6 = VAR_5; } ybuf[VAR_9] = VAR_6 << 1; prev_buf = ybuf; ybuf += VAR_0->width; } if (VAR_4) { int VAR_11, VAR_12; VAR_11 = VAR_1->VAR_7; if (VAR_3 > VAR_4)
VAR_11 = VAR_3; VAR_12 = xan_unpack(s->scratch_buffer, s->buffer_size,
VAR_1->data + 8 + VAR_4,
VAR_11 - VAR_4); if (VAR_12 < 0)
VAR_12 = 0; for (VAR_8 = 0; VAR_8 < VAR_12; VAR_8++) s->y_buffer[VAR_8*2+1] = (s->y_buffer[VAR_8*2+1] + (s->scratch_buffer[VAR_8] << 1)) & 0x3F; } src  = s->y_buffer; ybuf = s->pic.data[0]; for (VAR_9 = 0; VAR_9 < VAR_0->height; VAR_9++) { for (VAR_8 = 0; VAR_8 < VAR_0->width; VAR_8++) ybuf[VAR_8] = (src[VAR_8] << 2) | (src[VAR_8] >> 3); src  += VAR_0->width; ybuf += s->pic.linesize[0]; } return 0; }