static int dfa_decode_frame(AVCodecContext *avctx,

                            void *data, int *data_size,

                            AVPacket *avpkt)

{

    DfaContext *s = avctx->priv_data;

    const uint8_t *buf = avpkt->data;

    const uint8_t *buf_end = avpkt->data + avpkt->size;

    const uint8_t *tmp_buf;

    uint32_t chunk_type, chunk_size;

    uint8_t *dst;

    int ret;

    int i, pal_elems;



    if (s->pic.data[0])

        avctx->release_buffer(avctx, &s->pic);



    if ((ret = avctx->get_buffer(avctx, &s->pic))) {

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

        return ret;

    }



    while (buf < buf_end) {

        chunk_size = AV_RL32(buf + 4);

        chunk_type = AV_RL32(buf + 8);

        buf += 12;

        if (buf_end - buf < chunk_size) {

            av_log(avctx, AV_LOG_ERROR, "Chunk size is too big (%d bytes)\n", chunk_size);

            return -1;

        }

        if (!chunk_type)

            break;

        if (chunk_type == 1) {

            pal_elems = FFMIN(chunk_size / 3, 256);

            tmp_buf = buf;

            for (i = 0; i < pal_elems; i++) {

                s->pal[i] = bytestream_get_be24(&tmp_buf) << 2;

                s->pal[i] |= (s->pal[i] >> 6) & 0x333;

            }

            s->pic.palette_has_changed = 1;

        } else if (chunk_type <= 9) {

            if (decoder[chunk_type - 2](s->frame_buf, avctx->width, avctx->height,

                                        buf, buf + chunk_size)) {

                av_log(avctx, AV_LOG_ERROR, "Error decoding %s chunk\n",

                       chunk_name[chunk_type - 2]);

                return -1;

            }

        } else {

            av_log(avctx, AV_LOG_WARNING, "Ignoring unknown chunk type %d\n",

                   chunk_type);

        }

        buf += chunk_size;

    }



    buf = s->frame_buf;

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

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

        memcpy(dst, buf, avctx->width);

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

        buf += avctx->width;

    }

    memcpy(s->pic.data[1], s->pal, sizeof(s->pal));



    *data_size = sizeof(AVFrame);

    *(AVFrame*)data = s->pic;



    return avpkt->size;

}

static int dfa_decode_frame(AVCodecContext *avctx,

                            void *data, int *data_size,

                            AVPacket *avpkt)

{

    DfaContext *s = avctx->priv_data;

    const uint8_t *buf = avpkt->data;

    const uint8_t *buf_end = avpkt->data + avpkt->size;

    const uint8_t *tmp_buf;

    uint32_t chunk_type, chunk_size;

    uint8_t *dst;

    int ret;

    int i, pal_elems;



    if (s->pic.data[0])

        avctx->release_buffer(avctx, &s->pic);



    if ((ret = avctx->get_buffer(avctx, &s->pic))) {

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

        return ret;

    }



    while (buf < buf_end) {

        chunk_size = AV_RL32(buf + 4);

        chunk_type = AV_RL32(buf + 8);

        buf += 12;

        if (buf_end - buf < chunk_size) {

            av_log(avctx, AV_LOG_ERROR, "Chunk size is too big (%d bytes)\n", chunk_size);

            return -1;

        }

        if (!chunk_type)

            break;

        if (chunk_type == 1) {

            pal_elems = FFMIN(chunk_size / 3, 256);

            tmp_buf = buf;

            for (i = 0; i < pal_elems; i++) {

                s->pal[i] = bytestream_get_be24(&tmp_buf) << 2;

                s->pal[i] |= (s->pal[i] >> 6) & 0x333;

            }

            s->pic.palette_has_changed = 1;

        } else if (chunk_type <= 9) {

            if (decoder[chunk_type - 2](s->frame_buf, avctx->width, avctx->height,

                                        buf, buf + chunk_size)) {

                av_log(avctx, AV_LOG_ERROR, "Error decoding %s chunk\n",

                       chunk_name[chunk_type - 2]);

                return -1;

            }

        } else {

            av_log(avctx, AV_LOG_WARNING, "Ignoring unknown chunk type %d\n",

                   chunk_type);

        }

        buf += chunk_size;

    }



    buf = s->frame_buf;

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

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

        memcpy(dst, buf, avctx->width);

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

        buf += avctx->width;

    }

    memcpy(s->pic.data[1], s->pal, sizeof(s->pal));



    *data_size = sizeof(AVFrame);

    *(AVFrame*)data = s->pic;



    return avpkt->size;

}

                return -1;                 return -1;                 return -1;                 return -1;                 return -1;     const uint8_t *buf_end = avpkt->data + avpkt->size;     const uint8_t *tmp_buf;     while (buf < buf_end) {         chunk_size = AV_RL32(buf + 4);         chunk_type = AV_RL32(buf + 8);         buf += 12;         if (buf_end - buf < chunk_size) {             av_log(avctx, AV_LOG_ERROR, "Chunk size is too big (%d bytes)\n", chunk_size);             return -1;             tmp_buf = buf;                 s->pal[i] = bytestream_get_be24(&tmp_buf) << 2;             if (decoder[chunk_type - 2](s->frame_buf, avctx->width, avctx->height,                                         buf, buf + chunk_size)) {
static int FUNC_0(AVCodecContext *VAR_0,

                            void *VAR_1, int *VAR_2,

                            AVPacket *VAR_3)

{

    DfaContext *s = VAR_0->priv_data;

    const uint8_t *VAR_4 = VAR_3->VAR_1;

    const uint8_t *VAR_5 = VAR_3->VAR_1 + VAR_3->size;

    const uint8_t *VAR_6;

    uint32_t chunk_type, chunk_size;

    uint8_t *dst;

    int VAR_7;

    int VAR_8, VAR_9;



    if (s->pic.VAR_1[0])

        VAR_0->release_buffer(VAR_0, &s->pic);



    if ((VAR_7 = VAR_0->get_buffer(VAR_0, &s->pic))) {

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

        return VAR_7;

    }



    while (VAR_4 < VAR_5) {

        chunk_size = AV_RL32(VAR_4 + 4);

        chunk_type = AV_RL32(VAR_4 + 8);

        VAR_4 += 12;

        if (VAR_5 - VAR_4 < chunk_size) {

            av_log(VAR_0, AV_LOG_ERROR, "Chunk size is too big (%d bytes)\n", chunk_size);

            return -1;

        }

        if (!chunk_type)

            break;

        if (chunk_type == 1) {

            VAR_9 = FFMIN(chunk_size / 3, 256);

            VAR_6 = VAR_4;

            for (VAR_8 = 0; VAR_8 < VAR_9; VAR_8++) {

                s->pal[VAR_8] = bytestream_get_be24(&VAR_6) << 2;

                s->pal[VAR_8] |= (s->pal[VAR_8] >> 6) & 0x333;

            }

            s->pic.palette_has_changed = 1;

        } else if (chunk_type <= 9) {

            if (decoder[chunk_type - 2](s->frame_buf, VAR_0->width, VAR_0->height,

                                        VAR_4, VAR_4 + chunk_size)) {

                av_log(VAR_0, AV_LOG_ERROR, "Error decoding %s chunk\n",

                       chunk_name[chunk_type - 2]);

                return -1;

            }

        } else {

            av_log(VAR_0, AV_LOG_WARNING, "Ignoring unknown chunk type %d\n",

                   chunk_type);

        }

        VAR_4 += chunk_size;

    }



    VAR_4 = s->frame_buf;

    dst = s->pic.VAR_1[0];

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

        memcpy(dst, VAR_4, VAR_0->width);

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

        VAR_4 += VAR_0->width;

    }

    memcpy(s->pic.VAR_1[1], s->pal, sizeof(s->pal));



    *VAR_2 = sizeof(AVFrame);

    *(AVFrame*)VAR_1 = s->pic;



    return VAR_3->size;

}

static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{ DfaContext *s = VAR_0->priv_data; const uint8_t *VAR_4 = VAR_3->VAR_1; const uint8_t *VAR_5 = VAR_3->VAR_1 + VAR_3->size; const uint8_t *VAR_6; uint32_t chunk_type, chunk_size; uint8_t *dst; int VAR_7; int VAR_8, VAR_9; if (s->pic.VAR_1[0])
VAR_0->release_buffer(VAR_0, &s->pic); if ((VAR_7 = VAR_0->get_buffer(VAR_0, &s->pic))) { av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n"); return VAR_7; } while (VAR_4 < VAR_5) { chunk_size = AV_RL32(VAR_4 + 4); chunk_type = AV_RL32(VAR_4 + 8); VAR_4 += 12; if (VAR_5 - VAR_4 < chunk_size) { av_log(VAR_0, AV_LOG_ERROR, "Chunk size is too big (%d bytes)\n", chunk_size); return -1; } if (!chunk_type)
break; if (chunk_type == 1) { VAR_9 = FFMIN(chunk_size / 3, 256); VAR_6 = VAR_4; for (VAR_8 = 0; VAR_8 < VAR_9; VAR_8++) { s->pal[VAR_8] = bytestream_get_be24(&VAR_6) << 2; s->pal[VAR_8] |= (s->pal[VAR_8] >> 6) & 0x333; } s->pic.palette_has_changed = 1; } else if (chunk_type <= 9) { if (decoder[chunk_type - 2](s->frame_buf, VAR_0->width, VAR_0->height,
VAR_4, VAR_4 + chunk_size)) { av_log(VAR_0, AV_LOG_ERROR, "Error decoding %s chunk\n",
chunk_name[chunk_type - 2]); return -1; } } else { av_log(VAR_0, AV_LOG_WARNING, "Ignoring unknown chunk type %d\n",
chunk_type); } VAR_4 += chunk_size; } VAR_4 = s->frame_buf; dst = s->pic.VAR_1[0]; for (VAR_8 = 0; VAR_8 < VAR_0->height; VAR_8++) { memcpy(dst, VAR_4, VAR_0->width); dst += s->pic.linesize[0]; VAR_4 += VAR_0->width; } memcpy(s->pic.VAR_1[1], s->pal, sizeof(s->pal)); *VAR_2 = sizeof(AVFrame); *(AVFrame*)VAR_1 = s->pic; return VAR_3->size; }